|
@@ -20,7 +20,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
|
module.exports = factory();
|
|
|
else if(typeof define === 'function' && define.amd)
|
|
|
- define("babylonjs", factory);
|
|
|
+ define("babylonjs", [], factory);
|
|
|
else if(typeof exports === 'object')
|
|
|
exports["babylonjs"] = factory();
|
|
|
else {
|
|
@@ -9512,6 +9512,27 @@ var BABYLON;
|
|
|
}
|
|
|
return newPromise;
|
|
|
};
|
|
|
+ InternalPromise.race = function (promises) {
|
|
|
+ var newPromise = new InternalPromise();
|
|
|
+ if (promises.length) {
|
|
|
+ for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
|
|
|
+ var promise = promises_1[_i];
|
|
|
+ promise.then(function (value) {
|
|
|
+ if (newPromise) {
|
|
|
+ newPromise._resolve(value);
|
|
|
+ newPromise = null;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }, function (reason) {
|
|
|
+ if (newPromise) {
|
|
|
+ newPromise._reject(reason);
|
|
|
+ newPromise = null;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return newPromise;
|
|
|
+ };
|
|
|
return InternalPromise;
|
|
|
}());
|
|
|
/**
|
|
@@ -47099,6 +47120,16 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ Object.defineProperty(AnimationGroup.prototype, "animatables", {
|
|
|
+ /**
|
|
|
+ * returning the list of animatables controlled by this animation group.
|
|
|
+ */
|
|
|
+ get: function () {
|
|
|
+ return this._animatables;
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
/**
|
|
|
* Add an animation (with its target) in the group
|
|
|
* @param animation defines the animation we want to add
|
|
@@ -47259,6 +47290,22 @@ var BABYLON;
|
|
|
return this;
|
|
|
};
|
|
|
/**
|
|
|
+ * Goes to a specific frame in this animation group
|
|
|
+ *
|
|
|
+ * @param frame the frame number to go to
|
|
|
+ * @return the animationGroup
|
|
|
+ */
|
|
|
+ AnimationGroup.prototype.goToFrame = function (frame) {
|
|
|
+ if (!this._isStarted) {
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ for (var index = 0; index < this._animatables.length; index++) {
|
|
|
+ var animatable = this._animatables[index];
|
|
|
+ animatable.goToFrame(frame);
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Dispose all associated resources
|
|
|
*/
|
|
|
AnimationGroup.prototype.dispose = function () {
|
|
@@ -89828,8 +89875,13 @@ var BABYLON;
|
|
|
* @param scene The scene to add the material to
|
|
|
*/
|
|
|
function EnvironmentHelper(options, scene) {
|
|
|
+ var _this = this;
|
|
|
+ this._errorHandler = function (message, exception) {
|
|
|
+ _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
|
|
|
+ };
|
|
|
this._options = __assign({}, EnvironmentHelper._getDefaultOptions(), options);
|
|
|
this._scene = scene;
|
|
|
+ this.onErrorObservable = new BABYLON.Observable();
|
|
|
this._setupBackground();
|
|
|
this._setupImageProcessing();
|
|
|
}
|
|
@@ -90156,7 +90208,7 @@ var BABYLON;
|
|
|
this._groundMaterial.diffuseTexture = this._options.groundTexture;
|
|
|
return;
|
|
|
}
|
|
|
- var diffuseTexture = new BABYLON.Texture(this._options.groundTexture, this._scene);
|
|
|
+ var diffuseTexture = new BABYLON.Texture(this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
|
|
|
diffuseTexture.gammaSpace = false;
|
|
|
diffuseTexture.hasAlpha = true;
|
|
|
this._groundMaterial.diffuseTexture = diffuseTexture;
|
|
@@ -90242,7 +90294,7 @@ var BABYLON;
|
|
|
this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
|
|
|
return;
|
|
|
}
|
|
|
- this._skyboxTexture = new BABYLON.CubeTexture(this._options.skyboxTexture, this._scene);
|
|
|
+ this._skyboxTexture = new BABYLON.CubeTexture(this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
|
|
|
this._skyboxTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
|
|
|
this._skyboxTexture.gammaSpace = false;
|
|
|
this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
|
|
@@ -90562,6 +90614,10 @@ var BABYLON;
|
|
|
*/
|
|
|
this.onMaterialLoadedObservable = new BABYLON.Observable();
|
|
|
/**
|
|
|
+ * Raised when the loader creates an animation group after parsing the glTF properties of the material.
|
|
|
+ */
|
|
|
+ this.onAnimationGroupLoadedObservable = new BABYLON.Observable();
|
|
|
+ /**
|
|
|
* Raised when the asset is completely loaded, immediately before the loader is disposed.
|
|
|
* For assets with LODs, raised when all of the LODs are complete.
|
|
|
* For assets without LODs, raised when the model is complete, immediately after onSuccess.
|
|
@@ -90624,6 +90680,16 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ Object.defineProperty(GLTFFileLoader.prototype, "onAnimationGroupLoaded", {
|
|
|
+ set: function (callback) {
|
|
|
+ if (this._onAnimationGroupLoadedObserver) {
|
|
|
+ this.onAnimationGroupLoadedObservable.remove(this._onAnimationGroupLoadedObserver);
|
|
|
+ }
|
|
|
+ this._onAnimationGroupLoadedObserver = this.onAnimationGroupLoadedObservable.add(callback);
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
Object.defineProperty(GLTFFileLoader.prototype, "onComplete", {
|
|
|
set: function (callback) {
|
|
|
if (this._onCompleteObserver) {
|
|
@@ -90654,6 +90720,18 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ /**
|
|
|
+ * Gets a promise that resolves when the asset to be completely loaded.
|
|
|
+ * @returns A promise that resolves when the asset is completely loaded.
|
|
|
+ */
|
|
|
+ GLTFFileLoader.prototype.whenCompleteAsync = function () {
|
|
|
+ var _this = this;
|
|
|
+ return new Promise(function (resolve) {
|
|
|
+ _this.onCompleteObservable.add(function () {
|
|
|
+ resolve();
|
|
|
+ }, undefined, undefined, undefined, true);
|
|
|
+ });
|
|
|
+ };
|
|
|
Object.defineProperty(GLTFFileLoader.prototype, "loaderState", {
|
|
|
/**
|
|
|
* The loader state or null if not active.
|
|
@@ -92322,6 +92400,7 @@ var BABYLON;
|
|
|
this.onMeshLoadedObservable = new BABYLON.Observable();
|
|
|
this.onTextureLoadedObservable = new BABYLON.Observable();
|
|
|
this.onMaterialLoadedObservable = new BABYLON.Observable();
|
|
|
+ this.onAnimationGroupLoadedObservable = new BABYLON.Observable();
|
|
|
this.onCompleteObservable = new BABYLON.Observable();
|
|
|
this.onExtensionLoadedObservable = new BABYLON.Observable();
|
|
|
this.state = null;
|
|
@@ -93142,6 +93221,7 @@ var BABYLON;
|
|
|
this.onMeshLoadedObservable = new BABYLON.Observable();
|
|
|
this.onTextureLoadedObservable = new BABYLON.Observable();
|
|
|
this.onMaterialLoadedObservable = new BABYLON.Observable();
|
|
|
+ this.onAnimationGroupLoadedObservable = new BABYLON.Observable();
|
|
|
this.onExtensionLoadedObservable = new BABYLON.Observable();
|
|
|
this.onCompleteObservable = new BABYLON.Observable();
|
|
|
}
|
|
@@ -93229,9 +93309,12 @@ var BABYLON;
|
|
|
if (_this.compileShadowGenerators) {
|
|
|
promises.push(_this._compileShadowGeneratorsAsync());
|
|
|
}
|
|
|
- return Promise.all(promises).then(function () {
|
|
|
+ var resultPromise = Promise.all(promises).then(function () {
|
|
|
_this._state = BABYLON.GLTFLoaderState.Ready;
|
|
|
_this._startAnimations();
|
|
|
+ });
|
|
|
+ resultPromise.then(function () {
|
|
|
+ _this._rootBabylonMesh.setEnabled(true);
|
|
|
BABYLON.Tools.SetImmediate(function () {
|
|
|
if (!_this._disposed) {
|
|
|
Promise.all(_this._completePromises).then(function () {
|
|
@@ -93246,6 +93329,7 @@ var BABYLON;
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
+ return resultPromise;
|
|
|
}).catch(function (error) {
|
|
|
BABYLON.Tools.Error("glTF Loader: " + error.message);
|
|
|
_this._clear();
|
|
@@ -93324,6 +93408,7 @@ var BABYLON;
|
|
|
};
|
|
|
GLTFLoader.prototype._createRootNode = function () {
|
|
|
this._rootBabylonMesh = new BABYLON.Mesh("__root__", this._babylonScene);
|
|
|
+ this._rootBabylonMesh.setEnabled(false);
|
|
|
var rootNode = { _babylonMesh: this._rootBabylonMesh };
|
|
|
switch (this.coordinateSystemMode) {
|
|
|
case BABYLON.GLTFLoaderCoordinateSystemMode.AUTO: {
|
|
@@ -93487,7 +93572,6 @@ var BABYLON;
|
|
|
var _this = this;
|
|
|
var promises = new Array();
|
|
|
var babylonMesh = new BABYLON.Mesh((mesh.name || node._babylonMesh.name) + "_" + primitive._index, this._babylonScene, node._babylonMesh);
|
|
|
- babylonMesh.setEnabled(false);
|
|
|
node._primitiveBabylonMeshes = node._primitiveBabylonMeshes || [];
|
|
|
node._primitiveBabylonMeshes[primitive._index] = babylonMesh;
|
|
|
this._createMorphTargets(context, node, mesh, primitive, babylonMesh);
|
|
@@ -93500,12 +93584,12 @@ var BABYLON;
|
|
|
}
|
|
|
else {
|
|
|
var material = GLTFLoader._GetProperty(context + "/material", this._gltf.materials, primitive.material);
|
|
|
- promises.push(this._loadMaterialAsync("#/materials/" + material._index, material, babylonMesh));
|
|
|
+ promises.push(this._loadMaterialAsync("#/materials/" + material._index, material, babylonMesh, function (babylonMaterial) {
|
|
|
+ babylonMesh.material = babylonMaterial;
|
|
|
+ }));
|
|
|
}
|
|
|
this.onMeshLoadedObservable.notifyObservers(babylonMesh);
|
|
|
- return Promise.all(promises).then(function () {
|
|
|
- babylonMesh.setEnabled(true);
|
|
|
- });
|
|
|
+ return Promise.all(promises).then(function () { });
|
|
|
};
|
|
|
GLTFLoader.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) {
|
|
|
var _this = this;
|
|
@@ -93800,13 +93884,14 @@ var BABYLON;
|
|
|
var channel = _a[_i];
|
|
|
promises.push(this._loadAnimationChannelAsync(context + "/channels/" + channel._index, context, animation, channel, babylonAnimationGroup));
|
|
|
}
|
|
|
+ this.onAnimationGroupLoadedObservable.notifyObservers(babylonAnimationGroup);
|
|
|
return Promise.all(promises).then(function () {
|
|
|
babylonAnimationGroup.normalize();
|
|
|
});
|
|
|
};
|
|
|
GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, babylonAnimationGroup) {
|
|
|
var targetNode = GLTFLoader._GetProperty(context + "/target/node", this._gltf.nodes, channel.target.node);
|
|
|
- if (!targetNode._babylonMesh) {
|
|
|
+ if (!targetNode._babylonMesh || targetNode.skin != undefined) {
|
|
|
return Promise.resolve();
|
|
|
}
|
|
|
var sampler = GLTFLoader._GetProperty(context + "/sampler", animation.samplers, channel.sampler);
|
|
@@ -94124,25 +94209,24 @@ var BABYLON;
|
|
|
this._loadMaterialAlphaProperties(context, material);
|
|
|
return Promise.all(promises).then(function () { });
|
|
|
};
|
|
|
- GLTFLoader.prototype._loadMaterialAsync = function (context, material, babylonMesh) {
|
|
|
- var promise = GLTF2.GLTFLoaderExtension._LoadMaterialAsync(this, context, material, babylonMesh);
|
|
|
+ GLTFLoader.prototype._loadMaterialAsync = function (context, material, babylonMesh, assign) {
|
|
|
+ var promise = GLTF2.GLTFLoaderExtension._LoadMaterialAsync(this, context, material, babylonMesh, assign);
|
|
|
if (promise) {
|
|
|
return promise;
|
|
|
}
|
|
|
material._babylonMeshes = material._babylonMeshes || [];
|
|
|
material._babylonMeshes.push(babylonMesh);
|
|
|
- if (material._loaded) {
|
|
|
- babylonMesh.material = material._babylonMaterial;
|
|
|
- return material._loaded;
|
|
|
+ if (!material._loaded) {
|
|
|
+ var promises = new Array();
|
|
|
+ var babylonMaterial = this._createMaterial(material);
|
|
|
+ material._babylonMaterial = babylonMaterial;
|
|
|
+ promises.push(this._loadMaterialBasePropertiesAsync(context, material));
|
|
|
+ promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync(context, material));
|
|
|
+ this.onMaterialLoadedObservable.notifyObservers(babylonMaterial);
|
|
|
+ material._loaded = Promise.all(promises).then(function () { });
|
|
|
}
|
|
|
- var promises = new Array();
|
|
|
- var babylonMaterial = this._createMaterial(material);
|
|
|
- material._babylonMaterial = babylonMaterial;
|
|
|
- promises.push(this._loadMaterialBasePropertiesAsync(context, material));
|
|
|
- promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync(context, material));
|
|
|
- this.onMaterialLoadedObservable.notifyObservers(babylonMaterial);
|
|
|
- babylonMesh.material = babylonMaterial;
|
|
|
- return (material._loaded = Promise.all(promises).then(function () { }));
|
|
|
+ assign(material._babylonMaterial);
|
|
|
+ return material._loaded;
|
|
|
};
|
|
|
GLTFLoader.prototype._createMaterial = function (material) {
|
|
|
var babylonMaterial = new BABYLON.PBRMaterial(material.name || "material" + material._index, this._babylonScene);
|
|
@@ -94511,7 +94595,7 @@ var BABYLON;
|
|
|
/** Override this method to modify the default behavior for loading mesh primitive vertex data. */
|
|
|
GLTFLoaderExtension.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) { return null; };
|
|
|
/** Override this method to modify the default behavior for loading materials. */
|
|
|
- GLTFLoaderExtension.prototype._loadMaterialAsync = function (context, material, babylonMesh) { return null; };
|
|
|
+ GLTFLoaderExtension.prototype._loadMaterialAsync = function (context, material, babylonMesh, assign) { return null; };
|
|
|
/** Override this method to modify the default behavior for loading uris. */
|
|
|
GLTFLoaderExtension.prototype._loadUriAsync = function (context, uri) { return null; };
|
|
|
// #endregion
|
|
@@ -94548,8 +94632,8 @@ var BABYLON;
|
|
|
return loader._applyExtensions(function (extension) { return extension._loadVertexDataAsync(context, primitive, babylonMesh); });
|
|
|
};
|
|
|
/** Helper method called by the loader to allow extensions to override loading materials. */
|
|
|
- GLTFLoaderExtension._LoadMaterialAsync = function (loader, context, material, babylonMesh) {
|
|
|
- return loader._applyExtensions(function (extension) { return extension._loadMaterialAsync(context, material, babylonMesh); });
|
|
|
+ GLTFLoaderExtension._LoadMaterialAsync = function (loader, context, material, babylonMesh, assign) {
|
|
|
+ return loader._applyExtensions(function (extension) { return extension._loadMaterialAsync(context, material, babylonMesh, assign); });
|
|
|
};
|
|
|
/** Helper method called by the loader to allow extensions to override loading uris. */
|
|
|
GLTFLoaderExtension._LoadUriAsync = function (loader, context, uri) {
|
|
@@ -94628,7 +94712,7 @@ var BABYLON;
|
|
|
return firstPromise;
|
|
|
});
|
|
|
};
|
|
|
- MSFT_lod.prototype._loadMaterialAsync = function (context, material, babylonMesh) {
|
|
|
+ MSFT_lod.prototype._loadMaterialAsync = function (context, material, babylonMesh, assign) {
|
|
|
var _this = this;
|
|
|
// Don't load material LODs if already loading a node LOD.
|
|
|
if (this._loadingNodeLOD) {
|
|
@@ -94645,7 +94729,10 @@ var BABYLON;
|
|
|
_this._loadMaterialSignals[materialLOD._index] = new BABYLON.Deferred();
|
|
|
}
|
|
|
}
|
|
|
- var promise = _this._loader._loadMaterialAsync("#/materials/" + materialLOD._index, materialLOD, babylonMesh).then(function () {
|
|
|
+ var promise = _this._loader._loadMaterialAsync("#/materials/" + materialLOD._index, materialLOD, babylonMesh, indexLOD === 0 ? assign : function () { }).then(function () {
|
|
|
+ if (indexLOD !== 0) {
|
|
|
+ assign(materialLOD._babylonMaterial);
|
|
|
+ }
|
|
|
if (indexLOD !== materialLODs.length - 1) {
|
|
|
var materialIndex = materialLODs[indexLOD + 1]._index;
|
|
|
if (_this._loadMaterialSignals[materialIndex]) {
|
|
@@ -94814,26 +94901,25 @@ var BABYLON;
|
|
|
_this.name = NAME;
|
|
|
return _this;
|
|
|
}
|
|
|
- KHR_materials_pbrSpecularGlossiness.prototype._loadMaterialAsync = function (context, material, babylonMesh) {
|
|
|
+ KHR_materials_pbrSpecularGlossiness.prototype._loadMaterialAsync = function (context, material, babylonMesh, assign) {
|
|
|
var _this = this;
|
|
|
return this._loadExtensionAsync(context, material, function (context, extension) {
|
|
|
material._babylonMeshes = material._babylonMeshes || [];
|
|
|
material._babylonMeshes.push(babylonMesh);
|
|
|
- if (material._loaded) {
|
|
|
- babylonMesh.material = material._babylonMaterial;
|
|
|
- return material._loaded;
|
|
|
- }
|
|
|
- var promises = new Array();
|
|
|
- var babylonMaterial = _this._loader._createMaterial(material);
|
|
|
- material._babylonMaterial = babylonMaterial;
|
|
|
- promises.push(_this._loader._loadMaterialBasePropertiesAsync(context, material));
|
|
|
- promises.push(_this._loadSpecularGlossinessPropertiesAsync(_this._loader, context, material, extension));
|
|
|
- _this._loader.onMaterialLoadedObservable.notifyObservers(babylonMaterial);
|
|
|
- babylonMesh.material = babylonMaterial;
|
|
|
- return (material._loaded = Promise.all(promises).then(function () { }));
|
|
|
+ if (!material._loaded) {
|
|
|
+ var promises = new Array();
|
|
|
+ var babylonMaterial = _this._loader._createMaterial(material);
|
|
|
+ material._babylonMaterial = babylonMaterial;
|
|
|
+ promises.push(_this._loader._loadMaterialBasePropertiesAsync(context, material));
|
|
|
+ promises.push(_this._loadSpecularGlossinessPropertiesAsync(context, material, extension));
|
|
|
+ _this._loader.onMaterialLoadedObservable.notifyObservers(babylonMaterial);
|
|
|
+ material._loaded = Promise.all(promises).then(function () { });
|
|
|
+ }
|
|
|
+ assign(material._babylonMaterial);
|
|
|
+ return material._loaded;
|
|
|
});
|
|
|
};
|
|
|
- KHR_materials_pbrSpecularGlossiness.prototype._loadSpecularGlossinessPropertiesAsync = function (loader, context, material, properties) {
|
|
|
+ KHR_materials_pbrSpecularGlossiness.prototype._loadSpecularGlossinessPropertiesAsync = function (context, material, properties) {
|
|
|
var promises = new Array();
|
|
|
var babylonMaterial = material._babylonMaterial;
|
|
|
if (properties.diffuseFactor) {
|
|
@@ -94846,18 +94932,18 @@ var BABYLON;
|
|
|
babylonMaterial.reflectivityColor = properties.specularFactor ? BABYLON.Color3.FromArray(properties.specularFactor) : BABYLON.Color3.White();
|
|
|
babylonMaterial.microSurface = properties.glossinessFactor == undefined ? 1 : properties.glossinessFactor;
|
|
|
if (properties.diffuseTexture) {
|
|
|
- promises.push(loader._loadTextureAsync(context + "/diffuseTexture", properties.diffuseTexture, function (texture) {
|
|
|
+ promises.push(this._loader._loadTextureAsync(context + "/diffuseTexture", properties.diffuseTexture, function (texture) {
|
|
|
babylonMaterial.albedoTexture = texture;
|
|
|
}));
|
|
|
}
|
|
|
if (properties.specularGlossinessTexture) {
|
|
|
- promises.push(loader._loadTextureAsync(context + "/specularGlossinessTexture", properties.specularGlossinessTexture, function (texture) {
|
|
|
+ promises.push(this._loader._loadTextureAsync(context + "/specularGlossinessTexture", properties.specularGlossinessTexture, function (texture) {
|
|
|
babylonMaterial.reflectivityTexture = texture;
|
|
|
}));
|
|
|
babylonMaterial.reflectivityTexture.hasAlpha = true;
|
|
|
babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;
|
|
|
}
|
|
|
- loader._loadMaterialAlphaProperties(context, material);
|
|
|
+ this._loader._loadMaterialAlphaProperties(context, material);
|
|
|
return Promise.all(promises).then(function () { });
|
|
|
};
|
|
|
return KHR_materials_pbrSpecularGlossiness;
|