Documentation
    Preparing search index...

    Module @fourjs/physics-rapier

    @fourjs/physics-rapier

    Rapier solver adapters (2D and 3D, WebAssembly). Part of fourJS.

    Implements §37 and §102 of docs/SPECIFICATION.md; the first adapter per Phase 5 (§108). This package sits below @fourjs/physics: it implements PhysicsSolverAdapter and depends on nothing else in the engine, which is what makes the solver swappable. Application code should target @fourjs/physics and hand it an adapter instance.

    • Rapier2dAdapter and Rapier3dAdapter — one per §21 dimension, each wrapping its own @dimforge/rapier{2,3}d-compat build (pinned 0.20.0, base64-inlined wasm). Neither loads the other's module; importing the barrel costs nothing until initializeRapier2d / initializeRapier3d runs (async, §37 permits a Promise).
    • RapierBodyAccess — the per-handle SolverBodyAccess implementation, declared once and dimension-independent. Both adapters also implement SolverBodyTuningAccess (§37 property changes after createBody: the §23 mass triple, damping, gravity scale, the §31 mode, and a collider's §25 material / §24 filter), so a PhysicsWorld on either of them reports supportsLiveProperties: true.
    • Conversion helpers — toRapierVector2/3, fromRapierVector2/3, angle/rotation/quaternion conversions, shape and collider-descriptor builders, interaction-group packing, and principal-inertia conversion.
    • Adapters own monotonic, never-reused body ids (Rapier handles are unordered doubles) — the §33 checksum order; snapshot envelopes F4R2/F4R3 carry the id registry.
    • Rapier 0.20.0 exposes no joint reaction getters → reportsJointReactions is false and breakable joints are refused; motor maxTorque/maxForce acts as a force-based gain, not §28's hard cap.
    • collisionstay is adapter-derived from a touching-pair map (Rapier reports only start/stop); restitution combine is forced to Max per Appendix A; §32 sleep thresholds are unmapped (only enabled).

    Unit tests are colocated in tests/ per §92.

    Workspace name @fourjs/physics-rapier; publishes as @danielsimonjr/fourjs-physics-rapier.

    Rapier2dAdapter
    Rapier3dAdapter
    RapierBodyAccess
    RapierRotation3
    RapierVector3
    Rapier2dModule
    Rapier3dModule
    RapierVector2
    PACKAGE_NAME
    createRapierAdapter
    createRapierColliderDesc
    createRapierColliderDesc3d
    createRapierRotation3
    createRapierShape
    createRapierShape3d
    createRapierVector2
    createRapierVector3
    fromRapierAngle
    fromRapierRotation3
    fromRapierVector2
    fromRapierVector3
    initializeRapier2d
    initializeRapier3d
    isRapierSupported
    packInteractionGroups
    packInteractionGroups3d
    quaternionToAngleZ
    rapier2dModule
    rapier2dVersion
    rapier3dModule
    rapier3dVersion
    registerRapierSolver
    revoluteAxisSignZ
    rotateVectorByRotation3
    toPrincipalInertia3d
    toRapierAngle
    toRapierAngularScalar
    toRapierAngularVector3
    toRapierBodyType
    toRapierBodyType3d
    toRapierJointAxis2d
    toRapierRotation3
    toRapierVector2
    toRapierVector3