@woosh/meep-engine 2.54.0 → 2.56.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 (286) hide show
  1. package/editor/view/node-graph/PortView.js +2 -2
  2. package/package.json +1 -1
  3. package/src/core/__module.js +1 -1
  4. package/src/core/binary/BinaryBuffer.js +2 -1
  5. package/src/core/cache/Cache.js +1 -1
  6. package/src/core/cache/LoadingCache.js +10 -5
  7. package/src/core/collection/Stack.js +11 -14
  8. package/src/core/collection/array/array_contains_duplicates.js +5 -2
  9. package/src/core/collection/array/array_contains_duplicates.spec.js +14 -0
  10. package/src/core/collection/array/array_copy_entire.js +6 -11
  11. package/src/core/collection/array/array_get_index_in_range.js +5 -0
  12. package/src/core/collection/array/array_get_index_in_range.spec.js +16 -0
  13. package/src/core/collection/array/array_remove_element.js +6 -9
  14. package/src/core/collection/array/array_remove_first.js +13 -6
  15. package/src/core/collection/array/array_remove_first.spec.js +39 -0
  16. package/src/core/collection/array/binarySearchHighIndex.spec.js +10 -9
  17. package/src/core/collection/array/groupArrayBy.js +1 -1
  18. package/src/core/collection/array/isArrayEqual.js +4 -1
  19. package/src/core/collection/array/randomizeArrayElementOrder.js +1 -0
  20. package/src/core/collection/array/randomizeArrayElementOrder.spec.js +27 -0
  21. package/src/core/collection/heap/Uin32Heap.spec.js +100 -0
  22. package/src/core/collection/heap/Uint32Heap.js +16 -7
  23. package/src/core/collection/list/List.js +1 -0
  24. package/src/core/collection/{HashMap.js → map/HashMap.js} +10 -10
  25. package/src/core/collection/{HashMap.spec.js → map/HashMap.spec.js} +1 -1
  26. package/src/core/collection/{ObservedMap.js → map/ObservedMap.js} +1 -1
  27. package/src/core/collection/{HashSet.js → set/HashSet.js} +4 -3
  28. package/src/core/collection/{Set.d.ts → set/Set.d.ts} +1 -1
  29. package/src/core/collection/{Set.js → set/Set.js} +17 -14
  30. package/src/core/function/FunctionCompiler.js +4 -4
  31. package/src/core/function/Functions.js +0 -19
  32. package/src/core/geom/2d/aabb/AABB2.js +1 -1
  33. package/src/core/geom/3d/SurfacePoint3.js +30 -20
  34. package/src/core/geom/3d/SurfacePoint3.spec.js +116 -0
  35. package/src/core/geom/3d/aabb/AABB3.js +13 -10
  36. package/src/core/geom/3d/aabb/{aabb3_array_contains_point.js → aabb3_array_intersects_point.js} +4 -1
  37. package/src/core/geom/3d/aabb/aabb3_from_min_max.js +25 -1
  38. package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.js +2 -25
  39. package/src/core/geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js +5 -1
  40. package/src/core/geom/3d/apply_mat4_transform_to_direction_v3_array.js +5 -1
  41. package/src/core/geom/3d/apply_mat4_transform_to_v3_array.js +5 -1
  42. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +2 -2
  43. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_calc_edges.js +1 -1
  44. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.spec.js +26 -0
  45. package/src/core/geom/3d/v3_compute_triangle_normal.spec.js +18 -0
  46. package/src/core/geom/Vector2.js +1 -1
  47. package/src/core/geom/Vector3.js +1 -1
  48. package/src/core/geom/packing/miniball/Miniball.spec.js +24 -0
  49. package/src/core/math/statistics/computeStatisticalPartialMedian.js +2 -2
  50. package/src/core/model/ObservedInteger.js +12 -7
  51. package/src/core/model/ObservedString.js +10 -8
  52. package/src/core/model/node-graph/visual/NodeGraphVisualData.js +1 -1
  53. package/src/core/model/object/ImmutableObjectPool.js +1 -1
  54. package/src/core/model/object/read_property.js +2 -2
  55. package/src/core/model/object/write_property.js +3 -3
  56. package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.js +1 -1
  57. package/src/core/primitives/numbers/compareNumbers.js +4 -4
  58. package/src/core/primitives/numbers/number_compare_ascending.js +9 -0
  59. package/src/core/primitives/numbers/number_compare_ascending.spec.js +9 -0
  60. package/src/core/primitives/numbers/number_compare_descending.js +9 -0
  61. package/src/core/primitives/numbers/number_compare_descending.spec.js +9 -0
  62. package/src/core/primitives/numbers/number_format_by_thousands.spec.js +12 -0
  63. package/src/core/primitives/numbers/number_pretty_print.js +1 -1
  64. package/src/core/primitives/strings/compareStrings.spec.js +12 -0
  65. package/src/core/primitives/strings/string_capitalize.js +15 -0
  66. package/src/core/primitives/strings/string_capitalize.spec.js +13 -0
  67. package/src/core/primitives/strings/string_compute_byte_size.js +21 -0
  68. package/src/core/primitives/strings/string_compute_common_prefix.js +44 -0
  69. package/src/core/primitives/strings/string_compute_common_prefix.spec.js +23 -0
  70. package/src/core/primitives/strings/string_format_camel_to_kebab.js +9 -0
  71. package/src/core/primitives/strings/string_format_camel_to_kebab.spec.js +8 -0
  72. package/src/core/primitives/strings/string_format_kebab_to_underscore.js +8 -0
  73. package/src/core/time/current_time_in_seconds.js +11 -0
  74. package/src/engine/Clock.js +3 -13
  75. package/src/engine/animation/curve/AnimationCurve.spec.js +27 -0
  76. package/src/engine/asset/AssetManager.js +5 -5
  77. package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
  78. package/src/engine/ecs/EntityBlueprint.js +8 -10
  79. package/src/engine/ecs/EntityManager.js +8 -1
  80. package/src/engine/ecs/EntityManager.spec.js +56 -6
  81. package/src/engine/ecs/animation/Animation.spec.js +22 -0
  82. package/src/engine/ecs/animation/AnimationSerializationAdapter.js +2 -5
  83. package/src/engine/ecs/attachment/Attachment.js +24 -25
  84. package/src/engine/ecs/attachment/AttachmentBinding.js +27 -30
  85. package/src/engine/ecs/attachment/AttachmentSystem.js +21 -24
  86. package/src/engine/ecs/attachment/BoneAttachmentBinding.js +6 -9
  87. package/src/engine/ecs/attachment/TransformAttachmentBinding.js +0 -3
  88. package/src/engine/ecs/components/CharacterController.js +24 -18
  89. package/src/engine/ecs/components/Motion.js +0 -27
  90. package/src/engine/ecs/components/MotionSerializationAdapter.js +26 -0
  91. package/src/engine/ecs/components/PropertySet.js +0 -29
  92. package/src/engine/ecs/components/PropertySetSerializationAdapter.js +29 -0
  93. package/src/engine/ecs/components/SerializationMetadata.js +0 -28
  94. package/src/engine/ecs/components/SerializationMetadataSerializationAdapter.js +26 -0
  95. package/src/engine/ecs/components/Steering.js +0 -35
  96. package/src/engine/ecs/components/SteeringSerializationAdapter.js +34 -0
  97. package/src/engine/ecs/components/Tag.js +6 -102
  98. package/src/engine/ecs/components/TagSerializationAdapter.js +44 -0
  99. package/src/engine/ecs/components/TagSerializationUpgrader_0_1.js +18 -0
  100. package/src/engine/ecs/components/Timer.js +1 -1
  101. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +4 -3
  102. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleCooldownDescription.js +10 -14
  103. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +31 -39
  104. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescriptionTable.js +1 -1
  105. package/src/engine/ecs/dynamic_actions/{DynamicRuleDescriptionTable.spec.js → rules/DynamicRuleDescriptionTable.spec.js} +12 -12
  106. package/src/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +2 -5
  107. package/src/engine/ecs/fow/FogOfWarRevealer.js +2 -3
  108. package/src/engine/ecs/fow/serialization/FogOfWarRevealerSerializationAdapter.js +2 -5
  109. package/src/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.js +5 -8
  110. package/src/engine/ecs/gui/GUIElementSerializationAdapter.js +2 -5
  111. package/src/engine/ecs/gui/hud/HeadsUpDisplaySerializationAdapter.js +3 -6
  112. package/src/engine/ecs/gui/position/ViewportPosition.js +2 -5
  113. package/src/engine/ecs/ik/IKConstraint.js +95 -0
  114. package/src/engine/ecs/ik/IKMath.js +6 -1
  115. package/src/engine/ecs/ik/IKProblem.js +17 -17
  116. package/src/engine/ecs/ik/InverseKinematics.js +14 -174
  117. package/src/engine/ecs/ik/InverseKinematicsSerializationAdapter.js +72 -0
  118. package/src/engine/ecs/ik/InverseKinematicsSystem.js +24 -26
  119. package/src/engine/ecs/speaker/Voice.js +5 -8
  120. package/src/engine/ecs/speaker/VoiceSystem.js +15 -19
  121. package/src/engine/ecs/speaker/lines/LineDescription.js +20 -25
  122. package/src/engine/ecs/speaker/lines/sets/LineSetDescription.js +15 -19
  123. package/src/engine/ecs/storage/BinaryBufferSerializer.js +3 -3
  124. package/src/engine/ecs/storage/binary/BinaryClassSerializationAdapter.js +7 -0
  125. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -1
  126. package/src/engine/ecs/storage/binary/object/ObjectBasedClassSerializationAdapter.js +6 -9
  127. package/src/engine/ecs/systems/TagSystem.js +1 -6
  128. package/src/engine/ecs/team/TeamSerializationAdapter.js +2 -5
  129. package/src/engine/ecs/terrain/ecs/Terrain.spec.js +5 -0
  130. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.js +23 -21
  131. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationAdapter.js +2 -5
  132. package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.js +2 -2
  133. package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +2 -40
  134. package/src/engine/ecs/terrain/serialization/TerrainSerializationAdapter.js +7 -10
  135. package/src/engine/ecs/tooltip/TooltipComponent.spec.js +47 -0
  136. package/src/engine/ecs/tooltip/TooltipComponentSerializationAdapter.js +2 -5
  137. package/src/engine/ecs/transform/Transform.spec.js +52 -0
  138. package/src/engine/ecs/transform/TransformSerializationAdapter.js +2 -5
  139. package/src/engine/ecs/transform-attachment/TransformAttachment.js +18 -19
  140. package/src/engine/graphics/ecs/animation/AnimationController.js +20 -129
  141. package/src/engine/graphics/ecs/animation/AnimationControllerSerializationAdapter.js +27 -0
  142. package/src/engine/graphics/ecs/animation/AnimationRule.js +79 -0
  143. package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraphSerializationAdapter.js +9 -11
  144. package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionSerializationAdapter.js +3 -5
  145. package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.js +2 -5
  146. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSerializationAdapter.js +2 -6
  147. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLander.js +3 -15
  148. package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.js +2 -4
  149. package/src/engine/graphics/ecs/highlight/HighlightSerializationAdapter.js +2 -5
  150. package/src/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +1 -1
  151. package/src/engine/graphics/ecs/light/LightSerializationAdapter.js +2 -5
  152. package/src/engine/graphics/ecs/mesh/serialization/MeshSerializationAdapter.js +2 -5
  153. package/src/engine/graphics/ecs/mesh/skeleton/BoneMapping.js +2 -2
  154. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +3 -0
  155. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.spec.js +14 -0
  156. package/src/engine/graphics/ecs/mesh-v2/render/adapters/InstancedRendererAdapter.js +1 -1
  157. package/src/engine/graphics/ecs/mesh-v2/render/adapters/SGCacheKey.js +21 -9
  158. package/src/engine/graphics/ecs/mesh-v2/render/adapters/SGCacheKey.spec.js +79 -0
  159. package/src/engine/graphics/ecs/water/WaterSerializationAdapter.js +2 -5
  160. package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
  161. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +1 -1
  162. package/src/engine/graphics/material/manager/MaterialManager.js +1 -1
  163. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
  164. package/src/engine/graphics/particles/node-based/codegen/CodeContext.js +1 -1
  165. package/src/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +2 -5
  166. package/src/engine/graphics/particles/particular/engine/emitter/serde/ParticleEmitterSerializationAdapter.js +2 -5
  167. package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.js +1 -1
  168. package/src/engine/graphics/render/visibility/IncrementalDeltaSet.spec.js +7 -6
  169. package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +1 -1
  170. package/src/engine/graphics/texture/sampler/serialization/Sampler2DSerializationAdapter.js +2 -5
  171. package/src/engine/grid/grid2transform/GridPosition2Transform.js +11 -13
  172. package/src/engine/grid/grid2transform/GridPosition2TransformSerializationAdapter.js +3 -5
  173. package/src/engine/grid/obstacle/GridObstacleSerializationAdapter.js +2 -5
  174. package/src/engine/grid/position/GridPositionSerializationAdapter.js +2 -5
  175. package/src/engine/grid/transform2grid/Transform2GridPosition.js +10 -13
  176. package/src/engine/input/devices/KeyboardDevice.js +5 -2
  177. package/src/engine/input/devices/KeyboardDevice.spec.js +12 -0
  178. package/src/engine/input/devices/PointerDevice.js +5 -1
  179. package/src/engine/input/ecs/components/Input.js +37 -11
  180. package/src/engine/input/ecs/ism/InputBinding.js +30 -12
  181. package/src/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.js +7 -10
  182. package/src/engine/intelligence/behavior/ecs/WaitForEventBehaviorSerializationAdapter.js +2 -5
  183. package/src/engine/intelligence/behavior/primitive/FailingBehaviorSerializationAdapter.js +2 -6
  184. package/src/engine/intelligence/behavior/primitive/SucceedingBehaviorSerializationAdapter.js +2 -5
  185. package/src/engine/intelligence/blackboard/BlackboardSerializationAdapter.js +2 -5
  186. package/src/engine/knowledge/database/StaticKnowledgeDatabase.js +12 -13
  187. package/src/engine/knowledge/database/StaticKnowledgeDatabase.spec.js +23 -0
  188. package/src/engine/navigation/ecs/components/PathSerializationAdapter.js +2 -5
  189. package/src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.js +2 -5
  190. package/src/engine/navigation/grid/find_path_on_grid_astar.spec.js +25 -0
  191. package/src/engine/options/OptionAbstract.js +6 -5
  192. package/src/engine/options/OptionGroup.js +13 -25
  193. package/src/engine/options/OptionGroup.spec.js +61 -0
  194. package/src/engine/save/storage/InMemoryStorage.js +3 -2
  195. package/src/engine/simulation/Ticker.js +17 -20
  196. package/src/engine/sound/ecs/SoundController.js +2 -6
  197. package/src/engine/sound/ecs/SoundListener.js +3 -21
  198. package/src/engine/sound/ecs/emitter/SoundEmitterSerializationAdapter.js +2 -6
  199. package/src/generation/GridTaskGroup.js +5 -9
  200. package/src/generation/filtering/numeric/CellFilterCache.js +12 -16
  201. package/src/generation/filtering/numeric/complex/CellFilterFXAA.js +31 -32
  202. package/src/generation/filtering/numeric/complex/CellFilterLookupTable.js +6 -9
  203. package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +7 -10
  204. package/src/generation/filtering/numeric/complex/CellFilterSobel.js +6 -9
  205. package/src/generation/filtering/numeric/math/CellFilterMembershipGeneralizedBell.js +18 -21
  206. package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.js +24 -25
  207. package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js +1 -1
  208. package/src/generation/grid/GridData.js +23 -22
  209. package/src/generation/grid/GridData.spec.js +41 -0
  210. package/src/generation/grid/GridTaskGenerator.js +7 -8
  211. package/src/generation/grid/layers/GridDataLayer.js +23 -25
  212. package/src/generation/markers/GridActionRuleSet.js +20 -22
  213. package/src/generation/markers/GridCellActionPlaceMarker.js +40 -43
  214. package/src/generation/markers/GridCellActionPlaceMarkerGroup.js +7 -9
  215. package/src/generation/markers/MarkerNode.js +44 -44
  216. package/src/generation/markers/actions/MarkerNodeActionEntityPlacement.js +15 -18
  217. package/src/generation/markers/actions/MarkerNodeActionSequence.js +6 -9
  218. package/src/generation/markers/actions/MarkerNodeProcessingRuleSet.js +5 -7
  219. package/src/generation/markers/actions/MarkerProcessingRule.js +25 -26
  220. package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorClingToTerrain.js +12 -15
  221. package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorRandomRotation.js +2 -5
  222. package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorSequence.js +6 -9
  223. package/src/generation/markers/actions/probability/MarkerNodeActionSelectWeighted.js +8 -11
  224. package/src/generation/markers/actions/probability/MarkerNodeActionWeightedElement.js +13 -13
  225. package/src/generation/markers/actions/util/GridCellActionDebugBreak.js +5 -8
  226. package/src/generation/markers/actions/util/GridCellActionLogToConsole.js +1 -4
  227. package/src/generation/markers/emitter/MarkerNodeConsumerBuffer.js +10 -13
  228. package/src/generation/markers/emitter/MarkerNodeEmitterFromAction.js +5 -9
  229. package/src/generation/markers/emitter/MarkerNodeEmitterGridCellAction.js +12 -15
  230. package/src/generation/markers/emitter/MarkerNodeEmitterGroup.js +5 -8
  231. package/src/generation/markers/emitter/MarkerNodeEmitterPredicated.js +18 -21
  232. package/src/generation/markers/matcher/MarkerNodeMatcher.js +2 -1
  233. package/src/generation/markers/matcher/MarkerNodeMatcherBinary.js +12 -13
  234. package/src/generation/markers/matcher/MarkerNodeMatcherContainsTag.js +7 -9
  235. package/src/generation/markers/matcher/MarkerNodeMatcherNot.js +7 -9
  236. package/src/generation/markers/predicate/GridDataNodePredicateBinary.js +10 -14
  237. package/src/generation/markers/predicate/GridDataNodePredicateNot.js +9 -11
  238. package/src/generation/markers/predicate/GridDataNodePredicateOverlaps.js +6 -9
  239. package/src/generation/markers/transform/MarkerNodeTransformRotateRandom.js +2 -6
  240. package/src/generation/markers/transform/MarkerNodeTransformerAddPositionYFromFilter.js +6 -9
  241. package/src/generation/markers/transform/MarkerNodeTransformerOffsetPosition.js +1 -4
  242. package/src/generation/markers/transform/MarkerNodeTransformerRecordProperty.js +12 -15
  243. package/src/generation/markers/transform/MarkerNodeTransformerRecordPropertyClosure.js +14 -17
  244. package/src/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +21 -23
  245. package/src/generation/markers/transform/MarkerNodeTransformerRemoveTag.js +1 -4
  246. package/src/generation/markers/transform/MarkerNodeTransformerSequence.js +6 -9
  247. package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilter.js +13 -17
  248. package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.js +12 -16
  249. package/src/generation/placement/GridCellActionTransformNearbyMarkers.js +26 -29
  250. package/src/generation/placement/GridCellPlacementRule.js +30 -32
  251. package/src/generation/placement/action/GridCellActionPlaceTags.js +26 -28
  252. package/src/generation/placement/action/GridCellActionWriteFilterToLayer.js +16 -20
  253. package/src/generation/placement/action/random/weighted/CellActionSelectWeightedRandom.js +13 -16
  254. package/src/generation/placement/action/random/weighted/WeightedGridCellAction.js +11 -14
  255. package/src/generation/placement/action/util/CellMatcherWithinAABB.js +2 -6
  256. package/src/generation/placement/action/util/GridCellActionSequence.js +7 -9
  257. package/src/generation/placement/action/util/GridCellDisplacedAction.js +9 -12
  258. package/src/generation/rules/CellMatcherFromFilter.js +6 -9
  259. package/src/generation/rules/CellMatcherLayerBitMaskTest.js +6 -9
  260. package/src/generation/rules/GridLayerCellMatcher.js +11 -14
  261. package/src/generation/rules/cell/CellMatcherContainsMarkerWithinRadius.js +11 -14
  262. package/src/generation/rules/cell/CellMatcherGridPattern.js +6 -8
  263. package/src/generation/rules/cell/GridPatternMatcherCell.js +11 -12
  264. package/src/generation/rules/logic/CellMatcherBinary.js +10 -14
  265. package/src/generation/rules/logic/CellMatcherDecorator.js +5 -8
  266. package/src/generation/theme/AreaMask.js +15 -17
  267. package/src/generation/theme/AreaTheme.js +7 -8
  268. package/src/generation/theme/TerrainLayerDescription.js +10 -12
  269. package/src/generation/theme/TerrainLayerRule.js +11 -13
  270. package/src/generation/theme/TerrainTheme.js +6 -7
  271. package/src/generation/theme/Theme.js +15 -17
  272. package/src/generation/theme/ThemeEngine.js +17 -19
  273. package/src/view/string_tag_to_css_class_name.js +2 -2
  274. package/src/view/tooltip/gml/TooltipParser.js +2 -2
  275. package/src/core/cache/PersistentCacheAdapter.js +0 -378
  276. package/src/core/collection/LazyStream.js +0 -23
  277. package/src/core/collection/LazyStream.spec.js +0 -13
  278. package/src/core/collection/heap/BinaryHeap.js +0 -153
  279. package/src/core/primitives/strings/StringUtils.js +0 -105
  280. package/src/core/primitives/strings/StringUtils.spec.js +0 -42
  281. package/src/engine/ecs/components/GeometryBVH.js +0 -44
  282. package/src/engine/ecs/components/MonsterAI.js +0 -15
  283. package/src/engine/ecs/systems/GeometryBVHSystem.js +0 -36
  284. package/src/generation/markers/MarkerRelation.js +0 -13
  285. /package/src/core/collection/{HashMap.d.ts → map/HashMap.d.ts} +0 -0
  286. /package/src/core/collection/{HashSet.d.ts → set/HashSet.d.ts} +0 -0
