Matrix4.d.ts 7.2 KB
Newer Older
L
lu wang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
import { Vector3 } from './Vector3';
import { Euler } from './Euler';
import { Quaternion } from './Quaternion';
import { BufferAttribute } from './../core/BufferAttribute';
import { Matrix } from './Matrix3';
/**
 * A 4x4 Matrix.
 *
 * @example
 * // Simple rig for rotating around 3 axes
 * var m = new THREE.Matrix4();
 * var m1 = new THREE.Matrix4();
 * var m2 = new THREE.Matrix4();
 * var m3 = new THREE.Matrix4();
 * var alpha = 0;
 * var beta = Math.PI;
 * var gamma = Math.PI/2;
 * m1.makeRotationX( alpha );
 * m2.makeRotationY( beta );
 * m3.makeRotationZ( gamma );
 * m.multiplyMatrices( m1, m2 );
 * m.multiply( m3 );
 */
export class Matrix4 implements Matrix {
M
Mr.doob 已提交
25 26

	constructor();
L
lu wang 已提交
27

M
Mr.doob 已提交
28
	/**
M
Mugen87 已提交
29 30
	 * Array with matrix values.
	 */
M
Mr.doob 已提交
31
	elements: number[];
L
lu wang 已提交
32

M
Mr.doob 已提交
33
	/**
M
Mugen87 已提交
34 35
	 * Sets all fields of this matrix.
	 */
M
Mr.doob 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
	set(
		n11: number,
		n12: number,
		n13: number,
		n14: number,
		n21: number,
		n22: number,
		n23: number,
		n24: number,
		n31: number,
		n32: number,
		n33: number,
		n34: number,
		n41: number,
		n42: number,
		n43: number,
		n44: number
	): Matrix4;

