@woosh/meep-engine 2.165.5 → 2.165.7

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 (936) hide show
  1. package/editor/tools/v2/GizmoNode.d.ts +21 -0
  2. package/editor/tools/v2/GizmoNode.d.ts.map +1 -0
  3. package/editor/tools/v2/TransformControls.d.ts +87 -20
  4. package/editor/tools/v2/TransformControls.d.ts.map +1 -0
  5. package/editor/tools/v2/TransformControlsGizmo.d.ts +22 -0
  6. package/editor/tools/v2/TransformControlsGizmo.d.ts.map +1 -0
  7. package/editor/tools/v2/TransformControlsPlane.d.ts +6 -0
  8. package/editor/tools/v2/TransformControlsPlane.d.ts.map +1 -0
  9. package/editor/tools/v2/TranslateHelperGeometry.d.ts +6 -0
  10. package/editor/tools/v2/TranslateHelperGeometry.d.ts.map +1 -0
  11. package/package.json +1 -1
  12. package/src/core/binary/data_view/DataType2DataViewReaders.d.ts +8 -12
  13. package/src/core/binary/data_view/DataType2DataViewReaders.d.ts.map +1 -1
  14. package/src/core/binary/data_view/DataType2DataViewWriters.d.ts +8 -12
  15. package/src/core/binary/data_view/DataType2DataViewWriters.d.ts.map +1 -1
  16. package/src/core/binary/data_view/DataViewStructAccessor.d.ts +39 -18
  17. package/src/core/binary/type/BinaryDataType.d.ts +15 -15
  18. package/src/core/binary/type/DataType2TypedArrayConstructorMapping.d.ts +7 -11
  19. package/src/core/binary/type/DataType2TypedArrayConstructorMapping.d.ts.map +1 -1
  20. package/src/core/binary/type/DataTypeByteSizes.d.ts +7 -13
  21. package/src/core/binary/type/DataTypeByteSizes.d.ts.map +1 -1
  22. package/src/core/binary/type/DataTypeIndices.d.ts +8 -11
  23. package/src/core/binary/type/DataTypeIndices.d.ts.map +1 -1
  24. package/src/core/cache/Cache.d.ts +226 -56
  25. package/src/core/cache/Cache.d.ts.map +1 -1
  26. package/src/core/cache/LoadingCache.d.ts +72 -23
  27. package/src/core/collection/Stack.d.ts +2 -2
  28. package/src/core/collection/array/array_copy.d.ts +12 -7
  29. package/src/core/collection/array/computeHashArray.d.ts +9 -1
  30. package/src/core/collection/array/isArrayEqualStrict.d.ts +8 -1
  31. package/src/core/collection/array/isArraysEqualWithComparator.d.ts +10 -1
  32. package/src/core/collection/array/iterator/ArrayIteratorRandom.d.ts +3 -1
  33. package/src/core/collection/array/iterator/ArrayIteratorRandom.d.ts.map +1 -1
  34. package/src/core/collection/list/List.d.ts +334 -45
  35. package/src/core/collection/list/List.d.ts.map +1 -1
  36. package/src/core/collection/list/ListForwarder.d.ts +37 -18
  37. package/src/core/collection/map/HashMap.d.ts +199 -40
  38. package/src/core/collection/queue/Deque.d.ts +113 -37
  39. package/src/core/collection/set/ArraySet.d.ts +87 -26
  40. package/src/core/collection/set/HashSet.d.ts +66 -33
  41. package/src/core/collection/set/HashSet.d.ts.map +1 -1
  42. package/src/core/collection/table/bind/TableRecord.d.ts +21 -20
  43. package/src/core/color/Color.d.ts +1 -2
  44. package/src/core/color/Color.d.ts.map +1 -1
  45. package/src/core/events/signal/Signal.d.ts +210 -57
  46. package/src/core/events/signal/signal_filter.d.ts +1 -1
  47. package/src/core/fsm/simple/SimpleStateMachine.d.ts +83 -27
  48. package/src/core/fsm/simple/SimpleStateMachineDescription.d.ts +90 -21
  49. package/src/core/geom/2d/aabb/AABB2.d.ts +335 -51
  50. package/src/core/geom/2d/quad-tree/QuadTreeDatum.d.ts +1 -6
  51. package/src/core/geom/2d/quad-tree/QuadTreeDatum.d.ts.map +1 -1
  52. package/src/core/geom/2d/quad-tree/QuadTreeNode.d.ts +1 -2
  53. package/src/core/geom/2d/quad-tree/QuadTreeNode.d.ts.map +1 -1
  54. package/src/core/geom/3d/SurfacePoint3.d.ts +62 -17
  55. package/src/core/geom/3d/aabb/aabb3_build_corners.d.ts +13 -1
  56. package/src/core/geom/3d/frustum/read_three_planes_to_array.d.ts +7 -3
  57. package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.d.ts +7 -6
  58. package/src/core/geom/3d/sphere/harmonics/sh3_sample_by_direction.d.ts +16 -6
  59. package/src/core/geom/Quaternion.d.ts +1 -2
  60. package/src/core/geom/Quaternion.d.ts.map +1 -1
  61. package/src/core/geom/Vector1.d.ts +1 -2
  62. package/src/core/geom/Vector1.d.ts.map +1 -1
  63. package/src/core/geom/Vector2.d.ts +1 -2
  64. package/src/core/geom/Vector2.d.ts.map +1 -1
  65. package/src/core/geom/Vector3.d.ts +1 -2
  66. package/src/core/geom/Vector3.d.ts.map +1 -1
  67. package/src/core/geom/Vector4.d.ts +1 -1
  68. package/src/core/geom/Vector4.d.ts.map +1 -1
  69. package/src/core/graph/v2/Graph.d.ts +4 -4
  70. package/src/core/graph/v2/Graph.d.ts.map +1 -1
  71. package/src/core/json/resolvePathByArray.d.ts +10 -1
  72. package/src/core/math/clamp.d.ts +9 -1
  73. package/src/core/math/epsilonEquals.d.ts +9 -1
  74. package/src/core/math/interval/NumericInterval.d.ts +1 -2
  75. package/src/core/math/interval/NumericInterval.d.ts.map +1 -1
  76. package/src/core/math/noise/create_simplex_noise_2d.d.ts +7 -1
  77. package/src/core/math/random/seededRandom.d.ts +3 -1
  78. package/src/core/math/remap.d.ts +12 -5
  79. package/src/core/math/sign.d.ts +10 -1
  80. package/src/core/model/BooleanVector3.d.ts +77 -28
  81. package/src/core/model/BooleanVector3.d.ts.map +1 -1
  82. package/src/core/model/BoundedValue.d.ts +5 -5
  83. package/src/core/model/BoundedValue.d.ts.map +1 -1
  84. package/src/core/model/ModuleRegistry.d.ts +45 -3
  85. package/src/core/model/ObservedBoolean.d.ts +1 -2
  86. package/src/core/model/ObservedBoolean.d.ts.map +1 -1
  87. package/src/core/model/ObservedEnum.d.ts +91 -7
  88. package/src/core/model/ObservedEnum.d.ts.map +1 -1
  89. package/src/core/model/ObservedString.d.ts +1 -2
  90. package/src/core/model/ObservedString.d.ts.map +1 -1
  91. package/src/core/model/ObservedValue.d.ts +1 -1
  92. package/src/core/model/ObservedValue.d.ts.map +1 -1
  93. package/src/core/model/node-graph/Connection.d.ts +57 -12
  94. package/src/core/model/node-graph/NodeGraph.d.ts +2 -2
  95. package/src/core/model/node-graph/node/NodeDescription.d.ts +166 -15
  96. package/src/core/model/node-graph/node/NodeDescription.d.ts.map +1 -1
  97. package/src/core/model/node-graph/node/NodeInstance.d.ts +181 -22
  98. package/src/core/model/node-graph/node/NodeInstance.d.ts.map +1 -1
  99. package/src/core/model/node-graph/node/NodeInstancePortReference.d.ts +82 -3
  100. package/src/core/model/node-graph/node/Port.d.ts +72 -3
  101. package/src/core/model/node-graph/node/Port.d.ts.map +1 -1
  102. package/src/core/model/node-graph/node/PortDirection.d.ts +7 -5
  103. package/src/core/model/node-graph/type/DataType.d.ts +61 -4
  104. package/src/core/model/node-graph/type/ParametricDataType.d.ts +0 -1
  105. package/src/core/model/node-graph/type/ParametricDataType.d.ts.map +1 -1
  106. package/src/core/model/object/ImmutableObjectPool.d.ts +1 -2
  107. package/src/core/model/object/ImmutableObjectPool.d.ts.map +1 -1
  108. package/src/core/model/object/invokeObjectEquals.d.ts +9 -5
  109. package/src/core/model/object/invokeObjectHash.d.ts +7 -5
  110. package/src/core/model/object/objectDeepEquals.d.ts +10 -1
  111. package/src/core/model/object/objectKeyByValue.d.ts +10 -1
  112. package/src/core/model/object/read_property.d.ts +11 -1
  113. package/src/core/model/object/write_property.d.ts +10 -1
  114. package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.d.ts +6 -0
  115. package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.d.ts.map +1 -1
  116. package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.js +12 -12
  117. package/src/core/model/reactive/js/compileReactiveToJS.d.ts.map +1 -1
  118. package/src/core/model/reactive/js/compileReactiveToJS.js +35 -1
  119. package/src/core/model/reactive/model/ReactiveBinaryExpression.d.ts +1 -3
  120. package/src/core/model/reactive/model/ReactiveBinaryExpression.d.ts.map +1 -1
  121. package/src/core/model/reactive/model/ReactiveExpression.d.ts +63 -10
  122. package/src/core/model/reactive/model/ReactiveExpression.d.ts.map +1 -1
  123. package/src/core/model/reactive/model/ReactiveUnaryExpression.d.ts +0 -12
  124. package/src/core/model/reactive/model/ReactiveUnaryExpression.d.ts.map +1 -1
  125. package/src/core/model/reactive/model/arithmetic/ReactiveAdd.d.ts +1 -1
  126. package/src/core/model/reactive/model/arithmetic/ReactiveAdd.d.ts.map +1 -1
  127. package/src/core/model/reactive/model/arithmetic/ReactiveDivide.d.ts +1 -1
  128. package/src/core/model/reactive/model/arithmetic/ReactiveDivide.d.ts.map +1 -1
  129. package/src/core/model/reactive/model/arithmetic/ReactiveMultiply.d.ts +1 -1
  130. package/src/core/model/reactive/model/arithmetic/ReactiveMultiply.d.ts.map +1 -1
  131. package/src/core/model/reactive/model/arithmetic/ReactiveNegate.d.ts +1 -1
  132. package/src/core/model/reactive/model/arithmetic/ReactiveNegate.d.ts.map +1 -1
  133. package/src/core/model/reactive/model/arithmetic/ReactiveSubtract.d.ts +1 -1
  134. package/src/core/model/reactive/model/arithmetic/ReactiveSubtract.d.ts.map +1 -1
  135. package/src/core/model/reactive/model/comparative/ReactiveEquals.d.ts +1 -1
  136. package/src/core/model/reactive/model/comparative/ReactiveEquals.d.ts.map +1 -1
  137. package/src/core/model/reactive/model/comparative/ReactiveGreaterThan.d.ts +1 -1
  138. package/src/core/model/reactive/model/comparative/ReactiveGreaterThan.d.ts.map +1 -1
  139. package/src/core/model/reactive/model/comparative/ReactiveGreaterThanOrEqual.d.ts +1 -1
  140. package/src/core/model/reactive/model/comparative/ReactiveGreaterThanOrEqual.d.ts.map +1 -1
  141. package/src/core/model/reactive/model/comparative/ReactiveLessThan.d.ts +1 -1
  142. package/src/core/model/reactive/model/comparative/ReactiveLessThan.d.ts.map +1 -1
  143. package/src/core/model/reactive/model/comparative/ReactiveLessThanOrEqual.d.ts +1 -1
  144. package/src/core/model/reactive/model/comparative/ReactiveLessThanOrEqual.d.ts.map +1 -1
  145. package/src/core/model/reactive/model/comparative/ReactiveNotEquals.d.ts +1 -1
  146. package/src/core/model/reactive/model/comparative/ReactiveNotEquals.d.ts.map +1 -1
  147. package/src/core/model/reactive/model/logic/ReactiveAnd.d.ts +41 -5
  148. package/src/core/model/reactive/model/logic/ReactiveAnd.d.ts.map +1 -1
  149. package/src/core/model/reactive/model/logic/ReactiveNot.d.ts +1 -1
  150. package/src/core/model/reactive/model/logic/ReactiveNot.d.ts.map +1 -1
  151. package/src/core/model/reactive/model/logic/ReactiveOr.d.ts +2 -1
  152. package/src/core/model/reactive/model/logic/ReactiveOr.d.ts.map +1 -1
  153. package/src/core/model/reactive/model/terminal/ReactiveLiteralBoolean.d.ts +2 -1
  154. package/src/core/model/reactive/model/terminal/ReactiveLiteralBoolean.d.ts.map +1 -1
  155. package/src/core/model/reactive/model/terminal/ReactiveLiteralNumber.d.ts +2 -3
  156. package/src/core/model/reactive/model/terminal/ReactiveLiteralNumber.d.ts.map +1 -1
  157. package/src/core/model/reactive/model/terminal/ReactiveLiteralString.d.ts +2 -4
  158. package/src/core/model/reactive/model/terminal/ReactiveLiteralString.d.ts.map +1 -1
  159. package/src/core/model/reactive/model/terminal/ReactiveReference.d.ts +68 -11
  160. package/src/core/model/reactive/model/terminal/ReactiveReference.d.ts.map +1 -1
  161. package/src/core/model/stat/LinearModifier.d.ts +79 -24
  162. package/src/core/parser/simple/DataType.d.ts +13 -5
  163. package/src/core/parser/simple/Token.d.ts +52 -13
  164. package/src/core/parser/simple/readArrayLiteral.d.ts +1 -0
  165. package/src/core/parser/simple/readArrayLiteral.d.ts.map +1 -1
  166. package/src/core/parser/simple/readBooleanToken.d.ts +1 -0
  167. package/src/core/parser/simple/readBooleanToken.d.ts.map +1 -1
  168. package/src/core/parser/simple/readHexToken.d.ts +1 -0
  169. package/src/core/parser/simple/readHexToken.d.ts.map +1 -1
  170. package/src/core/parser/simple/readIdentifierToken.d.ts +1 -0
  171. package/src/core/parser/simple/readIdentifierToken.d.ts.map +1 -1
  172. package/src/core/parser/simple/readNumberToken.d.ts +1 -0
  173. package/src/core/parser/simple/readNumberToken.d.ts.map +1 -1
  174. package/src/core/parser/simple/readReferenceToken.d.ts +1 -0
  175. package/src/core/parser/simple/readReferenceToken.d.ts.map +1 -1
  176. package/src/core/parser/simple/readStringToken.d.ts +1 -0
  177. package/src/core/parser/simple/readStringToken.d.ts.map +1 -1
  178. package/src/core/parser/simple/readUnsignedIntegerToken.d.ts +1 -0
  179. package/src/core/parser/simple/readUnsignedIntegerToken.d.ts.map +1 -1
  180. package/src/core/process/BaseProcess.d.ts +17 -5
  181. package/src/core/process/BaseProcess.d.ts.map +1 -1
  182. package/src/core/process/CompositeProcess.d.ts +0 -1
  183. package/src/core/process/CompositeProcess.d.ts.map +1 -1
  184. package/src/core/process/action/AsynchronousAction.d.ts +3 -3
  185. package/src/core/process/executor/ConcurrentExecutor.d.ts +3 -3
  186. package/src/core/process/filter/MutableFilter.d.ts +1 -1
  187. package/src/core/process/filter/MutableFilter.d.ts.map +1 -1
  188. package/src/core/process/task/Task.d.ts +1 -1
  189. package/src/core/process/task/Task.d.ts.map +1 -1
  190. package/src/core/process/task/TaskGroup.d.ts +3 -3
  191. package/src/core/process/task/TaskSignal.d.ts +8 -6
  192. package/src/core/process/undo/Action.d.ts +31 -9
  193. package/src/core/process/undo/ActionGroup.d.ts +20 -5
  194. package/src/core/process/undo/ActionProcessor.d.ts +163 -27
  195. package/src/core/process/undo/ActionProcessor.d.ts.map +1 -1
  196. package/src/engine/Engine.d.ts +178 -42
  197. package/src/engine/Engine.d.ts.map +1 -1
  198. package/src/engine/EngineConfiguration.d.ts +74 -20
  199. package/src/engine/achievements/AchievementGateway.d.ts +17 -5
  200. package/src/engine/achievements/AchievementManager.d.ts +0 -1
  201. package/src/engine/achievements/AchievementManager.d.ts.map +1 -1
  202. package/src/engine/animation/Tween.d.ts +1 -1
  203. package/src/engine/animation/clip/AnimationClip.d.ts +24 -4
  204. package/src/engine/animation/clip/AnimationClipBinding.d.ts +35 -14
  205. package/src/engine/animation/curve/actionProcessorOperations/curveActions.d.ts +2 -2
  206. package/src/engine/animation/curve/actionProcessorOperations/curveActions.d.ts.map +1 -1
  207. package/src/engine/animation/curve/editor/createKeyframeMarker.d.ts +1 -1
  208. package/src/engine/animation/curve/editor/createKeyframeMarker.d.ts.map +1 -1
  209. package/src/engine/animation/keyed2/AnimationTrackPlayback.d.ts +1 -1
  210. package/src/engine/animation/keyed2/behavior/AnimationBehavior.d.ts +0 -1
  211. package/src/engine/animation/keyed2/behavior/AnimationBehavior.d.ts.map +1 -1
  212. package/src/engine/asset/Asset.d.ts +47 -7
  213. package/src/engine/asset/AssetManager.d.ts +258 -60
  214. package/src/engine/asset/AssetRequestScope.d.ts +27 -3
  215. package/src/engine/asset/AssetTransformer.d.ts +16 -5
  216. package/src/engine/asset/CORS/CrossOriginConfig.d.ts +8 -5
  217. package/src/engine/asset/CORS/CrossOriginConfig.d.ts.map +1 -1
  218. package/src/engine/asset/CORS/CrossOriginKind.d.ts +5 -4
  219. package/src/engine/asset/loaders/AssetLoader.d.ts +50 -12
  220. package/src/engine/asset/loaders/GLTFAssetLoader.d.ts +71 -6
  221. package/src/engine/asset/loaders/image/ImageRGBADataAsset.d.ts +0 -1
  222. package/src/engine/asset/loaders/image/ImageRGBADataAsset.d.ts.map +1 -1
  223. package/src/engine/asset/loaders/material/StaticMaterialCache.d.ts +30 -7
  224. package/src/engine/asset/loaders/material/computeMaterialEquality.d.ts +8 -3
  225. package/src/engine/asset/loaders/material/computeMaterialHash.d.ts +7 -3
  226. package/src/engine/asset/loaders/material/traverseMaterialTextures.d.ts +8 -3
  227. package/src/engine/asset/loaders/texture/TextureAssetLoader.d.ts +6 -6
  228. package/src/engine/asset/preloader/AssetPreloader.d.ts +6 -15
  229. package/src/engine/asset/preloader/AssetPreloader.d.ts.map +1 -1
  230. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +13 -13
  231. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
  232. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +14 -4
  233. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
  234. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts +1 -1
  235. package/src/engine/ecs/Entity.d.ts +228 -41
  236. package/src/engine/ecs/EntityBlueprint.d.ts +43 -17
  237. package/src/engine/ecs/EntityComponentDataset.d.ts +580 -60
  238. package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
  239. package/src/engine/ecs/EntityManager.d.ts +10 -9
  240. package/src/engine/ecs/EntityManager.d.ts.map +1 -1
  241. package/src/engine/ecs/EntityObserver.d.ts +80 -13
  242. package/src/engine/ecs/System.d.ts +162 -33
  243. package/src/engine/ecs/animation/AnimationSerializationAdapter.d.ts +0 -1
  244. package/src/engine/ecs/animation/AnimationSerializationAdapter.d.ts.map +1 -1
  245. package/src/engine/ecs/attachment/AttachmentSystem.d.ts +1 -1
  246. package/src/engine/ecs/attachment/AttachmentSystem.d.ts.map +1 -1
  247. package/src/engine/ecs/components/PropertySetSerializationAdapter.d.ts +0 -1
  248. package/src/engine/ecs/components/PropertySetSerializationAdapter.d.ts.map +1 -1
  249. package/src/engine/ecs/components/SerializationMetadataSerializationAdapter.d.ts +0 -1
  250. package/src/engine/ecs/components/SerializationMetadataSerializationAdapter.d.ts.map +1 -1
  251. package/src/engine/ecs/components/TagSerializationAdapter.d.ts +0 -1
  252. package/src/engine/ecs/components/TagSerializationAdapter.d.ts.map +1 -1
  253. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescriptionTable.d.ts +1 -1
  254. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescriptionTable.d.ts.map +1 -1
  255. package/src/engine/ecs/fow/FogOfWar.d.ts +1 -1
  256. package/src/engine/ecs/fow/FogOfWarRevealerSystem.d.ts +1 -1
  257. package/src/engine/ecs/fow/FogOfWarSystem.d.ts +1 -6
  258. package/src/engine/ecs/fow/FogOfWarSystem.d.ts.map +1 -1
  259. package/src/engine/ecs/fow/serialization/FogOfWarRevealerSerializationAdapter.d.ts +0 -1
  260. package/src/engine/ecs/fow/serialization/FogOfWarRevealerSerializationAdapter.d.ts.map +1 -1
  261. package/src/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.d.ts +0 -1
  262. package/src/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.d.ts.map +1 -1
  263. package/src/engine/ecs/gui/GUIElement.d.ts +115 -5
  264. package/src/engine/ecs/gui/GUIElementSerializationAdapter.d.ts +0 -1
  265. package/src/engine/ecs/gui/GUIElementSerializationAdapter.d.ts.map +1 -1
  266. package/src/engine/ecs/gui/GUIElementSystem.d.ts +59 -8
  267. package/src/engine/ecs/gui/GUIElementSystem.d.ts.map +1 -1
  268. package/src/engine/ecs/gui/hud/HeadsUpDisplaySerializationAdapter.d.ts +0 -1
  269. package/src/engine/ecs/gui/hud/HeadsUpDisplaySerializationAdapter.d.ts.map +1 -1
  270. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.d.ts +42 -6
  271. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.d.ts.map +1 -1
  272. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +65 -12
  273. package/src/engine/ecs/gui/hud/testHudEdgeStick.d.ts +2 -0
  274. package/src/engine/ecs/gui/hud/testHudEdgeStick.d.ts.map +1 -0
  275. package/src/engine/ecs/gui/hud/testHudEdgeStick.js +134 -0
  276. package/src/engine/ecs/gui/menu/radial/RadialContextMenu.d.ts +23 -22
  277. package/src/engine/ecs/gui/parallax/GuiElementParallaxSystem.d.ts +1 -1
  278. package/src/engine/ecs/gui/position/ViewportPositionSerializationAdapter.d.ts +0 -1
  279. package/src/engine/ecs/gui/position/ViewportPositionSerializationAdapter.d.ts.map +1 -1
  280. package/src/engine/ecs/gui/position/ViewportPositionSystem.d.ts +1 -1
  281. package/src/engine/ecs/gui/position/ViewportPositionSystem.d.ts.map +1 -1
  282. package/src/engine/ecs/gui/position/ViewportPositionSystem.js +44 -23
  283. package/src/engine/ecs/gui/view/ViewEntity.d.ts +1 -2
  284. package/src/engine/ecs/gui/view/ViewEntity.d.ts.map +1 -1
  285. package/src/engine/ecs/guid/UUIDSerializationAdapter.d.ts +0 -1
  286. package/src/engine/ecs/guid/UUIDSerializationAdapter.d.ts.map +1 -1
  287. package/src/engine/ecs/ik/InverseKinematicsSerializationAdapter.d.ts +0 -1
  288. package/src/engine/ecs/ik/InverseKinematicsSerializationAdapter.d.ts.map +1 -1
  289. package/src/engine/ecs/ik/InverseKinematicsSystem.d.ts +1 -1
  290. package/src/engine/ecs/ik/InverseKinematicsSystem.d.ts.map +1 -1
  291. package/src/engine/ecs/name/NameSerializationAdapter.d.ts +0 -1
  292. package/src/engine/ecs/name/NameSerializationAdapter.d.ts.map +1 -1
  293. package/src/engine/ecs/parent/ChildEntities.d.ts +23 -3
  294. package/src/engine/ecs/parent/EntityNode.d.ts +157 -25
  295. package/src/engine/ecs/parent/ParentEntity.d.ts +31 -11
  296. package/src/engine/ecs/parent/ParentEntitySystem.d.ts +44 -11
  297. package/src/engine/ecs/renderable/RenderSystem.d.ts +65 -7
  298. package/src/engine/ecs/renderable/Renderable.d.ts +95 -25
  299. package/src/engine/ecs/speaker/VoiceSystem.d.ts +3 -3
  300. package/src/engine/ecs/speaker/VoiceSystem.d.ts.map +1 -1
  301. package/src/engine/ecs/storage/binary/BinaryClassSerializationAdapter.d.ts +86 -21
  302. package/src/engine/ecs/storage/binary/object-v2/serializerTestHarness.d.ts +1 -1
  303. package/src/engine/ecs/storage/binary/object-v2/serializerTestHarness.d.ts.map +1 -1
  304. package/src/engine/ecs/system/AbstractContextSystem.d.ts +1 -1
  305. package/src/engine/ecs/system_validate_class.d.ts +1 -1
  306. package/src/engine/ecs/system_validate_class.d.ts.map +1 -1
  307. package/src/engine/ecs/systems/AnimationSystem.d.ts +41 -6
  308. package/src/engine/ecs/systems/AnimationSystem.d.ts.map +1 -1
  309. package/src/engine/ecs/systems/ScriptSystem.d.ts +9 -5
  310. package/src/engine/ecs/systems/ScriptSystem.d.ts.map +1 -1
  311. package/src/engine/ecs/systems/TimerSystem.d.ts +1 -1
  312. package/src/engine/ecs/systems/TimerSystem.d.ts.map +1 -1
  313. package/src/engine/ecs/team/TeamSerializationAdapter.d.ts +0 -1
  314. package/src/engine/ecs/team/TeamSerializationAdapter.d.ts.map +1 -1
  315. package/src/engine/ecs/terrain/ecs/OffsetScaleTransform2D.d.ts +7 -6
  316. package/src/engine/ecs/terrain/ecs/Terrain.d.ts +389 -17
  317. package/src/engine/ecs/terrain/ecs/TerrainSystem.d.ts +65 -8
  318. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationAdapter.d.ts +0 -1
  319. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationAdapter.d.ts.map +1 -1
  320. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.d.ts +1 -1
  321. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.d.ts.map +1 -1
  322. package/src/engine/ecs/terrain/serialization/TerrainSerializationAdapter.d.ts +0 -1
  323. package/src/engine/ecs/terrain/serialization/TerrainSerializationAdapter.d.ts.map +1 -1
  324. package/src/engine/ecs/terrain/tiles/TerrainTile.d.ts +2 -2
  325. package/src/engine/ecs/terrain/tiles/TerrainTile.d.ts.map +1 -1
  326. package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts +2 -2
  327. package/src/engine/ecs/tooltip/TooltipComponentSerializationAdapter.d.ts +0 -1
  328. package/src/engine/ecs/tooltip/TooltipComponentSerializationAdapter.d.ts.map +1 -1
  329. package/src/engine/ecs/tooltip/TooltipComponentSystem.d.ts +1 -1
  330. package/src/engine/ecs/transform/TransformSerializationAdapter.d.ts +0 -1
  331. package/src/engine/ecs/transform/TransformSerializationAdapter.d.ts.map +1 -1
  332. package/src/engine/ecs/transform-attachment/TransformAttachment.d.ts +116 -19
  333. package/src/engine/ecs/transform-attachment/TransformAttachmentSystem.d.ts +58 -6
  334. package/src/engine/graphics/GraphicsEngine.d.ts +220 -41
  335. package/src/engine/graphics/camera/CameraShake.d.ts +6 -6
  336. package/src/engine/graphics/camera/CameraShake.d.ts.map +1 -1
  337. package/src/engine/graphics/camera/CameraShakeBehavior.d.ts +1 -2
  338. package/src/engine/graphics/camera/CameraShakeBehavior.d.ts.map +1 -1
  339. package/src/engine/graphics/camera/CameraShakeTraumaBehavior.d.ts +1 -2
  340. package/src/engine/graphics/camera/CameraShakeTraumaBehavior.d.ts.map +1 -1
  341. package/src/engine/graphics/camera/camera_compute_distance_to_fit_length.d.ts +8 -1
  342. package/src/engine/graphics/camera/makeScreenScissorFrustum.d.ts +8 -4
  343. package/src/engine/graphics/composit/CompositLayer.d.ts +1 -1
  344. package/src/engine/graphics/ecs/animation/AnimationControllerSerializationAdapter.d.ts +0 -1
  345. package/src/engine/graphics/ecs/animation/AnimationControllerSerializationAdapter.d.ts.map +1 -1
  346. package/src/engine/graphics/ecs/animation/AnimationControllerSystem.d.ts +1 -2
  347. package/src/engine/graphics/ecs/animation/AnimationControllerSystem.d.ts.map +1 -1
  348. package/src/engine/graphics/ecs/animation/animator/AnimationGraphSystem.d.ts +1 -1
  349. package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraphSerializationAdapter.d.ts +0 -1
  350. package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraphSerializationAdapter.d.ts.map +1 -1
  351. package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionSerializationAdapter.d.ts +0 -1
  352. package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionSerializationAdapter.d.ts.map +1 -1
  353. package/src/engine/graphics/ecs/camera/Camera.d.ts +113 -18
  354. package/src/engine/graphics/ecs/camera/Camera.d.ts.map +1 -1
  355. package/src/engine/graphics/ecs/camera/CameraSystem.d.ts +74 -10
  356. package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.d.ts +0 -1
  357. package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.d.ts.map +1 -1
  358. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.d.ts +90 -33
  359. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSerializationAdapter.d.ts +0 -1
  360. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSerializationAdapter.d.ts.map +1 -1
  361. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.d.ts +34 -5
  362. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLander.d.ts +0 -1
  363. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLander.d.ts.map +1 -1
  364. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.d.ts +1 -1
  365. package/src/engine/graphics/ecs/decal/v2/Decal.d.ts +52 -15
  366. package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.d.ts +0 -1
  367. package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.d.ts.map +1 -1
  368. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts +70 -24
  369. package/src/engine/graphics/ecs/highlight/Highlight.d.ts +61 -16
  370. package/src/engine/graphics/ecs/highlight/HighlightDefinition.d.ts +57 -19
  371. package/src/engine/graphics/ecs/highlight/HighlightSerializationAdapter.d.ts +0 -1
  372. package/src/engine/graphics/ecs/highlight/HighlightSerializationAdapter.d.ts.map +1 -1
  373. package/src/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.d.ts +0 -1
  374. package/src/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.d.ts.map +1 -1
  375. package/src/engine/graphics/ecs/highlight/system/MeshHighlightSystem.d.ts +57 -8
  376. package/src/engine/graphics/ecs/highlight/system/MeshHighlightSystem.d.ts.map +1 -1
  377. package/src/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.d.ts +62 -8
  378. package/src/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.d.ts.map +1 -1
  379. package/src/engine/graphics/ecs/highlight/system/ShadedGeometryHighlightSystem.d.ts +68 -8
  380. package/src/engine/graphics/ecs/highlight/system/ShadedGeometryHighlightSystem.d.ts.map +1 -1
  381. package/src/engine/graphics/ecs/light/Light.d.ts +79 -19
  382. package/src/engine/graphics/ecs/light/Light.d.ts.map +1 -1
  383. package/src/engine/graphics/ecs/light/LightSerializationAdapter.d.ts +0 -1
  384. package/src/engine/graphics/ecs/light/LightSerializationAdapter.d.ts.map +1 -1
  385. package/src/engine/graphics/ecs/light/LightSystem.d.ts +123 -11
  386. package/src/engine/graphics/ecs/light/LightType.d.ts +8 -6
  387. package/src/engine/graphics/ecs/mesh/Mesh.d.ts +176 -30
  388. package/src/engine/graphics/ecs/mesh/MeshEvents.d.ts +6 -12
  389. package/src/engine/graphics/ecs/mesh/MeshSystem.d.ts +99 -7
  390. package/src/engine/graphics/ecs/mesh/serialization/MeshSerializationAdapter.d.ts +0 -1
  391. package/src/engine/graphics/ecs/mesh/serialization/MeshSerializationAdapter.d.ts.map +1 -1
  392. package/src/engine/graphics/ecs/mesh-v2/DrawMode.d.ts +8 -6
  393. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +147 -32
  394. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts.map +1 -1
  395. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +37 -0
  396. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGAnimationPlayback.d.ts +6 -5
  397. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.d.ts +162 -25
  398. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationController.d.ts +40 -12
  399. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationControllerSystem.d.ts +31 -11
  400. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshEvents.d.ts +5 -12
  401. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshHighlightSystem.d.ts +36 -7
  402. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.d.ts +63 -8
  403. package/src/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.d.ts +9 -4
  404. package/src/engine/graphics/ecs/path/PathDisplay.d.ts +21 -9
  405. package/src/engine/graphics/ecs/path/PathDisplayEvents.d.ts +6 -3
  406. package/src/engine/graphics/ecs/path/PathDisplaySpec.d.ts +28 -11
  407. package/src/engine/graphics/ecs/path/PathDisplaySystem.d.ts +55 -10
  408. package/src/engine/graphics/ecs/path/PathDisplaySystem.d.ts.map +1 -1
  409. package/src/engine/graphics/ecs/path/PathDisplayType.d.ts +8 -6
  410. package/src/engine/graphics/ecs/path/entity/EntityPathMarkerDefinition.d.ts +39 -8
  411. package/src/engine/graphics/ecs/path/entity/EntityPathStyle.d.ts +38 -12
  412. package/src/engine/graphics/ecs/path/highlight/PathDisplayHighlightSystem.d.ts +31 -7
  413. package/src/engine/graphics/ecs/path/ribbon/RibbonPathStyle.d.ts +24 -7
  414. package/src/engine/graphics/ecs/path/tube/BasicMaterialDefinition.d.ts +4 -3
  415. package/src/engine/graphics/ecs/path/tube/CapType.d.ts +7 -5
  416. package/src/engine/graphics/ecs/path/tube/MatcapMaterialDefinition.d.ts +11 -3
  417. package/src/engine/graphics/ecs/path/tube/PathNormalType.d.ts +6 -4
  418. package/src/engine/graphics/ecs/path/tube/StandardMaterialDefinition.d.ts +9 -4
  419. package/src/engine/graphics/ecs/path/tube/TubeMaterialType.d.ts +7 -6
  420. package/src/engine/graphics/ecs/path/tube/TubePathStyle.d.ts +114 -35
  421. package/src/engine/graphics/ecs/path/tube/TubePathStyle.d.ts.map +1 -1
  422. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts +85 -6
  423. package/src/engine/graphics/ecs/trail3d/Trail3D.d.ts +24 -1
  424. package/src/engine/graphics/ecs/trail3d/Trail3D.d.ts.map +1 -1
  425. package/src/engine/graphics/ecs/trail3d/Trail3D.js +43 -0
  426. package/src/engine/graphics/ecs/trail3d/Trail3DFlags.d.ts +1 -0
  427. package/src/engine/graphics/ecs/trail3d/Trail3DFlags.js +9 -1
  428. package/src/engine/graphics/ecs/trail3d/Trail3DSystem.d.ts +1 -1
  429. package/src/engine/graphics/ecs/trail3d/Trail3DSystem.d.ts.map +1 -1
  430. package/src/engine/graphics/ecs/trail3d/Trail3DSystem.js +4 -0
  431. package/src/engine/graphics/ecs/trail3d/prototypeTrail3D.js +22 -1
  432. package/src/engine/graphics/ecs/water/WaterSerializationAdapter.d.ts +0 -1
  433. package/src/engine/graphics/ecs/water/WaterSerializationAdapter.d.ts.map +1 -1
  434. package/src/engine/graphics/ecs/water/WaterSystem.d.ts +1 -1
  435. package/src/engine/graphics/geometry/AttributeGroupSpec.d.ts +75 -25
  436. package/src/engine/graphics/geometry/AttributeSpec.d.ts +85 -12
  437. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.d.ts +1 -2
  438. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.d.ts.map +1 -1
  439. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.d.ts +6 -4
  440. package/src/engine/graphics/material/manager/MaterialManager.d.ts +12 -0
  441. package/src/engine/graphics/material/manager/MaterialManager.d.ts.map +1 -1
  442. package/src/engine/graphics/material/manager/MaterialManager.js +78 -41
  443. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.d.ts +55 -7
  444. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.d.ts.map +1 -1
  445. package/src/engine/graphics/particles/node-based/codegen/glsl/getTypeByteSize.d.ts +9 -9
  446. package/src/engine/graphics/particles/node-based/editor/ParticleSpecificationEditorView.d.ts +1 -2
  447. package/src/engine/graphics/particles/node-based/editor/ParticleSpecificationEditorView.d.ts.map +1 -1
  448. package/src/engine/graphics/particles/node-based/nodes/FloatConstant.d.ts +0 -1
  449. package/src/engine/graphics/particles/node-based/nodes/FloatConstant.d.ts.map +1 -1
  450. package/src/engine/graphics/particles/node-based/nodes/ParticleDataTypes.d.ts +10 -9
  451. package/src/engine/graphics/particles/node-based/nodes/ParticleDataTypes.d.ts.map +1 -1
  452. package/src/engine/graphics/particles/node-based/nodes/ReadFloatUniform.d.ts +0 -1
  453. package/src/engine/graphics/particles/node-based/nodes/ReadFloatUniform.d.ts.map +1 -1
  454. package/src/engine/graphics/particles/node-based/nodes/ReadVelocity.d.ts +0 -1
  455. package/src/engine/graphics/particles/node-based/nodes/ReadVelocity.d.ts.map +1 -1
  456. package/src/engine/graphics/particles/node-based/nodes/Vector3Constant.d.ts +0 -1
  457. package/src/engine/graphics/particles/node-based/nodes/Vector3Constant.d.ts.map +1 -1
  458. package/src/engine/graphics/particles/node-based/nodes/Vector3Merge.d.ts +0 -1
  459. package/src/engine/graphics/particles/node-based/nodes/Vector3Merge.d.ts.map +1 -1
  460. package/src/engine/graphics/particles/node-based/nodes/Vector3Split.d.ts +0 -1
  461. package/src/engine/graphics/particles/node-based/nodes/Vector3Split.d.ts.map +1 -1
  462. package/src/engine/graphics/particles/node-based/nodes/WriteVelocity.d.ts +0 -1
  463. package/src/engine/graphics/particles/node-based/nodes/WriteVelocity.d.ts.map +1 -1
  464. package/src/engine/graphics/particles/node-based/nodes/attribute/ReadVector3Attribute.d.ts +0 -1
  465. package/src/engine/graphics/particles/node-based/nodes/attribute/ReadVector3Attribute.d.ts.map +1 -1
  466. package/src/engine/graphics/particles/node-based/nodes/attribute/WriteVector3Attribute.d.ts +0 -1
  467. package/src/engine/graphics/particles/node-based/nodes/attribute/WriteVector3Attribute.d.ts.map +1 -1
  468. package/src/engine/graphics/particles/node-based/nodes/math/AddFloatNode.d.ts +0 -1
  469. package/src/engine/graphics/particles/node-based/nodes/math/AddFloatNode.d.ts.map +1 -1
  470. package/src/engine/graphics/particles/node-based/nodes/math/Vector3Add.d.ts +0 -1
  471. package/src/engine/graphics/particles/node-based/nodes/math/Vector3Add.d.ts.map +1 -1
  472. package/src/engine/graphics/particles/node-based/nodes/math/Vector3Divide.d.ts +0 -1
  473. package/src/engine/graphics/particles/node-based/nodes/math/Vector3Divide.d.ts.map +1 -1
  474. package/src/engine/graphics/particles/node-based/nodes/math/Vector3Multiply.d.ts +0 -1
  475. package/src/engine/graphics/particles/node-based/nodes/math/Vector3Multiply.d.ts.map +1 -1
  476. package/src/engine/graphics/particles/node-based/nodes/math/Vector3Subtract.d.ts +0 -1
  477. package/src/engine/graphics/particles/node-based/nodes/math/Vector3Subtract.d.ts.map +1 -1
  478. package/src/engine/graphics/particles/node-based/nodes/noise/CurlNoiseNode.d.ts +0 -1
  479. package/src/engine/graphics/particles/node-based/nodes/noise/CurlNoiseNode.d.ts.map +1 -1
  480. package/src/engine/graphics/particles/node-based/particle/ParticleAttributeSpecification.d.ts +18 -18
  481. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts +252 -2
  482. package/src/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.d.ts +0 -1
  483. package/src/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.d.ts.map +1 -1
  484. package/src/engine/graphics/particles/particular/engine/emitter/serde/ParticleEmitterSerializationAdapter.d.ts +0 -1
  485. package/src/engine/graphics/particles/particular/engine/emitter/serde/ParticleEmitterSerializationAdapter.d.ts.map +1 -1
  486. package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.d.ts +2 -15
  487. package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrack.d.ts +5 -1
  488. package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrack.d.ts.map +1 -1
  489. package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrackSet.d.ts +1 -1
  490. package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrackSet.d.ts.map +1 -1
  491. package/src/engine/graphics/particles/particular/engine/parameter/ParticleParameter.d.ts +5 -1
  492. package/src/engine/graphics/particles/particular/engine/parameter/ParticleParameter.d.ts.map +1 -1
  493. package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.d.ts +76 -16
  494. package/src/engine/graphics/particles/particular/engine/utils/volume/SamplingFunctionKind.d.ts +6 -4
  495. package/src/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.d.ts +92 -8
  496. package/src/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.d.ts.map +1 -1
  497. package/src/engine/graphics/render/buffer/simple-fx/ao/SAOUpscaleShader.js +78 -37
  498. package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.d.ts +0 -3
  499. package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.d.ts.map +1 -1
  500. package/src/engine/graphics/render/forward_plus/LightManager.d.ts +5 -0
  501. package/src/engine/graphics/render/forward_plus/LightManager.d.ts.map +1 -1
  502. package/src/engine/graphics/render/forward_plus/LightManager.js +11 -0
  503. package/src/engine/graphics/render/forward_plus/model/AbstractLight.d.ts +16 -1
  504. package/src/engine/graphics/render/forward_plus/model/AbstractLight.d.ts.map +1 -1
  505. package/src/engine/graphics/render/forward_plus/model/AbstractLight.js +22 -1
  506. package/src/engine/graphics/render/forward_plus/model/Decal.d.ts +8 -1
  507. package/src/engine/graphics/render/forward_plus/model/Decal.d.ts.map +1 -1
  508. package/src/engine/graphics/render/forward_plus/model/Decal.js +11 -0
  509. package/src/engine/graphics/render/forward_plus/model/PointLight.d.ts +2 -0
  510. package/src/engine/graphics/render/forward_plus/model/PointLight.d.ts.map +1 -1
  511. package/src/engine/graphics/render/forward_plus/model/PointLight.js +10 -0
  512. package/src/engine/graphics/render/forward_plus/model/SpotLight.d.ts +2 -0
  513. package/src/engine/graphics/render/forward_plus/model/SpotLight.d.ts.map +1 -1
  514. package/src/engine/graphics/render/forward_plus/model/SpotLight.js +12 -0
  515. package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.d.ts +27 -5
  516. package/src/engine/graphics/render/forward_plus/plugin/MaterialTransformer.d.ts.map +1 -1
  517. package/src/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +4 -9
  518. package/src/engine/graphics/render/forward_plus/plugin/forwardPlusMaterialMarker.d.ts +16 -0
  519. package/src/engine/graphics/render/forward_plus/plugin/forwardPlusMaterialMarker.d.ts.map +1 -0
  520. package/src/engine/graphics/render/forward_plus/plugin/forwardPlusMaterialMarker.js +18 -0
  521. package/src/engine/graphics/render/forward_plus/plugin/isForwardPlusLightingSkipped.d.ts +16 -0
  522. package/src/engine/graphics/render/forward_plus/plugin/isForwardPlusLightingSkipped.d.ts.map +1 -0
  523. package/src/engine/graphics/render/forward_plus/plugin/isForwardPlusLightingSkipped.js +31 -0
  524. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts +1 -1
  525. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts.map +1 -1
  526. package/src/engine/graphics/render/frame_graph/resource/TextureResourceDescriptor.d.ts +1 -1
  527. package/src/engine/graphics/render/gizmo/Gizmo.d.ts +7 -3
  528. package/src/engine/graphics/render/gizmo/GizmoRenderingPlugin.d.ts +5 -5
  529. package/src/engine/graphics/render/gizmo/GizmoRenderingPlugin.d.ts.map +1 -1
  530. package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.d.ts +72 -13
  531. package/src/engine/graphics/render/layers/RenderLayer.d.ts +78 -22
  532. package/src/engine/graphics/render/layers/RenderLayerManager.d.ts +72 -17
  533. package/src/engine/graphics/render/layers/RenderLayerState.d.ts +18 -3
  534. package/src/engine/graphics/render/view/CameraView.d.ts +3 -3
  535. package/src/engine/graphics/render/view/CameraViewManager.d.ts +2 -2
  536. package/src/engine/graphics/render/visibility/IncrementalDeltaSet.d.ts +143 -24
  537. package/src/engine/graphics/sh3/lpg/serialization/LightProbeGridSerializationAdapter.d.ts +0 -1
  538. package/src/engine/graphics/sh3/lpg/serialization/LightProbeGridSerializationAdapter.d.ts.map +1 -1
  539. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +3 -1
  540. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  541. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts +0 -1
  542. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -1
  543. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts +1 -2
  544. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts.map +1 -1
  545. package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts +3 -3
  546. package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts.map +1 -1
  547. package/src/engine/graphics/texture/cubemap/load_environment_map.d.ts +13 -8
  548. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts +1 -1
  549. package/src/engine/graphics/texture/sampler/serialization/Sampler2DSerializationAdapter.d.ts +0 -1
  550. package/src/engine/graphics/texture/sampler/serialization/Sampler2DSerializationAdapter.d.ts.map +1 -1
  551. package/src/engine/graphics/texture/virtual/VirtualTextureTileLoader.d.ts +1 -3
  552. package/src/engine/graphics/texture/virtual/VirtualTextureTileLoader.d.ts.map +1 -1
  553. package/src/engine/graphics/three/cloneObject3D.d.ts +7 -3
  554. package/src/engine/graphics/trail/tube/TubeMaterialX.d.ts +8 -1
  555. package/src/engine/graphics/trail/tube/TubeMaterialX.d.ts.map +1 -1
  556. package/src/engine/graphics/trail/tube/TubeMaterialX.js +111 -15
  557. package/src/engine/graphics/trail/tube/TubeXMaterialSpec.d.ts +9 -2
  558. package/src/engine/graphics/trail/tube/TubeXMaterialSpec.d.ts.map +1 -1
  559. package/src/engine/graphics/trail/tube/TubeXMaterialSpec.js +15 -4
  560. package/src/engine/graphics/trail/tube/TubeXPlugin.d.ts +0 -1
  561. package/src/engine/graphics/trail/tube/TubeXPlugin.d.ts.map +1 -1
  562. package/src/engine/graphics/trail/tube/TubeXPlugin.js +7 -1
  563. package/src/engine/graphics/trail/x/RibbonXMaterialSpec.d.ts +13 -3
  564. package/src/engine/graphics/trail/x/RibbonXPlugin.d.ts +0 -3
  565. package/src/engine/graphics/trail/x/RibbonXPlugin.d.ts.map +1 -1
  566. package/src/engine/graphics/util/promiseMaterialLoaded.d.ts +7 -3
  567. package/src/engine/grid/grid2transform/GridPosition2TransformSerializationAdapter.d.ts +0 -1
  568. package/src/engine/grid/grid2transform/GridPosition2TransformSerializationAdapter.d.ts.map +1 -1
  569. package/src/engine/grid/grid2transform/GridPosition2TransformSystem.d.ts +1 -1
  570. package/src/engine/grid/obstacle/GridObstacleSerializationAdapter.d.ts +0 -1
  571. package/src/engine/grid/obstacle/GridObstacleSerializationAdapter.d.ts.map +1 -1
  572. package/src/engine/grid/position/GridPositionSerializationAdapter.d.ts +0 -1
  573. package/src/engine/grid/position/GridPositionSerializationAdapter.d.ts.map +1 -1
  574. package/src/engine/grid/position/GridPositionSystem.d.ts +1 -1
  575. package/src/engine/grid/transform2grid/Transform2GridPositionSystem.d.ts +1 -1
  576. package/src/engine/input/GAMEPAD_API_PROPOSAL.md +717 -0
  577. package/src/engine/input/analog/apply_radial_dead_zone.d.ts +23 -0
  578. package/src/engine/input/analog/apply_radial_dead_zone.d.ts.map +1 -0
  579. package/src/engine/input/analog/apply_radial_dead_zone.js +38 -0
  580. package/src/engine/input/devices/GamepadDevice.d.ts +140 -23
  581. package/src/engine/input/devices/GamepadDevice.d.ts.map +1 -1
  582. package/src/engine/input/devices/GamepadDevice.js +202 -16
  583. package/src/engine/input/devices/InputDeviceSwitch.d.ts +44 -11
  584. package/src/engine/input/devices/InputDeviceSwitch.d.ts.map +1 -1
  585. package/src/engine/input/devices/KeyCodes.d.ts +112 -1
  586. package/src/engine/input/devices/KeyboardDevice.d.ts +2 -3
  587. package/src/engine/input/devices/KeyboardDevice.d.ts.map +1 -1
  588. package/src/engine/input/devices/PointerDevice.d.ts +96 -31
  589. package/src/engine/input/devices/PointerDevice.d.ts.map +1 -1
  590. package/src/engine/input/devices/events/KeyboardEvents.d.ts +5 -4
  591. package/src/engine/input/devices/events/MouseEvents.d.ts +18 -12
  592. package/src/engine/input/devices/events/TouchEvents.d.ts +12 -6
  593. package/src/engine/input/devices/gamepad/GamepadAxes.d.ts +5 -1
  594. package/src/engine/input/devices/gamepad/GamepadAxes.d.ts.map +1 -1
  595. package/src/engine/input/devices/gamepad/GamepadAxes.js +5 -1
  596. package/src/engine/input/devices/gamepad/GamepadHandle.d.ts +130 -26
  597. package/src/engine/input/devices/gamepad/GamepadHandle.d.ts.map +1 -1
  598. package/src/engine/input/devices/gamepad/GamepadHandle.js +60 -34
  599. package/src/engine/input/devices/gamepad/GamepadStandardMapping.d.ts +20 -0
  600. package/src/engine/input/devices/gamepad/GamepadStandardMapping.d.ts.map +1 -0
  601. package/src/engine/input/devices/gamepad/GamepadStandardMapping.js +20 -0
  602. package/src/engine/input/devices/gamepad/GamepadStick.d.ts +93 -0
  603. package/src/engine/input/devices/gamepad/GamepadStick.d.ts.map +1 -0
  604. package/src/engine/input/devices/gamepad/GamepadStick.js +165 -0
  605. package/src/engine/input/devices/gamepad/GamepadStickCalibration.d.ts +84 -0
  606. package/src/engine/input/devices/gamepad/GamepadStickCalibration.d.ts.map +1 -0
  607. package/src/engine/input/devices/gamepad/GamepadStickCalibration.js +119 -0
  608. package/src/engine/input/devices/gamepad/GamepadStickCalibrator.d.ts +92 -0
  609. package/src/engine/input/devices/gamepad/GamepadStickCalibrator.d.ts.map +1 -0
  610. package/src/engine/input/devices/gamepad/GamepadStickCalibrator.js +250 -0
  611. package/src/engine/input/devices/gamepad/gamepad_write_dpad_vector.d.ts +17 -0
  612. package/src/engine/input/devices/gamepad/gamepad_write_dpad_vector.d.ts.map +1 -0
  613. package/src/engine/input/devices/gamepad/gamepad_write_dpad_vector.js +30 -0
  614. package/src/engine/input/devices/touch/TouchDevice.d.ts +3 -3
  615. package/src/engine/input/ecs/components/Input.d.ts +49 -6
  616. package/src/engine/input/ecs/components/InputController.d.ts +33 -3
  617. package/src/engine/input/ecs/ism/InputBinding.d.ts +40 -4
  618. package/src/engine/input/ecs/systems/InputControllerSystem.d.ts +28 -6
  619. package/src/engine/input/ecs/systems/InputSystem.d.ts +59 -6
  620. package/src/engine/intelligence/behavior/Behavior.d.ts +58 -16
  621. package/src/engine/intelligence/behavior/Behavior.d.ts.map +1 -1
  622. package/src/engine/intelligence/behavior/BehaviorStatus.d.ts +10 -8
  623. package/src/engine/intelligence/behavior/SelectorBehavior.d.ts +0 -1
  624. package/src/engine/intelligence/behavior/SelectorBehavior.d.ts.map +1 -1
  625. package/src/engine/intelligence/behavior/composite/ParallelBehavior.d.ts +0 -8
  626. package/src/engine/intelligence/behavior/composite/ParallelBehavior.d.ts.map +1 -1
  627. package/src/engine/intelligence/behavior/composite/ParallelBehaviorSerializationAdapter.d.ts +0 -1
  628. package/src/engine/intelligence/behavior/composite/ParallelBehaviorSerializationAdapter.d.ts.map +1 -1
  629. package/src/engine/intelligence/behavior/composite/SequenceBehavior.d.ts +0 -1
  630. package/src/engine/intelligence/behavior/composite/SequenceBehavior.d.ts.map +1 -1
  631. package/src/engine/intelligence/behavior/composite/SequenceBehaviorSerializationAdapter.d.ts +0 -1
  632. package/src/engine/intelligence/behavior/composite/SequenceBehaviorSerializationAdapter.d.ts.map +1 -1
  633. package/src/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.d.ts +0 -1
  634. package/src/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.d.ts.map +1 -1
  635. package/src/engine/intelligence/behavior/decorator/IgnoreFailureBehavior.d.ts +1 -2
  636. package/src/engine/intelligence/behavior/decorator/IgnoreFailureBehavior.d.ts.map +1 -1
  637. package/src/engine/intelligence/behavior/decorator/InvertStatusBehavior.d.ts +1 -2
  638. package/src/engine/intelligence/behavior/decorator/InvertStatusBehavior.d.ts.map +1 -1
  639. package/src/engine/intelligence/behavior/decorator/InvertStatusBehaviorSerializationAdapter.d.ts +0 -1
  640. package/src/engine/intelligence/behavior/decorator/InvertStatusBehaviorSerializationAdapter.d.ts.map +1 -1
  641. package/src/engine/intelligence/behavior/decorator/OverrideContextBehavior.d.ts +1 -1
  642. package/src/engine/intelligence/behavior/decorator/OverrideContextBehavior.d.ts.map +1 -1
  643. package/src/engine/intelligence/behavior/decorator/RepeatBehavior.d.ts +1 -2
  644. package/src/engine/intelligence/behavior/decorator/RepeatBehavior.d.ts.map +1 -1
  645. package/src/engine/intelligence/behavior/decorator/RepeatBehaviorSerializationAdapter.d.ts +0 -1
  646. package/src/engine/intelligence/behavior/decorator/RepeatBehaviorSerializationAdapter.d.ts.map +1 -1
  647. package/src/engine/intelligence/behavior/decorator/RepeatUntilSuccessBehavior.d.ts +1 -2
  648. package/src/engine/intelligence/behavior/decorator/RepeatUntilSuccessBehavior.d.ts.map +1 -1
  649. package/src/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.d.ts +0 -1
  650. package/src/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.d.ts.map +1 -1
  651. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.d.ts +1 -1
  652. package/src/engine/intelligence/behavior/ecs/DieBehavior.d.ts +1 -2
  653. package/src/engine/intelligence/behavior/ecs/DieBehavior.d.ts.map +1 -1
  654. package/src/engine/intelligence/behavior/ecs/EntityBehavior.d.ts +0 -1
  655. package/src/engine/intelligence/behavior/ecs/EntityBehavior.d.ts.map +1 -1
  656. package/src/engine/intelligence/behavior/ecs/KillBehavior.d.ts +1 -2
  657. package/src/engine/intelligence/behavior/ecs/KillBehavior.d.ts.map +1 -1
  658. package/src/engine/intelligence/behavior/ecs/OrbitingBehavior.d.ts +1 -2
  659. package/src/engine/intelligence/behavior/ecs/OrbitingBehavior.d.ts.map +1 -1
  660. package/src/engine/intelligence/behavior/ecs/SendEventBehavior.d.ts +1 -2
  661. package/src/engine/intelligence/behavior/ecs/SendEventBehavior.d.ts.map +1 -1
  662. package/src/engine/intelligence/behavior/ecs/WaitForEventBehavior.d.ts +1 -2
  663. package/src/engine/intelligence/behavior/ecs/WaitForEventBehavior.d.ts.map +1 -1
  664. package/src/engine/intelligence/behavior/ecs/WaitForEventBehaviorSerializationAdapter.d.ts +0 -1
  665. package/src/engine/intelligence/behavior/ecs/WaitForEventBehaviorSerializationAdapter.d.ts.map +1 -1
  666. package/src/engine/intelligence/behavior/primitive/ActionBehavior.d.ts +1 -2
  667. package/src/engine/intelligence/behavior/primitive/ActionBehavior.d.ts.map +1 -1
  668. package/src/engine/intelligence/behavior/primitive/FailingBehavior.d.ts +1 -3
  669. package/src/engine/intelligence/behavior/primitive/FailingBehavior.d.ts.map +1 -1
  670. package/src/engine/intelligence/behavior/primitive/FailingBehaviorSerializationAdapter.d.ts +0 -1
  671. package/src/engine/intelligence/behavior/primitive/FailingBehaviorSerializationAdapter.d.ts.map +1 -1
  672. package/src/engine/intelligence/behavior/primitive/PromiseBehavior.d.ts +2 -4
  673. package/src/engine/intelligence/behavior/primitive/PromiseBehavior.d.ts.map +1 -1
  674. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.d.ts +1 -3
  675. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.d.ts.map +1 -1
  676. package/src/engine/intelligence/behavior/primitive/SucceedingBehaviorSerializationAdapter.d.ts +0 -1
  677. package/src/engine/intelligence/behavior/primitive/SucceedingBehaviorSerializationAdapter.d.ts.map +1 -1
  678. package/src/engine/intelligence/behavior/selector/WeightedRandomBehavior.d.ts +1 -2
  679. package/src/engine/intelligence/behavior/selector/WeightedRandomBehavior.d.ts.map +1 -1
  680. package/src/engine/intelligence/behavior/util/BranchBehavior.d.ts +1 -3
  681. package/src/engine/intelligence/behavior/util/BranchBehavior.d.ts.map +1 -1
  682. package/src/engine/intelligence/behavior/util/ConditionBehavior.d.ts +1 -2
  683. package/src/engine/intelligence/behavior/util/ConditionBehavior.d.ts.map +1 -1
  684. package/src/engine/intelligence/behavior/util/DelayBehavior.d.ts +1 -3
  685. package/src/engine/intelligence/behavior/util/DelayBehavior.d.ts.map +1 -1
  686. package/src/engine/intelligence/behavior/util/LogMessageBehavior.d.ts +1 -2
  687. package/src/engine/intelligence/behavior/util/LogMessageBehavior.d.ts.map +1 -1
  688. package/src/engine/intelligence/behavior/util/RandomDelayBehavior.d.ts +4 -4
  689. package/src/engine/intelligence/behavior/util/RandomDelayBehavior.d.ts.map +1 -1
  690. package/src/engine/intelligence/behavior/util/RotationBehavior.d.ts +1 -2
  691. package/src/engine/intelligence/behavior/util/RotationBehavior.d.ts.map +1 -1
  692. package/src/engine/intelligence/blackboard/AbstractBlackboard.d.ts +58 -15
  693. package/src/engine/intelligence/blackboard/AbstractBlackboard.d.ts.map +1 -1
  694. package/src/engine/intelligence/blackboard/Blackboard.d.ts +79 -11
  695. package/src/engine/intelligence/blackboard/Blackboard.d.ts.map +1 -1
  696. package/src/engine/intelligence/blackboard/BlackboardSerializationAdapter.d.ts +0 -1
  697. package/src/engine/intelligence/blackboard/BlackboardSerializationAdapter.d.ts.map +1 -1
  698. package/src/engine/intelligence/blackboard/BlackboardValue.d.ts +1 -0
  699. package/src/engine/intelligence/blackboard/BlackboardValue.d.ts.map +1 -1
  700. package/src/engine/intelligence/controller/graph/StateGraphSystem.d.ts +1 -3
  701. package/src/engine/intelligence/controller/graph/StateGraphSystem.d.ts.map +1 -1
  702. package/src/engine/interpolation/InterpolationSystem.d.ts +1 -5
  703. package/src/engine/interpolation/InterpolationSystem.d.ts.map +1 -1
  704. package/src/engine/interpolation/TransformPoseSerializationAdapter.d.ts +0 -1
  705. package/src/engine/interpolation/TransformPoseSerializationAdapter.d.ts.map +1 -1
  706. package/src/engine/knowledge/database/StaticKnowledgeDataTable.d.ts +140 -9
  707. package/src/engine/knowledge/database/StaticKnowledgeDataTableDescriptor.d.ts +26 -7
  708. package/src/engine/knowledge/database/StaticKnowledgeDatabase.d.ts +2 -3
  709. package/src/engine/knowledge/database/StaticKnowledgeDatabase.d.ts.map +1 -1
  710. package/src/engine/navigation/ecs/components/InterpolationType.d.ts +8 -4
  711. package/src/engine/navigation/ecs/components/Path.d.ts +167 -47
  712. package/src/engine/navigation/ecs/components/PathEvents.d.ts +8 -6
  713. package/src/engine/navigation/ecs/components/PathSerializationAdapter.d.ts +0 -1
  714. package/src/engine/navigation/ecs/components/PathSerializationAdapter.d.ts.map +1 -1
  715. package/src/engine/navigation/ecs/path_following/PathFollower.d.ts +85 -45
  716. package/src/engine/navigation/ecs/path_following/PathFollowerEventType.d.ts +5 -3
  717. package/src/engine/navigation/ecs/path_following/PathFollowerFlags.d.ts +14 -20
  718. package/src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.d.ts +0 -1
  719. package/src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.d.ts.map +1 -1
  720. package/src/engine/navigation/ecs/path_following/PathFollowingSystem.d.ts +31 -6
  721. package/src/engine/navigation/ecs/path_following/PathFollowingSystem.d.ts.map +1 -1
  722. package/src/engine/network/adapters/TransformReplicationAdapter.d.ts +0 -1
  723. package/src/engine/network/adapters/TransformReplicationAdapter.d.ts.map +1 -1
  724. package/src/engine/network/ecs/NetworkSystem.d.ts +1 -1
  725. package/src/engine/network/ecs/serialization/NetworkIdentitySerializationAdapter.d.ts +0 -1
  726. package/src/engine/network/ecs/serialization/NetworkIdentitySerializationAdapter.d.ts.map +1 -1
  727. package/src/engine/options/Option.d.ts +3 -3
  728. package/src/engine/options/OptionsView.d.ts +1 -2
  729. package/src/engine/options/OptionsView.d.ts.map +1 -1
  730. package/src/engine/physics/body/SolverBodyState.d.ts.map +1 -1
  731. package/src/engine/physics/body/SolverBodyState.js +10 -1
  732. package/src/engine/physics/constraint/solve_constraints.d.ts.map +1 -1
  733. package/src/engine/physics/constraint/solve_constraints.js +840 -830
  734. package/src/engine/physics/ecs/ColliderObserverSystem.d.ts +3 -3
  735. package/src/engine/physics/ecs/ColliderObserverSystem.d.ts.map +1 -1
  736. package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts +0 -1
  737. package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts.map +1 -1
  738. package/src/engine/physics/ecs/JointSerializationAdapter.d.ts +0 -1
  739. package/src/engine/physics/ecs/JointSerializationAdapter.d.ts.map +1 -1
  740. package/src/engine/physics/ecs/PhysicsSystem.d.ts +14 -2
  741. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  742. package/src/engine/physics/ecs/PhysicsSystem.js +2246 -2172
  743. package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts +0 -1
  744. package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts.map +1 -1
  745. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +12 -8
  746. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts.map +1 -1
  747. package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +8 -4
  748. package/src/engine/physics/fluid/ecs/FluidSystem.d.ts.map +1 -1
  749. package/src/engine/physics/integration/integrate_velocity.d.ts.map +1 -1
  750. package/src/engine/physics/integration/integrate_velocity.js +25 -2
  751. package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -1
  752. package/src/engine/physics/narrowphase/capsule_contacts.js +622 -617
  753. package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts.map +1 -1
  754. package/src/engine/physics/narrowphase/convex_convex_manifold.js +632 -568
  755. package/src/engine/physics/solver/solve_contacts.d.ts +6 -5
  756. package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -1
  757. package/src/engine/physics/solver/solve_contacts.js +1506 -1482
  758. package/src/engine/platform/EnginePlatform.d.ts +24 -14
  759. package/src/engine/platform/WebEnginePlatform.d.ts +20 -5
  760. package/src/engine/platform/WebEnginePlatform.d.ts.map +1 -1
  761. package/src/engine/plugin/EnginePlugin.d.ts +36 -3
  762. package/src/engine/plugin/EnginePlugin.d.ts.map +1 -1
  763. package/src/engine/plugin/EnginePluginManager.d.ts +85 -16
  764. package/src/engine/plugin/EnginePluginManager.d.ts.map +1 -1
  765. package/src/engine/plugin/PluginReferenceContext.d.ts +1 -1
  766. package/src/engine/reference/v2/Reference.d.ts +55 -17
  767. package/src/engine/reference/v2/Reference.d.ts.map +1 -1
  768. package/src/engine/save/GameStateLoader.d.ts +0 -1
  769. package/src/engine/save/GameStateLoader.d.ts.map +1 -1
  770. package/src/engine/save/Storage.d.ts +75 -15
  771. package/src/engine/save/storage/InMemoryStorage.d.ts +0 -1
  772. package/src/engine/save/storage/InMemoryStorage.d.ts.map +1 -1
  773. package/src/engine/save/storage/IndexedDBStorage.d.ts +0 -2
  774. package/src/engine/save/storage/IndexedDBStorage.d.ts.map +1 -1
  775. package/src/engine/scene/Scene.d.ts +65 -7
  776. package/src/engine/scene/SceneManager.d.ts +125 -25
  777. package/src/engine/simulation/Ticker.d.ts +1 -2
  778. package/src/engine/simulation/Ticker.d.ts.map +1 -1
  779. package/src/engine/sound/SoundEngine.d.ts +46 -3
  780. package/src/engine/sound/ecs/SoundController.d.ts +0 -1
  781. package/src/engine/sound/ecs/SoundController.d.ts.map +1 -1
  782. package/src/engine/sound/ecs/SoundControllerSystem.d.ts +1 -2
  783. package/src/engine/sound/ecs/SoundControllerSystem.d.ts.map +1 -1
  784. package/src/engine/sound/ecs/SoundListener.d.ts +0 -1
  785. package/src/engine/sound/ecs/SoundListener.d.ts.map +1 -1
  786. package/src/engine/sound/ecs/SoundListenerSystem.d.ts +1 -1
  787. package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts +1 -1
  788. package/src/engine/sound/ecs/emitter/SoundEmitter.d.ts +1 -1
  789. package/src/engine/sound/ecs/emitter/SoundEmitter.d.ts.map +1 -1
  790. package/src/engine/sound/ecs/emitter/SoundEmitterSerializationAdapter.d.ts +0 -1
  791. package/src/engine/sound/ecs/emitter/SoundEmitterSerializationAdapter.d.ts.map +1 -1
  792. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts +1 -1
  793. package/src/engine/sound/ecs/emitter/SoundTrack.d.ts +1 -2
  794. package/src/engine/sound/ecs/emitter/SoundTrack.d.ts.map +1 -1
  795. package/src/engine/sound/simulation/core/AcousticMediumSerializationAdapter.d.ts +0 -1
  796. package/src/engine/sound/simulation/core/AcousticMediumSerializationAdapter.d.ts.map +1 -1
  797. package/src/engine/sound/simulation/definition/AcousticDirectivitySerializationAdapter.d.ts +0 -1
  798. package/src/engine/sound/simulation/definition/AcousticDirectivitySerializationAdapter.d.ts.map +1 -1
  799. package/src/engine/sound/simulation/definition/AcousticMaterialSerializationAdapter.d.ts +0 -1
  800. package/src/engine/sound/simulation/definition/AcousticMaterialSerializationAdapter.d.ts.map +1 -1
  801. package/src/engine/sound/simulation/ecs/AcousticBodySerializationAdapter.d.ts +0 -1
  802. package/src/engine/sound/simulation/ecs/AcousticBodySerializationAdapter.d.ts.map +1 -1
  803. package/src/engine/sound/simulation/ecs/AcousticProbeFieldSystem.d.ts +1 -1
  804. package/src/engine/sound/simulation/ecs/AcousticSimulationSystem.d.ts +1 -1
  805. package/src/engine/sound/simulation/ecs/AcousticVolumeSerializationAdapter.d.ts +0 -1
  806. package/src/engine/sound/simulation/ecs/AcousticVolumeSerializationAdapter.d.ts.map +1 -1
  807. package/src/engine/sound/simulation/ecs/AcousticVolumeSystem.d.ts +1 -1
  808. package/src/engine/sound/simulation/probe/AcousticProbeFieldSerializationAdapter.d.ts +0 -1
  809. package/src/engine/sound/simulation/probe/AcousticProbeFieldSerializationAdapter.d.ts.map +1 -1
  810. package/src/engine/sound/sopra/definition/BusDefinitionSerializationAdapter.d.ts +0 -1
  811. package/src/engine/sound/sopra/definition/BusDefinitionSerializationAdapter.d.ts.map +1 -1
  812. package/src/engine/sound/sopra/definition/DuckingRuleSerializationAdapter.d.ts +0 -1
  813. package/src/engine/sound/sopra/definition/DuckingRuleSerializationAdapter.d.ts.map +1 -1
  814. package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.d.ts +0 -1
  815. package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.d.ts.map +1 -1
  816. package/src/engine/sound/sopra/definition/MixerSnapshotSerializationAdapter.d.ts +0 -1
  817. package/src/engine/sound/sopra/definition/MixerSnapshotSerializationAdapter.d.ts.map +1 -1
  818. package/src/engine/sound/sopra/definition/ParameterDefinitionSerializationAdapter.d.ts +0 -1
  819. package/src/engine/sound/sopra/definition/ParameterDefinitionSerializationAdapter.d.ts.map +1 -1
  820. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClipSerializationAdapter.d.ts +0 -1
  821. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClipSerializationAdapter.d.ts.map +1 -1
  822. package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClipSerializationAdapter.d.ts +0 -1
  823. package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClipSerializationAdapter.d.ts.map +1 -1
  824. package/src/engine/sound/sopra/definition/clip/SampleAudioClipSerializationAdapter.d.ts +0 -1
  825. package/src/engine/sound/sopra/definition/clip/SampleAudioClipSerializationAdapter.d.ts.map +1 -1
  826. package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClipSerializationAdapter.d.ts +0 -1
  827. package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClipSerializationAdapter.d.ts.map +1 -1
  828. package/src/engine/sound/sopra/definition/clip/SilenceAudioClipSerializationAdapter.d.ts +0 -1
  829. package/src/engine/sound/sopra/definition/clip/SilenceAudioClipSerializationAdapter.d.ts.map +1 -1
  830. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClipSerializationAdapter.d.ts +0 -1
  831. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClipSerializationAdapter.d.ts.map +1 -1
  832. package/src/engine/sound/sopra/definition/effect/CompressorEffectSerializationAdapter.d.ts +0 -1
  833. package/src/engine/sound/sopra/definition/effect/CompressorEffectSerializationAdapter.d.ts.map +1 -1
  834. package/src/engine/sound/sopra/definition/effect/EqEffectSerializationAdapter.d.ts +0 -1
  835. package/src/engine/sound/sopra/definition/effect/EqEffectSerializationAdapter.d.ts.map +1 -1
  836. package/src/engine/sound/sopra/definition/effect/ReverbEffectSerializationAdapter.d.ts +0 -1
  837. package/src/engine/sound/sopra/definition/effect/ReverbEffectSerializationAdapter.d.ts.map +1 -1
  838. package/src/engine/sound/sopra/runtime/EventInstance.d.ts +1 -2
  839. package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
  840. package/src/engine/sound/sopra/runtime/ParameterStore.d.ts +1 -2
  841. package/src/engine/sound/sopra/runtime/ParameterStore.d.ts.map +1 -1
  842. package/src/engine/ui/bindings/DomElementProcessorManager.d.ts +0 -3
  843. package/src/engine/ui/bindings/DomElementProcessorManager.d.ts.map +1 -1
  844. package/src/engine/ui/modal/ModalStack.d.ts +3 -3
  845. package/src/engine/ui/notification/AnimatedObjectEmitter.d.ts +2 -2
  846. package/src/engine/ui/notification/ViewEmitter.d.ts +2 -2
  847. package/src/generation/filtering/CellFilter.d.ts +1 -1
  848. package/src/generation/filtering/CellFilter.d.ts.map +1 -1
  849. package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorRandomRotation.d.ts +3 -1
  850. package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorRandomRotation.d.ts.map +1 -1
  851. package/src/generation/markers/actions/probability/MarkerNodeActionSelectWeighted.d.ts +3 -1
  852. package/src/generation/markers/actions/probability/MarkerNodeActionSelectWeighted.d.ts.map +1 -1
  853. package/src/generation/markers/transform/MarkerNodeTransformRotateRandom.d.ts +3 -1
  854. package/src/generation/markers/transform/MarkerNodeTransformRotateRandom.d.ts.map +1 -1
  855. package/src/generation/markers/transform/MarkerNodeTransformerRecordPropertyClosure.d.ts +3 -1
  856. package/src/generation/markers/transform/MarkerNodeTransformerRecordPropertyClosure.d.ts.map +1 -1
  857. package/src/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.d.ts +3 -1
  858. package/src/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.d.ts.map +1 -1
  859. package/src/generation/placement/action/util/CellMatcherWithinAABB.d.ts +1 -1
  860. package/src/generation/placement/action/util/CellMatcherWithinAABB.d.ts.map +1 -1
  861. package/src/misc/makeMatcapSelectionOption.d.ts +11 -13
  862. package/src/view/View.d.ts +313 -30
  863. package/src/view/asset/AssetLoaderStatusView.d.ts +1 -1
  864. package/src/view/asset/PreloaderView.d.ts +1 -1
  865. package/src/view/common/LabelView.d.ts +2 -1
  866. package/src/view/common/LabelView.d.ts.map +1 -1
  867. package/src/view/common/ListView.d.ts +2 -2
  868. package/src/view/common/ListView.d.ts.map +1 -1
  869. package/src/view/common/TabbedView.d.ts +1 -1
  870. package/src/view/common/VirtualListView.d.ts +3 -3
  871. package/src/view/common/VirtualListView.d.ts.map +1 -1
  872. package/src/view/common/dnd/Draggable.d.ts +2 -2
  873. package/src/view/common/dnd/DropTarget.d.ts +6 -6
  874. package/src/view/controller/GuiController.d.ts +1 -2
  875. package/src/view/controller/GuiController.d.ts.map +1 -1
  876. package/src/view/controller/controls/BooleanVector3Control.d.ts +1 -2
  877. package/src/view/controller/controls/BooleanVector3Control.d.ts.map +1 -1
  878. package/src/view/controller/controls/NativeListController.d.ts +1 -1
  879. package/src/view/controller/controls/Vector1Control.d.ts +1 -1
  880. package/src/view/currency/CompositeCurrencyLabelView.d.ts +1 -1
  881. package/src/view/currency/CurrencyDenominationLabelView.d.ts +1 -1
  882. package/src/view/elements/BottomLeftResizeHandleView.d.ts +1 -1
  883. package/src/view/elements/CanvasView.d.ts +1 -2
  884. package/src/view/elements/CanvasView.d.ts.map +1 -1
  885. package/src/view/elements/CheckboxView.d.ts +1 -1
  886. package/src/view/elements/CompassArrowView.d.ts +1 -2
  887. package/src/view/elements/CompassArrowView.d.ts.map +1 -1
  888. package/src/view/elements/ConfirmationDialogView.d.ts +1 -1
  889. package/src/view/elements/DropDownSelectionView.d.ts +1 -1
  890. package/src/view/elements/EmptyView.d.ts +1 -2
  891. package/src/view/elements/EmptyView.d.ts.map +1 -1
  892. package/src/view/elements/Group.d.ts +1 -2
  893. package/src/view/elements/Group.d.ts.map +1 -1
  894. package/src/view/elements/MeshPreview.d.ts +1 -1
  895. package/src/view/elements/SimpleWindow.d.ts +1 -1
  896. package/src/view/elements/button/ButtonView.d.ts +1 -1
  897. package/src/view/elements/image/ImageView.d.ts +1 -2
  898. package/src/view/elements/image/ImageView.d.ts.map +1 -1
  899. package/src/view/elements/image/SvgImageView.d.ts +1 -1
  900. package/src/view/elements/label/LabeledValueView.d.ts +1 -1
  901. package/src/view/elements/navigation/ViewStack.d.ts +1 -8
  902. package/src/view/elements/navigation/ViewStack.d.ts.map +1 -1
  903. package/src/view/elements/notify/ToastLogView.d.ts +1 -1
  904. package/src/view/elements/progress/RectangularPieProgressView.d.ts +1 -1
  905. package/src/view/elements/progress/SmoothProgressBar.d.ts +1 -1
  906. package/src/view/elements/progress/segmented/SegmentedResourceBarView.d.ts +1 -1
  907. package/src/view/elements/radial/RadialMenu.d.ts +1 -1
  908. package/src/view/elements/radial/RadialMenuElement.d.ts +1 -1
  909. package/src/view/elements/radial/RadialMenuElementDefinition.d.ts +125 -39
  910. package/src/view/elements/radial/RadialProgressView.d.ts +1 -1
  911. package/src/view/elements/radial/RadialText.d.ts +1 -1
  912. package/src/view/elements/tiles2d/Tile.d.ts +1 -1
  913. package/src/view/elements/tiles2d/TileGrid.d.ts +4 -5
  914. package/src/view/elements/tiles2d/TileGrid.d.ts.map +1 -1
  915. package/src/view/elements/video/VideoView.d.ts +2 -2
  916. package/src/view/elements/video/VideoView.d.ts.map +1 -1
  917. package/src/view/elements/windrose/WindRoseDiagram.d.ts +1 -1
  918. package/src/view/game/achievements/AchievementNotificationView.d.ts +1 -1
  919. package/src/view/math/FunctionGraphView.d.ts +1 -1
  920. package/src/view/minimap/Minimap.d.ts +1 -1
  921. package/src/view/minimap/dom/MinimapCameraView.d.ts +1 -1
  922. package/src/view/minimap/dom/MinimapMarkerView.d.ts +1 -1
  923. package/src/view/minimap/dom/MinimapTerrainView.d.ts +1 -1
  924. package/src/view/task/TaskProgressView.d.ts +1 -1
  925. package/src/view/tooltip/DomTooltipObserver.d.ts +2 -2
  926. package/src/view/tooltip/TooltipView.d.ts +1 -1
  927. package/src/view/tooltip/gml/parser/parseTooltipString.d.ts +1 -0
  928. package/src/view/tooltip/gml/parser/parseTooltipString.d.ts.map +1 -1
  929. package/src/view/tooltip/gml/parser/readReferenceToken.d.ts +1 -0
  930. package/src/view/tooltip/gml/parser/readReferenceToken.d.ts.map +1 -1
  931. package/src/view/tooltip/gml/parser/readReferenceValueToken.d.ts +2 -1
  932. package/src/view/tooltip/gml/parser/readReferenceValueToken.d.ts.map +1 -1
  933. package/src/view/tooltip/gml/parser/readStyleToken.d.ts +1 -0
  934. package/src/view/tooltip/gml/parser/readStyleToken.d.ts.map +1 -1
  935. package/editor/ecs/component/TypeSchema.d.ts +0 -38
  936. package/editor/tools/v2/BlenderCameraOrientationGizmo.d.ts +0 -50
