@woosh/meep-engine 2.50.0 → 2.50.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.
Files changed (84) hide show
  1. package/README.md +39 -0
  2. package/editor/Editor.js +5 -1
  3. package/editor/SelectionVisualizer.js +9 -3
  4. package/editor/tools/paint/TerrainTexturePaintTool.js +6 -1
  5. package/editor/view/EditorView.js +5 -1
  6. package/editor/view/ecs/EntityList.js +48 -37
  7. package/editor/view/makeEntityDecorators.js +125 -0
  8. package/package.json +7 -3
  9. package/samples/generation/README.md +6 -0
  10. package/{src/generation/example → samples/generation}/SampleGenerator0.js +60 -46
  11. package/{src/generation/example → samples/generation}/filters/SampleGroundMoistureFilter.js +14 -12
  12. package/samples/generation/filters/SampleNoise20_0.js +3 -0
  13. package/{src/generation/example → samples/generation}/generators/interactive/mir_generator_place_buff_objects.js +29 -23
  14. package/{src/generation/example → samples/generation}/generators/mir_generator_place_bases.js +33 -25
  15. package/{src/generation/example → samples/generation}/generators/mir_generator_place_road_decorators.js +16 -14
  16. package/samples/generation/generators/mir_generator_place_starting_point.js +60 -0
  17. package/{src/generation/example → samples/generation}/grid/configureMirGrid.js +2 -2
  18. package/{src/generation/example → samples/generation}/main.js +29 -28
  19. package/{src/generation/example → samples/generation}/rules/matcher_not_play_area.js +1 -1
  20. package/samples/generation/rules/matcher_play_area.js +5 -0
  21. package/{src/generation/example → samples/generation}/rules/matcher_tag_not_traversable.js +1 -1
  22. package/samples/generation/rules/matcher_tag_occupied.js +5 -0
  23. package/samples/generation/rules/matcher_tag_traversable.js +5 -0
  24. package/{src/generation/example → samples/generation}/rules/matcher_tag_traversable_unoccupied.js +1 -1
  25. package/{src/generation/example → samples/generation}/rules/matcher_tag_unoccupied.js +1 -1
  26. package/{src/generation/example → samples/generation}/rules/mir_matcher_attack_corridor.js +3 -3
  27. package/{src/generation/example → samples/generation}/themes/SampleTheme0.js +57 -47
  28. package/{src/generation/example → samples/generation}/themes/SampleTheme1.js +4 -4
  29. package/{src/generation/example → samples/generation}/themes/SampleTheme2.js +4 -4
  30. package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.js +4 -4
  31. package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +5 -5
  32. package/src/core/geom/3d/plane/is_point_within_planes.js +1 -1
  33. package/src/core/geom/3d/plane/lerp_planes_to_array.js +2 -0
  34. package/src/core/geom/3d/plane/{plane_computeConvex3PlaneIntersection.js → plane3_compute_convex_3_plane_intersection.js} +1 -1
  35. package/src/core/geom/3d/plane/{plane3_computeLineSegmentIntersection.js → plane3_compute_line_segment_intersection.js} +1 -1
  36. package/src/core/geom/3d/plane/{computePlanePlaneIntersection.js → plane3_compute_plane_intersection.js} +15 -11
  37. package/src/core/geom/3d/plane/{computePlaneLineIntersection.js → plane3_compute_ray_intersection.js} +5 -1
  38. package/src/core/geom/3d/plane/plane3_intersect_plane.js +14 -0
  39. package/src/core/geom/3d/plane/{plane_three_compute_convex3_plane_intersection.js → plane3_three_compute_convex_3_plane_intersection.js} +7 -4
  40. package/src/core/geom/3d/plane/planeRayIntersection.js +2 -2
  41. package/src/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +5 -5
  42. package/src/core/geom/Vector3.d.ts +4 -2
  43. package/src/engine/ecs/EntityBlueprint.d.ts +14 -0
  44. package/src/engine/ecs/EntityBlueprint.js +2 -2
  45. package/src/engine/ecs/EntityBlueprint.spec.js +52 -0
  46. package/src/engine/ecs/EntityBuilder.js +8 -0
  47. package/src/engine/ecs/EntityManager.d.ts +1 -0
  48. package/src/engine/ecs/EntityManager.js +16 -8
  49. package/src/engine/ecs/EntityManager.spec.js +62 -1
  50. package/src/engine/ecs/System.js +8 -2
  51. package/src/engine/ecs/{Blueprint.js → storage/json/Blueprint.js} +1 -1
  52. package/src/engine/ecs/{EntityFactory.js → storage/json/EntityFactory.js} +1 -1
  53. package/src/engine/ecs/storage/{JSONDeSerializer.js → json/JSONDeSerializer.js} +4 -4
  54. package/src/engine/ecs/storage/json/README.md +5 -0
  55. package/src/engine/graphics/ecs/camera/Camera.js +2 -2
  56. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.spec.js +5 -0
  57. package/src/engine/graphics/ecs/path/entity/EntityPath.js +1 -1
  58. package/src/engine/graphics/render/forward_plus/computeFrustumCorners.js +10 -10
  59. package/src/engine/graphics/render/layers/RenderLayerUtils.js +3 -3
  60. package/src/engine/intelligence/behavior/Behavior.d.ts +5 -0
  61. package/src/engine/intelligence/behavior/Behavior.js +19 -0
  62. package/src/engine/intelligence/behavior/SelectorBehavior.js +4 -2
  63. package/src/engine/intelligence/behavior/composite/ParallelBehavior.js +2 -0
  64. package/src/engine/intelligence/behavior/composite/SequenceBehavior.js +3 -1
  65. package/src/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.js +2 -3
  66. package/src/engine/intelligence/behavior/decorator/RepeatBehavior.js +2 -2
  67. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.js +1 -1
  68. package/src/engine/scene/SceneManager.spec.js +24 -0
  69. package/src/generation/grid/GridData.js +8 -2
  70. package/src/generation/grid/GridData.spec.js +5 -0
  71. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
  72. package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
  73. package/src/generation/markers/actions/MarkerNodeActionEntityPlacement.js +1 -1
  74. package/src/view/common/VirtualListView.js +2 -0
  75. package/src/view/minimap/dom/MinimapCameraView.js +3 -3
  76. package/src/core/geom/3d/plane/computePlaneRayIntersection.js +0 -55
  77. package/src/generation/example/filters/SampleNoise20_0.js +0 -3
  78. package/src/generation/example/generators/mir_generator_place_starting_point.js +0 -52
  79. package/src/generation/example/rules/matcher_play_area.js +0 -5
  80. package/src/generation/example/rules/matcher_tag_occupied.js +0 -5
  81. package/src/generation/example/rules/matcher_tag_traversable.js +0 -5
  82. package/src/generation/grid/MarkerMatchCounter.js +0 -25
  83. /package/{src/generation/example → samples/generation}/grid/MirGridLayers.js +0 -0
  84. /package/src/engine/ecs/storage/{JSONSerializer.js → json/JSONSerializer.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
- plane_three_computeConvex3PlaneIntersection
3
- } from "../../../../core/geom/3d/plane/plane_three_compute_convex3_plane_intersection.js";
2
+ plane3_three_compute_convex_3_plane_intersection
3
+ } from "../../../../core/geom/3d/plane/plane3_three_compute_convex_3_plane_intersection.js";
4
4
 
