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