@woosh/meep-engine 2.31.1 → 2.31.5

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.
Files changed (55) hide show
  1. package/core/binary/BitSet.js +5 -1
  2. package/core/collection/RingBuffer.js +16 -1
  3. package/core/geom/Vector1.js +228 -219
  4. package/core/geom/Vector2.js +547 -502
  5. package/core/geom/Vector3.js +8 -0
  6. package/core/geom/Vector4.js +322 -311
  7. package/core/graph/v2/Graph.js +6 -6
  8. package/core/model/ObservedBoolean.js +12 -4
  9. package/core/process/worker/WorkerBuilder.js +27 -9
  10. package/core/process/worker/WorkerProxy.js +6 -0
  11. package/editor/Editor.js +10 -1
  12. package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +3 -1
  13. package/engine/EngineHarness.js +1 -1
  14. package/engine/ecs/parent/ParentEntitySystem.js +1 -1
  15. package/engine/ecs/terrain/ecs/Terrain.js +11 -2
  16. package/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +10 -10
  17. package/engine/graphics/camera/makeOrbitalCameraController.js +7 -1
  18. package/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +4 -31
  19. package/engine/graphics/ecs/mesh/Mesh.js +9 -3
  20. package/engine/graphics/ecs/path/entity/EntityPath.js +7 -7
  21. package/engine/graphics/ecs/trail2d/Trail2DSystem.js +31 -16
  22. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +17 -8
  23. package/engine/graphics/micron/build/graph/metis/metis.js +23 -33
  24. package/engine/graphics/micron/render/v1/MaterialContext.js +21 -2
  25. package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +1 -1
  26. package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +1 -1
  27. package/engine/graphics/render/buffer/buffers/NormalFrameBuffer.js +25 -16
  28. package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +6 -5
  29. package/engine/graphics/trail/x/RibbonMaterialX.js +7 -2
  30. package/engine/grid/components/GridPosition.js +22 -122
  31. package/engine/grid/components/GridPositionSerializationAdapter.js +58 -0
  32. package/engine/grid/components/GridPositionSerializationUpdater_0_1.js +37 -0
  33. package/engine/intelligence/mcts/MonteCarlo.js +12 -15
  34. package/engine/intelligence/mcts/StateNode.js +3 -3
  35. package/generation/GridTags.js +3 -2
  36. package/generation/example/SampleGenerator0.js +1 -1
  37. package/generation/example/generators/{mir_generator_place_buff_objects.js → interactive/mir_generator_place_buff_objects.js} +97 -26
  38. package/generation/example/generators/mir_generator_place_starting_point.js +12 -5
  39. package/generation/example/grid/configureMirGrid.js +1 -1
  40. package/generation/filtering/CellFilter.js +14 -0
  41. package/generation/filtering/numeric/util/CellFilterLogToConsole.js +2 -1
  42. package/generation/grid/GridData.js +18 -14
  43. package/generation/grid/MarkerMatchCounter.js +23 -0
  44. package/generation/grid/generation/GridTaskApplyActionToCells.js +86 -0
  45. package/generation/grid/generation/grid/select/CellSupplier.js +28 -0
  46. package/generation/grid/generation/grid/select/CellSupplierBestN.js +188 -0
  47. package/generation/grid/generation/grid/select/CellSupplierPathUpHill.js +187 -0
  48. package/generation/markers/GridActionRuleSet.js +1 -1
  49. package/generation/markers/MarkerNode.js +18 -0
  50. package/generation/markers/debug/visualizeMarkers.js +8 -1
  51. package/generation/markers/transform/MarkerNodeTransformerSequence.js +47 -0
  52. package/generation/placement/GridCellActionTransformNearbyMarkers.js +9 -17
  53. package/generation/rules/CellMatcherFromFilter.js +38 -0
  54. package/generation/rules/cell/CellMatcherContainsMarkerWithinRadius.js +1 -1
  55. package/package.json +3 -3
@@ -112,6 +112,10 @@ function BitSet() {
112
112
  this.__firstClearBitIndex = 0;
113
113
  }
114
114
 
115
+ BitSet.prototype.preventShrink = function () {
116
+ this.__shrinkFactor = 0;
117
+ }
118
+
115
119
  /**
116
120
  *
117
121
  * @param {number} numBits
@@ -145,7 +149,7 @@ BitSet.prototype.capacity = function () {
145
149
  * @private
146
150
  */
