{
  "name": "guitar",
  "title": "Guitar",
  "type": "registry:component",
  "description": "An acoustic, electric or bass guitar leaning on a floor stand; the kind and finish are seeded. Decorative.",
  "dependencies": [
    "@runek/core@^0.18.0"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "Guitar.tsx",
      "content": "import { pick, rng, useMaterials, useWorld, type WorldComponentProps } from '@runek/core'\n\nexport type GuitarKind = 'acoustic' | 'electric' | 'bass'\n\nexport interface GuitarProps extends WorldComponentProps {\n  /** Seeded when unset. */\n  kind?: GuitarKind\n  /** The body. Seeded from a few finishes for its kind when unset. */\n  color?: string\n}\n\nconst KINDS: GuitarKind[] = ['acoustic', 'electric', 'bass']\nconst FINISHES: Record<GuitarKind, string[]> = {\n  acoustic: ['#c98b4a', '#8a5a2b', '#e0b07a', '#3b2416'],\n  electric: ['#b3001b', '#f2efe8', '#101010', '#1f6fb2', '#f2a541', '#2e8b57'],\n  bass: ['#101010', '#7a1f1f', '#c98b4a', '#2f4858'],\n}\nconst BODY_TOP = 0.62\n\n/**\n * A guitar leaning back on a floor stand, its front toward local +Z: an acoustic with a round\n * sound hole, an electric with pickups, or a bass with its longer neck, each with a\n * fretboard, a headstock and tuning pegs. Seeded: the kind and the finish. Decorative: no\n * collider.\n */\nexport function Guitar({\n  position = [0, 0, 0],\n  rotation = [0, 0, 0],\n  seed = 1,\n  kind,\n  color,\n}: GuitarProps) {\n  const { unit: u } = useWorld()\n  const next = rng(seed)\n  const type = kind ?? pick(next, KINDS)\n  const finish = color ?? pick(next, FINISHES[type])\n  const acoustic = type === 'acoustic'\n  const m = useMaterials({\n    dark: { color: '#1d1d1f', roughness: 0.5 },\n    body: { color: finish, roughness: 0.25 },\n    neck: { color: '#3a2414', roughness: 0.6 },\n    peg: { slot: 'metal.bare', color: '#c9ccd1', roughness: 0.3, metalness: 0.8 },\n  })\n  const depth = acoustic ? 0.1 : 0.045\n  const lower = acoustic ? 0.2 : 0.17\n  const upper = acoustic ? 0.155 : 0.135\n  const neck = type === 'bass' ? 0.72 : 0.5\n\n  return (\n    <group position={position} rotation={rotation}>\n      {[-1, 1].map((s) => (\n        <mesh\n          key={s}\n          material={m.dark}\n          position={[s * 0.13 * u, 0.04 * u, 0.06 * u]}\n          rotation={[0, s * 0.4, 0]}\n        >\n          <boxGeometry args={[0.02 * u, 0.02 * u, 0.3 * u]} />\n        </mesh>\n      ))}\n      <mesh\n        material={m.dark}\n        castShadow\n        position={[0, 0.45 * u, -0.12 * u]}\n        rotation={[-0.25, 0, 0]}\n      >\n        <cylinderGeometry args={[0.01 * u, 0.01 * u, 0.9 * u, 6]} />\n      </mesh>\n      <group position={[0, 0.1 * u, 0]} rotation={[-0.22, 0, 0]}>\n        <mesh\n          material={m.body}\n          castShadow\n          position={[0, (0.12 + lower) * u, 0]}\n          rotation={[Math.PI / 2, 0, 0]}\n          scale={[1, 1, 1.12]}\n        >\n          <cylinderGeometry args={[lower * u, lower * u, depth * u, 28]} />\n        </mesh>\n        <mesh\n          material={m.body}\n          castShadow\n          position={[0, (BODY_TOP - upper * 0.55) * u, 0]}\n          rotation={[Math.PI / 2, 0, 0]}\n        >\n          <cylinderGeometry args={[upper * u, upper * u, depth * u, 28]} />\n        </mesh>\n        {acoustic ? (\n          <mesh\n            material={m.dark}\n            position={[0, (BODY_TOP - upper * 0.95) * u, (depth / 2 + 0.002) * u]}\n          >\n            <circleGeometry args={[0.045 * u, 24]} />\n          </mesh>\n        ) : (\n          [0.25, 0.4].map((y) => (\n            <mesh key={y} material={m.dark} position={[0, y * u, (depth / 2 + 0.004) * u]}>\n              <boxGeometry args={[0.08 * u, 0.025 * u, 0.008 * u]} />\n            </mesh>\n          ))\n        )}\n        <mesh\n          material={m.neck}\n          castShadow\n          position={[0, (BODY_TOP - 0.08 + neck / 2) * u, 0.01 * u]}\n        >\n          <boxGeometry args={[0.05 * u, neck * u, 0.025 * u]} />\n        </mesh>\n        <mesh\n          material={acoustic ? m.neck : m.body}\n          castShadow\n          position={[0, (BODY_TOP - 0.08 + neck + 0.08) * u, 0.005 * u]}\n          rotation={[0.12, 0, 0]}\n        >\n          <boxGeometry args={[0.075 * u, 0.17 * u, 0.018 * u]} />\n        </mesh>\n        {[-1, 1].flatMap((s) =>\n          [0, 1, 2].map((i) => (\n            <mesh\n              key={`${s}${i}`}\n              material={m.peg}\n              position={[s * 0.045 * u, (BODY_TOP + neck + 0.04 * i) * u, 0]}\n              rotation={[0, 0, Math.PI / 2]}\n            >\n              <cylinderGeometry args={[0.008 * u, 0.008 * u, 0.03 * u, 6]} />\n            </mesh>\n          )),\n        )}\n      </group>\n    </group>\n  )\n}\n\nGuitar.groundSitting = true\n",
      "type": "registry:component"
    }
  ]
}
