@vertexvis/geometry 0.24.5-canary.6 → 1.0.0-testing.1
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/angle.d.ts +35 -35
- package/dist/boundingBox.d.ts +49 -49
- package/dist/boundingSphere.d.ts +14 -14
- package/dist/bundle.cjs.js +2148 -2148
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +2148 -2148
- package/dist/bundle.esm.js.map +1 -1
- package/dist/cdn/bundle.esm.js +2149 -2183
- package/dist/cdn/bundle.esm.js.map +1 -1
- package/dist/cdn/bundle.esm.min.js +1 -15
- package/dist/cdn/bundle.esm.min.js.map +1 -1
- package/dist/dimensions.d.ts +94 -94
- package/dist/euler.d.ts +57 -57
- package/dist/index.d.ts +21 -21
- package/dist/line3.d.ts +48 -48
- package/dist/math.d.ts +20 -20
- package/dist/matrix.d.ts +73 -73
- package/dist/matrix2.d.ts +29 -29
- package/dist/matrix4.d.ts +285 -285
- package/dist/plane.d.ts +51 -51
- package/dist/point.d.ts +80 -80
- package/dist/quaternion.d.ts +65 -65
- package/dist/ray.d.ts +52 -52
- package/dist/rectangle.d.ts +125 -125
- package/dist/vector3.d.ts +226 -226
- package/dist/vector4.d.ts +23 -23
- package/package.json +10 -10
- package/dist/cdn/__tests__/angle.test.d.ts +0 -1
- package/dist/cdn/__tests__/boundingBox.test.d.ts +0 -1
- package/dist/cdn/__tests__/boundingSphere.test.d.ts +0 -1
- package/dist/cdn/__tests__/dimensions.test.d.ts +0 -1
- package/dist/cdn/__tests__/euler.test.d.ts +0 -1
- package/dist/cdn/__tests__/line3.test.d.ts +0 -1
- package/dist/cdn/__tests__/math.spec.d.ts +0 -1
- package/dist/cdn/__tests__/matrix.test.d.ts +0 -1
- package/dist/cdn/__tests__/matrix2.test.d.ts +0 -1
- package/dist/cdn/__tests__/matrix4.test.d.ts +0 -1
- package/dist/cdn/__tests__/plane.test.d.ts +0 -1
- package/dist/cdn/__tests__/point.test.d.ts +0 -1
- package/dist/cdn/__tests__/quaternion.test.d.ts +0 -1
- package/dist/cdn/__tests__/ray.test.d.ts +0 -1
- package/dist/cdn/__tests__/rectangle.test.d.ts +0 -1
- package/dist/cdn/__tests__/vector3.test.d.ts +0 -1
- package/dist/cdn/__tests__/vector4.test.d.ts +0 -1
- package/dist/cdn/angle.d.ts +0 -35
- package/dist/cdn/boundingBox.d.ts +0 -49
- package/dist/cdn/boundingSphere.d.ts +0 -14
- package/dist/cdn/dimensions.d.ts +0 -94
- package/dist/cdn/euler.d.ts +0 -57
- package/dist/cdn/index.d.ts +0 -21
- package/dist/cdn/line3.d.ts +0 -48
- package/dist/cdn/math.d.ts +0 -20
- package/dist/cdn/matrix.d.ts +0 -73
- package/dist/cdn/matrix2.d.ts +0 -29
- package/dist/cdn/matrix4.d.ts +0 -285
- package/dist/cdn/plane.d.ts +0 -51
- package/dist/cdn/point.d.ts +0 -80
- package/dist/cdn/quaternion.d.ts +0 -65
- package/dist/cdn/ray.d.ts +0 -52
- package/dist/cdn/rectangle.d.ts +0 -125
- package/dist/cdn/vector3.d.ts +0 -226
- package/dist/cdn/vector4.d.ts +0 -23
package/dist/matrix2.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import * as Point from './point';
|
|
2
|
-
/**
|
|
3
|
-
* A 2x2 matrix. The contents are mapped as follows:
|
|
4
|
-
*
|
|
5
|
-
* ```
|
|
6
|
-
* a b
|
|
7
|
-
* c d
|
|
8
|
-
* ```
|
|
9
|
-
*/
|
|
10
|
-
export interface Matrix {
|
|
11
|
-
a: number;
|
|
12
|
-
b: number;
|
|
13
|
-
c: number;
|
|
14
|
-
d: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new matrix.
|
|
18
|
-
*/
|
|
19
|
-
export declare function create(a: Point.Point, b: Point.Point): Matrix;
|
|
20
|
-
export declare function create(a: number, b: number, c: number, d: number): Matrix;
|
|
21
|
-
export declare function create(): Matrix;
|
|
22
|
-
/**
|
|
23
|
-
* Returns the determinant of the provided matrix.
|
|
24
|
-
*/
|
|
25
|
-
export declare function determinant(matrix: Matrix): number;
|
|
26
|
-
/**
|
|
27
|
-
* Returns the dot product of the two vectors represented in this matrix.
|
|
28
|
-
*/
|
|
29
|
-
export declare function dot(matrix: Matrix): number;
|
|
1
|
+
import * as Point from './point';
|
|
2
|
+
/**
|
|
3
|
+
* A 2x2 matrix. The contents are mapped as follows:
|
|
4
|
+
*
|
|
5
|
+
* ```
|
|
6
|
+
* a b
|
|
7
|
+
* c d
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export interface Matrix {
|
|
11
|
+
a: number;
|
|
12
|
+
b: number;
|
|
13
|
+
c: number;
|
|
14
|
+
d: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new matrix.
|
|
18
|
+
*/
|
|
19
|
+
export declare function create(a: Point.Point, b: Point.Point): Matrix;
|
|
20
|
+
export declare function create(a: number, b: number, c: number, d: number): Matrix;
|
|
21
|
+
export declare function create(): Matrix;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the determinant of the provided matrix.
|
|
24
|
+
*/
|
|
25
|
+
export declare function determinant(matrix: Matrix): number;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the dot product of the two vectors represented in this matrix.
|
|
28
|
+
*/
|
|
29
|
+
export declare function dot(matrix: Matrix): number;
|
package/dist/matrix4.d.ts
CHANGED
|
@@ -1,285 +1,285 @@
|
|
|
1
|
-
import * as Quaternion from './quaternion';
|
|
2
|
-
import * as Vector3 from './vector3';
|
|
3
|
-
/**
|
|
4
|
-
* A type alias representing a 4x4 column-major matrix.
|
|
5
|
-
*
|
|
6
|
-
* The common use-case for 4x4 matrices in 3D computer graphics are for
|
|
7
|
-
* [transformation
|
|
8
|
-
* matrices](https://en.wikipedia.org/wiki/Transformation_matrix). This allows a
|
|
9
|
-
* point in 3D space to be projected onto a 2D screen using transformations such
|
|
10
|
-
* as translation, rotation and scale.
|
|
11
|
-
*/
|
|
12
|
-
export
|
|
13
|
-
number,
|
|
14
|
-
number,
|
|
15
|
-
number,
|
|
16
|
-
number,
|
|
17
|
-
number,
|
|
18
|
-
number,
|
|
19
|
-
number,
|
|
20
|
-
number,
|
|
21
|
-
number,
|
|
22
|
-
number,
|
|
23
|
-
number,
|
|
24
|
-
number,
|
|
25
|
-
number,
|
|
26
|
-
number,
|
|
27
|
-
number,
|
|
28
|
-
number
|
|
29
|
-
];
|
|
30
|
-
/**
|
|
31
|
-
* An object representation of a `Matrix4`, where each value is represented as:
|
|
32
|
-
*
|
|
33
|
-
* ```
|
|
34
|
-
* m11 m12 m13 m14
|
|
35
|
-
* m21 m22 m23 m24
|
|
36
|
-
* m31 m32 m33 m34
|
|
37
|
-
* m41 m42 m43 m44
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* `Matrix4` arrays can be converted to an object using {@link toObject}.
|
|
41
|
-
*/
|
|
42
|
-
export interface Matrix4AsObject {
|
|
43
|
-
m11: number;
|
|
44
|
-
m12: number;
|
|
45
|
-
m13: number;
|
|
46
|
-
m14: number;
|
|
47
|
-
m21: number;
|
|
48
|
-
m22: number;
|
|
49
|
-
m23: number;
|
|
50
|
-
m24: number;
|
|
51
|
-
m31: number;
|
|
52
|
-
m32: number;
|
|
53
|
-
m33: number;
|
|
54
|
-
m34: number;
|
|
55
|
-
m41: number;
|
|
56
|
-
m42: number;
|
|
57
|
-
m43: number;
|
|
58
|
-
m44: number;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Creates a 4x4 matrix from a set of row-major components.
|
|
62
|
-
*/
|
|
63
|
-
export declare function fromValues(m11: number, m12: number, m13: number, m14: number, m21: number, m22: number, m23: number, m24: number, m31: number, m32: number, m33: number, m34: number, m41: number, m42: number, m43: number, m44: number): Matrix4;
|
|
64
|
-
/**
|
|
65
|
-
* Creates a `Matrix4` from an object representation.
|
|
66
|
-
*/
|
|
67
|
-
export declare function fromObject(obj: Matrix4AsObject): Matrix4;
|
|
68
|
-
/**
|
|
69
|
-
* Returns a new [identity matrix](https://en.wikipedia.org/wiki/Identity_matrix).
|
|
70
|
-
*/
|
|
71
|
-
export declare function makeIdentity(): Matrix4;
|
|
72
|
-
/**
|
|
73
|
-
* Returns a matrix with all values as 0.
|
|
74
|
-
*/
|
|
75
|
-
export declare function makeZero(): Matrix4;
|
|
76
|
-
/**
|
|
77
|
-
* Creates a translation matrix.
|
|
78
|
-
*
|
|
79
|
-
* ```
|
|
80
|
-
* 1, 0, 0, 0,
|
|
81
|
-
* 0, 1, 0, 0,
|
|
82
|
-
* 0, 0, 1, 0,
|
|
83
|
-
* x, y, z, 1
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* @param translation A vector representing the translation components.
|
|
87
|
-
* @returns A translation matrix.
|
|
88
|
-
*/
|
|
89
|
-
export declare function makeTranslation(translation: Vector3.Vector3): Matrix4;
|
|
90
|
-
/**
|
|
91
|
-
* Creates a rotation matrix.
|
|
92
|
-
*
|
|
93
|
-
* ```
|
|
94
|
-
* 1-2y²-2z², 2xy-2zw, 2xz+2yw, 0,
|
|
95
|
-
* 2xy+2zw, 1-2x²-2z², 2yz-2xw, 0,
|
|
96
|
-
* 2xz-2yw, 2yz+2xw, 1-2x²-2y², 0,
|
|
97
|
-
* 0, 0, 0, 1,
|
|
98
|
-
* ```
|
|
99
|
-
*
|
|
100
|
-
* @param rotation A quaternion representing the rotation.
|
|
101
|
-
* @see https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion
|
|
102
|
-
* @returns A rotation matrix.
|
|
103
|
-
*/
|
|
104
|
-
export declare function makeRotation(rotation: Quaternion.Quaternion): Matrix4;
|
|
105
|
-
/**
|
|
106
|
-
* Creates a scale matrix.
|
|
107
|
-
*
|
|
108
|
-
* ```
|
|
109
|
-
* x, 0, 0, 0,
|
|
110
|
-
* 0, y, 0, 0,
|
|
111
|
-
* 0, 0, z, 0,
|
|
112
|
-
* 0, 0, 0, 1
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* @param scale A vector representing the different scale components.
|
|
116
|
-
* @returns A scale matrix.
|
|
117
|
-
*/
|
|
118
|
-
export declare function makeScale(scale: Vector3.Vector3): Matrix4;
|
|
119
|
-
/**
|
|
120
|
-
* Creates a matrix that has translation, rotation and scale applied to it.
|
|
121
|
-
*
|
|
122
|
-
* @param translation The translation applied to the matrix.
|
|
123
|
-
* @param rotation The rotation applied to the matrix.
|
|
124
|
-
* @param scale The scale applied to the matrix.
|
|
125
|
-
* @returns A transformed matrix.
|
|
126
|
-
*/
|
|
127
|
-
export declare function makeTRS(translation: Vector3.Vector3, rotation: Quaternion.Quaternion, scale: Vector3.Vector3): Matrix4;
|
|
128
|
-
/**
|
|
129
|
-
* Returns a matrix that has the basis components (upper left 3x3 matrix) set to
|
|
130
|
-
* the following x, y, and z axis.
|
|
131
|
-
*
|
|
132
|
-
* ```
|
|
133
|
-
* x.x y.x z.x 0
|
|
134
|
-
* x.y y.y z.y 0
|
|
135
|
-
* x.z y.z z.z 0
|
|
136
|
-
* 0 0 0 0
|
|
137
|
-
* ```
|
|
138
|
-
*
|
|
139
|
-
* @param x The x axis to set.
|
|
140
|
-
* @param y The y axis to set.
|
|
141
|
-
* @param z The z axis to set.
|
|
142
|
-
* @returns A matrix with its basis components populated.
|
|
143
|
-
*/
|
|
144
|
-
export declare function makeBasis(x: Vector3.Vector3, y: Vector3.Vector3, z: Vector3.Vector3): Matrix4;
|
|
145
|
-
/**
|
|
146
|
-
* Creates a rotation matrix that is rotated around a given axis by the given
|
|
147
|
-
* angle.
|
|
148
|
-
*
|
|
149
|
-
* @param axis The axis of rotation.
|
|
150
|
-
* @param radians The angle of rotation.
|
|
151
|
-
* @returns A rotation matrix.
|
|
152
|
-
*/
|
|
153
|
-
export declare function makeRotationAxis(axis: Vector3.Vector3, radians: number): Matrix4;
|
|
154
|
-
/**
|
|
155
|
-
* Creates a matrix used for [perspective
|
|
156
|
-
* projections](https://en.wikipedia.org/wiki/3D_projection#Perspective_projection).
|
|
157
|
-
*
|
|
158
|
-
* The viewing volume is frustum-shaped and defined by the six parameters. Left,
|
|
159
|
-
* right, top, and bottom specify coordinates in the near clipping plane where
|
|
160
|
-
* the frustum edges intersect it, and the near and far parameters define the
|
|
161
|
-
* forward distances of the view volume. The resulting volume can be vertically
|
|
162
|
-
* and horizontally asymmetrical around the center of the near plane.
|
|
163
|
-
*
|
|
164
|
-
* @param left The left coordinate at the near plane.
|
|
165
|
-
* @param right The right coordinate at the near plane.
|
|
166
|
-
* @param top The top coordinate at the near plane.
|
|
167
|
-
* @param bottom The bottom coordinate at the near plane.
|
|
168
|
-
* @param near The near distance.
|
|
169
|
-
* @param far The far distance.
|
|
170
|
-
* @returns A matrix representing a view frustum.
|
|
171
|
-
*/
|
|
172
|
-
export declare function makeFrustum(left: number, right: number, top: number, bottom: number, near: number, far: number): Matrix4;
|
|
173
|
-
/**
|
|
174
|
-
* Creates a perspective projection matrix.
|
|
175
|
-
*
|
|
176
|
-
* Related to: gluPerspective. The viewing volume is frustum-shaped amd defined
|
|
177
|
-
* by the four parameters. The fovy and aspect ratio are used to compute the
|
|
178
|
-
* positions of the left, right, top, and bottom sides of the viewing volume in
|
|
179
|
-
* the zNear plane. The fovy is the y field-of-view, the angle made by the top
|
|
180
|
-
* and bottom sides of frustum if they were to intersect. The aspect ratio is
|
|
181
|
-
* the width of the frustum divided by its height. Note that the resulting
|
|
182
|
-
* volume is both vertically and horizontally symmetrical around the center of
|
|
183
|
-
* the near plane.
|
|
184
|
-
*
|
|
185
|
-
* @param near The near Z value.
|
|
186
|
-
* @param far The far Z value.
|
|
187
|
-
* @param fovY The field of view.
|
|
188
|
-
* @param aspect The aspect ratio.
|
|
189
|
-
* @returns A matrix.
|
|
190
|
-
*/
|
|
191
|
-
export declare function makePerspective(near: number, far: number, fovY: number, aspect: number): Matrix4;
|
|
192
|
-
/**
|
|
193
|
-
* Creates an orthographic projection matrix.
|
|
194
|
-
*
|
|
195
|
-
* Related to: gluOrtho. The viewing volume is cube-shaped and defined by
|
|
196
|
-
* the six parameters. The left and right values represent the coordinates of
|
|
197
|
-
* the vertical clipping planes, top and bottom values represent the coordinates
|
|
198
|
-
* of the horizontal clipping planes, and near and far values represent the
|
|
199
|
-
* coordinates of the depth clipping planes.
|
|
200
|
-
*
|
|
201
|
-
* @param left The coordinate of the left horizontal clipping plane.
|
|
202
|
-
* @param right The coordinate of the right horizontal clipping plane.
|
|
203
|
-
* @param bottom The coordinate of the bottom vertical clipping plane.
|
|
204
|
-
* @param top The coordinate of the top vertical clipping plane.
|
|
205
|
-
* @param near The coordinate of the near depth clipping plane.
|
|
206
|
-
* @param far The coordinate of the far depth clipping plane.
|
|
207
|
-
* @returns A matrix.
|
|
208
|
-
*/
|
|
209
|
-
export declare function makeOrthographic(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4;
|
|
210
|
-
/**
|
|
211
|
-
* Matrix becomes a combination of an inverse translation and rotation.
|
|
212
|
-
*
|
|
213
|
-
* Related to: gluLookAt. This creates the inverse of makeLookAtMatrix. The
|
|
214
|
-
* matrix will be an opposite translation from the 'eye' position, and it will
|
|
215
|
-
* rotate things in the opposite direction of the eye-to-center orientation.
|
|
216
|
-
* This is definitely confusing, but the main reason to use this transform is to
|
|
217
|
-
* set up a view matrix for a camera that's looking at a certain point. To
|
|
218
|
-
* achieve the effect of moving the camera somewhere and rotating it so that it
|
|
219
|
-
* points at something, the rest of the world is moved in the opposite direction
|
|
220
|
-
* and rotated in the opposite way around the camera. This way, you get the same
|
|
221
|
-
* effect as moving the actual camera, but all the projection math can still be
|
|
222
|
-
* done with the camera positioned at the origin (which makes it way simpler).
|
|
223
|
-
*
|
|
224
|
-
* @param position The position of the object.
|
|
225
|
-
* @param lookAt The point which the object is looking at.
|
|
226
|
-
* @param up The direction which the object considers up.
|
|
227
|
-
* @returns A matrix.
|
|
228
|
-
*/
|
|
229
|
-
export declare function makeLookAtView(position: Vector3.Vector3, lookAt: Vector3.Vector3, up: Vector3.Vector3): Matrix4;
|
|
230
|
-
/**
|
|
231
|
-
* Matrix becomes a combination of translation and rotation.
|
|
232
|
-
*
|
|
233
|
-
* Matrix becomes a combination of a translation to the position of 'eye' and a
|
|
234
|
-
* rotation matrix which orients an object to point towards 'center' along its
|
|
235
|
-
* z-axis. Use this function if you want an object to look at a point from
|
|
236
|
-
* another point in space.
|
|
237
|
-
*
|
|
238
|
-
* @param position The position of the object.
|
|
239
|
-
* @param lookAt The point which the object is looking at.
|
|
240
|
-
* @param up The direction which the object considers up.
|
|
241
|
-
* @returns A matrix.
|
|
242
|
-
*/
|
|
243
|
-
export declare function makeLookAt(position: Vector3.Vector3, lookAt: Vector3.Vector3, up: Vector3.Vector3): Matrix4;
|
|
244
|
-
/**
|
|
245
|
-
* Returns the inverse of the given matrix. If the determinate of the matrix is
|
|
246
|
-
* zero, then a zero matrix is returned.
|
|
247
|
-
*/
|
|
248
|
-
export declare function invert(matrix: Matrix4): Matrix4;
|
|
249
|
-
/**
|
|
250
|
-
* Returns a rotation matrix looking from position towards target and oriented
|
|
251
|
-
* by an up vector.
|
|
252
|
-
*
|
|
253
|
-
* @param m The matrix to transform.
|
|
254
|
-
* @param position The point from which to look at target.
|
|
255
|
-
* @param target The point to look at.
|
|
256
|
-
* @param up The orientation.
|
|
257
|
-
* @returns A rotation matrix.
|
|
258
|
-
*/
|
|
259
|
-
export declare function lookAt(m: Matrix4, position: Vector3.Vector3, target: Vector3.Vector3, up: Vector3.Vector3): Matrix4;
|
|
260
|
-
/**
|
|
261
|
-
* Returns a post-multiplied matrix.
|
|
262
|
-
*/
|
|
263
|
-
export declare function multiply(a: Matrix4, b: Matrix4): Matrix4;
|
|
264
|
-
/**
|
|
265
|
-
* Returns the [transpose](https://en.wikipedia.org/wiki/Transpose) of the given
|
|
266
|
-
* matrix.
|
|
267
|
-
*/
|
|
268
|
-
export declare function transpose(matrix: Matrix4): Matrix4;
|
|
269
|
-
/**
|
|
270
|
-
* Multiplies the columns of a matrix by the given vector.
|
|
271
|
-
*/
|
|
272
|
-
export declare function scale(matrix: Matrix4, scale: Vector3.Vector3): Matrix4;
|
|
273
|
-
export declare function position(matrix: Matrix4, other: Matrix4): Matrix4;
|
|
274
|
-
/**
|
|
275
|
-
* Returns true if the matrix is an identity matrix.
|
|
276
|
-
*/
|
|
277
|
-
export declare function isIdentity(matrix: Matrix4): boolean;
|
|
278
|
-
/**
|
|
279
|
-
* Returns an object representation of a `Matrix4`.
|
|
280
|
-
*/
|
|
281
|
-
export declare function toObject(m: Matrix4): Matrix4AsObject;
|
|
282
|
-
/**
|
|
283
|
-
* A type guard to check if `obj` is of type `Matrix4`.
|
|
284
|
-
*/
|
|
285
|
-
export declare function isType(obj: unknown): obj is Matrix4;
|
|
1
|
+
import * as Quaternion from './quaternion';
|
|
2
|
+
import * as Vector3 from './vector3';
|
|
3
|
+
/**
|
|
4
|
+
* A type alias representing a 4x4 column-major matrix.
|
|
5
|
+
*
|
|
6
|
+
* The common use-case for 4x4 matrices in 3D computer graphics are for
|
|
7
|
+
* [transformation
|
|
8
|
+
* matrices](https://en.wikipedia.org/wiki/Transformation_matrix). This allows a
|
|
9
|
+
* point in 3D space to be projected onto a 2D screen using transformations such
|
|
10
|
+
* as translation, rotation and scale.
|
|
11
|
+
*/
|
|
12
|
+
export type Matrix4 = [
|
|
13
|
+
number,
|
|
14
|
+
number,
|
|
15
|
+
number,
|
|
16
|
+
number,
|
|
17
|
+
number,
|
|
18
|
+
number,
|
|
19
|
+
number,
|
|
20
|
+
number,
|
|
21
|
+
number,
|
|
22
|
+
number,
|
|
23
|
+
number,
|
|
24
|
+
number,
|
|
25
|
+
number,
|
|
26
|
+
number,
|
|
27
|
+
number,
|
|
28
|
+
number
|
|
29
|
+
];
|
|
30
|
+
/**
|
|
31
|
+
* An object representation of a `Matrix4`, where each value is represented as:
|
|
32
|
+
*
|
|
33
|
+
* ```
|
|
34
|
+
* m11 m12 m13 m14
|
|
35
|
+
* m21 m22 m23 m24
|
|
36
|
+
* m31 m32 m33 m34
|
|
37
|
+
* m41 m42 m43 m44
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* `Matrix4` arrays can be converted to an object using {@link toObject}.
|
|
41
|
+
*/
|
|
42
|
+
export interface Matrix4AsObject {
|
|
43
|
+
m11: number;
|
|
44
|
+
m12: number;
|
|
45
|
+
m13: number;
|
|
46
|
+
m14: number;
|
|
47
|
+
m21: number;
|
|
48
|
+
m22: number;
|
|
49
|
+
m23: number;
|
|
50
|
+
m24: number;
|
|
51
|
+
m31: number;
|
|
52
|
+
m32: number;
|
|
53
|
+
m33: number;
|
|
54
|
+
m34: number;
|
|
55
|
+
m41: number;
|
|
56
|
+
m42: number;
|
|
57
|
+
m43: number;
|
|
58
|
+
m44: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Creates a 4x4 matrix from a set of row-major components.
|
|
62
|
+
*/
|
|
63
|
+
export declare function fromValues(m11: number, m12: number, m13: number, m14: number, m21: number, m22: number, m23: number, m24: number, m31: number, m32: number, m33: number, m34: number, m41: number, m42: number, m43: number, m44: number): Matrix4;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a `Matrix4` from an object representation.
|
|
66
|
+
*/
|
|
67
|
+
export declare function fromObject(obj: Matrix4AsObject): Matrix4;
|
|
68
|
+
/**
|
|
69
|
+
* Returns a new [identity matrix](https://en.wikipedia.org/wiki/Identity_matrix).
|
|
70
|
+
*/
|
|
71
|
+
export declare function makeIdentity(): Matrix4;
|
|
72
|
+
/**
|
|
73
|
+
* Returns a matrix with all values as 0.
|
|
74
|
+
*/
|
|
75
|
+
export declare function makeZero(): Matrix4;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a translation matrix.
|
|
78
|
+
*
|
|
79
|
+
* ```
|
|
80
|
+
* 1, 0, 0, 0,
|
|
81
|
+
* 0, 1, 0, 0,
|
|
82
|
+
* 0, 0, 1, 0,
|
|
83
|
+
* x, y, z, 1
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param translation A vector representing the translation components.
|
|
87
|
+
* @returns A translation matrix.
|
|
88
|
+
*/
|
|
89
|
+
export declare function makeTranslation(translation: Vector3.Vector3): Matrix4;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a rotation matrix.
|
|
92
|
+
*
|
|
93
|
+
* ```
|
|
94
|
+
* 1-2y²-2z², 2xy-2zw, 2xz+2yw, 0,
|
|
95
|
+
* 2xy+2zw, 1-2x²-2z², 2yz-2xw, 0,
|
|
96
|
+
* 2xz-2yw, 2yz+2xw, 1-2x²-2y², 0,
|
|
97
|
+
* 0, 0, 0, 1,
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @param rotation A quaternion representing the rotation.
|
|
101
|
+
* @see https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion
|
|
102
|
+
* @returns A rotation matrix.
|
|
103
|
+
*/
|
|
104
|
+
export declare function makeRotation(rotation: Quaternion.Quaternion): Matrix4;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a scale matrix.
|
|
107
|
+
*
|
|
108
|
+
* ```
|
|
109
|
+
* x, 0, 0, 0,
|
|
110
|
+
* 0, y, 0, 0,
|
|
111
|
+
* 0, 0, z, 0,
|
|
112
|
+
* 0, 0, 0, 1
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @param scale A vector representing the different scale components.
|
|
116
|
+
* @returns A scale matrix.
|
|
117
|
+
*/
|
|
118
|
+
export declare function makeScale(scale: Vector3.Vector3): Matrix4;
|
|
119
|
+
/**
|
|
120
|
+
* Creates a matrix that has translation, rotation and scale applied to it.
|
|
121
|
+
*
|
|
122
|
+
* @param translation The translation applied to the matrix.
|
|
123
|
+
* @param rotation The rotation applied to the matrix.
|
|
124
|
+
* @param scale The scale applied to the matrix.
|
|
125
|
+
* @returns A transformed matrix.
|
|
126
|
+
*/
|
|
127
|
+
export declare function makeTRS(translation: Vector3.Vector3, rotation: Quaternion.Quaternion, scale: Vector3.Vector3): Matrix4;
|
|
128
|
+
/**
|
|
129
|
+
* Returns a matrix that has the basis components (upper left 3x3 matrix) set to
|
|
130
|
+
* the following x, y, and z axis.
|
|
131
|
+
*
|
|
132
|
+
* ```
|
|
133
|
+
* x.x y.x z.x 0
|
|
134
|
+
* x.y y.y z.y 0
|
|
135
|
+
* x.z y.z z.z 0
|
|
136
|
+
* 0 0 0 0
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @param x The x axis to set.
|
|
140
|
+
* @param y The y axis to set.
|
|
141
|
+
* @param z The z axis to set.
|
|
142
|
+
* @returns A matrix with its basis components populated.
|
|
143
|
+
*/
|
|
144
|
+
export declare function makeBasis(x: Vector3.Vector3, y: Vector3.Vector3, z: Vector3.Vector3): Matrix4;
|
|
145
|
+
/**
|
|
146
|
+
* Creates a rotation matrix that is rotated around a given axis by the given
|
|
147
|
+
* angle.
|
|
148
|
+
*
|
|
149
|
+
* @param axis The axis of rotation.
|
|
150
|
+
* @param radians The angle of rotation.
|
|
151
|
+
* @returns A rotation matrix.
|
|
152
|
+
*/
|
|
153
|
+
export declare function makeRotationAxis(axis: Vector3.Vector3, radians: number): Matrix4;
|
|
154
|
+
/**
|
|
155
|
+
* Creates a matrix used for [perspective
|
|
156
|
+
* projections](https://en.wikipedia.org/wiki/3D_projection#Perspective_projection).
|
|
157
|
+
*
|
|
158
|
+
* The viewing volume is frustum-shaped and defined by the six parameters. Left,
|
|
159
|
+
* right, top, and bottom specify coordinates in the near clipping plane where
|
|
160
|
+
* the frustum edges intersect it, and the near and far parameters define the
|
|
161
|
+
* forward distances of the view volume. The resulting volume can be vertically
|
|
162
|
+
* and horizontally asymmetrical around the center of the near plane.
|
|
163
|
+
*
|
|
164
|
+
* @param left The left coordinate at the near plane.
|
|
165
|
+
* @param right The right coordinate at the near plane.
|
|
166
|
+
* @param top The top coordinate at the near plane.
|
|
167
|
+
* @param bottom The bottom coordinate at the near plane.
|
|
168
|
+
* @param near The near distance.
|
|
169
|
+
* @param far The far distance.
|
|
170
|
+
* @returns A matrix representing a view frustum.
|
|
171
|
+
*/
|
|
172
|
+
export declare function makeFrustum(left: number, right: number, top: number, bottom: number, near: number, far: number): Matrix4;
|
|
173
|
+
/**
|
|
174
|
+
* Creates a perspective projection matrix.
|
|
175
|
+
*
|
|
176
|
+
* Related to: gluPerspective. The viewing volume is frustum-shaped amd defined
|
|
177
|
+
* by the four parameters. The fovy and aspect ratio are used to compute the
|
|
178
|
+
* positions of the left, right, top, and bottom sides of the viewing volume in
|
|
179
|
+
* the zNear plane. The fovy is the y field-of-view, the angle made by the top
|
|
180
|
+
* and bottom sides of frustum if they were to intersect. The aspect ratio is
|
|
181
|
+
* the width of the frustum divided by its height. Note that the resulting
|
|
182
|
+
* volume is both vertically and horizontally symmetrical around the center of
|
|
183
|
+
* the near plane.
|
|
184
|
+
*
|
|
185
|
+
* @param near The near Z value.
|
|
186
|
+
* @param far The far Z value.
|
|
187
|
+
* @param fovY The field of view.
|
|
188
|
+
* @param aspect The aspect ratio.
|
|
189
|
+
* @returns A matrix.
|
|
190
|
+
*/
|
|
191
|
+
export declare function makePerspective(near: number, far: number, fovY: number, aspect: number): Matrix4;
|
|
192
|
+
/**
|
|
193
|
+
* Creates an orthographic projection matrix.
|
|
194
|
+
*
|
|
195
|
+
* Related to: gluOrtho. The viewing volume is cube-shaped and defined by
|
|
196
|
+
* the six parameters. The left and right values represent the coordinates of
|
|
197
|
+
* the vertical clipping planes, top and bottom values represent the coordinates
|
|
198
|
+
* of the horizontal clipping planes, and near and far values represent the
|
|
199
|
+
* coordinates of the depth clipping planes.
|
|
200
|
+
*
|
|
201
|
+
* @param left The coordinate of the left horizontal clipping plane.
|
|
202
|
+
* @param right The coordinate of the right horizontal clipping plane.
|
|
203
|
+
* @param bottom The coordinate of the bottom vertical clipping plane.
|
|
204
|
+
* @param top The coordinate of the top vertical clipping plane.
|
|
205
|
+
* @param near The coordinate of the near depth clipping plane.
|
|
206
|
+
* @param far The coordinate of the far depth clipping plane.
|
|
207
|
+
* @returns A matrix.
|
|
208
|
+
*/
|
|
209
|
+
export declare function makeOrthographic(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4;
|
|
210
|
+
/**
|
|
211
|
+
* Matrix becomes a combination of an inverse translation and rotation.
|
|
212
|
+
*
|
|
213
|
+
* Related to: gluLookAt. This creates the inverse of makeLookAtMatrix. The
|
|
214
|
+
* matrix will be an opposite translation from the 'eye' position, and it will
|
|
215
|
+
* rotate things in the opposite direction of the eye-to-center orientation.
|
|
216
|
+
* This is definitely confusing, but the main reason to use this transform is to
|
|
217
|
+
* set up a view matrix for a camera that's looking at a certain point. To
|
|
218
|
+
* achieve the effect of moving the camera somewhere and rotating it so that it
|
|
219
|
+
* points at something, the rest of the world is moved in the opposite direction
|
|
220
|
+
* and rotated in the opposite way around the camera. This way, you get the same
|
|
221
|
+
* effect as moving the actual camera, but all the projection math can still be
|
|
222
|
+
* done with the camera positioned at the origin (which makes it way simpler).
|
|
223
|
+
*
|
|
224
|
+
* @param position The position of the object.
|
|
225
|
+
* @param lookAt The point which the object is looking at.
|
|
226
|
+
* @param up The direction which the object considers up.
|
|
227
|
+
* @returns A matrix.
|
|
228
|
+
*/
|
|
229
|
+
export declare function makeLookAtView(position: Vector3.Vector3, lookAt: Vector3.Vector3, up: Vector3.Vector3): Matrix4;
|
|
230
|
+
/**
|
|
231
|
+
* Matrix becomes a combination of translation and rotation.
|
|
232
|
+
*
|
|
233
|
+
* Matrix becomes a combination of a translation to the position of 'eye' and a
|
|
234
|
+
* rotation matrix which orients an object to point towards 'center' along its
|
|
235
|
+
* z-axis. Use this function if you want an object to look at a point from
|
|
236
|
+
* another point in space.
|
|
237
|
+
*
|
|
238
|
+
* @param position The position of the object.
|
|
239
|
+
* @param lookAt The point which the object is looking at.
|
|
240
|
+
* @param up The direction which the object considers up.
|
|
241
|
+
* @returns A matrix.
|
|
242
|
+
*/
|
|
243
|
+
export declare function makeLookAt(position: Vector3.Vector3, lookAt: Vector3.Vector3, up: Vector3.Vector3): Matrix4;
|
|
244
|
+
/**
|
|
245
|
+
* Returns the inverse of the given matrix. If the determinate of the matrix is
|
|
246
|
+
* zero, then a zero matrix is returned.
|
|
247
|
+
*/
|
|
248
|
+
export declare function invert(matrix: Matrix4): Matrix4;
|
|
249
|
+
/**
|
|
250
|
+
* Returns a rotation matrix looking from position towards target and oriented
|
|
251
|
+
* by an up vector.
|
|
252
|
+
*
|
|
253
|
+
* @param m The matrix to transform.
|
|
254
|
+
* @param position The point from which to look at target.
|
|
255
|
+
* @param target The point to look at.
|
|
256
|
+
* @param up The orientation.
|
|
257
|
+
* @returns A rotation matrix.
|
|
258
|
+
*/
|
|
259
|
+
export declare function lookAt(m: Matrix4, position: Vector3.Vector3, target: Vector3.Vector3, up: Vector3.Vector3): Matrix4;
|
|
260
|
+
/**
|
|
261
|
+
* Returns a post-multiplied matrix.
|
|
262
|
+
*/
|
|
263
|
+
export declare function multiply(a: Matrix4, b: Matrix4): Matrix4;
|
|
264
|
+
/**
|
|
265
|
+
* Returns the [transpose](https://en.wikipedia.org/wiki/Transpose) of the given
|
|
266
|
+
* matrix.
|
|
267
|
+
*/
|
|
268
|
+
export declare function transpose(matrix: Matrix4): Matrix4;
|
|
269
|
+
/**
|
|
270
|
+
* Multiplies the columns of a matrix by the given vector.
|
|
271
|
+
*/
|
|
272
|
+
export declare function scale(matrix: Matrix4, scale: Vector3.Vector3): Matrix4;
|
|
273
|
+
export declare function position(matrix: Matrix4, other: Matrix4): Matrix4;
|
|
274
|
+
/**
|
|
275
|
+
* Returns true if the matrix is an identity matrix.
|
|
276
|
+
*/
|
|
277
|
+
export declare function isIdentity(matrix: Matrix4): boolean;
|
|
278
|
+
/**
|
|
279
|
+
* Returns an object representation of a `Matrix4`.
|
|
280
|
+
*/
|
|
281
|
+
export declare function toObject(m: Matrix4): Matrix4AsObject;
|
|
282
|
+
/**
|
|
283
|
+
* A type guard to check if `obj` is of type `Matrix4`.
|
|
284
|
+
*/
|
|
285
|
+
export declare function isType(obj: unknown): obj is Matrix4;
|