@@ -20,23 +20,24 @@ function check(mat4, Type) {
20
20
12 , 13 , 14 , 15 ,
21
21
] ;
22
22
23
+ function createCopyOfType ( v ) {
24
+ return Type === Array ? new Type ( ...v ) : new Type ( v ) ;
25
+ }
26
+
23
27
function testMat4WithoutDest ( func , expected , ...args ) {
24
28
const d = func ( ...args ) ;
25
29
assertEqualApproximately ( d , expected ) ;
26
30
}
27
31
28
32
function testMat4WithDest ( func , expected , ...args ) {
29
- expected = new Float32Array ( expected ) ;
30
- const d = new Float32Array ( 16 ) ;
33
+ expected = createCopyOfType ( expected ) ;
34
+ const d = new Type ( 16 ) . fill ( 0 ) ;
31
35
const c = func ( ...args , d ) ;
32
36
assertStrictEqual ( c , d ) ;
33
37
assertEqualApproximately ( c , expected ) ;
34
38
}
35
39
36
40
function testMat4WithAndWithoutDest ( func , expected , ...args ) {
37
- if ( mat4 . identity ( ) instanceof Float32Array ) {
38
- //expected = new Float32Array(expected);
39
- }
40
41
testMat4WithoutDest ( func , expected , ...args ) ;
41
42
testMat4WithDest ( func , expected , ...args ) ;
42
43
}
@@ -47,14 +48,14 @@ function check(mat4, Type) {
47
48
}
48
49
49
50
function testVec3WithDest ( func , expected ) {
50
- const d = new Float32Array ( 3 ) ;
51
+ const d = new Type ( 3 ) . fill ( 0 ) ;
51
52
const c = func ( d ) ;
52
53
assertStrictEqual ( c , d ) ;
53
54
assertEqualApproximately ( c , expected , 2e7 ) ;
54
55
}
55
56
56
57
function testVec3WithAndWithoutDest ( func , expected ) {
57
- expected = new Float32Array ( expected ) ;
58
+ expected = createCopyOfType ( expected ) ;
58
59
testVec3WithoutDest ( func , expected ) ;
59
60
testVec3WithDest ( func , expected ) ;
60
61
}
@@ -361,7 +362,7 @@ function check(mat4, Type) {
361
362
Math . sqrt ( 1 * 1 + 2 * 2 + 3 * 3 ) ,
362
363
Math . sqrt ( 5 * 5 + 6 * 6 + 7 * 7 ) ,
363
364
Math . sqrt ( 9 * 9 + 10 * 10 + 11 * 11 ) ,
364
- ] . map ( v => new Type ( [ v ] ) [ 0 ] ) ;
365
+ ] ;
365
366
testVec3WithAndWithoutDest ( ( newDst ) => {
366
367
return mat4 . getScaling ( m , newDst ) ;
367
368
} , expected ) ;
0 commit comments