@woosh/meep-engine 3.37.0 → 3.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1016) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/build/bundle-worker-terrain.js +1 -1
  3. package/package.json +1 -1
  4. package/src/core/binary/BinaryBuffer.d.ts +11 -0
  5. package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
  6. package/src/core/binary/BinaryBuffer.js +30 -0
  7. package/src/core/bvh2/bvh3/query/bvh_query_user_data_intersects_aabb.d.ts.map +1 -1
  8. package/src/core/bvh2/bvh3/query/bvh_query_user_data_intersects_aabb.js +28 -7
  9. package/src/core/geom/3d/aabb/aabb3_transform_oriented.d.ts +15 -0
  10. package/src/core/geom/3d/aabb/aabb3_transform_oriented.d.ts.map +1 -1
  11. package/src/core/geom/3d/aabb/aabb3_transform_oriented.js +41 -0
  12. package/src/core/geom/3d/aabb/aabb3_transform_oriented_inverse.d.ts +12 -0
  13. package/src/core/geom/3d/aabb/aabb3_transform_oriented_inverse.d.ts.map +1 -1
  14. package/src/core/geom/3d/aabb/aabb3_transform_oriented_inverse.js +27 -0
  15. package/src/core/geom/3d/gjk/gjk.js +3 -3
  16. package/src/core/geom/3d/gjk/gjk_distance.d.ts +94 -0
  17. package/src/core/geom/3d/gjk/gjk_distance.d.ts.map +1 -0
  18. package/src/core/geom/3d/gjk/gjk_distance.js +782 -0
  19. package/src/core/geom/3d/gjk/gjk_epa_penetration.d.ts +5 -4
  20. package/src/core/geom/3d/gjk/gjk_epa_penetration.d.ts.map +1 -1
  21. package/src/core/geom/3d/gjk/gjk_epa_penetration.js +14 -9
  22. package/src/core/geom/3d/gjk/minkowski_support.d.ts +11 -7
  23. package/src/core/geom/3d/gjk/minkowski_support.d.ts.map +1 -1
  24. package/src/core/geom/3d/gjk/minkowski_support.js +33 -9
  25. package/src/core/geom/3d/gjk/mpr.d.ts.map +1 -1
  26. package/src/core/geom/3d/gjk/mpr.js +26 -5
  27. package/src/core/geom/3d/line/line3_compute_segment_closest_point_to_aabb3_t.d.ts +15 -0
  28. package/src/core/geom/3d/line/line3_compute_segment_closest_point_to_aabb3_t.d.ts.map +1 -1
  29. package/src/core/geom/3d/line/line3_compute_segment_closest_point_to_aabb3_t.js +106 -33
  30. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale.d.ts +2 -1
  31. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale.d.ts.map +1 -1
  32. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale.js +4 -8
  33. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale_array.d.ts +32 -0
  34. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale_array.d.ts.map +1 -0
  35. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale_array.js +85 -0
  36. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale_scalar.d.ts +3 -3
  37. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale_scalar.d.ts.map +1 -1
  38. package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale_scalar.js +24 -34
  39. package/src/core/geom/3d/quaternion/quat3_integrate.d.ts +17 -0
  40. package/src/core/geom/3d/quaternion/quat3_integrate.d.ts.map +1 -1
  41. package/src/core/geom/3d/quaternion/quat3_integrate.js +45 -4
  42. package/src/core/geom/3d/quaternion/quat3_multiply.d.ts +16 -0
  43. package/src/core/geom/3d/quaternion/quat3_multiply.d.ts.map +1 -1
  44. package/src/core/geom/3d/quaternion/quat3_multiply.js +25 -0
  45. package/src/core/geom/3d/quaternion/quat3_nlerp.d.ts +18 -0
  46. package/src/core/geom/3d/quaternion/quat3_nlerp.d.ts.map +1 -1
  47. package/src/core/geom/3d/quaternion/quat3_nlerp.js +45 -0
  48. package/src/core/geom/3d/quaternion/quat3_shortest_arc.d.ts +17 -0
  49. package/src/core/geom/3d/quaternion/quat3_shortest_arc.d.ts.map +1 -1
  50. package/src/core/geom/3d/quaternion/quat3_shortest_arc.js +155 -94
  51. package/src/core/geom/3d/quaternion/quat3_to_matrix3.d.ts +12 -0
  52. package/src/core/geom/3d/quaternion/quat3_to_matrix3.d.ts.map +1 -1
  53. package/src/core/geom/3d/quaternion/quat3_to_matrix3.js +31 -0
  54. package/src/core/geom/3d/shape/AbstractShape3D.d.ts +20 -6
  55. package/src/core/geom/3d/shape/AbstractShape3D.d.ts.map +1 -1
  56. package/src/core/geom/3d/shape/AbstractShape3D.js +20 -6
  57. package/src/core/geom/3d/shape/BoxShape3D.d.ts +1 -1
  58. package/src/core/geom/3d/shape/BoxShape3D.d.ts.map +1 -1
  59. package/src/core/geom/3d/shape/BoxShape3D.js +5 -1
  60. package/src/core/geom/3d/shape/CapsuleShape3D.d.ts +1 -1
  61. package/src/core/geom/3d/shape/CapsuleShape3D.d.ts.map +1 -1
  62. package/src/core/geom/3d/shape/CapsuleShape3D.js +5 -1
  63. package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts +25 -11
  64. package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts.map +1 -1
  65. package/src/core/geom/3d/shape/ConvexHullShape3D.js +392 -22
  66. package/src/core/geom/3d/shape/CylinderShape3D.d.ts +8 -7
  67. package/src/core/geom/3d/shape/CylinderShape3D.d.ts.map +1 -1
  68. package/src/core/geom/3d/shape/CylinderShape3D.js +12 -7
  69. package/src/core/geom/3d/shape/HeightMapShape3D.d.ts +51 -8
  70. package/src/core/geom/3d/shape/HeightMapShape3D.d.ts.map +1 -1
  71. package/src/core/geom/3d/shape/HeightMapShape3D.js +260 -14
  72. package/src/core/geom/3d/shape/MeshShape3D.d.ts +61 -7
  73. package/src/core/geom/3d/shape/MeshShape3D.d.ts.map +1 -1
  74. package/src/core/geom/3d/shape/MeshShape3D.js +111 -20
  75. package/src/core/geom/3d/shape/PointShape3D.d.ts +1 -1
  76. package/src/core/geom/3d/shape/PointShape3D.d.ts.map +1 -1
  77. package/src/core/geom/3d/shape/PointShape3D.js +1 -1
  78. package/src/core/geom/3d/shape/PosedShape3D.d.ts +9 -0
  79. package/src/core/geom/3d/shape/PosedShape3D.d.ts.map +1 -1
  80. package/src/core/geom/3d/shape/PosedShape3D.js +36 -6
  81. package/src/core/geom/3d/shape/SphereShape3D.d.ts +1 -1
  82. package/src/core/geom/3d/shape/SphereShape3D.d.ts.map +1 -1
  83. package/src/core/geom/3d/shape/SphereShape3D.js +5 -1
  84. package/src/core/geom/3d/shape/TransformedShape3D.d.ts +12 -10
  85. package/src/core/geom/3d/shape/TransformedShape3D.d.ts.map +1 -1
  86. package/src/core/geom/3d/shape/TransformedShape3D.js +53 -19
  87. package/src/core/geom/3d/shape/Triangle3D.d.ts +1 -1
  88. package/src/core/geom/3d/shape/Triangle3D.d.ts.map +1 -1
  89. package/src/core/geom/3d/shape/Triangle3D.js +5 -1
  90. package/src/core/geom/3d/shape/UnionShape3D.d.ts +1 -1
  91. package/src/core/geom/3d/shape/UnionShape3D.d.ts.map +1 -1
  92. package/src/core/geom/3d/shape/UnionShape3D.js +19 -2
  93. package/src/core/geom/3d/shape/sdf/sdf3_box.d.ts +14 -0
  94. package/src/core/geom/3d/shape/sdf/sdf3_box.d.ts.map +1 -1
  95. package/src/core/geom/3d/shape/sdf/sdf3_box.js +67 -5
  96. package/src/core/geom/3d/shape/sdf/sdf3_capsule.d.ts +14 -0
  97. package/src/core/geom/3d/shape/sdf/sdf3_capsule.d.ts.map +1 -1
  98. package/src/core/geom/3d/shape/sdf/sdf3_capsule.js +61 -3
  99. package/src/core/geom/3d/shape/sdf/sdf3_cylinder.d.ts +14 -0
  100. package/src/core/geom/3d/shape/sdf/sdf3_cylinder.d.ts.map +1 -1
  101. package/src/core/geom/3d/shape/sdf/sdf3_cylinder.js +63 -4
  102. package/src/core/geom/3d/shape/sdf/sdf3_plane.d.ts +15 -0
  103. package/src/core/geom/3d/shape/sdf/sdf3_plane.d.ts.map +1 -1
  104. package/src/core/geom/3d/shape/sdf/sdf3_plane.js +64 -2
  105. package/src/core/geom/3d/shape/sdf/sdf3_sphere.d.ts +21 -0
  106. package/src/core/geom/3d/shape/sdf/sdf3_sphere.d.ts.map +1 -1
  107. package/src/core/geom/3d/shape/sdf/sdf3_sphere.js +66 -3
  108. package/src/core/geom/3d/shape/shape3_mesh_from_geometry.d.ts +2 -0
  109. package/src/core/geom/3d/shape/shape3_mesh_from_geometry.d.ts.map +1 -1
  110. package/src/core/geom/3d/shape/shape3_mesh_from_geometry.js +7 -0
  111. package/src/core/geom/3d/shape/util/mesh_compute_triangle_edge_flags.d.ts +41 -0
  112. package/src/core/geom/3d/shape/util/mesh_compute_triangle_edge_flags.d.ts.map +1 -0
  113. package/src/core/geom/3d/shape/util/mesh_compute_triangle_edge_flags.js +538 -0
  114. package/src/core/geom/3d/sphere/harmonics/sh_basis_at.d.ts +31 -0
  115. package/src/core/geom/3d/sphere/harmonics/sh_basis_at.d.ts.map +1 -0
  116. package/src/core/geom/3d/sphere/harmonics/sh_basis_at.js +85 -0
  117. package/src/core/geom/3d/sphere/harmonics/sh_vmf_window.d.ts +18 -0
  118. package/src/core/geom/3d/sphere/harmonics/sh_vmf_window.d.ts.map +1 -0
  119. package/src/core/geom/3d/sphere/harmonics/sh_vmf_window.js +19 -0
  120. package/src/core/geom/3d/triangle/TriangleEdgeFlags.d.ts +49 -0
  121. package/src/core/geom/3d/triangle/TriangleEdgeFlags.d.ts.map +1 -0
  122. package/src/core/geom/3d/triangle/TriangleEdgeFlags.js +55 -0
  123. package/src/core/geom/3d/triangle/tri3_classify_shared_edge.d.ts +42 -0
  124. package/src/core/geom/3d/triangle/tri3_classify_shared_edge.d.ts.map +1 -0
  125. package/src/core/geom/3d/triangle/tri3_classify_shared_edge.js +85 -0
  126. package/src/core/geom/3d/triangle/tri3_closest_point.d.ts +13 -0
  127. package/src/core/geom/3d/triangle/tri3_closest_point.d.ts.map +1 -1
  128. package/src/core/geom/3d/triangle/tri3_closest_point.js +36 -1
  129. package/src/core/geom/3d/triangle/tri3_closest_point_barycentric.d.ts +14 -0
  130. package/src/core/geom/3d/triangle/tri3_closest_point_barycentric.d.ts.map +1 -1
  131. package/src/core/geom/3d/triangle/tri3_closest_point_barycentric.js +40 -0
  132. package/src/core/geom/vec3/v3_quaternion_apply.d.ts +19 -0
  133. package/src/core/geom/vec3/v3_quaternion_apply.d.ts.map +1 -1
  134. package/src/core/geom/vec3/v3_quaternion_apply.js +32 -0
  135. package/src/core/geom/vec3/v3_quaternion_apply_inverse.d.ts +19 -0
  136. package/src/core/geom/vec3/v3_quaternion_apply_inverse.d.ts.map +1 -1
  137. package/src/core/geom/vec3/v3_quaternion_apply_inverse.js +32 -0
  138. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +135 -10
  139. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
  140. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +338 -105
  141. package/src/engine/control/first-person/abilities/Ability.d.ts +14 -5
  142. package/src/engine/control/first-person/abilities/Ability.d.ts.map +1 -1
  143. package/src/engine/control/first-person/abilities/Ability.js +14 -5
  144. package/src/engine/control/first-person/abilities/LedgeGrab.d.ts.map +1 -1
  145. package/src/engine/control/first-person/abilities/LedgeGrab.js +16 -12
  146. package/src/engine/control/first-person/abilities/Mantle.d.ts.map +1 -1
  147. package/src/engine/control/first-person/abilities/Mantle.js +5 -1
  148. package/src/engine/control/first-person/abilities/Slide.js +1 -1
  149. package/src/engine/control/first-person/collision/KinematicMover.d.ts +92 -14
  150. package/src/engine/control/first-person/collision/KinematicMover.d.ts.map +1 -1
  151. package/src/engine/control/first-person/collision/KinematicMover.js +218 -37
  152. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts +5 -0
  153. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts.map +1 -1
  154. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.js +17 -10
  155. package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
  156. package/src/engine/ecs/EntityComponentDataset.js +27 -13
  157. package/src/engine/ecs/storage/populateEngineSerializationRegistry.d.ts.map +1 -1
  158. package/src/engine/ecs/storage/populateEngineSerializationRegistry.js +6 -0
  159. package/src/engine/ecs/transform/TRANSFORM64_EVENT_PLACED.d.ts +11 -0
  160. package/src/engine/ecs/transform/TRANSFORM64_EVENT_PLACED.d.ts.map +1 -0
  161. package/src/engine/ecs/transform/TRANSFORM64_EVENT_PLACED.js +10 -0
  162. package/src/engine/ecs/transform/Transform64.d.ts +4 -2
  163. package/src/engine/ecs/transform/Transform64.d.ts.map +1 -1
  164. package/src/engine/ecs/transform/Transform64.js +10 -16
  165. package/src/engine/ecs/transform-attachment/TransformAttachmentSystem.d.ts.map +1 -1
  166. package/src/engine/ecs/transform-attachment/TransformAttachmentSystem.js +16 -0
  167. package/src/engine/graphics/ecs/water/Water.d.ts +26 -34
  168. package/src/engine/graphics/ecs/water/Water.d.ts.map +1 -1
  169. package/src/engine/graphics/ecs/water/Water.js +42 -36
  170. package/src/engine/graphics/ecs/water/WaterSerializationAdapter.d.ts.map +1 -1
  171. package/src/engine/graphics/ecs/water/WaterSerializationAdapter.js +38 -62
  172. package/src/engine/graphics/ecs/water/WaterSerializationUpgrader_1_2.d.ts +6 -0
  173. package/src/engine/graphics/ecs/water/WaterSerializationUpgrader_1_2.d.ts.map +1 -0
  174. package/src/engine/graphics/ecs/water/WaterSerializationUpgrader_1_2.js +27 -0
  175. package/src/engine/graphics/ecs/water/WaterSerializationUpgrader_2_3.d.ts +12 -0
  176. package/src/engine/graphics/ecs/water/WaterSerializationUpgrader_2_3.d.ts.map +1 -0
  177. package/src/engine/graphics/ecs/water/WaterSerializationUpgrader_2_3.js +45 -0
  178. package/src/engine/graphics/ecs/water/WaterWaves.d.ts +33 -0
  179. package/src/engine/graphics/ecs/water/WaterWaves.d.ts.map +1 -0
  180. package/src/engine/graphics/ecs/water/WaterWaves.js +46 -0
  181. package/src/engine/graphics/ecs/water/WaterWavesSerializationAdapter.d.ts +17 -0
  182. package/src/engine/graphics/ecs/water/WaterWavesSerializationAdapter.d.ts.map +1 -0
  183. package/src/engine/graphics/ecs/water/WaterWavesSerializationAdapter.js +26 -0
  184. package/src/engine/graphics/texture/3d/scs3d_sample_linear.d.ts +22 -0
  185. package/src/engine/graphics/texture/3d/scs3d_sample_linear.d.ts.map +1 -1
  186. package/src/engine/graphics/texture/3d/scs3d_sample_linear.js +43 -1
  187. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts +29 -3
  188. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  189. package/src/engine/graphics/texture/sampler/Sampler2D.js +102 -14
  190. package/src/engine/graphics3/WaterSystem.d.ts +58 -6
  191. package/src/engine/graphics3/WaterSystem.d.ts.map +1 -1
  192. package/src/engine/graphics3/WaterSystem.js +423 -293
  193. package/src/engine/interpolation/BinaryInterpolationAdapter.d.ts +10 -4
  194. package/src/engine/interpolation/BinaryInterpolationAdapter.d.ts.map +1 -1
  195. package/src/engine/interpolation/BinaryInterpolationAdapter.js +11 -5
  196. package/src/engine/interpolation/InterpolationLog.d.ts +11 -5
  197. package/src/engine/interpolation/InterpolationLog.d.ts.map +1 -1
  198. package/src/engine/interpolation/InterpolationLog.js +12 -6
  199. package/src/engine/interpolation/InterpolationSystem.d.ts.map +1 -1
  200. package/src/engine/interpolation/InterpolationSystem.js +39 -8
  201. package/src/engine/interpolation/PoseInterpolationAdapter.d.ts +1 -1
  202. package/src/engine/interpolation/PoseInterpolationAdapter.d.ts.map +1 -1
  203. package/src/engine/interpolation/PoseInterpolationAdapter.js +51 -22
  204. package/src/engine/interpolation/TransformPoseSerializationAdapter.d.ts.map +1 -1
  205. package/src/engine/interpolation/TransformPoseSerializationAdapter.js +18 -23
  206. package/src/engine/network/adapters/QuaternionInterpolationAdapter.d.ts +1 -1
  207. package/src/engine/network/adapters/QuaternionInterpolationAdapter.d.ts.map +1 -1
  208. package/src/engine/network/adapters/QuaternionInterpolationAdapter.js +3 -1
  209. package/src/engine/network/adapters/TransformInterpolationAdapter.d.ts +1 -1
  210. package/src/engine/network/adapters/TransformInterpolationAdapter.d.ts.map +1 -1
  211. package/src/engine/network/adapters/TransformInterpolationAdapter.js +3 -1
  212. package/src/engine/network/adapters/Vector3InterpolationAdapter.d.ts.map +1 -1
  213. package/src/engine/network/adapters/Vector3InterpolationAdapter.js +5 -2
  214. package/src/engine/physics/body/SolverBodyState.d.ts.map +1 -1
  215. package/src/engine/physics/body/SolverBodyState.js +4 -5
  216. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts +12 -0
  217. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts.map +1 -1
  218. package/src/engine/physics/broadphase/compute_fat_world_aabb.js +28 -3
  219. package/src/engine/physics/ccd/linear_sweep.d.ts +42 -12
  220. package/src/engine/physics/ccd/linear_sweep.d.ts.map +1 -1
  221. package/src/engine/physics/ccd/linear_sweep.js +1131 -97
  222. package/src/engine/physics/cloth/collider/ClothColliderIndex.d.ts +26 -14
  223. package/src/engine/physics/cloth/collider/ClothColliderIndex.d.ts.map +1 -1
  224. package/src/engine/physics/cloth/collider/ClothColliderIndex.js +221 -52
  225. package/src/engine/physics/cloth/collider/cloth_collider_bounds.d.ts +30 -0
  226. package/src/engine/physics/cloth/collider/cloth_collider_bounds.d.ts.map +1 -1
  227. package/src/engine/physics/cloth/collider/cloth_collider_bounds.js +117 -24
  228. package/src/engine/physics/cloth/collider/cloth_collider_sdf.d.ts +46 -3
  229. package/src/engine/physics/cloth/collider/cloth_collider_sdf.d.ts.map +1 -1
  230. package/src/engine/physics/cloth/collider/cloth_collider_sdf.js +116 -68
  231. package/src/engine/physics/cloth/ecs/ClothColliderFlags.js +2 -1
  232. package/src/engine/physics/cloth/ecs/ClothColliderSystem.d.ts +10 -1
  233. package/src/engine/physics/cloth/ecs/ClothColliderSystem.d.ts.map +1 -1
  234. package/src/engine/physics/cloth/ecs/ClothColliderSystem.js +36 -14
  235. package/src/engine/physics/cloth/ecs/ClothInstance.d.ts +15 -2
  236. package/src/engine/physics/cloth/ecs/ClothInstance.d.ts.map +1 -1
  237. package/src/engine/physics/cloth/ecs/ClothInstance.js +17 -2
  238. package/src/engine/physics/cloth/ecs/ClothWorld.d.ts.map +1 -1
  239. package/src/engine/physics/cloth/ecs/ClothWorld.js +78 -53
  240. package/src/engine/physics/cloth/ecs/cloth_gather_colliders.d.ts +18 -20
  241. package/src/engine/physics/cloth/ecs/cloth_gather_colliders.d.ts.map +1 -1
  242. package/src/engine/physics/cloth/ecs/cloth_gather_colliders.js +185 -128
  243. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.d.ts.map +1 -1
  244. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.js +46 -39
  245. package/src/engine/physics/cloth/ecs/cloth_write_back.d.ts.map +1 -1
  246. package/src/engine/physics/cloth/ecs/cloth_write_back.js +41 -36
  247. package/src/engine/physics/cloth/playground/garment_build.js +6 -6
  248. package/src/engine/physics/cloth/playground/garment_main.js +18 -14
  249. package/src/engine/physics/cloth/solver/cloth_contact_find.d.ts.map +1 -1
  250. package/src/engine/physics/cloth/solver/cloth_contact_find.js +8 -5
  251. package/src/engine/physics/cloth/solver/cloth_solve_vertex.d.ts.map +1 -1
  252. package/src/engine/physics/cloth/solver/cloth_solve_vertex.js +8 -5
  253. package/src/engine/physics/cloth/solver/constraint/cloth_contact_row.d.ts.map +1 -1
  254. package/src/engine/physics/cloth/solver/constraint/cloth_contact_row.js +15 -15
  255. package/src/engine/physics/cloth/solver/find_non_finite_cloth_state.d.ts +5 -0
  256. package/src/engine/physics/cloth/solver/find_non_finite_cloth_state.d.ts.map +1 -1
  257. package/src/engine/physics/cloth/solver/find_non_finite_cloth_state.js +32 -9
  258. package/src/engine/physics/constraint/solve_constraints.d.ts +50 -8
  259. package/src/engine/physics/constraint/solve_constraints.d.ts.map +1 -1
  260. package/src/engine/physics/constraint/solve_constraints.js +703 -429
  261. package/src/engine/physics/contact/ManifoldStore.d.ts +12 -0
  262. package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -1
  263. package/src/engine/physics/contact/ManifoldStore.js +32 -0
  264. package/src/engine/physics/ecs/BodyKind.d.ts +16 -8
  265. package/src/engine/physics/ecs/BodyKind.d.ts.map +1 -1
  266. package/src/engine/physics/ecs/BodyKind.js +16 -8
  267. package/src/engine/physics/ecs/Collider.d.ts +7 -2
  268. package/src/engine/physics/ecs/Collider.d.ts.map +1 -1
  269. package/src/engine/physics/ecs/Collider.js +7 -2
  270. package/src/engine/physics/ecs/PhysicsEvents.d.ts +13 -0
  271. package/src/engine/physics/ecs/PhysicsEvents.d.ts.map +1 -1
  272. package/src/engine/physics/ecs/PhysicsEvents.js +13 -0
  273. package/src/engine/physics/ecs/PhysicsSystem.d.ts +320 -36
  274. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  275. package/src/engine/physics/ecs/PhysicsSystem.js +810 -96
  276. package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
  277. package/src/engine/physics/fluid/FluidField.js +5 -1
  278. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +11 -9
  279. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts.map +1 -1
  280. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.js +7 -5
  281. package/src/engine/physics/fluid/ecs/fluid_reanchor_field.d.ts.map +1 -1
  282. package/src/engine/physics/fluid/ecs/fluid_reanchor_field.js +9 -7
  283. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts.map +1 -1
  284. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +3 -4
  285. package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
  286. package/src/engine/physics/fluid/effector/WakeFluidEffector.js +9 -7
  287. package/src/engine/physics/fluid/solver/v3_mac_advect_maccormack_velocity.d.ts.map +1 -1
  288. package/src/engine/physics/fluid/solver/v3_mac_advect_maccormack_velocity.js +65 -43
  289. package/src/engine/physics/inertia/MASS_PROPERTIES_SIZE.d.ts +23 -0
  290. package/src/engine/physics/inertia/MASS_PROPERTIES_SIZE.d.ts.map +1 -0
  291. package/src/engine/physics/inertia/MASS_PROPERTIES_SIZE.js +22 -0
  292. package/src/engine/physics/inertia/convex_hull_mass_properties.d.ts +29 -0
  293. package/src/engine/physics/inertia/convex_hull_mass_properties.d.ts.map +1 -0
  294. package/src/engine/physics/inertia/convex_hull_mass_properties.js +117 -0
  295. package/src/engine/physics/inertia/mass_properties_accumulate.d.ts +24 -0
  296. package/src/engine/physics/inertia/mass_properties_accumulate.d.ts.map +1 -0
  297. package/src/engine/physics/inertia/mass_properties_accumulate.js +93 -0
  298. package/src/engine/physics/inertia/primitive_mass_properties.d.ts +46 -0
  299. package/src/engine/physics/inertia/primitive_mass_properties.d.ts.map +1 -0
  300. package/src/engine/physics/inertia/primitive_mass_properties.js +118 -0
  301. package/src/engine/physics/inertia/rigid_body_set_mass_properties.d.ts +27 -0
  302. package/src/engine/physics/inertia/rigid_body_set_mass_properties.d.ts.map +1 -0
  303. package/src/engine/physics/inertia/rigid_body_set_mass_properties.js +62 -0
  304. package/src/engine/physics/inertia/world_inverse_inertia.d.ts +67 -25
  305. package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -1
  306. package/src/engine/physics/inertia/world_inverse_inertia.js +149 -26
  307. package/src/engine/physics/integration/integrate_position.d.ts +18 -19
  308. package/src/engine/physics/integration/integrate_position.d.ts.map +1 -1
  309. package/src/engine/physics/integration/integrate_position.js +40 -37
  310. package/src/engine/physics/integration/integrate_velocity.d.ts.map +1 -1
  311. package/src/engine/physics/integration/integrate_velocity.js +13 -4
  312. package/src/engine/physics/island/IslandBuilder.d.ts +124 -6
  313. package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -1
  314. package/src/engine/physics/island/IslandBuilder.js +322 -19
  315. package/src/engine/physics/narrowphase/box_box_manifold.d.ts +13 -0
  316. package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -1
  317. package/src/engine/physics/narrowphase/box_box_manifold.js +95 -39
  318. package/src/engine/physics/narrowphase/box_triangle_contact.d.ts +40 -0
  319. package/src/engine/physics/narrowphase/box_triangle_contact.d.ts.map +1 -1
  320. package/src/engine/physics/narrowphase/box_triangle_contact.js +415 -120
  321. package/src/engine/physics/narrowphase/capsule_contacts.d.ts +63 -0
  322. package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -1
  323. package/src/engine/physics/narrowphase/capsule_contacts.js +234 -46
  324. package/src/engine/physics/narrowphase/capsule_triangle_contact.d.ts +13 -0
  325. package/src/engine/physics/narrowphase/capsule_triangle_contact.d.ts.map +1 -1
  326. package/src/engine/physics/narrowphase/capsule_triangle_contact.js +141 -93
  327. package/src/engine/physics/narrowphase/compute_penetration.d.ts +29 -11
  328. package/src/engine/physics/narrowphase/compute_penetration.d.ts.map +1 -1
  329. package/src/engine/physics/narrowphase/compute_penetration.js +157 -34
  330. package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts +76 -0
  331. package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts.map +1 -1
  332. package/src/engine/physics/narrowphase/convex_convex_manifold.js +243 -48
  333. package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.d.ts +13 -0
  334. package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.d.ts.map +1 -1
  335. package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.js +28 -12
  336. package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.d.ts +13 -0
  337. package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.d.ts.map +1 -1
  338. package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.js +27 -0
  339. package/src/engine/physics/narrowphase/decomposition/heightmap_triangle_edge_flags.d.ts +42 -0
  340. package/src/engine/physics/narrowphase/decomposition/heightmap_triangle_edge_flags.d.ts.map +1 -0
  341. package/src/engine/physics/narrowphase/decomposition/heightmap_triangle_edge_flags.js +250 -0
  342. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts +27 -11
  343. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts.map +1 -1
  344. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.js +291 -12
  345. package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.d.ts +7 -1
  346. package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.d.ts.map +1 -1
  347. package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.js +7 -1
  348. package/src/engine/physics/narrowphase/decomposition/triangle_edge_flags.d.ts +35 -0
  349. package/src/engine/physics/narrowphase/decomposition/triangle_edge_flags.d.ts.map +1 -0
  350. package/src/engine/physics/narrowphase/decomposition/triangle_edge_flags.js +61 -0
  351. package/src/engine/physics/narrowphase/hull_sphere_contact.d.ts +54 -0
  352. package/src/engine/physics/narrowphase/hull_sphere_contact.d.ts.map +1 -0
  353. package/src/engine/physics/narrowphase/hull_sphere_contact.js +244 -0
  354. package/src/engine/physics/narrowphase/mesh_convex_hull.js +5 -1
  355. package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.d.ts +2 -0
  356. package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.d.ts.map +1 -1
  357. package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.js +56 -31
  358. package/src/engine/physics/narrowphase/narrowphase_step.d.ts +6 -5
  359. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -1
  360. package/src/engine/physics/narrowphase/narrowphase_step.js +2185 -483
  361. package/src/engine/physics/narrowphase/reduce_manifold_contacts.d.ts +56 -5
  362. package/src/engine/physics/narrowphase/reduce_manifold_contacts.d.ts.map +1 -1
  363. package/src/engine/physics/narrowphase/reduce_manifold_contacts.js +546 -5
  364. package/src/engine/physics/narrowphase/refine_ray_concave.d.ts +29 -2
  365. package/src/engine/physics/narrowphase/refine_ray_concave.d.ts.map +1 -1
  366. package/src/engine/physics/narrowphase/refine_ray_concave.js +628 -75
  367. package/src/engine/physics/narrowphase/refine_ray_hit.d.ts +3 -2
  368. package/src/engine/physics/narrowphase/refine_ray_hit.d.ts.map +1 -1
  369. package/src/engine/physics/narrowphase/refine_ray_hit.js +3 -2
  370. package/src/engine/physics/narrowphase/rigid_subject_pose.d.ts +27 -0
  371. package/src/engine/physics/narrowphase/rigid_subject_pose.d.ts.map +1 -0
  372. package/src/engine/physics/narrowphase/rigid_subject_pose.js +96 -0
  373. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts +14 -0
  374. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -1
  375. package/src/engine/physics/narrowphase/sphere_box_contact.js +51 -5
  376. package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts +12 -0
  377. package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts.map +1 -1
  378. package/src/engine/physics/narrowphase/sphere_sphere_contact.js +30 -0
  379. package/src/engine/physics/narrowphase/sphere_triangle_contact.d.ts +12 -0
  380. package/src/engine/physics/narrowphase/sphere_triangle_contact.d.ts.map +1 -1
  381. package/src/engine/physics/narrowphase/sphere_triangle_contact.js +37 -8
  382. package/src/engine/physics/narrowphase/support_feature_manifold.d.ts +139 -0
  383. package/src/engine/physics/narrowphase/support_feature_manifold.d.ts.map +1 -0
  384. package/src/engine/physics/narrowphase/support_feature_manifold.js +949 -0
  385. package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts +32 -13
  386. package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts.map +1 -1
  387. package/src/engine/physics/queries/PhysicsSurfacePoint.js +36 -13
  388. package/src/engine/physics/queries/convex_overlaps_shape.d.ts +27 -0
  389. package/src/engine/physics/queries/convex_overlaps_shape.d.ts.map +1 -0
  390. package/src/engine/physics/queries/convex_overlaps_shape.js +169 -0
  391. package/src/engine/physics/queries/overlap_shape.d.ts.map +1 -1
  392. package/src/engine/physics/queries/overlap_shape.js +57 -79
  393. package/src/engine/physics/queries/raycast.d.ts +10 -4
  394. package/src/engine/physics/queries/raycast.d.ts.map +1 -1
  395. package/src/engine/physics/queries/raycast.js +133 -9
  396. package/src/engine/physics/queries/shape_cast.d.ts +55 -24
  397. package/src/engine/physics/queries/shape_cast.d.ts.map +1 -1
  398. package/src/engine/physics/queries/shape_cast.js +2061 -245
  399. package/src/engine/physics/solver/apply_impulse_to_body.d.ts +32 -10
  400. package/src/engine/physics/solver/apply_impulse_to_body.d.ts.map +1 -1
  401. package/src/engine/physics/solver/apply_impulse_to_body.js +69 -28
  402. package/src/engine/physics/solver/solve_contacts.d.ts +65 -18
  403. package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -1
  404. package/src/engine/physics/solver/solve_contacts.js +458 -234
  405. package/src/engine/physics/vehicle/RaycastVehicle.d.ts.map +1 -1
  406. package/src/engine/physics/vehicle/RaycastVehicle.js +5 -6
  407. package/src/shade/assets/textures/split_sum.bin +0 -0
  408. package/src/shade/device/mock/SoftwareGPUQueue.d.ts.map +1 -1
  409. package/src/shade/device/mock/SoftwareGPUQueue.js +2 -1
  410. package/src/shade/playground/path_traced_media/README.md +78 -0
  411. package/src/shade/playground/path_traced_media/capture_radiance.d.ts +33 -0
  412. package/src/shade/playground/path_traced_media/capture_radiance.d.ts.map +1 -0
  413. package/src/shade/playground/path_traced_media/capture_radiance.js +174 -0
  414. package/src/shade/playground/path_traced_media/checks.d.ts +160 -0
  415. package/src/shade/playground/path_traced_media/checks.d.ts.map +1 -0
  416. package/src/shade/playground/path_traced_media/checks.js +921 -0
  417. package/src/shade/playground/path_traced_media/index.html +71 -0
  418. package/src/shade/playground/path_traced_media/main.d.ts +2 -0
  419. package/src/shade/playground/path_traced_media/main.d.ts.map +1 -0
  420. package/src/shade/playground/path_traced_media/main.js +440 -0
  421. package/src/shade/playground/path_traced_media/make_wave_pool_geometry.d.ts +26 -0
  422. package/src/shade/playground/path_traced_media/make_wave_pool_geometry.d.ts.map +1 -0
  423. package/src/shade/playground/path_traced_media/make_wave_pool_geometry.js +117 -0
  424. package/src/shade/playground/path_traced_media/views.d.ts +21 -0
  425. package/src/shade/playground/path_traced_media/views.d.ts.map +1 -0
  426. package/src/shade/playground/path_traced_media/views.js +161 -0
  427. package/src/shade/playground/sh_exponential/README.md +43 -0
  428. package/src/shade/playground/sh_exponential/index.html +59 -0
  429. package/src/shade/playground/sh_exponential/main.d.ts +2 -0
  430. package/src/shade/playground/sh_exponential/main.d.ts.map +1 -0
  431. package/src/shade/playground/sh_exponential/main.js +571 -0
  432. package/src/shade/playground/sh_exponential/sh_exp_playground_shaders.d.ts +46 -0
  433. package/src/shade/playground/sh_exponential/sh_exp_playground_shaders.d.ts.map +1 -0
  434. package/src/shade/playground/sh_exponential/sh_exp_playground_shaders.js +270 -0
  435. package/src/shade/playground/water_refraction/README.md +158 -0
  436. package/src/shade/playground/water_refraction/index.html +40 -0
  437. package/src/shade/playground/water_refraction/main.d.ts +2 -0
  438. package/src/shade/playground/water_refraction/main.d.ts.map +1 -0
  439. package/src/shade/playground/water_refraction/main.js +202 -0
  440. package/src/shade/playground/water_refraction/world.d.ts +39 -0
  441. package/src/shade/playground/water_refraction/world.d.ts.map +1 -0
  442. package/src/shade/playground/water_refraction/world.js +141 -0
  443. package/src/shade/renderer/Renderer.d.ts +2 -0
  444. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  445. package/src/shade/renderer/Renderer.js +27 -0
  446. package/src/shade/renderer/animation/chunk_pose_accumulator.d.ts +2 -3
  447. package/src/shade/renderer/animation/chunk_pose_accumulator.d.ts.map +1 -1
  448. package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_reduce.d.ts.map +1 -1
  449. package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_draw.d.ts.map +1 -1
  450. package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_draw.js +9 -1
  451. package/src/shade/renderer/geometry/sdf/chunk_scene_point_query_volume_sign.d.ts.map +1 -1
  452. package/src/shade/renderer/geometry/sdf/chunk_scene_point_query_volume_sign.js +6 -4
  453. package/src/shade/renderer/global_illumination/brick4/gpu/bake/brick4_bake_basic.d.ts.map +1 -1
  454. package/src/shade/renderer/global_illumination/brick4/gpu/bake/brick4_bake_basic.js +1 -0
  455. package/src/shade/renderer/global_illumination/brick4/gpu/bake/sampling/chunk_direction_by_index_rand1.d.ts +7 -0
  456. package/src/shade/renderer/global_illumination/brick4/gpu/bake/sampling/chunk_direction_by_index_rand1.d.ts.map +1 -1
  457. package/src/shade/renderer/global_illumination/brick4/gpu/bake/sampling/chunk_direction_by_index_rand1.js +12 -12
  458. package/src/shade/renderer/global_illumination/brick4/gpu/bake/sampling/chunk_direction_by_index_spherical.d.ts +4 -0
  459. package/src/shade/renderer/global_illumination/brick4/gpu/bake/sampling/chunk_direction_by_index_spherical.d.ts.map +1 -1
  460. package/src/shade/renderer/global_illumination/brick4/gpu/bake/sampling/chunk_direction_by_index_spherical.js +13 -9
  461. package/src/shade/renderer/global_illumination/brick4/gpu/bake/shader_brick4_bake_probes.d.ts.map +1 -1
  462. package/src/shade/renderer/global_illumination/brick4/gpu/bake/shader_brick4_bake_probes.js +2 -0
  463. package/src/shade/renderer/global_illumination/lpv/bake/GPULightProbeVolumeRenderer.d.ts.map +1 -1
  464. package/src/shade/renderer/global_illumination/lpv/bake/GPULightProbeVolumeRenderer.js +3 -0
  465. package/src/shade/renderer/global_illumination/lpv/deprecated/probe_trace_compute_shader_code.d.ts.map +1 -1
  466. package/src/shade/renderer/global_illumination/lpv/deprecated/probe_trace_compute_shader_code.js +4 -9
  467. package/src/shade/renderer/light/LIGHT_DATABASE_SPEC.d.ts.map +1 -1
  468. package/src/shade/renderer/light/LIGHT_DATABASE_SPEC.js +20 -10
  469. package/src/shade/renderer/light/environment/chunk_roughness_to_mip_ratio.d.ts +8 -0
  470. package/src/shade/renderer/light/environment/chunk_roughness_to_mip_ratio.d.ts.map +1 -0
  471. package/src/shade/renderer/light/environment/chunk_sphere_probe_roughness_to_lod.d.ts +0 -6
  472. package/src/shade/renderer/light/environment/chunk_sphere_probe_roughness_to_lod.d.ts.map +1 -1
  473. package/src/shade/renderer/light/environment/rgbe/load_environment_map.d.ts +2 -1
  474. package/src/shade/renderer/light/environment/rgbe/load_environment_map.d.ts.map +1 -1
  475. package/src/shade/renderer/light/environment/rgbe/load_environment_map.js +2 -1
  476. package/src/shade/renderer/light/environment/sh_exponential/README.md +171 -0
  477. package/src/shade/renderer/light/environment/sh_exponential/SHExpEncoder.d.ts +170 -0
  478. package/src/shade/renderer/light/environment/sh_exponential/SHExpEncoder.d.ts.map +1 -0
  479. package/src/shade/renderer/light/environment/sh_exponential/SHExpEncoder.js +377 -0
  480. package/src/shade/renderer/light/environment/sh_exponential/SH_EXP_ENCODE_PARAMETERS_STRUCT.d.ts +16 -0
  481. package/src/shade/renderer/light/environment/sh_exponential/SH_EXP_ENCODE_PARAMETERS_STRUCT.d.ts.map +1 -0
  482. package/src/shade/renderer/light/environment/sh_exponential/SH_EXP_ENCODE_PARAMETERS_STRUCT.js +27 -0
  483. package/src/shade/renderer/light/environment/sh_exponential/chunk_sh_exp_workgroup_sum.d.ts +21 -0
  484. package/src/shade/renderer/light/environment/sh_exponential/chunk_sh_exp_workgroup_sum.d.ts.map +1 -0
  485. package/src/shade/renderer/light/environment/sh_exponential/chunk_sh_exp_workgroup_sum.js +53 -0
  486. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_design_row.d.ts +33 -0
  487. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_design_row.d.ts.map +1 -0
  488. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_design_row.js +90 -0
  489. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_fit_samples.d.ts +28 -0
  490. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_fit_samples.d.ts.map +1 -0
  491. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_fit_samples.js +92 -0
  492. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_layout.d.ts +39 -0
  493. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_layout.d.ts.map +1 -0
  494. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_layout.js +44 -0
  495. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_solve_matrix.d.ts +42 -0
  496. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_solve_matrix.d.ts.map +1 -0
  497. package/src/shade/renderer/light/environment/sh_exponential/sh_exp_solve_matrix.js +123 -0
  498. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_environment_cells.d.ts +30 -0
  499. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_environment_cells.d.ts.map +1 -0
  500. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_environment_cells.js +147 -0
  501. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_log_floor.d.ts +24 -0
  502. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_log_floor.d.ts.map +1 -0
  503. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_log_floor.js +79 -0
  504. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_project.d.ts +17 -0
  505. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_project.d.ts.map +1 -0
  506. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_project.js +99 -0
  507. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_reference_reflectance.d.ts +24 -0
  508. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_reference_reflectance.d.ts.map +1 -0
  509. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_reference_reflectance.js +104 -0
  510. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_solve.d.ts +12 -0
  511. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_solve.d.ts.map +1 -0
  512. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_solve.js +93 -0
  513. package/src/shade/renderer/lightmap/GPULightMap.d.ts.map +1 -1
  514. package/src/shade/renderer/lightmap/GPULightMap.js +1 -0
  515. package/src/shade/renderer/lightmap/bake/shader_lightmap_viz_to_irradiance_flat.d.ts.map +1 -1
  516. package/src/shade/renderer/lightmap/bake/shader_lightmap_viz_to_irradiance_flat.js +4 -0
  517. package/src/shade/renderer/lightmap/bake/shader_lightmap_viz_to_sh.d.ts.map +1 -1
  518. package/src/shade/renderer/lightmap/bake/shader_lightmap_viz_to_sh.js +4 -0
  519. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  520. package/src/shade/renderer/material/PIXEL_TEXTURE_ORM.d.ts +1 -1
  521. package/src/shade/renderer/material/PIXEL_TEXTURE_ORM.d.ts.map +1 -1
  522. package/src/shade/renderer/material/StandardShadeMaterial.d.ts +15 -0
  523. package/src/shade/renderer/material/StandardShadeMaterial.d.ts.map +1 -1
  524. package/src/shade/renderer/material/StandardShadeMaterial.js +17 -0
  525. package/src/shade/renderer/material/resident/GPUResidentMaterialContext.d.ts +36 -2
  526. package/src/shade/renderer/material/resident/GPUResidentMaterialContext.d.ts.map +1 -1
  527. package/src/shade/renderer/material/resident/GPUResidentMaterialContext.js +218 -18
  528. package/src/shade/renderer/material/resident/INDIRECT_MATERIAL_STRUCT.d.ts.map +1 -1
  529. package/src/shade/renderer/material/resident/INDIRECT_MATERIAL_STRUCT.js +10 -0
  530. package/src/shade/renderer/medium/MEDIA_TABLE_STRUCT.d.ts +17 -0
  531. package/src/shade/renderer/medium/MEDIA_TABLE_STRUCT.d.ts.map +1 -0
  532. package/src/shade/renderer/medium/MEDIA_TABLE_STRUCT.js +24 -0
  533. package/src/shade/renderer/medium/MEDIUM_PHASE_LOBE_KIND.d.ts +24 -0
  534. package/src/shade/renderer/medium/MEDIUM_PHASE_LOBE_KIND.d.ts.map +1 -0
  535. package/src/shade/renderer/medium/MEDIUM_PHASE_LOBE_KIND.js +18 -0
  536. package/src/shade/renderer/medium/MEDIUM_STRUCT.d.ts +20 -0
  537. package/src/shade/renderer/medium/MEDIUM_STRUCT.d.ts.map +1 -0
  538. package/src/shade/renderer/medium/MEDIUM_STRUCT.js +43 -0
  539. package/src/shade/renderer/medium/ParticipatingMedium.d.ts +108 -0
  540. package/src/shade/renderer/medium/ParticipatingMedium.d.ts.map +1 -0
  541. package/src/shade/renderer/medium/ParticipatingMedium.js +204 -0
  542. package/src/shade/renderer/medium/chunk_medium_lobe_phase.d.ts +13 -0
  543. package/src/shade/renderer/medium/chunk_medium_lobe_phase.d.ts.map +1 -0
  544. package/src/shade/renderer/medium/chunk_medium_lobe_phase.js +33 -0
  545. package/src/shade/renderer/medium/participating_medium_serialization.d.ts +32 -0
  546. package/src/shade/renderer/medium/participating_medium_serialization.d.ts.map +1 -0
  547. package/src/shade/renderer/medium/participating_medium_serialization.js +181 -0
  548. package/src/shade/renderer/medium/phase/MediumPhaseFunction.d.ts +48 -0
  549. package/src/shade/renderer/medium/phase/MediumPhaseFunction.d.ts.map +1 -0
  550. package/src/shade/renderer/medium/phase/MediumPhaseFunction.js +42 -0
  551. package/src/shade/renderer/medium/phase/PhaseCornetteShanks.d.ts +23 -0
  552. package/src/shade/renderer/medium/phase/PhaseCornetteShanks.d.ts.map +1 -0
  553. package/src/shade/renderer/medium/phase/PhaseCornetteShanks.js +45 -0
  554. package/src/shade/renderer/medium/phase/PhaseDraine.d.ts +30 -0
  555. package/src/shade/renderer/medium/phase/PhaseDraine.d.ts.map +1 -0
  556. package/src/shade/renderer/medium/phase/PhaseDraine.js +58 -0
  557. package/src/shade/renderer/medium/phase/PhaseFournierForand.d.ts +24 -0
  558. package/src/shade/renderer/medium/phase/PhaseFournierForand.d.ts.map +1 -0
  559. package/src/shade/renderer/medium/phase/PhaseFournierForand.js +53 -0
  560. package/src/shade/renderer/medium/phase/PhaseHenyeyGreenstein.d.ts +21 -0
  561. package/src/shade/renderer/medium/phase/PhaseHenyeyGreenstein.d.ts.map +1 -0
  562. package/src/shade/renderer/medium/phase/PhaseHenyeyGreenstein.js +43 -0
  563. package/src/shade/renderer/medium/phase/PhaseJendersieDeon.d.ts +25 -0
  564. package/src/shade/renderer/medium/phase/PhaseJendersieDeon.d.ts.map +1 -0
  565. package/src/shade/renderer/medium/phase/PhaseJendersieDeon.js +66 -0
  566. package/src/shade/renderer/medium/phase/PhaseRayleigh.d.ts +9 -0
  567. package/src/shade/renderer/medium/phase/PhaseRayleigh.d.ts.map +1 -0
  568. package/src/shade/renderer/medium/phase/PhaseRayleigh.js +21 -0
  569. package/src/shade/renderer/medium/phase/PhaseWaterMolecular.d.ts +28 -0
  570. package/src/shade/renderer/medium/phase/PhaseWaterMolecular.d.ts.map +1 -0
  571. package/src/shade/renderer/medium/phase/PhaseWaterMolecular.js +49 -0
  572. package/src/shade/renderer/medium/water/WATER_DEFAULT_PATH_LENGTHS.d.ts +10 -0
  573. package/src/shade/renderer/medium/water/WATER_DEFAULT_PATH_LENGTHS.d.ts.map +1 -0
  574. package/src/shade/renderer/medium/water/WATER_DEFAULT_PATH_LENGTHS.js +25 -0
  575. package/src/shade/renderer/medium/water/water_iop_from_appearance.d.ts +47 -0
  576. package/src/shade/renderer/medium/water/water_iop_from_appearance.d.ts.map +1 -0
  577. package/src/shade/renderer/medium/water/water_iop_from_appearance.js +174 -0
  578. package/src/shade/renderer/medium/water/water_iop_from_constituents.d.ts +57 -0
  579. package/src/shade/renderer/medium/water/water_iop_from_constituents.d.ts.map +1 -0
  580. package/src/shade/renderer/medium/water/water_iop_from_constituents.js +242 -0
  581. package/src/shade/renderer/medium/water/water_iop_jerlov.d.ts +41 -0
  582. package/src/shade/renderer/medium/water/water_iop_jerlov.d.ts.map +1 -0
  583. package/src/shade/renderer/medium/water/water_iop_jerlov.js +231 -0
  584. package/src/shade/renderer/medium/water/water_iop_spectral_reference.d.ts +66 -0
  585. package/src/shade/renderer/medium/water/water_iop_spectral_reference.d.ts.map +1 -0
  586. package/src/shade/renderer/medium/water/water_iop_spectral_reference.js +223 -0
  587. package/src/shade/renderer/medium/water/water_medium_from_iop.d.ts +96 -0
  588. package/src/shade/renderer/medium/water/water_medium_from_iop.d.ts.map +1 -0
  589. package/src/shade/renderer/medium/water/water_medium_from_iop.js +145 -0
  590. package/src/shade/renderer/medium/water/water_presets.d.ts +69 -0
  591. package/src/shade/renderer/medium/water/water_presets.d.ts.map +1 -0
  592. package/src/shade/renderer/medium/water/water_presets.js +119 -0
  593. package/src/shade/renderer/medium/water/water_rgb_from_spectral.d.ts +69 -0
  594. package/src/shade/renderer/medium/water/water_rgb_from_spectral.d.ts.map +1 -0
  595. package/src/shade/renderer/medium/water/water_rgb_from_spectral.js +341 -0
  596. package/src/shade/renderer/particles/DESIGN.md +4 -2
  597. package/src/shade/renderer/particles/bounds/chunk_particle_bounds.d.ts +1 -1
  598. package/src/shade/renderer/particles/bounds/chunk_particle_bounds.d.ts.map +1 -1
  599. package/src/shade/renderer/particles/shaders/chunk_particle_avboit_voxel_fade.d.ts +26 -0
  600. package/src/shade/renderer/particles/shaders/chunk_particle_avboit_voxel_fade.d.ts.map +1 -0
  601. package/src/shade/renderer/particles/shaders/chunk_particle_avboit_voxel_fade.js +71 -0
  602. package/src/shade/renderer/particles/shaders/shader_particle_avboit_draw.d.ts.map +1 -1
  603. package/src/shade/renderer/particles/shaders/shader_particle_avboit_draw.js +16 -1
  604. package/src/shade/renderer/particles/shaders/shader_particle_avboit_splat.d.ts.map +1 -1
  605. package/src/shade/renderer/particles/shaders/shader_particle_avboit_splat.js +6 -13
  606. package/src/shade/renderer/path_tracer/PATH_TRACED_MEDIA_PLAN_2026_10_02.md +520 -0
  607. package/src/shade/renderer/path_tracer/accumulating/AccumulatingPathTracer.d.ts.map +1 -1
  608. package/src/shade/renderer/path_tracer/accumulating/AccumulatingPathTracer.js +1 -0
  609. package/src/shade/renderer/path_tracer/accumulating/shader_accumulating_path_tracer.d.ts.map +1 -1
  610. package/src/shade/renderer/path_tracer/accumulating/shader_accumulating_path_tracer.js +2 -0
  611. package/src/shade/renderer/path_tracer/graph_path_trace_scene.d.ts.map +1 -1
  612. package/src/shade/renderer/path_tracer/graph_path_trace_scene.js +188 -185
  613. package/src/shade/renderer/path_tracer/shader/STANDARD_MATERIAL_DATA_STRUCT.d.ts.map +1 -1
  614. package/src/shade/renderer/path_tracer/shader/STANDARD_MATERIAL_DATA_STRUCT.js +4 -1
  615. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_tangent_normal.d.ts +13 -0
  616. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_tangent_normal.d.ts.map +1 -0
  617. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_tangent_normal.js +29 -0
  618. package/src/shade/renderer/path_tracer/shader/chunk_render_trace_path.d.ts +79 -0
  619. package/src/shade/renderer/path_tracer/shader/chunk_render_trace_path.d.ts.map +1 -1
  620. package/src/shade/renderer/path_tracer/shader/chunk_render_trace_path.js +360 -70
  621. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.d.ts.map +1 -1
  622. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.js +4 -3
  623. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_beam.d.ts +24 -0
  624. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_beam.d.ts.map +1 -0
  625. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_beam.js +99 -0
  626. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_connect.d.ts +68 -0
  627. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_connect.d.ts.map +1 -0
  628. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_connect.js +263 -0
  629. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_constraint.d.ts +55 -0
  630. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_constraint.d.ts.map +1 -0
  631. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_constraint.js +148 -0
  632. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_light.d.ts +17 -0
  633. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_light.d.ts.map +1 -0
  634. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_light.js +41 -0
  635. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_light_sample.d.ts +20 -0
  636. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_light_sample.d.ts.map +1 -0
  637. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_light_sample.js +105 -0
  638. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_triangle.d.ts +28 -0
  639. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_triangle.d.ts.map +1 -0
  640. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_triangle.js +97 -0
  641. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_triangle_of_hit.d.ts +12 -0
  642. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_triangle_of_hit.d.ts.map +1 -0
  643. package/src/shade/renderer/path_tracer/shader/manifold/chunk_manifold_triangle_of_hit.js +46 -0
  644. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_interface.d.ts +25 -0
  645. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_interface.d.ts.map +1 -0
  646. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_interface.js +75 -0
  647. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_path.d.ts +54 -0
  648. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_path.d.ts.map +1 -0
  649. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_path.js +245 -0
  650. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_phase.d.ts +42 -0
  651. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_phase.d.ts.map +1 -0
  652. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_phase.js +236 -0
  653. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_scatter_nee.d.ts +24 -0
  654. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_scatter_nee.d.ts.map +1 -0
  655. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_scatter_nee.js +97 -0
  656. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_stack.d.ts +57 -0
  657. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_stack.d.ts.map +1 -0
  658. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_stack.js +222 -0
  659. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_transport.d.ts +88 -0
  660. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_transport.d.ts.map +1 -0
  661. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_transport.js +304 -0
  662. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_volumes.d.ts +35 -0
  663. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_volumes.d.ts.map +1 -0
  664. package/src/shade/renderer/path_tracer/shader/media/chunk_medium_volumes.js +137 -0
  665. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  666. package/src/shade/renderer/postprocess/ssr/reproject/chunk_ssr_sample_history.d.ts.map +1 -1
  667. package/src/shade/renderer/postprocess/ssr/reproject/chunk_ssr_sample_history.js +85 -84
  668. package/src/shade/renderer/rasterize/native/avboit/AVBOITSettings.d.ts +8 -0
  669. package/src/shade/renderer/rasterize/native/avboit/AVBOITSettings.d.ts.map +1 -1
  670. package/src/shade/renderer/rasterize/native/avboit/AVBOITSettings.js +9 -0
  671. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts +28 -1
  672. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts.map +1 -1
  673. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.js +17 -1
  674. package/src/shade/renderer/rasterize/native/avboit/AVBOIT_CONSTANTS.d.ts +13 -7
  675. package/src/shade/renderer/rasterize/native/avboit/AVBOIT_CONSTANTS.d.ts.map +1 -1
  676. package/src/shade/renderer/rasterize/native/avboit/AVBOIT_CONSTANTS.js +13 -7
  677. package/src/shade/renderer/rasterize/native/avboit/AVBOIT_LEDGER.md +309 -0
  678. package/src/shade/renderer/rasterize/native/avboit/AVBOIT_PLAN_2026_09_03.md +54 -9
  679. package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.d.ts.map +1 -1
  680. package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.js +9 -1
  681. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_footprint_bias.d.ts +33 -0
  682. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_footprint_bias.d.ts.map +1 -0
  683. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_footprint_bias.js +45 -0
  684. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_integral_depth_coordinate.d.ts +4 -0
  685. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_integral_depth_coordinate.d.ts.map +1 -1
  686. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_integral_depth_coordinate.js +6 -2
  687. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_renormalization.d.ts +4 -0
  688. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_renormalization.d.ts.map +1 -0
  689. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_renormalization.js +11 -0
  690. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_rgb_contribution.d.ts +4 -0
  691. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_rgb_contribution.d.ts.map +1 -0
  692. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_rgb_contribution.js +19 -0
  693. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_sample_transmittance.d.ts +2 -1
  694. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_sample_transmittance.d.ts.map +1 -1
  695. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_sample_transmittance.js +4 -2
  696. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_splat_slice.d.ts.map +1 -1
  697. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_splat_slice.js +5 -3
  698. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_split_counts.d.ts +4 -0
  699. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_split_counts.d.ts.map +1 -0
  700. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_split_counts.js +8 -0
  701. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_level_word.d.ts +14 -0
  702. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_level_word.d.ts.map +1 -0
  703. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_level_word.js +28 -0
  704. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_lut_entry.d.ts +10 -0
  705. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_lut_entry.d.ts.map +1 -0
  706. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_lut_entry.js +18 -0
  707. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_marks.d.ts +19 -0
  708. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_marks.d.ts.map +1 -0
  709. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_marks.js +44 -0
  710. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_step_count.d.ts +10 -0
  711. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_step_count.d.ts.map +1 -0
  712. package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_warp_step_count.js +17 -0
  713. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts +1 -1
  714. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts.map +1 -1
  715. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.js +23 -2
  716. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_build_warp.d.ts.map +1 -1
  717. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_build_warp.js +163 -64
  718. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_resolve.d.ts.map +1 -1
  719. package/src/shade/renderer/rasterize/native/avboit/shader_avboit_resolve.js +4 -8
  720. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  721. package/src/shade/renderer/scene/GPUSceneContext.js +4 -1
  722. package/src/shade/renderer/scene/SCENE_DATABASE_SPEC.d.ts.map +1 -1
  723. package/src/shade/renderer/scene/SCENE_DATABASE_SPEC.js +5 -0
  724. package/src/shade/renderer/scene/shader_bvh_extract_instance_leaves.d.ts.map +1 -1
  725. package/src/shade/renderer/shader/chunk/atmosphere/C_MIE_SCATTERING_DECLARATION.d.ts +12 -1
  726. package/src/shade/renderer/shader/chunk/atmosphere/C_MIE_SCATTERING_DECLARATION.d.ts.map +1 -1
  727. package/src/shade/renderer/shader/chunk/atmosphere/C_MIE_SCATTERING_DECLARATION.js +22 -3
  728. package/src/shade/renderer/shader/chunk/atmosphere/phase/chunk_sample_henyey_greenstein_cos.d.ts +18 -0
  729. package/src/shade/renderer/shader/chunk/atmosphere/phase/chunk_sample_henyey_greenstein_cos.d.ts.map +1 -0
  730. package/src/shade/renderer/shader/chunk/atmosphere/phase/chunk_sample_henyey_greenstein_cos.js +31 -0
  731. package/src/shade/renderer/shader/chunk/atmosphere/phase/ff/chunk_phase_fournier_forand.d.ts +43 -0
  732. package/src/shade/renderer/shader/chunk/atmosphere/phase/ff/chunk_phase_fournier_forand.d.ts.map +1 -0
  733. package/src/shade/renderer/shader/chunk/atmosphere/phase/ff/chunk_phase_fournier_forand.js +153 -0
  734. package/src/shade/renderer/shader/chunk/atmosphere/phase/ff/chunk_sample_fournier_forand.d.ts +13 -0
  735. package/src/shade/renderer/shader/chunk/atmosphere/phase/ff/chunk_sample_fournier_forand.d.ts.map +1 -0
  736. package/src/shade/renderer/shader/chunk/atmosphere/phase/ff/chunk_sample_fournier_forand.js +57 -0
  737. package/src/shade/renderer/shader/chunk/atmosphere/phase/ff/fournier_forand_parameters_from_backscatter.d.ts +45 -0
  738. package/src/shade/renderer/shader/chunk/atmosphere/phase/ff/fournier_forand_parameters_from_backscatter.d.ts.map +1 -0
  739. package/src/shade/renderer/shader/chunk/atmosphere/phase/ff/fournier_forand_parameters_from_backscatter.js +109 -0
  740. package/src/shade/renderer/shader/chunk/atmosphere/phase/jd/chunk_phase_draine.d.ts.map +1 -1
  741. package/src/shade/renderer/shader/chunk/atmosphere/phase/jd/chunk_phase_draine.js +6 -3
  742. package/src/shade/renderer/shader/chunk/atmosphere/phase/jd/chunk_sample_draine.d.ts +24 -0
  743. package/src/shade/renderer/shader/chunk/atmosphere/phase/jd/chunk_sample_draine.d.ts.map +1 -0
  744. package/src/shade/renderer/shader/chunk/atmosphere/phase/jd/chunk_sample_draine.js +49 -0
  745. package/src/shade/renderer/shader/chunk/atmosphere/phase/jd/chunk_sample_draine_cos.d.ts +18 -0
  746. package/src/shade/renderer/shader/chunk/atmosphere/phase/jd/chunk_sample_draine_cos.d.ts.map +1 -1
  747. package/src/shade/renderer/shader/chunk/atmosphere/phase/jd/chunk_sample_draine_cos.js +18 -0
  748. package/src/shade/renderer/shader/chunk/atomic/chunk_atomic_add_f32_storage.d.ts +12 -0
  749. package/src/shade/renderer/shader/chunk/atomic/chunk_atomic_add_f32_storage.d.ts.map +1 -0
  750. package/src/shade/renderer/shader/chunk/atomic/chunk_atomic_max_f32_storage.d.ts +12 -0
  751. package/src/shade/renderer/shader/chunk/atomic/chunk_atomic_max_f32_storage.d.ts.map +1 -0
  752. package/src/shade/renderer/shader/chunk/atomic/chunk_atomic_min_f32_storage.d.ts +12 -0
  753. package/src/shade/renderer/shader/chunk/atomic/chunk_atomic_min_f32_storage.d.ts.map +1 -0
  754. package/src/shade/renderer/shader/chunk/brdf/dfg/chunk_integrate_brdf.d.ts +3 -0
  755. package/src/shade/renderer/shader/chunk/brdf/dfg/chunk_integrate_brdf.d.ts.map +1 -1
  756. package/src/shade/renderer/shader/chunk/brdf/dfg/chunk_integrate_brdf.js +3 -0
  757. package/src/shade/renderer/shader/chunk/brdf/dfg/shader_split_sum_dgf_lut.d.ts.map +1 -1
  758. package/src/shade/renderer/shader/chunk/brdf/dfg/shader_split_sum_dgf_lut.js +3 -1
  759. package/src/shade/renderer/shader/chunk/brdf/fresnel/chunk_F_dielectric.d.ts +24 -0
  760. package/src/shade/renderer/shader/chunk/brdf/fresnel/chunk_F_dielectric.d.ts.map +1 -0
  761. package/src/shade/renderer/shader/chunk/brdf/fresnel/chunk_F_dielectric.js +53 -0
  762. package/src/shade/renderer/shader/chunk/geometry/plane/{plane_ray_raycast.d.ts → chunk_plane_ray_raycast.d.ts} +2 -2
  763. package/src/shade/renderer/shader/chunk/geometry/plane/chunk_plane_ray_raycast.d.ts.map +1 -0
  764. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_scene_point_query_is_inside_geometry.d.ts +7 -1
  765. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_scene_point_query_is_inside_geometry.d.ts.map +1 -1
  766. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_scene_point_query_is_inside_geometry.js +12 -60
  767. package/src/shade/renderer/shader/chunk/geometry/sphere/chunk_compute_spherical_excess.d.ts +26 -6
  768. package/src/shade/renderer/shader/chunk/geometry/sphere/chunk_compute_spherical_excess.d.ts.map +1 -1
  769. package/src/shade/renderer/shader/chunk/geometry/sphere/chunk_compute_spherical_excess.js +30 -20
  770. package/src/shade/renderer/shader/chunk/light/sample/chunk_light_importance_directional.d.ts.map +1 -1
  771. package/src/shade/renderer/shader/chunk/light/sample/chunk_light_importance_directional.js +3 -1
  772. package/src/shade/renderer/shader/chunk/light/sample/chunk_light_importance_point.d.ts.map +1 -1
  773. package/src/shade/renderer/shader/chunk/light/sample/chunk_light_importance_point.js +3 -1
  774. package/src/shade/renderer/shader/chunk/light/sample/chunk_light_importance_spot.d.ts.map +1 -1
  775. package/src/shade/renderer/shader/chunk/light/sample/chunk_light_importance_spot.js +3 -1
  776. package/src/shade/renderer/shader/chunk/light/sample/chunk_light_receiver_cosine.d.ts +14 -0
  777. package/src/shade/renderer/shader/chunk/light/sample/chunk_light_receiver_cosine.d.ts.map +1 -0
  778. package/src/shade/renderer/shader/chunk/light/sample/chunk_light_receiver_cosine.js +25 -0
  779. package/src/shade/renderer/shader/chunk/light/sample/chunk_select_light_importance.d.ts +9 -2
  780. package/src/shade/renderer/shader/chunk/light/sample/chunk_select_light_importance.d.ts.map +1 -1
  781. package/src/shade/renderer/shader/chunk/light/sample/chunk_select_light_importance.js +33 -10
  782. package/src/shade/renderer/shader/chunk/screen_space/chunk_screen_space_newton_ray.d.ts +4 -0
  783. package/src/shade/renderer/shader/chunk/screen_space/chunk_screen_space_newton_ray.d.ts.map +1 -0
  784. package/src/shade/renderer/shader/chunk/screen_space/chunk_screen_space_newton_ray.js +135 -0
  785. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh_band_of_index.d.ts +14 -0
  786. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh_band_of_index.d.ts.map +1 -0
  787. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh_band_of_index.js +30 -0
  788. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh_basis_function.d.ts +19 -0
  789. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh_basis_function.d.ts.map +1 -0
  790. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh_basis_function.js +73 -0
  791. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh_vmf_window.d.ts +19 -0
  792. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh_vmf_window.d.ts.map +1 -0
  793. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh_vmf_window.js +25 -0
  794. package/src/shade/renderer/shader/chunk/spherical_harmonics/exponential/SH_EXP_P4Q2_PROBE_STRUCT.d.ts +17 -0
  795. package/src/shade/renderer/shader/chunk/spherical_harmonics/exponential/SH_EXP_P4Q2_PROBE_STRUCT.d.ts.map +1 -0
  796. package/src/shade/renderer/shader/chunk/spherical_harmonics/exponential/SH_EXP_P4Q2_PROBE_STRUCT.js +23 -0
  797. package/src/shade/renderer/shader/chunk/spherical_harmonics/exponential/chunk_sh_exp_p4q2_base_reflectance.d.ts +26 -0
  798. package/src/shade/renderer/shader/chunk/spherical_harmonics/exponential/chunk_sh_exp_p4q2_base_reflectance.d.ts.map +1 -0
  799. package/src/shade/renderer/shader/chunk/spherical_harmonics/exponential/chunk_sh_exp_p4q2_base_reflectance.js +55 -0
  800. package/src/shade/renderer/shader/chunk/spherical_harmonics/exponential/chunk_sh_exp_split_sum.d.ts +52 -0
  801. package/src/shade/renderer/shader/chunk/spherical_harmonics/exponential/chunk_sh_exp_split_sum.d.ts.map +1 -0
  802. package/src/shade/renderer/shader/chunk/spherical_harmonics/exponential/chunk_sh_exp_split_sum.js +65 -0
  803. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh10_basis_at.d.ts +13 -0
  804. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh10_basis_at.d.ts.map +1 -0
  805. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh10_basis_at.js +229 -0
  806. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh10_color_evaluate_vmf.d.ts +23 -0
  807. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh10_color_evaluate_vmf.d.ts.map +1 -0
  808. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh10_color_evaluate_vmf.js +278 -0
  809. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh2_color_evaluate_vmf.d.ts +23 -0
  810. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh2_color_evaluate_vmf.d.ts.map +1 -0
  811. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh2_color_evaluate_vmf.js +58 -0
  812. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh3_color_evaluate_vmf.d.ts +23 -0
  813. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh3_color_evaluate_vmf.d.ts.map +1 -0
  814. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh3_color_evaluate_vmf.js +75 -0
  815. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh4_basis_at.d.ts +13 -0
  816. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh4_basis_at.d.ts.map +1 -0
  817. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh4_basis_at.js +70 -0
  818. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh4_color_evaluate_vmf.d.ts +23 -0
  819. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh4_color_evaluate_vmf.d.ts.map +1 -0
  820. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh4_color_evaluate_vmf.js +95 -0
  821. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh5_basis_at.d.ts +13 -0
  822. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh5_basis_at.d.ts.map +1 -0
  823. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh5_basis_at.js +89 -0
  824. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh5_color_evaluate_vmf.d.ts +23 -0
  825. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh5_color_evaluate_vmf.d.ts.map +1 -0
  826. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh5_color_evaluate_vmf.js +118 -0
  827. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh6_basis_at.d.ts +13 -0
  828. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh6_basis_at.d.ts.map +1 -0
  829. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh6_basis_at.js +111 -0
  830. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh6_color_evaluate_vmf.d.ts +23 -0
  831. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh6_color_evaluate_vmf.d.ts.map +1 -0
  832. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh6_color_evaluate_vmf.js +144 -0
  833. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh7_basis_at.d.ts +13 -0
  834. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh7_basis_at.d.ts.map +1 -0
  835. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh7_basis_at.js +136 -0
  836. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh7_color_evaluate_vmf.d.ts +23 -0
  837. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh7_color_evaluate_vmf.d.ts.map +1 -0
  838. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh7_color_evaluate_vmf.js +173 -0
  839. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh8_basis_at.d.ts +13 -0
  840. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh8_basis_at.d.ts.map +1 -0
  841. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh8_basis_at.js +164 -0
  842. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh8_color_evaluate_vmf.d.ts +23 -0
  843. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh8_color_evaluate_vmf.d.ts.map +1 -0
  844. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh8_color_evaluate_vmf.js +205 -0
  845. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh9_basis_at.d.ts +13 -0
  846. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh9_basis_at.d.ts.map +1 -0
  847. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh9_basis_at.js +195 -0
  848. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh9_color_evaluate_vmf.d.ts +23 -0
  849. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh9_color_evaluate_vmf.d.ts.map +1 -0
  850. package/src/shade/renderer/shader/chunk/spherical_harmonics/generated/chunk_sh9_color_evaluate_vmf.js +240 -0
  851. package/src/shade/renderer/shader/resource/ShaderResourceGroupDescriptor.d.ts +0 -6
  852. package/src/shade/renderer/shader/resource/ShaderResourceGroupDescriptor.d.ts.map +1 -1
  853. package/src/shade/renderer/shader/resource/ShaderResourceGroupDescriptor.js +46 -1
  854. package/src/shade/renderer/shadow/map/DEFAULT_SHADOWMAP_UPDATE_BUDGET.d.ts +7 -7
  855. package/src/shade/renderer/shadow/map/DEFAULT_SHADOWMAP_UPDATE_BUDGET.js +7 -7
  856. package/src/shade/renderer/shadow/map/DirectionalLightShadowmap.d.ts +42 -10
  857. package/src/shade/renderer/shadow/map/DirectionalLightShadowmap.d.ts.map +1 -1
  858. package/src/shade/renderer/shadow/map/DirectionalLightShadowmap.js +104 -48
  859. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.d.ts +20 -4
  860. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.d.ts.map +1 -1
  861. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.js +186 -74
  862. package/src/shade/renderer/shadow/map/Shadowmap.d.ts +2 -1
  863. package/src/shade/renderer/shadow/map/Shadowmap.d.ts.map +1 -1
  864. package/src/shade/renderer/shadow/map/Shadowmap.js +2 -1
  865. package/src/shade/renderer/shadow/map/csm/CSM_CASCADE_STRUCT.d.ts +30 -0
  866. package/src/shade/renderer/shadow/map/csm/CSM_CASCADE_STRUCT.d.ts.map +1 -0
  867. package/src/shade/renderer/shadow/map/csm/CSM_CASCADE_STRUCT.js +52 -0
  868. package/src/shade/renderer/shadow/map/csm/CSM_SHADOWMAP_STRUCT.d.ts +14 -0
  869. package/src/shade/renderer/shadow/map/csm/CSM_SHADOWMAP_STRUCT.d.ts.map +1 -0
  870. package/src/shade/renderer/shadow/map/csm/CSM_SHADOWMAP_STRUCT.js +20 -0
  871. package/src/shade/renderer/shadow/map/csm/SHADOWMAP_CSM_DEFAULT_CASCADE_COUNT.d.ts +8 -0
  872. package/src/shade/renderer/shadow/map/csm/SHADOWMAP_CSM_DEFAULT_CASCADE_COUNT.d.ts.map +1 -0
  873. package/src/shade/renderer/shadow/map/csm/SHADOWMAP_CSM_DEFAULT_CASCADE_COUNT.js +7 -0
  874. package/src/shade/renderer/shadow/map/csm/shader/shader_csm_caster_range.d.ts +8 -6
  875. package/src/shade/renderer/shadow/map/csm/shader/shader_csm_caster_range.d.ts.map +1 -1
  876. package/src/shade/renderer/shadow/map/csm/shader/shader_csm_caster_range.js +28 -34
  877. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_csm_compute_cascade_blended.d.ts +3 -2
  878. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_csm_compute_cascade_blended.d.ts.map +1 -1
  879. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_csm_compute_cascade_blended.js +19 -14
  880. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_directional.d.ts +4 -3
  881. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_directional.d.ts.map +1 -1
  882. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_directional.js +12 -7
  883. package/src/shade/renderer/shadow/map/shadowmap_budget_carry_over.d.ts +4 -4
  884. package/src/shade/renderer/shadow/map/shadowmap_budget_carry_over.js +4 -4
  885. package/src/shade/renderer/shadow/vsm/GPUViewShadowMaps.d.ts.map +1 -1
  886. package/src/shade/renderer/shadow/vsm/GPUViewShadowMaps.js +39 -17
  887. package/src/shade/renderer/shadow/vsm/GPUVirtualShadowTextureResidence.d.ts.map +1 -1
  888. package/src/shade/renderer/shadow/vsm/GPUVirtualShadowTextureResidence.js +5 -36
  889. package/src/shade/renderer/shadow/vsm/VSM_UNIFORMS_STRUCT.d.ts.map +1 -1
  890. package/src/shade/renderer/shadow/vsm/VSM_UNIFORMS_STRUCT.js +3 -2
  891. package/src/shade/renderer/shadow/vsm/VirtualShadowMap.d.ts +1 -1
  892. package/src/shade/renderer/shadow/vsm/VirtualShadowMap.d.ts.map +1 -1
  893. package/src/shade/renderer/shadow/vsm/VirtualShadowMap.js +49 -35
  894. package/src/shade/renderer/shadow/vsm/VirtualShadowmapRenderer.d.ts +4 -1
  895. package/src/shade/renderer/shadow/vsm/VirtualShadowmapRenderer.d.ts.map +1 -1
  896. package/src/shade/renderer/shadow/vsm/VirtualShadowmapRenderer.js +8 -9
  897. package/src/shade/renderer/shadow/vsm/debug_inspect_residence_buffer.js +2 -2
  898. package/src/shade/renderer/shadow/vsm/decode_tile_address.d.ts.map +1 -1
  899. package/src/shade/renderer/shadow/vsm/decode_tile_address.js +15 -23
  900. package/src/shade/renderer/shadow/vsm/vms_pipeline_compute_coarse_bounds.d.ts.map +1 -1
  901. package/src/shade/renderer/shadow/vsm/vms_pipeline_compute_coarse_bounds.js +6 -9
  902. package/src/shade/renderer/shadow/vsm/vsm_residence_pipeline.d.ts.map +1 -1
  903. package/src/shade/renderer/shadow/vsm/vsm_residence_pipeline.js +19 -9
  904. package/src/shade/renderer/shadow/vsm/vsm_tile_allocation_pipeline.d.ts.map +1 -1
  905. package/src/shade/renderer/shadow/vsm/vsm_tile_allocation_pipeline.js +18 -6
  906. package/src/shade/renderer/texture/util/BLACK_PIXEL_TEXTURE.d.ts +1 -1
  907. package/src/shade/renderer/texture/util/BLACK_PIXEL_TEXTURE.d.ts.map +1 -1
  908. package/src/shade/renderer/texture/util/PIXEL_TEXTURE_NORMAL.d.ts +18 -1
  909. package/src/shade/renderer/texture/util/PIXEL_TEXTURE_NORMAL.d.ts.map +1 -1
  910. package/src/shade/renderer/texture/util/PIXEL_TEXTURE_NORMAL.js +24 -3
  911. package/src/shade/renderer/texture/util/WHITE_PIXEL_TEXTURE.d.ts +1 -1
  912. package/src/shade/renderer/texture/util/WHITE_PIXEL_TEXTURE.d.ts.map +1 -1
  913. package/src/shade/renderer/texture/util/get_single_pixel_texture.d.ts +0 -1
  914. package/src/shade/renderer/texture/util/get_single_pixel_texture.d.ts.map +1 -1
  915. package/src/shade/renderer/texture/util/get_single_pixel_texture.js +2 -23
  916. package/src/shade/renderer/texture/util/single_pixel_texture_from_sampler.d.ts +11 -0
  917. package/src/shade/renderer/texture/util/single_pixel_texture_from_sampler.d.ts.map +1 -0
  918. package/src/shade/renderer/texture/util/single_pixel_texture_from_sampler.js +34 -0
  919. package/src/shade/renderer/volumetrics/GPUSceneVolumetrics.d.ts +17 -8
  920. package/src/shade/renderer/volumetrics/GPUSceneVolumetrics.d.ts.map +1 -1
  921. package/src/shade/renderer/volumetrics/GPUSceneVolumetrics.js +35 -64
  922. package/src/shade/renderer/volumetrics/chunk_participating_media_volume_sample.d.ts +21 -0
  923. package/src/shade/renderer/volumetrics/chunk_participating_media_volume_sample.d.ts.map +1 -0
  924. package/src/shade/renderer/volumetrics/chunk_participating_media_volume_sample.js +70 -0
  925. package/src/shade/renderer/volumetrics/chunk_participating_media_volumes_iterate.d.ts +31 -0
  926. package/src/shade/renderer/volumetrics/chunk_participating_media_volumes_iterate.d.ts.map +1 -0
  927. package/src/shade/renderer/volumetrics/chunk_participating_media_volumes_iterate.js +86 -0
  928. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts.map +1 -1
  929. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +2 -4
  930. package/src/shade/renderer/volumetrics/shader_volumetrics_build_participating_media.d.ts.map +1 -1
  931. package/src/shade/renderer/volumetrics/shader_volumetrics_build_participating_media.js +6 -7
  932. package/src/shade/renderer/volumetrics/shader_volumetrics_build_scattering_lut.js +7 -7
  933. package/src/shade/renderer/water/GPUWaterRenderer.d.ts +72 -27
  934. package/src/shade/renderer/water/GPUWaterRenderer.d.ts.map +1 -1
  935. package/src/shade/renderer/water/GPUWaterRenderer.js +275 -138
  936. package/src/shade/renderer/water/chunk_water_gi.d.ts +14 -0
  937. package/src/shade/renderer/water/chunk_water_gi.d.ts.map +1 -0
  938. package/src/shade/renderer/water/chunk_water_gi.js +56 -0
  939. package/src/shade/renderer/water/chunk_water_transport.d.ts +7 -0
  940. package/src/shade/renderer/water/chunk_water_transport.d.ts.map +1 -0
  941. package/src/shade/renderer/water/chunk_water_transport.js +105 -0
  942. package/src/shade/renderer/water/medium/GPUWaterBodies.d.ts +29 -0
  943. package/src/shade/renderer/water/medium/GPUWaterBodies.d.ts.map +1 -0
  944. package/src/shade/renderer/water/medium/GPUWaterBodies.js +116 -0
  945. package/src/shade/renderer/water/medium/WATER_BODIES_STRUCT.d.ts +23 -0
  946. package/src/shade/renderer/water/medium/WATER_BODIES_STRUCT.d.ts.map +1 -0
  947. package/src/shade/renderer/water/medium/WATER_BODIES_STRUCT.js +42 -0
  948. package/src/shade/renderer/water/medium/chunk_water_medium_derived.d.ts +9 -0
  949. package/src/shade/renderer/water/medium/chunk_water_medium_derived.d.ts.map +1 -0
  950. package/src/shade/renderer/water/medium/chunk_water_medium_derived.js +55 -0
  951. package/src/shade/renderer/water/medium/chunk_water_medium_scattering.d.ts +8 -0
  952. package/src/shade/renderer/water/medium/chunk_water_medium_scattering.d.ts.map +1 -0
  953. package/src/shade/renderer/water/medium/chunk_water_medium_scattering.js +17 -0
  954. package/src/shade/renderer/water/medium/shader_water_bodies_derive.d.ts +8 -0
  955. package/src/shade/renderer/water/medium/shader_water_bodies_derive.d.ts.map +1 -0
  956. package/src/shade/renderer/water/medium/shader_water_bodies_derive.js +30 -0
  957. package/src/shade/renderer/water/optics/chunk_water_inscatter.d.ts +28 -0
  958. package/src/shade/renderer/water/optics/chunk_water_inscatter.d.ts.map +1 -0
  959. package/src/shade/renderer/water/optics/chunk_water_inscatter.js +123 -0
  960. package/src/shade/renderer/water/optics/chunk_water_light_transmittance.d.ts +23 -0
  961. package/src/shade/renderer/water/optics/chunk_water_light_transmittance.d.ts.map +1 -0
  962. package/src/shade/renderer/water/optics/chunk_water_light_transmittance_dry.d.ts +18 -0
  963. package/src/shade/renderer/water/optics/chunk_water_light_transmittance_dry.d.ts.map +1 -0
  964. package/src/shade/renderer/water/optics/chunk_water_optics.d.ts +12 -0
  965. package/src/shade/renderer/water/optics/chunk_water_optics.d.ts.map +1 -0
  966. package/src/shade/renderer/water/optics/chunk_water_optics.js +75 -0
  967. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.d.ts +27 -0
  968. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.d.ts.map +1 -0
  969. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.js +74 -0
  970. package/src/shade/renderer/water/shader_water.d.ts +15 -26
  971. package/src/shade/renderer/water/shader_water.d.ts.map +1 -1
  972. package/src/shade/renderer/water/shader_water.js +373 -213
  973. package/src/shade/renderer/water/shader_water_avboit.d.ts +12 -0
  974. package/src/shade/renderer/water/shader_water_avboit.d.ts.map +1 -0
  975. package/src/shade/renderer/water/shader_water_avboit.js +268 -0
  976. package/src/shade/renderer/water/surface/GPUWaterWaveSimulation.d.ts +98 -0
  977. package/src/shade/renderer/water/surface/GPUWaterWaveSimulation.d.ts.map +1 -0
  978. package/src/shade/renderer/water/surface/GPUWaterWaveSimulation.js +408 -0
  979. package/src/shade/renderer/water/surface/WATER_SURFACE_VERTEX_STRUCT.d.ts +12 -0
  980. package/src/shade/renderer/water/surface/WATER_SURFACE_VERTEX_STRUCT.d.ts.map +1 -0
  981. package/src/shade/renderer/water/surface/WATER_SURFACE_VERTEX_STRUCT.js +27 -0
  982. package/src/shade/renderer/water/surface/WATER_WAVE_PARAMETERS_STRUCT.d.ts +14 -0
  983. package/src/shade/renderer/water/surface/WATER_WAVE_PARAMETERS_STRUCT.d.ts.map +1 -0
  984. package/src/shade/renderer/water/surface/WATER_WAVE_PARAMETERS_STRUCT.js +49 -0
  985. package/src/shade/renderer/water/surface/chunk_water_wave.d.ts +15 -0
  986. package/src/shade/renderer/water/surface/chunk_water_wave.d.ts.map +1 -0
  987. package/src/shade/renderer/water/surface/chunk_water_wave.js +48 -0
  988. package/src/shade/renderer/water/surface/chunk_water_wave_grid.d.ts +9 -0
  989. package/src/shade/renderer/water/surface/chunk_water_wave_grid.d.ts.map +1 -0
  990. package/src/shade/renderer/water/surface/chunk_water_wave_grid.js +47 -0
  991. package/src/shade/renderer/water/surface/shader_water_surface_write.d.ts +10 -0
  992. package/src/shade/renderer/water/surface/shader_water_surface_write.d.ts.map +1 -0
  993. package/src/shade/renderer/water/surface/shader_water_surface_write.js +51 -0
  994. package/src/shade/renderer/water/surface/shader_water_wave_step.d.ts +12 -0
  995. package/src/shade/renderer/water/surface/shader_water_wave_step.d.ts.map +1 -0
  996. package/src/shade/renderer/water/surface/shader_water_wave_step.js +54 -0
  997. package/src/shade/renderer/water/surface/water_surface_grid_indices.d.ts +13 -0
  998. package/src/shade/renderer/water/surface/water_surface_grid_indices.d.ts.map +1 -0
  999. package/src/shade/renderer/water/surface/water_surface_grid_indices.js +39 -0
  1000. package/src/shade/renderer/water/water_missing_receiver_path.d.ts +17 -0
  1001. package/src/shade/renderer/water/water_missing_receiver_path.d.ts.map +1 -0
  1002. package/src/shade/renderer/water/water_missing_receiver_path.js +40 -0
  1003. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.d.ts.map +1 -1
  1004. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +247 -23
  1005. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts +18 -14
  1006. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  1007. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +61 -6
  1008. package/src/shade/renderer/animation/skinning/bounds_refresh/chunk_aabb_atomic_f32.d.ts +0 -29
  1009. package/src/shade/renderer/animation/skinning/bounds_refresh/chunk_aabb_atomic_f32.d.ts.map +0 -1
  1010. package/src/shade/renderer/shader/chunk/geometry/plane/plane_ray_raycast.d.ts.map +0 -1
  1011. package/src/shade/renderer/shadow/map/csm/CSM_CASTER_RANGE_STRUCT.d.ts +0 -29
  1012. package/src/shade/renderer/shadow/map/csm/CSM_CASTER_RANGE_STRUCT.d.ts.map +0 -1
  1013. package/src/shade/renderer/shadow/map/csm/CSM_CASTER_RANGE_STRUCT.js +0 -43
  1014. package/src/shade/renderer/shadow/map/csm/SHADOWMAP_CSM_CASCADE_COUNT.d.ts +0 -7
  1015. package/src/shade/renderer/shadow/map/csm/SHADOWMAP_CSM_CASCADE_COUNT.d.ts.map +0 -1
  1016. package/src/shade/renderer/shadow/map/csm/SHADOWMAP_CSM_CASCADE_COUNT.js +0 -6
