{
  "name": "lightrig",
  "title": "LightRig",
  "type": "registry:component",
  "description": "Sun + hemisphere/ground fill with shadow configuration.",
  "dependencies": [
    "@react-three/fiber@^9.6.1",
    "@runek/core@^0.12.0",
    "three@^0.184.0"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "LightRig.tsx",
      "content": "import { useFrame } from '@react-three/fiber'\nimport { currentHours, sunState, useWorld, type Vec3 } from '@runek/core'\nimport { useState } from 'react'\nimport { Color } from 'three'\n\nexport interface LightRigProps {\n  sunPosition?: Vec3\n  sunColor?: string\n  sunIntensity?: number\n  ambient?: number\n  skyColor?: string\n  groundColor?: string\n  shadows?: boolean\n  /** Half-extent of the shadow camera frustum, in units. */\n  shadowRange?: number\n}\n\n// Sun tint across the day: warm at the horizon, near-white at noon, cool moonlight at night.\nconst NOON = new Color('#fff4e0')\nconst HORIZON = new Color('#ff9a55')\nconst MOON = new Color('#9fb2e6')\n\nfunction sunTint(day: boolean, elevation: number): string {\n  if (!day) return `#${MOON.getHexString()}`\n  return `#${HORIZON.clone().lerp(NOON, elevation).getHexString()}`\n}\n\n/**\n * A drop-in sun + sky/ground fill rig. Pair with `<World lights={false}>`. With no\n * explicit sun props it tracks the world's time-of-day: the sun's position, tint,\n * and intensity follow `<World time>` / `timezone` (golden hour, blue hour, dim\n * moonlight). Any prop you set wins over the time-derived value.\n */\nexport function LightRig({\n  sunPosition,\n  sunColor,\n  sunIntensity,\n  ambient,\n  skyColor = '#bcd4ff',\n  groundColor = '#4a4030',\n  shadows = true,\n  shadowRange = 30,\n}: LightRigProps) {\n  const { time } = useWorld()\n\n  const [hours, setHours] = useState(() => currentHours(time))\n  useFrame(() => {\n    if (!time.live) return\n    const h = currentHours(time)\n    setHours((prev) => (Math.abs(h - prev) > 0.02 ? h : prev))\n  })\n\n  const sun = sunState(hours)\n  const e = sun.elevation\n\n  const position = sunPosition ?? sun.position\n  const color = sunColor ?? sunTint(sun.day, e)\n  const intensity = sunIntensity ?? (sun.day ? 0.3 + 1.4 * e : 0.08)\n  const amb = ambient ?? (sun.day ? 0.18 + 0.22 * e : 0.1)\n  const hemiIntensity = sun.day ? 0.25 + 0.45 * e : 0.15\n\n  return (\n    <>\n      <hemisphereLight color={skyColor} groundColor={groundColor} intensity={hemiIntensity} />\n      <ambientLight intensity={amb} />\n      <directionalLight\n        position={position}\n        color={color}\n        intensity={intensity}\n        castShadow={shadows}\n        shadow-mapSize={[2048, 2048]}\n        shadow-camera-near={1}\n        shadow-camera-far={120}\n        shadow-camera-left={-shadowRange}\n        shadow-camera-right={shadowRange}\n        shadow-camera-top={shadowRange}\n        shadow-camera-bottom={-shadowRange}\n      />\n    </>\n  )\n}\n",
      "type": "registry:component"
    }
  ]
}
