|
@@ -10555,9 +10555,13 @@ var BABYLON;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
Engine.prototype._setAnisotropicLevel = function (key, texture) {
|
|
Engine.prototype._setAnisotropicLevel = function (key, texture) {
|
|
|
|
+ var internalTexture = texture.getInternalTexture();
|
|
|
|
+ if (!internalTexture) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
|
|
var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
|
|
var value = texture.anisotropicFilteringLevel;
|
|
var value = texture.anisotropicFilteringLevel;
|
|
- if (texture.getInternalTexture().samplingMode === BABYLON.Texture.NEAREST_SAMPLINGMODE) {
|
|
|
|
|
|
+ if (internalTexture.samplingMode === BABYLON.Texture.NEAREST_SAMPLINGMODE) {
|
|
value = 1;
|
|
value = 1;
|
|
}
|
|
}
|
|
if (anisotropicFilterExtension && texture._cachedAnisotropicFilteringLevel !== value) {
|
|
if (anisotropicFilterExtension && texture._cachedAnisotropicFilteringLevel !== value) {
|
|
@@ -24889,7 +24893,9 @@ var BABYLON;
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
};
|
|
};
|
|
- // Force shader compilation including textures ready check
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Force shader compilation including textures ready check
|
|
|
|
+ */
|
|
Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
|
|
Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
|
|
var _this = this;
|
|
var _this = this;
|
|
var subMesh = new BABYLON.BaseSubMesh();
|
|
var subMesh = new BABYLON.BaseSubMesh();
|
|
@@ -24902,7 +24908,7 @@ var BABYLON;
|
|
var alphaTestState = engine.getAlphaTesting();
|
|
var alphaTestState = engine.getAlphaTesting();
|
|
var clipPlaneState = scene.clipPlane;
|
|
var clipPlaneState = scene.clipPlane;
|
|
engine.setAlphaTesting(options ? options.alphaTest : _this.needAlphaTesting());
|
|
engine.setAlphaTesting(options ? options.alphaTest : _this.needAlphaTesting());
|
|
- if (options.clipPlane) {
|
|
|
|
|
|
+ if (options && options.clipPlane) {
|
|
scene.clipPlane = new BABYLON.Plane(0, 0, 0, 1);
|
|
scene.clipPlane = new BABYLON.Plane(0, 0, 0, 1);
|
|
}
|
|
}
|
|
if (_this.storeEffectOnSubMeshes) {
|
|
if (_this.storeEffectOnSubMeshes) {
|
|
@@ -24926,7 +24932,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
engine.setAlphaTesting(alphaTestState);
|
|
engine.setAlphaTesting(alphaTestState);
|
|
- if (options.clipPlane) {
|
|
|
|
|
|
+ if (options && options.clipPlane) {
|
|
scene.clipPlane = clipPlaneState;
|
|
scene.clipPlane = clipPlaneState;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -27816,6 +27822,7 @@ var BABYLON;
|
|
//Init vertex buffer cache
|
|
//Init vertex buffer cache
|
|
this._vertexBuffers = {};
|
|
this._vertexBuffers = {};
|
|
this._indices = [];
|
|
this._indices = [];
|
|
|
|
+ this._updatable = updatable;
|
|
// vertexData
|
|
// vertexData
|
|
if (vertexData) {
|
|
if (vertexData) {
|
|
this.setAllVerticesData(vertexData, updatable);
|
|
this.setAllVerticesData(vertexData, updatable);
|
|
@@ -28327,6 +28334,7 @@ var BABYLON;
|
|
Geometry.prototype.serialize = function () {
|
|
Geometry.prototype.serialize = function () {
|
|
var serializationObject = {};
|
|
var serializationObject = {};
|
|
serializationObject.id = this.id;
|
|
serializationObject.id = this.id;
|
|
|
|
+ serializationObject.updatable = this._updatable;
|
|
if (BABYLON.Tags && BABYLON.Tags.HasTags(this)) {
|
|
if (BABYLON.Tags && BABYLON.Tags.HasTags(this)) {
|
|
serializationObject.tags = BABYLON.Tags.GetTags(this);
|
|
serializationObject.tags = BABYLON.Tags.GetTags(this);
|
|
}
|
|
}
|
|
@@ -28604,7 +28612,7 @@ var BABYLON;
|
|
if (scene.getGeometryByID(parsedVertexData.id)) {
|
|
if (scene.getGeometryByID(parsedVertexData.id)) {
|
|
return null; // null since geometry could be something else than a box...
|
|
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) {
|
|
if (BABYLON.Tags) {
|
|
BABYLON.Tags.AddTagsTo(geometry, parsedVertexData.tags);
|
|
BABYLON.Tags.AddTagsTo(geometry, parsedVertexData.tags);
|
|
}
|
|
}
|
|
@@ -32441,14 +32449,14 @@ var BABYLON;
|
|
var camera;
|
|
var camera;
|
|
if (this.activeCamera) {
|
|
if (this.activeCamera) {
|
|
camera = this.activeCamera;
|
|
camera = this.activeCamera;
|
|
- engine.setViewport(this.activeCamera.viewport);
|
|
|
|
|
|
+ engine.setViewport(this.activeCamera.viewport, this._size, this._size);
|
|
if (this.activeCamera !== scene.activeCamera) {
|
|
if (this.activeCamera !== scene.activeCamera) {
|
|
scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
|
|
scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
camera = scene.activeCamera;
|
|
camera = scene.activeCamera;
|
|
- engine.setViewport(scene.activeCamera.viewport);
|
|
|
|
|
|
+ engine.setViewport(scene.activeCamera.viewport, this._size, this._size);
|
|
}
|
|
}
|
|
// Prepare renderingManager
|
|
// Prepare renderingManager
|
|
this._renderingManager.reset();
|
|
this._renderingManager.reset();
|
|
@@ -34907,6 +34915,36 @@ var BABYLON;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
|
|
+ * Force shader compilation including textures ready check
|
|
|
|
+ */
|
|
|
|
+ ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
|
|
|
|
+ var _this = this;
|
|
|
|
+ var scene = this._scene;
|
|
|
|
+ var engine = scene.getEngine();
|
|
|
|
+ var subMeshes = new Array();
|
|
|
|
+ var currentIndex = 0;
|
|
|
|
+ for (var _i = 0, _a = this.getShadowMap().renderList; _i < _a.length; _i++) {
|
|
|
|
+ var mesh = _a[_i];
|
|
|
|
+ subMeshes.push.apply(subMeshes, mesh.subMeshes);
|
|
|
|
+ }
|
|
|
|
+ var checkReady = function () {
|
|
|
|
+ var subMesh = subMeshes[currentIndex];
|
|
|
|
+ if (_this._scene && _this._scene.getEngine() && _this.isReady(subMesh, options ? options.useInstances : false)) {
|
|
|
|
+ currentIndex++;
|
|
|
|
+ if (currentIndex >= subMeshes.length) {
|
|
|
|
+ if (onCompiled) {
|
|
|
|
+ onCompiled(_this);
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ setTimeout(checkReady, 16);
|
|
|
|
+ };
|
|
|
|
+ if (subMeshes.length > 0) {
|
|
|
|
+ checkReady();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
* Boolean : true when the ShadowGenerator is finally computed.
|
|
* Boolean : true when the ShadowGenerator is finally computed.
|
|
*/
|
|
*/
|
|
ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
|
|
ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
|
|
@@ -48389,6 +48427,7 @@ var BABYLON;
|
|
var plugin = registeredPlugin.plugin;
|
|
var plugin = registeredPlugin.plugin;
|
|
var useArrayBuffer = registeredPlugin.isBinary;
|
|
var useArrayBuffer = registeredPlugin.isBinary;
|
|
var database;
|
|
var database;
|
|
|
|
+ SceneLoader.OnPluginActivatedObservable.notifyObservers(registeredPlugin.plugin);
|
|
var dataCallback = function (data) {
|
|
var dataCallback = function (data) {
|
|
if (scene.isDisposed) {
|
|
if (scene.isDisposed) {
|
|
onError("Scene has been disposed");
|
|
onError("Scene has been disposed");
|
|
@@ -48580,6 +48619,7 @@ var BABYLON;
|
|
SceneLoader._ShowLoadingScreen = true;
|
|
SceneLoader._ShowLoadingScreen = true;
|
|
SceneLoader._loggingLevel = SceneLoader.NO_LOGGING;
|
|
SceneLoader._loggingLevel = SceneLoader.NO_LOGGING;
|
|
// Members
|
|
// Members
|
|
|
|
+ SceneLoader.OnPluginActivatedObservable = new BABYLON.Observable();
|
|
SceneLoader._registeredPlugins = {};
|
|
SceneLoader._registeredPlugins = {};
|
|
BABYLON.SceneLoader = SceneLoader;
|
|
BABYLON.SceneLoader = SceneLoader;
|
|
;
|
|
;
|
|
@@ -49191,7 +49231,47 @@ var BABYLON;
|
|
eventDrop.preventDefault();
|
|
eventDrop.preventDefault();
|
|
this.loadFiles(eventDrop);
|
|
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) {
|
|
FilesInput.prototype.loadFiles = function (event) {
|
|
|
|
+ var _this = this;
|
|
if (this._startingProcessingFilesCallback)
|
|
if (this._startingProcessingFilesCallback)
|
|
this._startingProcessingFilesCallback();
|
|
this._startingProcessingFilesCallback();
|
|
// Handling data transfer via drag'n'drop
|
|
// Handling data transfer via drag'n'drop
|
|
@@ -49203,19 +49283,51 @@ var BABYLON;
|
|
this._filesToLoad = event.target.files;
|
|
this._filesToLoad = event.target.files;
|
|
}
|
|
}
|
|
if (this._filesToLoad && this._filesToLoad.length > 0) {
|
|
if (this._filesToLoad && this._filesToLoad.length > 0) {
|
|
|
|
+ var files_1 = [];
|
|
|
|
+ var folders = [];
|
|
for (var i = 0; i < this._filesToLoad.length; i++) {
|
|
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 {
|
|
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 () {
|
|
FilesInput.prototype.reload = function () {
|
|
@@ -51911,6 +52023,7 @@ var BABYLON;
|
|
this._renderReady = false;
|
|
this._renderReady = false;
|
|
this._disposed = false;
|
|
this._disposed = false;
|
|
this._objectURLs = new Array();
|
|
this._objectURLs = new Array();
|
|
|
|
+ this._blockPendingTracking = false;
|
|
// Observable with boolean indicating success or error.
|
|
// Observable with boolean indicating success or error.
|
|
this._renderReadyObservable = new BABYLON.Observable();
|
|
this._renderReadyObservable = new BABYLON.Observable();
|
|
// Count of pending work that needs to complete before the asset is rendered.
|
|
// Count of pending work that needs to complete before the asset is rendered.
|
|
@@ -52020,11 +52133,15 @@ var BABYLON;
|
|
this._renderReadyObservable.notifyObservers(this);
|
|
this._renderReadyObservable.notifyObservers(this);
|
|
};
|
|
};
|
|
GLTFLoader.prototype._onLoaderComplete = function () {
|
|
GLTFLoader.prototype._onLoaderComplete = function () {
|
|
- this.dispose();
|
|
|
|
if (this._parent.onComplete) {
|
|
if (this._parent.onComplete) {
|
|
this._parent.onComplete();
|
|
this._parent.onComplete();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+ GLTFLoader.prototype._onLoaderFirstLODComplete = function () {
|
|
|
|
+ if (this._parent.onFirstLODComplete) {
|
|
|
|
+ this._parent.onFirstLODComplete();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
GLTFLoader.prototype._loadData = function (data) {
|
|
GLTFLoader.prototype._loadData = function (data) {
|
|
this._gltf = data.json;
|
|
this._gltf = data.json;
|
|
var binaryBuffer;
|
|
var binaryBuffer;
|
|
@@ -52234,13 +52351,14 @@ var BABYLON;
|
|
if (isNew && _this._parent.onMaterialLoaded) {
|
|
if (isNew && _this._parent.onMaterialLoaded) {
|
|
_this._parent.onMaterialLoaded(babylonMaterial);
|
|
_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;
|
|
|
|
+ }
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -52653,6 +52771,13 @@ var BABYLON;
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+ Object.defineProperty(GLTFLoader.prototype, "blockPendingTracking", {
|
|
|
|
+ set: function (value) {
|
|
|
|
+ this._blockPendingTracking = value;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
GLTFLoader.prototype.addPendingData = function (data) {
|
|
GLTFLoader.prototype.addPendingData = function (data) {
|
|
if (!this._renderReady) {
|
|
if (!this._renderReady) {
|
|
this._renderPendingCount++;
|
|
this._renderPendingCount++;
|
|
@@ -52668,12 +52793,30 @@ var BABYLON;
|
|
}
|
|
}
|
|
this.removeLoaderPendingData(data);
|
|
this.removeLoaderPendingData(data);
|
|
};
|
|
};
|
|
|
|
+ GLTFLoader.prototype.addLoaderNonBlockingPendingData = function (data) {
|
|
|
|
+ if (!this._nonBlockingData) {
|
|
|
|
+ this._nonBlockingData = new Array();
|
|
|
|
+ }
|
|
|
|
+ this._nonBlockingData.push(data);
|
|
|
|
+ };
|
|
GLTFLoader.prototype.addLoaderPendingData = function (data) {
|
|
GLTFLoader.prototype.addLoaderPendingData = function (data) {
|
|
|
|
+ if (this._blockPendingTracking) {
|
|
|
|
+ this.addLoaderNonBlockingPendingData(data);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
this._loaderPendingCount++;
|
|
this._loaderPendingCount++;
|
|
};
|
|
};
|
|
GLTFLoader.prototype.removeLoaderPendingData = function (data) {
|
|
GLTFLoader.prototype.removeLoaderPendingData = function (data) {
|
|
- if (--this._loaderPendingCount === 0) {
|
|
|
|
|
|
+ var indexInPending = this._nonBlockingData ? this._nonBlockingData.indexOf(data) : -1;
|
|
|
|
+ if (indexInPending !== -1) {
|
|
|
|
+ this._nonBlockingData.splice(indexInPending, 1);
|
|
|
|
+ }
|
|
|
|
+ else if (--this._loaderPendingCount === 0) {
|
|
|
|
+ this._onLoaderFirstLODComplete();
|
|
|
|
+ }
|
|
|
|
+ if ((!this._nonBlockingData || this._nonBlockingData.length === 0) && this._loaderPendingCount === 0) {
|
|
this._onLoaderComplete();
|
|
this._onLoaderComplete();
|
|
|
|
+ this.dispose();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
GLTFLoader.prototype._getDefaultMaterial = function () {
|
|
GLTFLoader.prototype._getDefaultMaterial = function () {
|
|
@@ -53031,33 +53174,49 @@ var BABYLON;
|
|
// Clear out the extension so that it won't get loaded again.
|
|
// Clear out the extension so that it won't get loaded again.
|
|
material.extensions[this.name] = undefined;
|
|
material.extensions[this.name] = undefined;
|
|
// Tell the loader not to clear its state until the highest LOD is loaded.
|
|
// Tell the loader not to clear its state until the highest LOD is loaded.
|
|
|
|
+ var materialLODs = [material.index].concat(properties.ids);
|
|
loader.addLoaderPendingData(material);
|
|
loader.addLoaderPendingData(material);
|
|
|
|
+ for (var index = 0; index < materialLODs.length; index++) {
|
|
|
|
+ loader.addLoaderNonBlockingPendingData(index);
|
|
|
|
+ }
|
|
// Start with the lowest quality LOD.
|
|
// Start with the lowest quality LOD.
|
|
- var materialLODs = [material.index].concat(properties.ids);
|
|
|
|
this.loadMaterialLOD(loader, material, materialLODs, materialLODs.length - 1, assign);
|
|
this.loadMaterialLOD(loader, material, materialLODs, materialLODs.length - 1, assign);
|
|
return true;
|
|
return true;
|
|
};
|
|
};
|
|
MSFTLOD.prototype.loadMaterialLOD = function (loader, material, materialLODs, lod, assign) {
|
|
MSFTLOD.prototype.loadMaterialLOD = function (loader, material, materialLODs, lod, assign) {
|
|
var _this = this;
|
|
var _this = this;
|
|
var materialLOD = loader.gltf.materials[materialLODs[lod]];
|
|
var materialLOD = loader.gltf.materials[materialLODs[lod]];
|
|
|
|
+ if (lod !== materialLODs.length - 1) {
|
|
|
|
+ loader.blockPendingTracking = true;
|
|
|
|
+ }
|
|
loader.loadMaterial(materialLOD, function (babylonMaterial, isNew) {
|
|
loader.loadMaterial(materialLOD, function (babylonMaterial, isNew) {
|
|
assign(babylonMaterial, isNew);
|
|
assign(babylonMaterial, isNew);
|
|
- // Loading is complete if this is the highest quality LOD.
|
|
|
|
- if (lod === 0) {
|
|
|
|
|
|
+ loader.removeLoaderPendingData(lod);
|
|
|
|
+ // Loading is considered complete if this is the lowest quality LOD.
|
|
|
|
+ if (lod === materialLODs.length - 1) {
|
|
loader.removeLoaderPendingData(material);
|
|
loader.removeLoaderPendingData(material);
|
|
|
|
+ }
|
|
|
|
+ if (lod === 0) {
|
|
|
|
+ loader.blockPendingTracking = false;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
// Load the next LOD when the loader is ready to render and
|
|
// Load the next LOD when the loader is ready to render and
|
|
// all active material textures of the current LOD are loaded.
|
|
// all active material textures of the current LOD are loaded.
|
|
loader.executeWhenRenderReady(function () {
|
|
loader.executeWhenRenderReady(function () {
|
|
BABYLON.BaseTexture.WhenAllReady(babylonMaterial.getActiveTextures(), 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;
|
|
return MSFTLOD;
|
|
}(GLTF2.GLTFLoaderExtension));
|
|
}(GLTF2.GLTFLoaderExtension));
|
|
|
|
+ /**
|
|
|
|
+ * Specify the minimal delay between LODs in ms (default = 250)
|
|
|
|
+ */
|
|
|
|
+ MSFTLOD.MinimalLODDelay = 250;
|
|
Extensions.MSFTLOD = MSFTLOD;
|
|
Extensions.MSFTLOD = MSFTLOD;
|
|
GLTF2.GLTFLoader.RegisterExtension(new MSFTLOD());
|
|
GLTF2.GLTFLoader.RegisterExtension(new MSFTLOD());
|
|
})(Extensions = GLTF2.Extensions || (GLTF2.Extensions = {}));
|
|
})(Extensions = GLTF2.Extensions || (GLTF2.Extensions = {}));
|