1 | import { BufferAttribute } from "../core/BufferAttribute.js";
|
2 | import { Matrix4 } from "./Matrix4.js";
|
3 | import { QuaternionLike } from "./Quaternion.js";
|
4 |
|
5 | export type Vector4Tuple = [number, number, number, number];
|
6 |
|
7 | export interface Vector4Like {
|
8 | readonly x: number;
|
9 | readonly y: number;
|
10 | readonly z: number;
|
11 | readonly w: number;
|
12 | }
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | export class Vector4 {
|
18 | constructor(x?: number, y?: number, z?: number, w?: number);
|
19 |
|
20 | /**
|
21 | * @default 0
|
22 | */
|
23 | x: number;
|
24 |
|
25 | /**
|
26 | * @default 0
|
27 | */
|
28 | y: number;
|
29 |
|
30 | /**
|
31 | * @default 0
|
32 | */
|
33 | z: number;
|
34 |
|
35 | /**
|
36 | * @default 0
|
37 | */
|
38 | w: number;
|
39 |
|
40 | width: number;
|
41 | height: number;
|
42 | readonly isVector4: true;
|
43 |
|
44 | /**
|
45 | * Sets value of this vector.
|
46 | */
|
47 | set(x: number, y: number, z: number, w: number): this;
|
48 |
|
49 | /**
|
50 | * Sets all values of this vector.
|
51 | */
|
52 | setScalar(scalar: number): this;
|
53 |
|
54 | /**
|
55 | * Sets X component of this vector.
|
56 | */
|
57 | setX(x: number): this;
|
58 |
|
59 | /**
|
60 | * Sets Y component of this vector.
|
61 | */
|
62 | setY(y: number): this;
|
63 |
|
64 | /**
|
65 | * Sets Z component of this vector.
|
66 | */
|
67 | setZ(z: number): this;
|
68 |
|
69 | /**
|
70 | * Sets w component of this vector.
|
71 | */
|
72 | setW(w: number): this;
|
73 |
|
74 | setComponent(index: number, value: number): this;
|
75 |
|
76 | getComponent(index: number): number;
|
77 |
|
78 | /**
|
79 | * Clones this vector.
|
80 | */
|
81 | clone(): this;
|
82 |
|
83 | /**
|
84 | * Copies value of v to this vector.
|
85 | */
|
86 | copy(v: Vector4Like): this;
|
87 |
|
88 | /**
|
89 | * Adds v to this vector.
|
90 | */
|
91 | add(v: Vector4Like): this;
|
92 |
|
93 | addScalar(scalar: number): this;
|
94 |
|
95 | /**
|
96 | * Sets this vector to a + b.
|
97 | */
|
98 | addVectors(a: Vector4Like, b: Vector4Like): this;
|
99 |
|
100 | addScaledVector(v: Vector4Like, s: number): this;
|
101 | /**
|
102 | * Subtracts v from this vector.
|
103 | */
|
104 | sub(v: Vector4Like): this;
|
105 |
|
106 | subScalar(s: number): this;
|
107 |
|
108 | /**
|
109 | * Sets this vector to a - b.
|
110 | */
|
111 | subVectors(a: Vector4Like, b: Vector4Like): this;
|
112 |
|
113 | multiply(v: Vector4Like): this;
|
114 |
|
115 | /**
|
116 | * Multiplies this vector by scalar s.
|
117 | */
|
118 | multiplyScalar(s: number): this;
|
119 |
|
120 | applyMatrix4(m: Matrix4): this;
|
121 |
|
122 | divide(v: Vector4Like): this;
|
123 |
|
124 | /**
|
125 | * Divides this vector by scalar s.
|
126 | * Set vector to ( 0, 0, 0 ) if s == 0.
|
127 | */
|
128 | divideScalar(s: number): this;
|
129 |
|
130 | /**
|
131 | * http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
|
132 | * @param q is assumed to be normalized
|
133 | */
|
134 | setAxisAngleFromQuaternion(q: QuaternionLike): this;
|
135 |
|
136 | /**
|
137 | * http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
|
138 | * @param m assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
|
139 | */
|
140 | setAxisAngleFromRotationMatrix(m: Matrix4): this;
|
141 |
|
142 | /**
|
143 | * Sets this vector to the position elements of the
|
144 | * [transformation matrix]{@link https:
|
145 | */
|
146 | setFromMatrixPosition(m: Matrix4): this;
|
147 |
|
148 | min(v: Vector4Like): this;
|
149 | max(v: Vector4Like): this;
|
150 | clamp(min: Vector4Like, max: Vector4Like): this;
|
151 | clampScalar(min: number, max: number): this;
|
152 | floor(): this;
|
153 | ceil(): this;
|
154 | round(): this;
|
155 | roundToZero(): this;
|
156 |
|
157 | |
158 |
|
159 |
|
160 | negate(): this;
|
161 |
|
162 | |
163 |
|
164 |
|
165 | dot(v: Vector4Like): number;
|
166 |
|
167 | |
168 |
|
169 |
|
170 | lengthSq(): number;
|
171 |
|
172 | |
173 |
|
174 |
|
175 | length(): number;
|
176 |
|
177 | |
178 |
|
179 |
|
180 |
|
181 |
|
182 | manhattanLength(): number;
|
183 |
|
184 | |
185 |
|
186 |
|
187 | normalize(): this;
|
188 |
|
189 | |
190 |
|
191 |
|
192 | setLength(length: number): this;
|
193 |
|
194 | |
195 |
|
196 |
|
197 | lerp(v: Vector4Like, alpha: number): this;
|
198 |
|
199 | lerpVectors(v1: Vector4Like, v2: Vector4Like, alpha: number): this;
|
200 |
|
201 | |
202 |
|
203 |
|
204 | equals(v: Vector4Like): boolean;
|
205 |
|
206 | |
207 |
|
208 |
|
209 |
|
210 |
|
211 | fromArray(array: number[] | ArrayLike<number>, offset?: number): this;
|
212 |
|
213 | |
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 | toArray(array?: number[], offset?: number): number[];
|
220 | toArray(array?: Vector4Tuple, offset?: 0): Vector4Tuple;
|
221 |
|
222 | |
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 | toArray(array: ArrayLike<number>, offset?: number): ArrayLike<number>;
|
229 |
|
230 | fromBufferAttribute(attribute: BufferAttribute, index: number): this;
|
231 |
|
232 | |
233 |
|
234 |
|
235 | random(): this;
|
236 |
|
237 | |
238 |
|
239 |
|
240 | [Symbol.iterator](): Iterator<number>;
|
241 | }
|