mathue 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2189 @@
1
+ export declare interface AdditiveGroup<T> {
2
+ add(other: T): T;
3
+ subtract(other: T): T;
4
+ }
5
+
6
+ export declare interface Clonable<T> {
7
+ clone(): T;
8
+ }
9
+
10
+ export declare interface Matrix<Order extends MatrixOrder> {
11
+ readonly order: Order;
12
+ readonly elements: Float32Array;
13
+ }
14
+
15
+ /**
16
+ * 3x3 matrix class. It looks column-major order. And post multiplied.
17
+ */
18
+ export declare class Matrix3 implements Matrix<3>, AdditiveGroup<Matrix3>, PartialMultiplicativeGroup<Matrix3>, Scalable<Matrix3>, Clonable<Matrix3> {
19
+ /**
20
+ * @example
21
+ * ```ts
22
+ * const m = Matrix3.identity();
23
+ * console.log(m.order); // 3
24
+ * ```
25
+ */
26
+ readonly order = 3;
27
+ /**
28
+ * @example
29
+ * ```ts
30
+ * const m = Matrix3.identity();
31
+ * console.log(m.elements);
32
+ * // [ 1, 0, 0,
33
+ * // 0, 1, 0,
34
+ * // 0, 0, 1 ]
35
+ * ```
36
+ */
37
+ readonly elements: Float32Array;
38
+ private static _tmpMatrix?;
39
+ private static get tmpMatrix();
40
+ private static _tmpVector?;
41
+ private static get tmpVector();
42
+ /**
43
+ * Creates a new 3x3 matrix with the specified elements. \
44
+ * The internal data is stored in **column-major** order in a `Float32Array`.
45
+ *
46
+ * The parameters `e(column)(row)` correspond to this following matrix positions: \
47
+ * ```
48
+ * | e00 e10 e20 |
49
+ * | e01 e11 e21 |
50
+ * | e02 e12 e22 |
51
+ * ```
52
+ *
53
+ * The `elements` array stores each column sequentialy: \
54
+ * `[e00, e01, e02, e10, e11, e12, e20, e21, e22]`
55
+ *
56
+ * @param e00 element in column 0, row 0
57
+ * @param e01 element in column 0, row 1
58
+ * @param e02 element in column 0, row 2
59
+ * @param e10 element in column 1, row 0
60
+ * @param e11 element in column 1, row 1
61
+ * @param e12 element in column 1, row 2
62
+ * @param e20 element in column 2, row 0
63
+ * @param e21 element in column 2, row 1
64
+ * @param e22 element in column 2, row 2
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const m = new Matrix3(0, 1, 2, 3, 4, 5, 6, 7, 8);
69
+ * console.log(m.elements);
70
+ * // [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
71
+ * ```
72
+ */
73
+ constructor(e00: number, e01: number, e02: number, e10: number, e11: number, e12: number, e20: number, e21: number, e22: number);
74
+ /**
75
+ * Creates a identity matrix instance
76
+ * @returns new identity matrix instance
77
+ * @group Factory Methods
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const m = Matrix3.identity();
82
+ * console.log(m.elements);
83
+ * // [ 1, 0, 0,
84
+ * // 0, 1, 0,
85
+ * // 0, 0, 1 ]
86
+ * ```
87
+ */
88
+ static identity(): Matrix3;
89
+ /**
90
+ * Creates a new zero matrix instance
91
+ * @returns new zero matrix instance
92
+ * @group Factory Methods
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const m = Matrix3.zero();
97
+ * console.log(m.elements);
98
+ * // [ 0, 0, 0,
99
+ * // 0, 0, 0,
100
+ * // 0, 0, 0 ]
101
+ * ```
102
+ */
103
+ static zero(): Matrix3;
104
+ /**
105
+ * Creates new instance has same elements (pure)
106
+ * @returns new cloned matrix instance
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * const m = Matrix3.identity();
111
+ * const c = m.clone();
112
+ * console.log(c.elements);
113
+ * // [ 1, 0, 0,
114
+ * // 0, 1, 0,
115
+ * // 0, 0, 1 ]
116
+ * ```
117
+ */
118
+ clone(): Matrix3;
119
+ /**
120
+ * Sets all elements (mutates this)
121
+ * @param e00 element in column 0, row 0
122
+ * @param e01 element in column 0, row 1
123
+ * @param e02 element in column 0, row 2
124
+ * @param e10 element in column 1, row 0
125
+ * @param e11 element in column 1, row 1
126
+ * @param e12 element in column 1, row 2
127
+ * @param e20 element in column 2, row 0
128
+ * @param e21 element in column 2, row 1
129
+ * @param e22 element in column 2, row 2
130
+ * @returns this instance, for method chaining
131
+ *
132
+ * @example
133
+ * const m = Matrix3.zero();
134
+ * m.set(0, 1, 2, 3, 4, 5, 6, 7, 8);
135
+ * console.log(m.elements);
136
+ * // [ 0, 1, 2,
137
+ * // 3, 4, 5,
138
+ * // 6, 7, 8 ]
139
+ */
140
+ set(e00: number, e01: number, e02: number, e10: number, e11: number, e12: number, e20: number, e21: number, e22: number): Matrix3;
141
+ /**
142
+ * Copies all elements from other matrix (mutates this)
143
+ * @param other other matrix
144
+ * @returns this instance, for method chaining
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * const m = Matrix3.zero();
149
+ * const i = Matrix3.identity();
150
+ * m.set(i);
151
+ * console.log(m.elements);
152
+ * // [ 1, 0, 0,
153
+ * // 0, 1, 0,
154
+ * // 0, 0, 1 ]
155
+ * ```
156
+ */
157
+ copy(other: Matrix3): void;
158
+ /**
159
+ * Sets identity matrix (mutates this)
160
+ * @returns this instance, for method chaining
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * const m = Matrix4.zero();
165
+ * m.setIdentity();
166
+ * console.log(m.elements);
167
+ * // [ 1, 0, 0,
168
+ * // 0, 1, 0,
169
+ * // 0, 0, 1 ]
170
+ * ```
171
+ */
172
+ setIdentity(): Matrix3;
173
+ /**
174
+ * Adds by other matrix (mutates this)
175
+ * @param other other matrix
176
+ * @returns this instance, for method chaining
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * const m1 = Matrix3.zero();
181
+ * const m2 = Matrix3.identity();
182
+ * m1.add(m2);
183
+ * console.log(m1.elements);
184
+ * // [ 1, 0, 0,
185
+ * // 0, 1, 0,
186
+ * // 0, 0, 1 ]
187
+ * ```
188
+ */
189
+ add(other: Matrix3): Matrix3;
190
+ /**
191
+ * Subtracts by other matrix (mutates this)
192
+ * @param other other matrix
193
+ * @returns this instance, for method chaining
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * const m1 = Matrix3.zero();
198
+ * const m2 = Matrix3.identity();
199
+ * m1.subtract(m2);
200
+ * console.log(m1.lements);
201
+ * // [ -1, 0, 0,
202
+ * // 0, -1, 0,
203
+ * // 0, 0, -1 ]
204
+ * ```
205
+ */
206
+ subtract(other: Matrix3): Matrix3;
207
+ /**
208
+ * Multiplies all elements by scalar (mutates this)
209
+ * @param scalar
210
+ * @returns this instance, for method chaining
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * const m = Matrix3.identity();
215
+ * m.multiplyScalar(2);
216
+ * console.log(m.elements);
217
+ * // [ 2, 0, 0,
218
+ * // 0, 2, 0,
219
+ * // 0, 0, 2 ]
220
+ * ```
221
+ */
222
+ multiplyScalar(scalar: number): Matrix3;
223
+ /**
224
+ * Divides all elements by scalar (mutates this)
225
+ * @param scalar
226
+ * @returns this instance, for method chaining
227
+ *
228
+ * @example
229
+ * ```ts
230
+ * const m = Matrix3.identity();
231
+ * m.divideScalar(2);
232
+ * console.log(m.elements);
233
+ * // [ 0.5, 0, 0,
234
+ * // 0, 0.5, 0,
235
+ * // 0, 0, 0.5 ]
236
+ * ```
237
+ */
238
+ divideScalar(scalar: number): Matrix3;
239
+ /**
240
+ * Multiplies this matrix by other matrix (mutates this)
241
+ * @param other other matrix
242
+ * @returns this instance, for method chaining
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * const m1 = Matrix3.identity();
247
+ * const m2 = Matrix3.zero();
248
+ * m1.multiply(m2);
249
+ * console.log(m.elements);
250
+ * // [ 0, 0, 0,
251
+ * // 0, 0, 0,
252
+ * // 0, 0, 0 ]
253
+ * ```
254
+ */
255
+ multiply(other: Matrix3): Matrix3;
256
+ /**
257
+ * Calculates determinant of this matrix (pure)
258
+ * @returns determinant of this matrix
259
+ */
260
+ determinant(): number;
261
+ /**
262
+ * Sets inverse of this matrix to this instance (mutates this)
263
+ * @returns `this` instance for method chaining if this is invertible, `null` otherwise
264
+ */
265
+ invert(): Matrix3 | null;
266
+ /**
267
+ * Transposes this matrix (mutates this)
268
+ * @returns this instance, for method chaining
269
+ */
270
+ transpose(): Matrix3;
271
+ /**
272
+ * Divides by other matrix (mutates this)
273
+ * @param other other matrix
274
+ * @returns `this` instance for method chaining if other is invertible, `null` otherwise
275
+ */
276
+ divide(other: Matrix3): Matrix3 | null;
277
+ /** @ignore */
278
+ _applyVector(x: number, y: number, z: number): Vector3;
279
+ }
280
+
281
+ /**
282
+ * 4x4 matrix class. It looks column-major order. And post multiplied.
283
+ */
284
+ export declare class Matrix4 implements Matrix<4>, AdditiveGroup<Matrix4>, PartialMultiplicativeGroup<Matrix4>, Scalable<Matrix4>, Clonable<Matrix4> {
285
+ /**
286
+ * @example
287
+ * ```ts
288
+ * const m = Matrix4.identity();
289
+ * console.log(m.order); // 4
290
+ * ```
291
+ */
292
+ readonly order = 4;
293
+ /**
294
+ * @example
295
+ * ```ts
296
+ * const m = Matrix4.identity();
297
+ * console.log(m.elements);
298
+ * // [ 1, 0, 0, 0,
299
+ * // 0, 1, 0, 0,
300
+ * // 0, 0, 1, 0,
301
+ * // 0, 0, 0, 1 ]
302
+ * ```
303
+ */
304
+ readonly elements: Float32Array;
305
+ private static _tmpMatrix?;
306
+ private static get tmpMatrix();
307
+ private static _tmpVector?;
308
+ private static get tmpVector();
309
+ /**
310
+ * Creates a new 4x4 matrix with the specified elements. \
311
+ * The internal data is stored in **column-major** order in a `Float32Array`.
312
+ *
313
+ * The parameters `e(column)(row)` correspond to the following matrix positions: \
314
+ * ```
315
+ * | e00 e10 e20 e30 |
316
+ * | e01 e11 e21 e31 |
317
+ * | e02 e12 e22 e32 |
318
+ * | e03 e13 e23 e33 |
319
+ * ```
320
+ *
321
+ * The `elements` array stores each column sequentialy: \
322
+ * `[e00, e01, e02, e03, e10, e11, e12, e13, e20, e21, e22, e23, e30, e31, e32, e33]`
323
+ *
324
+ * @param e00 element in column 0, row 0
325
+ * @param e01 element in column 0, row 1
326
+ * @param e02 element in column 0, row 2
327
+ * @param e03 element in column 0, row 3
328
+ * @param e10 element in column 1, row 0
329
+ * @param e11 element in column 1, row 1
330
+ * @param e12 element in column 1, row 2
331
+ * @param e13 element in column 1, row 3
332
+ * @param e20 element in column 2, row 0
333
+ * @param e21 element in column 2, row 1
334
+ * @param e22 element in column 2, row 2
335
+ * @param e23 element in column 2, row 3
336
+ * @param e30 element in column 3, row 0
337
+ * @param e31 element in column 3, row 1
338
+ * @param e32 element in column 3, row 2
339
+ * @param e33 element in column 3, row 3
340
+ *
341
+ * @example
342
+ * ```ts
343
+ * const m = new Matrix4(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
344
+ * console.log(m.elements);
345
+ * // [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]
346
+ * ```
347
+ */
348
+ constructor(e00: number, e01: number, e02: number, e03: number, e10: number, e11: number, e12: number, e13: number, e20: number, e21: number, e22: number, e23: number, e30: number, e31: number, e32: number, e33: number);
349
+ /**
350
+ * Creates a identity matrix instance
351
+ * @returns new identity matrix instance
352
+ * @group Factory Methods
353
+ *
354
+ * @example
355
+ * ```ts
356
+ * const m = Matrix4.identity();
357
+ * console.log(m.elements);
358
+ * // [ 1, 0, 0, 0,
359
+ * // 0, 1, 0, 0,
360
+ * // 0, 0, 1, 0,
361
+ * // 0, 0, 0, 1 ]
362
+ * ```
363
+ */
364
+ static identity(): Matrix4;
365
+ /**
366
+ * Creates a new zero matrix instance
367
+ * @returns new zero matrix instance
368
+ * @group Factory Methods
369
+ *
370
+ * @example
371
+ * ```ts
372
+ * const m = Matrix4.zero();
373
+ * console.log(m.elements);
374
+ * // [ 1, 0, 0, 0,
375
+ * // 0, 1, 0, 0,
376
+ * // 0, 0, 1, 0,
377
+ * // 0, 0, 0, 1 ]
378
+ * ```
379
+ */
380
+ static zero(): Matrix4;
381
+ /**
382
+ * Creates new instance has same elements (pure)
383
+ * @returns new cloned matrix instance
384
+ *
385
+ * @example
386
+ * ```ts
387
+ * const m = Matrix4.identity();
388
+ * const c = m.clone();
389
+ * console.log(c.elements);
390
+ * // [ 1, 0, 0, 0,
391
+ * // 0, 1, 0, 0,
392
+ * // 0, 0, 1, 0,
393
+ * // 0, 0, 0, 1 ]
394
+ * ```
395
+ */
396
+ clone(): Matrix4;
397
+ /**
398
+ * Sets all elements (mutates this)
399
+ * @param e00 element in column 0, row 0
400
+ * @param e01 element in column 0, row 1
401
+ * @param e02 element in column 0, row 2
402
+ * @param e03 element in column 0, row 3
403
+ * @param e10 element in column 1, row 0
404
+ * @param e11 element in column 1, row 1
405
+ * @param e12 element in column 1, row 2
406
+ * @param e13 element in column 1, row 3
407
+ * @param e20 element in column 2, row 0
408
+ * @param e21 element in column 2, row 1
409
+ * @param e22 element in column 2, row 2
410
+ * @param e23 element in column 2, row 3
411
+ * @param e30 element in column 3, row 0
412
+ * @param e31 element in column 3, row 1
413
+ * @param e32 element in column 3, row 2
414
+ * @param e33 element in column 3, row 3
415
+ * @returns this instance, for method chaining
416
+ *
417
+ * @example
418
+ * const m = Matrix4.zero();
419
+ * m.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
420
+ * console.log(m.elements);
421
+ * // [ 1, 0, 0, 0,
422
+ * // 0, 1, 0, 0,
423
+ * // 0, 0, 1, 0,
424
+ * // 0, 0, 0, 1 ]
425
+ */
426
+ set(e00: number, e01: number, e02: number, e03: number, e10: number, e11: number, e12: number, e13: number, e20: number, e21: number, e22: number, e23: number, e30: number, e31: number, e32: number, e33: number): Matrix4;
427
+ /**
428
+ * Copies all elements from other matrix (mutates this)
429
+ * @param other other matrix
430
+ * @returns this instance, for method chaining
431
+ *
432
+ * @example
433
+ * ```ts
434
+ * const m = Matrix4.zero();
435
+ * const i = Matrix4.identity();
436
+ * m.set(i);
437
+ * console.log(m.elements);
438
+ * // [ 1, 0, 0, 0,
439
+ * // 0, 1, 0, 0,
440
+ * // 0, 0, 1, 0,
441
+ * // 0, 0, 0, 1 ]
442
+ * ```
443
+ */
444
+ copy(other: Matrix4): void;
445
+ /**
446
+ * Sets identity matrix (mutates this)
447
+ * @returns this instance, for method chaining
448
+ *
449
+ * @example
450
+ * ```ts
451
+ * const m = Matrix4.zero();
452
+ * m.setIdentity();
453
+ * console.log(m.elements);
454
+ * // [ 1, 0, 0, 0,
455
+ * // 0, 1, 0, 0,
456
+ * // 0, 0, 1, 0,
457
+ * // 0, 0, 0, 1 ]
458
+ * ```
459
+ */
460
+ setIdentity(): Matrix4;
461
+ /**
462
+ * Sets rotation matrix from quaternion (mutates this)
463
+ * @param quaternion
464
+ * @returns this instance, for method chaining
465
+ *
466
+ * @example
467
+ * ```ts
468
+ * const m = Matrix4.zero();
469
+ * const q = Quaternion.identity();
470
+ * m.setQuaternion(q);
471
+ * console.log(m.elements);
472
+ * // [ 0, 0, 0, 0,
473
+ * // 0, 0, 0, 0,
474
+ * // 0, 0, 0, 0,
475
+ * // 0, 0, 0, 0 ]
476
+ * ```
477
+ */
478
+ setQuaternion(quaternion: Quaternion): Matrix4;
479
+ /**
480
+ * Adds by other matrix (mutates this)
481
+ * @param other other matrix
482
+ * @returns this instance, for method chaining
483
+ *
484
+ * @example
485
+ * ```ts
486
+ * const m1 = Matrix4.zero();
487
+ * const m2 = Matrix4.identity();
488
+ * m1.add(m2);
489
+ * console.log(m1.elements);
490
+ * // [ 1, 0, 0, 0,
491
+ * // 0, 1, 0, 0,
492
+ * // 0, 0, 1, 0,
493
+ * // 0, 0, 0, 1 ]
494
+ * ```
495
+ */
496
+ add(other: Matrix4): Matrix4;
497
+ /**
498
+ * Subtracts by other matrix (mutates this)
499
+ * @param other other matrix
500
+ * @returns this instance, for method chaining
501
+ *
502
+ * @example
503
+ * ```ts
504
+ * const m1 = Matrix4.zero();
505
+ * const m2 = Matrix4.identity();
506
+ * m1.subtract(m2);
507
+ * console.log(m1.lements);
508
+ * // [ -1, 0, 0, 0,
509
+ * // 0, -1, 0, 0,
510
+ * // 0, 0, -1, 0,
511
+ * // 0, 0, 0, -1 ]
512
+ * ```
513
+ */
514
+ subtract(other: Matrix4): Matrix4;
515
+ /**
516
+ * Multiplies all elements by scalar (mutates this)
517
+ * @param scalar
518
+ * @returns this instance, for method chaining
519
+ *
520
+ * @example
521
+ * ```ts
522
+ * const m = Matrix4.identity();
523
+ * m.multiplyScalar(2);
524
+ * console.log(m.elements);
525
+ * // [ 2, 0, 0, 0,
526
+ * // 0, 2, 0, 0,
527
+ * // 0, 0, 2, 0,
528
+ * // 0, 0, 0, 2 ]
529
+ * ```
530
+ */
531
+ multiplyScalar(scalar: number): Matrix4;
532
+ /**
533
+ * Divides all elements by scalar (mutates this)
534
+ * @param scalar
535
+ * @returns this instance, for method chaining
536
+ *
537
+ * @example
538
+ * ```ts
539
+ * const m = Matrix4.identity();
540
+ * m.divideScalar(2);
541
+ * console.log(m.elements);
542
+ * // [ 0.5, 0, 0, 0,
543
+ * // 0, 0.5, 0, 0,
544
+ * // 0, 0, 0.5, 0,
545
+ * // 0, 0, 0, 0.5 ]
546
+ * ```
547
+ */
548
+ divideScalar(scalar: number): Matrix4;
549
+ /**
550
+ * Multiplies this matrix by other matrix (mutates this)
551
+ * @param other other matrix
552
+ * @returns this instance, for method chaining
553
+ *
554
+ * @example
555
+ * ```ts
556
+ * const m1 = Matrix4.identity();
557
+ * const m2 = Matrix4.zero();
558
+ * m1.multiply(m2);
559
+ * console.log(m.elements);
560
+ * // [ 0, 0, 0, 0,
561
+ * // 0, 0, 0, 0,
562
+ * // 0, 0, 0, 0,
563
+ * // 0, 0, 0, 0 ]
564
+ * ```
565
+ */
566
+ multiply(other: Matrix4): Matrix4;
567
+ /**
568
+ * Calculates determinant of this matrix (pure)
569
+ * @returns determinant of this matrix
570
+ */
571
+ determinant(): number;
572
+ /**
573
+ * Sets inverse of this matrix to this instance (mutates this)
574
+ * @returns `this` instance for method chaining if this is invertible, `null` otherwise
575
+ */
576
+ invert(): Matrix4 | null;
577
+ /**
578
+ * Transposes this matrix (mutates this)
579
+ * @returns this instance, for method chaining
580
+ */
581
+ transpose(): Matrix4;
582
+ /**
583
+ * Divides by other matrix (mutates this)
584
+ * @param other other matrix
585
+ * @returns `this` instance for method chaining if other is invertible, `null` otherwise
586
+ */
587
+ divide(other: Matrix4): Matrix4 | null;
588
+ /**
589
+ * Sets scale transformation matrix (mutates this)
590
+ * @param scale 3D scale vector
591
+ * @returns this instance, for method chaining
592
+ *
593
+ * @example
594
+ * ```ts
595
+ * const m = Matrix4.identity();
596
+ * const s = new Vector3(2, 3, 4);
597
+ * m.scale(s);
598
+ * console.log(m.elements);
599
+ * // [ 2, 0, 0, 0,
600
+ * // 0, 3, 0, 0,
601
+ * // 0, 0, 4, 0,
602
+ * // 0, 0, 0, 1 ]
603
+ * ```
604
+ */
605
+ scale(scale: Vector3): Matrix4;
606
+ /**
607
+ * Sets translation transformation matrix (mutates this)
608
+ * @param translation translation vector
609
+ * @returns this instance, for method chaining
610
+ *
611
+ * @example
612
+ * ```ts
613
+ * const m = Matrix4.identity();
614
+ * const t = new Vector3(2, 3, 4);
615
+ * m.translate(t);
616
+ * console.log(m.elements);
617
+ * // [ 1, 0, 0, 0,
618
+ * // 0, 1, 0, 0,
619
+ * // 0, 0, 1, 0,
620
+ * // 2, 3, 4, 1 ]
621
+ * ```
622
+ */
623
+ translate(translation: Vector3): Matrix4;
624
+ /**
625
+ * Sets view transformation matrix (mutates this)
626
+ * @param position camera position
627
+ * @param target camera target looking at
628
+ * @param up up vector of camera
629
+ * @returns this instance, for method chaining
630
+ *
631
+ * @example
632
+ * ```ts
633
+ * const m = Matrix4.identity();
634
+ * const p = new Vector3(0, -2, 0);
635
+ * const t = Vector3.zero();
636
+ * const u = new Vector3(0, 0, 1);
637
+ * m.lookAt(p, t, u);
638
+ * ```
639
+ */
640
+ lookAt(position: Vector3, target: Vector3, up: Vector3): Matrix4;
641
+ /**
642
+ * Sets projection matrix of perspective camera (mutates this)
643
+ * @param verticalFov vertical field of view in radians
644
+ * @param near near clipping plane distance
645
+ * @param far far clipping plane distance
646
+ * @param aspect aspect ratio (width / height)
647
+ * @returns this instance, for method chaining
648
+ *
649
+ * @example
650
+ * ```ts
651
+ * const m = Matrix4.identity();
652
+ * const fov = Math.PI / 4;
653
+ * const near = 0.01;
654
+ * const far = 4.0;
655
+ * const aspect = 300 / 150;
656
+ * m.perspective(fov, near, far, aspect);
657
+ * ```
658
+ */
659
+ perspective(verticalFov: number, near: number, far: number, aspect: number): Matrix4;
660
+ /** @ignore */
661
+ _applyVector(x: number, y: number, z: number, w: number): Vector4;
662
+ }
663
+
664
+ export declare type MatrixOrder = 3 | 4;
665
+
666
+ /**
667
+ * Represents a multiplicative monoid.
668
+ *
669
+ * Types implementing this interface support:
670
+ * - Associativity: `(a * b) * c = a * (b * c)`
671
+ * - Closure: `a * b` produces another value of type `T`
672
+ */
673
+ export declare interface MultiplicativeMonoid<T> {
674
+ multiply(other: T): T;
675
+ }
676
+
677
+ export declare interface Normalizable<T> {
678
+ length(): number;
679
+ normalize(): T;
680
+ }
681
+
682
+ /**
683
+ * Represents a partial multiplicative group where multiplication is defined for all elements, \
684
+ * but inverses exist only for certain elements (those that are invertible).
685
+ *
686
+ * ### Invertibility Conditions:
687
+ * | Type | Invertible when | Condition |
688
+ * |------|-----------------|-----------|
689
+ * | **Matrix** | `det(M) ≠ 0` | Non-singular (full rank) |
690
+ * | **Quaternion** | `\|q\| ≠ 0` (non-zero norm) | Non-zero quaternion |
691
+ */
692
+ export declare interface PartialMultiplicativeGroup<T> extends MultiplicativeMonoid<T> {
693
+ invert(): T | null;
694
+ divide(other: T): T | null;
695
+ }
696
+
697
+ export declare class PolarCoordinate3 {
698
+ private _phi;
699
+ private _theta;
700
+ private _radius;
701
+ /**
702
+ * @param phi polar angle phi in range [0, π] in radians
703
+ * @param theta azimuthal angle theta in range [0, 2π] in radians
704
+ * @param radius radial distance from the origin, must be non-negative
705
+ */
706
+ constructor(phi: number, theta: number, radius: number);
707
+ /**
708
+ * Gets polar angle phi in range [0, π] in radians, measured from positive z-axis.
709
+ */
710
+ get phi(): number;
711
+ /**
712
+ * Sets polar angle phi in range [0, π] in radians, measured from positive z-axis.
713
+ * @param value polar angle in range [0, π]
714
+ */
715
+ set phi(value: number);
716
+ /**
717
+ * Gets azimuthal angle theta in range [0, 2π] in radians, measured from the positive x-axis.
718
+ */
719
+ get theta(): number;
720
+ /**
721
+ * Sets azimuthal angle theta in range [0, 2π] in radians, measured from the positive x-axis.
722
+ * @param value azimuthal angle in range [0, 2π]
723
+ */
724
+ set theta(value: number);
725
+ /**
726
+ * Gets radial distance from the origin, must be non-negative.
727
+ */
728
+ get radius(): number;
729
+ /**
730
+ * Sets radial distance from the origin, must be non-negative.
731
+ */
732
+ set radius(value: number);
733
+ /**
734
+ * Converts polar coordinate to Vector3 and stores result in `out` vector.
735
+ * @param out vector instance to receive result
736
+ * @returns {void}
737
+ */
738
+ toVector3(out: Vector3): void;
739
+ /**
740
+ * Converts to tangent vector pointing positive z-axis direction, and sotres result in `out` vector.
741
+ * @param out vector instance to receive result
742
+ * @returns {void}
743
+ */
744
+ toTangentZ(out: Vector3): void;
745
+ }
746
+
747
+ /**
748
+ * Represents a quaternion using Hamilton's notation: q = a + bi + cj + dk
749
+ */
750
+ export declare class Quaternion implements AdditiveGroup<Quaternion>, PartialMultiplicativeGroup<Quaternion>, Scalable<Quaternion>, Clonable<Quaternion> {
751
+ private _a;
752
+ private _b;
753
+ private _c;
754
+ private _d;
755
+ private static temporary;
756
+ /**
757
+ * Constructor of quaternion: q = a + bi + cj + dk
758
+ * @param a the first real component
759
+ * @param b the i-coefficient
760
+ * @param c the j-coefficient
761
+ * @param d the k-coefficient
762
+ *
763
+ * @example
764
+ * ```ts
765
+ * const q = new Quaternion(1, 0, 0, 0);
766
+ * ```
767
+ */
768
+ constructor(a: number, b: number, c: number, d: number);
769
+ /**
770
+ * Gets the first real component of this quaternion
771
+ * @readonly
772
+ *
773
+ * @example
774
+ * ```ts
775
+ * const q = new Quaternion(1, 2, 3, 4);
776
+ * console.log(q.a); // 1
777
+ * ```
778
+ */
779
+ get a(): number;
780
+ /**
781
+ * Gets the i-coefficient of this quaternion
782
+ * @readonly
783
+ *
784
+ * @example
785
+ * ```ts
786
+ * const q = new Quaternion(1, 2, 3, 4);
787
+ * console.log(q.b); // 2
788
+ * ```
789
+ */
790
+ get b(): number;
791
+ /**
792
+ * Gets the j-coefficient of this quaternion
793
+ * @readonly
794
+ *
795
+ * @example
796
+ * ```ts
797
+ * const q = new Quaternion(1, 2, 3, 4);
798
+ * console.log(q.c); // 3
799
+ * ```
800
+ */
801
+ get c(): number;
802
+ /**
803
+ * Gets the k-coefficient of this quaternion
804
+ * @readonly
805
+ *
806
+ * @example
807
+ * ```ts
808
+ * const q = new Quaternion(1, 2, 3, 4);
809
+ * console.log(q.d); // 4
810
+ * ```
811
+ */
812
+ get d(): number;
813
+ /**
814
+ * @returns new identity quaternion instance
815
+ *
816
+ * @group Factory Methods
817
+ *
818
+ * @example
819
+ * ```ts
820
+ * const q = Quaternion.identity();
821
+ * console.log(q); // (1, 0, 0, 0)
822
+ * ```
823
+ */
824
+ static identity(): Quaternion;
825
+ /**
826
+ * @param axis the rotation axis
827
+ * @param angle the rotation angle in radians
828
+ * @returns new normalized quaternion instance from axis and radian
829
+ *
830
+ * @group Factory Methods
831
+ *
832
+ * @example
833
+ * ```ts
834
+ * const axis = new Vector3(0, 1, 0);
835
+ * const radian = Math.PI / 3;
836
+ * const q = Quaternion.identity(axis, radian);
837
+ * ```
838
+ */
839
+ static fromAxisAndAngle(axis: Vector3, angle: number): Quaternion;
840
+ /**
841
+ * @returns new cloned quaternion instance
842
+ *
843
+ * @example
844
+ * ```ts
845
+ * const q = Quaternion.identity();
846
+ * const c = q.clone();
847
+ * console.log(c); // (1, 0, 0, 0)
848
+ * ```
849
+ */
850
+ clone(): Quaternion;
851
+ /**
852
+ * Sets all components of this quaternion: q = a + bi + cj + dk (mutates this)
853
+ * @param a the first real component
854
+ * @param b the i-coefficient
855
+ * @param c the j-coefficient
856
+ * @param d the k-coefficient
857
+ * @returns this instance, for method chaining
858
+ *
859
+ * @example
860
+ * ```ts
861
+ * const q = Quaternion.identity();
862
+ * console.log(q); // (1, 0, 0, 0)
863
+ * q.set(0, 0, 0, 1);
864
+ * console.log(q); // (0, 0, 0, 1)
865
+ * ```
866
+ */
867
+ set(a: number, b: number, c: number, d: number): Quaternion;
868
+ /**
869
+ * Sets this quaternion to other quaternion (mutates this)
870
+ * @param other the other quaternion
871
+ * @returns this instance, for method chaining
872
+ *
873
+ * @example
874
+ * ```ts
875
+ * const q1 = new Quaternion(1, 2, 3, 4);
876
+ * const q2 = new Quaternion(5, 6, 7, 8);
877
+ * q1.copy(q2);
878
+ * console.log(q1); // (5, 6, 7, 8)
879
+ * console.log(q2); // (5, 6, 7, 8)
880
+ * ```
881
+ */
882
+ copy(other: Quaternion): Quaternion;
883
+ /**
884
+ * Sets this instance to identity quaternion (mutates this)
885
+ * @returns this instance, for method chaining
886
+ *
887
+ * @example
888
+ * ```ts
889
+ * const q = new Quaternion(1, 2, 3, 4);
890
+ * q.setIdentity();
891
+ * console.log(q); // (1, 0, 0, 0)
892
+ * ```
893
+ */
894
+ setIdentity(): void;
895
+ /**
896
+ * Sets this quaternion from axis and radian (mutates this)
897
+ * @param axis the rotation axis
898
+ * @param angle the rotation angle in radians
899
+ * @returns this instance, for method chaining
900
+ *
901
+ * @example
902
+ * ```ts
903
+ * const q = Quaternion.identity();
904
+ * const axis = new Vector3(0, 1, 0);
905
+ * const radian = Math.PI / 3;
906
+ * q.setAxisAndAngle(axis, radian);
907
+ * ```
908
+ */
909
+ setAxisAndAngle(axis: Vector3, angle: number): void;
910
+ /**
911
+ * Calculates squared norm of this quaternion (pure)
912
+ * @returns squared norm of this quaternion
913
+ *
914
+ * @example
915
+ * ```ts
916
+ * const q = new Quaternion(1, 2, 2, 4);
917
+ * console.log(q.squaredNorm()); // 25
918
+ * ```
919
+ */
920
+ squaredNorm(): number;
921
+ /**
922
+ * Calculates norm of this quaternion (pure)
923
+ * @returns norm of this quaternion
924
+ *
925
+ * @example
926
+ * ```ts
927
+ * const q = new Quaternion(1, 2, 2, 4);
928
+ * console.log(q.norm()); // 5
929
+ * ```
930
+ */
931
+ norm(): number;
932
+ /**
933
+ * Calculates conjugate of this quaternion (mutates this)
934
+ * @returns this instance, for method chaining
935
+ *
936
+ * @example
937
+ * ```ts
938
+ * const q = new Quaternion(1, 2, 3, 4);
939
+ * q.conjugate();
940
+ * console.log(q); // (1, -2, -3, -4)
941
+ * ```
942
+ */
943
+ conjugate(): Quaternion;
944
+ /**
945
+ * Adds other quaternion to this instance (mutates this)
946
+ * @param other other quaternion
947
+ * @returns this instance, for method chaining
948
+ *
949
+ * @example
950
+ * ```ts
951
+ * const q1 = new Quaternion(1, 2, 3, 4);
952
+ * const q2 = new Quaternion(5, 6, 7, 8);
953
+ * q1.add(q2);
954
+ * console.log(q1); // (6, 8, 10, 12)
955
+ * console.log(q2); // (5, 6, 7, 8)
956
+ * ```
957
+ */
958
+ add(other: Quaternion): Quaternion;
959
+ /**
960
+ * Subtracts other quaternion from this instance (mutates this)
961
+ * @param other other quaternion
962
+ * @returns this instance, for method chaining
963
+ *
964
+ * @example
965
+ * ```ts
966
+ * const q1 = new Quaternion(5, 6, 7, 8);
967
+ * const q2 = new Quaternion(1, 2, 3, 4);
968
+ * q1.subtract(q2);
969
+ * console.log(q1); // (4, 4, 4, 4)
970
+ * console.log(q2); // (1, 2, 3, 4)
971
+ * ```
972
+ */
973
+ subtract(other: Quaternion): Quaternion;
974
+ /**
975
+ * Multiplies this instance by other quaternion (mutates this)
976
+ * @param other other quaternion
977
+ * @returns this instance, for method chaining
978
+ *
979
+ * @example
980
+ * ```ts
981
+ * const q1 = new Quaternion(1, 2, 3, 4);
982
+ * const q2 = new Quaternion(5, 6, 7, 8);
983
+ * q1.multiply(q2);
984
+ * console.log(q1); // (-60, 12, 30, 24)
985
+ * console.log(q2); // (5, 6, 7, 8)
986
+ * ```
987
+ */
988
+ multiply(other: Quaternion): Quaternion;
989
+ /**
990
+ * Calculates inverse of this quaternion (mutates this)
991
+ * @returns this instance, for method chaining
992
+ *
993
+ * @example
994
+ * ```ts
995
+ * const q = new Quaternion(1, 2, 3, 4);
996
+ * q.inverse();
997
+ * console.log(q); // (0.0333, -0.0667, -0.1, -0.1333)
998
+ * ```
999
+ */
1000
+ invert(): Quaternion | null;
1001
+ /**
1002
+ * Divides this instance by other quaternion (mutates this)
1003
+ * @param other other quaternion
1004
+ * @returns this instance, for method chaining
1005
+ *
1006
+ * @example
1007
+ * ```ts
1008
+ * const q1 = new Quaternion(1, 2, 3, 4);
1009
+ * const q2 = new Quaternion(5, 6, 7, 8);
1010
+ * q1.divide(q2);
1011
+ * console.log(q1); // (0.1333, 0.0667, 0.1, 0.1333)
1012
+ * console.log(q2); // (5, 6, 7, 8)
1013
+ * ```
1014
+ */
1015
+ divide(other: Quaternion): Quaternion | null;
1016
+ /**
1017
+ * Multiplies this quaternion by a scalar (mutates this)
1018
+ * @param scalar scalar value
1019
+ * @returns this instance, for method chaining
1020
+ *
1021
+ * @example
1022
+ * ```ts
1023
+ * const q = new Quaternion(1, 2, 3, 4);
1024
+ * q.multiplyScalar(2);
1025
+ * console.log(q); // (2, 4, 6, 8)
1026
+ * ```
1027
+ */
1028
+ multiplyScalar(scalar: number): Quaternion;
1029
+ /**
1030
+ * Divides this quaternion by a scalar (mutates this)
1031
+ * @param scalar scalar value
1032
+ * @returns this instance, for method chaining
1033
+ *
1034
+ * @example
1035
+ * ```ts
1036
+ * const q = new Quaternion(2, 4, 6, 8);
1037
+ * q.divideScalar(2);
1038
+ * console.log(q); // (1, 2, 3, 4)
1039
+ * ```
1040
+ */
1041
+ divideScalar(scalar: number): Quaternion;
1042
+ /**
1043
+ * Rotates this quaternion around X axis by given radian (mutates this)
1044
+ * @param radian the rotation angle in radians
1045
+ * @returns this instance, for method chaining
1046
+ *
1047
+ * @example
1048
+ * ```ts
1049
+ * const q = Quaternion.identity();
1050
+ * q.rotateX(Math.PI / 2);
1051
+ * console.log(q); // (0.7071, 0.7071, 0, 0)
1052
+ * ```
1053
+ */
1054
+ rotateX(radian: number): Quaternion;
1055
+ /**
1056
+ * Rotates this quaternion around Y axis by given radian (mutates this)
1057
+ * @param radian the rotation angle in radians
1058
+ * @returns this instance, for method chaining
1059
+ *
1060
+ * @example
1061
+ * ```ts
1062
+ * const q = Quaternion.identity();
1063
+ * q.rotateY(Math.PI / 2);
1064
+ * console.log(q); // (0.7071, 0, 0.7071, 0)
1065
+ * ```
1066
+ */
1067
+ rotateY(radian: number): Quaternion;
1068
+ /**
1069
+ * Rotates this quaternion around Z axis by given radian (mutates this)
1070
+ * @param radian the rotation angle in radians
1071
+ * @returns this instance, for method chaining
1072
+ *
1073
+ * @example
1074
+ * ```ts
1075
+ * const q = Quaternion.identity();
1076
+ * q.rotateZ(Math.PI / 2);
1077
+ * console.log(q); // (0.7071, 0, 0, 0.7071)
1078
+ * ```
1079
+ */
1080
+ rotateZ(radian: number): Quaternion;
1081
+ }
1082
+
1083
+ /**
1084
+ * Creates a generator that yields numbers in a specified range
1085
+ * @param stop exclusive bound (sequence stops before reaching this)
1086
+ * @param options optional range configuration
1087
+ * @returns generator yielding numbers from `start` to `stop` (exclusive)
1088
+ *
1089
+ * @example
1090
+ * ```ts
1091
+ * for (const i of range(5)) {
1092
+ * console.log(i);
1093
+ * }
1094
+ * // 0, 1, 2, 3, 4
1095
+ *
1096
+ * for (const i of range(10, { start: 2, step: 2 })) {
1097
+ * console.log(i);
1098
+ * }
1099
+ * // 2, 4, 6, 8
1100
+ *
1101
+ * for (const i of range(0, { start: 10, step: -3 })) {
1102
+ * console.log(n);
1103
+ * }
1104
+ * // 10, 7, 4, 1
1105
+ * ```
1106
+ */
1107
+ export declare function range(stop: number, options?: RangeOptions): Generator<number, void, unknown>;
1108
+
1109
+ /**
1110
+ * Options of range function
1111
+ */
1112
+ export declare type RangeOptions = {
1113
+ /** inclusive bound (default `0`) */
1114
+ start?: number;
1115
+ /** step size (default `1`, must be non-zero) */
1116
+ step?: number;
1117
+ };
1118
+
1119
+ export declare interface Scalable<T> {
1120
+ multiplyScalar(scalar: number): T;
1121
+ divideScalar(scalar: number): T;
1122
+ }
1123
+
1124
+ /**
1125
+ * Computes the sum of all values in an iterable of numbers
1126
+ * @param values iterable containing numbers to sum
1127
+ * @returns sum of all values (0 if empty)
1128
+ *
1129
+ * @example
1130
+ * ```ts
1131
+ * sum([1, 2, 3]); // 6 (1+2+3)
1132
+ * ```
1133
+ */
1134
+ export declare function sum(values: Iterable<number>): number;
1135
+
1136
+ /**
1137
+ * Computes the sum of mapped values from an iterable, where `null` values contribute `0`.
1138
+ * @param values iterable of input values
1139
+ * @param callback mapping function `(value: T) => number | null`
1140
+ * @returns sum of non-null mapped values (0 if empty or all null)
1141
+ *
1142
+ * @example
1143
+ * ```ts
1144
+ * sumMap([1, 2, 3], x => x * x); // 14 (1+4+9)
1145
+ *
1146
+ * const objects = [{x: 1}, {x: 2}, {x: 3}];
1147
+ * sumMap(objects, obj => obj.x ?? null); // 6 (1+2+3)
1148
+ * ```
1149
+ */
1150
+ export declare function sumMap<T>(values: Iterable<T>, callback: (value: T) => number | null): number;
1151
+
1152
+ /**
1153
+ * @example
1154
+ * ```ts
1155
+ * type NumberTuple2 = TupleOf<number, 2>; // [number, number]
1156
+ * ```
1157
+ */
1158
+ export declare type TupleOf<Ele, Len extends number, Tup extends Ele[] = []> = Tup['length'] extends Len ? Tup : TupleOf<Ele, Len, [...Tup, Ele]>;
1159
+
1160
+ export declare interface Vector<D extends VectorDimension> {
1161
+ readonly dimension: D;
1162
+ readonly elements: TupleOf<number, D>;
1163
+ }
1164
+
1165
+ export declare class Vector1 implements Vector<1>, AdditiveGroup<Vector1>, Scalable<Vector1>, Normalizable<Vector1>, Clonable<Vector1> {
1166
+ /**
1167
+ * @example
1168
+ * ```ts
1169
+ * const v = new Vector1(2);
1170
+ * console.log(v.dimension); // 1
1171
+ * ```
1172
+ */
1173
+ readonly dimension = 1;
1174
+ /**
1175
+ * @example
1176
+ * ```ts
1177
+ * const v = new Vector1(2);
1178
+ * console.log(v.elements); // [1]
1179
+ * ```
1180
+ */
1181
+ readonly elements: [number];
1182
+ private static _tmpMatrix3?;
1183
+ private static get tmpMatrix3();
1184
+ private static _tmpMatrix4?;
1185
+ private static get tmpMatrix4();
1186
+ /**
1187
+ * @example
1188
+ * ```ts
1189
+ * const v = new Vector1(2);
1190
+ * ```
1191
+ */
1192
+ constructor(x: number);
1193
+ /**
1194
+ * @example
1195
+ * ```ts
1196
+ * const v = new Vector1(2);
1197
+ * console.log(v.x); // 2
1198
+ * ```
1199
+ */
1200
+ get x(): number;
1201
+ /**
1202
+ * @example
1203
+ * ```ts
1204
+ * const v = new Vector1(2);
1205
+ * v.x = 3;
1206
+ * console.log(v.x); // 3
1207
+ * ```
1208
+ */
1209
+ set x(x: number);
1210
+ /**
1211
+ * Creates a zero vector instance
1212
+ * @returns new zero vector instance
1213
+ * @group Factory Methods
1214
+ *
1215
+ * @example
1216
+ * ```ts
1217
+ * const v = Vector1.zero();
1218
+ * console.log(v.x); // 0
1219
+ * ```
1220
+ */
1221
+ static zero(): Vector1;
1222
+ /**
1223
+ * Creates a all ones vector instance
1224
+ * @returns new one vector instance
1225
+ * @group Factory Methods
1226
+ *
1227
+ * @example
1228
+ * ```ts
1229
+ * const v = Vector1.one();
1230
+ * console.log(v.x); // 1
1231
+ * ```
1232
+ */
1233
+ static one(): Vector1;
1234
+ /**
1235
+ * Creates new instance has same element (pure)
1236
+ * @returns new cloned vector instance
1237
+ *
1238
+ * @example
1239
+ * ```ts
1240
+ * const v = new Vector1(2);
1241
+ * const c = v.clone();
1242
+ * console.log(c.x); // 2
1243
+ * ```
1244
+ */
1245
+ clone(): Vector1;
1246
+ /**
1247
+ * Determines if this vector is the zero vector
1248
+ * @returns `true` if this vector is exactly zero, `false` otherwise
1249
+ *
1250
+ * @example
1251
+ * ```ts
1252
+ * const zero = Vector1.zero();
1253
+ * const one = Vector1.one();
1254
+ * console.log(zero.isZero()); // true
1255
+ * console.log(one.isZero()); // false
1256
+ * ```
1257
+ */
1258
+ isZero(): boolean;
1259
+ /**
1260
+ * Sets element value (mutates this)
1261
+ * @param x element value
1262
+ * @returns this instance, for method chaining
1263
+ *
1264
+ * @example
1265
+ * ```ts
1266
+ * const v = new Vector1(2);
1267
+ * v.set(3);
1268
+ * console.log(v.x); // 3
1269
+ * ```
1270
+ */
1271
+ set(x: number): Vector1;
1272
+ /**
1273
+ * Copies element value from other vector (mutates this)
1274
+ * @param other other vector
1275
+ * @returns this instance, for method chaining
1276
+ *
1277
+ * @example
1278
+ * ```ts
1279
+ * const v1 = new Vector1(1);
1280
+ * const v2 = new Vector1(2);
1281
+ * v1.copy(v2);
1282
+ * console.log(v1.x); // 2
1283
+ * console.log(v2.x); // 2
1284
+ * ```
1285
+ */
1286
+ copy(other: Vector1): Vector1;
1287
+ /**
1288
+ * Adds by other vector (mutates this)
1289
+ * @param other other vector
1290
+ * @returns this instance, for method chaining
1291
+ *
1292
+ * @example
1293
+ * ```ts
1294
+ * const v1 = new Vector1(2);
1295
+ * const v2 = new Vector1(3);
1296
+ * v1.add(v2);
1297
+ * console.log(v1.x); // 5
1298
+ * console.log(v2.x); // 3
1299
+ * ```
1300
+ */
1301
+ add(other: Vector1): Vector1;
1302
+ /**
1303
+ * Subtracts by other vector (mutates this)
1304
+ * @param other other vector
1305
+ * @returns this instance, for method chaining
1306
+ *
1307
+ * @example
1308
+ * ```ts
1309
+ * const v1 = new Vector1(2);
1310
+ * const v2 = new Vector1(3);
1311
+ * v1.subtract(v2);
1312
+ * console.log(v1.x); // -1
1313
+ * console.log(v2.x); // 3
1314
+ * ```
1315
+ */
1316
+ subtract(other: Vector1): Vector1;
1317
+ /**
1318
+ * Multiplies element by scalar (mutates this)
1319
+ * @param scalar
1320
+ * @returns this instance, for method chaining
1321
+ *
1322
+ * @example
1323
+ * ```ts
1324
+ * const v = new Vector1(2);
1325
+ * v.multiplyScalar(3);
1326
+ * console.log(v.x); // 6
1327
+ * ```
1328
+ */
1329
+ multiplyScalar(scalar: number): Vector1;
1330
+ /**
1331
+ * Divides element by scalar (mutates this)
1332
+ * @param scalar
1333
+ * @returns this instance, for method chaining
1334
+ *
1335
+ * @example
1336
+ * ```ts
1337
+ * const v = new Vector1(6);
1338
+ * v.divideScalar(2);
1339
+ * console.log(v.x); // 3
1340
+ * ```
1341
+ */
1342
+ divideScalar(scalar: number): Vector1;
1343
+ /**
1344
+ * Calculates the length of this vector
1345
+ * @returns the length of this vector (always non-negative)
1346
+ *
1347
+ * @example
1348
+ * ```ts
1349
+ * const v = new Vector1(2);
1350
+ * console.log(v.length()); // 2
1351
+ * ```
1352
+ */
1353
+ length(): number;
1354
+ /**
1355
+ * Normalizes this vector to length 1
1356
+ * @returns this instance, for method chaining
1357
+ *
1358
+ * @example
1359
+ * ```ts
1360
+ * const v = new Vector1(-2);
1361
+ * v.normalize();
1362
+ * console.log(v.x); // -1
1363
+ * ```
1364
+ */
1365
+ normalize(): Vector1;
1366
+ /**
1367
+ * Applies matrix to this vector (mutates this)
1368
+ * @param matrix
1369
+ * @returns this instance, for method chaining
1370
+ */
1371
+ applyMatrix3(matrix: Matrix3): Vector1;
1372
+ /**
1373
+ * Applies matrix to this vector (mutates this)
1374
+ * @param matrix
1375
+ * @returns this instance, for method chaining
1376
+ */
1377
+ applyMatrix4(matrix: Matrix4): Vector1;
1378
+ /**
1379
+ * Applies quaternion to this vector (mutates this)
1380
+ * @param quaternion
1381
+ * @returns this instance, for method chaining
1382
+ */
1383
+ applyQuaternion(quaternion: Quaternion): Vector1;
1384
+ }
1385
+
1386
+ export declare class Vector2 implements Vector<2>, AdditiveGroup<Vector2>, Scalable<Vector2>, Normalizable<Vector2>, Clonable<Vector2> {
1387
+ /**
1388
+ * @example
1389
+ * ```ts
1390
+ * const v = new Vector2(3, 4);
1391
+ * console.log(v.dimension); // 2
1392
+ * ```
1393
+ */
1394
+ readonly dimension = 2;
1395
+ /**
1396
+ * @example
1397
+ * ```ts
1398
+ * const v = new Vector2(3, 4);
1399
+ * console.log(v.elements); // [3, 4]
1400
+ * ```
1401
+ */
1402
+ readonly elements: [number, number];
1403
+ private static _tmpMatrix3?;
1404
+ private static get tmpMatrix3();
1405
+ private static _tmpMatrix4?;
1406
+ private static get tmpMatrix4();
1407
+ /**
1408
+ * @example
1409
+ * ```ts
1410
+ * const v = new Vector2(3, 4);
1411
+ * ```
1412
+ */
1413
+ constructor(x: number, y: number);
1414
+ /**
1415
+ * @example
1416
+ * ```ts
1417
+ * const v = new Vector2(3, 4);
1418
+ * console.log(v.x); // 3
1419
+ * ```
1420
+ */
1421
+ get x(): number;
1422
+ /**
1423
+ * @example
1424
+ * ```ts
1425
+ * const v = new Vector2(3, 4);
1426
+ * v.x = 5;
1427
+ * console.log(v.x); // 5
1428
+ * ```
1429
+ */
1430
+ set x(x: number);
1431
+ /**
1432
+ * @example
1433
+ * ```ts
1434
+ * const v = new Vector2(3, 4);
1435
+ * console.log(v.y); // 4
1436
+ * ```
1437
+ */
1438
+ get y(): number;
1439
+ /**
1440
+ * @example
1441
+ * ```ts
1442
+ * const v = new Vector2(3, 4);
1443
+ * v.y = 5;
1444
+ * console.log(v.y); // 5
1445
+ * ```
1446
+ */
1447
+ set y(y: number);
1448
+ /**
1449
+ * Creates a zero vector instance
1450
+ * @returns new zero vector instance
1451
+ * @group Factory Methods
1452
+ *
1453
+ * @example
1454
+ * ```ts
1455
+ * const v = Vector2.zero();
1456
+ * console.log(v); // (0, 0)
1457
+ * ```
1458
+ */
1459
+ static zero(): Vector2;
1460
+ /**
1461
+ * Creates all ones vector instance
1462
+ * @returns new all ones vector instance
1463
+ * @group Factory Methods
1464
+ *
1465
+ * @example
1466
+ * ```ts
1467
+ * const v = Vector2.one();
1468
+ * console.log(v); // (1, 1)
1469
+ * ```
1470
+ */
1471
+ static one(): Vector2;
1472
+ /**
1473
+ * Creates new instance has same elements (pure)
1474
+ * @returns new cloned vector instance
1475
+ *
1476
+ * @example
1477
+ * ```ts
1478
+ * const v = new Vector2(3, 4);
1479
+ * const c = v.clone();
1480
+ * console.log(c); // (3, 4)
1481
+ * ```
1482
+ */
1483
+ clone(): Vector2;
1484
+ /**
1485
+ * Determines if this vector is the zero vector (all components are zero)
1486
+ * @returns `true` if this vector is exactly zero, `false` otherwise
1487
+ *
1488
+ * @example
1489
+ * ```ts
1490
+ * const zero = Vector2.zero();
1491
+ * const ones = Vector2.one();
1492
+ * console.log(zero.isZero()); // true
1493
+ * console.log(ones.isZero()); // false
1494
+ */
1495
+ isZero(): boolean;
1496
+ /**
1497
+ * Sets all elements (mutates this)
1498
+ * @param x
1499
+ * @param y
1500
+ * @returns this instance, for method chaining
1501
+ *
1502
+ * @example
1503
+ * ```ts
1504
+ * const v = new Vector2(3, 4);
1505
+ * v.set(5, 6);
1506
+ * console.log(v); // (5, 6)
1507
+ * ```
1508
+ */
1509
+ set(x: number, y: number): Vector2;
1510
+ /**
1511
+ * Copies all elements from other vector (mutates this)
1512
+ * @returns this instance, for method chaining
1513
+ *
1514
+ * @example
1515
+ * ```ts
1516
+ * const v1 = new Vector2(3, 4);
1517
+ * const v2 = new Vector2(5, 6);
1518
+ * v1.copy(v2);
1519
+ * console.log(v1); // (5, 6)
1520
+ * console.log(v2); // (5, 6)
1521
+ * ```
1522
+ */
1523
+ copy(other: Vector2): Vector2;
1524
+ /**
1525
+ * Adds by other vector (mutates this)
1526
+ * @param other other vector
1527
+ * @returns this instance, for method chaining
1528
+ *
1529
+ * @example
1530
+ * ```ts
1531
+ * const v1 = new Vector2(3, 4);
1532
+ * const v2 = new Vector2(5, 6);
1533
+ * v1.add(v2);
1534
+ * console.log(v1); // (8, 10)
1535
+ * console.log(v2); // (5, 6)
1536
+ * ```
1537
+ */
1538
+ add(other: Vector2): Vector2;
1539
+ /**
1540
+ * Subtracts by other vector (mutates this)
1541
+ * @param other other vector
1542
+ * @returns this instance, for method chaining
1543
+ *
1544
+ * @example
1545
+ * ```ts
1546
+ * const v1 = new Vector2(3, 4);
1547
+ * const v2 = new Vector2(5, 6);
1548
+ * v1.subtract(v2);
1549
+ * console.log(v1); // (-2, -2)
1550
+ * console.log(v2); // (5, 6)
1551
+ * ```
1552
+ */
1553
+ subtract(other: Vector2): Vector2;
1554
+ /**
1555
+ * Multiplies all elements by scalar (mutates this)
1556
+ * @param scalar
1557
+ * @returns this instance, for method chaining
1558
+ *
1559
+ * @example
1560
+ * ```ts
1561
+ * const v = new Vector2(3, 4);
1562
+ * v.multiplyScalar(2);
1563
+ * console.log(v); // (6, 8)
1564
+ * ```
1565
+ */
1566
+ multiplyScalar(scalar: number): Vector2;
1567
+ /**
1568
+ * Divides all elements by scalar (mutates this)
1569
+ * @param scalar
1570
+ * @returns this instance, for method chaining
1571
+ *
1572
+ * @example
1573
+ * ```ts
1574
+ * const v = new Vector2(3, 4);
1575
+ * v.divideScalar(2);
1576
+ * console.log(v); // (1.5, 2)
1577
+ * ```
1578
+ */
1579
+ divideScalar(scalar: number): Vector2;
1580
+ /**
1581
+ * Calculates the length of this vector (pure)
1582
+ * @returns the length of this vector (always non-negative)
1583
+ *
1584
+ * @example
1585
+ * ```ts
1586
+ * const v = new Vector2(3, 4);
1587
+ * console.log(v.length()); // 5
1588
+ * ```
1589
+ */
1590
+ length(): number;
1591
+ /**
1592
+ * Normalizes this vector to length 1 (mutates this)
1593
+ * @returns this instance, for method chaining
1594
+ *
1595
+ * @example
1596
+ * ```ts
1597
+ * const v = new Vector2(3, 4);
1598
+ * v.normalize();
1599
+ * console.log(v); // (0.6, 0.8)
1600
+ * ```
1601
+ */
1602
+ normalize(): Vector2;
1603
+ /**
1604
+ * Rotates vector by given angle in radians (mutates this)
1605
+ * @param radian angle in radians, measured counter-clockwise from the positive x-axis
1606
+ * @returns this instance, for method chaining
1607
+ *
1608
+ * @example
1609
+ * ```ts
1610
+ * const v = new Vector2(1, 1);
1611
+ * v.rotate(Math.PI / 2);
1612
+ * console.log(v); // (-1, 1)
1613
+ * ```
1614
+ */
1615
+ rotate(radian: number): Vector2;
1616
+ /**
1617
+ * Applies matrix to this vector (mutates this)
1618
+ * @param matrix
1619
+ * @returns this instance, for method chaining
1620
+ */
1621
+ applyMatrix3(matrix: Matrix3): Vector2;
1622
+ /**
1623
+ * Applies matrix to this vector (mutates this)
1624
+ * @param matrix
1625
+ * @returns this instance, for method chaining
1626
+ */
1627
+ applyMatrix4(matrix: Matrix4): Vector2;
1628
+ /**
1629
+ * Applies quaternion to this vector (mutates this)
1630
+ * @param quaternion
1631
+ * @returns this instance, for method chaining
1632
+ */
1633
+ applyQuaternion(quaternion: Quaternion): Vector2;
1634
+ }
1635
+
1636
+ export declare class Vector3 implements Vector<3>, AdditiveGroup<Vector3>, Scalable<Vector3>, Normalizable<Vector3>, Clonable<Vector3> {
1637
+ /**
1638
+ * @example
1639
+ * ```ts
1640
+ * const v = new Vector3(4, 5, 6);
1641
+ * console.log(v.dimension); // 3
1642
+ * ```
1643
+ */
1644
+ readonly dimension = 3;
1645
+ /**
1646
+ * @example
1647
+ * ```ts
1648
+ * const v = new Vector3(4, 5, 6);
1649
+ * console.log(v.elements); // [4, 5, 6]
1650
+ * ```
1651
+ */
1652
+ readonly elements: [number, number, number];
1653
+ private static _tmpMatrix3?;
1654
+ private static get tmpMatrix3();
1655
+ private static _tmpMatrix4?;
1656
+ private static get tmpMatrix4();
1657
+ /**
1658
+ * @example
1659
+ * ```ts
1660
+ * const v = new Vector3(4, 5, 6);
1661
+ * ```
1662
+ */
1663
+ constructor(x: number, y: number, z: number);
1664
+ /**
1665
+ * @example
1666
+ * ```ts
1667
+ * const v = new Vector3(4, 5, 6);
1668
+ * console.log(v.x); // 4
1669
+ * ```
1670
+ */
1671
+ get x(): number;
1672
+ /**
1673
+ * @example
1674
+ * ```ts
1675
+ * const v = new Vector3(4, 5, 6);
1676
+ * v.x = 7;
1677
+ * console.log(v.x); // 7
1678
+ * ```
1679
+ */
1680
+ set x(x: number);
1681
+ /**
1682
+ * @example
1683
+ * ```ts
1684
+ * const v = new Vector3(4, 5, 6);
1685
+ * console.log(v.y); // 5
1686
+ * ```
1687
+ */
1688
+ get y(): number;
1689
+ /**
1690
+ * @example
1691
+ * ```ts
1692
+ * const v = new Vector3(4, 5, 6);
1693
+ * v.y = 7;
1694
+ * console.log(v.y); // 7
1695
+ * ```
1696
+ */
1697
+ set y(y: number);
1698
+ /**
1699
+ * @example
1700
+ * ```ts
1701
+ * const v = new Vector3(4, 5, 6);
1702
+ * console.log(v.z); // 6
1703
+ * ```
1704
+ */
1705
+ get z(): number;
1706
+ /**
1707
+ * @example
1708
+ * ```ts
1709
+ * const v = new Vector3(4, 5, 6);
1710
+ * v.z = 7;
1711
+ * console.log(v.z); // 7
1712
+ * ```
1713
+ */
1714
+ set z(z: number);
1715
+ /**
1716
+ * Creates a zero vector instance
1717
+ * @returns new zero vector instance
1718
+ * @group Factory Methods
1719
+ *
1720
+ * @example
1721
+ * ```ts
1722
+ * const v = Vector3.zero();
1723
+ * console.log(v); // (0, 0, 0)
1724
+ * ```
1725
+ */
1726
+ static zero(): Vector3;
1727
+ /**
1728
+ * Creates all ones vector instance
1729
+ * @returns new all ones vector instance
1730
+ * @group Factory Methods
1731
+ *
1732
+ * @example
1733
+ * ```ts
1734
+ * const v = Vector3.one();
1735
+ * console.log(v); // (1, 1, 1)
1736
+ * ```
1737
+ *
1738
+ */
1739
+ static one(): Vector3;
1740
+ /**
1741
+ * Creates new instance has same elements (pure)
1742
+ * @returns new cloned vector instance
1743
+ *
1744
+ * @example
1745
+ * ```ts
1746
+ * const v = new Vector3(4, 5, 6);
1747
+ * const c = v.clone();
1748
+ * console.log(c); // (4, 5, 6)
1749
+ * ```
1750
+ */
1751
+ clone(): Vector3;
1752
+ /**
1753
+ * Determines if this vector is the zero vector (all components are zero)
1754
+ * @returns `true` if this vector is exactly zero, `false` otherwise
1755
+ *
1756
+ * @example
1757
+ * ```ts
1758
+ * const zero = Vector3.zero();
1759
+ * const ones = Vector3.one();
1760
+ * console.log(zero.isZero()); // true
1761
+ * console.log(ones.isZero()); // false
1762
+ * ```
1763
+ */
1764
+ isZero(): boolean;
1765
+ /**
1766
+ * Sets all elements (mutates this)
1767
+ * @param x
1768
+ * @param y
1769
+ * @param z
1770
+ * @returns this instance, for method chaining
1771
+ *
1772
+ * @example
1773
+ * ```ts
1774
+ * const v = new Vector3(4, 5, 6);
1775
+ * v.set(7, 8, 9);
1776
+ * console.log(v); // (7, 8, 9)
1777
+ * ```
1778
+ */
1779
+ set(x: number, y: number, z: number): Vector3;
1780
+ /**
1781
+ * Copies all elements from other vector (mutates this)
1782
+ * @returns this instance, for method chaining
1783
+ *
1784
+ * @example
1785
+ * ```ts
1786
+ * const v1 = new Vector3(4, 5, 6);
1787
+ * const v2 = new Vector3(7, 8, 9);
1788
+ * v1.copy(v2);
1789
+ * console.log(v1); // (7, 8, 9)
1790
+ * console.log(v2); // (7, 8, 9)
1791
+ * ```
1792
+ */
1793
+ copy(other: Vector3): Vector3;
1794
+ /**
1795
+ * Adds by other vector (mutates this)
1796
+ * @param other other vector
1797
+ * @returns this instance, for method chaining
1798
+ *
1799
+ * @example
1800
+ * ```ts
1801
+ * const v1 = new Vector3(4, 5, 6);
1802
+ * const v2 = new Vector3(7, 8, 9);
1803
+ * v1.add(v2);
1804
+ * console.log(v1); // (11, 13, 15)
1805
+ * console.log(v2); // (7, 8, 9)
1806
+ * ```
1807
+ */
1808
+ add(other: Vector3): Vector3;
1809
+ /**
1810
+ * Subtracts by other vector (mutates this)
1811
+ * @param other other vector
1812
+ * @returns this instance, for method chaining
1813
+ *
1814
+ * @example
1815
+ * ```ts
1816
+ * const v1 = new Vector3(4, 5, 6);
1817
+ * const v2 = new Vector3(7, 8, 9);
1818
+ * v1.subtract(v2);
1819
+ * console.log(v1); // (-3, -3, -3)
1820
+ * console.log(v2); // (7, 8, 9)
1821
+ * ```
1822
+ */
1823
+ subtract(other: Vector3): Vector3;
1824
+ /**
1825
+ * Multiplies all elements by scalar (mutates this)
1826
+ * @param scalar
1827
+ * @returns this instance, for method chaining
1828
+ *
1829
+ * @example
1830
+ * ```ts
1831
+ * const v = new Vector3(4, 5, 6);
1832
+ * v.multiplyScalar(2);
1833
+ * console.log(v); // (8, 10, 12)
1834
+ * ```
1835
+ */
1836
+ multiplyScalar(scalar: number): Vector3;
1837
+ /**
1838
+ * Divides all elements by scalar (mutates this)
1839
+ * @param scalar
1840
+ * @returns this instance, for method chaining
1841
+ *
1842
+ * @example
1843
+ * ```ts
1844
+ * const v = new Vector3(4, 5, 6);
1845
+ * v.divideScalar(2);
1846
+ * console.log(v); // (2, 2.5, 3)
1847
+ * ```
1848
+ */
1849
+ divideScalar(scalar: number): Vector3;
1850
+ /**
1851
+ * Calculates the length of this vector (pure)
1852
+ * @returns the length of this vector (always non-negative)
1853
+ *
1854
+ * @example
1855
+ * ```ts
1856
+ * const v = new Vector3(2, 3, 6);
1857
+ * console.log(v.length()); // 7
1858
+ * ```
1859
+ */
1860
+ length(): number;
1861
+ /**
1862
+ * Normalizes this vector to length 1 (mutates this)
1863
+ * @returns this instance, for method chaining
1864
+ *
1865
+ * @example
1866
+ * ```ts
1867
+ * const v = new Vector3(2, 3, 6);
1868
+ * v.normalize();
1869
+ * console.log(v); // (2/7, 3/7, 6/7)
1870
+ * ```
1871
+ */
1872
+ normalize(): Vector3;
1873
+ /**
1874
+ * Calculates the cross product of this and other (mutates this)
1875
+ * @param other other vector
1876
+ * @returns this instance, for method chaining
1877
+ *
1878
+ * @example
1879
+ * ```ts
1880
+ * const v1 = new Vector3(1, 0, 0);
1881
+ * const v2 = Vector3.zero();
1882
+ * v1.cross(v2);
1883
+ * console.log(v1); // (0, 0, 1);
1884
+ *
1885
+ * const v3 = new Vector3(1, 0, 0);
1886
+ * const v4 = Vector3.zero();
1887
+ * const out = Vector3.zero();
1888
+ * v3.cross(v4, out);
1889
+ * console.log(v3); // (1, 0, 0)
1890
+ * console.log(out); // (0, 0, 1)
1891
+ * ```
1892
+ */
1893
+ cross(other: Vector3): Vector3;
1894
+ /**
1895
+ * Calculates the cross product of this and other (mutates out)
1896
+ * @param other other vector
1897
+ * @param out vector instance to receive cross
1898
+ * @returns
1899
+ */
1900
+ crossTo(other: Vector3, out: Vector3): Vector3;
1901
+ /**
1902
+ * Applies matrix to this vector (mutates this)
1903
+ * @param matrix
1904
+ * @returns this instance, for method chaining
1905
+ */
1906
+ applyMatrix3(matrix: Matrix3): Vector3;
1907
+ /**
1908
+ * Applies matrix to this vector (mutates this)
1909
+ * @param matrix
1910
+ * @returns this instance, for method chaining
1911
+ */
1912
+ applyMatrix4(matrix: Matrix4): Vector3;
1913
+ /**
1914
+ * Applies quaternion to this vector (mutates this)
1915
+ * @param quaternion
1916
+ * @returns this instance, for method chaining
1917
+ */
1918
+ applyQuaternion(quaternion: Quaternion): Vector3;
1919
+ }
1920
+
1921
+ export declare class Vector4 implements Vector<4>, AdditiveGroup<Vector4>, Scalable<Vector4>, Normalizable<Vector4>, Clonable<Vector4> {
1922
+ /**
1923
+ * @example
1924
+ * ```ts
1925
+ * const v = new Vector4(0, 1, 2, 3);
1926
+ * console.log(v.dimension); // 4
1927
+ * ```
1928
+ */
1929
+ readonly dimension = 4;
1930
+ /**
1931
+ * @example
1932
+ * ```ts
1933
+ * const v = new Vector4(0, 1, 2, 3);
1934
+ * console.log(v.elements); // [0, 1, 2, 3]
1935
+ * ```
1936
+ */
1937
+ readonly elements: [number, number, number, number];
1938
+ private static _tmpMatrix4?;
1939
+ private static get tmpMatrix4();
1940
+ /**
1941
+ * @example
1942
+ * ```ts
1943
+ * const v = new Vector4(0, 1, 2, 3);
1944
+ * ```
1945
+ */
1946
+ constructor(x: number, y: number, z: number, w: number);
1947
+ /**
1948
+ * @example
1949
+ * ```ts
1950
+ * const v = new Vector4(0, 1, 2, 3);
1951
+ * console.log(v.x); // 0
1952
+ * ```
1953
+ */
1954
+ get x(): number;
1955
+ /**
1956
+ * @example
1957
+ * ```ts
1958
+ * const v = new Vector4(0, 1, 2, 3);
1959
+ * v.x = 5;
1960
+ * console.log(v.x); // 5
1961
+ * ```
1962
+ */
1963
+ set x(x: number);
1964
+ /**
1965
+ * @example
1966
+ * ```ts
1967
+ * const v = new Vector4(0, 1, 2, 3);
1968
+ * console.log(v.y); // 1
1969
+ * ```
1970
+ */
1971
+ get y(): number;
1972
+ /**
1973
+ * @example
1974
+ * ```ts
1975
+ * const v = new Vector4(0, 1, 2, 3);
1976
+ * v.y = 5;
1977
+ * console.log(v.y); // 5
1978
+ * ```
1979
+ */
1980
+ set y(y: number);
1981
+ /**
1982
+ * @example
1983
+ * ```ts
1984
+ * const v = new Vector4(0, 1, 2, 3);
1985
+ * console.log(v.z); // 2
1986
+ * ```
1987
+ */
1988
+ get z(): number;
1989
+ /**
1990
+ * @example
1991
+ * ```ts
1992
+ * const v = new Vector4(0, 1, 2, 3);
1993
+ * v.z = 5;
1994
+ * console.log(v.z); // 5
1995
+ * ```
1996
+ */
1997
+ set z(z: number);
1998
+ /**
1999
+ * @example
2000
+ * ```ts
2001
+ * const v = new Vector4(0, 1, 2, 3);
2002
+ * console.log(v.w); // 3
2003
+ * ```
2004
+ */
2005
+ get w(): number;
2006
+ /**
2007
+ * @example
2008
+ * ```ts
2009
+ * const v = new Vector4(0, 1, 2, 3);
2010
+ * v.w = 5;
2011
+ * console.log(v.w); // 5
2012
+ * ```
2013
+ */
2014
+ set w(w: number);
2015
+ /**
2016
+ * Creates a zero vector instance
2017
+ * @returns new zero vector instance
2018
+ * @group Factory Methods
2019
+ *
2020
+ * @example
2021
+ * ```ts
2022
+ * const v = Vector4.zero();
2023
+ * console.log(v); // (0, 0, 0, 0)
2024
+ * ```
2025
+ */
2026
+ static zero(): Vector4;
2027
+ /**
2028
+ * Creates all ones vector instance
2029
+ * @returns new all ones vector instance
2030
+ * @group Factory Methods
2031
+ *
2032
+ * @example
2033
+ * ```ts
2034
+ * const v = Vector4.one();
2035
+ * console.log(v); // (1, 1, 1, 1)
2036
+ * ```
2037
+ */
2038
+ static one(): Vector4;
2039
+ /**
2040
+ * Creates new instance has same elements (pure)
2041
+ * @returns new cloned vector instance
2042
+ *
2043
+ * @example
2044
+ * ```ts
2045
+ * const v = new Vector4(0, 1, 2, 3);
2046
+ * const c = v.clone();
2047
+ * console.log(c); // (0, 1, 2, 3);
2048
+ * ```
2049
+ */
2050
+ clone(): Vector4;
2051
+ /**
2052
+ * Determines if this vector is the zero vector (all components are zero)
2053
+ * @returns `true` if this vector is exactly zero, `false` otherwise
2054
+ *
2055
+ * @example
2056
+ * ```ts
2057
+ * const zero = Vector4.zero();
2058
+ * const ones = Vector4.one();
2059
+ * console.log(zero.isZero()); // true
2060
+ * console.log(ones.isZero()); // false
2061
+ * ```
2062
+ */
2063
+ isZero(): boolean;
2064
+ /**
2065
+ * Sets all elements (mutates this)
2066
+ * @param x
2067
+ * @param y
2068
+ * @param z
2069
+ * @param w
2070
+ * @returns this instance, for method chaining
2071
+ *
2072
+ * @example
2073
+ * ```ts
2074
+ * const v = new Vector4(0, 1, 2, 3);
2075
+ * v.set(5, 6, 7, 8);
2076
+ * console.log(v); // (5, 6, 7, 8)
2077
+ * ```
2078
+ */
2079
+ set(x: number, y: number, z: number, w: number): void;
2080
+ /**
2081
+ * Copies all elements from other vector (mutates this)
2082
+ * @returns this instance, for method chaining
2083
+ *
2084
+ * @example
2085
+ * ```ts
2086
+ * const v1 = new Vector4(0, 1, 2, 3);
2087
+ * const v2 = new Vector4(5, 6, 7, 8);
2088
+ * v1.copy(v2);
2089
+ * console.log(v1); // (5, 6, 7, 8)
2090
+ * console.log(v2); // (5, 6, 7, 8)
2091
+ * ```
2092
+ */
2093
+ copy(other: Vector4): void;
2094
+ /**
2095
+ * Adds by other vector (mutates this)
2096
+ * @param other other vector
2097
+ * @returns this instance, for method chaining
2098
+ *
2099
+ * @example
2100
+ * ```ts
2101
+ * const v1 = new Vector4(0, 1, 2, 3);
2102
+ * const v2 = new Vector4(5, 6, 7, 8);
2103
+ * v1.add(v2);
2104
+ * console.log(v1); // (5, 7, 9, 11)
2105
+ * console.log(v2); // (5, 6, 7, 8)
2106
+ * ```
2107
+ */
2108
+ add(other: Vector4): Vector4;
2109
+ /**
2110
+ * Subtracts by other vector (mutates this)
2111
+ * @param other other vector
2112
+ * @returns this instance, for method chaining
2113
+ *
2114
+ * @example
2115
+ * ```ts
2116
+ * const v1 = new Vector4(0, 1, 2, 3);
2117
+ * const v2 = new Vector4(5, 6, 7, 8);
2118
+ * v1.subtract(v2);
2119
+ * console.log(v1); // (-5, -5, -5, -5)
2120
+ * console.log(v2); // (5, 6, 7, 8)
2121
+ * ```
2122
+ */
2123
+ subtract(other: Vector4): Vector4;
2124
+ /**
2125
+ * Multiplies all elements by scalar (mutates this)
2126
+ * @param scalar
2127
+ * @returns this instance, for method chaining
2128
+ *
2129
+ * @example
2130
+ * ```ts
2131
+ * const v = new Vector4(0, 1, 2, 3);
2132
+ * v.multiplyScalar(2);
2133
+ * console.log(v); // (0, 2, 4, 6)
2134
+ * ```
2135
+ */
2136
+ multiplyScalar(scalar: number): Vector4;
2137
+ /**
2138
+ * Divides all elements by scalar (mutates this)
2139
+ * @param scalar
2140
+ * @returns this instance, for method chaining
2141
+ *
2142
+ * @example
2143
+ * ```ts
2144
+ * const v = new Vector4(0, 1, 2, 3);
2145
+ * v.divideScalar(2);
2146
+ * console.log(v); // (0, 0.5, 1, 1.5)
2147
+ * ```
2148
+ */
2149
+ divideScalar(scalar: number): Vector4;
2150
+ /**
2151
+ * Calculates the length of this vector (pure)
2152
+ * @returns the length of this vector (always non-negative)
2153
+ *
2154
+ * @example
2155
+ * ```ts
2156
+ * const v = new Vector4(1, 2, 2, 4);
2157
+ * console.log(v.length()); // 5
2158
+ * ```
2159
+ */
2160
+ length(): number;
2161
+ /**
2162
+ * Normalizes this vector to length 1 (mutates this)
2163
+ * @returns this instance, for method chaining
2164
+ *
2165
+ * @example
2166
+ * ```ts
2167
+ * const v = new Vector4(1, 2, 2, 4);
2168
+ * v.normalize();
2169
+ * console.log(v); // (1/5, 2/5, 2/5, 4/5)
2170
+ * ```
2171
+ */
2172
+ normalize(): Vector4;
2173
+ /**
2174
+ * Applies matrix to this vector (mutates this)
2175
+ * @param matrix
2176
+ * @returns this instance, for method chaining
2177
+ */
2178
+ applyMatrix4(matrix: Matrix4): Vector4;
2179
+ /**
2180
+ * Applies quaternion to this vector (mutates this)
2181
+ * @param quaternion
2182
+ * @returns this instance, for method chaining
2183
+ */
2184
+ applyQuaternion(quaternion: Quaternion): Vector4;
2185
+ }
2186
+
2187
+ export declare type VectorDimension = 1 | 2 | 3 | 4;
2188
+
2189
+ export { }