@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
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
5
+ import KeyboardDevice from "./KeyboardDevice.js";
6
+
7
+ test("constructor does not throw", () => {
8
+ const el = document.createElement('div');
9
+ el.setAttribute('tabindex', "0");
10
+
11
+ new KeyboardDevice(el);
12
+ });
@@ -322,9 +322,13 @@ export function readPositionFromMouseEvent(result, event, source = event.target)
322
322
  result.set(x, y);
323
323
  }
324
324
 
325
+ /**
326
+ * Abstracts Mouse and Touch interfaces as single "pointer" device.
327
+ */
325
328
  export class PointerDevice {
326
329
 
327
330
  /**
331
+ * Current live position of the pointer
328
332
  * @readonly
329
333
  * @type {Vector2}
330
334
  */
@@ -373,7 +377,7 @@ export class PointerDevice {
373
377
  isRunning = false;
374
378
 
375
379
  /**
376
- * The MouseEvent.buttons is a 32bit field, which means we can encode up to 32 buttons
380
+ * The {@link MouseEvent.buttons} is a 32bit field, which means we can encode up to 32 buttons
377
381
  * @readonly
378
382
  * @type {InputDeviceSwitch[]}
379
383
  */
@@ -4,12 +4,28 @@ import { InputBinding } from "../ism/InputBinding.js";
4
4
 
5
5
 
6
6
  export class Input {
7
- constructor() {
8
- /**
9
- *
10
- * @type {List<InputBinding>}
11
- */
12
- this.bindings = new List();
7
+
8
+ /**
9
+ * @readonly
10
+ * @type {List<InputBinding>}
11
+ */
12
+ bindings = new List();
13
+
14
+ /**
15
+ *
16
+ * @param {Input} other
17
+ * @returns {boolean}
18
+ */
19
+ equals(other) {
20
+ return this.bindings.equals(other.bindings);
21
+ }
22
+
23
+ /**
24
+ *
25
+ * @return {number}
26
+ */
27
+ hash() {
28
+ return this.bindings.hash();
13
29
  }
14
30
 
15
31
  /**
@@ -19,10 +35,20 @@ export class Input {
19
35
  * @returns {boolean}
20
36
  */
21
37
  exists(path, event) {
22
- assert.typeOf(path, 'string', "path");
23
- assert.typeOf(event, 'string', "event");
38
+ assert.isString(path, "path");
39
+ assert.isString(event, "event");
40
+
41
+ const bindings = this.bindings;
42
+ const count = bindings.length;
43
+ for (let i = 0; i < count; i++) {
44
+ const binding = bindings.get(i);
45
+
46
+ if (binding.path === path && binding.event === event) {
47
+ return true;
48
+ }
49
+ }
24
50
 
25
- return this.bindings.some(b => b.path === path && b.event === event);
51
+ return false;
26
52
  }
27
53
 
28
54
  /**
@@ -32,8 +58,8 @@ export class Input {
32
58
  * @returns {boolean}
33
59
  */
34
60
  bind(path, event) {
35
- assert.typeOf(path, 'string', path);
36
- assert.typeOf(event, 'string', path);
61
+ assert.isString(path, "path");
62
+ assert.isString(event, "event");
37
63
 
38
64
  if (this.exists(path, event)) {
39
65
  //binding exists
@@ -1,18 +1,18 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
+ import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
2
3
 
3
4
  export class InputBinding {
4
- constructor() {
5
- /**
6
- *
7
- * @type {string}
8
- */
9
- this.path = "";
10
- /**
11
- *
12
- * @type {string}
13
- */
14
- this.event = "";
15
- }
5
+
6
+ /**
7
+ *
8
+ * @type {string}
9
+ */
10
+ path = "";
11
+ /**
12
+ *
13
+ * @type {string}
14
+ */
15
+ event = "";
16
16
 
17
17
  /**
18
18
  *
@@ -27,6 +27,24 @@ export class InputBinding {
27
27
  this.event = event;
28
28
  }
29
29
 
30
+ /**
31
+ *
32
+ * @param {InputBinding} other
33
+ * @returns {boolean}
34
+ */
35
+ equals(other) {
36
+ return this.event === other.event
37
+ && this.path === other.path;
38
+ }
39
+
40
+ /**
41
+ *
42
+ * @return {number}
43
+ */
44
+ hash() {
45
+ return computeStringHash(this.event) ^ computeStringHash(this.path);
46
+ }
47
+
30
48
  /**
31
49
  *
32
50
  * @param {BinaryBuffer} buffer
@@ -4,18 +4,15 @@ import { SequenceBehavior } from "../composite/SequenceBehavior.js";
4
4
  import { SucceedingBehavior } from "../primitive/SucceedingBehavior.js";
5
5
 
6
6
  export class BehaviorComponentSerializationAdapter extends BinaryClassSerializationAdapter {
7
- constructor() {
8
- super();
9
7
 
10
- this.klass = BehaviorComponent;
11
- this.version = 0;
8
+ klass = BehaviorComponent;
9
+ version = 0;
12
10
 
13
- /**
14
- *
15
- * @type {BinaryObjectSerializationAdapter}
16
- */
17
- this.objectAdapter = null;
18
- }
11
+ /**
12
+ *
13
+ * @type {BinaryObjectSerializationAdapter}
14
+ */
15
+ objectAdapter = null;
19
16
 
20
17
  /**
21
18
  *
@@ -2,12 +2,9 @@ import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/Bin
2
2
  import { WaitForEventBehavior } from "./WaitForEventBehavior.js";
3
3
 
4
4
  export class WaitForEventBehaviorSerializationAdapter extends BinaryClassSerializationAdapter {
5
- constructor() {
6
- super();
7
5
 
8
- this.klass = WaitForEventBehavior;
9
- this.version = 0;
10
- }
6
+ klass = WaitForEventBehavior;
7
+ version = 0;
11
8
 
12
9
  /**
13
10
  *
@@ -2,12 +2,8 @@ import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/Bin
2
2
  import { FailingBehavior } from "./FailingBehavior.js";
3
3
 
4
4
  export class FailingBehaviorSerializationAdapter extends BinaryClassSerializationAdapter {
5
- constructor() {
6
- super();
7
-
8
- this.klass = FailingBehavior;
9
- this.version = 0;
10
- }
5
+ klass = FailingBehavior;
6
+ version = 0;
11
7
 
12
8
  /**
13
9
  *
@@ -2,12 +2,9 @@ import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/Bin
2
2
  import { SucceedingBehavior } from "./SucceedingBehavior.js";
3
3
 
4
4
  export class SucceedingBehaviorSerializationAdapter extends BinaryClassSerializationAdapter {
5
- constructor() {
6
- super();
7
5
 
8
- this.klass = SucceedingBehavior;
9
- this.version = 0;
10
- }
6
+ klass = SucceedingBehavior;
7
+ version = 0;
11
8
 
12
9
  /**
13
10
  *
@@ -4,12 +4,9 @@ import { Blackboard } from "./Blackboard.js";
4
4
  import { BlackboardValue } from "./BlackboardValue.js";
5
5
 
6
6
  export class BlackboardSerializationAdapter extends BinaryClassSerializationAdapter {
7
- constructor() {
8
- super();
9
7
 
10
- this.klass = Blackboard;
11
- this.version = 0;
12
- }
8
+ klass = Blackboard;
9
+ version = 0;
13
10
 
14
11
  /**
15
12
  *
@@ -18,22 +18,21 @@ export const StaticKnowledgeState = {
18
18
  };
19
19
 
20
20
  export class StaticKnowledgeDatabase {
21
- constructor() {
22
21
 
23
- /**
24
- *
25
- * @type {ObservedEnum<StaticKnowledgeState>}
26
- */
27
- this.__state = new ObservedEnum(StaticKnowledgeState.Initial, StaticKnowledgeState);
22
+ /**
23
+ *
24
+ * @type {ObservedEnum<StaticKnowledgeState>}
25
+ */
26
+ __state = new ObservedEnum(StaticKnowledgeState.Initial, StaticKnowledgeState);
28
27
 
29
28
 
30
- /**
31
- *
32
- * @type {StaticKnowledgeDataTableDescriptor[]}
33
- * @private
34
- */
35
- this.__specs = [];
36
- }
29
+ /**
30
+ *
31
+ * @type {StaticKnowledgeDataTableDescriptor[]}
32
+ * @private
33
+ */
34
+ __specs = [];
35
+
37
36
 
38
37
  /**
39
38
  * Reset database, drop all table data
@@ -0,0 +1,23 @@
1
+ import { StaticKnowledgeDatabase } from "./StaticKnowledgeDatabase.js";
2
+ import { StaticKnowledgeDataTable } from "./StaticKnowledgeDataTable.js";
3
+
4
+ test("constructor does not throw", () => {
5
+ new StaticKnowledgeDatabase()
6
+ });
7
+
8
+ test("reset empty", () => {
9
+ const database = new StaticKnowledgeDatabase();
10
+
11
+ database.reset();
12
+ });
13
+
14
+ test("add/get", () => {
15
+ const database = new StaticKnowledgeDatabase();
16
+
17
+ const table = new StaticKnowledgeDataTable();
18
+ database.add("x", "y", table)
19
+
20
+ const actual = database.getTable('x');
21
+
22
+ expect(actual).toBe(table);
23
+ });
@@ -6,12 +6,9 @@ import Path from "./Path.js";
6
6
  const v0 = new Vector3();
7
7
 
8
8
  export class PathSerializationAdapter extends BinaryClassSerializationAdapter {
9
- constructor() {
10
- super();
11
9
 
12
- this.klass = Path;
13
- this.version = 3;
14
- }
10
+ klass = Path;
11
+ version = 3;
15
12
 
16
13
  /**
17
14
  *
@@ -2,12 +2,9 @@ import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/Bin
2
2
  import PathFollower from "./PathFollower.js";
3
3
 
4
4
  export class PathFollowerSerializationAdapter extends BinaryClassSerializationAdapter {
5
- constructor() {
6
- super();
7
5
 
8
- this.klass = PathFollower;
9
- this.version = 3;
10
- }
6
+ klass = PathFollower;
7
+ version = 3;
11
8
 
12
9
  /**
13
10
  *
@@ -5,3 +5,28 @@ test("sanity check on 1x1 grid", () => {
5
5
 
6
6
  expect(path).toEqual([0]);
7
7
  });
8
+
9
+ test("sanity check on 2x1 grid", () => {
10
+ const path = find_path_on_grid_astar(
11
+ [0, 0], 2, 1,
12
+ 0, 1,
13
+ 0, 0, 1
14
+ );
15
+
16
+ expect(path).toEqual([0, 1]);
17
+ });
18
+
19
+ test("sanity check on 2x2 grid", () => {
20
+
21
+ const path = find_path_on_grid_astar(
22
+ [
23
+ 0, 0,
24
+ 1, 0
25
+ ],
26
+ 2, 2,
27
+ 0, 3,
28
+ 0, 0, 1
29
+ );
30
+
31
+ expect(path).toEqual([0, 1, 3]);
32
+ });
@@ -1,4 +1,10 @@
1
1
  export class OptionAbstract {
2
+ /**
3
+ *
4
+ * @type {OptionGroup|null}
5
+ */
6
+ parent = null;
7
+
2
8
  /**
3
9
  *
4
10
  * @param {string} id
@@ -11,11 +17,6 @@ export class OptionAbstract {
11
17
  */
12
18
  this.id = id;
13
19
 
14
- /**
15
- *
16
- * @type {OptionGroup|null}
17
- */
18
- this.parent = null;
19
20
  }
20
21
 
21
22
  /**
@@ -8,20 +8,12 @@ function isOption(c) {
8
8
  }
9
9
 
10
10
  export class OptionGroup extends OptionAbstract {
11
+
11
12
  /**
12
13
  *
13
- * @param {string} id
14
- * @constructor
14
+ * @type {Array<OptionGroup|Option>}
15
15
  */
16
- constructor(id) {
17
- super(id);
18
-
19
- /**
20
- *
21
- * @type {Array<OptionGroup|Option>}
22
- */
23
- this.children = [];
24
- }
16
+ children = [];
25
17
 
26
18
  /**
27
19
  *
@@ -141,6 +133,7 @@ export class OptionGroup extends OptionAbstract {
141
133
  *
142
134
  * @param {string} path
143
135
  * @param {Storage} storage
136
+ * @returns {Promise}
144
137
  */
145
138
  attachToStorage(path, storage) {
146
139
  const group = this;
@@ -151,20 +144,6 @@ export class OptionGroup extends OptionAbstract {
151
144
  storage.load(key, resolve, reject);
152
145
  });
153
146
 
154
- p
155
- .then((loaded) => {
156
- try {
157
- group.fromJSON(JSON.parse(loaded));
158
- } catch (e) {
159
- console.log('Failed to load options')
160
- }
161
- })
162
- .catch(console.error)
163
- .finally(() => {
164
-
165
- group.traverseOptions(op => op.on.written.add(store));
166
- });
167
-
168
147
 
169
148
  function store() {
170
149
  const json = group.toJSON();
@@ -174,6 +153,15 @@ export class OptionGroup extends OptionAbstract {
174
153
  storage.store(key, value, noop, console.error, noop);
175
154
  }
176
155
 
156
+ return p
157
+ .then((loaded) => {
158
+ group.fromJSON(JSON.parse(loaded));
159
+ })
160
+ .finally(() => {
161
+
162
+ group.traverseOptions(op => op.on.written.add(store));
163
+ });
164
+
177
165
  }
178
166
  }
179
167
 
@@ -0,0 +1,61 @@
1
+ import { OptionGroup } from "./OptionGroup.js";
2
+ import { noop } from "../../core/function/Functions.js";
3
+ import { InMemoryStorage } from "../save/storage/InMemoryStorage.js";
4
+
5
+ test("constructor", () => {
6
+ const group = new OptionGroup("x");
7
+
8
+ expect(group.id).toEqual("x");
9
+ });
10
+
11
+ test("resolve non-existent", () => {
12
+
13
+ const group = new OptionGroup("x");
14
+
15
+ expect(() => group.resolve(['a'])).toThrow();
16
+
17
+ });
18
+
19
+ test("add/get", () => {
20
+ const group = new OptionGroup("x");
21
+
22
+ group.add("a", noop, noop, {});
23
+
24
+ expect(group.getChildById('a')).toBeDefined();
25
+ });
26
+
27
+ test("to/from JSON", () => {
28
+ const group = new OptionGroup("x");
29
+
30
+ const writer = jest.fn();
31
+
32
+ group.add("a", () => 7, writer, {});
33
+
34
+ const json = group.toJSON();
35
+
36
+ expect(json).toEqual({ a: 7 });
37
+
38
+ group.fromJSON({ a: 13 });
39
+
40
+ expect(writer).toHaveBeenCalledTimes(1);
41
+ expect(writer).toHaveBeenCalledWith(13);
42
+ });
43
+
44
+
45
+ test("attach to storage", async () => {
46
+ const group = new OptionGroup("x");
47
+
48
+ const op_a = {
49
+ value: 3
50
+ };
51
+
52
+ group.add('a', () => op_a.value, v => op_a.value = v, {});
53
+
54
+ const storage = new InMemoryStorage();
55
+
56
+ storage.store('options', JSON.stringify({ a: 13 }));
57
+
58
+ await group.attachToStorage('options', storage);
59
+
60
+ expect(op_a.value).toEqual(13);
61
+ });
@@ -1,10 +1,11 @@
1
1
  import Storage from "../Storage.js";
2
2
  import { collectIteratorValueToArray } from "../../../core/collection/collectIteratorValueToArray.js";
3
+ import { noop } from "../../../core/function/Functions.js";
3
4
 
4
5
  export class InMemoryStorage extends Storage {
5
6
  #data = new Map();
6
7
 
7
- store(key, value, resolve, reject, progress) {
8
+ store(key, value, resolve=noop, reject, progress) {
8
9
  this.#data.set(key, value);
9
10
 
10
11
  resolve();
@@ -14,7 +15,7 @@ export class InMemoryStorage extends Storage {
14
15
  resolve(this.#data.get(key));
15
16
  }
16
17
 
17
- remove(key, resolve, reject) {
18
+ remove(key, resolve=noop, reject) {
18
19
  this.#data.delete(key);
19
20
 
20
21
  resolve();
@@ -6,32 +6,29 @@ import { SignalHandler } from "../../core/events/signal/SignalHandler.js";
6
6
  import { assert } from "../../core/assert.js";
7
7
 
8
8
  class Ticker {
9
+ /**
10
+ * @readonly
11
+ * @type {Clock}
12
+ */
13
+ clock = new Clock();
14
+ /**
15
+ * @private
16
+ * @type {boolean}
17
+ */
18
+ isRunning = false;
19
+
20
+ /**
21
+ *
22
+ * @type {SignalHandler[]}
23
+ */
24
+ callbacks = [];
25
+
9
26
  /**
10
27
  *
11
28
  * @constructor
12
29
  */
13
30
  constructor() {
14
-
15
- /**
16
- * @readonly
17
- * @type {Clock}
18
- */
19
- this.clock = new Clock();
20
-
21
-
22
31
  this.clock.pause();
23
-
24
- /**
25
- * @private
26
- * @type {boolean}
27
- */
28
- this.isRunning = false;
29
-
30
- /**
31
- *
32
- * @type {SignalHandler[]}
33
- */
34
- this.callbacks = [];
35
32
  }
36
33
 
37
34
  /**
@@ -146,12 +146,8 @@ export default SoundController;
146
146
 
147
147
 
148
148
  export class SoundControllerSerializationAdapter extends BinaryClassSerializationAdapter {
149
- constructor() {
150
- super();
151
-
152
- this.klass = SoundController;
153
- this.version = 0;
154
- }
149
+ klass = SoundController;
150
+ version = 0;
155
151
 
156
152
  /**
157
153
  *
@@ -42,26 +42,8 @@ export default SoundListener;
42
42
 
43
43
 
44
44
  export class SoundListenerSerializationAdapter extends BinaryClassSerializationAdapter {
45
- constructor() {
46
- super();
45
+ klass = SoundListener;
46
+ version = 0;
47
47
 
48
- this.klass = SoundListener;
49
- this.version = 0;
50
- }
51
-
52
- /**
53
- *
54
- * @param {BinaryBuffer} buffer
55
- * @param {SoundListener} value
56
- */
57
- serialize(buffer, value) {
58
- }
59
-
60
- /**
61
- *
62
- * @param {BinaryBuffer} buffer
63
- * @param {SoundListener} value
64
- */
65
- deserialize(buffer, value) {
66
- }
48
+ // NO-OP
67
49
  }
@@ -3,13 +3,9 @@ import { SoundEmitter } from "./SoundEmitter.js";
3
3
  import { SoundTrack } from "./SoundTrack.js";
4
4
 
5
5
  export class SoundEmitterSerializationAdapter extends BinaryClassSerializationAdapter {
6
- constructor() {
7
- super();
8
-
9
- this.klass = SoundEmitter;
10
- this.version = 2;
11
- }
12
6
 
7
+ klass = SoundEmitter;
8
+ version = 2;
13
9
 
14
10
  /**
15
11
  *
@@ -2,16 +2,12 @@ import TaskGroup from "../core/process/task/TaskGroup.js";
2
2
  import { GridTaskGenerator } from "./grid/GridTaskGenerator.js";
3
3
 
4
4
  export class GridTaskGroup extends GridTaskGenerator {
5
- constructor() {
6
- super();
7
5
 
8
- /**
9
- *
10
- * @type {GridTaskGenerator[]}
11
- */
12
- this.children = [];
13
-
14
- }
6
+ /**
7
+ *
8
+ * @type {GridTaskGenerator[]}
9
+ */
10
+ children = [];
15
11
 
16
12
 
17
13
  /**