1 | import { Euler } from './Euler';
|
2 | import { Vector3 } from './Vector3';
|
3 | import { Matrix4 } from './Matrix4';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export class Quaternion {
|
15 | |
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | constructor(x?: number, y?: number, z?: number, w?: number);
|
22 |
|
23 | /**
|
24 | * @default 0
|
25 | */
|
26 | x: number;
|
27 |
|
28 | /**
|
29 | * @default 0
|
30 | */
|
31 | y: number;
|
32 |
|
33 | /**
|
34 | * @default 0
|
35 | */
|
36 | z: number;
|
37 |
|
38 | /**
|
39 | * @default 1
|
40 | */
|
41 | w: number;
|
42 | readonly isQuaternion: true;
|
43 |
|
44 | /**
|
45 | * Sets values of this quaternion.
|
46 | */
|
47 | set(x: number, y: number, z: number, w: number): Quaternion;
|
48 |
|
49 | /**
|
50 | * Clones this quaternion.
|
51 | */
|
52 | clone(): this;
|
53 |
|
54 | /**
|
55 | * Copies values of q to this quaternion.
|
56 | */
|
57 | copy(q: Quaternion): this;
|
58 |
|
59 | /**
|
60 | * Sets this quaternion from rotation specified by Euler angles.
|
61 | */
|
62 | setFromEuler(euler: Euler, update?: boolean): Quaternion;
|
63 |
|
64 | /**
|
65 | * Sets this quaternion from rotation specified by axis and angle.
|
66 | * Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm.
|
67 | * Axis have to be normalized, angle is in radians.
|
68 | */
|
69 | setFromAxisAngle(axis: Vector3, angle: number): Quaternion;
|
70 |
|
71 | /**
|
72 | * Sets this quaternion from rotation component of m. Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm.
|
73 | */
|
74 | setFromRotationMatrix(m: Matrix4): Quaternion;
|
75 | setFromUnitVectors(vFrom: Vector3, vTo: Vector3): Quaternion;
|
76 | angleTo(q: Quaternion): number;
|
77 | rotateTowards(q: Quaternion, step: number): Quaternion;
|
78 |
|
79 | identity(): Quaternion;
|
80 |
|
81 | /**
|
82 | * Inverts this quaternion.
|
83 | */
|
84 | invert(): Quaternion;
|
85 |
|
86 | conjugate(): Quaternion;
|
87 | dot(v: Quaternion): number;
|
88 | lengthSq(): number;
|
89 |
|
90 | /**
|
91 | * Computes length of this quaternion.
|
92 | */
|
93 | length(): number;
|
94 |
|
95 | /**
|
96 | * Normalizes this quaternion.
|
97 | */
|
98 | normalize(): Quaternion;
|
99 |
|
100 | /**
|
101 | * Multiplies this quaternion by b.
|
102 | */
|
103 | multiply(q: Quaternion): Quaternion;
|
104 | premultiply(q: Quaternion): Quaternion;
|
105 |
|
106 | /**
|
107 | * Sets this quaternion to a x b
|
108 | * Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm.
|
109 | */
|
110 | multiplyQuaternions(a: Quaternion, b: Quaternion): Quaternion;
|
111 |
|
112 | slerp(qb: Quaternion, t: number): Quaternion;
|
113 | slerpQuaternions(qa: Quaternion, qb: Quaternion, t: number): Quaternion;
|
114 | equals(v: Quaternion): boolean;
|
115 |
|
116 | /**
|
117 | * Sets this quaternion's x, y, z and w value from the provided array or array-like.
|
118 | * @param array the source array or array-like.
|
119 | * @param offset (optional) offset into the array. Default is 0.
|
120 | */
|
121 | fromArray(array: number[] | ArrayLike<number>, offset?: number): this;
|
122 |
|
123 | /**
|
124 | * Returns an array [x, y, z, w], or copies x, y, z and w into the provided array.
|
125 | * @param array (optional) array to store the quaternion to. If this is not provided, a new array will be created.
|
126 | * @param offset (optional) optional offset into the array.
|
127 | * @return The created or provided array.
|
128 | */
|
129 | toArray(array?: number[], offset?: number): number[];
|
130 |
|
131 | /**
|
132 | * Copies x, y, z and w into the provided array-like.
|
133 | * @param array array-like to store the quaternion to.
|
134 | * @param offset (optional) optional offset into the array.
|
135 | * @return The provided array-like.
|
136 | */
|
137 | toArray(array: ArrayLike<number>, offset?: number): ArrayLike<number>;
|
138 |
|
139 | _onChange(callback: () => void): Quaternion;
|
140 | _onChangeCallback: () => void;
|
141 |
|
142 | static slerpFlat(
|
143 | dst: number[],
|
144 | dstOffset: number,
|
145 | src0: number[],
|
146 | srcOffset: number,
|
147 | src1: number[],
|
148 | stcOffset1: number,
|
149 | t: number,
|
150 | ): Quaternion;
|
151 |
|
152 | static multiplyQuaternionsFlat(
|
153 | dst: number[],
|
154 | dstOffset: number,
|
155 | src0: number[],
|
156 | srcOffset: number,
|
157 | src1: number[],
|
158 | stcOffset1: number,
|
159 | ): number[];
|
160 |
|
161 | /**
|
162 | * @deprecated Use qm.slerpQuaternions( qa, qb, t ) instead..
|
163 | */
|
164 | static slerp(qa: Quaternion, qb: Quaternion, qm: Quaternion, t: number): number;
|
165 |
|
166 | /**
|
167 | * @deprecated Use {@link Vector#applyQuaternion vector.applyQuaternion( quaternion )} instead.
|
168 | */
|
169 | multiplyVector3(v: any): any;
|
170 |
|
171 | |
172 |
|
173 |
|
174 | inverse(): Quaternion;
|
175 | }
|