{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tote-tank",
  "type": "registry:component",
  "title": "Offshore chemical tote tank",
  "description": "Portable offshore chemical tank: a stainless tank, sized from its capacity, in a painted SHS lifting frame with an RHS base, two fork-pocket tunnels, tank bearers and side and rear diagonals. The tank has a clamped manway, a vent with flame arrestor, a fill cap and a sight-glass level gauge. The bottom outlet is a 2\" ball valve with a lever, ending in a Class 150 weld-neck flange inside the frame (port outlet, utility). DNV data plate, tag plate, padeyes, shackles and a 4-leg sling set.",
  "dependencies": [
    "three",
    "@react-three/fiber",
    "@react-three/drei"
  ],
  "registryDependencies": [
    "https://deck-twin-library.demoareeb.workers.dev/r/core.json"
  ],
  "files": [
    {
      "path": "lifting/tote-tank.tsx",
      "type": "registry:file",
      "target": "components/deck-twin/lifting/tote-tank.tsx",
      "content": "// Offshore chemical tote tank (portable offshore tank, DNV 2.7-1 / EN 12079-1): stainless tank in a lifting frame with fork pockets, manway, vent, level gauge, ball-valve outlet and 4-leg sling set.\nimport { Kit, type MatKey, type V3 } from '../lib/kit'\nimport { KitMesh, useKit, type GroupProps } from '../lib/mesh'\nimport { paint } from '../lib/materials'\nimport { flange, member, tagPlate } from '../lib/parts'\nimport { port, type Port } from '../lib/ports'\nimport { SECTIONS, pipeOD, pipeWall } from '../lib/standards'\nimport { textMaterial } from '../lib/textures'\nimport { boxMM, padeyeShackle, slingSet } from './_rigging'\n\nexport interface ToteTankProps {\n  /** tank capacity, litres */\n  volume?: number\n  /** frame colour */\n  color?: string\n  tag?: string\n  liftingSet?: boolean\n}\n\nexport const defaults = {\n  volume: 1500,\n  color: '#2d5fa8',\n  tag: 'TT-101',\n  liftingSet: true,\n}\n\nconst NPS = 2\nconst RATING = 150\n\nfunction dims(volume: number) {\n  const V = Math.min(Math.max(volume, 400), 6000) / 1000\n  const t = Math.cbrt(V / 1.15)\n  const Lt = t\n  const Ht = 1.15 * t\n  const s = SECTIONS['SHS 100x100x6.3'].b\n  const base = SECTIONS['RHS 200x100x8'].b\n  const half = Lt / 2 + s + 0.06\n  const yT0 = base + 0.06\n  return { Lt, Ht, s, base, half, yT0, H: yT0 + Ht + 0.25, outlet: { y: yT0 + 0.12, z0: Lt / 2, zf: half - 0.03 } }\n}\n\nexport function ports(p: ToteTankProps = {}): Port[] {\n  const d = dims(p.volume ?? defaults.volume)\n  return [port('outlet', 'Bottom outlet', [0, d.outlet.y, d.outlet.zf], [0, 0, 1], NPS, RATING, 'utility')]\n}\n\nexport function ToteTank({ volume = defaults.volume, color = defaults.color, tag = defaults.tag, liftingSet = defaults.liftingSet, ...group }: ToteTankProps & GroupProps) {\n  const data = useKit((k) => build(k, volume, color, tag, liftingSet), [volume, color, tag, liftingSet])\n  return (\n    <group {...group}>\n      <KitMesh data={data} />\n    </group>\n  )\n}\n\nexport default ToteTank\n\nfunction build(k: Kit, volume: number, color: string, tag: string, lifting: boolean) {\n  const d = dims(volume)\n  const P = paint(color, { weather: 1 })\n  const ss: MatKey = 'stainless'\n  const { half, s, H, yT0, Lt, Ht } = d\n  const sq = 'SHS 100x100x6.3'\n  const e = half - s / 2\n\n  // base frame (RHS laid flat) with two fork-pocket tunnels front to back\n  const bb = d.base\n  for (const sx of [-1, 1]) member(k, [sx * (half - bb / 2), 0.05, -half], [sx * (half - bb / 2), 0.05, half], 'RHS 200x100x8', P, [1, 0, 0])\n  for (const sz of [-1, 1]) member(k, [-half + bb, 0.05, sz * (half - 0.05)], [half - bb, 0.05, sz * (half - 0.05)], 'RHS 200x100x8', P, [0, 0, 1])\n  const fx = Math.min(0.3, half * 0.38)\n  for (const sx of [-1, 1]) {\n    const x = sx * fx\n    boxMM(k, P, [x - 0.11, 0.0, -half + 0.1], [x + 0.11, 0.008, half - 0.1])\n    boxMM(k, P, [x - 0.11, 0.092, -half + 0.1], [x + 0.11, 0.1, half - 0.1])\n    for (const dx of [-0.11, 0.11]) boxMM(k, P, [x + dx - 0.004, 0.008, -half + 0.1], [x + dx + 0.004, 0.092, half - 0.1])\n    for (const sz of [-1, 1]) boxMM(k, 'rubberBlack', [x - 0.105, 0.01, sz * (half + 0.001) - 0.001], [x + 0.105, 0.09, sz * (half + 0.001) + 0.001])\n  }\n  boxMM(k, P, [-half + bb, 0.1, -half + 0.1], [half - bb, 0.108, half - 0.1])\n  // tank cradle bearers\n  for (const sz of [-0.3, 0.3]) boxMM(k, P, [-half + bb, 0.108, sz * Lt - 0.04], [half - bb, yT0, sz * Lt + 0.04])\n  // corner posts, top frame, side diagonals\n  for (const sx of [-1, 1]) for (const sz of [-1, 1]) member(k, [sx * e, 0.1, sz * e], [sx * e, H - s, sz * e], sq, P, [1, 0, 0])\n  for (const sz of [-1, 1]) member(k, [-half, H - s / 2, sz * e], [half, H - s / 2, sz * e], sq, P)\n  for (const sx of [-1, 1]) member(k, [sx * e, H - s / 2, -e + s / 2], [sx * e, H - s / 2, e - s / 2], sq, P)\n  for (const sx of [-1, 1]) member(k, [sx * e, 0.15, -e + s / 2], [sx * e, H - s, e - s / 2], 'SHS 100x100x6.3', P)\n  member(k, [-e + s / 2, 0.15, -e], [e - s / 2, H - s, -e], 'SHS 100x100x6.3', P)\n\n  // stainless tank with sloped floor to the outlet, manway, vent, fill, level gauge\n  k.rbox(paint('#c8cccf', { metalness: 0.55, roughness: 0.38, clearcoat: 0, weather: 0.3 }), [Lt, Ht, Lt], 0.06, [0, yT0 + Ht / 2, 0])\n  const yTop = yT0 + Ht\n  k.cyl(ss, 0.2, 0.08, [0, yTop + 0.04, 0], 'y', 32)\n  k.cyl(ss, 0.215, 0.025, [0, yTop + 0.09, 0], 'y', 32)\n  k.torus('galvanised', 0.215, 0.012, [0, yTop + 0.08, 0], 'y', 6, 32)\n  k.cyl('rubberBlack', 0.03, 0.05, [0.2, yTop + 0.09, 0], 'x', 10)\n  k.cyl(ss, 0.03, 0.12, [-Lt * 0.3, yTop + 0.06, -Lt * 0.3], 'y', 12)\n  k.cyl('brass', 0.05, 0.06, [-Lt * 0.3, yTop + 0.15, -Lt * 0.3], 'y', 14)\n  k.cyl(ss, 0.05, 0.06, [Lt * 0.3, yTop + 0.03, -Lt * 0.3], 'y', 16)\n  k.cyl('actuatorRed', 0.055, 0.03, [Lt * 0.3, yTop + 0.075, -Lt * 0.3], 'y', 16)\n  const gx = Lt / 2 - 0.12\n  for (const y of [yT0 + 0.15, yTop - 0.12]) k.rod(ss, [gx, y, Lt / 2], [gx, y, Lt / 2 + 0.06], 0.012, 8)\n  k.cyl('glass', 0.018, yTop - yT0 - 0.27, [gx, (yTop + yT0 + 0.03) / 2, Lt / 2 + 0.06], 'y', 12)\n  k.cyl(ss, 0.006, yTop - yT0 - 0.3, [gx + 0.03, (yTop + yT0 + 0.03) / 2, Lt / 2 + 0.06], 'y', 6)\n  k.plane(textMaterial(`${Math.round(volume)} L`, '#f4f4ef', '#111111', 256, 96), 0.24, 0.09, [-Lt / 4, yTop - 0.15, Lt / 2 + 0.001])\n\n  // bottom outlet: nozzle, 2\" ball valve with lever, weld-neck flange (port face)\n  const o = d.outlet\n  const L = flange(k, NPS, RATING, [0, o.y, o.zf], [0, 0, 1], true)\n  const od = pipeOD(NPS)\n  k.pipe(ss, [0, o.y, o.z0 - 0.01], [0, o.y, o.zf - L], od, pipeWall(NPS, '40S'))\n  const zv = (o.z0 + o.zf - L) / 2\n  k.cyl(ss, od * 0.95, 0.11, [0, o.y, zv], 'z', 20)\n  k.sphere(ss, od * 1.05, [0, o.y, zv], undefined, 18)\n  k.cyl(ss, 0.012, 0.07, [0, o.y + od + 0.02, zv], 'y', 8)\n  k.box('actuatorYellow', [0.2, 0.012, 0.03], [0.09, o.y + od + 0.06, zv])\n  k.box('rubberBlack', [0.06, 0.03, 0.04], [0.19, o.y + od + 0.06, zv])\n\n  // DNV data plate, tag plate, product label\n  k.box('nameplate', [0.24, 0.16, 0.003], [-half * 0.35, 0.05, half + 0.002])\n  k.plane(textMaterial('DNV 2.7-1', '#e9eae6', '#222222', 256, 64), 0.2, 0.05, [-half * 0.35, 0.09, half + 0.0036])\n  if (tag) {\n    tagPlate(k, tag, [half * 0.4, 0.05, half + 0.002], 'z', 0.24)\n    k.plane(textMaterial(tag, color, '#ffffff', 512, 128), 0.5, 0.125, [0, H - s / 2, half + 0.002])\n  }\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 * e, H, sz * e], 'z', 1, P))\n    slingSet(k, eyes, [0, H + Math.SQRT2 * e * 1.05, 0], 0.22, 0.011)\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": "ToteTank",
    "anchor": "base",
    "standards": [
      "DNV 2.7-1",
      "EN 12079-1",
      "ASME B16.5"
    ]
  }
}