1 | import { CoordinateSystem } from "../constants.js";
|
2 | import { Euler } from "./Euler.js";
|
3 | import { Matrix3 } from "./Matrix3.js";
|
4 | import { Quaternion } from "./Quaternion.js";
|
5 | import { Vector3 } from "./Vector3.js";
|
6 |
|
7 | export type Matrix4Tuple = [
|
8 | n11: number,
|
9 | n12: number,
|
10 | n13: number,
|
11 | n14: number,
|
12 | n21: number,
|
13 | n22: number,
|
14 | n23: number,
|
15 | n24: number,
|
16 | n31: number,
|
17 | n32: number,
|
18 | n33: number,
|
19 | n34: number,
|
20 | n41: number,
|
21 | n42: number,
|
22 | n43: number,
|
23 | n44: number,
|
24 | ];
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | export class Matrix4 {
|
45 | readonly isMatrix4: true;
|
46 |
|
47 | |
48 |
|
49 |
|
50 |
|
51 | elements: Matrix4Tuple;
|
52 |
|
53 | |
54 |
|
55 |
|
56 | constructor();
|
57 | /**
|
58 | * Creates a 4x4 matrix with the given arguments in row-major order.
|
59 | */
|
60 | constructor(
|
61 | n11: number,
|
62 | n12: number,
|
63 | n13: number,
|
64 | n14: number,
|
65 | n21: number,
|
66 | n22: number,
|
67 | n23: number,
|
68 | n24: number,
|
69 | n31: number,
|
70 | n32: number,
|
71 | n33: number,
|
72 | n34: number,
|
73 | n41: number,
|
74 | n42: number,
|
75 | n43: number,
|
76 | n44: number,
|
77 | );
|
78 |
|
79 | /**
|
80 | * Sets all fields of this matrix.
|
81 | */
|
82 | set(
|
83 | n11: number,
|
84 | n12: number,
|
85 | n13: number,
|
86 | n14: number,
|
87 | n21: number,
|
88 | n22: number,
|
89 | n23: number,
|
90 | n24: number,
|
91 | n31: number,
|
92 | n32: number,
|
93 | n33: number,
|
94 | n34: number,
|
95 | n41: number,
|
96 | n42: number,
|
97 | n43: number,
|
98 | n44: number,
|
99 | ): this;
|
100 |
|
101 | /**
|
102 | * Resets this matrix to identity.
|
103 | */
|
104 | identity(): this;
|
105 |
|
106 | clone(): Matrix4;
|
107 |
|
108 | copy(m: Matrix4): this;
|
109 |
|
110 | copyPosition(m: Matrix4): this;
|
111 |
|
112 | /**
|
113 | * Set the upper 3x3 elements of this matrix to the values of the Matrix3 m.
|
114 | */
|
115 | setFromMatrix3(m: Matrix3): this;
|
116 |
|
117 | extractBasis(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): this;
|
118 |
|
119 | makeBasis(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): this;
|
120 |
|
121 | /**
|
122 | * Copies the rotation component of the supplied matrix m into this matrix rotation component.
|
123 | */
|
124 | extractRotation(m: Matrix4): this;
|
125 |
|
126 | makeRotationFromEuler(euler: Euler): this;
|
127 |
|
128 | makeRotationFromQuaternion(q: Quaternion): this;
|
129 |
|
130 | /**
|
131 | * Constructs a rotation matrix, looking from eye towards center with defined up vector.
|
132 | */
|
133 | lookAt(eye: Vector3, target: Vector3, up: Vector3): this;
|
134 |
|
135 | /**
|
136 | * Multiplies this matrix by m.
|
137 | */
|
138 | multiply(m: Matrix4): this;
|
139 |
|
140 | premultiply(m: Matrix4): this;
|
141 |
|
142 | /**
|
143 | * Sets this matrix to a x b.
|
144 | */
|
145 | multiplyMatrices(a: Matrix4, b: Matrix4): this;
|
146 |
|
147 | /**
|
148 | * Multiplies this matrix by s.
|
149 | */
|
150 | multiplyScalar(s: number): this;
|
151 |
|
152 | /**
|
153 | * Computes determinant of this matrix.
|
154 | * Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
|
155 | */
|
156 | determinant(): number;
|
157 |
|
158 | /**
|
159 | * Transposes this matrix.
|
160 | */
|
161 | transpose(): this;
|
162 |
|
163 | /**
|
164 | * Sets the position component for this matrix from vector v.
|
165 | */
|
166 | setPosition(v: Vector3): this;
|
167 | setPosition(x: number, y: number, z: number): this;
|
168 |
|
169 | /**
|
170 | * Inverts this matrix.
|
171 | */
|
172 | invert(): this;
|
173 |
|
174 | /**
|
175 | * Multiplies the columns of this matrix by vector v.
|
176 | */
|
177 | scale(v: Vector3): this;
|
178 |
|
179 | getMaxScaleOnAxis(): number;
|
180 |
|
181 | /**
|
182 | * Sets this matrix as translation transform.
|
183 | */
|
184 | makeTranslation(v: Vector3): this;
|
185 | makeTranslation(x: number, y: number, z: number): this;
|
186 |
|
187 | /**
|
188 | * Sets this matrix as rotation transform around x axis by theta radians.
|
189 | *
|
190 | * @param theta Rotation angle in radians.
|
191 | */
|
192 | makeRotationX(theta: number): this;
|
193 |
|
194 | /**
|
195 | * Sets this matrix as rotation transform around y axis by theta radians.
|
196 | *
|
197 | * @param theta Rotation angle in radians.
|
198 | */
|
199 | makeRotationY(theta: number): this;
|
200 |
|
201 | /**
|
202 | * Sets this matrix as rotation transform around z axis by theta radians.
|
203 | *
|
204 | * @param theta Rotation angle in radians.
|
205 | */
|
206 | makeRotationZ(theta: number): this;
|
207 |
|
208 | /**
|
209 | * Sets this matrix as rotation transform around axis by angle radians.
|
210 | * Based on http://www.gamedev.net/reference/articles/article1199.asp.
|
211 | *
|
212 | * @param axis Rotation axis.
|
213 | * @param angle Rotation angle in radians.
|
214 | */
|
215 | makeRotationAxis(axis: Vector3, angle: number): this;
|
216 |
|
217 | /**
|
218 | * Sets this matrix as scale transform.
|
219 | */
|
220 | makeScale(x: number, y: number, z: number): this;
|
221 |
|
222 | /**
|
223 | * Sets this matrix as shear transform.
|
224 | */
|
225 | makeShear(xy: number, xz: number, yx: number, yz: number, zx: number, zy: number): this;
|
226 |
|
227 | /**
|
228 | * Sets this matrix to the transformation composed of translation, rotation and scale.
|
229 | */
|
230 | compose(position: Vector3, quaternion: Quaternion, scale: Vector3): this;
|
231 |
|
232 | /**
|
233 | * Decomposes this matrix into it's position, quaternion and scale components.
|
234 | */
|
235 | decompose(position: Vector3, quaternion: Quaternion, scale: Vector3): this;
|
236 |
|
237 | /**
|
238 | * Creates a perspective projection matrix.
|
239 | */
|
240 | makePerspective(
|
241 | left: number,
|
242 | right: number,
|
243 | top: number,
|
244 | bottom: number,
|
245 | near: number,
|
246 | far: number,
|
247 | coordinateSystem?: CoordinateSystem,
|
248 | ): this;
|
249 |
|
250 | /**
|
251 | * Creates an orthographic projection matrix.
|
252 | */
|
253 | makeOrthographic(
|
254 | left: number,
|
255 | right: number,
|
256 | top: number,
|
257 | bottom: number,
|
258 | near: number,
|
259 | far: number,
|
260 | coordinateSystem?: CoordinateSystem,
|
261 | ): this;
|
262 |
|
263 | equals(matrix: Matrix4): boolean;
|
264 |
|
265 | /**
|
266 | * Sets the values of this matrix from the provided array or array-like.
|
267 | * @param array the source array or array-like.
|
268 | * @param offset (optional) offset into the array-like. Default is 0.
|
269 | */
|
270 | fromArray(array: ArrayLike<number>, offset?: number): this;
|
271 |
|
272 | /**
|
273 | * Writes the elements of this matrix to an array in
|
274 | * {@link https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major} format.
|
275 | */
|
276 | toArray(): Matrix4Tuple;
|
277 | /**
|
278 | * Writes the elements of this matrix to an array in
|
279 | * {@link https:
|
280 | * @param array array to store the resulting vector in.
|
281 | * @param offset (optional) offset in the array at which to put the result.
|
282 | */
|
283 | toArray<TArray extends ArrayLike<number>>(array: TArray, offset?: number): TArray;
|
284 | }
|