@woosh/meep-engine 2.120.1 → 2.120.2
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/2d/circle/Circle.d.ts +7 -5
- package/src/core/geom/2d/circle/Circle.d.ts.map +1 -1
- package/src/core/geom/2d/circle/Circle.js +7 -5
- package/src/core/geom/2d/circle/circle_area.d.ts +7 -0
- package/src/core/geom/2d/circle/circle_area.d.ts.map +1 -0
- package/src/core/geom/2d/circle/circle_area.js +8 -0
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +57 -23
- package/src/engine/ecs/Entity.js +2 -2
- package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
- package/src/engine/ecs/EntityComponentDataset.js +31 -13
- package/src/engine/ecs/EntityManager.d.ts.map +1 -1
- package/src/engine/ecs/EntityManager.js +10 -1
- package/src/engine/ecs/EntityObserver.d.ts.map +1 -1
- package/src/engine/ecs/EntityObserver.js +2 -10
- package/src/engine/ecs/EntityReference.d.ts +10 -2
- package/src/engine/ecs/EntityReference.d.ts.map +1 -1
- package/src/engine/ecs/EntityReference.js +24 -6
- package/src/engine/ecs/terrain/ecs/Terrain.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.d.ts +349 -50
- package/src/engine/intelligence/behavior/ecs/DieBehavior.d.ts +3 -0
- package/src/engine/intelligence/behavior/ecs/DieBehavior.d.ts.map +1 -1
- package/src/engine/intelligence/behavior/ecs/DieBehavior.js +4 -0
- package/src/engine/intelligence/behavior/ecs/KillBehavior.d.ts +17 -0
- package/src/engine/intelligence/behavior/ecs/KillBehavior.d.ts.map +1 -0
- package/src/engine/intelligence/behavior/ecs/KillBehavior.js +47 -0
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.d.ts +7 -6
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.d.ts.map +1 -1
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.js +51 -43
- package/editor/actions/concrete/ModifyPatchSampler2DAction.d.ts +0 -48
- package/editor/actions/concrete/ModifyPatchTextureArray2DAction.d.ts.map +0 -1
- package/editor/actions/concrete/PaintTerrainOverlayAction.d.ts.map +0 -1
- package/editor/actions/concrete/PatchTerrainHeightAction.d.ts.map +0 -1
- package/editor/actions/concrete/SelectionAddAction.d.ts.map +0 -1
- package/editor/actions/concrete/SelectionClearAction.d.ts.map +0 -1
- package/editor/actions/concrete/SelectionRemoveAction.d.ts.map +0 -1
- package/editor/actions/concrete/TransformModifyAction.d.ts.map +0 -1
- package/editor/actions/concrete/WriteGridValueAction.d.ts.map +0 -1
- package/src/engine/ecs/read_entity_reference.d.ts +0 -9
- package/src/engine/ecs/read_entity_reference.d.ts.map +0 -1
- package/src/engine/ecs/read_entity_reference.js +0 -15
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export default Circle;
|
|
2
|
+
/**
|
|
3
|
+
* A circle or a 2-dimensional sphere. Represented as a position (x,y) and radius (r)
|
|
4
|
+
*/
|
|
2
5
|
declare class Circle {
|
|
3
6
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
8
|
-
* @constructor
|
|
7
|
+
*
|
|
8
|
+
* @param {number} [x=0]
|
|
9
|
+
* @param {number} [y=0]
|
|
10
|
+
* @param {number} [r=0] radius
|
|
9
11
|
*/
|
|
10
12
|
constructor(x?: number, y?: number, r?: number);
|
|
11
13
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/circle/Circle.js"],"names":[],"mappings":";AAEA;IACI
|
|
1
|
+
{"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/circle/Circle.js"],"names":[],"mappings":";AAEA;;GAEG;AACH;IACI;;;;;OAKG;IACH,gBAJW,MAAM,MACN,MAAM,MACN,MAAM,EAoBhB;IAjBG;;;OAGG;IACH,UAAU;IAEV;;;OAGG;IACH,UAAU;IAEV;;;OAGG;IACH,UAAU;IAGd;;;OAGG;IACH,qBAFW,OAAO,QAIjB;IAED;;;;OAIG;IACH,2CAGC;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,OAAO,CAYnB;IAED;;;;OAIG;IACH,cAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;OAKG;IACH,OAJW,MAAM,KACN,MAAM,KACN,MAAM,QAOhB;IAED;;;OAGG;IACH,YAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,SAFa,MAAM,CAIlB;CACJ"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { circle_intersects_circle } from "./circle_intersects_circle.js";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A circle or a 2-dimensional sphere. Represented as a position (x,y) and radius (r)
|
|
5
|
+
*/
|
|
3
6
|
class Circle {
|
|
4
7
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
9
|
-
* @constructor
|
|
8
|
+
*
|
|
9
|
+
* @param {number} [x=0]
|
|
10
|
+
* @param {number} [y=0]
|
|
11
|
+
* @param {number} [r=0] radius
|
|
10
12
|
*/
|
|
11
13
|
constructor(x = 0, y = 0, r = 0) {
|
|
12
14
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circle_area.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/circle/circle_area.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oCAHW,MAAM,GACJ,MAAM,CAIlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Quaternion.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Quaternion.js"],"names":[],"mappings":";AAqBA;IAqOI;;;;;OAKG;IACH,2BAJW,OAAO,SACP,MAAM,GACJ,UAAU,CAQtB;
|
|
1
|
+
{"version":3,"file":"Quaternion.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Quaternion.js"],"names":[],"mappings":";AAqBA;;;GAGG;AACH;IAqOI;;;;;OAKG;IACH,2BAJW,OAAO,SACP,MAAM,GACJ,UAAU,CAQtB;IAunCD;;;;OAIG;IACH,kCAFa,UAAU,CAQtB;IAED;;;;;;OAMG;IACH,0BALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,UAAU,CAQtB;IAED;;;;;;OAMG;IACH,6BALW,UAAU,QACV,UAAU,MACV,UAAU,aACV,MAAM,QAkBhB;IA15CD;;;;;;;OAOG;IACH,gBANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,EA+BhB;IA1BG;;;OAGG;IACH,GAFU,MAAM,CAEN;IACV;;;OAGG;IACH,GAFU,MAAM,CAEN;IACV;;;OAGG;IACH,GAFU,MAAM,CAEN;IACV;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,oBAFU,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAEnD;IAqBjC,iBAEC;IAlBD,gBAEC;IAkBD,iBAEC;IAlBD,gBAEC;IAkBD,iBAEC;IAlBD,gBAEC;IAkBD,iBAEC;IAlBD,gBAEC;IA+BD;;;;;;;;OAQG;IACH,kBAPW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAiDhB;IAED;;;;;OAKG;IACH,uBAJW,OAAO,QACP,OAAO,QAMjB;IAED;;;;OAIG;IACH,WAHW,UAAU,GACT,MAAM,CAQjB;IAED;;;OAGG;IACH,mBAFW,UAAU,QAKpB;IAED;;OAEG;IACH,eAqBC;IAED;;;;OAIG;IACH,eAHW,UAAU,GACT,MAAM,CAoBjB;IAiBD;;;;OAIG;IACH,oBAHW,OAAO,SACP,MAAM,QAMhB;IAED;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AM,CAIlB;IAED;;;;OAIG;IACH,qBAHW,MAAM,EAAE,WACR,MAAM,QAShB;IAED;;;;;OAKG;IACH,qBAJW,MAAM,EAAE,WACR,MAAM,GACJ,MAAM,EAAE,CASpB;IAED;;;;OAIG;IACH,cAHW,UAAU,GACR,OAAO,CAQnB;IAED;;;OAGG;IACH,QAFa,MAAM,CAQlB;IAED;;;;;OAKG;IACH,qBAJW,UAAU,cACV,MAAM,GACL,OAAO,CAIlB;IAED;;;;;;;;;OASG;IACH,uBAKC;IAED;;;;OAIG;IACH,gBAHW,MAAW,MAAM,GAChB,UAAU,CAkBrB;IAED,mBAEC;IAwDL,mBAhKe,MAAM,EAAE,WACR,MAAM,UA+JS;IAC9B,kBAnJe,MAAM,EAAE,WACR,MAAM,KACJ,MAAM,EAAE,CAiJG;IAC5B,kBApJe,MAAM,EAAE,WACR,MAAM,KACJ,MAAM,EAAE,CAkJG;IAC5B,qBAtxBe,MAAM,KACN,MAAM,KACN,MAAM,gBAoxBe;IAx1ChC;;OAEG;IACH,sDAOC;CAy0CJ;;kBASS,UAAU;;mBA77CD,4BAA4B;oBAW3B,cAAc"}
|
|
@@ -19,6 +19,10 @@ const scratch_v3_c = new Vector3();
|
|
|
19
19
|
const sin = Math.sin;
|
|
20
20
|
const cos = Math.cos;
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Rotation representation in 3d space
|
|
24
|
+
* @see https://en.wikipedia.org/wiki/Quaternion
|
|
25
|
+
*/
|
|
22
26
|
class Quaternion {
|
|
23
27
|
/**
|
|
24
28
|
*
|
|
@@ -268,6 +272,8 @@ class Quaternion {
|
|
|
268
272
|
* @param {number} angle
|
|
269
273
|
*/
|
|
270
274
|
fromAxisAngle(axis, angle) {
|
|
275
|
+
assert.defined(axis,'axis');
|
|
276
|
+
|
|
271
277
|
this._fromAxisAngle(axis.x, axis.y, axis.z, angle);
|
|
272
278
|
}
|
|
273
279
|
|
|
@@ -384,6 +390,10 @@ class Quaternion {
|
|
|
384
390
|
return rad;
|
|
385
391
|
}
|
|
386
392
|
|
|
393
|
+
/**
|
|
394
|
+
*
|
|
395
|
+
* @returns {this}
|
|
396
|
+
*/
|
|
387
397
|
normalize() {
|
|
388
398
|
let l = this.length();
|
|
389
399
|
|
|
@@ -395,12 +405,14 @@ class Quaternion {
|
|
|
395
405
|
const m = 1 / l;
|
|
396
406
|
this.multiplyScalar(m);
|
|
397
407
|
}
|
|
408
|
+
|
|
409
|
+
return this;
|
|
398
410
|
}
|
|
399
411
|
|
|
400
412
|
/**
|
|
401
413
|
*
|
|
402
414
|
* @param {number} val
|
|
403
|
-
* @return {
|
|
415
|
+
* @return {this}
|
|
404
416
|
*/
|
|
405
417
|
multiplyScalar(val) {
|
|
406
418
|
return this.set(
|
|
@@ -413,15 +425,17 @@ class Quaternion {
|
|
|
413
425
|
|
|
414
426
|
/**
|
|
415
427
|
* @param {Quaternion} other
|
|
428
|
+
* @returns {this}
|
|
416
429
|
*/
|
|
417
430
|
multiply(other) {
|
|
418
|
-
this.multiplyQuaternions(this, other);
|
|
431
|
+
return this.multiplyQuaternions(this, other);
|
|
419
432
|
}
|
|
420
433
|
|
|
421
434
|
/**
|
|
422
435
|
*
|
|
423
436
|
* @param {Quaternion} first
|
|
424
437
|
* @param {Quaternion} second
|
|
438
|
+
* @returns {this}
|
|
425
439
|
*/
|
|
426
440
|
multiplyQuaternions(first, second) {
|
|
427
441
|
const aX = first.x;
|
|
@@ -434,7 +448,7 @@ class Quaternion {
|
|
|
434
448
|
const bZ = second.z;
|
|
435
449
|
const bW = second.w;
|
|
436
450
|
|
|
437
|
-
this._multiplyQuaternions(aX, aY, aZ, aW, bX, bY, bZ, bW)
|
|
451
|
+
return this._multiplyQuaternions(aX, aY, aZ, aW, bX, bY, bZ, bW)
|
|
438
452
|
}
|
|
439
453
|
|
|
440
454
|
/**
|
|
@@ -447,9 +461,12 @@ class Quaternion {
|
|
|
447
461
|
* @param {number} by
|
|
448
462
|
* @param {number} bz
|
|
449
463
|
* @param {number} bw
|
|
450
|
-
* @
|
|
464
|
+
* @returns {this}
|
|
451
465
|
*/
|
|
452
|
-
_multiplyQuaternions(
|
|
466
|
+
_multiplyQuaternions(
|
|
467
|
+
ax, ay, az, aw,
|
|
468
|
+
bx, by, bz, bw
|
|
469
|
+
) {
|
|
453
470
|
|
|
454
471
|
// see http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
|
|
455
472
|
|
|
@@ -478,9 +495,12 @@ class Quaternion {
|
|
|
478
495
|
*
|
|
479
496
|
* @param {Quaternion} other
|
|
480
497
|
* @param {number} max_delta in radians
|
|
498
|
+
* @returns {this}
|
|
481
499
|
*/
|
|
482
500
|
rotateTowards(other, max_delta) {
|
|
483
501
|
Quaternion.rotateTowards(this, this, other, max_delta);
|
|
502
|
+
|
|
503
|
+
return this;
|
|
484
504
|
}
|
|
485
505
|
|
|
486
506
|
/**
|
|
@@ -504,9 +524,11 @@ class Quaternion {
|
|
|
504
524
|
* @param {function():number} random
|
|
505
525
|
*/
|
|
506
526
|
setRandom(random) {
|
|
527
|
+
assert.isFunction(random,'random');
|
|
528
|
+
|
|
507
529
|
this.set(random(), random(), random(), random());
|
|
508
530
|
|
|
509
|
-
this.normalize();
|
|
531
|
+
return this.normalize();
|
|
510
532
|
}
|
|
511
533
|
|
|
512
534
|
/**
|
|
@@ -655,6 +677,7 @@ class Quaternion {
|
|
|
655
677
|
* @param {number} x angle in X axis in radians
|
|
656
678
|
* @param {number} y angle in Y axis in radians
|
|
657
679
|
* @param {number} z angle in Z axis in radians
|
|
680
|
+
* @returns {this}
|
|
658
681
|
*/
|
|
659
682
|
fromEulerAnglesXYZ(x, y, z) {
|
|
660
683
|
const half_x = x * 0.5;
|
|
@@ -674,7 +697,7 @@ class Quaternion {
|
|
|
674
697
|
const _z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
675
698
|
const _w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
676
699
|
|
|
677
|
-
this.set(_x, _y, _z, _w);
|
|
700
|
+
return this.set(_x, _y, _z, _w);
|
|
678
701
|
}
|
|
679
702
|
|
|
680
703
|
/**
|
|
@@ -685,6 +708,7 @@ class Quaternion {
|
|
|
685
708
|
* @param {number} x angle in X axis in radians
|
|
686
709
|
* @param {number} y angle in Y axis in radians
|
|
687
710
|
* @param {number} z angle in Z axis in radians
|
|
711
|
+
* @returns {this}
|
|
688
712
|
*/
|
|
689
713
|
fromEulerAnglesYXZ(x, y, z) {
|
|
690
714
|
const scaled_x = x * 0.5;
|
|
@@ -704,7 +728,7 @@ class Quaternion {
|
|
|
704
728
|
const _z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
705
729
|
const _w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
706
730
|
|
|
707
|
-
this.set(_x, _y, _z, _w);
|
|
731
|
+
return this.set(_x, _y, _z, _w);
|
|
708
732
|
}
|
|
709
733
|
|
|
710
734
|
/**
|
|
@@ -715,6 +739,7 @@ class Quaternion {
|
|
|
715
739
|
* @param {number} x angle in X axis in radians
|
|
716
740
|
* @param {number} y angle in Y axis in radians
|
|
717
741
|
* @param {number} z angle in Z axis in radians
|
|
742
|
+
* @returns {this}
|
|
718
743
|
*/
|
|
719
744
|
fromEulerAnglesZXY(x, y, z) {
|
|
720
745
|
const scaled_x = x * 0.5;
|
|
@@ -734,7 +759,7 @@ class Quaternion {
|
|
|
734
759
|
const _z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
735
760
|
const _w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
736
761
|
|
|
737
|
-
this.set(_x, _y, _z, _w);
|
|
762
|
+
return this.set(_x, _y, _z, _w);
|
|
738
763
|
}
|
|
739
764
|
|
|
740
765
|
/**
|
|
@@ -745,6 +770,7 @@ class Quaternion {
|
|
|
745
770
|
* @param {number} x angle in X axis in radians
|
|
746
771
|
* @param {number} y angle in Y axis in radians
|
|
747
772
|
* @param {number} z angle in Z axis in radians
|
|
773
|
+
* @returns {this}
|
|
748
774
|
*/
|
|
749
775
|
fromEulerAnglesZYX(x, y, z) {
|
|
750
776
|
const scaled_x = x * 0.5;
|
|
@@ -764,7 +790,7 @@ class Quaternion {
|
|
|
764
790
|
const _z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
765
791
|
const _w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
766
792
|
|
|
767
|
-
this.set(_x, _y, _z, _w);
|
|
793
|
+
return this.set(_x, _y, _z, _w);
|
|
768
794
|
}
|
|
769
795
|
|
|
770
796
|
/**
|
|
@@ -775,6 +801,7 @@ class Quaternion {
|
|
|
775
801
|
* @param {number} x angle in X axis in radians
|
|
776
802
|
* @param {number} y angle in Y axis in radians
|
|
777
803
|
* @param {number} z angle in Z axis in radians
|
|
804
|
+
* @returns {this}
|
|
778
805
|
*/
|
|
779
806
|
fromEulerAnglesYZX(x, y, z) {
|
|
780
807
|
const scaled_x = x * 0.5;
|
|
@@ -794,7 +821,7 @@ class Quaternion {
|
|
|
794
821
|
const _z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
795
822
|
const _w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
796
823
|
|
|
797
|
-
this.set(_x, _y, _z, _w);
|
|
824
|
+
return this.set(_x, _y, _z, _w);
|
|
798
825
|
}
|
|
799
826
|
|
|
800
827
|
/**
|
|
@@ -805,6 +832,7 @@ class Quaternion {
|
|
|
805
832
|
* @param {number} x angle in X axis in radians
|
|
806
833
|
* @param {number} y angle in Y axis in radians
|
|
807
834
|
* @param {number} z angle in Z axis in radians
|
|
835
|
+
* @returns {this}
|
|
808
836
|
*/
|
|
809
837
|
fromEulerAnglesXZY(x, y, z) {
|
|
810
838
|
const scaled_x = x * 0.5;
|
|
@@ -824,7 +852,7 @@ class Quaternion {
|
|
|
824
852
|
const _z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
825
853
|
const _w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
826
854
|
|
|
827
|
-
this.set(_x, _y, _z, _w);
|
|
855
|
+
return this.set(_x, _y, _z, _w);
|
|
828
856
|
}
|
|
829
857
|
|
|
830
858
|
/**
|
|
@@ -832,6 +860,7 @@ class Quaternion {
|
|
|
832
860
|
* Based on blog post: http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors
|
|
833
861
|
* @param {Vector3} from
|
|
834
862
|
* @param {Vector3} to
|
|
863
|
+
* @returns {this}
|
|
835
864
|
*/
|
|
836
865
|
fromUnitVectors(from, to) {
|
|
837
866
|
assert.ok(from.isNormalized(), `from vector is not normalized, length = ${from.length()}`);
|
|
@@ -890,7 +919,7 @@ class Quaternion {
|
|
|
890
919
|
const wZ = inv_m * crossZ;
|
|
891
920
|
|
|
892
921
|
|
|
893
|
-
this.set(
|
|
922
|
+
return this.set(
|
|
894
923
|
wX,
|
|
895
924
|
wY,
|
|
896
925
|
wZ,
|
|
@@ -900,12 +929,13 @@ class Quaternion {
|
|
|
900
929
|
|
|
901
930
|
/**
|
|
902
931
|
* @param {number[]} m4x4
|
|
932
|
+
* @returns {this}
|
|
903
933
|
*/
|
|
904
934
|
setFromRotationMatrix(m4x4) {
|
|
905
935
|
assert.defined(m4x4, 'm4x4');
|
|
906
936
|
assert.isArrayLike(m4x4, 'm4x4');
|
|
907
937
|
|
|
908
|
-
this.__setFromRotationMatrix(
|
|
938
|
+
return this.__setFromRotationMatrix(
|
|
909
939
|
m4x4[0], m4x4[4], m4x4[8],
|
|
910
940
|
m4x4[1], m4x4[5], m4x4[9],
|
|
911
941
|
m4x4[2], m4x4[6], m4x4[10]
|
|
@@ -926,7 +956,7 @@ class Quaternion {
|
|
|
926
956
|
* @param {number} m31
|
|
927
957
|
* @param {number} m32
|
|
928
958
|
* @param {number} m33
|
|
929
|
-
* @returns {
|
|
959
|
+
* @returns {this}
|
|
930
960
|
*/
|
|
931
961
|
__setFromRotationMatrix(
|
|
932
962
|
m11, m12, m13,
|
|
@@ -1008,18 +1038,21 @@ class Quaternion {
|
|
|
1008
1038
|
* Linear interpolation
|
|
1009
1039
|
* @param {Quaternion} other
|
|
1010
1040
|
* @param {number} t fractional value between 0 and 1
|
|
1041
|
+
* @returns {this}
|
|
1011
1042
|
*/
|
|
1012
1043
|
lerp(other, t) {
|
|
1013
1044
|
|
|
1014
|
-
this.lerpQuaternions(this, other, t);
|
|
1045
|
+
return this.lerpQuaternions(this, other, t);
|
|
1015
1046
|
|
|
1016
1047
|
}
|
|
1017
1048
|
|
|
1018
1049
|
/**
|
|
1019
|
-
*
|
|
1050
|
+
* Linear interpolation of two quaternions
|
|
1051
|
+
* Pretty good, not as good as slerp, but close enough for most application
|
|
1020
1052
|
* @param {Quaternion} first
|
|
1021
1053
|
* @param {Quaternion} second
|
|
1022
1054
|
* @param {number} t
|
|
1055
|
+
* @returns {this}
|
|
1023
1056
|
*/
|
|
1024
1057
|
lerpQuaternions(first, second, t) {
|
|
1025
1058
|
|
|
@@ -1034,7 +1067,7 @@ class Quaternion {
|
|
|
1034
1067
|
const w = lerp(first.w, second.w, t);
|
|
1035
1068
|
|
|
1036
1069
|
|
|
1037
|
-
|
|
1070
|
+
return this.set(x, y, z, w);
|
|
1038
1071
|
}
|
|
1039
1072
|
|
|
1040
1073
|
/**
|
|
@@ -1042,6 +1075,7 @@ class Quaternion {
|
|
|
1042
1075
|
* @param {Quaternion} from
|
|
1043
1076
|
* @param {Quaternion} to
|
|
1044
1077
|
* @param {number} t coefficient, how much between the input quats?
|
|
1078
|
+
* @returns {this}
|
|
1045
1079
|
*/
|
|
1046
1080
|
slerpQuaternions(from, to, t) {
|
|
1047
1081
|
assert.isNumber(t, 't');
|
|
@@ -1095,7 +1129,7 @@ class Quaternion {
|
|
|
1095
1129
|
const _z = scale0 * az + scale1 * bz;
|
|
1096
1130
|
const _w = scale0 * aw + scale1 * bw;
|
|
1097
1131
|
|
|
1098
|
-
this.set(_x, _y, _z, _w);
|
|
1132
|
+
return this.set(_x, _y, _z, _w);
|
|
1099
1133
|
}
|
|
1100
1134
|
|
|
1101
1135
|
|
|
@@ -1110,7 +1144,7 @@ class Quaternion {
|
|
|
1110
1144
|
|
|
1111
1145
|
/**
|
|
1112
1146
|
*
|
|
1113
|
-
* @param {function} handler
|
|
1147
|
+
* @param {function(x:number,y:number,z:number,w:number)} handler
|
|
1114
1148
|
*/
|
|
1115
1149
|
process(handler) {
|
|
1116
1150
|
handler(this.x, this.y, this.z, this.w);
|
|
@@ -1121,7 +1155,7 @@ class Quaternion {
|
|
|
1121
1155
|
/**
|
|
1122
1156
|
*
|
|
1123
1157
|
* @param {Quaternion} other
|
|
1124
|
-
* @returns {
|
|
1158
|
+
* @returns {this}
|
|
1125
1159
|
*/
|
|
1126
1160
|
copy(other) {
|
|
1127
1161
|
return this.set(other.x, other.y, other.z, other.w);
|
|
@@ -1145,7 +1179,7 @@ class Quaternion {
|
|
|
1145
1179
|
* @param {number} y
|
|
1146
1180
|
* @param {number} z
|
|
1147
1181
|
* @param {number} w
|
|
1148
|
-
* @returns {
|
|
1182
|
+
* @returns {this}
|
|
1149
1183
|
*/
|
|
1150
1184
|
set(x, y, z, w) {
|
|
1151
1185
|
assert.isNumber(x, 'x');
|
|
@@ -1180,7 +1214,7 @@ class Quaternion {
|
|
|
1180
1214
|
|
|
1181
1215
|
/**
|
|
1182
1216
|
*
|
|
1183
|
-
* @returns {
|
|
1217
|
+
* @returns {this}
|
|
1184
1218
|
*/
|
|
1185
1219
|
conjugate() {
|
|
1186
1220
|
return this.set(-this.x, -this.y, -this.z, this.w);
|
package/src/engine/ecs/Entity.js
CHANGED
|
@@ -68,7 +68,7 @@ class Entity {
|
|
|
68
68
|
components = [];
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* Listeners added before the entity is build live here
|
|
72
72
|
* @type {{name:string,listener:(function|Function), context:*}[]}
|
|
73
73
|
*/
|
|
74
74
|
#deferredListeners = [];
|
|
@@ -451,7 +451,7 @@ class Entity {
|
|
|
451
451
|
|
|
452
452
|
r.dataset = dataset;
|
|
453
453
|
|
|
454
|
-
r.reference.bind(dataset,entity);
|
|
454
|
+
r.reference.bind(dataset, entity);
|
|
455
455
|
|
|
456
456
|
return r;
|
|
457
457
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityComponentDataset.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityComponentDataset.js"],"names":[],"mappings":"AA2GA;;;;;GAKG;AACH;IAEI;;;OAGG;IACH,wBAA+B;IAE/B;;;;;OAKG;IACH,yBAAsC;IAEtC;;;OAGG;IACH,2BAAkC;IAElC;;;OAGG;IACH,yBAAsB;IAEtB;;;;OAIG;IACH,4BAAgC;IAEhC;;;;OAIG;IACH,2BAAuB;IAEvB;;;OAGG;IACH,mBAAgB;IAEhB;;;;OAIG;IACH,oBAAgB;IAEhB;;;;;;;OAOG;IACH,mBAAe;IAEf;;;OAGG;IACH,0BAFU,MAAM,CAAC,MAAM,CAAC,CAEO;IAE/B;;;OAGG;IACH,0BAFU,MAAM,CAEe;IAG/B;;;;OAIG;IACH,+BAA4B;IAE5B;;;;OAIG;IACH,kCAA+B;IAE/B;;;OAGG;IACH,kBAAe;IAGf;;;;;;OAMG;IACH,iBALa,CAAC,EAAE,CAAC,UACN,GAAG,iBACH,CAAC,GACC,OAAO,CAAC,CAAC,CAAC,CAoCtB;IAED;;;;;OAKG;IACH,sBAJW,cAAc,cACd,OAAO,GACL,OAAO,CAqDnB;IAED;;;;;OAKG;IACH,yBAJW,cAAc,cACd,OAAO,GACL,OAAO,CAuDnB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,yBAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,kCAoChB;IAED;;;;OAIG;IACH,
|
|
1
|
+
{"version":3,"file":"EntityComponentDataset.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityComponentDataset.js"],"names":[],"mappings":"AA2GA;;;;;GAKG;AACH;IAEI;;;OAGG;IACH,wBAA+B;IAE/B;;;;;O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
@@ -431,22 +431,29 @@ export class EntityComponentDataset {
|
|
|
431
431
|
|
|
432
432
|
/**
|
|
433
433
|
* Get all components associated with a given entity
|
|
434
|
-
* @
|
|
435
|
-
* @
|
|
434
|
+
* @param {number} entity_id
|
|
435
|
+
* @returns {[]} all components attached to the entity, array is not compacted
|
|
436
436
|
*/
|
|
437
|
-
getAllComponents(
|
|
438
|
-
assert.
|
|
437
|
+
getAllComponents(entity_id) {
|
|
438
|
+
assert.isNonNegativeInteger(entity_id, 'entity_id');
|
|
439
|
+
assert.ok(this.entityExists(entity_id), `Entity ${entity_id} doesn't exist`);
|
|
439
440
|
|
|
440
441
|
const ret = [];
|
|
441
442
|
|
|
442
443
|
const componentTypeCount = this.componentTypeCount;
|
|
443
|
-
const
|
|
444
|
-
const
|
|
444
|
+
const occupancy_start = componentTypeCount * entity_id;
|
|
445
|
+
const occupancy_end = occupancy_start + componentTypeCount;
|
|
445
446
|
|
|
446
|
-
|
|
447
|
+
const occupancy = this.componentOccupancy;
|
|
448
|
+
|
|
449
|
+
for (
|
|
450
|
+
let i = occupancy.nextSetBit(occupancy_start);
|
|
451
|
+
i < occupancy_end && i !== -1;
|
|
452
|
+
i = occupancy.nextSetBit(i + 1)
|
|
453
|
+
) {
|
|
447
454
|
const componentIndex = i % componentTypeCount;
|
|
448
455
|
|
|
449
|
-
ret[componentIndex] = this.components[componentIndex][
|
|
456
|
+
ret[componentIndex] = this.components[componentIndex][entity_id];
|
|
450
457
|
}
|
|
451
458
|
|
|
452
459
|
return ret;
|
|
@@ -968,7 +975,7 @@ export class EntityComponentDataset {
|
|
|
968
975
|
}
|
|
969
976
|
|
|
970
977
|
/**
|
|
971
|
-
* @template
|
|
978
|
+
* @template T
|
|
972
979
|
* @param {T} klass
|
|
973
980
|
* @returns {number}
|
|
974
981
|
*/
|
|
@@ -1017,6 +1024,10 @@ export class EntityComponentDataset {
|
|
|
1017
1024
|
|
|
1018
1025
|
assert.defined(componentInstance, "componentInstance");
|
|
1019
1026
|
|
|
1027
|
+
/**
|
|
1028
|
+
*
|
|
1029
|
+
* @type {Class<C>}
|
|
1030
|
+
*/
|
|
1020
1031
|
const klass = componentInstance.constructor;
|
|
1021
1032
|
|
|
1022
1033
|
const componentTypeIndex = this.__type_to_index_map.get(klass);
|
|
@@ -1836,7 +1847,7 @@ export class EntityComponentDataset {
|
|
|
1836
1847
|
}
|
|
1837
1848
|
|
|
1838
1849
|
/**
|
|
1839
|
-
* Tells
|
|
1850
|
+
* Tells if dataset has any entities
|
|
1840
1851
|
* @returns {boolean}
|
|
1841
1852
|
*/
|
|
1842
1853
|
isEmpty() {
|
|
@@ -1846,14 +1857,21 @@ export class EntityComponentDataset {
|
|
|
1846
1857
|
/**
|
|
1847
1858
|
*
|
|
1848
1859
|
* @param {function(entityIndex:number)} visitor
|
|
1860
|
+
* @param {*} [thisArg]
|
|
1849
1861
|
*/
|
|
1850
|
-
traverseEntityIndices(visitor) {
|
|
1862
|
+
traverseEntityIndices(visitor, thisArg) {
|
|
1851
1863
|
let entityIndex;
|
|
1852
1864
|
|
|
1853
1865
|
const occupancy = this.entityOccupancy;
|
|
1854
1866
|
|
|
1855
|
-
for (
|
|
1856
|
-
|
|
1867
|
+
for (
|
|
1868
|
+
entityIndex = occupancy.nextSetBit(0);
|
|
1869
|
+
entityIndex !== -1;
|
|
1870
|
+
entityIndex = occupancy.nextSetBit(entityIndex + 1)
|
|
1871
|
+
) {
|
|
1872
|
+
|
|
1873
|
+
visitor.call(thisArg, entityIndex);
|
|
1874
|
+
|
|
1857
1875
|
}
|
|
1858
1876
|
}
|
|
1859
1877
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityManager.js"],"names":[],"mappings":";;;wBAcU,MAAM;;;;;;iCAWN,MAAM;;;;;;;;;AAWhB;IAEI;;;OAGG;IACH,kBAFU,iCAAQ,CAEL;IAEb
|
|
1
|
+
{"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityManager.js"],"names":[],"mappings":";;;wBAcU,MAAM;;;;;;iCAWN,MAAM;;;;;;;;;AAWhB;;;GAGG;AACH;IAEI;;;OAGG;IACH,kBAFU,iCAAQ,CAEL;IAEb;;;;OAIG;IACH,uCAA2B;IAE3B;;;;OAIG;IACH,iCAAqB;IAErB;;OAEG;IACH;;;QAGI;;WAEG;qBADO,MAAM,iCAAQ;;MAI1B;IAEF;;;OAGG;IACH,OAFU,kBAAkB,CAEO;IAEnC;;;;;;OAMG;IACH,gDAA2C;IAE3C;;;;OAIG;IACH,qBAFU,MAAM,CAEY;IAE5B;;;;;OAKG;IACH,wCAFU,MAAM,CAE4B;IAE5C;;;OAGG;IACH,SAFU,sBAAsB,CAEjB;IAEf;;;;;OAKG;IACH,uCAAsC;IAEtC;;;OAGG;IACH,6BA8EC;IAED,sBAcC;IAED;;;OAGG;IACH,uBAFa,KAAK,EAAE,CAuBnB;IAED;;;;;OAKG;IACH,uBAJW,sBAAsB,QA0BhC;IAED;;;;OAIG;IACH,UAJa,CAAC,eACH,KAAK,CAAC,CAAC,CAAC,GACN,OAAO,CAInB;IAED;;;;OAIG;IACH,UAJa,CAAC,eACH,KAAK,CAAC,CAAC,CAAC,GACN,CAAC,GAAC,IAAI,CAgBlB;IAED;;;;;OAKG;IACH,wBAJa,CAAC,aACH,MAAM,GACJ,IAAI,GAAC,KAAK,CAAC,CAAC,CAAC,CAezB;IAGD;;;OAGG;IACH,oBAFW,MAAM,QAkEhB;IAED;;;;;OAKG;IACH,iEA0EC;IAED;;;;OAIG;IACH,uDAFa,OAAO,CAAC,OAAO,CAAC,CAyC5B;IAED;;;;;OAKG;IACH,mBA6BC;IAED;;;;;OAKG;IACH,oBAwCC;IAED;;;;OAIG;IACH,gEAwEC;IAED;;;;OAIG;IACH,2BAHW,KAAK,GACH,OAAO,iCAAS,CA0B5B;IAED;;;;;OAKG;IACH,kCAJW,KAAK,SACL,WAAW,GACT,OAAO,iCAAS,CAsB5B;IAED;;;;OAIG;IACH,iEAkEC;CACJ;uBA7yBsD,aAAa;mBANjD,oCAAoC"}
|
|
@@ -34,6 +34,10 @@ export const EntityManagerState = {
|
|
|
34
34
|
Stopped: 5
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Brings together {@link System}s and an {@link EntityComponentDataset}
|
|
39
|
+
* Main entry point into the simulation process
|
|
40
|
+
*/
|
|
37
41
|
export class EntityManager {
|
|
38
42
|
|
|
39
43
|
/**
|
|
@@ -44,12 +48,14 @@ export class EntityManager {
|
|
|
44
48
|
|
|
45
49
|
/**
|
|
46
50
|
* @readonly
|
|
51
|
+
* @private
|
|
47
52
|
* @type {System[]}
|
|
48
53
|
*/
|
|
49
54
|
systemsExecutionOrder = [];
|
|
50
55
|
|
|
51
56
|
/**
|
|
52
57
|
* @readonly
|
|
58
|
+
* @private
|
|
53
59
|
* @type {EntityObserver[]}
|
|
54
60
|
*/
|
|
55
61
|
systemObservers = [];
|
|
@@ -74,6 +80,8 @@ export class EntityManager {
|
|
|
74
80
|
state = EntityManagerState.Initial;
|
|
75
81
|
|
|
76
82
|
/**
|
|
83
|
+
* Track remainders of simulation time for fixed step
|
|
84
|
+
* Needed for accurate time keeping
|
|
77
85
|
* @private
|
|
78
86
|
* @readonly
|
|
79
87
|
* @type {Map<System, number>}
|
|
@@ -102,7 +110,8 @@ export class EntityManager {
|
|
|
102
110
|
dataset = null;
|
|
103
111
|
|
|
104
112
|
/**
|
|
105
|
-
*
|
|
113
|
+
* Whenever a system is added or removed, optimal execution plan changes, this flag tells us to rebuild the current plan
|
|
114
|
+
* see {@link #systemsExecutionOrder}
|
|
106
115
|
* @type {boolean}
|
|
107
116
|
* @private
|
|
108
117
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityObserver.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityObserver.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EntityObserver.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityObserver.js"],"names":[],"mappings":"AAGA;IAoBI;;;;;;;OAOG;IACH,0FAHW,GAAC,EA+CX;IAvED;;;OAGG;IACH,eAFU,MAAM,CAEa;IAE7B;;;;OAIG;IACH,uBAFU,MAAM,EAAE,CAES;IAE3B;;;OAGG;IACH,SAFU,sBAAsB,GAAC,IAAI,CAEtB;IA0BX;;OAEG;IACH,oBAFU,MAAM,CAE2B;IAE3C;;;OAGG;IACH,kBAFU,CAAS,IAAK,eAAC,CAEgB;IAEzC;;;OAGG;IACH,gBAFU,CAAS,IAAK,eAAC,CAEW;IAEpC;;;OAGG;IACH,sBAAoC;IAEpC;;;OAGG;IACH,SAFU,GAAC,CAEW;IAG1B;;;OAGG;IACH,qCAqBC;IAED;;;OAGG;IACH,iBAFW,sBAAsB,QAIhC;IAED,mBAGC;CACJ;uBAnHsB,6BAA6B"}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {Array} componentTypes
|
|
4
|
-
* @param {function(components:Array)} completedCallback "this" parameter will be set to entity ID
|
|
5
|
-
* @param {function(components:Array)} brokenCallback "this" parameter will be set to entity ID
|
|
6
|
-
* @constructor
|
|
7
|
-
* @class
|
|
8
|
-
*/
|
|
9
1
|
import { assert } from "../../core/assert.js";
|
|
10
2
|
import { BitSet } from "../../core/binary/BitSet.js";
|
|
11
3
|
|
|
@@ -32,8 +24,8 @@ export class EntityObserver {
|
|
|
32
24
|
/**
|
|
33
25
|
*
|
|
34
26
|
* @param {Array} componentTypes
|
|
35
|
-
* @param {function} completedCallback
|
|
36
|
-
* @param {function} brokenCallback
|
|
27
|
+
* @param {function(components:Array)} completedCallback
|
|
28
|
+
* @param {function(components:Array)} brokenCallback
|
|
37
29
|
* @param {*} [thisArg=undefined] will assume {@link this} value inside callbacks
|
|
38
30
|
* @constructor
|
|
39
31
|
*/
|
|
@@ -10,6 +10,13 @@ export class EntityReference {
|
|
|
10
10
|
* @return {EntityReference}
|
|
11
11
|
*/
|
|
12
12
|
static from(id: number, generation: number): EntityReference;
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {EntityComponentDataset} ecd
|
|
16
|
+
* @param {number} id
|
|
17
|
+
* @returns {EntityReference}
|
|
18
|
+
*/
|
|
19
|
+
static bind(ecd: EntityComponentDataset, id: number): EntityReference;
|
|
13
20
|
/**
|
|
14
21
|
* Entity ID
|
|
15
22
|
* When entity is live - this is the entity ID inside associated `EntityComponentDataset`, when the entity is not live - it's set to -1
|
|
@@ -50,9 +57,10 @@ export class EntityReference {
|
|
|
50
57
|
*/
|
|
51
58
|
verify(ecd: EntityComponentDataset): boolean;
|
|
52
59
|
/**
|
|
53
|
-
*
|
|
60
|
+
* Destroys entity bound to this reference
|
|
61
|
+
* If the reference is invalid for the given dataset - does nothing
|
|
54
62
|
* @param {EntityComponentDataset} ecd
|
|
55
|
-
* @returns {boolean}
|
|
63
|
+
* @returns {boolean} true if entity was destroyed, false otherwise
|
|
56
64
|
*/
|
|
57
65
|
destroy(ecd: EntityComponentDataset): boolean;
|
|
58
66
|
/**
|