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:
| Field | Type | Description |
|---|---|---|
objectId | string | Linked scene object |
type | static / dynamic / kinematic | Physics behavior |
mass | number | Mass in kg (dynamic only) |
friction | number | Surface friction coefficient |
restitution | number | Bounciness (0 = clay, 1 = rubber) |
Store Actions
| Action | Effect |
|---|---|
addBody(objectId, config) | Register a physics body |
removeBody(objectId) | Remove physics simulation |
startSimulation() | Unpause physics engine |
stopSimulation() | Pause physics |
stepSimulation() | Advance one physics tick |