|
@@ -1371,6 +1371,10 @@
|
|
|
return new Quaternion(-q.x, -q.y, -q.z, q.w);
|
|
|
}
|
|
|
|
|
|
+ public static Identity(): Quaternion {
|
|
|
+ return new Quaternion(0, 0, 0, 1);
|
|
|
+ }
|
|
|
+
|
|
|
public static RotationAxis(axis: Vector3, angle: number): Quaternion {
|
|
|
var result = new Quaternion();
|
|
|
var sin = Math.sin(angle / 2);
|
|
@@ -1653,6 +1657,39 @@
|
|
|
this.m[12], this.m[13], this.m[14], this.m[15]);
|
|
|
}
|
|
|
|
|
|
+ public decompose(scale: Vector3, rotation: Quaternion, translation: Vector3) {
|
|
|
+ translation.x = this.m[12];
|
|
|
+ translation.y = this.m[13];
|
|
|
+ translation.z = this.m[14];
|
|
|
+
|
|
|
+ var xs = Tools.Sign(this.m[0] * this.m[1] * this.m[2] * this.m[3]) < 0 ? -1 : 1;
|
|
|
+ var ys = Tools.Sign(this.m[4] * this.m[5] * this.m[6] * this.m[7]) < 0 ? -1 : 1;
|
|
|
+ var zs = Tools.Sign(this.m[8] * this.m[9] * this.m[10] * this.m[11]) < 0 ? -1 : 1;
|
|
|
+
|
|
|
+ debugger;
|
|
|
+
|
|
|
+ scale.x = xs * Math.sqrt(this.m[0] * this.m[0] + this.m[1] * this.m[1] + this.m[2] * this.m[2]);
|
|
|
+ scale.y = ys * Math.sqrt(this.m[4] * this.m[4] + this.m[5] * this.m[5] + this.m[6] * this.m[6]);
|
|
|
+ scale.z = zs * Math.sqrt(this.m[8] * this.m[8] + this.m[9] * this.m[9] + this.m[10] * this.m[10]);
|
|
|
+
|
|
|
+ if (scale.x == 0 || scale.y == 0 || scale.z == 0) {
|
|
|
+ rotation.x = 0;
|
|
|
+ rotation.y = 0;
|
|
|
+ rotation.z = 0;
|
|
|
+ rotation.w = 1;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var rotationMatrix = BABYLON.Matrix.FromValues(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);
|
|
|
+
|
|
|
+ rotation.fromRotationMatrix(rotationMatrix);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
// Statics
|
|
|
public static FromArray(array: number[], offset?: number): Matrix {
|
|
|
var result = new Matrix();
|
|
@@ -2612,7 +2649,7 @@
|
|
|
}
|
|
|
|
|
|
export class PathCursor {
|
|
|
- private _onchange = new Array <(cursor: PathCursor) => void>();
|
|
|
+ private _onchange = new Array<(cursor: PathCursor) => void>();
|
|
|
|
|
|
value: number = 0;
|
|
|
animations = new Array<Animation>();
|
|
@@ -2620,14 +2657,14 @@
|
|
|
constructor(private path: Path2) {
|
|
|
}
|
|
|
|
|
|
- getPoint() : Vector3 {
|
|
|
+ getPoint(): Vector3 {
|
|
|
var point = this.path.getPointAtLengthPosition(this.value);
|
|
|
return new Vector3(point.x, 0, point.y);
|
|
|
}
|
|
|
|
|
|
moveAhead(step: number = 0.002) {
|
|
|
this.move(step);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
moveBack(step: number = 0.002) {
|
|
@@ -2635,7 +2672,7 @@
|
|
|
}
|
|
|
|
|
|
move(step: number) {
|
|
|
-
|
|
|
+
|
|
|
if (Math.abs(step) > 1) {
|
|
|
throw "step size should be less than 1.";
|
|
|
}
|
|
@@ -2648,7 +2685,7 @@
|
|
|
private ensureLimits() {
|
|
|
while (this.value > 1) {
|
|
|
this.value -= 1;
|
|
|
- }
|
|
|
+ }
|
|
|
while (this.value < 0) {
|
|
|
this.value += 1;
|
|
|
}
|