Skip to main content
Reads <light> elements from the loaded MuJoCo model and creates corresponding Three.js lights.

Usage

<MujocoCanvas config={config}>
  <SceneLights />
</MujocoCanvas>

With Intensity Multiplier

<SceneLights intensity={1.5} />

Props

intensity
number
default:"1.0"
Multiplier applied to all light intensities.

Light Mapping

MJCF light_typeThree.js Light
0 (directional)DirectionalLight
1 (spot)SpotLight
The component reads from the MuJoCo model:
  • model.nlight — number of lights
  • light_pos — position
  • light_dir — direction
  • light_diffuse — color
  • light_castshadow — shadow casting
  • light_attenuation — attenuation coefficients
  • light_cutoff — spotlight cone angle

Hook Alternative

For imperative usage inside your own components, use useSceneLights:
import { useSceneLights } from "mujoco-react";

function MyScene() {
  useSceneLights(1.5);
  // ... your other scene setup
  return <mesh />;
}

Alternative

You can also enable MJCF lights via the mjcfLights prop on MujocoCanvas:
<MujocoCanvas config={config} mjcfLights>
Or skip both and define your own Three.js lights:
<MujocoCanvas config={config}>
  <ambientLight intensity={0.7} />
  <directionalLight position={[1, 2, 5]} castShadow />
</MujocoCanvas>

Notes

  • Lights are created once when the model loads and cleaned up on unmount
  • If your MJCF has no <light> elements, this component does nothing
  • The component delegates to useSceneLights internally