@@ -5,27 +5,38 @@ import {
5
5
  bvh_query_user_data_intersects_aabb
6
6
  } from "../../../core/bvh2/bvh3/query/bvh_query_user_data_intersects_aabb.js";
7
7
  import { returnTrue } from "../../../core/function/returnTrue.js";
8
- import { aabb3_transform_oriented } from "../../../core/geom/3d/aabb/aabb3_transform_oriented.js";
8
+ import {
9
+ aabb3_transform_oriented,
10
+ aabb3_transform_oriented_array
11
+ } from "../../../core/geom/3d/aabb/aabb3_transform_oriented.js";
12
+ import { quat3_multiply_array } from "../../../core/geom/3d/quaternion/quat3_multiply.js";
9
13
  import Vector3 from "../../../core/geom/Vector3.js";
14
+ import { f32_next_down } from "../../../core/math/f32_next_down.js";
15
+ import { f32_next_up } from "../../../core/math/f32_next_up.js";
10
16
  import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
11
17
  import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
12
18
  import { System } from "../../ecs/System.js";
13
19
  import { t64_announce_change } from "../../ecs/transform/t64_announce_change.js";
14
- import { Transform64 } from "../../ecs/transform/Transform64.js";
20
+ import { TRANSFORM64_EVENT_PLACED } from "../../ecs/transform/TRANSFORM64_EVENT_PLACED.js";
21
+ import {
22
+ Transform64,
23
+ TRANSFORM64_ROTATION_OFFSET,
24
+ TRANSFORM64_TRANSLATION_OFFSET
25
+ } from "../../ecs/transform/Transform64.js";
15
26
  import { Interpolated } from "../../interpolation/Interpolated.js";
