@woosh/meep-engine 2.131.17 → 2.131.19
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/editor/ecs/component/editors/geom/QuaternionEditor.js +3 -3
- package/editor/tools/TransformTool.js +14 -3
- package/package.json +1 -1
- package/src/core/geom/Quaternion.d.ts +52 -19
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +77 -27
- package/src/core/geom/Vector3.d.ts +3 -0
- package/src/core/geom/Vector3.d.ts.map +1 -1
- package/src/core/geom/Vector3.js +16 -6
- package/src/core/math/spline/spline3_hermite.d.ts +1 -1
- package/src/core/math/spline/spline3_hermite.js +1 -1
- package/src/core/math/spline/spline3_hermite_bounds.d.ts +1 -1
- package/src/core/math/spline/spline3_hermite_bounds.js +2 -2
- package/src/core/math/spline/spline3_hermite_derivative.d.ts +8 -6
- package/src/core/math/spline/spline3_hermite_derivative.d.ts.map +1 -1
- package/src/core/math/spline/spline3_hermite_derivative.js +10 -7
- package/src/core/math/spline/spline3_hermite_integral.d.ts +14 -0
- package/src/core/math/spline/spline3_hermite_integral.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_integral.js +35 -0
- package/src/core/math/spline/spline3_hermite_subdivide.d.ts +1 -1
- package/src/core/math/spline/spline3_hermite_subdivide.js +1 -1
- package/src/core/model/node-graph/NodeGraph.d.ts +1 -0
- package/src/core/model/node-graph/NodeGraph.d.ts.map +1 -1
- package/src/core/model/node-graph/NodeGraph.js +4 -0
- package/src/engine/animation/curve/animation_curve_fit.d.ts +17 -0
- package/src/engine/animation/curve/animation_curve_fit.d.ts.map +1 -0
- package/src/engine/animation/curve/animation_curve_fit.js +195 -0
- package/src/engine/animation/curve/animation_curve_optimize.d.ts.map +1 -1
- package/src/engine/animation/curve/animation_curve_optimize.js +65 -21
- package/src/engine/animation/curve/animation_curve_subdivide.d.ts +4 -2
- package/src/engine/animation/curve/animation_curve_subdivide.d.ts.map +1 -1
- package/src/engine/animation/curve/animation_curve_subdivide.js +4 -2
- package/src/engine/ecs/transform/Transform.d.ts +9 -6
- package/src/engine/ecs/transform/Transform.d.ts.map +1 -1
- package/src/engine/ecs/transform/Transform.js +15 -8
- package/src/engine/graphics/ecs/camera/topdown/ComputeCameraFacingVector.js +1 -1
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +1 -1
- package/src/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilter.d.ts.map +1 -1
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilter.js +3 -3
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.d.ts.map +1 -1
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.js +5 -6
- package/src/view/View.d.ts +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TypeEditor } from "../../TypeEditor.js";
|
|
2
1
|
import Vector3 from "../../../../../src/core/geom/Vector3.js";
|
|
3
|
-
import { makeV3_editor } from "../common/makeV3_editor.js";
|
|
4
2
|
import { DEG_TO_RAD } from "../../../../../src/core/math/DEG_TO_RAD.js";
|
|
5
3
|
import { RAD_TO_DEG } from "../../../../../src/core/math/RAD_TO_DEG.js";
|
|
4
|
+
import { TypeEditor } from "../../TypeEditor.js";
|
|
5
|
+
import { makeV3_editor } from "../common/makeV3_editor.js";
|
|
6
6
|
|
|
7
7
|
export class QuaternionEditor extends TypeEditor {
|
|
8
8
|
build(parent, field, registry) {
|
|
@@ -22,7 +22,7 @@ export class QuaternionEditor extends TypeEditor {
|
|
|
22
22
|
|
|
23
23
|
lock = true;
|
|
24
24
|
|
|
25
|
-
q.
|
|
25
|
+
q.fromEulerAnglesXYZ(
|
|
26
26
|
euler.x * DEG_TO_RAD,
|
|
27
27
|
euler.y * DEG_TO_RAD,
|
|
28
28
|
euler.z * DEG_TO_RAD
|
|
@@ -103,7 +103,7 @@ class TransformContainer {
|
|
|
103
103
|
allowWriteToSurrogate = false;
|
|
104
104
|
|
|
105
105
|
try {
|
|
106
|
-
transform.rotation.
|
|
106
|
+
transform.rotation.fromEulerAnglesXYZ(surrogate.rotation.x, surrogate.rotation.y, surrogate.rotation.z);
|
|
107
107
|
} catch (e) {
|
|
108
108
|
console.error(e);
|
|
109
109
|
}
|
|
@@ -131,7 +131,13 @@ class TransformContainer {
|
|
|
131
131
|
|
|
132
132
|
//set surrogate transform to match component
|
|
133
133
|
surrogate.position.copy(transform.position);
|
|
134
|
-
|
|
134
|
+
|
|
135
|
+
if (surrogate.rotation.order === "XYZ") {
|
|
136
|
+
transform.rotation.fromEulerAnglesXYZ(surrogate.rotation.x, surrogate.rotation.y, surrogate.rotation.z);
|
|
137
|
+
} else {
|
|
138
|
+
throw new Error("Unsupported rotation order");
|
|
139
|
+
}
|
|
140
|
+
|
|
135
141
|
surrogate.quaternion.copy(transform.rotation);
|
|
136
142
|
surrogate.scale.copy(transform.scale);
|
|
137
143
|
|
|
@@ -160,7 +166,12 @@ class TransformContainer {
|
|
|
160
166
|
if (allowWriteToSurrogate) {
|
|
161
167
|
const rotation = transform.rotation;
|
|
162
168
|
|
|
163
|
-
|
|
169
|
+
if (surrogate.rotation.order === "XYZ") {
|
|
170
|
+
rotation.fromEulerAnglesXYZ(surrogate.rotation.x, surrogate.rotation.y, surrogate.rotation.z);
|
|
171
|
+
} else {
|
|
172
|
+
throw new Error("Unsupported rotation order");
|
|
173
|
+
}
|
|
174
|
+
|
|
164
175
|
|
|
165
176
|
surrogate.quaternion.set(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
166
177
|
}
|
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.131.
|
|
8
|
+
"version": "2.131.19",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -71,7 +71,7 @@ export class Quaternion implements Iterable<number> {
|
|
|
71
71
|
*/
|
|
72
72
|
w: number;
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
74
|
+
* Fires when the value of the quaternion changes
|
|
75
75
|
* Signature of the signal data is as follows:
|
|
76
76
|
* (new_x, new_y, new_z, new_w, old_x, old_y, old_z, old_w)
|
|
77
77
|
* @readonly
|
|
@@ -122,6 +122,9 @@ export class Quaternion implements Iterable<number> {
|
|
|
122
122
|
* Orient quaternion on a `forward` vector, with the spin matching `up` vector
|
|
123
123
|
* Useful for `lookAt` operations, such as for camera or inverse kinematics.
|
|
124
124
|
* Normalizes input, meaning input does not have to be normalized.
|
|
125
|
+
*
|
|
126
|
+
* NOTE: `forward` and `up` vectors being the same is allowed, but you will likely get unexpected rotation along the look axis, so prefer not to do it.
|
|
127
|
+
*
|
|
125
128
|
* @param {number} fx forward vector
|
|
126
129
|
* @param {number} fy forward vector
|
|
127
130
|
* @param {number} fz forward vector
|
|
@@ -151,10 +154,20 @@ export class Quaternion implements Iterable<number> {
|
|
|
151
154
|
*/
|
|
152
155
|
copyInverse(other: Quaternion): this;
|
|
153
156
|
/**
|
|
154
|
-
* Calculates the inverse
|
|
157
|
+
* Calculates the inverse.
|
|
158
|
+
* Correctly handles unnormalized quaternions.
|
|
159
|
+
*
|
|
160
|
+
* If your quaternion is normalized, you can use {@link conjugate} instead for speed.
|
|
155
161
|
* @returns {this}
|
|
162
|
+
* @see conjugate
|
|
156
163
|
*/
|
|
157
164
|
invert(): this;
|
|
165
|
+
/**
|
|
166
|
+
* NOTE: this is the same as {@link invert} if the quaternion is normalized.
|
|
167
|
+
* @returns {this}
|
|
168
|
+
* @see invert
|
|
169
|
+
*/
|
|
170
|
+
conjugate(): this;
|
|
158
171
|
/**
|
|
159
172
|
* Returns angle between this orientation and another
|
|
160
173
|
* @param {Quaternion} other
|
|
@@ -256,17 +269,14 @@ export class Quaternion implements Iterable<number> {
|
|
|
256
269
|
*/
|
|
257
270
|
lookAt(source: Vector3, target: Vector3, up?: Vector3): void;
|
|
258
271
|
/**
|
|
259
|
-
* @deprecated use {@link
|
|
260
|
-
* @param {function():number} random
|
|
261
|
-
*/
|
|
262
|
-
setRandom(random: () => number): void;
|
|
263
|
-
/**
|
|
272
|
+
* @deprecated use {@link fromEulerAnglesXYZ} or others specifically.
|
|
264
273
|
*
|
|
265
274
|
* @param {number} x
|
|
266
275
|
* @param {number} y
|
|
267
276
|
* @param {number} z
|
|
268
277
|
* @param {String} [order='XYZ'] a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
269
278
|
* @returns {this}
|
|
279
|
+
*
|
|
270
280
|
* @see fromEulerAnglesXYZ
|
|
271
281
|
* @see fromEulerAnglesYXZ
|
|
272
282
|
* @see fromEulerAnglesZXY
|
|
@@ -291,6 +301,21 @@ export class Quaternion implements Iterable<number> {
|
|
|
291
301
|
* @param {Vector3} result
|
|
292
302
|
*/
|
|
293
303
|
toEulerAnglesZYX(result: Vector3): void;
|
|
304
|
+
/**
|
|
305
|
+
* Set rotation from Euler angles in degrees.
|
|
306
|
+
*
|
|
307
|
+
* Order is explicitly XYZ.
|
|
308
|
+
*
|
|
309
|
+
* Utility shortcut, same as `fromEulerAnglesXYZ(x * π / 180, y * π / 180, z * π / 180)`
|
|
310
|
+
*
|
|
311
|
+
* @param {number} [x] angle in degrees
|
|
312
|
+
* @param {number} [y] angle in degrees
|
|
313
|
+
* @param {number} [z] angle in degrees
|
|
314
|
+
* @returns {this}
|
|
315
|
+
*
|
|
316
|
+
* @see fromEulerAnglesXYZ
|
|
317
|
+
*/
|
|
318
|
+
fromDegrees(x?: number, y?: number, z?: number): this;
|
|
294
319
|
/**
|
|
295
320
|
* XYZ order
|
|
296
321
|
* @source: https://stackoverflow.com/questions/12088610/conversion-between-euler-quaternion-like-in-unity3d-engine
|
|
@@ -445,11 +470,6 @@ export class Quaternion implements Iterable<number> {
|
|
|
445
470
|
* @returns {this}
|
|
446
471
|
*/
|
|
447
472
|
set(x: number, y: number, z: number, w: number): this;
|
|
448
|
-
/**
|
|
449
|
-
*
|
|
450
|
-
* @returns {this}
|
|
451
|
-
*/
|
|
452
|
-
conjugate(): this;
|
|
453
473
|
toJSON(): {
|
|
454
474
|
x: number;
|
|
455
475
|
y: number;
|
|
@@ -488,14 +508,14 @@ export class Quaternion implements Iterable<number> {
|
|
|
488
508
|
* @param {number} [offset]
|
|
489
509
|
* @returns {this}
|
|
490
510
|
*/
|
|
491
|
-
|
|
511
|
+
fromArray(array: number[], offset?: number): this;
|
|
492
512
|
/**
|
|
493
513
|
*
|
|
494
514
|
* @param {number[]} [array]
|
|
495
515
|
* @param {number} [offset]
|
|
496
516
|
* @returns {number[]}
|
|
497
517
|
*/
|
|
498
|
-
|
|
518
|
+
toArray(array?: number[], offset?: number): number[];
|
|
499
519
|
/**
|
|
500
520
|
* Strict equality check
|
|
501
521
|
* @param {Quaternion} other
|
|
@@ -525,15 +545,28 @@ export class Quaternion implements Iterable<number> {
|
|
|
525
545
|
* @return {boolean}
|
|
526
546
|
*/
|
|
527
547
|
_roughlyEquals(x: number, y: number, z: number, w: number, tolerance?: number): boolean;
|
|
548
|
+
/**
|
|
549
|
+
* @deprecated use {@link random} instead
|
|
550
|
+
* @param {function():number} random
|
|
551
|
+
*/
|
|
552
|
+
setRandom(random: () => number): void;
|
|
528
553
|
/**
|
|
529
554
|
* Randomly orient current quaternion
|
|
530
|
-
* @param {function():number} [random]
|
|
531
|
-
* @return {Quaternion}
|
|
555
|
+
* @param {function():number} [random=Math.random] Random number generator function.
|
|
532
556
|
*/
|
|
533
|
-
random(random?: () => number):
|
|
557
|
+
random(random?: () => number): this;
|
|
534
558
|
toString(): string;
|
|
535
|
-
|
|
536
|
-
|
|
559
|
+
/**
|
|
560
|
+
* @deprecated use `fromArray`
|
|
561
|
+
*/
|
|
562
|
+
readFromArray: (array: number[], offset?: number) => this;
|
|
563
|
+
/**
|
|
564
|
+
* @deprecated use `toArray`
|
|
565
|
+
*/
|
|
566
|
+
writeToArray: (array?: number[], offset?: number) => number[];
|
|
567
|
+
/**
|
|
568
|
+
* @deprecated use `toArray`
|
|
569
|
+
*/
|
|
537
570
|
asArray: (array?: number[], offset?: number) => number[];
|
|
538
571
|
fromEulerAngles: (x: number, y: number, z: number) => this;
|
|
539
572
|
/**
|
|
@@ -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":"AAqBA;;;;;;;;;;;GAWG;AACH,4CALwB,MAAM;IA+S1B;;;;;OAKG;IACH,2BAJW,OAAO,SACP,MAAM,GACJ,UAAU,CAQtB;IAurCD;;;;OAIG;IACH,kCAFa,UAAU,CAQtB;IAED;;;;;;;OAOG;IACH,0BALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,UAAU,CAQtB;IAED;;;;;;OAMG;IACH,6BALW,UAAU,QACV,UAAU,MACV,UAAU,aACV,MAAM,QA0BhB;IAxiDD;;;;;;;OAOG;IACH,gBANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,EAsChB;IA7BG;;;OAGG;IACH,GAFU,MAAM,CAEN;IACV;;;OAGG;IACH,GAFU,MAAM,CAEN;IACV;;;OAGG;IACH,GAFU,MAAM,CAEN;IACV;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV;;;;;;OAMG;IACH,oBAFU,OAAO,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAEnD;IAqCjC;;;OAGG;IACH,mBAEC;IAtCD;;;OAGG;I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AM,EAAE,WACR,MAAM,KACJ,MAAM,EAAE,CAqLQ;IAEjC;;OAEG;IACH,kBA5Le,MAAM,EAAE,WACR,MAAM,KACJ,MAAM,EAAE,CA0LG;IAC5B,qBA3zBe,MAAM,KACN,MAAM,KACN,MAAM,KACJ,IAAI,CAwzBe;IAQpC;;;;OAIG;IACH,uBAFU,OAAO,CAEgB;IAv9C7B;;;OAGG;IACH,qBAFa,UAAU,MAAM,CAAC,CAS7B;CA+6CJ;;kBAoBS,UAAU;kBAaV,MAAM;;;mBA3mDG,4BAA4B;oBAW3B,cAAc"}
|
|
@@ -2,6 +2,7 @@ import { assert } from "../assert.js";
|
|
|
2
2
|
import Signal from "../events/signal/Signal.js";
|
|
3
3
|
import { clamp } from "../math/clamp.js";
|
|
4
4
|
import { clamp01 } from "../math/clamp01.js";
|
|
5
|
+
import { DEG_TO_RAD } from "../math/DEG_TO_RAD.js";
|
|
5
6
|
import { EPSILON } from "../math/EPSILON.js";
|
|
6
7
|
import { epsilonEquals } from "../math/epsilonEquals.js";
|
|
7
8
|
import { lerp } from "../math/lerp.js";
|
|
@@ -67,7 +68,7 @@ export class Quaternion {
|
|
|
67
68
|
this.w = w;
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
|
-
*
|
|
71
|
+
* Fires when the value of the quaternion changes
|
|
71
72
|
* Signature of the signal data is as follows:
|
|
72
73
|
* (new_x, new_y, new_z, new_w, old_x, old_y, old_z, old_w)
|
|
73
74
|
* @readonly
|
|
@@ -160,6 +161,9 @@ export class Quaternion {
|
|
|
160
161
|
* Orient quaternion on a `forward` vector, with the spin matching `up` vector
|
|
161
162
|
* Useful for `lookAt` operations, such as for camera or inverse kinematics.
|
|
162
163
|
* Normalizes input, meaning input does not have to be normalized.
|
|
164
|
+
*
|
|
165
|
+
* NOTE: `forward` and `up` vectors being the same is allowed, but you will likely get unexpected rotation along the look axis, so prefer not to do it.
|
|
166
|
+
*
|
|
163
167
|
* @param {number} fx forward vector
|
|
164
168
|
* @param {number} fy forward vector
|
|
165
169
|
* @param {number} fz forward vector
|
|
@@ -260,8 +264,12 @@ export class Quaternion {
|
|
|
260
264
|
}
|
|
261
265
|
|
|
262
266
|
/**
|
|
263
|
-
* Calculates the inverse
|
|
267
|
+
* Calculates the inverse.
|
|
268
|
+
* Correctly handles unnormalized quaternions.
|
|
269
|
+
*
|
|
270
|
+
* If your quaternion is normalized, you can use {@link conjugate} instead for speed.
|
|
264
271
|
* @returns {this}
|
|
272
|
+
* @see conjugate
|
|
265
273
|
*/
|
|
266
274
|
invert() {
|
|
267
275
|
const x = this.x;
|
|
@@ -269,14 +277,14 @@ export class Quaternion {
|
|
|
269
277
|
const z = this.z;
|
|
270
278
|
const w = this.w;
|
|
271
279
|
|
|
272
|
-
const
|
|
280
|
+
const dot_product = x * x + y * y + z * z + w * w;
|
|
273
281
|
|
|
274
|
-
if (
|
|
282
|
+
if (dot_product === 0) {
|
|
275
283
|
// 0 magnitude, avoid division by 0 and set identity (arbitrage)
|
|
276
284
|
return this.set(0, 0, 0, 1);
|
|
277
285
|
}
|
|
278
286
|
|
|
279
|
-
const invDot = 1.0 /
|
|
287
|
+
const invDot = 1.0 / dot_product;
|
|
280
288
|
|
|
281
289
|
const _x = -x * invDot;
|
|
282
290
|
const _y = -y * invDot;
|
|
@@ -286,6 +294,15 @@ export class Quaternion {
|
|
|
286
294
|
return this.set(_x, _y, _z, _w);
|
|
287
295
|
}
|
|
288
296
|
|
|
297
|
+
/**
|
|
298
|
+
* NOTE: this is the same as {@link invert} if the quaternion is normalized.
|
|
299
|
+
* @returns {this}
|
|
300
|
+
* @see invert
|
|
301
|
+
*/
|
|
302
|
+
conjugate() {
|
|
303
|
+
return this.set(-this.x, -this.y, -this.z, this.w);
|
|
304
|
+
}
|
|
305
|
+
|
|
289
306
|
/**
|
|
290
307
|
* Returns angle between this orientation and another
|
|
291
308
|
* @param {Quaternion} other
|
|
@@ -602,21 +619,16 @@ export class Quaternion {
|
|
|
602
619
|
this.lookRotation(forward, up);
|
|
603
620
|
}
|
|
604
621
|
|
|
605
|
-
/**
|
|
606
|
-
* @deprecated use {@link random} instead
|
|
607
|
-
* @param {function():number} random
|
|
608
|
-
*/
|
|
609
|
-
setRandom(random) {
|
|
610
|
-
throw new Error("use .random() instead");
|
|
611
|
-
}
|
|
612
622
|
|
|
613
623
|
/**
|
|
624
|
+
* @deprecated use {@link fromEulerAnglesXYZ} or others specifically.
|
|
614
625
|
*
|
|
615
626
|
* @param {number} x
|
|
616
627
|
* @param {number} y
|
|
617
628
|
* @param {number} z
|
|
618
629
|
* @param {String} [order='XYZ'] a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
619
630
|
* @returns {this}
|
|
631
|
+
*
|
|
620
632
|
* @see fromEulerAnglesXYZ
|
|
621
633
|
* @see fromEulerAnglesYXZ
|
|
622
634
|
* @see fromEulerAnglesZXY
|
|
@@ -758,6 +770,28 @@ export class Quaternion {
|
|
|
758
770
|
result.set(psi, theta, phi);
|
|
759
771
|
}
|
|
760
772
|
|
|
773
|
+
/**
|
|
774
|
+
* Set rotation from Euler angles in degrees.
|
|
775
|
+
*
|
|
776
|
+
* Order is explicitly XYZ.
|
|
777
|
+
*
|
|
778
|
+
* Utility shortcut, same as `fromEulerAnglesXYZ(x * π / 180, y * π / 180, z * π / 180)`
|
|
779
|
+
*
|
|
780
|
+
* @param {number} [x] angle in degrees
|
|
781
|
+
* @param {number} [y] angle in degrees
|
|
782
|
+
* @param {number} [z] angle in degrees
|
|
783
|
+
* @returns {this}
|
|
784
|
+
*
|
|
785
|
+
* @see fromEulerAnglesXYZ
|
|
786
|
+
*/
|
|
787
|
+
fromDegrees(x = 0, y = 0, z = 0) {
|
|
788
|
+
return this.fromEulerAnglesXYZ(
|
|
789
|
+
x * DEG_TO_RAD,
|
|
790
|
+
y * DEG_TO_RAD,
|
|
791
|
+
z * DEG_TO_RAD
|
|
792
|
+
);
|
|
793
|
+
}
|
|
794
|
+
|
|
761
795
|
|
|
762
796
|
/**
|
|
763
797
|
* XYZ order
|
|
@@ -1316,14 +1350,6 @@ export class Quaternion {
|
|
|
1316
1350
|
return this;
|
|
1317
1351
|
}
|
|
1318
1352
|
|
|
1319
|
-
/**
|
|
1320
|
-
*
|
|
1321
|
-
* @returns {this}
|
|
1322
|
-
*/
|
|
1323
|
-
conjugate() {
|
|
1324
|
-
return this.set(-this.x, -this.y, -this.z, this.w);
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
1353
|
toJSON() {
|
|
1328
1354
|
return {
|
|
1329
1355
|
x: this.x,
|
|
@@ -1396,7 +1422,10 @@ export class Quaternion {
|
|
|
1396
1422
|
* @param {number} [offset]
|
|
1397
1423
|
* @returns {this}
|
|
1398
1424
|
*/
|
|
1399
|
-
|
|
1425
|
+
fromArray(array, offset = 0) {
|
|
1426
|
+
assert.defined(array, "array");
|
|
1427
|
+
assert.isNonNegativeInteger(offset, "offset");
|
|
1428
|
+
|
|
1400
1429
|
return this.set(
|
|
1401
1430
|
array[offset],
|
|
1402
1431
|
array[offset + 1],
|
|
@@ -1411,7 +1440,10 @@ export class Quaternion {
|
|
|
1411
1440
|
* @param {number} [offset]
|
|
1412
1441
|
* @returns {number[]}
|
|
1413
1442
|
*/
|
|
1414
|
-
|
|
1443
|
+
toArray(array = [], offset = 0) {
|
|
1444
|
+
assert.defined(array, 'array');
|
|
1445
|
+
assert.isNonNegativeInteger(offset, "offset");
|
|
1446
|
+
|
|
1415
1447
|
array[offset] = this.x;
|
|
1416
1448
|
array[offset + 1] = this.y;
|
|
1417
1449
|
array[offset + 2] = this.z;
|
|
@@ -1477,10 +1509,17 @@ export class Quaternion {
|
|
|
1477
1509
|
&& epsilonEquals(this.w, w, tolerance);
|
|
1478
1510
|
}
|
|
1479
1511
|
|
|
1512
|
+
/**
|
|
1513
|
+
* @deprecated use {@link random} instead
|
|
1514
|
+
* @param {function():number} random
|
|
1515
|
+
*/
|
|
1516
|
+
setRandom(random) {
|
|
1517
|
+
throw new Error("use .random() instead");
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1480
1520
|
/**
|
|
1481
1521
|
* Randomly orient current quaternion
|
|
1482
|
-
* @param {function():number} [random]
|
|
1483
|
-
* @return {Quaternion}
|
|
1522
|
+
* @param {function():number} [random=Math.random] Random number generator function.
|
|
1484
1523
|
*/
|
|
1485
1524
|
random(random = Math.random) {
|
|
1486
1525
|
assert.isFunction(random, 'random');
|
|
@@ -1572,9 +1611,20 @@ export class Quaternion {
|
|
|
1572
1611
|
}
|
|
1573
1612
|
}
|
|
1574
1613
|
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1614
|
+
/**
|
|
1615
|
+
* @deprecated use `fromArray`
|
|
1616
|
+
*/
|
|
1617
|
+
Quaternion.prototype.readFromArray = Quaternion.prototype.fromArray;
|
|
1618
|
+
|
|
1619
|
+
/**
|
|
1620
|
+
* @deprecated use `toArray`
|
|
1621
|
+
*/
|
|
1622
|
+
Quaternion.prototype.writeToArray = Quaternion.prototype.toArray;
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* @deprecated use `toArray`
|
|
1626
|
+
*/
|
|
1627
|
+
Quaternion.prototype.asArray = Quaternion.prototype.toArray;
|
|
1578
1628
|
Quaternion.prototype.fromEulerAngles = Quaternion.prototype.fromEulerAnglesXYZ;
|
|
1579
1629
|
|
|
1580
1630
|
/**
|
|
@@ -517,6 +517,9 @@ export class Vector3 implements Iterable<number> {
|
|
|
517
517
|
_projectVectors(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): this;
|
|
518
518
|
/**
|
|
519
519
|
* Convert spherical coordinates to cartesian
|
|
520
|
+
*
|
|
521
|
+
* We assume Y-up coordinate system.
|
|
522
|
+
*
|
|
520
523
|
* @param {number} radius
|
|
521
524
|
* @param {number} phi Also known as Azimuth
|
|
522
525
|
* @param {number} theta Also known as Elevation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vector3.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector3.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;GAcG;AACH,yCALwB,MAAM;
|
|
1
|
+
{"version":3,"file":"Vector3.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector3.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;GAcG;AACH,yCALwB,MAAM;IAoiC1B;;;;;OAKG;IACH,cAJW,OAAO,UAAQ,KACf,OAAO,UAAQ,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;IAvkCD;;;;;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,OAAO,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,CAAC,CAE9B;IA2BjC;;;OAGG;IACH,mBAEC;IA9BD;;;OAGG;IACH,gBAEC;IA0BD;;;OAGG;IACH,mBAEC;IA9BD;;;OAGG;IACH,gBAEC;IA0BD;;;OAGG;IACH,mBAEC;IA9BD;;;OAGG;IACH,gBAEC;IAsCD;;;;;OAKG;IACH,iBAJW,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,GACJ,IAAI,CAWhB;IAED;;;;OAIG;IACH,gBAJW,MAAM,EAAE,GAAC,YAAY,iBAAU,WAC/B,MAAM,GACJ,MAAM,EAAE,CAUpB;IAED;;;;;;OAMG;IACH,OALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,IAAI,CAgChB;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,IAAI,CAIhB;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QAAC,CAAC,EAAC,MAAM,CAAC;QAAC,CAAC,EAAC,MAAM,CAAA;KAAC,GAAC,MAAM,QAS/C;IAED,mBAEC;IAED;;;;OAIG;IACH,2CAIC;IAED;;;;OAIG;IACH,6CAMC;IAED;;;;OAIG;IACH,kDAIC;IAED;;;;OAIG;IACH,oDAMC;IAED,eAMC;IAgDL,2BA3fe,OAAO,KACL,MAAM,CA0fY;IAEnC,gBA7kBiB,MAAM,CA6kBG;IAC1B;;;OAGG;IACH,gCAx+Be,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,KACJ,IAAI,CAs+BU;IAC/B;;;OAGG;IACH,gCA79Be,MAAM,EAAE,GAAC,YAAY,iBAAU,WAC/B,MAAM,KACJ,MAAM,EAAE,CA29BK;IAC9B;;;OAGG;IACH,2BAl+Be,MAAM,EAAE,GAAC,YAAY,iBAAU,WAC/B,MAAM,KACJ,MAAM,EAAE,CAg+BA;IA2DzB;;;OAGG;IACH,oBAFU,OAAO,CAEU;IA/jCvB;;;OAGG;IACH,qBAFY,UAAU,MAAM,CAAC,CAQ5B;CAi+BJ;;cA0BS,OAAO;aAOP,OAAO;mBAOP,OAAO;YAMP,OAAO;cAMP,OAAO;cAMP,OAAO;eAMP,OAAO;iBAMP,OAAO;cAMP,OAAO;kBAYP,MAAM;;;mBA9rCG,4BAA4B"}
|
package/src/core/geom/Vector3.js
CHANGED
|
@@ -39,11 +39,11 @@ export class Vector3 {
|
|
|
39
39
|
assert.isNumber(x, 'x');
|
|
40
40
|
assert.notNaN(x, 'x');
|
|
41
41
|
|
|
42
|
-
assert.isNumber(y, '
|
|
43
|
-
assert.notNaN(y, '
|
|
42
|
+
assert.isNumber(y, 'y');
|
|
43
|
+
assert.notNaN(y, 'y');
|
|
44
44
|
|
|
45
|
-
assert.isNumber(z, '
|
|
46
|
-
assert.notNaN(z, '
|
|
45
|
+
assert.isNumber(z, 'z');
|
|
46
|
+
assert.notNaN(z, 'z');
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Do not assign directly, use {@link set} method instead
|
|
@@ -141,6 +141,9 @@ export class Vector3 {
|
|
|
141
141
|
* @returns {this}
|
|
142
142
|
*/
|
|
143
143
|
fromArray(array, offset = 0) {
|
|
144
|
+
assert.defined(array, "array");
|
|
145
|
+
assert.isNonNegativeInteger(offset, "offset");
|
|
146
|
+
|
|
144
147
|
return this.set(
|
|
145
148
|
array[offset],
|
|
146
149
|
array[offset + 1],
|
|
@@ -154,6 +157,8 @@ export class Vector3 {
|
|
|
154
157
|
* @returns {number[]}
|
|
155
158
|
*/
|
|
156
159
|
toArray(array = [], offset = 0) {
|
|
160
|
+
assert.isNonNegativeInteger(offset, "offset");
|
|
161
|
+
|
|
157
162
|
array[offset] = this.x;
|
|
158
163
|
array[offset + 1] = this.y;
|
|
159
164
|
array[offset + 2] = this.z;
|
|
@@ -659,6 +664,8 @@ export class Vector3 {
|
|
|
659
664
|
* @returns {this}
|
|
660
665
|
*/
|
|
661
666
|
applyQuaternion(q) {
|
|
667
|
+
// NOTE: the logic is inlines for speed
|
|
668
|
+
|
|
662
669
|
//transform point into quaternion
|
|
663
670
|
|
|
664
671
|
const x = this.x;
|
|
@@ -936,9 +943,9 @@ export class Vector3 {
|
|
|
936
943
|
|
|
937
944
|
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
938
945
|
|
|
939
|
-
const
|
|
946
|
+
const length_sqr = (x1 * x1 + y1 * y1 + z1 * z1);
|
|
940
947
|
|
|
941
|
-
const m = d /
|
|
948
|
+
const m = d / length_sqr;
|
|
942
949
|
|
|
943
950
|
const x = x1 * m;
|
|
944
951
|
const y = y1 * m;
|
|
@@ -949,6 +956,9 @@ export class Vector3 {
|
|
|
949
956
|
|
|
950
957
|
/**
|
|
951
958
|
* Convert spherical coordinates to cartesian
|
|
959
|
+
*
|
|
960
|
+
* We assume Y-up coordinate system.
|
|
961
|
+
*
|
|
952
962
|
* @param {number} radius
|
|
953
963
|
* @param {number} phi Also known as Azimuth
|
|
954
964
|
* @param {number} theta Also known as Elevation
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Compute `y0,y1` bounds of a cubic
|
|
2
|
+
* Compute `y0,y1` bounds of a cubic Hermite spline.
|
|
3
3
|
* Lower bound will be written into result[offset], upper bounds will be written into result[offset+result_stride]
|
|
4
4
|
*
|
|
5
5
|
* @param {number[]|Float32Array} result output will be written here, only y0 and y1
|
|
@@ -4,7 +4,7 @@ import { min2 } from "../min2.js";
|
|
|
4
4
|
import { spline3_hermite } from "./spline3_hermite.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Compute `y0,y1` bounds of a cubic
|
|
7
|
+
* Compute `y0,y1` bounds of a cubic Hermite spline.
|
|
8
8
|
* Lower bound will be written into result[offset], upper bounds will be written into result[offset+result_stride]
|
|
9
9
|
*
|
|
10
10
|
* @param {number[]|Float32Array} result output will be written here, only y0 and y1
|
|
@@ -26,7 +26,7 @@ export function spline3_hermite_bounds(
|
|
|
26
26
|
|
|
27
27
|
/*
|
|
28
28
|
Solution is based on https://stackoverflow.com/questions/24809978/calculating-the-bounding-box-of-cubic-bezier-curve
|
|
29
|
-
Differentiation of
|
|
29
|
+
Differentiation of Hermite polynomial is done in WolframAlpha:
|
|
30
30
|
0 = 3 t^2 (m0 + m1 + 2 p0 - 2 p1) - 2 t (2 m0 + m1 + 3 p0 - 3 p1) + m0
|
|
31
31
|
*/
|
|
32
32
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns the first-order partial derivative of a
|
|
2
|
+
* Returns the first-order partial derivative of a Hermite curve with control points p0, m0, p1, m1 at the parameter t in [0,1].
|
|
3
3
|
*
|
|
4
|
-
* @param {number} t
|
|
5
|
-
* @param {number} p0
|
|
6
|
-
* @param {number} p1
|
|
7
|
-
* @param {number} m0
|
|
8
|
-
* @param {number} m1
|
|
4
|
+
* @param {number} t normalized interpolation position in interval [0,1]
|
|
5
|
+
* @param {number} p0 first value
|
|
6
|
+
* @param {number} p1 second value
|
|
7
|
+
* @param {number} m0 first tangent
|
|
8
|
+
* @param {number} m1 second tangent
|
|
9
9
|
* @returns {number}
|
|
10
|
+
*
|
|
11
|
+
* @see spline3_hermite_integral
|
|
10
12
|
*/
|
|
11
13
|
export function spline3_hermite_derivative(t: number, p0: number, p1: number, m0: number, m1: number): number;
|
|
12
14
|
//# sourceMappingURL=spline3_hermite_derivative.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spline3_hermite_derivative.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline3_hermite_derivative.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"spline3_hermite_derivative.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline3_hermite_derivative.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,8CATW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAgBlB"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns the first-order partial derivative of a
|
|
2
|
+
* Returns the first-order partial derivative of a Hermite curve with control points p0, m0, p1, m1 at the parameter t in [0,1].
|
|
3
3
|
*
|
|
4
|
-
* @param {number} t
|
|
5
|
-
* @param {number} p0
|
|
6
|
-
* @param {number} p1
|
|
7
|
-
* @param {number} m0
|
|
8
|
-
* @param {number} m1
|
|
4
|
+
* @param {number} t normalized interpolation position in interval [0,1]
|
|
5
|
+
* @param {number} p0 first value
|
|
6
|
+
* @param {number} p1 second value
|
|
7
|
+
* @param {number} m0 first tangent
|
|
8
|
+
* @param {number} m1 second tangent
|
|
9
9
|
* @returns {number}
|
|
10
|
+
*
|
|
11
|
+
* @see spline3_hermite_integral
|
|
10
12
|
*/
|
|
11
13
|
export function spline3_hermite_derivative(t, p0, p1, m0, m1) {
|
|
12
14
|
|
|
@@ -20,4 +22,5 @@ export function spline3_hermite_derivative(t, p0, p1, m0, m1) {
|
|
|
20
22
|
|
|
21
23
|
return dcx1 * p0 + dcx2 * p1 + dcv1 * m0 + dcv2 * m1
|
|
22
24
|
|
|
23
|
-
}
|
|
25
|
+
}
|
|
26
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the integral (area under the curve) of a cubic hermite spline from 0 to t.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} t normalized interpolation position in interval [0,1]
|
|
5
|
+
* @param {number} p0 first value
|
|
6
|
+
* @param {number} p1 second value
|
|
7
|
+
* @param {number} m0 first tangent
|
|
8
|
+
* @param {number} m1 second tangent
|
|
9
|
+
* @returns {number} The definite integral from 0 to t
|
|
10
|
+
*
|
|
11
|
+
* @see spline3_hermite_derivative
|
|
12
|
+
*/
|
|
13
|
+
export function spline3_hermite_integral(t: number, p0: number, p1: number, m0: number, m1: number): number;
|
|
14
|
+
//# sourceMappingURL=spline3_hermite_integral.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spline3_hermite_integral.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline3_hermite_integral.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,4CATW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CA0BlB"}
|