@woosh/meep-engine 2.126.2 → 2.126.4

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.4",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -23,6 +23,8 @@ export default class AABB2 {
23
23
 
24
24
  equals(other: AABB2): boolean
25
25
 
26
+ hash():number
27
+
26
28
  setBoundsUnordered(x0: number, y0: number, x1: number, y1: number): void
27
29
 
28
30
  getCenter(result?: Vector2): Vector2
@@ -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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;;OAMG;IACH,UALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAQhB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAsBhB;IAED;;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;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;IA8ChB;;OAEG;IACH,aAFW,MAAM,EAIhB;IAtCD;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAkCD;;OAEG;IACH,aAFW,MAAM,EAIhB;IArCD;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAiCD;;OAEG;IACH,aAFW,MAAM,EAIhB;IApCD;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAgCD;;OAEG;IACH,aAFW,MAAM,EAIhB;IAnCD;;;OAGG;IACH,SAFa,MAAM,CAIlB;IA+BD;;;OAGG;IACH,gBAFW,MAAM,QAQhB;IAED;;;OAGG;IACH,iBAFW,MAAM,QAQhB;IAED;;;OAGG;IACH,WAFW,MAAM,QAMhB;IAED;;;OAGG;IACH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IAED;;;OAGG;IACH,SAFa,KAAK,CAIjB;IAED;;;;OAIG;IACH,YAHW,KAAK,GACH,KAAK,CAIjB;IAED;;;;OAIG;IACH,cAHW,KAAK,GACH,OAAO,CAOnB;IAED;;;OAGG;IACH,QAFY,MAAM,CA4BjB;IAED;;;;;;OAMG;IACH,UALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAQhB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAsBhB;IAED;;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;IA5qBnB,sDAQC;CA+nBJ;;;qBA2CS,KAAK;qBAML,KAAK;;oBAlvBK,kBAAkB;AAosBtC;;;;;;;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,17 +99,46 @@ 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
 
106
+
107
+ /**
108
+ * @param {number} value
109
+ */
110
+ set 0(value) {
111
+ this.x0 = value;
112
+ }
113
+
114
+ /**
115
+ * @param {number} value
116
+ */
117
+ set 1(value) {
118
+ this.y0 = value;
119
+ }
120
+
121
+ /**
122
+ * @param {number} value
123
+ */
124
+ set 2(value) {
125
+ this.x1 = value;
126
+ }
127
+
128
+ /**
129
+ * @param {number} value
130
+ */
131
+ set 3(value) {
132
+ this.y1 = value;
133
+ }
134
+
95
135
  /**
96
136
  *
97
137
  * @param {number} size
98
138
  */
99
- growWidth(size){
100
- assert.isNumber(size,'size');
101
- assert.notNaN(size,'size');
139
+ growWidth(size) {
140
+ assert.isNumber(size, 'size');
141
+ assert.notNaN(size, 'size');
102
142
 
103
143
  this.x0 -= size;
104
144
  this.x1 += size;
@@ -108,9 +148,9 @@ class AABB2 {
108
148
  *
109
149
  * @param {number} size
110
150
  */
111
- growHeight(size){
112
- assert.isNumber(size,'size');
113
- assert.notNaN(size,'size');
151
+ growHeight(size) {
152
+ assert.isNumber(size, 'size');
153
+ assert.notNaN(size, 'size');
114
154
 
115
155
  this.y0 -= size;
116
156
  this.y1 += size;
@@ -479,7 +519,7 @@ class AABB2 {
479
519
  * @param {Number} y0
480
520
  * @param {Number} x1
481
521
  * @param {Number} y1
482
- * returns {AABB2} this
522
+ * @returns {this}
483
523
  */
484
524
  set(x0, y0, x1, y1) {
485
525
  assert.isNumber(x0, `x0`);
@@ -514,11 +554,12 @@ class AABB2 {
514
554
 
515
555
  /**
516
556
  * Relative displacement of the AABB by given vector described by {@param deltaX} and {@param deltaY}
517
- * @param {number} deltaX
518
- * @param {number} deltaY
557
+ * @param {number} deltaX displacement in X
558
+ * @param {number} deltaY displacement in Y
559
+ * @returns {this}
519
560
  */
520
561
  move(deltaX, deltaY) {
521
- this.set(
562
+ return this.set(
522
563
  this.x0 + deltaX, this.y0 + deltaY,
523
564
  this.x1 + deltaX, this.y1 + deltaY
524
565
  );
@@ -553,6 +594,38 @@ class AABB2 {
553
594
  && this.y1 === other.y1;
554
595
  }
555
596
 
597
+ /**
598
+ *
599
+ * @return {number}
600
+ */
601
+ hash(){
602
+ let h = 0; // Initial hash value
603
+
604
+ // Prime numbers for mixing. These are often chosen to be large and coprime.
605
+ const p1 = 73856093;
606
+ const p2 = 19349663;
607
+ const p3 = 83492791;
608
+ const p4 = 536870912; // This is 2^29, can also use another large prime
609
+
610
+ // Mix in x0
611
+ h = (h ^ (this.x0 * p1)) >>> 0; // XOR and unsigned right shift
612
+ h = (h << 13 | h >>> 19) >>> 0; // Rotate left (or use a combination of shifts)
613
+
614
+ // Mix in y0
615
+ h = (h ^ (this.y0 * p2)) >>> 0;
616
+ h = (h << 17 | h >>> 15) >>> 0;
617
+
618
+ // Mix in x1
619
+ h = (h ^ (this.x1 * p3)) >>> 0;
620
+ h = (h << 23 | h >>> 9) >>> 0;
621
+
622
+ // Mix in y1
623
+ h = (h ^ (this.y1 * p4)) >>> 0; // Using p4 here
624
+ h = (h << 29 | h >>> 3) >>> 0;
625
+
626
+ return h;
627
+ }
628
+
556
629
  /**
557
630
  * Clamps AABB to specified region
558
631
  * @param {number} x0
@@ -626,12 +699,12 @@ class AABB2 {
626
699
  * @param {number} offset
627
700
  * @returns {number[]|Float32Array}
628
701
  */
629
- toArray(target=[], offset=0){
702
+ toArray(target = [], offset = 0) {
630
703
 
631
704
  target[offset] = this.x0;
632
- target[offset+1] = this.y0;
633
- target[offset+2] = this.x1;
634
- target[offset+3] = this.y1;
705
+ target[offset + 1] = this.y0;
706
+ target[offset + 2] = this.x1;
707
+ target[offset + 3] = this.y1;
635
708
 
636
709
  return target;
637
710
  }
@@ -668,6 +741,12 @@ function computeLineBetweenTwoBoxes(b0, b1, p0, p1) {
668
741
  return true;
669
742
  }
670
743
 
744
+ /**
745
+ * @readonly
746
+ * @type {boolean}
747
+ */
748
+ AABB2.prototype.isAABB2 = true;
749
+
671
750
  AABB2.computeLineBetweenTwoBoxes = computeLineBetweenTwoBoxes;
672
751
 
673
752
  /**
@@ -682,5 +761,11 @@ AABB2.zero = Object.freeze(new AABB2(0, 0, 0, 0));
682
761
  */
683
762
  AABB2.unit = Object.freeze(new AABB2(0, 0, 1, 1));
684
763
 
764
+ /**
765
+ * Pretending to be an array
766
+ * @readonly
767
+ * @type {number}
768
+ */
769
+ AABB3.prototype.length = 4
685
770
 
686
771
  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(