@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
@@ -1,6 +1,6 @@
1
1
  import { ThreeInstancedAdapter } from "../instanced/ThreeInstancedAdapter.js";
2
2
  import { composeCompile } from "../../../material/composeCompile.js";
3
- import { Mesh, MeshDepthMaterial, RGBADepthPacking } from "three";
3
+ import { Mesh, MeshDepthMaterial, MeshNormalMaterial, RGBADepthPacking } from "three";
4
4
 
5
5
  const MATERIAL_FLAG = '@micron_instanced_rewritten';
6
6
 
@@ -97,9 +97,28 @@ export class MaterialContext {
97
97
  const customDepthMaterial = new MeshDepthMaterial({
98
98
  depthPacking: RGBADepthPacking
99
99
  });
100
- m.customDepthMaterial = customDepthMaterial;
100
+
101
+ customDepthMaterial.map = material.map;
102
+ customDepthMaterial.alphaTest = material.alphaTest;
101
103
  customDepthMaterial.onBeforeCompile = rewrite_material;
102
104
 
105
+ m.customDepthMaterial = customDepthMaterial;
106
+
107
+ const customNormalMaterial = new MeshNormalMaterial({
108
+ depthWrite: true
109
+ });
110
+
111
+ customNormalMaterial.map = material.map;
112
+ customNormalMaterial.normalMap = material.normalMap;
113
+ customNormalMaterial.normalScale = material.normalScale;
114
+ customNormalMaterial.normalMapType = material.normalMapType;
115
+
116
+ customNormalMaterial.alphaTest = material.alphaTest;
117
+ customNormalMaterial.onBeforeCompile = rewrite_material;
118
+
119
+ m.customNormalMaterial = customNormalMaterial;
120
+
121
+
103
122
  //
104
123
  this.adapter.onRebuild.add(() => {
105
124
  m.geometry = this.adapter.__buffer_geometry;
@@ -31,7 +31,7 @@ async function init(engineHarness) {
31
31
 
32
32
  const config = new EngineConfiguration();
33
33
 
34
- config.addSystem(new MeshSystem(engine.graphics, engine.assetManager));
34
+ config.addSystem(new MeshSystem(engine));
35
35
  config.addLoader('image', new ImageRGBADataLoader());
36
36
 
37
37
  await config.apply(engine);
@@ -36,7 +36,7 @@ export class SimulationStepFixedPhysics extends AbstractSimulationStep {
36
36
 
37
37
  const layer_position = particles.readAttributeScalar(i, PARTICLE_ATTRIBUTE_LAYER_POSITION);
38
38
 
39
- const layer_index = layer_position * layerCount;
39
+ const layer_index = Math.round(layer_position * layerCount);
40
40
 
41
41
  if ((layerMask & (1 << layer_index)) === 0) {
42
42
  //skip
@@ -93,6 +93,10 @@ export class NormalFrameBuffer extends FrameBuffer {
93
93
  * @param {Object3D} object
94
94
  */
95
95
  __renderObject(object) {
96
+ if (!object.visible) {
97
+ return;
98
+ }
99
+
96
100
  if (object.isMesh || object.isSkinnedMesh) {
97
101
 
98
102
  /**
@@ -107,28 +111,33 @@ export class NormalFrameBuffer extends FrameBuffer {
107
111
  return;
108
112
  }
109
113
 
110
- /**
111
- *
112
- * @type {Material}
113
- */
114
- const source_material = mesh.material;
115
-
116
114
 
117
115
  let target_material;
118
116
 
119
- // TODO take normal map into account
120
-
121
- if (mesh.isSkinnedMesh) {
122
- target_material = this.__material_skinned;
117
+ if (mesh.customNormalMaterial !== undefined) {
118
+ target_material = mesh.customNormalMaterial;
123
119
  } else {
124
- target_material = this.__material_static;
125
- }
120
+
121
+ /**
122
+ *
123
+ * @type {Material}
124
+ */
125
+ const source_material = mesh.material;
126
+
127
+ // TODO take normal map into account
128
+
129
+ if (mesh.isSkinnedMesh) {
130
+ target_material = this.__material_skinned;
131
+ } else {
132
+ target_material = this.__material_static;
133
+ }
126
134
 
127
135
 
128
- if (source_material !== undefined) {
129
- // assign normal map and color map
130
- target_material.map = source_material.map;
131
- target_material.normalMap = source_material.normalMap;
136
+ if (source_material !== undefined) {
137
+ // assign normal map and color map
138
+ target_material.map = source_material.map;
139
+ target_material.normalMap = source_material.normalMap;
140
+ }
132
141
  }
133
142
 
134
143
  this.__renderer.renderBufferDirect(this.__current_render_camera, null, geometry, target_material, mesh, null);
@@ -41,7 +41,6 @@ import { FogOfWarRevealerSystem } from "../../../../ecs/fow/FogOfWarRevealerSyst
41
41
  import { BehaviorSystem } from "../../../../intelligence/behavior/ecs/BehaviorSystem.js";
42
42
  import { SerializationMetadataSystem } from "../../../../ecs/systems/SerializationMetadataSystem.js";
43
43
  import { InverseKinematicsSystem } from "../../../../ecs/animation/InverseKinematicsSystem.js";
44
- import { PathDisplaySystem } from "../../../../../../model/engine/visual/path/PathDisplaySystem.js";
45
44
  import { CanvasView } from "../../../../../view/elements/CanvasView.js";
46
45
  import Vector3 from "../../../../../core/geom/Vector3.js";
47
46
  import Vector2 from "../../../../../core/geom/Vector2.js";
@@ -67,6 +66,8 @@ import {
67
66
  } from "three";
68
67
  import { buildCubeURLs, StandardFrameBuffers } from "../../../GraphicsEngine.js";
69
68
  import { AmbientOcclusionPostProcessEffect } from "../simple-fx/ao/AmbientOcclusionPostProcessEffect.js";
69
+ import { PathDisplaySystem } from "../../../ecs/path/PathDisplaySystem.js";
70
+ import { MicronRenderPlugin } from "../../../micron/plugin/MicronRenderPlugin.js";
70
71
 
71
72
  const engineHarness = new EngineHarness();
72
73
 
@@ -104,7 +105,7 @@ function makeConfig(engine) {
104
105
  new TopDownCameraControllerSystem(graphics),
105
106
  new TopDownCameraLanderSystem(),
106
107
  new CameraSystem(graphics.scene, graphics),
107
- new MeshSystem(graphics, assetManager),
108
+ new MeshSystem(engine),
108
109
  new ClingToTerrainSystem(),
109
110
  new TerrainSystem(graphics, assetManager),
110
111
  new WaterSystem(graphics),
@@ -133,13 +134,14 @@ function makeConfig(engine) {
133
134
  new PathDisplaySystem(engine),
134
135
  );
135
136
 
137
+
138
+
136
139
  // Plugins
140
+ config.addPlugin(MicronRenderPlugin);
137
141
 
138
142
 
139
143
  // Knowledge
140
144
 
141
- config.knowledge.push();
142
-
143
145
  return config;
144
146
  }
145
147
 
@@ -343,7 +345,6 @@ function main(engine) {
343
345
  engine.graphics.loadEnvironmentMap(buildCubeURLs('data/textures/cubemaps/hip_miramar/32/', '.png'));
344
346
 
345
347
 
346
-
347
348
  engine.plugins.acquire(AmbientOcclusionPostProcessEffect);
348
349
  }
349
350
 
@@ -1,4 +1,4 @@
1
- import { ShaderMaterial, Vector2 } from "three";
1
+ import { DoubleSide, NormalBlending, ShaderMaterial, Vector2 } from "three";
2
2
 
3
3
  const vertexShader = `
4
4
  varying vec2 vUv;
@@ -110,7 +110,12 @@ export class RibbonMaterialX extends ShaderMaterial {
110
110
  defines: {
111
111
  USE_TEXTURE: false
112
112
  }
113
- }
113
+ },
114
+ blending: NormalBlending,
115
+ transparent: true,
116
+ depthWrite: false,
117
+ depthTest: true,
118
+ side: DoubleSide
114
119
  });
115
120
 
116
121
  this.setValues(params);
@@ -3,149 +3,49 @@
3
3
  */
4
4
 
5
5
  import Vector2 from '../../../core/geom/Vector2.js';
6
- import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
7
- import { BinaryClassUpgrader } from "../../ecs/storage/binary/BinaryClassUpgrader.js";
8
6
 
9
- /**
10
- * @extends {Vector2}
11
- * @constructor
12
- */
13
- function GridPosition() {
14
- Vector2.call(this);
15
- }
16
-
17
- GridPosition.typeName = "GridPosition";
18
-
19
- GridPosition.prototype = Object.create(Vector2.prototype);
20
- GridPosition.prototype.constructor = GridPosition;
21
-
22
- /**
23
- *
24
- * @param {object} json
25
- * @returns {GridPosition}
26
- */
27
- GridPosition.fromJSON = function (json) {
28
- const r = new GridPosition();
29
-
30
- r.fromJSON(json);
31
-
32
- return r;
33
- };
34
-
35
- GridPosition.prototype.toJSON = function () {
36
- return {
37
- x: this.x,
38
- y: this.y
39
- };
40
- };
41
-
42
- GridPosition.prototype.fromJSON = function (obj) {
43
- this.x = obj.x;
44
- this.y = obj.y;
45
- };
46
-
47
- /**
48
- *
49
- * @param {GridPosition|Vector2} other
50
- */
51
- GridPosition.prototype.copy = function (other) {
52
- Vector2.prototype.copy.call(this, other);
53
- return this;
54
- };
55
-
56
- GridPosition.prototype.clone = function () {
57
- const clone = new GridPosition();
58
-
59
- clone.copy(this);
60
-
61
- return clone;
62
- };
63
-
64
- export default GridPosition;
65
-
66
- export class GridPositionSerializationAdapter extends BinaryClassSerializationAdapter {
7
+ class GridPosition extends Vector2{
8
+ /**
9
+ * @extends {Vector2}
10
+ * @constructor
11
+ */
67
12
  constructor() {
68
13
  super();
69
-
70
- this.klass = GridPosition;
71
- this.version = 1;
72
14
  }
73
15
 
74
16
  /**
75
17
  *
76
- * @param {BinaryBuffer} buffer
77
- * @param {GridPosition} value
18
+ * @param {GridPosition|Vector2} other
78
19
  */
79
- serialize(buffer, value) {
80
- const x = value.x;
81
- const y = value.y;
20
+ copy(other) {
21
+ Vector2.prototype.copy.call(this, other);
22
+ return this;
23
+ }
82
24
 
83
- let header = 0;
84
- if (Number.isInteger(x) && Number.isInteger(y) && x >= 0 && y >= 0) {
85
- header = 1;
86
- }
25
+ clone() {
26
+ const clone = new GridPosition();
87
27
 
88
- buffer.writeUint8(header);
28
+ clone.copy(this);
89
29
 
90
- if (header === 1) {
91
- //both components are uint
92
- buffer.writeUintVar(x);
93
- buffer.writeUintVar(y);
94
- } else {
95
- buffer.writeFloat32(x);
96
- buffer.writeFloat32(y);
97
- }
30
+ return clone;
98
31
  }
99
32
 
100
33
  /**
101
34
  *
102
- * @param {BinaryBuffer} buffer
103
- * @param {GridPosition} value
35
+ * @param {object} json
36
+ * @returns {GridPosition}
104
37
  */
105
- deserialize(buffer, value) {
106
- const header = buffer.readUint8();
38
+ static fromJSON(json) {
39
+ const r = new GridPosition();
107
40
 
108
- let x = 0, y = 0;
109
- if (header === 1) {
110
- x = buffer.readUintVar();
111
- y = buffer.readUintVar();
112
- } else {
113
- //float
114
- x = buffer.readFloat32();
115
- y = buffer.readFloat32();
116
- }
41
+ r.fromJSON(json);
117
42
 
118
- value.set(x, y);
43
+ return r;
119
44
  }
120
45
  }
121
46
 
122
- export class GridPositionSerializationUpdater_0_1 extends BinaryClassUpgrader {
123
- constructor() {
124
- super();
125
-
126
- this.__targetVersion = 1;
127
- this.__startVersion = 0;
128
- }
129
-
130
- upgrade(source, target) {
131
- const x = source.readFloat64();
132
- const y = source.readFloat64();
133
-
134
- let header = 0;
135
- if (Number.isInteger(x) && Number.isInteger(y) && x >= 0 && y >= 0) {
136
- header = 1;
137
- }
47
+ GridPosition.typeName = "GridPosition";
138
48
 
139
- target.writeUint8(header);
140
49
 
141
- if (header === 1) {
142
- //both components are uint
143
- target.writeUintVar(x);
144
- target.writeUintVar(y);
145
- } else {
146
- target.writeFloat32(x);
147
- target.writeFloat32(y);
148
- }
50
+ export default GridPosition;
149
51
 
150
- }
151
- }
@@ -0,0 +1,58 @@
1
+ import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
2
+ import GridPosition from "./GridPosition.js";
3
+
4
+ export class GridPositionSerializationAdapter extends BinaryClassSerializationAdapter {
5
+ constructor() {
6
+ super();
7
+
8
+ this.klass = GridPosition;
9
+ this.version = 1;
10
+ }
11
+
12
+ /**
13
+ *
14
+ * @param {BinaryBuffer} buffer
15
+ * @param {GridPosition} value
16
+ */
17
+ serialize(buffer, value) {
18
+ const x = value.x;
19
+ const y = value.y;
20
+
21
+ let header = 0;
22
+ if (Number.isInteger(x) && Number.isInteger(y) && x >= 0 && y >= 0) {
23
+ header = 1;
24
+ }
25
+
26
+ buffer.writeUint8(header);
27
+
28
+ if (header === 1) {
29
+ //both components are uint
30
+ buffer.writeUintVar(x);
31
+ buffer.writeUintVar(y);
32
+ } else {
33
+ buffer.writeFloat32(x);
34
+ buffer.writeFloat32(y);
35
+ }
36
+ }
37
+
38
+ /**
39
+ *
40
+ * @param {BinaryBuffer} buffer
41
+ * @param {GridPosition} value
42
+ */
43
+ deserialize(buffer, value) {
44
+ const header = buffer.readUint8();
45
+
46
+ let x = 0, y = 0;
47
+ if (header === 1) {
48
+ x = buffer.readUintVar();
49
+ y = buffer.readUintVar();
50
+ } else {
51
+ //float
52
+ x = buffer.readFloat32();
53
+ y = buffer.readFloat32();
54
+ }
55
+
56
+ value.set(x, y);
57
+ }
58
+ }
@@ -0,0 +1,37 @@
1
+ import { BinaryClassUpgrader } from "../../ecs/storage/binary/BinaryClassUpgrader.js";
2
+
3
+ export class GridPositionSerializationUpdater_0_1 extends BinaryClassUpgrader {
4
+ constructor() {
5
+ super();
6
+
7
+ this.__targetVersion = 1;
8
+ this.__startVersion = 0;
9
+ }
10
+
11
+ upgrade(source, target) {
12
+ const x = source.readFloat64();
13
+ const y = source.readFloat64();
14
+
15
+ let header = 0;
16
+ if (
17
+ Number.isInteger(x)
18
+ && Number.isInteger(y)
19
+ && x >= 0
20
+ && y >= 0
21
+ ) {
22
+ header = 1;
23
+ }
24
+
25
+ target.writeUint8(header);
26
+
27
+ if (header === 1) {
28
+ //both components are uint
29
+ target.writeUintVar(x);
30
+ target.writeUintVar(y);
31
+ } else {
32
+ target.writeFloat32(x);
33
+ target.writeFloat32(y);
34
+ }
35
+
36
+ }
37
+ }
@@ -236,7 +236,17 @@ export class MonteCarloTreeSearch {
236
236
  if (!node.isTerminal() && node.depth >= this.maxExplorationDepth) {
237
237
  //cap the state by depth, propagate heuristic score
238
238
  node.type = StateType.DepthCapped;
239
- recordArbitratedPlayout(node, state);
239
+ }
240
+
241
+ // record play-through
242
+ const terminalFlag = node.type;
243
+
244
+ if (terminalFlag === StateType.Win) {
245
+ node.addPlayouts(1, 1, 0);
246
+ } else if (terminalFlag === StateType.Loss) {
247
+ node.addPlayouts(1, 0, 1);
248
+ } else if (terminalFlag === StateType.Tie || terminalFlag === StateType.DepthCapped) {
249
+ node.addPlayouts(1, 0, 0);
240
250
  }
241
251
 
242
252
  return state;
@@ -273,22 +283,9 @@ function materializedEdgeTarget(state, source, edge, computeTerminalFlag, heuris
273
283
 
274
284
  child.heuristicValue = childHeuristicScore;
275
285
 
276
- if (terminalFlag === StateType.Undecided) {
277
- //do nothing
278
- } else {
279
-
280
-
281
- if (terminalFlag === StateType.Win) {
282
- child.addPlayouts(1, 1, 0);
283
- } else if (terminalFlag === StateType.Loss) {
284
- child.addPlayouts(1, 0, 1);
285
- } else if (terminalFlag === StateType.Tie || terminalFlag === StateType.DepthCapped) {
286
- child.addPlayouts(1, 0, 0);
287
- }
288
- }
289
286
 
290
287
  // bubble the heuristic score up the tree
291
- child.bubbleUpHeuristicScore();
288
+ // child.bubbleUpHeuristicScore(); // heuristic value changes sign depending on the team making the move, so aggregation becomes tricky
292
289
 
293
290
  return computedState;
294
291
  }
@@ -235,9 +235,9 @@ export class StateNode {
235
235
  */
236
236
  const moves = computeValidMoves(state, this);
237
237
 
238
- assert.notEqual(moves, null, 'computedValidMoves expected to be an array, instead it was null');
239
- assert.notEqual(moves, undefined, 'computedValidMoves expected to be an array, instead it was undefined');
240
- assert.ok(Array.isArray(moves), 'computedValidMoves expected to be an array, instead was something else');
238
+ assert.notNull(moves, 'moves');
239
+ assert.defined(moves, 'moves');
240
+ assert.isArray(moves, 'moves');
241
241
 
242
242
  const numMoves = moves.length;
243
243
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- *
2
+ * Tags
3
3
  * @enum {number}
4
4
  */
5
5
  export const GridTags = {
@@ -10,5 +10,6 @@ export const GridTags = {
10
10
  StartingPoint: 16,
11
11
  Occupied: 32,
12
12
  Road: 64,
13
- PlayArea: 128
13
+ PlayArea: 128,
14
+ Objective: 256,
14
15
  };
@@ -21,7 +21,7 @@ import { matcher_tag_traversable } from "./rules/matcher_tag_traversable.js";
21
21
  import { GridTaskGenerateRoads } from "../grid/generation/road/GridTaskGenerateRoads.js";
22
22
  import { mir_generator_place_road_decorators } from "./generators/mir_generator_place_road_decorators.js";
23
23
  import { MarkerNodeMatcherByType } from "../markers/matcher/MarkerNodeMatcherByType.js";
24
- import { mir_generator_place_buff_objects } from "./generators/mir_generator_place_buff_objects.js";
24
+ import { mir_generator_place_buff_objects } from "./generators/interactive/mir_generator_place_buff_objects.js";
25
25
  import { GridTaskDensityMarkerDistribution } from "../grid/generation/GridTaskDensityMarkerDistribution.js";
26
26
  import { CellFilterSimplexNoise } from "../filtering/numeric/complex/CellFilterSimplexNoise.js";
27
27
  import { NumericInterval } from "../../core/math/interval/NumericInterval.js";