@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.
- package/core/binary/BitSet.js +5 -1
- package/core/collection/RingBuffer.js +16 -1
- package/core/geom/Vector1.js +228 -219
- package/core/geom/Vector2.js +547 -502
- package/core/geom/Vector3.js +8 -0
- package/core/geom/Vector4.js +322 -311
- package/core/graph/v2/Graph.js +6 -6
- package/core/model/ObservedBoolean.js +12 -4
- package/core/process/worker/WorkerBuilder.js +27 -9
- package/core/process/worker/WorkerProxy.js +6 -0
- package/editor/Editor.js +10 -1
- package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +3 -1
- package/engine/EngineHarness.js +1 -1
- package/engine/ecs/parent/ParentEntitySystem.js +1 -1
- package/engine/ecs/terrain/ecs/Terrain.js +11 -2
- package/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +10 -10
- package/engine/graphics/camera/makeOrbitalCameraController.js +7 -1
- package/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +4 -31
- package/engine/graphics/ecs/mesh/Mesh.js +9 -3
- package/engine/graphics/ecs/path/entity/EntityPath.js +7 -7
- package/engine/graphics/ecs/trail2d/Trail2DSystem.js +31 -16
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +17 -8
- package/engine/graphics/micron/build/graph/metis/metis.js +23 -33
- package/engine/graphics/micron/render/v1/MaterialContext.js +21 -2
- package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +1 -1
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +1 -1
- package/engine/graphics/render/buffer/buffers/NormalFrameBuffer.js +25 -16
- package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +6 -5
- package/engine/graphics/trail/x/RibbonMaterialX.js +7 -2
- package/engine/grid/components/GridPosition.js +22 -122
- package/engine/grid/components/GridPositionSerializationAdapter.js +58 -0
- package/engine/grid/components/GridPositionSerializationUpdater_0_1.js +37 -0
- package/engine/intelligence/mcts/MonteCarlo.js +12 -15
- package/engine/intelligence/mcts/StateNode.js +3 -3
- package/generation/GridTags.js +3 -2
- package/generation/example/SampleGenerator0.js +1 -1
- package/generation/example/generators/{mir_generator_place_buff_objects.js → interactive/mir_generator_place_buff_objects.js} +97 -26
- package/generation/example/generators/mir_generator_place_starting_point.js +12 -5
- package/generation/example/grid/configureMirGrid.js +1 -1
- package/generation/filtering/CellFilter.js +14 -0
- package/generation/filtering/numeric/util/CellFilterLogToConsole.js +2 -1
- package/generation/grid/GridData.js +18 -14
- package/generation/grid/MarkerMatchCounter.js +23 -0
- package/generation/grid/generation/GridTaskApplyActionToCells.js +86 -0
- package/generation/grid/generation/grid/select/CellSupplier.js +28 -0
- package/generation/grid/generation/grid/select/CellSupplierBestN.js +188 -0
- package/generation/grid/generation/grid/select/CellSupplierPathUpHill.js +187 -0
- package/generation/markers/GridActionRuleSet.js +1 -1
- package/generation/markers/MarkerNode.js +18 -0
- package/generation/markers/debug/visualizeMarkers.js +8 -1
- package/generation/markers/transform/MarkerNodeTransformerSequence.js +47 -0
- package/generation/placement/GridCellActionTransformNearbyMarkers.js +9 -17
- package/generation/rules/CellMatcherFromFilter.js +38 -0
- package/generation/rules/cell/CellMatcherContainsMarkerWithinRadius.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { CellSupplier } from "./CellSupplier.js";
|
|
2
|
+
import { BitSet } from "../../../../../core/binary/BitSet.js";
|
|
3
|
+
import { assert } from "../../../../../core/assert.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @type {Uint32Array}
|
|
8
|
+
*/
|
|
9
|
+
const scratch_neighbours = new Uint32Array(4);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Supply cells that trace from source cells up to maximum value cells via hill climbing.
|
|
13
|
+
* Useful for tracing paths between features, such as path between a shipyard and the nearest water source
|
|
14
|
+
*/
|
|
15
|
+
export class CellSupplierPathUpHill extends CellSupplier {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {CellMatcher|null}
|
|
22
|
+
*/
|
|
23
|
+
this.source = null;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @type {CellFilter|null}
|
|
28
|
+
*/
|
|
29
|
+
this.value = null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @type {BitSet}
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
this.__open_set = new BitSet();
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @type {BitSet}
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
this.__visited_set = new BitSet();
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @type { Float32Array|null}
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
this.__cached_values = null;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @type {GridData|null}
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
this.__grid = null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {CellFilter} value
|
|
62
|
+
* @param {CellMatcher} source
|
|
63
|
+
*/
|
|
64
|
+
static from(value, source) {
|
|
65
|
+
assert.equal(value.isCellFilter, true, 'value.isCellFilter !== true');
|
|
66
|
+
assert.equal(source.isCellMatcher, true, 'source.isCellMatcher !== true');
|
|
67
|
+
|
|
68
|
+
const r = new CellSupplierPathUpHill();
|
|
69
|
+
|
|
70
|
+
r.value = value;
|
|
71
|
+
r.source = source;
|
|
72
|
+
|
|
73
|
+
return r;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
initialize(grid, seed) {
|
|
77
|
+
this.__grid = grid;
|
|
78
|
+
|
|
79
|
+
this.source.initialize(grid, seed);
|
|
80
|
+
this.value.ensureInitialized(grid, seed);
|
|
81
|
+
|
|
82
|
+
const grid_size = grid.width * grid.height;
|
|
83
|
+
|
|
84
|
+
this.__open_set.preventShrink();
|
|
85
|
+
this.__open_set.reset();
|
|
86
|
+
this.__open_set.setCapacity(grid_size);
|
|
87
|
+
|
|
88
|
+
this.__visited_set.preventShrink();
|
|
89
|
+
this.__visited_set.reset();
|
|
90
|
+
this.__visited_set.setCapacity(grid_size);
|
|
91
|
+
|
|
92
|
+
this.__cached_values = new Float32Array(grid_size);
|
|
93
|
+
|
|
94
|
+
// identify source cells
|
|
95
|
+
for (let y = 0; y < grid.height; y++) {
|
|
96
|
+
for (let x = 0; x < grid.width; x++) {
|
|
97
|
+
|
|
98
|
+
if (this.source.match(grid, x, y, 0)) {
|
|
99
|
+
|
|
100
|
+
const index = y * grid.width + x;
|
|
101
|
+
this.__open_set.set(index, true);
|
|
102
|
+
this.__visited_set.set(index, true);
|
|
103
|
+
|
|
104
|
+
this.__cached_values[index] = this.value.execute(grid, x, y, 0);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
next() {
|
|
112
|
+
const grid_width = this.__grid.width;
|
|
113
|
+
const current_index = this.__open_set.nextSetBit(0);
|
|
114
|
+
|
|
115
|
+
if (current_index === -1) {
|
|
116
|
+
// no more
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.__open_set.clear(current_index);
|
|
121
|
+
|
|
122
|
+
const current_value = this.__cached_values[current_index];
|
|
123
|
+
|
|
124
|
+
const current_x = current_index % grid_width;
|
|
125
|
+
const current_y = (current_index / grid_width) | 0;
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
// update neighbours of the cell
|
|
129
|
+
let neighbour_count = 0;
|
|
130
|
+
|
|
131
|
+
if (current_y > 0) {
|
|
132
|
+
// up
|
|
133
|
+
scratch_neighbours[neighbour_count] = current_index - grid_width;
|
|
134
|
+
neighbour_count++;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (current_x > 0) {
|
|
138
|
+
// left
|
|
139
|
+
scratch_neighbours[neighbour_count] = current_index - 1;
|
|
140
|
+
neighbour_count++;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (current_x < grid_width - 1) {
|
|
144
|
+
// right
|
|
145
|
+
scratch_neighbours[neighbour_count] = current_index + 1;
|
|
146
|
+
neighbour_count++;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (current_y < this.__grid.height - 1) {
|
|
150
|
+
// up
|
|
151
|
+
scratch_neighbours[neighbour_count] = current_index + grid_width;
|
|
152
|
+
neighbour_count++;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
for (let i = 0; i < neighbour_count; i++) {
|
|
156
|
+
const neighbour = scratch_neighbours[i];
|
|
157
|
+
|
|
158
|
+
if (this.__visited_set.get(neighbour) || this.__open_set.get(neighbour)) {
|
|
159
|
+
//already visited
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
const n_x = neighbour % grid_width;
|
|
163
|
+
const n_y = (neighbour - n_x) / grid_width;
|
|
164
|
+
|
|
165
|
+
// pick smallest
|
|
166
|
+
const n_v = this.value.execute(this.__grid, n_x, n_y, 0);
|
|
167
|
+
|
|
168
|
+
if (n_v < current_value) {
|
|
169
|
+
// invalid
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
this.__open_set.set(neighbour, true);
|
|
174
|
+
this.__visited_set.set(neighbour, true);
|
|
175
|
+
|
|
176
|
+
this.__cached_values[neighbour] = n_v;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
x: current_x,
|
|
182
|
+
y: current_y,
|
|
183
|
+
rotation: 0
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
}
|
|
@@ -52,6 +52,24 @@ export class MarkerNode {
|
|
|
52
52
|
return this.tags.includes(tag);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param {string[]} tags
|
|
58
|
+
* @returns {boolean}
|
|
59
|
+
*/
|
|
60
|
+
hasAllTags(tags) {
|
|
61
|
+
const n = tags.length;
|
|
62
|
+
const this_tags = this.tags;
|
|
63
|
+
|
|
64
|
+
for (let i = 0; i < n; i++) {
|
|
65
|
+
if (!this_tags.includes(tags[i])) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
55
73
|
/**
|
|
56
74
|
*
|
|
57
75
|
* @returns {MarkerNode}
|
|
@@ -17,6 +17,7 @@ import GUIElement from "../../../engine/ecs/gui/GUIElement.js";
|
|
|
17
17
|
import ViewportPosition from "../../../engine/ecs/gui/position/ViewportPosition.js";
|
|
18
18
|
import HeadsUpDisplay from "../../../engine/ecs/gui/hud/HeadsUpDisplay.js";
|
|
19
19
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
20
|
+
import { MarkerNodeMatcherAny } from "../matcher/MarkerNodeMatcherAny.js";
|
|
20
21
|
|
|
21
22
|
function formatValue(v) {
|
|
22
23
|
|
|
@@ -49,8 +50,9 @@ function CircleGeometry(radius, arc) {
|
|
|
49
50
|
*
|
|
50
51
|
* @param {GridData} grid
|
|
51
52
|
* @param {EntityComponentDataset} ecd
|
|
53
|
+
* @param {MarkerNodeMatcher} marker_filter
|
|
52
54
|
*/
|
|
53
|
-
export function visualizeMarkers(grid, ecd) {
|
|
55
|
+
export function visualizeMarkers({ grid, ecd, marker_filter = MarkerNodeMatcherAny.INSTANCE }) {
|
|
54
56
|
|
|
55
57
|
/**
|
|
56
58
|
*
|
|
@@ -92,6 +94,11 @@ export function visualizeMarkers(grid, ecd) {
|
|
|
92
94
|
for (let i = 0; i < n; i++) {
|
|
93
95
|
const markerNode = markers[i];
|
|
94
96
|
|
|
97
|
+
if (!marker_filter.match(markerNode)) {
|
|
98
|
+
// reject marker
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
95
102
|
const g = new Group();
|
|
96
103
|
|
|
97
104
|
const mark_0 = new ThreeMesh(geometry_0, m0);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { MarkerNodeTransformer } from "./MarkerNodeTransformer.js";
|
|
2
|
+
|
|
3
|
+
export class MarkerNodeTransformerSequence extends MarkerNodeTransformer {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @type {MarkerNodeTransformer[]}
|
|
10
|
+
*/
|
|
11
|
+
this.elements = [];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static from(elements) {
|
|
15
|
+
const r = new MarkerNodeTransformerSequence();
|
|
16
|
+
|
|
17
|
+
r.elements = elements;
|
|
18
|
+
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
initialize(grid, seed) {
|
|
23
|
+
const elements = this.elements;
|
|
24
|
+
const n = elements.length;
|
|
25
|
+
|
|
26
|
+
for (let i = 0; i < n; i++) {
|
|
27
|
+
const e = elements[i];
|
|
28
|
+
e.initialize(grid, seed);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
transform(node, grid) {
|
|
33
|
+
const elements = this.elements;
|
|
34
|
+
const element_count = elements.length;
|
|
35
|
+
|
|
36
|
+
let n = node;
|
|
37
|
+
|
|
38
|
+
// transform
|
|
39
|
+
for (let j = 0; j < element_count; j++) {
|
|
40
|
+
const transformer = elements[j];
|
|
41
|
+
|
|
42
|
+
n = transformer.transform(n, grid);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return n;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -19,9 +19,9 @@ export class GridCellActionTransformNearbyMarkers extends GridCellAction {
|
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
*
|
|
22
|
-
* @type {MarkerNodeTransformer
|
|
22
|
+
* @type {MarkerNodeTransformer}
|
|
23
23
|
*/
|
|
24
|
-
this.
|
|
24
|
+
this.transformer = null;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* @private
|
|
@@ -41,19 +41,19 @@ export class GridCellActionTransformNearbyMarkers extends GridCellAction {
|
|
|
41
41
|
*
|
|
42
42
|
* @param {number} radius
|
|
43
43
|
* @param {MarkerNodeMatcher} matcher
|
|
44
|
-
* @param {MarkerNodeTransformer
|
|
44
|
+
* @param {MarkerNodeTransformer} transformer
|
|
45
45
|
* @returns {GridCellActionTransformNearbyMarkers}
|
|
46
46
|
*/
|
|
47
|
-
static from(radius, matcher,
|
|
47
|
+
static from(radius, matcher, transformer) {
|
|
48
48
|
assert.greaterThanOrEqual(radius, 0, 'radius');
|
|
49
49
|
assert.equal(matcher.isMarkerNodeMatcher, true, 'matcher.isMarkerNodeMatcher');
|
|
50
|
-
assert.
|
|
50
|
+
assert.equal(transformer.isMarkerNodeTransformer, true, 'matcher.isMarkerNodeTransformer');
|
|
51
51
|
|
|
52
52
|
const r = new GridCellActionTransformNearbyMarkers();
|
|
53
53
|
|
|
54
54
|
r.radius = radius;
|
|
55
55
|
r.matcher = matcher;
|
|
56
|
-
r.
|
|
56
|
+
r.transformer = transformer;
|
|
57
57
|
|
|
58
58
|
return r;
|
|
59
59
|
}
|
|
@@ -61,7 +61,7 @@ export class GridCellActionTransformNearbyMarkers extends GridCellAction {
|
|
|
61
61
|
initialize(data, seed) {
|
|
62
62
|
super.initialize(data, seed);
|
|
63
63
|
|
|
64
|
-
this.
|
|
64
|
+
this.transformer.initialize(data, seed);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
@@ -89,9 +89,7 @@ export class GridCellActionTransformNearbyMarkers extends GridCellAction {
|
|
|
89
89
|
|
|
90
90
|
execute(data, x, y, rotation) {
|
|
91
91
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const transformerCount = transformers.length;
|
|
92
|
+
const transformer = this.transformer;
|
|
95
93
|
|
|
96
94
|
// reset cursor
|
|
97
95
|
this.__leaf_cursor = 0;
|
|
@@ -112,14 +110,8 @@ export class GridCellActionTransformNearbyMarkers extends GridCellAction {
|
|
|
112
110
|
for (let i = 0; i < match_count; i++) {
|
|
113
111
|
const leaf = leaves[i];
|
|
114
112
|
|
|
115
|
-
let node = leaf.data;
|
|
116
|
-
|
|
117
113
|
// transform
|
|
118
|
-
|
|
119
|
-
const transformer = transformers[j];
|
|
120
|
-
|
|
121
|
-
node = transformer.transform(node, data);
|
|
122
|
-
}
|
|
114
|
+
const node = transformer.transform(leaf.data, data);
|
|
123
115
|
|
|
124
116
|
// insert the node
|
|
125
117
|
data.addMarker(node);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CellMatcher } from "./CellMatcher.js";
|
|
2
|
+
|
|
3
|
+
export class CellMatcherFromFilter extends CellMatcher {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @type {CellFilter|null}
|
|
10
|
+
*/
|
|
11
|
+
this.filter = null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {CellFilter} f
|
|
17
|
+
* @returns {CellMatcherFromFilter}
|
|
18
|
+
*/
|
|
19
|
+
static from(f) {
|
|
20
|
+
const r = new CellMatcherFromFilter();
|
|
21
|
+
|
|
22
|
+
r.filter = f;
|
|
23
|
+
|
|
24
|
+
return r;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
initialize(grid, seed) {
|
|
28
|
+
if (!this.filter.initialized) {
|
|
29
|
+
this.filter.initialize(grid, seed);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
match(grid, x, y, rotation) {
|
|
34
|
+
const v = this.filter.execute(grid, x, y, rotation);
|
|
35
|
+
|
|
36
|
+
return v > 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
"productName": "Meep",
|
|
5
5
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
6
6
|
"author": "Alexander Goldring",
|
|
7
|
-
"version": "2.31.
|
|
7
|
+
"version": "2.31.5",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"fast-levenshtein": "2.0.6",
|
|
10
10
|
"opentype.js": "1.3.3",
|
|
11
11
|
"simplex-noise": "2.4.0",
|
|
12
|
-
"three": "
|
|
12
|
+
"three": "0.132.2 - 0.133.1"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"babel-jest": "^26.6.3",
|
|
16
|
-
"@types/three": "
|
|
16
|
+
"@types/three": "0.133.0"
|
|
17
17
|
}
|
|
18
18
|
}
|