Interface RapierContext

Hierarchy

  • RapierContext

Properties

isDebug: boolean

Is debug mode enabled

isPaused: boolean

If the physics simulation is paused

rapier: __module

Direct access to the Rapier instance

setWorld: ((world: World) => void)

Type declaration

    • (world: World): void
    • Can be used to overwrite the current World. Useful when working with snapshots.

      Example

      import { useRapier } from '@react-three/rapier';

      const SnapshottingComponent = () => {
      const { world, setWorld, rapier } = useRapier();
      const worldSnapshot = useRef<Uint8Array>();

      // Store the snapshot
      const takeSnapshot = () => {
      const snapshot = world.takeSnapshot()
      worldSnapshot.current = snapshot
      }

      // Create a new World from the snapshot, and replace the current one
      const restoreSnapshot = () => {
      setWorld(rapier.World.restoreSnapshot(worldSnapshot.current))
      }

      return <>
      <Rigidbody>...</RigidBody>
      <Rigidbody>...</RigidBody>
      <Rigidbody>...</RigidBody>
      <Rigidbody>...</RigidBody>
      <Rigidbody>...</RigidBody>
      </>
      }

      Parameters

      • world: World

      Returns void

step: ((deltaTime: number) => void)

Type declaration

    • (deltaTime: number): void
    • Step the physics world one step

      Example

      step(1/60)
      

      Parameters

      • deltaTime: number

        The delta time to step the world with

      Returns void

world: World

The Rapier physics world

Generated using TypeDoc