|
@@ -1,6 +1,4 @@
|
|
|
-/// <reference path="..\babylon.node.ts" />
|
|
|
-
|
|
|
-module BABYLON {
|
|
|
+module BABYLON {
|
|
|
export class Bone extends Node {
|
|
|
|
|
|
private static _tmpVecs: Vector3[] = [Vector3.Zero(), Vector3.Zero()];
|
|
@@ -41,8 +39,8 @@ module BABYLON {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- constructor(public name: string, skeleton: Skeleton, parentBone: Nullable<Bone> = null, localMatrix: Nullable<Matrix> = null,
|
|
|
- restPose: Nullable<Matrix> = null, baseMatrix: Nullable<Matrix> = null, index: Nullable<number> = null) {
|
|
|
+ constructor(public name: string, skeleton: Skeleton, parentBone: Nullable<Bone> = null, localMatrix: Nullable<Matrix> = null,
|
|
|
+ restPose: Nullable<Matrix> = null, baseMatrix: Nullable<Matrix> = null, index: Nullable<number> = null) {
|
|
|
super(name, skeleton.getScene());
|
|
|
this._skeleton = skeleton;
|
|
|
this._localMatrix = localMatrix ? localMatrix : Matrix.Identity();
|
|
@@ -99,7 +97,7 @@ module BABYLON {
|
|
|
|
|
|
public getRestPose(): Matrix {
|
|
|
return this._restPose;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
public returnToRest(): void {
|
|
|
this.updateMatrix(this._restPose.clone());
|
|
@@ -202,21 +200,21 @@ module BABYLON {
|
|
|
var from = sourceRange.from;
|
|
|
var to = sourceRange.to;
|
|
|
var sourceKeys = source.animations[0].getKeys();
|
|
|
-
|
|
|
+
|
|
|
// rescaling prep
|
|
|
var sourceBoneLength = source.length;
|
|
|
var sourceParent = source.getParent();
|
|
|
var parent = this.getParent();
|
|
|
var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
|
|
|
var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
|
|
|
-
|
|
|
- var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
|
|
|
-
|
|
|
+
|
|
|
+ var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
|
|
|
+
|
|
|
var destKeys = this.animations[0].getKeys();
|
|
|
-
|
|
|
+
|
|
|
// loop vars declaration
|
|
|
var orig: { frame: number, value: Matrix };
|
|
|
- var origTranslation : Vector3;
|
|
|
+ var origTranslation: Vector3;
|
|
|
var mat: Matrix;
|
|
|
|
|
|
for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
|
|
@@ -224,20 +222,20 @@ module BABYLON {
|
|
|
if (orig.frame >= from && orig.frame <= to) {
|
|
|
if (rescaleAsRequired) {
|
|
|
mat = orig.value.clone();
|
|
|
-
|
|
|
+
|
|
|
// scale based on parent ratio, when bone has parent
|
|
|
if (parentScalingReqd) {
|
|
|
origTranslation = mat.getTranslation();
|
|
|
mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
|
|
|
-
|
|
|
- // scale based on skeleton dimension ratio when root bone, and value is passed
|
|
|
+
|
|
|
+ // scale based on skeleton dimension ratio when root bone, and value is passed
|
|
|
} else if (dimensionsScalingReqd && skelDimensionsRatio) {
|
|
|
origTranslation = mat.getTranslation();
|
|
|
- mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
|
|
|
+ mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
|
|
|
|
|
|
- // use original when root bone, and no data for skelDimensionsRatio
|
|
|
+ // use original when root bone, and no data for skelDimensionsRatio
|
|
|
} else {
|
|
|
- mat = orig.value;
|
|
|
+ mat = orig.value;
|
|
|
}
|
|
|
} else {
|
|
|
mat = orig.value;
|
|
@@ -258,7 +256,7 @@ module BABYLON {
|
|
|
public translate(vec: Vector3, space = Space.LOCAL, mesh?: AbstractMesh): void {
|
|
|
var lm = this.getLocalMatrix();
|
|
|
|
|
|
- if(space == Space.LOCAL){
|
|
|
+ if (space == Space.LOCAL) {
|
|
|
lm.m[12] += vec.x;
|
|
|
lm.m[13] += vec.y;
|
|
|
lm.m[14] += vec.z;
|
|
@@ -266,7 +264,7 @@ module BABYLON {
|
|
|
var wm: Nullable<Matrix> = null;
|
|
|
|
|
|
//mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
|
|
|
- if (mesh){
|
|
|
+ if (mesh) {
|
|
|
wm = mesh.getWorldMatrix();
|
|
|
}
|
|
|
|
|
@@ -297,7 +295,7 @@ module BABYLON {
|
|
|
}
|
|
|
|
|
|
this.markAsDirty();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -318,7 +316,7 @@ module BABYLON {
|
|
|
var wm: Nullable<Matrix> = null;
|
|
|
|
|
|
//mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
|
|
|
- if(mesh){
|
|
|
+ if (mesh) {
|
|
|
wm = mesh.getWorldMatrix();
|
|
|
}
|
|
|
|
|
@@ -346,7 +344,7 @@ module BABYLON {
|
|
|
}
|
|
|
|
|
|
this.markAsDirty();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -354,7 +352,7 @@ module BABYLON {
|
|
|
* @param position The position to set the bone.
|
|
|
* @param mesh The mesh that this bone is attached to.
|
|
|
*/
|
|
|
- public setAbsolutePosition(position:Vector3, mesh?: AbstractMesh){
|
|
|
+ public setAbsolutePosition(position: Vector3, mesh?: AbstractMesh) {
|
|
|
|
|
|
this.setPosition(position, Space.WORLD, mesh);
|
|
|
|
|
@@ -371,9 +369,9 @@ module BABYLON {
|
|
|
|
|
|
if (this.animations[0] && !this.animations[0].hasRunningRuntimeAnimations) {
|
|
|
if (!scaleChildren) {
|
|
|
- this._negateScaleChildren.x = 1/x;
|
|
|
- this._negateScaleChildren.y = 1/y;
|
|
|
- this._negateScaleChildren.z = 1/z;
|
|
|
+ this._negateScaleChildren.x = 1 / x;
|
|
|
+ this._negateScaleChildren.y = 1 / y;
|
|
|
+ this._negateScaleChildren.z = 1 / z;
|
|
|
}
|
|
|
this._syncScaleVector();
|
|
|
}
|
|
@@ -390,7 +388,7 @@ module BABYLON {
|
|
|
* @param scaleChildren Set this to true if children of the bone should be scaled.
|
|
|
*/
|
|
|
public scale(x: number, y: number, z: number, scaleChildren = false): void {
|
|
|
-
|
|
|
+
|
|
|
var locMat = this.getLocalMatrix();
|
|
|
var origLocMat = Bone._tmpMats[0];
|
|
|
origLocMat.copyFrom(locMat);
|
|
@@ -414,14 +412,14 @@ module BABYLON {
|
|
|
|
|
|
if (parent) {
|
|
|
locMat.multiplyToRef(parent.getAbsoluteTransform(), this.getAbsoluteTransform());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
this.getAbsoluteTransform().copyFrom(locMat);
|
|
|
}
|
|
|
|
|
|
var len = this.children.length;
|
|
|
|
|
|
scaleMat.invert();
|
|
|
-
|
|
|
+
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
var child = this.children[i];
|
|
|
var cm = child.getLocalMatrix();
|
|
@@ -433,12 +431,12 @@ module BABYLON {
|
|
|
}
|
|
|
|
|
|
this.computeAbsoluteTransforms();
|
|
|
-
|
|
|
+
|
|
|
if (scaleChildren) {
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
this.children[i].scale(x, y, z, scaleChildren);
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
this.markAsDirty();
|
|
|
|
|
@@ -453,18 +451,18 @@ module BABYLON {
|
|
|
* @param mesh The mesh that this bone is attached to. This is only used in world space.
|
|
|
*/
|
|
|
public setYawPitchRoll(yaw: number, pitch: number, roll: number, space = Space.LOCAL, mesh?: AbstractMesh): void {
|
|
|
-
|
|
|
+
|
|
|
var rotMat = Bone._tmpMats[0];
|
|
|
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);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -475,16 +473,16 @@ module BABYLON {
|
|
|
* @param mesh The mesh that this bone is attached to. This is only used in world space.
|
|
|
*/
|
|
|
public rotate(axis: Vector3, amount: number, space = Space.LOCAL, mesh?: AbstractMesh): void {
|
|
|
-
|
|
|
+
|
|
|
var rmat = Bone._tmpMats[0];
|
|
|
rmat.m[12] = 0;
|
|
|
rmat.m[13] = 0;
|
|
|
rmat.m[14] = 0;
|
|
|
-
|
|
|
+
|
|
|
Matrix.RotationAxisToRef(axis, amount, rmat);
|
|
|
-
|
|
|
+
|
|
|
this._rotateWithMatrix(rmat, space, mesh);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -499,9 +497,9 @@ module BABYLON {
|
|
|
var rotMat = Bone._tmpMats[0];
|
|
|
Matrix.RotationAxisToRef(axis, angle, rotMat);
|
|
|
var rotMatInv = Bone._tmpMats[1];
|
|
|
-
|
|
|
+
|
|
|
this._getNegativeRotationToRef(rotMatInv, space, mesh);
|
|
|
-
|
|
|
+
|
|
|
rotMatInv.multiplyToRef(rotMat, rotMat);
|
|
|
this._rotateWithMatrix(rotMat, space, mesh);
|
|
|
|
|
@@ -514,7 +512,7 @@ module BABYLON {
|
|
|
* @param mesh The mesh that this bone is attached to. This is only used in world space.
|
|
|
*/
|
|
|
public setRotation(rotation: Vector3, space = Space.LOCAL, mesh?: AbstractMesh): void {
|
|
|
-
|
|
|
+
|
|
|
this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
|
|
|
|
|
|
}
|
|
@@ -549,14 +547,14 @@ module BABYLON {
|
|
|
public setRotationMatrix(rotMat: Matrix, space = Space.LOCAL, mesh?: AbstractMesh): void {
|
|
|
|
|
|
var rotMatInv = Bone._tmpMats[0];
|
|
|
-
|
|
|
+
|
|
|
this._getNegativeRotationToRef(rotMatInv, space, mesh);
|
|
|
|
|
|
var rotMat2 = Bone._tmpMats[1];
|
|
|
rotMat2.copyFrom(rotMat);
|
|
|
|
|
|
rotMatInv.multiplyToRef(rotMat, rotMat2);
|
|
|
-
|
|
|
+
|
|
|
this._rotateWithMatrix(rotMat2, space, mesh);
|
|
|
|
|
|
}
|
|
@@ -576,10 +574,10 @@ module BABYLON {
|
|
|
if (mesh) {
|
|
|
parentScale.copyFrom(mesh.getWorldMatrix());
|
|
|
parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
parentScale.copyFrom(parent.getAbsoluteTransform());
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
parentScale = parent._scaleMatrix;
|
|
|
}
|
|
|
parentScaleInv.copyFrom(parentScale);
|
|
@@ -587,7 +585,7 @@ module BABYLON {
|
|
|
lmat.multiplyToRef(parentScale, lmat);
|
|
|
lmat.multiplyToRef(rmat, lmat);
|
|
|
lmat.multiplyToRef(parentScaleInv, lmat);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
if (space == Space.WORLD && mesh) {
|
|
|
parentScale.copyFrom(mesh.getWorldMatrix());
|
|
|
parentScaleInv.copyFrom(parentScale);
|
|
@@ -595,7 +593,7 @@ module BABYLON {
|
|
|
lmat.multiplyToRef(parentScale, lmat);
|
|
|
lmat.multiplyToRef(rmat, lmat);
|
|
|
lmat.multiplyToRef(parentScaleInv, lmat);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
lmat.multiplyToRef(rmat, lmat);
|
|
|
}
|
|
|
}
|
|
@@ -616,7 +614,7 @@ module BABYLON {
|
|
|
var scaleMatrix = Bone._tmpMats[2];
|
|
|
scaleMatrix.copyFrom(this._scaleMatrix);
|
|
|
rotMatInv.copyFrom(this.getAbsoluteTransform());
|
|
|
-
|
|
|
+
|
|
|
if (mesh) {
|
|
|
rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
|
|
|
var meshScale = Bone._tmpMats[3];
|
|
@@ -652,9 +650,9 @@ module BABYLON {
|
|
|
* @returns the scale of the bone
|
|
|
*/
|
|
|
public getScale(): Vector3 {
|
|
|
-
|
|
|
+
|
|
|
return this._scaleVector.clone();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -662,9 +660,9 @@ module BABYLON {
|
|
|
* @param result The vector3 to copy the scale to
|
|
|
*/
|
|
|
public getScaleToRef(result: Vector3): void {
|
|
|
-
|
|
|
+
|
|
|
result.copyFrom(this._scaleVector);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -689,28 +687,28 @@ module BABYLON {
|
|
|
*/
|
|
|
public getPositionToRef(space = Space.LOCAL, mesh: Nullable<AbstractMesh>, result: Vector3): void {
|
|
|
|
|
|
- if (space == Space.LOCAL){
|
|
|
+ if (space == Space.LOCAL) {
|
|
|
var lm = this.getLocalMatrix();
|
|
|
|
|
|
result.x = lm.m[12];
|
|
|
result.y = lm.m[13];
|
|
|
result.z = lm.m[14];
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
var wm: Nullable<Matrix> = null;
|
|
|
-
|
|
|
+
|
|
|
//mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
|
|
|
- if (mesh){
|
|
|
+ if (mesh) {
|
|
|
wm = mesh.getWorldMatrix();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
this._skeleton.computeAbsoluteTransforms();
|
|
|
-
|
|
|
+
|
|
|
var tmat = Bone._tmpMats[0];
|
|
|
|
|
|
if (mesh && wm) {
|
|
|
tmat.copyFrom(this.getAbsoluteTransform());
|
|
|
tmat.multiplyToRef(wm, tmat);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
tmat = this.getAbsoluteTransform();
|
|
|
}
|
|
|
|
|
@@ -758,8 +756,8 @@ module BABYLON {
|
|
|
|
|
|
var poseMatrix = this._skeleton.getPoseMatrix();
|
|
|
|
|
|
- if(poseMatrix){
|
|
|
- this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
|
|
|
+ if (poseMatrix) {
|
|
|
+ this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -772,29 +770,29 @@ module BABYLON {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private _syncScaleVector(): void{
|
|
|
-
|
|
|
+ private _syncScaleVector(): void {
|
|
|
+
|
|
|
var lm = this.getLocalMatrix();
|
|
|
-
|
|
|
+
|
|
|
var xsq = (lm.m[0] * lm.m[0] + lm.m[1] * lm.m[1] + lm.m[2] * lm.m[2]);
|
|
|
var ysq = (lm.m[4] * lm.m[4] + lm.m[5] * lm.m[5] + lm.m[6] * lm.m[6]);
|
|
|
var zsq = (lm.m[8] * lm.m[8] + lm.m[9] * lm.m[9] + lm.m[10] * lm.m[10]);
|
|
|
-
|
|
|
+
|
|
|
var xs = lm.m[0] * lm.m[1] * lm.m[2] * lm.m[3] < 0 ? -1 : 1;
|
|
|
var ys = lm.m[4] * lm.m[5] * lm.m[6] * lm.m[7] < 0 ? -1 : 1;
|
|
|
var zs = lm.m[8] * lm.m[9] * lm.m[10] * lm.m[11] < 0 ? -1 : 1;
|
|
|
-
|
|
|
+
|
|
|
this._scaleVector.x = xs * Math.sqrt(xsq);
|
|
|
this._scaleVector.y = ys * Math.sqrt(ysq);
|
|
|
this._scaleVector.z = zs * Math.sqrt(zsq);
|
|
|
-
|
|
|
+
|
|
|
if (this._parent) {
|
|
|
this._scaleVector.x /= this._parent._negateScaleChildren.x;
|
|
|
this._scaleVector.y /= this._parent._negateScaleChildren.y;
|
|
|
this._scaleVector.z /= this._parent._negateScaleChildren.z;
|
|
|
}
|
|
|
-
|
|
|
- Matrix.FromValuesToRef(this._scaleVector.x, 0, 0, 0, 0, this._scaleVector.y, 0, 0, 0, 0, this._scaleVector.z, 0, 0, 0, 0, 1, this._scaleMatrix);
|
|
|
+
|
|
|
+ Matrix.FromValuesToRef(this._scaleVector.x, 0, 0, 0, 0, this._scaleVector.y, 0, 0, 0, 0, this._scaleVector.z, 0, 0, 0, 0, 1, this._scaleMatrix);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -804,12 +802,12 @@ module BABYLON {
|
|
|
* @param mesh The mesh that this bone is attached to.
|
|
|
* @returns The world direction
|
|
|
*/
|
|
|
- public getDirection(localAxis: Vector3, mesh: Nullable<AbstractMesh> = null): Vector3{
|
|
|
+ public getDirection(localAxis: Vector3, mesh: Nullable<AbstractMesh> = null): Vector3 {
|
|
|
|
|
|
var result = Vector3.Zero();
|
|
|
|
|
|
this.getDirectionToRef(localAxis, mesh, result);
|
|
|
-
|
|
|
+
|
|
|
return result;
|
|
|
|
|
|
}
|
|
@@ -825,12 +823,12 @@ module BABYLON {
|
|
|
var wm: Nullable<Matrix> = null;
|
|
|
|
|
|
//mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
|
|
|
- if(mesh){
|
|
|
+ if (mesh) {
|
|
|
wm = mesh.getWorldMatrix();
|
|
|
}
|
|
|
|
|
|
this._skeleton.computeAbsoluteTransforms();
|
|
|
-
|
|
|
+
|
|
|
var mat = Bone._tmpMats[0];
|
|
|
|
|
|
mat.copyFrom(this.getAbsoluteTransform());
|
|
@@ -856,7 +854,7 @@ module BABYLON {
|
|
|
var result = Vector3.Zero();
|
|
|
|
|
|
this.getRotationToRef(space, mesh, result);
|
|
|
-
|
|
|
+
|
|
|
return result;
|
|
|
|
|
|
}
|
|
@@ -872,7 +870,7 @@ module BABYLON {
|
|
|
var quat = Bone._tmpQuat;
|
|
|
|
|
|
this.getRotationQuaternionToRef(space, mesh, quat);
|
|
|
-
|
|
|
+
|
|
|
quat.toEulerAnglesToRef(result);
|
|
|
|
|
|
}
|
|
@@ -899,20 +897,20 @@ module BABYLON {
|
|
|
* @param mesh The mesh that this bone is attached to. This is only used in world space.
|
|
|
* @param result The quaternion that the rotation should be copied to.
|
|
|
*/
|
|
|
- public getRotationQuaternionToRef(space = Space.LOCAL, mesh: Nullable<AbstractMesh> = null, result: Quaternion): void{
|
|
|
+ public getRotationQuaternionToRef(space = Space.LOCAL, mesh: Nullable<AbstractMesh> = null, result: Quaternion): void {
|
|
|
|
|
|
- if(space == Space.LOCAL){
|
|
|
+ if (space == Space.LOCAL) {
|
|
|
|
|
|
this.getLocalMatrix().decompose(Bone._tmpVecs[0], result, Bone._tmpVecs[1]);
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
|
|
|
var mat = Bone._tmpMats[0];
|
|
|
var amat = this.getAbsoluteTransform();
|
|
|
|
|
|
- if(mesh){
|
|
|
+ if (mesh) {
|
|
|
amat.multiplyToRef(mesh.getWorldMatrix(), mat);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
mat.copyFrom(amat);
|
|
|
}
|
|
|
|
|
@@ -947,20 +945,20 @@ module BABYLON {
|
|
|
* @param mesh The mesh that this bone is attached to. This is only used in world space.
|
|
|
* @param result The quaternion that the rotation should be copied to.
|
|
|
*/
|
|
|
- public getRotationMatrixToRef(space = Space.LOCAL, mesh: AbstractMesh, result: Matrix): void{
|
|
|
+ public getRotationMatrixToRef(space = Space.LOCAL, mesh: AbstractMesh, result: Matrix): void {
|
|
|
|
|
|
- if(space == Space.LOCAL){
|
|
|
+ if (space == Space.LOCAL) {
|
|
|
|
|
|
this.getLocalMatrix().getRotationMatrixToRef(result);
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
|
|
|
var mat = Bone._tmpMats[0];
|
|
|
var amat = this.getAbsoluteTransform();
|
|
|
|
|
|
- if(mesh){
|
|
|
+ if (mesh) {
|
|
|
amat.multiplyToRef(mesh.getWorldMatrix(), mat);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
mat.copyFrom(amat);
|
|
|
}
|
|
|
|
|
@@ -969,7 +967,7 @@ module BABYLON {
|
|
|
mat.m[2] *= this._scalingDeterminant;
|
|
|
|
|
|
mat.getRotationMatrixToRef(result);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -980,7 +978,7 @@ module BABYLON {
|
|
|
* @param mesh The mesh that this bone is attached to.
|
|
|
* @returns The world position
|
|
|
*/
|
|
|
- public getAbsolutePositionFromLocal(position:Vector3, mesh: Nullable<AbstractMesh> = null): Vector3{
|
|
|
+ public getAbsolutePositionFromLocal(position: Vector3, mesh: Nullable<AbstractMesh> = null): Vector3 {
|
|
|
|
|
|
var result = Vector3.Zero();
|
|
|
|
|
@@ -996,23 +994,23 @@ module BABYLON {
|
|
|
* @param mesh The mesh that this bone is attached to.
|
|
|
* @param result The vector3 that the world position should be copied to.
|
|
|
*/
|
|
|
- public getAbsolutePositionFromLocalToRef(position:Vector3, mesh: Nullable<AbstractMesh> = null, result:Vector3): void{
|
|
|
+ public getAbsolutePositionFromLocalToRef(position: Vector3, mesh: Nullable<AbstractMesh> = null, result: Vector3): void {
|
|
|
|
|
|
var wm: Nullable<Matrix> = null;
|
|
|
|
|
|
//mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
|
|
|
- if(mesh){
|
|
|
+ if (mesh) {
|
|
|
wm = mesh.getWorldMatrix();
|
|
|
}
|
|
|
|
|
|
this._skeleton.computeAbsoluteTransforms();
|
|
|
|
|
|
var tmat = Bone._tmpMats[0];
|
|
|
-
|
|
|
+
|
|
|
if (mesh && wm) {
|
|
|
tmat.copyFrom(this.getAbsoluteTransform());
|
|
|
tmat.multiplyToRef(wm, tmat);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
tmat = this.getAbsoluteTransform();
|
|
|
}
|
|
|
|
|
@@ -1026,7 +1024,7 @@ module BABYLON {
|
|
|
* @param mesh The mesh that this bone is attached to.
|
|
|
* @returns The local position
|
|
|
*/
|
|
|
- public getLocalPositionFromAbsolute(position:Vector3, mesh: Nullable<AbstractMesh> = null): Vector3{
|
|
|
+ public getLocalPositionFromAbsolute(position: Vector3, mesh: Nullable<AbstractMesh> = null): Vector3 {
|
|
|
|
|
|
var result = Vector3.Zero();
|
|
|
|
|
@@ -1042,12 +1040,12 @@ module BABYLON {
|
|
|
* @param mesh The mesh that this bone is attached to.
|
|
|
* @param result The vector3 that the local position should be copied to.
|
|
|
*/
|
|
|
- public getLocalPositionFromAbsoluteToRef(position:Vector3, mesh: Nullable<AbstractMesh> = null, result:Vector3): void{
|
|
|
+ public getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: Nullable<AbstractMesh> = null, result: Vector3): void {
|
|
|
|
|
|
var wm: Nullable<Matrix> = null;
|
|
|
|
|
|
//mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
|
|
|
- if(mesh){
|
|
|
+ if (mesh) {
|
|
|
wm = mesh.getWorldMatrix();
|
|
|
}
|
|
|
|
|
@@ -1056,7 +1054,7 @@ module BABYLON {
|
|
|
var tmat = Bone._tmpMats[0];
|
|
|
|
|
|
tmat.copyFrom(this.getAbsoluteTransform());
|
|
|
-
|
|
|
+
|
|
|
if (mesh && wm) {
|
|
|
tmat.multiplyToRef(wm, tmat);
|
|
|
}
|