@woosh/meep-engine 2.51.0 → 2.53.0

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 (160) hide show
  1. package/editor/actions/concrete/WriteGridValueAction.js +1 -1
  2. package/editor/ecs/component/prototypeObjectEditor.js +1 -1
  3. package/editor/process/ObstacleGridDisplayProcess.js +2 -2
  4. package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +1 -1
  5. package/editor/tools/GridPaintTool.js +2 -2
  6. package/package.json +4 -3
  7. package/samples/generation/SampleGenerator0.js +1 -1
  8. package/samples/generation/generators/interactive/mir_generator_place_buff_objects.js +1 -1
  9. package/samples/generation/generators/mir_generator_place_bases.js +1 -1
  10. package/samples/generation/generators/mir_generator_place_road_decorators.js +1 -1
  11. package/samples/generation/generators/mir_generator_place_starting_point.js +1 -1
  12. package/samples/generation/main.js +2 -2
  13. package/samples/generation/rules/matcher_play_area.js +1 -1
  14. package/samples/generation/rules/matcher_tag_occupied.js +1 -1
  15. package/samples/generation/rules/matcher_tag_traversable.js +1 -1
  16. package/samples/generation/themes/SampleTheme0.js +5 -5
  17. package/src/core/NumberFormat.js +0 -71
  18. package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -0
  19. package/src/core/bvh2/bvh3/query/BVHQueryAny.js +16 -0
  20. package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +5 -5
  21. package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +2 -3
  22. package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.spec.js +22 -0
  23. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +2 -2
  24. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.spec.js +64 -0
  25. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +2 -3
  26. package/src/core/collection/table/RowFirstTableSpec.js +8 -4
  27. package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.js +41 -0
  28. package/src/core/geom/3d/matrix/MATRIX_4_IDENTITY.spec.js +10 -0
  29. package/src/core/geom/3d/topology/struct/TopoMesh.js +3 -2
  30. package/src/core/geom/3d/topology/struct/prototypeBinaryTopology.js +4 -4
  31. package/src/core/geom/Vector2.d.ts +9 -0
  32. package/src/core/geom/Vector2.js +8 -22
  33. package/src/core/geom/Vector2.spec.js +153 -0
  34. package/src/core/model/ModuleRegistry.js +2 -4
  35. package/src/core/model/ModuleRegistry.spec.js +31 -0
  36. package/src/core/model/reactive/js/compileReactiveToJS.spec.js +14 -0
  37. package/src/core/model/reactive/model/logic/ReactiveAnd.spec.js +31 -1
  38. package/src/core/model/reactive/model/logic/ReactiveOr.spec.js +53 -0
  39. package/src/core/model/stat/LinearModifier.js +2 -2
  40. package/src/core/model/stat/LinearModifier.spec.js +62 -0
  41. package/src/core/model/stat/Stat.js +12 -0
  42. package/src/core/model/stat/Stat.spec.js +36 -0
  43. package/src/core/primitives/array/computeStridedIntegerArrayHash.spec.js +28 -0
  44. package/src/core/primitives/numbers/number_format_by_thousands.js +14 -0
  45. package/src/core/primitives/numbers/number_pretty_print.js +49 -0
  46. package/src/core/primitives/strings/computeStringHash.spec.js +12 -5
  47. package/src/core/process/BaseProcess.js +8 -8
  48. package/src/engine/Clock.js +30 -29
  49. package/src/engine/Clock.spec.js +26 -0
  50. package/src/engine/Engine.spec.js +4 -0
  51. package/src/engine/ecs/EntityBuilder.js +3 -1
  52. package/src/engine/ecs/EntityBuilder.spec.js +21 -0
  53. package/src/engine/ecs/EntityComponentDataset.js +1 -1
  54. package/src/engine/ecs/EntityObserver.spec.js +1 -1
  55. package/src/engine/ecs/dynamic_actions/actions/definition/{WhiteToBlackboardActionDescription.js → WriteToBlackboardActionDescription.js} +2 -2
  56. package/src/engine/ecs/dynamic_actions/actions/definition/deserializeActionFromJSON.js +2 -2
  57. package/src/engine/ecs/gui/GUIElement.js +1 -1
  58. package/src/engine/ecs/gui/position/ViewportPosition.js +3 -3
  59. package/src/engine/ecs/guid/GUIDSerializationAdapter.spec.js +21 -0
  60. package/src/engine/ecs/parent/EntityNode.js +1 -1
  61. package/src/engine/ecs/parent/EntityNode.spec.js +104 -0
  62. package/src/engine/ecs/speaker/Voice.js +4 -0
  63. package/src/engine/ecs/team/Team.js +0 -44
  64. package/src/engine/ecs/team/TeamSerializationAdapter.js +46 -0
  65. package/src/engine/ecs/terrain/ecs/TerrainClassifier.js +1 -1
  66. package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +1 -1
  67. package/src/engine/ecs/transform/Transform.js +2 -1
  68. package/src/engine/ecs/transform/Transform.spec.js +24 -0
  69. package/src/engine/graphics/camera/testClippingPlaneComputation.js +2 -6
  70. package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraph.spec.js +5 -0
  71. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +24 -25
  72. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.spec.js +5 -0
  73. package/src/engine/graphics/ecs/decal/DecalSystem.js +2 -20
  74. package/src/engine/graphics/ecs/decal/v2/Decal.js +32 -32
  75. package/src/engine/graphics/ecs/decal/v2/Decal.spec.js +5 -0
  76. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +4 -2
  77. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +4 -33
  78. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +8 -4
  79. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.spec.js +5 -0
  80. package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +0 -12
  81. package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
  82. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +2 -6
  83. package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +2 -4
  84. package/src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js +1 -1
  85. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +0 -2
  86. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +2 -6
  87. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -6
  88. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
  89. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +4 -8
  90. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +2 -1
  91. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +6 -1
  92. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -2
  93. package/src/engine/graphics/shadows/testShadowMapRendering.js +0 -2
  94. package/src/engine/graphics/texture/TextureBackedMemoryRegion.js +4 -1
  95. package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
  96. package/src/engine/graphics/texture/sampler/filter/filter_lanczos3.js +7 -2
  97. package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +3 -23
  98. package/src/engine/grid/grid2transform/GridPosition2Transform.js +122 -0
  99. package/src/engine/grid/grid2transform/GridPosition2TransformSerializationAdapter.js +70 -0
  100. package/src/engine/grid/grid2transform/GridPosition2TransformSerializationUpgrader_0_1.js +40 -0
  101. package/src/engine/grid/{systems → grid2transform}/GridPosition2TransformSystem.js +3 -3
  102. package/src/engine/grid/{components → obstacle}/GridObstacle.js +45 -25
  103. package/src/engine/grid/obstacle/GridObstacle.spec.js +175 -0
  104. package/src/engine/grid/{components → position}/GridPosition.js +6 -14
  105. package/src/engine/grid/{systems → position}/GridPositionSystem.js +1 -1
  106. package/src/engine/grid/transform2grid/Transform2GridPositionSystem.js +1 -1
  107. package/src/engine/input/devices/PointerDevice.spec.js +5 -0
  108. package/src/engine/navigation/ecs/components/computeCatmullRomSpline.js +5 -1
  109. package/src/engine/navigation/ecs/path_following/PathFollower.js +40 -32
  110. package/src/engine/navigation/ecs/path_following/PathFollower.spec.js +27 -0
  111. package/src/engine/plugin/EnginePlugin.js +12 -14
  112. package/src/engine/plugin/EnginePlugin.spec.js +5 -0
  113. package/src/engine/plugin/EnginePluginManager.js +18 -22
  114. package/src/engine/scene/transitionToScene.js +12 -1
  115. package/src/engine/simulation/Ticker.js +1 -1
  116. package/src/generation/filtering/CellFilter.js +6 -9
  117. package/src/generation/filtering/boolean/CellFilterLiteralBoolean.js +1 -4
  118. package/src/generation/filtering/core/CellFilterBinaryOperation.js +12 -15
  119. package/src/generation/filtering/core/CellFilterOperationTertiary.js +15 -19
  120. package/src/generation/filtering/numeric/CellFilterLiteralFloat.js +6 -9
  121. package/src/generation/grid/actions/ContinuousGridCellActionSetTerrainObstacle.js +1 -1
  122. package/src/generation/grid/actions/ContinuousGridCellActionWriteObstacle.js +2 -2
  123. package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +1 -1
  124. package/src/generation/markers/actions/MarkerNodeActionEntityPlacement.js +1 -1
  125. package/src/generation/theme/TerrainLayerDescription.js +1 -1
  126. package/src/view/common/LabelView.js +3 -3
  127. package/src/engine/ecs/components/AimController.js +0 -18
  128. package/src/engine/ecs/components/Attacker.js +0 -13
  129. package/src/engine/ecs/components/MeshCollider.js +0 -15
  130. package/src/engine/ecs/components/RangedAttack.js +0 -12
  131. package/src/engine/ecs/components/TargetAI.js +0 -11
  132. package/src/engine/ecs/components/ViewportMeshProjection.js +0 -18
  133. package/src/engine/ecs/systems/AimControllerSystem.js +0 -63
  134. package/src/engine/ecs/systems/AttackerSystem.js +0 -67
  135. package/src/engine/ecs/systems/MeshColliderSystem.js +0 -47
  136. package/src/engine/ecs/systems/MonsterAISystem.js +0 -163
  137. package/src/engine/ecs/systems/MortalitySystem.js +0 -46
  138. package/src/engine/ecs/systems/RangedAttackSystem.js +0 -132
  139. package/src/engine/ecs/systems/SerializationMetadataSystem.js +0 -10
  140. package/src/engine/ecs/systems/TargetAISystem.js +0 -107
  141. package/src/engine/ecs/systems/ViewportMeshProjectionSystem.js +0 -68
  142. package/src/engine/graphics/particles/ParticleEmitterLibrary.js +0 -87
  143. package/src/engine/graphics/texture/ExportCanvasAsPNG.js +0 -7
  144. package/src/engine/grid/components/GridObstacle.spec.js +0 -46
  145. package/src/engine/grid/components/GridPosition2Transform.js +0 -232
  146. package/src/engine/grid/components/ViewportGridProjection.js +0 -20
  147. package/src/engine/grid/systems/GridObstacleSystem.js +0 -58
  148. package/src/engine/grid/systems/ViewportGridProjectionSystem.js +0 -105
  149. package/src/engine/navigation/PathFinder.js +0 -172
  150. package/src/engine/navigation/PathWorker.js +0 -78
  151. package/src/engine/navigation/ecs/systems/PathFinderSystem.js +0 -63
  152. package/src/engine/navigation/ecs/systems/PathSystem.js +0 -19
  153. package/src/engine/navigation/funnel/Funnel.js +0 -196
  154. package/src/generation/ZoneNode.js +0 -9
  155. /package/{src/generation → samples/generation/grid}/GridTags.js +0 -0
  156. /package/src/{engine → core/primitives/array}/computeStridedIntegerArrayHash.js +0 -0
  157. /package/src/engine/grid/{components → grid2transform}/GridPosition2TransformFlags.js +0 -0
  158. /package/src/engine/grid/{components → obstacle}/GridObstacleSerializationAdapter.js +0 -0
  159. /package/src/engine/grid/{components → position}/GridPositionSerializationAdapter.js +0 -0
  160. /package/src/engine/grid/{components → position}/GridPositionSerializationUpdater_0_1.js +0 -0
