Skip to main content

Factory Simulation & Physics

Add rigid body physics to scene objects for factory simulation, product testing, and interactive demos.

Status: Scaffolded. PhysicsWorld wrapper is live in SceneRenderer (currently a pass-through stub). Install @react-three/rapier to enable.

Enable Physics

pnpm --filter yugma-app add @react-three/rapier @dimforge/rapier3d-compat

Then replace the PhysicsWorld.tsx stub body:

import { Physics } from '@react-three/rapier'

export function PhysicsWorld({ children }) {
const running = usePhysicsStore(s => s.simulation.running)
return <Physics paused={!running}>{children}</Physics>
}

Physics Bodies

Each scene object can have an associated PhysicsBody:

FieldTypeDescription
objectIdstringLinked scene object
typestatic / dynamic / kinematicPhysics behavior
massnumberMass in kg (dynamic only)
frictionnumberSurface friction coefficient
restitutionnumberBounciness (0 = clay, 1 = rubber)

Store Actions

ActionEffect
addBody(objectId, config)Register a physics body
removeBody(objectId)Remove physics simulation
startSimulation()Unpause physics engine
stopSimulation()Pause physics
stepSimulation()Advance one physics tick