|
@@ -4433,6 +4433,18 @@ var BABYLON;
|
|
|
return this;
|
|
|
};
|
|
|
/**
|
|
|
+ * Multiplies in place the current quaternion by a scale factor
|
|
|
+ * @param value defines the scale factor
|
|
|
+ * @returns the current modified quaternion
|
|
|
+ */
|
|
|
+ Quaternion.prototype.scaleInPlace = function (value) {
|
|
|
+ this.x *= value;
|
|
|
+ this.y *= value;
|
|
|
+ this.z *= value;
|
|
|
+ this.w *= value;
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Scale the current quaternion values by a factor and add the result to a given quaternion
|
|
|
* @param scale defines the scale factor
|
|
|
* @param result defines the Quaternion object where to store the result
|
|
@@ -5293,20 +5305,23 @@ var BABYLON;
|
|
|
translation.y = this.m[13];
|
|
|
translation.z = this.m[14];
|
|
|
}
|
|
|
+ scale = scale || MathTmp.Vector3[0];
|
|
|
scale.x = Math.sqrt(this.m[0] * this.m[0] + this.m[1] * this.m[1] + this.m[2] * this.m[2]);
|
|
|
scale.y = Math.sqrt(this.m[4] * this.m[4] + this.m[5] * this.m[5] + this.m[6] * this.m[6]);
|
|
|
scale.z = Math.sqrt(this.m[8] * this.m[8] + this.m[9] * this.m[9] + this.m[10] * this.m[10]);
|
|
|
if (this.determinant() <= 0) {
|
|
|
scale.y *= -1;
|
|
|
}
|
|
|
- if (rotation) {
|
|
|
- if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
|
|
|
+ if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
|
|
|
+ if (rotation) {
|
|
|
rotation.x = 0;
|
|
|
rotation.y = 0;
|
|
|
rotation.z = 0;
|
|
|
rotation.w = 1;
|
|
|
- return false;
|
|
|
}
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (rotation) {
|
|
|
Matrix.FromValuesToRef(this.m[0] / scale.x, this.m[1] / scale.x, this.m[2] / scale.x, 0, this.m[4] / scale.y, this.m[5] / scale.y, this.m[6] / scale.y, 0, this.m[8] / scale.z, this.m[9] / scale.z, this.m[10] / scale.z, 0, 0, 0, 0, 1, MathTmp.Matrix[0]);
|
|
|
Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
|
|
|
}
|
|
@@ -5441,13 +5456,18 @@ var BABYLON;
|
|
|
*/
|
|
|
Matrix.prototype.getRotationMatrixToRef = function (result) {
|
|
|
var m = this.m;
|
|
|
- var xs = m[0] * m[1] * m[2] * m[3] < 0 ? -1 : 1;
|
|
|
- var ys = m[4] * m[5] * m[6] * m[7] < 0 ? -1 : 1;
|
|
|
- var zs = m[8] * m[9] * m[10] * m[11] < 0 ? -1 : 1;
|
|
|
- var sx = xs * Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
|
|
|
- var sy = ys * Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
|
|
|
- var sz = zs * Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
|
|
|
- Matrix.FromValuesToRef(m[0] / sx, m[1] / sx, m[2] / sx, 0, m[4] / sy, m[5] / sy, m[6] / sy, 0, m[8] / sz, m[9] / sz, m[10] / sz, 0, 0, 0, 0, 1, result);
|
|
|
+ var sx = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
|
|
|
+ var sy = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
|
|
|
+ var sz = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
|
|
|
+ if (this.determinant() <= 0) {
|
|
|
+ sy *= -1;
|
|
|
+ }
|
|
|
+ if (sx === 0 || sy === 0 || sz === 0) {
|
|
|
+ Matrix.IdentityToRef(result);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Matrix.FromValuesToRef(m[0] / sx, m[1] / sx, m[2] / sx, 0, m[4] / sy, m[5] / sy, m[6] / sy, 0, m[8] / sz, m[9] / sz, m[10] / sz, 0, 0, 0, 0, 1, result);
|
|
|
+ }
|
|
|
return this;
|
|
|
};
|
|
|
// Statics
|
|
@@ -25438,6 +25458,46 @@ var BABYLON;
|
|
|
target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
|
|
|
target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
|
|
|
};
|
|
|
+ Scene.prototype._processLateAnimationBindingsForMatrices = function (holder, originalValue) {
|
|
|
+ var normalizer = 1.0;
|
|
|
+ var finalPosition = BABYLON.Tmp.Vector3[0];
|
|
|
+ var finalScaling = BABYLON.Tmp.Vector3[1];
|
|
|
+ var finalQuaternion = BABYLON.Tmp.Quaternion[0];
|
|
|
+ var startIndex = 0;
|
|
|
+ var originalAnimation = holder.animations[0];
|
|
|
+ var scale = 1;
|
|
|
+ if (holder.totalWeight < 1.0) {
|
|
|
+ // We need to mix the original value in
|
|
|
+ originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
|
|
|
+ scale = 1.0 - holder.totalWeight;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ startIndex = 1;
|
|
|
+ // We need to normalize the weights
|
|
|
+ normalizer = holder.totalWeight;
|
|
|
+ originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
|
|
|
+ scale = originalAnimation.weight / normalizer;
|
|
|
+ if (scale == 1) {
|
|
|
+ return originalAnimation.currentValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finalScaling.scaleInPlace(scale);
|
|
|
+ finalPosition.scaleInPlace(scale);
|
|
|
+ finalQuaternion.scaleInPlace(scale);
|
|
|
+ for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
|
|
|
+ var runtimeAnimation = holder.animations[animIndex];
|
|
|
+ var scale = runtimeAnimation.weight / normalizer;
|
|
|
+ var currentPosition = BABYLON.Tmp.Vector3[2];
|
|
|
+ var currentScaling = BABYLON.Tmp.Vector3[3];
|
|
|
+ var currentQuaternion = BABYLON.Tmp.Quaternion[1];
|
|
|
+ runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
|
|
|
+ currentScaling.scaleAndAddToRef(scale, finalScaling);
|
|
|
+ currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
|
|
|
+ currentPosition.scaleAndAddToRef(scale, finalPosition);
|
|
|
+ }
|
|
|
+ BABYLON.Matrix.ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
|
|
|
+ return originalAnimation._workValue;
|
|
|
+ };
|
|
|
Scene.prototype._processLateAnimationBindings = function () {
|
|
|
if (!this._registeredForLateAnimationBindings.length) {
|
|
|
return;
|
|
@@ -25446,53 +25506,55 @@ var BABYLON;
|
|
|
var target = this._registeredForLateAnimationBindings.data[index];
|
|
|
for (var path in target._lateAnimationHolders) {
|
|
|
var holder = target._lateAnimationHolders[path];
|
|
|
- var originalValue = holder.animations[0].originalValue;
|
|
|
- // Sanity check
|
|
|
- if (!originalValue.scaleAndAddToRef) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ var originalAnimation = holder.animations[0];
|
|
|
+ var originalValue = originalAnimation.originalValue;
|
|
|
+ var finalTarget = originalAnimation.target;
|
|
|
var matrixDecomposeMode = BABYLON.Animation.AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
|
|
|
- var normalizer = 1.0;
|
|
|
var finalValue = void 0;
|
|
|
- if (holder.totalWeight < 1.0) {
|
|
|
- // We need to mix the original value in
|
|
|
- if (matrixDecomposeMode) {
|
|
|
- finalValue = originalValue.clone();
|
|
|
- }
|
|
|
- else {
|
|
|
- finalValue = originalValue.scale(1.0 - holder.totalWeight);
|
|
|
- }
|
|
|
+ if (matrixDecomposeMode) {
|
|
|
+ finalValue = this._processLateAnimationBindingsForMatrices(holder, originalValue);
|
|
|
}
|
|
|
else {
|
|
|
- // We need to normalize the weights
|
|
|
- normalizer = holder.totalWeight;
|
|
|
- }
|
|
|
- for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
|
|
|
- var runtimeAnimation = holder.animations[animIndex];
|
|
|
- var scale = runtimeAnimation.weight / normalizer;
|
|
|
- if (finalValue) {
|
|
|
- if (matrixDecomposeMode) {
|
|
|
- BABYLON.Matrix.DecomposeLerpToRef(finalValue, runtimeAnimation.currentValue, scale, finalValue);
|
|
|
+ var startIndex = 0;
|
|
|
+ var normalizer = 1.0;
|
|
|
+ if (holder.totalWeight < 1.0) {
|
|
|
+ // We need to mix the original value in
|
|
|
+ if (originalValue.scale) {
|
|
|
+ finalValue = originalValue.scale(1.0 - holder.totalWeight);
|
|
|
}
|
|
|
else {
|
|
|
- runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
|
|
|
+ finalValue = originalValue * (1.0 - holder.totalWeight);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- if (scale !== 1) {
|
|
|
- if (matrixDecomposeMode) {
|
|
|
- finalValue = runtimeAnimation.currentValue.clone();
|
|
|
+ // We need to normalize the weights
|
|
|
+ normalizer = holder.totalWeight;
|
|
|
+ var scale_1 = originalAnimation.weight / normalizer;
|
|
|
+ if (scale_1 !== 1) {
|
|
|
+ if (originalAnimation.currentValue.scale) {
|
|
|
+ finalValue = originalAnimation.currentValue.scale(scale_1);
|
|
|
}
|
|
|
else {
|
|
|
- finalValue = runtimeAnimation.currentValue.scale(scale);
|
|
|
+ finalValue = originalAnimation.currentValue * scale_1;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- finalValue = runtimeAnimation.currentValue;
|
|
|
+ finalValue = originalAnimation.currentValue;
|
|
|
+ }
|
|
|
+ startIndex = 1;
|
|
|
+ }
|
|
|
+ for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
|
|
|
+ var runtimeAnimation = holder.animations[animIndex];
|
|
|
+ var scale = runtimeAnimation.weight / normalizer;
|
|
|
+ if (runtimeAnimation.currentValue.scaleAndAddToRef) {
|
|
|
+ runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ finalValue += runtimeAnimation.currentValue * scale;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- runtimeAnimation.target[path] = finalValue;
|
|
|
+ finalTarget[path] = finalValue;
|
|
|
}
|
|
|
target._lateAnimationHolders = {};
|
|
|
}
|
|
@@ -51055,12 +51117,24 @@ var BABYLON;
|
|
|
*/
|
|
|
RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
|
|
|
if (weight === void 0) { weight = 1.0; }
|
|
|
+ if (this._target instanceof Array) {
|
|
|
+ for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
|
|
|
+ var target = _a[_i];
|
|
|
+ this._setValue(target, currentValue, weight);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this._setValue(this._target, currentValue, weight);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ RuntimeAnimation.prototype._setValue = function (target, currentValue, weight) {
|
|
|
+ if (weight === void 0) { weight = 1.0; }
|
|
|
// Set value
|
|
|
var path;
|
|
|
var destination;
|
|
|
var targetPropertyPath = this._animation.targetPropertyPath;
|
|
|
if (targetPropertyPath.length > 1) {
|
|
|
- var property = this._target[targetPropertyPath[0]];
|
|
|
+ var property = target[targetPropertyPath[0]];
|
|
|
for (var index = 1; index < targetPropertyPath.length - 1; index++) {
|
|
|
property = property[targetPropertyPath[index]];
|
|
|
}
|
|
@@ -51069,14 +51143,14 @@ var BABYLON;
|
|
|
}
|
|
|
else {
|
|
|
path = targetPropertyPath[0];
|
|
|
- destination = this._target;
|
|
|
+ destination = target;
|
|
|
}
|
|
|
this._targetPath = path;
|
|
|
this._activeTarget = destination;
|
|
|
this._weight = weight;
|
|
|
// Blending
|
|
|
- var enableBlending = this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
|
|
|
- var blendingSpeed = this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
|
|
|
+ var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
|
|
|
+ var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
|
|
|
if (enableBlending && this._blendingFactor <= 1.0) {
|
|
|
if (!this._originalBlendValue) {
|
|
|
var originalValue = destination[path];
|
|
@@ -51146,8 +51220,8 @@ var BABYLON;
|
|
|
else {
|
|
|
destination[path] = this._currentValue;
|
|
|
}
|
|
|
- if (this._target.markAsDirty) {
|
|
|
- this._target.markAsDirty(this._animation.targetProperty);
|
|
|
+ if (target.markAsDirty) {
|
|
|
+ target.markAsDirty(this._animation.targetProperty);
|
|
|
}
|
|
|
};
|
|
|
RuntimeAnimation.prototype._getCorrectLoopMode = function () {
|
|
@@ -51359,11 +51433,11 @@ var BABYLON;
|
|
|
this._speedRatio = 1;
|
|
|
this._weight = -1.0;
|
|
|
this.animationStarted = false;
|
|
|
+ this._scene = scene;
|
|
|
if (animations) {
|
|
|
this.appendAnimations(target, animations);
|
|
|
}
|
|
|
this._speedRatio = speedRatio;
|
|
|
- this._scene = scene;
|
|
|
scene._activeAnimatables.push(this);
|
|
|
}
|
|
|
Object.defineProperty(Animatable.prototype, "syncRoot", {
|
|
@@ -76661,7 +76735,7 @@ var BABYLON;
|
|
|
_this._negateScaleChildren = BABYLON.Vector3.One();
|
|
|
_this._scalingDeterminant = 1;
|
|
|
_this._skeleton = skeleton;
|
|
|
- _this._localMatrix = localMatrix ? localMatrix : BABYLON.Matrix.Identity();
|
|
|
+ _this._localMatrix = localMatrix ? localMatrix.clone() : BABYLON.Matrix.Identity();
|
|
|
_this._restPose = restPose ? restPose : _this._localMatrix.clone();
|
|
|
_this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
|
|
|
_this._index = index;
|
|
@@ -76674,13 +76748,8 @@ var BABYLON;
|
|
|
get: function () {
|
|
|
return this._localMatrix;
|
|
|
},
|
|
|
- set: function (val) {
|
|
|
- if (this._localMatrix) {
|
|
|
- this._localMatrix.copyFrom(val);
|
|
|
- }
|
|
|
- else {
|
|
|
- this._localMatrix = val;
|
|
|
- }
|
|
|
+ set: function (value) {
|
|
|
+ this._localMatrix.copyFrom(value);
|
|
|
},
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
@@ -76710,6 +76779,7 @@ var BABYLON;
|
|
|
if (updateDifferenceMatrix) {
|
|
|
this._updateDifferenceMatrix();
|
|
|
}
|
|
|
+ this.markAsDirty();
|
|
|
};
|
|
|
Bone.prototype.getLocalMatrix = function () {
|
|
|
return this._localMatrix;
|
|
@@ -76765,10 +76835,14 @@ var BABYLON;
|
|
|
});
|
|
|
Object.defineProperty(Bone.prototype, "scaling", {
|
|
|
get: function () {
|
|
|
- return this.getScale();
|
|
|
+ var value = BABYLON.Vector3.One();
|
|
|
+ this._localMatrix.decompose(value, undefined, undefined);
|
|
|
+ return value;
|
|
|
},
|
|
|
set: function (newScaling) {
|
|
|
- this.setScale(newScaling.x, newScaling.y, newScaling.z);
|
|
|
+ this._localMatrix.decompose(undefined, Bone._tmpQuat, Bone._tmpVecs[0]);
|
|
|
+ BABYLON.Matrix.ComposeToRef(newScaling, Bone._tmpQuat, Bone._tmpVecs[0], this._localMatrix);
|
|
|
+ this.markAsDirty();
|
|
|
},
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
@@ -76786,12 +76860,12 @@ var BABYLON;
|
|
|
// Methods
|
|
|
Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix) {
|
|
|
if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
|
|
|
- this._baseMatrix = matrix.clone();
|
|
|
- this._localMatrix = matrix.clone();
|
|
|
- this._skeleton._markAsDirty();
|
|
|
+ this._baseMatrix.copyFrom(matrix);
|
|
|
+ this._localMatrix.copyFrom(matrix);
|
|
|
if (updateDifferenceMatrix) {
|
|
|
this._updateDifferenceMatrix();
|
|
|
}
|
|
|
+ this.markAsDirty();
|
|
|
};
|
|
|
Bone.prototype._updateDifferenceMatrix = function (rootMatrix) {
|
|
|
if (!rootMatrix) {
|
|
@@ -76963,13 +77037,13 @@ var BABYLON;
|
|
|
this.setPosition(position, BABYLON.Space.WORLD, mesh);
|
|
|
};
|
|
|
/**
|
|
|
- * Set the scale of the bone on the x, y and z axes.
|
|
|
- * @param x The scale of the bone on the x axis.
|
|
|
- * @param x The scale of the bone on the y axis.
|
|
|
- * @param z The scale of the bone on the z axis.
|
|
|
+ * Adds an additional scale to the bone on the x, y and z axes.
|
|
|
+ * @param x The additional scale of the bone on the x axis.
|
|
|
+ * @param y The additional scale of the bone on the y axis.
|
|
|
+ * @param z The additional scale of the bone on the z axis.
|
|
|
* @param scaleChildren Set this to true if children of the bone should be scaled.
|
|
|
*/
|
|
|
- Bone.prototype.setScale = function (x, y, z, scaleChildren) {
|
|
|
+ Bone.prototype.setAdditionalScale = function (x, y, z, scaleChildren) {
|
|
|
if (scaleChildren === void 0) { scaleChildren = false; }
|
|
|
if (this.animations[0] && !this.animations[0].hasRunningRuntimeAnimations) {
|
|
|
if (!scaleChildren) {
|
|
@@ -76997,7 +77071,7 @@ var BABYLON;
|
|
|
origLocMatInv.copyFrom(origLocMat);
|
|
|
origLocMatInv.invert();
|
|
|
var scaleMat = Bone._tmpMats[2];
|
|
|
- BABYLON.Matrix.FromValuesToRef(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1, scaleMat);
|
|
|
+ BABYLON.Matrix.ScalingToRef(x, y, z, scaleMat);
|
|
|
this._scaleMatrix.multiplyToRef(scaleMat, this._scaleMatrix);
|
|
|
this._scaleVector.x *= x;
|
|
|
this._scaleVector.y *= y;
|
|
@@ -77041,10 +77115,12 @@ var BABYLON;
|
|
|
*/
|
|
|
Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
|
|
|
if (space === void 0) { space = BABYLON.Space.LOCAL; }
|
|
|
- var rotMat = Bone._tmpMats[0];
|
|
|
+ var rotMatInv = Bone._tmpMats[0];
|
|
|
+ if (!this._getNegativeRotationToRef(rotMatInv, space, mesh)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var rotMat = Bone._tmpMats[1];
|
|
|
BABYLON.Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
|
|
|
- var rotMatInv = Bone._tmpMats[1];
|
|
|
- this._getNegativeRotationToRef(rotMatInv, space, mesh);
|
|
|
rotMatInv.multiplyToRef(rotMat, rotMat);
|
|
|
this._rotateWithMatrix(rotMat, space, mesh);
|
|
|
};
|
|
@@ -77073,10 +77149,12 @@ var BABYLON;
|
|
|
*/
|
|
|
Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
|
|
|
if (space === void 0) { space = BABYLON.Space.LOCAL; }
|
|
|
- var rotMat = Bone._tmpMats[0];
|
|
|
+ var rotMatInv = Bone._tmpMats[0];
|
|
|
+ if (!this._getNegativeRotationToRef(rotMatInv, space, mesh)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var rotMat = Bone._tmpMats[1];
|
|
|
BABYLON.Matrix.RotationAxisToRef(axis, angle, rotMat);
|
|
|
- var rotMatInv = Bone._tmpMats[1];
|
|
|
- this._getNegativeRotationToRef(rotMatInv, space, mesh);
|
|
|
rotMatInv.multiplyToRef(rotMat, rotMat);
|
|
|
this._rotateWithMatrix(rotMat, space, mesh);
|
|
|
};
|
|
@@ -77099,7 +77177,9 @@ var BABYLON;
|
|
|
Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
|
|
|
if (space === void 0) { space = BABYLON.Space.LOCAL; }
|
|
|
var rotMatInv = Bone._tmpMats[0];
|
|
|
- this._getNegativeRotationToRef(rotMatInv, space, mesh);
|
|
|
+ if (!this._getNegativeRotationToRef(rotMatInv, space, mesh)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
var rotMat = Bone._tmpMats[1];
|
|
|
BABYLON.Matrix.FromQuaternionToRef(quat, rotMat);
|
|
|
rotMatInv.multiplyToRef(rotMat, rotMat);
|
|
@@ -77114,7 +77194,9 @@ var BABYLON;
|
|
|
Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
|
|
|
if (space === void 0) { space = BABYLON.Space.LOCAL; }
|
|
|
var rotMatInv = Bone._tmpMats[0];
|
|
|
- this._getNegativeRotationToRef(rotMatInv, space, mesh);
|
|
|
+ if (!this._getNegativeRotationToRef(rotMatInv, space, mesh)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
var rotMat2 = Bone._tmpMats[1];
|
|
|
rotMat2.copyFrom(rotMat);
|
|
|
rotMatInv.multiplyToRef(rotMat, rotMat2);
|
|
@@ -77180,12 +77262,22 @@ var BABYLON;
|
|
|
scaleMatrix.multiplyToRef(meshScale, scaleMatrix);
|
|
|
}
|
|
|
rotMatInv.invert();
|
|
|
+ if (isNaN(rotMatInv.m[0])) {
|
|
|
+ // Matrix failed to invert.
|
|
|
+ // This can happen if scale is zero for example.
|
|
|
+ return false;
|
|
|
+ }
|
|
|
scaleMatrix.m[0] *= this._scalingDeterminant;
|
|
|
rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
|
|
|
}
|
|
|
else {
|
|
|
rotMatInv.copyFrom(this.getLocalMatrix());
|
|
|
rotMatInv.invert();
|
|
|
+ if (isNaN(rotMatInv.m[0])) {
|
|
|
+ // Matrix failed to invert.
|
|
|
+ // This can happen if scale is zero for example.
|
|
|
+ return false;
|
|
|
+ }
|
|
|
var scaleMatrix = Bone._tmpMats[2];
|
|
|
scaleMatrix.copyFrom(this._scaleMatrix);
|
|
|
if (this._parent) {
|
|
@@ -77199,19 +77291,20 @@ var BABYLON;
|
|
|
}
|
|
|
rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
|
|
|
}
|
|
|
+ return true;
|
|
|
};
|
|
|
/**
|
|
|
- * Get the scale of the bone
|
|
|
- * @returns the scale of the bone
|
|
|
+ * Get the additional scale of the bone
|
|
|
+ * @returns the additional scale of the bone
|
|
|
*/
|
|
|
- Bone.prototype.getScale = function () {
|
|
|
+ Bone.prototype.getAdditionalScale = function () {
|
|
|
return this._scaleVector.clone();
|
|
|
};
|
|
|
/**
|
|
|
- * Copy the scale of the bone to a vector3.
|
|
|
- * @param result The vector3 to copy the scale to
|
|
|
+ * Copy the additional scale of the bone to a vector3.
|
|
|
+ * @param result The vector3 to copy the additional scale to
|
|
|
*/
|
|
|
- Bone.prototype.getScaleToRef = function (result) {
|
|
|
+ Bone.prototype.getAdditionalScaleToRef = function (result) {
|
|
|
result.copyFrom(this._scaleVector);
|
|
|
};
|
|
|
/**
|
|
@@ -77401,7 +77494,7 @@ var BABYLON;
|
|
|
if (space === void 0) { space = BABYLON.Space.LOCAL; }
|
|
|
if (mesh === void 0) { mesh = null; }
|
|
|
if (space == BABYLON.Space.LOCAL) {
|
|
|
- this.getLocalMatrix().decompose(Bone._tmpVecs[0], result, Bone._tmpVecs[1]);
|
|
|
+ this.getLocalMatrix().decompose(undefined, result, undefined);
|
|
|
}
|
|
|
else {
|
|
|
var mat = Bone._tmpMats[0];
|
|
@@ -77415,7 +77508,7 @@ var BABYLON;
|
|
|
mat.m[0] *= this._scalingDeterminant;
|
|
|
mat.m[1] *= this._scalingDeterminant;
|
|
|
mat.m[2] *= this._scalingDeterminant;
|
|
|
- mat.decompose(Bone._tmpVecs[0], result, Bone._tmpVecs[1]);
|
|
|
+ mat.decompose(undefined, result, undefined);
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
@@ -77572,8 +77665,8 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
if (this._bone1.length) {
|
|
|
- var boneScale1 = this._bone1.getScale();
|
|
|
- var boneScale2 = this._bone2.getScale();
|
|
|
+ var boneScale1 = this._bone1.getAdditionalScale();
|
|
|
+ var boneScale2 = this._bone2.getAdditionalScale();
|
|
|
this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
|
|
|
this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
|
|
|
}
|