Documentation
    Preparing search index...

    Interface RapierBodyAccess

    Per-handle access to a Rapier body — the seam §37's two sync* methods leave open (see the module header).

    PhysicsSolverAdapter deliberately says nothing about reading or writing an individual body: §37's contract is about the step, and the transform exchange with the scene is @fourjs/physics's business. That leaves the physics package needing an interface it can call per body per step, which is this one. It is declared here, in the adapter package, rather than added to @fourjs/physics — the plan reserves that as an allowed extension point, and a WP-5.1 amendment can promote it later once the 3D adapter (WP-5.5) has confirmed the shape is dimension-independent.

    Every method takes handles minted by the same adapter and throws a FourError for a foreign or destroyed handle. Reading methods take out parameters and write into them (§7b, D7); the only allocations left are the { x, y } objects Rapier's own bindings return, which no caller can avoid at 0.19.3.

    Angles, torques, and angular velocities are the §21 planar scalars: a number is about +Z, and a Vector3 must lie on the Z axis.

    interface RapierBodyAccess {
        applyAngularImpulse(
            handle: PhysicsBodyHandle,
            angularImpulse: AngularVelocityInput,
        ): void;
        applyForce(handle: PhysicsBodyHandle, force: Vector3Input): void;
        applyForceAtPoint(
            handle: PhysicsBodyHandle,
            force: Vector3Input,
            worldPoint: Vector3Input,
        ): void;
        applyImpulse(handle: PhysicsBodyHandle, impulse: Vector3Input): void;
        applyImpulseAtPoint(
            handle: PhysicsBodyHandle,
            impulse: Vector3Input,
            worldPoint: Vector3Input,
        ): void;
        applyTorque(handle: PhysicsBodyHandle, torque: AngularVelocityInput): void;
        forEachBody(visit: (handle: PhysicsBodyHandle, id: number) => void): void;
        forEachCollider(
            visit: (handle: PhysicsColliderHandle, id: number) => void,
        ): void;
        getBodyCcdMode(handle: PhysicsBodyHandle): CCDMode;
        getBodyCenterOfMass(handle: PhysicsBodyHandle, out: Vector3): void;
        getBodyId(handle: PhysicsBodyHandle): number;
        getBodyMass(handle: PhysicsBodyHandle): number;
        getBodyTransform(
            handle: PhysicsBodyHandle,
            outPosition: Vector3,
            outRotation: Quaternion,
        ): void;
        getBodyVelocities(
            handle: PhysicsBodyHandle,
            outLinear: Vector3,
            outAngular: Vector3,
        ): void;
        getColliderBody(handle: PhysicsColliderHandle): PhysicsBodyHandle;
        getColliderId(handle: PhysicsColliderHandle): number;
        isBodySleeping(handle: PhysicsBodyHandle): boolean;
        resetForces(handle: PhysicsBodyHandle): void;
        setBodyTransform(
            handle: PhysicsBodyHandle,
            position: Vector3Input,
            rotation: RotationInput,
            wake?: boolean,
        ): void;
        setBodyType(
            handle: PhysicsBodyHandle,
            type: BodyType,
            wake?: boolean,
        ): void;
        setBodyVelocities(
            handle: PhysicsBodyHandle,
            linear: Vector3Input,
            angular: AngularVelocityInput,
            wake?: boolean,
        ): void;
        setNextKinematicTransform(
            handle: PhysicsBodyHandle,
            position: Vector3Input,
            rotation?: RotationInput,
        ): void;
        sleepBody(handle: PhysicsBodyHandle): void;
        wakeBody(handle: PhysicsBodyHandle): void;
    }

    Implemented by

    Index