{
  "name": "drum-kit",
  "title": "DrumKit",
  "type": "registry:component",
  "description": "A five-piece drum kit with hi-hat, crash and ride cymbals on stands and a throne behind it; seeded shell finish. One cuboid collider round the drums.",
  "dependencies": [
    "@react-three/rapier@^2.2.0",
    "@runek/core@^0.18.0"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "DrumKit.tsx",
      "content": "import { CuboidCollider, RigidBody } from '@react-three/rapier'\nimport { pick, rng, useMaterials, useWorld, type Vec3, type WorldComponentProps } from '@runek/core'\n\nexport interface DrumKitProps extends WorldComponentProps {\n  /** The shells. Seeded from a few finishes when unset. */\n  color?: string\n}\n\nconst SHELLS = ['#8e1b1b', '#14213d', '#1b1b1b', '#e5e5e5', '#2a6f4e', '#6b3fa0']\nconst LEG_ANGLES = [0, 1, 2].map((i) => (i * 2 * Math.PI) / 3)\n\n/**\n * A five-piece kit facing local +Z with the throne behind it: a bass drum on its side, a\n * snare, two toms on the bass drum and a floor tom, a hi-hat, and crash and ride cymbals on\n * stands, laid out for a right-handed player sitting at the throne. Seeded: the shell finish.\n * One cuboid collider round the drums; the throne has none, so a `Person` can sit on it.\n */\nexport function DrumKit({\n  position = [0, 0, 0],\n  rotation = [0, 0, 0],\n  seed = 1,\n  color,\n}: DrumKitProps) {\n  const { unit: u } = useWorld()\n  const m = useMaterials({\n    shell: { color: color ?? pick(rng(seed), SHELLS), roughness: 0.25, metalness: 0.2 },\n    head: { color: '#efe9dc', roughness: 0.6 },\n    chrome: { slot: 'metal.bare', color: '#c9ccd1', roughness: 0.3, metalness: 0.8 },\n    bronze: { slot: 'metal.bare', color: '#c9a24a', roughness: 0.25, metalness: 0.8 },\n    seat: { color: '#1b1b1b', roughness: 0.7 },\n  })\n  const at = (p: Vec3): Vec3 => [p[0] * u, p[1] * u, p[2] * u]\n\n  const drum = (key: string, r: number, h: number, p: Vec3, tilt: Vec3 = [0, 0, 0]) => (\n    <group key={key} position={at(p)} rotation={tilt}>\n      <mesh material={m.shell} castShadow receiveShadow>\n        <cylinderGeometry args={[r * u, r * u, h * u, 24]} />\n      </mesh>\n      {[1, -1].map((s) => (\n        <mesh key={s} material={s > 0 ? m.head : m.chrome} position={[0, (s * h * u) / 2, 0]}>\n          <cylinderGeometry args={[r * 1.03 * u, r * 1.03 * u, 0.012 * u, 24]} />\n        </mesh>\n      ))}\n    </group>\n  )\n  const stand = (key: string, x: number, z: number, h: number) => (\n    <group key={`stand-${key}`} position={[x * u, 0, z * u]}>\n      <mesh material={m.chrome} position={[0, (h / 2) * u, 0]}>\n        <cylinderGeometry args={[0.012 * u, 0.012 * u, h * u, 8]} />\n      </mesh>\n      {LEG_ANGLES.map((a) => (\n        <mesh\n          key={a}\n          material={m.chrome}\n          position={[Math.sin(a) * 0.12 * u, 0.06 * u, Math.cos(a) * 0.12 * u]}\n          rotation={[0, a, 0.9]}\n        >\n          <cylinderGeometry args={[0.008 * u, 0.008 * u, 0.28 * u, 6]} />\n        </mesh>\n      ))}\n    </group>\n  )\n  const cymbal = (key: string, r: number, p: Vec3, tilt: number) => (\n    <mesh\n      key={`cymbal-${key}`}\n      material={m.bronze}\n      castShadow\n      position={at(p)}\n      rotation={[tilt, 0, tilt * 0.4]}\n    >\n      <cylinderGeometry args={[r * u, 0.02 * u, 0.02 * u, 28]} />\n    </mesh>\n  )\n\n  return (\n    <group position={position} rotation={rotation}>\n      <RigidBody type=\"fixed\" colliders={false}>\n        <CuboidCollider args={[0.7 * u, 0.4 * u, 0.45 * u]} position={[0, 0.4 * u, 0.05 * u]} />\n      </RigidBody>\n      {drum('bass', 0.28, 0.42, [0, 0.29, 0.15], [Math.PI / 2, 0, 0])}\n      {drum('snare', 0.18, 0.14, [0.22, 0.62, -0.22], [-0.12, 0, 0.08])}\n      {drum('tom-1', 0.13, 0.2, [-0.13, 0.78, 0.08], [-0.35, 0, -0.15])}\n      {drum('tom-2', 0.14, 0.22, [0.17, 0.79, 0.08], [-0.35, 0, 0.15])}\n      {drum('floor-tom', 0.2, 0.38, [-0.5, 0.45, -0.12])}\n      {stand('floor-tom', -0.5, -0.12, 0.26)}\n      {stand('snare', 0.22, -0.22, 0.55)}\n      {stand('hi-hat', 0.5, -0.25, 0.86)}\n      {cymbal('hi-hat-bottom', 0.18, [0.5, 0.84, -0.25], 0)}\n      {cymbal('hi-hat-top', 0.18, [0.5, 0.87, -0.25], 0)}\n      {stand('crash', 0.5, 0.3, 1.32)}\n      {cymbal('crash', 0.22, [0.5, 1.33, 0.3], -0.3)}\n      {stand('ride', -0.72, 0.25, 1.2)}\n      {cymbal('ride', 0.27, [-0.72, 1.21, 0.25], -0.25)}\n      <group position={[0, 0, -0.62 * u]}>\n        <mesh material={m.seat} castShadow position={[0, 0.5 * u, 0]}>\n          <cylinderGeometry args={[0.18 * u, 0.17 * u, 0.08 * u, 20]} />\n        </mesh>\n        {stand('throne', 0, 0, 0.46)}\n      </group>\n    </group>\n  )\n}\n\nDrumKit.groundSitting = true\n",
      "type": "registry:component"
    }
  ]
}