5
5
  /**
6
6
  * Get frustum corners from a set of planes
@@ -13,7 +13,7 @@ export function computeFrustumCorners(result, planes) {
13
13
  const plane_y0 = planes[2];
14
14
  const plane_z0 = planes[4];
15
15
 
16
- plane_three_computeConvex3PlaneIntersection(result, 0,
16
+ plane3_three_compute_convex_3_plane_intersection(result, 0,
17
17
  plane_x0,
18
18
  plane_y0,
19
19
  plane_z0
@@ -21,7 +21,7 @@ export function computeFrustumCorners(result, planes) {
21
21
 
22
22
  const plane_z1 = planes[5];
23
23
 
24
- plane_three_computeConvex3PlaneIntersection(result, 3,
24
+ plane3_three_compute_convex_3_plane_intersection(result, 3,
25
25
  plane_x0,
26
26
  plane_y0,
27
27
  plane_z1
@@ -29,13 +29,13 @@ export function computeFrustumCorners(result, planes) {
29
29
 
30
30
  const plane_y1 = planes[3];
31
31
 
32
- plane_three_computeConvex3PlaneIntersection(result, 6,
32
+ plane3_three_compute_convex_3_plane_intersection(result, 6,
33
33
  plane_x0,
34
34
  plane_y1,
35
35
  plane_z0
36
36
  );
37
37
 
38
- plane_three_computeConvex3PlaneIntersection(result, 9,
38
+ plane3_three_compute_convex_3_plane_intersection(result, 9,
39
39
  plane_x0,
40
40
  plane_y1,
41
41
  plane_z1
@@ -43,25 +43,25 @@ export function computeFrustumCorners(result, planes) {
43
43
 
44
44
  const plane_x1 = planes[1];
45
45
 
46
- plane_three_computeConvex3PlaneIntersection(result, 12,
46
+ plane3_three_compute_convex_3_plane_intersection(result, 12,
47
47
  plane_x1,
48
48
  plane_y0,
49
49
  plane_z0
50
50
  );
51
51
 
52
- plane_three_computeConvex3PlaneIntersection(result, 15,
52
+ plane3_three_compute_convex_3_plane_intersection(result, 15,
53
53
  plane_x1,
54
54
  plane_y0,
55
55
  plane_z1
56
56
  );
57
57
 
58
- plane_three_computeConvex3PlaneIntersection(result, 18,
58
+ plane3_three_compute_convex_3_plane_intersection(result, 18,
59
59
  plane_x1,
60
60
  plane_y1,
61
61
  plane_z0
62
62
  );
63
63
 
64
- plane_three_computeConvex3PlaneIntersection(result, 21,
64
+ plane3_three_compute_convex_3_plane_intersection(result, 21,
65
65
  plane_x1,
66
66
  plane_y1,
67
67
  plane_z1
@@ -1,7 +1,7 @@
1
1
  import { v3_distance_above_plane } from "../../../../core/geom/v3_distance_above_plane.js";
2
2
  import {
3
- plane_three_computeConvex3PlaneIntersection
4
- } from "../../../../core/geom/3d/plane/plane_three_compute_convex3_plane_intersection.js";
3
+ plane3_three_compute_convex_3_plane_intersection
4
+ } from "../../../../core/geom/3d/plane/plane3_three_compute_convex_3_plane_intersection.js";
5
5
 
6
6
  /**
7
7
  *
@@ -43,7 +43,7 @@ export function buildPlanarRenderLayerClipPlaneComputationMethod(traversePlanes,
43
43
  const p0 = pair[0];
44
44
  const p1 = pair[1];
45
45
 
46
- const planeIntersection = plane_three_computeConvex3PlaneIntersection(p, 0, p0, p1, objectPlane);
46
+ const planeIntersection = plane3_three_compute_convex_3_plane_intersection(p, 0, p0, p1, objectPlane);
47
47
 
48
48
  if (!planeIntersection) {
49
49
  //no intersection
@@ -1,8 +1,13 @@
1
1
  import {BehaviorStatus} from "./BehaviorStatus";
2
+ import Signal from "../../../core/events/signal/Signal";
2
3
 
3
4
  export class Behavior<CTX> {
4
5
  context: CTX | null
5
6
 
7
+ readonly onInitialized: Signal<this, CTX>
8
+
9
+ readonly onFinalized: Signal<this>
10
+
6
11
  tick(timeDeltaSeconds: number): BehaviorStatus
7
12
 
8
13
  initialize(context: CTX): void
@@ -1,4 +1,5 @@
1
1
  import { BehaviorStatus } from "./BehaviorStatus.js";
2
+ import Signal from "../../../core/events/signal/Signal.js";
2
3
 
3
4
  /**
4
5
  * Base class of behavior tree implementation
@@ -15,6 +16,20 @@ export class Behavior {
15
16
  */
