@woosh/meep-engine 2.139.0 → 2.141.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 (199) hide show
  1. package/package.json +1 -1
  2. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_aabb.d.ts +3 -3
  3. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_aabb.d.ts.map +1 -1
  4. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_aabb.js +4 -4
  5. package/src/{engine/physics/broadphase/aabb_transform_oriented.d.ts → core/geom/3d/aabb/aabb3_transform_oriented.d.ts} +2 -2
  6. package/src/core/geom/3d/aabb/aabb3_transform_oriented.d.ts.map +1 -0
  7. package/src/{engine/physics/broadphase/aabb_transform_oriented.js → core/geom/3d/aabb/aabb3_transform_oriented.js} +1 -1
  8. package/src/core/geom/3d/quaternion/quat3_multiply.d.ts +21 -0
  9. package/src/core/geom/3d/quaternion/quat3_multiply.d.ts.map +1 -0
  10. package/src/core/geom/3d/quaternion/quat3_multiply.js +25 -0
  11. package/src/core/geom/3d/quaternion/quat3_to_matrix3.d.ts +54 -0
  12. package/src/core/geom/3d/quaternion/quat3_to_matrix3.d.ts.map +1 -0
  13. package/src/core/geom/3d/quaternion/quat3_to_matrix3.js +69 -0
  14. package/src/core/geom/3d/shape/AbstractShape3D.d.ts +24 -2
  15. package/src/core/geom/3d/shape/AbstractShape3D.d.ts.map +1 -1
  16. package/src/core/geom/3d/shape/AbstractShape3D.js +24 -1
  17. package/src/core/geom/3d/shape/HeightMapShape3D.d.ts +148 -0
  18. package/src/core/geom/3d/shape/HeightMapShape3D.d.ts.map +1 -0
  19. package/src/core/geom/3d/shape/HeightMapShape3D.js +451 -0
  20. package/src/core/geom/3d/shape/MeshShape3D.d.ts +210 -0
  21. package/src/core/geom/3d/shape/MeshShape3D.d.ts.map +1 -0
  22. package/src/core/geom/3d/shape/MeshShape3D.js +593 -0
  23. package/src/core/geom/3d/shape/TransformedShape3D.d.ts.map +1 -1
  24. package/src/core/geom/3d/shape/TransformedShape3D.js +46 -2
  25. package/src/core/geom/3d/shape/Triangle3D.d.ts +95 -0
  26. package/src/core/geom/3d/shape/Triangle3D.d.ts.map +1 -0
  27. package/src/core/geom/3d/shape/Triangle3D.js +318 -0
  28. package/src/core/geom/3d/shape/UnionShape3D.js +13 -0
  29. package/src/core/geom/3d/shape/shape_mesh_from_geometry.d.ts +30 -0
  30. package/src/core/geom/3d/shape/shape_mesh_from_geometry.d.ts.map +1 -0
  31. package/src/core/geom/3d/shape/shape_mesh_from_geometry.js +64 -0
  32. package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.js +9 -11
  33. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_build_vertex_to_tets_map.d.ts +28 -0
  34. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_build_vertex_to_tets_map.d.ts.map +1 -0
  35. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_build_vertex_to_tets_map.js +48 -0
  36. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts.map +1 -1
  37. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.js +40 -18
  38. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts +9 -5
  39. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts.map +1 -1
  40. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.js +38 -10
  41. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts +14 -5
  42. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts.map +1 -1
  43. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.js +47 -5
  44. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts +19 -0
  45. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts.map +1 -1
  46. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.js +75 -13
  47. package/src/core/geom/3d/triangle/v3_compute_triangle_normal.d.ts +2 -2
  48. package/src/core/geom/3d/triangle/v3_compute_triangle_normal.d.ts.map +1 -1
  49. package/src/core/geom/3d/triangle/v3_compute_triangle_normal.js +1 -1
  50. package/src/core/geom/vec3/v3_dot_array_array.d.ts +3 -3
  51. package/src/core/geom/vec3/v3_dot_array_array.d.ts.map +1 -1
  52. package/src/core/geom/vec3/v3_dot_array_array.js +2 -2
  53. package/src/core/geom/vec3/v3_negate_array.d.ts +3 -3
  54. package/src/core/geom/vec3/v3_negate_array.d.ts.map +1 -1
  55. package/src/core/geom/vec3/v3_negate_array.js +2 -2
  56. package/src/core/geom/vec3/v3_quat3_apply.d.ts +29 -0
  57. package/src/core/geom/vec3/v3_quat3_apply.d.ts.map +1 -0
  58. package/src/core/geom/vec3/v3_quat3_apply.js +39 -0
  59. package/src/core/geom/vec3/v3_quat3_apply_inverse.d.ts +30 -0
  60. package/src/core/geom/vec3/v3_quat3_apply_inverse.d.ts.map +1 -0
  61. package/src/core/geom/vec3/v3_quat3_apply_inverse.js +41 -0
  62. package/src/core/geom/vec3/v3_triple_cross_product.d.ts +32 -0
  63. package/src/core/geom/vec3/v3_triple_cross_product.d.ts.map +1 -0
  64. package/src/core/geom/vec3/v3_triple_cross_product.js +45 -0
  65. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +16 -3
  66. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
  67. package/src/engine/control/first-person/FirstPersonPlayerController.js +211 -211
  68. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +72 -8
  69. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -1
  70. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +37 -5
  71. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +101 -3
  72. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
  73. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +1789 -1416
  74. package/src/engine/control/first-person/TODO.md +173 -127
  75. package/src/engine/control/first-person/abilities/Slide.d.ts.map +1 -1
  76. package/src/engine/control/first-person/abilities/Slide.js +9 -1
  77. package/src/engine/control/first-person/prototype_first_person_controller.js +88 -2
  78. package/src/engine/control/first-person/test/buildTestPlayer.d.ts.map +1 -1
  79. package/src/engine/control/first-person/test/buildTestPlayer.js +9 -1
  80. package/src/engine/graphics/geometry/CapsuleGeometry.d.ts +42 -0
  81. package/src/engine/graphics/geometry/CapsuleGeometry.d.ts.map +1 -0
  82. package/src/engine/graphics/geometry/CapsuleGeometry.js +171 -0
  83. package/src/engine/physics/BULLET_REVIEW.md +945 -0
  84. package/src/engine/physics/CANNON_REVIEW.md +1300 -0
  85. package/src/engine/physics/JOLT_REVIEW.md +913 -0
  86. package/src/engine/physics/PLAN.md +578 -236
  87. package/src/engine/physics/RAPIER_REVIEW.md +934 -0
  88. package/src/engine/physics/REVIEW_001_ACTION_PLAN.md +642 -0
  89. package/src/engine/physics/REVIEW_002.md +151 -0
  90. package/src/engine/physics/broadphase/compute_fat_world_aabb.js +2 -2
  91. package/src/engine/physics/constraint/DofMode.d.ts +28 -0
  92. package/src/engine/physics/constraint/DofMode.d.ts.map +1 -0
  93. package/src/engine/physics/constraint/DofMode.js +35 -0
  94. package/src/engine/physics/constraint/solve_constraints.d.ts +16 -0
  95. package/src/engine/physics/constraint/solve_constraints.d.ts.map +1 -0
  96. package/src/engine/physics/constraint/solve_constraints.js +436 -0
  97. package/src/engine/physics/contact/ManifoldStore.d.ts +83 -10
  98. package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -1
  99. package/src/engine/physics/contact/ManifoldStore.js +608 -499
  100. package/src/engine/physics/ecs/ColliderObserverSystem.d.ts +2 -2
  101. package/src/engine/physics/ecs/ColliderObserverSystem.d.ts.map +1 -1
  102. package/src/engine/physics/ecs/Joint.d.ts +179 -0
  103. package/src/engine/physics/ecs/Joint.d.ts.map +1 -0
  104. package/src/engine/physics/ecs/Joint.js +234 -0
  105. package/src/engine/physics/ecs/PhysicsSystem.d.ts +180 -20
  106. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  107. package/src/engine/physics/ecs/PhysicsSystem.js +1423 -1159
  108. package/src/engine/physics/fluid/FluidField.d.ts +14 -10
  109. package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
  110. package/src/engine/physics/fluid/FluidField.js +14 -10
  111. package/src/engine/physics/fluid/FluidSimulator.js +1 -1
  112. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts +17 -10
  113. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts.map +1 -1
  114. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.js +18 -11
  115. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts +13 -10
  116. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts.map +1 -1
  117. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.js +18 -13
  118. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts +4 -3
  119. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts.map +1 -1
  120. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.js +15 -11
  121. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts +30 -6
  122. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts.map +1 -1
  123. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.js +44 -18
  124. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts +6 -6
  125. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +1 -1
  126. package/src/engine/physics/gjk/expanding_polytope_algorithm.js +68 -22
  127. package/src/engine/physics/gjk/gjk.d.ts +28 -2
  128. package/src/engine/physics/gjk/gjk.d.ts.map +1 -1
  129. package/src/engine/physics/gjk/gjk.js +421 -378
  130. package/src/engine/physics/gjk/minkowski_support.d.ts +37 -0
  131. package/src/engine/physics/gjk/minkowski_support.d.ts.map +1 -0
  132. package/src/engine/physics/gjk/minkowski_support.js +75 -0
  133. package/src/engine/physics/gjk/mpr.d.ts +56 -0
  134. package/src/engine/physics/gjk/mpr.d.ts.map +1 -0
  135. package/src/engine/physics/gjk/mpr.js +344 -0
  136. package/src/engine/physics/inertia/world_inverse_inertia.d.ts +20 -5
  137. package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -1
  138. package/src/engine/physics/inertia/world_inverse_inertia.js +36 -38
  139. package/src/engine/physics/integration/integrate_position.d.ts +25 -7
  140. package/src/engine/physics/integration/integrate_position.d.ts.map +1 -1
  141. package/src/engine/physics/integration/integrate_position.js +43 -12
  142. package/src/engine/physics/integration/integrate_velocity.d.ts +30 -0
  143. package/src/engine/physics/integration/integrate_velocity.d.ts.map +1 -1
  144. package/src/engine/physics/integration/integrate_velocity.js +82 -1
  145. package/src/engine/physics/island/IslandBuilder.d.ts +4 -1
  146. package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -1
  147. package/src/engine/physics/island/IslandBuilder.js +33 -16
  148. package/src/engine/physics/narrowphase/PosedShape.d.ts +0 -8
  149. package/src/engine/physics/narrowphase/PosedShape.d.ts.map +1 -1
  150. package/src/engine/physics/narrowphase/PosedShape.js +28 -30
  151. package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -1
  152. package/src/engine/physics/narrowphase/box_box_manifold.js +140 -18
  153. package/src/engine/physics/narrowphase/box_triangle_contact.d.ts +30 -0
  154. package/src/engine/physics/narrowphase/box_triangle_contact.d.ts.map +1 -0
  155. package/src/engine/physics/narrowphase/box_triangle_contact.js +811 -0
  156. package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -1
  157. package/src/engine/physics/narrowphase/capsule_contacts.js +10 -56
  158. package/src/engine/physics/narrowphase/capsule_triangle_contact.d.ts +71 -0
  159. package/src/engine/physics/narrowphase/capsule_triangle_contact.d.ts.map +1 -0
  160. package/src/engine/physics/narrowphase/capsule_triangle_contact.js +375 -0
  161. package/src/engine/physics/narrowphase/compute_penetration.d.ts +91 -0
  162. package/src/engine/physics/narrowphase/compute_penetration.d.ts.map +1 -0
  163. package/src/engine/physics/narrowphase/compute_penetration.js +396 -0
  164. package/src/engine/physics/narrowphase/decomposition/aabb_world_to_local.d.ts +35 -0
  165. package/src/engine/physics/narrowphase/decomposition/aabb_world_to_local.d.ts.map +1 -0
  166. package/src/engine/physics/narrowphase/decomposition/aabb_world_to_local.js +80 -0
  167. package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.d.ts +31 -0
  168. package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.d.ts.map +1 -0
  169. package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.js +55 -0
  170. package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.d.ts +42 -0
  171. package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.d.ts.map +1 -0
  172. package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.js +204 -0
  173. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts +42 -0
  174. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts.map +1 -0
  175. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.js +94 -0
  176. package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.d.ts +37 -0
  177. package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.d.ts.map +1 -0
  178. package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.js +37 -0
  179. package/src/engine/physics/narrowphase/narrowphase_step.d.ts +41 -2
  180. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -1
  181. package/src/engine/physics/narrowphase/narrowphase_step.js +1497 -382
  182. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -1
  183. package/src/engine/physics/narrowphase/sphere_box_contact.js +16 -23
  184. package/src/engine/physics/narrowphase/sphere_triangle_contact.d.ts +48 -0
  185. package/src/engine/physics/narrowphase/sphere_triangle_contact.d.ts.map +1 -0
  186. package/src/engine/physics/narrowphase/sphere_triangle_contact.js +143 -0
  187. package/src/engine/physics/queries/overlap_shape.d.ts +51 -0
  188. package/src/engine/physics/queries/overlap_shape.d.ts.map +1 -0
  189. package/src/engine/physics/queries/overlap_shape.js +183 -0
  190. package/src/engine/physics/queries/shape_cast.d.ts +56 -0
  191. package/src/engine/physics/queries/shape_cast.d.ts.map +1 -0
  192. package/src/engine/physics/queries/shape_cast.js +387 -0
  193. package/src/engine/physics/solver/solve_contacts.d.ts +146 -32
  194. package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -1
  195. package/src/engine/physics/solver/solve_contacts.js +809 -223
  196. package/src/engine/physics/broadphase/aabb_transform_oriented.d.ts.map +0 -1
  197. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts +0 -20
  198. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts.map +0 -1
  199. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.js +0 -83