	/**
M
Mugen87 已提交
56 57
	 * Resets this matrix to identity.
	 */
M
Mr.doob 已提交
58 59 60 61 62 63
	identity(): Matrix4;
	clone(): this;
	copy( m: Matrix4 ): this;
	copyPosition( m: Matrix4 ): Matrix4;
	extractBasis( xAxis: Vector3, yAxis: Vector3, zAxis: Vector3 ): Matrix4;
	makeBasis( xAxis: Vector3, yAxis: Vector3, zAxis: Vector3 ): Matrix4;
L
lu wang 已提交
64

M
Mr.doob 已提交
65
	/**
M
Mugen87 已提交
66 67
	 * Copies the rotation component of the supplied matrix m into this matrix rotation component.
	 */
M
Mr.doob 已提交
68 69 70 71
	extractRotation( m: Matrix4 ): Matrix4;
	makeRotationFromEuler( euler: Euler ): Matrix4;
	makeRotationFromQuaternion( q: Quaternion ): Matrix4;
	/**
M
Mugen87 已提交
72 73
	 * Constructs a rotation matrix, looking from eye towards center with defined up vector.
	 */
M
Mr.doob 已提交
74
	lookAt( eye: Vector3, target: Vector3, up: Vector3 ): Matrix4;
L
lu wang 已提交
75

M
Mr.doob 已提交
76
	/**
M
Mugen87 已提交
77 78
	 * Multiplies this matrix by m.
	 */
M
Mr.doob 已提交
79
	multiply( m: Matrix4 ): Matrix4;
L
lu wang 已提交
80

M
Mr.doob 已提交
81
	premultiply( m: Matrix4 ): Matrix4;
L
lu wang 已提交
82

M
Mr.doob 已提交
83
	/**
M
Mugen87 已提交
84 85
	 * Sets this matrix to a x b.
	 */
M
Mr.doob 已提交
86
	multiplyMatrices( a: Matrix4, b: Matrix4 ): Matrix4;
L
lu wang 已提交
87

M
Mr.doob 已提交
88
	/**
M
Mugen87 已提交
89 90 91 92 93
	 * Sets this matrix to a x b and stores the result into the flat array r.
	 * r can be either a regular Array or a TypedArray.
	 *
	 * @deprecated This method has been removed completely.
	 */
M
Mr.doob 已提交
94
	multiplyToArray( a: Matrix4, b: Matrix4, r: number[] ): Matrix4;
L
lu wang 已提交
95

M
Mr.doob 已提交
96
	/**
M
Mugen87 已提交
97 98
	 * Multiplies this matrix by s.
	 */
M
Mr.doob 已提交
99
	multiplyScalar( s: number ): Matrix4;
L
lu wang 已提交
100

M
Mr.doob 已提交
101
	/**
M
Mugen87 已提交
102 103 104
	 * Computes determinant of this matrix.
	 * Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
	 */
M
Mr.doob 已提交
105
	determinant(): number;
L
lu wang 已提交
106

M
Mr.doob 已提交
107
	/**
M
Mugen87 已提交
108 109
	 * Transposes this matrix.
	 */
M
Mr.doob 已提交
110
	transpose(): Matrix4;
L
lu wang 已提交
111

M
Mr.doob 已提交
112
	/**
M
Mugen87 已提交
113 114
	 * Sets the position component for this matrix from vector v.
	 */
M
Mr.doob 已提交
115
	setPosition( v: Vector3 | number, y?: number, z?: number ): Matrix4;
L
lu wang 已提交
116

M
Mr.doob 已提交
117
	/**
M
Mugen87 已提交
118 119 120
	 * Sets this matrix to the inverse of matrix m.
	 * Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm.
	 */
M
Mr.doob 已提交
121
	getInverse( m: Matrix4, throwOnDegeneratee?: boolean ): Matrix4;
L
lu wang 已提交
122

M
Mr.doob 已提交
123
	/**
M
Mugen87 已提交
124 125
	 * Multiplies the columns of this matrix by vector v.
	 */
M
Mr.doob 已提交
126
	scale( v: Vector3 ): Matrix4;
L
lu wang 已提交
127

M
Mr.doob 已提交
128 129
	getMaxScaleOnAxis(): number;
	/**
M
Mugen87 已提交
130 131
	 * Sets this matrix as translation transform.
	 */
M
Mr.doob 已提交
132
	makeTranslation( x: number, y: number, z: number ): Matrix4;
L
lu wang 已提交
133

M
Mr.doob 已提交
134
	/**
M
Mugen87 已提交
135 136 137 138
	 * Sets this matrix as rotation transform around x axis by theta radians.
	 *
	 * @param theta Rotation angle in radians.
	 */
M
Mr.doob 已提交
139
	makeRotationX( theta: number ): Matrix4;
L
lu wang 已提交
140

M
Mr.doob 已提交
141
	/**
M
Mugen87 已提交
142 143 144 145
	 * Sets this matrix as rotation transform around y axis by theta radians.
	 *
	 * @param theta Rotation angle in radians.
	 */
M
Mr.doob 已提交
146
	makeRotationY( theta: number ): Matrix4;
L
lu wang 已提交
147

M
Mr.doob 已提交
148
	/**
M
Mugen87 已提交
149 150 151 152
	 * Sets this matrix as rotation transform around z axis by theta radians.
	 *
	 * @param theta Rotation angle in radians.
	 */
M
Mr.doob 已提交
153
	makeRotationZ( theta: number ): Matrix4;
L
lu wang 已提交
154

M
Mr.doob 已提交
155
	/**
M
Mugen87 已提交
156 157 158 159 160 161
	 * Sets this matrix as rotation transform around axis by angle radians.
	 * Based on http://www.gamedev.net/reference/articles/article1199.asp.
	 *
	 * @param axis Rotation axis.
	 * @param theta Rotation angle in radians.
	 */
M
Mr.doob 已提交
162
	makeRotationAxis( axis: Vector3, angle: number ): Matrix4;
L
lu wang 已提交
163

M
Mr.doob 已提交
164
	/**
M
Mugen87 已提交
165 166
	 * Sets this matrix as scale transform.
	 */
M
Mr.doob 已提交
167
	makeScale( x: number, y: number, z: number ): Matrix4;
L
lu wang 已提交
168

M
Mr.doob 已提交
169
	/**
M
Mugen87 已提交
170 171
	 * Sets this matrix to the transformation composed of translation, rotation and scale.
	 */
M
Mr.doob 已提交
172
	compose( translation: Vector3, rotation: Quaternion, scale: Vector3 ): Matrix4;
L
lu wang 已提交
173

M
Mr.doob 已提交
174
	/**
M
Mugen87 已提交
175 176 177
	 * Decomposes this matrix into the translation, rotation and scale components.
	 * If parameters are not passed, new instances will be created.
	 */
M
Mr.doob 已提交
178 179 180 181 182
	decompose(
		translation?: Vector3,
		rotation?: Quaternion,
		scale?: Vector3
	): Object[]; // [Vector3, Quaternion, Vector3]
L
lu wang 已提交
183

M
Mr.doob 已提交
184
	/**
M
Mugen87 已提交
185 186
	 * Creates a frustum matrix.
	 */
M
Mr.doob 已提交
187 188 189 190 191 192 193 194
	makePerspective(
		left: number,
		right: number,
		bottom: number,
		top: number,
		near: number,
		far: number
	): Matrix4;
L
lu wang 已提交
195

M
Mr.doob 已提交
196
	/**
M
Mugen87 已提交
197 198
	 * Creates a perspective projection matrix.
	 */
M
Mr.doob 已提交
199 200 201 202 203 204
	makePerspective(
		fov: number,
		aspect: number,
		near: number,
		far: number
	): Matrix4;
L
lu wang 已提交
205

M
Mr.doob 已提交
206
	/**
M
Mugen87 已提交
207 208
	 * Creates an orthographic projection matrix.
	 */
M
Mr.doob 已提交
209 210 211 212 213 214 215 216 217
	makeOrthographic(
		left: number,
		right: number,
		top: number,
		bottom: number,
		near: number,
		far: number
	): Matrix4;
	equals( matrix: Matrix4 ): boolean;
218 219 220 221 222 223