16
17
  context = null;
17
18
 
19
+ /**
20
+ * Dispatched after initialization is complete
21
+ * @readonly
22
+ * @type {Signal<this,CTX>}
23
+ */
24
+ onInitialized = new Signal();
25
+
26
+ /**
27
+ * Dispatched after finalization is complete
28
+ * @readonly
29
+ * @type {Signal<this>}
30
+ */
31
+ onFinalized = new Signal();
32
+
18
33
  /**
19
34
  * Main update function. Every behavior executes some logic, some behaviors are long-running and some are instantaneous
20
35
  * @param {number} timeDelta time step in seconds
@@ -27,18 +42,22 @@ export class Behavior {
27
42
  /**
28
43
  * Called before behavior gets executed via {@link #tick} for the first time
29
44
  * Used to prepare the behavior for execution
45
+ * You can think of it as "start"
30
46
  * @param {CTX} [context]
31
47
  */
32
48
  initialize(context) {
33
49
  this.context = context;
50
+ this.onInitialized.send2(this, context);
34
51
  }
35
52
 
36
53
  /**
37
54
  * Called when behavior is finished, or interrupted
38
55
  * Used to clean up any resources
56
+ * You can think of it as "stop"
39
57
  */
40
58
  finalize() {
41
59
  // extend in subclasses as necessary
60
+ this.onFinalized.send1(this);
42
61
  }