147
151
  BitSet.prototype.__resize = function (bitCapacity) {
148
- assert.ok(Number.isInteger(bitCapacity), `bitCapacity must be an integer, instead was '${bitCapacity}'`)
152
+ assert.isNonNegativeInteger(bitCapacity, 'bitCapacity');
149
153
 
150
154
  const byteCapacity = Math.ceil(bitCapacity / 8);
151
155
 
@@ -29,7 +29,22 @@ export class RingBuffer {
29
29
  * @return {V}
30
30
  */
31
31
  getHead() {
32
- return this.data[this.head];
32
+ return this.data[this.head - 1];
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @param {number} offset
38
+ * @returns {V}
39
+ */
40
+ getFromHead(offset) {
41
+ let i = this.head - (offset + 1);
42
+
43
+ while (i < 0) {
44
+ i += this.size;
45
+ }
46
+
47
+ return this.data[i];
33
48
  }
34
49
 
35
50
  clear() {
@@ -9,267 +9,276 @@ import { clamp } from "../math/clamp.js";
9
9
  import { computeHashFloat } from "../math/MathUtils.js";
10
10
 
11
11
 
12
- /**
13
- *
14
- * @param {number} [x=0]
15
- * @constructor
16
- * @class
17
- * @property {number} x
18
- */
19
- function Vector1(x = 0) {
20
- assert.equal(typeof x, "number", `X must be of type "number", instead was "${typeof x}"`);
12
+ class Vector1 extends Number {
13
+ /**
14
+ *
15
+ * @param {number} [x=0]
16
+ * @constructor
17
+ * @class
18
+ * @property {number} x
19
+ */
20
+ constructor(x = 0) {
21
+ super();
21
22
 
22
- assert.ok(!Number.isNaN(x), `X must be a valid number, instead was NaN`);
23
+ assert.equal(typeof x, "number", `X must be of type "number", instead was "${typeof x}"`);
23
24
 
24
- this.x = x;
25
- this.onChanged = new Signal();
26
- }
25
+ assert.ok(!Number.isNaN(x), `X must be a valid number, instead was NaN`);
27
26
 
28
- Vector1.typeName = "Vector1";
27
+ this.x = x;
29
28
 
30
- Vector1.prototype = Object.create(Number.prototype);
29
+ this.onChanged = new Signal();
30
+ }
31
31
 
32
- /**
33
- * @readonly
34
- * @type {boolean}
35
- */
36
- Vector1.prototype.isVector1 = true;
32
+ /**
33
+ * Inherited from Number class
34
+ * @returns {number}
35
+ */
36
+ valueOf() {
37
+ return this.x;
38
+ }
37
39
 
38
- /**
39
- * Inherited from Number class
40
- * @returns {number}
41
- */
42
- Vector1.prototype.valueOf = function () {
43
- return this.x;
44
- };
40
+ /**
41
+ *
42
+ * @returns {string}
43
+ */
44
+ toString() {
45
+ return String(this.x);
46
+ }
45
47
 
46
- /**
47
- *
48
- * @returns {string}
49
- */
50
- Vector1.prototype.toString = function () {
51
- return String(this.x);
52
- };
48
+ /**
49
+ *
50
+ * @returns {number}
51
+ */
52
+ getValue() {
53
+ return this.x;
54
+ }
53
55
 
54
- /**
55
- *
56
- * @returns {number}
57
- */
58
- Vector1.prototype.getValue = function () {
59
- return this.x;
60
- };
56
+ /**
57
+ *
58
+ * @param {Vector1} other
59
+ * @returns {number}
60
+ */
61
+ compareTo(other) {
62
+ return this.x - other.x;
63
+ }
61
64
 
62
- /**
63
- *
64
- * @param {Vector1} other
65
- * @returns {number}
66
- */
67
- Vector1.prototype.compareTo = function (other) {
68
- return this.x - other.x;
69
- };
65
+ /**
66
+ *
67
+ * @param {number} x
68
+ * @returns {Vector1}
69
+ */
70
+ set(x) {
71
+ assert.equal(typeof x, "number", `X must be of type "number", instead was "${typeof x}"`);
70
72
 
71
- /**
72
- *
73
- * @param {Vector1} a
74
- * @param {Vector1} b
75
- * @return {number}
76
- */
77
- Vector1.compare = function (a, b) {
78
- return a.x - b.x;
79
- };
73
+ assert.ok(!Number.isNaN(x), `X must be a valid number, instead was NaN`);
80
74
 
81
- /**
82
- *
83
- * @param {number} x
84
- * @returns {Vector1}
85
- */
86
- Vector1.prototype.set = function (x) {
87
- assert.equal(typeof x, "number", `X must be of type "number", instead was "${typeof x}"`);
75
+ const oldValue = this.x;
76
+ if (oldValue !== x) {
77
+ this.x = x;
78
+
79
+ if (this.onChanged.hasHandlers()) {
80
+ this.onChanged.send2(x, oldValue);
81
+ }
82
+ }
88
83
 
89
- assert.ok(!Number.isNaN(x), `X must be a valid number, instead was NaN`);
84
+ return this;
85
+ }
90
86
 
91
- const oldValue = this.x;
92
- if (oldValue !== x) {
87
+ /**
88
+ * Set value without triggering {@link #onChanged} signal
89
+ * @param {number} x
90
+ */
91
+ setSilent(x) {
93
92
  this.x = x;
93
+ }
94
94
 
95
- if (this.onChanged.hasHandlers()) {
96
- this.onChanged.send2(x, oldValue);
97
- }
95
+ /**
96
+ *
97
+ * @return {boolean}
98
+ */
99
+ isZero() {
100
+ return this.x === 0;
98
101
  }
99
102
 
100
- return this;
101
- };
103
+ increment() {
104
+ this._add(1);
105
+ }
102
106
 
103
- /**
104
- * Set value without triggering {@link #onChanged} signal
105
- * @param {number} x
106
- */
107
- Vector1.prototype.setSilent = function (x) {
108
- this.x = x;
109
- };
107
+ decrement() {
108
+ this._add(-1);
109
+ }
110
110
 
111
- /**
112
- *
113
- * @return {boolean}
114
- */
115
- Vector1.prototype.isZero = function () {
116
- return this.x === 0;
117
- }
111
+ /**
112
+ *
113
+ * @param {Number} v
114
+ * @return {Vector1}
115
+ */
116
+ _add(v) {
117
+ return this.set(this.x + v);
118
+ }
118
119
 
119
- Vector1.prototype.increment = function () {
120
- this._add(1);
121
- };
120
+ /**
121
+ *
122
+ * @param {Vector1|Vector2|Vector3|Vector4} other
123
+ */
124
+ add(other) {
125
+ return this._add(other.x);
126
+ }
122
127
 
123
- Vector1.prototype.decrement = function () {
124
- this._add(-1);
125
- };
128
+ /**
129
+ *
130
+ * @param {Number} v
131
+ * @return {Vector1}
132
+ */
133
+ _sub(v) {
134
+ return this._add(-v);
135
+ }
126
136
 
127
- /**
128
- *
129
- * @param {Number} v
130
- * @return {Vector1}
131
- */
132
- Vector1.prototype._add = function (v) {
133
- return this.set(this.x + v);
134
- };
137
+ /**
138
+ *
139
+ * @param {Vector1} other
140
+ * @returns {Vector1}
141
+ */
142
+ sub(other) {
143
+ return this._sub(other.x);
144
+ }
135
145
 
136
- /**
137
- *
138
- * @param {Vector1|Vector2|Vector3|Vector4} other
139
- */
140
- Vector1.prototype.add = function (other) {
141
- return this._add(other.x);
142
- };
146
+ /**
147
+ *
148
+ * @param {Vector1} other
149
+ * @returns {Vector1}
150
+ */
151
+ multiply(other) {
152
+ return this.set(this.x * other.x);
153
+ }
143
154
 
144
- /**
145
- *
146
- * @param {Number} v
147
- * @return {Vector1}
148
- */
149
- Vector1.prototype._sub = function (v) {
150
- return this._add(-v);
151
- };
155
+ /**
156
+ *
157
+ * @param {number} v
158
+ */
159
+ multiplyScalar(v) {
160
+ this.set(this.x * v);
161
+ }
152
162
 
153
- /**
154
- *
155
- * @param {Vector1} other
156
- * @returns {Vector1}
157
- */
158
- Vector1.prototype.sub = function (other) {
159
- return this._sub(other.x);
160
- };
163
+ /**
164
+ *
165
+ * @param {number} low
166
+ * @param {number} high
167
+ * @returns {Vector1}
168
+ */
169
+ clamp(low, high) {
170
+ return this.set(clamp(this.x, low, high));
171
+ }
161
172
 
162
- /**
163
- *
164
- * @param {Vector1} other
165
- * @returns {Vector1}
166
- */
167
- Vector1.prototype.multiply = function (other) {
168
- return this.set(this.x * other.x);
169
- };
173
+ /**
174
+ *
175
+ * @param {Vector1|Vector2|Vector3|Vector4} other
176
+ */
177
+ copy(other) {
178
+ this.set(other.x);
179
+ }
170
180
 
171
- /**
172
- *
173
- * @param {number} v
174
- */
175
- Vector1.prototype.multiplyScalar = function (v) {
176
- this.set(this.x * v);
177
- };
181
+ /**
182
+ *
183
+ * @returns {Vector1}
184
+ */
185
+ clone() {
186
+ return new Vector1(this.x);
187
+ }
178
188
 
179
- /**
180
- *
181
- * @param {number} low
182
- * @param {number} high
183
- * @returns {Vector1}
184
- */
185
- Vector1.prototype.clamp = function (low, high) {
186
- return this.set(clamp(this.x, low, high));
187
- };
189
+ /**
190
+ *
191
+ * @param {Vector1} other
192
+ * @returns {boolean}
193
+ */
194
+ equals(other) {
195
+ return this.x === other.x;
196
+ }
188
197
 
189
- /**
190
- *
191
- * @param {Vector1|Vector2|Vector3|Vector4} other
192
- */
193
- Vector1.prototype.copy = function (other) {
194
- this.set(other.x);
195
- };
198
+ /**
199
+ * @returns {number}
200
+ */
201
+ hash() {
202
+ return computeHashFloat(this.x);
203
+ }
196
204
 
197
- /**
198
- *
199
- * @returns {Vector1}
200
- */
201
- Vector1.prototype.clone = function () {
202
- return new Vector1(this.x);
203
- };
205
+ /**
206
+ *
207
+ * @param {function(newValue:number, oldValue:number)} handler
208
+ */
209
+ process(handler) {
210
+ handler(this.x, this.x);
211
+ this.onChanged.add(handler);
212
+ }
204
213
 
205
- /**
206
- *
207
- * @param {Vector1} other
208
- * @returns {boolean}
209
- */
210
- Vector1.prototype.equals = function (other) {
211
- return this.x === other.x;
212
- };
214
+ toJSON() {
215
+ return this.x;
216
+ }
213
217
 
214
- /**
215
- * @returns {number}
216
- */
217
- Vector1.prototype.hash = function () {
218
- return computeHashFloat(this.x);
219
- };
218
+ fromJSON(val) {
219
+ this.set(val);
220
+ }
220
221
 
221
- /**
222
- *
223
- * @param {function(newValue:number, oldValue:number)} handler
224
- */
225
- Vector1.prototype.process = function (handler) {
226
- handler(this.x, this.x);
227
- this.onChanged.add(handler);
228
- };
222
+ /**
223
+ *
224
+ * @param {number[]} array
225
+ * @param {number} offset
226
+ */
227
+ readFromArray(array, offset) {
228
+ this.set(array[offset]);
229
+ }
229
230
 
230
- Vector1.prototype.toJSON = function () {
231
- return this.x;
232
- };
231
+ /**
232
+ *
233
+ * @param {number[]} array
234
+ * @param {number} offset
235
+ */
236
+ writeToArray(array, offset) {
237
+ array[offset] = this.x;
238
+ }
233
239
 
234
- Vector1.prototype.fromJSON = function (val) {
235
- this.set(val);
236
- };
240
+ /**
241
+ *
242
+ * @param {BinaryBuffer} buffer
243
+ */
244
+ toBinaryBuffer(buffer) {
245
+ buffer.writeFloat64(this.x);
246
+ }
237
247
 
238
- /**
239
- *
240
- * @param {number[]} array
241
- * @param {number} offset
242
- */
243
- Vector1.prototype.readFromArray = function (array, offset) {
244
- this.set(array[offset]);
245
- };
248
+ /**
249
+ *
250
+ * @param {BinaryBuffer} buffer
251
+ */
252
+ fromBinaryBuffer(buffer) {
253
+ const x = buffer.readFloat64();
246
254
 
247
- /**
248
- *
249
- * @param {number[]} array
250
- * @param {number} offset
251
- */
252
- Vector1.prototype.writeToArray = function (array, offset) {
253
- array[offset] = this.x;
254
- };
255
+ this.set(x);
256
+ }
255
257
 
256
- /**
257
- *
258
- * @param {BinaryBuffer} buffer
259
- */
260
- Vector1.prototype.toBinaryBuffer = function (buffer) {
261
- buffer.writeFloat64(this.x);
262
- };
258
+ /**
259
+ *
260
+ * @param {Vector1} a
261
+ * @param {Vector1} b
262
+ * @return {number}
263
+ */
264
+ static compare(a, b) {
265
+ return a.x - b.x;
266
+ }
267
+
268
+ * [Symbol.iterator]() {
269
+
270
+ yield this.x;
271
+
272
+ }
273
+ }
263
274
 
264
275
  /**
265
- *
266
- * @param {BinaryBuffer} buffer
276
+ * @readonly
277
+ * @type {boolean}
267
278
  */
268
- Vector1.prototype.fromBinaryBuffer = function (buffer) {
269
- const x = buffer.readFloat64();
279
+ Vector1.prototype.isVector1 = true;
270
280
 
271
- this.set(x);
272
- };
281
+ Vector1.typeName = "Vector1";
273
282
 
274
283
  /**
275
284
  * @readonly