@math.gl/core 3.5.6 → 3.6.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/base/math-array.d.ts +66 -0
- package/dist/classes/base/math-array.d.ts.map +1 -0
- package/dist/classes/base/math-array.js +216 -0
- package/dist/classes/base/matrix.d.ts +14 -0
- package/dist/classes/base/matrix.d.ts.map +1 -0
- package/dist/classes/base/matrix.js +61 -0
- package/dist/classes/base/vector.d.ts +44 -0
- package/dist/classes/base/vector.d.ts.map +1 -0
- package/dist/classes/base/vector.js +126 -0
- package/dist/classes/euler.d.ts +77 -0
- package/dist/classes/euler.d.ts.map +1 -0
- package/dist/classes/euler.js +485 -0
- package/dist/classes/matrix3.d.ts +60 -0
- package/dist/classes/matrix3.d.ts.map +1 -0
- package/dist/classes/matrix3.js +201 -0
- package/dist/classes/matrix4.d.ts +226 -0
- package/dist/classes/matrix4.d.ts.map +1 -0
- package/dist/classes/matrix4.js +538 -0
- package/dist/classes/pose.d.ts +40 -0
- package/dist/classes/pose.d.ts.map +1 -0
- package/dist/classes/pose.js +109 -0
- package/dist/classes/quaternion.d.ts +63 -0
- package/dist/classes/quaternion.d.ts.map +1 -0
- package/dist/classes/quaternion.js +262 -0
- package/dist/classes/spherical-coordinates.d.ts +60 -0
- package/dist/classes/spherical-coordinates.d.ts.map +1 -0
- package/dist/classes/spherical-coordinates.js +148 -0
- package/dist/classes/vector2.d.ts +55 -0
- package/dist/classes/vector2.d.ts.map +1 -0
- package/dist/classes/vector2.js +111 -0
- package/dist/classes/vector3.d.ts +56 -0
- package/dist/classes/vector3.d.ts.map +1 -0
- package/dist/classes/vector3.js +133 -0
- package/dist/classes/vector4.d.ts +41 -0
- package/dist/classes/vector4.d.ts.map +1 -0
- package/dist/classes/vector4.js +114 -0
- package/dist/es5/classes/base/math-array.js +57 -61
- package/dist/es5/classes/base/math-array.js.map +1 -1
- package/dist/es5/classes/base/matrix.js +0 -14
- package/dist/es5/classes/base/matrix.js.map +1 -1
- package/dist/es5/classes/base/vector.js +0 -12
- package/dist/es5/classes/base/vector.js.map +1 -1
- package/dist/es5/classes/euler.js +63 -49
- package/dist/es5/classes/euler.js.map +1 -1
- package/dist/es5/classes/matrix3.js +60 -33
- package/dist/es5/classes/matrix3.js.map +1 -1
- package/dist/es5/classes/matrix4.js +167 -164
- package/dist/es5/classes/matrix4.js.map +1 -1
- package/dist/es5/classes/pose.js +7 -6
- package/dist/es5/classes/pose.js.map +1 -1
- package/dist/es5/classes/quaternion.js +44 -36
- package/dist/es5/classes/quaternion.js.map +1 -1
- package/dist/es5/classes/spherical-coordinates.js +12 -8
- package/dist/es5/classes/spherical-coordinates.js.map +1 -1
- package/dist/es5/classes/vector2.js.map +1 -1
- package/dist/es5/classes/vector3.js +7 -2
- package/dist/es5/classes/vector3.js.map +1 -1
- package/dist/es5/classes/vector4.js +7 -2
- package/dist/es5/classes/vector4.js.map +1 -1
- package/dist/es5/docs/README.md +0 -0
- package/dist/es5/index.js +71 -89
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/assert.js.map +1 -1
- package/dist/es5/lib/common.js +40 -43
- package/dist/es5/lib/common.js.map +1 -1
- package/dist/es5/lib/gl-matrix-extras.js.map +1 -1
- package/dist/es5/lib/gl-matrix.d.js +2 -0
- package/dist/es5/lib/gl-matrix.d.js.map +1 -0
- package/dist/es5/lib/math-utils.js.map +1 -1
- package/dist/es5/lib/validators.js.map +1 -1
- package/dist/esm/classes/base/math-array.js +45 -47
- package/dist/esm/classes/base/math-array.js.map +1 -1
- package/dist/esm/classes/base/matrix.js +0 -11
- package/dist/esm/classes/base/matrix.js.map +1 -1
- package/dist/esm/classes/base/vector.js +0 -10
- package/dist/esm/classes/base/vector.js.map +1 -1
- package/dist/esm/classes/euler.js +61 -48
- package/dist/esm/classes/euler.js.map +1 -1
- package/dist/esm/classes/matrix3.js +55 -33
- package/dist/esm/classes/matrix3.js.map +1 -1
- package/dist/esm/classes/matrix4.js +156 -136
- package/dist/esm/classes/matrix4.js.map +1 -1
- package/dist/esm/classes/pose.js +8 -4
- package/dist/esm/classes/pose.js.map +1 -1
- package/dist/esm/classes/quaternion.js +37 -27
- package/dist/esm/classes/quaternion.js.map +1 -1
- package/dist/esm/classes/spherical-coordinates.js +15 -5
- package/dist/esm/classes/spherical-coordinates.js.map +1 -1
- package/dist/esm/classes/vector2.js.map +1 -1
- package/dist/esm/classes/vector3.js +7 -2
- package/dist/esm/classes/vector3.js.map +1 -1
- package/dist/esm/classes/vector4.js +7 -2
- package/dist/esm/classes/vector4.js.map +1 -1
- package/dist/esm/docs/README.md +0 -0
- package/dist/esm/index.js +2 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/assert.js.map +1 -1
- package/dist/esm/lib/common.js +41 -44
- package/dist/esm/lib/common.js.map +1 -1
- package/dist/esm/lib/gl-matrix-extras.js.map +1 -1
- package/dist/esm/lib/gl-matrix.d.js +2 -0
- package/dist/esm/lib/gl-matrix.d.js.map +1 -0
- package/dist/esm/lib/math-utils.js.map +1 -1
- package/dist/esm/lib/validators.js.map +1 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/lib/assert.d.ts +2 -0
- package/dist/lib/assert.d.ts.map +1 -0
- package/dist/lib/assert.js +5 -0
- package/dist/lib/common.d.ts +93 -0
- package/dist/lib/common.d.ts.map +1 -0
- package/dist/lib/common.js +210 -0
- package/dist/lib/gl-matrix-extras.d.ts +7 -0
- package/dist/lib/gl-matrix-extras.d.ts.map +1 -0
- package/dist/lib/gl-matrix-extras.js +49 -0
- package/dist/lib/math-utils.d.ts +28 -0
- package/dist/lib/math-utils.d.ts.map +1 -0
- package/dist/lib/math-utils.js +28 -0
- package/dist/lib/validators.d.ts +6 -0
- package/dist/lib/validators.d.ts.map +1 -0
- package/dist/lib/validators.js +33 -0
- package/package.json +5 -4
- package/src/classes/base/math-array.ts +265 -0
- package/src/classes/base/{matrix.js → matrix.ts} +15 -19
- package/src/classes/base/{vector.js → vector.ts} +47 -54
- package/src/classes/{euler.js → euler.ts} +121 -221
- package/src/classes/matrix3.ts +253 -0
- package/src/classes/matrix4.ts +668 -0
- package/src/classes/{pose.js → pose.ts} +52 -49
- package/src/classes/{quaternion.js → quaternion.ts} +107 -95
- package/src/classes/{spherical-coordinates.js → spherical-coordinates.ts} +84 -54
- package/src/classes/vector2.ts +127 -0
- package/src/classes/{vector3.js → vector3.ts} +43 -55
- package/src/classes/{vector4.js → vector4.ts} +44 -48
- package/src/docs/README.md +0 -0
- package/{dist/esm/index.d.ts → src/index.ts} +32 -34
- package/src/lib/{assert.js → assert.ts} +1 -1
- package/src/lib/common.ts +304 -0
- package/src/lib/{gl-matrix-extras.js → gl-matrix-extras.ts} +26 -5
- package/src/lib/gl-matrix.d.ts +266 -0
- package/src/lib/{math-utils.js → math-utils.ts} +0 -0
- package/src/lib/{validators.js → validators.ts} +10 -6
- package/dist/es5/addons/polygon.d.ts +0 -17
- package/dist/es5/classes/base/math-array.d.ts +0 -56
- package/dist/es5/classes/base/matrix.d.ts +0 -15
- package/dist/es5/classes/base/vector.d.ts +0 -45
- package/dist/es5/classes/euler.d.ts +0 -92
- package/dist/es5/classes/matrix3.d.ts +0 -91
- package/dist/es5/classes/matrix4.d.ts +0 -161
- package/dist/es5/classes/pose.d.ts +0 -92
- package/dist/es5/classes/quaternion.d.ts +0 -107
- package/dist/es5/classes/spherical-coordinates.d.ts +0 -87
- package/dist/es5/classes/vector2.d.ts +0 -65
- package/dist/es5/classes/vector3.d.ts +0 -65
- package/dist/es5/classes/vector4.d.ts +0 -34
- package/dist/es5/index.d.ts +0 -54
- package/dist/es5/lib/common.d.ts +0 -80
- package/dist/esm/addons/polygon.d.ts +0 -17
- package/dist/esm/classes/base/math-array.d.ts +0 -56
- package/dist/esm/classes/base/matrix.d.ts +0 -15
- package/dist/esm/classes/base/vector.d.ts +0 -45
- package/dist/esm/classes/euler.d.ts +0 -92
- package/dist/esm/classes/matrix3.d.ts +0 -91
- package/dist/esm/classes/matrix4.d.ts +0 -161
- package/dist/esm/classes/pose.d.ts +0 -92
- package/dist/esm/classes/quaternion.d.ts +0 -107
- package/dist/esm/classes/spherical-coordinates.d.ts +0 -87
- package/dist/esm/classes/vector2.d.ts +0 -65
- package/dist/esm/classes/vector3.d.ts +0 -65
- package/dist/esm/classes/vector4.d.ts +0 -34
- package/dist/esm/lib/common.d.ts +0 -80
- package/src/addons/polygon.d.ts +0 -17
- package/src/classes/base/math-array.d.ts +0 -56
- package/src/classes/base/math-array.js +0 -250
- package/src/classes/base/matrix.d.ts +0 -15
- package/src/classes/base/vector.d.ts +0 -45
- package/src/classes/euler.d.ts +0 -92
- package/src/classes/matrix3.d.ts +0 -91
- package/src/classes/matrix3.js +0 -225
- package/src/classes/matrix4.d.ts +0 -161
- package/src/classes/matrix4.js +0 -530
- package/src/classes/pose.d.ts +0 -92
- package/src/classes/quaternion.d.ts +0 -107
- package/src/classes/spherical-coordinates.d.ts +0 -87
- package/src/classes/vector2.d.ts +0 -65
- package/src/classes/vector2.js +0 -122
- package/src/classes/vector3.d.ts +0 -65
- package/src/classes/vector4.d.ts +0 -34
- package/src/index.d.ts +0 -54
- package/src/index.js +0 -86
- package/src/lib/common.d.ts +0 -80
- package/src/lib/common.js +0 -222
package/src/classes/matrix4.d.ts
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import Matrix from './base/matrix';
|
|
2
|
-
// import Quaternion from './quaternion';
|
|
3
|
-
|
|
4
|
-
type Array16 = number[];
|
|
5
|
-
// = [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number];
|
|
6
|
-
|
|
7
|
-
export default class Matrix4 extends Matrix<Matrix4> {
|
|
8
|
-
static IDENTITY: number[];
|
|
9
|
-
static ZERO: number[];
|
|
10
|
-
|
|
11
|
-
INDICES: number[];
|
|
12
|
-
get ELEMENTS(): number;
|
|
13
|
-
get RANK(): number;
|
|
14
|
-
|
|
15
|
-
constructor();
|
|
16
|
-
constructor(array: Array16);
|
|
17
|
-
|
|
18
|
-
copy(array: Array16);
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line max-params
|
|
21
|
-
set(
|
|
22
|
-
m00: number,
|
|
23
|
-
m01: number,
|
|
24
|
-
m02: number,
|
|
25
|
-
m03: number,
|
|
26
|
-
m10: number,
|
|
27
|
-
m11: number,
|
|
28
|
-
m12: number,
|
|
29
|
-
m13: number,
|
|
30
|
-
m20: number,
|
|
31
|
-
m21: number,
|
|
32
|
-
m22: number,
|
|
33
|
-
m23: number,
|
|
34
|
-
m30: number,
|
|
35
|
-
m31: number,
|
|
36
|
-
m32: number,
|
|
37
|
-
m33: number
|
|
38
|
-
);
|
|
39
|
-
setRowMajor(
|
|
40
|
-
m00: number,
|
|
41
|
-
m01: number,
|
|
42
|
-
m02: number,
|
|
43
|
-
m03: number,
|
|
44
|
-
m10: number,
|
|
45
|
-
m11: number,
|
|
46
|
-
m12: number,
|
|
47
|
-
m13: number,
|
|
48
|
-
m20: number,
|
|
49
|
-
m21: number,
|
|
50
|
-
m22: number,
|
|
51
|
-
m23: number,
|
|
52
|
-
m30: number,
|
|
53
|
-
m31: number,
|
|
54
|
-
m32: number,
|
|
55
|
-
m33: number
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
toRowMajor(result: Array16);
|
|
59
|
-
|
|
60
|
-
identity(): Matrix4;
|
|
61
|
-
|
|
62
|
-
// Calculates a 4x4 matrix from the given quaternion
|
|
63
|
-
fromQuaternion(q: number[]): Matrix4;
|
|
64
|
-
|
|
65
|
-
// Generates a frustum matrix with the given bounds
|
|
66
|
-
frustum(args: {
|
|
67
|
-
left: number;
|
|
68
|
-
right: number;
|
|
69
|
-
bottom: number;
|
|
70
|
-
top: number;
|
|
71
|
-
near: number;
|
|
72
|
-
far: number;
|
|
73
|
-
}): Matrix4;
|
|
74
|
-
|
|
75
|
-
// Generates a look-at matrix with the given eye position, focal point, and up axis
|
|
76
|
-
lookAt(eye: number[], center?: number[], up?: number[]): Matrix4;
|
|
77
|
-
lookAt(args: {eye: number[]; center?: number[]; up?: number[]}): Matrix4;
|
|
78
|
-
|
|
79
|
-
// Generates a orthogonal projection matrix with the given bounds
|
|
80
|
-
ortho(args: {
|
|
81
|
-
left: number;
|
|
82
|
-
right: number;
|
|
83
|
-
bottom: number;
|
|
84
|
-
top: number;
|
|
85
|
-
near: number;
|
|
86
|
-
far: number;
|
|
87
|
-
}): Matrix4;
|
|
88
|
-
|
|
89
|
-
// Generates an orthogonal projection matrix with the same parameters
|
|
90
|
-
orthographic(args: {
|
|
91
|
-
fovy: number;
|
|
92
|
-
aspect?: number;
|
|
93
|
-
focalDistance?: number;
|
|
94
|
-
near?: number;
|
|
95
|
-
far?: number;
|
|
96
|
-
}): Matrix4;
|
|
97
|
-
|
|
98
|
-
// Generates a perspective projection matrix with the given bounds
|
|
99
|
-
perspective(args: {
|
|
100
|
-
fovy?: number;
|
|
101
|
-
fov?: number;
|
|
102
|
-
aspect?: number;
|
|
103
|
-
near?: number;
|
|
104
|
-
far?: number;
|
|
105
|
-
}): Matrix4;
|
|
106
|
-
|
|
107
|
-
// Accessors
|
|
108
|
-
|
|
109
|
-
determinant(): Matrix4;
|
|
110
|
-
|
|
111
|
-
// Decomposition
|
|
112
|
-
// Extracts the non-uniform scale assuming the matrix is an affine transformation.
|
|
113
|
-
// The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
|
|
114
|
-
getScale(): number[];
|
|
115
|
-
getScale<T extends number[]>(result: T): T;
|
|
116
|
-
// Gets the translation portion, assuming the matrix is a affine transformation matrix.
|
|
117
|
-
getTranslation(): number[];
|
|
118
|
-
getTranslation<T extends number[]>(result: T): T;
|
|
119
|
-
// Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
|
|
120
|
-
getRotation(): number[];
|
|
121
|
-
getRotation<T extends number[]>(result: T, scaleResult?: number[]): T;
|
|
122
|
-
getRotationMatrix3(): number[];
|
|
123
|
-
getRotationMatrix3<T extends number[]>(result: T, scaleResult?: number[]): T;
|
|
124
|
-
|
|
125
|
-
// Modifiers
|
|
126
|
-
transpose(): Matrix4;
|
|
127
|
-
invert(): Matrix4;
|
|
128
|
-
|
|
129
|
-
// Operations
|
|
130
|
-
multiplyLeft(a: number[]): Matrix4;
|
|
131
|
-
multiplyRight(a: number[]): Matrix4;
|
|
132
|
-
|
|
133
|
-
scale(factor): Matrix4;
|
|
134
|
-
translate(vec): Matrix4;
|
|
135
|
-
rotateX(radians: number): Matrix4;
|
|
136
|
-
rotateY(radians: number): Matrix4;
|
|
137
|
-
rotateZ(radians: number): Matrix4;
|
|
138
|
-
rotateXYZ([rx, ry, rz]: number[]): Matrix4;
|
|
139
|
-
rotateAxis(radians, axis): Matrix4;
|
|
140
|
-
|
|
141
|
-
// Transforms
|
|
142
|
-
|
|
143
|
-
// Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
|
|
144
|
-
transform(vector: number[], result: number[]): number[];
|
|
145
|
-
|
|
146
|
-
// Transforms any 2 or 3 element array as point (w implicitly 1)
|
|
147
|
-
transformAsPoint(vector: number[], result: number[]): number[];
|
|
148
|
-
transformAsVector(vector: number[], result: number[]): number[];
|
|
149
|
-
|
|
150
|
-
// three.js math API compatibility
|
|
151
|
-
makeRotationX(radians: number): Matrix4;
|
|
152
|
-
makeTranslation(x: number, y: number, z: number): Matrix4;
|
|
153
|
-
|
|
154
|
-
// DEPRECATED in 3.0
|
|
155
|
-
/** @deprecated Use Matrix4.transformAsPoint instead. */
|
|
156
|
-
transformPoint(vector: number[], result?: number[]): number[];
|
|
157
|
-
/** @deprecated Use Matrix4.transformAsPoint instead. */
|
|
158
|
-
transformVector(vector: number[], result?: number[]): number[];
|
|
159
|
-
/** @deprecated Use Matrix4.transformAsPoint instead. */
|
|
160
|
-
transformDirection(vector: number[], result?: number[]): number[];
|
|
161
|
-
}
|
package/src/classes/matrix4.js
DELETED
|
@@ -1,530 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2017 Uber Technologies, Inc.
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
// in the Software without restriction, including without limitation the rights
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
// THE SOFTWARE.
|
|
20
|
-
|
|
21
|
-
import {checkVector, deprecated} from '../lib/validators';
|
|
22
|
-
import Matrix from './base/matrix';
|
|
23
|
-
// eslint-disable-next-line camelcase
|
|
24
|
-
import {vec2_transformMat4AsVector, vec3_transformMat4AsVector} from '../lib/gl-matrix-extras';
|
|
25
|
-
|
|
26
|
-
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
|
|
27
|
-
import * as mat4 from 'gl-matrix/mat4';
|
|
28
|
-
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
|
|
29
|
-
import * as vec2 from 'gl-matrix/vec2';
|
|
30
|
-
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
|
|
31
|
-
import * as vec3 from 'gl-matrix/vec3';
|
|
32
|
-
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
|
|
33
|
-
import * as vec4 from 'gl-matrix/vec4';
|
|
34
|
-
|
|
35
|
-
const IDENTITY = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
36
|
-
const ZERO = Object.freeze([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
37
|
-
|
|
38
|
-
const INDICES = Object.freeze({
|
|
39
|
-
COL0ROW0: 0,
|
|
40
|
-
COL0ROW1: 1,
|
|
41
|
-
COL0ROW2: 2,
|
|
42
|
-
COL0ROW3: 3,
|
|
43
|
-
COL1ROW0: 4,
|
|
44
|
-
COL1ROW1: 5,
|
|
45
|
-
COL1ROW2: 6,
|
|
46
|
-
COL1ROW3: 7,
|
|
47
|
-
COL2ROW0: 8,
|
|
48
|
-
COL2ROW1: 9,
|
|
49
|
-
COL2ROW2: 10,
|
|
50
|
-
COL2ROW3: 11,
|
|
51
|
-
COL3ROW0: 12,
|
|
52
|
-
COL3ROW1: 13,
|
|
53
|
-
COL3ROW2: 14,
|
|
54
|
-
COL3ROW3: 15
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const constants = {};
|
|
58
|
-
|
|
59
|
-
export default class Matrix4 extends Matrix {
|
|
60
|
-
static get IDENTITY() {
|
|
61
|
-
constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix4(IDENTITY));
|
|
62
|
-
return constants.IDENTITY;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static get ZERO() {
|
|
66
|
-
constants.ZERO = constants.ZERO || Object.freeze(new Matrix4(ZERO));
|
|
67
|
-
return constants.ZERO;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
get INDICES() {
|
|
71
|
-
return INDICES;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
get ELEMENTS() {
|
|
75
|
-
return 16;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
get RANK() {
|
|
79
|
-
return 4;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
constructor(array) {
|
|
83
|
-
// PERF NOTE: initialize elements as double precision numbers
|
|
84
|
-
super(-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
|
|
85
|
-
if (arguments.length === 1 && Array.isArray(array)) {
|
|
86
|
-
this.copy(array);
|
|
87
|
-
} else {
|
|
88
|
-
this.identity();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
copy(array) {
|
|
93
|
-
this[0] = array[0];
|
|
94
|
-
this[1] = array[1];
|
|
95
|
-
this[2] = array[2];
|
|
96
|
-
this[3] = array[3];
|
|
97
|
-
this[4] = array[4];
|
|
98
|
-
this[5] = array[5];
|
|
99
|
-
this[6] = array[6];
|
|
100
|
-
this[7] = array[7];
|
|
101
|
-
this[8] = array[8];
|
|
102
|
-
this[9] = array[9];
|
|
103
|
-
this[10] = array[10];
|
|
104
|
-
this[11] = array[11];
|
|
105
|
-
this[12] = array[12];
|
|
106
|
-
this[13] = array[13];
|
|
107
|
-
this[14] = array[14];
|
|
108
|
-
this[15] = array[15];
|
|
109
|
-
return this.check();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// eslint-disable-next-line max-params
|
|
113
|
-
set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
|
|
114
|
-
this[0] = m00;
|
|
115
|
-
this[1] = m10;
|
|
116
|
-
this[2] = m20;
|
|
117
|
-
this[3] = m30;
|
|
118
|
-
this[4] = m01;
|
|
119
|
-
this[5] = m11;
|
|
120
|
-
this[6] = m21;
|
|
121
|
-
this[7] = m31;
|
|
122
|
-
this[8] = m02;
|
|
123
|
-
this[9] = m12;
|
|
124
|
-
this[10] = m22;
|
|
125
|
-
this[11] = m32;
|
|
126
|
-
this[12] = m03;
|
|
127
|
-
this[13] = m13;
|
|
128
|
-
this[14] = m23;
|
|
129
|
-
this[15] = m33;
|
|
130
|
-
return this.check();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// accepts row major order, stores as column major
|
|
134
|
-
// eslint-disable-next-line max-params
|
|
135
|
-
setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
136
|
-
this[0] = m00;
|
|
137
|
-
this[1] = m10;
|
|
138
|
-
this[2] = m20;
|
|
139
|
-
this[3] = m30;
|
|
140
|
-
this[4] = m01;
|
|
141
|
-
this[5] = m11;
|
|
142
|
-
this[6] = m21;
|
|
143
|
-
this[7] = m31;
|
|
144
|
-
this[8] = m02;
|
|
145
|
-
this[9] = m12;
|
|
146
|
-
this[10] = m22;
|
|
147
|
-
this[11] = m32;
|
|
148
|
-
this[12] = m03;
|
|
149
|
-
this[13] = m13;
|
|
150
|
-
this[14] = m23;
|
|
151
|
-
this[15] = m33;
|
|
152
|
-
return this.check();
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
toRowMajor(result) {
|
|
156
|
-
result[0] = this[0];
|
|
157
|
-
result[1] = this[4];
|
|
158
|
-
result[2] = this[8];
|
|
159
|
-
result[3] = this[12];
|
|
160
|
-
result[4] = this[1];
|
|
161
|
-
result[5] = this[5];
|
|
162
|
-
result[6] = this[9];
|
|
163
|
-
result[7] = this[13];
|
|
164
|
-
result[8] = this[2];
|
|
165
|
-
result[9] = this[6];
|
|
166
|
-
result[10] = this[10];
|
|
167
|
-
result[11] = this[14];
|
|
168
|
-
result[12] = this[3];
|
|
169
|
-
result[13] = this[7];
|
|
170
|
-
result[14] = this[11];
|
|
171
|
-
result[15] = this[15];
|
|
172
|
-
return result;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// Constructors
|
|
176
|
-
|
|
177
|
-
identity() {
|
|
178
|
-
return this.copy(IDENTITY);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Calculates a 4x4 matrix from the given quaternion
|
|
182
|
-
// q quat Quaternion to create matrix from
|
|
183
|
-
fromQuaternion(q) {
|
|
184
|
-
mat4.fromQuat(this, q);
|
|
185
|
-
return this.check();
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Generates a frustum matrix with the given bounds
|
|
189
|
-
// left Number Left bound of the frustum
|
|
190
|
-
// right Number Right bound of the frustum
|
|
191
|
-
// bottom Number Bottom bound of the frustum
|
|
192
|
-
// top Number Top bound of the frustum
|
|
193
|
-
// near Number Near bound of the frustum
|
|
194
|
-
// far Number Far bound of the frustum
|
|
195
|
-
frustum({left, right, bottom, top, near, far}) {
|
|
196
|
-
if (far === Infinity) {
|
|
197
|
-
Matrix4._computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
|
|
198
|
-
} else {
|
|
199
|
-
mat4.frustum(this, left, right, bottom, top, near, far);
|
|
200
|
-
}
|
|
201
|
-
return this.check();
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// eslint-disable-next-line max-params
|
|
205
|
-
static _computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, near) {
|
|
206
|
-
const column0Row0 = (2.0 * near) / (right - left);
|
|
207
|
-
const column1Row1 = (2.0 * near) / (top - bottom);
|
|
208
|
-
const column2Row0 = (right + left) / (right - left);
|
|
209
|
-
const column2Row1 = (top + bottom) / (top - bottom);
|
|
210
|
-
const column2Row2 = -1.0;
|
|
211
|
-
const column2Row3 = -1.0;
|
|
212
|
-
const column3Row2 = -2.0 * near;
|
|
213
|
-
|
|
214
|
-
result[0] = column0Row0;
|
|
215
|
-
result[1] = 0.0;
|
|
216
|
-
result[2] = 0.0;
|
|
217
|
-
result[3] = 0.0;
|
|
218
|
-
result[4] = 0.0;
|
|
219
|
-
result[5] = column1Row1;
|
|
220
|
-
result[6] = 0.0;
|
|
221
|
-
result[7] = 0.0;
|
|
222
|
-
result[8] = column2Row0;
|
|
223
|
-
result[9] = column2Row1;
|
|
224
|
-
result[10] = column2Row2;
|
|
225
|
-
result[11] = column2Row3;
|
|
226
|
-
result[12] = 0.0;
|
|
227
|
-
result[13] = 0.0;
|
|
228
|
-
result[14] = column3Row2;
|
|
229
|
-
result[15] = 0.0;
|
|
230
|
-
return result;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Generates a look-at matrix with the given eye position, focal point,
|
|
234
|
-
// and up axis
|
|
235
|
-
// eye vec3 Position of the viewer
|
|
236
|
-
// center vec3 Point the viewer is looking at
|
|
237
|
-
// up vec3 vec3 pointing up
|
|
238
|
-
lookAt(eye, center, up) {
|
|
239
|
-
// Signature: lookAt({eye, center = [0, 0, 0], up = [0, 1, 0]}))
|
|
240
|
-
if (arguments.length === 1) {
|
|
241
|
-
({eye, center, up} = eye);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
center = center || [0, 0, 0];
|
|
245
|
-
up = up || [0, 1, 0];
|
|
246
|
-
|
|
247
|
-
mat4.lookAt(this, eye, center, up);
|
|
248
|
-
return this.check();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// Generates a orthogonal projection matrix with the given bounds
|
|
252
|
-
// from "traditional" view space parameters
|
|
253
|
-
// left number Left bound of the frustum
|
|
254
|
-
// right number Right bound of the frustum
|
|
255
|
-
// bottom number Bottom bound of the frustum
|
|
256
|
-
// top number Top bound of the frustum
|
|
257
|
-
// near number Near bound of the frustum
|
|
258
|
-
// far number Far bound of the frustum
|
|
259
|
-
ortho({left, right, bottom, top, near = 0.1, far = 500}) {
|
|
260
|
-
mat4.ortho(this, left, right, bottom, top, near, far);
|
|
261
|
-
return this.check();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Generates an orthogonal projection matrix with the same parameters
|
|
265
|
-
// as a perspective matrix (plus focalDistance)
|
|
266
|
-
// fovy number Vertical field of view in radians
|
|
267
|
-
// aspect number Aspect ratio. typically viewport width/height
|
|
268
|
-
// focalDistance distance in the view frustum used for extent calculations
|
|
269
|
-
// near number Near bound of the frustum
|
|
270
|
-
// far number Far bound of the frustum
|
|
271
|
-
orthographic({
|
|
272
|
-
fovy = (45 * Math.PI) / 180,
|
|
273
|
-
aspect = 1,
|
|
274
|
-
focalDistance = 1,
|
|
275
|
-
near = 0.1,
|
|
276
|
-
far = 500
|
|
277
|
-
}) {
|
|
278
|
-
if (fovy > Math.PI * 2) {
|
|
279
|
-
throw Error('radians');
|
|
280
|
-
}
|
|
281
|
-
const halfY = fovy / 2;
|
|
282
|
-
const top = focalDistance * Math.tan(halfY); // focus_plane is the distance from the camera
|
|
283
|
-
const right = top * aspect;
|
|
284
|
-
|
|
285
|
-
return new Matrix4().ortho({
|
|
286
|
-
left: -right,
|
|
287
|
-
right,
|
|
288
|
-
bottom: -top,
|
|
289
|
-
top,
|
|
290
|
-
near,
|
|
291
|
-
far
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// Generates a perspective projection matrix with the given bounds
|
|
296
|
-
// fovy number Vertical field of view in radians
|
|
297
|
-
// aspect number Aspect ratio. typically viewport width/height
|
|
298
|
-
// near number Near bound of the frustum
|
|
299
|
-
// far number Far bound of the frustum
|
|
300
|
-
perspective({
|
|
301
|
-
fovy = undefined,
|
|
302
|
-
fov = (45 * Math.PI) / 180, // DEPRECATED
|
|
303
|
-
aspect = 1,
|
|
304
|
-
near = 0.1,
|
|
305
|
-
far = 500
|
|
306
|
-
} = {}) {
|
|
307
|
-
fovy = fovy || fov;
|
|
308
|
-
if (fovy > Math.PI * 2) {
|
|
309
|
-
throw Error('radians');
|
|
310
|
-
}
|
|
311
|
-
mat4.perspective(this, fovy, aspect, near, far);
|
|
312
|
-
return this.check();
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// Accessors
|
|
316
|
-
|
|
317
|
-
determinant() {
|
|
318
|
-
return mat4.determinant(this);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// Extracts the non-uniform scale assuming the matrix is an affine transformation.
|
|
322
|
-
// The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
|
|
323
|
-
getScale(result = [-0, -0, -0]) {
|
|
324
|
-
// explicit is faster than hypot...
|
|
325
|
-
result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
|
|
326
|
-
result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
|
|
327
|
-
result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
|
|
328
|
-
// result[0] = Math.hypot(this[0], this[1], this[2]);
|
|
329
|
-
// result[1] = Math.hypot(this[4], this[5], this[6]);
|
|
330
|
-
// result[2] = Math.hypot(this[8], this[9], this[10]);
|
|
331
|
-
return result;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// Gets the translation portion, assuming the matrix is a affine transformation matrix.
|
|
335
|
-
getTranslation(result = [-0, -0, -0]) {
|
|
336
|
-
result[0] = this[12];
|
|
337
|
-
result[1] = this[13];
|
|
338
|
-
result[2] = this[14];
|
|
339
|
-
return result;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
|
|
343
|
-
getRotation(
|
|
344
|
-
result = [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0],
|
|
345
|
-
scaleResult = null
|
|
346
|
-
) {
|
|
347
|
-
const scale = this.getScale(scaleResult || [-0, -0, -0]);
|
|
348
|
-
|
|
349
|
-
const inverseScale0 = 1 / scale[0];
|
|
350
|
-
const inverseScale1 = 1 / scale[1];
|
|
351
|
-
const inverseScale2 = 1 / scale[2];
|
|
352
|
-
|
|
353
|
-
result[0] = this[0] * inverseScale0;
|
|
354
|
-
result[1] = this[1] * inverseScale1;
|
|
355
|
-
result[2] = this[2] * inverseScale2;
|
|
356
|
-
result[3] = 0;
|
|
357
|
-
result[4] = this[4] * inverseScale0;
|
|
358
|
-
result[5] = this[5] * inverseScale1;
|
|
359
|
-
result[6] = this[6] * inverseScale2;
|
|
360
|
-
result[7] = 0;
|
|
361
|
-
result[8] = this[8] * inverseScale0;
|
|
362
|
-
result[9] = this[9] * inverseScale1;
|
|
363
|
-
result[10] = this[10] * inverseScale2;
|
|
364
|
-
result[11] = 0;
|
|
365
|
-
result[12] = 0;
|
|
366
|
-
result[13] = 0;
|
|
367
|
-
result[14] = 0;
|
|
368
|
-
result[15] = 1;
|
|
369
|
-
return result;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
getRotationMatrix3(result = [-0, -0, -0, -0, -0, -0, -0, -0, -0], scaleResult = null) {
|
|
373
|
-
const scale = this.getScale(scaleResult || [-0, -0, -0]);
|
|
374
|
-
|
|
375
|
-
const inverseScale0 = 1 / scale[0];
|
|
376
|
-
const inverseScale1 = 1 / scale[1];
|
|
377
|
-
const inverseScale2 = 1 / scale[2];
|
|
378
|
-
|
|
379
|
-
result[0] = this[0] * inverseScale0;
|
|
380
|
-
result[1] = this[1] * inverseScale1;
|
|
381
|
-
result[2] = this[2] * inverseScale2;
|
|
382
|
-
result[3] = this[4] * inverseScale0;
|
|
383
|
-
result[4] = this[5] * inverseScale1;
|
|
384
|
-
result[5] = this[6] * inverseScale2;
|
|
385
|
-
result[6] = this[8] * inverseScale0;
|
|
386
|
-
result[7] = this[9] * inverseScale1;
|
|
387
|
-
result[8] = this[10] * inverseScale2;
|
|
388
|
-
return result;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// Modifiers
|
|
392
|
-
|
|
393
|
-
transpose() {
|
|
394
|
-
mat4.transpose(this, this);
|
|
395
|
-
return this.check();
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
invert() {
|
|
399
|
-
mat4.invert(this, this);
|
|
400
|
-
return this.check();
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// Operations
|
|
404
|
-
|
|
405
|
-
multiplyLeft(a) {
|
|
406
|
-
mat4.multiply(this, a, this);
|
|
407
|
-
return this.check();
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
multiplyRight(a) {
|
|
411
|
-
mat4.multiply(this, this, a);
|
|
412
|
-
return this.check();
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// Rotates a matrix by the given angle around the X axis
|
|
416
|
-
rotateX(radians) {
|
|
417
|
-
mat4.rotateX(this, this, radians);
|
|
418
|
-
// mat4.rotate(this, this, radians, [1, 0, 0]);
|
|
419
|
-
return this.check();
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// Rotates a matrix by the given angle around the Y axis.
|
|
423
|
-
rotateY(radians) {
|
|
424
|
-
mat4.rotateY(this, this, radians);
|
|
425
|
-
// mat4.rotate(this, this, radians, [0, 1, 0]);
|
|
426
|
-
return this.check();
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// Rotates a matrix by the given angle around the Z axis.
|
|
430
|
-
rotateZ(radians) {
|
|
431
|
-
mat4.rotateZ(this, this, radians);
|
|
432
|
-
// mat4.rotate(this, this, radians, [0, 0, 1]);
|
|
433
|
-
return this.check();
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
rotateXYZ([rx, ry, rz]) {
|
|
437
|
-
return this.rotateX(rx).rotateY(ry).rotateZ(rz);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
rotateAxis(radians, axis) {
|
|
441
|
-
mat4.rotate(this, this, radians, axis);
|
|
442
|
-
return this.check();
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
scale(factor) {
|
|
446
|
-
if (Array.isArray(factor)) {
|
|
447
|
-
mat4.scale(this, this, factor);
|
|
448
|
-
} else {
|
|
449
|
-
mat4.scale(this, this, [factor, factor, factor]);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
return this.check();
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
translate(vec) {
|
|
456
|
-
mat4.translate(this, this, vec);
|
|
457
|
-
return this.check();
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// Transforms
|
|
461
|
-
|
|
462
|
-
// Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
|
|
463
|
-
transform(vector, result) {
|
|
464
|
-
if (vector.length === 4) {
|
|
465
|
-
result = vec4.transformMat4(result || [-0, -0, -0, -0], vector, this);
|
|
466
|
-
checkVector(result, 4);
|
|
467
|
-
return result;
|
|
468
|
-
}
|
|
469
|
-
return this.transformAsPoint(vector, result);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// Transforms any 2 or 3 element array as point (w implicitly 1)
|
|
473
|
-
transformAsPoint(vector, result) {
|
|
474
|
-
const {length} = vector;
|
|
475
|
-
switch (length) {
|
|
476
|
-
case 2:
|
|
477
|
-
result = vec2.transformMat4(result || [-0, -0], vector, this);
|
|
478
|
-
break;
|
|
479
|
-
case 3:
|
|
480
|
-
result = vec3.transformMat4(result || [-0, -0, -0], vector, this);
|
|
481
|
-
break;
|
|
482
|
-
default:
|
|
483
|
-
throw new Error('Illegal vector');
|
|
484
|
-
}
|
|
485
|
-
checkVector(result, vector.length);
|
|
486
|
-
return result;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// Transforms any 2 or 3 element array as vector (w implicitly 0)
|
|
490
|
-
transformAsVector(vector, result) {
|
|
491
|
-
switch (vector.length) {
|
|
492
|
-
case 2:
|
|
493
|
-
result = vec2_transformMat4AsVector(result || [-0, -0], vector, this);
|
|
494
|
-
break;
|
|
495
|
-
case 3:
|
|
496
|
-
result = vec3_transformMat4AsVector(result || [-0, -0, -0], vector, this);
|
|
497
|
-
break;
|
|
498
|
-
default:
|
|
499
|
-
throw new Error('Illegal vector');
|
|
500
|
-
}
|
|
501
|
-
checkVector(result, vector.length);
|
|
502
|
-
return result;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
// three.js math API compatibility
|
|
506
|
-
makeRotationX(radians) {
|
|
507
|
-
return this.identity().rotateX(radians);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
makeTranslation(x, y, z) {
|
|
511
|
-
return this.identity().translate([x, y, z]);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// DEPRECATED in 3.0
|
|
515
|
-
|
|
516
|
-
transformPoint(vector, result) {
|
|
517
|
-
deprecated('Matrix4.transformPoint', '3.0');
|
|
518
|
-
return this.transformAsPoint(vector, result);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
transformVector(vector, result) {
|
|
522
|
-
deprecated('Matrix4.transformVector', '3.0');
|
|
523
|
-
return this.transformAsPoint(vector, result);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
transformDirection(vector, result) {
|
|
527
|
-
deprecated('Matrix4.transformDirection', '3.0');
|
|
528
|
-
return this.transformAsVector(vector, result);
|
|
529
|
-
}
|
|
530
|
-
}
|