	/**
	 * Sets the values of this matrix from the provided array.
	 * @param array the source array.
	 * @param offset (optional) offset into the array. Default is 0.
	 */
M
Mr.doob 已提交
224
	fromArray( array: number[], offset?: number ): Matrix4;
225

226 227 228 229 230 231 232 233 234 235 236 237 238
	/**
	 * Sets the values of this matrix from the provided array-like.
	 * @param array the source array-like.
	 * @param offset (optional) offset into the array-like. Default is 0.
	 */
	fromArray( array: ArrayLike<number>, offset?: number ): Matrix4;

	/**
	 * Returns an array with the values of this matrix, or copies them into the provided array.
	 * @param array (optional) array to store the matrix to. If this is not provided, a new array will be created.
	 * @param offset (optional) optional offset into the array.
	 * @return The created or provided array.
	 */
239
	toArray( array?: number[], offset?: number ): number[];
M
Mr.doob 已提交
240

241 242 243 244 245 246 247 248
	/**
	 * Copies he values of this matrix into the provided array-like.
	 * @param array array-like to store the matrix to.
	 * @param offset (optional) optional offset into the array-like.
	 * @return The provided array-like.
	 */
	toArray( array?: ArrayLike<number>, offset?: number ): ArrayLike<number>;

M
Mr.doob 已提交
249
	/**
M
Mugen87 已提交
250 251
	 * @deprecated Use {@link Matrix4#copyPosition .copyPosition()} instead.
	 */
M
Mr.doob 已提交
252
	extractPosition( m: Matrix4 ): Matrix4;
L
lu wang 已提交
253

M
Mr.doob 已提交
254
	/**
M
Mugen87 已提交
255 256
	 * @deprecated Use {@link Matrix4#makeRotationFromQuaternion .makeRotationFromQuaternion()} instead.
	 */
M
Mr.doob 已提交
257
	setRotationFromQuaternion( q: Quaternion ): Matrix4;
L
lu wang 已提交
258

M
Mr.doob 已提交
259
	/**
M
Mugen87 已提交
260 261
	 * @deprecated Use {@link Vector3#applyMatrix4 vector.applyMatrix4( matrix )} instead.
	 */
M
Mr.doob 已提交
262
	multiplyVector3( v: any ): any;
L
lu wang 已提交
263

M
Mr.doob 已提交
264
	/**
M
Mugen87 已提交
265 266
	 * @deprecated Use {@link Vector4#applyMatrix4 vector.applyMatrix4( matrix )} instead.
	 */
M
Mr.doob 已提交
267
	multiplyVector4( v: any ): any;
L
lu wang 已提交
268

M
Mr.doob 已提交
269
	/**
M
Mugen87 已提交
270 271
	 * @deprecated This method has been removed completely.
	 */
M
Mr.doob 已提交
272
	multiplyVector3Array( array: number[] ): number[];
L
lu wang 已提交
273

M
Mr.doob 已提交
274
	/**
M
Mugen87 已提交
275 276
	 * @deprecated Use {@link Vector3#transformDirection Vector3.transformDirection( matrix )} instead.
	 */
M
Mr.doob 已提交
277
	rotateAxis( v: any ): void;
L
lu wang 已提交
278

M
Mr.doob 已提交
279
	/**
M
Mugen87 已提交
280 281
	 * @deprecated Use {@link Vector3#applyMatrix4 vector.applyMatrix4( matrix )} instead.
	 */
M
Mr.doob 已提交
282
	crossVector( v: any ): void;
L
lu wang 已提交
283

M
Mr.doob 已提交
284
	/**
M
Mugen87 已提交
285 286
	 * @deprecated Use {@link Matrix4#toArray .toArray()} instead.
	 */
M
Mr.doob 已提交
287
	flattenToArrayOffset( array: number[], offset: number ): number[];
M
Mr.doob 已提交
288

L
lu wang 已提交
289
}