43
62
  }
44
63
 
@@ -78,11 +78,11 @@ export class SelectorBehavior extends CompositeBehavior {
78
78
  this.__currentBehaviour.finalize();
79
79
  this.__currentBehaviour = null;
80
80
  }
81
+
82
+ super.finalize();
81
83
  }
82
84
 
83
85
  initialize(context) {
84
- super.initialize(context);
85
-
86
86
  const children = this.__children;
87
87
 
88
88
  if (children.length > 0) {
@@ -99,5 +99,7 @@ export class SelectorBehavior extends CompositeBehavior {
99
99
  this.__currentBehaviour = null;
100
100
 
101
101
  }
102
+
103
+ super.initialize(context);
102
104
  }
103
105
  }
@@ -218,6 +218,8 @@ export class ParallelBehavior extends CompositeBehavior {
218
218
  //finalize remaining active behaviours
219
219
 
220
220
  this.__finalizeActiveChildren();
221
+
222
+ super.finalize();
221
223
  }
222
224
 
223
225
  /**
@@ -34,7 +34,6 @@ export class SequenceBehavior extends CompositeBehavior {
34
34
 
35
35
  initialize(context) {
36
36
  // console.log('+ SequenceBehavior');
37
- super.initialize(context);
38
37
 
39
38
  this.__currentBehaviourIndex = 0;
40
39
  this.__currentBehaviour = this.__children[0];
@@ -43,6 +42,8 @@ export class SequenceBehavior extends CompositeBehavior {
43
42
  this.__currentBehaviour.initialize(context);
44
43
 
45
44
  this.__currentBehaviourState = BehaviorStatus.Running;
45
+
46
+ super.initialize(context);
46
47
  }
47
48
 
48
49
 
@@ -100,6 +101,7 @@ export class SequenceBehavior extends CompositeBehavior {
100
101
  this.__currentBehaviourIndex = child_count;
101
102
 
102
103
  // console.warn('- SequenceBehavior');
104
+ super.finalize();
103
105
  }
104
106
 
105
107
  /**
@@ -35,14 +35,13 @@ export class AbstractDecoratorBehavior extends Behavior {
35
35
  }
36
36
 
37
37
  initialize(context) {
38
- super.initialize(context);
39
38
  this.__source.initialize(context);
39
+ super.initialize(context);
40
40
  }
41
41
 
42
42
  finalize() {
43
- super.finalize();
44
-
45
43
  this.__source.finalize();
44
+ super.finalize();
46
45
  }
47
46
  }
48
47
 
@@ -59,10 +59,10 @@ export class RepeatBehavior extends AbstractDecoratorBehavior {
59
59
  }
60
60
 
61
61
  initialize(context) {
62
- super.initialize(context);
63
-
64
62
  // reset iterator
65
63
  this.__iterator = 0;
64
+
65
+ super.initialize(context);
66
66
  }
67
67
 
68
68
  tick(timeDelta) {
@@ -20,7 +20,7 @@ export class SucceedingBehavior extends Behavior {
20
20
  }
21
21
 
22
22
  /**
23
- *
23
+ * @deprecated use static INSTANCE instead
24
24
  * @param {number} delayTicks
25
25
  * @return {SucceedingBehavior}
26
26
  */
