{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "davit-crane",
  "type": "registry:component",
  "title": "Pedestal davit crane (manual)",
  "description": "Small slewing pipe davit for maintenance and stores lifts. A gusseted base plate with anchor bolts carries a socket with a slew-lock pin. The mast is pipe sized by SWL, turning through a 2.5D gooseneck bend into the jib, with a knee brace. A hand winch on the mast has a ratchet, pawl and crank, and the wire runs over a guide sheave at the gooseneck, along rope guides on the jib, over the tip sheave and down to a swivel hook. slew and hook move it. SWL and tag plates sit on the socket.",
  "dependencies": [
    "three",
    "@react-three/fiber",
    "@react-three/drei"
  ],
  "registryDependencies": [
    "https://deck-twin-library.demoareeb.workers.dev/r/core.json"
  ],
  "files": [
    {
      "path": "lifting/davit-crane.tsx",
      "type": "registry:file",
      "target": "components/deck-twin/lifting/davit-crane.tsx",
      "content": "// Manual pedestal (pipe) davit crane after EN 13852-1 / EN 13157: socketed base plate, slewing gooseneck mast and jib, hand winch, sheaves, wire rope and hook.\nimport * as THREE from 'three'\nimport { useMemo } from 'react'\nimport { Kit, type V3 } from '../lib/kit'\nimport { KitMesh, useKit, type GroupProps } from '../lib/mesh'\nimport { tagPlate } from '../lib/parts'\nimport { pipeOD, pipeWall } from '../lib/standards'\nimport { textMaterial } from '../lib/textures'\nimport { Rope, bar, boxMM, craneYellow, hook, ropeMaterial } from './_rigging'\n\nexport interface DavitCraneProps {\n  /** outreach from the mast axis to the hook, m */\n  reach?: number\n  /** jib centreline above the deck, m */\n  height?: number\n  /** slew, deg, counter-clockwise from above; 0 = jib along +X */\n  slew?: number\n  /** hook below the jib-tip sheave, m */\n  hook?: number\n  /** safe working load, t */\n  swl?: number\n  tag?: string\n}\n\nexport const defaults = {\n  reach: 1.6,\n  height: 2.6,\n  slew: 0,\n  hook: 1.4,\n  swl: 0.5,\n  tag: 'DC-101',\n}\n\nconst DEG = Math.PI / 180\nconst clamp = (v: number, a: number, b: number) => Math.max(a, Math.min(b, v))\n\nfunction dims(reach: number, height: number, swl: number) {\n  const nps = swl <= 0.5 ? 6 : swl <= 1 ? 8 : swl <= 2 ? 10 : 12\n  const od = pipeOD(nps)\n  const rM = od / 2\n  const R = 2.5 * od\n  const h = clamp(height, 1.8, 6)\n  const reachC = clamp(reach, R + 0.45, 6)\n  const rt = 0.08\n  const xTip = reachC - rt\n  const rg = 0.1\n  const xr = -(rM + 0.05)\n  return { nps, od, rM, R, h, reach: reachC, rt, xTip, rg, xr, xg: xr + rg, yg: h + rt - rg, yRope: h + rt, socketH: 0.6, yWinch: 1.1 }\n}\ntype D = ReturnType<typeof dims>\n\nexport function DavitCrane({ reach = defaults.reach, height = defaults.height, slew = defaults.slew, hook: drop = defaults.hook, swl = defaults.swl, tag = defaults.tag, ...group }: DavitCraneProps & GroupProps) {\n  const D = useMemo(() => dims(reach, height, swl), [reach, height, swl])\n  const base = useKit((k) => buildBase(k, D, swl, tag), [D, swl, tag])\n  const mast = useKit((k) => buildMast(k, D, swl), [D, swl])\n  const hk = useKit((k) => buildHook(k, swl), [swl])\n  const yHook = D.h - clamp(drop, 0.3, D.h + 20)\n  const xr = D.xTip + D.rt\n  return (\n    <group {...group}>\n      <KitMesh data={base} />\n      <group rotation={[0, slew * DEG, 0]}>\n        <KitMesh data={mast} />\n        <Rope a={[xr, D.h, 0]} b={[xr, yHook + 0.1, 0]} r={0.006} material={ropeMaterial()} />\n        <group position={[xr, yHook, 0]}>\n          <KitMesh data={hk} />\n        </group>\n      </group>\n    </group>\n  )\n}\n\nexport default DavitCrane\n\nfunction buildBase(k: Kit, D: D, swl: number, tag: string) {\n  const Y = craneYellow()\n  const rs = D.rM + 0.035\n  const bp = Math.max(0.5, rs * 2 + 0.25)\n  boxMM(k, Y, [-bp / 2, 0, -bp / 2], [bp / 2, 0.03, bp / 2])\n  k.pipe(Y, [0, 0.03, 0], [0, D.socketH, 0], rs * 2, 0.012, 32)\n  for (let i = 0; i < 4; i++) {\n    const a = (i * Math.PI) / 2 + Math.PI / 4\n    const sh = new THREE.Shape([new THREE.Vector2(0, 0), new THREE.Vector2(bp / 2 * Math.SQRT2 - rs - 0.06, 0), new THREE.Vector2(0, D.socketH * 0.6)])\n    const q = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), -a)\n    const o = new THREE.Vector3(Math.cos(a) * rs, 0.03, Math.sin(a) * rs).add(new THREE.Vector3(0, 0, -0.006).applyQuaternion(q))\n    k.extrude(Y, sh, 0.012, new THREE.Matrix4().compose(o, q, new THREE.Vector3(1, 1, 1)))\n  }\n  for (const sx of [-1, 1])\n    for (const sz of [-1, 1]) {\n      const p: V3 = [sx * (bp / 2 - 0.06), 0.03, sz * (bp / 2 - 0.06)]\n      k.cyl('stainless', 0.025, 0.004, [p[0], 0.032, p[2]], 'y', 14)\n      k.hex('nut', 0.042, 0.024, [p[0], 0.046, p[2]])\n      k.cyl('boltXylan', 0.011, 0.07, [p[0], 0.06, p[2]], 'y', 8)\n    }\n  // socket head ring with the slew-lock pin\n  k.cyl(Y, rs + 0.03, 0.03, [0, D.socketH - 0.015, 0], 'y', 32)\n  k.cyl('castIron', 0.012, 0.08, [-(rs + 0.015), D.socketH + 0.02, 0], 'y', 8)\n  k.rod('actuatorRed', [-(rs + 0.015), D.socketH + 0.06, 0], [-(rs + 0.1), D.socketH + 0.06, 0], 0.008, 6)\n  // SWL + tag plates on the socket\n  const q = new THREE.Quaternion()\n  k.box('stainless', [0.2, 0.08, 0.003], [0, D.socketH * 0.55, rs + 0.002], q)\n  k.plane(textMaterial(`SWL ${swl} t`, '#f4f4ef', '#111111', 256, 96), 0.18, 0.065, [0, D.socketH * 0.55, rs + 0.0037])\n  if (tag) tagPlate(k, tag, [0, D.socketH * 0.3, rs + 0.001], 'z', 0.16)\n}\n\nfunction buildMast(k: Kit, D: D, swl: number) {\n  const Y = craneYellow()\n  const dark = 'castIron' as const\n  const rope = ropeMaterial()\n  const { od, R, h, rM } = D\n  const wall = pipeWall(D.nps, 'XS')\n  // slew bearing ring, mast, gooseneck bend, jib, knee brace\n  k.cyl(dark, rM + 0.045, 0.04, [0, D.socketH + 0.02, 0], 'y', 32)\n  k.pipe(Y, [0, D.socketH * 0.3, 0], [0, h - R, 0], od, wall, 28)\n  k.bend(Y, [0, h - R, 0], [0, 1, 0], [1, 0, 0], R, od, Math.PI / 2, wall)\n  k.pipe(Y, [R, h, 0], [D.xTip - 0.12, h, 0], od, wall, 28)\n  k.disc(Y, rM, [D.xTip - 0.12, h, 0], 'x', 28)\n  const kb = Math.max(0.6, (D.xTip - R) * 0.6 + R)\n  k.rod(Y, [rM * 0.9, h - R - 0.7, 0], [kb, h - rM * 0.9, 0], od * 0.22, 12)\n  // jib-tip cheek plates, sheave, wire wrap\n  for (const sz of [-1, 1]) bar(k, Y, [D.xTip - 0.3, h, sz * 0.03], [D.xTip + 0.03, h, sz * 0.03], Math.max(od, 0.18), 0.01, [0, 0, 1])\n  k.cyl(dark, D.rt, 0.035, [D.xTip, h, 0], 'z', 22)\n  k.cyl('stainless', 0.012, 0.09, [D.xTip, h, 0], 'z', 8)\n  k.torus(rope, D.rt, 0.006, [D.xTip, h, 0], 'z', 6, 18, Math.PI / 2)\n  // guide sheave over the gooseneck on twin brackets\n  for (const sz of [-1, 1]) bar(k, Y, [D.xg, D.yg, sz * 0.028], [0, h - R - 0.05, sz * 0.028], 0.1, 0.01, [0, 0, 1])\n  k.cyl(dark, D.rg, 0.03, [D.xg, D.yg, 0], 'z', 22)\n  k.cyl('stainless', 0.012, 0.08, [D.xg, D.yg, 0], 'z', 8)\n  k.add(rope, new THREE.TorusGeometry(D.rg, 0.006, 6, 18, Math.PI / 2).rotateZ(Math.PI / 2), new THREE.Matrix4().makeTranslation(D.xg, D.yg, 0))\n  // hand winch on the back of the mast: clamp bands, side plates, drum, ratchet, pawl, crank\n  const yw = D.yWinch\n  const rd = 0.06 + swl * 0.02\n  const xd = D.xr - rd - 0.008\n  for (const y of [yw - 0.18, yw + 0.18]) k.torus(Y, rM + 0.008, 0.012, [0, y, 0], 'y', 6, 28)\n  for (const sz of [-1, 1]) {\n    boxMM(k, Y, [xd - rd - 0.08, yw - 0.22, sz * 0.11 - 0.006], [-rM * 0.6, yw + 0.22, sz * 0.11 + 0.006])\n  }\n  k.cyl(dark, rd, 0.2, [xd, yw, 0], 'z', 20)\n  k.cyl(rope, rd + 0.008, 0.17, [xd, yw, 0], 'z', 20)\n  for (const sz of [-1, 1]) k.cyl(Y, rd + 0.05, 0.008, [xd, yw, sz * 0.095], 'z', 24)\n  k.cyl('stainless', 0.015, 0.34, [xd, yw, 0.03], 'z', 10)\n  const nT = 16\n  for (let i = 0; i < nT; i++) {\n    const a = (i / nT) * Math.PI * 2\n    k.box(dark, [0.02, 0.012, 0.012], [xd + Math.cos(a) * (rd + 0.04), yw + Math.sin(a) * (rd + 0.04), 0.125], new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 0, 1), a))\n  }\n  k.cyl(dark, rd + 0.035, 0.012, [xd, yw, 0.125], 'z', 24)\n  bar(k, dark, [xd - rd - 0.06, yw + 0.08, 0.125], [xd - rd - 0.03, yw + 0.035, 0.125], 0.012, 0.02, [0, 0, 1])\n  bar(k, 'handwheel', [xd, yw, 0.2], [xd - 0.2, yw - 0.12, 0.2], 0.025, 0.015, [0, 0, 1])\n  k.cyl('rubberBlack', 0.016, 0.12, [xd - 0.2, yw - 0.12, 0.26], 'z', 10)\n  // wire: drum → guide sheave → along the jib → tip sheave\n  k.rod(rope, [D.xr, yw, 0], [D.xr, D.yg, 0], 0.006, 6)\n  k.rod(rope, [D.xg, D.yRope, 0], [D.xTip, D.yRope, 0], 0.006, 6)\n  for (let x = R + 0.25; x < D.xTip - 0.3; x += 0.6) {\n    for (const sz of [-1, 1]) boxMM(k, Y, [x - 0.02, h + rM - 0.01, sz * 0.03 - 0.004], [x + 0.02, D.yRope + 0.02, sz * 0.03 + 0.004])\n    k.cyl('nut', 0.012, 0.064, [x, D.yRope + 0.014, 0], 'z', 8)\n  }\n}\n\nfunction buildHook(k: Kit, swl: number) {\n  const s = clamp(0.7 + swl * 0.3, 0.7, 1.5)\n  k.cyl('castIron', 0.016 * s, 0.09, [0, 0.07, 0], 'y', 8)\n  k.torus('galvanised', 0.025 * s, 0.006 * s, [0, 0.12, 0], 'z', 6, 14)\n  k.cyl('castIron', 0.03 * s, 0.05 * s, [0, 0.0, 0], 'y', 12)\n  hook(k, [0, -0.08 * s, 0], 0.035 * s, 'castIron')\n}\n"
    },
    {
      "path": "lifting/_rigging.tsx",
      "type": "registry:file",
      "target": "components/deck-twin/lifting/_rigging.tsx",
      "content": "// Shared rigging for the lifting category: wire rope, shackles, master links, 4-leg sling sets, hooks, hazard panels and oriented bars.\nimport * as THREE from 'three'\nimport { useMemo } from 'react'\nimport { Kit, mat4, uvScale, type MatKey, type V3 } from '../lib/kit'\nimport { paint } from '../lib/materials'\nimport { liftingLug } from '../lib/parts'\nimport { hazardStripeMaterial } from '../lib/textures'\n\nconst UNIT_ROPE = new THREE.CylinderGeometry(1, 1, 1, 8, 1, false)\n\n/** Galvanised wire rope (dark, oily). */\nexport const ropeMaterial = () => paint('#3a3d40', { metalness: 0.75, roughness: 0.42, clearcoat: 0, weather: 0 })\n/** Offshore crane / lifting-gear yellow (RAL 1003). */\nexport const craneYellow = () => paint('#eab308', { weather: 0.9 })\n\n/** Axis-aligned box from min to max corners. */\nexport function boxMM(k: Kit, mat: MatKey, a: V3, b: V3) {\n  k.box(mat, [Math.abs(b[0] - a[0]), Math.abs(b[1] - a[1]), Math.abs(b[2] - a[2])], [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2])\n}\n\n/** Rectangular bar from a to b, w across (perpendicular to up), h along `up`. */\nexport function bar(k: Kit, mat: MatKey, a: V3, b: V3, w: number, h: number, up: V3 = [0, 1, 0]) {\n  const A = new THREE.Vector3(...a)\n  const d = new THREE.Vector3(...b).sub(A)\n  const L = d.length()\n  if (L < 1e-6) return\n  const x = d.normalize()\n  let u = new THREE.Vector3(...up).normalize()\n  if (Math.abs(u.dot(x)) > 0.99) u = Math.abs(x.y) > 0.9 ? new THREE.Vector3(1, 0, 0) : new THREE.Vector3(0, 1, 0)\n  const z = new THREE.Vector3().crossVectors(x, u).normalize()\n  const y = new THREE.Vector3().crossVectors(z, x).normalize()\n  const m = new THREE.Matrix4().makeBasis(x, y, z).setPosition(A.addScaledVector(x, L / 2))\n  k.add(mat, new THREE.BoxGeometry(L, h, w), m)\n}\n\n/** Black/yellow hazard chevron panel of w × h, centred at pos, facing `normal`, laid 4 mm proud. */\nexport function hazardPanel(k: Kit, pos: V3, w: number, h: number, normal: V3, stripe = 0.3) {\n  const n = new THREE.Vector3(...normal).normalize()\n  const q = new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 0, 1), n)\n  const g = new THREE.PlaneGeometry(w, h)\n  uvScale(g, w / (stripe * 2), h / (stripe * 2))\n  const p = new THREE.Vector3(...pos).addScaledVector(n, 0.004)\n  k.add(hazardStripeMaterial(), g, mat4(p.toArray() as V3, q))\n}\n\n/** Bow shackle: bow and pin in the plane of `along` and +Y, pin centre at pos (pairs with a padeye plate across `along`). s = jaw width. */\nexport function shackle(k: Kit, pos: V3, s = 0.06, along: 'x' | 'z' = 'x', mat: MatKey = 'galvanised') {\n  const r = s * 0.22\n  const q = along === 'x' ? new THREE.Quaternion() : new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI / 2)\n  const m = (p: V3) => new THREE.Matrix4().compose(new THREE.Vector3(...p).applyQuaternion(q).add(new THREE.Vector3(...pos)), q, new THREE.Vector3(1, 1, 1))\n  const bow = new THREE.TorusGeometry(s / 2, r, 6, 16, Math.PI)\n  k.add(mat, bow, m([0, s * 0.9, 0]))\n  for (const sx of [-1, 1]) k.add(mat, new THREE.CylinderGeometry(r, r, s * 0.9, 6), m([sx * (s / 2), s * 0.45, 0]))\n  k.add('nut', new THREE.CylinderGeometry(r * 0.95, r * 0.95, s + r * 6, 8).rotateZ(Math.PI / 2), m([0, 0, 0]))\n  for (const sx of [-1, 1]) k.add(mat, new THREE.SphereGeometry(r * 1.25, 8, 6), m([sx * (s / 2), 0, 0]))\n}\n\n/** Top of a shackle's bow (where a sling eye sits). */\nexport const shackleTop = (pos: V3, s = 0.06): V3 => [pos[0], pos[1] + s * 1.4, pos[2]]\n\n/** Oblong master link, long axis vertical, centre at pos. */\nexport function masterLink(k: Kit, pos: V3, s = 0.25, mat: MatKey = 'galvanised') {\n  const g = new THREE.TorusGeometry(s * 0.32, s * 0.08, 8, 24)\n  g.scale(1, 1.55, 1)\n  k.add(mat, g, mat4(pos))\n}\n\n/** Four-leg sling set: legs from each attachment point to a master link at `apex`, with thimble eyes and ferrules. */\nexport function slingSet(k: Kit, eyes: V3[], apex: V3, s = 0.25, rope = 0.012) {\n  const rm = ropeMaterial()\n  const link = s * 0.32 * 1.55\n  const bottom: V3 = [apex[0], apex[1] - link + s * 0.04, apex[2]]\n  masterLink(k, apex, s)\n  // intermediate links (one per pair of legs)\n  for (const sx of [-1, 1]) {\n    const g = new THREE.TorusGeometry(s * 0.16, s * 0.05, 6, 18)\n    g.scale(1, 1.4, 1)\n    k.add('galvanised', g, mat4([bottom[0] + sx * s * 0.12, bottom[1] - s * 0.12, bottom[2]], new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI / 2)))\n  }\n  const hang: V3 = [bottom[0], bottom[1] - s * 0.3, bottom[2]]\n  for (const e of eyes) {\n    const top: V3 = [hang[0] + Math.sign(e[0] - hang[0]) * s * 0.12, hang[1], hang[2] + Math.sign(e[2] - hang[2]) * s * 0.02]\n    const E = new THREE.Vector3(...e)\n    const T = new THREE.Vector3(...top)\n    const dir = T.clone().sub(E).normalize()\n    // thimble eye at the shackle, ferrule a little up the leg\n    const eyeC = E.clone().addScaledVector(dir, 0.06)\n    k.rod(rm, eyeC.toArray() as V3, T.toArray() as V3, rope, 6)\n    k.rod('aluminium', eyeC.clone().addScaledVector(dir, 0.12).toArray() as V3, eyeC.clone().addScaledVector(dir, 0.22).toArray() as V3, rope * 1.9, 8)\n    k.torus('galvanised', 0.035, rope * 0.9, eyeC.toArray() as V3, new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 1, 0), new THREE.Vector3(-dir.z, 0, dir.x).normalize()), 6, 14)\n    k.rod(rm, T.toArray() as V3, [top[0], top[1] + 0.04, top[2]], rope, 6)\n  }\n}\n\n/** Forged single hook (DIN 15401 shape): shank up from pos, bowl below, latch. size = bowl inner radius. */\nexport function hook(k: Kit, pos: V3, size = 0.12, mat: MatKey = 'castIron', latch: MatKey = 'safetyYellow') {\n  const [x, y, z] = pos\n  const r = size\n  const t = size * 0.42\n  k.cyl(mat, t * 0.55, r * 1.3, [x, y + r * 0.65, z], 'y', 12)\n  k.hex('nut', t * 1.6, t * 0.6, [x, y + r * 1.35, z])\n  // bowl: 300° arc of a tapered section, open towards +X\n  const arc = new THREE.TorusGeometry(r, t * 0.6, 10, 24, (5 * Math.PI) / 3)\n  arc.rotateZ(Math.PI / 2 + Math.PI / 6)\n  k.add(mat, arc, mat4([x, y - r * 1.0, z], undefined, [1, 1.05, 1.3]))\n  k.sphere(mat, t * 0.55, [x + r * Math.cos(Math.PI / 6 + Math.PI / 2 + (5 * Math.PI) / 3), y - r + r * Math.sin(Math.PI / 6 + Math.PI / 2 + (5 * Math.PI) / 3), z], undefined, 10)\n  k.rod(latch, [x + t * 0.5, y + r * 0.1, z], [x + r * 0.95, y - r * 0.45, z], t * 0.12, 6)\n}\n\n/** Stretched-rope mesh between two points (moves with props without rebuilding geometry). */\nexport function Rope({ a, b, r = 0.022, material }: { a: V3; b: V3; r?: number; material?: THREE.Material }) {\n  const t = useMemo(() => {\n    const A = new THREE.Vector3(...a)\n    const d = new THREE.Vector3(...b).sub(A)\n    const L = Math.max(d.length(), 1e-4)\n    const q = new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 1, 0), d.normalize())\n    return { p: A.addScaledVector(d, L / 2), q, s: new THREE.Vector3(r, L, r) }\n  }, [a[0], a[1], a[2], b[0], b[1], b[2], r]) // eslint-disable-line react-hooks/exhaustive-deps\n  const m = material ?? ropeMaterial()\n  return <mesh geometry={UNIT_ROPE} material={m} position={t.p} quaternion={t.q} scale={t.s} castShadow />\n}\n\n/** Padeye plate (across `across`) with a bow shackle through its hole; returns the bow top for the sling eye. */\nexport function padeyeShackle(k: Kit, pos: V3, across: 'x' | 'z' = 'x', s = 1, mat: MatKey = 'structSteel'): V3 {\n  liftingLug(k, pos, across === 'x' ? 'z' : 'x', s, mat)\n  const pin: V3 = [pos[0], pos[1] + 0.12 * s * 0.65, pos[2]]\n  shackle(k, pin, 0.065 * s, across)\n  return shackleTop(pin, 0.065 * s)\n}\n"
    }
  ],
  "categories": [
    "lifting"
  ],
  "meta": {
    "export": "DavitCrane",
    "anchor": "base",
    "standards": [
      "EN 13852-1",
      "EN 13157",
      "LOLER / DNV-ST-0378"
    ]
  }
}