|
@@ -20159,7 +20159,8 @@ var BABYLON;
|
|
* By default the system will update normals to compensate
|
|
* By default the system will update normals to compensate
|
|
*/
|
|
*/
|
|
_this.ignoreNonUniformScaling = false;
|
|
_this.ignoreNonUniformScaling = false;
|
|
- _this._localWorld = BABYLON.Matrix.Zero();
|
|
|
|
|
|
+ /** @hidden */
|
|
|
|
+ _this._localMatrix = BABYLON.Matrix.Zero();
|
|
_this._absolutePosition = BABYLON.Vector3.Zero();
|
|
_this._absolutePosition = BABYLON.Vector3.Zero();
|
|
_this._pivotMatrix = BABYLON.Matrix.Identity();
|
|
_this._pivotMatrix = BABYLON.Matrix.Identity();
|
|
_this._postMultiplyPivotMatrix = false;
|
|
_this._postMultiplyPivotMatrix = false;
|
|
@@ -20473,7 +20474,7 @@ var BABYLON;
|
|
*/
|
|
*/
|
|
TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
|
|
TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
|
|
this.computeWorldMatrix();
|
|
this.computeWorldMatrix();
|
|
- this.position = BABYLON.Vector3.TransformNormal(vector3, this._localWorld);
|
|
|
|
|
|
+ this.position = BABYLON.Vector3.TransformNormal(vector3, this._localMatrix);
|
|
return this;
|
|
return this;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -20483,7 +20484,7 @@ var BABYLON;
|
|
TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
|
|
TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
|
|
this.computeWorldMatrix();
|
|
this.computeWorldMatrix();
|
|
var invLocalWorldMatrix = BABYLON.Tmp.Matrix[0];
|
|
var invLocalWorldMatrix = BABYLON.Tmp.Matrix[0];
|
|
- this._localWorld.invertToRef(invLocalWorldMatrix);
|
|
|
|
|
|
+ this._localMatrix.invertToRef(invLocalWorldMatrix);
|
|
return BABYLON.Vector3.TransformNormal(this.position, invLocalWorldMatrix);
|
|
return BABYLON.Vector3.TransformNormal(this.position, invLocalWorldMatrix);
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -20493,7 +20494,7 @@ var BABYLON;
|
|
*/
|
|
*/
|
|
TransformNode.prototype.locallyTranslate = function (vector3) {
|
|
TransformNode.prototype.locallyTranslate = function (vector3) {
|
|
this.computeWorldMatrix(true);
|
|
this.computeWorldMatrix(true);
|
|
- this.position = BABYLON.Vector3.TransformCoordinates(vector3, this._localWorld);
|
|
|
|
|
|
+ this.position = BABYLON.Vector3.TransformCoordinates(vector3, this._localMatrix);
|
|
return this;
|
|
return this;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -20942,7 +20943,7 @@ var BABYLON;
|
|
BABYLON.Tmp.Matrix[5].multiplyToRef(this._pivotMatrixInverse, BABYLON.Tmp.Matrix[5]);
|
|
BABYLON.Tmp.Matrix[5].multiplyToRef(this._pivotMatrixInverse, BABYLON.Tmp.Matrix[5]);
|
|
}
|
|
}
|
|
// Local world
|
|
// Local world
|
|
- BABYLON.Tmp.Matrix[5].multiplyToRef(BABYLON.Tmp.Matrix[2], this._localWorld);
|
|
|
|
|
|
+ BABYLON.Tmp.Matrix[5].multiplyToRef(BABYLON.Tmp.Matrix[2], this._localMatrix);
|
|
// Parent
|
|
// Parent
|
|
if (this.parent && this.parent.getWorldMatrix) {
|
|
if (this.parent && this.parent.getWorldMatrix) {
|
|
if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
|
|
if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
|
|
@@ -20953,24 +20954,24 @@ var BABYLON;
|
|
else {
|
|
else {
|
|
BABYLON.Tmp.Matrix[5].copyFrom(this.parent.getWorldMatrix());
|
|
BABYLON.Tmp.Matrix[5].copyFrom(this.parent.getWorldMatrix());
|
|
}
|
|
}
|
|
- this._localWorld.getTranslationToRef(BABYLON.Tmp.Vector3[5]);
|
|
|
|
|
|
+ this._localMatrix.getTranslationToRef(BABYLON.Tmp.Vector3[5]);
|
|
BABYLON.Vector3.TransformCoordinatesToRef(BABYLON.Tmp.Vector3[5], BABYLON.Tmp.Matrix[5], BABYLON.Tmp.Vector3[5]);
|
|
BABYLON.Vector3.TransformCoordinatesToRef(BABYLON.Tmp.Vector3[5], BABYLON.Tmp.Matrix[5], BABYLON.Tmp.Vector3[5]);
|
|
- this._worldMatrix.copyFrom(this._localWorld);
|
|
|
|
|
|
+ this._worldMatrix.copyFrom(this._localMatrix);
|
|
this._worldMatrix.setTranslation(BABYLON.Tmp.Vector3[5]);
|
|
this._worldMatrix.setTranslation(BABYLON.Tmp.Vector3[5]);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
if (this._transformToBoneReferal) {
|
|
if (this._transformToBoneReferal) {
|
|
- this._localWorld.multiplyToRef(this.parent.getWorldMatrix(), BABYLON.Tmp.Matrix[6]);
|
|
|
|
|
|
+ this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), BABYLON.Tmp.Matrix[6]);
|
|
BABYLON.Tmp.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
|
|
BABYLON.Tmp.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- this._localWorld.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
|
|
|
|
|
|
+ this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this._markSyncedWithParent();
|
|
this._markSyncedWithParent();
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- this._worldMatrix.copyFrom(this._localWorld);
|
|
|
|
|
|
+ this._worldMatrix.copyFrom(this._localMatrix);
|
|
}
|
|
}
|
|
// Normal matrix
|
|
// Normal matrix
|
|
if (!this.ignoreNonUniformScaling) {
|
|
if (!this.ignoreNonUniformScaling) {
|
|
@@ -22249,13 +22250,14 @@ var BABYLON;
|
|
};
|
|
};
|
|
/** @hidden */
|
|
/** @hidden */
|
|
AbstractMesh.prototype._updateBoundingInfo = function () {
|
|
AbstractMesh.prototype._updateBoundingInfo = function () {
|
|
|
|
+ var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
|
|
if (this._boundingInfo) {
|
|
if (this._boundingInfo) {
|
|
- this._boundingInfo.update(this.worldMatrixFromCache);
|
|
|
|
|
|
+ this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- this._boundingInfo = new BABYLON.BoundingInfo(this.absolutePosition, this.absolutePosition, this.worldMatrixFromCache);
|
|
|
|
|
|
+ this._boundingInfo = new BABYLON.BoundingInfo(this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
|
|
}
|
|
}
|
|
- this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
|
|
|
|
|
|
+ this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
|
|
return this;
|
|
return this;
|
|
};
|
|
};
|
|
/** @hidden */
|
|
/** @hidden */
|
|
@@ -34275,10 +34277,11 @@ var BABYLON;
|
|
if (!effect) {
|
|
if (!effect) {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
+ var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
|
|
var sideOrientation = this.overrideMaterialSideOrientation;
|
|
var sideOrientation = this.overrideMaterialSideOrientation;
|
|
if (sideOrientation == null) {
|
|
if (sideOrientation == null) {
|
|
sideOrientation = this._effectiveMaterial.sideOrientation;
|
|
sideOrientation = this._effectiveMaterial.sideOrientation;
|
|
- if (this._getWorldMatrixDeterminant() < 0) {
|
|
|
|
|
|
+ if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
|
|
sideOrientation = (sideOrientation === BABYLON.Material.ClockWiseSideOrientation ? BABYLON.Material.CounterClockWiseSideOrientation : BABYLON.Material.ClockWiseSideOrientation);
|
|
sideOrientation = (sideOrientation === BABYLON.Material.ClockWiseSideOrientation ? BABYLON.Material.CounterClockWiseSideOrientation : BABYLON.Material.ClockWiseSideOrientation);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -34291,7 +34294,7 @@ var BABYLON;
|
|
if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
|
|
if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
|
|
this._bind(subMesh, effect, fillMode);
|
|
this._bind(subMesh, effect, fillMode);
|
|
}
|
|
}
|
|
- var world = this.getWorldMatrix();
|
|
|
|
|
|
+ var world = effectiveMesh.getWorldMatrix();
|
|
if (this._effectiveMaterial._storeEffectOnSubMeshes) {
|
|
if (this._effectiveMaterial._storeEffectOnSubMeshes) {
|
|
this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
|
|
this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
|
|
}
|
|
}
|
|
@@ -92931,6 +92934,8 @@ var BABYLON;
|
|
_this._worldTransform = new BABYLON.Matrix();
|
|
_this._worldTransform = new BABYLON.Matrix();
|
|
_this._needToDecompose = true;
|
|
_this._needToDecompose = true;
|
|
_this._needToCompose = false;
|
|
_this._needToCompose = false;
|
|
|
|
+ /** @hidden */
|
|
|
|
+ _this._linkedTransformNode = null;
|
|
_this._skeleton = skeleton;
|
|
_this._skeleton = skeleton;
|
|
_this._localMatrix = localMatrix ? localMatrix.clone() : BABYLON.Matrix.Identity();
|
|
_this._localMatrix = localMatrix ? localMatrix.clone() : BABYLON.Matrix.Identity();
|
|
_this._restPose = restPose ? restPose : _this._localMatrix.clone();
|
|
_this._restPose = restPose ? restPose : _this._localMatrix.clone();
|
|
@@ -93046,6 +93051,20 @@ var BABYLON;
|
|
Bone.prototype.getAbsoluteTransform = function () {
|
|
Bone.prototype.getAbsoluteTransform = function () {
|
|
return this._absoluteTransform;
|
|
return this._absoluteTransform;
|
|
};
|
|
};
|
|
|
|
+ /**
|
|
|
|
+ * Links with the given transform node.
|
|
|
|
+ * The local matrix of this bone is copied from the transform node every frame.
|
|
|
|
+ * @param transformNode defines the transform node to link to
|
|
|
|
+ */
|
|
|
|
+ Bone.prototype.linkTransformNode = function (transformNode) {
|
|
|
|
+ if (this._linkedTransformNode) {
|
|
|
|
+ this._skeleton._numBonesWithLinkedTransformNode--;
|
|
|
|
+ }
|
|
|
|
+ this._linkedTransformNode = transformNode;
|
|
|
|
+ if (this._linkedTransformNode) {
|
|
|
|
+ this._skeleton._numBonesWithLinkedTransformNode++;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
Object.defineProperty(Bone.prototype, "position", {
|
|
Object.defineProperty(Bone.prototype, "position", {
|
|
// Properties (matches AbstractMesh properties)
|
|
// Properties (matches AbstractMesh properties)
|
|
/** Gets or sets current position (in local space) */
|
|
/** Gets or sets current position (in local space) */
|
|
@@ -94591,19 +94610,25 @@ var BABYLON;
|
|
this.name = name;
|
|
this.name = name;
|
|
this.id = id;
|
|
this.id = id;
|
|
/**
|
|
/**
|
|
- * Gets the list of child bones
|
|
|
|
|
|
+ * Defines the list of child bones
|
|
*/
|
|
*/
|
|
this.bones = new Array();
|
|
this.bones = new Array();
|
|
/**
|
|
/**
|
|
- * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
|
|
|
|
|
|
+ * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
|
|
*/
|
|
*/
|
|
this.needInitialSkinMatrix = false;
|
|
this.needInitialSkinMatrix = false;
|
|
|
|
+ /**
|
|
|
|
+ * Defines a mesh that override the matrix used to get the world matrix (null by default).
|
|
|
|
+ */
|
|
|
|
+ this.overrideMesh = null;
|
|
this._isDirty = true;
|
|
this._isDirty = true;
|
|
this._meshesWithPoseMatrix = new Array();
|
|
this._meshesWithPoseMatrix = new Array();
|
|
this._identity = BABYLON.Matrix.Identity();
|
|
this._identity = BABYLON.Matrix.Identity();
|
|
this._ranges = {};
|
|
this._ranges = {};
|
|
this._lastAbsoluteTransformsUpdateId = -1;
|
|
this._lastAbsoluteTransformsUpdateId = -1;
|
|
this._canUseTextureForBones = false;
|
|
this._canUseTextureForBones = false;
|
|
|
|
+ /** @hidden */
|
|
|
|
+ this._numBonesWithLinkedTransformNode = 0;
|
|
/**
|
|
/**
|
|
* Specifies if the skeleton should be serialized
|
|
* Specifies if the skeleton should be serialized
|
|
*/
|
|
*/
|
|
@@ -94894,6 +94919,18 @@ var BABYLON;
|
|
* Build all resources required to render a skeleton
|
|
* Build all resources required to render a skeleton
|
|
*/
|
|
*/
|
|
Skeleton.prototype.prepare = function () {
|
|
Skeleton.prototype.prepare = function () {
|
|
|
|
+ // Update the local matrix of bones with linked transform nodes.
|
|
|
|
+ if (this._numBonesWithLinkedTransformNode > 0) {
|
|
|
|
+ for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
|
|
|
|
+ var bone_1 = _a[_i];
|
|
|
|
+ if (bone_1._linkedTransformNode) {
|
|
|
|
+ // Computing the world matrix also computes the local matrix.
|
|
|
|
+ bone_1._linkedTransformNode.computeWorldMatrix();
|
|
|
|
+ bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
|
|
|
|
+ bone_1.markAsDirty();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if (!this._isDirty) {
|
|
if (!this._isDirty) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|