16
27
  import { body_id_index, BodyStorage } from "../body/BodyStorage.js";
17
28
  import { SBS_STRIDE, SolverBodyState } from "../body/SolverBodyState.js";
18
- import { compute_world_aabb, fatten_world_aabb } from "../broadphase/compute_fat_world_aabb.js";
29
+ import { compute_world_aabb, fatten_world_aabb_array } from "../broadphase/compute_fat_world_aabb.js";
19
30
  import { generate_pairs } from "../broadphase/generate_pairs.js";
20
31
  import { PairList } from "../broadphase/PairList.js";
21
- import { ccd_release_contacts, ccd_resolve } from "../ccd/linear_sweep.js";
22
- import { solve_joints } from "../constraint/solve_constraints.js";
32
+ import { ccd_clamped_bodies, ccd_release_contacts, ccd_resolve } from "../ccd/linear_sweep.js";
33
+ import { relax_joints, solve_joints } from "../constraint/solve_constraints.js";
23
34
  import { ManifoldStore } from "../contact/ManifoldStore.js";
24
35
  import { ContactEventBuffer, ContactEventKind } from "../events/ContactEventBuffer.js";
25
36
  import { diff_manifolds } from "../events/diff_manifolds.js";
26
37
  import { v3_add } from "../../../core/geom/vec3/v3_add.js";
