{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "oily-water-separator",
  "type": "registry:component",
  "title": "Oily-water separator (CPI)",
  "description": "Corrugated plate interceptor in a lined reinforced-concrete or stiffened steel basin. Inlet chamber with sludge draw-off, perforated distribution baffle, 45° corrugated plate packs in stainless frames (one per 60 m³/h), oil layer gathering at a rotatable slotted-pipe skimmer, underflow baffle and adjustable outlet weir into the clean-water chamber. Checker-plate covers with vents and a level transmitter leave the plate-pack bay open; walkway and stair along one wall. Ports: inlet, treated-water outlet and skimmed-oil outlet.",
  "dependencies": [
    "three",
    "@react-three/fiber",
    "@react-three/drei"
  ],
  "registryDependencies": [
    "https://deck-twin-library.demoareeb.workers.dev/r/core.json"
  ],
  "files": [
    {
      "path": "onshore/oily-water-separator.tsx",
      "type": "registry:file",
      "target": "components/deck-twin/onshore/oily-water-separator.tsx",
      "content": "// Corrugated plate interceptor (CPI) oily-water separator: open basin with inlet chamber, 45° plate packs, slotted-pipe oil skimmer, underflow baffle and outlet weir. API 421.\nimport * as THREE from 'three'\nimport type { Kit, MatKey } from '../lib/kit'\nimport { KitMesh, useKit, type GroupProps } from '../lib/mesh'\nimport { checkerPlate, grating, handrail, member, nozzle, pipeRun, tagPlate } from '../lib/parts'\nimport { paint } from '../lib/materials'\nimport { port, type Port } from '../lib/ports'\nimport { pipeOD, type Rating } from '../lib/standards'\nimport { clamp, earthBond, plinth, stair } from './_onshore'\n\nexport interface OilyWaterSeparatorProps {\n  /** design flow, m³/h (sets the number of plate packs) */\n  flow?: number\n  construction?: 'concrete' | 'steel'\n  inletNps?: number\n  oilNps?: number\n  rating?: Rating\n  /** checker-plate covers, with the plate-pack bay left open for inspection */\n  covers?: boolean\n  tag?: string\n}\n\nexport const defaults = { flow: 120, construction: 'concrete' as 'concrete' | 'steel', inletNps: 8, oilNps: 3, rating: 150 as Rating, covers: true, tag: '' }\n\nfunction layout(p: typeof defaults) {\n  const packs = clamp(Math.ceil(p.flow / 60), 1, 6)\n  const conc = p.construction === 'concrete'\n  const t = conc ? 0.3 : 0.01\n  const base = conc ? 0.3 : 0.25\n  const Wi = packs * 1.05 + 0.3\n  const Li = 7.2\n  const Hi = 2.4\n  const top = base + Hi\n  const wl = top - 0.45\n  const X0 = -Li / 2\n  const X1 = Li / 2\n  // chambers along X: inlet | plate packs | skimmer bay | baffle + weir | outlet\n  const xPack0 = X0 + 1.5\n  const xPack1 = xPack0 + 1.9\n  const xSkim = xPack1 + 0.6\n  const xBaffle = xPack1 + 1.3\n  const xWeir = xBaffle + 0.45\n  const inY = top - 0.55\n  const outY = wl - 0.35\n  return { packs, conc, t, base, Wi, Li, Hi, top, wl, X0, X1, xPack0, xPack1, xSkim, xBaffle, xWeir, inY, outY, so: 0.35 }\n}\n\nexport function ports(props: OilyWaterSeparatorProps = {}): Port[] {\n  const p = { ...defaults, ...props }\n  const g = layout(p)\n  return [\n    port('inlet', 'Oily water inlet', [g.X0 - g.t - g.so, g.inY, 0], [-1, 0, 0], p.inletNps, p.rating),\n    port('water-out', 'Treated water outlet', [g.X1 + g.t + g.so, g.outY, 0], [1, 0, 0], p.inletNps, p.rating),\n    port('oil-out', 'Skimmed oil outlet', [g.xSkim, g.wl - 0.25, g.Wi / 2 + g.t + g.so], [0, 0, 1], p.oilNps, p.rating),\n  ]\n}\n\nexport function OilyWaterSeparator(props: OilyWaterSeparatorProps & GroupProps) {\n  const { flow, construction, inletNps, oilNps, rating, covers, tag, ...group } = { ...defaults, ...props }\n  const p = { flow, construction, inletNps, oilNps, rating, covers, tag }\n  const data = useKit((k) => build(k, p, layout(p)), [flow, construction, inletNps, oilNps, rating, covers, tag])\n  return (\n    <group {...group}>\n      <KitMesh data={data} />\n    </group>\n  )\n}\n\nexport default OilyWaterSeparator\n\ntype P = typeof defaults\ntype G = ReturnType<typeof layout>\n\nfunction build(k: Kit, p: P, g: G) {\n  const { t, base, Wi, Li, Hi, top, wl, X0, X1 } = g\n  const W = Wi + 2 * t\n  const L = Li + 2 * t\n  const shell: MatKey = g.conc ? 'concrete' : paint('#6f7f74', { clearcoat: 0.2 })\n  const steel = paint('#5c6a73')\n  const lining = paint('#3c4a4f', { roughness: 0.7, clearcoat: 0, weather: 0.6 })\n  // base and walls (hollow basin); steel tank sits on a skid with external stiffeners\n  if (g.conc) k.box('concrete', [L + 0.3, base, W + 0.3], [0, base / 2, 0])\n  else {\n    plinth(k, 0, 0, L + 0.6, W + 0.6, 0.12)\n    for (const z of [-W / 2 + 0.15, 0, W / 2 - 0.15]) member(k, [-L / 2, 0.12 + 0.06, z], [L / 2, 0.12 + 0.06, z], 'HEB 120', 'structSteelDark')\n    k.box(shell, [L, 0.012, W], [0, base - 0.006, 0])\n  }\n  k.box(lining, [Li, 0.01, Wi], [0, base + 0.005, 0])\n  for (const s of [-1, 1]) {\n    k.box(shell, [L, Hi, t], [0, base + Hi / 2, s * (Wi / 2 + t / 2)])\n    k.box(shell, [t, Hi, Wi], [s * (Li / 2 + t / 2), base + Hi / 2, 0])\n    k.box(lining, [Li, Hi - 0.01, 0.01], [0, base + Hi / 2, s * (Wi / 2 - 0.005)])\n  }\n  if (!g.conc) {\n    for (let x = -L / 2 + 0.4; x < L / 2 - 0.2; x += 0.8) for (const s of [-1, 1]) k.box(shell, [0.012, Hi, 0.1], [x, base + Hi / 2, s * (W / 2 + 0.05)])\n    for (const s of [-1, 1]) k.box(shell, [L + 0.2, 0.012, 0.15], [0, top - 0.006, s * (W / 2 + 0.06)])\n  } else for (const s of [-1, 1]) k.box('concrete', [L, 0.06, 0.06], [0, top + 0.03, s * (Wi / 2 + t / 2)])\n  // inlet distribution baffle (perforated) after the inlet chamber\n  const xb0 = g.xPack0 - 0.35\n  k.box(steel, [0.012, Hi - 0.6, Wi], [xb0, base + 0.3 + (Hi - 0.6) / 2, 0])\n  for (let y = base + 0.5; y < wl - 0.2; y += 0.22)\n    for (let z = -Wi / 2 + 0.15; z < Wi / 2 - 0.1; z += 0.2) k.cyl('pipeBore', 0.035, 0.014, [xb0, y, z], 'x', 10)\n  // plate packs: frames with corrugated plates at 45°, side by side across the width\n  const ph = 1.3\n  const py0 = base + 0.45\n  const plate = paint('#e9e6da', { metalness: 0, roughness: 0.5, clearcoat: 0 })\n  for (let i = 0; i < g.packs; i++) {\n    const zc = -Wi / 2 + 0.15 + 0.525 + i * 1.05\n    const pl = g.xPack1 - g.xPack0\n    for (const sy of [py0, py0 + ph]) for (const sz of [-0.5, 0.5]) k.box('stainless', [pl, 0.04, 0.04], [(g.xPack0 + g.xPack1) / 2, sy, zc + sz])\n    for (const sx of [g.xPack0, g.xPack1]) for (const sz of [-0.5, 0.5]) k.box('stainless', [0.04, ph, 0.04], [sx, py0 + ph / 2, zc + sz])\n    const n = 26\n    const q = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 0, 1), Math.PI / 4)\n    const len = ph * Math.SQRT2 * 0.98\n    for (let j = 0; j < n; j++) {\n      const x = g.xPack0 + ph / 2 + ((pl - ph) * j) / (n - 1)\n      k.box(plate, [len, 0.004, 0.98], [x, py0 + ph / 2, zc], q)\n      k.box(plate, [len, 0.012, 0.01], [x, py0 + ph / 2 + 0.006, zc - 0.25], q)\n      k.box(plate, [len, 0.012, 0.01], [x, py0 + ph / 2 + 0.006, zc + 0.25], q)\n    }\n    // pack support legs and lifting eyes\n    for (const sx of [g.xPack0 + 0.1, g.xPack1 - 0.1]) for (const sz of [-0.45, 0.45]) k.box('stainless', [0.06, py0 - base, 0.06], [sx, (py0 + base) / 2, zc + sz])\n    for (const sx of [g.xPack0 + 0.3, g.xPack1 - 0.3]) k.torus('stainless', 0.05, 0.01, [sx, py0 + ph + 0.07, zc], 'z', 6, 14)\n  }\n  // water surface and oil layer gathering at the skimmer\n  k.box('liquidWater', [Li - 0.02, 0.02, Wi - 0.02], [0, wl - 0.01, 0])\n  k.box('liquidOil', [g.xBaffle - g.xPack1 - 0.05, 0.02, Wi - 0.03], [(g.xBaffle + g.xPack1) / 2, wl + 0.008, 0])\n  // slotted-pipe skimmer across the width, turned by a handwheel on the wall top\n  const sNps = Math.max(p.oilNps + 1, 4)\n  const sod = pipeOD(sNps)\n  k.pipe('stainless', [g.xSkim, wl - 0.02, -Wi / 2 + 0.02], [g.xSkim, wl - 0.02, Wi / 2 + t + 0.02], sod, 0.006)\n  k.disc('stainless', sod / 2, [g.xSkim, wl - 0.02, -Wi / 2 + 0.02], '-z', 24)\n  k.box('rubberBlack', [0.012, 0.05, Wi - 0.3], [g.xSkim, wl - 0.02 + sod / 2 - 0.01, 0])\n  const zo = Wi / 2 + t\n  pipeRun(k, [[g.xSkim, wl - 0.02, zo + 0.02], [g.xSkim, wl - 0.02, zo + 0.12], [g.xSkim, wl - 0.25, zo + 0.12], [g.xSkim, wl - 0.25, zo + 0.25]], p.oilNps, { mat: 'stainless' })\n  k.cyl('stainless', sod / 2 + 0.01, 0.02, [g.xSkim, wl - 0.02, zo + 0.02], 'z', 24)\n  nozzle(k, { base: [g.xSkim, wl - 0.25, zo + 0.25], dir: [0, 0, 1], nps: p.oilNps, rating: p.rating, standout: g.so - 0.25, mat: 'stainless' })\n  k.rod('stainless', [g.xSkim, wl - 0.02, -Wi / 2 + 0.02], [g.xSkim, top + 0.45, -Wi / 2 + 0.02], 0.02, 8)\n  k.handwheel('handwheel', 0.3, [g.xSkim, top + 0.45, -Wi / 2 + 0.02], 'y', 4)\n  // underflow baffle and adjustable outlet weir into the clean-water chamber\n  k.box(steel, [0.012, top - (base + 0.5), Wi], [g.xBaffle, (top + base + 0.5) / 2, 0])\n  k.box(g.conc ? 'concrete' : shell, [0.2, wl - 0.05 - base, Wi], [g.xWeir, base + (wl - 0.05 - base) / 2, 0])\n  k.box('stainless', [0.008, 0.25, Wi], [g.xWeir - 0.104, wl - 0.1, 0])\n  for (let z = -Wi / 2 + 0.2; z < Wi / 2; z += 0.4) k.hex('nut', 0.025, 0.012, [g.xWeir - 0.11, wl - 0.15, z], 'x')\n  // inlet and outlet nozzles through the end walls\n  nozzle(k, { base: [X0 + 0.05, g.inY, 0], dir: [-1, 0, 0], nps: p.inletNps, rating: p.rating, standout: t + g.so - 0.05, mat: 'pipePaint' })\n  nozzle(k, { base: [X1 - 0.05, g.outY, 0], dir: [1, 0, 0], nps: p.inletNps, rating: p.rating, standout: t + g.so - 0.05, mat: 'pipePaint' })\n  // inlet chamber sludge draw-off and stilling hood\n  pipeRun(k, [[X0 + 0.5, base + 0.15, -Wi / 2 + 0.3], [X0 + 0.5, top + 0.4, -Wi / 2 + 0.3]], 3)\n  k.cyl('valveBody', 0.07, 0.18, [X0 + 0.5, top + 0.5, -Wi / 2 + 0.3], 'y', 14)\n  k.handwheel('handwheel', 0.18, [X0 + 0.5, top + 0.62, -Wi / 2 + 0.3], 'y', 4)\n  // covers: checker plate on steel bearers, plate-pack bay left open; else perimeter handrail\n  if (p.covers) {\n    const segs: [number, number][] = [[X0, g.xPack0 - 0.2], [g.xPack1 + 0.2, X1]]\n    for (const [a, b] of segs) {\n      for (let x = a + 0.3; x < b - 0.1; x += 1.2) member(k, [x, top + 0.06, -Wi / 2 - t / 2], [x, top + 0.06, Wi / 2 + t / 2], 'UPN 120', 'galvanised', [0, 1, 0])\n      checkerPlate(k, [(a + b) / 2, top + 0.13, 0], b - a, Wi + t)\n    }\n    for (const x of [X0 + 0.9, X1 - 0.6]) {\n      pipeRun(k, [[x, top + 0.13, Wi / 4], [x, top + 0.7, Wi / 4], [x + 0.2, top + 0.7, Wi / 4], [x + 0.2, top + 0.5, Wi / 4]], 3, { mat: 'galvanised' })\n    }\n    k.cyl(paint('#3a6ea5'), 0.08, 0.2, [X1 - 0.6, top + 0.24, -Wi / 4], 'y', 18)\n    k.cyl(paint('#3a6ea5'), 0.12, 0.05, [X1 - 0.6, top + 0.37, -Wi / 4], 'y', 18)\n    handrail(k, [[g.xPack0 - 0.2, top + 0.13, Wi / 2 + t / 2], [g.xPack1 + 0.2, top + 0.13, Wi / 2 + t / 2]])\n  } else handrail(k, [[X0, top + 0.06, Wi / 2 + t / 2], [X1, top + 0.06, Wi / 2 + t / 2]])\n  // walkway on the -Z wall, stair down at the inlet end\n  const zw = -W / 2 - 0.45\n  for (let x = X0; x <= X1 + 0.01; x += Li / 4) member(k, [x, top - 0.1, -W / 2], [x, top - 0.1, zw - 0.4], 'UPN 120', 'galvanised', [0, 1, 0])\n  grating(k, [0, top, zw], Li, 0.9)\n  handrail(k, [[X0 + 1.0, top, zw - 0.45], [X1, top, zw - 0.45], [X1, top, -W / 2]])\n  stair(k, [X0 - 0.01 - stairRun(top), 0, zw - 0.0], 'x', top, 0.8, 'left')\n  if (g.conc) for (const x of [X0 + 0.2, X1 - 0.2]) member(k, [x, 0, zw - 0.35], [x, top - 0.18, zw - 0.35], 'SHS 100x100x6', 'galvanised')\n  // tag, earth boss on the steel work\n  if (p.tag) tagPlate(k, p.tag, [0, top - 0.5, W / 2 + 0.002], 'z', 0.35)\n  earthBond(k, [X1 + t + 0.002, 0.45, -W / 2 + 0.4], [1, 0, 0], 0, 0.35)\n}\n\nfunction stairRun(rise: number) {\n  const n = Math.max(1, Math.round(rise / 0.18))\n  return ((n - 1) * rise) / n / Math.tan((38 * Math.PI) / 180)\n}\n"
    },
    {
      "path": "onshore/_onshore.ts",
      "type": "registry:file",
      "target": "components/deck-twin/onshore/_onshore.ts",
      "content": "// Shared onshore parts: plinths, anchor bolts, earth bonds, ISO 14122 stairs, shedded insulators, lattice steel and swivel joints.\nimport * as THREE from 'three'\nimport { axisVec, type Axis, type Kit, type MatKey, type V3 } from '../lib/kit'\nimport { paint } from '../lib/materials'\nimport { grating, handrail, member } from '../lib/parts'\nimport { stairFlight } from '../lib/standards'\n\nexport const add = (a: V3, b: V3, s = 1): V3 => [a[0] + b[0] * s, a[1] + b[1] * s, a[2] + b[2] * s]\nexport const deg = (d: number) => (d * Math.PI) / 180\nexport const clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v))\n\nexport const porcelain = () => paint('#6e3420', { metalness: 0.05, roughness: 0.12, clearcoat: 0.9, clearcoatRoughness: 0.1, weather: 0 })\nexport const silicone = () => paint('#8b9399', { metalness: 0, roughness: 0.55, clearcoat: 0.2, clearcoatRoughness: 0.5, weather: 0.3 })\nexport const earthLead = () => paint('#5c9e33', { metalness: 0, roughness: 0.6, clearcoat: 0, weather: 0 })\nexport const lightGrey = () => paint('#cfd2cf', { metalness: 0.2, roughness: 0.5, clearcoat: 0.25, weather: 1 })\n\n/** Concrete plinth from y0 up to y0 + h with a small arris, centred on (cx, cz). */\nexport function plinth(k: Kit, cx: number, cz: number, sx: number, sz: number, h: number, y0 = 0) {\n  const c = Math.min(0.025, h * 0.2)\n  k.box('concrete', [sx, h - c, sz], [cx, y0 + (h - c) / 2, cz])\n  k.box('concrete', [sx - 2 * c, c, sz - 2 * c], [cx, y0 + h - c / 2, cz])\n}\n\n/** Cast-in anchor bolt standing on a surface at p: washer, double nut, projecting thread. */\nexport function anchorBolt(k: Kit, p: V3, dia = 0.024) {\n  k.cyl('galvanised', dia * 1.1, 0.005, [p[0], p[1] + 0.0025, p[2]], 'y', 12)\n  k.hex('nut', dia * 1.85, dia * 0.9, [p[0], p[1] + 0.005 + dia * 0.45, p[2]])\n  k.hex('nut', dia * 1.85, dia * 0.9, [p[0], p[1] + 0.005 + dia * 1.4, p[2]])\n  k.cyl('boltXylan', dia / 2, dia * 2.6, [p[0], p[1] + dia * 1.3, p[2]], 'y', 8)\n}\n\n/** Steel base plate with its top at y, on a grout bed, anchored near each corner. */\nexport function basePlate(k: Kit, cx: number, y: number, cz: number, sx: number, sz: number, t = 0.025, dia = 0.024, mat: MatKey = 'galvanised') {\n  k.box(mat, [sx, t, sz], [cx, y - t / 2, cz])\n  const ix = sx / 2 - dia * 2.2\n  const iz = sz / 2 - dia * 2.2\n  for (const a of [-1, 1]) for (const b of [-1, 1]) anchorBolt(k, [cx + a * ix, y, cz + b * iz], dia)\n}\n\n/** Earth boss with a bolted lug and a green/yellow bonding lead down to an inspection pit at grade. */\nexport function earthBond(k: Kit, pos: V3, out: V3, ground = 0, pitOffset = 0.3) {\n  const o = new THREE.Vector3(...out).normalize().toArray() as V3\n  k.cyl('brass', 0.017, 0.03, add(pos, o, 0.015), o, 10)\n  k.box('copper', [0.03, 0.05, 0.004], add(add(pos, o, 0.032), [0, -0.012, 0]), o)\n  k.hex('nut', 0.022, 0.012, add(pos, o, 0.04), o)\n  const lug = add(add(pos, o, 0.035), [0, -0.035, 0])\n  const pit: V3 = [pos[0] + o[0] * pitOffset, ground, pos[2] + o[2] * pitOffset]\n  if (pos[1] - ground > 0.12) {\n    k.spline(earthLead(), [lug, add(lug, [0, -0.08, 0]), add([pit[0], ground + 0.25, pit[2]], o, -pitOffset * 0.3), [pit[0], ground + 0.1, pit[2]], [pit[0], ground + 0.03, pit[2]]], 0.0065, 6, 24)\n    k.cyl('concrete', 0.14, 0.05, [pit[0], ground + 0.025, pit[2]], 'y', 16)\n    k.cyl('castIron', 0.1, 0.008, [pit[0], ground + 0.054, pit[2]], 'y', 16)\n  }\n}\n\n/** ISO 14122-3 straight stair: first riser at `foot`, climbing along `dir` by `rise`. Channel stringers, grating treads, handrails. Returns the horizontal run. */\nexport function stair(k: Kit, foot: V3, dir: Axis, rise: number, width = 0.9, rails: 'both' | 'left' | 'right' | 'none' = 'both') {\n  const f = stairFlight(rise)\n  const n = f.steps\n  const g = f.going\n  const q = new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(1, 0, 0), axisVec(dir).setY(0).normalize())\n  const w = width / 2\n  const slope = f.riser / g\n  k.with(new THREE.Matrix4().compose(new THREE.Vector3(...foot), q, new THREE.Vector3(1, 1, 1)), () => {\n    const sd = 0.18\n    const yAt = (x: number) => f.riser + x * slope - 0.07\n    const x0 = (sd * 0.45 + 0.07 - f.riser) / slope\n    const run = (n - 1) * g\n    for (const s of [-1, 1]) {\n      const z = s * (w + 0.04)\n      member(k, [x0, yAt(x0), z], [run, yAt(run), z], 'UPN 180', 'galvanised', [-slope, 1, 0])\n      k.box('galvanised', [0.22, 0.015, 0.16], [x0 + 0.06, 0.0075, z])\n    }\n    for (let i = 1; i < n; i++) {\n      const y = i * f.riser\n      grating(k, [(i - 1) * g + g / 2 + 0.0125, y, 0], g + 0.025, width)\n      k.box('safetyYellow', [0.03, 0.032, width], [(i - 1) * g + 0.015, y - 0.016, 0])\n    }\n    const pts = (z: number): V3[] => [[0, f.riser * 0.5, z], [run, rise, z]]\n    if (rails === 'both' || rails === 'left') handrail(k, pts(w + 0.04), 'safetyYellow')\n    if (rails === 'both' || rails === 'right') handrail(k, pts(-w - 0.04), 'safetyYellow')\n  })\n  return (n - 1) * g\n}\n\n/** Shedded post insulator from `base` along `axis` for L: galvanised end caps, alternating sheds of radius ~2.2 r. */\nexport function insulator(k: Kit, base: V3, L: number, r: number, mat: MatKey, axis: Axis = 'y') {\n  const v = axisVec(axis).toArray() as V3\n  const cap = Math.min(0.08, L * 0.08)\n  const prof: [number, number][] = [[0, cap], [r, cap]]\n  const body = L - 2 * cap\n  const n = Math.max(3, Math.round(body / Math.max(0.045, r * 0.75)))\n  const pitch = body / n\n  let y = cap\n  for (let i = 0; i < n; i++) {\n    const big = i % 2 === 0 ? 2.3 : 1.85\n    prof.push([r * 1.05, y + pitch * 0.15], [r * big, y + pitch * 0.42], [r * (big - 0.1), y + pitch * 0.55], [r, y + pitch * 0.62])\n    y += pitch\n    prof.push([r, y])\n  }\n  prof.push([0, L - cap])\n  k.lathe(mat, prof, base, v, 20)\n  for (const t of [cap / 2, L - cap / 2]) k.cyl('galvanised', r * 1.25, cap, add(base, v, t), v, 18)\n  for (const t of [0.006, L - 0.006]) k.cyl('galvanised', r * 1.9, 0.012, add(base, v, t), v, 18)\n}\n\n/** Square lattice column of four angle legs with zig-zag bracing on every face, (cx, cz) centre, from y0 to y1. */\nexport function latticeColumn(k: Kit, cx: number, cz: number, y0: number, y1: number, w: number, leg = 'L100x100x10', brace = 'L50x50x5', mat: MatKey = 'galvanised') {\n  const h = w / 2\n  const c: [number, number][] = [[-h, -h], [h, -h], [h, h], [-h, h]]\n  for (const [x, z] of c) member(k, [cx + x, y0, cz + z], [cx + x, y1, cz + z], leg, mat, [-x, 0, -z])\n  const H = y1 - y0\n  const nb = Math.max(1, Math.round(H / w))\n  const dy = H / nb\n  for (let f = 0; f < 4; f++) {\n    const [ax, az] = c[f]\n    const [bx, bz] = c[(f + 1) % 4]\n    for (let i = 0; i < nb; i++) {\n      const ya = y0 + i * dy\n      const flip = (i + f) % 2 === 0\n      const p0: V3 = [cx + (flip ? ax : bx), ya, cz + (flip ? az : bz)]\n      const p1: V3 = [cx + (flip ? bx : ax), ya + dy, cz + (flip ? bz : az)]\n      member(k, p0, p1, brace, mat, [ax + bx, 0, az + bz])\n    }\n    member(k, [cx + ax, y1 - 0.03, cz + az], [cx + bx, y1 - 0.03, cz + bz], brace, mat)\n  }\n}\n\n/** Swivel joint between a and b: two ball-race housings, seal ring, grease nipples and plug bolts. od = pipe OD. */\nexport function swivel(k: Kit, a: V3, b: V3, od: number, mat: MatKey = 'flangeSteel') {\n  const A = new THREE.Vector3(...a)\n  const d = new THREE.Vector3(...b).sub(A)\n  const L = d.length()\n  d.normalize()\n  const v = d.toArray() as V3\n  const at = (t: number) => A.clone().addScaledVector(d, t).toArray() as V3\n  const R = od * 0.82\n  const ri = od * 0.44\n  ring(k, mat, ri, od * 0.56, L, at(L / 2), v)\n  k.cyl('pipeBore', ri, L, at(L / 2), v, 32, undefined, true)\n  ring(k, mat, od * 0.55, R, L * 0.36, at(L * 0.3), v)\n  ring(k, 'machined', od * 0.55, R * 0.96, L * 0.04, at(L * 0.5), v)\n  ring(k, mat, od * 0.55, R * 0.92, L * 0.3, at(L * 0.69), v)\n  for (const t of [0.12, 0.88]) ring(k, mat, od * 0.55, od * 0.7, L * 0.06, at(L * t), v)\n  const [u, w] = perpOf(d)\n  for (let i = 0; i < 6; i++) {\n    const ang = (i / 6) * Math.PI * 2\n    const r = new THREE.Vector3().addScaledVector(u, Math.cos(ang) * R).addScaledVector(w, Math.sin(ang) * R)\n    const p = new THREE.Vector3(...at(L * 0.3)).add(r)\n    k.hex('nut', Math.max(0.018, od * 0.06), 0.012, p.toArray() as V3, r.clone().normalize().toArray() as V3)\n  }\n  const gp = new THREE.Vector3(...at(L * 0.69)).addScaledVector(u, R * 0.92)\n  k.cyl('brass', Math.max(0.006, od * 0.02), 0.03, gp.clone().addScaledVector(u, 0.012).toArray() as V3, u.toArray() as V3, 8)\n}\n\nfunction perpOf(d: THREE.Vector3): [THREE.Vector3, THREE.Vector3] {\n  const ref = Math.abs(d.y) > 0.9 ? new THREE.Vector3(1, 0, 0) : new THREE.Vector3(0, 1, 0)\n  const u = new THREE.Vector3().crossVectors(d, ref).normalize()\n  return [u, new THREE.Vector3().crossVectors(d, u).normalize()]\n}\n\n/** Annular ring (hollow short cylinder) centred on pos along axis, open through the middle. */\nexport function ring(k: Kit, mat: MatKey, ri: number, ro: number, h: number, pos: V3, axis: Axis = 'y', seg = 36) {\n  const v = axisVec(axis)\n  const base = new THREE.Vector3(...pos).addScaledVector(v, -h / 2).toArray() as V3\n  k.lathe(mat, [[ro, 0], [ro, h], [ri, h], [ri, 0], [ro, 0]], base, v.toArray() as V3, seg)\n}\n\n/** Hydraulic cylinder from a (barrel end clevis) to b (rod eye). */\nexport function hydraulicCylinder(k: Kit, a: V3, b: V3, bore: number, mat: MatKey = 'actuatorBlue') {\n  const A = new THREE.Vector3(...a)\n  const B = new THREE.Vector3(...b)\n  const L = A.distanceTo(B)\n  if (L < 1e-3) return\n  const d = B.clone().sub(A).normalize()\n  const bl = Math.min(L * 0.62, L - 0.1)\n  const p = (t: number) => A.clone().addScaledVector(d, t).toArray() as V3\n  k.rod(mat, p(0.04), p(bl), bore / 2, 16)\n  k.rod(mat, p(0.04), p(0.1), bore * 0.62, 16)\n  k.rod(mat, p(bl - 0.06), p(bl), bore * 0.62, 16)\n  k.rod('stainless', p(bl), p(L - 0.04), bore * 0.28, 12)\n  const side = Math.abs(d.x) > 0.9 ? 'z' : 'x'\n  for (const t of [0.02, L - 0.02]) k.cyl('flangeSteel', bore * 0.45, bore * 0.6, p(t), side, 12)\n  k.rod('tubing', add(p(0.12), [0, bore * 0.6, 0]), add(p(bl - 0.08), [0, bore * 0.6, 0]), 0.006, 6)\n}\n\n/**\n * Trapezoidal profiled sheet (wall or roof cladding): profile runs along `u` for `length`, ribs stand out along `n`,\n * extruded `height` along `w`; `origin` is the (0, 0, 0) corner. Typical 35 mm rib at 200 mm pitch.\n */\nexport function profiledSheet(k: Kit, mat: MatKey, length: number, height: number, origin: V3, u: V3, n: V3, w: V3, pitch = 0.2, depth = 0.035) {\n  const top = pitch * 0.2\n  const slope = pitch * 0.15\n  const pts: [number, number][] = [[0, 0]]\n  const ribs = Math.max(1, Math.round(length / pitch))\n  const sc = length / (ribs * pitch)\n  for (let i = 0; i < ribs; i++) {\n    const a = i * pitch * sc\n    const m = a + (pitch * sc) / 2\n    pts.push([m - (top / 2 + slope) * sc, 0], [m - (top / 2) * sc, depth], [m + (top / 2) * sc, depth], [m + (top / 2 + slope) * sc, 0])\n  }\n  pts.push([length, 0])\n  const sh = new THREE.Shape()\n  pts.forEach(([x, y], i) => (i ? sh.lineTo(x, y) : sh.moveTo(x, y)))\n  for (let i = pts.length - 1; i >= 0; i--) sh.lineTo(pts[i][0], pts[i][1] - 0.0015)\n  sh.closePath()\n  const m = new THREE.Matrix4().makeBasis(new THREE.Vector3(...u), new THREE.Vector3(...n), new THREE.Vector3(...w)).setPosition(...origin)\n  k.extrude(mat, sh, height, m, 1)\n}\n"
    }
  ],
  "categories": [
    "onshore"
  ],
  "meta": {
    "export": "OilyWaterSeparator",
    "anchor": "base",
    "standards": [
      "API 421",
      "API 650 (steel variant)",
      "ASME B16.5",
      "ISO 14122"
    ]
  }
}