@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assert } from "../../../core/assert.js";
|
|
2
2
|
import { ArrayIteratorRandom } from "../../../core/collection/array/iterator/ArrayIteratorRandom.js";
|
|
3
|
+
import { circle_area } from "../../../core/geom/2d/circle/circle_area.js";
|
|
3
4
|
import { clamp } from "../../../core/math/clamp.js";
|
|
4
5
|
import { clamp01 } from "../../../core/math/clamp01.js";
|
|
5
6
|
import { NumericInterval } from "../../../core/math/interval/NumericInterval.js";
|
|
@@ -13,15 +14,6 @@ import { actionTask } from "../../../core/process/task/util/actionTask.js";
|
|
|
13
14
|
import { MarkerNodeMatcherAny } from "../../markers/matcher/MarkerNodeMatcherAny.js";
|
|
14
15
|
import { GridTaskGenerator } from "../GridTaskGenerator.js";
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @param {number} radius
|
|
20
|
-
*/
|
|
21
|
-
function estimateDensityTarget(radius) {
|
|
22
|
-
return Math.PI * radius * radius;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
17
|
export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
26
18
|
|
|
27
19
|
/**
|
|
@@ -43,7 +35,7 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
43
35
|
scale = new NumericInterval(1, 1);
|
|
44
36
|
|
|
45
37
|
/**
|
|
46
|
-
* RNG seed
|
|
38
|
+
* RNG seed
|
|
47
39
|
* @type {number}
|
|
48
40
|
* @private
|
|
49
41
|
*/
|
|
@@ -77,13 +69,14 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
77
69
|
/**
|
|
78
70
|
*
|
|
79
71
|
* @param {GridData} grid
|
|
80
|
-
* @param x0
|
|
81
|
-
* @param y0
|
|
82
|
-
* @param x1
|
|
83
|
-
* @param y1
|
|
72
|
+
* @param {number} x0
|
|
73
|
+
* @param {number} y0
|
|
74
|
+
* @param {number} x1
|
|
75
|
+
* @param {number} y1
|
|
76
|
+
* @returns {number}
|
|
84
77
|
*/
|
|
85
78
|
estimateTapCount(grid, x0, y0, x1, y1) {
|
|
86
|
-
const random = seededRandom(
|
|
79
|
+
const random = seededRandom(this.__seed + 91234);
|
|
87
80
|
|
|
88
81
|
/*
|
|
89
82
|
for tap count we ween 3 things:
|
|
@@ -95,17 +88,23 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
95
88
|
const width = x1 - x0;
|
|
96
89
|
const height = y1 - y0;
|
|
97
90
|
|
|
98
|
-
const
|
|
91
|
+
const grid_cell_count = width * height;
|
|
99
92
|
|
|
100
|
-
const SAMPLE_SIZE = 60 +
|
|
93
|
+
const SAMPLE_SIZE = 60 + grid_cell_count * 0.01;
|
|
101
94
|
|
|
102
95
|
const x_max = width - 1;
|
|
103
96
|
const y_max = height - 1;
|
|
104
97
|
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
* @type {number[]}
|
|
101
|
+
*/
|
|
105
102
|
const samplesCollisions = [];
|
|
106
103
|
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @type {number[]}
|
|
107
|
+
*/
|
|
109
108
|
const samplesSize = [];
|
|
110
109
|
|
|
111
110
|
const SIZE_SAMPLE_LIMIT = 10 + SAMPLE_SIZE * 3;
|
|
@@ -121,8 +120,6 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
121
120
|
|
|
122
121
|
const density = clamp01(densityValue);
|
|
123
122
|
|
|
124
|
-
samplesDensity.push(density);
|
|
125
|
-
|
|
126
123
|
if (density <= 0) {
|
|
127
124
|
continue;
|
|
128
125
|
}
|
|
@@ -156,9 +153,9 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
156
153
|
const meanNodeSize = samplesSize.length > 0 ? computeStatisticalMean(samplesSize) : 1;
|
|
157
154
|
|
|
158
155
|
//compute relative density per unit square of a single marker
|
|
159
|
-
const meanSingleNodeDensity =
|
|
156
|
+
const meanSingleNodeDensity = circle_area(meanNodeSize);
|
|
160
157
|
|
|
161
|
-
const saturationTapCount =
|
|
158
|
+
const saturationTapCount = grid_cell_count / meanSingleNodeDensity;
|
|
162
159
|
|
|
163
160
|
// it is possible that a tap will collide with other existing nodes, in which situation the tap is rejected, to account for that we want to estimate how often this will happen and increase the tap count accordingly
|
|
164
161
|
const collisionCompensation = clamp(1 / (1 - collisionProbability), 1, 10);
|
|
@@ -176,7 +173,11 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
176
173
|
* @param {number} y1
|
|
177
174
|
* @returns {Task}
|
|
178
175
|
*/
|
|
179
|
-
processArea(
|
|
176
|
+
processArea(
|
|
177
|
+
seed,
|
|
178
|
+
grid,
|
|
179
|
+
x0, y0, x1, y1
|
|
180
|
+
) {
|
|
180
181
|
|
|
181
182
|
//we want to estimate average size of a marker
|
|
182
183
|
|
|
@@ -203,8 +204,6 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
203
204
|
*/
|
|
204
205
|
const scale = this.scale;
|
|
205
206
|
|
|
206
|
-
const self = this;
|
|
207
|
-
|
|
208
207
|
const random = seededRandom(seed);
|
|
209
208
|
|
|
210
209
|
const width = x1 - x0;
|
|
@@ -232,7 +231,7 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
232
231
|
//sample density mask
|
|
233
232
|
const densityValue = density.execute(grid, _x, _y, 0);
|
|
234
233
|
|
|
235
|
-
if (densityValue
|
|
234
|
+
if (densityValue <= 1e-6) {
|
|
236
235
|
// 0% chance
|
|
237
236
|
return TaskSignal.Continue;
|
|
238
237
|
}
|
|
@@ -277,24 +276,22 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
277
276
|
return TaskSignal.Continue;
|
|
278
277
|
}
|
|
279
278
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
return new Task({
|
|
280
|
+
name: 'Density marker distribution',
|
|
281
|
+
cycleFunction,
|
|
282
|
+
initializer: () => {
|
|
283
283
|
|
|
284
|
-
|
|
285
|
-
iteration = 0;
|
|
284
|
+
random.setCurrentSeed(seed);
|
|
286
285
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
assert.ok(!Number.isNaN(iterationLimit), 'iterationLimit is NaN');
|
|
286
|
+
iterationLimit = this.estimateTapCount(grid, x0, y0, x1, y1);
|
|
287
|
+
iteration = 0;
|
|
290
288
|
|
|
291
|
-
|
|
292
|
-
|
|
289
|
+
assert.isNumber(iterationLimit, 'iterationLimit');
|
|
290
|
+
assert.isFiniteNumber(iterationLimit, 'iterationLimit');
|
|
291
|
+
assert.ok(!Number.isNaN(iterationLimit), 'iterationLimit is NaN');
|
|
293
292
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
cycleFunction,
|
|
297
|
-
initializer,
|
|
293
|
+
rejectedSampleBudget = iterationLimit * 0.15;
|
|
294
|
+
},
|
|
298
295
|
estimatedDuration: height * width / 6000,
|
|
299
296
|
computeProgress() {
|
|
300
297
|
if (iterationLimit === 0) {
|
|
@@ -312,9 +309,11 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
312
309
|
const random = seededRandom(seed);
|
|
313
310
|
|
|
314
311
|
const tile_size = 16;
|
|
315
|
-
|
|
312
|
+
|
|
313
|
+
|
|
316
314
|
const tasks = [];
|
|
317
315
|
|
|
316
|
+
//we want to estimate average size of a marker
|
|
318
317
|
const tInitialize = actionTask(() => {
|
|
319
318
|
|
|
320
319
|
if (!this.density.initialized) {
|
|
@@ -324,12 +323,21 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
324
323
|
this.action.initialize(grid, seed);
|
|
325
324
|
});
|
|
326
325
|
|
|
326
|
+
/*
|
|
327
|
+
we break the entire region into smaller tiles (16x16)
|
|
328
|
+
this puts an upper bound of sorts on how many samples we have to take, irrespective of actual grid size
|
|
329
|
+
these tiles also give us something closer to blue noise distribution
|
|
330
|
+
The assumption with which the tile size was chosen is average marker size of ~1
|
|
331
|
+
Actual tile size was tweaked using empirical tests
|
|
332
|
+
*/
|
|
327
333
|
|
|
328
334
|
for (let j = 0; j < grid.height; j += tile_size) {
|
|
335
|
+
|
|
329
336
|
const y0 = j;
|
|
330
337
|
const y1 = min2(grid.height, j + tile_size);
|
|
331
338
|
|
|
332
339
|
for (let i = 0; i < grid.width; i += tile_size) {
|
|
340
|
+
|
|
333
341
|
const x0 = i;
|
|
334
342
|
const x1 = min2(grid.width, i + tile_size);
|
|
335
343
|
|
|
@@ -343,7 +351,7 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
343
351
|
}
|
|
344
352
|
}
|
|
345
353
|
|
|
346
|
-
//build a random dependency chain to ensure that tiles are not processed in parallel, thus crating race
|
|
354
|
+
// build a random dependency chain to ensure that tiles are not processed in parallel, thus crating race conditions and leading to non-deterministic result
|
|
347
355
|
const iteratorRandom = new ArrayIteratorRandom();
|
|
348
356
|
iteratorRandom.initialize(tasks);
|
|
349
357
|
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export class ModifyPatchSampler2DAction extends Action<any> {
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {Sampler2D} sampler
|
|
5
|
-
* @param {number[]} bounds
|
|
6
|
-
*/
|
|
7
|
-
constructor(sampler: Sampler2D, bounds: number[]);
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @type {Sampler2D}
|
|
11
|
-
* @private
|
|
12
|
-
*/
|
|
13
|
-
private __sampler;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @type {number[]}
|
|
17
|
-
* @private
|
|
18
|
-
*/
|
|
19
|
-
private __bounds;
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @type {Sampler2D}
|
|
23
|
-
*/
|
|
24
|
-
__patch_new: Sampler2D;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @type {Sampler2D}
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
private __patch_old;
|
|
31
|
-
get patch(): Sampler2D;
|
|
32
|
-
get x(): number;
|
|
33
|
-
get y(): number;
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @param {number} x coordinate in global space
|
|
37
|
-
* @param {number} y coordinate in global space
|
|
38
|
-
* @param {number} [channel]
|
|
39
|
-
* @returns {number} delta between original value and the new one after the change
|
|
40
|
-
*/
|
|
41
|
-
computeDelta(x: number, y: number, channel?: number): number;
|
|
42
|
-
computeByteSize(): any;
|
|
43
|
-
apply(context: any): Promise<void>;
|
|
44
|
-
revert(context: any): Promise<void>;
|
|
45
|
-
}
|
|
46
|
-
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
47
|
-
import { Sampler2D } from "../../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
48
|
-
//# sourceMappingURL=ModifyPatchSampler2DAction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModifyPatchTextureArray2DAction.d.ts","sourceRoot":"","sources":["ModifyPatchTextureArray2DAction.js"],"names":[],"mappings":"AAKA;IACI;;;;;OAKG;IACH,kBAJW,MAAM,EAAE,GAAC,UAAU,GAAC,WAAW,GAAC,YAAY,mBAC5C,MAAM,EAAE,UACR,MAAM,EAAE,EA6BlB;IAtBG,2DAAkB;IAClB,4BAAwC;IACxC,mBAAsB;IAUtB;;;OAGG;IACH,oBAAmD;IACnD;;;OAGG;IACH,oBAAmD;IAGvD;;;;;;;;;OASG;IACH,kCARW,MAAM,YACN,MAAM,iCAEN,MAAM,UACN,MAAM,cACN,MAAM,cACN,MAAM,QAiEhB;IAED,oCAEC;IAOD,mCA8BC;IAED,oCAuBC;CACJ;uBArLsB,0CAA0C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PaintTerrainOverlayAction.d.ts","sourceRoot":"","sources":["PaintTerrainOverlayAction.js"],"names":[],"mappings":";AAIA;IACI;;;;;;;OAOG;IACH,oBANW,MAAM,KACN,MAAM,KACN,MAAM,SACN,OAAO,EAYjB;IAPG,eAAoB;IACpB,UAAU;IACV,UAAU;IACV,eAAkB;IAElB,aAAmB;IACnB,kBAA6B;IAGjC,kCASC;IAED,mCAKC;CACJ;uBAxCsB,0CAA0C;oBAD7C,mCAAmC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PatchTerrainHeightAction.d.ts","sourceRoot":"","sources":["PatchTerrainHeightAction.js"],"names":[],"mappings":"AAEA;IACI;;;;;;;OAOG;IACH,iCALW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,EAUhB;IALG;;;OAGG;IACH,iBAAsB;IAG1B,+BAgCC;CAaJ;2CAlE0C,iCAAiC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionAddAction.d.ts","sourceRoot":"","sources":["SelectionAddAction.js"],"names":[],"mappings":";AAGA;IACI;;;;OAIG;IACH,sBAHW,KAAK,EAWf;IANG,cAAoB;IACpB;;;OAGG;IACH,UAFU,KAAK,CAES;IAG5B,kCAMC;IAED,mCAEC;CACJ;uBA9BsB,0CAA0C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionClearAction.d.ts","sourceRoot":"","sources":["SelectionClearAction.js"],"names":[],"mappings":";AAEA;IACI,cAGC;IADG,cAAoB;IAGxB,kCAGC;IAED,mCAEC;CACJ;uBAhBsB,0CAA0C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionRemoveAction.d.ts","sourceRoot":"","sources":["SelectionRemoveAction.js"],"names":[],"mappings":";AAEA;IACI,2BAIC;IAFG,cAAoB;IACpB,cAAwB;IAG5B,kCAUC;IAED,mCAEC;CACJ;uBAxBsB,0CAA0C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TransformModifyAction.d.ts","sourceRoot":"","sources":["TransformModifyAction.js"],"names":[],"mappings":";AAGA;IACI;;;;;OAKG;IACH,mCAHW,SAAS,EASnB;IAHG,cAAoB;IACpB,oBAAwB;IACxB,YAAoB;IAqBxB,mCAMC;CACJ;uBA1CsB,0CAA0C;0BADvC,gDAAgD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WriteGridValueAction.d.ts","sourceRoot":"","sources":["WriteGridValueAction.js"],"names":[],"mappings":";AAGA;IACI,qDAUC;IAPG,YAAoB;IACpB,OAAU;IACV,OAAU;IACV,WAAkB;IAElB,uBAAoB;IACpB,iBAAoB;IAGxB,kCAgBC;IAED,mCAGC;CACJ;uBArCsB,0CAA0C;yBADxC,mDAAmD"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {EntityComponentDataset} ecd
|
|
4
|
-
* @param {number} entity
|
|
5
|
-
* @returns {EntityReference}
|
|
6
|
-
*/
|
|
7
|
-
export function read_entity_reference(ecd: EntityComponentDataset, entity: number): EntityReference;
|
|
8
|
-
import { EntityReference } from "./EntityReference.js";
|
|
9
|
-
//# sourceMappingURL=read_entity_reference.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read_entity_reference.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/read_entity_reference.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,2CAJW,sBAAsB,UACtB,MAAM,GACJ,eAAe,CAQ3B;gCAd+B,sBAAsB"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { EntityReference } from "./EntityReference.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {EntityComponentDataset} ecd
|
|
6
|
-
* @param {number} entity
|
|
7
|
-
* @returns {EntityReference}
|
|
8
|
-
*/
|
|
9
|
-
export function read_entity_reference(ecd, entity) {
|
|
10
|
-
|
|
11
|
-
const generation = ecd.getEntityGeneration(entity);
|
|
12
|
-
|
|
13
|
-
return EntityReference.from(entity, generation);
|
|
14
|
-
|
|
15
|
-
}
|