-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathMatrixInterface.js
More file actions
54 lines (53 loc) · 1.27 KB
/
MatrixInterface.js
File metadata and controls
54 lines (53 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
export let GLMAT_ARRAY_TYPE = Array;
export let isMatrixArray = x => Array.isArray(x);
if (typeof Float32Array !== 'undefined') {
GLMAT_ARRAY_TYPE = Float32Array;
isMatrixArray = x => Array.isArray(x) || x instanceof Float32Array;
}
export class MatrixInterface {
// Private field to store the matrix
#matrix = null;
constructor(...args) {
if (this.constructor === MatrixInterface) {
throw new Error("Class is of abstract type and can't be instantiated");
}
// TODO: don't check this at runtime but still at compile time
/*const methods = [
'add',
'setElement',
'reset',
'set',
'get',
'copy',
'clone',
'diagonal',
'row',
'column',
'transpose',
'mult',
'multiplyVec',
'invert',
'createSubMatrix3x3',
'inverseTranspose4x4',
'apply',
'scale',
'rotate4x4',
'translate',
'rotateX',
'rotateY',
'rotateZ',
'perspective',
'ortho',
'multiplyVec4',
'multiplyPoint',
'multiplyAndNormalizePoint',
'multiplyDirection',
'multiplyVec3'
];
methods.forEach(method => {
if (this[method] === undefined) {
throw new Error(`${method}() method must be implemented`);
}
});*/
}
}