@woosh/meep-engine 2.126.54 → 2.126.57
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/build/bundle-worker-terrain.js +1 -1
- package/package.json +1 -1
- package/src/core/geom/3d/mat4/apply_mat4_transform_to_v3_array.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/apply_mat4_transform_to_v3_array.js +3 -29
- package/src/core/geom/3d/mat4/m4_extract_scale.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_extract_scale.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_extract_scale.js +9 -3
- package/src/core/geom/3d/mat4/m4_inverse_rotation_translation.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_inverse_rotation_translation.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_inverse_rotation_translation.js +3 -0
- package/src/core/geom/3d/mat4/m4_invert.d.ts +1 -1
- package/src/core/geom/3d/mat4/m4_invert.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_invert.js +5 -2
- package/src/core/geom/3d/mat4/m4_make_scale.d.ts +1 -1
- package/src/core/geom/3d/mat4/m4_make_scale.js +1 -1
- package/src/core/geom/3d/mat4/m4_make_translation.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_make_translation.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_make_translation.js +3 -0
- package/src/core/geom/3d/mat4/m4_multiply.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_multiply.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_multiply.js +3 -0
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.js +3 -0
- package/src/core/geom/3d/mat4/m4_orthographic_off_center_z0.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_orthographic_off_center_z0.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_orthographic_off_center_z0.js +3 -0
- package/src/core/geom/3d/mat4/m4_rotation_translation.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_rotation_translation.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_rotation_translation.js +3 -0
- package/src/core/geom/3d/morton/v3_morton_encode_bounded.d.ts.map +1 -1
- package/src/core/geom/3d/morton/v3_morton_encode_bounded.js +5 -10
- package/src/core/geom/3d/morton/v3_morton_encode_normalized.d.ts +9 -0
- package/src/core/geom/3d/morton/v3_morton_encode_normalized.d.ts.map +1 -0
- package/src/core/geom/3d/morton/v3_morton_encode_normalized.js +26 -0
- package/src/core/geom/3d/morton/v3_morton_encode_transformed.d.ts.map +1 -1
- package/src/core/geom/3d/morton/v3_morton_encode_transformed.js +10 -16
- package/src/core/geom/Quaternion.d.ts +31 -20
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +35 -21
- package/src/engine/ecs/Entity.d.ts.map +1 -1
- package/src/engine/ecs/Entity.js +34 -16
- package/src/engine/ecs/EntityReference.d.ts +2 -1
- package/src/engine/ecs/EntityReference.d.ts.map +1 -1
- package/src/engine/ecs/EntityReference.js +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v3_morton_encode_transformed.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/v3_morton_encode_transformed.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,gDANW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,GACN,MAAM,
|
|
1
|
+
{"version":3,"file":"v3_morton_encode_transformed.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/v3_morton_encode_transformed.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,gDANW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,GACN,MAAM,CAqBlB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { clamp01 } from "../../../math/clamp01.js";
|
|
2
|
+
import { v3_morton_encode_normalized } from "./v3_morton_encode_normalized.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Assumes that coordinates will be mapped to -1..1 range after transform
|
|
@@ -17,22 +17,16 @@ export function v3_morton_encode_transformed(x, y, z, matrix) {
|
|
|
17
17
|
const _z = matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14];
|
|
18
18
|
const _w = matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15];
|
|
19
19
|
|
|
20
|
-
const d =
|
|
20
|
+
const d = 0.5 / _w;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const ndc_z = _z * d;
|
|
22
|
+
const n_x = clamp01(_x * d + 0.5);
|
|
23
|
+
const n_y = clamp01(_y * d + 0.5);
|
|
24
|
+
const n_z = clamp01(_z * d + 0.5);
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return v3_morton_encode(
|
|
33
|
-
Math.round(px),
|
|
34
|
-
Math.round(py),
|
|
35
|
-
Math.round(pz)
|
|
26
|
+
return v3_morton_encode_normalized(
|
|
27
|
+
n_x,
|
|
28
|
+
n_y,
|
|
29
|
+
n_z
|
|
36
30
|
);
|
|
37
31
|
}
|
|
38
32
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Represents rotation in 3d space
|
|
4
4
|
*
|
|
5
5
|
* Iterating through a Quaternion instance will yield its components `(x, y, z, w)` in the corresponding order.
|
|
6
|
-
*
|
|
6
|
+
* Note that a quaternion must be {@link normalize}d to properly represent rotation. Check documentation of individual operations when in doubt.
|
|
7
7
|
* @see https://en.wikipedia.org/wiki/Quaternion
|
|
8
8
|
* @implements Iterable<number>
|
|
9
9
|
*
|
|
@@ -120,7 +120,8 @@ export class Quaternion implements Iterable<number> {
|
|
|
120
120
|
get 3(): number;
|
|
121
121
|
/**
|
|
122
122
|
* Orient quaternion on a `forward` vector, with the spin matching `up` vector
|
|
123
|
-
* Useful for `lookAt` operations, such as for camera or inverse kinematics
|
|
123
|
+
* Useful for `lookAt` operations, such as for camera or inverse kinematics.
|
|
124
|
+
* Normalizes input, meaning input does not have to be normalized.
|
|
124
125
|
* @param {number} fx forward vector
|
|
125
126
|
* @param {number} fy forward vector
|
|
126
127
|
* @param {number} fz forward vector
|
|
@@ -131,11 +132,12 @@ export class Quaternion implements Iterable<number> {
|
|
|
131
132
|
*/
|
|
132
133
|
_lookRotation(fx: number, fy: number, fz: number, ux: number, uy: number, uz: number): this;
|
|
133
134
|
/**
|
|
134
|
-
* Orient quaternion to align with the `forward`
|
|
135
|
-
* @param {Vector3} forward
|
|
136
|
-
* @param {Vector3} [up=Vector3.up]
|
|
135
|
+
* Orient quaternion to align with the `forward` direction.
|
|
136
|
+
* @param {Vector3} forward Does not need to be normalized.
|
|
137
|
+
* @param {Vector3} [up=Vector3.up] Does not need to be normalized.
|
|
138
|
+
* @returns {this}
|
|
137
139
|
*/
|
|
138
|
-
lookRotation(forward: Vector3, up?: Vector3):
|
|
140
|
+
lookRotation(forward: Vector3, up?: Vector3): this;
|
|
139
141
|
/**
|
|
140
142
|
* Vector dot product in 4 dimensions
|
|
141
143
|
* @param {Quaternion} other
|
|
@@ -145,8 +147,9 @@ export class Quaternion implements Iterable<number> {
|
|
|
145
147
|
/**
|
|
146
148
|
* Makes this quaternion into an inverse of the other
|
|
147
149
|
* @param {Quaternion} other
|
|
150
|
+
* @returns {this}
|
|
148
151
|
*/
|
|
149
|
-
copyInverse(other: Quaternion):
|
|
152
|
+
copyInverse(other: Quaternion): this;
|
|
150
153
|
/**
|
|
151
154
|
* Calculates the inverse
|
|
152
155
|
* @returns {this}
|
|
@@ -162,16 +165,18 @@ export class Quaternion implements Iterable<number> {
|
|
|
162
165
|
* Set quaternion from axis + angle definition
|
|
163
166
|
* @param {Vector3} axis
|
|
164
167
|
* @param {number} angle
|
|
168
|
+
* @returns {this}
|
|
165
169
|
*/
|
|
166
|
-
fromAxisAngle(axis: Vector3, angle: number):
|
|
170
|
+
fromAxisAngle(axis: Vector3, angle: number): this;
|
|
167
171
|
/**
|
|
168
172
|
*
|
|
169
173
|
* @param {number} axis_x
|
|
170
174
|
* @param {number} axis_y
|
|
171
175
|
* @param {number} axis_z
|
|
172
176
|
* @param {number} angle
|
|
177
|
+
* @returns {this}
|
|
173
178
|
*/
|
|
174
|
-
_fromAxisAngle(axis_x: number, axis_y: number, axis_z: number, angle: number):
|
|
179
|
+
_fromAxisAngle(axis_x: number, axis_y: number, axis_z: number, angle: number): this;
|
|
175
180
|
/**
|
|
176
181
|
* 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
182
|
* `twist` just the twist around the given axis, no change in orientation.
|
|
@@ -189,11 +194,11 @@ export class Quaternion implements Iterable<number> {
|
|
|
189
194
|
*/
|
|
190
195
|
computeTwistAngle(axis: Vector3): number;
|
|
191
196
|
/**
|
|
192
|
-
*
|
|
193
|
-
* @param {Vector3} axis
|
|
197
|
+
* Decompose quaternion to the axis of rotation and angle around this axis.
|
|
198
|
+
* @param {Vector3} out_axis axis will be written here
|
|
194
199
|
* @returns {number} angle in radians
|
|
195
200
|
*/
|
|
196
|
-
toAxisAngle(
|
|
201
|
+
toAxisAngle(out_axis: Vector3): number;
|
|
197
202
|
/**
|
|
198
203
|
*
|
|
199
204
|
* @returns {this}
|
|
@@ -261,9 +266,15 @@ export class Quaternion implements Iterable<number> {
|
|
|
261
266
|
* @param {number} y
|
|
262
267
|
* @param {number} z
|
|
263
268
|
* @param {String} [order='XYZ'] a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
264
|
-
* @returns {
|
|
269
|
+
* @returns {this}
|
|
270
|
+
* @see fromEulerAnglesXYZ
|
|
271
|
+
* @see fromEulerAnglesYXZ
|
|
272
|
+
* @see fromEulerAnglesZXY
|
|
273
|
+
* @see fromEulerAnglesZYX
|
|
274
|
+
* @see fromEulerAnglesYZX
|
|
275
|
+
* @see fromEulerAnglesXZY
|
|
265
276
|
*/
|
|
266
|
-
__setFromEuler(x: number, y: number, z: number, order?: string):
|
|
277
|
+
__setFromEuler(x: number, y: number, z: number, order?: string): this;
|
|
267
278
|
/**
|
|
268
279
|
* @see https://localcoder.org/euler-angle-to-quaternion-then-quaternion-to-euler-angle
|
|
269
280
|
* @see https://discourse.mcneel.com/t/what-is-the-right-method-to-convert-quaternion-to-plane-using-rhinocommon/92411/21?page=2
|
|
@@ -349,18 +360,18 @@ export class Quaternion implements Iterable<number> {
|
|
|
349
360
|
/**
|
|
350
361
|
* NOTE: Vectors need to be normalized
|
|
351
362
|
*
|
|
352
|
-
* @param {Vector3} from
|
|
353
|
-
* @param {Vector3} to
|
|
363
|
+
* @param {Vector3} from Must be normalized
|
|
364
|
+
* @param {Vector3} to Must be normalized
|
|
354
365
|
* @returns {this}
|
|
355
366
|
*/
|
|
356
367
|
fromUnitVectors(from: Vector3, to: Vector3): this;
|
|
357
368
|
/**
|
|
358
|
-
* @param {number[]} m4x4
|
|
369
|
+
* @param {number[]|Float32Array} m4x4
|
|
359
370
|
* @returns {this}
|
|
360
371
|
*/
|
|
361
|
-
setFromRotationMatrix(m4x4: number[]): this;
|
|
372
|
+
setFromRotationMatrix(m4x4: number[] | Float32Array): this;
|
|
362
373
|
/**
|
|
363
|
-
* This algorithm comes from
|
|
374
|
+
* This algorithm comes from "Quaternion Calculus and Fast Animation",
|
|
364
375
|
* Ken Shoemake, 1987 SIGGRAPH course notes
|
|
365
376
|
* @see https://gitlab.com/libeigen/eigen/-/blob/master/Eigen/src/Geometry/Quaternion.h#L813
|
|
366
377
|
* @param {number} m11
|
|
@@ -395,7 +406,7 @@ export class Quaternion implements Iterable<number> {
|
|
|
395
406
|
* Spherical linear interpolation
|
|
396
407
|
* @param {Quaternion} from
|
|
397
408
|
* @param {Quaternion} to
|
|
398
|
-
* @param {number} t coefficient, how much between the input
|
|
409
|
+
* @param {number} t coefficient, how much between the input quaternions? Must be a value between 0 and 1
|
|
399
410
|
* @returns {this}
|
|
400
411
|
*/
|
|
401
412
|
slerpQuaternions(from: Quaternion, to: Quaternion, t: number): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Quaternion.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Quaternion.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;GAWG;AACH,mCALe,QAAQ,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"Quaternion.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Quaternion.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;GAWG;AACH,mCALe,QAAQ,CAAC,MAAM;IA+R1B;;;;;OAKG;IACH,2BAJW,OAAO,SACP,MAAM,GACJ,UAAU,CAQtB;IAiqCD;;;;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;IAlgDD;;;;;;;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,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAEnD;IAqCjC;;;OAGG;IACH,SAFW,MAAM,EAIhB;IAtCD;;;OAGG;IACH,SAFY,MAAM,CAIjB;IAkCD;;;OAGG;IACH,SAFW,MAA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M,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;IAt6C7B;;;OAGG;IACH,qBAFa,SAAS,CAAC,MAAM,CAAC,CAS7B;CAy4CJ;;kBASS,UAAU;kBAaV,MAAM;;;mBAzjDG,4BAA4B;oBAU3B,cAAc"}
|
|
@@ -23,7 +23,7 @@ const cos = Math.cos;
|
|
|
23
23
|
* Represents rotation in 3d space
|
|
24
24
|
*
|
|
25
25
|
* Iterating through a Quaternion instance will yield its components `(x, y, z, w)` in the corresponding order.
|
|
26
|
-
*
|
|
26
|
+
* Note that a quaternion must be {@link normalize}d to properly represent rotation. Check documentation of individual operations when in doubt.
|
|
27
27
|
* @see https://en.wikipedia.org/wiki/Quaternion
|
|
28
28
|
* @implements Iterable<number>
|
|
29
29
|
*
|
|
@@ -158,7 +158,8 @@ export class Quaternion {
|
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
160
|
* Orient quaternion on a `forward` vector, with the spin matching `up` vector
|
|
161
|
-
* Useful for `lookAt` operations, such as for camera or inverse kinematics
|
|
161
|
+
* Useful for `lookAt` operations, such as for camera or inverse kinematics.
|
|
162
|
+
* Normalizes input, meaning input does not have to be normalized.
|
|
162
163
|
* @param {number} fx forward vector
|
|
163
164
|
* @param {number} fy forward vector
|
|
164
165
|
* @param {number} fz forward vector
|
|
@@ -221,13 +222,14 @@ export class Quaternion {
|
|
|
221
222
|
}
|
|
222
223
|
|
|
223
224
|
/**
|
|
224
|
-
* Orient quaternion to align with the `forward`
|
|
225
|
-
* @param {Vector3} forward
|
|
226
|
-
* @param {Vector3} [up=Vector3.up]
|
|
225
|
+
* Orient quaternion to align with the `forward` direction.
|
|
226
|
+
* @param {Vector3} forward Does not need to be normalized.
|
|
227
|
+
* @param {Vector3} [up=Vector3.up] Does not need to be normalized.
|
|
228
|
+
* @returns {this}
|
|
227
229
|
*/
|
|
228
230
|
lookRotation(forward, up = Vector3.up) {
|
|
229
231
|
|
|
230
|
-
this._lookRotation(
|
|
232
|
+
return this._lookRotation(
|
|
231
233
|
forward.x, forward.y, forward.z,
|
|
232
234
|
up.x, up.y, up.z
|
|
233
235
|
);
|
|
@@ -250,10 +252,11 @@ export class Quaternion {
|
|
|
250
252
|
/**
|
|
251
253
|
* Makes this quaternion into an inverse of the other
|
|
252
254
|
* @param {Quaternion} other
|
|
255
|
+
* @returns {this}
|
|
253
256
|
*/
|
|
254
257
|
copyInverse(other) {
|
|
255
258
|
this.copy(other);
|
|
256
|
-
this.invert();
|
|
259
|
+
return this.invert();
|
|
257
260
|
}
|
|
258
261
|
|
|
259
262
|
/**
|
|
@@ -327,11 +330,14 @@ export class Quaternion {
|
|
|
327
330
|
* Set quaternion from axis + angle definition
|
|
328
331
|
* @param {Vector3} axis
|
|
329
332
|
* @param {number} angle
|
|
333
|
+
* @returns {this}
|
|
330
334
|
*/
|
|
331
335
|
fromAxisAngle(axis, angle) {
|
|
332
336
|
assert.defined(axis, 'axis');
|
|
337
|
+
assert.isObject(axis, 'axis');
|
|
338
|
+
assert.isNumber(angle, 'angle');
|
|
333
339
|
|
|
334
|
-
this._fromAxisAngle(axis.x, axis.y, axis.z, angle);
|
|
340
|
+
return this._fromAxisAngle(axis.x, axis.y, axis.z, angle);
|
|
335
341
|
}
|
|
336
342
|
|
|
337
343
|
/**
|
|
@@ -340,6 +346,7 @@ export class Quaternion {
|
|
|
340
346
|
* @param {number} axis_y
|
|
341
347
|
* @param {number} axis_z
|
|
342
348
|
* @param {number} angle
|
|
349
|
+
* @returns {this}
|
|
343
350
|
*/
|
|
344
351
|
_fromAxisAngle(axis_x, axis_y, axis_z, angle) {
|
|
345
352
|
assert.isNumber(axis_x, 'axis_x');
|
|
@@ -372,7 +379,7 @@ export class Quaternion {
|
|
|
372
379
|
const z = qz * m;
|
|
373
380
|
const w = qw * m;
|
|
374
381
|
|
|
375
|
-
this.set(x, y, z, w);
|
|
382
|
+
return this.set(x, y, z, w);
|
|
376
383
|
}
|
|
377
384
|
|
|
378
385
|
/**
|
|
@@ -442,25 +449,26 @@ export class Quaternion {
|
|
|
442
449
|
}
|
|
443
450
|
|
|
444
451
|
/**
|
|
445
|
-
*
|
|
446
|
-
* @param {Vector3} axis
|
|
452
|
+
* Decompose quaternion to the axis of rotation and angle around this axis.
|
|
453
|
+
* @param {Vector3} out_axis axis will be written here
|
|
447
454
|
* @returns {number} angle in radians
|
|
448
455
|
*/
|
|
449
|
-
toAxisAngle(
|
|
456
|
+
toAxisAngle(out_axis) {
|
|
450
457
|
const rad = Math.acos(this.w) * 2.0;
|
|
451
458
|
|
|
452
459
|
const s = sin(rad * 0.5);
|
|
453
460
|
|
|
454
461
|
if (Math.abs(s) > EPSILON) {
|
|
455
|
-
|
|
462
|
+
out_axis.set(
|
|
456
463
|
this.x / s,
|
|
457
464
|
this.y / s,
|
|
458
465
|
this.z / s
|
|
459
466
|
);
|
|
460
467
|
} else {
|
|
461
468
|
// If s is zero, return any axis (no rotation - axis does not matter)
|
|
462
|
-
|
|
469
|
+
out_axis.set(1, 0, 0);
|
|
463
470
|
}
|
|
471
|
+
|
|
464
472
|
return rad;
|
|
465
473
|
}
|
|
466
474
|
|
|
@@ -608,7 +616,13 @@ export class Quaternion {
|
|
|
608
616
|
* @param {number} y
|
|
609
617
|
* @param {number} z
|
|
610
618
|
* @param {String} [order='XYZ'] a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
611
|
-
* @returns {
|
|
619
|
+
* @returns {this}
|
|
620
|
+
* @see fromEulerAnglesXYZ
|
|
621
|
+
* @see fromEulerAnglesYXZ
|
|
622
|
+
* @see fromEulerAnglesZXY
|
|
623
|
+
* @see fromEulerAnglesZYX
|
|
624
|
+
* @see fromEulerAnglesYZX
|
|
625
|
+
* @see fromEulerAnglesXZY
|
|
612
626
|
*/
|
|
613
627
|
__setFromEuler(
|
|
614
628
|
x,
|
|
@@ -934,12 +948,12 @@ export class Quaternion {
|
|
|
934
948
|
/**
|
|
935
949
|
* NOTE: Vectors need to be normalized
|
|
936
950
|
*
|
|
937
|
-
* @param {Vector3} from
|
|
938
|
-
* @param {Vector3} to
|
|
951
|
+
* @param {Vector3} from Must be normalized
|
|
952
|
+
* @param {Vector3} to Must be normalized
|
|
939
953
|
* @returns {this}
|
|
940
954
|
*/
|
|
941
955
|
fromUnitVectors(from, to) {
|
|
942
|
-
// Based on blog post: http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors
|
|
956
|
+
// Based on this blog post: http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors
|
|
943
957
|
|
|
944
958
|
assert.ok(from.isNormalized(), `from vector is not normalized, length = ${from.length()}`);
|
|
945
959
|
assert.ok(to.isNormalized(), `to vector is not normalized, length = ${to.length()}`);
|
|
@@ -1005,7 +1019,7 @@ export class Quaternion {
|
|
|
1005
1019
|
}
|
|
1006
1020
|
|
|
1007
1021
|
/**
|
|
1008
|
-
* @param {number[]} m4x4
|
|
1022
|
+
* @param {number[]|Float32Array} m4x4
|
|
1009
1023
|
* @returns {this}
|
|
1010
1024
|
*/
|
|
1011
1025
|
setFromRotationMatrix(m4x4) {
|
|
@@ -1021,7 +1035,7 @@ export class Quaternion {
|
|
|
1021
1035
|
}
|
|
1022
1036
|
|
|
1023
1037
|
/**
|
|
1024
|
-
* This algorithm comes from
|
|
1038
|
+
* This algorithm comes from "Quaternion Calculus and Fast Animation",
|
|
1025
1039
|
* Ken Shoemake, 1987 SIGGRAPH course notes
|
|
1026
1040
|
* @see https://gitlab.com/libeigen/eigen/-/blob/master/Eigen/src/Geometry/Quaternion.h#L813
|
|
1027
1041
|
* @param {number} m11
|
|
@@ -1151,7 +1165,7 @@ export class Quaternion {
|
|
|
1151
1165
|
* Spherical linear interpolation
|
|
1152
1166
|
* @param {Quaternion} from
|
|
1153
1167
|
* @param {Quaternion} to
|
|
1154
|
-
* @param {number} t coefficient, how much between the input
|
|
1168
|
+
* @param {number} t coefficient, how much between the input quaternions? Must be a value between 0 and 1
|
|
1155
1169
|
* @returns {this}
|
|
1156
1170
|
*/
|
|
1157
1171
|
slerpQuaternions(from, to, t) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":"AAgBA
|
|
1
|
+
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH;IAsbI;;;;;;;;;;;;OAYG;IACH,+BAJW,MAAM,WACN,sBAAsB,GACpB,MAAM,CAqBlB;IApdD;;;;;OAKG;IACH,oBAFU,eAAe,CAES;IAGlC;;;OAGG;IACH,UAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,2BAAgB;IAShB;;;;;;OAMG;IACH,SAJU,sBAAsB,CAIjB;IAEf;;;OAGG;IACH,OAFU,WAAW,GAAC,MAAM,CAEN;IAEtB;;;;OAIG;IACH,yBAAgB;IAEhB;;OAEG;IACH;QACI;;WAEG;;MAEL;IAUF;;;OAGG;IACH,eAFW,MAAM,GAAC,WAAW,QAI5B;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,WAAW,GAChB,OAAO,CAMnB;IAED;;;OAGG;IACH,gBAFW,MAAM,GAAC,WAAW,QAI5B;IAED;;;;;;;OAOG;IACH,wBALa,OAAO,CAOnB;IAED;;OAEG;IACH,4BAQC;IAED;;;OAGG;IACH,aAFY,MAAM,CAIjB;IAED;;;;;;OAMG;IACH,IAJa,CAAC,sBACH,CAAC,GACC,MAAM,CAsBlB;IAED;;;;;OAKG;IACH,aAJa,CAAC,SACH,CAAC,GACC,OAAO,CAInB;IAED;;;;OAIG;IACH,aAJa,CAAC,SACH,KAAK,CAAC,CAAC,CAAC,GACN,CAAC,GAAC,IAAI,CAclB;IAED;;;;;OAKG;IACH,iBAJa,CAAC,SACH,KAAK,CAAC,CAAC,CAAC,GACN,CAAC,CAUb;IAED;;;;OAIG;IACH,kCAFa,GAAC,GAAC,IAAI,CA0BlB;IAED;;;;OAIG;IACH,qBAHW,MAAM,UACN,GAAC,QAQX;IAED;;;OAGG;IACH,wBAFW,MAAM,gBAiBhB;IAED;;;;;;OAMG;IACH,4BALW,MAAM,gCAEN,GAAC,GACC,MAAM,CAalB;IAED;;;;;;OAMG;IACH,+BALW,MAAM,gCAEN,GAAC,GACC,MAAM,CAyBlB;IAED;;;;;;OAMG;IACH,WAJa,OAAO,CA0BnB;IAED;;;;;;;;;;;;;;;OAeG;IACH,eALW,sBAAsB,GADpB,MAAM,CA+DlB;IAqCL;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;;CAPxB;;gCAhgB+B,sBAAsB;4BAD1B,kBAAkB;mBAF3B,oCAAoC"}
|
package/src/engine/ecs/Entity.js
CHANGED
|
@@ -39,6 +39,7 @@ const DEFAULT_FLAGS =
|
|
|
39
39
|
* // ... Once entity is no longer needed, we destroy it
|
|
40
40
|
* entity.destroy();
|
|
41
41
|
*
|
|
42
|
+
* @see {@link EntityComponentDataset}
|
|
42
43
|
* @author Alex Goldring
|
|
43
44
|
* @copyright Company Named Limited (c) 2025
|
|
44
45
|
*/
|
|
@@ -46,7 +47,7 @@ export class Entity {
|
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* Reference to the entity in a dataset. Do not modify directly.
|
|
49
|
-
* Only valid when the entity is built
|
|
50
|
+
* Only valid when the entity is built, check with {@link isBuilt}.
|
|
50
51
|
* @readonly
|
|
51
52
|
* @type {EntityReference}
|
|
52
53
|
*/
|
|
@@ -78,6 +79,7 @@ export class Entity {
|
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
81
|
* Listeners added before the entity is build live here
|
|
82
|
+
* @private
|
|
81
83
|
* @type {{name:string,listener:(function|Function), context:*}[]}
|
|
82
84
|
*/
|
|
83
85
|
#deferredListeners = [];
|
|
@@ -86,17 +88,19 @@ export class Entity {
|
|
|
86
88
|
* Dataset in which this entity exists, if built. If not built - null.
|
|
87
89
|
* Do not modify directly.
|
|
88
90
|
* @type {EntityComponentDataset}
|
|
91
|
+
* @see {@link build}
|
|
92
|
+
* @see {@link destroy}
|
|
89
93
|
*/
|
|
90
94
|
dataset = null;
|
|
91
95
|
|
|
92
96
|
/**
|
|
93
|
-
*
|
|
97
|
+
* Do not modify directly unless you understand the consequences of doing so.
|
|
94
98
|
* @type {EntityFlags|number}
|
|
95
99
|
*/
|
|
96
100
|
flags = DEFAULT_FLAGS;
|
|
97
101
|
|
|
98
102
|
/**
|
|
99
|
-
* Arbitrary user
|
|
103
|
+
* Arbitrary user data, add anything you want here.
|
|
100
104
|
* @readonly
|
|
101
105
|
* @type {Object}
|
|
102
106
|
*/
|
|
@@ -148,8 +152,12 @@ export class Entity {
|
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
/**
|
|
155
|
+
* True is the entity is currently attached to a dataset. When this is `true`, {@link dataset} property will be set as well.
|
|
151
156
|
* @readonly
|
|
152
157
|
* @returns {boolean}
|
|
158
|
+
* @see {@link build}
|
|
159
|
+
* @see {@link destroy}
|
|
160
|
+
*
|
|
153
161
|
*/
|
|
154
162
|
get isBuilt() {
|
|
155
163
|
return this.getFlag(EntityFlags.Built);
|
|
@@ -177,35 +185,38 @@ export class Entity {
|
|
|
177
185
|
}
|
|
178
186
|
|
|
179
187
|
/**
|
|
180
|
-
* @
|
|
181
|
-
*
|
|
188
|
+
* Note that this is live-edit, if the {@link Entity} is built - component will be added to the dataset as well.
|
|
189
|
+
*
|
|
190
|
+
* @template T class of the component
|
|
191
|
+
* @param {T} component_instance
|
|
182
192
|
* @returns {Entity}
|
|
183
193
|
*/
|
|
184
|
-
add(
|
|
185
|
-
assert.defined(
|
|
186
|
-
assert.notNull(
|
|
194
|
+
add(component_instance) {
|
|
195
|
+
assert.defined(component_instance, 'component_instance');
|
|
196
|
+
assert.notNull(component_instance, 'component_instance');
|
|
187
197
|
|
|
188
|
-
assert.notOk(this.hasComponent(Object.getPrototypeOf(
|
|
198
|
+
assert.notOk(this.hasComponent(Object.getPrototypeOf(component_instance).constructor), 'Component of this type already exists');
|
|
189
199
|
|
|
190
|
-
this.components.push(
|
|
200
|
+
this.components.push(component_instance);
|
|
191
201
|
|
|
192
202
|
if (this.getFlag(EntityFlags.Built)) {
|
|
193
203
|
|
|
194
204
|
//already built, add component to entity
|
|
195
205
|
|
|
196
206
|
if (this.getFlag(EntityFlags.RegisterComponents)) {
|
|
197
|
-
this.dataset.registerComponentType(
|
|
207
|
+
this.dataset.registerComponentType(component_instance.constructor)
|
|
198
208
|
}
|
|
199
209
|
|
|
200
|
-
this.dataset.addComponentToEntity(this.reference.id,
|
|
210
|
+
this.dataset.addComponentToEntity(this.reference.id, component_instance);
|
|
201
211
|
}
|
|
202
212
|
|
|
203
213
|
return this;
|
|
204
214
|
}
|
|
205
215
|
|
|
206
216
|
/**
|
|
217
|
+
* Check if a component of a given type is present on this entity.
|
|
207
218
|
* @template T
|
|
208
|
-
* @param {T} klass
|
|
219
|
+
* @param {T} klass type of the component
|
|
209
220
|
* @returns {boolean}
|
|
210
221
|
*/
|
|
211
222
|
hasComponent(klass) {
|
|
@@ -214,7 +225,7 @@ export class Entity {
|
|
|
214
225
|
|
|
215
226
|
/**
|
|
216
227
|
* @template T
|
|
217
|
-
* @param {Class<T>} klass
|
|
228
|
+
* @param {Class<T>} klass type of the component
|
|
218
229
|
* @returns {T|null} component of specified class
|
|
219
230
|
*/
|
|
220
231
|
getComponent(klass) {
|
|
@@ -248,7 +259,7 @@ export class Entity {
|
|
|
248
259
|
}
|
|
249
260
|
|
|
250
261
|
/**
|
|
251
|
-
*
|
|
262
|
+
* Note that this is live-edit, if the {@link Entity} is built - component will be removed from the dataset as well.
|
|
252
263
|
* @param {function} klass
|
|
253
264
|
* @returns {*|null}
|
|
254
265
|
*/
|
|
@@ -365,8 +376,11 @@ export class Entity {
|
|
|
365
376
|
}
|
|
366
377
|
|
|
367
378
|
/**
|
|
368
|
-
* Removes built entity from the {@link EntityManager}.
|
|
379
|
+
* Removes built entity from the {@link EntityManager}.
|
|
380
|
+
* Note that the destroyed {@link Entity} can be later re-built.
|
|
369
381
|
* @returns {boolean} true if entity was destroyed, false if entity was not built
|
|
382
|
+
* @see {@link build}
|
|
383
|
+
* @see {@link isBuilt}
|
|
370
384
|
*/
|
|
371
385
|
destroy() {
|
|
372
386
|
if (!this.getFlag(EntityFlags.Built)) {
|
|
@@ -404,6 +418,9 @@ export class Entity {
|
|
|
404
418
|
*
|
|
405
419
|
* @returns {number} entity ID
|
|
406
420
|
* @param {EntityComponentDataset} dataset
|
|
421
|
+
* @see {@link destroy}
|
|
422
|
+
* @see {@link isBuilt}
|
|
423
|
+
*
|
|
407
424
|
*/
|
|
408
425
|
build(dataset) {
|
|
409
426
|
assert.defined(dataset, "dataset");
|
|
@@ -466,6 +483,7 @@ export class Entity {
|
|
|
466
483
|
|
|
467
484
|
/**
|
|
468
485
|
* Extract data about an entity and its components from a dataset.
|
|
486
|
+
* Note that this behaves the same way as if you first created the {@link Entity} and then called {@link build} on it, just the other way around.
|
|
469
487
|
*
|
|
470
488
|
* @example
|
|
471
489
|
* const ecd:EntityComponentDataset = ...;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* // 4. After you no longer need the entity - destroy the entity via reference.
|
|
15
15
|
* entityRef.destroy(ecd);
|
|
16
16
|
*
|
|
17
|
+
* @see {@link EntityComponentDataset}
|
|
17
18
|
* @author Alex Goldring
|
|
18
19
|
* @copyright Company Named Limited (c) 2025
|
|
19
20
|
*/
|
|
@@ -41,7 +42,7 @@ export class EntityReference {
|
|
|
41
42
|
/**
|
|
42
43
|
* Entity generation number. This uniquely identifies an entity in combination with the ID
|
|
43
44
|
* Generation of an existing entity must match for it to be considered "the same".
|
|
44
|
-
* see {@link EntityComponentDataset.getEntityGeneration}
|
|
45
|
+
* @see {@link EntityComponentDataset.getEntityGeneration}
|
|
45
46
|
* @type {number}
|
|
46
47
|
*/
|
|
47
48
|
generation: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityReference.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityReference.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"EntityReference.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityReference.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAsHI;;;;;OAKG;IACH,gBAJW,MAAM,cACN,MAAM,GACL,eAAe,CAQ1B;IAED;;;;;OAKG;IACH,iBAJW,sBAAsB,MACtB,MAAM,GACJ,eAAe,CAQ3B;IA9ID;;;;OAIG;IACH,IAFU,MAAM,CAET;IAEP;;;;;OAKG;IACH,YAFU,MAAM,CAED;IAEf;;;OAGG;IACH,YAFW,eAAe,QAKzB;IAED;;;OAGG;IACH,SAFa,eAAe,CAQ3B;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,cAHW,eAAe,GACd,OAAO,CAMlB;IAED;;;;OAIG;IACH,YAHW,sBAAsB,GACpB,OAAO,CAYnB;IAED;;;;;OAKG;IACH,aAHW,sBAAsB,GACpB,OAAO,CASnB;IAED;;;;OAIG;IACH,UAHW,sBAAsB,UACtB,MAAM,QAShB;IAED;;;;OAIG;IACH,SAHW,MAAM,cACN,MAAM,QAUhB;IA+BL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;;cAWS,eAAe"}
|
|
@@ -16,6 +16,7 @@ import { assert } from "../../core/assert.js";
|
|
|
16
16
|
* // 4. After you no longer need the entity - destroy the entity via reference.
|
|
17
17
|
* entityRef.destroy(ecd);
|
|
18
18
|
*
|
|
19
|
+
* @see {@link EntityComponentDataset}
|
|
19
20
|
* @author Alex Goldring
|
|
20
21
|
* @copyright Company Named Limited (c) 2025
|
|
21
22
|
*/
|
|
@@ -31,7 +32,7 @@ export class EntityReference {
|
|
|
31
32
|
/**
|
|
32
33
|
* Entity generation number. This uniquely identifies an entity in combination with the ID
|
|
33
34
|
* Generation of an existing entity must match for it to be considered "the same".
|
|
34
|
-
* see {@link EntityComponentDataset.getEntityGeneration}
|
|
35
|
+
* @see {@link EntityComponentDataset.getEntityGeneration}
|
|
35
36
|
* @type {number}
|
|
36
37
|
*/
|
|
37
38
|
generation = -1
|
|
@@ -62,7 +63,7 @@ export class EntityReference {
|
|
|
62
63
|
* @return {number}
|
|
63
64
|
*/
|
|
64
65
|
hash() {
|
|
65
|
-
return this.id ^ this.generation;
|
|
66
|
+
return (this.id * 31) ^ this.generation;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/**
|
|
@@ -173,7 +174,7 @@ export class EntityReference {
|
|
|
173
174
|
EntityReference.prototype.isEntityReference = true;
|
|
174
175
|
|
|
175
176
|
/**
|
|
176
|
-
* Special singleton to describe an invalid reference
|
|
177
|
+
* Special utility singleton to describe an invalid reference.
|
|
177
178
|
* @readonly
|
|
178
179
|
* @type {EntityReference}
|
|
179
180
|
*/
|