@@ -1,4 +1,4 @@
1
- import GridObstacle from "../../../src/engine/grid/components/GridObstacle.js";
1
+ import GridObstacle from "../../../src/engine/grid/obstacle/GridObstacle.js";
2
2
  import { Action } from "../../../src/core/process/undo/Action.js";
3
3
 
4
4
  class WriteGridValueAction extends Action {
@@ -47,7 +47,7 @@ import { ParticleEmitterEditor } from "./editors/ecs/ParticleEmitterEditor.js";
47
47
  import Vector4 from "../../../src/core/geom/Vector4.js";
48
48
  import { Vector4Editor } from "./editors/geom/Vector4Editor.js";
49
49
  import { Trail2DEditor } from "./editors/ecs/Trail2DEditor.js";
50
- import GridObstacle from "../../../src/engine/grid/components/GridObstacle.js";
50
+ import GridObstacle from "../../../src/engine/grid/obstacle/GridObstacle.js";
51
51
  import { Vector2Editor } from "./editors/geom/Vector2Editor.js";
52
52
  import Vector2 from "../../../src/core/geom/Vector2.js";
53
53
  import { randomIntegerBetween } from "../../../src/core/math/random/randomIntegerBetween.js";
@@ -1,6 +1,6 @@
1
1
  import { EditorProcess } from "./EditorProcess.js";
2
- import GridObstacle from "../../src/engine/grid/components/GridObstacle.js";
3
- import GridPosition from "../../src/engine/grid/components/GridPosition.js";
2
+ import GridObstacle from "../../src/engine/grid/obstacle/GridObstacle.js";
3
+ import GridPosition from "../../src/engine/grid/position/GridPosition.js";
4
4
  import { Sampler2D } from "../../src/engine/graphics/texture/sampler/Sampler2D.js";
5
5
  import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
6
6
 
@@ -11,7 +11,7 @@ import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
11
11
  import EditorEntity from "../../ecs/EditorEntity.js";
12
12
  import { EventType } from "../../../src/engine/ecs/EntityManager.js";
13
13
  import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
14
- import GridPosition from "../../../src/engine/grid/components/GridPosition.js";
14
+ import GridPosition from "../../../src/engine/grid/position/GridPosition.js";
15
15
  import { ProcessState } from "../../../src/core/process/ProcessState.js";
16
16
  import { obtainTerrain } from "../../../src/engine/ecs/terrain/util/obtainTerrain.js";
17
17
 
@@ -1,6 +1,6 @@
1
1
  import Tool from "./engine/Tool.js";
2
- import GridPosition from "../../src/engine/grid/components/GridPosition.js";
3
- import GridObstacle from "../../src/engine/grid/components/GridObstacle.js";
2
+ import GridPosition from "../../src/engine/grid/position/GridPosition.js";
3
+ import GridObstacle from "../../src/engine/grid/obstacle/GridObstacle.js";
4
4
  import Vector4 from "../../src/core/geom/Vector4.js";
5
5
  import ObservedValue from "../../src/core/model/ObservedValue.js";
6
6
  import Vector1 from "../../src/core/geom/Vector1.js";
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.51.0",
8
+ "version": "2.53.0",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -52,8 +52,9 @@
52
52
  "@rollup/plugin-terser": "0.4.0",
53
53
  "@rollup/plugin-strip": "3.0.2",
54
54
  "@types/three": "^0.135.0",
55
- "babel-jest": "26.6.3",
56
- "jest": "26.6.3",
55
+ "babel-jest": "29.5.0",
56
+ "jest": "29.5.0",
57
+ "jest-environment-jsdom": "29.5.0",
57
58
  "rollup": "3.16.0"
58
59
  },