27
38
  import { v3_set } from "../../../core/geom/vec3/v3_set.js";
28
- import { world_inverse_inertia_apply } from "../inertia/world_inverse_inertia.js";
39
+ import { world_inverse_inertia_apply_raw } from "../inertia/world_inverse_inertia.js";
29
40
  import { integrate_position } from "../integration/integrate_position.js";
30
41
  import { integrate_velocity_forces, integrate_velocity_gravity } from "../integration/integrate_velocity.js";
31
42
  import { IslandBuilder } from "../island/IslandBuilder.js";
@@ -38,6 +49,7 @@ import {
38
49
  prepare_contacts,
39
50
  redetect_concave_contacts,
40
51
  refresh_contacts,
52
+ RESTITUTION_VELOCITY_THRESHOLD,
41
53
  solve_position,
42
54
  solve_velocity,
43
55
  warm_start_contacts,
@@ -94,6 +106,12 @@ let scratch_wake_candidates = new Uint32Array(64);
94
106
  */
95
107
  const scratch_stored_aabb = new Float64Array(6);
96
108
 
109
+ /**
110
+ * A collider's pose, `[px, py, pz, qx, qy, qz, qw]`, for the broadphase refit's box transform.
111
+ * @type {Float64Array}
112
+ */
113
+ const scratch_refit_pose = new Float64Array(7);
114
+
97
115
  /**
98
116
  * Scratch boxes for {@link PhysicsSystem#__swept_proximity} — the mover's
99
117
  * velocity-swept tight AABB and the sleeper's tight AABB.
@@ -102,12 +120,65 @@ const scratch_stored_aabb = new Float64Array(6);
102
120
  const scratch_prox_mover = new Float64Array(6);
103
121
  const scratch_prox_sleeper = new Float64Array(6);
104
122
 
123
+ /**
124
+ * Doubles per body slot in {@link PhysicsSystem#__target_poses}: the packed id of the body that set
125
+ * the target, then position `[x, y, z]` and rotation `[x, y, z, w]`.
126
+ * @type {number}
127
+ */
128
+ const TARGET_POSE_STRIDE = 8;
129
+
130
+ /**
131
+ * Scratch for {@link PhysicsSystem#__derive_target_velocities}' rotation from the current
132
+ * orientation to the target, as `[x, y, z, w]`.
133
+ * @type {Float64Array}
134
+ */
135
+ const scratch_target_dq = new Float64Array(4);
136
+
137
+ /**
138
+ * Scratch for {@link PhysicsSystem#__derive_target_velocities}: the conjugate of the body's current
139
+ * orientation, `[x, y, z, w]`, the second operand of that rotation.
140
+ * @type {Float64Array}
141
+ */
142
+ const scratch_target_conjugate = new Float64Array(4);
143
+
144
+ /**
145
+ * What {@link PhysicsSystem#collidersOf} answers for a body that has none: one shared, frozen
146
+ * empty list.
147
+ * @type {ReadonlyArray<{collider: Collider, transform: Transform64, entity: number}>}
148
+ */
149
+ const NO_COLLIDERS = Object.freeze([]);
150
+
105
151
  /**
106
152
  * {@link PhysicsSystem#interpolationLog} warns once per process, not once per system.
107
153
  * @type {boolean}
108
154
  */
109
155
  let interpolation_log_deprecation_warned = false;
110
156
 
157
+ /**
158
+ * Round a world box outward to float32, in place: each lower bound down and each upper bound up
159
+ * to a float32 value, so the box keeps containing what it bounded once the broadphase stores it.
160
+ *
161
+ * The BVHs store float32, and a plain write rounds to the NEAREST float32 — inward on any side
162
+ * that rounds that way, by up to half a float32 step: 3 cm at 1e6 m. A static leaf is its body's
163
+ * tight box, so a query reaching the body through its leaf missed whatever of the body lay
164
+ * outside it. A ray dropped onto a 2 mm plate 1e6 m out missed it; so did rays a millimetre inside
165
+ * a 1 m crate's faces 1e5 m out. The refit skip in stage 2 also leans on it: a stationary body's
166
+ * box is contained by its own stored leaf only if that leaf did not shrink.
167
+ *
168
+ * @param {Float64Array} aabb `[x0, y0, z0, x1, y1, z1]`
169
+ */
170
+ function aabb3_round_outward_f32(aabb) {
171
+ for (let i = 0; i < 3; i++) {
172
+ const lower = aabb[i];
173
+ const lower_f32 = Math.fround(lower);
174
+ aabb[i] = lower_f32 > lower ? f32_next_down(lower_f32) : lower_f32;
175
+
176
+ const upper = aabb[i + 3];
177
+ const upper_f32 = Math.fround(upper);
178
+ aabb[i + 3] = upper_f32 < upper ? f32_next_up(upper_f32) : upper_f32;
179
+ }
180
+ }
181
+
111
182
  /**
112
183
  * Rigid-body physics system.
113
184
  *
@@ -201,10 +272,20 @@ export class PhysicsSystem extends System {
201
272
  __solver_state = new SolverBodyState();
202
273
 
203
274
  /**
204
- * Velocity-squared threshold below which a body is eligible to start
205
- * accumulating sleep time. Combined linear + angular kinetic-ish
206
- * metric: `vx²+vy²+vz² + ωx²+ωy²+ωz²`. Default 0.01 corresponds to
207
- * ~0.1 m/s linear or ~0.1 rad/s angular.
275
+ * Speed-squared threshold, (m/s)², below which a body is eligible to start
276
+ * accumulating sleep time. The speed measured is that of the body's far
277
+ * end, `|v|² + |ω|²·R²`, where `R` is the body's extent
278
+ * ({@link __body_extent}: a bound on how far its colliders reach from its
279
+ * centre, from their local bounding boxes) floored at 1 m. Default 0.01
280
+ * corresponds to ~0.1 m/s linear; for a body whose extent is no more than
281
+ * a metre, ~0.1 rad/s angular, exactly as before the extent was counted;
282
+ * for a larger one, ~0.1 m/s at its far end (a 100 m rod turning at
283
+ * 0.05 rad/s is moving 5 m/s at the tip, and stays awake).
284
+ *
285
+ * The far end of a long body magnifies any wobble of its contacts, and the
286
+ * test sees it at full size: a long plank resting on a bumpy mesh or
287
+ * heightmap floor whose contacts jitter can stay awake where a short body
288
+ * would sleep.
208
289
  * @type {number}
209
290
  */
210
291
  sleepVelocitySqrThreshold = 0.01;
@@ -239,6 +320,48 @@ export class PhysicsSystem extends System {
239
320
  */
240
321
  positionIterations = 1;
241
322
 
323
+ /**
324
+ * Restitution passes per step, after the substep loop: Gauss-Seidel sweeps
325
+ * over the contacts with non-zero restitution, each driving a bouncing
326
+ * contact's normal velocity toward `-e` times its approach. A body that
327
+ * strikes at several points at once needs more than one: after a single
328
+ * pass, a cube dropped flat at e = 0.8 left the ground spinning at 5 rad/s
329
+ * and rebounded at 0.77 of its impact speed instead of 0.8. Two (Box3D's
330
+ * default) bring it within half a percent of 0.8, all but without spin.
331
+ * Each contact's bounce is capped at `e` times the impulse it took, which
332
+ * stops an unconverged pass overshooting: in zero gravity, uncapped, one
333
+ * pass sent a cube tumbling onto frictionless ground at e = 1 off with up
334
+ * to 7% more kinetic energy than it struck with; capped, 0.2% at worst.
335
+ * More passes still change the result, not just the cost: they converge
336
+ * contacts that load each other further — an e = 1 stack of four boxes
337
+ * struck by a ball keeps 201 J of its 309 J after 10 s at 2 passes, 88 J
338
+ * at 8. `0` turns restitution off.
339
+ *
340
+ * Under gravity a bounce can still gain energy, mostly not from these
341
+ * passes: a landing body is corrected out of the depth it sank into the
342
+ * ground — by the penetration bias with soft contacts, by the position pass
343
+ * with hard ones — and that lift is potential energy, while restitution
344
+ * still returns the full approach speed. Tumbling cubes landing on
345
+ * frictionless ground at e = 1, 60 drops of 5 s: no drop gains at all at
346
+ * the defaults (soft contacts, 2 passes, 4 substeps); 22 gain over 0.1%
347
+ * at 8 substeps
348
+ * (worst +0.64%: the contact is stiffer against the shorter substep and
349
+ * recovers more depth); with hard contacts 53 (+2.2%), and +6.4% at 8
350
+ * substeps. At 2 passes, turning off the bias, the position pass or
351
+ * restitution leaves none gaining. At 1 pass 8 gain (+2.2%), and the pass
352
+ * itself is part of it: with the bias off, 4 still gain (+0.8%).
353
+ * @type {number}
354
+ */
355
+ restitutionIterations = 2;
356
+
357
+ /**
358
+ * Approach speed, m/s, below which a contact does not bounce whatever its
359
+ * restitution, so resting and slowly settling bodies do not buzz. The
360
+ * discrete solver and the CCD pass apply the same rule.
361
+ * @type {number}
362
+ */
363
+ restitutionThreshold = RESTITUTION_VELOCITY_THRESHOLD;
364
+
242
365
  /**
243
366
  * Contact softness frequency, Hz. Softening is what lets resting stacks
244
367
  * settle instead of ringing just above the sleep threshold; `0` gives
@@ -348,10 +471,14 @@ export class PhysicsSystem extends System {
348
471
  __joints_sorted = [];
349
472
 
350
473
  /**
351
- * Velocity iterations per substep for the joint solver. Joints (and
352
- * especially joint chains) want a few more iterations than contacts to
353
- * propagate impulses along the chain; cheap because joints are far
354
- * fewer than contacts.
474
+ * Joint solver passes per substep. Each pass is one Gauss-Seidel sweep over
475
+ * every joint, so joints that load each other — a chain, a ragdoll limb, a
476
+ * heavy body on a light rope — converge together: more passes, tighter
477
+ * joints under load. The first pass also warm-starts each joint; a relax
478
+ * pass over the limit / motor / spring rows after the position integrate
479
+ * comes on top. Cost is passes × joints; cheap because joints are far fewer
480
+ * than contacts. 0 turns the joint solver off, relax included: the joints
481
+ * still tie their bodies' islands together, but push on nothing.
355
482
  * @type {number}
356
483
  */
357
484
  jointIterations = 8;
@@ -360,13 +487,13 @@ export class PhysicsSystem extends System {
360
487
  * Per-body pseudo-velocity for the Catto split-impulse position
361
488
  * pass (TGS Phase 1). Flat layout, 6 doubles per body slot index:
362
489
  * `[lin.x, lin.y, lin.z, ang.x, ang.y, ang.z]`. Sized to
363
- * `storage.high_water_mark * 6` at the top of each fixedUpdate
364
- * and zeroed in place so unwritten slots contribute nothing to
365
- * `integrate_position`.
490
+ * `storage.high_water_mark * 6` at the top of each fixedUpdate, and
491
+ * zero wherever `integrate_position` reads it unless a position pass
492
+ * wrote it this substep, so unwritten slots contribute nothing.
366
493
  *
367
494
  * The solver writes during its position pass; `integrate_position`
368
- * reads and folds into the pose update on the same tick, then
369
- * the next tick's zero-pass wipes the state. It NEVER lands in
495
+ * reads and folds into the pose update on the same substep, and the
496
+ * next substep wipes it first. It NEVER lands in
370
497
  * `linearVelocity` / `angularVelocity` — that's the point of
371
498
  * split impulse: depth correction does not contaminate persistent
372
499
  * velocity (so a `restitution = 0` impact stops cleanly).
@@ -375,6 +502,21 @@ export class PhysicsSystem extends System {
375
502
  */
376
503
  __pseudo_velocity = new Float64Array(0);
377
504
 
505
+ /**
506
+ * Length of the prefix of {@link __pseudo_velocity} that a position pass
507
+ * may have written since it was last zeroed; everything past it is zero.
508
+ * Set by the hard-contact position pass of {@link fixedUpdate} and of the
509
+ * `solve_contacts` driver. `0` when the whole buffer is zero — always,
510
+ * with soft contacts (the default), which run no position pass. The wipes
511
+ * zero this prefix only, and only when it is non-empty: zeroing the whole
512
+ * buffer every substep cost work proportional to the body-slot
513
+ * high-water mark, not to the bodies awake — most of a 0.6 ms step at
514
+ * 100k slots with ten awake.
515
+ * @private
516
+ * @type {number}
517
+ */
518
+ __pseudo_velocity_dirty = 0;
519
+
378
520
  /**
379
521
  * Master switch for the continuous-collision pass. When false the
380
522
  * {@link RigidBodyFlags.CCD} flag is ignored and no swept queries run.
@@ -392,6 +534,85 @@ export class PhysicsSystem extends System {
392
534
  */
393
535
  __ccd_start_pos = new Float64Array(0);
394
536
 
537
+ /**
538
+ * Start-of-step linear velocities of the awake DYNAMIC bodies — every one,
539
+ * not only the CCD-flagged — captured with {@link __ccd_start_pos} (after
540
+ * forces, before the substep loop) in any step with a flagged body awake;
541
+ * 3 doubles per body slot index. The CCD pass replaces each with the
542
+ * body's velocity change through the solve, which tells it how a body it
543
+ * struck fell through the step.
544
+ * @type {Float64Array}
545
+ */
546
+ __ccd_start_vel = new Float64Array(0);
547
+
548
+ /**
549
+ * The CCD movers of the current step: storage indices of the bodies whose
550
+ * start pose {@link __ccd_start_pos} took this step, the first
551
+ * {@link __ccd_mover_count} of them. The CCD pass sweeps these and no
552
+ * others — a body made a mover after the capture, by a listener on an
553
+ * announcement, has no start pose this step. Grows by doubling.
554
+ * @type {Uint32Array}
555
+ */
556
+ __ccd_movers = new Uint32Array(16);
557
+
558
+ /**
559
+ * Beside each of {@link __ccd_movers}, the collider its start pose was
560
+ * taken from, its body's primary at the time; a mover whose primary
561
+ * collider has changed since is not swept this step.
562
+ * @type {Array<Collider|null>}
563
+ */
564
+ __ccd_mover_colliders = [];
565
+
566
+ /**
567
+ * Number of live entries in {@link __ccd_movers}.
568
+ * @type {number}
569
+ */
570
+ __ccd_mover_count = 0;
571
+
572
+ /**
573
+ * Per-body extent, metres, indexed by body slot: a bound on the distance
574
+ * from the body's centre to any point of its colliders — the largest, over
575
+ * its colliders, of the local bounding box's corner radius plus the
576
+ * collider's offset from the body. Exact for a box centred on its body;
577
+ * larger than the body for other shapes (a sphere of radius r reads
578
+ * r·√3). Written for every awake body in stage 2 of each
579
+ * step, from the step's starting poses, and read by the sleep test to
580
+ * turn angular velocity into the speed of the body's far end. Rotation
581
+ * invariant (local boxes, not world ones), so a body's orientation does
582
+ * not change when it may sleep. Derived state: recomputed each step,
583
+ * never serialized. Grows to `storage.high_water_mark`.
584
+ * @type {Float64Array}
585
+ */
586
+ __body_extent = new Float64Array(0);
587
+
588
+ /**
589
+ * Pending {@link setTargetPose} targets, {@link TARGET_POSE_STRIDE} doubles per body slot
590
+ * index: the packed id of the body that set the target ({@link RIGID_BODY_UNALLOCATED} for
591
+ * none), then position `[x, y, z]` and rotation `[x, y, z, w]`. Keyed by the packed id rather
592
+ * than a flag, so a slot freed and reused by another body before the step never inherits a
593
+ * target. Grows to cover the slots targets are set on; never shrinks.
594
+ * @private
595
+ * @type {Float64Array}
596
+ */
597
+ __target_poses = new Float64Array(0);
598
+
599
+ /**
600
+ * Packed ids of the bodies holding a pending target in {@link __target_poses}, in call order:
601
+ * the first {@link __target_pose_count}. Consumed and emptied by the next {@link fixedUpdate},
602
+ * which resets the count and keeps the array's storage — truncating it gave the storage up, and
603
+ * the next step's first target allocated it again.
604
+ * @private
605
+ * @type {number[]}
606
+ */
607
+ __target_pose_bodies = [];
608
+
609
+ /**
610
+ * How many of {@link __target_pose_bodies} are pending.
611
+ * @private
612
+ * @type {number}
613
+ */
614
+ __target_pose_count = 0;
615
+
395
616
  /**
396
617
  * @type {InterpolationLog|null}
397
618
  */
@@ -500,10 +721,12 @@ export class PhysicsSystem extends System {
500
721
 
501
722
  /**
502
723
  * Resize {@link __pseudo_velocity} to cover every live body slot and
503
- * zero its contents. Called at the top of each fixedUpdate so the
504
- * split-impulse position pass starts from a clean state — bodies the
505
- * solver doesn't touch contribute zero pseudo-velocity to
506
- * {@link integrate_position}.
724
+ * bring it to all-zero, zeroing only what a position pass may have
725
+ * written since it last was ({@link __pseudo_velocity_dirty}), so bodies
726
+ * the solver doesn't touch contribute zero pseudo-velocity to
727
+ * {@link integrate_position}. Called at the top of each fixedUpdate, and
728
+ * by a caller of the `solve_contacts` driver whose buffer may hold a
729
+ * hard-contact step's last correction.
507
730
  *
508
731
  * Doubles on growth like the other physics scratches; never shrinks.
509
732
  *
@@ -513,8 +736,22 @@ export class PhysicsSystem extends System {
513
736
  const required = this.storage.high_water_mark * 6;
514
737
  if (this.__pseudo_velocity.length < required) {
515
738
  this.__pseudo_velocity = new Float64Array(required * 2);
516
- } else if (required > 0) {
517
- this.__pseudo_velocity.fill(0, 0, required);
739
+ this.__pseudo_velocity_dirty = 0;
740
+ } else {
741
+ this.__clear_pseudo_velocity();
742
+ }
743
+ }
744
+
745
+ /**
746
+ * Zero what a position pass may have written to {@link __pseudo_velocity}
747
+ * since it was last zeroed; nothing if none has run.
748
+ * @private
749
+ */
750
+ __clear_pseudo_velocity() {
751
+ const dirty = this.__pseudo_velocity_dirty;
752
+ if (dirty > 0) {
753
+ this.__pseudo_velocity.fill(0, 0, dirty);
754
+ this.__pseudo_velocity_dirty = 0;
518
755
  }
519
756
  }
520
757
 
@@ -533,6 +770,14 @@ export class PhysicsSystem extends System {
533
770
 
534
771
  /**
535
772
  * Install (or remove with `null`) the contact filter callback.
773
+ *
774
+ * It is asked during the step, and also from inside the CCD pass's sweep — a
775
+ * {@link shapeCast} — so it may run a {@link raycast} or an {@link overlap},
776
+ * but not a {@link shapeCast} (refused by an assert: a cast cannot run
777
+ * inside another). A production build strips asserts, and there nothing
778
+ * refuses it: the sweep's own cast is overwritten and CCD tunnels without a
779
+ * word — 200 of 200 fast spheres fired at a 2 cm wall went through it.
780
+ *
536
781
  * @param {((entityA:number, entityB:number, colliderA:Collider, colliderB:Collider) => boolean) | null} fn
537
782
  */
538
783
  setContactFilter(fn) {
@@ -570,6 +815,8 @@ export class PhysicsSystem extends System {
570
815
  transform.rotation_x, transform.rotation_y, transform.rotation_z, transform.rotation_w
571
816
  );
572
817
 
818
+ aabb3_round_outward_f32(scratch_world_aabb);
819
+
573
820
  const bvh = rb.kind === BodyKind.Static ? this.staticBvh : this.dynamicBvh;
574
821
  const node = bvh.allocate_node();
575
822
 
@@ -644,6 +891,13 @@ export class PhysicsSystem extends System {
644
891
  * @param {number} entity
645
892
  */
646
893
  link(rigidBody, transform, entity) {
894
+ // Every kind test in the engine is an identity comparison, so a value that is none of the
895
+ // kinds is taken for "not Static, not Dynamic" everywhere, silently.
896
+ const kind = rigidBody.kind;
897
+ assert.ok(kind === BodyKind.Static || kind === BodyKind.Dynamic
898
+ || kind === BodyKind.KinematicVelocity || kind === BodyKind.KinematicPosition,
899
+ `link: RigidBody.kind must be a BodyKind, was ${kind}`);
900
+
647
901
  const packed = this.storage.allocate(entity);
648
902
  rigidBody._bodyId = packed;
649
903
 
@@ -907,6 +1161,47 @@ export class PhysicsSystem extends System {
907
1161
  return this.storage.entity_at(body_id_index(packed_body_id));
908
1162
  }
909
1163
 
1164
+ /**
1165
+ * Resolve a packed body id to the {@link RigidBody} linked under it, or `undefined` if the id
1166
+ * is stale. The id a query reports names a body; this is how its flags, kind and velocity are
1167
+ * read without the dataset.
1168
+ *
1169
+ * @param {number} packed_body_id as a query reports it
1170
+ * @returns {RigidBody|undefined}
1171
+ */
1172
+ bodyOf(packed_body_id) {
1173
+ if (!this.storage.is_valid(packed_body_id)) return undefined;
1174
+ return this.__bodies[body_id_index(packed_body_id)];
1175
+ }
1176
+
1177
+ /**
1178
+ * The colliders attached to a body, in attach order. Each entry gives the `collider`, the world
1179
+ * `transform` it is posed at — the body's own Transform64 for a collider on the body entity, the
1180
+ * child entity's for a compound body's child — and the `entity` that owns the collider. These are
1181
+ * the colliders a query tests when it reaches the body, each at its own transform, in this
1182
+ * order; an overlap query reports the body on the first of them that overlaps.
1183
+ *
1184
+ * **This is the system's live list, not a copy: never write to it.** The array and its entries
1185
+ * are what the broadphase, the narrowphase and every query read, so a `push`, `pop` or `splice`,
1186
+ * or an edit to an entry, changes what the body collides with everywhere — a caller's `pop()`
1187
+ * drops a collider from every query. Attach and detach colliders through
1188
+ * {@link attach_collider} / {@link detach_collider}. The list changes in place on the body's
1189
+ * next attach, detach or unlink; copy what must outlive that. A stale id has no colliders: the
1190
+ * result is one shared, frozen empty array.
1191
+ *
1192
+ * A read-only view is not offered because it is not free: a Proxy that refuses writes made a
1193
+ * walk of an 8-entry list 8.5x as slow to read, and a frozen copy per body would allocate on
1194
+ * every attach and detach and still hand out the live entries.
1195
+ *
1196
+ * @param {number} packed_body_id as a query reports it
1197
+ * @returns {ReadonlyArray<{collider: Collider, transform: Transform64, entity: number}>}
1198
+ */
1199
+ collidersOf(packed_body_id) {
1200
+ if (!this.storage.is_valid(packed_body_id)) return NO_COLLIDERS;
1201
+ const list = this.__body_collider_lists[body_id_index(packed_body_id)];
1202
+ return list === undefined ? NO_COLLIDERS : list;
1203
+ }
1204
+
910
1205
  /**
911
1206
  * Number of live bodies (regardless of awake/sleeping state).
912
1207
  * @returns {number}
@@ -999,7 +1294,12 @@ export class PhysicsSystem extends System {
999
1294
  scratch_locked_inertia[0] = (flags & RigidBodyFlags.LockRotX) !== 0 ? 0 : ii[0];
1000
1295
  scratch_locked_inertia[1] = (flags & RigidBodyFlags.LockRotY) !== 0 ? 0 : ii[1];
1001
1296
  scratch_locked_inertia[2] = (flags & RigidBodyFlags.LockRotZ) !== 0 ? 0 : ii[2];
1002
- world_inverse_inertia_apply(scratch_angular_delta, 0, scratch_locked_inertia, transform.rotation, tx, ty, tz);
1297
+ world_inverse_inertia_apply_raw(
1298
+ scratch_angular_delta, 0,
1299
+ scratch_locked_inertia[0], scratch_locked_inertia[1], scratch_locked_inertia[2],
1300
+ transform.rotation_x, transform.rotation_y, transform.rotation_z, transform.rotation_w,
1301
+ tx, ty, tz
1302
+ );
1003
1303
 
1004
1304
  v3_add(
1005
1305
  rigidBody.angularVelocity, 0,
@@ -1010,8 +1310,11 @@ export class PhysicsSystem extends System {
1010
1310
  }
1011
1311
 
1012
1312
  /**
1013
- * Accumulate a continuous torque (world-space) for integration on the
1014
- * next fixedUpdate. Pairs with {@link applyForce} for the rotational case.
1313
+ * Accumulate a torque (world-space, N·m) for the next fixedUpdate. Pairs
1314
+ * with {@link applyForce} for the rotational case, and is spent the same
1315
+ * way: once, as the angular impulse `τ·dt` over the whole step, before the
1316
+ * substeps — a per-step budget, to be applied again every step it should
1317
+ * last.
1015
1318
  *
1016
1319
  * Wakes the body if asleep.
1017
1320
  *
@@ -1032,9 +1335,12 @@ export class PhysicsSystem extends System {
1032
1335
  }
1033
1336
 
1034
1337
  /**
1035
- * Apply a continuous force at a specific world-space point. The force
1036
- * generates both a linear acceleration (F/m) and a torque (r × F) about
1037
- * the body's centre of mass.
1338
+ * Accumulate a force at a specific world-space point for the next
1339
+ * fixedUpdate. The force generates both a linear acceleration (F/m) and a
1340
+ * torque (r × F) about the body's centre of mass, `r` taken from
1341
+ * `transform` now. Both are spent like {@link applyForce}'s: once, as
1342
+ * `F·dt` and `(r × F)·dt` over the whole step, before the substeps — a
1343
+ * per-step budget, to be applied again every step it should last.
1038
1344
  *
1039
1345
  * Wakes the body if asleep.
1040
1346
  *
@@ -1075,7 +1381,17 @@ export class PhysicsSystem extends System {
1075
1381
  }
1076
1382
 
1077
1383
  /**
1078
- * Accumulate a continuous force to be integrated next fixedUpdate step.
1384
+ * Accumulate a force (world-space, newtons) for the next fixedUpdate.
1385
+ *
1386
+ * The step spends the accumulated force once: as the impulse `F·dt`, `dt`
1387
+ * the whole step, added to the body's velocity before the substeps run,
1388
+ * after which the accumulator is empty. It is not re-applied at each
1389
+ * substep the way gravity is. So a force is a per-step budget — the same
1390
+ * change of momentum whatever {@link substeps} is — and one that should
1391
+ * last must be applied again every step. A force worked out from the
1392
+ * body's state (a spring's pull, a drag) is evaluated at the pose and
1393
+ * velocity it was computed from and acts unchanged through the step.
1394
+ *
1079
1395
  * Wakes the body if asleep.
1080
1396
  *
1081
1397
  * @param {RigidBody} rigidBody
@@ -1147,6 +1463,9 @@ export class PhysicsSystem extends System {
1147
1463
  * as-is; zero it via {@link setLinearVelocity} if the teleport should also stop
1148
1464
  * the body.
1149
1465
  *
1466
+ * Cancels a {@link setTargetPose} target set for the body earlier in the step, so the
1467
+ * teleport is where the step finds it.
1468
+ *
1150
1469
  * Works for STATIC bodies too: their broadphase leaves are re-homed to
1151
1470
  * the new pose, and sleepers at both the old and the new location are
1152
1471
  * woken — a moved support drops what rested on it, and whatever it moved
@@ -1168,15 +1487,48 @@ export class PhysicsSystem extends System {
1168
1487
  assert.isNumber(rotation[2], 'rotation[2]');
1169
1488
  assert.isNumber(rotation[3], 'rotation[3]');
1170
1489
 
1171
- const idx = body_id_index(rigidBody._bodyId);
1490
+ const body_id = rigidBody._bodyId;
1491
+ if (!this.storage.is_valid(body_id)) return;
1492
+
1493
+ const idx = body_id_index(body_id);
1172
1494
  const transform = this.__transforms[idx];
1173
- if (transform === undefined) {
1495
+ if (transform === undefined || this.__bodies[idx] !== rigidBody) {
1174
1496
  return;
1175
1497
  }
1176
1498
 
1499
+ // A teleport supersedes a target set earlier in the step - the last call wins, as between
1500
+ // two targets. Left pending, the target would be reached from the teleported pose, at the
1501
+ // velocity that takes the body straight back.
1502
+ const target_base = idx * TARGET_POSE_STRIDE;
1503
+ if (target_base < this.__target_poses.length && this.__target_poses[target_base] === body_id) {
1504
+ this.__target_poses[target_base] = RIGID_BODY_UNALLOCATED;
1505
+ }
1506
+
1177
1507
  transform.setTranslation(position[0], position[1], position[2]);
1178
1508
  transform.setRotation(rotation[0], rotation[1], rotation[2], rotation[3]);
1179
1509
 
1510
+ const dataset = this.entityManager?.dataset;
1511
+ const entity = this.storage.entity_at(idx);
1512
+ if (dataset !== null && dataset !== undefined) {
1513
+ // Snap interpolation before publishing the pose. Compose attached
1514
+ // worlds before re-homing any of the body's collider leaves below.
1515
+ const interpolated = dataset.getComponent(entity, Interpolated);
1516
+ if (interpolated !== undefined && interpolated !== null) {
1517
+ interpolated.snap = true;
1518
+ }
1519
+ transform.updateMatrix();
1520
+ t64_announce_change(dataset, entity);
1521
+
1522
+ // Listeners can destroy/relink this body and immediately reuse its
1523
+ // slot or entity id. Neither its replacement's leaves nor its
1524
+ // placement listeners belong to this call. Check the generation
1525
+ // as well as the references: a listener can relink the same objects.
1526
+ if (rigidBody._bodyId !== body_id || !this.storage.is_valid(body_id)
1527
+ || this.__bodies[idx] !== rigidBody || this.__transforms[idx] !== transform) {
1528
+ return;
1529
+ }
1530
+ }
1531
+
1180
1532
  if (rigidBody.kind !== BodyKind.Dynamic) {
1181
1533
  // Static AND Kinematic: the body itself never sleeps and __wake_body is a no-op for it,
1182
1534
  // so teleporting a support must instead wake what rested on it (old pose) and what it
@@ -1203,21 +1555,219 @@ export class PhysicsSystem extends System {
1203
1555
  this.__wake_body(rigidBody);
1204
1556
  }
1205
1557
 
1206
- // Flag a snap on the body's Interpolated component, if any: the
1207
- // InterpolationSystem keeps this pose rather than putting back what a render
1208
- // blend displaced, and rewrites the body's recent interpolation records with
1209
- // it, so the blend resumes from here instead of sliding across the jump.
1210
- const em = this.entityManager;
1211
- if (em !== null && em !== undefined) {
1212
- const dataset = em.dataset;
1213
- if (dataset !== null && dataset !== undefined) {
1214
- const entity = this.storage.entity_at(idx);
1215
- const interpolated = dataset.getComponent(entity, Interpolated);
1216
- if (interpolated !== undefined && interpolated !== null) {
1217
- interpolated.snap = true;
1218
- }
1558
+ if (dataset !== null && dataset !== undefined) {
1559
+ // Motion consumers reset history at this pose; subsequent ordinary
1560
+ // movement is still a sweep. Attachments forward the placement.
1561
+ dataset.sendEvent(entity, TRANSFORM64_EVENT_PLACED);
1562
+ }
1563
+ }
1564
+
1565
+ /**
1566
+ * Move a {@link BodyKind.KinematicPosition} body to a pose over the next {@link fixedUpdate},
1567
+ * as a motion rather than a teleport: a moving platform, a door, an animated collider.
1568
+ *
1569
+ * The target is consumed by the next `fixedUpdate(dt)`. Before anything in that step reads
1570
+ * velocity, the step sets the body's {@link RigidBody#linearVelocity} to the displacement from
1571
+ * its current position over `dt`, and its {@link RigidBody#angularVelocity} to the shortest-arc
1572
+ * rotation from its current orientation to the target's, as axis × angle over `dt`. Those are
1573
+ * the velocities the contact solver sees, so a body resting on it is carried by friction
1574
+ * (along, and round when it turns), and a body in its way is pushed. The step integrates them
1575
+ * like any velocity and then writes the target pose exactly, so the body ends the step on the
1576
+ * target to the last bit, whatever the substep count does to the rotation's integration.
1577
+ *
1578
+ * - Calling it again before the step replaces the target; the last call wins.
1579
+ * - The velocities stay on the body after the step, as Box3D's `b3Body_SetTargetTransform`
1580
+ * leaves them: a step with no new target integrates them like any kinematic velocity, so the
1581
+ * body keeps moving at the same rate. To stop it, target the pose it is at (zero velocity),
1582
+ * or set its velocities to zero.
1583
+ * - It is a motion from the pose the body has when the step begins. {@link setPose} is the
1584
+ * teleport — it moves the body with no velocity, so nothing riding it is carried. The later
1585
+ * of the two calls wins: a setPose after this one cancels the target, and this one after a
1586
+ * setPose is a motion from the teleported pose.
1587
+ * - Only a KinematicPosition body takes a target. A Dynamic body's motion is the solver's; a
1588
+ * KinematicVelocity body is driven by the velocity written to it; a Static one never moves.
1589
+ * - Unlike Box3D, which takes the time step with the target and derives the velocity at the
1590
+ * call, the velocity is derived from the step's own `dt` when the step runs, so the two
1591
+ * cannot disagree. Kinematic bodies never sleep here, so there is no sleep-threshold skip.
1592
+ *
1593
+ * @param {RigidBody} rigidBody a linked {@link BodyKind.KinematicPosition} body
1594
+ * @param {Vector3|ArrayLike<number>} position world position to reach, indexed as [x, y, z]
1595
+ * @param {Quaternion|ArrayLike<number>} rotation world unit-quaternion rotation to reach,
1596
+ * indexed as [x, y, z, w]; asserted unit (squared length within 1e-6 of 1), since it is
1597
+ * written into the transform as given
1598
+ */
1599
+ setTargetPose(rigidBody, position, rotation) {
1600
+ assert.defined(position, 'position');
1601
+ assert.isNumber(position[0], 'position[0]');
1602
+ assert.isNumber(position[1], 'position[1]');
1603
+ assert.isNumber(position[2], 'position[2]');
1604
+
1605
+ assert.defined(rotation, 'rotation');
1606
+ assert.isNumber(rotation[0], 'rotation[0]');
1607
+ assert.isNumber(rotation[1], 'rotation[1]');
1608
+ assert.isNumber(rotation[2], 'rotation[2]');
1609
+ assert.isNumber(rotation[3], 'rotation[3]');
1610
+
1611
+ // The pose is written verbatim at the end of the step, so a non-unit rotation would land
1612
+ // in the transform as a scale.
1613
+ const rotation_length_sqr = rotation[0] * rotation[0] + rotation[1] * rotation[1]
1614
+ + rotation[2] * rotation[2] + rotation[3] * rotation[3];
1615
+
1616
+ // the message is built only when the check fails: as an argument it was a string per call
1617
+ if (!(Math.abs(rotation_length_sqr - 1) <= 1e-6)) {
1618
+ assert.ok(false, `setTargetPose: rotation must be a unit quaternion, its squared length is ${rotation_length_sqr}`);
1619
+ }
1620
+
1621
+ assert.equal(rigidBody.kind, BodyKind.KinematicPosition, 'setTargetPose: the body must be BodyKind.KinematicPosition');
1622
+
1623
+ const body_id = rigidBody._bodyId;
1624
+ if (!this.storage.is_valid(body_id)) return;
1625
+
1626
+ const idx = body_id_index(body_id);
1627
+ if (this.__bodies[idx] !== rigidBody) return;
1628
+
1629
+ const base = idx * TARGET_POSE_STRIDE;
1630
+
1631
+ let poses = this.__target_poses;
1632
+ if (poses.length < base + TARGET_POSE_STRIDE) {
1633
+ const grown = new Float64Array(Math.max(base + TARGET_POSE_STRIDE, poses.length * 2));
1634
+ grown.set(poses);
1635
+ for (let i = poses.length; i < grown.length; i += TARGET_POSE_STRIDE) {
1636
+ grown[i] = RIGID_BODY_UNALLOCATED;
1219
1637
  }
1638
+ this.__target_poses = poses = grown;
1220
1639
  }
1640
+
1641
+ if (poses[base] !== body_id) {
1642
+ poses[base] = body_id;
1643
+ this.__target_pose_bodies[this.__target_pose_count++] = body_id;
1644
+ }
1645
+
1646
+ poses[base + 1] = position[0];
1647
+ poses[base + 2] = position[1];
1648
+ poses[base + 3] = position[2];
1649
+ poses[base + 4] = rotation[0];
1650
+ poses[base + 5] = rotation[1];
1651
+ poses[base + 6] = rotation[2];
1652
+ poses[base + 7] = rotation[3];
1653
+ }
1654
+
1655
+ /**
1656
+ * Start of {@link fixedUpdate}: give every body with a pending {@link setTargetPose} target the
1657
+ * velocity that reaches it over `dt`. A step of no duration reaches nothing; its targets stay
1658
+ * pending for the next one.
1659
+ *
1660
+ * @private
1661
+ * @param {number} dt
1662
+ */
1663
+ __derive_target_velocities(dt) {
1664
+ const pending = this.__target_pose_bodies;
1665
+ const pending_count = this.__target_pose_count;
1666
+ if (pending_count === 0 || !(dt > 0)) return;
1667
+
1668
+ const poses = this.__target_poses;
1669
+ const inv_dt = 1 / dt;
1670
+
1671
+ for (let i = 0; i < pending_count; i++) {
1672
+ const body_id = pending[i];
1673
+ if (!this.storage.is_valid(body_id)) continue;
1674
+
1675
+ const idx = body_id_index(body_id);
1676
+ const base = idx * TARGET_POSE_STRIDE;
1677
+ if (poses[base] !== body_id) continue;
1678
+
1679
+ const rb = this.__bodies[idx];
1680
+ if (rb.kind !== BodyKind.KinematicPosition) continue;
1681
+
1682
+ const tr = this.__transforms[idx];
1683
+
1684
+ // the transform's lanes, read in place: a component getter V8 leaves out of line hands
1685
+ // its number back boxed
1686
+ v3_set(rb.linearVelocity, 0,
1687
+ (poses[base + 1] - tr[TRANSFORM64_TRANSLATION_OFFSET]) * inv_dt,
1688
+ (poses[base + 2] - tr[TRANSFORM64_TRANSLATION_OFFSET + 1]) * inv_dt,
1689
+ (poses[base + 3] - tr[TRANSFORM64_TRANSLATION_OFFSET + 2]) * inv_dt
1690
+ );
1691
+
1692
+ // World-frame rotation from the current orientation to the target: dq = q_target ⊗ q⁻¹,
1693
+ // the one a world angular velocity integrates (dq/dt = ½ ω ⊗ q). Its axis × angle over
1694
+ // dt is the angular velocity; the shorter of the two arcs a quaternion pair describes.
1695
+ // Both operands go in as arrays, the target straight from its slot.
1696
+ scratch_target_conjugate[0] = -tr[TRANSFORM64_ROTATION_OFFSET];
1697
+ scratch_target_conjugate[1] = -tr[TRANSFORM64_ROTATION_OFFSET + 1];
1698
+ scratch_target_conjugate[2] = -tr[TRANSFORM64_ROTATION_OFFSET + 2];
1699
+ scratch_target_conjugate[3] = tr[TRANSFORM64_ROTATION_OFFSET + 3];
1700
+
1701
+ quat3_multiply_array(scratch_target_dq, 0, poses, base + 4, scratch_target_conjugate, 0);
1702
+
1703
+ let dx = scratch_target_dq[0];
1704
+ let dy = scratch_target_dq[1];
1705
+ let dz = scratch_target_dq[2];
1706
+ let dw = scratch_target_dq[3];
1707
+
1708
+ if (dw < 0) {
1709
+ dx = -dx;
1710
+ dy = -dy;
1711
+ dz = -dz;
1712
+ dw = -dw;
1713
+ }
1714
+
1715
+ const sin_half = Math.sqrt(dx * dx + dy * dy + dz * dz);
1716
+
1717
+ if (sin_half > 0) {
1718
+ const k = 2 * Math.atan2(sin_half, dw) / sin_half * inv_dt;
1719
+ v3_set(rb.angularVelocity, 0, dx * k, dy * k, dz * k);
1720
+ } else {
1721
+ v3_set(rb.angularVelocity, 0, 0, 0, 0);
1722
+ }
1723
+ }
1724
+ }
1725
+
1726
+ /**
1727
+ * After the substep loop of {@link fixedUpdate}: write every body driven by
1728
+ * {@link setTargetPose} onto its target exactly, and empty the pending list. Skipped, like
1729
+ * {@link __derive_target_velocities}, by a step of no duration.
1730
+ *
1731
+ * @private
1732
+ * @param {number} dt
1733
+ */
1734
+ __land_target_poses(dt) {
1735
+ const pending = this.__target_pose_bodies;
1736
+ const pending_count = this.__target_pose_count;
1737
+ if (pending_count === 0 || !(dt > 0)) return;
1738
+
1739
+ const poses = this.__target_poses;
1740
+
1741
+ for (let i = 0; i < pending_count; i++) {
1742
+ const body_id = pending[i];
1743
+ const idx = body_id_index(body_id);
1744
+ const base = idx * TARGET_POSE_STRIDE;
1745
+
1746
+ if (poses[base] !== body_id) continue;
1747
+ poses[base] = RIGID_BODY_UNALLOCATED;
1748
+
1749
+ if (!this.storage.is_valid(body_id)) continue;
1750
+
1751
+ const rb = this.__bodies[idx];
1752
+ if (rb.kind !== BodyKind.KinematicPosition) continue;
1753
+
1754
+ const tr = this.__transforms[idx];
1755
+
1756
+ // slot to lanes, no number handed to a call: V8 left setRotation out of line here, and a
1757
+ // call that is not inlined boxes the numbers it is passed
1758
+ tr[TRANSFORM64_TRANSLATION_OFFSET] = poses[base + 1];
1759
+ tr[TRANSFORM64_TRANSLATION_OFFSET + 1] = poses[base + 2];
1760
+ tr[TRANSFORM64_TRANSLATION_OFFSET + 2] = poses[base + 3];
1761
+ tr[TRANSFORM64_ROTATION_OFFSET] = poses[base + 4];
1762
+ tr[TRANSFORM64_ROTATION_OFFSET + 1] = poses[base + 5];
1763
+ tr[TRANSFORM64_ROTATION_OFFSET + 2] = poses[base + 6];
1764
+ tr[TRANSFORM64_ROTATION_OFFSET + 3] = poses[base + 7];
1765
+
1766
+ // the orientation was written, so the matrix is behind the components
1767
+ tr.updateMatrix();
1768
+ }
1769
+
1770
+ this.__target_pose_count = 0;
1221
1771
  }
1222
1772
 
1223
1773
  /**
@@ -1379,10 +1929,18 @@ export class PhysicsSystem extends System {
1379
1929
  * Raycast against both broadphase trees. Fills `result` with the nearest
1380
1930
  * hit and returns `true` on hit, `false` on miss.
1381
1931
  *
1382
- * Resolves to the BVH leaf, not the shape: `result.t` is the distance to
1383
- * the leaf's inflated AABB and `result.normal` is that AABB's face
1384
- * normal. Exact for AABB-shaped colliders, approximate for the rest —
1385
- * use {@link shapeCast} when you need the true surface.
1932
+ * Resolves against the real shapes: `result.t` is the distance to the
1933
+ * struck surface and `result.normal` its normal there, for every shape the
1934
+ * engine defines (a shape from outside it falls back to its tight bounding
1935
+ * box). Every collider of a compound body is tested; `result.collider_entity`
1936
+ * names the one struck, and `result.triangle` the triangle of a mesh or
1937
+ * heightmap collider. Sensors are passed through.
1938
+ *
1939
+ * The filter may run a {@link shapeCast} or an {@link overlap} of its own,
1940
+ * but not another raycast (refused by an assert: queries of one kind share
1941
+ * their working state). A production build strips asserts, and there
1942
+ * nothing refuses it: the answer is silently wrong — a ray whose filter cast
1943
+ * another ray named entity 8 at t 1.5, where the truth is entity 1 at 2.5.
1386
1944
  *
1387
1945
  * @param {Ray3} ray origin + unit direction + `tMax`
1388
1946
  * @param {PhysicsSurfacePoint} result populated on hit; untouched on miss
@@ -1399,15 +1957,23 @@ export class PhysicsSystem extends System {
1399
1957
  * The shape starts at `ray.origin` oriented by `rotation` and translates
1400
1958
  * along `ray.direction` for up to `ray.tMax` units.
1401
1959
  *
1402
- * Unlike {@link raycast} this resolves against the real shapes, so `t` is
1403
- * a true time of impact rather than a distance to a bounding box.
1960
+ * `t` is the time of impact — the swept shape at `t` is just apart from
1961
+ * what it struck — and `result.position` the swept shape's centre there,
1962
+ * not a point on the surface. `result.collider_entity` names the struck
1963
+ * collider and `result.triangle` the triangle of a mesh or heightmap one.
1964
+ *
1965
+ * The filter may run a {@link raycast} or an {@link overlap} of its own,
1966
+ * but not another shapeCast (refused by an assert: queries of one kind
1967
+ * share their working state). A production build strips asserts, and there
1968
+ * nothing refuses it: the outer cast silently misses what it should hit.
1404
1969
  *
1405
1970
  * @param {Ray3} ray origin + unit direction + `tMax`
1406
1971
  * @param {AbstractShape3D} shape
1407
1972
  * @param {ArrayLike<number>} rotation fixed orientation of the swept shape
1408
- * as `[x, y, z, w]`, a unit quaternion — which a Transform64's `rotation`
1409
- * already is. Read by index, so an `{x, y, z, w}` object silently misses
1410
- * everything rather than throwing
1973
+ * as `[x, y, z, w]`, a unit quaternion, in an array the caller retains —
1974
+ * not a Transform64's `rotation`, which allocates a view on every read.
1975
+ * Read by index, so an `{x, y, z, w}` object silently misses everything
1976
+ * rather than throwing
1411
1977
  * @param {PhysicsSurfacePoint} result populated on hit; untouched on miss
1412
1978
  * @param {(entity:number, collider:Collider)=>boolean} [filter]
1413
1979
  * @returns {boolean}
@@ -1428,13 +1994,17 @@ export class PhysicsSystem extends System {
1428
1994
  * available.
1429
1995
  *
1430
1996
  * `filter` runs before the shape test, which is the expensive part — use
1431
- * it to skip the caller's own body, allies, sensors.
1997
+ * it to skip the caller's own body, allies, sensors. It may run a
1998
+ * {@link raycast} or a {@link shapeCast} of its own, but not another overlap
1999
+ * (refused by an assert: queries of one kind share their working state). A
2000
+ * production build strips asserts, and there nothing refuses it: the outer
2001
+ * overlap silently comes back short — 0 of the 8 bodies it overlapped.
1432
2002
  *
1433
2003
  * The query shape must be convex; a concave one throws.
1434
2004
  *
1435
2005
  * @param {AbstractShape3D} shape convex query shape, in its local frame
1436
- * @param {ArrayLike<number>} position world position of the query shape, as `[x, y, z]` -
1437
- * which a Transform64's translation already is
2006
+ * @param {ArrayLike<number>} position world position of the query shape, as `[x, y, z]`, in an
2007
+ * array the caller retains - not a Transform64's `translation`, which allocates a view per read
1438
2008
  * @param {ArrayLike<number>} rotation world rotation as `[x, y, z, w]`, a unit quaternion
1439
2009
  * @param {Uint32Array|number[]} output buffer to receive body_ids
1440
2010
  * @param {number} output_offset starting index in output
@@ -1674,7 +2244,8 @@ export class PhysicsSystem extends System {
1674
2244
  *
1675
2245
  * - If any member carries {@link RigidBodyFlags.DisableSleep}, the
1676
2246
  * entire island is exempt; every member's sleep_timer is reset.
1677
- * - If `max(|v|² + |ω|²)` across all members is below
2247
+ * - If `max(|v|² + |ω|²·max(R, 1)²)` across all members (`R` the
2248
+ * member's extent, {@link __body_extent}) is below
1678
2249
  * {@link sleepVelocitySqrThreshold}, every member's sleep_timer is
1679
2250
  * incremented by `dt`. When the smallest member's timer crosses
1680
2251
  * {@link sleepTimeThreshold}, the whole island sleeps atomically in
@@ -1699,6 +2270,8 @@ export class PhysicsSystem extends System {
1699
2270
  const island_count = islands.island_count;
1700
2271
  const body_offsets = islands.body_offsets;
1701
2272
  const body_data = islands.body_data;
2273
+ // Every island member was awake at stage 2, which wrote its extent.
2274
+ const body_extent = this.__body_extent;
1702
2275
 
1703
2276
  for (let isl = 0; isl < island_count; isl++) {
1704
2277
  const start = body_offsets[isl];
@@ -1716,10 +2289,20 @@ export class PhysicsSystem extends System {
1716
2289
  any_disable_sleep = true;
1717
2290
  break;
1718
2291
  }
2292
+ // Speed of the body's far end: angular velocity times the
2293
+ // body's extent, floored at a metre — so a body whose extent is
2294
+ // at most a metre is judged on |v|² + |ω|² exactly as it always
2295
+ // was, and a 100 m rod turning at 0.05 rad/s, its tip moving at
2296
+ // 5 m/s, is not at rest (Box3D: |v| + |ω × maxExtent|).
2297
+ const extent = body_extent[idx];
2298
+ const reach = extent > 1 ? extent : 1;
1719
2299
  const lv = rb.linearVelocity;
1720
2300
  const av = rb.angularVelocity;
2301
+ const wx = av[0] * reach;
2302
+ const wy = av[1] * reach;
2303
+ const wz = av[2] * reach;
1721
2304
  const v_sqr = lv[0] * lv[0] + lv[1] * lv[1] + lv[2] * lv[2]
1722
- + av[0] * av[0] + av[1] * av[1] + av[2] * av[2];
2305
+ + wx * wx + wy * wy + wz * wz;
1723
2306
  if (v_sqr > max_v_sqr) max_v_sqr = v_sqr;
1724
2307
  }
1725
2308
 
@@ -1880,6 +2463,11 @@ export class PhysicsSystem extends System {
1880
2463
  const joints = this.__joints;
1881
2464
  const manifolds = this.manifolds;
1882
2465
 
2466
+ // Stage -1: turn each pending setTargetPose target into the velocity that reaches it over
2467
+ // this step, before anything reads velocity — the parked-platform test in the wake
2468
+ // propagation below, the broadphase pad, the solver.
2469
+ this.__derive_target_velocities(dt);
2470
+
1883
2471
  // Stage 0: wake propagation — through the persistent manifolds
1884
2472
  // (last frame's broadphase-touched pairs), then through joints.
1885
2473
  // Runs before everything else so a just-woken body is part of this
@@ -1914,6 +2502,13 @@ export class PhysicsSystem extends System {
1914
2502
  // pose, padded by the swept extent for the body's velocity. The fat
1915
2503
  // margin uses the post-force velocity; this frame's gravity increment
1916
2504
  // is a sub-millimetre slack difference, safely inside the margin.
2505
+ // Records each awake body's extent for the sleep test on the way, from
2506
+ // the same local boxes.
2507
+ if (this.__body_extent.length < storage.high_water_mark) {
2508
+ this.__body_extent = new Float64Array(storage.high_water_mark * 2);
2509
+ }
2510
+
2511
+ const body_extent = this.__body_extent;
1917
2512
  const lists = this.__body_collider_lists;
1918
2513
  for (let i = 0; i < count; i++) {
1919
2514
 
@@ -1921,17 +2516,58 @@ export class PhysicsSystem extends System {
1921
2516
  const rb = bodies[idx];
1922
2517
  const list = lists[idx];
1923
2518
 
2519
+ body_extent[idx] = 0;
2520
+
1924
2521
  if (list === undefined) {
1925
2522
  continue;
1926
2523
  }
1927
2524
 
1928
2525
  const lv = rb.linearVelocity;
2526
+ const body_transform = transforms[idx];
1929
2527
 
1930
2528
  const list_length = list.length;
1931
2529
 
2530
+ let extent = 0;
2531
+
1932
2532
  for (let k = 0; k < list_length; k++) {
1933
2533
 
1934
2534
  const entry = list[k];
2535
+ const collider_transform = entry.transform;
2536
+
2537
+ // The tight world box, as compute_world_aabb builds it, from a
2538
+ // local box this loop keeps for the extent below.
2539
+ entry.collider.shape.compute_bounding_box(scratch_local_aabb);
2540
+
2541
+ // The pose goes in an array: handed to aabb3_transform_oriented as seven numbers
2542
+ // (it is not inlined into this step), each would be boxed, per collider per step.
2543
+ // It, and the offset below, are read off the transforms' lanes rather than through
2544
+ // their accessors, which this step does not inline either and which return their
2545
+ // numbers boxed.
2546
+ const pose = scratch_refit_pose;
2547
+ pose[0] = collider_transform[TRANSFORM64_TRANSLATION_OFFSET];
2548
+ pose[1] = collider_transform[TRANSFORM64_TRANSLATION_OFFSET + 1];
2549
+ pose[2] = collider_transform[TRANSFORM64_TRANSLATION_OFFSET + 2];
2550
+ pose[3] = collider_transform[TRANSFORM64_ROTATION_OFFSET];
2551
+ pose[4] = collider_transform[TRANSFORM64_ROTATION_OFFSET + 1];
2552
+ pose[5] = collider_transform[TRANSFORM64_ROTATION_OFFSET + 2];
2553
+ pose[6] = collider_transform[TRANSFORM64_ROTATION_OFFSET + 3];
2554
+
2555
+ aabb3_transform_oriented_array(scratch_world_aabb, 0, scratch_local_aabb, 0, pose, 0);
2556
+
2557
+ // Farthest corner of the local box from the collider's origin,
2558
+ // plus the collider's offset from the body's centre: no point
2559
+ // of the collider lies farther from the body's centre.
2560
+ const ex = Math.max(-scratch_local_aabb[0], scratch_local_aabb[3]);
2561
+ const ey = Math.max(-scratch_local_aabb[1], scratch_local_aabb[4]);
2562
+ const ez = Math.max(-scratch_local_aabb[2], scratch_local_aabb[5]);
2563
+ const ox = pose[0] - body_transform[TRANSFORM64_TRANSLATION_OFFSET];
2564
+ const oy = pose[1] - body_transform[TRANSFORM64_TRANSLATION_OFFSET + 1];
2565
+ const oz = pose[2] - body_transform[TRANSFORM64_TRANSLATION_OFFSET + 2];
2566
+ const reach = Math.sqrt(ex * ex + ey * ey + ez * ez) + Math.sqrt(ox * ox + oy * oy + oz * oz);
2567
+
2568
+ if (reach > extent) {
2569
+ extent = reach;
2570
+ }
1935
2571
 
1936
2572
  // Refit skip — the fat margin's whole purpose: while the
1937
2573
  // body's FATTENED box (tight + velocity pad) stays inside the
@@ -1949,8 +2585,7 @@ export class PhysicsSystem extends System {
1949
2585
  // otherwise keep a leaf covering none of the path it travels
1950
2586
  // this step — invisible to pair generation and to other
1951
2587
  // bodies' CCD sweeps for the whole step.
1952
- compute_world_aabb(scratch_world_aabb, 0, entry.collider.shape, entry.transform);
1953
- fatten_world_aabb(scratch_world_aabb, 0, lv[0], lv[1], lv[2], dt);
2588
+ fatten_world_aabb_array(scratch_world_aabb, 0, lv, 0, dt);
1954
2589
  const node = entry.bvhNode;
1955
2590
  this.dynamicBvh.node_get_aabb(node, scratch_stored_aabb);
1956
2591
  if (scratch_world_aabb[0] >= scratch_stored_aabb[0]
@@ -1962,8 +2597,14 @@ export class PhysicsSystem extends System {
1962
2597
  continue;
1963
2598
  }
1964
2599
 
2600
+ // Outward, so the stored leaf still contains this fat box: the
2601
+ // next step's skip test is then exact for a body that has not
2602
+ // moved, as well as conservative for every query in between.
2603
+ aabb3_round_outward_f32(scratch_world_aabb);
1965
2604
  this.dynamicBvh.node_move_aabb(node, scratch_world_aabb);
1966
2605
  }
2606
+
2607
+ body_extent[idx] = extent;
1967
2608
  }
1968
2609
 
1969
2610
  // Stage 3: broadphase pair generation. The fat AABBs cover the full
@@ -2000,8 +2641,8 @@ export class PhysicsSystem extends System {
2000
2641
  // at a resting contact (each cancels `h` of the other), so stacks hold
2001
2642
  // at zero velocity and sleep; the position correction adapts as bodies
2002
2643
  // separate between substeps — the TGS stack-stability mechanism —
2003
- // without re-running narrowphase. Restitution is applied once after
2004
- // the loop.
2644
+ // without re-running narrowphase. Restitution is applied after the
2645
+ // loop.
2005
2646
  // Clamp the substep count: 0 (or a negative / fractional value) would
2006
2647
  // feed h = dt / N = Infinity into prepare_contacts and a broken loop
2007
2648
  // bound into the solver.
@@ -2013,8 +2654,10 @@ export class PhysicsSystem extends System {
2013
2654
  // post-wake awake set (poses are unchanged until the substep loop below
2014
2655
  // integrates them). The CCD pass after the solver sweeps from here to
2015
2656
  // each body's final pose. Reads the primary collider's transform so the
2016
- // start matches the end the resolve pass reads. Zero-cost when no body
2017
- // is flagged.
2657
+ // start matches the end the resolve pass reads. When any body is
2658
+ // flagged, also the start-of-step velocity of every awake dynamic
2659
+ // body, any of which a sweep can strike. Costs nothing more than the
2660
+ // walk when no body is flagged.
2018
2661
  const ccd_on = this.ccdEnabled;
2019
2662
 
2020
2663
  if (ccd_on) {
@@ -2023,9 +2666,12 @@ export class PhysicsSystem extends System {
2023
2666
 
2024
2667
  if (this.__ccd_start_pos.length < ccd_need) {
2025
2668
  this.__ccd_start_pos = new Float64Array(ccd_need);
2669
+ this.__ccd_start_vel = new Float64Array(ccd_need);
2026
2670
  }
2027
2671
 
2028
2672
  const ccd_start = this.__ccd_start_pos;
2673
+ const ccd_movers_before = this.__ccd_mover_count;
2674
+ let ccd_count = 0;
2029
2675
 
2030
2676
  for (let i = 0; i < count_after_wake; i++) {
2031
2677
  const idx = storage.awake_at(i);
@@ -2050,12 +2696,47 @@ export class PhysicsSystem extends System {
2050
2696
  ccd_start[cb] = cp.translation_x;
2051
2697
  ccd_start[cb + 1] = cp.translation_y;
2052
2698
  ccd_start[cb + 2] = cp.translation_z;
2699
+
2700
+ if (ccd_count === this.__ccd_movers.length) {
2701
+ const grown = new Uint32Array(this.__ccd_movers.length * 2);
2702
+ grown.set(this.__ccd_movers);
2703
+ this.__ccd_movers = grown;
2704
+ }
2705
+ this.__ccd_movers[ccd_count] = idx;
2706
+ this.__ccd_mover_colliders[ccd_count] = list[0].collider;
2707
+ ccd_count++;
2708
+ }
2709
+
2710
+ // Let go of last step's colliders past this step's count.
2711
+ for (let k = ccd_count; k < ccd_movers_before; k++) {
2712
+ this.__ccd_mover_colliders[k] = null;
2713
+ }
2714
+ this.__ccd_mover_count = ccd_count;
2715
+
2716
+ if (ccd_count > 0) {
2717
+ const ccd_start_vel = this.__ccd_start_vel;
2718
+
2719
+ for (let i = 0; i < count_after_wake; i++) {
2720
+ const idx = storage.awake_at(i);
2721
+ const rb = bodies[idx];
2722
+
2723
+ if (rb.kind !== BodyKind.Dynamic) {
2724
+ continue;
2725
+ }
2726
+
2727
+ const lv = rb.linearVelocity;
2728
+ const cb = idx * 3;
2729
+
2730
+ ccd_start_vel[cb] = lv[0];
2731
+ ccd_start_vel[cb + 1] = lv[1];
2732
+ ccd_start_vel[cb + 2] = lv[2];
2733
+ }
2053
2734
  }
2054
2735
  }
2055
2736
 
2056
2737
  // Size the pseudo-velocity buffer ONCE (it may reallocate on growth),
2057
- // then capture the reference. Inside the loop we only zero its live
2058
- // region per substep — re-capturing is unnecessary since it won't
2738
+ // then capture the reference. Inside the loop we only zero what a
2739
+ // position pass wrote — re-capturing is unnecessary since it won't
2059
2740
  // reallocate again this step.
2060
2741
  this.__reset_pseudo_velocity();
2061
2742
  const pseudoVel = this.__pseudo_velocity;
@@ -2138,15 +2819,17 @@ export class PhysicsSystem extends System {
2138
2819
  // Joints share the substep: warm-start + velocity-solve the 6-DOF
2139
2820
  // constraints on real velocity, coupled with the contacts above
2140
2821
  // (a body touched by both sees one substep of Gauss-Seidel across
2141
- // contacts then joints). Position correction for locked DOFs is a
2142
- // SPOOK bias inside this solve, so no separate joint position pass.
2143
- // Solved in the entity-canonical order (NOT joint-id order, which
2144
- // encodes link/unlink history) — see __joints_sorted.
2822
+ // contacts then joints), in jointIterations passes over all the
2823
+ // joints. Position correction is a SPOOK bias inside this solve, so
2824
+ // no separate joint position pass (the relax below takes the limits'
2825
+ // push back out). Solved in the entity-canonical order (NOT joint-id
2826
+ // order, which encodes link/unlink history) — see __joints_sorted.
2827
+ const joints_reverse = (s & 1) === 1;
2145
2828
  if (this.__joints_sorted.length > 0) {
2146
2829
  // Alternate the joint sweep direction on odd substeps so the chain
2147
2830
  // is solved root→tip and tip→root across the step (symmetric
2148
2831
  // Gauss-Seidel), cancelling the one-direction propagation bias.
2149
- solve_joints(this.__joints_sorted, this, h, this.jointIterations, (s & 1) === 1);
2832
+ solve_joints(this.__joints_sorted, this, h, this.jointIterations, joints_reverse);
2150
2833
  }
2151
2834
 
2152
2835
  // Position correction writes pseudo-velocity (zeroed first so it
@@ -2154,21 +2837,20 @@ export class PhysicsSystem extends System {
2154
2837
  // position integrate and then discarded. SOFT contacts skip it:
2155
2838
  // their penetration recovery is the velocity-bias term, and the
2156
2839
  // relax pass below strips the momentum that bias injected
2157
- // (Box2D-v3 substep order).
2840
+ // (Box2D-v3 substep order). Zeroing is a no-op unless a position
2841
+ // pass has written since, so soft steps never pay for it.
2158
2842
  const contacts_soft = this.contactHertz > 0;
2159
- pseudoVel.fill(0, 0, pseudo_len);
2843
+ this.__clear_pseudo_velocity();
2160
2844
  if (!contacts_soft) {
2161
2845
  solve_position(manifolds, this, this.positionIterations);
2846
+ this.__pseudo_velocity_dirty = pseudo_len;
2162
2847
  }
2163
2848
 
2164
2849
  for (let i = 0; i < count_after_wake; i++) {
2165
2850
  const idx = storage.awake_at(i);
2166
2851
  const rb = bodies[idx];
2167
2852
  const tr = transforms[idx];
2168
- const base = idx * 6;
2169
- integrate_position(ss_data, idx * SBS_STRIDE, rb, tr, h,
2170
- pseudoVel[base], pseudoVel[base + 1], pseudoVel[base + 2],
2171
- pseudoVel[base + 3], pseudoVel[base + 4], pseudoVel[base + 5]);
2853
+ integrate_position(ss_data, idx * SBS_STRIDE, rb, tr, h, pseudoVel, idx * 6);
2172
2854
  }
2173
2855
 
2174
2856
  // Relax pass (soft contacts only): one biasless sweep over the
@@ -2178,11 +2860,21 @@ export class PhysicsSystem extends System {
2178
2860
  if (contacts_soft) {
2179
2861
  solve_velocity(manifolds, this, 1, false);
2180
2862
  }
2863
+
2864
+ // Joint relax, whatever the contact mode: one pass over the limit,
2865
+ // motor and spring rows without their position-correction bias,
2866
+ // removing the velocity a limit pushed its DOF out of violation with
2867
+ // — the joints have no pseudo-velocity channel, and a one-sided row
2868
+ // cannot take its push back, so it would carry the DOF onto its far
2869
+ // stop.
2870
+ if (this.__joints_sorted.length > 0) {
2871
+ relax_joints(this.__joints_sorted, this, joints_reverse);
2872
+ }
2181
2873
  }
2182
2874
 
2183
- // Stage 8: one-shot restitution, after the substep loop, keyed off
2184
- // the approach velocity captured at prepare time.
2185
- apply_restitution(manifolds, this);
2875
+ // Stage 8: restitution, after the substep loop, keyed off the approach
2876
+ // velocity captured at prepare time.
2877
+ apply_restitution(manifolds, this, this.restitutionIterations);
2186
2878
 
2187
2879
  // Scatter the solved persistent linear / angular velocity back onto the
2188
2880
  // RigidBody components (pose was written through to the transforms each
@@ -2190,25 +2882,28 @@ export class PhysicsSystem extends System {
2190
2882
  // interpolation recording, and the sleep test below.
2191
2883
  solver_state.scatter(bodies);
2192
2884
 
2885
+ // Bodies driven by setTargetPose end the step exactly on their targets, before the move is
2886
+ // announced. The substeps put them there to rounding in translation; the rotation's
2887
+ // first-order integration falls short by O(angle³).
2888
+ this.__land_target_poses(dt);
2889
+
2193
2890
  // The transforms moved and carry no signals of their own, so the move is announced here:
2194
2891
  // once per awake body per step, rather than once per substep write. Everything that used to
2195
2892
  // wake on position.onChanged - the render placement, the parent/child sync, fog-of-war -
2196
2893
  // wakes on this instead.
2197
- {
2198
- const ecd = (this.entityManager !== null && this.entityManager !== undefined)
2199
- ? this.entityManager.dataset
2200
- : null;
2894
+ const ecd = (this.entityManager !== null && this.entityManager !== undefined)
2895
+ ? this.entityManager.dataset
2896
+ : null;
2201
2897
 
2202
- if (ecd !== null) {
2203
- const awake_count = storage.awake_count;
2898
+ if (ecd !== null) {
2899
+ const awake_count = storage.awake_count;
2204
2900
 
2205
- for (let i = 0; i < awake_count; i++) {
2206
- const idx = storage.awake_at(i);
2207
- const entity = storage.entity_at(idx);
2901
+ for (let i = 0; i < awake_count; i++) {
2902
+ const idx = storage.awake_at(i);
2903
+ const entity = storage.entity_at(idx);
2208
2904
 
2209
- if (entity >= 0) {
2210
- t64_announce_change(ecd, entity);
2211
- }
2905
+ if (entity >= 0) {
2906
+ t64_announce_change(ecd, entity);
2212
2907
  }
2213
2908
  }
2214
2909
  }
@@ -2218,8 +2913,27 @@ export class PhysicsSystem extends System {
2218
2913
  // can't tunnel through thin geometry between discrete steps. Runs on the
2219
2914
  // final post-solve poses, before the sleep test sees the clamped
2220
2915
  // velocities. No-op when no awake body is flagged.
2916
+ //
2917
+ // It has to run AFTER the announcement above, which is what composes a
2918
+ // compound body's child colliders: the sweep reads its end pose from the
2919
+ // primary collider's transform. So a body it clamps was announced at the
2920
+ // pose it would have TUNNELLED to, and everything composed from that
2921
+ // pose synchronously — attached children, child colliders, listeners —
2922
+ // is stale. Announce those bodies again, now at their final pose.
2221
2923
  if (ccd_on) {
2222
- ccd_resolve(this);
2924
+ const clamped = ccd_resolve(this, dt, h, count_after_wake);
2925
+
2926
+ if (clamped > 0 && ecd !== null) {
2927
+ const clamped_bodies = ccd_clamped_bodies();
2928
+
2929
+ for (let i = 0; i < clamped; i++) {
2930
+ const entity = storage.entity_at(clamped_bodies[i]);
2931
+
2932
+ if (entity >= 0) {
2933
+ t64_announce_change(ecd, entity);
2934
+ }
2935
+ }
2936
+ }
2223
2937
  }
2224
2938
 
2225
2939
  // Stage 9: sleep test.