@woosh/meep-engine 2.121.8 → 2.121.11
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.
- package/package.json +1 -1
- package/src/core/binary/to_half_float_uint16.d.ts +1 -2
- package/src/core/binary/to_half_float_uint16.d.ts.map +1 -1
- package/src/core/binary/to_half_float_uint16.js +1 -2
- package/src/core/geom/ConicRay.d.ts +8 -0
- package/src/core/geom/ConicRay.d.ts.map +1 -1
- package/src/core/geom/ConicRay.js +11 -0
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +102 -49
- package/src/core/geom/Vector1.d.ts.map +1 -1
- package/src/core/geom/Vector1.js +11 -8
- package/src/core/geom/Vector2.d.ts.map +1 -1
- package/src/core/geom/Vector2.js +89 -59
- package/src/core/geom/Vector3.d.ts.map +1 -1
- package/src/core/geom/Vector3.js +108 -68
- package/src/core/geom/Vector4.d.ts +230 -40
- package/src/core/geom/Vector4.d.ts.map +1 -1
- package/src/core/geom/Vector4.js +36 -1
- package/src/core/geom/packing/max-rect/cutArea.d.ts.map +1 -1
- package/src/core/geom/packing/max-rect/cutArea.js +7 -8
- package/src/core/geom/packing/miniball/Miniball.d.ts +188 -11
- package/src/core/geom/packing/miniball/PointSet.d.ts +46 -3
- package/src/core/geom/vec3/v3_slerp.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_slerp.js +2 -0
- package/src/core/math/EPSILON.d.ts.map +1 -1
- package/src/core/math/EPSILON.js +1 -1
- package/src/engine/ecs/EntityManager.d.ts +181 -35
- package/src/engine/ecs/EntityManager.d.ts.map +1 -1
- package/src/engine/ecs/EntityManager.js +11 -9
- package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts +6 -1
- package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere.d.ts +1 -1
- package/src/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_to_f16.d.ts.map +1 -1
- package/src/generation/markers/transform/MarkerNodeTransformRotateRandom.js +1 -1
- package/editor/tools/GridPaintTool.d.ts +0 -17
- package/editor/tools/GridPaintTool.d.ts.map +0 -1
- package/editor/tools/SelectionTool.d.ts +0 -27
- package/editor/tools/SelectionTool.d.ts.map +0 -1
- package/editor/tools/TopDownCameraControlTool.d.ts +0 -13
- package/editor/tools/TopDownCameraControlTool.d.ts.map +0 -1
package/src/core/geom/Vector3.js
CHANGED
|
@@ -17,7 +17,7 @@ import { v3_slerp } from "./vec3/v3_slerp.js";
|
|
|
17
17
|
* @author Alex Goldring
|
|
18
18
|
* @copyright Alex Goldring 2015-2024
|
|
19
19
|
*/
|
|
20
|
-
class Vector3 {
|
|
20
|
+
export class Vector3 {
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
23
|
* @param {number} [x=0]
|
|
@@ -36,21 +36,21 @@ class Vector3 {
|
|
|
36
36
|
assert.notNaN(z, 'x');
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Do not assign directly, use {@link set} method instead
|
|
40
40
|
* @readonly
|
|
41
41
|
* @type {number}
|
|
42
42
|
*/
|
|
43
43
|
this.x = x;
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Do not assign directly, use {@link set} method instead
|
|
47
47
|
* @readonly
|
|
48
48
|
* @type {number}
|
|
49
49
|
*/
|
|
50
50
|
this.y = y;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Do not assign directly, use {@link set} method instead
|
|
54
54
|
* @readonly
|
|
55
55
|
* @type {number}
|
|
56
56
|
*/
|
|
@@ -91,10 +91,10 @@ class Vector3 {
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
*
|
|
94
|
-
* @param {
|
|
95
|
-
* @param {
|
|
96
|
-
* @param {
|
|
97
|
-
* @returns {
|
|
94
|
+
* @param {number} x
|
|
95
|
+
* @param {number} y
|
|
96
|
+
* @param {number} z
|
|
97
|
+
* @returns {this}
|
|
98
98
|
*/
|
|
99
99
|
set(x, y, z) {
|
|
100
100
|
assert.isNumber(x, "x");
|
|
@@ -128,15 +128,16 @@ class Vector3 {
|
|
|
128
128
|
/**
|
|
129
129
|
*
|
|
130
130
|
* @param {number} v
|
|
131
|
+
* @returns {this}
|
|
131
132
|
*/
|
|
132
133
|
setScalar(v) {
|
|
133
|
-
this.set(v, v, v);
|
|
134
|
+
return this.set(v, v, v);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
/**
|
|
137
138
|
*
|
|
138
139
|
* @param {number} v
|
|
139
|
-
* @returns {
|
|
140
|
+
* @returns {this}
|
|
140
141
|
*/
|
|
141
142
|
setX(v) {
|
|
142
143
|
return this.set(v, this.y, this.z);
|
|
@@ -145,7 +146,7 @@ class Vector3 {
|
|
|
145
146
|
/**
|
|
146
147
|
*
|
|
147
148
|
* @param {number} v
|
|
148
|
-
* @returns {
|
|
149
|
+
* @returns {this}
|
|
149
150
|
*/
|
|
150
151
|
setY(v) {
|
|
151
152
|
return this.set(this.x, v, this.z);
|
|
@@ -154,7 +155,7 @@ class Vector3 {
|
|
|
154
155
|
/**
|
|
155
156
|
*
|
|
156
157
|
* @param {number} v
|
|
157
|
-
* @returns {
|
|
158
|
+
* @returns {this}
|
|
158
159
|
*/
|
|
159
160
|
setZ(v) {
|
|
160
161
|
return this.set(this.x, this.y, v);
|
|
@@ -164,7 +165,7 @@ class Vector3 {
|
|
|
164
165
|
*
|
|
165
166
|
* @param {number} x
|
|
166
167
|
* @param {number} y
|
|
167
|
-
* @returns {
|
|
168
|
+
* @returns {this}
|
|
168
169
|
*/
|
|
169
170
|
setXY(x, y) {
|
|
170
171
|
return this.set(x, y, this.z);
|
|
@@ -174,7 +175,7 @@ class Vector3 {
|
|
|
174
175
|
*
|
|
175
176
|
* @param {number} x
|
|
176
177
|
* @param {number} z
|
|
177
|
-
* @returns {
|
|
178
|
+
* @returns {this}
|
|
178
179
|
*/
|
|
179
180
|
setXZ(x, z) {
|
|
180
181
|
return this.set(x, this.y, z);
|
|
@@ -184,7 +185,7 @@ class Vector3 {
|
|
|
184
185
|
*
|
|
185
186
|
* @param {number} y
|
|
186
187
|
* @param {number} z
|
|
187
|
-
* @returns {
|
|
188
|
+
* @returns {this}
|
|
188
189
|
*/
|
|
189
190
|
setYZ(y, z) {
|
|
190
191
|
return this.set(this.x, y, z);
|
|
@@ -194,19 +195,20 @@ class Vector3 {
|
|
|
194
195
|
*
|
|
195
196
|
* @param {Vector3} a
|
|
196
197
|
* @param {Vector3} b
|
|
198
|
+
* @returns {this}
|
|
197
199
|
*/
|
|
198
200
|
addVectors(a, b) {
|
|
199
201
|
const x = a.x + b.x;
|
|
200
202
|
const y = a.y + b.y;
|
|
201
203
|
const z = a.z + b.z;
|
|
202
204
|
|
|
203
|
-
this.set(x, y, z);
|
|
205
|
+
return this.set(x, y, z);
|
|
204
206
|
}
|
|
205
207
|
|
|
206
208
|
/**
|
|
207
209
|
*
|
|
208
210
|
* @param {Vector3} other
|
|
209
|
-
* @returns {
|
|
211
|
+
* @returns {this}
|
|
210
212
|
*/
|
|
211
213
|
add(other) {
|
|
212
214
|
return this._add(other.x, other.y, other.z);
|
|
@@ -214,10 +216,10 @@ class Vector3 {
|
|
|
214
216
|
|
|
215
217
|
/**
|
|
216
218
|
*
|
|
217
|
-
* @param {
|
|
218
|
-
* @param {
|
|
219
|
-
* @param {
|
|
220
|
-
* @returns {
|
|
219
|
+
* @param {number} x
|
|
220
|
+
* @param {number} y
|
|
221
|
+
* @param {number} z
|
|
222
|
+
* @returns {this}
|
|
221
223
|
*/
|
|
222
224
|
_add(x, y, z) {
|
|
223
225
|
return this.set(this.x + x, this.y + y, this.z + z);
|
|
@@ -228,19 +230,20 @@ class Vector3 {
|
|
|
228
230
|
*
|
|
229
231
|
* @param {Vector3} a
|
|
230
232
|
* @param {Vector3} b
|
|
233
|
+
* @returns {this}
|
|
231
234
|
*/
|
|
232
235
|
subVectors(a, b) {
|
|
233
236
|
const x = a.x - b.x;
|
|
234
237
|
const y = a.y - b.y;
|
|
235
238
|
const z = a.z - b.z;
|
|
236
239
|
|
|
237
|
-
this.set(x, y, z);
|
|
240
|
+
return this.set(x, y, z);
|
|
238
241
|
}
|
|
239
242
|
|
|
240
243
|
/**
|
|
241
244
|
*
|
|
242
245
|
* @param {Vector3} other
|
|
243
|
-
* @returns {
|
|
246
|
+
* @returns {this}
|
|
244
247
|
*/
|
|
245
248
|
sub(other) {
|
|
246
249
|
return this._sub(other.x, other.y, other.z);
|
|
@@ -248,10 +251,10 @@ class Vector3 {
|
|
|
248
251
|
|
|
249
252
|
/**
|
|
250
253
|
*
|
|
251
|
-
* @param {
|
|
252
|
-
* @param {
|
|
253
|
-
* @param {
|
|
254
|
-
* @returns {
|
|
254
|
+
* @param {number} x
|
|
255
|
+
* @param {number} y
|
|
256
|
+
* @param {number} z
|
|
257
|
+
* @returns {this}
|
|
255
258
|
*/
|
|
256
259
|
_sub(x, y, z) {
|
|
257
260
|
const _x = this.x - x;
|
|
@@ -263,10 +266,10 @@ class Vector3 {
|
|
|
263
266
|
|
|
264
267
|
/**
|
|
265
268
|
*
|
|
266
|
-
* @param {
|
|
267
|
-
* @param {
|
|
268
|
-
* @param {
|
|
269
|
-
* @returns {
|
|
269
|
+
* @param {number} x
|
|
270
|
+
* @param {number} y
|
|
271
|
+
* @param {number} z
|
|
272
|
+
* @returns {this}
|
|
270
273
|
*/
|
|
271
274
|
_multiply(x, y, z) {
|
|
272
275
|
return this.set(this.x * x, this.y * y, this.z * z);
|
|
@@ -275,7 +278,7 @@ class Vector3 {
|
|
|
275
278
|
/**
|
|
276
279
|
*
|
|
277
280
|
* @param {Vector3} other
|
|
278
|
-
* @returns {
|
|
281
|
+
* @returns {this}
|
|
279
282
|
*/
|
|
280
283
|
multiply(other) {
|
|
281
284
|
return this._multiply(other.x, other.y, other.z);
|
|
@@ -285,9 +288,10 @@ class Vector3 {
|
|
|
285
288
|
*
|
|
286
289
|
* @param {Vector3} a
|
|
287
290
|
* @param {Vector3} b
|
|
291
|
+
* @returns {this}
|
|
288
292
|
*/
|
|
289
293
|
multiplyVectors(a, b) {
|
|
290
|
-
this.set(
|
|
294
|
+
return this.set(
|
|
291
295
|
a.x * b.x,
|
|
292
296
|
a.y * b.y,
|
|
293
297
|
a.z * b.z
|
|
@@ -299,7 +303,7 @@ class Vector3 {
|
|
|
299
303
|
* @param {number} x
|
|
300
304
|
* @param {number} y
|
|
301
305
|
* @param {number} z
|
|
302
|
-
* @returns {
|
|
306
|
+
* @returns {this}
|
|
303
307
|
*/
|
|
304
308
|
_divide(x, y, z) {
|
|
305
309
|
return this.set(
|
|
@@ -312,7 +316,7 @@ class Vector3 {
|
|
|
312
316
|
/**
|
|
313
317
|
*
|
|
314
318
|
* @param {Vector3} other
|
|
315
|
-
* @returns {
|
|
319
|
+
* @returns {this}
|
|
316
320
|
*/
|
|
317
321
|
divide(other) {
|
|
318
322
|
return this._divide(other.x, other.y, other.z);
|
|
@@ -321,7 +325,7 @@ class Vector3 {
|
|
|
321
325
|
/**
|
|
322
326
|
* Subtract scalar value from each component of the vector
|
|
323
327
|
* @param {number} val
|
|
324
|
-
* @returns {
|
|
328
|
+
* @returns {this}
|
|
325
329
|
*/
|
|
326
330
|
subScalar(val) {
|
|
327
331
|
return this.set(this.x - val, this.y - val, this.z - val);
|
|
@@ -330,7 +334,7 @@ class Vector3 {
|
|
|
330
334
|
/**
|
|
331
335
|
* Add a scalar value to each component of the vector
|
|
332
336
|
* @param {number} val
|
|
333
|
-
* @returns {
|
|
337
|
+
* @returns {this}
|
|
334
338
|
*/
|
|
335
339
|
addScalar(val) {
|
|
336
340
|
return this.set(this.x + val, this.y + val, this.z + val);
|
|
@@ -347,7 +351,7 @@ class Vector3 {
|
|
|
347
351
|
/**
|
|
348
352
|
*
|
|
349
353
|
* @param {number} val
|
|
350
|
-
* @returns {
|
|
354
|
+
* @returns {this}
|
|
351
355
|
*/
|
|
352
356
|
multiplyScalar(val) {
|
|
353
357
|
assert.isNumber(val, "val");
|
|
@@ -361,30 +365,32 @@ class Vector3 {
|
|
|
361
365
|
* @returns {boolean}
|
|
362
366
|
*/
|
|
363
367
|
isZero() {
|
|
364
|
-
return this.x === 0
|
|
368
|
+
return this.x === 0
|
|
369
|
+
&& this.y === 0
|
|
370
|
+
&& this.z === 0
|
|
371
|
+
;
|
|
365
372
|
}
|
|
366
373
|
|
|
367
374
|
/**
|
|
368
375
|
* Compute cross-product of two vectors. Result is written to this vector.
|
|
369
376
|
* @param {Vector3} other
|
|
370
|
-
* @returns {
|
|
377
|
+
* @returns {this}
|
|
371
378
|
*/
|
|
372
379
|
cross(other) {
|
|
373
|
-
this.crossVectors(this, other);
|
|
374
|
-
|
|
375
|
-
return this;
|
|
380
|
+
return this.crossVectors(this, other);
|
|
376
381
|
}
|
|
377
382
|
|
|
378
383
|
/**
|
|
379
384
|
*
|
|
380
385
|
* @param {Vector3} first
|
|
381
386
|
* @param {Vector3} second
|
|
387
|
+
* @returns {this}
|
|
382
388
|
*/
|
|
383
389
|
crossVectors(first, second) {
|
|
384
390
|
const ax = first.x, ay = first.y, az = first.z;
|
|
385
391
|
const bx = second.x, by = second.y, bz = second.z;
|
|
386
392
|
|
|
387
|
-
this._crossVectors(
|
|
393
|
+
return this._crossVectors(
|
|
388
394
|
ax, ay, az,
|
|
389
395
|
bx, by, bz
|
|
390
396
|
);
|
|
@@ -399,18 +405,19 @@ class Vector3 {
|
|
|
399
405
|
* @param {number} bx
|
|
400
406
|
* @param {number} by
|
|
401
407
|
* @param {number} bz
|
|
408
|
+
* @returns {this}
|
|
402
409
|
*/
|
|
403
410
|
_crossVectors(ax, ay, az, bx, by, bz) {
|
|
404
411
|
const x = ay * bz - az * by;
|
|
405
412
|
const y = az * bx - ax * bz;
|
|
406
413
|
const z = ax * by - ay * bx;
|
|
407
414
|
|
|
408
|
-
this.set(x, y, z);
|
|
415
|
+
return this.set(x, y, z);
|
|
409
416
|
}
|
|
410
417
|
|
|
411
418
|
/**
|
|
412
419
|
* Sets all components of the vector to absolute value (positive)
|
|
413
|
-
* @returns {
|
|
420
|
+
* @returns {this}
|
|
414
421
|
*/
|
|
415
422
|
abs() {
|
|
416
423
|
return this.set(
|
|
@@ -448,13 +455,14 @@ class Vector3 {
|
|
|
448
455
|
|
|
449
456
|
/**
|
|
450
457
|
* Normalizes the vector, preserving its direction, but making magnitude equal to 1
|
|
458
|
+
* @returns {this}
|
|
451
459
|
*/
|
|
452
460
|
normalize() {
|
|
453
461
|
const l = this.length();
|
|
454
462
|
|
|
455
463
|
if (l === 0) {
|
|
456
464
|
//special case, can't normalize 0 length vector
|
|
457
|
-
return;
|
|
465
|
+
return this;
|
|
458
466
|
}
|
|
459
467
|
|
|
460
468
|
const m = 1 / l;
|
|
@@ -475,7 +483,7 @@ class Vector3 {
|
|
|
475
483
|
/**
|
|
476
484
|
*
|
|
477
485
|
* @param {Vector3|{x:number,y:number,z:number}} other
|
|
478
|
-
* @returns {
|
|
486
|
+
* @returns {this}
|
|
479
487
|
*/
|
|
480
488
|
copy(other) {
|
|
481
489
|
return this.set(other.x, other.y, other.z);
|
|
@@ -484,10 +492,14 @@ class Vector3 {
|
|
|
484
492
|
|
|
485
493
|
/**
|
|
486
494
|
* Negates every component of the vector making it {-x, -y, -z}
|
|
487
|
-
* @returns {
|
|
495
|
+
* @returns {this}
|
|
488
496
|
*/
|
|
489
497
|
negate() {
|
|
490
|
-
return this.set(
|
|
498
|
+
return this.set(
|
|
499
|
+
-this.x,
|
|
500
|
+
-this.y,
|
|
501
|
+
-this.z
|
|
502
|
+
);
|
|
491
503
|
}
|
|
492
504
|
|
|
493
505
|
/**
|
|
@@ -507,16 +519,25 @@ class Vector3 {
|
|
|
507
519
|
* @return {number}
|
|
508
520
|
*/
|
|
509
521
|
_distanceTo(x, y, z) {
|
|
510
|
-
return v3_distance(
|
|
522
|
+
return v3_distance(
|
|
523
|
+
this.x, this.y, this.z,
|
|
524
|
+
x, y, z
|
|
525
|
+
);
|
|
511
526
|
}
|
|
512
527
|
|
|
513
528
|
/**
|
|
514
529
|
* Squared distance between this vector and another. It is faster than computing real distance because no SQRT operation is needed.
|
|
515
530
|
* @param {Vector3} other
|
|
516
|
-
* returns {number}
|
|
531
|
+
* @returns {number}
|
|
517
532
|
*/
|
|
518
533
|
distanceSqrTo(other) {
|
|
519
|
-
|
|
534
|
+
assert.defined(other, "other");
|
|
535
|
+
|
|
536
|
+
const dx = this.x - other.x;
|
|
537
|
+
const dy = this.y - other.y;
|
|
538
|
+
const dz = this.z - other.z;
|
|
539
|
+
|
|
540
|
+
return v3_length_sqr(dx, dy, dz);
|
|
520
541
|
}
|
|
521
542
|
|
|
522
543
|
/**
|
|
@@ -536,19 +557,28 @@ class Vector3 {
|
|
|
536
557
|
* @returns {number}
|
|
537
558
|
*/
|
|
538
559
|
angleTo(other) {
|
|
539
|
-
return v3_angle_between(
|
|
560
|
+
return v3_angle_between(
|
|
561
|
+
this.x, this.y, this.z,
|
|
562
|
+
other.x, other.y, other.z
|
|
563
|
+
);
|
|
540
564
|
}
|
|
541
565
|
|
|
542
566
|
/**
|
|
543
567
|
*
|
|
544
568
|
* @param {Quaternion} q
|
|
545
|
-
* @returns {
|
|
569
|
+
* @returns {this}
|
|
546
570
|
*/
|
|
547
571
|
applyQuaternion(q) {
|
|
548
572
|
//transform point into quaternion
|
|
549
573
|
|
|
550
|
-
const x = this.x
|
|
551
|
-
const
|
|
574
|
+
const x = this.x;
|
|
575
|
+
const y = this.y;
|
|
576
|
+
const z = this.z;
|
|
577
|
+
|
|
578
|
+
const qx = q.x;
|
|
579
|
+
const qy = q.y;
|
|
580
|
+
const qz = q.z;
|
|
581
|
+
const qw = q.w;
|
|
552
582
|
|
|
553
583
|
// calculate quat * vector
|
|
554
584
|
|
|
@@ -569,7 +599,7 @@ class Vector3 {
|
|
|
569
599
|
/**
|
|
570
600
|
* Set components X,Y,Z to values 1,0 or -1 based on the sign of their original value.
|
|
571
601
|
* @example new Vector(5,0,-10).sign().equals(new Vector(1,0,-1)); //true
|
|
572
|
-
* @returns {
|
|
602
|
+
* @returns {this}
|
|
573
603
|
*/
|
|
574
604
|
sign() {
|
|
575
605
|
return this.set(
|
|
@@ -582,8 +612,8 @@ class Vector3 {
|
|
|
582
612
|
/**
|
|
583
613
|
* Linear interpolation
|
|
584
614
|
* @param {Vector3} other
|
|
585
|
-
* @param {
|
|
586
|
-
* @returns {
|
|
615
|
+
* @param {number} fraction between 0 and 1
|
|
616
|
+
* @returns {this}
|
|
587
617
|
*/
|
|
588
618
|
lerp(other, fraction) {
|
|
589
619
|
return this.lerpVectors(this, other, fraction);
|
|
@@ -628,6 +658,7 @@ class Vector3 {
|
|
|
628
658
|
/**
|
|
629
659
|
*
|
|
630
660
|
* @param {ArrayLike<number>|number[]|Float32Array} m4
|
|
661
|
+
* @returns {this}
|
|
631
662
|
*/
|
|
632
663
|
applyMatrix4(m4) {
|
|
633
664
|
const x = this.x;
|
|
@@ -640,12 +671,13 @@ class Vector3 {
|
|
|
640
671
|
const _y = (m4[1] * x + m4[5] * y + m4[9] * z + m4[13]) * w;
|
|
641
672
|
const _z = (m4[2] * x + m4[6] * y + m4[10] * z + m4[14]) * w;
|
|
642
673
|
|
|
643
|
-
|
|
674
|
+
return this.set(_x, _y, _z);
|
|
644
675
|
}
|
|
645
676
|
|
|
646
677
|
/**
|
|
647
678
|
* Assume current vector holds a direction, transform using a matrix to produce a new directional unit vector
|
|
648
679
|
* @param {ArrayLike<number>|number[]|Float32Array} m4
|
|
680
|
+
* @returns {this}
|
|
649
681
|
*/
|
|
650
682
|
applyDirectionMatrix4(m4) {
|
|
651
683
|
const x = this.x;
|
|
@@ -660,7 +692,7 @@ class Vector3 {
|
|
|
660
692
|
// normalize the result
|
|
661
693
|
const _l = 1 / v3_length(_x, _y, _z);
|
|
662
694
|
|
|
663
|
-
this.set(
|
|
695
|
+
return this.set(
|
|
664
696
|
_x * _l,
|
|
665
697
|
_y * _l,
|
|
666
698
|
_z * _l
|
|
@@ -670,6 +702,7 @@ class Vector3 {
|
|
|
670
702
|
/**
|
|
671
703
|
*
|
|
672
704
|
* @param {number[]|Float32Array} mat
|
|
705
|
+
* @returns {this}
|
|
673
706
|
*/
|
|
674
707
|
applyMatrix3(mat) {
|
|
675
708
|
const x = this.x;
|
|
@@ -680,13 +713,14 @@ class Vector3 {
|
|
|
680
713
|
const _y = mat[1] * x + mat[4] * y + mat[7] * z;
|
|
681
714
|
const _z = mat[2] * x + mat[5] * y + mat[8] * z;
|
|
682
715
|
|
|
683
|
-
this.set(_x, _y, _z);
|
|
716
|
+
return this.set(_x, _y, _z);
|
|
684
717
|
}
|
|
685
718
|
|
|
686
719
|
|
|
687
720
|
/**
|
|
688
721
|
*
|
|
689
722
|
* @param {ArrayLike<number>|number[]|Float32Array} matrix4 4x4 transform matrix
|
|
723
|
+
* @returns {this}
|
|
690
724
|
*/
|
|
691
725
|
setFromMatrixPosition(matrix4) {
|
|
692
726
|
|
|
@@ -694,7 +728,7 @@ class Vector3 {
|
|
|
694
728
|
const _y = matrix4[13];
|
|
695
729
|
const _z = matrix4[14];
|
|
696
730
|
|
|
697
|
-
|
|
731
|
+
return this.set(_x, _y, _z);
|
|
698
732
|
}
|
|
699
733
|
|
|
700
734
|
/**
|
|
@@ -741,17 +775,21 @@ class Vector3 {
|
|
|
741
775
|
&& epsilonEquals(this.z, z, tolerance);
|
|
742
776
|
}
|
|
743
777
|
|
|
778
|
+
/**
|
|
779
|
+
* @returns {this}
|
|
780
|
+
*/
|
|
744
781
|
floor() {
|
|
745
782
|
const x = this.x | 0;
|
|
746
783
|
const y = this.y | 0;
|
|
747
784
|
const z = this.z | 0;
|
|
748
785
|
|
|
749
|
-
this.set(x, y, z);
|
|
786
|
+
return this.set(x, y, z);
|
|
750
787
|
}
|
|
751
788
|
|
|
752
789
|
/**
|
|
753
790
|
* Project this vector onto another
|
|
754
791
|
* @param {Vector3} other
|
|
792
|
+
* @returns {this}
|
|
755
793
|
*/
|
|
756
794
|
projectOntoVector3(other) {
|
|
757
795
|
const x0 = this.x;
|
|
@@ -762,7 +800,7 @@ class Vector3 {
|
|
|
762
800
|
const y1 = other.y;
|
|
763
801
|
const z1 = other.z;
|
|
764
802
|
|
|
765
|
-
this._projectVectors(x0, y0, z0, x1, y1, z1);
|
|
803
|
+
return this._projectVectors(x0, y0, z0, x1, y1, z1);
|
|
766
804
|
}
|
|
767
805
|
|
|
768
806
|
/**
|
|
@@ -773,6 +811,7 @@ class Vector3 {
|
|
|
773
811
|
* @param {number} x1
|
|
774
812
|
* @param {number} y1
|
|
775
813
|
* @param {number} z1
|
|
814
|
+
* @returns {this}
|
|
776
815
|
*/
|
|
777
816
|
_projectVectors(
|
|
778
817
|
x0, y0, z0,
|
|
@@ -789,7 +828,7 @@ class Vector3 {
|
|
|
789
828
|
const y = y1 * m;
|
|
790
829
|
const z = z1 * m;
|
|
791
830
|
|
|
792
|
-
this.set(x, y, z);
|
|
831
|
+
return this.set(x, y, z);
|
|
793
832
|
}
|
|
794
833
|
|
|
795
834
|
/**
|
|
@@ -797,6 +836,7 @@ class Vector3 {
|
|
|
797
836
|
* @param {number} radius
|
|
798
837
|
* @param {number} phi Also known as Azimuth
|
|
799
838
|
* @param {number} theta Also known as Elevation
|
|
839
|
+
* @returns {this}
|
|
800
840
|
*/
|
|
801
841
|
setFromSphericalCoords(radius, phi, theta) {
|
|
802
842
|
assert.isNumber(radius, 'radius');
|
|
@@ -818,7 +858,7 @@ class Vector3 {
|
|
|
818
858
|
const _y = radius * cos_phi;
|
|
819
859
|
const _z = radius * sin_phi * cos_theta;
|
|
820
860
|
|
|
821
|
-
|
|
861
|
+
return this.set(_x, _y, _z);
|
|
822
862
|
}
|
|
823
863
|
|
|
824
864
|
/**
|