@@ -85,6 +85,7 @@ test("set active scene", () => {
85
85
  manager.set('x');
86
86
 
87
87
  expect(manager.current_scene).toBe(scene);
88
+ expect(scene.active.getValue()).toBe(true);
88
89
  expect(entityManager.dataset).toBe(scene.dataset);
89
90
  });
90
91
 
@@ -105,3 +106,26 @@ test("stack push/pop", () => {
105
106
 
106
107
  expect(manager.current_scene).toBe(scene_x);
107
108
  });
109
+
110
+ test("clear on empty does nothing", () => {
111
+ const { manager } = makeSM();
112
+
113
+ manager.clear();
114
+
115
+ expect(manager.current_scene).toBeNull();
116
+ });
117
+
118
+ test("clear correctly clears active scene", () => {
119
+
120
+ const { manager, entityManager } = makeSM();
121
+
122
+ const scene = manager.create('x');
123
+
124
+ manager.set('x');
125
+
126
+ manager.clear();
127
+
128
+ expect(manager.current_scene).toBeNull();
129
+ expect(scene.active.getValue()).toBe(false);
130
+ expect(entityManager.dataset).toBe(null);
131
+ });
@@ -3,7 +3,6 @@ import { QuadTreeNode } from "../../core/geom/2d/quad-tree/QuadTreeNode.js";
3
3
  import { OffsetScaleTransform2D } from "../../engine/ecs/terrain/ecs/OffsetScaleTransform2D.js";
4
4
  import { max2 } from "../../core/math/max2.js";
5
5
  import { qt_collect_by_circle } from "../../core/geom/2d/quad-tree/qt_collect_by_circle.js";
6
- import { v2_length_sqr } from "../../core/geom/Vector2.js";
7
6
 
