|
@@ -18,9 +18,9 @@ function matrixEquals4( a, b, tolerance ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- for ( var i = 0, il = a.elements.length; i < il; i ++ ) {
|
|
|
|
|
|
+ for ( let i = 0, il = a.elements.length; i < il; i ++ ) {
|
|
|
|
|
|
- var delta = a.elements[ i ] - b.elements[ i ];
|
|
|
|
|
|
+ const delta = a.elements[ i ] - b.elements[ i ];
|
|
if ( delta > tolerance ) {
|
|
if ( delta > tolerance ) {
|
|
|
|
|
|
return false;
|
|
return false;
|
|
@@ -37,7 +37,7 @@ function matrixEquals4( a, b, tolerance ) {
|
|
function eulerEquals( a, b, tolerance ) {
|
|
function eulerEquals( a, b, tolerance ) {
|
|
|
|
|
|
tolerance = tolerance || 0.0001;
|
|
tolerance = tolerance || 0.0001;
|
|
- var diff = Math.abs( a.x - b.x ) + Math.abs( a.y - b.y ) + Math.abs( a.z - b.z );
|
|
|
|
|
|
+ const diff = Math.abs( a.x - b.x ) + Math.abs( a.y - b.y ) + Math.abs( a.z - b.z );
|
|
return ( diff < tolerance );
|
|
return ( diff < tolerance );
|
|
|
|
|
|
}
|
|
}
|
|
@@ -49,10 +49,10 @@ export default QUnit.module( 'Maths', () => {
|
|
// INSTANCING
|
|
// INSTANCING
|
|
QUnit.test( 'Instancing', ( assert ) => {
|
|
QUnit.test( 'Instancing', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
assert.ok( a.determinant() == 1, 'Passed!' );
|
|
assert.ok( a.determinant() == 1, 'Passed!' );
|
|
|
|
|
|
- var b = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
|
|
+ const b = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
assert.ok( b.elements[ 0 ] == 0 );
|
|
assert.ok( b.elements[ 0 ] == 0 );
|
|
assert.ok( b.elements[ 1 ] == 4 );
|
|
assert.ok( b.elements[ 1 ] == 4 );
|
|
assert.ok( b.elements[ 2 ] == 8 );
|
|
assert.ok( b.elements[ 2 ] == 8 );
|
|
@@ -77,17 +77,17 @@ export default QUnit.module( 'Maths', () => {
|
|
// PUBLIC STUFF
|
|
// PUBLIC STUFF
|
|
QUnit.test( 'isMatrix4', ( assert ) => {
|
|
QUnit.test( 'isMatrix4', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
assert.ok( a.isMatrix4 === true, 'Passed!' );
|
|
assert.ok( a.isMatrix4 === true, 'Passed!' );
|
|
|
|
|
|
- var b = new Vector3();
|
|
|
|
|
|
+ const b = new Vector3();
|
|
assert.ok( ! b.isMatrix4, 'Passed!' );
|
|
assert.ok( ! b.isMatrix4, 'Passed!' );
|
|
|
|
|
|
} );
|
|
} );
|
|
|
|
|
|
QUnit.test( 'set', ( assert ) => {
|
|
QUnit.test( 'set', ( assert ) => {
|
|
|
|
|
|
- var b = new Matrix4();
|
|
|
|
|
|
+ const b = new Matrix4();
|
|
assert.ok( b.determinant() == 1, 'Passed!' );
|
|
assert.ok( b.determinant() == 1, 'Passed!' );
|
|
|
|
|
|
b.set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
b.set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
@@ -112,7 +112,7 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'identity', ( assert ) => {
|
|
QUnit.test( 'identity', ( assert ) => {
|
|
|
|
|
|
- var b = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
|
|
+ const b = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
assert.ok( b.elements[ 0 ] == 0 );
|
|
assert.ok( b.elements[ 0 ] == 0 );
|
|
assert.ok( b.elements[ 1 ] == 4 );
|
|
assert.ok( b.elements[ 1 ] == 4 );
|
|
assert.ok( b.elements[ 2 ] == 8 );
|
|
assert.ok( b.elements[ 2 ] == 8 );
|
|
@@ -130,7 +130,7 @@ export default QUnit.module( 'Maths', () => {
|
|
assert.ok( b.elements[ 14 ] == 11 );
|
|
assert.ok( b.elements[ 14 ] == 11 );
|
|
assert.ok( b.elements[ 15 ] == 15 );
|
|
assert.ok( b.elements[ 15 ] == 15 );
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
assert.ok( ! matrixEquals4( a, b ), 'Passed!' );
|
|
assert.ok( ! matrixEquals4( a, b ), 'Passed!' );
|
|
|
|
|
|
b.identity();
|
|
b.identity();
|
|
@@ -140,8 +140,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'clone', ( assert ) => {
|
|
QUnit.test( 'clone', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
- var b = a.clone();
|
|
|
|
|
|
+ const a = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
+ const b = a.clone();
|
|
|
|
|
|
assert.ok( matrixEquals4( a, b ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, b ), 'Passed!' );
|
|
|
|
|
|
@@ -153,8 +153,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'copy', ( assert ) => {
|
|
QUnit.test( 'copy', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
- var b = new Matrix4().copy( a );
|
|
|
|
|
|
+ const a = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
+ const b = new Matrix4().copy( a );
|
|
|
|
|
|
assert.ok( matrixEquals4( a, b ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, b ), 'Passed!' );
|
|
|
|
|
|
@@ -166,13 +166,13 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'setFromMatrix3', ( assert ) => {
|
|
QUnit.test( 'setFromMatrix3', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix3().set(
|
|
|
|
|
|
+ const a = new Matrix3().set(
|
|
0, 1, 2,
|
|
0, 1, 2,
|
|
3, 4, 5,
|
|
3, 4, 5,
|
|
6, 7, 8
|
|
6, 7, 8
|
|
);
|
|
);
|
|
- var b = new Matrix4();
|
|
|
|
- var c = new Matrix4().set(
|
|
|
|
|
|
+ const b = new Matrix4();
|
|
|
|
+ const c = new Matrix4().set(
|
|
0, 1, 2, 0,
|
|
0, 1, 2, 0,
|
|
3, 4, 5, 0,
|
|
3, 4, 5, 0,
|
|
6, 7, 8, 0,
|
|
6, 7, 8, 0,
|
|
@@ -185,8 +185,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'copyPosition', ( assert ) => {
|
|
QUnit.test( 'copyPosition', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4().set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
- var b = new Matrix4().set( 1, 2, 3, 0, 5, 6, 7, 0, 9, 10, 11, 0, 13, 14, 15, 16 );
|
|
|
|
|
|
+ const a = new Matrix4().set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
+ const b = new Matrix4().set( 1, 2, 3, 0, 5, 6, 7, 0, 9, 10, 11, 0, 13, 14, 15, 16 );
|
|
|
|
|
|
assert.notOk( matrixEquals4( a, b ), 'a and b initially not equal' );
|
|
assert.notOk( matrixEquals4( a, b ), 'a and b initially not equal' );
|
|
|
|
|
|
@@ -197,27 +197,27 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'makeBasis/extractBasis', ( assert ) => {
|
|
QUnit.test( 'makeBasis/extractBasis', ( assert ) => {
|
|
|
|
|
|
- var identityBasis = [ new Vector3( 1, 0, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ) ];
|
|
|
|
- var a = new Matrix4().makeBasis( identityBasis[ 0 ], identityBasis[ 1 ], identityBasis[ 2 ] );
|
|
|
|
- var identity = new Matrix4();
|
|
|
|
|
|
+ const identityBasis = [ new Vector3( 1, 0, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ) ];
|
|
|
|
+ const a = new Matrix4().makeBasis( identityBasis[ 0 ], identityBasis[ 1 ], identityBasis[ 2 ] );
|
|
|
|
+ const identity = new Matrix4();
|
|
assert.ok( matrixEquals4( a, identity ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, identity ), 'Passed!' );
|
|
|
|
|
|
- var testBases = [[ new Vector3( 0, 1, 0 ), new Vector3( - 1, 0, 0 ), new Vector3( 0, 0, 1 ) ]];
|
|
|
|
- for ( var i = 0; i < testBases.length; i ++ ) {
|
|
|
|
|
|
+ const testBases = [[ new Vector3( 0, 1, 0 ), new Vector3( - 1, 0, 0 ), new Vector3( 0, 0, 1 ) ]];
|
|
|
|
+ for ( let i = 0; i < testBases.length; i ++ ) {
|
|
|
|
|
|
- var testBasis = testBases[ i ];
|
|
|
|
- var b = new Matrix4().makeBasis( testBasis[ 0 ], testBasis[ 1 ], testBasis[ 2 ] );
|
|
|
|
- var outBasis = [ new Vector3(), new Vector3(), new Vector3() ];
|
|
|
|
|
|
+ const testBasis = testBases[ i ];
|
|
|
|
+ const b = new Matrix4().makeBasis( testBasis[ 0 ], testBasis[ 1 ], testBasis[ 2 ] );
|
|
|
|
+ const outBasis = [ new Vector3(), new Vector3(), new Vector3() ];
|
|
b.extractBasis( outBasis[ 0 ], outBasis[ 1 ], outBasis[ 2 ] );
|
|
b.extractBasis( outBasis[ 0 ], outBasis[ 1 ], outBasis[ 2 ] );
|
|
// check what goes in, is what comes out.
|
|
// check what goes in, is what comes out.
|
|
- for ( var j = 0; j < outBasis.length; j ++ ) {
|
|
|
|
|
|
+ for ( let j = 0; j < outBasis.length; j ++ ) {
|
|
|
|
|
|
assert.ok( outBasis[ j ].equals( testBasis[ j ] ), 'Passed!' );
|
|
assert.ok( outBasis[ j ].equals( testBasis[ j ] ), 'Passed!' );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// get the basis out the hard war
|
|
// get the basis out the hard war
|
|
- for ( var j = 0; j < identityBasis.length; j ++ ) {
|
|
|
|
|
|
+ for ( let j = 0; j < identityBasis.length; j ++ ) {
|
|
|
|
|
|
outBasis[ j ].copy( identityBasis[ j ] );
|
|
outBasis[ j ].copy( identityBasis[ j ] );
|
|
outBasis[ j ].applyMatrix4( b );
|
|
outBasis[ j ].applyMatrix4( b );
|
|
@@ -225,7 +225,7 @@ export default QUnit.module( 'Maths', () => {
|
|
}
|
|
}
|
|
|
|
|
|
// did the multiply method of basis extraction work?
|
|
// did the multiply method of basis extraction work?
|
|
- for ( var j = 0; j < outBasis.length; j ++ ) {
|
|
|
|
|
|
+ for ( let j = 0; j < outBasis.length; j ++ ) {
|
|
|
|
|
|
assert.ok( outBasis[ j ].equals( testBasis[ j ] ), 'Passed!' );
|
|
assert.ok( outBasis[ j ].equals( testBasis[ j ] ), 'Passed!' );
|
|
|
|
|
|
@@ -237,7 +237,7 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'makeRotationFromEuler/extractRotation', ( assert ) => {
|
|
QUnit.test( 'makeRotationFromEuler/extractRotation', ( assert ) => {
|
|
|
|
|
|
- var testValues = [
|
|
|
|
|
|
+ const testValues = [
|
|
new Euler( 0, 0, 0, 'XYZ' ),
|
|
new Euler( 0, 0, 0, 'XYZ' ),
|
|
new Euler( 1, 0, 0, 'XYZ' ),
|
|
new Euler( 1, 0, 0, 'XYZ' ),
|
|
new Euler( 0, 1, 0, 'ZYX' ),
|
|
new Euler( 0, 1, 0, 'ZYX' ),
|
|
@@ -245,20 +245,20 @@ export default QUnit.module( 'Maths', () => {
|
|
new Euler( 0, 0, - 0.5, 'YZX' )
|
|
new Euler( 0, 0, - 0.5, 'YZX' )
|
|
];
|
|
];
|
|
|
|
|
|
- for ( var i = 0; i < testValues.length; i ++ ) {
|
|
|
|
|
|
+ for ( let i = 0; i < testValues.length; i ++ ) {
|
|
|
|
|
|
- var v = testValues[ i ];
|
|
|
|
|
|
+ const v = testValues[ i ];
|
|
|
|
|
|
- var m = new Matrix4().makeRotationFromEuler( v );
|
|
|
|
|
|
+ const m = new Matrix4().makeRotationFromEuler( v );
|
|
|
|
|
|
- var v2 = new Euler().setFromRotationMatrix( m, v.order );
|
|
|
|
- var m2 = new Matrix4().makeRotationFromEuler( v2 );
|
|
|
|
|
|
+ const v2 = new Euler().setFromRotationMatrix( m, v.order );
|
|
|
|
+ const m2 = new Matrix4().makeRotationFromEuler( v2 );
|
|
|
|
|
|
assert.ok( matrixEquals4( m, m2, eps ), 'makeRotationFromEuler #' + i + ': original and Euler-derived matrices are equal' );
|
|
assert.ok( matrixEquals4( m, m2, eps ), 'makeRotationFromEuler #' + i + ': original and Euler-derived matrices are equal' );
|
|
assert.ok( eulerEquals( v, v2, eps ), 'makeRotationFromEuler #' + i + ': original and matrix-derived Eulers are equal' );
|
|
assert.ok( eulerEquals( v, v2, eps ), 'makeRotationFromEuler #' + i + ': original and matrix-derived Eulers are equal' );
|
|
|
|
|
|
- var m3 = new Matrix4().extractRotation( m2 );
|
|
|
|
- var v3 = new Euler().setFromRotationMatrix( m3, v.order );
|
|
|
|
|
|
+ const m3 = new Matrix4().extractRotation( m2 );
|
|
|
|
+ const v3 = new Euler().setFromRotationMatrix( m3, v.order );
|
|
|
|
|
|
assert.ok( matrixEquals4( m, m3, eps ), 'extractRotation #' + i + ': original and extracted matrices are equal' );
|
|
assert.ok( matrixEquals4( m, m3, eps ), 'extractRotation #' + i + ': original and extracted matrices are equal' );
|
|
assert.ok( eulerEquals( v, v3, eps ), 'extractRotation #' + i + ': original and extracted Eulers are equal' );
|
|
assert.ok( eulerEquals( v, v3, eps ), 'extractRotation #' + i + ': original and extracted Eulers are equal' );
|
|
@@ -276,14 +276,14 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'lookAt', ( assert ) => {
|
|
QUnit.test( 'lookAt', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
- var expected = new Matrix4().identity();
|
|
|
|
- var eye = new Vector3( 0, 0, 0 );
|
|
|
|
- var target = new Vector3( 0, 1, - 1 );
|
|
|
|
- var up = new Vector3( 0, 1, 0 );
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
|
|
+ const expected = new Matrix4().identity();
|
|
|
|
+ const eye = new Vector3( 0, 0, 0 );
|
|
|
|
+ const target = new Vector3( 0, 1, - 1 );
|
|
|
|
+ const up = new Vector3( 0, 1, 0 );
|
|
|
|
|
|
a.lookAt( eye, target, up );
|
|
a.lookAt( eye, target, up );
|
|
- var rotation = new Euler().setFromRotationMatrix( a );
|
|
|
|
|
|
+ const rotation = new Euler().setFromRotationMatrix( a );
|
|
assert.numEqual( rotation.x * ( 180 / Math.PI ), 45, 'Check the rotation' );
|
|
assert.numEqual( rotation.x * ( 180 / Math.PI ), 45, 'Check the rotation' );
|
|
|
|
|
|
// eye and target are in the same position
|
|
// eye and target are in the same position
|
|
@@ -307,8 +307,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'multiply', ( assert ) => {
|
|
QUnit.test( 'multiply', ( assert ) => {
|
|
|
|
|
|
- var lhs = new Matrix4().set( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 );
|
|
|
|
- var rhs = new Matrix4().set( 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131 );
|
|
|
|
|
|
+ const lhs = new Matrix4().set( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 );
|
|
|
|
+ const rhs = new Matrix4().set( 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131 );
|
|
|
|
|
|
lhs.multiply( rhs );
|
|
lhs.multiply( rhs );
|
|
|
|
|
|
@@ -333,8 +333,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'premultiply', ( assert ) => {
|
|
QUnit.test( 'premultiply', ( assert ) => {
|
|
|
|
|
|
- var lhs = new Matrix4().set( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 );
|
|
|
|
- var rhs = new Matrix4().set( 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131 );
|
|
|
|
|
|
+ const lhs = new Matrix4().set( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 );
|
|
|
|
+ const rhs = new Matrix4().set( 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131 );
|
|
|
|
|
|
rhs.premultiply( lhs );
|
|
rhs.premultiply( lhs );
|
|
|
|
|
|
@@ -376,9 +376,9 @@ export default QUnit.module( 'Maths', () => {
|
|
// [ 5318 5562 5980 6246]
|
|
// [ 5318 5562 5980 6246]
|
|
// [10514 11006 11840 12378]
|
|
// [10514 11006 11840 12378]
|
|
// [15894 16634 17888 18710]]
|
|
// [15894 16634 17888 18710]]
|
|
- var lhs = new Matrix4().set( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 );
|
|
|
|
- var rhs = new Matrix4().set( 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131 );
|
|
|
|
- var ans = new Matrix4();
|
|
|
|
|
|
+ const lhs = new Matrix4().set( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 );
|
|
|
|
+ const rhs = new Matrix4().set( 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131 );
|
|
|
|
+ const ans = new Matrix4();
|
|
|
|
|
|
ans.multiplyMatrices( lhs, rhs );
|
|
ans.multiplyMatrices( lhs, rhs );
|
|
|
|
|
|
@@ -403,7 +403,7 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'multiplyScalar', ( assert ) => {
|
|
QUnit.test( 'multiplyScalar', ( assert ) => {
|
|
|
|
|
|
- var b = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
|
|
+ const b = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
assert.ok( b.elements[ 0 ] == 0 );
|
|
assert.ok( b.elements[ 0 ] == 0 );
|
|
assert.ok( b.elements[ 1 ] == 4 );
|
|
assert.ok( b.elements[ 1 ] == 4 );
|
|
assert.ok( b.elements[ 2 ] == 8 );
|
|
assert.ok( b.elements[ 2 ] == 8 );
|
|
@@ -443,7 +443,7 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'determinant', ( assert ) => {
|
|
QUnit.test( 'determinant', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
assert.ok( a.determinant() == 1, 'Passed!' );
|
|
assert.ok( a.determinant() == 1, 'Passed!' );
|
|
|
|
|
|
a.elements[ 0 ] = 2;
|
|
a.elements[ 0 ] = 2;
|
|
@@ -460,12 +460,12 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'transpose', ( assert ) => {
|
|
QUnit.test( 'transpose', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
- var b = a.clone().transpose();
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
|
|
+ let b = a.clone().transpose();
|
|
assert.ok( matrixEquals4( a, b ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, b ), 'Passed!' );
|
|
|
|
|
|
- var b = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
- var c = b.clone().transpose();
|
|
|
|
|
|
+ b = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
+ const c = b.clone().transpose();
|
|
assert.ok( ! matrixEquals4( b, c ), 'Passed!' );
|
|
assert.ok( ! matrixEquals4( b, c ), 'Passed!' );
|
|
c.transpose();
|
|
c.transpose();
|
|
assert.ok( matrixEquals4( b, c ), 'Passed!' );
|
|
assert.ok( matrixEquals4( b, c ), 'Passed!' );
|
|
@@ -474,15 +474,15 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'setPosition', ( assert ) => {
|
|
QUnit.test( 'setPosition', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
- var b = new Vector3( - 1, - 2, - 3 );
|
|
|
|
- var c = new Matrix4().set( 0, 1, 2, - 1, 4, 5, 6, - 2, 8, 9, 10, - 3, 12, 13, 14, 15 );
|
|
|
|
|
|
+ const a = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
+ const b = new Vector3( - 1, - 2, - 3 );
|
|
|
|
+ const c = new Matrix4().set( 0, 1, 2, - 1, 4, 5, 6, - 2, 8, 9, 10, - 3, 12, 13, 14, 15 );
|
|
|
|
|
|
a.setPosition( b );
|
|
a.setPosition( b );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
|
|
|
|
- var d = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
- var e = new Matrix4().set( 0, 1, 2, - 1, 4, 5, 6, - 2, 8, 9, 10, - 3, 12, 13, 14, 15 );
|
|
|
|
|
|
+ const d = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
|
|
|
|
+ const e = new Matrix4().set( 0, 1, 2, - 1, 4, 5, 6, - 2, 8, 9, 10, - 3, 12, 13, 14, 15 );
|
|
|
|
|
|
d.setPosition( - 1, - 2, - 3 );
|
|
d.setPosition( - 1, - 2, - 3 );
|
|
assert.ok( matrixEquals4( d, e ), 'Passed!' );
|
|
assert.ok( matrixEquals4( d, e ), 'Passed!' );
|
|
@@ -491,17 +491,17 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'invert', ( assert ) => {
|
|
QUnit.test( 'invert', ( assert ) => {
|
|
|
|
|
|
- var zero = new Matrix4().set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
|
|
|
|
- var identity = new Matrix4();
|
|
|
|
|
|
+ const zero = new Matrix4().set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
|
|
|
|
+ const identity = new Matrix4();
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
- var b = new Matrix4().set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
|
|
+ const b = new Matrix4().set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
|
|
|
|
|
|
a.copy( b ).invert();
|
|
a.copy( b ).invert();
|
|
assert.ok( matrixEquals4( a, zero ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, zero ), 'Passed!' );
|
|
|
|
|
|
|
|
|
|
- var testMatrices = [
|
|
|
|
|
|
+ const testMatrices = [
|
|
new Matrix4().makeRotationX( 0.3 ),
|
|
new Matrix4().makeRotationX( 0.3 ),
|
|
new Matrix4().makeRotationX( - 0.3 ),
|
|
new Matrix4().makeRotationX( - 0.3 ),
|
|
new Matrix4().makeRotationY( 0.3 ),
|
|
new Matrix4().makeRotationY( 0.3 ),
|
|
@@ -515,12 +515,12 @@ export default QUnit.module( 'Maths', () => {
|
|
new Matrix4().makeTranslation( 1, 2, 3 )
|
|
new Matrix4().makeTranslation( 1, 2, 3 )
|
|
];
|
|
];
|
|
|
|
|
|
- for ( var i = 0, il = testMatrices.length; i < il; i ++ ) {
|
|
|
|
|
|
+ for ( let i = 0, il = testMatrices.length; i < il; i ++ ) {
|
|
|
|
|
|
- var m = testMatrices[ i ];
|
|
|
|
|
|
+ const m = testMatrices[ i ];
|
|
|
|
|
|
- var mInverse = new Matrix4().copy( m ).invert();
|
|
|
|
- var mSelfInverse = m.clone();
|
|
|
|
|
|
+ const mInverse = new Matrix4().copy( m ).invert();
|
|
|
|
+ const mSelfInverse = m.clone();
|
|
mSelfInverse.copy( mSelfInverse ).invert();
|
|
mSelfInverse.copy( mSelfInverse ).invert();
|
|
|
|
|
|
// self-inverse should the same as inverse
|
|
// self-inverse should the same as inverse
|
|
@@ -529,7 +529,7 @@ export default QUnit.module( 'Maths', () => {
|
|
// the determinant of the inverse should be the reciprocal
|
|
// the determinant of the inverse should be the reciprocal
|
|
assert.ok( Math.abs( m.determinant() * mInverse.determinant() - 1 ) < 0.0001, 'Passed!' );
|
|
assert.ok( Math.abs( m.determinant() * mInverse.determinant() - 1 ) < 0.0001, 'Passed!' );
|
|
|
|
|
|
- var mProduct = new Matrix4().multiplyMatrices( m, mInverse );
|
|
|
|
|
|
+ const mProduct = new Matrix4().multiplyMatrices( m, mInverse );
|
|
|
|
|
|
// the determinant of the identity matrix is 1
|
|
// the determinant of the identity matrix is 1
|
|
assert.ok( Math.abs( mProduct.determinant() - 1 ) < 0.0001, 'Passed!' );
|
|
assert.ok( Math.abs( mProduct.determinant() - 1 ) < 0.0001, 'Passed!' );
|
|
@@ -541,9 +541,9 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'scale', ( assert ) => {
|
|
QUnit.test( 'scale', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4().set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
- var b = new Vector3( 2, 3, 4 );
|
|
|
|
- var c = new Matrix4().set( 2, 6, 12, 4, 10, 18, 28, 8, 18, 30, 44, 12, 26, 42, 60, 16 );
|
|
|
|
|
|
+ const a = new Matrix4().set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
+ const b = new Vector3( 2, 3, 4 );
|
|
|
|
+ const c = new Matrix4().set( 2, 6, 12, 4, 10, 18, 28, 8, 18, 30, 44, 12, 26, 42, 60, 16 );
|
|
|
|
|
|
a.scale( b );
|
|
a.scale( b );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
@@ -552,8 +552,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'getMaxScaleOnAxis', ( assert ) => {
|
|
QUnit.test( 'getMaxScaleOnAxis', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4().set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
- var expected = Math.sqrt( 3 * 3 + 7 * 7 + 11 * 11 );
|
|
|
|
|
|
+ const a = new Matrix4().set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
+ const expected = Math.sqrt( 3 * 3 + 7 * 7 + 11 * 11 );
|
|
|
|
|
|
assert.ok( Math.abs( a.getMaxScaleOnAxis() - expected ) <= eps, 'Check result' );
|
|
assert.ok( Math.abs( a.getMaxScaleOnAxis() - expected ) <= eps, 'Check result' );
|
|
|
|
|
|
@@ -561,9 +561,9 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'makeTranslation', ( assert ) => {
|
|
QUnit.test( 'makeTranslation', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
- var b = new Vector3( 2, 3, 4 );
|
|
|
|
- var c = new Matrix4().set( 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 0, 0, 0, 1 );
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
|
|
+ const b = new Vector3( 2, 3, 4 );
|
|
|
|
+ const c = new Matrix4().set( 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 0, 0, 0, 1 );
|
|
|
|
|
|
a.makeTranslation( b.x, b.y, b.z );
|
|
a.makeTranslation( b.x, b.y, b.z );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
@@ -572,9 +572,9 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'makeRotationX', ( assert ) => {
|
|
QUnit.test( 'makeRotationX', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
- var b = Math.sqrt( 3 ) / 2;
|
|
|
|
- var c = new Matrix4().set( 1, 0, 0, 0, 0, b, - 0.5, 0, 0, 0.5, b, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
|
|
+ const b = Math.sqrt( 3 ) / 2;
|
|
|
|
+ const c = new Matrix4().set( 1, 0, 0, 0, 0, b, - 0.5, 0, 0, 0.5, b, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
a.makeRotationX( Math.PI / 6 );
|
|
a.makeRotationX( Math.PI / 6 );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
@@ -584,9 +584,9 @@ export default QUnit.module( 'Maths', () => {
|
|
QUnit.test( 'makeRotationY', ( assert ) => {
|
|
QUnit.test( 'makeRotationY', ( assert ) => {
|
|
|
|
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
- var b = Math.sqrt( 3 ) / 2;
|
|
|
|
- var c = new Matrix4().set( b, 0, 0.5, 0, 0, 1, 0, 0, - 0.5, 0, b, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
|
|
+ const b = Math.sqrt( 3 ) / 2;
|
|
|
|
+ const c = new Matrix4().set( b, 0, 0.5, 0, 0, 1, 0, 0, - 0.5, 0, b, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
a.makeRotationY( Math.PI / 6 );
|
|
a.makeRotationY( Math.PI / 6 );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
@@ -596,9 +596,9 @@ export default QUnit.module( 'Maths', () => {
|
|
QUnit.test( 'makeRotationZ', ( assert ) => {
|
|
QUnit.test( 'makeRotationZ', ( assert ) => {
|
|
|
|
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
- var b = Math.sqrt( 3 ) / 2;
|
|
|
|
- var c = new Matrix4().set( b, - 0.5, 0, 0, 0.5, b, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
|
|
+ const b = Math.sqrt( 3 ) / 2;
|
|
|
|
+ const c = new Matrix4().set( b, - 0.5, 0, 0, 0.5, b, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
a.makeRotationZ( Math.PI / 6 );
|
|
a.makeRotationZ( Math.PI / 6 );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
@@ -607,11 +607,11 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'makeRotationAxis', ( assert ) => {
|
|
QUnit.test( 'makeRotationAxis', ( assert ) => {
|
|
|
|
|
|
- var axis = new Vector3( 1.5, 0.0, 1.0 ).normalize();
|
|
|
|
- var radians = MathUtils.degToRad( 45 );
|
|
|
|
- var a = new Matrix4().makeRotationAxis( axis, radians );
|
|
|
|
|
|
+ const axis = new Vector3( 1.5, 0.0, 1.0 ).normalize();
|
|
|
|
+ const radians = MathUtils.degToRad( 45 );
|
|
|
|
+ const a = new Matrix4().makeRotationAxis( axis, radians );
|
|
|
|
|
|
- var expected = new Matrix4().set(
|
|
|
|
|
|
+ const expected = new Matrix4().set(
|
|
0.9098790095958609, - 0.39223227027636803, 0.13518148560620882, 0,
|
|
0.9098790095958609, - 0.39223227027636803, 0.13518148560620882, 0,
|
|
0.39223227027636803, 0.7071067811865476, - 0.588348405414552, 0,
|
|
0.39223227027636803, 0.7071067811865476, - 0.588348405414552, 0,
|
|
0.13518148560620882, 0.588348405414552, 0.7972277715906868, 0,
|
|
0.13518148560620882, 0.588348405414552, 0.7972277715906868, 0,
|
|
@@ -624,8 +624,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'makeScale', ( assert ) => {
|
|
QUnit.test( 'makeScale', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
- var c = new Matrix4().set( 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
|
|
+ const c = new Matrix4().set( 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
a.makeScale( 2, 3, 4 );
|
|
a.makeScale( 2, 3, 4 );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
@@ -634,8 +634,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'makeShear', ( assert ) => {
|
|
QUnit.test( 'makeShear', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
- var c = new Matrix4().set( 1, 3, 5, 0, 1, 1, 6, 0, 2, 4, 1, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
|
|
+ const c = new Matrix4().set( 1, 3, 5, 0, 1, 1, 6, 0, 2, 4, 1, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
a.makeShear( 1, 2, 3, 4, 5, 6 );
|
|
a.makeShear( 1, 2, 3, 4, 5, 6 );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
assert.ok( matrixEquals4( a, c ), 'Passed!' );
|
|
@@ -644,7 +644,7 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'compose/decompose', ( assert ) => {
|
|
QUnit.test( 'compose/decompose', ( assert ) => {
|
|
|
|
|
|
- var tValues = [
|
|
|
|
|
|
+ const tValues = [
|
|
new Vector3(),
|
|
new Vector3(),
|
|
new Vector3( 3, 0, 0 ),
|
|
new Vector3( 3, 0, 0 ),
|
|
new Vector3( 0, 4, 0 ),
|
|
new Vector3( 0, 4, 0 ),
|
|
@@ -656,7 +656,7 @@ export default QUnit.module( 'Maths', () => {
|
|
new Vector3( - 2, - 5, - 9 )
|
|
new Vector3( - 2, - 5, - 9 )
|
|
];
|
|
];
|
|
|
|
|
|
- var sValues = [
|
|
|
|
|
|
+ const sValues = [
|
|
new Vector3( 1, 1, 1 ),
|
|
new Vector3( 1, 1, 1 ),
|
|
new Vector3( 2, 2, 2 ),
|
|
new Vector3( 2, 2, 2 ),
|
|
new Vector3( 1, - 1, 1 ),
|
|
new Vector3( 1, - 1, 1 ),
|
|
@@ -668,35 +668,35 @@ export default QUnit.module( 'Maths', () => {
|
|
new Vector3( - 2, - 2, - 2 )
|
|
new Vector3( - 2, - 2, - 2 )
|
|
];
|
|
];
|
|
|
|
|
|
- var rValues = [
|
|
|
|
|
|
+ const rValues = [
|
|
new Quaternion(),
|
|
new Quaternion(),
|
|
new Quaternion().setFromEuler( new Euler( 1, 1, 0 ) ),
|
|
new Quaternion().setFromEuler( new Euler( 1, 1, 0 ) ),
|
|
new Quaternion().setFromEuler( new Euler( 1, - 1, 1 ) ),
|
|
new Quaternion().setFromEuler( new Euler( 1, - 1, 1 ) ),
|
|
new Quaternion( 0, 0.9238795292366128, 0, 0.38268342717215614 )
|
|
new Quaternion( 0, 0.9238795292366128, 0, 0.38268342717215614 )
|
|
];
|
|
];
|
|
|
|
|
|
- for ( var ti = 0; ti < tValues.length; ti ++ ) {
|
|
|
|
|
|
+ for ( let ti = 0; ti < tValues.length; ti ++ ) {
|
|
|
|
|
|
- for ( var si = 0; si < sValues.length; si ++ ) {
|
|
|
|
|
|
+ for ( let si = 0; si < sValues.length; si ++ ) {
|
|
|
|
|
|
- for ( var ri = 0; ri < rValues.length; ri ++ ) {
|
|
|
|
|
|
+ for ( let ri = 0; ri < rValues.length; ri ++ ) {
|
|
|
|
|
|
- var t = tValues[ ti ];
|
|
|
|
- var s = sValues[ si ];
|
|
|
|
- var r = rValues[ ri ];
|
|
|
|
|
|
+ const t = tValues[ ti ];
|
|
|
|
+ const s = sValues[ si ];
|
|
|
|
+ const r = rValues[ ri ];
|
|
|
|
|
|
- var m = new Matrix4().compose( t, r, s );
|
|
|
|
- var t2 = new Vector3();
|
|
|
|
- var r2 = new Quaternion();
|
|
|
|
- var s2 = new Vector3();
|
|
|
|
|
|
+ const m = new Matrix4().compose( t, r, s );
|
|
|
|
+ const t2 = new Vector3();
|
|
|
|
+ const r2 = new Quaternion();
|
|
|
|
+ const s2 = new Vector3();
|
|
|
|
|
|
m.decompose( t2, r2, s2 );
|
|
m.decompose( t2, r2, s2 );
|
|
|
|
|
|
- var m2 = new Matrix4().compose( t2, r2, s2 );
|
|
|
|
|
|
+ const m2 = new Matrix4().compose( t2, r2, s2 );
|
|
|
|
|
|
/*
|
|
/*
|
|
// debug code
|
|
// debug code
|
|
- var matrixIsSame = matrixEquals4( m, m2 );
|
|
|
|
|
|
+ const matrixIsSame = matrixEquals4( m, m2 );
|
|
if ( ! matrixIsSame ) {
|
|
if ( ! matrixIsSame ) {
|
|
|
|
|
|
console.log( t, s, r );
|
|
console.log( t, s, r );
|
|
@@ -718,8 +718,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'makePerspective', ( assert ) => {
|
|
QUnit.test( 'makePerspective', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4().makePerspective( - 1, 1, - 1, 1, 1, 100 );
|
|
|
|
- var expected = new Matrix4().set(
|
|
|
|
|
|
+ const a = new Matrix4().makePerspective( - 1, 1, - 1, 1, 1, 100 );
|
|
|
|
+ const expected = new Matrix4().set(
|
|
1, 0, 0, 0,
|
|
1, 0, 0, 0,
|
|
0, - 1, 0, 0,
|
|
0, - 1, 0, 0,
|
|
0, 0, - 101 / 99, - 200 / 99,
|
|
0, 0, - 101 / 99, - 200 / 99,
|
|
@@ -731,8 +731,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'makeOrthographic', ( assert ) => {
|
|
QUnit.test( 'makeOrthographic', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4().makeOrthographic( - 1, 1, - 1, 1, 1, 100 );
|
|
|
|
- var expected = new Matrix4().set(
|
|
|
|
|
|
+ const a = new Matrix4().makeOrthographic( - 1, 1, - 1, 1, 1, 100 );
|
|
|
|
+ const expected = new Matrix4().set(
|
|
1, 0, 0, 0,
|
|
1, 0, 0, 0,
|
|
0, - 1, 0, 0,
|
|
0, - 1, 0, 0,
|
|
0, 0, - 2 / 99, - 101 / 99,
|
|
0, 0, - 2 / 99, - 101 / 99,
|
|
@@ -745,8 +745,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'equals', ( assert ) => {
|
|
QUnit.test( 'equals', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
- var b = new Matrix4().set( 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
|
|
+ const a = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
+ const b = new Matrix4().set( 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
|
|
assert.notOk( a.equals( b ), 'Check that a does not equal b' );
|
|
assert.notOk( a.equals( b ), 'Check that a does not equal b' );
|
|
assert.notOk( b.equals( a ), 'Check that b does not equal a' );
|
|
assert.notOk( b.equals( a ), 'Check that b does not equal a' );
|
|
@@ -759,8 +759,8 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'fromArray', ( assert ) => {
|
|
QUnit.test( 'fromArray', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4();
|
|
|
|
- var b = new Matrix4().set( 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 );
|
|
|
|
|
|
+ const a = new Matrix4();
|
|
|
|
+ const b = new Matrix4().set( 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 );
|
|
|
|
|
|
a.fromArray( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] );
|
|
a.fromArray( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] );
|
|
assert.ok( a.equals( b ), 'Passed' );
|
|
assert.ok( a.equals( b ), 'Passed' );
|
|
@@ -769,18 +769,18 @@ export default QUnit.module( 'Maths', () => {
|
|
|
|
|
|
QUnit.test( 'toArray', ( assert ) => {
|
|
QUnit.test( 'toArray', ( assert ) => {
|
|
|
|
|
|
- var a = new Matrix4().set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
- var noOffset = [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ];
|
|
|
|
- var withOffset = [ undefined, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ];
|
|
|
|
|
|
+ const a = new Matrix4().set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
|
|
|
+ const noOffset = [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ];
|
|
|
|
+ const withOffset = [ undefined, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ];
|
|
|
|
|
|
- var array = a.toArray();
|
|
|
|
|
|
+ let array = a.toArray();
|
|
assert.deepEqual( array, noOffset, 'No array, no offset' );
|
|
assert.deepEqual( array, noOffset, 'No array, no offset' );
|
|
|
|
|
|
- var array = [];
|
|
|
|
|
|
+ array = [];
|
|
a.toArray( array );
|
|
a.toArray( array );
|
|
assert.deepEqual( array, noOffset, 'With array, no offset' );
|
|
assert.deepEqual( array, noOffset, 'With array, no offset' );
|
|
|
|
|
|
- var array = [];
|
|
|
|
|
|
+ array = [];
|
|
a.toArray( array, 1 );
|
|
a.toArray( array, 1 );
|
|
assert.deepEqual( array, withOffset, 'With array, with offset' );
|
|
assert.deepEqual( array, withOffset, 'With array, with offset' );
|
|
|
|
|