|
@@ -4585,6 +4585,15 @@ module BABYLON {
|
|
* @returns the current matrix
|
|
* @returns the current matrix
|
|
*/
|
|
*/
|
|
public multiplyToRef(other: Readonly<Matrix>, result: Matrix): Matrix {
|
|
public multiplyToRef(other: Readonly<Matrix>, result: Matrix): Matrix {
|
|
|
|
+ if (this._isIdentity) {
|
|
|
|
+ result.copyFrom(other);
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+ if ((other as Matrix)._isIdentity) {
|
|
|
|
+ result.copyFrom(this);
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
this.multiplyToArray(other, result._m, 0);
|
|
this.multiplyToArray(other, result._m, 0);
|
|
result._markAsUpdated();
|
|
result._markAsUpdated();
|
|
return this;
|
|
return this;
|
|
@@ -4598,15 +4607,6 @@ module BABYLON {
|
|
* @returns the current matrix
|
|
* @returns the current matrix
|
|
*/
|
|
*/
|
|
public multiplyToArray(other: Readonly<Matrix>, result: Float32Array, offset: number): Matrix {
|
|
public multiplyToArray(other: Readonly<Matrix>, result: Float32Array, offset: number): Matrix {
|
|
- if (this._isIdentity) {
|
|
|
|
- other.copyToArray(result, offset);
|
|
|
|
- return this;
|
|
|
|
- }
|
|
|
|
- if ((other as Matrix)._isIdentity) {
|
|
|
|
- this.copyToArray(result, offset);
|
|
|
|
- return this;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
const m = this._m;
|
|
const m = this._m;
|
|
const otherM = other.m;
|
|
const otherM = other.m;
|
|
var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
|
|
var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
|
|
@@ -4882,7 +4882,7 @@ module BABYLON {
|
|
* @returns a new matrix sets to the extracted rotation matrix from the current one
|
|
* @returns a new matrix sets to the extracted rotation matrix from the current one
|
|
*/
|
|
*/
|
|
public getRotationMatrix(): Matrix {
|
|
public getRotationMatrix(): Matrix {
|
|
- var result = Matrix.Identity();
|
|
|
|
|
|
+ var result = new Matrix();
|
|
this.getRotationMatrixToRef(result);
|
|
this.getRotationMatrixToRef(result);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -4948,6 +4948,7 @@ module BABYLON {
|
|
Matrix.FromArrayToRef(array, offset, result);
|
|
Matrix.FromArrayToRef(array, offset, result);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Copy the content of an array into a given matrix
|
|
* Copy the content of an array into a given matrix
|
|
* @param array defines the source array
|
|
* @param array defines the source array
|
|
@@ -5059,7 +5060,7 @@ module BABYLON {
|
|
* @returns a new matrix
|
|
* @returns a new matrix
|
|
*/
|
|
*/
|
|
public static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix {
|
|
public static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix {
|
|
- var result = Matrix.Identity();
|
|
|
|
|
|
+ var result = new Matrix();
|
|
Matrix.ComposeToRef(scale, rotation, translation, result);
|
|
Matrix.ComposeToRef(scale, rotation, translation, result);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -5333,7 +5334,7 @@ module BABYLON {
|
|
* @returns the new matrix
|
|
* @returns the new matrix
|
|
*/
|
|
*/
|
|
public static Translation(x: number, y: number, z: number): Matrix {
|
|
public static Translation(x: number, y: number, z: number): Matrix {
|
|
- var result = Matrix.Identity();
|
|
|
|
|
|
+ var result = new Matrix();
|
|
Matrix.TranslationToRef(x, y, z, result);
|
|
Matrix.TranslationToRef(x, y, z, result);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -5811,16 +5812,17 @@ module BABYLON {
|
|
var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
|
|
var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
|
|
var xScale = 2.0 / (leftTan + rightTan);
|
|
var xScale = 2.0 / (leftTan + rightTan);
|
|
var yScale = 2.0 / (upTan + downTan);
|
|
var yScale = 2.0 / (upTan + downTan);
|
|
- result._m[0] = xScale;
|
|
|
|
- result._m[1] = result._m[2] = result._m[3] = result._m[4] = 0.0;
|
|
|
|
- result._m[5] = yScale;
|
|
|
|
- result._m[6] = result._m[7] = 0.0;
|
|
|
|
- result._m[8] = ((leftTan - rightTan) * xScale * 0.5);
|
|
|
|
- result._m[9] = -((upTan - downTan) * yScale * 0.5);
|
|
|
|
- result._m[10] = -zfar / (znear - zfar);
|
|
|
|
- result._m[11] = 1.0 * rightHandedFactor;
|
|
|
|
- result._m[12] = result._m[13] = result._m[15] = 0.0;
|
|
|
|
- result._m[14] = -(2.0 * zfar * znear) / (zfar - znear);
|
|
|
|
|
|
+ const m = result._m;
|
|
|
|
+ m[0] = xScale;
|
|
|
|
+ m[1] = m[2] = m[3] = m[4] = 0.0;
|
|
|
|
+ m[5] = yScale;
|
|
|
|
+ m[6] = m[7] = 0.0;
|
|
|
|
+ m[8] = ((leftTan - rightTan) * xScale * 0.5);
|
|
|
|
+ m[9] = -((upTan - downTan) * yScale * 0.5);
|
|
|
|
+ m[10] = -zfar / (znear - zfar);
|
|
|
|
+ m[11] = 1.0 * rightHandedFactor;
|
|
|
|
+ m[12] = m[13] = m[15] = 0.0;
|
|
|
|
+ m[14] = -(2.0 * zfar * znear) / (zfar - znear);
|
|
|
|
|
|
result._markAsUpdated();
|
|
result._markAsUpdated();
|
|
}
|
|
}
|
|
@@ -5841,14 +5843,16 @@ module BABYLON {
|
|
var cx = viewport.x;
|
|
var cx = viewport.x;
|
|
var cy = viewport.y;
|
|
var cy = viewport.y;
|
|
|
|
|
|
- var viewportMatrix = Matrix.FromValues(cw / 2.0, 0.0, 0.0, 0.0,
|
|
|
|
- 0.0, -ch / 2.0, 0.0, 0.0,
|
|
|
|
- 0.0, 0.0, zmax - zmin, 0.0,
|
|
|
|
- cx + cw / 2.0, ch / 2.0 + cy, zmin, 1);
|
|
|
|
|
|
+ var viewportMatrix = Matrix.FromValues(
|
|
|
|
+ cw / 2.0, 0.0, 0.0, 0.0,
|
|
|
|
+ 0.0, -ch / 2.0, 0.0, 0.0,
|
|
|
|
+ 0.0, 0.0, zmax - zmin, 0.0,
|
|
|
|
+ cx + cw / 2.0, ch / 2.0 + cy, zmin, 1.0);
|
|
|
|
|
|
- world.multiplyToRef(view, MathTmp.Matrix[0]);
|
|
|
|
- MathTmp.Matrix[0].multiplyToRef(projection, MathTmp.Matrix[1]);
|
|
|
|
- return MathTmp.Matrix[1].multiply(viewportMatrix);
|
|
|
|
|
|
+ var matrix = MathTmp.Matrix[0];
|
|
|
|
+ world.multiplyToRef(view, matrix);
|
|
|
|
+ matrix.multiplyToRef(projection, matrix);
|
|
|
|
+ return matrix.multiply(viewportMatrix);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|