@@ -1,617 +1,622 @@
1
- import { line3_compute_segment_segment_closest_points } from "../../../core/geom/3d/line/line3_compute_segment_segment_closest_points.js";
2
- import { line3_compute_segment_closest_point_t } from "../../../core/geom/3d/line/line3_compute_segment_closest_point_t.js";
3
- import { line3_compute_segment_closest_point_to_aabb3_t } from "../../../core/geom/3d/line/line3_compute_segment_closest_point_to_aabb3_t.js";
4
- import { v3_quaternion_apply } from "../../../core/geom/vec3/v3_quaternion_apply.js";
5
- import { v3_quaternion_apply_inverse } from "../../../core/geom/vec3/v3_quaternion_apply_inverse.js";
6
- import { sphere_box_contact } from "./sphere_box_contact.js";
7
-
8
- /**
9
- * Closed-form narrowphase helpers for the capsule family. A capsule is the
10
- * Minkowski sum of a line segment and a sphere of radius `r`, so contact
11
- * resolution reduces to:
12
- * - capsule-sphere → point-on-segment distance, then sphere-style normal
13
- * - capsule-capsule → segment-segment closest pair
14
- * - capsule-box → segment-vs-OBB closest point (iterative)
15
- *
16
- * Output convention (matches the rest of the narrowphase family):
17
- * out[0..2] : normal pointing from B toward A
18
- * out[3] : penetration depth (positive)
19
- * out[4..6] : world contact on A's surface
20
- * out[7..9] : world contact on B's surface
21
- *
22
- * @author Alex Goldring
23
- * @copyright Company Named Limited (c) 2026
24
- */
25
-
26
- const scratch_st = new Float64Array(2);
27
-
28
- const scratch_seg = new Float64Array(6);
29
-
30
- /**
31
- * Compute the two world endpoints of a capsule's central segment given its
32
- * pose. The capsule is Y-aligned in body frame; the segment runs from
33
- * `(0, -h/2, 0)` to `(0, +h/2, 0)`. Writes endpoints into `out` as
34
- * `[ax, ay, az, bx, by, bz]`.
35
- *
36
- * @param {number[]|Float64Array} out length >= 6
37
- * @param {number} cx capsule centre x
38
- * @param {number} cy
39
- * @param {number} cz
40
- * @param {number} qx quaternion x
41
- * @param {number} qy
42
- * @param {number} qz
43
- * @param {number} qw
44
- * @param {number} half_height
45
- */
46
- export function capsule_world_segment(out, cx, cy, cz, qx, qy, qz, qw, half_height) {
47
- v3_quaternion_apply(out, 0, 0, -half_height, 0, qx, qy, qz, qw);
48
- v3_quaternion_apply(out, 3, 0, half_height, 0, qx, qy, qz, qw);
49
- out[0] += cx; out[1] += cy; out[2] += cz;
50
- out[3] += cx; out[4] += cy; out[5] += cz;
51
- }
52
-
53
- // --- capsule vs sphere ------------------------------------------------------
54
-
55
- /**
56
- * Capsule (A) vs sphere (B) contact, closed-form via point-segment distance.
57
- *
58
- * @param {number[]|Float64Array} out length >= 10
59
- * @param {number} a_cx capsule centre x
60
- * @param {number} a_cy
61
- * @param {number} a_cz
62
- * @param {number} a_qx capsule rotation
63
- * @param {number} a_qy
64
- * @param {number} a_qz
65
- * @param {number} a_qw
66
- * @param {number} a_radius
67
- * @param {number} a_half_h capsule half-height (not including caps)
68
- * @param {number} b_cx sphere centre x
69
- * @param {number} b_cy
70
- * @param {number} b_cz
71
- * @param {number} b_radius
72
- * @returns {boolean} true on overlap
73
- */
74
- export function capsule_sphere_contact(
75
- out,
76
- a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
77
- b_cx, b_cy, b_cz, b_radius
78
- ) {
79
- capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
80
- const sax = scratch_seg[0], say = scratch_seg[1], saz = scratch_seg[2];
81
- const sbx = scratch_seg[3], sby = scratch_seg[4], sbz = scratch_seg[5];
82
-
83
- const t = line3_compute_segment_closest_point_t(sax, say, saz, sbx, sby, sbz, b_cx, b_cy, b_cz);
84
-
85
- const px = sax + (sbx - sax) * t;
86
- const py = say + (sby - say) * t;
87
- const pz = saz + (sbz - saz) * t;
88
-
89
- const dx = px - b_cx;
90
- const dy = py - b_cy;
91
- const dz = pz - b_cz;
92
- const dist_sqr = dx * dx + dy * dy + dz * dz;
93
- const sum = a_radius + b_radius;
94
- if (dist_sqr >= sum * sum) return false;
95
-
96
- const dist = Math.sqrt(dist_sqr);
97
- let nx, ny, nz;
98
- if (dist > 0) {
99
- const inv = 1 / dist;
100
- nx = dx * inv; ny = dy * inv; nz = dz * inv;
101
- } else {
102
- // Sphere centre exactly on the capsule segment — pick a deterministic tie-break.
103
- nx = 1; ny = 0; nz = 0;
104
- }
105
-
106
- out[0] = nx; out[1] = ny; out[2] = nz; // normal from B to A
107
- out[3] = sum - dist;
108
- // World contact on A (capsule): segment point pushed back by capsule radius along -normal
109
- out[4] = px - nx * a_radius;
110
- out[5] = py - ny * a_radius;
111
- out[6] = pz - nz * a_radius;
112
- // World contact on B (sphere): sphere centre pushed along +normal by sphere radius
113
- out[7] = b_cx + nx * b_radius;
114
- out[8] = b_cy + ny * b_radius;
115
- out[9] = b_cz + nz * b_radius;
116
- return true;
117
- }
118
-
119
- // --- capsule vs capsule -----------------------------------------------------
120
-
121
- const scratch_seg_b = new Float64Array(6);
122
-
123
- /**
124
- * Two capsules (A and B). Reduces to segment-segment closest pair + radius.
125
- *
126
- * @param {number[]|Float64Array} out length >= 10
127
- * @returns {boolean} true on overlap
128
- */
129
- export function capsule_capsule_contact(
130
- out,
131
- a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
132
- b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_radius, b_half_h
133
- ) {
134
- capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
135
- capsule_world_segment(scratch_seg_b, b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_half_h);
136
-
137
- const a0x = scratch_seg[0], a0y = scratch_seg[1], a0z = scratch_seg[2];
138
- const a1x = scratch_seg[3], a1y = scratch_seg[4], a1z = scratch_seg[5];
139
- const b0x = scratch_seg_b[0], b0y = scratch_seg_b[1], b0z = scratch_seg_b[2];
140
- const b1x = scratch_seg_b[3], b1y = scratch_seg_b[4], b1z = scratch_seg_b[5];
141
-
142
- line3_compute_segment_segment_closest_points(
143
- scratch_st,
144
- a0x, a0y, a0z, a1x, a1y, a1z,
145
- b0x, b0y, b0z, b1x, b1y, b1z
146
- );
147
-
148
- const s = scratch_st[0];
149
- const t = scratch_st[1];
150
-
151
- const pax = a0x + (a1x - a0x) * s;
152
- const pay = a0y + (a1y - a0y) * s;
153
- const paz = a0z + (a1z - a0z) * s;
154
- const pbx = b0x + (b1x - b0x) * t;
155
- const pby = b0y + (b1y - b0y) * t;
156
- const pbz = b0z + (b1z - b0z) * t;
157
-
158
- const dx = pax - pbx;
159
- const dy = pay - pby;
160
- const dz = paz - pbz;
161
- const dist_sqr = dx * dx + dy * dy + dz * dz;
162
- const sum = a_radius + b_radius;
163
- if (dist_sqr >= sum * sum) return false;
164
-
165
- const dist = Math.sqrt(dist_sqr);
166
- let nx, ny, nz;
167
- if (dist > 0) {
168
- const inv = 1 / dist;
169
- nx = dx * inv; ny = dy * inv; nz = dz * inv;
170
- } else {
171
- // Segments touch — fall back to the world-frame direction from B's
172
- // segment centre toward A's segment centre as a tie-break.
173
- const acx = (a0x + a1x) * 0.5;
174
- const acy = (a0y + a1y) * 0.5;
175
- const acz = (a0z + a1z) * 0.5;
176
- const bcx = (b0x + b1x) * 0.5;
177
- const bcy = (b0y + b1y) * 0.5;
178
- const bcz = (b0z + b1z) * 0.5;
179
- const ddx = acx - bcx, ddy = acy - bcy, ddz = acz - bcz;
180
- const dd_sqr = ddx * ddx + ddy * ddy + ddz * ddz;
181
- if (dd_sqr > 0) {
182
- const inv2 = 1 / Math.sqrt(dd_sqr);
183
- nx = ddx * inv2; ny = ddy * inv2; nz = ddz * inv2;
184
- } else {
185
- nx = 1; ny = 0; nz = 0;
186
- }
187
- }
188
-
189
- out[0] = nx; out[1] = ny; out[2] = nz;
190
- out[3] = sum - dist;
191
- out[4] = pax - nx * a_radius;
192
- out[5] = pay - ny * a_radius;
193
- out[6] = paz - nz * a_radius;
194
- out[7] = pbx + nx * b_radius;
195
- out[8] = pby + ny * b_radius;
196
- out[9] = pbz + nz * b_radius;
197
- return true;
198
- }
199
-
200
- /**
201
- * Output stride per contact in {@link capsule_capsule_multi_contacts} —
202
- * matches {@link CAPSULE_BOX_CONTACT_STRIDE}:
203
- * 0..2 : world contact on capsule A side
204
- * 3..5 : world contact on capsule B side
205
- * 6..8 : normal from B toward A
206
- * 9 : depth (positive = penetration)
207
- * @type {number}
208
- */
209
- export const CAPSULE_CAPSULE_CONTACT_STRIDE = 10;
210
-
211
- /**
212
- * Maximum contacts {@link capsule_capsule_multi_contacts} can emit (the two
213
- * ends of the parallel-overlap interval).
214
- * @type {number}
215
- */
216
- export const CAPSULE_CAPSULE_MAX_CONTACTS = 2;
217
-
218
- /**
219
- * Squared-sine threshold for treating two capsule axes as parallel: below
220
- * ~2.5 degrees the single closest-point contact is ambiguous along the
221
- * overlap interval (the solver sees a point contact with a bogus lever arm
222
- * and stacked capsules wobble), so the manifold switches to two contacts at
223
- * the interval ends.
224
- * @type {number}
225
- */
226
- const CAPSULE_PARALLEL_SIN_SQR = 0.002;
227
-
228
- /**
229
- * Capsule-vs-capsule with a parallel-aware multi-point manifold: NEAR-PARALLEL
230
- * overlapping capsules emit one contact at each end of their axial overlap
231
- * interval (the two-point support a resting capsule physically has); every
232
- * other configuration emits the single closest-point contact of
233
- * {@link capsule_capsule_contact}.
234
- *
235
- * @param {number[]|Float64Array} out length >= 2 * CAPSULE_CAPSULE_CONTACT_STRIDE
236
- * @returns {number} number of contacts written (0 = no overlap)
237
- */
238
- export function capsule_capsule_multi_contacts(
239
- out,
240
- a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
241
- b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_radius, b_half_h
242
- ) {
243
- capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
244
- capsule_world_segment(scratch_seg_b, b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_half_h);
245
-
246
- const a0x = scratch_seg[0], a0y = scratch_seg[1], a0z = scratch_seg[2];
247
- const a1x = scratch_seg[3], a1y = scratch_seg[4], a1z = scratch_seg[5];
248
- const b0x = scratch_seg_b[0], b0y = scratch_seg_b[1], b0z = scratch_seg_b[2];
249
- const b1x = scratch_seg_b[3], b1y = scratch_seg_b[4], b1z = scratch_seg_b[5];
250
-
251
- const d1x = a1x - a0x, d1y = a1y - a0y, d1z = a1z - a0z;
252
- const d2x = b1x - b0x, d2y = b1y - b0y, d2z = b1z - b0z;
253
- const len1_sqr = d1x * d1x + d1y * d1y + d1z * d1z;
254
- const len2_sqr = d2x * d2x + d2y * d2y + d2z * d2z;
255
-
256
- const cx = d1y * d2z - d1z * d2y;
257
- const cy = d1z * d2x - d1x * d2z;
258
- const cz = d1x * d2y - d1y * d2x;
259
- const cross_sqr = cx * cx + cy * cy + cz * cz;
260
-
261
- const sum = a_radius + b_radius;
262
-
263
- // Near-parallel with real segments: try the two-end manifold.
264
- if (len1_sqr > 0 && len2_sqr > 0
265
- && cross_sqr < CAPSULE_PARALLEL_SIN_SQR * len1_sqr * len2_sqr) {
266
-
267
- const inv_len1 = 1 / Math.sqrt(len1_sqr);
268
- const ux = d1x * inv_len1, uy = d1y * inv_len1, uz = d1z * inv_len1;
269
-
270
- // B's endpoints parameterised along A's axis (origin a0).
271
- const t0 = (b0x - a0x) * ux + (b0y - a0y) * uy + (b0z - a0z) * uz;
272
- const t1 = (b1x - a0x) * ux + (b1y - a0y) * uy + (b1z - a0z) * uz;
273
- const len1 = Math.sqrt(len1_sqr);
274
- const lo = Math.max(0, Math.min(t0, t1));
275
- const hi = Math.min(len1, Math.max(t0, t1));
276
-
277
- if (hi > lo) {
278
- // Direction along B for projecting A-axis points onto B.
279
- const inv_len2_sqr = 1 / len2_sqr;
280
- let n_written = 0;
281
- for (let e = 0; e < 2; e++) {
282
- const sA = e === 0 ? lo : hi;
283
- const pax = a0x + ux * sA;
284
- const pay = a0y + uy * sA;
285
- const paz = a0z + uz * sA;
286
- // Closest point on segment B to pa.
287
- let tB = ((pax - b0x) * d2x + (pay - b0y) * d2y + (paz - b0z) * d2z) * inv_len2_sqr;
288
- tB = tB < 0 ? 0 : (tB > 1 ? 1 : tB);
289
- const pbx = b0x + d2x * tB;
290
- const pby = b0y + d2y * tB;
291
- const pbz = b0z + d2z * tB;
292
-
293
- const dx = pax - pbx, dy = pay - pby, dz = paz - pbz;
294
- const dist_sqr = dx * dx + dy * dy + dz * dz;
295
- if (dist_sqr >= sum * sum) continue;
296
- const dist = Math.sqrt(dist_sqr);
297
-
298
- let nx, ny, nz;
299
- if (dist > 0) {
300
- const inv = 1 / dist;
301
- nx = dx * inv; ny = dy * inv; nz = dz * inv;
302
- } else {
303
- // Axes coincide at this point - centre tie-break.
304
- const ddx = a_cx - b_cx, ddy = a_cy - b_cy, ddz = a_cz - b_cz;
305
- const dd = ddx * ddx + ddy * ddy + ddz * ddz;
306
- if (dd > 0) {
307
- const inv2 = 1 / Math.sqrt(dd);
308
- nx = ddx * inv2; ny = ddy * inv2; nz = ddz * inv2;
309
- } else {
310
- nx = 1; ny = 0; nz = 0;
311
- }
312
- }
313
-
314
- const off = n_written * CAPSULE_CAPSULE_CONTACT_STRIDE;
315
- out[off] = pax - nx * a_radius;
316
- out[off + 1] = pay - ny * a_radius;
317
- out[off + 2] = paz - nz * a_radius;
318
- out[off + 3] = pbx + nx * b_radius;
319
- out[off + 4] = pby + ny * b_radius;
320
- out[off + 5] = pbz + nz * b_radius;
321
- out[off + 6] = nx;
322
- out[off + 7] = ny;
323
- out[off + 8] = nz;
324
- out[off + 9] = sum - dist;
325
- n_written++;
326
- }
327
- if (n_written > 0) return n_written;
328
- return 0; // parallel but everywhere out of reach
329
- }
330
- // Degenerate interval (axially offset end-to-end) - single contact below.
331
- }
332
-
333
- // General case: single closest-point contact.
334
- if (!capsule_capsule_contact(
335
- scratch_single,
336
- a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
337
- b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_radius, b_half_h
338
- )) {
339
- return 0;
340
- }
341
- out[0] = scratch_single[4];
342
- out[1] = scratch_single[5];
343
- out[2] = scratch_single[6];
344
- out[3] = scratch_single[7];
345
- out[4] = scratch_single[8];
346
- out[5] = scratch_single[9];
347
- out[6] = scratch_single[0];
348
- out[7] = scratch_single[1];
349
- out[8] = scratch_single[2];
350
- out[9] = scratch_single[3];
351
- return 1;
352
- }
353
-
354
- const scratch_single = new Float64Array(10);
355
-
356
- // --- capsule vs oriented box ------------------------------------------------
357
-
358
- const scratch_a0_local = new Float64Array(3);
359
- const scratch_a1_local = new Float64Array(3);
360
-
361
- /**
362
- * Capsule (A) vs oriented box (B). Brings the capsule segment into box-local
363
- * space, then refines via 2 fixed-point iterations between:
364
- * - closest point on the segment to the current box-side candidate
365
- * - clamped point on the box closest to the current segment-side candidate
366
- *
367
- * Two iterations suffice for the cases this engine targets (sphere-like cap
368
- * geometry against axis-aligned-in-local box). When the segment passes
369
- * through the box, the "inside" branch picks the smallest-overlap face
370
- * deterministically, mirroring {@link sphere_box_contact}.
371
- *
372
- * @param {number[]|Float64Array} out length >= 10
373
- * @returns {boolean}
374
- */
375
- export function capsule_box_contact(
376
- out,
377
- a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
378
- b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_hx, b_hy, b_hz
379
- ) {
380
- // Bring the capsule's segment endpoints into box-local space: build them in
381
- // world first (from the capsule centre + rotated half-height axis), then map
382
- // world box-local below.
383
- capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
384
- // World → box-local: subtract box centre, then rotate by conjugate of box quat.
385
- const w_a0x = scratch_seg[0] - b_cx, w_a0y = scratch_seg[1] - b_cy, w_a0z = scratch_seg[2] - b_cz;
386
- const w_a1x = scratch_seg[3] - b_cx, w_a1y = scratch_seg[4] - b_cy, w_a1z = scratch_seg[5] - b_cz;
387
- v3_quaternion_apply_inverse(scratch_a0_local, 0, w_a0x, w_a0y, w_a0z, b_qx, b_qy, b_qz, b_qw);
388
- v3_quaternion_apply_inverse(scratch_a1_local, 0, w_a1x, w_a1y, w_a1z, b_qx, b_qy, b_qz, b_qw);
389
-
390
- const a0lx = scratch_a0_local[0], a0ly = scratch_a0_local[1], a0lz = scratch_a0_local[2];
391
- const a1lx = scratch_a1_local[0], a1ly = scratch_a1_local[1], a1lz = scratch_a1_local[2];
392
-
393
- // Exact closest point on the capsule segment to the box-local AABB [−h, h].
394
- // Replaces a 2-iteration alternating projection (project onto segment, clamp
395
- // into box, repeat) that converged too slowly for capsules near-parallel to
396
- // a box face/edge overestimating the segment-vs-box distance, which
397
- // under-detected contacts (~0.85% of random configs missed) and mis-placed
398
- // depth/normal on many more. See core/geom/3d/gjk/GJK_REVIEW_NOTES.md.
399
- const t = line3_compute_segment_closest_point_to_aabb3_t(
400
- a0lx, a0ly, a0lz, a1lx, a1ly, a1lz,
401
- -b_hx, -b_hy, -b_hz, b_hx, b_hy, b_hz
402
- );
403
- const plx = a0lx + (a1lx - a0lx) * t;
404
- const ply = a0ly + (a1ly - a0ly) * t;
405
- const plz = a0lz + (a1lz - a0lz) * t;
406
-
407
- // Final box-side point. `let` because the interior branch snaps it onto
408
- // the chosen face for an inside segment point the clamp is an identity.
409
- let qlx = plx < -b_hx ? -b_hx : (plx > b_hx ? b_hx : plx);
410
- let qly = ply < -b_hy ? -b_hy : (ply > b_hy ? b_hy : ply);
411
- let qlz = plz < -b_hz ? -b_hz : (plz > b_hz ? b_hz : plz);
412
- const inside = qlx === plx && qly === ply && qlz === plz;
413
-
414
- let nlx, nly, nlz, dist;
415
- if (!inside) {
416
- const ex = plx - qlx, ey = ply - qly, ez = plz - qlz;
417
- const d_sqr = ex * ex + ey * ey + ez * ez;
418
- if (d_sqr >= a_radius * a_radius) return false;
419
- dist = Math.sqrt(d_sqr);
420
- if (dist > 0) {
421
- const inv = 1 / dist;
422
- nlx = ex * inv; nly = ey * inv; nlz = ez * inv;
423
- } else {
424
- nlx = 1; nly = 0; nlz = 0;
425
- }
426
- } else {
427
- // Segment point is inside the box. Pick the smallest-overlap face and
428
- // snap the box witness onto it, so the reported box contact lies on
429
- // the SURFACE and is consistent with the normal/depth — not left at
430
- // the interior segment point, which hands the solver a wrong lever
431
- // arm exactly in deep penetration. Mirrors sphere_box_contact's
432
- // interior branch.
433
- const dxf = b_hx - Math.abs(plx);
434
- const dyf = b_hy - Math.abs(ply);
435
- const dzf = b_hz - Math.abs(plz);
436
- if (dxf <= dyf && dxf <= dzf) {
437
- nlx = plx >= 0 ? 1 : -1; nly = 0; nlz = 0; dist = -dxf;
438
- qlx = plx >= 0 ? b_hx : -b_hx;
439
- } else if (dyf <= dzf) {
440
- nlx = 0; nly = ply >= 0 ? 1 : -1; nlz = 0; dist = -dyf;
441
- qly = ply >= 0 ? b_hy : -b_hy;
442
- } else {
443
- nlx = 0; nly = 0; nlz = plz >= 0 ? 1 : -1; dist = -dzf;
444
- qlz = plz >= 0 ? b_hz : -b_hz;
445
- }
446
- }
447
-
448
- // Normal (box capsule axis point) into world.
449
- v3_quaternion_apply(out, 0, nlx, nly, nlz, b_qx, b_qy, b_qz, b_qw);
450
- const nx = out[0], ny = out[1], nz = out[2];
451
- out[3] = a_radius - dist;
452
-
453
- // Capsule-side contact: world segment point pushed back by radius.
454
- v3_quaternion_apply(out, 4, plx, ply, plz, b_qx, b_qy, b_qz, b_qw);
455
- out[4] += b_cx - nx * a_radius;
456
- out[5] += b_cy - ny * a_radius;
457
- out[6] += b_cz - nz * a_radius;
458
-
459
- // Box-side contact: world projection of the box-surface point.
460
- v3_quaternion_apply(out, 7, qlx, qly, qlz, b_qx, b_qy, b_qz, b_qw);
461
- out[7] += b_cx;
462
- out[8] += b_cy;
463
- out[9] += b_cz;
464
-
465
- return true;
466
- }
467
-
468
- // --- capsule vs oriented box, multi-point manifold --------------------------
469
-
470
- /**
471
- * Output stride per contact in {@link capsule_box_multi_contacts}.
472
- * Matches the candidate-buffer layout used by `narrowphase_step`.
473
- *
474
- * 0..2 : world contact on capsule side
475
- * 3..5 : world contact on box side
476
- * 6..8 : normal from box (B) toward capsule (A)
477
- * 9 : depth (positive = penetration)
478
- *
479
- * @type {number}
480
- */
481
- export const CAPSULE_BOX_CONTACT_STRIDE = 10;
482
-
483
- /**
484
- * Maximum contact points {@link capsule_box_multi_contacts} can emit.
485
- * - 1 from the closest-point-on-segment vs OBB query (primary)
486
- * - up to 2 from the cap-centre sphere-vs-OBB queries (one per endpoint)
487
- * @type {number}
488
- */
489
- export const CAPSULE_BOX_MAX_CONTACTS = 3;
490
-
491
- const scratch_primary = new Float64Array(10);
492
- const scratch_endpoint = new Float64Array(10);
493
-
494
- /**
495
- * Two world positions are treated as the same contact when their squared
496
- * distance is below this threshold. Picked so that a capsule resting flat
497
- * doesn't double up the primary closest-segment-point contact with whichever
498
- * endpoint it happens to coincide with.
499
- *
500
- * Looser than the manifold's warm-start match tolerance (≈0.02) because we
501
- * specifically want to dedupe contacts at the *same* point; small lateral
502
- * shifts of the capsule produce distinct contacts that should both be kept.
503
- * @type {number}
504
- */
505
- const DEDUPE_DIST_SQR = 1e-6;
506
-
507
- /**
508
- * Multi-point capsule-vs-OBB contact generation. Emits up to
509
- * {@link CAPSULE_BOX_MAX_CONTACTS} contacts into `out` in the
510
- * `(wax, way, waz, wbx, wby, wbz, nx, ny, nz, depth)` stride layout.
511
- *
512
- * The motivation: a capsule lying flat on a face needs more than one
513
- * contact to rest stably — a single contact at the segment's closest point
514
- * is positionally ambiguous (every interior segment point is equidistant
515
- * from the face), and the body wobbles around whichever point the
516
- * iterative closest-point solver happened to converge on. Two contacts at
517
- * the cap centres pin the capsule's rotation about its long axis.
518
- *
519
- * Algorithm:
520
- * 1. Closest-point-on-segment vs OBB primary contact (same as
521
- * {@link capsule_box_contact}).
522
- * 2. Treat each cap centre as a sphere of cap-radius and run
523
- * {@link sphere_box_contact} → up to two additional contacts.
524
- * 3. Dedupe spatially against the primary so a capsule touching with one
525
- * cap doesn't emit two contacts at the same point.
526
- *
527
- * @param {Float64Array} out length >= CAPSULE_BOX_MAX_CONTACTS * CAPSULE_BOX_CONTACT_STRIDE
528
- * @param {number} a_cx capsule centre x
529
- * @param {number} a_cy
530
- * @param {number} a_cz
531
- * @param {number} a_qx capsule rotation
532
- * @param {number} a_qy
533
- * @param {number} a_qz
534
- * @param {number} a_qw
535
- * @param {number} a_radius
536
- * @param {number} a_half_h
537
- * @param {number} b_cx box centre x
538
- * @param {number} b_cy
539
- * @param {number} b_cz
540
- * @param {number} b_qx
541
- * @param {number} b_qy
542
- * @param {number} b_qz
543
- * @param {number} b_qw
544
- * @param {number} b_hx
545
- * @param {number} b_hy
546
- * @param {number} b_hz
547
- * @returns {number} number of contacts emitted, in `[0, CAPSULE_BOX_MAX_CONTACTS]`
548
- */
549
- export function capsule_box_multi_contacts(
550
- out,
551
- a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
552
- b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_hx, b_hy, b_hz
553
- ) {
554
- // 1. Primary contact: closest segment point vs OBB.
555
- const primary_ok = capsule_box_contact(
556
- scratch_primary,
557
- a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
558
- b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_hx, b_hy, b_hz
559
- );
560
- if (!primary_ok) return 0;
561
-
562
- // Repack scratch_primary (normal, depth, A, B) into the candidate stride
563
- // (A, B, normal, depth) at out[0..10).
564
- const p_nx = scratch_primary[0], p_ny = scratch_primary[1], p_nz = scratch_primary[2];
565
- const p_depth = scratch_primary[3];
566
- const p_ax = scratch_primary[4], p_ay = scratch_primary[5], p_az = scratch_primary[6];
567
- const p_bx = scratch_primary[7], p_by = scratch_primary[8], p_bz = scratch_primary[9];
568
- out[0] = p_ax; out[1] = p_ay; out[2] = p_az;
569
- out[3] = p_bx; out[4] = p_by; out[5] = p_bz;
570
- out[6] = p_nx; out[7] = p_ny; out[8] = p_nz;
571
- out[9] = p_depth;
572
- let count = 1;
573
-
574
- // 2. Endpoint contacts: treat each cap centre as a sphere of cap-radius.
575
- capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
576
-
577
- for (let i = 0; i < 2; i++) {
578
- // Endpoint i lives at scratch_seg[i*3 .. i*3+2] — index directly rather
579
- // than allocating three throwaway arrays per call (hot narrowphase path).
580
- const ok = sphere_box_contact(
581
- scratch_endpoint,
582
- scratch_seg[i * 3], scratch_seg[i * 3 + 1], scratch_seg[i * 3 + 2], a_radius,
583
- b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw,
584
- b_hx, b_hy, b_hz
585
- );
586
- if (!ok) continue;
587
-
588
- const e_nx = scratch_endpoint[0], e_ny = scratch_endpoint[1], e_nz = scratch_endpoint[2];
589
- const e_depth = scratch_endpoint[3];
590
- const e_ax = scratch_endpoint[4], e_ay = scratch_endpoint[5], e_az = scratch_endpoint[6];
591
- const e_bx = scratch_endpoint[7], e_by = scratch_endpoint[8], e_bz = scratch_endpoint[9];
592
-
593
- // Dedupe against every already-emitted contact (primary, then any
594
- // prior endpoint we've already accepted). The capsule-side world
595
- // point uniquely identifies a contact for this purpose — two distinct
596
- // box-surface points always have distinct capsule-side projections
597
- // along the local-A axis.
598
- let duplicate = false;
599
- for (let k = 0; k < count; k++) {
600
- const ko = k * CAPSULE_BOX_CONTACT_STRIDE;
601
- const dx = e_ax - out[ko];
602
- const dy = e_ay - out[ko + 1];
603
- const dz = e_az - out[ko + 2];
604
- if (dx * dx + dy * dy + dz * dz < DEDUPE_DIST_SQR) { duplicate = true; break; }
605
- }
606
- if (duplicate) continue;
607
-
608
- const o = count * CAPSULE_BOX_CONTACT_STRIDE;
609
- out[o] = e_ax; out[o + 1] = e_ay; out[o + 2] = e_az;
610
- out[o + 3] = e_bx; out[o + 4] = e_by; out[o + 5] = e_bz;
611
- out[o + 6] = e_nx; out[o + 7] = e_ny; out[o + 8] = e_nz;
612
- out[o + 9] = e_depth;
613
- count++;
614
- }
615
-
616
- return count;
617
- }
1
+ import { line3_compute_segment_segment_closest_points } from "../../../core/geom/3d/line/line3_compute_segment_segment_closest_points.js";
2
+ import { line3_compute_segment_closest_point_t } from "../../../core/geom/3d/line/line3_compute_segment_closest_point_t.js";
3
+ import { line3_compute_segment_closest_point_to_aabb3_t } from "../../../core/geom/3d/line/line3_compute_segment_closest_point_to_aabb3_t.js";
4
+ import { v3_quaternion_apply } from "../../../core/geom/vec3/v3_quaternion_apply.js";
5
+ import { v3_quaternion_apply_inverse } from "../../../core/geom/vec3/v3_quaternion_apply_inverse.js";
6
+ import { sphere_box_contact } from "./sphere_box_contact.js";
7
+
8
+ /**
9
+ * Closed-form narrowphase helpers for the capsule family. A capsule is the
10
+ * Minkowski sum of a line segment and a sphere of radius `r`, so contact
11
+ * resolution reduces to:
12
+ * - capsule-sphere → point-on-segment distance, then sphere-style normal
13
+ * - capsule-capsule → segment-segment closest pair
14
+ * - capsule-box → segment-vs-OBB closest point (iterative)
15
+ *
16
+ * Output convention (matches the rest of the narrowphase family):
17
+ * out[0..2] : normal pointing from B toward A
18
+ * out[3] : penetration depth (positive)
19
+ * out[4..6] : world contact on A's surface
20
+ * out[7..9] : world contact on B's surface
21
+ *
22
+ * @author Alex Goldring
23
+ * @copyright Company Named Limited (c) 2026
24
+ */
25
+
26
+ const scratch_st = new Float64Array(2);
27
+
28
+ const scratch_seg = new Float64Array(6);
29
+
30
+ /**
31
+ * Compute the two world endpoints of a capsule's central segment given its
32
+ * pose. The capsule is Y-aligned in body frame; the segment runs from
33
+ * `(0, -h/2, 0)` to `(0, +h/2, 0)`. Writes endpoints into `out` as
34
+ * `[ax, ay, az, bx, by, bz]`.
35
+ *
36
+ * @param {number[]|Float64Array} out length >= 6
37
+ * @param {number} cx capsule centre x
38
+ * @param {number} cy
39
+ * @param {number} cz
40
+ * @param {number} qx quaternion x
41
+ * @param {number} qy
42
+ * @param {number} qz
43
+ * @param {number} qw
44
+ * @param {number} half_height
45
+ */
46
+ export function capsule_world_segment(out, cx, cy, cz, qx, qy, qz, qw, half_height) {
47
+ v3_quaternion_apply(out, 0, 0, -half_height, 0, qx, qy, qz, qw);
48
+ v3_quaternion_apply(out, 3, 0, half_height, 0, qx, qy, qz, qw);
49
+ out[0] += cx; out[1] += cy; out[2] += cz;
50
+ out[3] += cx; out[4] += cy; out[5] += cz;
51
+ }
52
+
53
+ // --- capsule vs sphere ------------------------------------------------------
54
+
55
+ /**
56
+ * Capsule (A) vs sphere (B) contact, closed-form via point-segment distance.
57
+ *
58
+ * @param {number[]|Float64Array} out length >= 10
59
+ * @param {number} a_cx capsule centre x
60
+ * @param {number} a_cy
61
+ * @param {number} a_cz
62
+ * @param {number} a_qx capsule rotation
63
+ * @param {number} a_qy
64
+ * @param {number} a_qz
65
+ * @param {number} a_qw
66
+ * @param {number} a_radius
67
+ * @param {number} a_half_h capsule half-height (not including caps)
68
+ * @param {number} b_cx sphere centre x
69
+ * @param {number} b_cy
70
+ * @param {number} b_cz
71
+ * @param {number} b_radius
72
+ * @returns {boolean} true on overlap
73
+ */
74
+ export function capsule_sphere_contact(
75
+ out,
76
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
77
+ b_cx, b_cy, b_cz, b_radius
78
+ ) {
79
+ capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
80
+ const sax = scratch_seg[0], say = scratch_seg[1], saz = scratch_seg[2];
81
+ const sbx = scratch_seg[3], sby = scratch_seg[4], sbz = scratch_seg[5];
82
+
83
+ const t = line3_compute_segment_closest_point_t(sax, say, saz, sbx, sby, sbz, b_cx, b_cy, b_cz);
84
+
85
+ const px = sax + (sbx - sax) * t;
86
+ const py = say + (sby - say) * t;
87
+ const pz = saz + (sbz - saz) * t;
88
+
89
+ const dx = px - b_cx;
90
+ const dy = py - b_cy;
91
+ const dz = pz - b_cz;
92
+ const dist_sqr = dx * dx + dy * dy + dz * dz;
93
+ const sum = a_radius + b_radius;
94
+ if (dist_sqr >= sum * sum) return false;
95
+
96
+ const dist = Math.sqrt(dist_sqr);
97
+ let nx, ny, nz;
98
+ if (dist > 0) {
99
+ const inv = 1 / dist;
100
+ nx = dx * inv; ny = dy * inv; nz = dz * inv;
101
+ } else {
102
+ // Sphere centre exactly on the capsule segment — pick a deterministic tie-break.
103
+ nx = 1; ny = 0; nz = 0;
104
+ }
105
+
106
+ out[0] = nx; out[1] = ny; out[2] = nz; // normal from B to A
107
+ out[3] = sum - dist;
108
+ // World contact on A (capsule): segment point pushed back by capsule radius along -normal
109
+ out[4] = px - nx * a_radius;
110
+ out[5] = py - ny * a_radius;
111
+ out[6] = pz - nz * a_radius;
112
+ // World contact on B (sphere): sphere centre pushed along +normal by sphere radius
113
+ out[7] = b_cx + nx * b_radius;
114
+ out[8] = b_cy + ny * b_radius;
115
+ out[9] = b_cz + nz * b_radius;
116
+ return true;
117
+ }
118
+
119
+ // --- capsule vs capsule -----------------------------------------------------
120
+
121
+ const scratch_seg_b = new Float64Array(6);
122
+
123
+ /**
124
+ * Two capsules (A and B). Reduces to segment-segment closest pair + radius.
125
+ *
126
+ * @param {number[]|Float64Array} out length >= 10
127
+ * @returns {boolean} true on overlap
128
+ */
129
+ export function capsule_capsule_contact(
130
+ out,
131
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
132
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_radius, b_half_h
133
+ ) {
134
+ capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
135
+ capsule_world_segment(scratch_seg_b, b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_half_h);
136
+
137
+ const a0x = scratch_seg[0], a0y = scratch_seg[1], a0z = scratch_seg[2];
138
+ const a1x = scratch_seg[3], a1y = scratch_seg[4], a1z = scratch_seg[5];
139
+ const b0x = scratch_seg_b[0], b0y = scratch_seg_b[1], b0z = scratch_seg_b[2];
140
+ const b1x = scratch_seg_b[3], b1y = scratch_seg_b[4], b1z = scratch_seg_b[5];
141
+
142
+ line3_compute_segment_segment_closest_points(
143
+ scratch_st,
144
+ a0x, a0y, a0z, a1x, a1y, a1z,
145
+ b0x, b0y, b0z, b1x, b1y, b1z
146
+ );
147
+
148
+ const s = scratch_st[0];
149
+ const t = scratch_st[1];
150
+
151
+ const pax = a0x + (a1x - a0x) * s;
152
+ const pay = a0y + (a1y - a0y) * s;
153
+ const paz = a0z + (a1z - a0z) * s;
154
+ const pbx = b0x + (b1x - b0x) * t;
155
+ const pby = b0y + (b1y - b0y) * t;
156
+ const pbz = b0z + (b1z - b0z) * t;
157
+
158
+ const dx = pax - pbx;
159
+ const dy = pay - pby;
160
+ const dz = paz - pbz;
161
+ const dist_sqr = dx * dx + dy * dy + dz * dz;
162
+ const sum = a_radius + b_radius;
163
+ if (dist_sqr >= sum * sum) return false;
164
+
165
+ const dist = Math.sqrt(dist_sqr);
166
+ let nx, ny, nz;
167
+ if (dist > 0) {
168
+ const inv = 1 / dist;
169
+ nx = dx * inv; ny = dy * inv; nz = dz * inv;
170
+ } else {
171
+ // Segments touch — fall back to the world-frame direction from B's
172
+ // segment centre toward A's segment centre as a tie-break.
173
+ const acx = (a0x + a1x) * 0.5;
174
+ const acy = (a0y + a1y) * 0.5;
175
+ const acz = (a0z + a1z) * 0.5;
176
+ const bcx = (b0x + b1x) * 0.5;
177
+ const bcy = (b0y + b1y) * 0.5;
178
+ const bcz = (b0z + b1z) * 0.5;
179
+ const ddx = acx - bcx, ddy = acy - bcy, ddz = acz - bcz;
180
+ const dd_sqr = ddx * ddx + ddy * ddy + ddz * ddz;
181
+ if (dd_sqr > 0) {
182
+ const inv2 = 1 / Math.sqrt(dd_sqr);
183
+ nx = ddx * inv2; ny = ddy * inv2; nz = ddz * inv2;
184
+ } else {
185
+ nx = 1; ny = 0; nz = 0;
186
+ }
187
+ }
188
+
189
+ out[0] = nx; out[1] = ny; out[2] = nz;
190
+ out[3] = sum - dist;
191
+ out[4] = pax - nx * a_radius;
192
+ out[5] = pay - ny * a_radius;
193
+ out[6] = paz - nz * a_radius;
194
+ out[7] = pbx + nx * b_radius;
195
+ out[8] = pby + ny * b_radius;
196
+ out[9] = pbz + nz * b_radius;
197
+ return true;
198
+ }
199
+
200
+ /**
201
+ * Output stride per contact in {@link capsule_capsule_multi_contacts} —
202
+ * matches {@link CAPSULE_BOX_CONTACT_STRIDE}:
203
+ * 0..2 : world contact on capsule A side
204
+ * 3..5 : world contact on capsule B side
205
+ * 6..8 : normal from B toward A
206
+ * 9 : depth (positive = penetration)
207
+ * @type {number}
208
+ */
209
+ export const CAPSULE_CAPSULE_CONTACT_STRIDE = 10;
210
+
211
+ /**
212
+ * Maximum contacts {@link capsule_capsule_multi_contacts} can emit (the two
213
+ * ends of the parallel-overlap interval).
214
+ * @type {number}
215
+ */
216
+ export const CAPSULE_CAPSULE_MAX_CONTACTS = 2;
217
+
218
+ /**
219
+ * Squared-sine threshold for treating two capsule axes as parallel: below
220
+ * ~2.5 degrees the single closest-point contact is ambiguous along the
221
+ * overlap interval (the solver sees a point contact with a bogus lever arm
222
+ * and stacked capsules wobble), so the manifold switches to two contacts at
223
+ * the interval ends.
224
+ * @type {number}
225
+ */
226
+ const CAPSULE_PARALLEL_SIN_SQR = 0.002;
227
+
228
+ /**
229
+ * Capsule-vs-capsule with a parallel-aware multi-point manifold: NEAR-PARALLEL
230
+ * overlapping capsules emit one contact at each end of their axial overlap
231
+ * interval (the two-point support a resting capsule physically has); every
232
+ * other configuration emits the single closest-point contact of
233
+ * {@link capsule_capsule_contact}.
234
+ *
235
+ * @param {number[]|Float64Array} out length >= 2 * CAPSULE_CAPSULE_CONTACT_STRIDE
236
+ * @returns {number} number of contacts written (0 = no overlap)
237
+ */
238
+ export function capsule_capsule_multi_contacts(
239
+ out,
240
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
241
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_radius, b_half_h
242
+ ) {
243
+ capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
244
+ capsule_world_segment(scratch_seg_b, b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_half_h);
245
+
246
+ const a0x = scratch_seg[0], a0y = scratch_seg[1], a0z = scratch_seg[2];
247
+ const a1x = scratch_seg[3], a1y = scratch_seg[4], a1z = scratch_seg[5];
248
+ const b0x = scratch_seg_b[0], b0y = scratch_seg_b[1], b0z = scratch_seg_b[2];
249
+ const b1x = scratch_seg_b[3], b1y = scratch_seg_b[4], b1z = scratch_seg_b[5];
250
+
251
+ const d1x = a1x - a0x, d1y = a1y - a0y, d1z = a1z - a0z;
252
+ const d2x = b1x - b0x, d2y = b1y - b0y, d2z = b1z - b0z;
253
+ const len1_sqr = d1x * d1x + d1y * d1y + d1z * d1z;
254
+ const len2_sqr = d2x * d2x + d2y * d2y + d2z * d2z;
255
+
256
+ const cx = d1y * d2z - d1z * d2y;
257
+ const cy = d1z * d2x - d1x * d2z;
258
+ const cz = d1x * d2y - d1y * d2x;
259
+ const cross_sqr = cx * cx + cy * cy + cz * cz;
260
+
261
+ const sum = a_radius + b_radius;
262
+
263
+ // Near-parallel with real segments: try the two-end manifold.
264
+ if (len1_sqr > 0 && len2_sqr > 0
265
+ && cross_sqr < CAPSULE_PARALLEL_SIN_SQR * len1_sqr * len2_sqr) {
266
+
267
+ const inv_len1 = 1 / Math.sqrt(len1_sqr);
268
+ const ux = d1x * inv_len1, uy = d1y * inv_len1, uz = d1z * inv_len1;
269
+
270
+ // B's endpoints parameterised along A's axis (origin a0).
271
+ const t0 = (b0x - a0x) * ux + (b0y - a0y) * uy + (b0z - a0z) * uz;
272
+ const t1 = (b1x - a0x) * ux + (b1y - a0y) * uy + (b1z - a0z) * uz;
273
+ const len1 = Math.sqrt(len1_sqr);
274
+ const lo = Math.max(0, Math.min(t0, t1));
275
+ const hi = Math.min(len1, Math.max(t0, t1));
276
+
277
+ if (hi > lo) {
278
+ // Direction along B for projecting A-axis points onto B.
279
+ const inv_len2_sqr = 1 / len2_sqr;
280
+ let n_written = 0;
281
+ for (let e = 0; e < 2; e++) {
282
+ const sA = e === 0 ? lo : hi;
283
+ const pax = a0x + ux * sA;
284
+ const pay = a0y + uy * sA;
285
+ const paz = a0z + uz * sA;
286
+ // Closest point on segment B to pa.
287
+ let tB = ((pax - b0x) * d2x + (pay - b0y) * d2y + (paz - b0z) * d2z) * inv_len2_sqr;
288
+ tB = tB < 0 ? 0 : (tB > 1 ? 1 : tB);
289
+ const pbx = b0x + d2x * tB;
290
+ const pby = b0y + d2y * tB;
291
+ const pbz = b0z + d2z * tB;
292
+
293
+ const dx = pax - pbx, dy = pay - pby, dz = paz - pbz;
294
+ const dist_sqr = dx * dx + dy * dy + dz * dz;
295
+ if (dist_sqr >= sum * sum) continue;
296
+ const dist = Math.sqrt(dist_sqr);
297
+
298
+ let nx, ny, nz;
299
+ if (dist > 0) {
300
+ const inv = 1 / dist;
301
+ nx = dx * inv; ny = dy * inv; nz = dz * inv;
302
+ } else {
303
+ // Axes coincide at this point - centre tie-break.
304
+ const ddx = a_cx - b_cx, ddy = a_cy - b_cy, ddz = a_cz - b_cz;
305
+ const dd = ddx * ddx + ddy * ddy + ddz * ddz;
306
+ if (dd > 0) {
307
+ const inv2 = 1 / Math.sqrt(dd);
308
+ nx = ddx * inv2; ny = ddy * inv2; nz = ddz * inv2;
309
+ } else {
310
+ nx = 1; ny = 0; nz = 0;
311
+ }
312
+ }
313
+
314
+ const off = n_written * CAPSULE_CAPSULE_CONTACT_STRIDE;
315
+ out[off] = pax - nx * a_radius;
316
+ out[off + 1] = pay - ny * a_radius;
317
+ out[off + 2] = paz - nz * a_radius;
318
+ out[off + 3] = pbx + nx * b_radius;
319
+ out[off + 4] = pby + ny * b_radius;
320
+ out[off + 5] = pbz + nz * b_radius;
321
+ out[off + 6] = nx;
322
+ out[off + 7] = ny;
323
+ out[off + 8] = nz;
324
+ out[off + 9] = sum - dist;
325
+ n_written++;
326
+ }
327
+ if (n_written > 0) return n_written;
328
+ // Both interval ends are out of reach — but the two-end sampling is a REFINEMENT,
329
+ // not a detection gate. For a non-zero inter-axis angle the segment-segment distance
330
+ // is strictly convex along the interval with its minimum in the INTERIOR, so the ends
331
+ // being out of reach does not imply the whole interval is. Fall through to the exact
332
+ // single-closest-point path below (which correctly returns no contact for genuinely
333
+ // parallel axes, where the distance is constant).
334
+ }
335
+ // Degenerate interval (axially offset end-to-end) - single contact below.
336
+ }
337
+
338
+ // General case: single closest-point contact.
339
+ if (!capsule_capsule_contact(
340
+ scratch_single,
341
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
342
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_radius, b_half_h
343
+ )) {
344
+ return 0;
345
+ }
346
+ out[0] = scratch_single[4];
347
+ out[1] = scratch_single[5];
348
+ out[2] = scratch_single[6];
349
+ out[3] = scratch_single[7];
350
+ out[4] = scratch_single[8];
351
+ out[5] = scratch_single[9];
352
+ out[6] = scratch_single[0];
353
+ out[7] = scratch_single[1];
354
+ out[8] = scratch_single[2];
355
+ out[9] = scratch_single[3];
356
+ return 1;
357
+ }
358
+
359
+ const scratch_single = new Float64Array(10);
360
+
361
+ // --- capsule vs oriented box ------------------------------------------------
362
+
363
+ const scratch_a0_local = new Float64Array(3);
364
+ const scratch_a1_local = new Float64Array(3);
365
+
366
+ /**
367
+ * Capsule (A) vs oriented box (B). Brings the capsule segment into box-local
368
+ * space, then refines via 2 fixed-point iterations between:
369
+ * - closest point on the segment to the current box-side candidate
370
+ * - clamped point on the box closest to the current segment-side candidate
371
+ *
372
+ * Two iterations suffice for the cases this engine targets (sphere-like cap
373
+ * geometry against axis-aligned-in-local box). When the segment passes
374
+ * through the box, the "inside" branch picks the smallest-overlap face
375
+ * deterministically, mirroring {@link sphere_box_contact}.
376
+ *
377
+ * @param {number[]|Float64Array} out length >= 10
378
+ * @returns {boolean}
379
+ */
380
+ export function capsule_box_contact(
381
+ out,
382
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
383
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_hx, b_hy, b_hz
384
+ ) {
385
+ // Bring the capsule's segment endpoints into box-local space: build them in
386
+ // world first (from the capsule centre + rotated half-height axis), then map
387
+ // world box-local below.
388
+ capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
389
+ // World → box-local: subtract box centre, then rotate by conjugate of box quat.
390
+ const w_a0x = scratch_seg[0] - b_cx, w_a0y = scratch_seg[1] - b_cy, w_a0z = scratch_seg[2] - b_cz;
391
+ const w_a1x = scratch_seg[3] - b_cx, w_a1y = scratch_seg[4] - b_cy, w_a1z = scratch_seg[5] - b_cz;
392
+ v3_quaternion_apply_inverse(scratch_a0_local, 0, w_a0x, w_a0y, w_a0z, b_qx, b_qy, b_qz, b_qw);
393
+ v3_quaternion_apply_inverse(scratch_a1_local, 0, w_a1x, w_a1y, w_a1z, b_qx, b_qy, b_qz, b_qw);
394
+
395
+ const a0lx = scratch_a0_local[0], a0ly = scratch_a0_local[1], a0lz = scratch_a0_local[2];
396
+ const a1lx = scratch_a1_local[0], a1ly = scratch_a1_local[1], a1lz = scratch_a1_local[2];
397
+
398
+ // Exact closest point on the capsule segment to the box-local AABB [−h, h].
399
+ // Replaces a 2-iteration alternating projection (project onto segment, clamp
400
+ // into box, repeat) that converged too slowly for capsules near-parallel to
401
+ // a box face/edge — overestimating the segment-vs-box distance, which
402
+ // under-detected contacts (~0.85% of random configs missed) and mis-placed
403
+ // depth/normal on many more. See core/geom/3d/gjk/GJK_REVIEW_NOTES.md.
404
+ const t = line3_compute_segment_closest_point_to_aabb3_t(
405
+ a0lx, a0ly, a0lz, a1lx, a1ly, a1lz,
406
+ -b_hx, -b_hy, -b_hz, b_hx, b_hy, b_hz
407
+ );
408
+ const plx = a0lx + (a1lx - a0lx) * t;
409
+ const ply = a0ly + (a1ly - a0ly) * t;
410
+ const plz = a0lz + (a1lz - a0lz) * t;
411
+
412
+ // Final box-side point. `let` because the interior branch snaps it onto
413
+ // the chosen face — for an inside segment point the clamp is an identity.
414
+ let qlx = plx < -b_hx ? -b_hx : (plx > b_hx ? b_hx : plx);
415
+ let qly = ply < -b_hy ? -b_hy : (ply > b_hy ? b_hy : ply);
416
+ let qlz = plz < -b_hz ? -b_hz : (plz > b_hz ? b_hz : plz);
417
+ const inside = qlx === plx && qly === ply && qlz === plz;
418
+
419
+ let nlx, nly, nlz, dist;
420
+ if (!inside) {
421
+ const ex = plx - qlx, ey = ply - qly, ez = plz - qlz;
422
+ const d_sqr = ex * ex + ey * ey + ez * ez;
423
+ if (d_sqr >= a_radius * a_radius) return false;
424
+ dist = Math.sqrt(d_sqr);
425
+ if (dist > 0) {
426
+ const inv = 1 / dist;
427
+ nlx = ex * inv; nly = ey * inv; nlz = ez * inv;
428
+ } else {
429
+ nlx = 1; nly = 0; nlz = 0;
430
+ }
431
+ } else {
432
+ // Segment point is inside the box. Pick the smallest-overlap face and
433
+ // snap the box witness onto it, so the reported box contact lies on
434
+ // the SURFACE and is consistent with the normal/depth — not left at
435
+ // the interior segment point, which hands the solver a wrong lever
436
+ // arm exactly in deep penetration. Mirrors sphere_box_contact's
437
+ // interior branch.
438
+ const dxf = b_hx - Math.abs(plx);
439
+ const dyf = b_hy - Math.abs(ply);
440
+ const dzf = b_hz - Math.abs(plz);
441
+ if (dxf <= dyf && dxf <= dzf) {
442
+ nlx = plx >= 0 ? 1 : -1; nly = 0; nlz = 0; dist = -dxf;
443
+ qlx = plx >= 0 ? b_hx : -b_hx;
444
+ } else if (dyf <= dzf) {
445
+ nlx = 0; nly = ply >= 0 ? 1 : -1; nlz = 0; dist = -dyf;
446
+ qly = ply >= 0 ? b_hy : -b_hy;
447
+ } else {
448
+ nlx = 0; nly = 0; nlz = plz >= 0 ? 1 : -1; dist = -dzf;
449
+ qlz = plz >= 0 ? b_hz : -b_hz;
450
+ }
451
+ }
452
+
453
+ // Normal (box capsule axis point) into world.
454
+ v3_quaternion_apply(out, 0, nlx, nly, nlz, b_qx, b_qy, b_qz, b_qw);
455
+ const nx = out[0], ny = out[1], nz = out[2];
456
+ out[3] = a_radius - dist;
457
+
458
+ // Capsule-side contact: world segment point pushed back by radius.
459
+ v3_quaternion_apply(out, 4, plx, ply, plz, b_qx, b_qy, b_qz, b_qw);
460
+ out[4] += b_cx - nx * a_radius;
461
+ out[5] += b_cy - ny * a_radius;
462
+ out[6] += b_cz - nz * a_radius;
463
+
464
+ // Box-side contact: world projection of the box-surface point.
465
+ v3_quaternion_apply(out, 7, qlx, qly, qlz, b_qx, b_qy, b_qz, b_qw);
466
+ out[7] += b_cx;
467
+ out[8] += b_cy;
468
+ out[9] += b_cz;
469
+
470
+ return true;
471
+ }
472
+
473
+ // --- capsule vs oriented box, multi-point manifold --------------------------
474
+
475
+ /**
476
+ * Output stride per contact in {@link capsule_box_multi_contacts}.
477
+ * Matches the candidate-buffer layout used by `narrowphase_step`.
478
+ *
479
+ * 0..2 : world contact on capsule side
480
+ * 3..5 : world contact on box side
481
+ * 6..8 : normal from box (B) toward capsule (A)
482
+ * 9 : depth (positive = penetration)
483
+ *
484
+ * @type {number}
485
+ */
486
+ export const CAPSULE_BOX_CONTACT_STRIDE = 10;
487
+
488
+ /**
489
+ * Maximum contact points {@link capsule_box_multi_contacts} can emit.
490
+ * - 1 from the closest-point-on-segment vs OBB query (primary)
491
+ * - up to 2 from the cap-centre sphere-vs-OBB queries (one per endpoint)
492
+ * @type {number}
493
+ */
494
+ export const CAPSULE_BOX_MAX_CONTACTS = 3;
495
+
496
+ const scratch_primary = new Float64Array(10);
497
+ const scratch_endpoint = new Float64Array(10);
498
+
499
+ /**
500
+ * Two world positions are treated as the same contact when their squared
501
+ * distance is below this threshold. Picked so that a capsule resting flat
502
+ * doesn't double up the primary closest-segment-point contact with whichever
503
+ * endpoint it happens to coincide with.
504
+ *
505
+ * Looser than the manifold's warm-start match tolerance (≈0.02) because we
506
+ * specifically want to dedupe contacts at the *same* point; small lateral
507
+ * shifts of the capsule produce distinct contacts that should both be kept.
508
+ * @type {number}
509
+ */
510
+ const DEDUPE_DIST_SQR = 1e-6;
511
+
512
+ /**
513
+ * Multi-point capsule-vs-OBB contact generation. Emits up to
514
+ * {@link CAPSULE_BOX_MAX_CONTACTS} contacts into `out` in the
515
+ * `(wax, way, waz, wbx, wby, wbz, nx, ny, nz, depth)` stride layout.
516
+ *
517
+ * The motivation: a capsule lying flat on a face needs more than one
518
+ * contact to rest stably — a single contact at the segment's closest point
519
+ * is positionally ambiguous (every interior segment point is equidistant
520
+ * from the face), and the body wobbles around whichever point the
521
+ * iterative closest-point solver happened to converge on. Two contacts at
522
+ * the cap centres pin the capsule's rotation about its long axis.
523
+ *
524
+ * Algorithm:
525
+ * 1. Closest-point-on-segment vs OBB primary contact (same as
526
+ * {@link capsule_box_contact}).
527
+ * 2. Treat each cap centre as a sphere of cap-radius and run
528
+ * {@link sphere_box_contact} up to two additional contacts.
529
+ * 3. Dedupe spatially against the primary so a capsule touching with one
530
+ * cap doesn't emit two contacts at the same point.
531
+ *
532
+ * @param {Float64Array} out length >= CAPSULE_BOX_MAX_CONTACTS * CAPSULE_BOX_CONTACT_STRIDE
533
+ * @param {number} a_cx capsule centre x
534
+ * @param {number} a_cy
535
+ * @param {number} a_cz
536
+ * @param {number} a_qx capsule rotation
537
+ * @param {number} a_qy
538
+ * @param {number} a_qz
539
+ * @param {number} a_qw
540
+ * @param {number} a_radius
541
+ * @param {number} a_half_h
542
+ * @param {number} b_cx box centre x
543
+ * @param {number} b_cy
544
+ * @param {number} b_cz
545
+ * @param {number} b_qx
546
+ * @param {number} b_qy
547
+ * @param {number} b_qz
548
+ * @param {number} b_qw
549
+ * @param {number} b_hx
550
+ * @param {number} b_hy
551
+ * @param {number} b_hz
552
+ * @returns {number} number of contacts emitted, in `[0, CAPSULE_BOX_MAX_CONTACTS]`
553
+ */
554
+ export function capsule_box_multi_contacts(
555
+ out,
556
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
557
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_hx, b_hy, b_hz
558
+ ) {
559
+ // 1. Primary contact: closest segment point vs OBB.
560
+ const primary_ok = capsule_box_contact(
561
+ scratch_primary,
562
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
563
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_hx, b_hy, b_hz
564
+ );
565
+ if (!primary_ok) return 0;
566
+
567
+ // Repack scratch_primary (normal, depth, A, B) into the candidate stride
568
+ // (A, B, normal, depth) at out[0..10).
569
+ const p_nx = scratch_primary[0], p_ny = scratch_primary[1], p_nz = scratch_primary[2];
570
+ const p_depth = scratch_primary[3];
571
+ const p_ax = scratch_primary[4], p_ay = scratch_primary[5], p_az = scratch_primary[6];
572
+ const p_bx = scratch_primary[7], p_by = scratch_primary[8], p_bz = scratch_primary[9];
573
+ out[0] = p_ax; out[1] = p_ay; out[2] = p_az;
574
+ out[3] = p_bx; out[4] = p_by; out[5] = p_bz;
575
+ out[6] = p_nx; out[7] = p_ny; out[8] = p_nz;
576
+ out[9] = p_depth;
577
+ let count = 1;
578
+
579
+ // 2. Endpoint contacts: treat each cap centre as a sphere of cap-radius.
580
+ capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
581
+
582
+ for (let i = 0; i < 2; i++) {
583
+ // Endpoint i lives at scratch_seg[i*3 .. i*3+2] — index directly rather
584
+ // than allocating three throwaway arrays per call (hot narrowphase path).
585
+ const ok = sphere_box_contact(
586
+ scratch_endpoint,
587
+ scratch_seg[i * 3], scratch_seg[i * 3 + 1], scratch_seg[i * 3 + 2], a_radius,
588
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw,
589
+ b_hx, b_hy, b_hz
590
+ );
591
+ if (!ok) continue;
592
+
593
+ const e_nx = scratch_endpoint[0], e_ny = scratch_endpoint[1], e_nz = scratch_endpoint[2];
594
+ const e_depth = scratch_endpoint[3];
595
+ const e_ax = scratch_endpoint[4], e_ay = scratch_endpoint[5], e_az = scratch_endpoint[6];
596
+ const e_bx = scratch_endpoint[7], e_by = scratch_endpoint[8], e_bz = scratch_endpoint[9];
597
+
598
+ // Dedupe against every already-emitted contact (primary, then any
599
+ // prior endpoint we've already accepted). The capsule-side world
600
+ // point uniquely identifies a contact for this purpose — two distinct
601
+ // box-surface points always have distinct capsule-side projections
602
+ // along the local-A axis.
603
+ let duplicate = false;
604
+ for (let k = 0; k < count; k++) {
605
+ const ko = k * CAPSULE_BOX_CONTACT_STRIDE;
606
+ const dx = e_ax - out[ko];
607
+ const dy = e_ay - out[ko + 1];
608
+ const dz = e_az - out[ko + 2];
609
+ if (dx * dx + dy * dy + dz * dz < DEDUPE_DIST_SQR) { duplicate = true; break; }
610
+ }
611
+ if (duplicate) continue;
612
+
613
+ const o = count * CAPSULE_BOX_CONTACT_STRIDE;
614
+ out[o] = e_ax; out[o + 1] = e_ay; out[o + 2] = e_az;
615
+ out[o + 3] = e_bx; out[o + 4] = e_by; out[o + 5] = e_bz;
616
+ out[o + 6] = e_nx; out[o + 7] = e_ny; out[o + 8] = e_nz;
617
+ out[o + 9] = e_depth;
618
+ count++;
619
+ }
620
+
621
+ return count;
622
+ }