|
@@ -24908,7 +24908,7 @@ var BABYLON;
|
|
|
var alphaTestState = engine.getAlphaTesting();
|
|
|
var clipPlaneState = scene.clipPlane;
|
|
|
engine.setAlphaTesting(options ? options.alphaTest : _this.needAlphaTesting());
|
|
|
- if (options.clipPlane) {
|
|
|
+ if (options && options.clipPlane) {
|
|
|
scene.clipPlane = new BABYLON.Plane(0, 0, 0, 1);
|
|
|
}
|
|
|
if (_this.storeEffectOnSubMeshes) {
|
|
@@ -24932,7 +24932,7 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
engine.setAlphaTesting(alphaTestState);
|
|
|
- if (options.clipPlane) {
|
|
|
+ if (options && options.clipPlane) {
|
|
|
scene.clipPlane = clipPlaneState;
|
|
|
}
|
|
|
};
|
|
@@ -27822,6 +27822,7 @@ var BABYLON;
|
|
|
//Init vertex buffer cache
|
|
|
this._vertexBuffers = {};
|
|
|
this._indices = [];
|
|
|
+ this._updatable = updatable;
|
|
|
// vertexData
|
|
|
if (vertexData) {
|
|
|
this.setAllVerticesData(vertexData, updatable);
|
|
@@ -28333,6 +28334,7 @@ var BABYLON;
|
|
|
Geometry.prototype.serialize = function () {
|
|
|
var serializationObject = {};
|
|
|
serializationObject.id = this.id;
|
|
|
+ serializationObject.updatable = this._updatable;
|
|
|
if (BABYLON.Tags && BABYLON.Tags.HasTags(this)) {
|
|
|
serializationObject.tags = BABYLON.Tags.GetTags(this);
|
|
|
}
|
|
@@ -28610,7 +28612,7 @@ var BABYLON;
|
|
|
if (scene.getGeometryByID(parsedVertexData.id)) {
|
|
|
return null; // null since geometry could be something else than a box...
|
|
|
}
|
|
|
- var geometry = new Geometry(parsedVertexData.id, scene);
|
|
|
+ var geometry = new Geometry(parsedVertexData.id, scene, null, parsedVertexData.updatable);
|
|
|
if (BABYLON.Tags) {
|
|
|
BABYLON.Tags.AddTagsTo(geometry, parsedVertexData.tags);
|
|
|
}
|
|
@@ -32447,14 +32449,14 @@ var BABYLON;
|
|
|
var camera;
|
|
|
if (this.activeCamera) {
|
|
|
camera = this.activeCamera;
|
|
|
- engine.setViewport(this.activeCamera.viewport);
|
|
|
+ engine.setViewport(this.activeCamera.viewport, this._size, this._size);
|
|
|
if (this.activeCamera !== scene.activeCamera) {
|
|
|
scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
camera = scene.activeCamera;
|
|
|
- engine.setViewport(scene.activeCamera.viewport);
|
|
|
+ engine.setViewport(scene.activeCamera.viewport, this._size, this._size);
|
|
|
}
|
|
|
// Prepare renderingManager
|
|
|
this._renderingManager.reset();
|
|
@@ -34927,7 +34929,7 @@ var BABYLON;
|
|
|
}
|
|
|
var checkReady = function () {
|
|
|
var subMesh = subMeshes[currentIndex];
|
|
|
- if (_this.isReady(subMesh, options ? options.useInstances : false)) {
|
|
|
+ if (_this._scene && _this._scene.getEngine() && _this.isReady(subMesh, options ? options.useInstances : false)) {
|
|
|
currentIndex++;
|
|
|
if (currentIndex >= subMeshes.length) {
|
|
|
if (onCompiled) {
|
|
@@ -48425,6 +48427,7 @@ var BABYLON;
|
|
|
var plugin = registeredPlugin.plugin;
|
|
|
var useArrayBuffer = registeredPlugin.isBinary;
|
|
|
var database;
|
|
|
+ SceneLoader.OnPluginActivatedObservable.notifyObservers(registeredPlugin.plugin);
|
|
|
var dataCallback = function (data) {
|
|
|
if (scene.isDisposed) {
|
|
|
onError("Scene has been disposed");
|
|
@@ -48616,6 +48619,7 @@ var BABYLON;
|
|
|
SceneLoader._ShowLoadingScreen = true;
|
|
|
SceneLoader._loggingLevel = SceneLoader.NO_LOGGING;
|
|
|
// Members
|
|
|
+ SceneLoader.OnPluginActivatedObservable = new BABYLON.Observable();
|
|
|
SceneLoader._registeredPlugins = {};
|
|
|
BABYLON.SceneLoader = SceneLoader;
|
|
|
;
|
|
@@ -49227,7 +49231,47 @@ var BABYLON;
|
|
|
eventDrop.preventDefault();
|
|
|
this.loadFiles(eventDrop);
|
|
|
};
|
|
|
+ FilesInput.prototype._handleFolderDrop = function (entry, files, callback) {
|
|
|
+ var reader = entry.createReader(), relativePath = entry.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
|
|
|
+ reader.readEntries(function (fileEntries) {
|
|
|
+ var remaining = fileEntries.length;
|
|
|
+ for (var _i = 0, fileEntries_1 = fileEntries; _i < fileEntries_1.length; _i++) {
|
|
|
+ var fileEntry = fileEntries_1[_i];
|
|
|
+ if (fileEntry.isFile) {
|
|
|
+ fileEntry.file(function (file) {
|
|
|
+ file.correctName = relativePath + file.name;
|
|
|
+ files.push(file);
|
|
|
+ remaining--;
|
|
|
+ if (remaining === 0) {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ remaining--;
|
|
|
+ if (remaining === 0) {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ FilesInput.prototype._processFiles = function (files) {
|
|
|
+ for (var i = 0; i < files.length; i++) {
|
|
|
+ var name = files[i].correctName.toLowerCase();
|
|
|
+ var extension = name.split('.').pop();
|
|
|
+ if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
|
|
|
+ && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
|
|
|
+ this._sceneFileToLoad = files[i];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ FilesInput.FilesToLoad[name] = files[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.reload();
|
|
|
+ };
|
|
|
FilesInput.prototype.loadFiles = function (event) {
|
|
|
+ var _this = this;
|
|
|
if (this._startingProcessingFilesCallback)
|
|
|
this._startingProcessingFilesCallback();
|
|
|
// Handling data transfer via drag'n'drop
|
|
@@ -49239,19 +49283,51 @@ var BABYLON;
|
|
|
this._filesToLoad = event.target.files;
|
|
|
}
|
|
|
if (this._filesToLoad && this._filesToLoad.length > 0) {
|
|
|
+ var files_1 = [];
|
|
|
+ var folders = [];
|
|
|
for (var i = 0; i < this._filesToLoad.length; i++) {
|
|
|
- var name_1 = this._filesToLoad[i].name.toLowerCase();
|
|
|
- var extension = name_1.split('.').pop();
|
|
|
- var type = this._filesToLoad[i].type;
|
|
|
- if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
|
|
|
- && name_1.indexOf(".binary.babylon") === -1 && name_1.indexOf(".incremental.babylon") === -1) {
|
|
|
- this._sceneFileToLoad = this._filesToLoad[i];
|
|
|
+ var fileToLoad = this._filesToLoad[i];
|
|
|
+ var name_1 = fileToLoad.name.toLowerCase();
|
|
|
+ var type = fileToLoad.type;
|
|
|
+ var entry = void 0;
|
|
|
+ fileToLoad.correctName = name_1;
|
|
|
+ if (event.dataTransfer && event.dataTransfer.items) {
|
|
|
+ var item = event.dataTransfer.items[i];
|
|
|
+ if (item.getAsEntry) {
|
|
|
+ entry = item.getAsEntry();
|
|
|
+ }
|
|
|
+ else if (item.webkitGetAsEntry) {
|
|
|
+ entry = item.webkitGetAsEntry();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!entry) {
|
|
|
+ files_1.push(fileToLoad);
|
|
|
}
|
|
|
else {
|
|
|
- FilesInput.FilesToLoad[name_1] = this._filesToLoad[i];
|
|
|
+ if (entry.isDirectory) {
|
|
|
+ folders.push(entry);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ files_1.push(fileToLoad);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (folders.length === 0) {
|
|
|
+ this._processFiles(files_1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var remaining = folders.length;
|
|
|
+ // Extract folder content
|
|
|
+ for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
|
|
|
+ var folder = folders_1[_i];
|
|
|
+ this._handleFolderDrop(folder, files_1, function () {
|
|
|
+ remaining--;
|
|
|
+ if (remaining === 0) {
|
|
|
+ _this._processFiles(files_1);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
- this.reload();
|
|
|
}
|
|
|
};
|
|
|
FilesInput.prototype.reload = function () {
|
|
@@ -52275,13 +52351,14 @@ var BABYLON;
|
|
|
if (isNew && _this._parent.onMaterialLoaded) {
|
|
|
_this._parent.onMaterialLoaded(babylonMaterial);
|
|
|
}
|
|
|
- // Note: Removing force compilation from loader as this will be delegated to users as they
|
|
|
- // may want to add more options to the material before compiling it
|
|
|
- //this.addPendingData(material);
|
|
|
- //babylonMaterial.forceCompilation(babylonMesh, babylonMaterial => {
|
|
|
- babylonMultiMaterial.subMaterials[i] = babylonMaterial;
|
|
|
- // this.removePendingData(material);
|
|
|
- //});
|
|
|
+ if (_this._parent.onBeforeMaterialReadyAsync) {
|
|
|
+ _this._parent.onBeforeMaterialReadyAsync(babylonMaterial, babylonMesh, babylonMultiMaterial.subMaterials[i] != null, function () {
|
|
|
+ babylonMultiMaterial.subMaterials[i] = babylonMaterial;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ babylonMultiMaterial.subMaterials[i] = babylonMaterial;
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -52716,12 +52793,15 @@ var BABYLON;
|
|
|
}
|
|
|
this.removeLoaderPendingData(data);
|
|
|
};
|
|
|
+ GLTFLoader.prototype.addLoaderNonBlockingPendingData = function (data) {
|
|
|
+ if (!this._nonBlockingData) {
|
|
|
+ this._nonBlockingData = new Array();
|
|
|
+ }
|
|
|
+ this._nonBlockingData.push(data);
|
|
|
+ };
|
|
|
GLTFLoader.prototype.addLoaderPendingData = function (data) {
|
|
|
if (this._blockPendingTracking) {
|
|
|
- if (!this._nonBlockingData) {
|
|
|
- this._nonBlockingData = new Array();
|
|
|
- }
|
|
|
- this._nonBlockingData.push(data);
|
|
|
+ this.addLoaderNonBlockingPendingData(data);
|
|
|
return;
|
|
|
}
|
|
|
this._loaderPendingCount++;
|
|
@@ -53094,9 +53174,12 @@ var BABYLON;
|
|
|
// Clear out the extension so that it won't get loaded again.
|
|
|
material.extensions[this.name] = undefined;
|
|
|
// Tell the loader not to clear its state until the highest LOD is loaded.
|
|
|
+ var materialLODs = [material.index].concat(properties.ids);
|
|
|
loader.addLoaderPendingData(material);
|
|
|
+ for (var index = 0; index < materialLODs.length; index++) {
|
|
|
+ loader.addLoaderNonBlockingPendingData(index);
|
|
|
+ }
|
|
|
// Start with the lowest quality LOD.
|
|
|
- var materialLODs = [material.index].concat(properties.ids);
|
|
|
this.loadMaterialLOD(loader, material, materialLODs, materialLODs.length - 1, assign);
|
|
|
return true;
|
|
|
};
|
|
@@ -53108,6 +53191,7 @@ var BABYLON;
|
|
|
}
|
|
|
loader.loadMaterial(materialLOD, function (babylonMaterial, isNew) {
|
|
|
assign(babylonMaterial, isNew);
|
|
|
+ loader.removeLoaderPendingData(lod);
|
|
|
// Loading is considered complete if this is the lowest quality LOD.
|
|
|
if (lod === materialLODs.length - 1) {
|
|
|
loader.removeLoaderPendingData(material);
|
|
@@ -53120,13 +53204,19 @@ var BABYLON;
|
|
|
// all active material textures of the current LOD are loaded.
|
|
|
loader.executeWhenRenderReady(function () {
|
|
|
BABYLON.BaseTexture.WhenAllReady(babylonMaterial.getActiveTextures(), function () {
|
|
|
- _this.loadMaterialLOD(loader, material, materialLODs, lod - 1, assign);
|
|
|
+ setTimeout(function () {
|
|
|
+ _this.loadMaterialLOD(loader, material, materialLODs, lod - 1, assign);
|
|
|
+ }, MSFTLOD.MinimalLODDelay);
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
return MSFTLOD;
|
|
|
}(GLTF2.GLTFLoaderExtension));
|
|
|
+ /**
|
|
|
+ * Specify the minimal delay between LODs in ms (default = 250)
|
|
|
+ */
|
|
|
+ MSFTLOD.MinimalLODDelay = 250;
|
|
|
Extensions.MSFTLOD = MSFTLOD;
|
|
|
GLTF2.GLTFLoader.RegisterExtension(new MSFTLOD());
|
|
|
})(Extensions = GLTF2.Extensions || (GLTF2.Extensions = {}));
|