|
@@ -3552,6 +3552,8 @@ export class Quaternion {
|
|
|
* Class used to store matrix data (4x4)
|
|
|
*/
|
|
|
export class Matrix {
|
|
|
+ public static Use64Bits = true;
|
|
|
+
|
|
|
private static _updateFlagSeed = 0;
|
|
|
private static _identityReadOnly = Matrix.Identity() as DeepImmutable<Matrix>;
|
|
|
|
|
@@ -3566,12 +3568,12 @@ export class Matrix {
|
|
|
*/
|
|
|
public updateFlag: number = -1;
|
|
|
|
|
|
- private readonly _m: Float32Array = new Float32Array(16);
|
|
|
+ private readonly _m: Float32Array | Array<number>;
|
|
|
|
|
|
/**
|
|
|
* Gets the internal data of the matrix
|
|
|
*/
|
|
|
- public get m(): DeepImmutable<Float32Array> { return this._m; }
|
|
|
+ public get m(): DeepImmutable<Float32Array | Array<number>> { return this._m; }
|
|
|
|
|
|
/** @hidden */
|
|
|
public _markAsUpdated() {
|
|
@@ -3595,6 +3597,7 @@ export class Matrix {
|
|
|
* Creates an empty matrix (filled with zeros)
|
|
|
*/
|
|
|
public constructor() {
|
|
|
+ this._m = Matrix.Use64Bits ? new Array(16) : new Float32Array(16);
|
|
|
this._updateIdentityStatus(false);
|
|
|
}
|
|
|
|
|
@@ -3684,14 +3687,14 @@ export class Matrix {
|
|
|
* Returns the matrix as a Float32Array
|
|
|
* @returns the matrix underlying array
|
|
|
*/
|
|
|
- public toArray(): DeepImmutable<Float32Array> {
|
|
|
+ public toArray(): DeepImmutable<Float32Array | Array<number>> {
|
|
|
return this._m;
|
|
|
}
|
|
|
/**
|
|
|
* Returns the matrix as a Float32Array
|
|
|
* @returns the matrix underlying array.
|
|
|
*/
|
|
|
- public asArray(): DeepImmutable<Float32Array> {
|
|
|
+ public asArray(): DeepImmutable<Float32Array | Array<number>> {
|
|
|
return this._m;
|
|
|
}
|
|
|
|
|
@@ -3969,7 +3972,7 @@ export class Matrix {
|
|
|
* @param offset defines the offset in the target array where to start storing values
|
|
|
* @returns the current matrix
|
|
|
*/
|
|
|
- public copyToArray(array: Float32Array, offset: number = 0): Matrix {
|
|
|
+ public copyToArray(array: Float32Array | Array<number>, offset: number = 0): Matrix {
|
|
|
let source = this._m;
|
|
|
array[offset] = source[0];
|
|
|
array[offset + 1] = source[1];
|
|
@@ -4019,7 +4022,7 @@ export class Matrix {
|
|
|
* @param offset defines the offset in the target array where to start storing values
|
|
|
* @returns the current matrix
|
|
|
*/
|
|
|
- public multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix {
|
|
|
+ public multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix {
|
|
|
const m = this._m;
|
|
|
const otherM = other.m;
|
|
|
var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
|
|
@@ -4382,7 +4385,7 @@ export class Matrix {
|
|
|
* @param scale defines the scaling factor
|
|
|
* @param result defines the target matrix
|
|
|
*/
|
|
|
- public static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix) {
|
|
|
+ public static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix) {
|
|
|
for (var index = 0; index < 16; index++) {
|
|
|
result._m[index] = array[index + offset] * scale;
|
|
|
}
|
|
@@ -5378,7 +5381,7 @@ export class Matrix {
|
|
|
* @param matrix defines the matrix to use
|
|
|
* @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
|
|
|
*/
|
|
|
- public static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array {
|
|
|
+ public static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number> {
|
|
|
const m = matrix.m;
|
|
|
return new Float32Array([m[0], m[1], m[4], m[5]]);
|
|
|
}
|
|
@@ -5387,7 +5390,7 @@ export class Matrix {
|
|
|
* @param matrix defines the matrix to use
|
|
|
* @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
|
|
|
*/
|
|
|
- public static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array {
|
|
|
+ public static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number> {
|
|
|
const m = matrix.m;
|
|
|
return new Float32Array([
|
|
|
m[0], m[1], m[2],
|