@woosh/meep-engine 2.126.35 → 2.126.37
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/geom/3d/shape/util/shape_to_visual_entity.js +12 -12
- package/src/core/geom/Quaternion.d.ts +24 -14
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +60 -26
- package/src/core/geom/Vector1.d.ts +7 -1
- package/src/core/geom/Vector1.d.ts.map +1 -1
- package/src/core/geom/Vector1.js +6 -0
- package/src/core/geom/Vector2.d.ts +11 -1
- package/src/core/geom/Vector2.d.ts.map +1 -1
- package/src/core/geom/Vector2.js +10 -0
- package/src/core/geom/Vector3.d.ts +12 -2
- package/src/core/geom/Vector3.d.ts.map +1 -1
- package/src/core/geom/Vector3.js +11 -1
- package/src/core/geom/Vector4.d.ts +20 -2
- package/src/core/geom/Vector4.d.ts.map +1 -1
- package/src/core/geom/Vector4.js +26 -6
- package/src/engine/asset/loaders/GLTFAssetLoader.js +19 -19
- package/src/engine/ecs/Entity.d.ts.map +1 -1
- package/src/engine/ecs/Entity.js +3 -1
- package/src/engine/ecs/attachment/TransformAttachmentBinding.js +5 -5
- package/src/engine/ecs/transform/Transform.d.ts +19 -5
- package/src/engine/ecs/transform/Transform.d.ts.map +1 -1
- package/src/engine/ecs/transform/Transform.js +30 -9
- package/src/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.js +1 -1
- package/src/engine/navigation/ecs/path_following/PathFollowingSystem.d.ts.map +1 -1
- package/src/engine/navigation/ecs/path_following/PathFollowingSystem.js +4 -2
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.126.
|
|
8
|
+
"version": "2.126.37",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { UnionShape3D } from "../UnionShape3D.js";
|
|
2
|
-
import { UnitCubeShape3D } from "../UnitCubeShape3D.js";
|
|
3
|
-
import { UnitSphereShape3D } from "../UnitSphereShape3D.js";
|
|
4
|
-
import { TransformedShape3D } from "../TransformedShape3D.js";
|
|
5
|
-
import Entity from "../../../../../engine/ecs/Entity.js";
|
|
6
|
-
import { Transform } from "../../../../../engine/ecs/transform/Transform.js";
|
|
7
|
-
import { AttachmentSockets } from "../../../../../engine/ecs/sockets/AttachmentSockets.js";
|
|
8
|
-
import { Attachment } from "../../../../../engine/ecs/attachment/Attachment.js";
|
|
9
|
-
import { ShadedGeometry } from "../../../../../engine/graphics/ecs/mesh-v2/ShadedGeometry.js";
|
|
10
1
|
import { LineBasicMaterial } from "three";
|
|
11
|
-
import { makeHelperSphereGeometry } from "../../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
|
|
12
|
-
import { DrawMode } from "../../../../../engine/graphics/ecs/mesh-v2/DrawMode.js";
|
|
13
2
|
import { makeHelperBoxGeometry } from "../../../../../../editor/process/symbolic/makeHelperBoxGeometry.js";
|
|
3
|
+
import { makeHelperSphereGeometry } from "../../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
|
|
4
|
+
import { Attachment } from "../../../../../engine/ecs/attachment/Attachment.js";
|
|
14
5
|
import Tag from "../../../../../engine/ecs/components/Tag.js";
|
|
6
|
+
import Entity from "../../../../../engine/ecs/Entity.js";
|
|
7
|
+
import { AttachmentSockets } from "../../../../../engine/ecs/sockets/AttachmentSockets.js";
|
|
8
|
+
import { Transform } from "../../../../../engine/ecs/transform/Transform.js";
|
|
9
|
+
import { DrawMode } from "../../../../../engine/graphics/ecs/mesh-v2/DrawMode.js";
|
|
10
|
+
import { ShadedGeometry } from "../../../../../engine/graphics/ecs/mesh-v2/ShadedGeometry.js";
|
|
11
|
+
import { TransformedShape3D } from "../TransformedShape3D.js";
|
|
12
|
+
import { UnionShape3D } from "../UnionShape3D.js";
|
|
13
|
+
import { UnitCubeShape3D } from "../UnitCubeShape3D.js";
|
|
14
|
+
import { UnitSphereShape3D } from "../UnitSphereShape3D.js";
|
|
15
15
|
|
|
16
16
|
const g_unit_sphere = makeHelperSphereGeometry(0.5, 32);
|
|
17
17
|
const g_unit_cube = makeHelperBoxGeometry(1, 1, 1);
|
|
@@ -131,7 +131,7 @@ function transformed_shape_to_entity(shape, ecd) {
|
|
|
131
131
|
immediate: true
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
-
attachment.transform.
|
|
134
|
+
attachment.transform.fromMatrix(shape.transform);
|
|
135
135
|
|
|
136
136
|
subject.add(attachment);
|
|
137
137
|
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Implementation of a quaternion.
|
|
3
|
+
* Represents rotation in 3d space
|
|
4
|
+
*
|
|
5
|
+
* Iterating through a Quaternion instance will yield its components `(x, y, z, w)` in the corresponding order.
|
|
6
|
+
*
|
|
3
7
|
* @see https://en.wikipedia.org/wiki/Quaternion
|
|
8
|
+
* @implements Iterable<number>
|
|
4
9
|
*
|
|
5
10
|
* @author Alex Goldring
|
|
6
11
|
* @copyright Company Named Limited (c) 2025
|
|
7
12
|
*/
|
|
8
|
-
export class Quaternion {
|
|
13
|
+
export class Quaternion implements Iterable<number> {
|
|
9
14
|
/**
|
|
10
15
|
*
|
|
11
16
|
* @param {Vector3} axis
|
|
@@ -126,7 +131,7 @@ export class Quaternion {
|
|
|
126
131
|
*/
|
|
127
132
|
_lookRotation(fx: number, fy: number, fz: number, ux: number, uy: number, uz: number): this;
|
|
128
133
|
/**
|
|
129
|
-
*
|
|
134
|
+
* Orient quaternion to align with the `forward` drection.
|
|
130
135
|
* @param {Vector3} forward
|
|
131
136
|
* @param {Vector3} [up=Vector3.up]
|
|
132
137
|
*/
|
|
@@ -154,24 +159,27 @@ export class Quaternion {
|
|
|
154
159
|
*/
|
|
155
160
|
angleTo(other: Quaternion): number;
|
|
156
161
|
/**
|
|
157
|
-
*
|
|
162
|
+
* Set quaternion from axis + angle definition
|
|
158
163
|
* @param {Vector3} axis
|
|
159
164
|
* @param {number} angle
|
|
160
165
|
*/
|
|
161
166
|
fromAxisAngle(axis: Vector3, angle: number): void;
|
|
162
167
|
/**
|
|
163
168
|
*
|
|
164
|
-
* @param {number}
|
|
165
|
-
* @param {number}
|
|
166
|
-
* @param {number}
|
|
169
|
+
* @param {number} axis_x
|
|
170
|
+
* @param {number} axis_y
|
|
171
|
+
* @param {number} axis_z
|
|
167
172
|
* @param {number} angle
|
|
168
173
|
*/
|
|
169
|
-
_fromAxisAngle(
|
|
174
|
+
_fromAxisAngle(axis_x: number, axis_y: number, axis_z: number, angle: number): void;
|
|
170
175
|
/**
|
|
171
|
-
*
|
|
176
|
+
* Given a direction axis, compute rotation quaternions from current rotation to that axis as swing and twist. Swing moves to a given orientation while without "twisting",
|
|
177
|
+
* `twist` just the twist around the given axis, no change in orientation.
|
|
172
178
|
* @param {Vector3} axis
|
|
173
|
-
* @param {Quaternion} swing
|
|
174
|
-
* @param {Quaternion} twist
|
|
179
|
+
* @param {Quaternion} swing Swing quaternion will be written here
|
|
180
|
+
* @param {Quaternion} twist Twist quaternion will be written here
|
|
181
|
+
* @returns {void}
|
|
182
|
+
* @see slerp
|
|
175
183
|
*/
|
|
176
184
|
computeSwingAndTwist(axis: Vector3, swing: Quaternion, twist: Quaternion): void;
|
|
177
185
|
/**
|
|
@@ -239,6 +247,7 @@ export class Quaternion {
|
|
|
239
247
|
* @param {Vector3} source
|
|
240
248
|
* @param {Vector3} target
|
|
241
249
|
* @param {Vector3} [up]
|
|
250
|
+
* @see lookRotation
|
|
242
251
|
*/
|
|
243
252
|
lookAt(source: Vector3, target: Vector3, up?: Vector3): void;
|
|
244
253
|
/**
|
|
@@ -251,7 +260,7 @@ export class Quaternion {
|
|
|
251
260
|
* @param {number} x
|
|
252
261
|
* @param {number} y
|
|
253
262
|
* @param {number} z
|
|
254
|
-
* @param {String} [order] a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
263
|
+
* @param {String} [order='XYZ'] a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
255
264
|
* @returns {Quaternion}
|
|
256
265
|
*/
|
|
257
266
|
__setFromEuler(x: number, y: number, z: number, order?: string): Quaternion;
|
|
@@ -477,9 +486,10 @@ export class Quaternion {
|
|
|
477
486
|
*/
|
|
478
487
|
writeToArray(array?: number[], offset?: number): number[];
|
|
479
488
|
/**
|
|
480
|
-
*
|
|
489
|
+
* Strict equality check
|
|
481
490
|
* @param {Quaternion} other
|
|
482
491
|
* @returns {boolean}
|
|
492
|
+
* @see roughlyEquals
|
|
483
493
|
*/
|
|
484
494
|
equals(other: Quaternion): boolean;
|
|
485
495
|
/**
|
|
@@ -500,7 +510,7 @@ export class Quaternion {
|
|
|
500
510
|
* @param {number} y
|
|
501
511
|
* @param {number} z
|
|
502
512
|
* @param {number} w
|
|
503
|
-
* @param {number} [tolerance]
|
|
513
|
+
* @param {number} [tolerance] acceptable difference value per coordinate
|
|
504
514
|
* @return {boolean}
|
|
505
515
|
*/
|
|
506
516
|
_roughlyEquals(x: number, y: number, z: number, w: number, tolerance?: number): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Quaternion.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Quaternion.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Quaternion.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Quaternion.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;GAWG;AACH,mCALe,QAAQ,CAAC,MAAM;IA4R1B;;;;;OAKG;IACH,2BAJW,OAAO,SACP,MAAM,GACJ,UAAU,CAQtB;IAspCD;;;;OAIG;IACH,kCAFa,UAAU,CAQtB;IAED;;;;;;;OAOG;IACH,0BALW,MAAM,KACN,MAAM,KACN,MAA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,WACR,MAAM,GACJ,IAAI,CAShB;IAED;;;;;OAKG;IACH,qBAJW,MAAM,EAAE,WACR,MAAM,GACJ,MAAM,EAAE,CASpB;IAED;;;;;OAKG;IACH,cAJW,UAAU,GACR,OAAO,CASnB;IAED;;;OAGG;IACH,QAFa,MAAM,CAQlB;IAED;;;;;OAKG;IACH,qBAJW,UAAU,cACV,MAAM,GACL,OAAO,CAOlB;IAED;;;;;;;;OAQG;IACH,kBAPW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,cACN,MAAM,GACL,OAAO,CASlB;IAED;;;;OAIG;IACH,gBAHW,MAAW,MAAM,GAChB,UAAU,CAuBrB;IAED,mBAEC;IAiEL,mBApLe,MAAM,EAAE,WACR,MAAM,gBAmLS;IAC9B,kBAtKe,MAAM,EAAE,WACR,MAAM,KACJ,MAAM,EAAE,CAoKG;IAC5B,kBAvKe,MAAM,EAAE,WACR,MAAM,KACJ,MAAM,EAAE,CAqKG;IAC5B,qBA3yBe,MAAM,KACN,MAAM,KACN,MAAM,gBAyyBe;IAQpC;;;;OAIG;IACH,uBAFU,OAAO,CAEgB;IAx5C7B;;;OAGG;IACH,qBAFa,SAAS,CAAC,MAAM,CAAC,CAS7B;CA23CJ;;kBASS,UAAU;kBAaV,MAAM;;;mBA3iDG,4BAA4B;oBAU3B,cAAc"}
|
|
@@ -5,6 +5,7 @@ import { clamp01 } from "../math/clamp01.js";
|
|
|
5
5
|
import { EPSILON } from "../math/EPSILON.js";
|
|
6
6
|
import { epsilonEquals } from "../math/epsilonEquals.js";
|
|
7
7
|
import { lerp } from "../math/lerp.js";
|
|
8
|
+
import { PI2 } from "../math/PI2.js";
|
|
8
9
|
import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
|
|
9
10
|
import { v3_dot } from "./vec3/v3_dot.js";
|
|
10
11
|
import { v4_length } from "./vec4/v4_length.js";
|
|
@@ -18,8 +19,13 @@ const sin = Math.sin;
|
|
|
18
19
|
const cos = Math.cos;
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Implementation of a quaternion.
|
|
23
|
+
* Represents rotation in 3d space
|
|
24
|
+
*
|
|
25
|
+
* Iterating through a Quaternion instance will yield its components `(x, y, z, w)` in the corresponding order.
|
|
26
|
+
*
|
|
22
27
|
* @see https://en.wikipedia.org/wiki/Quaternion
|
|
28
|
+
* @implements Iterable<number>
|
|
23
29
|
*
|
|
24
30
|
* @author Alex Goldring
|
|
25
31
|
* @copyright Company Named Limited (c) 2025
|
|
@@ -207,7 +213,7 @@ export class Quaternion {
|
|
|
207
213
|
const m12 = scratch_v3_a.y;
|
|
208
214
|
const m22 = scratch_v3_a.z;
|
|
209
215
|
|
|
210
|
-
|
|
216
|
+
return this.__setFromRotationMatrix(
|
|
211
217
|
m00, m01, m02,
|
|
212
218
|
m10, m11, m12,
|
|
213
219
|
m20, m21, m22
|
|
@@ -215,7 +221,7 @@ export class Quaternion {
|
|
|
215
221
|
}
|
|
216
222
|
|
|
217
223
|
/**
|
|
218
|
-
*
|
|
224
|
+
* Orient quaternion to align with the `forward` drection.
|
|
219
225
|
* @param {Vector3} forward
|
|
220
226
|
* @param {Vector3} [up=Vector3.up]
|
|
221
227
|
*/
|
|
@@ -318,7 +324,7 @@ export class Quaternion {
|
|
|
318
324
|
}
|
|
319
325
|
|
|
320
326
|
/**
|
|
321
|
-
*
|
|
327
|
+
* Set quaternion from axis + angle definition
|
|
322
328
|
* @param {Vector3} axis
|
|
323
329
|
* @param {number} angle
|
|
324
330
|
*/
|
|
@@ -330,25 +336,30 @@ export class Quaternion {
|
|
|
330
336
|
|
|
331
337
|
/**
|
|
332
338
|
*
|
|
333
|
-
* @param {number}
|
|
334
|
-
* @param {number}
|
|
335
|
-
* @param {number}
|
|
339
|
+
* @param {number} axis_x
|
|
340
|
+
* @param {number} axis_y
|
|
341
|
+
* @param {number} axis_z
|
|
336
342
|
* @param {number} angle
|
|
337
343
|
*/
|
|
338
|
-
_fromAxisAngle(
|
|
339
|
-
assert.isNumber(
|
|
340
|
-
assert.isNumber(
|
|
341
|
-
assert.isNumber(
|
|
344
|
+
_fromAxisAngle(axis_x, axis_y, axis_z, angle) {
|
|
345
|
+
assert.isNumber(axis_x, 'axis_x');
|
|
346
|
+
assert.isNumber(axis_y, 'axis_y');
|
|
347
|
+
assert.isNumber(axis_z, 'axis_z');
|
|
342
348
|
assert.isNumber(angle, 'angle');
|
|
343
349
|
|
|
350
|
+
assert.notNaN(axis_x, 'axis_x');
|
|
351
|
+
assert.notNaN(axis_y, 'axis_y');
|
|
352
|
+
assert.notNaN(axis_z, 'axis_z');
|
|
353
|
+
assert.notNaN(angle, 'angle');
|
|
354
|
+
|
|
344
355
|
const halfAngle = angle * 0.5;
|
|
345
356
|
|
|
346
357
|
const sinA2 = sin(halfAngle);
|
|
347
358
|
const cosA2 = cos(halfAngle);
|
|
348
359
|
|
|
349
|
-
const qx =
|
|
350
|
-
const qy =
|
|
351
|
-
const qz =
|
|
360
|
+
const qx = axis_x * sinA2;
|
|
361
|
+
const qy = axis_y * sinA2;
|
|
362
|
+
const qz = axis_z * sinA2;
|
|
352
363
|
const qw = cosA2;
|
|
353
364
|
|
|
354
365
|
//normalize
|
|
@@ -365,12 +376,21 @@ export class Quaternion {
|
|
|
365
376
|
}
|
|
366
377
|
|
|
367
378
|
/**
|
|
368
|
-
*
|
|
379
|
+
* Given a direction axis, compute rotation quaternions from current rotation to that axis as swing and twist. Swing moves to a given orientation while without "twisting",
|
|
380
|
+
* `twist` just the twist around the given axis, no change in orientation.
|
|
369
381
|
* @param {Vector3} axis
|
|
370
|
-
* @param {Quaternion} swing
|
|
371
|
-
* @param {Quaternion} twist
|
|
382
|
+
* @param {Quaternion} swing Swing quaternion will be written here
|
|
383
|
+
* @param {Quaternion} twist Twist quaternion will be written here
|
|
384
|
+
* @returns {void}
|
|
385
|
+
* @see slerp
|
|
372
386
|
*/
|
|
373
387
|
computeSwingAndTwist(axis, swing, twist) {
|
|
388
|
+
assert.defined(axis, 'axis');
|
|
389
|
+
assert.defined(swing, 'swing');
|
|
390
|
+
assert.defined(twist, 'twist');
|
|
391
|
+
|
|
392
|
+
// see https://stackoverflow.com/questions/3684269/component-of-a-quaternion-rotation-around-an-axis
|
|
393
|
+
|
|
374
394
|
const x = this.x;
|
|
375
395
|
const y = this.y;
|
|
376
396
|
const z = this.z;
|
|
@@ -388,16 +408,19 @@ export class Quaternion {
|
|
|
388
408
|
const pz = axis.z * m;
|
|
389
409
|
|
|
390
410
|
if (d < 0) {
|
|
411
|
+
|
|
391
412
|
// axis points in the opposite direction from calculated twist, invert all components
|
|
392
413
|
twist.set(-px, -py, -pz, -w);
|
|
414
|
+
|
|
393
415
|
} else {
|
|
416
|
+
|
|
394
417
|
twist.set(px, py, pz, w);
|
|
395
418
|
|
|
396
419
|
}
|
|
397
420
|
|
|
398
421
|
twist.normalize();
|
|
399
422
|
|
|
400
|
-
// rotation * twist.conjugated()
|
|
423
|
+
// rotation * twist.conjugated(), basically undo the twist
|
|
401
424
|
swing._multiplyQuaternions(x, y, z, w, -twist.x, -twist.y, -twist.z, twist.w);
|
|
402
425
|
}
|
|
403
426
|
|
|
@@ -414,7 +437,7 @@ export class Quaternion {
|
|
|
414
437
|
|
|
415
438
|
this.computeSwingAndTwist(axis, swing, twist);
|
|
416
439
|
|
|
417
|
-
//
|
|
440
|
+
// Extract the twist angle from quaternion, see {@link #toAxisAngle}
|
|
418
441
|
return Math.acos(twist.w) * 2;
|
|
419
442
|
}
|
|
420
443
|
|
|
@@ -559,6 +582,7 @@ export class Quaternion {
|
|
|
559
582
|
* @param {Vector3} source
|
|
560
583
|
* @param {Vector3} target
|
|
561
584
|
* @param {Vector3} [up]
|
|
585
|
+
* @see lookRotation
|
|
562
586
|
*/
|
|
563
587
|
lookAt(source, target, up = Vector3.up) {
|
|
564
588
|
const forward = scratch_v3_a;
|
|
@@ -583,7 +607,7 @@ export class Quaternion {
|
|
|
583
607
|
* @param {number} x
|
|
584
608
|
* @param {number} y
|
|
585
609
|
* @param {number} z
|
|
586
|
-
* @param {String} [order] a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
610
|
+
* @param {String} [order='XYZ'] a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
587
611
|
* @returns {Quaternion}
|
|
588
612
|
*/
|
|
589
613
|
__setFromEuler(
|
|
@@ -1163,6 +1187,7 @@ export class Quaternion {
|
|
|
1163
1187
|
|
|
1164
1188
|
// calculate coefficients
|
|
1165
1189
|
if ((1.0 - cos_angle) > EPSILON) {
|
|
1190
|
+
|
|
1166
1191
|
// standard case (slerp)
|
|
1167
1192
|
const angle = Math.acos(cos_angle);
|
|
1168
1193
|
|
|
@@ -1172,10 +1197,12 @@ export class Quaternion {
|
|
|
1172
1197
|
scale1 = sin(t * angle) * recip_sin_angle;
|
|
1173
1198
|
|
|
1174
1199
|
} else {
|
|
1200
|
+
|
|
1175
1201
|
// "from" and "to" quaternions are very close
|
|
1176
1202
|
// ... so we can do a linear interpolation
|
|
1177
1203
|
scale0 = 1.0 - t;
|
|
1178
1204
|
scale1 = t;
|
|
1205
|
+
|
|
1179
1206
|
}
|
|
1180
1207
|
|
|
1181
1208
|
// calculate final values
|
|
@@ -1380,9 +1407,10 @@ export class Quaternion {
|
|
|
1380
1407
|
}
|
|
1381
1408
|
|
|
1382
1409
|
/**
|
|
1383
|
-
*
|
|
1410
|
+
* Strict equality check
|
|
1384
1411
|
* @param {Quaternion} other
|
|
1385
1412
|
* @returns {boolean}
|
|
1413
|
+
* @see roughlyEquals
|
|
1386
1414
|
*/
|
|
1387
1415
|
equals(other) {
|
|
1388
1416
|
return this.x === other.x
|
|
@@ -1411,7 +1439,10 @@ export class Quaternion {
|
|
|
1411
1439
|
* @return {boolean}
|
|
1412
1440
|
*/
|
|
1413
1441
|
roughlyEquals(other, tolerance) {
|
|
1414
|
-
return this._roughlyEquals(
|
|
1442
|
+
return this._roughlyEquals(
|
|
1443
|
+
other.x, other.y, other.z, other.w,
|
|
1444
|
+
tolerance
|
|
1445
|
+
);
|
|
1415
1446
|
}
|
|
1416
1447
|
|
|
1417
1448
|
/**
|
|
@@ -1420,10 +1451,12 @@ export class Quaternion {
|
|
|
1420
1451
|
* @param {number} y
|
|
1421
1452
|
* @param {number} z
|
|
1422
1453
|
* @param {number} w
|
|
1423
|
-
* @param {number} [tolerance]
|
|
1454
|
+
* @param {number} [tolerance] acceptable difference value per coordinate
|
|
1424
1455
|
* @return {boolean}
|
|
1425
1456
|
*/
|
|
1426
1457
|
_roughlyEquals(x, y, z, w, tolerance = EPSILON) {
|
|
1458
|
+
assert.isNumber(tolerance, 'tolerance');
|
|
1459
|
+
|
|
1427
1460
|
return epsilonEquals(this.x, x, tolerance)
|
|
1428
1461
|
&& epsilonEquals(this.y, y, tolerance)
|
|
1429
1462
|
&& epsilonEquals(this.z, z, tolerance)
|
|
@@ -1446,8 +1479,6 @@ export class Quaternion {
|
|
|
1446
1479
|
const sqrt1u1 = Math.sqrt(1 - u1);
|
|
1447
1480
|
const sqrtu1 = Math.sqrt(u1);
|
|
1448
1481
|
|
|
1449
|
-
const PI2 = 2 * Math.PI;
|
|
1450
|
-
|
|
1451
1482
|
const u2 = PI2 * random();
|
|
1452
1483
|
|
|
1453
1484
|
const u3 = PI2 * random();
|
|
@@ -1511,9 +1542,12 @@ export class Quaternion {
|
|
|
1511
1542
|
|
|
1512
1543
|
const angle = from.angleTo(to);
|
|
1513
1544
|
|
|
1545
|
+
|
|
1514
1546
|
if (angle === 0) {
|
|
1515
|
-
//
|
|
1547
|
+
// We're already where we need to be.
|
|
1548
|
+
// Also - avoid division by 0.
|
|
1516
1549
|
result.copy(to);
|
|
1550
|
+
|
|
1517
1551
|
} else {
|
|
1518
1552
|
// clamp to 1, to make sure we don't overshoot
|
|
1519
1553
|
const t = clamp01(max_delta / angle);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Wrapper around a scalar value, `Vector1` is used for consistence with {@link Vector2} and {@link Vector3}
|
|
3
|
+
*
|
|
2
4
|
* @author Alex Goldring
|
|
3
5
|
* @copyright Company Named Limited (c) 2025
|
|
4
6
|
*/
|
|
@@ -19,7 +21,11 @@ export class Vector1 extends Number {
|
|
|
19
21
|
*/
|
|
20
22
|
constructor(x?: number);
|
|
21
23
|
x: number;
|
|
22
|
-
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {Signal<number,number>}
|
|
27
|
+
*/
|
|
28
|
+
onChanged: Signal<number, number>;
|
|
23
29
|
/**
|
|
24
30
|
*
|
|
25
31
|
* @returns {string}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vector1.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector1.js"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"Vector1.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector1.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH;IAgRI;;;;;OAKG;IACH,kBAJW,OAAO,KACP,OAAO,GACN,MAAM,CAIjB;IAvRD;;;;;;OAMG;IACH,gBALW,MAAM,EAkBhB;IAPG,UAAU;IAEV;;;OAGG;IACH,WAFU,MAAM,CAAC,MAAM,EAAC,MAAM,CAAC,CAEF;IAWjC;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAHW,OAAO,GACL,MAAM,CAIlB;IAED;;;;OAIG;IACH,OAHW,MAAM,GACJ,OAAO,CAgBnB;IAED;;;OAGG;IACH,aAFW,MAAM,QAOhB;IAED;;;OAGG;IACH,UAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,kBAEC;IAED;;;OAGG;IACH,kBAEC;IAED;;;;OAIG;IACH,iBAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,WAFW,OAAO,GAAC,OAAO,GAAC,OAAO,GAAC,OAAO,WAKzC;IAED;;;;OAIG;IACH,iBAFY,OAAO,CAIlB;IAED;;;;OAIG;IACH,WAHW,OAAO,GACL,OAAO,CAInB;IAED;;;;OAIG;IACH,gBAHW,OAAO,GACL,OAAO,CAInB;IAED;;;OAGG;IACH,kBAFW,MAAM,QAIhB;IAED;;;;;OAKG;IACH,WAJW,MAAM,QACN,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,eAEC;IAED;;;OAGG;IACH,YAFW,OAAO,GAAC,OAAO,GAAC,OAAO,GAAC,OAAO,QAIzC;IAED;;;OAGG;IACH,SAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,cAHW,OAAO,GACL,OAAO,CAInB;IAED;;OAEG;IACH,QAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,4BAGC;IAED,iBAEC;IAED,yBAEC;IAED;;;;OAIG;IACH,qBAHW,MAAM,EAAE,WACR,MAAM,QAIhB;IAED;;;;OAIG;IACH,oBAHW,MAAM,EAAE,WACR,MAAM,QAIhB;IAED,oBAEC;IAED;;;OAGG;IACH,uBAFW,YAAY,QAItB;IAED;;;OAGG;IACH,yBAFW,YAAY,QAMtB;IAkBD,iBAEC;IAND,gBAEC;IAaL;;;OAGG;IACH,oBAFU,OAAO,CAEU;IAXvB,sDAIC;CACJ;;kBAUS,MAAM;cAON,OAAO;aAOP,OAAO;;;mBA3UE,4BAA4B"}
|
package/src/core/geom/Vector1.js
CHANGED
|
@@ -4,6 +4,8 @@ import { clamp } from "../math/clamp.js";
|
|
|
4
4
|
import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
+
* Wrapper around a scalar value, `Vector1` is used for consistence with {@link Vector2} and {@link Vector3}
|
|
8
|
+
*
|
|
7
9
|
* @author Alex Goldring
|
|
8
10
|
* @copyright Company Named Limited (c) 2025
|
|
9
11
|
*/
|
|
@@ -23,6 +25,10 @@ export class Vector1 extends Number {
|
|
|
23
25
|
|
|
24
26
|
this.x = x;
|
|
25
27
|
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @type {Signal<number,number>}
|
|
31
|
+
*/
|
|
26
32
|
this.onChanged = new Signal();
|
|
27
33
|
}
|
|
28
34
|
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Class representing a 2D vector. A 2D vector is an ordered pair of numbers (labeled x and y), which can be used to represent a number of things, such as:
|
|
3
|
+
*
|
|
4
|
+
* A point in 2D space (i.e. a position on a plane).
|
|
5
|
+
* A direction and length across a plane. The length will always be the Euclidean distance (straight-line distance) from `(0, 0)` to `(x, y)` and the direction is also measured from `(0, 0)` towards `(x, y)`.
|
|
6
|
+
* Any arbitrary ordered pair of numbers.
|
|
7
|
+
* There are other things a 2D vector can be used to represent, such as momentum vectors, complex numbers and so on, however these are the most common uses.
|
|
8
|
+
*
|
|
9
|
+
* Iterating through a Vector2 instance will yield its components `(x, y)` in the corresponding order.
|
|
10
|
+
*
|
|
11
|
+
* @implements Iterable<number>
|
|
2
12
|
*
|
|
3
13
|
* @author Alex Goldring
|
|
4
14
|
* @copyright Company Named Limited (c) 2025
|
|
5
15
|
*/
|
|
6
|
-
export class Vector2 {
|
|
16
|
+
export class Vector2 implements Iterable<number> {
|
|
7
17
|
/**
|
|
8
18
|
*
|
|
9
19
|
* @param {number} [x=0]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vector2.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector2.js"],"names":[],"mappings":"AAcA
|
|
1
|
+
{"version":3,"file":"Vector2.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector2.js"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;GAcG;AACH,gCALe,QAAQ,CAAC,MAAM;IAM1B;;;;OAIG;IACH,gBAHW,MAAM,MACN,MAAM,EA0BhB;IAjBG;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,oBAFU,MAAM,CAAC,MAAM,EAAC,M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IAAI,CAahB;IAGD;;;OAGG;IACH,QAFa,MAAM,CAOlB;IAED;;;;OAIG;IACH,cAHW,MAAM,GACJ,IAAI,CAahB;IAED;;;;;OAKG;IACH,uCAHW,GAAC,GACC,IAAI,CAQhB;IAED,mBAEC;IAED;;;;OAIG;IACH,cAHW,OAAO,GACL,OAAO,CAMnB;IAED;;;;;OAKG;IACH,qBAJW,OAAO,cACP,MAAM,GACL,OAAO,CAIlB;IAED;;;;;;OAMG;IACH,kBALW,MAAM,KACN,MAAM,cACN,MAAM,GACL,OAAO,CAKlB;IAUD,iBAEC;IAVD,gBAEC;IAUD,iBAEC;IAVD,gBAEC;IAsDL;;OAEG;IACH,sBAvoBe,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,UAsoBS;IAE9B;;OAEG;IACH,uBAzpBe,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,aAwpBU;IAG/B;;;OAGG;IACH,oBAFU,OAAO,CAEU;IA1DvB,sDAKC;CACJ;;mBAIS,OAAO;qBAMP,OAAO;qBAMP,OAAO;sBAMP,OAAO;qBAMP,OAAO;oBAKP,OAAO;;yBAsBP,MAAM;;;mBAjuBG,4BAA4B;4BAQnB,uBAAuB"}
|
package/src/core/geom/Vector2.js
CHANGED
|
@@ -13,6 +13,16 @@ import { v2_length } from "./vec2/v2_length.js";
|
|
|
13
13
|
import { v2_length_sqr } from "./vec2/v2_length_sqr.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
+
* Class representing a 2D vector. A 2D vector is an ordered pair of numbers (labeled x and y), which can be used to represent a number of things, such as:
|
|
17
|
+
*
|
|
18
|
+
* A point in 2D space (i.e. a position on a plane).
|
|
19
|
+
* A direction and length across a plane. The length will always be the Euclidean distance (straight-line distance) from `(0, 0)` to `(x, y)` and the direction is also measured from `(0, 0)` towards `(x, y)`.
|
|
20
|
+
* Any arbitrary ordered pair of numbers.
|
|
21
|
+
* There are other things a 2D vector can be used to represent, such as momentum vectors, complex numbers and so on, however these are the most common uses.
|
|
22
|
+
*
|
|
23
|
+
* Iterating through a Vector2 instance will yield its components `(x, y)` in the corresponding order.
|
|
24
|
+
*
|
|
25
|
+
* @implements Iterable<number>
|
|
16
26
|
*
|
|
17
27
|
* @author Alex Goldring
|
|
18
28
|
* @copyright Company Named Limited (c) 2025
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Class representing a 3D vector. A 3D vector is an ordered triplet of numbers (labeled x, y, and z), which can be used to represent a number of things, such as:
|
|
3
|
+
*
|
|
4
|
+
* A point in 3D space.
|
|
5
|
+
* A direction and length in 3D space. The length will always be the Euclidean distance (straight-line distance) from `(0, 0, 0)` to `(x, y, z)` and the direction is also measured from `(0, 0, 0)` towards `(x, y, z)`.
|
|
6
|
+
* Any arbitrary ordered triplet of numbers.
|
|
7
|
+
* There are other things a 3D vector can be used to represent, such as momentum vectors and so on, however these are the most common uses.
|
|
8
|
+
*
|
|
9
|
+
* Iterating through a Vector3 instance will yield its components `(x, y, z)` in the corresponding order.
|
|
10
|
+
*
|
|
11
|
+
* @implements Iterable<number>
|
|
2
12
|
*
|
|
3
13
|
* @author Alex Goldring
|
|
4
14
|
* @copyright Company Named Limited (c) 2025
|
|
5
15
|
*/
|
|
6
|
-
export class Vector3 {
|
|
16
|
+
export class Vector3 implements Iterable<number> {
|
|
7
17
|
/**
|
|
8
18
|
* Dot product
|
|
9
19
|
* @param {Vector3|Vector4} a
|
|
@@ -36,7 +46,6 @@ export class Vector3 {
|
|
|
36
46
|
* @param {number} [x=0]
|
|
37
47
|
* @param {number} [y=0]
|
|
38
48
|
* @param {number} [z=0]
|
|
39
|
-
* @constructor
|
|
40
49
|
*/
|
|
41
50
|
constructor(x?: number, y?: number, z?: number);
|
|
42
51
|
/**
|
|
@@ -58,6 +67,7 @@ export class Vector3 {
|
|
|
58
67
|
*/
|
|
59
68
|
readonly z: number;
|
|
60
69
|
/**
|
|
70
|
+
* Dispatches ( x, y, z, old_x, old_y, old_z )
|
|
61
71
|
* @readonly
|
|
62
72
|
* @type {Signal<number,number,number,number,number,number>}
|
|
63
73
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vector3.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector3.js"],"names":[],"mappings":"AAeA
|
|
1
|
+
{"version":3,"file":"Vector3.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector3.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;GAcG;AACH,gCALe,QAAQ,CAAC,MAAM;IAk/B1B;;;;;OAKG;IACH,cAJW,OAAO,GAAC,OAAO,KACf,OAAO,GAAC,OAAO,GACb,MAAM,CAIlB;IAED;;;;;OAKG;IACH,mBAJW,OAAO,KACP,OAAO,GACL,MAAM,CAIlB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,EAAE,WACR,MAAM,GACJ,OAAO,CAQnB;IAED;;;;OAIG;IACH,yBAHW,MAAM,GACJ,OAAO,CAInB;IArhCD;;;;;OAKG;IACH,gBAJW,MAAM,MACN,MAAM,MACN,MAAM,EAuChB;IA3BG;;;;OAIG;IACH,YAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,YAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,YAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,oBAFU,MAAM,CAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,CAAC,CAE9B;IA2BjC;;;OAGG;IACH,SAFW,MAAM,EAIhB;IA9BD;;;OAGG;IACH,SAFY,MAAM,CAIjB;IA0BD;;;OAGG;IACH,SAFW,MAAM,EAIhB;IA9BD;;;OAGG;IACH,SAFY,MAAM,CAIjB;IA0BD;;;OAGG;IACH,SAFW,MAAM,EAIhB;IA9BD;;;OAGG;IACH,SAFY,MAAM,CAIjB;IAsCD;;;;;OAKG;IACH,iBAJW,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,GACJ,IAAI,CAQhB;IAED;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;;;OAKG;IACH,uCAHW,GAAC,GACC,OAAO,CASnB;IAED;;;;MAMC;IAED;;;OAGG;IACH,eAFW;QAAC,CAAC,EAAC,MAAM,CAAC;QAAC,CAAC,EAAC,MAAM,CAAC;QAAC,CAAC,EAAC,MAAM,CAAA;KAAC,GAAC,MAAM,QAS/C;IAED,mBAEC;IAED;;;;OAIG;IACH,uBAHW,YAAY,QAOtB;IAED;;;;OAIG;IACH,yBAHW,YAAY,QAStB;IAED;;;;OAIG;IACH,8BAHW,YAAY,QAOtB;IAED;;;;OAIG;IACH,gCAHW,YAAY,QAStB;IAED,eAMC;IAgDL,2BA7de,OAAO,KACL,MAAM,CA4dY;IAEnC,gBA/iBiB,MAAM,CA+iBG;IAC1B;;;OAGG;IACH,gCAt7Be,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,aAq7BU;IAC/B;;;OAGG;IACH,gCA96Be,MAAM,EAAE,GAAC,YAAY,iBAAU,WAC/B,MAAM,KACJ,MAAM,EAAE,CA46BK;IAC9B;;;OAGG;IACH,2BAn7Be,MAAM,EAAE,GAAC,YAAY,iBAAU,WAC/B,MAAM,KACJ,MAAM,EAAE,CAi7BA;IA2DzB;;;OAGG;IACH,oBAFU,OAAO,CAEU;IA7gCvB;;;OAGG;IACH,qBAFY,SAAS,CAAC,MAAM,CAAC,CAQ5B;CA+6BJ;;cA0BS,OAAO;aAOP,OAAO;mBAOP,OAAO;YAMP,OAAO;cAMP,OAAO;cAMP,OAAO;eAMP,OAAO;iBAMP,OAAO;cAMP,OAAO;kBAYP,MAAM;;;mBA5oCG,4BAA4B"}
|
package/src/core/geom/Vector3.js
CHANGED
|
@@ -14,6 +14,16 @@ import { v3_slerp } from "./vec3/v3_slerp.js";
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
+
* Class representing a 3D vector. A 3D vector is an ordered triplet of numbers (labeled x, y, and z), which can be used to represent a number of things, such as:
|
|
18
|
+
*
|
|
19
|
+
* A point in 3D space.
|
|
20
|
+
* A direction and length in 3D space. The length will always be the Euclidean distance (straight-line distance) from `(0, 0, 0)` to `(x, y, z)` and the direction is also measured from `(0, 0, 0)` towards `(x, y, z)`.
|
|
21
|
+
* Any arbitrary ordered triplet of numbers.
|
|
22
|
+
* There are other things a 3D vector can be used to represent, such as momentum vectors and so on, however these are the most common uses.
|
|
23
|
+
*
|
|
24
|
+
* Iterating through a Vector3 instance will yield its components `(x, y, z)` in the corresponding order.
|
|
25
|
+
*
|
|
26
|
+
* @implements Iterable<number>
|
|
17
27
|
*
|
|
18
28
|
* @author Alex Goldring
|
|
19
29
|
* @copyright Company Named Limited (c) 2025
|
|
@@ -24,7 +34,6 @@ export class Vector3 {
|
|
|
24
34
|
* @param {number} [x=0]
|
|
25
35
|
* @param {number} [y=0]
|
|
26
36
|
* @param {number} [z=0]
|
|
27
|
-
* @constructor
|
|
28
37
|
*/
|
|
29
38
|
constructor(x = 0, y = 0, z = 0) {
|
|
30
39
|
assert.isNumber(x, 'x');
|
|
@@ -58,6 +67,7 @@ export class Vector3 {
|
|
|
58
67
|
this.z = z;
|
|
59
68
|
|
|
60
69
|
/**
|
|
70
|
+
* Dispatches ( x, y, z, old_x, old_y, old_z )
|
|
61
71
|
* @readonly
|
|
62
72
|
* @type {Signal<number,number,number,number,number,number>}
|
|
63
73
|
*/
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Class representing a 4D vector. A 4D vector is an ordered quadruplet of numbers (labeled x, y, z, and w), which can be used to represent a number of things, such as:
|
|
3
|
+
*
|
|
4
|
+
* A point in 4D space.
|
|
5
|
+
* A direction and length in 4D space. The length will always be the Euclidean distance (straight-line distance) from `(0, 0, 0, 0)` to `(x, y, z, w)` and the direction is also measured from `(0, 0, 0, 0)` towards `(x, y, z, w)`.
|
|
6
|
+
* Any arbitrary ordered quadruplet of numbers.
|
|
7
|
+
* There are other things a 4D vector can be used to represent, however these are the most common uses.
|
|
8
|
+
*
|
|
9
|
+
* Iterating through a Vector4 instance will yield its components (x, y, z, w) in the corresponding order.
|
|
10
|
+
*
|
|
11
|
+
* @implements Iterable<number>
|
|
12
|
+
*/
|
|
13
|
+
export class Vector4 implements Iterable<number> {
|
|
2
14
|
/**
|
|
3
15
|
*
|
|
4
16
|
* @param {Vector4} v0
|
|
@@ -149,11 +161,17 @@ export class Vector4 {
|
|
|
149
161
|
*/
|
|
150
162
|
add3(v3: Vector3 | Vector4): Vector4;
|
|
151
163
|
/**
|
|
152
|
-
*
|
|
164
|
+
* @deprecated use {@link applyMatrix4} directly instead
|
|
153
165
|
* @param {Matrix4} m
|
|
154
166
|
* @returns {Vector4} this
|
|
155
167
|
*/
|
|
156
168
|
threeApplyMatrix4(m: Matrix4): Vector4;
|
|
169
|
+
/**
|
|
170
|
+
*
|
|
171
|
+
* @param {number[]|Float32Array} m 4x4 transformation matrix
|
|
172
|
+
* @return {Vector4}
|
|
173
|
+
*/
|
|
174
|
+
applyMatrix4(m: number[] | Float32Array): Vector4;
|
|
157
175
|
/**
|
|
158
176
|
*
|
|
159
177
|
* @param {Vector4} vec4
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vector4.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector4.js"],"names":[],"mappings":"AAMA;
|
|
1
|
+
{"version":3,"file":"Vector4.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector4.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;GAWG;AACH,gCAFe,QAAQ,CAAC,MAAM;IAgc1B;;;;;;OAMG;IACH,gBALW,OAAO,MACP,OAAO,qBAEP,OAAO,QASjB;IA3cD;;;;;;;;OAQG;IACH,gBAPW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,EAsChB;IA3BG;;;OAGG;IACH,GAFU,MAAM,CAEN;IACV;;;OAGG;IACH,GAFU,MAAM,CAEN;IACV;;;OAGG;IACH,GAFU,MAAM,CAEN;IACV;;;OAGG;IACH,GAFU,MAAM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a,OAAO,CAQnB;IAED;;;OAGG;IACH,mBAFW,UAAU,QAyBpB;IAED;;;;OAIG;IACH,aAHW,OAAO,GACL,OAAO,CAInB;IAED;;;OAGG;IACH,QAFY,MAAM,CASjB;IAED;;;;OAIG;IACH,gBAJW,OAAO,MACP,OAAO,mBAKjB;IAuGL,kBAnGe,MAAM,EAAE,UAmGE;IA1FrB;;OAEG;IACH,WAFa,MAAM,EAAE,CAQpB;IAED;;;;OAIG;IACH,mBAHW,MAAM,EAAE,UACR,MAAM,QAIhB;IAED;;;;;MAOC;IAED,0BAEC;IAED;;;OAGG;IACH,uBAFW,YAAY,QAOtB;IAED;;;OAGG;IACH,yBAFW,YAAY,QAStB;IA4BL;;;OAGG;IACH,oBAFU,OAAO,CAEU;IAE3B,mBArWe,MAAM,EAAE,WACR,MAAM,UAoWM;IAhCvB,sDAOC;CAiBJ;;kBAaS,MAAM"}
|
package/src/core/geom/Vector4.js
CHANGED
|
@@ -4,6 +4,18 @@ import { Signal } from "../events/signal/Signal.js";
|
|
|
4
4
|
import { lerp } from "../math/lerp.js";
|
|
5
5
|
import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Class representing a 4D vector. A 4D vector is an ordered quadruplet of numbers (labeled x, y, z, and w), which can be used to represent a number of things, such as:
|
|
9
|
+
*
|
|
10
|
+
* A point in 4D space.
|
|
11
|
+
* A direction and length in 4D space. The length will always be the Euclidean distance (straight-line distance) from `(0, 0, 0, 0)` to `(x, y, z, w)` and the direction is also measured from `(0, 0, 0, 0)` towards `(x, y, z, w)`.
|
|
12
|
+
* Any arbitrary ordered quadruplet of numbers.
|
|
13
|
+
* There are other things a 4D vector can be used to represent, however these are the most common uses.
|
|
14
|
+
*
|
|
15
|
+
* Iterating through a Vector4 instance will yield its components (x, y, z, w) in the corresponding order.
|
|
16
|
+
*
|
|
17
|
+
* @implements Iterable<number>
|
|
18
|
+
*/
|
|
7
19
|
export class Vector4 {
|
|
8
20
|
/**
|
|
9
21
|
*
|
|
@@ -270,17 +282,25 @@ export class Vector4 {
|
|
|
270
282
|
}
|
|
271
283
|
|
|
272
284
|
/**
|
|
273
|
-
*
|
|
285
|
+
* @deprecated use {@link applyMatrix4} directly instead
|
|
274
286
|
* @param {Matrix4} m
|
|
275
287
|
* @returns {Vector4} this
|
|
276
288
|
*/
|
|
277
289
|
threeApplyMatrix4(m) {
|
|
278
|
-
|
|
290
|
+
return this.applyMatrix4(m.elements);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
*
|
|
295
|
+
* @param {number[]|Float32Array} m 4x4 transformation matrix
|
|
296
|
+
* @return {Vector4}
|
|
297
|
+
*/
|
|
298
|
+
applyMatrix4(m) {
|
|
279
299
|
return this._applyMatrix4(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
300
|
+
m[0], m[1], m[2], m[3],
|
|
301
|
+
m[4], m[5], m[6], m[7],
|
|
302
|
+
m[8], m[9], m[10], m[11],
|
|
303
|
+
m[12], m[13], m[14], m[15]
|
|
284
304
|
);
|
|
285
305
|
}
|
|
286
306
|
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { MeshDepthMaterial, RGBADepthPacking } from "three";
|
|
2
|
+
import { DDSLoader } from "three/examples/jsm/loaders/DDSLoader.js";
|
|
3
|
+
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
4
4
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
5
|
+
import { HashSet } from "../../../core/collection/set/HashSet.js";
|
|
5
6
|
import { AABB3 } from "../../../core/geom/3d/aabb/AABB3.js";
|
|
6
|
-
import { StaticMaterialCache } from "./material/StaticMaterialCache.js";
|
|
7
|
-
import { DDSLoader } from "three/examples/jsm/loaders/DDSLoader.js";
|
|
8
7
|
import { AnimationOptimizer } from "../../ecs/animation/AnimationOptimizer.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { Transform } from "../../ecs/transform/Transform.js";
|
|
9
|
+
import { traverseThreeObject } from "../../graphics/ecs/highlight/renderer/traverseThreeObject.js";
|
|
10
|
+
import { computeGeometryEquality } from "../../graphics/geometry/buffered/computeGeometryEquality.js";
|
|
11
|
+
import { computeGeometryHash } from "../../graphics/geometry/buffered/computeGeometryHash.js";
|
|
12
12
|
import { ensureGeometryBoundingSphere } from "../../graphics/geometry/buffered/ensureGeometryBoundingSphere.js";
|
|
13
13
|
import {
|
|
14
14
|
computeSkinnedMeshBoundingVolumes
|
|
15
15
|
} from "../../graphics/geometry/skining/computeSkinnedMeshBoundingVolumes.js";
|
|
16
|
-
import { ensureGeometryBoundingBox } from "../../graphics/util/ensureGeometryBoundingBox.js";
|
|
17
16
|
import { cloneObject3D } from "../../graphics/three/cloneObject3D.js";
|
|
18
|
-
import
|
|
17
|
+
import { three_computeObjectBoundingBox } from "../../graphics/three/three_computeObjectBoundingBox.js";
|
|
18
|
+
import { prepareMaterial, prepareObject } from "../../graphics/three/ThreeFactory.js";
|
|
19
|
+
import { ensureGeometryBoundingBox } from "../../graphics/util/ensureGeometryBoundingBox.js";
|
|
20
|
+
import { Asset } from "../Asset.js";
|
|
19
21
|
import { CrossOriginKind } from "../CORS/CrossOriginKind.js";
|
|
22
|
+
import { AssetLoader } from "./AssetLoader.js";
|
|
23
|
+
import { async_traverse_three_object } from "./async_traverse_three_object.js";
|
|
20
24
|
import { computeObjectBoundingSphere } from "./gltf/computeObjectBoundingSphere.js";
|
|
25
|
+
import GLTFTextureDDSExtension from "./gltf/extensions/MSFT_texture_dds.js";
|
|
21
26
|
import { isMesh } from "./gltf/isMesh.js";
|
|
22
|
-
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
23
|
-
import { HashSet } from "../../../core/collection/set/HashSet.js";
|
|
24
|
-
import { computeGeometryHash } from "../../graphics/geometry/buffered/computeGeometryHash.js";
|
|
25
|
-
import { computeGeometryEquality } from "../../graphics/geometry/buffered/computeGeometryEquality.js";
|
|
26
|
-
import { traverseThreeObject } from "../../graphics/ecs/highlight/renderer/traverseThreeObject.js";
|
|
27
|
-
import { computeTextureHash } from "./material/computeTextureHash.js";
|
|
28
27
|
import { computeTextureEquality } from "./material/computeTextureEquality.js";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
28
|
+
import { computeTextureHash } from "./material/computeTextureHash.js";
|
|
29
|
+
import { StaticMaterialCache } from "./material/StaticMaterialCache.js";
|
|
30
|
+
import { TextureAttachmentsByMaterialType } from "./material/TextureAttachmensByMaterialType.js";
|
|
31
31
|
|
|
32
32
|
const animationOptimizer = new AnimationOptimizer();
|
|
33
33
|
const materialCache = StaticMaterialCache.Global;
|
|
@@ -80,7 +80,7 @@ function transferRootTransform(root, result) {
|
|
|
80
80
|
|
|
81
81
|
// record transformation matrix on the root
|
|
82
82
|
root.updateMatrix();
|
|
83
|
-
result.
|
|
83
|
+
result.fromMatrix(root.matrix.elements);
|
|
84
84
|
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;
|
|
1
|
+
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IAsaI;;;;;;;;;;;OAWG;IACH,+BAJW,MAAM,WACN,sBAAsB,GACpB,MAAM,CAqBlB;IAncD;;;;;OAKG;IACH,oBAFU,eAAe,CAES;IAGlC;;;OAGG;IACH,UAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;OAIG;I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ANGED
|
@@ -408,6 +408,8 @@ export class Entity {
|
|
|
408
408
|
build(dataset) {
|
|
409
409
|
assert.defined(dataset, "dataset");
|
|
410
410
|
assert.notNull(dataset, "dataset");
|
|
411
|
+
assert.isObject(dataset, 'dataset');
|
|
412
|
+
assert.equal(dataset.isEntityComponentDataset, true, 'dataset.isEntityComponentDataset !== true');
|
|
411
413
|
|
|
412
414
|
if (
|
|
413
415
|
this.getFlag(EntityFlags.Built)
|
|
@@ -497,7 +499,7 @@ export class Entity {
|
|
|
497
499
|
}
|
|
498
500
|
|
|
499
501
|
/**
|
|
500
|
-
* Useful for faster alternative to `instanceof` checks
|
|
502
|
+
* Useful for a faster alternative to `instanceof` checks
|
|
501
503
|
* @readonly
|
|
502
504
|
* @type {boolean}
|
|
503
505
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AttachmentBinding } from "./AttachmentBinding.js";
|
|
2
1
|
import { mat4 } from "gl-matrix";
|
|
2
|
+
import { AttachmentBinding } from "./AttachmentBinding.js";
|
|
3
3
|
|
|
4
4
|
const scratch_m4_0 = new Float32Array(16);
|
|
5
5
|
const scratch_m4_1 = new Float32Array(16);
|
|
@@ -12,9 +12,9 @@ export class TransformAttachmentBinding extends AttachmentBinding {
|
|
|
12
12
|
*/
|
|
13
13
|
update() {
|
|
14
14
|
|
|
15
|
-
this.socket.transform.
|
|
16
|
-
this.parentTransform.
|
|
17
|
-
this.attachment.transform.
|
|
15
|
+
this.socket.transform.toMatrix(scratch_m4_0);
|
|
16
|
+
this.parentTransform.toMatrix(scratch_m4_1);
|
|
17
|
+
this.attachment.transform.toMatrix(scratch_m4_2);
|
|
18
18
|
|
|
19
19
|
mat4.multiply(
|
|
20
20
|
scratch_m4_0, scratch_m4_1, scratch_m4_0
|
|
@@ -23,7 +23,7 @@ export class TransformAttachmentBinding extends AttachmentBinding {
|
|
|
23
23
|
scratch_m4_0, scratch_m4_0, scratch_m4_2
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
this.attachedTransform.
|
|
26
|
+
this.attachedTransform.fromMatrix(scratch_m4_0);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
link() {
|
|
@@ -51,6 +51,7 @@ export class Transform {
|
|
|
51
51
|
readonly scale: Vector3;
|
|
52
52
|
/**
|
|
53
53
|
* transform matrix, position, rotation, and scale must match, but shear can be different
|
|
54
|
+
* Note: this is managed by the Transform itself, do not modify the matrix directly. If you want to set it - use {@link fromMatrix} method instead
|
|
54
55
|
* @readonly
|
|
55
56
|
* @type {Float32Array}
|
|
56
57
|
*/
|
|
@@ -143,7 +144,9 @@ export class Transform {
|
|
|
143
144
|
};
|
|
144
145
|
};
|
|
145
146
|
/**
|
|
146
|
-
*
|
|
147
|
+
* Set this transform to match `other`.
|
|
148
|
+
* Afterward `this.equals(other) === true`.
|
|
149
|
+
* The `other` is unchanged in the process.
|
|
147
150
|
* @param {Transform} other
|
|
148
151
|
*/
|
|
149
152
|
copy(other: Transform): void;
|
|
@@ -153,7 +156,7 @@ export class Transform {
|
|
|
153
156
|
*/
|
|
154
157
|
clone(): Transform;
|
|
155
158
|
/**
|
|
156
|
-
*
|
|
159
|
+
* Strict equality check
|
|
157
160
|
* @param {Transform} other
|
|
158
161
|
* @returns {boolean}
|
|
159
162
|
*/
|
|
@@ -183,12 +186,13 @@ export class Transform {
|
|
|
183
186
|
* @param {mat4|number[]|Float32Array} matrix 4x4 affine matrix
|
|
184
187
|
* @returns {this}
|
|
185
188
|
*/
|
|
186
|
-
|
|
189
|
+
fromMatrix(matrix: mat4 | number[] | Float32Array): this;
|
|
187
190
|
/**
|
|
188
191
|
* Write out the current transform to a supplied container
|
|
189
|
-
* @param {number[]|Float32Array} result
|
|
192
|
+
* @param {number[]|Float32Array} [result] if not provided, `Float32Array` of size 16 will be created
|
|
193
|
+
* @returns {number[]} same as the input
|
|
190
194
|
*/
|
|
191
|
-
|
|
195
|
+
toMatrix(result?: number[] | Float32Array): number[];
|
|
192
196
|
/**
|
|
193
197
|
* reset transform, resulting transform is an identity matrix
|
|
194
198
|
* - position: [0,0,0]
|
|
@@ -212,6 +216,16 @@ export class Transform {
|
|
|
212
216
|
* }
|
|
213
217
|
*/
|
|
214
218
|
readonly isTransform: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* @readonly
|
|
221
|
+
* @deprecated use {@link Transform.prototype.toMatrix} instead
|
|
222
|
+
*/
|
|
223
|
+
readonly toMatrix4: (result?: number[] | Float32Array) => number[];
|
|
224
|
+
/**
|
|
225
|
+
* @readonly
|
|
226
|
+
* @deprecated use {@link Transform.prototype.fromMatrix} instead
|
|
227
|
+
*/
|
|
228
|
+
readonly fromMatrix4: (matrix: mat4 | number[] | Float32Array) => Transform;
|
|
215
229
|
#private;
|
|
216
230
|
}
|
|
217
231
|
export namespace Transform {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transform.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/transform/Transform.js"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;GAaG;AACH;
|
|
1
|
+
{"version":3,"file":"Transform.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/transform/Transform.js"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;GAaG;AACH;IA6QI;;;;OAIG;IACH,4BAFa,SAAS,CAQrB;IAED;;;;OAIG;IACH,uBAHW,MAAM,EAAE,GAAC,YAAY,GACnB,SAAS,CAQrB;IA0FD;;;;;OAKG;IACH,wCAJW,UAAU,gBACV,OAAO,wBAejB;IA/YD;;;OAGG;IACH,mBAHU,OAAO,CAGe;IAEhC;;;;;OAKG;IACH,mBAHU,UAAU,CAGkB;IAEtC;;;OAGG;IACH,gBAHU,OAAO,CAGY;IAE7B;;;;;OAKG;IACH,iBAFU,YAAY,CAEC;IAEvB;;;;OAIG;IACH,OAFU,MAAM,CAEM;IAOtB;;;;OAIG;IACH,eAFa,OAAO,CAQnB;IAED;;;OAGG;IACH,UAFY,OAAO,CAQlB;IAED;;;OAGG;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5B,kCAAkC;+BAE1B,qBAAqB"}
|
|
@@ -58,6 +58,7 @@ export class Transform {
|
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* transform matrix, position, rotation, and scale must match, but shear can be different
|
|
61
|
+
* Note: this is managed by the Transform itself, do not modify the matrix directly. If you want to set it - use {@link fromMatrix} method instead
|
|
61
62
|
* @readonly
|
|
62
63
|
* @type {Float32Array}
|
|
63
64
|
*/
|
|
@@ -250,11 +251,13 @@ export class Transform {
|
|
|
250
251
|
}
|
|
251
252
|
|
|
252
253
|
/**
|
|
253
|
-
*
|
|
254
|
+
* Set this transform to match `other`.
|
|
255
|
+
* Afterward `this.equals(other) === true`.
|
|
256
|
+
* The `other` is unchanged in the process.
|
|
254
257
|
* @param {Transform} other
|
|
255
258
|
*/
|
|
256
259
|
copy(other) {
|
|
257
|
-
// prevent matrix from being
|
|
260
|
+
// prevent the matrix from being overridden
|
|
258
261
|
this.clearFlag(TransformFlags.AutomaticChangeDetection);
|
|
259
262
|
|
|
260
263
|
this.matrix.set(other.matrix);
|
|
@@ -281,7 +284,7 @@ export class Transform {
|
|
|
281
284
|
}
|
|
282
285
|
|
|
283
286
|
/**
|
|
284
|
-
*
|
|
287
|
+
* Strict equality check
|
|
285
288
|
* @param {Transform} other
|
|
286
289
|
* @returns {boolean}
|
|
287
290
|
*/
|
|
@@ -321,7 +324,7 @@ export class Transform {
|
|
|
321
324
|
static fromMatrix(mat) {
|
|
322
325
|
const result = new Transform();
|
|
323
326
|
|
|
324
|
-
result.
|
|
327
|
+
result.fromMatrix(mat);
|
|
325
328
|
|
|
326
329
|
return result;
|
|
327
330
|
}
|
|
@@ -351,7 +354,7 @@ export class Transform {
|
|
|
351
354
|
|
|
352
355
|
m4_multiply(scratch_matrix, a.matrix, b.matrix);
|
|
353
356
|
|
|
354
|
-
return this.
|
|
357
|
+
return this.fromMatrix(scratch_matrix);
|
|
355
358
|
}
|
|
356
359
|
|
|
357
360
|
/**
|
|
@@ -359,7 +362,7 @@ export class Transform {
|
|
|
359
362
|
* @param {mat4|number[]|Float32Array} matrix 4x4 affine matrix
|
|
360
363
|
* @returns {this}
|
|
361
364
|
*/
|
|
362
|
-
|
|
365
|
+
fromMatrix(matrix) {
|
|
363
366
|
assert.isArrayLike(matrix, 'matrix');
|
|
364
367
|
assert.greaterThanOrEqual(matrix.length, 16, 'matrix.length must be >= 16');
|
|
365
368
|
|
|
@@ -380,10 +383,14 @@ export class Transform {
|
|
|
380
383
|
|
|
381
384
|
/**
|
|
382
385
|
* Write out the current transform to a supplied container
|
|
383
|
-
* @param {number[]|Float32Array} result
|
|
386
|
+
* @param {number[]|Float32Array} [result] if not provided, `Float32Array` of size 16 will be created
|
|
387
|
+
* @returns {number[]} same as the input
|
|
384
388
|
*/
|
|
385
|
-
|
|
389
|
+
toMatrix(result = new Float32Array(16)) {
|
|
390
|
+
|
|
386
391
|
compose_matrix4_array(result, this.position, this.rotation, this.scale);
|
|
392
|
+
|
|
393
|
+
return result;
|
|
387
394
|
}
|
|
388
395
|
|
|
389
396
|
/**
|
|
@@ -393,7 +400,7 @@ export class Transform {
|
|
|
393
400
|
* - scale: [1,1,1]
|
|
394
401
|
*/
|
|
395
402
|
makeIdentity() {
|
|
396
|
-
this.
|
|
403
|
+
this.fromMatrix(MATRIX_4_IDENTITY);
|
|
397
404
|
}
|
|
398
405
|
|
|
399
406
|
/**
|
|
@@ -421,6 +428,8 @@ export class Transform {
|
|
|
421
428
|
targetVector,
|
|
422
429
|
limit = Infinity
|
|
423
430
|
) {
|
|
431
|
+
console.warn('deprecated, use Transform.rotation.rotateTowards instead');
|
|
432
|
+
|
|
424
433
|
const q = new Quaternion();
|
|
425
434
|
|
|
426
435
|
q.lookRotation(targetVector);
|
|
@@ -446,5 +455,17 @@ Transform.typeName = "Transform";
|
|
|
446
455
|
*/
|
|
447
456
|
Transform.prototype.isTransform = true;
|
|
448
457
|
|
|
458
|
+
/**
|
|
459
|
+
* @readonly
|
|
460
|
+
* @deprecated use {@link Transform.prototype.toMatrix} instead
|
|
461
|
+
*/
|
|
462
|
+
Transform.prototype.toMatrix4 = Transform.prototype.toMatrix
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* @readonly
|
|
466
|
+
* @deprecated use {@link Transform.prototype.fromMatrix} instead
|
|
467
|
+
*/
|
|
468
|
+
Transform.prototype.fromMatrix4 = Transform.prototype.fromMatrix
|
|
469
|
+
|
|
449
470
|
|
|
450
471
|
|
|
@@ -21,7 +21,7 @@ export function three_object_to_entity_composition(root) {
|
|
|
21
21
|
|
|
22
22
|
const transform = new Transform();
|
|
23
23
|
// initialize world transform
|
|
24
|
-
transform.
|
|
24
|
+
transform.fromMatrix(root.matrixWorld.elements);
|
|
25
25
|
|
|
26
26
|
entity.add(transform);
|
|
27
27
|
entity.add(new Name(root.name));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathFollowingSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/navigation/ecs/path_following/PathFollowingSystem.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PathFollowingSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/navigation/ecs/path_following/PathFollowingSystem.js"],"names":[],"mappings":";AAwHA;IACI,cAiBC;IAdG,sCAAkC;IAElC,iKAIC;IAED;;;;OAIG;IACH,qBAAqB;IAGzB;;;;;;OAMG;IACH,6BALW,YAAY,aACZ,SAAS,QACT,IAAI,UACJ,MAAM,QAuBhB;CAgBJ;uBAnLsB,wBAAwB;yBAGtB,mBAAmB;0BAFlB,qCAAqC;4CAFnB,uDAAuD;iBAGlF,uBAAuB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Quaternion from "../../../../core/geom/Quaternion.js";
|
|
1
2
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
2
3
|
import { min2 } from "../../../../core/math/min2.js";
|
|
3
4
|
import { ResourceAccessKind } from "../../../../core/model/ResourceAccessKind.js";
|
|
@@ -12,7 +13,7 @@ import { PathFollowerFlags } from "./PathFollowerFlags.js";
|
|
|
12
13
|
const v3_forward = new Vector3();
|
|
13
14
|
const v3_temp1 = new Vector3();
|
|
14
15
|
const v3_temp2 = new Vector3();
|
|
15
|
-
|
|
16
|
+
const scratch_quaternion = new Quaternion();
|
|
16
17
|
/**
|
|
17
18
|
*
|
|
18
19
|
* @param {PathFollower} pathFollower
|
|
@@ -107,7 +108,8 @@ function performStep(pathFollower, path, transform, timeDelta) {
|
|
|
107
108
|
|
|
108
109
|
// console.log("Angular limit:", angularLimit, positionDelta.toJSON());
|
|
109
110
|
|
|
110
|
-
|
|
111
|
+
scratch_quaternion.lookRotation(positionDelta);
|
|
112
|
+
transform.rotation.rotateTowards(scratch_quaternion,angularLimit);
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
position.copy(nextPosition);
|