59
60
  "keywords": [
@@ -2,7 +2,7 @@ import { GridTaskGroup } from "../../src/generation/GridTaskGroup.js";
2
2
  import { GridCellPlacementRule } from "../../src/generation/placement/GridCellPlacementRule.js";
3
3
  import { CellMatcherGridPattern } from "../../src/generation/rules/cell/CellMatcherGridPattern.js";
4
4
  import { CellMatcherLayerBitMaskTest } from "../../src/generation/rules/CellMatcherLayerBitMaskTest.js";
5
- import { GridTags } from "../../src/generation/GridTags.js";
5
+ import { GridTags } from "./grid/GridTags.js";
6
6
  import { CellMatcherNot } from "../../src/generation/rules/logic/CellMatcherNot.js";
7
7
  import { GridCellActionPlaceMarker } from "../../src/generation/markers/GridCellActionPlaceMarker.js";
8
8
  import { GridTaskCellularAutomata } from "../../src/generation/grid/generation/discrete/GridTaskCellularAutomata.js";
@@ -5,7 +5,7 @@ import {
5
5
  CellMatcherContainsMarkerWithinRadius
6
6
  } from "../../../../src/generation/rules/cell/CellMatcherContainsMarkerWithinRadius.js";
7
7
  import { GridCellActionPlaceTags } from "../../../../src/generation/placement/action/GridCellActionPlaceTags.js";
8
- import { GridTags } from "../../../../src/generation/GridTags.js";
8
+ import { GridTags } from "../../grid/GridTags.js";
9
9
  import { bitwiseAnd } from "../../../../src/core/binary/operations/bitwiseAnd.js";
10
10
  import { GridCellActionPlaceMarker } from "../../../../src/generation/markers/GridCellActionPlaceMarker.js";
11
11
  import { GridCellPlacementRule } from "../../../../src/generation/placement/GridCellPlacementRule.js";
@@ -3,7 +3,7 @@ import { GridCellPlacementRule } from "../../../src/generation/placement/GridCel
3
3
  import { CellMatcherGridPattern } from "../../../src/generation/rules/cell/CellMatcherGridPattern.js";
4
4
  import { GridActionRuleSet } from "../../../src/generation/markers/GridActionRuleSet.js";
5
5
  import { GridCellActionPlaceTags } from "../../../src/generation/placement/action/GridCellActionPlaceTags.js";
6
- import { GridTags } from "../../../src/generation/GridTags.js";
6
+ import { GridTags } from "../grid/GridTags.js";
7
7
  import { GridCellActionPlaceMarker } from "../../../src/generation/markers/GridCellActionPlaceMarker.js";
8
8
  import { CellMatcherNot } from "../../../src/generation/rules/logic/CellMatcherNot.js";
9
9
  import {
@@ -3,7 +3,7 @@ import { GridActionRuleSet } from "../../../src/generation/markers/GridActionRul
3
3
  import { GridCellPlacementRule } from "../../../src/generation/placement/GridCellPlacementRule.js";
4
4
  import { CellMatcherGridPattern } from "../../../src/generation/rules/cell/CellMatcherGridPattern.js";
5
5
  import { CellMatcherLayerBitMaskTest } from "../../../src/generation/rules/CellMatcherLayerBitMaskTest.js";
6
- import { GridTags } from "../../../src/generation/GridTags.js";
6
+ import { GridTags } from "../grid/GridTags.js";
7
7
  import { CellMatcherAnd } from "../../../src/generation/rules/logic/CellMatcherAnd.js";
8
8
  import { CellMatcherNot } from "../../../src/generation/rules/logic/CellMatcherNot.js";
9
9
  import { GridCellActionPlaceMarker } from "../../../src/generation/markers/GridCellActionPlaceMarker.js";
@@ -2,7 +2,7 @@ import { GridCellPlacementRule } from "../../../src/generation/placement/GridCel
2
2
  import { matcher_tag_traversable_unoccupied } from "../rules/matcher_tag_traversable_unoccupied.js";
3
3
  import { CellMatcherNot } from "../../../src/generation/rules/logic/CellMatcherNot.js";
4
4
  import { GridCellActionPlaceTags } from "../../../src/generation/placement/action/GridCellActionPlaceTags.js";
5
- import { GridTags } from "../../../src/generation/GridTags.js";
5
+ import { GridTags } from "../grid/GridTags.js";
6
6
  import { GridCellActionPlaceMarker } from "../../../src/generation/markers/GridCellActionPlaceMarker.js";
7
7
  import { GridTaskExecuteRuleTimes } from "../../../src/generation/grid/generation/GridTaskExecuteRuleTimes.js";
8
8
  import { CellMatcherLayerBitMaskTest } from "../../../src/generation/rules/CellMatcherLayerBitMaskTest.js";
@@ -7,9 +7,9 @@ import { TopDownCameraLander } from "../../src/engine/graphics/ecs/camera/topdow
7
7
  import Terrain from "../../src/engine/ecs/terrain/ecs/Terrain.js";
8
8
  import { TerrainFlags } from "../../src/engine/ecs/terrain/ecs/TerrainFlags.js";
9
9
  import Water from "../../src/engine/graphics/ecs/water/Water.js";
10
- import GridObstacle from "../../src/engine/grid/components/GridObstacle.js";
10
+ import GridObstacle from "../../src/engine/grid/obstacle/GridObstacle.js";
11
11
  import EntityBuilder from "../../src/engine/ecs/EntityBuilder.js";
12
- import GridPosition from "../../src/engine/grid/components/GridPosition.js";
12
+ import GridPosition from "../../src/engine/grid/position/GridPosition.js";
13
13
  import { Transform } from "../../src/engine/ecs/transform/Transform.js";
14
14
  import { GridData } from "../../src/generation/grid/GridData.js";
15
15
  import { computeStringHash } from "../../src/core/primitives/strings/computeStringHash.js";
@@ -1,5 +1,5 @@
1
1
  import { CellMatcherLayerBitMaskTest } from "../../../src/generation/rules/CellMatcherLayerBitMaskTest.js";
2
- import { GridTags } from "../../../src/generation/GridTags.js";
2
+ import { GridTags } from "../grid/GridTags.js";
3
3
  import { MirGridLayers } from "../grid/MirGridLayers.js";
4
4
 
5
5
  export const matcher_play_area = CellMatcherLayerBitMaskTest.from(GridTags.PlayArea, MirGridLayers.Tags);
@@ -1,5 +1,5 @@
1
1
  import { CellMatcherLayerBitMaskTest } from "../../../src/generation/rules/CellMatcherLayerBitMaskTest.js";
2
- import { GridTags } from "../../../src/generation/GridTags.js";
2
+ import { GridTags } from "../grid/GridTags.js";
3
3
  import { MirGridLayers } from "../grid/MirGridLayers.js";
4
4
 
5
5
  export const matcher_tag_occupied = CellMatcherLayerBitMaskTest.from(GridTags.Occupied, MirGridLayers.Tags);
@@ -1,5 +1,5 @@
1
1
  import { CellMatcherLayerBitMaskTest } from "../../../src/generation/rules/CellMatcherLayerBitMaskTest.js";
2
- import { GridTags } from "../../../src/generation/GridTags.js";
2
+ import { GridTags } from "../grid/GridTags.js";
3
3
  import { MirGridLayers } from "../grid/MirGridLayers.js";
4
4
 
5
5
  export const matcher_tag_traversable = CellMatcherLayerBitMaskTest.from(GridTags.Traversable, MirGridLayers.Tags);
@@ -6,13 +6,13 @@ import { MarkerNodeMatcherByType } from "../../../src/generation/markers/matcher
6
6
  import {
7
7
  MarkerNodeActionEntityPlacement
8
8
  } from "../../../src/generation/markers/actions/MarkerNodeActionEntityPlacement.js";
9
- import { EntityBlueprint } from "../../../src/engine/ecs/EntityBlueprintjs";
10
- import Mesh from "../../../src/engine/graphics/ecs/mesh/Meshjs";
11
- import { Transform } from "../../../src/engine/ecs/transform/Transformjs";
12
- import GridPosition from "../../../src/engine/grid/components/GridPosition.js";
9
+ import { EntityBlueprint } from "../../../src/engine/ecs/EntityBlueprint.js";
10
+ import Mesh from "../../../src/engine/graphics/ecs/mesh/Mesh.js";
11
+ import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
12
+ import GridPosition from "../../../src/engine/grid/position/GridPosition.js";
13
13
  import { matcher_tag_not_traversable } from "../rules/matcher_tag_not_traversable.js";
14
14
  import { CellMatcherLayerBitMaskTest } from "../../../src/generation/rules/CellMatcherLayerBitMaskTest.js";
15
- import { GridTags } from "../../../src/generation/GridTags.js";
15
+ import { GridTags } from "../grid/GridTags.js";
16
16
  import { CellFilterCellMatcher } from "../../../src/generation/filtering/CellFilterCellMatcher.js";
17
17
  import { CellFilterSimplexNoise } from "../../../src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js";
18
18
  import { CellFilterFXAA } from "../../../src/generation/filtering/numeric/complex/CellFilterFXAA.js";
@@ -2,74 +2,3 @@
2
2
  * Created by Alex on 08/08/2016.
3
3
  * @copyright Alex Goldring 2016
4
4
  */
5
-
6
-
7
- import { assert } from "./assert.js";
8
-
9
- /**
10
- *
11
- * @param {number} x
12
- * @param {string} [separator]
13
- * @returns {string}
14
- */
15
- function formatNumberByThousands(x, separator) {
16
- if (separator === undefined) {
17
- separator = ','
18
- }
19
-
20
- return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, separator);
21
- }
22
-
23
-
24
- /**
25
- *
26
- * @param {string} value
27
- * @returns {number}
28
- */
29
- function countDecimals(value) {
30
- if (value % 1 === 0) {
31
- //whole number
32
- return 0;
33
- }
34
- const s = value.toString();
35
- const index = s.indexOf('.');
36
-
37
- if (index === -1) {
38
- return 0;
39
- }
40
-
41
- //find last 0
42
- let endIndex = s.length - 1;
43
- for (; endIndex > index && s.charAt(endIndex) === "0"; endIndex--) {
44
-
45
- }
46
- const result = endIndex - index;
47
- return result;
48
- }
49
-
50
- /**
51
- *
52
- * @param {number} value
53
- * @returns {string|number}
54
- */
55
- function prettyPrint(value) {
56
- assert.typeOf(value, 'number', 'value');
57
-
58
- const MAX_DECIMALS = 2;
59
-
60
- const fraction = value % 1;
61
- if (fraction !== 0 && Math.abs(value) < 100) {
62
- const decimals = countDecimals(value.toFixed(MAX_DECIMALS));
63
- const decimalsToPrint = Math.min(decimals, MAX_DECIMALS);
64
- return value.toFixed(decimalsToPrint);
65
- } else {
66
- //no fraction
67
- return formatNumberByThousands(value - fraction, ",");
68
- }
69
-
70
- }
71
-
72
- export {
73
- prettyPrint,
74
- formatNumberByThousands
75
- };
@@ -583,6 +583,7 @@ export class ExplicitBinaryBoundingVolumeHierarchy {
583
583
  */
584
584
  insert_leaf(leaf) {
585
585
  assert.isNonNegativeInteger(leaf, 'leaf');
586
+ assert.equal(this.node_is_leaf(leaf), true, 'not is not a leaf');
586
587
 
587
588
  let uint32 = this.__data_uint32;
588
589
 
@@ -0,0 +1,16 @@
1
+ import { BVHQuery } from "./BVHQuery.js";
2
+
3
+ /**
4
+ * Accept any node
5
+ */
6
+ export class BVHQueryAny extends BVHQuery {
7
+ evaluate(node, tree) {
8
+ return true;
9
+ }
10
+
11
+ /**
12
+ * @readonly
13
+ * @type {BVHQueryAny}
14
+ */
15
+ static INSTANCE = new BVHQueryAny();
16
+ }
@@ -10,15 +10,15 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
10
10
  * @param {number[]} destination
11
11
  * @param {number} destination_offset
12
12
  * @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
13
- * @param {number} node
13
+ * @param {number} root
14
14
  * @returns {number} number of collected elements
15
15
  */
16
16
  export function bvh_collect_user_data(
17
17
  destination, destination_offset,
18
- bvh, node
18
+ bvh, root
19
19
  ) {
20
20
 
21
- if (node === NULL_NODE) {
21
+ if (root === NULL_NODE) {
22
22
  return 0;
23
23
  }
24
24
 
@@ -28,7 +28,7 @@ export function bvh_collect_user_data(
28
28
  */
29
29
  const stack_top = stack.pointer++;
30
30
 
31
- stack[stack_top] = node;
31
+ stack[stack_top] = root;
32
32
 
33
33
  let result_cursor = destination_offset;
34
34
 
@@ -54,7 +54,7 @@ export function bvh_collect_user_data(
54
54
  stack[stack.pointer++] = child2;
55
55
 
56
56
  } else {
57
- // leaf node
57
+ // leaf root
58
58
 
59
59
  destination[result_cursor++] = bvh.node_get_user_data(node);
60
60
  }
@@ -8,16 +8,15 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
8
8
  * @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
9
9
  * @param {number[]} result
10
10
  * @param {number} result_offset
11
+ * @param {number} root
11
12
  * @param {BVHQuery} query
12
13
  * @returns {number}
13
14
  */
14
15
  export function bvh_query_leaves_generic(
15
16
  result, result_offset,
16
- bvh, query
17
+ bvh, root, query
17
18
  ) {
18
19
 
19
- const root = bvh.root;
20
-
21
20
  if (root === NULL_NODE) {
22
21
  return 0;
23
22
  }
@@ -0,0 +1,22 @@
1
+ import { ExplicitBinaryBoundingVolumeHierarchy } from "../ExplicitBinaryBoundingVolumeHierarchy.js";
2
+ import { bvh_query_leaves_generic } from "./bvh_query_leaves_generic.js";
3
+ import { BVHQueryAny } from "./BVHQueryAny.js";
4
+
5
+ test("all-accepting query", () => {
6
+ const bvh = new ExplicitBinaryBoundingVolumeHierarchy();
7
+
8
+ const leaf_a = bvh.allocate_node();
9
+ const leaf_b = bvh.allocate_node();
10
+
11
+ bvh.insert_leaf(leaf_a);
12
+ bvh.insert_leaf(leaf_b);
13
+
14
+ const result = [];
15
+
16
+ const count = bvh_query_leaves_generic(result, 1, bvh, bvh.root, BVHQueryAny.INSTANCE);
17
+
18
+ expect(count).toBe(2);
19
+ expect(result).toContain(leaf_a);
20
+ expect(result).toContain(leaf_b);
21
+
22
+ });
@@ -13,6 +13,7 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
13
13
  /**
14
14
  *
15
15
  * @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
16
+ * @param {number} root
16
17
  * @param {number[]} result
17
18
  * @param {number} result_offset
18
19
  * @param {number} origin_x
@@ -24,12 +25,11 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
24
25
  * @returns {number}
25
26
  */
26
27
  export function bvh_query_leaves_ray(
27
- bvh,
28
+ bvh, root,
28
29
  result, result_offset,
29
30
  origin_x, origin_y, origin_z,
30
31
  direction_x, direction_y, direction_z
31
32
  ) {
32
- const root = bvh.root;
33
33
 
34
34
  if (root === NULL_NODE) {
35
35
  return 0;
@@ -0,0 +1,64 @@
1
+ import { ExplicitBinaryBoundingVolumeHierarchy } from "../ExplicitBinaryBoundingVolumeHierarchy.js";
2
+ import { bvh_query_leaves_ray } from "./bvh_query_leaves_ray.js";
3
+
4
+ /**
5
+ *
6
+ * @param {number[]} leaves
7
+ */
8
+ function makeBVH(...leaves) {
9
+
10
+ const bvh = new ExplicitBinaryBoundingVolumeHierarchy();
11
+
12
+ for (let i = 0; i < leaves.length; i++) {
13
+
14
+ const node = bvh.allocate_node();
15
+
16
+ bvh.node_set_aabb(node, leaves[i]);
17
+ bvh.node_set_user_data(node, i);
18
+
19
+ bvh.insert_leaf(node);
20
+ }
21
+
22
+ return bvh;
23
+ }
24
+
25
+ test("cast positive -X to +X, 1 node", () => {
26
+
27
+ const bvh = makeBVH(
28
+ [1, 3, 5, 7, 11, 13]
29
+ );
30
+
31
+ const result = [];
32
+
33
+ const match_count = bvh_query_leaves_ray(
34
+ bvh, bvh.root,
35
+ result, 0,
36
+ -1, 4, 6,
37
+ 1, 0, 0
38
+ );
39
+
40
+ expect(match_count).toBe(1);
41
+
42
+ expect(result[0]).toEqual(0);
43
+ });
44
+
45
+ test("cast positive -X to +X, 1/2 nodes", () => {
46
+
47
+ const bvh = makeBVH(
48
+ [-4, 3, 5, -2, 11, 13],
49
+ [1, 3, 5, 7, 11, 13]
50
+ );
51
+
52
+ const result = [];
53
+
54
+ const match_count = bvh_query_leaves_ray(
55
+ bvh, bvh.root,
56
+ result, 0,
57
+ -1, 4, 6,
58
+ 1, 0, 0
59
+ );
60
+
61
+ expect(match_count).toBe(1);
62
+
63
+ expect(result[0]).toEqual(1);
64
+ });
@@ -9,16 +9,15 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
9
9
  * @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
10
10
  * @param {number[]} result
11
11
  * @param {number} result_offset
12
+ * @param {number} root
12
13
  * @param {BVHQuery} query
13
14
  * @returns {number}
14
15
  */
15
16
  export function bvh_query_user_data_generic(
16
17
  result, result_offset,
17
- bvh, query
18
+ bvh,root, query
18
19
  ) {
19
20
 
20
- const root = bvh.root;
21
-
22
21
  if (root === NULL_NODE) {
23
22
  return 0;
24
23
  }
@@ -88,7 +88,7 @@ function genRowReader(types, endianType = EndianType.BigEndian) {
88
88
  *
89
89
  * @param {BinaryDataType[]} types
90
90
  * @param {EndianType} [endianType]
91
- * @returns {(data_view:DataView, byte_offset:number, record:number[])=>void}
91
+ * @returns {function(data_view:DataView, byte_offset:number, record:number[]):void}
92
92
  */
93
93
  function genRowWriter(types, endianType = EndianType.BigEndian) {
94
94
  let offset = 0;
@@ -122,7 +122,7 @@ function genRowWriter(types, endianType = EndianType.BigEndian) {
122
122
  * @param {BinaryDataType} type
123
123
  * @param {number} offset
124
124
  * @param {EndianType} [endianType]
125
- * @returns {Function}
125
+ * @returns {function(data_view:DataView, byte_offset:number, value:number):void}
126
126
  */
127
127
  function genCellWriter(type, offset, endianType = EndianType.BigEndian) {
128
128
  const writeMethod = DataType2DataViewWriters[type];
@@ -140,7 +140,7 @@ function genCellWriter(type, offset, endianType = EndianType.BigEndian) {
140
140
  * @param {BinaryDataType} type
141
141
  * @param {number} offset
142
142
  * @param {EndianType} [endianType]
143
- * @returns {Function}
143
+ * @returns {function(data_view:DataView, byte_offset:number):number}
144
144
  */
145
145
  function genCellReader(type, offset, endianType = EndianType.BigEndian) {
146
146
  const readMethod = DataType2DataViewReaders[type];
@@ -153,6 +153,10 @@ function genCellReader(type, offset, endianType = EndianType.BigEndian) {
153
153
  });
154
154
  }
155
155
 
156
+ /**
157
+ * This is a schema class for binary data tables of class {@link RowFirstTable}
158
+ * @class
159
+ */
156
160
  export class RowFirstTableSpec {
157
161
  /**
158
162
  *
@@ -179,7 +183,7 @@ export class RowFirstTableSpec {
179
183
 
180
184
  /**
181
185
  * @readonly
182
- * @type {number[]}
186
+ * @type {Uint32Array}
183
187
  */
184
188
  this.columnOffsets = new Uint32Array(numTypes);
185
189
 
@@ -0,0 +1,41 @@
1
+ import { assert } from "../../../assert.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number[]|ArrayLike<number>|Float32Array} result
6
+ * @param {BufferGeometry} geometry
7
+ */
8
+ export function aabb3_from_threejs_geometry(result, geometry) {
9
+ const gbb = geometry.boundingBox;
10
+
11
+ assert.notNull(gbb, 'boundingBox');
12
+
13
+ const min = gbb.min;
14
+ const max = gbb.max;
15
+
16
+ const x0 = min.x;
17
+ const y0 = min.y;
18
+ const z0 = min.z;
19
+
20
+ const x1 = max.x;
21
+ const y1 = max.y;
22
+ const z1 = max.z;
23
+
24
+ // validate bounds
25
+ assert.notNaN(x0, 'x0');
26
+ assert.notNaN(y0, 'y0');
27
+ assert.notNaN(z0, 'z0');
28
+
29
+ assert.notNaN(x1, 'x1');
30
+ assert.notNaN(y1, 'y1');
31
+ assert.notNaN(z1, 'z1');
32
+
33
+ // marshal into transform-accepted format
34
+ result[0] = x0;
35
+ result[1] = y0;
36
+ result[2] = z0;
37
+
38
+ result[3] = x1;
39
+ result[4] = y1;
40
+ result[5] = z1;
41
+ }
@@ -0,0 +1,10 @@
1
+ import { MATRIX_4_IDENTITY } from "./MATRIX_4_IDENTITY.js";
2
+
3
+ test("sanity", () => {
4
+ expect(Array.from(MATRIX_4_IDENTITY)).toEqual([
5
+ 1, 0, 0, 0,
6
+ 0, 1, 0, 0,
7
+ 0, 0, 1, 0,
8
+ 0, 0, 0, 1
9
+ ]);
10
+ });
@@ -8,7 +8,8 @@ import { tm_kill_only_vert } from "../tm_kill_only_vert.js";
8
8
  import { tm_kill_only_edge } from "../tm_kill_only_edge.js";
9
9
  import { tm_kill_only_face } from "../tm_kill_only_face.js";
10
10
  import { query_edge_other_vertex } from "../query/query_edge_other_vertex.js";
11
- import { formatNumberByThousands } from "../../../../NumberFormat.js";
11
+
12
+ import { number_format_by_thousands } from "../../../../primitives/numbers/number_format_by_thousands.js";
12
13
 
13
14
  export class TopoMesh {
14
15
  constructor() {
@@ -643,7 +644,7 @@ export class TopoMesh {
643
644
  }
644
645
 
645
646
  toString() {
646
- return `TopoMesh{ vertices: ${formatNumberByThousands(this.vertices.length)}, edges: ${formatNumberByThousands(this.getEdges().size)}, faces: ${formatNumberByThousands(this.getFaces().size)} }`;
647
+ return `TopoMesh{ vertices: ${number_format_by_thousands(this.vertices.length)}, edges: ${number_format_by_thousands(this.getEdges().size)}, faces: ${number_format_by_thousands(this.getFaces().size)} }`;
647
648
  }
648
649
  }
649
650
 
@@ -5,8 +5,8 @@ import { BinaryTopology } from "./binary/BinaryTopology.js";
5
5
  import {
6
6
  compute_buffer_geometry_byte_size
7
7
  } from "../../../../../engine/graphics/geometry/buffered/compute_buffer_geometry_byte_size.js";
8
- import { prettyPrint } from "../../../../NumberFormat.js";
9
8
  import { TopoMesh } from "./TopoMesh.js";
9
+ import { number_pretty_print } from "../../../../primitives/numbers/number_pretty_print.js";
10
10
 
11
11
  function promise_ply(url) {
12
12
 
@@ -44,9 +44,9 @@ async function main() {
44
44
 
45
45
  console.log(mesh, lucy_geom);
46
46
 
47
- console.log(`source mesh size: ${prettyPrint(compute_buffer_geometry_byte_size(lucy_geom))} bytes`);
48
- console.log(`binary topology size: ${prettyPrint(mesh.byteSize)} bytes`);
49
- console.log(`object topology size: ${prettyPrint(topoMesh.byteSize)} bytes`);
47
+ console.log(`source mesh size: ${number_pretty_print(compute_buffer_geometry_byte_size(lucy_geom))} bytes`);
48
+ console.log(`binary topology size: ${number_pretty_print(mesh.byteSize)} bytes`);
49
+ console.log(`object topology size: ${number_pretty_print(topoMesh.byteSize)} bytes`);
50
50
 
51
51
  window.topo_obj = topoMesh;
52
52
  }
@@ -23,6 +23,8 @@ export default class Vector2 {
23
23
 
24
24
  _sub(x: number, y: number): void
25
25
 
26
+ lerpVectors(a: Vector2, b: Vector2, f: number): void
27
+
26
28
  abs(): void
27
29
 
28
30
  round(): void
@@ -31,6 +33,8 @@ export default class Vector2 {
31
33
 
32
34
  ceil(): void
33
35
 
36
+ rotate(angle: number): void
37
+
34
38
  copy(other: Vector2): void
35
39
 
36
40
  clone(): Vector2
@@ -39,8 +43,13 @@ export default class Vector2 {
39
43
 
40
44
  roughlyEquals(other: Vector2, tolerance?: number): boolean
41
45
 
46
+ hash(): number
47
+
42
48
  distanceTo(other: Vector2): number
43
49
 
50
+ manhattanDistanceTo(other: Vector2): number
51
+
52
+
44
53
  isZero(): boolean
45
54
 
46
55
  readFromArray(array: ArrayLike<number>, offset?: number): void