@@ -25,7 +25,7 @@ export class ColliderObserverSystem extends System<any, any, any, any, any> {
25
25
  /** @type {PhysicsSystem} */
26
26
  __physics: PhysicsSystem;
27
27
  dependencies: (typeof Transform | typeof Collider)[];
28
- components_used: (ResourceAccessSpecification<typeof Transform> | ResourceAccessSpecification<typeof RigidBody> | ResourceAccessSpecification<typeof Collider> | ResourceAccessSpecification<typeof ParentEntity>)[];
28
+ components_used: (ResourceAccessSpecification<typeof RigidBody> | ResourceAccessSpecification<typeof Collider> | ResourceAccessSpecification<typeof Transform> | ResourceAccessSpecification<typeof ParentEntity>)[];
29
29
  /**
30
30
  * @param {Collider} collider
31
31
  * @param {Transform} transform
@@ -52,7 +52,7 @@ export class ColliderObserverSystem extends System<any, any, any, any, any> {
52
52
  import { System } from "../../ecs/System.js";
53
53
  import { Transform } from "../../ecs/transform/Transform.js";
54
54
  import { Collider } from "./Collider.js";
55
- import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
56
55
  import { RigidBody } from "./RigidBody.js";
56
+ import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
57
57
  import { ParentEntity } from "../../ecs/parent/ParentEntity.js";
58
58
  //# sourceMappingURL=ColliderObserverSystem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ColliderObserverSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/ColliderObserverSystem.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;GAkBG;AACH;IAEI;;OAEG;IACH,0CAcC;IAXG,4BAA4B;IAC5B,yBAA8B;IAE9B,qDAAyC;IAEzC,qNAKC;IAGL;;;;OAIG;IACH,eAJW,QAAQ,aACR,SAAS,UACT,MAAM,QAYhB;IAED;;;;OAIG;IACH,iBAJW,QAAQ,aACR,SAAS,UACT,MAAM,QAYhB;IAED;;;;;;;;OAQG;IACH,8BAUC;CACJ;uBAnGsB,qBAAqB;0BAClB,kCAAkC;yBACnC,eAAe;4CAHI,oDAAoD;0BAItE,gBAAgB;6BANb,kCAAkC"}
1
+ {"version":3,"file":"ColliderObserverSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/ColliderObserverSystem.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;GAkBG;AACH;IAEI;;OAEG;IACH,0CAcC;IAXG,4BAA4B;IAC5B,yBAA8B;IAE9B,qDAAyC;IAEzC,qNAKC;IAGL;;;;OAIG;IACH,eAJW,QAAQ,aACR,SAAS,UACT,MAAM,QAYhB;IAED;;;;OAIG;IACH,iBAJW,QAAQ,aACR,SAAS,UACT,MAAM,QAYhB;IAED;;;;;;;;OAQG;IACH,8BAUC;CACJ;uBAnGsB,qBAAqB;0BAClB,kCAAkC;yBACnC,eAAe;0BACd,gBAAgB;4CAJE,oDAAoD;6BAFnE,kCAAkC"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Sentinel for {@link Joint#_jointId} before the joint is linked into a
3
+ * {@link PhysicsSystem}.
4
+ * @type {number}
5
+ */
6
+ export const JOINT_UNALLOCATED: number;
7
+ /**
8
+ * `entityB` value meaning "the world" — body A is constrained to a fixed
9
+ * world anchor rather than to a second body.
10
+ * @type {number}
11
+ */
12
+ export const JOINT_WORLD: number;
13
+ /**
14
+ * A configurable 6-DOF constraint between two bodies (or a body and the
15
+ * world). Connects body A's anchor frame to body B's; each of the 6 relative
16
+ * degrees of freedom (3 linear, 3 angular) is independently
17
+ * locked / free / limited / springy / motorised ({@link DofMode}). One
18
+ * constraint type expresses the whole joint taxonomy — see DofMode.
19
+ *
20
+ * The default configuration is a **ball-socket** (point-to-point): the three
21
+ * linear DOFs LOCKED (the two anchor points are held coincident), the three
22
+ * angular DOFs FREE. That alone gives chains, ropes, and pendulums.
23
+ *
24
+ * Anchors live in body-local frames. When `entityB === JOINT_WORLD`,
25
+ * `localAnchorB` is interpreted as a fixed **world** point instead of a
26
+ * local anchor on a second body.
27
+ *
28
+ * Solver state ({@link dofImpulse}, the `_*` fields) is owned by the
29
+ * PhysicsSystem; user code must not write it.
30
+ *
31
+ * @author Alex Goldring
32
+ * @copyright Company Named Limited (c) 2026
33
+ */
34
+ export class Joint {
35
+ /**
36
+ * Entity owning body A (the constraint's first body — always a real body).
37
+ * @type {number}
38
+ */
39
+ entityA: number;
40
+ /**
41
+ * Entity owning body B, or {@link JOINT_WORLD} to anchor A to the world.
42
+ * @type {number}
43
+ */
44
+ entityB: number;
45
+ /**
46
+ * Anchor point on body A, in A's local frame.
47
+ * @readonly
48
+ * @type {Vector3}
49
+ */
50
+ readonly localAnchorA: Vector3;
51
+ /**
52
+ * Anchor point on body B in B's local frame — or, when
53
+ * `entityB === JOINT_WORLD`, a fixed world-space anchor point.
54
+ * @readonly
55
+ * @type {Vector3}
56
+ */
57
+ readonly localAnchorB: Vector3;
58
+ /**
59
+ * Orientation of the joint's reference frame on body A, in A's local
60
+ * space (a unit quaternion; identity = the joint frame is the body
61
+ * frame). The 3 linear and 3 angular DOFs are expressed in this frame:
62
+ * locked/limited/etc. axes are the frame's axes, not world axes. For a
63
+ * hinge, the free angular axis is one of these frame axes — orient the
64
+ * frame so that axis is the hinge axis.
65
+ * @readonly
66
+ * @type {Quaternion}
67
+ */
68
+ readonly localBasisA: Quaternion;
69
+ /**
70
+ * Orientation of the joint's reference frame on body B, in B's local
71
+ * space. At rest a fully-locked joint holds frame B aligned to frame A.
72
+ * When `entityB === JOINT_WORLD`, the world frame is treated as identity
73
+ * (angular locks hold A's frame to world axes).
74
+ * @readonly
75
+ * @type {Quaternion}
76
+ */
77
+ readonly localBasisB: Quaternion;
78
+ /**
79
+ * Per-DOF mode, 6 entries: `[lin x, lin y, lin z, ang x, ang y, ang z]`.
80
+ * Default = ball-socket (linear locked, angular free).
81
+ * @readonly
82
+ * @type {Uint8Array}
83
+ */
84
+ readonly dofMode: Uint8Array;
85
+ /**
86
+ * Lower / upper bounds per DOF, used by {@link DofMode.LIMITED}. Linear in
87
+ * metres, angular in radians. (Reserved — consumed once the LIMITED mode
88
+ * lands.)
89
+ * @readonly
90
+ * @type {Float64Array}
91
+ */
92
+ readonly dofLowerLimit: Float64Array;
93
+ /** @readonly @type {Float64Array} */
94
+ readonly dofUpperLimit: Float64Array;
95
+ /**
96
+ * Spring stiffness / damping per DOF, used by {@link DofMode.SPRING}.
97
+ * (Reserved — consumed once the SPRING mode lands.)
98
+ * @readonly
99
+ * @type {Float64Array}
100
+ */
101
+ readonly dofStiffness: Float64Array;
102
+ /** @readonly @type {Float64Array} */
103
+ readonly dofDamping: Float64Array;
104
+ /**
105
+ * Motor target velocity / max force per DOF, used by
106
+ * {@link DofMode.MOTOR}. (Reserved — consumed once the MOTOR mode lands.)
107
+ * @readonly
108
+ * @type {Float64Array}
109
+ */
110
+ readonly dofMotorTargetVelocity: Float64Array;
111
+ /** @readonly @type {Float64Array} */
112
+ readonly dofMotorMaxForce: Float64Array;
113
+ /**
114
+ * Accumulated constraint impulse per DOF — warm-start state carried across
115
+ * frames. System-owned.
116
+ * @readonly
117
+ * @type {Float64Array}
118
+ */
119
+ readonly dofImpulse: Float64Array;
120
+ /**
121
+ * Resolved packed body id of A, set at link time. System-private.
122
+ * @type {number}
123
+ */
124
+ _bodyIdA: number;
125
+ /**
126
+ * Resolved packed body id of B, or {@link JOINT_WORLD}. System-private.
127
+ * @type {number}
128
+ */
129
+ _bodyIdB: number;
130
+ /**
131
+ * Packed joint handle assigned at link. System-private.
132
+ * @type {number}
133
+ */
134
+ _jointId: number;
135
+ /**
136
+ * Configure this joint as a ball-socket (point-to-point) between two
137
+ * anchors. Linear DOFs locked, angular free — the default, provided as a
138
+ * named helper for clarity at call sites.
139
+ * @returns {Joint} this
140
+ */
141
+ asBallSocket(): Joint;
142
+ /**
143
+ * Configure as a weld (fixed) joint: all 6 DOFs locked, holding the two
144
+ * bodies rigidly in their relative pose.
145
+ * @returns {Joint} this
146
+ */
147
+ asWeld(): Joint;
148
+ /**
149
+ * Configure as a hinge (revolute): 3 linear + 2 angular locked, free to
150
+ * rotate about a single frame axis. Orient {@link localBasisA} /
151
+ * {@link localBasisB} so that frame axis is the desired hinge axis.
152
+ *
153
+ * @param {number} [freeAngularAxis] which frame axis is free: 0 = x
154
+ * (default), 1 = y, 2 = z.
155
+ * @returns {Joint} this
156
+ */
157
+ asHinge(freeAngularAxis?: number): Joint;
158
+ /**
159
+ * Configure as a prismatic (slider): 2 linear + 3 angular locked, free to
160
+ * translate along a single frame axis. Orient {@link localBasisA} /
161
+ * {@link localBasisB} so that frame axis is the desired slide direction.
162
+ *
163
+ * @param {number} [freeLinearAxis] which frame axis is free: 0 = x
164
+ * (default), 1 = y, 2 = z.
165
+ * @returns {Joint} this
166
+ */
167
+ asPrismatic(freeLinearAxis?: number): Joint;
168
+ /**
169
+ * @readonly
170
+ * @type {boolean}
171
+ */
172
+ readonly isJoint: boolean;
173
+ }
174
+ export namespace Joint {
175
+ let typeName: string;
176
+ }
177
+ import Vector3 from "../../../core/geom/Vector3.js";
178
+ import Quaternion from "../../../core/geom/Quaternion.js";
179
+ //# sourceMappingURL=Joint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Joint.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/Joint.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,gCAFU,MAAM,CAEoB;AAEpC;;;;GAIG;AACH,0BAFU,MAAM,CAEc;AAE9B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IAEI;;;OAGG;IACH,SAFU,MAAM,CAEH;IAEb;;;OAGG;IACH,SAFU,MAAM,CAEM;IAEtB;;;;OAIG;IACH,uBAFU,OAAO,CAEmB;IAEpC;;;;;OAKG;IACH,uBAFU,OAAO,CAEmB;IAEpC;;;;;;;;;OASG;IACH,sBAFU,UAAU,CAEW;IAE/B;;;;;;;OAOG;IACH,sBAFU,UAAU,CAEW;IAE/B;;;;;OAKG;IACH,kBAFU,UAAU,CAKjB;IAEH;;;;;;OAMG;IACH,wBAFU,YAAY,CAEc;IACpC,qCAAqC;IACrC,wBADqB,YAAY,CACG;IAEpC;;;;;OAKG;IACH,uBAFU,YAAY,CAEa;IACnC,qCAAqC;IACrC,qBADqB,YAAY,CACA;IAEjC;;;;;OAKG;IACH,iCAFU,YAAY,CAEuB;IAC7C,qCAAqC;IACrC,2BADqB,YAAY,CACM;IAEvC;;;;;OAKG;IACH,qBAFU,YAAY,CAEW;IAEjC;;;OAGG;IACH,UAFU,MAAM,CAEF;IACd;;;OAGG;IACH,UAFU,MAAM,CAEO;IACvB;;;OAGG;IACH,UAFU,MAAM,CAEa;IAE7B;;;;;OAKG;IACH,gBAFa,KAAK,CAUjB;IAED;;;;OAIG;IACH,UAFa,KAAK,CAKjB;IAED;;;;;;;;OAQG;IACH,0BAJW,MAAM,GAEJ,KAAK,CAWjB;IAED;;;;;;;;OAQG;IACH,6BAJW,MAAM,GAEJ,KAAK,CAWjB;IASL;;;OAGG;IACH,kBAFU,OAAO,CAEM;CAZtB;;kBAIS,MAAM;;oBAjOI,+BAA+B;uBAC5B,kCAAkC"}
@@ -0,0 +1,234 @@
1
+ import Vector3 from "../../../core/geom/Vector3.js";
2
+ import Quaternion from "../../../core/geom/Quaternion.js";
3
+ import { DofMode } from "../constraint/DofMode.js";
4
+
5
+ /**
6
+ * Sentinel for {@link Joint#_jointId} before the joint is linked into a
7
+ * {@link PhysicsSystem}.
8
+ * @type {number}
9
+ */
10
+ export const JOINT_UNALLOCATED = -1;
11
+
12
+ /**
13
+ * `entityB` value meaning "the world" — body A is constrained to a fixed
14
+ * world anchor rather than to a second body.
15
+ * @type {number}
16
+ */
17
+ export const JOINT_WORLD = -1;
18
+
19
+ /**
20
+ * A configurable 6-DOF constraint between two bodies (or a body and the
21
+ * world). Connects body A's anchor frame to body B's; each of the 6 relative
22
+ * degrees of freedom (3 linear, 3 angular) is independently
23
+ * locked / free / limited / springy / motorised ({@link DofMode}). One
24
+ * constraint type expresses the whole joint taxonomy — see DofMode.
25
+ *
26
+ * The default configuration is a **ball-socket** (point-to-point): the three
27
+ * linear DOFs LOCKED (the two anchor points are held coincident), the three
28
+ * angular DOFs FREE. That alone gives chains, ropes, and pendulums.
29
+ *
30
+ * Anchors live in body-local frames. When `entityB === JOINT_WORLD`,
31
+ * `localAnchorB` is interpreted as a fixed **world** point instead of a
32
+ * local anchor on a second body.
33
+ *
34
+ * Solver state ({@link dofImpulse}, the `_*` fields) is owned by the
35
+ * PhysicsSystem; user code must not write it.
36
+ *
37
+ * @author Alex Goldring
38
+ * @copyright Company Named Limited (c) 2026
39
+ */
40
+ export class Joint {
41
+
42
+ /**
43
+ * Entity owning body A (the constraint's first body — always a real body).
44
+ * @type {number}
45
+ */
46
+ entityA = -1;
47
+
48
+ /**
49
+ * Entity owning body B, or {@link JOINT_WORLD} to anchor A to the world.
50
+ * @type {number}
51
+ */
52
+ entityB = JOINT_WORLD;
53
+
54
+ /**
55
+ * Anchor point on body A, in A's local frame.
56
+ * @readonly
57
+ * @type {Vector3}
58
+ */
59
+ localAnchorA = new Vector3(0, 0, 0);
60
+
61
+ /**
62
+ * Anchor point on body B in B's local frame — or, when
63
+ * `entityB === JOINT_WORLD`, a fixed world-space anchor point.
64
+ * @readonly
65
+ * @type {Vector3}
66
+ */
67
+ localAnchorB = new Vector3(0, 0, 0);
68
+
69
+ /**
70
+ * Orientation of the joint's reference frame on body A, in A's local
71
+ * space (a unit quaternion; identity = the joint frame is the body
72
+ * frame). The 3 linear and 3 angular DOFs are expressed in this frame:
73
+ * locked/limited/etc. axes are the frame's axes, not world axes. For a
74
+ * hinge, the free angular axis is one of these frame axes — orient the
75
+ * frame so that axis is the hinge axis.
76
+ * @readonly
77
+ * @type {Quaternion}
78
+ */
79
+ localBasisA = new Quaternion();
80
+
81
+ /**
82
+ * Orientation of the joint's reference frame on body B, in B's local
83
+ * space. At rest a fully-locked joint holds frame B aligned to frame A.
84
+ * When `entityB === JOINT_WORLD`, the world frame is treated as identity
85
+ * (angular locks hold A's frame to world axes).
86
+ * @readonly
87
+ * @type {Quaternion}
88
+ */
89
+ localBasisB = new Quaternion();
90
+
91
+ /**
92
+ * Per-DOF mode, 6 entries: `[lin x, lin y, lin z, ang x, ang y, ang z]`.
93
+ * Default = ball-socket (linear locked, angular free).
94
+ * @readonly
95
+ * @type {Uint8Array}
96
+ */
97
+ dofMode = Uint8Array.from([
98
+ DofMode.LOCKED, DofMode.LOCKED, DofMode.LOCKED,
99
+ DofMode.FREE, DofMode.FREE, DofMode.FREE,
100
+ ]);
101
+
102
+ /**
103
+ * Lower / upper bounds per DOF, used by {@link DofMode.LIMITED}. Linear in
104
+ * metres, angular in radians. (Reserved — consumed once the LIMITED mode
105
+ * lands.)
106
+ * @readonly
107
+ * @type {Float64Array}
108
+ */
109
+ dofLowerLimit = new Float64Array(6);
110
+ /** @readonly @type {Float64Array} */
111
+ dofUpperLimit = new Float64Array(6);
112
+
113
+ /**
114
+ * Spring stiffness / damping per DOF, used by {@link DofMode.SPRING}.
115
+ * (Reserved — consumed once the SPRING mode lands.)
116
+ * @readonly
117
+ * @type {Float64Array}
118
+ */
119
+ dofStiffness = new Float64Array(6);
120
+ /** @readonly @type {Float64Array} */
121
+ dofDamping = new Float64Array(6);
122
+
123
+ /**
124
+ * Motor target velocity / max force per DOF, used by
125
+ * {@link DofMode.MOTOR}. (Reserved — consumed once the MOTOR mode lands.)
126
+ * @readonly
127
+ * @type {Float64Array}
128
+ */
129
+ dofMotorTargetVelocity = new Float64Array(6);
130
+ /** @readonly @type {Float64Array} */
131
+ dofMotorMaxForce = new Float64Array(6);
132
+
133
+ /**
134
+ * Accumulated constraint impulse per DOF — warm-start state carried across
135
+ * frames. System-owned.
136
+ * @readonly
137
+ * @type {Float64Array}
138
+ */
139
+ dofImpulse = new Float64Array(6);
140
+
141
+ /**
142
+ * Resolved packed body id of A, set at link time. System-private.
143
+ * @type {number}
144
+ */
145
+ _bodyIdA = -1;
146
+ /**
147
+ * Resolved packed body id of B, or {@link JOINT_WORLD}. System-private.
148
+ * @type {number}
149
+ */
150
+ _bodyIdB = JOINT_WORLD;
151
+ /**
152
+ * Packed joint handle assigned at link. System-private.
153
+ * @type {number}
154
+ */
155
+ _jointId = JOINT_UNALLOCATED;
156
+
157
+ /**
158
+ * Configure this joint as a ball-socket (point-to-point) between two
159
+ * anchors. Linear DOFs locked, angular free — the default, provided as a
160
+ * named helper for clarity at call sites.
161
+ * @returns {Joint} this
162
+ */
163
+ asBallSocket() {
164
+ this.dofMode[0] = DofMode.LOCKED;
165
+ this.dofMode[1] = DofMode.LOCKED;
166
+ this.dofMode[2] = DofMode.LOCKED;
167
+ this.dofMode[3] = DofMode.FREE;
168
+ this.dofMode[4] = DofMode.FREE;
169
+ this.dofMode[5] = DofMode.FREE;
170
+ return this;
171
+ }
172
+
173
+ /**
174
+ * Configure as a weld (fixed) joint: all 6 DOFs locked, holding the two
175
+ * bodies rigidly in their relative pose.
176
+ * @returns {Joint} this
177
+ */
178
+ asWeld() {
179
+ for (let i = 0; i < 6; i++) this.dofMode[i] = DofMode.LOCKED;
180
+ return this;
181
+ }
182
+
183
+ /**
184
+ * Configure as a hinge (revolute): 3 linear + 2 angular locked, free to
185
+ * rotate about a single frame axis. Orient {@link localBasisA} /
186
+ * {@link localBasisB} so that frame axis is the desired hinge axis.
187
+ *
188
+ * @param {number} [freeAngularAxis] which frame axis is free: 0 = x
189
+ * (default), 1 = y, 2 = z.
190
+ * @returns {Joint} this
191
+ */
192
+ asHinge(freeAngularAxis = 0) {
193
+ this.dofMode[0] = DofMode.LOCKED;
194
+ this.dofMode[1] = DofMode.LOCKED;
195
+ this.dofMode[2] = DofMode.LOCKED;
196
+ this.dofMode[3] = DofMode.LOCKED;
197
+ this.dofMode[4] = DofMode.LOCKED;
198
+ this.dofMode[5] = DofMode.LOCKED;
199
+ this.dofMode[3 + freeAngularAxis] = DofMode.FREE;
200
+ return this;
201
+ }
202
+
203
+ /**
204
+ * Configure as a prismatic (slider): 2 linear + 3 angular locked, free to
205
+ * translate along a single frame axis. Orient {@link localBasisA} /
206
+ * {@link localBasisB} so that frame axis is the desired slide direction.
207
+ *
208
+ * @param {number} [freeLinearAxis] which frame axis is free: 0 = x
209
+ * (default), 1 = y, 2 = z.
210
+ * @returns {Joint} this
211
+ */
212
+ asPrismatic(freeLinearAxis = 0) {
213
+ this.dofMode[0] = DofMode.LOCKED;
214
+ this.dofMode[1] = DofMode.LOCKED;
215
+ this.dofMode[2] = DofMode.LOCKED;
216
+ this.dofMode[freeLinearAxis] = DofMode.FREE;
217
+ this.dofMode[3] = DofMode.LOCKED;
218
+ this.dofMode[4] = DofMode.LOCKED;
219
+ this.dofMode[5] = DofMode.LOCKED;
220
+ return this;
221
+ }
222
+ }
223
+
224
+ /**
225
+ * @readonly
226
+ * @type {string}
227
+ */
228
+ Joint.typeName = "Joint";
229
+
230
+ /**
231
+ * @readonly
232
+ * @type {boolean}
233
+ */
234
+ Joint.prototype.isJoint = true;