Matrix4.d.ts 6.4 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
	 * @deprecated Use {@link Matrix4#applyToBufferAttribute matrix4.applyToBufferAttribute( attribute )} instead.
	 */
M
Mr.doob 已提交
104 105 106 107 108
	applyToBuffer(
		buffer: BufferAttribute,
		offset?: number,
		length?: number
	): BufferAttribute;
L
lu wang 已提交
109

M
Mr.doob 已提交
110
	applyToBufferAttribute( attribute: BufferAttribute ): BufferAttribute;
L
lu wang 已提交
111

M
Mr.doob 已提交
112
	/**
M
Mugen87 已提交
113 114 115
	 * Computes determinant of this matrix.
	 * Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
	 */
M
Mr.doob 已提交
116
	determinant(): number;
L
lu wang 已提交
117

M
Mr.doob 已提交
118
	/**
M
Mugen87 已提交
119 120
	 * Transposes this matrix.
	 */
M
Mr.doob 已提交
121
	transpose(): Matrix4;
L
lu wang 已提交
122

M
Mr.doob 已提交
123
	/**
M
Mugen87 已提交
124 125
	 * Sets the position component for this matrix from vector v.
	 */
M
Mr.doob 已提交
126
	setPosition( v: Vector3 | number, y?: number, z?: number ): Matrix4;
L
lu wang 已提交
127

M
Mr.doob 已提交
128
	/**
M
Mugen87 已提交
129 130 131
	 * 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 已提交
132
	getInverse( m: Matrix4, throwOnDegeneratee?: boolean ): Matrix4;
L
lu wang 已提交
133

M
Mr.doob 已提交
134
	/**
M
Mugen87 已提交
135 136
	 * Multiplies the columns of this matrix by vector v.
	 */
M
Mr.doob 已提交
137
	scale( v: Vector3 ): Matrix4;
L
lu wang 已提交
138

M
Mr.doob 已提交
139 140
	getMaxScaleOnAxis(): number;
	/**
M
Mugen87 已提交
141 142
	 * Sets this matrix as translation transform.
	 */
M
Mr.doob 已提交
143
	makeTranslation( x: number, y: number, z: number ): Matrix4;
L
lu wang 已提交
144

M
Mr.doob 已提交
145
	/**
M
Mugen87 已提交
146 147 148 149
	 * Sets this matrix as rotation transform around x axis by theta radians.
	 *
	 * @param theta Rotation angle in radians.
	 */
M
Mr.doob 已提交
150
	makeRotationX( theta: number ): Matrix4;
L
lu wang 已提交
151

M
Mr.doob 已提交
152
	/**
M
Mugen87 已提交
153 154 155 156
	 * Sets this matrix as rotation transform around y axis by theta radians.
	 *
	 * @param theta Rotation angle in radians.
	 */
M
Mr.doob 已提交
157
	makeRotationY( theta: number ): Matrix4;
L
lu wang 已提交
158

M
Mr.doob 已提交
159
	/**
M
Mugen87 已提交
160 161 162 163
	 * Sets this matrix as rotation transform around z axis by theta radians.
	 *
	 * @param theta Rotation angle in radians.
	 */
M
Mr.doob 已提交
164
	makeRotationZ( theta: number ): Matrix4;
L
lu wang 已提交
165

M
Mr.doob 已提交
166
	/**
M
Mugen87 已提交
167 168 169 170 171 172
	 * 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 已提交
173
	makeRotationAxis( axis: Vector3, angle: number ): Matrix4;
L
lu wang 已提交
174

M
Mr.doob 已提交
175
	/**
M
Mugen87 已提交
176 177
	 * Sets this matrix as scale transform.
	 */
M
Mr.doob 已提交
178
	makeScale( x: number, y: number, z: number ): Matrix4;
L
lu wang 已提交
179

M
Mr.doob 已提交
180
	/**
M
Mugen87 已提交
181 182
	 * Sets this matrix to the transformation composed of translation, rotation and scale.
	 */
M
Mr.doob 已提交
183
	compose( translation: Vector3, rotation: Quaternion, scale: Vector3 ): Matrix4;
L
lu wang 已提交
184

M
Mr.doob 已提交
185
	/**
M
Mugen87 已提交
186 187 188
	 * Decomposes this matrix into the translation, rotation and scale components.
	 * If parameters are not passed, new instances will be created.
	 */
M
Mr.doob 已提交
189 190 191 192 193
	decompose(
		translation?: Vector3,
		rotation?: Quaternion,
		scale?: Vector3
	): Object[]; // [Vector3, Quaternion, Vector3]
L
lu wang 已提交
194

M
Mr.doob 已提交
195
	/**
M
Mugen87 已提交
196 197
	 * Creates a frustum matrix.
	 */
M
Mr.doob 已提交
198 199 200 201 202 203 204 205
	makePerspective(
		left: number,
		right: number,
		bottom: number,
		top: number,
		near: number,
		far: number
	): Matrix4;
L
lu wang 已提交
206

M
Mr.doob 已提交
207
	/**
M
Mugen87 已提交
208 209
	 * Creates a perspective projection matrix.
	 */
M
Mr.doob 已提交
210 211 212 213 214 215
	makePerspective(
		fov: number,
		aspect: number,
		near: number,
		far: number
	): Matrix4;
L
lu wang 已提交
216

M
Mr.doob 已提交
217
	/**
M
Mugen87 已提交
218 219
	 * Creates an orthographic projection matrix.
	 */
M
Mr.doob 已提交
220 221 222 223 224 225 226 227 228 229 230 231 232
	makeOrthographic(
		left: number,
		right: number,
		top: number,
		bottom: number,
		near: number,
		far: number
	): Matrix4;
	equals( matrix: Matrix4 ): boolean;
	fromArray( array: number[], offset?: number ): Matrix4;
	toArray(): number[];

	/**
M
Mugen87 已提交
233 234
	 * @deprecated Use {@link Matrix4#copyPosition .copyPosition()} instead.
	 */
M
Mr.doob 已提交
235
	extractPosition( m: Matrix4 ): Matrix4;
L
lu wang 已提交
236

M
Mr.doob 已提交
237
	/**
M
Mugen87 已提交
238 239
	 * @deprecated Use {@link Matrix4#makeRotationFromQuaternion .makeRotationFromQuaternion()} instead.
	 */
M
Mr.doob 已提交
240
	setRotationFromQuaternion( q: Quaternion ): Matrix4;
L
lu wang 已提交
241

M
Mr.doob 已提交
242
	/**
M
Mugen87 已提交
243 244
	 * @deprecated Use {@link Vector3#applyMatrix4 vector.applyMatrix4( matrix )} instead.
	 */
M
Mr.doob 已提交
245
	multiplyVector3( v: any ): any;
L
lu wang 已提交
246

M
Mr.doob 已提交
247
	/**
M
Mugen87 已提交
248 249
	 * @deprecated Use {@link Vector4#applyMatrix4 vector.applyMatrix4( matrix )} instead.
	 */
M
Mr.doob 已提交
250
	multiplyVector4( v: any ): any;
L
lu wang 已提交
251

M
Mr.doob 已提交
252
	/**
M
Mugen87 已提交
253 254
	 * @deprecated This method has been removed completely.
	 */
M
Mr.doob 已提交
255
	multiplyVector3Array( array: number[] ): number[];
L
lu wang 已提交
256

M
Mr.doob 已提交
257
	/**
M
Mugen87 已提交
258 259
	 * @deprecated Use {@link Vector3#transformDirection Vector3.transformDirection( matrix )} instead.
	 */
M
Mr.doob 已提交
260
	rotateAxis( v: any ): void;
L
lu wang 已提交
261

M
Mr.doob 已提交
262
	/**
M
Mugen87 已提交
263 264
	 * @deprecated Use {@link Vector3#applyMatrix4 vector.applyMatrix4( matrix )} instead.
	 */
M
Mr.doob 已提交
265
	crossVector( v: any ): void;
L
lu wang 已提交
266

M
Mr.doob 已提交
267
	/**
M
Mugen87 已提交
268 269
	 * @deprecated Use {@link Matrix4#toArray .toArray()} instead.
	 */
M
Mr.doob 已提交
270
	flattenToArrayOffset( array: number[], offset: number ): number[];
M
Mr.doob 已提交
271

L
lu wang 已提交
272
}