|
@@ -96111,8 +96111,10 @@ var BABYLON;
|
|
|
};
|
|
|
return _this;
|
|
|
}
|
|
|
- Object.defineProperty(BackgroundMaterial.prototype, "perceptualColor", {
|
|
|
+ Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
|
|
|
/**
|
|
|
+ * Experimental Internal Use Only.
|
|
|
+ *
|
|
|
* Key light Color in "perceptual value" meaning the color you would like to see on screen.
|
|
|
* This acts as a helper to set the primary color to a more "human friendly" value.
|
|
|
* Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
|
|
@@ -96121,10 +96123,10 @@ var BABYLON;
|
|
|
* part of lighting setup.)
|
|
|
*/
|
|
|
get: function () {
|
|
|
- return this._perceptualColor;
|
|
|
+ return this.__perceptualColor;
|
|
|
},
|
|
|
set: function (value) {
|
|
|
- this._perceptualColor = value;
|
|
|
+ this.__perceptualColor = value;
|
|
|
this._computePrimaryColorFromPerceptualColor();
|
|
|
this._markAllSubMeshesAsLightsDirty();
|
|
|
},
|
|
@@ -96624,29 +96626,14 @@ var BABYLON;
|
|
|
* Compute the primary color according to the chosen perceptual color.
|
|
|
*/
|
|
|
BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
|
|
|
- if (!this._perceptualColor) {
|
|
|
+ if (!this.__perceptualColor) {
|
|
|
return;
|
|
|
}
|
|
|
- this._primaryColor.copyFrom(this._perceptualColor);
|
|
|
+ this._primaryColor.copyFrom(this.__perceptualColor);
|
|
|
// Revert gamma space.
|
|
|
this._primaryColor.toLinearSpaceToRef(this._primaryColor);
|
|
|
// Revert image processing configuration.
|
|
|
if (this._imageProcessingConfiguration) {
|
|
|
- // Revert tone mapping.
|
|
|
- if (this._imageProcessingConfiguration.toneMappingEnabled) {
|
|
|
- // shader reference.
|
|
|
- // tonemapped.rgb = 1.0 - exp2(-tonemappingCalibration * color.rgb);
|
|
|
- // providing
|
|
|
- // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration = color.rgb;
|
|
|
- // 1.0 - tonemapped.rgb
|
|
|
- this._white.subtractToRef(this._primaryColor, this._primaryColor);
|
|
|
- // log2(1.0 - tonemapped.rgb)
|
|
|
- this._primaryColor.r = BABYLON.Scalar.Log2(this._primaryColor.r);
|
|
|
- this._primaryColor.g = BABYLON.Scalar.Log2(this._primaryColor.g);
|
|
|
- this._primaryColor.b = BABYLON.Scalar.Log2(this._primaryColor.b);
|
|
|
- // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration
|
|
|
- this._primaryColor.scaleToRef(-1 / BackgroundMaterial._tonemappingCalibration, this._primaryColor);
|
|
|
- }
|
|
|
// Revert Exposure.
|
|
|
this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
|
|
|
}
|
|
@@ -96662,12 +96649,10 @@ var BABYLON;
|
|
|
// Find the highlight color based on the configuration.
|
|
|
this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
|
|
|
this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
|
|
|
- this._primaryShadowColor.clampToRef(0, 1, this._primaryShadowColor);
|
|
|
// Find the shadow color based on the configuration.
|
|
|
this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
|
|
|
this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
|
|
|
this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
|
|
|
- this._primaryHighlightColor.clampToRef(0, 1, this._primaryHighlightColor);
|
|
|
};
|
|
|
/**
|
|
|
* Build the uniform buffer used in the material.
|
|
@@ -96869,10 +96854,6 @@ var BABYLON;
|
|
|
* Standard reflectance value at grazing angle.
|
|
|
*/
|
|
|
BackgroundMaterial.StandardReflectance90 = 0.5;
|
|
|
- /**
|
|
|
- * Tone Mapping calibration (should match image processing tone mapping calibration value).
|
|
|
- */
|
|
|
- BackgroundMaterial._tonemappingCalibration = 1.590579;
|
|
|
__decorate([
|
|
|
BABYLON.serializeAsColor3()
|
|
|
], BackgroundMaterial.prototype, "_primaryColor", void 0);
|
|
@@ -96881,7 +96862,7 @@ var BABYLON;
|
|
|
], BackgroundMaterial.prototype, "primaryColor", void 0);
|
|
|
__decorate([
|
|
|
BABYLON.serializeAsColor3()
|
|
|
- ], BackgroundMaterial.prototype, "_perceptualColor", void 0);
|
|
|
+ ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
|
|
|
__decorate([
|
|
|
BABYLON.serialize()
|
|
|
], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
|
|
@@ -97198,33 +97179,16 @@ var BABYLON;
|
|
|
/**
|
|
|
* Sets the primary color of all the available elements.
|
|
|
* @param color the main color to affect to the ground and the background
|
|
|
- * @param perceptual Specifies wether the chosen color has been set as intented to be seen e.g. in gamma space not accounting for exposure and tone mapping
|
|
|
*/
|
|
|
- EnvironmentHelper.prototype.setMainColor = function (color, perceptual) {
|
|
|
- if (perceptual === void 0) { perceptual = false; }
|
|
|
+ EnvironmentHelper.prototype.setMainColor = function (color) {
|
|
|
if (this.groundMaterial) {
|
|
|
- if (perceptual) {
|
|
|
- this.groundMaterial.perceptualColor = color;
|
|
|
- }
|
|
|
- else {
|
|
|
- this.groundMaterial.primaryColor = color;
|
|
|
- }
|
|
|
+ this.groundMaterial.primaryColor = color;
|
|
|
}
|
|
|
if (this.skyboxMaterial) {
|
|
|
- if (perceptual) {
|
|
|
- this.skyboxMaterial.perceptualColor = color;
|
|
|
- }
|
|
|
- else {
|
|
|
- this.skyboxMaterial.primaryColor = color;
|
|
|
- }
|
|
|
+ this.skyboxMaterial.primaryColor = color;
|
|
|
}
|
|
|
if (this.groundMirror) {
|
|
|
- if (perceptual && this.groundMaterial) {
|
|
|
- this.groundMirror.clearColor = new BABYLON.Color4(this.groundMaterial.primaryColor.r, this.groundMaterial.primaryColor.g, this.groundMaterial.primaryColor.b, 1.0);
|
|
|
- }
|
|
|
- else {
|
|
|
- this.groundMirror.clearColor = new BABYLON.Color4(color.r, color.g, color.b, 1.0);
|
|
|
- }
|
|
|
+ this.groundMirror.clearColor = new BABYLON.Color4(color.r, color.g, color.b, 1.0);
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
@@ -105112,7 +105076,6 @@ var BABYLON;
|
|
|
return Promise.all(promises).then(function () { });
|
|
|
};
|
|
|
GLTFLoader.prototype._loadMeshAsync = function (context, node, mesh, babylonMesh) {
|
|
|
- // TODO: instancing
|
|
|
var _this = this;
|
|
|
var promises = new Array();
|
|
|
var primitives = mesh.primitives;
|
|
@@ -105314,9 +105277,9 @@ var BABYLON;
|
|
|
};
|
|
|
GLTFLoader.prototype._loadSkinAsync = function (context, node, mesh, skin) {
|
|
|
var _this = this;
|
|
|
- var assignSkeleton = function () {
|
|
|
+ var assignSkeleton = function (skeleton) {
|
|
|
_this._forEachPrimitive(node, function (babylonMesh) {
|
|
|
- babylonMesh.skeleton = skin._babylonSkeleton;
|
|
|
+ babylonMesh.skeleton = skeleton;
|
|
|
});
|
|
|
// Ignore the TRS of skinned nodes.
|
|
|
// See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
|
|
@@ -105327,61 +105290,68 @@ var BABYLON;
|
|
|
};
|
|
|
if (skin._loaded) {
|
|
|
return skin._loaded.then(function () {
|
|
|
- assignSkeleton();
|
|
|
+ assignSkeleton(skin._babylonSkeleton);
|
|
|
});
|
|
|
}
|
|
|
- // TODO: split into two parts so that bones are created before inverseBindMatricesData is loaded (for compiling materials).
|
|
|
+ var skeletonId = "skeleton" + skin._index;
|
|
|
+ var babylonSkeleton = new BABYLON.Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene);
|
|
|
+ skin._babylonSkeleton = babylonSkeleton;
|
|
|
+ this._loadBones(context, skin);
|
|
|
+ assignSkeleton(babylonSkeleton);
|
|
|
return (skin._loaded = this._loadSkinInverseBindMatricesDataAsync(context, skin).then(function (inverseBindMatricesData) {
|
|
|
- var skeletonId = "skeleton" + skin._index;
|
|
|
- var babylonSkeleton = new BABYLON.Skeleton(skin.name || skeletonId, skeletonId, _this._babylonScene);
|
|
|
- skin._babylonSkeleton = babylonSkeleton;
|
|
|
- _this._loadBones(context, skin, inverseBindMatricesData);
|
|
|
- assignSkeleton();
|
|
|
+ _this._updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
|
|
|
}));
|
|
|
};
|
|
|
- GLTFLoader.prototype._loadSkinInverseBindMatricesDataAsync = function (context, skin) {
|
|
|
- if (skin.inverseBindMatrices == undefined) {
|
|
|
- return Promise.resolve(null);
|
|
|
- }
|
|
|
- var accessor = GLTFLoader._GetProperty(context + "/inverseBindMatrices", this._gltf.accessors, skin.inverseBindMatrices);
|
|
|
- return this._loadAccessorAsync("#/accessors/" + accessor._index, accessor).then(function (data) {
|
|
|
- return data;
|
|
|
- });
|
|
|
- };
|
|
|
- GLTFLoader.prototype._createBone = function (node, skin, parent, localMatrix, baseMatrix, index) {
|
|
|
- var babylonBone = new BABYLON.Bone(node.name || "joint" + node._index, skin._babylonSkeleton, parent, localMatrix, null, baseMatrix, index);
|
|
|
- node._babylonAnimationTargets = node._babylonAnimationTargets || [];
|
|
|
- node._babylonAnimationTargets.push(babylonBone);
|
|
|
- return babylonBone;
|
|
|
- };
|
|
|
- GLTFLoader.prototype._loadBones = function (context, skin, inverseBindMatricesData) {
|
|
|
+ GLTFLoader.prototype._loadBones = function (context, skin) {
|
|
|
var babylonBones = {};
|
|
|
for (var _i = 0, _a = skin.joints; _i < _a.length; _i++) {
|
|
|
var index = _a[_i];
|
|
|
var node = GLTFLoader._GetProperty(context + "/joints/" + index, this._gltf.nodes, index);
|
|
|
- this._loadBone(node, skin, inverseBindMatricesData, babylonBones);
|
|
|
+ this._loadBone(node, skin, babylonBones);
|
|
|
}
|
|
|
};
|
|
|
- GLTFLoader.prototype._loadBone = function (node, skin, inverseBindMatricesData, babylonBones) {
|
|
|
+ GLTFLoader.prototype._loadBone = function (node, skin, babylonBones) {
|
|
|
var babylonBone = babylonBones[node._index];
|
|
|
if (babylonBone) {
|
|
|
return babylonBone;
|
|
|
}
|
|
|
- var boneIndex = skin.joints.indexOf(node._index);
|
|
|
- var baseMatrix = BABYLON.Matrix.Identity();
|
|
|
- if (inverseBindMatricesData && boneIndex !== -1) {
|
|
|
- baseMatrix = BABYLON.Matrix.FromArray(inverseBindMatricesData, boneIndex * 16);
|
|
|
- baseMatrix.invertToRef(baseMatrix);
|
|
|
- }
|
|
|
var babylonParentBone = null;
|
|
|
if (node._parent._babylonMesh !== this._rootBabylonMesh) {
|
|
|
- babylonParentBone = this._loadBone(node._parent, skin, inverseBindMatricesData, babylonBones);
|
|
|
- baseMatrix.multiplyToRef(babylonParentBone.getInvertedAbsoluteTransform(), baseMatrix);
|
|
|
+ babylonParentBone = this._loadBone(node._parent, skin, babylonBones);
|
|
|
}
|
|
|
- babylonBone = this._createBone(node, skin, babylonParentBone, this._getNodeMatrix(node), baseMatrix, boneIndex);
|
|
|
+ var boneIndex = skin.joints.indexOf(node._index);
|
|
|
+ babylonBone = new BABYLON.Bone(node.name || "joint" + node._index, skin._babylonSkeleton, babylonParentBone, this._getNodeMatrix(node), null, null, boneIndex);
|
|
|
babylonBones[node._index] = babylonBone;
|
|
|
+ node._babylonAnimationTargets = node._babylonAnimationTargets || [];
|
|
|
+ node._babylonAnimationTargets.push(babylonBone);
|
|
|
return babylonBone;
|
|
|
};
|
|
|
+ GLTFLoader.prototype._loadSkinInverseBindMatricesDataAsync = function (context, skin) {
|
|
|
+ if (skin.inverseBindMatrices == undefined) {
|
|
|
+ return Promise.resolve(null);
|
|
|
+ }
|
|
|
+ var accessor = GLTFLoader._GetProperty(context + "/inverseBindMatrices", this._gltf.accessors, skin.inverseBindMatrices);
|
|
|
+ return this._loadAccessorAsync("#/accessors/" + accessor._index, accessor).then(function (data) {
|
|
|
+ return data;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ GLTFLoader.prototype._updateBoneMatrices = function (babylonSkeleton, inverseBindMatricesData) {
|
|
|
+ for (var _i = 0, _a = babylonSkeleton.bones; _i < _a.length; _i++) {
|
|
|
+ var babylonBone = _a[_i];
|
|
|
+ var baseMatrix = BABYLON.Matrix.Identity();
|
|
|
+ var boneIndex = babylonBone._index;
|
|
|
+ if (inverseBindMatricesData && boneIndex !== -1) {
|
|
|
+ BABYLON.Matrix.FromArrayToRef(inverseBindMatricesData, boneIndex * 16, baseMatrix);
|
|
|
+ baseMatrix.invertToRef(baseMatrix);
|
|
|
+ }
|
|
|
+ var babylonParentBone = babylonBone.getParent();
|
|
|
+ if (babylonParentBone) {
|
|
|
+ baseMatrix.multiplyToRef(babylonParentBone.getInvertedAbsoluteTransform(), baseMatrix);
|
|
|
+ }
|
|
|
+ babylonBone.updateMatrix(baseMatrix, false, false);
|
|
|
+ babylonBone._updateDifferenceMatrix(undefined, false);
|
|
|
+ }
|
|
|
+ };
|
|
|
GLTFLoader.prototype._getNodeMatrix = function (node) {
|
|
|
return node.matrix ?
|
|
|
BABYLON.Matrix.FromArray(node.matrix) :
|