@woosh/meep-engine 2.92.9 → 2.92.10

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.
@@ -54355,13 +54355,6 @@ function inverseLerp(a, b, value) {
54355
54355
  return scaledValue / range;
54356
54356
  }
54357
54357
 
54358
- /**
54359
- *
54360
- * @param {number} min
54361
- * @param {number} max
54362
- * @constructor
54363
- */
54364
-
54365
54358
  class NumericInterval {
54366
54359
  /**
54367
54360
  *
@@ -54435,9 +54428,9 @@ class NumericInterval {
54435
54428
  }
54436
54429
 
54437
54430
  /**
54438
- * Performs inverse linear interpolation on a given input
54439
- * @param {number} v
54440
- * @returns {number}
54431
+ * Compute normalized position of input within this interval, where result is 0 if input is equal to `min`, and 1 when input is equal to `max`
54432
+ * @param {number} v value to be normalized
54433
+ * @returns {number} value between 0..1 if input is within [min,max] range, otherwise result will be extrapolated proportionately outside the 0,1 region
54441
54434
  */
54442
54435
  normalizeValue(v) {
54443
54436
  return inverseLerp(this.min, this.max, v);
@@ -54465,7 +54458,7 @@ class NumericInterval {
54465
54458
  * @returns {number}
54466
54459
  */
54467
54460
  computeAverage() {
54468
- return (this.min + this.max) / 2;
54461
+ return (this.min + this.max) * 0.5;
54469
54462
  }
54470
54463
 
54471
54464
  /**
@@ -55268,6 +55261,7 @@ class BinaryUint32BVH {
55268
55261
  * @param {number} count
55269
55262
  */
55270
55263
  setLeafCount(count) {
55264
+
55271
55265
  this.__node_count_leaf = count;
55272
55266
 
55273
55267
  const twoLeafLimit = ceilPowerOfTwo(count);
@@ -66306,14 +66300,14 @@ class GeometrySpatialQueryAccelerator {
66306
66300
  * @returns {BinaryUint32BVH}
66307
66301
  */
66308
66302
  __buildBVH(geometry) {
66303
+ const bvh = new BinaryUint32BVH();
66304
+
66309
66305
  const position_attribute = geometry.getAttribute('position');
66310
66306
  const index_attribute = geometry.getIndex();
66311
66307
 
66312
66308
  const de_interleaved_position_attribute = deinterleaveBufferAttribute(position_attribute);
66313
66309
  const vertices = de_interleaved_position_attribute.array;
66314
66310
 
66315
- const bvh = new BinaryUint32BVH();
66316
-
66317
66311
  if (index_attribute === undefined || index_attribute === null) {
66318
66312
  bvh32_from_unindexed_geometry(bvh, vertices);
66319
66313
  } else {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.92.9",
8
+ "version": "2.92.10",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"BinaryUint32BVH.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/binary/2/BinaryUint32BVH.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;;GAIG;AACH,mCAFU,MAAM,CAEsB;AACtC;;;GAGG;AACH,iCAFU,MAAM,CAEoB;AAiDpC;IACI;;;;OAIG;IACH,sBAAc;IAEd;;;;OAIG;IACH,gCAAe;IAEf;;;;OAIG;IACH,+BAAc;IAEd;;;;OAIG;IACH,4BAAwB;IAExB;;;;OAIG;IACH,0BAAsB;IA0CtB;;;OAGG;IACH,2BAOC;IAED,wBAEC;IAnDD;;;OAGG;IACH,oBAFa,MAAM,CAIlB;IAED,2BAEC;IAED,gCAEC;IAED,8BAEC;IAED;;;OAGG;IACH,uBAFa,MAAM,CAIlB;IAED,4BAEC;IAED,0BAEC;IAmBD;;;;OAIG;IACH,2BAHW,MAAM,GACJ,MAAM,CAalB;IAED,6BASC;IAED;;;OAGG;IACH,oBAFW,MAAM,QAchB;IAED;;;;;;;;;;OAUG;IACH,mBATW,MAAM,WACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAwBhB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,QAIhB;IAED;;;;OAIG;IACH,4BAHW,MAAM,GACJ,MAAM,CAQlB;IAED,qCAoBC;IAED;;;;;;;OAOG;IACH,yCAYC;IAED;;;;;;OAMG;IACH,kDAuBC;IAED,wBAUC;IAGD;;;OAGG;IACH,oBAFW,MAAM,EAAE,QAkElB;IAED;;;;;OAKG;IACH,sBAUC;IAED;;OAEG;IACH,cAsEC;CACJ"}
1
+ {"version":3,"file":"BinaryUint32BVH.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/binary/2/BinaryUint32BVH.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;;GAIG;AACH,mCAFU,MAAM,CAEsB;AACtC;;;GAGG;AACH,iCAFU,MAAM,CAEoB;AAiDpC;IACI;;;;OAIG;IACH,sBAAc;IAEd;;;;OAIG;IACH,gCAAe;IAEf;;;;OAIG;IACH,+BAAc;IAEd;;;;OAIG;IACH,4BAAwB;IAExB;;;;OAIG;IACH,0BAAsB;IA0CtB;;;OAGG;IACH,2BAOC;IAED,wBAEC;IAnDD;;;OAGG;IACH,oBAFa,MAAM,CAIlB;IAED,2BAEC;IAED,gCAEC;IAED,8BAEC;IAED;;;OAGG;IACH,uBAFa,MAAM,CAIlB;IAED,4BAEC;IAED,0BAEC;IAmBD;;;;OAIG;IACH,2BAHW,MAAM,GACJ,MAAM,CAalB;IAED,6BASC;IAED;;;OAGG;IACH,oBAFW,MAAM,QAgBhB;IAED;;;;;;;;;;OAUG;IACH,mBATW,MAAM,WACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QA0BhB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,QAIhB;IAED;;;;OAIG;IACH,4BAHW,MAAM,GACJ,MAAM,CAQlB;IAED,qCAoBC;IAED;;;;;;;OAOG;IACH,yCAYC;IAED;;;;;;OAMG;IACH,kDAuBC;IAED,wBAUC;IAGD;;;OAGG;IACH,oBAFW,MAAM,EAAE,QAkElB;IAED;;;;;OAKG;IACH,sBAUC;IAED;;OAEG;IACH,cAsEC;CACJ"}
@@ -204,6 +204,8 @@ export class BinaryUint32BVH {
204
204
  * @param {number} count
205
205
  */
206
206
  setLeafCount(count) {
207
+ assert.isNonNegativeInteger(count, 'count');
208
+
207
209
  this.__node_count_leaf = count;
208
210
 
209
211
  const twoLeafLimit = ceilPowerOfTwo(count);
@@ -240,6 +242,8 @@ export class BinaryUint32BVH {
240
242
  assert.notNaN(y1, 'y1');
241
243
  assert.notNaN(z1, 'z1');
242
244
 
245
+ assert.isNonNegativeInteger(payload, 'payload');
246
+
243
247
  const address = index * BVH_LEAF_NODE_SIZE + this.__node_count_binary * BVH_BINARY_NODE_SIZE;
244
248
 
245
249
  aabb3_array_set(
@@ -34,9 +34,9 @@ export class NumericInterval {
34
34
  */
35
35
  multiplyScalar(value: number): void;
36
36
  /**
37
- * Performs inverse linear interpolation on a given input
38
- * @param {number} v
39
- * @returns {number}
37
+ * Compute normalized position of input within this interval, where result is 0 if input is equal to `min`, and 1 when input is equal to `max`
38
+ * @param {number} v value to be normalized
39
+ * @returns {number} value between 0..1 if input is within [min,max] range, otherwise result will be extrapolated proportionately outside the 0,1 region
40
40
  */
41
41
  normalizeValue(v: number): number;
42
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"NumericInterval.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/interval/NumericInterval.js"],"names":[],"mappings":"AAWA;IACI;;;;;OAKG;IACH,kBAJW,MAAM,QACN,MAAM,EAwBhB;IAZG;;;OAGG;IACH,KAFU,MAAM,CAEF;IACd;;;OAGG;IACH,KAFU,MAAM,CAEF;IAEd,0DAA6B;IAIjC;;;;OAIG;IACH,SAHW,MAAM,OACN,MAAM,QAsBhB;IAED;;;OAGG;IACH,YAFW,eAAe,QAIzB;IAED;;;OAGG;IACH,sBAFW,MAAM,QAahB;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;OAGG;IACH,UAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,gCAFa,MAAM,CAMlB;IAED,0BAEC;IAED;;;MAKC;IAED;;;OAGG;IACH,2CAGC;IAED;;;OAGG;IACH,6CAGC;IAED;;;;OAIG;IACH,cAHW,eAAe,GACb,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,MAAM,CAQlB;IAED;;;OAGG;IACH,mBAEC;IAGL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;;iBAUS,eAAe;mBAKf,eAAe;;mBA5MN,+BAA+B"}
1
+ {"version":3,"file":"NumericInterval.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/interval/NumericInterval.js"],"names":[],"mappings":"AAKA;IACI;;;;;OAKG;IACH,kBAJW,MAAM,QACN,MAAM,EAwBhB;IAZG;;;OAGG;IACH,KAFU,MAAM,CAEF;IACd;;;OAGG;IACH,KAFU,MAAM,CAEF;IAEd,0DAA6B;IAIjC;;;;OAIG;IACH,SAHW,MAAM,OACN,MAAM,QAsBhB;IAED;;;OAGG;IACH,YAFW,eAAe,QAIzB;IAED;;;OAGG;IACH,sBAFW,MAAM,QAahB;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;OAGG;IACH,UAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,gCAFa,MAAM,CAMlB;IAED,0BAEC;IAED;;;MAKC;IAED;;;OAGG;IACH,2CAGC;IAED;;;OAGG;IACH,6CAGC;IAED;;;;OAIG;IACH,cAHW,eAAe,GACb,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,MAAM,CAQlB;IAED;;;OAGG;IACH,mBAEC;IAGL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;;iBAUS,eAAe;mBAKf,eAAe;;mBA5MN,+BAA+B"}
@@ -1,13 +1,7 @@
1
- /**
2
- *
3
- * @param {number} min
4
- * @param {number} max
5
- * @constructor
6
- */
7
1
  import { assert } from "../../assert.js";
8
2
  import Signal from "../../events/signal/Signal.js";
9
- import { inverseLerp } from "../inverseLerp.js";
10
3
  import { computeHashFloat } from "../../primitives/numbers/computeHashFloat.js";
4
+ import { inverseLerp } from "../inverseLerp.js";
11
5
 
12
6
  export class NumericInterval {
13
7
  /**
@@ -23,7 +17,7 @@ export class NumericInterval {
23
17
  assert.isNumber(min, 'min');
24
18
  assert.isNumber(max, 'max');
25
19
 
26
- assert.ok(max >= min, `max=${max} must be >= than min=${min}`);
20
+ assert.greaterThanOrEqual(max, min, `max [${max}] must be >= than min[${min}]`);
27
21
 
28
22
  /**
29
23
  *
@@ -93,9 +87,9 @@ export class NumericInterval {
93
87
  }
94
88
 
95
89
  /**
96
- * Performs inverse linear interpolation on a given input
97
- * @param {number} v
98
- * @returns {number}
90
+ * Compute normalized position of input within this interval, where result is 0 if input is equal to `min`, and 1 when input is equal to `max`
91
+ * @param {number} v value to be normalized
92
+ * @returns {number} value between 0..1 if input is within [min,max] range, otherwise result will be extrapolated proportionately outside the 0,1 region
99
93
  */
100
94
  normalizeValue(v) {
101
95
  return inverseLerp(this.min, this.max, v);
@@ -123,7 +117,7 @@ export class NumericInterval {
123
117
  * @returns {number}
124
118
  */
125
119
  computeAverage() {
126
- return (this.min + this.max) / 2;
120
+ return (this.min + this.max) * 0.5;
127
121
  }
128
122
 
129
123
  /**
@@ -132,7 +126,7 @@ export class NumericInterval {
132
126
  * @returns {number}
133
127
  */
134
128
  sampleRandom(random) {
135
- assert.equal(typeof random, 'function', `random must be a function, instead was ${typeof random}`);
129
+ assert.isFunction(random, "random");
136
130
 
137
131
  return this.min + random() * (this.max - this.min);
138
132
  }
@@ -78,3 +78,12 @@ test("sampleRandom", () => {
78
78
  expect(sut.sampleRandom(() => 1)).toBe(7);
79
79
  expect(sut.sampleRandom(() => 0.5)).toBeCloseTo(2);
80
80
  });
81
+
82
+ test("computeAverage", () => {
83
+ expect(new NumericInterval(0, 0).computeAverage()).toBe(0);
84
+ expect(new NumericInterval(1, 1).computeAverage()).toBe(1);
85
+ expect(new NumericInterval(-1, -1).computeAverage()).toBe(-1);
86
+
87
+ expect(new NumericInterval(3, 7).computeAverage()).toBe(5);
88
+ expect(new NumericInterval(3.1, 7.1).computeAverage()).toBe(5.1);
89
+ });
@@ -1,6 +1,8 @@
1
1
  import { max3 } from "./max3.js";
2
2
 
3
3
  test("max3", () => {
4
+ expect(max3(0, 0, 0)).toBe(0);
5
+
4
6
  expect(max3(-1, -3, 1)).toBe(1);
5
7
 
6
8
  expect(max3(-3, -1, 1)).toBe(1);
@@ -1,6 +1,8 @@
1
1
  import { min3 } from "./min3.js";
2
2
 
3
3
  test("min3", () => {
4
+ expect(min3(0,0,0)).toBe(0);
5
+
4
6
  expect(min3(-1, -3, 1)).toBe(-3);
5
7
 
6
8
  expect(min3(-3, -1, 1)).toBe(-3);
@@ -232,14 +232,14 @@ export class GeometrySpatialQueryAccelerator {
232
232
  * @returns {BinaryUint32BVH}
233
233
  */
234
234
  __buildBVH(geometry) {
235
+ const bvh = new BinaryUint32BVH();
236
+
235
237
  const position_attribute = geometry.getAttribute('position');
236
238
  const index_attribute = geometry.getIndex();
237
239
 
238
240
  const de_interleaved_position_attribute = deinterleaveBufferAttribute(position_attribute);
239
241
  const vertices = de_interleaved_position_attribute.array;
240
242
 
241
- const bvh = new BinaryUint32BVH();
242
-
243
243
  if (index_attribute === undefined || index_attribute === null) {
244
244
  bvh32_from_unindexed_geometry(bvh, vertices);
245
245
  } else {