@woosh/meep-engine 2.126.2 → 2.126.3

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 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.2",
8
+ "version": "2.126.3",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"AABB2.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/AABB2.js"],"names":[],"mappings":";AAYA;;;GAGG;AACH;IACI;;;;;;OAMG;IACH,iBANW,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,EAuChB;IApBG;;;OAGG;IACH,IAFU,MAAM,CAEJ;IACZ;;;OAGG;IACH,IAFU,MAAM,CAEJ;IACZ;;;OAGG;IACH,IAFU,MAAM,CAEJ;IACZ;;;OAGG;IACH,IAFU,MAAM,CAEJ;IAGhB;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAQhB;IAED;;;OAGG;IACH,iBAFW,MAAM,QAQhB;IAED;;;OAGG;IACH,WAFW,MAAM,QAMhB;IAED;;;OAGG;IACH,aAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QA8BlB;IAED;;;OAGG;IACH,sBAFW,MAAM,QAShB;IAED;;;;;OAKG;IACH,sBAJW,KAAK,UACL,KAAK,GACH,OAAO,CAcnB;IAED;;;;OAIG;IACH,qBAHW,KAAK,GACH,OAAO,CAcnB;IAED;;;;;;;OAOG;IACH,0EAMC;IAED;;;;OAIG;IACH,qBAHW,MAAM,KAC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AED,mBAEC;IAED;;;;;MAOC;IAED,0BAEC;IAED;;;;OAIG;IACH,iBAJW,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,GACJ,MAAM,EAAE,GAAC,YAAY,CAUjC;CACJ;;;qBAqCS,KAAK;qBAML,KAAK;;oBApqBK,kBAAkB;AA4nBtC;;;;;;;GAOG;AACH,gDANW,KAAK,MACL,KAAK,MACL,OAAO,MACP,OAAO,GACL,OAAO,CAsBnB"}
1
+ {"version":3,"file":"AABB2.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/AABB2.js"],"names":[],"mappings":";AAaA;;;GAGG;AACH;IACI;;;;;;OAMG;IACH,iBANW,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,EAuChB;IApBG;;;OAGG;IACH,IAFU,MAAM,CAEJ;IACZ;;;OAGG;IACH,IAFU,MAAM,CAEJ;IACZ;;;OAGG;IACH,IAFU,MAAM,CAEJ;IACZ;;;OAGG;IACH,IAFU,MAAM,CAEJ;IAahB;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAQhB;IAED;;;OAGG;IACH,iBAFW,MAAM,QAQhB;IAED;;;OAGG;IACH,WAFW,MAAM,QAMhB;IAED;;;OAGG;IACH,aAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QA8BlB;IAED;;;OAGG;IACH,sBAFW,MAAM,QAShB;IAED;;;;;OAKG;IACH,sBAJW,KAAK,UACL,KAAK,GACH,OAAO,CAcnB;IAED;;;;OAIG;IACH,qBAHW,KAAK,GACH,OAAO,CAcnB;IAED;;;;;;;OAOG;IACH,0EAMC;IAED;;;;OAIG;IACH,qBAHW,MAAM,KACN,MAAM,QAKhB;IAED;;;;;;OAMG;IACH,0BALW,OA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OAEG;IACH,oCAEC;IAED,mBAEC;IAED;;;;;MAOC;IAED,0BAEC;IAED;;;;OAIG;IACH,iBAJW,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,GACJ,MAAM,EAAE,GAAC,YAAY,CAUjC;IAkCL;;;OAGG;IACH,kBAFU,OAAO,CAEM;IA/oBnB,sDAQC;CAkmBJ;;;qBA2CS,KAAK;qBAML,KAAK;;oBArtBK,kBAAkB;AAuqBtC;;;;;;;GAOG;AACH,gDANW,KAAK,MACL,KAAK,MACL,OAAO,MACP,OAAO,GACL,OAAO,CAsBnB"}
@@ -2,6 +2,7 @@ import { assert } from "../../../assert.js";
2
2
  import { clamp } from "../../../math/clamp.js";
3
3
  import { max2 } from "../../../math/max2.js";
4
4
  import { min2 } from "../../../math/min2.js";
5
+ import { AABB3 } from "../../3d/aabb/AABB3.js";
5
6
  import Vector2 from "../../Vector2.js";
