Skip to main content
The <Body> component lets you add physical bodies (boxes, spheres, cylinders) to the simulation as JSX. Bodies are injected into the MJCF XML before model compilation, so they participate fully in physics — collisions, gravity, grasping, etc.

Usage

How it works

<Body> registers its definition in a provider-level registry. Bodies present at initial mount are included in the first loadScene() call with zero extra reloads. Bodies added or removed after the initial load trigger a debounced scene reload. When children are provided, the SceneRenderer skips default geom visuals for that body, and the <Body> component syncs a <group> wrapper to the body’s physics pose each frame instead.

Props

string
required
Unique body name. Used as the MuJoCo body name in the XML.
'box' | 'sphere' | 'cylinder'
required
Geom type for the body.
[number, number, number]
required
Geom size. Interpretation depends on type — see MuJoCo geom size docs.
[number, number, number]
default:"[0, 0, 0]"
Initial world position of the body.
[number, number, number, number]
default:"[0.5, 0.5, 0.5, 1]"
Color and alpha for the default geom visual. Ignored when children are provided.
number
Body mass in kg.
boolean
Whether to add a freejoint so the body can move freely.
string
MuJoCo friction parameters, e.g. "1.5 0.3 0.1".
string
MuJoCo solver reference parameters.
string
MuJoCo solver impedance parameters.
number
Contact dimensionality. Use 4 or 6 for grasping.
React.ReactNode
Optional custom Three.js visuals. When provided, default geom rendering is skipped and the children are synced to the body’s physics pose.