@@ -1,11 +1,12 @@
1
- import { invokeObjectEquals } from "../model/object/invokeObjectEquals.js";
2
- import { invokeObjectHash } from "../model/object/invokeObjectHash.js";
3
- import { HashMap } from "./HashMap.js";
1
+ import { invokeObjectEquals } from "../../model/object/invokeObjectEquals.js";
2
+ import { invokeObjectHash } from "../../model/object/invokeObjectHash.js";
3
+ import { HashMap } from "../map/HashMap.js";
4
4
 
5
5
 
6
6
  /**
7
7
  * Spec-compliant with ES Set interface
8
8
  * @template T
9
+ * @extends {Set}
9
10
  */
10
11
  export class HashSet {
11
12
  /**
@@ -1,4 +1,4 @@
1
- import Signal from "../events/signal/Signal";
1
+ import Signal from "../../events/signal/Signal";
2
2
 
3
3
  export default class Set<T> {
4
4
  on: {
@@ -3,12 +3,28 @@
3
3
  */
4
4
 
5
5
 
6
- import Signal from "../events/signal/Signal.js";
6
+ import Signal from "../../events/signal/Signal.js";
7
7
 
8
8
  /**
9
9
  * Structure with event signals for observing changes.
10
10
  */
11
11
  class Set {
12
+ /**
13
+ * @readonly
14
+ */
15
+ on = {
16
+ added: new Signal(),
17
+ removed: new Signal()
18
+ };
19
+
20
+ /**
21
+ * @private
22
+ * @type {T[]}
23
+ */
24
+ data = [];
25
+
26
+ length = 0;
27
+
12
28
  /**
13
29
  *
14
30
  * @param {Array.<T>} [array=[]]
@@ -17,19 +33,6 @@ class Set {
17
33
  * @property {{added: Signal, removed: Signal}} on
18
34
  */
19
35
  constructor(array) {
20
- this.on = {
21
- added: new Signal(),
22
- removed: new Signal()
23
- };
24
-
25
- /**
26
- *
27
- * @type {T[]}
28
- */
29
- this.data = [];
30
-
31
- this.length = 0;
32
-
33
36
  if (array !== undefined) {
34
37
  this.addAll(array);
35
38
  }
@@ -4,9 +4,9 @@ import { isArrayEqualStrict } from "../collection/array/isArrayEqualStrict.js";
4
4
  import { invokeObjectEquals } from "../model/object/invokeObjectEquals.js";
5
5
  import { invokeObjectHash } from "../model/object/invokeObjectHash.js";
6
6
  import { computeStringHash } from "../primitives/strings/computeStringHash.js";
7
- import { computeUTF8StringByteSize } from "../primitives/strings/StringUtils.js";
8
7
  import { computeHashArray } from "../collection/array/computeHashArray.js";
9
8
  import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
9
+ import { string_compute_byte_size } from "../primitives/strings/string_compute_byte_size.js";
10
10
 
11
11
  /**
12
12
  * Hash is an integer value, so this is an invalid value for a computed hash
@@ -62,17 +62,17 @@ class FunctionDefinition {
62
62
  */
63
63
  computeByteSize() {
64
64
 
65
- let result = computeUTF8StringByteSize(this.body);
65
+ let result = string_compute_byte_size(this.body);
66
66
 
67
67
  if (this.name !== undefined) {
68
- result += computeUTF8StringByteSize(this.name);
68
+ result += string_compute_byte_size(this.name);
69
69
  }
70
70
 
71
71
  const n = this.args.length;
72
72
  for (let i = 0; i < n; i++) {
73
73
  const arg = this.args[i];
74
74
 
75
- result += computeUTF8StringByteSize(arg);
75
+ result += string_compute_byte_size(arg);
76
76
  }
77
77
 
78
78
  return result;
@@ -101,22 +101,3 @@ export function chainFunctions(...processes) {
101
101
  }
102
102
 
103
103
 
104
- /**
105
- *
106
- * @param {number} a
107
- * @param {number} b
108
- * @return {number}
109
- */
110
- export function compareNumbersAscending(a, b) {
111
- return a - b;
112
- }
113
-
114
- /**
115
- *
116
- * @param {number} a
117
- * @param {number} b
118
- * @return {number}
119
- */
120
- export function compareNumbersDescending(a, b) {
121
- return b - a;
122
- }
@@ -17,7 +17,7 @@ import {
17
17
 
18
18
  /**
19
19
  *
20
- * Axis-Aligned Bounding Box 2D
20
+ * Axis-Aligned Bounding Box in 2D
21
21
  */
22
22
  class AABB2 {
23
23
  /**
@@ -6,26 +6,25 @@ import { assert } from "../../assert.js";
6
6
  * Used for representing points on a 3D surface. Used for raycasting contacts
7
7
  */
8
8
  export class SurfacePoint3 {
9
- constructor() {
10
- /**
11
- * @readonly
12
- * @type {Vector3}
13
- */
14
- this.normal = new Vector3(0, 1, 0);
15
-
16
- /**
17
- * @readonly
18
- * @type {Vector3}
19
- */
20
- this.position = new Vector3(0, 0, 0);
21
-
22
- /**
23
- * Primitive index, such as triangle/point/line from the source geometry
24
- * optional
25
- * @type {number}
26
- */
27
- this.index = -1;
28
- }
9
+
10
+ /**
11
+ * @readonly
12
+ * @type {Vector3}
13
+ */
14
+ normal = new Vector3(0, 1, 0);
15
+
16
+ /**
17
+ * @readonly
18
+ * @type {Vector3}
19
+ */
20
+ position = new Vector3(0, 0, 0);
21
+
22
+ /**
23
+ * Primitive index, such as triangle/point/line from the source geometry
24
+ * optional
25
+ * @type {number}
26
+ */
27
+ index = -1;
29
28
 
30
29
  get 0() {
31
30
  return this.position.x;
@@ -129,6 +128,17 @@ export class SurfacePoint3 {
129
128
  this.normal.writeToArray(array, offset + 3);
130
129
  }
131
130
 
131
+ /**
132
+ *
133
+ * @param {SurfacePoint3} other
134
+ * @returns {boolean}
135
+ */
136
+ equals(other) {
137
+ return this.index === other.index
138
+ && this.position.equals(other.position)
139
+ && this.normal.equals(other.normal);
140
+ }
141
+
132
142
  /**
133
143
  *
134
144
  * @param {SurfacePoint3} other
@@ -0,0 +1,116 @@
1
+ import { SurfacePoint3 } from "./SurfacePoint3.js";
2
+ import { MATRIX_4_IDENTITY } from "./matrix/MATRIX_4_IDENTITY.js";
3
+
4
+
5
+ test("equals", () => {
6
+
7
+ const a = new SurfacePoint3();
8
+
9
+ a.position.set(1, 3, 5);
10
+ a.normal.set(7, 11, 13);
11
+ a.index = 97;
12
+
13
+ const b = new SurfacePoint3();
14
+
15
+ expect(a.equals(b)).toBe(false);
16
+
17
+ b.index = 97;
18
+
19
+ expect(a.equals(b)).toBe(false);
20
+
21
+ b.position.set(1, 3, 5);
22
+
23
+ expect(a.equals(b)).toBe(false);
24
+
25
+ b.normal.set(7, 11, 13);
26
+
27
+ expect(a.equals(b)).toBe(true);
28
+
29
+ b.index = 91;
30
+
31
+ expect(a.equals(b)).toBe(false);
32
+ });
33
+
34
+ test("copy", () => {
35
+ const a = new SurfacePoint3();
36
+
37
+ a.position.set(1, 3, 5);
38
+ a.normal.set(7, 11, 13);
39
+ a.index = 97;
40
+
41
+ const b = new SurfacePoint3();
42
+
43
+ b.copy(a);
44
+
45
+ expect(b.position.x).toBe(1);
46
+ expect(b.position.y).toBe(3);
47
+ expect(b.position.z).toBe(5);
48
+
49
+ expect(b.normal.x).toBe(7);
50
+ expect(b.normal.y).toBe(11);
51
+ expect(b.normal.z).toBe(13);
52
+
53
+ expect(b.index).toBe(97);
54
+ });
55
+
56
+ test("array-style getters", () => {
57
+
58
+ const point = new SurfacePoint3();
59
+
60
+ point.position.set(1, 3, 5);
61
+ point.normal.set(7, 11, 13);
62
+
63
+ expect(point[0]).toBe(1);
64
+ expect(point[1]).toBe(3);
65
+ expect(point[2]).toBe(5);
66
+
67
+ expect(point[3]).toBe(7);
68
+ expect(point[4]).toBe(11);
69
+ expect(point[5]).toBe(13);
70
+
71
+ });
72
+
73
+ test("toArray", () => {
74
+
75
+ const point = new SurfacePoint3();
76
+
77
+ point.position.set(1, 3, 5);
78
+ point.normal.set(7, 11, 13);
79
+
80
+ const array = [99];
81
+
82
+ point.toArray(array, 1);
83
+
84
+ expect(array).toEqual([99, 1, 3, 5, 7, 11, 13]);
85
+ });
86
+
87
+ test("fromArray", () => {
88
+ const point = new SurfacePoint3();
89
+
90
+ point.fromArray([99, 1, 3, 5, 7, 11, 13], 1);
91
+
92
+ expect(point.position.x).toBe(1);
93
+ expect(point.position.y).toBe(3);
94
+ expect(point.position.z).toBe(5);
95
+
96
+ expect(point.normal.x).toBe(7);
97
+ expect(point.normal.y).toBe(11);
98
+ expect(point.normal.z).toBe(13);
99
+
100
+ });
101
+
102
+ test("applyMatrix4 with identity matrix", () => {
103
+
104
+ const original = new SurfacePoint3();
105
+
106
+ original.position.set(1, 3, 5);
107
+ original.normal.set(7, 11, 13);
108
+
109
+ original.normal.normalize();
110
+
111
+ const transformed = original.clone();
112
+
113
+ transformed.applyMatrix4(MATRIX_4_IDENTITY);
114
+
115
+ expect(transformed.equals(original)).toBe(true);
116
+ });
@@ -15,9 +15,11 @@ import { aabb3_compute_surface_area } from "./aabb3_compute_surface_area.js";
15
15
  import { aabb3_intersects_frustum_array } from "./aabb3_intersects_frustum_array.js";
16
16
  import { aabb3_matrix4_project } from "./aabb3_matrix4_project.js";
17
17
  import { aabb3_signed_distance_sqr_to_point } from "./aabb3_signed_distance_sqr_to_point.js";
18
- import { aabb3_array_contains_point } from "./aabb3_array_contains_point.js";
19
-
18
+ import { aabb3_array_intersects_point } from "./aabb3_array_intersects_point.js";
20
19
 
20
+ /**
21
+ * Axis-Aligned bounding box in 3D
22
+ */
21
23
  export class AABB3 {
22
24
  /**
23
25
  *
@@ -104,14 +106,14 @@ export class AABB3 {
104
106
  }
105
107
 
106
108
  /**
107
- * @deprecated use {@link aabb3_array_contains_point} directly
109
+ * @deprecated use {@link aabb3_array_intersects_point} directly
108
110
  * @param {number} x
109
111
  * @param {number} y
110
112
  * @param {number} z
111
113
  * @returns {boolean}
112
114
  */
113
115
  containsPoint(x, y, z) {
114
- return aabb3_array_contains_point(this, x, y, z);
116
+ return aabb3_array_intersects_point(this, x, y, z);
115
117
  }
116
118
 
117
119
  /**
@@ -249,6 +251,8 @@ export class AABB3 {
249
251
  * @param {Number} z1
250
252
  */
251
253
  setBoundsUnordered(x0, y0, z0, x1, y1, z1) {
254
+
255
+ // sort bound coordinates
252
256
  let _x0, _y0, _z0, _x1, _y1, _z1;
253
257
  if (x0 < x1) {
254
258
  _x0 = x0;
@@ -271,7 +275,10 @@ export class AABB3 {
271
275
  _z0 = z1;
272
276
  _z1 = z0;
273
277
  }
278
+
279
+ // write sorted
274
280
  this.setBounds(_x0, _y0, _z0, _x1, _y1, _z1);
281
+
275
282
  }
276
283
 
277
284
  setNegativelyInfiniteBounds() {
@@ -291,12 +298,8 @@ export class AABB3 {
291
298
  */
292
299
  distanceToPoint2(x, y, z) {
293
300
  return aabb3_signed_distance_sqr_to_point(
294
- this.x0,
295
- this.y0,
296
- this.z0,
297
- this.x1,
298
- this.y1,
299
- this.z1,
301
+ this.x0, this.y0, this.z0,
302
+ this.x1, this.y1, this.z1,
300
303
  x, y, z
301
304
  );
302
305
  }
@@ -8,7 +8,10 @@
8
8
  * @param {number} z
9
9
  * @return {boolean}
10
10
  */
11
- export function aabb3_array_contains_point(aabb, x, y, z) {
11
+ export function aabb3_array_intersects_point(
12
+ aabb,
13
+ x, y, z
14
+ ) {
12
15
  return x >= aabb[0]
13
16
  && x <= aabb[3]
14
17
  && y >= aabb[1]
@@ -1,10 +1,34 @@
1
+ import { assert } from "../../../assert.js";
2
+
1
3
  /**
2
4
  *
3
5
  * @param {number[]|Float32Array|Float64Array} result
4
6
  * @param {{x:number,y:number,z:number}} min
5
7
  * @param {{x:number,y:number,z:number}} max
6
8
  */
7
- export function aabb3_from_min_max(result, min, max) {
9
+ export function aabb3_from_min_max(
10
+ result,
11
+ min, max
12
+ ) {
13
+ // read out bounds
14
+ const x0 = min.x;
15
+ const y0 = min.y;
16
+ const z0 = min.z;
17
+
18
+ const x1 = max.x;
19
+ const y1 = max.y;
20
+ const z1 = max.z;
21
+
22
+ // validate bounds
23
+ assert.notNaN(x0, 'x0');
24
+ assert.notNaN(y0, 'y0');
25
+ assert.notNaN(z0, 'z0');
26
+
27
+ assert.notNaN(x1, 'x1');
28
+ assert.notNaN(y1, 'y1');
29
+ assert.notNaN(z1, 'z1');
30
+
31
+ // marshal to output
8
32
  result[0] = min.x;
9
33
  result[1] = min.y;
10
34
  result[2] = min.z;
@@ -1,4 +1,5 @@
1
1
  import { assert } from "../../../assert.js";
2
+ import { aabb3_from_min_max } from "./aabb3_from_min_max.js";
2
3
 
3
4
  /**
4
5
  *
@@ -13,29 +14,5 @@ export function aabb3_from_threejs_geometry(result, geometry) {
13
14
  const min = gbb.min;
14
15
  const max = gbb.max;
15
16
 
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;
17
+ aabb3_from_min_max(result, min, max);
41
18
  }
@@ -13,7 +13,11 @@ import { max2 } from "../../../math/max2.js";
13
13
  * @param {number} point_z
14
14
  * @returns {number}
15
15
  */
16
- export function aabb3_signed_distance_sqr_to_point(x0, y0, z0, x1, y1, z1, point_x, point_y, point_z) {
16
+ export function aabb3_signed_distance_sqr_to_point(
17
+ x0, y0, z0,
18
+ x1, y1, z1,
19
+ point_x, point_y, point_z
20
+ ) {
17
21
  //do projection
18
22
  const xp0 = x0 - point_x;
19
23
  const xp1 = point_x - x1;
@@ -8,7 +8,11 @@
8
8
  * @param {number} vertex_count
9
9
  * @param {mat4|number[]|Float32Array} mat4
10
10
  */
11
- export function apply_mat4_transform_to_direction_v3_array(source, source_offset, destination, destination_offset, vertex_count, mat4) {
11
+ export function apply_mat4_transform_to_direction_v3_array(
12
+ source, source_offset,
13
+ destination, destination_offset,
14
+ vertex_count, mat4
15
+ ) {
12
16
 
13
17
  const a0 = mat4[0];
14
18
  const a1 = mat4[1];
@@ -8,7 +8,11 @@
8
8
  * @param {number} vertex_count
9
9
  * @param {mat4|number[]|Float32Array} mat4
10
10
  */
11
- export function apply_mat4_transform_to_v3_array(source, source_offset, destination, destination_offset, vertex_count, mat4) {
11
+ export function apply_mat4_transform_to_v3_array(
12
+ source, source_offset,
13
+ destination, destination_offset,
14
+ vertex_count, mat4
15
+ ) {
12
16
 
13
17
  const a0 = mat4[0];
14
18
  const a1 = mat4[1];
@@ -4,9 +4,9 @@ import { max3 } from "../../../math/max3.js";
4
4
  import { assert } from "../../../assert.js";
5
5
  import { array_copy } from "../../../collection/array/array_copy.js";
6
6
  import { array_quick_sort_by_comparator } from "../../../collection/array/arrayQuickSort.js";
7
- import { compareNumbersDescending } from "../../../function/Functions.js";
8
7
  import { BinaryBuffer } from "../../../binary/BinaryBuffer.js";
9
8
  import { Base64 } from "../../../binary/Base64.js";
9
+ import { number_compare_descending } from "../../../primitives/numbers/number_compare_descending.js";
10
10
 
11
11
  /**
12
12
  * @readonly
@@ -546,7 +546,7 @@ export class TetrahedralMesh {
546
546
  */
547
547
  compact() {
548
548
  // sort free
549
- array_quick_sort_by_comparator(this.__free, compareNumbersDescending, null, 0, this.__free_pointer - 1);
549
+ array_quick_sort_by_comparator(this.__free, number_compare_descending, null, 0, this.__free_pointer - 1);
550
550
 
551
551
  let relocation_count = 0;
552
552
  let free_head_pointer = 0;
@@ -1,5 +1,5 @@
1
1
  import { OrderedEdge } from "./OrderedEdge.js";
2
- import { HashMap } from "../../../../../../collection/HashMap.js";
2
+ import { HashMap } from "../../../../../../collection/map/HashMap.js";
3
3
 
4
4
  /**
5
5
  * @see https://github.com/blender/blender/blob/9cb061f4f0119e647173e7d354e1457e97632333/source/blender/blenkernel/intern/mesh_calc_edges.cc#L209
@@ -0,0 +1,26 @@
1
+ import { computeTriangleRayIntersectionBarycentric } from "./computeTriangleRayIntersectionBarycentric.js";
2
+
3
+ test("orthogonal, through center", () => {
4
+
5
+ const result = [];
6
+
7
+ const hit_found = computeTriangleRayIntersectionBarycentric(
8
+ result,
9
+ 0, 0, 3,
10
+ 0, 0, -1,
11
+ -1, -1, 0,
12
+ 1, -1, 0,
13
+ 1, 1, 0
14
+ );
15
+
16
+ expect(hit_found).toBe(true);
17
+
18
+ expect(result[0]).toBeCloseTo(3);
19
+
20
+ // note that UVs are just checked for sanity
21
+ expect(result[1]).toBeGreaterThanOrEqual(0);
22
+ expect(result[1]).toBeLessThanOrEqual(1);
23
+
24
+ expect(result[2]).toBeGreaterThanOrEqual(0);
25
+ expect(result[2]).toBeLessThanOrEqual(1);
26
+ });
@@ -25,3 +25,21 @@ test("axis aligned triangles on -X plane", () => {
25
25
 
26
26
  expect(result).toEqual([-1, 0, 0]);
27
27
  });
28
+
29
+ test("degenerate triangle with all points at the same position", () => {
30
+ const result = [];
31
+
32
+ v3_compute_triangle_normal(
33
+ result, 0,
34
+ 1, 3, 5,
35
+ 1, 3, 5,
36
+ 1, 3, 5,
37
+ );
38
+
39
+ expect(result[0]).not.toBeNaN();
40
+ expect(result[1]).not.toBeNaN();
41
+ expect(result[2]).not.toBeNaN();
42
+
43
+ // normal vector length should be 1
44
+ expect(Math.hypot(result[0], result[1], result[2])).toBeCloseTo(1);
45
+ });
@@ -581,7 +581,7 @@ class Vector2 {
581
581
  }
582
582
 
583
583
  toString() {
584
- return `Vector2{x:${this.x}, y:${this.y}}`;
584
+ return `Vector2{ x:${this.x}, y:${this.y} }`;
585
585
  }
586
586
 
587
587
  /**
@@ -806,7 +806,7 @@ class Vector3 {
806
806
  }
807
807
 
808
808
  toString() {
809
- return `{ x:${this.x}, y:${this.y}, z:${this.z} }`;
809
+ return `Vector3{ x:${this.x}, y:${this.y}, z:${this.z} }`;
810
810
  }
811
811
 
812
812
  /**
@@ -1,6 +1,13 @@
1
1
  import { Miniball } from "./Miniball.js";
2
2
  import { PointSet } from "./PointSet.js";
3
3
 
4
+
5
+ test("empty point set in 1d", () => {
6
+
7
+ new Miniball(new PointSet(0, 1, []));
8
+
9
+ });
10
+
4
11
  test("single point in 1d", () => {
5
12
 
6
13
  const miniball = new Miniball(new PointSet(1, 1, [7]));
@@ -9,3 +16,20 @@ test("single point in 1d", () => {
9
16
  expect(miniball.radius()).toEqual(0);
10
17
 
11
18
  });
19
+
20
+ test("3 points in 1d", () => {
21
+ const miniball = new Miniball(new PointSet(3, 1, [-3, 7, 11]));
22
+
23
+ expect(miniball.center()[0]).toBeCloseTo(4);
24
+ expect(miniball.radius()).toBeCloseTo(7);
25
+ });
26
+
27
+ test("toString produces a valid string", () => {
28
+
29
+ const miniball = new Miniball(new PointSet(1, 1, [7]));
30
+
31
+ const s = miniball.toString();
32
+
33
+ expect(typeof s).toBe("string");
34
+ expect(s.trim().length).toBeGreaterThan(0);
35
+ });
@@ -1,5 +1,5 @@
1
- import { compareNumbersAscending } from "../../function/Functions.js";
2
1
  import { assert } from "../../assert.js";
2
+ import { number_compare_ascending } from "../../primitives/numbers/number_compare_ascending.js";
3
3
 
4
4
  /**
5
5
  *
@@ -14,7 +14,7 @@ export function computeStatisticalPartialMedian(values, start, end) {
14
14
 
15
15
  const copy = values.slice();
16
16
 
17
- copy.sort(compareNumbersAscending);
17
+ copy.sort(number_compare_ascending);
18
18
 
19
19
  const range = end - start;
20
20