@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,568 +1,632 @@
1
- import { line3_compute_segment_segment_closest_points } from "../../../core/geom/3d/line/line3_compute_segment_segment_closest_points.js";
2
- import { v3_centroid_v3_buffer } from "../../../core/geom/vec3/v3_centroid_v3_buffer.js";
3
- import { v3_dot } from "../../../core/geom/vec3/v3_dot.js";
4
- import { v3_length } from "../../../core/geom/vec3/v3_length.js";
5
- import { v3_quaternion_apply } from "../../../core/geom/vec3/v3_quaternion_apply.js";
6
- import { reduce_manifold_contacts } from "./reduce_manifold_contacts.js";
7
-
8
- /**
9
- * Multi-point contact manifold between two convex polytopes with **polygon
10
- * faces**, computed entirely from the current poses — no cross-frame state, so
11
- * it preserves reset-and-resimulate (rollback) determinism.
12
- *
13
- * A piece is described by:
14
- * - `vertices` : Float32Array, flat (x,y,z) per vertex, local frame
15
- * - `face_offsets` : Uint32Array length F+1, CSR offsets into `face_loops`
16
- * - `face_loops` : Uint32Array, each face's vertex indices, ordered CCW so
17
- * the face normal (from its first three loop verts) points
18
- * outward.
19
- * A triangle-faced piece (a tetrahedron) is just the special case where every
20
- * face loop has length 3; a merged/box piece has quads or larger polygons.
21
- * Handling polygon faces directly is what lets a flat face produce a full
22
- * face-on-face patch instead of mismatched triangle slivers.
23
- *
24
- * The separating axis comes from SAT (the structure mirrors Bullet's
25
- * `clipHullAgainstHull`, which clips around a `separatingNormal`). A GJK+EPA
26
- * axis source was prototyped — Bullet sources the normal from EITHER SAT OR
27
- * `btGjkPairDetector`, the source being orthogonal to the clip — but this
28
- * engine's EPA returns a non-minimal, non-scaling axis for polytopes (a 0.05 m
29
- * overlap reports ~0.8 m depth), so clipping around it produces a garbage
30
- * manifold. SAT is exact and, for the low-poly hulls authored as collision
31
- * proxies and the small pieces of a decomposed mesh, cheap. See memory:
32
- * feedback_epa_unreliable_polytopes.
33
- *
34
- * Algorithm (general form of {@link box_box_manifold}):
35
- * 1. SAT over every face normal of A, every face normal of B, and every
36
- * edge(A)×edge(B) cross finds the minimum-translation axis `n` (B→A).
37
- * 2. Face-axis winner ⇒ reference face = the polygon that owns the axis;
38
- * incident face = the polygon on the other piece most antiparallel to the
39
- * reference outward normal. Clip the incident polygon against the reference
40
- * polygon's side planes (3-D Sutherland–Hodgman) and keep penetrating points.
41
- * 3. Edge-axis winner ⇒ a single deepest support-pair contact.
42
- * 4. Reduce survivors to ≤ {@link MAX_CONTACTS} (deepest + spread).
43
- *
44
- * Output layout (matches {@link box_box_manifold}):
45
- * out[0..2] : world normal (B→A)
46
- * out[3] : contact count (0 .. MAX_CONTACTS)
47
- * out[4 + k*7 + 0..2] : world contact on A's surface
48
- * out[4 + k*7 + 3..5] : world contact on B's surface
49
- * out[4 + k*7 + 6] : penetration depth (positive)
50
- *
51
- * @author Alex Goldring
52
- * @copyright Company Named Limited (c) 2026
53
- */
54
-
55
- const MAX_CONTACTS = 4;
56
- const CONTACT_STRIDE = 7;
57
- export const CONVEX_CONVEX_OUT_LENGTH = 4 + MAX_CONTACTS * CONTACT_STRIDE;
58
-
59
- const INITIAL_V = 256; // initial world-vertex scratch capacity (verts per piece/hull)
60
- const MAX_POLY = 64; // polygon verts during clipping
61
-
62
- const TIE_REL = 0.02;
63
- const TIE_ABS = 1e-5;
64
- const PARALLEL_EPS = 1e-9;
65
-
66
- // --- scratch ----------------------------------------------------------------
67
- // World-vertex buffers. `let` + grow-on-demand: a convex MESH routed as a single
68
- // hull (get_mesh_convex_hull) can have far more than the initial capacity of
69
- // surface vertices (a subdivided icosphere is hundreds). Without the grow, the
70
- // excess writes were silently dropped and SAT/clip read NaN past the end,
71
- // computing a truncated (wrong) manifold against part of the hull.
72
- let wvA = new Float64Array(INITIAL_V * 3);
73
- let wvB = new Float64Array(INITIAL_V * 3);
74
- // Clipping scratch — `let` + grow-on-demand like wvA/wvB: a coplanar-merged
75
- // face (e.g. a tessellated cylinder cap routed through get_mesh_convex_hull)
76
- // can be wider than MAX_POLY, and each side-plane clip can add one more
77
- // vertex. emit_face_manifold sizes these to inc_len + ref_len before use.
78
- let poly_in = new Float64Array(MAX_POLY * 3);
79
- let poly_out = new Float64Array(MAX_POLY * 3);
80
- let cand = new Float64Array(MAX_POLY * 4);
81
- const cenA = new Float64Array(3);
82
- const cenB = new Float64Array(3);
83
- const tmp_n = new Float64Array(3);
84
-
85
- const sat = { overlap: Infinity, nx: 0, ny: 0, nz: 0, kind: -1, face: -1 };
86
-
87
- // --- per-call geometry refs (single-thread re-entrancy, like the scratch) ---
88
- let g_foA, g_flA, g_foB, g_flB, g_fA, g_fB, g_nA, g_nB;
89
-
90
- function set_geom(A, B) {
91
- g_nA = A.vertices.length / 3; g_nB = B.vertices.length / 3;
92
- g_foA = A.face_offsets; g_flA = A.face_loops; g_fA = g_foA.length - 1;
93
- g_foB = B.face_offsets; g_flB = B.face_loops; g_fB = g_foB.length - 1;
94
- // Grow the world-vertex scratch to fit, so large hulls aren't truncated.
95
- if (wvA.length < g_nA * 3) wvA = new Float64Array(g_nA * 3);
96
- if (wvB.length < g_nB * 3) wvB = new Float64Array(g_nB * 3);
97
- }
98
-
99
- function load_world(out, verts, n, p, q) {
100
- for (let i = 0; i < n; i++) {
101
- v3_quaternion_apply(out, i * 3, verts[i * 3], verts[i * 3 + 1], verts[i * 3 + 2], q.x, q.y, q.z, q.w);
102
- out[i * 3] += p.x; out[i * 3 + 1] += p.y; out[i * 3 + 2] += p.z;
103
- }
104
- }
105
-
106
- /**
107
- * Outward normal of a polygon face (Newell's method over the whole loop, world).
108
- * Robust against collinear consecutive vertices, unlike a first-three cross.
109
- */
110
- function face_normal(out, wv, loops, off, end) {
111
- let nx = 0, ny = 0, nz = 0;
112
- for (let i = off; i < end; i++) {
113
- const p = loops[i] * 3, q = loops[i + 1 < end ? i + 1 : off] * 3;
114
- nx += (wv[p + 1] - wv[q + 1]) * (wv[p + 2] + wv[q + 2]);
115
- ny += (wv[p + 2] - wv[q + 2]) * (wv[p] + wv[q]);
116
- nz += (wv[p] - wv[q]) * (wv[p + 1] + wv[q + 1]);
117
- }
118
- out[0] = nx; out[1] = ny; out[2] = nz;
119
- }
120
-
121
- /**
122
- * Unique edges of a hull piece as vertex-index pairs `(v0, v1)`, flat in a
123
- * Uint32Array, cached on the (immutable) piece as `__sat_edges` built on
124
- * first use, like `get_mesh_convex_hull`'s cache (D4).
125
- *
126
- * The SAT edge×edge loop used to enumerate every FACE-LOOP edge of A
127
- * against every face-loop edge of B; an interior edge of a closed hull
128
- * borders exactly two faces, so each unique edge pair was tested up to 4×,
129
- * each test paying a full O(nA + nB) interval projection. Deduplication
130
- * cuts the dominant quartic term ~4×.
131
- *
132
- * Order and orientation are FIRST-OCCURRENCE (the face-loop scan order):
133
- * the sequence of first tests per unique pair which is what resolves
134
- * near-tie axes under the deadband — is exactly the sequence the full scan
135
- * produced, and the duplicate tests in between were no-ops (an identical
136
- * axis can never beat itself past the hysteresis band; a reversed-edge
137
- * duplicate only flips the axis sign, which the centroid-keyed sign
138
- * canonicalisation in test_axis erases). Results are bit-identical.
139
- *
140
- * @param {{face_offsets: Uint32Array, face_loops: Uint32Array, __sat_edges: (Uint32Array|undefined)}} shape
141
- * @returns {Uint32Array}
142
- */
143
- function get_sat_edges(shape) {
144
- let edges = shape.__sat_edges;
145
- if (edges !== undefined) return edges;
146
-
147
- const fo = shape.face_offsets;
148
- const fl = shape.face_loops;
149
- const nf = fo.length - 1;
150
- const seen = new Set();
151
- const list = [];
152
- for (let f = 0; f < nf; f++) {
153
- const s = fo[f];
154
- const l = fo[f + 1] - s;
155
- for (let i = 0; i < l; i++) {
156
- const v0 = fl[s + i];
157
- const v1 = fl[s + (i + 1) % l];
158
- // Canonical undirected key; hull vertex indices stay far below
159
- // 2^26, so min·2^26 + max is exact in a double.
160
- const key = v0 < v1 ? v0 * 67108864 + v1 : v1 * 67108864 + v0;
161
- if (seen.has(key)) continue;
162
- seen.add(key);
163
- list.push(v0, v1);
164
- }
165
- }
166
- edges = Uint32Array.from(list);
167
- shape.__sat_edges = edges;
168
- return edges;
169
- }
170
-
171
- /** SAT axis test; true if the axis SEPARATES the pieces. */
172
- function test_axis(ux, uy, uz, nA, nB, kind, face) {
173
- const len2 = ux * ux + uy * uy + uz * uz;
174
- if (len2 < PARALLEL_EPS) return false;
175
- const inv = 1 / Math.sqrt(len2);
176
- ux *= inv; uy *= inv; uz *= inv;
177
-
178
- let minA = Infinity, maxA = -Infinity;
179
- for (let i = 0; i < nA; i++) {
180
- const d = v3_dot(ux, uy, uz, wvA[i * 3], wvA[i * 3 + 1], wvA[i * 3 + 2]);
181
- if (d < minA) minA = d; if (d > maxA) maxA = d;
182
- }
183
- let minB = Infinity, maxB = -Infinity;
184
- for (let i = 0; i < nB; i++) {
185
- const d = v3_dot(ux, uy, uz, wvB[i * 3], wvB[i * 3 + 1], wvB[i * 3 + 2]);
186
- if (d < minB) minB = d; if (d > maxB) maxB = d;
187
- }
188
- if (maxA < minB || maxB < minA) return true;
189
-
190
- const overlap = Math.min(maxA, maxB) - Math.max(minA, minB);
191
- if (sat.kind === -1 || overlap < sat.overlap - (sat.overlap * TIE_REL + TIE_ABS)) {
192
- sat.overlap = overlap;
193
- const dcx = cenA[0] - cenB[0], dcy = cenA[1] - cenB[1], dcz = cenA[2] - cenB[2];
194
- const sign = v3_dot(ux, uy, uz, dcx, dcy, dcz) >= 0 ? 1 : -1;
195
- sat.nx = ux * sign; sat.ny = uy * sign; sat.nz = uz * sign;
196
- sat.kind = kind; sat.face = face;
197
- }
198
- return false;
199
- }
200
-
201
- /**
202
- * SAT entry point — finds the minimum-translation axis itself, then clips.
203
- * For the SMALL convex pieces of a decomposed mesh.
204
- *
205
- * @param {Float64Array|number[]} out length CONVEX_CONVEX_OUT_LENGTH
206
- * @param {{vertices:Float32Array, face_offsets:Uint32Array, face_loops:Uint32Array}} A
207
- * @param {{x,y,z}} posA @param {{x,y,z,w}} rotA
208
- * @param {{vertices:Float32Array, face_offsets:Uint32Array, face_loops:Uint32Array}} B
209
- * @param {{x,y,z}} posB @param {{x,y,z,w}} rotB
210
- * @returns {boolean}
211
- */
212
- export function convex_convex_manifold(out, A, posA, rotA, B, posB, rotB) {
213
- set_geom(A, B);
214
-
215
- load_world(wvA, A.vertices, g_nA, posA, rotA);
216
- load_world(wvB, B.vertices, g_nB, posB, rotB);
217
- v3_centroid_v3_buffer(cenA, 0, wvA, 0, g_nA);
218
- v3_centroid_v3_buffer(cenB, 0, wvB, 0, g_nB);
219
-
220
- sat.kind = -1; sat.overlap = Infinity;
221
-
222
- // A face normals.
223
- for (let f = 0; f < g_fA; f++) {
224
- face_normal(tmp_n, wvA, g_flA, g_foA[f], g_foA[f + 1]);
225
- if (test_axis(tmp_n[0], tmp_n[1], tmp_n[2], g_nA, g_nB, 0, f)) return false;
226
- }
227
- // B face normals.
228
- for (let f = 0; f < g_fB; f++) {
229
- face_normal(tmp_n, wvB, g_flB, g_foB[f], g_foB[f + 1]);
230
- if (test_axis(tmp_n[0], tmp_n[1], tmp_n[2], g_nA, g_nB, 1, f)) return false;
231
- }
232
- // Edge × edge crosses, over each hull's UNIQUE edges (cached per shape —
233
- // see get_sat_edges; the face-loop scan retested every interior edge pair
234
- // up to 4×, each paying a full interval projection).
235
- const edgesA = get_sat_edges(A);
236
- const edgesB = get_sat_edges(B);
237
- const neA = edgesA.length;
238
- const neB = edgesB.length;
239
- for (let ia = 0; ia < neA; ia += 2) {
240
- const a0 = edgesA[ia] * 3, a1 = edgesA[ia + 1] * 3;
241
- const eax = wvA[a1] - wvA[a0], eay = wvA[a1 + 1] - wvA[a0 + 1], eaz = wvA[a1 + 2] - wvA[a0 + 2];
242
- for (let ib = 0; ib < neB; ib += 2) {
243
- const b0 = edgesB[ib] * 3, b1 = edgesB[ib + 1] * 3;
244
- const ebx = wvB[b1] - wvB[b0], eby = wvB[b1 + 1] - wvB[b0 + 1], ebz = wvB[b1 + 2] - wvB[b0 + 2];
245
- const cx = eay * ebz - eaz * eby, cy = eaz * ebx - eax * ebz, cz = eax * eby - eay * ebx;
246
- if (test_axis(cx, cy, cz, g_nA, g_nB, 2, -1)) return false;
247
- }
248
- }
249
-
250
- if (sat.kind === -1) return false;
251
-
252
- const nx = sat.nx, ny = sat.ny, nz = sat.nz;
253
- out[0] = nx; out[1] = ny; out[2] = nz;
254
-
255
- // Edge-cross winner: single contact at the winning edges' closest points.
256
- if (sat.kind === 2) {
257
- emit_edge_pair_contact(out, nx, ny, nz, sat.overlap);
258
- return true;
259
- }
260
-
261
- // Face winner: reference / incident polygon clipping.
262
- emit_face_manifold(out, sat.kind === 0, sat.face, nx, ny, nz);
263
- return true;
264
- }
265
-
266
- /**
267
- * Clip-only entry point the caller supplies the separating axis `n` (B→A,
268
- * unit) from a robust GJK+EPA query ({@link gjk_epa_penetration}); we only build
269
- * the multi-point manifold. This is Bullet's `clipHullAgainstHull(sepNormal,…)`
270
- * with the normal sourced from GJK rather than SAT. Used for LARGE convex
271
- * polytopes (authored hulls, a convex mesh as one piece) where SAT's O(Fa·Fb +
272
- * Ea·Eb) edge term is prohibitive but GJK+EPA is O(support queries). Always
273
- * emits 1 contact (the caller already established penetration): if the face
274
- * clip empties (a vertex/edge feature) it falls back to the deepest support-pair.
275
- *
276
- * @param {Float64Array|number[]} out length ≥ CONVEX_CONVEX_OUT_LENGTH
277
- * @param {{vertices,face_offsets,face_loops}} A @param {{x,y,z}} posA @param {{x,y,z,w}} rotA
278
- * @param {{vertices,face_offsets,face_loops}} B @param {{x,y,z}} posB @param {{x,y,z,w}} rotB
279
- * @param {number} nx @param {number} ny @param {number} nz unit axis as
280
- * returned by {@link gjk_epa_penetration} (A→B); this function re-orients it
281
- * against the geometric centres before use, so either sign convention works
282
- * @returns {boolean} always true
283
- */
284
- export function convex_hull_clip(out, A, posA, rotA, B, posB, rotB, nx, ny, nz) {
285
- set_geom(A, B);
286
- load_world(wvA, A.vertices, g_nA, posA, rotA);
287
- load_world(wvB, B.vertices, g_nB, posB, rotB);
288
-
289
- // Orient the axis B→A using the shapes' GEOMETRIC centres (centroids of the
290
- // world vertices), the same robust reference the SAT path uses. A body-frame
291
- // guard (transform positions) degenerates when the two origins nearly
292
- // coincide — e.g. a tet resting base-to-base on another, both transforms at
293
- // the contact plane leaving the normal mis-oriented and the stack tunnels.
294
- v3_centroid_v3_buffer(cenA, 0, wvA, 0, g_nA);
295
- v3_centroid_v3_buffer(cenB, 0, wvB, 0, g_nB);
296
- if (nx * (cenA[0] - cenB[0]) + ny * (cenA[1] - cenB[1]) + nz * (cenA[2] - cenB[2]) < 0) {
297
- nx = -nx; ny = -ny; nz = -nz;
298
- }
299
- out[0] = nx; out[1] = ny; out[2] = nz;
300
-
301
- // Reference face = the face (A or B) whose outward normal is most aligned
302
- // with the axis pointing toward the other body. A's contact face points
303
- // toward B (along −n); B's toward A (along +n). The flatter (better-aligned)
304
- // one is the reference. Mirrors Bullet's "face most opposing the normal",
305
- // made symmetric across A and B.
306
- let bestA = -Infinity, faceA = 0;
307
- for (let f = 0; f < g_fA; f++) {
308
- face_normal(tmp_n, wvA, g_flA, g_foA[f], g_foA[f + 1]);
309
- const l = v3_length(tmp_n[0], tmp_n[1], tmp_n[2]) || 1;
310
- const d = v3_dot(tmp_n[0], tmp_n[1], tmp_n[2], -nx, -ny, -nz) / l;
311
- if (d > bestA) { bestA = d; faceA = f; }
312
- }
313
- let bestB = -Infinity, faceB = 0;
314
- for (let f = 0; f < g_fB; f++) {
315
- face_normal(tmp_n, wvB, g_flB, g_foB[f], g_foB[f + 1]);
316
- const l = v3_length(tmp_n[0], tmp_n[1], tmp_n[2]) || 1;
317
- const d = v3_dot(tmp_n[0], tmp_n[1], tmp_n[2], nx, ny, nz) / l;
318
- if (d > bestB) { bestB = d; faceB = f; }
319
- }
320
-
321
- const ref_is_A = bestA >= bestB;
322
- emit_face_manifold(out, ref_is_A, ref_is_A ? faceA : faceB, nx, ny, nz);
323
-
324
- if ((out[3] | 0) === 0) {
325
- const overlap = projection_overlap(nx, ny, nz);
326
- emit_single_contact(out, nx, ny, nz, overlap > 0 ? overlap : 0);
327
- }
328
- return true;
329
- }
330
-
331
- /** Overlap of the two pieces' projections onto axis `n` (B→A); A is on the +n side. */
332
- function projection_overlap(nx, ny, nz) {
333
- let minA = Infinity, maxB = -Infinity;
334
- for (let i = 0; i < g_nA; i++) {
335
- const d = v3_dot(nx, ny, nz, wvA[i * 3], wvA[i * 3 + 1], wvA[i * 3 + 2]);
336
- if (d < minA) minA = d;
337
- }
338
- for (let i = 0; i < g_nB; i++) {
339
- const d = v3_dot(nx, ny, nz, wvB[i * 3], wvB[i * 3 + 1], wvB[i * 3 + 2]);
340
- if (d > maxB) maxB = d;
341
- }
342
- return maxB - minA;
343
- }
344
-
345
- /** Single deepest support-pair contact along axis `n` (B→A). */
346
- function emit_single_contact(out, nx, ny, nz, depth) {
347
- let sa = -Infinity, ai = 0;
348
- for (let i = 0; i < g_nA; i++) {
349
- const d = -v3_dot(nx, ny, nz, wvA[i * 3], wvA[i * 3 + 1], wvA[i * 3 + 2]);
350
- if (d > sa) { sa = d; ai = i; }
351
- }
352
- let sb = -Infinity, bi = 0;
353
- for (let i = 0; i < g_nB; i++) {
354
- const d = v3_dot(nx, ny, nz, wvB[i * 3], wvB[i * 3 + 1], wvB[i * 3 + 2]);
355
- if (d > sb) { sb = d; bi = i; }
356
- }
357
- out[3] = 1;
358
- out[4] = wvA[ai * 3]; out[5] = wvA[ai * 3 + 1]; out[6] = wvA[ai * 3 + 2];
359
- out[7] = wvB[bi * 3]; out[8] = wvB[bi * 3 + 1]; out[9] = wvB[bi * 3 + 2];
360
- out[10] = depth;
361
- }
362
-
363
- const scratch_st = new Float64Array(2);
364
- const scratch_edge = new Int32Array(4); // [a0, a1] then [b0, b1] vertex indices
365
-
366
- /**
367
- * Find a piece's SUPPORTING EDGE along direction d: the face-loop edge that
368
- * maximises the SMALLER of its two endpoint projections. For an edge-cross
369
- * SAT winner the true contact edge lies perpendicular to the axis, so both
370
- * its endpoints project to the common maximum and its min-endpoint
371
- * projection beats every other edge's. (Recording the SAT loop's winning
372
- * pair instead does NOT work: parallel edge pairs alias one axis with equal
373
- * overlap, and the first-tested pair is usually not the touching one.)
374
- *
375
- * @param {Float64Array} wv world vertices
376
- * @param {Uint32Array} fo face offsets
377
- * @param {Uint32Array} fl face loops
378
- * @param {number} fcount face count
379
- * @param {number} dx @param {number} dy @param {number} dz
380
- * @param {Int32Array} out_pair 2 slots written at `pair_off`
381
- * @param {number} pair_off
382
- */
383
- function find_support_edge(wv, fo, fl, fcount, dx, dy, dz, out_pair, pair_off) {
384
- let best = -Infinity;
385
- for (let f = 0; f < fcount; f++) {
386
- const start = fo[f], len = fo[f + 1] - start;
387
- for (let i = 0; i < len; i++) {
388
- const v0 = fl[start + i] * 3;
389
- const v1 = fl[start + (i + 1) % len] * 3;
390
- const d0 = wv[v0] * dx + wv[v0 + 1] * dy + wv[v0 + 2] * dz;
391
- const d1 = wv[v1] * dx + wv[v1 + 1] * dy + wv[v1 + 2] * dz;
392
- const m = d0 < d1 ? d0 : d1;
393
- if (m > best) {
394
- best = m;
395
- out_pair[pair_off] = v0;
396
- out_pair[pair_off + 1] = v1;
397
- }
398
- }
399
- }
400
- }
401
-
402
- /**
403
- * Single contact for an edge-cross SAT winner, at the CLOSEST POINTS of the
404
- * two supporting edges. A support-VERTEX pick is ambiguous here: every point
405
- * of the contact edge projects identically onto the cross axis, so the
406
- * argmax lands on an arbitrary endpoint and hands the solver a lever arm up
407
- * to half an edge length off - resting boxes twist.
408
- */
409
- function emit_edge_pair_contact(out, nx, ny, nz, depth) {
410
- // A's supporting edge faces the contact (toward B): extreme along -n;
411
- // B's faces A: extreme along +n. (n is B -> A.)
412
- find_support_edge(wvA, g_foA, g_flA, g_fA, -nx, -ny, -nz, scratch_edge, 0);
413
- find_support_edge(wvB, g_foB, g_flB, g_fB, nx, ny, nz, scratch_edge, 2);
414
- const a0 = scratch_edge[0], a1 = scratch_edge[1];
415
- const b0 = scratch_edge[2], b1 = scratch_edge[3];
416
-
417
- line3_compute_segment_segment_closest_points(
418
- scratch_st,
419
- wvA[a0], wvA[a0 + 1], wvA[a0 + 2],
420
- wvA[a1], wvA[a1 + 1], wvA[a1 + 2],
421
- wvB[b0], wvB[b0 + 1], wvB[b0 + 2],
422
- wvB[b1], wvB[b1 + 1], wvB[b1 + 2]
423
- );
424
- const s = scratch_st[0];
425
- const t = scratch_st[1];
426
- out[3] = 1;
427
- out[4] = wvA[a0] + (wvA[a1] - wvA[a0]) * s;
428
- out[5] = wvA[a0 + 1] + (wvA[a1 + 1] - wvA[a0 + 1]) * s;
429
- out[6] = wvA[a0 + 2] + (wvA[a1 + 2] - wvA[a0 + 2]) * s;
430
- out[7] = wvB[b0] + (wvB[b1] - wvB[b0]) * t;
431
- out[8] = wvB[b0 + 1] + (wvB[b1 + 1] - wvB[b0 + 1]) * t;
432
- out[9] = wvB[b0 + 2] + (wvB[b1 + 2] - wvB[b0 + 2]) * t;
433
- out[10] = depth;
434
- }
435
-
436
- /**
437
- * Reference/incident polygon clipping given the reference face. Writes the
438
- * manifold (count + contacts) into `out`; leaves out[0..2] (the normal) as set
439
- * by the caller. Shared by both the SAT and GJK+EPA entry points.
440
- *
441
- * @param {boolean} ref_is_A reference face belongs to A (else B)
442
- * @param {number} ref_face reference face index within its piece
443
- * @param {number} nx @param {number} ny @param {number} nz axis (B→A), unit
444
- */
445
- function emit_face_manifold(out, ref_is_A, ref_face, nx, ny, nz) {
446
- const ref_wv = ref_is_A ? wvA : wvB;
447
- const ref_fo = ref_is_A ? g_foA : g_foB;
448
- const ref_fl = ref_is_A ? g_flA : g_flB;
449
- const inc_wv = ref_is_A ? wvB : wvA;
450
- const inc_fo = ref_is_A ? g_foB : g_foA;
451
- const inc_fl = ref_is_A ? g_flB : g_flA;
452
- const inc_fcount = ref_is_A ? g_fB : g_fA;
453
-
454
- // Reference outward normal points ref incident: −n if ref is A, +n if ref is B.
455
- const rmx = ref_is_A ? -nx : nx, rmy = ref_is_A ? -ny : ny, rmz = ref_is_A ? -nz : nz;
456
-
457
- const ref_s = ref_fo[ref_face], ref_len = ref_fo[ref_face + 1] - ref_s;
458
- const r0 = ref_fl[ref_s] * 3;
459
- const r0x = ref_wv[r0], r0y = ref_wv[r0 + 1], r0z = ref_wv[r0 + 2];
460
-
461
- // Incident face = the polygon on the other piece most antiparallel to rm.
462
- let inc_face = 0, most_anti = Infinity;
463
- for (let f = 0; f < inc_fcount; f++) {
464
- face_normal(tmp_n, inc_wv, inc_fl, inc_fo[f], inc_fo[f + 1]);
465
- const l = v3_length(tmp_n[0], tmp_n[1], tmp_n[2]) || 1;
466
- const dot = v3_dot(tmp_n[0], tmp_n[1], tmp_n[2], rmx, rmy, rmz) / l;
467
- if (dot < most_anti) { most_anti = dot; inc_face = f; }
468
- }
469
-
470
- // Incident polygon (world). Worst-case working size: the incident loop
471
- // plus one extra vertex per reference side-plane clip (a convex polygon
472
- // clipped by a half-space gains at most one vertex) — grow the shared
473
- // scratch to fit, so wide coplanar-merged faces aren't truncated into
474
- // OOB reads (NaN / stale contacts).
475
- const inc_s = inc_fo[inc_face], inc_len = inc_fo[inc_face + 1] - inc_s;
476
- const max_poly_verts = inc_len + ref_len;
477
- if (poly_in.length < max_poly_verts * 3) {
478
- poly_in = new Float64Array(max_poly_verts * 3);
479
- poly_out = new Float64Array(max_poly_verts * 3);
480
- cand = new Float64Array(max_poly_verts * 4);
481
- }
482
- let n_poly = inc_len;
483
- for (let i = 0; i < inc_len; i++) {
484
- const vi = inc_fl[inc_s + i] * 3;
485
- poly_in[i * 3] = inc_wv[vi]; poly_in[i * 3 + 1] = inc_wv[vi + 1]; poly_in[i * 3 + 2] = inc_wv[vi + 2];
486
- }
487
-
488
- // Reference polygon centroid (orients side planes inward).
489
- let rcx = 0, rcy = 0, rcz = 0;
490
- for (let i = 0; i < ref_len; i++) {
491
- const vi = ref_fl[ref_s + i] * 3;
492
- rcx += ref_wv[vi]; rcy += ref_wv[vi + 1]; rcz += ref_wv[vi + 2];
493
- }
494
- rcx /= ref_len; rcy /= ref_len; rcz /= ref_len;
495
-
496
- // Clip the incident polygon against each reference-face side plane.
497
- let src = poly_in, dst = poly_out;
498
- for (let e = 0; e < ref_len && n_poly > 0; e++) {
499
- const va = ref_fl[ref_s + e] * 3, vb = ref_fl[ref_s + (e + 1) % ref_len] * 3;
500
- const edx = ref_wv[vb] - ref_wv[va], edy = ref_wv[vb + 1] - ref_wv[va + 1], edz = ref_wv[vb + 2] - ref_wv[va + 2];
501
- let sx = edy * rmz - edz * rmy, sy = edz * rmx - edx * rmz, sz = edx * rmy - edy * rmx;
502
- const pax = ref_wv[va], pay = ref_wv[va + 1], paz = ref_wv[va + 2];
503
- if ((rcx - pax) * sx + (rcy - pay) * sy + (rcz - paz) * sz > 0) { sx = -sx; sy = -sy; sz = -sz; }
504
- n_poly = clip_poly(src, n_poly, dst, sx, sy, sz, pax, pay, paz);
505
- const t = src; src = dst; dst = t;
506
- }
507
- if (n_poly === 0) { out[3] = 0; return; }
508
-
509
- let nc = 0;
510
- for (let i = 0; i < n_poly; i++) {
511
- const px = src[i * 3], py = src[i * 3 + 1], pz = src[i * 3 + 2];
512
- const sep = (px - r0x) * rmx + (py - r0y) * rmy + (pz - r0z) * rmz;
513
- const depth = -sep;
514
- if (depth < 0) continue;
515
- cand[nc * 4] = px; cand[nc * 4 + 1] = py; cand[nc * 4 + 2] = pz; cand[nc * 4 + 3] = depth;
516
- nc++;
517
- }
518
- if (nc === 0) { out[3] = 0; return; }
519
-
520
- const kept = reduce_manifold_contacts(cand, nc, 4, MAX_CONTACTS, 3);
521
- out[3] = kept;
522
- for (let k = 0; k < kept; k++) {
523
- const px = cand[k * 4], py = cand[k * 4 + 1], pz = cand[k * 4 + 2], depth = cand[k * 4 + 3];
524
- const d2p = (px - r0x) * rmx + (py - r0y) * rmy + (pz - r0z) * rmz;
525
- const rpx = px - rmx * d2p, rpy = py - rmy * d2p, rpz = pz - rmz * d2p;
526
- const base = 4 + k * CONTACT_STRIDE;
527
- if (ref_is_A) {
528
- out[base] = rpx; out[base + 1] = rpy; out[base + 2] = rpz;
529
- out[base + 3] = px; out[base + 4] = py; out[base + 5] = pz;
530
- } else {
531
- out[base] = px; out[base + 1] = py; out[base + 2] = pz;
532
- out[base + 3] = rpx; out[base + 4] = rpy; out[base + 5] = rpz;
533
- }
534
- out[base + 6] = depth;
535
- }
536
- }
537
-
538
- /**
539
- * Sutherland–Hodgman: keep polygon points where (P a)·s ≤ 0, with crossings.
540
- * Capacity-guarded on BOTH emit branches: `m` must never pass `dst`'s capacity
541
- * or the dropped OOB writes leave stale/NaN points that later reads consume
542
- * (the buffers are pre-sized to inc_len + ref_len, so the guard is a backstop
543
- * for degenerate input, not the normal bound).
544
- */
545
- function clip_poly(src, n, dst, sx, sy, sz, ax, ay, az) {
546
- const cap = (dst.length / 3) | 0;
547
- let m = 0;
548
- for (let i = 0; i < n && m < cap; i++) {
549
- const j = (i + 1) % n;
550
- const px = src[i * 3], py = src[i * 3 + 1], pz = src[i * 3 + 2];
551
- const qx = src[j * 3], qy = src[j * 3 + 1], qz = src[j * 3 + 2];
552
- const dp = v3_dot(px - ax, py - ay, pz - az, sx, sy, sz);
553
- const dq = v3_dot(qx - ax, qy - ay, qz - az, sx, sy, sz);
554
- const p_in = dp <= 0, q_in = dq <= 0;
555
- if (p_in) { dst[m * 3] = px; dst[m * 3 + 1] = py; dst[m * 3 + 2] = pz; m++; }
556
- if (p_in !== q_in && m < cap) {
557
- const t = dp / (dp - dq);
558
- dst[m * 3] = px + (qx - px) * t;
559
- dst[m * 3 + 1] = py + (qy - py) * t;
560
- dst[m * 3 + 2] = pz + (qz - pz) * t;
561
- m++;
562
- }
563
- }
564
- return m;
565
- }
566
-
567
- // Contact reduction (deepest + farthest-point spread) is shared with
568
- // box_box_manifold via reduce_manifold_contacts (stride 4).
1
+ import { line3_compute_segment_segment_closest_points } from "../../../core/geom/3d/line/line3_compute_segment_segment_closest_points.js";
2
+ import { v3_centroid_v3_buffer } from "../../../core/geom/vec3/v3_centroid_v3_buffer.js";
3
+ import { v3_dot } from "../../../core/geom/vec3/v3_dot.js";
4
+ import { v3_length } from "../../../core/geom/vec3/v3_length.js";
5
+ import { v3_quaternion_apply } from "../../../core/geom/vec3/v3_quaternion_apply.js";
6
+ import { reduce_manifold_contacts } from "./reduce_manifold_contacts.js";
7
+
8
+ /**
9
+ * Multi-point contact manifold between two convex polytopes with **polygon
10
+ * faces**, computed entirely from the current poses — no cross-frame state, so
11
+ * it preserves reset-and-resimulate (rollback) determinism.
12
+ *
13
+ * A piece is described by:
14
+ * - `vertices` : Float32Array, flat (x,y,z) per vertex, local frame
15
+ * - `face_offsets` : Uint32Array length F+1, CSR offsets into `face_loops`
16
+ * - `face_loops` : Uint32Array, each face's vertex indices, ordered CCW so
17
+ * the face normal (from its first three loop verts) points
18
+ * outward.
19
+ * A triangle-faced piece (a tetrahedron) is just the special case where every
20
+ * face loop has length 3; a merged/box piece has quads or larger polygons.
21
+ * Handling polygon faces directly is what lets a flat face produce a full
22
+ * face-on-face patch instead of mismatched triangle slivers.
23
+ *
24
+ * The separating axis comes from SAT (the structure mirrors Bullet's
25
+ * `clipHullAgainstHull`, which clips around a `separatingNormal`). A GJK+EPA
26
+ * axis source was prototyped — Bullet sources the normal from EITHER SAT OR
27
+ * `btGjkPairDetector`, the source being orthogonal to the clip — but this
28
+ * engine's EPA returns a non-minimal, non-scaling axis for polytopes (a 0.05 m
29
+ * overlap reports ~0.8 m depth), so clipping around it produces a garbage
30
+ * manifold. SAT is exact and, for the low-poly hulls authored as collision
31
+ * proxies and the small pieces of a decomposed mesh, cheap. See memory:
32
+ * feedback_epa_unreliable_polytopes.
33
+ *
34
+ * Algorithm (general form of {@link box_box_manifold}):
35
+ * 1. SAT over every face normal of A, every face normal of B, and every
36
+ * edge(A)×edge(B) cross finds the minimum-translation axis `n` (B→A).
37
+ * 2. Face-axis winner ⇒ reference face = the polygon that owns the axis;
38
+ * incident face = the polygon on the other piece most antiparallel to the
39
+ * reference outward normal. Clip the incident polygon against the reference
40
+ * polygon's side planes (3-D Sutherland–Hodgman) and keep penetrating points.
41
+ * 3. Edge-axis winner ⇒ a single deepest support-pair contact.
42
+ * 4. Reduce survivors to ≤ {@link MAX_CONTACTS} (deepest + spread).
43
+ *
44
+ * Output layout (matches {@link box_box_manifold}):
45
+ * out[0..2] : world normal (B→A)
46
+ * out[3] : contact count (0 .. MAX_CONTACTS)
47
+ * out[4 + k*7 + 0..2] : world contact on A's surface
48
+ * out[4 + k*7 + 3..5] : world contact on B's surface
49
+ * out[4 + k*7 + 6] : penetration depth (positive)
50
+ *
51
+ * @author Alex Goldring
52
+ * @copyright Company Named Limited (c) 2026
53
+ */
54
+
55
+ const MAX_CONTACTS = 4;
56
+ const CONTACT_STRIDE = 7;
57
+ export const CONVEX_CONVEX_OUT_LENGTH = 4 + MAX_CONTACTS * CONTACT_STRIDE;
58
+
59
+ const INITIAL_V = 256; // initial world-vertex scratch capacity (verts per piece/hull)
60
+ const MAX_POLY = 64; // polygon verts during clipping
61
+
62
+ const TIE_REL = 0.02;
63
+ const TIE_ABS = 1e-5;
64
+ // Scale-INVARIANT degeneracy cutoff for a candidate SAT axis. The incoming axis is unnormalised
65
+ // (a Newell face normal of magnitude 2·area, or an edge×edge cross of magnitude |ea||eb|sinθ), so
66
+ // its raw length is scale-dependent and must NOT be thresholded against an absolute constant —
67
+ // doing so silently drops small faces and near-parallel short edges. Instead we threshold the
68
+ // dimensionless ratio len² / ref², where ref² is the square of the axis's own characteristic
69
+ // magnitude: for an edge cross that ratio is sin²θ (true parallelism), for a face it is a shape
70
+ // "fatness" factor that only vanishes for a genuinely degenerate (collinear) loop. Matches the
71
+ // unit-axis sin²θ cutoff box_box_manifold already uses (PARALLEL_EPS_SQR).
72
+ const PARALLEL_EPS_REL = 1e-8;
73
+
74
+ // --- scratch ----------------------------------------------------------------
75
+ // World-vertex buffers. `let` + grow-on-demand: a convex MESH routed as a single
76
+ // hull (get_mesh_convex_hull) can have far more than the initial capacity of
77
+ // surface vertices (a subdivided icosphere is hundreds). Without the grow, the
78
+ // excess writes were silently dropped and SAT/clip read NaN past the end,
79
+ // computing a truncated (wrong) manifold against part of the hull.
80
+ let wvA = new Float64Array(INITIAL_V * 3);
81
+ let wvB = new Float64Array(INITIAL_V * 3);
82
+ // Clipping scratch `let` + grow-on-demand like wvA/wvB: a coplanar-merged
83
+ // face (e.g. a tessellated cylinder cap routed through get_mesh_convex_hull)
84
+ // can be wider than MAX_POLY, and each side-plane clip can add one more
85
+ // vertex. emit_face_manifold sizes these to inc_len + ref_len before use.
86
+ let poly_in = new Float64Array(MAX_POLY * 3);
87
+ let poly_out = new Float64Array(MAX_POLY * 3);
88
+ let cand = new Float64Array(MAX_POLY * 4);
89
+ const cenA = new Float64Array(3);
90
+ const cenB = new Float64Array(3);
91
+ const tmp_n = new Float64Array(3);
92
+
93
+ const sat = { overlap: Infinity, nx: 0, ny: 0, nz: 0, kind: -1 };
94
+
95
+ /** Result of {@link select_reference_face}. */
96
+ const ref_sel = { face: 0, score: 0 };
97
+
98
+ // --- per-call geometry refs (single-thread re-entrancy, like the scratch) ---
99
+ let g_foA, g_flA, g_foB, g_flB, g_fA, g_fB, g_nA, g_nB;
100
+
101
+ function set_geom(A, B) {
102
+ g_nA = A.vertices.length / 3; g_nB = B.vertices.length / 3;
103
+ g_foA = A.face_offsets; g_flA = A.face_loops; g_fA = g_foA.length - 1;
104
+ g_foB = B.face_offsets; g_flB = B.face_loops; g_fB = g_foB.length - 1;
105
+ // Grow the world-vertex scratch to fit, so large hulls aren't truncated.
106
+ if (wvA.length < g_nA * 3) wvA = new Float64Array(g_nA * 3);
107
+ if (wvB.length < g_nB * 3) wvB = new Float64Array(g_nB * 3);
108
+ }
109
+
110
+ function load_world(out, verts, n, p, q) {
111
+ for (let i = 0; i < n; i++) {
112
+ v3_quaternion_apply(out, i * 3, verts[i * 3], verts[i * 3 + 1], verts[i * 3 + 2], q.x, q.y, q.z, q.w);
113
+ out[i * 3] += p.x; out[i * 3 + 1] += p.y; out[i * 3 + 2] += p.z;
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Outward normal of a polygon face (Newell's method over the whole loop, world).
119
+ * Robust against collinear consecutive vertices, unlike a first-three cross.
120
+ *
121
+ * @returns {number} the loop's summed squared edge length Σ|eᵢ|² — a scale²-matched
122
+ * characteristic magnitude for the face (|normal| = 2·area this), so `|normal|² / result²`
123
+ * is the dimensionless "fatness" used by {@link test_axis} to reject only degenerate loops.
124
+ */
125
+ function face_normal(out, wv, loops, off, end) {
126
+ let nx = 0, ny = 0, nz = 0, s2 = 0;
127
+ for (let i = off; i < end; i++) {
128
+ const p = loops[i] * 3, q = loops[i + 1 < end ? i + 1 : off] * 3;
129
+ nx += (wv[p + 1] - wv[q + 1]) * (wv[p + 2] + wv[q + 2]);
130
+ ny += (wv[p + 2] - wv[q + 2]) * (wv[p] + wv[q]);
131
+ nz += (wv[p] - wv[q]) * (wv[p + 1] + wv[q + 1]);
132
+ const ex = wv[p] - wv[q], ey = wv[p + 1] - wv[q + 1], ez = wv[p + 2] - wv[q + 2];
133
+ s2 += ex * ex + ey * ey + ez * ez;
134
+ }
135
+ out[0] = nx; out[1] = ny; out[2] = nz;
136
+ return s2;
137
+ }
138
+
139
+ /**
140
+ * Unique edges of a hull piece as vertex-index pairs `(v0, v1)`, flat in a
141
+ * Uint32Array, cached on the (immutable) piece as `__sat_edges` — built on
142
+ * first use, like `get_mesh_convex_hull`'s cache (D4).
143
+ *
144
+ * The SAT edge×edge loop used to enumerate every FACE-LOOP edge of A
145
+ * against every face-loop edge of B; an interior edge of a closed hull
146
+ * borders exactly two faces, so each unique edge pair was tested up to 4×,
147
+ * each test paying a full O(nA + nB) interval projection. Deduplication
148
+ * cuts the dominant quartic term ~4×.
149
+ *
150
+ * Order and orientation are FIRST-OCCURRENCE (the face-loop scan order):
151
+ * the sequence of first tests per unique pair — which is what resolves
152
+ * near-tie axes under the deadband is exactly the sequence the full scan
153
+ * produced, and the duplicate tests in between were no-ops (an identical
154
+ * axis can never beat itself past the hysteresis band; a reversed-edge
155
+ * duplicate only flips the axis sign, which the centroid-keyed sign
156
+ * canonicalisation in test_axis erases). Results are bit-identical.
157
+ *
158
+ * @param {{face_offsets: Uint32Array, face_loops: Uint32Array, __sat_edges: (Uint32Array|undefined)}} shape
159
+ * @returns {Uint32Array}
160
+ */
161
+ function get_sat_edges(shape) {
162
+ let edges = shape.__sat_edges;
163
+ if (edges !== undefined) return edges;
164
+
165
+ const fo = shape.face_offsets;
166
+ const fl = shape.face_loops;
167
+ const nf = fo.length - 1;
168
+ const seen = new Set();
169
+ const list = [];
170
+ for (let f = 0; f < nf; f++) {
171
+ const s = fo[f];
172
+ const l = fo[f + 1] - s;
173
+ for (let i = 0; i < l; i++) {
174
+ const v0 = fl[s + i];
175
+ const v1 = fl[s + (i + 1) % l];
176
+ // Canonical undirected key; hull vertex indices stay far below
177
+ // 2^26, so min·2^26 + max is exact in a double.
178
+ const key = v0 < v1 ? v0 * 67108864 + v1 : v1 * 67108864 + v0;
179
+ if (seen.has(key)) continue;
180
+ seen.add(key);
181
+ list.push(v0, v1);
182
+ }
183
+ }
184
+ edges = Uint32Array.from(list);
185
+ shape.__sat_edges = edges;
186
+ return edges;
187
+ }
188
+
189
+ /**
190
+ * Select the reference face of one piece: the face whose outward normal is most aligned with
191
+ * `(mx,my,mz)`, the axis pointing toward the other body (−n for A, +n for B). Writes {@link ref_sel}.
192
+ *
193
+ * A face's SAT axis is direction-agnostic a closed hull carries both `u` and `−u` as face normals
194
+ * and both project to an identical overlap so the face index that WON the SAT scan is whichever of
195
+ * an antipodal pair happened to be enumerated first, which is unrelated to the side the other body is
196
+ * on. The reference face must therefore be re-derived from the (sign-canonicalised) normal rather than
197
+ * taken from the SAT scan. Mirrors Bullet's "face most opposing the normal", made symmetric across A and B.
198
+ *
199
+ * @param {boolean} is_A select within piece A, otherwise piece B
200
+ * @param {number} mx @param {number} my @param {number} mz axis toward the other body
201
+ */
202
+ function select_reference_face(is_A, mx, my, mz) {
203
+ const nf = is_A ? g_fA : g_fB;
204
+ const wv = is_A ? wvA : wvB;
205
+ const fl = is_A ? g_flA : g_flB;
206
+ const fo = is_A ? g_foA : g_foB;
207
+
208
+ let best = -Infinity;
209
+ let best_face = 0;
210
+
211
+ for (let f = 0; f < nf; f++) {
212
+ face_normal(tmp_n, wv, fl, fo[f], fo[f + 1]);
213
+
214
+ const l = v3_length(tmp_n[0], tmp_n[1], tmp_n[2]) || 1;
215
+ const d = v3_dot(tmp_n[0], tmp_n[1], tmp_n[2], mx, my, mz) / l;
216
+
217
+ if (d > best) {
218
+ best = d;
219
+ best_face = f;
220
+ }
221
+ }
222
+
223
+ ref_sel.face = best_face;
224
+ ref_sel.score = best;
225
+ }
226
+
227
+ /**
228
+ * SAT axis test; true if the axis SEPARATES the pieces.
229
+ * @param {number} ref2 square of the axis's characteristic magnitude (Σ|edge|² for a face,
230
+ * |ea|²·|eb|² for an edge cross); the axis is rejected as degenerate when `len2 / ref2` — a
231
+ * scale-invariant fatness / sin²θ — falls below {@link PARALLEL_EPS_REL}. See PARALLEL_EPS_REL.
232
+ */
233
+ function test_axis(ux, uy, uz, nA, nB, kind, ref2) {
234
+ const len2 = ux * ux + uy * uy + uz * uz;
235
+ if (len2 < PARALLEL_EPS_REL * ref2) return false;
236
+ const inv = 1 / Math.sqrt(len2);
237
+ ux *= inv; uy *= inv; uz *= inv;
238
+
239
+ let minA = Infinity, maxA = -Infinity;
240
+ for (let i = 0; i < nA; i++) {
241
+ const d = v3_dot(ux, uy, uz, wvA[i * 3], wvA[i * 3 + 1], wvA[i * 3 + 2]);
242
+ if (d < minA) minA = d; if (d > maxA) maxA = d;
243
+ }
244
+ let minB = Infinity, maxB = -Infinity;
245
+ for (let i = 0; i < nB; i++) {
246
+ const d = v3_dot(ux, uy, uz, wvB[i * 3], wvB[i * 3 + 1], wvB[i * 3 + 2]);
247
+ if (d < minB) minB = d; if (d > maxB) maxB = d;
248
+ }
249
+ if (maxA < minB || maxB < minA) return true;
250
+
251
+ const overlap = Math.min(maxA, maxB) - Math.max(minA, minB);
252
+ if (sat.kind === -1 || overlap < sat.overlap - (sat.overlap * TIE_REL + TIE_ABS)) {
253
+ sat.overlap = overlap;
254
+ const dcx = cenA[0] - cenB[0], dcy = cenA[1] - cenB[1], dcz = cenA[2] - cenB[2];
255
+ const sign = v3_dot(ux, uy, uz, dcx, dcy, dcz) >= 0 ? 1 : -1;
256
+ sat.nx = ux * sign; sat.ny = uy * sign; sat.nz = uz * sign;
257
+ sat.kind = kind;
258
+ }
259
+ return false;
260
+ }
261
+
262
+ /**
263
+ * SAT entry point — finds the minimum-translation axis itself, then clips.
264
+ * For the SMALL convex pieces of a decomposed mesh.
265
+ *
266
+ * @param {Float64Array|number[]} out length ≥ CONVEX_CONVEX_OUT_LENGTH
267
+ * @param {{vertices:Float32Array, face_offsets:Uint32Array, face_loops:Uint32Array}} A
268
+ * @param {{x,y,z}} posA @param {{x,y,z,w}} rotA
269
+ * @param {{vertices:Float32Array, face_offsets:Uint32Array, face_loops:Uint32Array}} B
270
+ * @param {{x,y,z}} posB @param {{x,y,z,w}} rotB
271
+ * @returns {boolean}
272
+ */
273
+ export function convex_convex_manifold(out, A, posA, rotA, B, posB, rotB) {
274
+ set_geom(A, B);
275
+
276
+ load_world(wvA, A.vertices, g_nA, posA, rotA);
277
+ load_world(wvB, B.vertices, g_nB, posB, rotB);
278
+ v3_centroid_v3_buffer(cenA, 0, wvA, 0, g_nA);
279
+ v3_centroid_v3_buffer(cenB, 0, wvB, 0, g_nB);
280
+
281
+ sat.kind = -1; sat.overlap = Infinity;
282
+
283
+ // A face normals.
284
+ for (let f = 0; f < g_fA; f++) {
285
+ const s2 = face_normal(tmp_n, wvA, g_flA, g_foA[f], g_foA[f + 1]);
286
+ if (test_axis(tmp_n[0], tmp_n[1], tmp_n[2], g_nA, g_nB, 0, s2 * s2)) return false;
287
+ }
288
+ // B face normals.
289
+ for (let f = 0; f < g_fB; f++) {
290
+ const s2 = face_normal(tmp_n, wvB, g_flB, g_foB[f], g_foB[f + 1]);
291
+ if (test_axis(tmp_n[0], tmp_n[1], tmp_n[2], g_nA, g_nB, 1, s2 * s2)) return false;
292
+ }
293
+ // Edge × edge crosses, over each hull's UNIQUE edges (cached per shape —
294
+ // see get_sat_edges; the face-loop scan retested every interior edge pair
295
+ // up to 4×, each paying a full interval projection).
296
+ const edgesA = get_sat_edges(A);
297
+ const edgesB = get_sat_edges(B);
298
+ const neA = edgesA.length;
299
+ const neB = edgesB.length;
300
+ for (let ia = 0; ia < neA; ia += 2) {
301
+ const a0 = edgesA[ia] * 3, a1 = edgesA[ia + 1] * 3;
302
+ const eax = wvA[a1] - wvA[a0], eay = wvA[a1 + 1] - wvA[a0 + 1], eaz = wvA[a1 + 2] - wvA[a0 + 2];
303
+ const ea2 = eax * eax + eay * eay + eaz * eaz;
304
+ for (let ib = 0; ib < neB; ib += 2) {
305
+ const b0 = edgesB[ib] * 3, b1 = edgesB[ib + 1] * 3;
306
+ const ebx = wvB[b1] - wvB[b0], eby = wvB[b1 + 1] - wvB[b0 + 1], ebz = wvB[b1 + 2] - wvB[b0 + 2];
307
+ const cx = eay * ebz - eaz * eby, cy = eaz * ebx - eax * ebz, cz = eax * eby - eay * ebx;
308
+ // ref² = |ea|²·|eb|² makes len²/ref² = sin²θ, a true (scale-invariant) parallelism test.
309
+ if (test_axis(cx, cy, cz, g_nA, g_nB, 2, ea2 * (ebx * ebx + eby * eby + ebz * ebz))) return false;
310
+ }
311
+ }
312
+
313
+ if (sat.kind === -1) return false;
314
+
315
+ const nx = sat.nx, ny = sat.ny, nz = sat.nz;
316
+ out[0] = nx; out[1] = ny; out[2] = nz;
317
+
318
+ // Edge-cross winner: single contact at the winning edges' closest points.
319
+ if (sat.kind === 2) {
320
+ emit_edge_pair_contact(out, nx, ny, nz, sat.overlap);
321
+ return true;
322
+ }
323
+
324
+ // Face winner: reference / incident polygon clipping. SAT decided WHICH piece owns the
325
+ // reference face, but not which of its two antipodal faces — see select_reference_face.
326
+ const ref_is_A = sat.kind === 0;
327
+ select_reference_face(
328
+ ref_is_A,
329
+ ref_is_A ? -nx : nx,
330
+ ref_is_A ? -ny : ny,
331
+ ref_is_A ? -nz : nz
332
+ );
333
+
334
+ emit_face_manifold(out, ref_is_A, ref_sel.face, nx, ny, nz);
335
+ return true;
336
+ }
337
+
338
+ /**
339
+ * Clip-only entry point the caller supplies the separating axis `n` (B→A,
340
+ * unit) from a robust GJK+EPA query ({@link gjk_epa_penetration}); we only build
341
+ * the multi-point manifold. This is Bullet's `clipHullAgainstHull(sepNormal,…)`
342
+ * with the normal sourced from GJK rather than SAT. Used for LARGE convex
343
+ * polytopes (authored hulls, a convex mesh as one piece) where SAT's O(Fa·Fb +
344
+ * Ea·Eb) edge term is prohibitive but GJK+EPA is O(support queries). Always
345
+ * emits 1 contact (the caller already established penetration): if the face
346
+ * clip empties (a vertex/edge feature) it falls back to the deepest support-pair.
347
+ *
348
+ * @param {Float64Array|number[]} out length CONVEX_CONVEX_OUT_LENGTH
349
+ * @param {{vertices,face_offsets,face_loops}} A @param {{x,y,z}} posA @param {{x,y,z,w}} rotA
350
+ * @param {{vertices,face_offsets,face_loops}} B @param {{x,y,z}} posB @param {{x,y,z,w}} rotB
351
+ * @param {number} nx @param {number} ny @param {number} nz unit axis as
352
+ * returned by {@link gjk_epa_penetration} (A→B); this function re-orients it
353
+ * against the geometric centres before use, so either sign convention works
354
+ * @returns {boolean} always true
355
+ */
356
+ export function convex_hull_clip(out, A, posA, rotA, B, posB, rotB, nx, ny, nz) {
357
+ set_geom(A, B);
358
+ load_world(wvA, A.vertices, g_nA, posA, rotA);
359
+ load_world(wvB, B.vertices, g_nB, posB, rotB);
360
+
361
+ // Orient the axis B→A using the shapes' GEOMETRIC centres (centroids of the
362
+ // world vertices), the same robust reference the SAT path uses. A body-frame
363
+ // guard (transform positions) degenerates when the two origins nearly
364
+ // coincide e.g. a tet resting base-to-base on another, both transforms at
365
+ // the contact plane — leaving the normal mis-oriented and the stack tunnels.
366
+ v3_centroid_v3_buffer(cenA, 0, wvA, 0, g_nA);
367
+ v3_centroid_v3_buffer(cenB, 0, wvB, 0, g_nB);
368
+ if (nx * (cenA[0] - cenB[0]) + ny * (cenA[1] - cenB[1]) + nz * (cenA[2] - cenB[2]) < 0) {
369
+ nx = -nx; ny = -ny; nz = -nz;
370
+ }
371
+ out[0] = nx; out[1] = ny; out[2] = nz;
372
+
373
+ // Reference face = the face (A or B) whose outward normal is most aligned
374
+ // with the axis pointing toward the other body. A's contact face points
375
+ // toward B (along −n); B's toward A (along +n). The flatter (better-aligned)
376
+ // one is the reference.
377
+ select_reference_face(true, -nx, -ny, -nz);
378
+ const bestA = ref_sel.score;
379
+ const faceA = ref_sel.face;
380
+
381
+ select_reference_face(false, nx, ny, nz);
382
+ const bestB = ref_sel.score;
383
+ const faceB = ref_sel.face;
384
+
385
+ const ref_is_A = bestA >= bestB;
386
+ emit_face_manifold(out, ref_is_A, ref_is_A ? faceA : faceB, nx, ny, nz);
387
+
388
+ if ((out[3] | 0) === 0) {
389
+ const overlap = projection_overlap(nx, ny, nz);
390
+ emit_single_contact(out, nx, ny, nz, overlap > 0 ? overlap : 0);
391
+ }
392
+ return true;
393
+ }
394
+
395
+ /** Overlap of the two pieces' projections onto axis `n` (B→A); A is on the +n side. */
396
+ function projection_overlap(nx, ny, nz) {
397
+ let minA = Infinity, maxB = -Infinity;
398
+ for (let i = 0; i < g_nA; i++) {
399
+ const d = v3_dot(nx, ny, nz, wvA[i * 3], wvA[i * 3 + 1], wvA[i * 3 + 2]);
400
+ if (d < minA) minA = d;
401
+ }
402
+ for (let i = 0; i < g_nB; i++) {
403
+ const d = v3_dot(nx, ny, nz, wvB[i * 3], wvB[i * 3 + 1], wvB[i * 3 + 2]);
404
+ if (d > maxB) maxB = d;
405
+ }
406
+ return maxB - minA;
407
+ }
408
+
409
+ /** Single deepest support-pair contact along axis `n` (B→A). */
410
+ function emit_single_contact(out, nx, ny, nz, depth) {
411
+ let sa = -Infinity, ai = 0;
412
+ for (let i = 0; i < g_nA; i++) {
413
+ const d = -v3_dot(nx, ny, nz, wvA[i * 3], wvA[i * 3 + 1], wvA[i * 3 + 2]);
414
+ if (d > sa) { sa = d; ai = i; }
415
+ }
416
+ let sb = -Infinity, bi = 0;
417
+ for (let i = 0; i < g_nB; i++) {
418
+ const d = v3_dot(nx, ny, nz, wvB[i * 3], wvB[i * 3 + 1], wvB[i * 3 + 2]);
419
+ if (d > sb) { sb = d; bi = i; }
420
+ }
421
+ out[3] = 1;
422
+ out[4] = wvA[ai * 3]; out[5] = wvA[ai * 3 + 1]; out[6] = wvA[ai * 3 + 2];
423
+ out[7] = wvB[bi * 3]; out[8] = wvB[bi * 3 + 1]; out[9] = wvB[bi * 3 + 2];
424
+ out[10] = depth;
425
+ }
426
+
427
+ const scratch_st = new Float64Array(2);
428
+ const scratch_edge = new Int32Array(4); // [a0, a1] then [b0, b1] vertex indices
429
+
430
+ /**
431
+ * Find a piece's SUPPORTING EDGE along direction d: the face-loop edge that
432
+ * maximises the SMALLER of its two endpoint projections. For an edge-cross
433
+ * SAT winner the true contact edge lies perpendicular to the axis, so both
434
+ * its endpoints project to the common maximum and its min-endpoint
435
+ * projection beats every other edge's. (Recording the SAT loop's winning
436
+ * pair instead does NOT work: parallel edge pairs alias one axis with equal
437
+ * overlap, and the first-tested pair is usually not the touching one.)
438
+ *
439
+ * @param {Float64Array} wv world vertices
440
+ * @param {Uint32Array} fo face offsets
441
+ * @param {Uint32Array} fl face loops
442
+ * @param {number} fcount face count
443
+ * @param {number} dx @param {number} dy @param {number} dz
444
+ * @param {Int32Array} out_pair 2 slots written at `pair_off`
445
+ * @param {number} pair_off
446
+ */
447
+ function find_support_edge(wv, fo, fl, fcount, dx, dy, dz, out_pair, pair_off) {
448
+ let best = -Infinity;
449
+ for (let f = 0; f < fcount; f++) {
450
+ const start = fo[f], len = fo[f + 1] - start;
451
+ for (let i = 0; i < len; i++) {
452
+ const v0 = fl[start + i] * 3;
453
+ const v1 = fl[start + (i + 1) % len] * 3;
454
+ const d0 = wv[v0] * dx + wv[v0 + 1] * dy + wv[v0 + 2] * dz;
455
+ const d1 = wv[v1] * dx + wv[v1 + 1] * dy + wv[v1 + 2] * dz;
456
+ const m = d0 < d1 ? d0 : d1;
457
+ if (m > best) {
458
+ best = m;
459
+ out_pair[pair_off] = v0;
460
+ out_pair[pair_off + 1] = v1;
461
+ }
462
+ }
463
+ }
464
+ }
465
+
466
+ /**
467
+ * Single contact for an edge-cross SAT winner, at the CLOSEST POINTS of the
468
+ * two supporting edges. A support-VERTEX pick is ambiguous here: every point
469
+ * of the contact edge projects identically onto the cross axis, so the
470
+ * argmax lands on an arbitrary endpoint and hands the solver a lever arm up
471
+ * to half an edge length off - resting boxes twist.
472
+ */
473
+ function emit_edge_pair_contact(out, nx, ny, nz, depth) {
474
+ // A's supporting edge faces the contact (toward B): extreme along -n;
475
+ // B's faces A: extreme along +n. (n is B -> A.)
476
+ find_support_edge(wvA, g_foA, g_flA, g_fA, -nx, -ny, -nz, scratch_edge, 0);
477
+ find_support_edge(wvB, g_foB, g_flB, g_fB, nx, ny, nz, scratch_edge, 2);
478
+ const a0 = scratch_edge[0], a1 = scratch_edge[1];
479
+ const b0 = scratch_edge[2], b1 = scratch_edge[3];
480
+
481
+ line3_compute_segment_segment_closest_points(
482
+ scratch_st,
483
+ wvA[a0], wvA[a0 + 1], wvA[a0 + 2],
484
+ wvA[a1], wvA[a1 + 1], wvA[a1 + 2],
485
+ wvB[b0], wvB[b0 + 1], wvB[b0 + 2],
486
+ wvB[b1], wvB[b1 + 1], wvB[b1 + 2]
487
+ );
488
+ const s = scratch_st[0];
489
+ const t = scratch_st[1];
490
+ out[3] = 1;
491
+ out[4] = wvA[a0] + (wvA[a1] - wvA[a0]) * s;
492
+ out[5] = wvA[a0 + 1] + (wvA[a1 + 1] - wvA[a0 + 1]) * s;
493
+ out[6] = wvA[a0 + 2] + (wvA[a1 + 2] - wvA[a0 + 2]) * s;
494
+ out[7] = wvB[b0] + (wvB[b1] - wvB[b0]) * t;
495
+ out[8] = wvB[b0 + 1] + (wvB[b1 + 1] - wvB[b0 + 1]) * t;
496
+ out[9] = wvB[b0 + 2] + (wvB[b1 + 2] - wvB[b0 + 2]) * t;
497
+ out[10] = depth;
498
+ }
499
+
500
+ /**
501
+ * Reference/incident polygon clipping given the reference face. Writes the
502
+ * manifold (count + contacts) into `out`; leaves out[0..2] (the normal) as set
503
+ * by the caller. Shared by both the SAT and GJK+EPA entry points.
504
+ *
505
+ * @param {boolean} ref_is_A reference face belongs to A (else B)
506
+ * @param {number} ref_face reference face index within its piece
507
+ * @param {number} nx @param {number} ny @param {number} nz axis (B→A), unit
508
+ */
509
+ function emit_face_manifold(out, ref_is_A, ref_face, nx, ny, nz) {
510
+ const ref_wv = ref_is_A ? wvA : wvB;
511
+ const ref_fo = ref_is_A ? g_foA : g_foB;
512
+ const ref_fl = ref_is_A ? g_flA : g_flB;
513
+ const inc_wv = ref_is_A ? wvB : wvA;
514
+ const inc_fo = ref_is_A ? g_foB : g_foA;
515
+ const inc_fl = ref_is_A ? g_flB : g_flA;
516
+ const inc_fcount = ref_is_A ? g_fB : g_fA;
517
+
518
+ // Reference outward normal points ref → incident: −n if ref is A, +n if ref is B.
519
+ const rmx = ref_is_A ? -nx : nx, rmy = ref_is_A ? -ny : ny, rmz = ref_is_A ? -nz : nz;
520
+
521
+ const ref_s = ref_fo[ref_face], ref_len = ref_fo[ref_face + 1] - ref_s;
522
+ const r0 = ref_fl[ref_s] * 3;
523
+ const r0x = ref_wv[r0], r0y = ref_wv[r0 + 1], r0z = ref_wv[r0 + 2];
524
+
525
+ // Incident face = the polygon on the other piece most antiparallel to rm.
526
+ let inc_face = 0, most_anti = Infinity;
527
+ for (let f = 0; f < inc_fcount; f++) {
528
+ face_normal(tmp_n, inc_wv, inc_fl, inc_fo[f], inc_fo[f + 1]);
529
+ const l = v3_length(tmp_n[0], tmp_n[1], tmp_n[2]) || 1;
530
+ const dot = v3_dot(tmp_n[0], tmp_n[1], tmp_n[2], rmx, rmy, rmz) / l;
531
+ if (dot < most_anti) { most_anti = dot; inc_face = f; }
532
+ }
533
+
534
+ // Incident polygon (world). Worst-case working size: the incident loop
535
+ // plus one extra vertex per reference side-plane clip (a convex polygon
536
+ // clipped by a half-space gains at most one vertex) — grow the shared
537
+ // scratch to fit, so wide coplanar-merged faces aren't truncated into
538
+ // OOB reads (NaN / stale contacts).
539
+ const inc_s = inc_fo[inc_face], inc_len = inc_fo[inc_face + 1] - inc_s;
540
+ const max_poly_verts = inc_len + ref_len;
541
+ if (poly_in.length < max_poly_verts * 3) {
542
+ poly_in = new Float64Array(max_poly_verts * 3);
543
+ poly_out = new Float64Array(max_poly_verts * 3);
544
+ cand = new Float64Array(max_poly_verts * 4);
545
+ }
546
+ let n_poly = inc_len;
547
+ for (let i = 0; i < inc_len; i++) {
548
+ const vi = inc_fl[inc_s + i] * 3;
549
+ poly_in[i * 3] = inc_wv[vi]; poly_in[i * 3 + 1] = inc_wv[vi + 1]; poly_in[i * 3 + 2] = inc_wv[vi + 2];
550
+ }
551
+
552
+ // Reference polygon centroid (orients side planes inward).
553
+ let rcx = 0, rcy = 0, rcz = 0;
554
+ for (let i = 0; i < ref_len; i++) {
555
+ const vi = ref_fl[ref_s + i] * 3;
556
+ rcx += ref_wv[vi]; rcy += ref_wv[vi + 1]; rcz += ref_wv[vi + 2];
557
+ }
558
+ rcx /= ref_len; rcy /= ref_len; rcz /= ref_len;
559
+
560
+ // Clip the incident polygon against each reference-face side plane.
561
+ let src = poly_in, dst = poly_out;
562
+ for (let e = 0; e < ref_len && n_poly > 0; e++) {
563
+ const va = ref_fl[ref_s + e] * 3, vb = ref_fl[ref_s + (e + 1) % ref_len] * 3;
564
+ const edx = ref_wv[vb] - ref_wv[va], edy = ref_wv[vb + 1] - ref_wv[va + 1], edz = ref_wv[vb + 2] - ref_wv[va + 2];
565
+ let sx = edy * rmz - edz * rmy, sy = edz * rmx - edx * rmz, sz = edx * rmy - edy * rmx;
566
+ const pax = ref_wv[va], pay = ref_wv[va + 1], paz = ref_wv[va + 2];
567
+ if ((rcx - pax) * sx + (rcy - pay) * sy + (rcz - paz) * sz > 0) { sx = -sx; sy = -sy; sz = -sz; }
568
+ n_poly = clip_poly(src, n_poly, dst, sx, sy, sz, pax, pay, paz);
569
+ const t = src; src = dst; dst = t;
570
+ }
571
+ if (n_poly === 0) { out[3] = 0; return; }
572
+
573
+ let nc = 0;
574
+ for (let i = 0; i < n_poly; i++) {
575
+ const px = src[i * 3], py = src[i * 3 + 1], pz = src[i * 3 + 2];
576
+ const sep = (px - r0x) * rmx + (py - r0y) * rmy + (pz - r0z) * rmz;
577
+ const depth = -sep;
578
+ if (depth < 0) continue;
579
+ cand[nc * 4] = px; cand[nc * 4 + 1] = py; cand[nc * 4 + 2] = pz; cand[nc * 4 + 3] = depth;
580
+ nc++;
581
+ }
582
+ if (nc === 0) { out[3] = 0; return; }
583
+
584
+ const kept = reduce_manifold_contacts(cand, nc, 4, MAX_CONTACTS, 3);
585
+ out[3] = kept;
586
+ for (let k = 0; k < kept; k++) {
587
+ const px = cand[k * 4], py = cand[k * 4 + 1], pz = cand[k * 4 + 2], depth = cand[k * 4 + 3];
588
+ const d2p = (px - r0x) * rmx + (py - r0y) * rmy + (pz - r0z) * rmz;
589
+ const rpx = px - rmx * d2p, rpy = py - rmy * d2p, rpz = pz - rmz * d2p;
590
+ const base = 4 + k * CONTACT_STRIDE;
591
+ if (ref_is_A) {
592
+ out[base] = rpx; out[base + 1] = rpy; out[base + 2] = rpz;
593
+ out[base + 3] = px; out[base + 4] = py; out[base + 5] = pz;
594
+ } else {
595
+ out[base] = px; out[base + 1] = py; out[base + 2] = pz;
596
+ out[base + 3] = rpx; out[base + 4] = rpy; out[base + 5] = rpz;
597
+ }
598
+ out[base + 6] = depth;
599
+ }
600
+ }
601
+
602
+ /**
603
+ * Sutherland–Hodgman: keep polygon points where (P − a)·s ≤ 0, with crossings.
604
+ * Capacity-guarded on BOTH emit branches: `m` must never pass `dst`'s capacity
605
+ * or the dropped OOB writes leave stale/NaN points that later reads consume
606
+ * (the buffers are pre-sized to inc_len + ref_len, so the guard is a backstop
607
+ * for degenerate input, not the normal bound).
608
+ */
609
+ function clip_poly(src, n, dst, sx, sy, sz, ax, ay, az) {
610
+ const cap = (dst.length / 3) | 0;
611
+ let m = 0;
612
+ for (let i = 0; i < n && m < cap; i++) {
613
+ const j = (i + 1) % n;
614
+ const px = src[i * 3], py = src[i * 3 + 1], pz = src[i * 3 + 2];
615
+ const qx = src[j * 3], qy = src[j * 3 + 1], qz = src[j * 3 + 2];
616
+ const dp = v3_dot(px - ax, py - ay, pz - az, sx, sy, sz);
617
+ const dq = v3_dot(qx - ax, qy - ay, qz - az, sx, sy, sz);
618
+ const p_in = dp <= 0, q_in = dq <= 0;
619
+ if (p_in) { dst[m * 3] = px; dst[m * 3 + 1] = py; dst[m * 3 + 2] = pz; m++; }
620
+ if (p_in !== q_in && m < cap) {
621
+ const t = dp / (dp - dq);
622
+ dst[m * 3] = px + (qx - px) * t;
623
+ dst[m * 3 + 1] = py + (qy - py) * t;
624
+ dst[m * 3 + 2] = pz + (qz - pz) * t;
625
+ m++;
626
+ }
627
+ }
628
+ return m;
629
+ }
630
+
631
+ // Contact reduction (deepest + farthest-point spread) is shared with
632
+ // box_box_manifold via reduce_manifold_contacts (stride 4).