8
7
  /**
9
8
  *
@@ -122,7 +121,14 @@ export class GridData {
122
121
  const distance_limit_sqr = distance_limit * distance_limit;
123
122
 
124
123
  // check refined containment
125
- if (v2_length_sqr(x - marker.position.x, y - marker.position.y) > distance_limit_sqr) {
124
+ const position = marker.position;
125
+
126
+ const dx = x - position.x;
127
+ const dy = y - position.y;
128
+
129
+ const distance_sqr = dx * dx + dy * dy;
130
+
131
+ if (distance_sqr > distance_limit_sqr) {
126
132
  continue;
127
133
  }
128
134
 
@@ -0,0 +1,5 @@
1
+ import { GridData } from "./GridData.js";
2
+
3
+ test("constructor does not throw", () => {
4
+ expect(() => new GridData()).not.toThrow()
5
+ });
@@ -10,7 +10,7 @@ import TaskGroup from "../../../../core/process/task/TaskGroup.js";
10
10
  import { Sampler2D } from "../../../../engine/graphics/texture/sampler/Sampler2D.js";
11
11
  import { bitSet2Sampler2D } from "../../../../engine/graphics/texture/sampler/util/bitSet2Sampler2D.js";
12
12
  import { drawSamplerHTML } from "../../../../engine/graphics/texture/sampler/util/drawSamplerHTML.js";
13
- import { matcher_tag_unoccupied } from "../../../example/rules/matcher_tag_unoccupied.js";
13
+ import { matcher_tag_unoccupied } from "../../../../../samples/generation/rules/matcher_tag_unoccupied.js";
14
14
  import { buildDistanceMapToObjective } from "../util/buildDistanceMapToObjective.js";
15
15
  import { buildPathFromDistanceMap } from "../util/buildPathFromDistanceMap.js";
16
16
  import { assert } from "../../../../core/assert.js";
@@ -6,7 +6,7 @@ import TaskGroup from "../../../../core/process/task/TaskGroup.js";
6
6
  import Graph from "../../../../core/graph/Graph.js";
7
7
  import BinaryHeap from "../../../../core/collection/heap/FastBinaryHeap.js";
8
8
  import { BitSet } from "../../../../core/binary/BitSet.js";
9
- import { matcher_tag_traversable } from "../../../example/rules/matcher_tag_traversable.js";
9
+ import { matcher_tag_traversable } from "../../../../../samples/generation/rules/matcher_tag_traversable.js";
10
10
  import { buildPathFromDistanceMap } from "../util/buildPathFromDistanceMap.js";
11
11
  import { GridCellActionPlaceTags } from "../../../placement/action/GridCellActionPlaceTags.js";
12
12
  import { GridTags } from "../../../GridTags.js";
@@ -20,7 +20,7 @@ import { readMarkerNodeGroupId } from "./readMarkerNodeGroupId.js";
20
20
  import { buildUnsignedDistanceField } from "../util/buildUnsignedDistanceField.js";
21
21
  import { CellMatcherNot } from "../../../rules/logic/CellMatcherNot.js";
22
22
  import { RoadConnectionNetwork } from "./RoadConnectionNetwork.js";
23
- import { MirGridLayers } from "../../../example/grid/MirGridLayers.js";
23
+ import { MirGridLayers } from "../../../../../samples/generation/grid/MirGridLayers.js";
24
24
  import { actionTask } from "../../../../core/process/task/util/actionTask.js";
25
25
  import { countTask } from "../../../../core/process/task/util/countTask.js";
26
26
  import { groupArrayBy } from "../../../../core/collection/array/groupArrayBy.js";
@@ -64,7 +64,7 @@ export class MarkerNodeActionEntityPlacement extends MarkerNodeAction {
64
64
  execute(grid, ecd, node) {
65
65
  const blueprint = this.entity;
66
66
 
67
- const entityBuilder = blueprint.buildEntityBuilder(node.properties);
67
+ const entityBuilder = blueprint.build(node.properties);
68
68
 
69
69
  // execute post-process step
70
70
  if (this.processor !== null) {
@@ -16,6 +16,8 @@ export const AlignmentOption = {
16
16
  End: 'end'
17
17
  };
18
18
 
19
+ const update_scratch = [];
20
+
19
21
  class VirtualListView extends View {
20
22
  /**
21
23
  * @template T
@@ -3,7 +3,7 @@ import Vector3 from "../../../core/geom/Vector3.js";
3
3
  import ObservedValue from "../../../core/model/ObservedValue.js";
4
4
  import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
5
5
  import SVG from "../../SVG.js";
6
- import { computePlaneRayIntersection } from "../../../core/geom/3d/plane/computePlaneRayIntersection.js";
6
+ import { plane3_compute_ray_intersection } from "../../../core/geom/3d/plane/plane3_compute_ray_intersection.js";
7
7
 
8
8
 
9
9
  const rayContact = new SurfacePoint3();
@@ -93,7 +93,7 @@ export class MinimapCameraView extends View {
93
93
  const JITTER = 0.00001;
94
94
 
95
95
  if (terrain === null) {
96
- computePlaneRayIntersection(result, originX, originY, originZ, directionX, directionY, directionZ, 0, 1, 0, 0);
96
+ plane3_compute_ray_intersection(result, originX, originY, originZ, directionX, directionY, directionZ, 0, 1, 0, 0);
97
97
  } else {
98
98
 
99
99
  let oX = originX;
@@ -118,7 +118,7 @@ export class MinimapCameraView extends View {
118
118
 
119
119
  if (!foundHit) {
120
120
  //no hit found, fall back to planar test
121
- computePlaneRayIntersection(result, originX, originY, originZ, directionX, directionY, directionZ, 0, 1, 0, 0);
121
+ plane3_compute_ray_intersection(result, originX, originY, originZ, directionX, directionY, directionZ, 0, 1, 0, 0);
122
122
  }
123
123
 
124
124
  }
@@ -1,55 +0,0 @@
1
- import { v3_dot } from "../../v3_dot.js";
2
-
3
- /**
4
- *
5
- * @param {Vector3} out Result will be written here
6
- * @param {number} originX Ray origin
7
- * @param {number} originY Ray origin
8
- * @param {number} originZ Ray origin
9
- * @param {number} directionX Ray direction
10
- * @param {number} directionY Ray direction
11
- * @param {number} directionZ Ray direction
12
- * @param {number} normalX Plane normal
13
- * @param {number} normalY Plane normal
14
- * @param {number} normalZ Plane normal
15
- * @param {number} dist Plane distance
16
- * @returns {boolean} true if intersection is found, false otherwise
17
- */
18
- export function computePlaneRayIntersection(out, originX, originY, originZ, directionX, directionY, directionZ, normalX, normalY, normalZ, dist) {
19
- const denom = v3_dot(directionX, directionY, directionZ, normalX, normalY, normalZ);
20
-
21
- const p = v3_dot(normalX, normalY, normalZ, originX, originY, originZ) + dist;
22
-
23
- if (denom !== 0) {
24
-
25
- const t = -p / denom;
26
-
27
- if (t < 0) {
28
- return false;
29
- }
30
-
31
- out.set(
32
- directionX * t + originX,
33
- directionY * t + originY,
34
- directionZ * t + originZ
35
- );
36
-
37
- return true;
38
-
39
- } else {
40
-
41
- if (p === 0) {
42
-
43
- out.set(originX, originY, originZ);
44
-
45
- return true;
46
-
47
- } else {
48
-
49
- //no intersection
50
- return false;
51
-
52
- }
53
-
54
- }
55
- }
@@ -1,3 +0,0 @@
1
- import { CellFilterSimplexNoise } from "../../filtering/numeric/complex/CellFilterSimplexNoise.js";
2
-
3
- export const SampleNoise20_0 = CellFilterSimplexNoise.from(20, 20);
@@ -1,52 +0,0 @@
1
- import { GridCellPlacementRule } from "../../placement/GridCellPlacementRule.js";
2
- import { matcher_tag_traversable_unoccupied } from "../rules/matcher_tag_traversable_unoccupied.js";
3
- import { CellMatcherNot } from "../../rules/logic/CellMatcherNot.js";
4
- import { GridCellActionPlaceTags } from "../../placement/action/GridCellActionPlaceTags.js";
5
- import { GridTags } from "../../GridTags.js";
6
- import { GridCellActionPlaceMarker } from "../../markers/GridCellActionPlaceMarker.js";
7
- import { GridTaskExecuteRuleTimes } from "../../grid/generation/GridTaskExecuteRuleTimes.js";
8
- import { CellMatcherLayerBitMaskTest } from "../../rules/CellMatcherLayerBitMaskTest.js";
9
- import { CellMatcherGridPattern } from "../../rules/cell/CellMatcherGridPattern.js";
10
- import { MirGridLayers } from "../grid/MirGridLayers.js";
11
- import { GridCellActionTransformNearbyMarkers } from "../../placement/GridCellActionTransformNearbyMarkers.js";
12
- import { MarkerNodeMatcherByType } from "../../markers/matcher/MarkerNodeMatcherByType.js";
13
- import { MarkerNodeTransformerRecordProperty } from "../../markers/transform/MarkerNodeTransformerRecordProperty.js";
14
- import { CellFilterLiteralFloat } from "../../filtering/numeric/CellFilterLiteralFloat.js";
15
- import { MirMarkerTypes } from "../../../../../generator/MirMarkerTypes.js";
16
- import { MarkerNodeTransformerRemoveTag } from "../../markers/transform/MarkerNodeTransformerRemoveTag.js";
17
- import { MirMarkerTags } from "../../../../../generator/MirMarkerTags.js";
18
- import { MarkerNodeTransformerSequence } from "../../markers/transform/MarkerNodeTransformerSequence.js";
19
- import { GridCellActionSequence } from "../../placement/action/util/GridCellActionSequence.js";
20
-
21
- const MATCH_STARTING_POINT = CellMatcherLayerBitMaskTest.from(GridTags.StartingPoint, MirGridLayers.Tags);
22
-
23
-
24
- const pattern = new CellMatcherGridPattern();
25
-
26
- pattern.addRule(0, 0, matcher_tag_traversable_unoccupied);
27
- pattern.addRule(0, 0, CellMatcherNot.from(MATCH_STARTING_POINT));
28
- // NEXT TO A BASE
29
- pattern.addRule(0, -1, CellMatcherLayerBitMaskTest.from(GridTags.Base, MirGridLayers.Tags));
30
-
31
- const rule = GridCellPlacementRule.from(
32
- {
33
- matcher: pattern,
34
- action: GridCellActionSequence.from([
35
- GridCellActionPlaceTags.from(GridTags.StartingPoint | GridTags.Occupied, MirGridLayers.Tags),
36
- GridCellActionPlaceMarker.from({ type: MirMarkerTypes.StartingPoint }),
37
- // transfer ownership of any base within some distance to the player
38
- GridCellActionTransformNearbyMarkers.from(
39
- 5,
40
- MarkerNodeMatcherByType.from(MirMarkerTypes.Base),
41
- MarkerNodeTransformerSequence.from([
42
- MarkerNodeTransformerRecordProperty.from('team', CellFilterLiteralFloat.from(0)),
43
- MarkerNodeTransformerRemoveTag.from(MirMarkerTags.Encounter)
44
- ])
45
- )
46
- ])
47
- }
48
- );
49
-
50
- rule.allowRotation = true;
51
-
52
- export const mir_generator_place_starting_point = () => GridTaskExecuteRuleTimes.from(rule, 1);
@@ -1,5 +0,0 @@
1
- import { CellMatcherLayerBitMaskTest } from "../../rules/CellMatcherLayerBitMaskTest.js";
2
- import { GridTags } from "../../GridTags.js";
3
- import { MirGridLayers } from "../grid/MirGridLayers.js";
4
-
5
- export const matcher_play_area = CellMatcherLayerBitMaskTest.from(GridTags.PlayArea, MirGridLayers.Tags);
@@ -1,5 +0,0 @@
1
- import { CellMatcherLayerBitMaskTest } from "../../rules/CellMatcherLayerBitMaskTest.js";
2
- import { GridTags } from "../../GridTags.js";
3
- import { MirGridLayers } from "../grid/MirGridLayers.js";
4
-
5
- export const matcher_tag_occupied = CellMatcherLayerBitMaskTest.from(GridTags.Occupied, MirGridLayers.Tags);
@@ -1,5 +0,0 @@
1
- import { CellMatcherLayerBitMaskTest } from "../../rules/CellMatcherLayerBitMaskTest.js";
2
- import { GridTags } from "../../GridTags.js";
3
- import { MirGridLayers } from "../grid/MirGridLayers.js";
4
-
5
- export const matcher_tag_traversable = CellMatcherLayerBitMaskTest.from(GridTags.Traversable, MirGridLayers.Tags);
@@ -1,25 +0,0 @@
1
- export class MarkerMatchCounter {
2
- /**
3
- * @template T
4
- */
5
- constructor() {
6
- /**
7
- * Predicate
8
- * @type {MarkerNodeMatcher|null}
9
- */
10
- this.matcher = null;
11
- this.count = 0;
12
- }
13
-
14
- /**
15
- *
16
- * @param {QuadTreeDatum<MarkerNode>} node
17
- */
18
- exec(node) {
19
- const marker = node.data;
20
-
21
- if (this.matcher.match(marker)) {
22
- this.count++;
23
- }
24
- }
25
- }