6
7
  import {
7
8
  line_segment_compute_line_segment_intersection_2d
@@ -60,11 +61,21 @@ class AABB2 {
60
61
  this.y1 = y1;
61
62
  }
62
63
 
64
+ * [Symbol.iterator]() {
65
+
66
+ yield this.x0;
67
+ yield this.y0;
68
+
69
+ yield this.x1;
70
+ yield this.y1;
71
+
72
+ }
73
+
63
74
  /**
64
75
  *
65
76
  * @returns {number}
66
77
  */
67
- get 0(){
78
+ get 0() {
68
79
  return this.x0;
69
80
  }
70
81
 
@@ -72,7 +83,7 @@ class AABB2 {
72
83
  *
73
84
  * @returns {number}
74
85
  */
75
- get 1(){
86
+ get 1() {
76
87
  return this.y0;
77
88
  }
78
89
 
@@ -80,7 +91,7 @@ class AABB2 {
80
91
  *
81
92
  * @returns {number}
82
93
  */
83
- get 2(){
94
+ get 2() {
84
95
  return this.x1;
85
96
  }
86
97
 
@@ -88,7 +99,7 @@ class AABB2 {
88
99
  *
89
100
  * @returns {number}
90
101
  */
91
- get 3(){
102
+ get 3() {
92
103
  return this.y1;
93
104
  }
94
105
 
@@ -96,9 +107,9 @@ class AABB2 {
96
107
  *
97
108
  * @param {number} size
98
109
  */
99
- growWidth(size){
100
- assert.isNumber(size,'size');
101
- assert.notNaN(size,'size');
110
+ growWidth(size) {
111
+ assert.isNumber(size, 'size');
112
+ assert.notNaN(size, 'size');
102
113
 
103
114
  this.x0 -= size;
104
115
  this.x1 += size;
@@ -108,9 +119,9 @@ class AABB2 {
108
119
  *
109
120
  * @param {number} size
110
121
  */
111
- growHeight(size){
112
- assert.isNumber(size,'size');
113
- assert.notNaN(size,'size');
122
+ growHeight(size) {
123
+ assert.isNumber(size, 'size');
124
+ assert.notNaN(size, 'size');
114
125
 
115
126
  this.y0 -= size;
116
127
  this.y1 += size;
@@ -479,7 +490,7 @@ class AABB2 {
479
490
  * @param {Number} y0
480
491
  * @param {Number} x1
481
492
  * @param {Number} y1
482
- * returns {AABB2} this
493
+ * @returns {this}
483
494
  */
484
495
  set(x0, y0, x1, y1) {
485
496
  assert.isNumber(x0, `x0`);
@@ -514,11 +525,12 @@ class AABB2 {
514
525
 
515
526
  /**
516
527
  * Relative displacement of the AABB by given vector described by {@param deltaX} and {@param deltaY}
517
- * @param {number} deltaX
518
- * @param {number} deltaY
528
+ * @param {number} deltaX displacement in X
529
+ * @param {number} deltaY displacement in Y
530
+ * @returns {this}
519
531
  */
520
532
  move(deltaX, deltaY) {
521
- this.set(
533
+ return this.set(
522
534
  this.x0 + deltaX, this.y0 + deltaY,
523
535
  this.x1 + deltaX, this.y1 + deltaY
524
536
  );
@@ -553,6 +565,38 @@ class AABB2 {
553
565
  && this.y1 === other.y1;
554
566
  }
555
567
 
568
+ /**
569
+ *
570
+ * @return {number}
571
+ */
572
+ hash(){
573
+ let h = 0; // Initial hash value
574
+
575
+ // Prime numbers for mixing. These are often chosen to be large and coprime.
576
+ const p1 = 73856093;
577
+ const p2 = 19349663;
578
+ const p3 = 83492791;
579
+ const p4 = 536870912; // This is 2^29, can also use another large prime
580
+
581
+ // Mix in x0
582
+ h = (h ^ (this.x0 * p1)) >>> 0; // XOR and unsigned right shift
583
+ h = (h << 13 | h >>> 19) >>> 0; // Rotate left (or use a combination of shifts)
584
+
585
+ // Mix in y0
586
+ h = (h ^ (this.y0 * p2)) >>> 0;
587
+ h = (h << 17 | h >>> 15) >>> 0;
588
+
589
+ // Mix in x1
590
+ h = (h ^ (this.x1 * p3)) >>> 0;
591
+ h = (h << 23 | h >>> 9) >>> 0;
592
+
593
+ // Mix in y1
594
+ h = (h ^ (this.y1 * p4)) >>> 0; // Using p4 here
595
+ h = (h << 29 | h >>> 3) >>> 0;
596
+
597
+ return h;
598
+ }
599
+
556
600
  /**
557
601
  * Clamps AABB to specified region
558
602
  * @param {number} x0
@@ -626,12 +670,12 @@ class AABB2 {
626
670
  * @param {number} offset
627
671
  * @returns {number[]|Float32Array}
628
672
  */
629
- toArray(target=[], offset=0){
673
+ toArray(target = [], offset = 0) {
630
674
 
631
675
  target[offset] = this.x0;
632
- target[offset+1] = this.y0;
633
- target[offset+2] = this.x1;
634
- target[offset+3] = this.y1;
676
+ target[offset + 1] = this.y0;
677
+ target[offset + 2] = this.x1;
678
+ target[offset + 3] = this.y1;
635
679
 
636
680
  return target;
637
681
  }
@@ -668,6 +712,12 @@ function computeLineBetweenTwoBoxes(b0, b1, p0, p1) {
668
712
  return true;
669
713
  }
670
714
 
715
+ /**
716
+ * @readonly
717
+ * @type {boolean}
718
+ */
719
+ AABB2.prototype.isAABB2 = true;
720
+
671
721
  AABB2.computeLineBetweenTwoBoxes = computeLineBetweenTwoBoxes;
672
722
 
673
723
  /**
@@ -682,5 +732,11 @@ AABB2.zero = Object.freeze(new AABB2(0, 0, 0, 0));
682
732
  */
683
733
  AABB2.unit = Object.freeze(new AABB2(0, 0, 1, 1));
684
734
 
735
+ /**
736
+ * Pretending to be an array
737
+ * @readonly
738
+ * @type {number}
739
+ */
740
+ AABB3.prototype.length = 4
685
741
 
686
742
  export default AABB2;
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ * @param {ArrayLike<number>|number[]|Float32Array|AABB2} result
4
+ * @param {number[]|ArrayLike<number>|Float32Array} input
5
+ * @param {number} input_length length of the input array
6
+ */
7
+ export function aabb2_from_v2_array(result: ArrayLike<number> | number[] | Float32Array | AABB2, input: number[] | ArrayLike<number> | Float32Array, input_length: number): void;
8
+ //# sourceMappingURL=aabb2_from_v2_array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aabb2_from_v2_array.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/aabb2_from_v2_array.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,4CAJW,SAAS,CAAC,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,GAAC,KAAK,SAC7C,MAAM,EAAE,GAAC,SAAS,CAAC,MAAM,CAAC,GAAC,YAAY,gBACvC,MAAM,QAuBhB"}
@@ -0,0 +1,33 @@
1
+ import { assert } from "../../../assert.js";
2
+ import { max2 } from "../../../math/max2.js";
3
+ import { min2 } from "../../../math/min2.js";
4
+ import { aabb2_array_set } from "./aabb2_array_set.js";
5
+
6
+ /**
7
+ *
8
+ * @param {ArrayLike<number>|number[]|Float32Array|AABB2} result
9
+ * @param {number[]|ArrayLike<number>|Float32Array} input
10
+ * @param {number} input_length length of the input array
11
+ */
12
+ export function aabb2_from_v2_array(result, input, input_length) {
13
+ assert.equal(input_length % 2, 0, `Input must be divisible by 2, instead was ${input_length}`)
14
+
15
+ let x0 = Infinity;
16
+ let y0 = Infinity;
17
+
18
+ let x1 = -Infinity;
19
+ let y1 = -Infinity;
20
+
21
+ for (let i = 0; i < input_length; i += 2) {
22
+ const x = input[i];
23
+ const y = input[i + 1];
24
+
25
+ x0 = min2(x, x0);
26
+ y0 = min2(y, y0);
27
+ x1 = max2(x, x1);
28
+ y1 = max2(y, y1);
29
+ }
30
+
31
+ // read out
32
+ aabb2_array_set(result, 0, x0, y0, x1, y1);
33
+ }
@@ -20,12 +20,12 @@ import { aabb3_signed_distance_to_aabb3 } from "./aabb3_signed_distance_to_aabb3
20
20
  export class AABB3 {
21
21
  /**
22
22
  *
23
- * @param {number} x0
24
- * @param {number} y0
25
- * @param {number} z0
26
- * @param {number} x1
27
- * @param {number} y1
28
- * @param {number} z1
23
+ * @param {number} [x0]
24
+ * @param {number} [y0]
25
+ * @param {number} [z0]
26
+ * @param {number} [x1]
27
+ * @param {number} [y1]
28
+ * @param {number} [z1]
29
29
  * @constructor
30
30
  */
31
31
  constructor(