{
  "name": "lamp",
  "title": "Lamp",
  "type": "registry:component",
  "description": "Lamp that emits a point light.",
  "dependencies": [
    "@react-three/fiber@^9.6.1",
    "@react-three/rapier@^2.2.0",
    "@runek/core@^0.12.0",
    "three@^0.184.0"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "Lamp.tsx",
      "content": "import { useFrame } from '@react-three/fiber'\nimport { CuboidCollider, RigidBody } from '@react-three/rapier'\nimport { useWorld, type Vec3 } from '@runek/core'\nimport { useRef } from 'react'\nimport type { PointLight } from 'three'\n\nexport interface LampProps {\n  position?: Vec3\n  rotation?: Vec3\n  height?: number\n  /** Base + pole color. Defaults to the world palette's `metal` slot. */\n  color?: string\n  shadeColor?: string\n  lightColor?: string\n  intensity?: number\n  /** Candle-like intensity flicker, 0–1; 0 holds the light steady. */\n  flicker?: number\n}\n\nexport function Lamp({\n  position = [0, 0, 0],\n  rotation = [0, 0, 0],\n  height = 1.6,\n  color,\n  shadeColor = '#e9d8a6',\n  lightColor = '#ffe8c2',\n  intensity = 18,\n  flicker = 0.08,\n}: LampProps) {\n  const { unit, palette } = useWorld()\n  const metalColor = color ?? palette.metal\n  const h = height * unit\n  const baseR = 0.16 * unit\n  const poleR = 0.02 * unit\n  const shadeR = 0.19 * unit\n  const shadeH = 0.26 * unit\n  const poleH = h - shadeH\n  const lightRef = useRef<PointLight>(null)\n\n  useFrame(({ clock }) => {\n    if (!lightRef.current || flicker <= 0) return\n    const t = clock.elapsedTime\n    // layered sines read as a candle without any per-frame randomness\n    const n = Math.sin(t * 9.3) * 0.5 + Math.sin(t * 23.7) * 0.3 + Math.sin(t * 41.1) * 0.2\n    lightRef.current.intensity = intensity * (1 + n * flicker)\n  })\n\n  return (\n    <RigidBody type=\"fixed\" colliders={false} position={position} rotation={rotation}>\n      <CuboidCollider args={[baseR, h / 2, baseR]} position={[0, h / 2, 0]} />\n\n      <mesh castShadow position={[0, 0.025 * unit, 0]}>\n        <cylinderGeometry args={[baseR, baseR, 0.05 * unit, 24]} />\n        <meshStandardMaterial color={metalColor} metalness={0.4} roughness={0.5} />\n      </mesh>\n      <mesh castShadow position={[0, poleH / 2, 0]}>\n        <cylinderGeometry args={[poleR, poleR, poleH, 12]} />\n        <meshStandardMaterial color={metalColor} metalness={0.4} roughness={0.5} />\n      </mesh>\n      <mesh castShadow position={[0, h - shadeH / 2, 0]}>\n        <coneGeometry args={[shadeR, shadeH, 24, 1, true]} />\n        <meshStandardMaterial\n          color={shadeColor}\n          emissive={shadeColor}\n          emissiveIntensity={0.4}\n          side={2}\n        />\n      </mesh>\n\n      <pointLight\n        ref={lightRef}\n        position={[0, h - shadeH, 0]}\n        color={lightColor}\n        intensity={intensity}\n        distance={12 * unit}\n        decay={2}\n      />\n    </RigidBody>\n  )\n}\n",
      "type": "registry:component"
    }
  ]
}
