{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cargo-basket",
  "type": "registry:component",
  "title": "Offshore cargo basket",
  "description": "Open-top offshore cargo basket: RHS 200 × 100 base frame with channel cross members and a checker-plate floor, two fork-pocket tunnels across the width, SHS posts at ≤ 1.6 m with top and mid rails, kick plates and expanded-metal mesh sides, floor lashing and tag-line D-rings, marking plates and four padeyes with shackles and a 4-leg sling set to a master link. Length runs along X.",
  "dependencies": [
    "three",
    "@react-three/fiber",
    "@react-three/drei"
  ],
  "registryDependencies": [
    "https://deck-twin-library.demoareeb.workers.dev/r/core.json"
  ],
  "files": [
    {
      "path": "lifting/cargo-basket.tsx",
      "type": "registry:file",
      "target": "components/deck-twin/lifting/cargo-basket.tsx",
      "content": "// Offshore open-top cargo basket after DNV 2.7-1 / EN 12079-1: RHS base frame with fork pockets, posts and rails, kick plates and mesh sides, padeyes with a 4-leg sling set.\nimport * as THREE from 'three'\nimport { Kit, type MatKey, type V3 } from '../lib/kit'\nimport { KitMesh, useKit, type GroupProps } from '../lib/mesh'\nimport { paint } from '../lib/materials'\nimport { checkerPlate, member, tagPlate } from '../lib/parts'\nimport { SECTIONS } from '../lib/standards'\nimport { meshGuardMaterial, textMaterial } from '../lib/textures'\nimport { boxMM, padeyeShackle, slingSet } from './_rigging'\n\nexport interface CargoBasketProps {\n  /** external length, m */\n  length?: number\n  /** external width, m */\n  width?: number\n  /** side wall height above the deck, m */\n  height?: number\n  color?: string\n  /** maximum gross weight, t (marking plate) */\n  swl?: number\n  liftingSet?: boolean\n  tag?: string\n}\n\nexport const defaults = {\n  length: 6,\n  width: 2.5,\n  height: 1.2,\n  color: '#e8641c',\n  swl: 10,\n  liftingSet: true,\n  tag: 'CB-101',\n}\n\nexport function CargoBasket({ length = defaults.length, width = defaults.width, height = defaults.height, color = defaults.color, swl = defaults.swl, liftingSet = defaults.liftingSet, tag = defaults.tag, ...group }: CargoBasketProps & GroupProps) {\n  const data = useKit((k) => build(k, length, width, height, color, swl, liftingSet, tag), [length, width, height, color, swl, liftingSet, tag])\n  return (\n    <group {...group}>\n      <KitMesh data={data} />\n    </group>\n  )\n}\n\nexport default CargoBasket\n\nfunction build(k: Kit, Lx: number, Wz: number, Hy: number, color: string, swl: number, lifting: boolean, tag: string) {\n  const L = Math.max(1.5, Lx)\n  const W = Math.max(1.0, Wz)\n  const H = Math.max(0.6, Hy)\n  const P = paint(color, { weather: 1.2 })\n  const dark: MatKey = 'rubberBlack'\n  const base = 'RHS 200x100x8'\n  const bd = SECTIONS[base].d\n  const bb = SECTIONS[base].b\n  const sq = 'SHS 100x100x6.3'\n  const s = SECTIONS[sq].b\n  const hx = L / 2\n  const hz = W / 2\n  const ex = hx - bb / 2\n  const ez = hz - bb / 2\n\n  // base frame, cross members, plate floor\n  for (const sz of [-1, 1]) member(k, [-hx, bd / 2, sz * ez], [hx, bd / 2, sz * ez], base, P)\n  for (const sx of [-1, 1]) member(k, [sx * ex, bd / 2, -ez + bb / 2], [sx * ex, bd / 2, ez - bb / 2], base, P)\n  const n = Math.max(2, Math.round(L / 0.6))\n  for (let i = 1; i < n; i++) {\n    const x = -ex + (2 * ex * i) / n\n    member(k, [x, bd / 2 + 0.02, -ez + bb / 2], [x, bd / 2 + 0.02, ez - bb / 2], 'UPN 160', P)\n  }\n  checkerPlate(k, [0, bd + 0.008, 0], L - 2 * bb + 0.02, W - 2 * bb + 0.02)\n  // fork pockets across the width (two tunnels, openings framed in the side beams)\n  const fork = Math.min(2.05, L * 0.34)\n  for (const sx of [-1, 1]) {\n    const x = (sx * fork) / 2\n    boxMM(k, P, [x - 0.2, 0.012, -hz + bb], [x + 0.2, 0.02, hz - bb])\n    for (const dx of [-0.2, 0.2]) boxMM(k, P, [x + dx - 0.006, 0.012, -hz + bb], [x + dx + 0.006, bd, hz - bb])\n    for (const sz of [-1, 1]) {\n      boxMM(k, P, [x - 0.23, 0.0, sz * (hz + 0.006) - 0.006], [x + 0.23, bd + 0.01, sz * (hz + 0.006) + 0.006])\n      boxMM(k, dark, [x - 0.185, 0.03, sz * (hz + 0.013) - 0.002], [x + 0.185, 0.14, sz * (hz + 0.013) + 0.002])\n    }\n  }\n\n  // posts (corners + intermediates ≤ 1.6 m), top rail, mid rail\n  const nx = Math.max(1, Math.ceil(L / 1.6))\n  const nz = Math.max(1, Math.ceil(W / 1.6))\n  const px = (i: number) => -hx + s / 2 + ((L - s) * i) / nx\n  const pz = (j: number) => -hz + s / 2 + ((W - s) * j) / nz\n  const posts: [number, number][] = []\n  for (let i = 0; i <= nx; i++) for (const sz of [-1, 1]) posts.push([px(i), sz * (hz - s / 2)])\n  for (let j = 1; j < nz; j++) for (const sx of [-1, 1]) posts.push([sx * (hx - s / 2), pz(j)])\n  for (const [x, z] of posts) member(k, [x, bd, z], [x, H - s, z], sq, P, [1, 0, 0])\n  const ym = (bd + H) / 2\n  for (const y of [H - s / 2, ym]) {\n    const sec = y === ym ? 'SHS 100x100x6.3' : sq\n    for (const sz of [-1, 1]) member(k, [-hx, y, sz * (hz - s / 2)], [hx, y, sz * (hz - s / 2)], sec, P)\n    for (const sx of [-1, 1]) member(k, [sx * (hx - s / 2), y, -hz + s], [sx * (hx - s / 2), y, hz - s], sec, P)\n  }\n  // kick plates and expanded-metal mesh infill on the inside face of each side\n  const kick = Math.min(0.3, ym - bd - 0.06)\n  const mesh = meshGuardMaterial('#5b6066')\n  const panel = (a: V3, b: V3, y0: number, y1: number, n2: THREE.Vector3) => {\n    const len = Math.hypot(b[0] - a[0], b[2] - a[2])\n    const q = new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 0, 1), n2)\n    const c = new THREE.Vector3((a[0] + b[0]) / 2, (y0 + y1) / 2, (a[2] + b[2]) / 2)\n    const g = new THREE.PlaneGeometry(len, y1 - y0)\n    const uv = g.getAttribute('uv') as THREE.BufferAttribute\n    for (let i = 0; i < uv.count; i++) uv.setXY(i, uv.getX(i) * (len / 0.12), uv.getY(i) * ((y1 - y0) / 0.12))\n    k.add(mesh, g, new THREE.Matrix4().compose(c, q, new THREE.Vector3(1, 1, 1)))\n  }\n  for (const sz of [-1, 1]) {\n    const z = sz * (hz - s / 2)\n    boxMM(k, P, [-hx + s, bd, z - 0.004], [hx - s, bd + kick, z + 0.004])\n    panel([-hx + s, 0, z], [hx - s, 0, z], ym + s / 2, H - s, new THREE.Vector3(0, 0, sz))\n    panel([-hx + s, 0, z], [hx - s, 0, z], bd + kick, ym - s / 2, new THREE.Vector3(0, 0, sz))\n  }\n  for (const sx of [-1, 1]) {\n    const x = sx * (hx - s / 2)\n    boxMM(k, P, [x - 0.004, bd, -hz + s], [x + 0.004, bd + kick, hz - s])\n    panel([x, 0, -hz + s], [x, 0, hz - s], ym + s / 2, H - s, new THREE.Vector3(sx, 0, 0))\n    panel([x, 0, -hz + s], [x, 0, hz - s], bd + kick, ym - s / 2, new THREE.Vector3(sx, 0, 0))\n  }\n  // floor lashing D-rings by each post, tag-line D-rings at mid-length on the outside of each side\n  for (const [x, z] of posts) {\n    const ix = Math.abs(x) > hx - s ? x - Math.sign(x) * (s / 2 + 0.06) : x\n    const iz = Math.abs(z) > hz - s ? z - Math.sign(z) * (s / 2 + 0.06) : z\n    boxMM(k, 'galvanised', [ix - 0.04, bd + 0.008, iz - 0.03], [ix + 0.04, bd + 0.03, iz + 0.03])\n    k.torus('galvanised', 0.035, 0.008, [ix, bd + 0.06, iz], Math.abs(x) > hx - s ? 'x' : 'z', 6, 14)\n  }\n  for (const sz of [-1, 1]) k.torus('galvanised', 0.045, 0.01, [0, H - s - 0.05, sz * (hz + 0.01)], 'z', 6, 16)\n  for (const sx of [-1, 1]) k.torus('galvanised', 0.045, 0.01, [sx * (hx + 0.01), H - s - 0.05, 0], 'x', 6, 16)\n  // drain holes in the floor corners, marking plates\n  for (const sx of [-1, 1]) for (const sz of [-1, 1]) k.disc(dark, 0.03, [sx * (hx - bb - 0.12), bd + 0.0085, sz * (hz - bb - 0.12)], 'y', 12)\n  const plate = textMaterial(`MGW ${swl} t  DNV 2.7-1`, '#f4f4ef', '#111111', 768, 96)\n  k.plane(plate, 0.8, 0.1, [hx - 0.75, bd / 2, hz + 0.004])\n  if (tag) tagPlate(k, tag, [-hx + 0.75, bd / 2, hz + 0.003], 'z', 0.3)\n  k.plane(textMaterial('CARGO BASKET', color, '#151515', 768, 112), 1.2, 0.175, [0, H - s / 2, hz + 0.003])\n\n  if (lifting) {\n    const eyes: V3[] = []\n    for (const sx of [-1, 1]) for (const sz of [-1, 1]) eyes.push(padeyeShackle(k, [sx * (hx - s / 2), H, sz * (hz - s / 2)], 'z', 1.2, P))\n    slingSet(k, eyes, [0, H + Math.hypot(hx, hz) * 1.05, 0], 0.26, 0.013)\n  }\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": "CargoBasket",
    "anchor": "base",
    "standards": [
      "DNV 2.7-1",
      "EN 12079-1",
      "ISO 10855-1"
    ]
  }
}