@adatechnology/game-fluids 0.6.6 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/data/liquids.json","../src/liquids.ts","../src/math.ts","../src/landing.ts","../src/locale.ts","../src/shapes.ts","../src/stains.ts","../src/surface-pose.ts","../src/world.ts","../src/data/item-uses.json","../src/item-use.ts","../src/film/deposit.ts","../src/film/drops.ts","../src/film/simulate.ts","../src/film/sources.ts","../src/film/film.ts","../src/film/random.ts","../src/film/noise.ts","../src/film/layout.ts","../src/film/surface-layout.ts","../src/data/film-profiles.json","../src/film/profiles.ts"],"sourcesContent":["export { createFluids } from './world'\nexport { LIQUIDS } from './liquids'\nexport { ITEM_USES, createItemUse } from './item-use'\nexport type { HandTransform } from './item-use'\nexport { describeEvent, locales, resolveStrings } from './locale'\nexport type { FluidLocale, FluidStrings } from './locale'\nexport { ballistic, sampleStream } from './landing'\nexport { SAMPLES as STAIN_SAMPLES, stainDirection } from './stains'\nexport * from './film/index'\nexport type {\n ContainerSpec,\n ContainerState,\n FluidEvent,\n FluidOptions,\n FluidWorld,\n ItemUseDef,\n ItemUsePlayer,\n LiquidDef,\n LiquidId,\n Quat,\n SplashOptions,\n StainState,\n StainTint,\n StreamCause,\n StreamState,\n SurfacePose,\n SurfaceSpec,\n TapSpec,\n TapState,\n Vec3,\n} from './types'\n","[\n {\n \"id\": \"water\",\n \"color\": 11064558,\n \"opacity\": 0.35,\n \"stainColor\": 7309206,\n \"viscosity\": 1,\n \"density\": 1000,\n \"dryTime\": 180,\n \"gloss\": 0.9,\n \"drink\": {\n \"thirst\": 100,\n \"effects\": []\n },\n \"tags\": [\n \"drink\",\n \"clear\"\n ]\n },\n {\n \"id\": \"coffee\",\n \"color\": 3875604,\n \"opacity\": 0.95,\n \"stainColor\": 2824202,\n \"viscosity\": 1.5,\n \"density\": 1005,\n \"dryTime\": 900,\n \"gloss\": 0.8,\n \"leavesMark\": true,\n \"steamC\": 60,\n \"drink\": {\n \"thirst\": 80,\n \"effects\": [\n \"caffeine\"\n ]\n },\n \"tags\": [\n \"drink\",\n \"hot\"\n ]\n },\n {\n \"id\": \"tea\",\n \"color\": 9063188,\n \"opacity\": 0.8,\n \"stainColor\": 6961682,\n \"viscosity\": 1.4,\n \"density\": 1005,\n \"dryTime\": 800,\n \"gloss\": 0.8,\n \"leavesMark\": true,\n \"steamC\": 60,\n \"drink\": {\n \"thirst\": 90,\n \"effects\": []\n },\n \"tags\": [\n \"drink\",\n \"hot\"\n ]\n },\n {\n \"id\": \"milk\",\n \"color\": 16052712,\n \"opacity\": 0.98,\n \"stainColor\": 14473160,\n \"viscosity\": 2,\n \"density\": 1030,\n \"dryTime\": 900,\n \"gloss\": 0.5,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 70,\n \"effects\": []\n },\n \"tags\": [\n \"drink\"\n ]\n },\n {\n \"id\": \"soda\",\n \"color\": 3808530,\n \"opacity\": 0.85,\n \"stainColor\": 2757901,\n \"viscosity\": 1.3,\n \"density\": 1040,\n \"dryTime\": 1200,\n \"gloss\": 0.85,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 60,\n \"effects\": []\n },\n \"tags\": [\n \"drink\",\n \"sticky\"\n ]\n },\n {\n \"id\": \"juice\",\n \"color\": 15239467,\n \"opacity\": 0.9,\n \"stainColor\": 12741916,\n \"viscosity\": 2,\n \"density\": 1045,\n \"dryTime\": 1100,\n \"gloss\": 0.8,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 75,\n \"effects\": []\n },\n \"tags\": [\n \"drink\",\n \"sticky\"\n ]\n },\n {\n \"id\": \"beer\",\n \"color\": 14259740,\n \"opacity\": 0.8,\n \"stainColor\": 11039764,\n \"viscosity\": 1.4,\n \"density\": 1010,\n \"dryTime\": 900,\n \"gloss\": 0.8,\n \"drink\": {\n \"thirst\": 50,\n \"effects\": [\n \"alcohol\"\n ]\n },\n \"tags\": [\n \"drink\",\n \"alcohol\"\n ]\n },\n {\n \"id\": \"wine\",\n \"color\": 7016223,\n \"opacity\": 0.9,\n \"stainColor\": 5048854,\n \"viscosity\": 1.6,\n \"density\": 990,\n \"dryTime\": 800,\n \"gloss\": 0.85,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 40,\n \"effects\": [\n \"alcohol\"\n ]\n },\n \"tags\": [\n \"drink\",\n \"alcohol\"\n ]\n },\n {\n \"id\": \"spirits\",\n \"color\": 13214042,\n \"opacity\": 0.6,\n \"stainColor\": 10320959,\n \"viscosity\": 1.8,\n \"density\": 940,\n \"dryTime\": 200,\n \"gloss\": 0.85,\n \"flammable\": true,\n \"drink\": {\n \"thirst\": 5,\n \"effects\": [\n \"alcohol\"\n ]\n },\n \"tags\": [\n \"drink\",\n \"alcohol\"\n ]\n },\n {\n \"id\": \"fuel\",\n \"color\": 14926682,\n \"opacity\": 0.6,\n \"stainColor\": 7232298,\n \"viscosity\": 0.6,\n \"density\": 740,\n \"dryTime\": 60,\n \"gloss\": 0.95,\n \"leavesMark\": false,\n \"flammable\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"fuel\",\n \"gasoline\"\n ]\n },\n {\n \"id\": \"diesel\",\n \"color\": 12098094,\n \"opacity\": 0.8,\n \"stainColor\": 5917208,\n \"viscosity\": 3,\n \"density\": 830,\n \"dryTime\": 3600,\n \"gloss\": 0.95,\n \"leavesMark\": true,\n \"flammable\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"fuel\"\n ]\n },\n {\n \"id\": \"motor_oil\",\n \"color\": 3877388,\n \"opacity\": 0.95,\n \"stainColor\": 1840134,\n \"viscosity\": 100,\n \"density\": 880,\n \"dryTime\": 0,\n \"gloss\": 1,\n \"leavesMark\": true,\n \"flammable\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"oil\"\n ]\n },\n {\n \"id\": \"cooking_oil\",\n \"color\": 14267708,\n \"opacity\": 0.85,\n \"stainColor\": 11110698,\n \"viscosity\": 60,\n \"density\": 920,\n \"dryTime\": 0,\n \"gloss\": 1,\n \"leavesMark\": true,\n \"flammable\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"oil\",\n \"food\"\n ]\n },\n {\n \"id\": \"blood\",\n \"color\": 7997964,\n \"opacity\": 0.92,\n \"stainColor\": 3874068,\n \"viscosity\": 4,\n \"density\": 1060,\n \"dryTime\": 600,\n \"gloss\": 0.75,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 10,\n \"effects\": [\n \"disgust\"\n ]\n },\n \"tags\": [\n \"organic\"\n ]\n },\n {\n \"id\": \"old_blood\",\n \"color\": 7085078,\n \"opacity\": 0.92,\n \"stainColor\": 2758158,\n \"viscosity\": 4,\n \"density\": 1060,\n \"dryTime\": 360,\n \"gloss\": 0.7,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 10,\n \"effects\": [\n \"disgust\"\n ]\n },\n \"tags\": [\n \"organic\"\n ]\n },\n {\n \"id\": \"bile\",\n \"color\": 9083434,\n \"opacity\": 0.9,\n \"stainColor\": 4080160,\n \"viscosity\": 6,\n \"density\": 1020,\n \"dryTime\": 900,\n \"gloss\": 0.75,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"disgust\"\n ]\n },\n \"tags\": [\n \"organic\"\n ]\n },\n {\n \"id\": \"sap\",\n \"color\": 13146940,\n \"opacity\": 0.8,\n \"stainColor\": 10122282,\n \"viscosity\": 200,\n \"density\": 1100,\n \"dryTime\": 3600,\n \"gloss\": 0.8,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 20,\n \"effects\": []\n },\n \"tags\": [\n \"organic\",\n \"sticky\"\n ]\n },\n {\n \"id\": \"acid\",\n \"color\": 10146378,\n \"opacity\": 0.6,\n \"stainColor\": 7313970,\n \"viscosity\": 1.5,\n \"density\": 1200,\n \"dryTime\": 900,\n \"gloss\": 0.9,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"corrosive\"\n ]\n },\n {\n \"id\": \"paint\",\n \"color\": 11740715,\n \"opacity\": 0.98,\n \"stainColor\": 9050655,\n \"viscosity\": 300,\n \"density\": 1300,\n \"dryTime\": 1800,\n \"gloss\": 0.6,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"paint\"\n ]\n },\n {\n \"id\": \"bleach\",\n \"color\": 15134688,\n \"opacity\": 0.7,\n \"stainColor\": 13621446,\n \"viscosity\": 1.2,\n \"density\": 1100,\n \"dryTime\": 900,\n \"gloss\": 0.85,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"corrosive\"\n ]\n },\n {\n \"id\": \"honey\",\n \"color\": 14193162,\n \"opacity\": 0.9,\n \"stainColor\": 12089350,\n \"viscosity\": 3000,\n \"density\": 1420,\n \"dryTime\": 14400,\n \"gloss\": 0.95,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 10,\n \"effects\": []\n },\n \"tags\": [\n \"drink\",\n \"sticky\"\n ]\n },\n {\n \"id\": \"mud\",\n \"color\": 4008988,\n \"opacity\": 0.95,\n \"stainColor\": 3811866,\n \"viscosity\": 40,\n \"density\": 1600,\n \"dryTime\": 900,\n \"gloss\": 0.4,\n \"tags\": [\n \"dirty\"\n ]\n }\n]\n","import liquidsData from './data/liquids.json'\nimport type { LiquidDef } from './types'\n\n/**\n * Built-in liquids (data in `data/liquids.json`; colours are `0xRRGGBB` stored as integers).\n * Viscosity is relative to water, density in kg/m³, `dryTime` in seconds for a thin film at 20 °C (0 = never dries).\n */\nexport const LIQUIDS: LiquidDef[] = liquidsData as unknown as LiquidDef[]\n","import type { Quat, Vec3 } from './types'\n\nexport const GRAVITY = 9.81\nexport const EPS = 1e-7\n\nexport const clamp = (v: number, lo: number, hi: number): number => (v < lo ? lo : v > hi ? hi : v)\nexport const lerp = (a: number, b: number, t: number): number => a + (b - a) * t\n\nexport const add = (a: Vec3, b: Vec3): Vec3 => [a[0] + b[0], a[1] + b[1], a[2] + b[2]]\nexport const sub = (a: Vec3, b: Vec3): Vec3 => [a[0] - b[0], a[1] - b[1], a[2] - b[2]]\nexport const scale = (a: Vec3, s: number): Vec3 => [a[0] * s, a[1] * s, a[2] * s]\nexport const dot = (a: Vec3, b: Vec3): number => a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\nexport const cross = (a: Vec3, b: Vec3): Vec3 => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]\nexport const length = (a: Vec3): number => Math.hypot(a[0], a[1], a[2])\nexport const distance = (a: Vec3, b: Vec3): number => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2])\nexport const normalize = (a: Vec3, fallback: Vec3 = [0, 1, 0]): Vec3 => {\n const l = length(a)\n return l < 1e-9 ? [fallback[0], fallback[1], fallback[2]] : [a[0] / l, a[1] / l, a[2] / l]\n}\nexport const copy3 = (a: Vec3): Vec3 => [a[0], a[1], a[2]]\nexport const lerp3 = (a: Vec3, b: Vec3, t: number): Vec3 => [lerp(a[0], b[0], t), lerp(a[1], b[1], t), lerp(a[2], b[2], t)]\n\n/** Rotate `v` by the unit quaternion `q` (x, y, z, w). */\nexport const quatRotate = (q: Quat, v: Vec3): Vec3 => {\n const u: Vec3 = [q[0], q[1], q[2]]\n const c1 = cross(u, v)\n const c2 = cross(u, c1)\n return [v[0] + 2 * (q[3] * c1[0] + c2[0]), v[1] + 2 * (q[3] * c1[1] + c2[1]), v[2] + 2 * (q[3] * c1[2] + c2[2])]\n}\nexport const quatConjugate = (q: Quat): Quat => [-q[0], -q[1], -q[2], q[3]]\nexport const quatMultiply = (a: Quat, b: Quat): Quat => [\n a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1],\n a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0],\n a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3],\n a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2],\n]\nexport const quatNormalize = (q: Quat): Quat => {\n const l = Math.hypot(q[0], q[1], q[2], q[3])\n return l < 1e-9 ? [0, 0, 0, 1] : [q[0] / l, q[1] / l, q[2] / l, q[3] / l]\n}\n/** Quaternion from Euler angles in XYZ order (the same convention as three.js). */\nexport const quatFromEuler = (x: number, y: number, z: number): Quat => {\n const c1 = Math.cos(x / 2)\n const c2 = Math.cos(y / 2)\n const c3 = Math.cos(z / 2)\n const s1 = Math.sin(x / 2)\n const s2 = Math.sin(y / 2)\n const s3 = Math.sin(z / 2)\n return [s1 * c2 * c3 + c1 * s2 * s3, c1 * s2 * c3 - s1 * c2 * s3, c1 * c2 * s3 + s1 * s2 * c3, c1 * c2 * c3 - s1 * s2 * s3]\n}\n\n/** Small seeded generator (mulberry32). Its whole state is one integer, so it serialises trivially. */\nexport class Rng {\n state: number\n constructor(seed: number) {\n this.state = (Math.imul((seed | 0) ^ 0x9e3779b9, 0x85ebca6b) >>> 0) || 1\n }\n next(): number {\n this.state = (this.state + 0x6d2b79f5) >>> 0\n let t = this.state\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n","import type { StreamState, Vec3 } from './types'\nimport { dot, sub } from './math'\nimport type { Basis } from './stains'\n\nexport const GROUND_ID = 'ground'\n/** Longest flight simulated for a stream before it counts as landing nowhere. */\nexport const MAX_FLIGHT = 3\n\n/** Position of a ballistic jet `t` seconds after leaving its origin. */\nexport const ballistic = (origin: Vec3, velocity: Vec3, gravity: number, t: number): Vec3 => [\n origin[0] + velocity[0] * t,\n origin[1] + velocity[1] * t - 0.5 * gravity * t * t,\n origin[2] + velocity[2] * t,\n]\n\n/** Point of a stream's path `t` seconds after its origin (use with `StreamState.flightTime` and the world's `gravity`). */\nexport const sampleStream = (stream: Pick<StreamState, 'origin' | 'velocity'>, gravity: number, t: number): Vec3 =>\n ballistic(stream.origin, stream.velocity, gravity, t)\n\nexport interface LandingSurface extends Basis {\n id: string\n point: Vec3\n half: [number, number]\n}\n\nexport interface Hit {\n t: number\n point: Vec3\n normal: Vec3\n surface: string\n /** Velocity of the jet at impact. */\n velocity: Vec3\n}\n\nconst velocityAt = (velocity: Vec3, gravity: number, t: number): Vec3 => [velocity[0], velocity[1] - gravity * t, velocity[2]]\n\n/** First thing a jet hits: an authored surface (plane with half extents) or else the ground. */\nexport const trace = (\n surfaces: Iterable<LandingSurface>,\n groundAt: (x: number, z: number) => number,\n origin: Vec3,\n velocity: Vec3,\n gravity: number,\n): Hit | null => {\n let best: Hit | null = null\n for (const s of surfaces) {\n const n = s.normal\n const c = dot(n, sub(origin, s.point))\n if (c < -0.005) continue\n const a = -0.5 * gravity * n[1]\n const b = dot(n, velocity)\n let t = Infinity\n if (Math.abs(a) < 1e-9) {\n if (b < -1e-9) t = -c / b\n } else {\n const disc = b * b - 4 * a * c\n if (disc >= 0) {\n const sq = Math.sqrt(disc)\n for (const root of [(-b - sq) / (2 * a), (-b + sq) / (2 * a)]) {\n if (root >= -1e-6 && b + 2 * a * root < 0 && root < t) t = root\n }\n }\n }\n if (!Number.isFinite(t) || t > MAX_FLIGHT) continue\n t = Math.max(0, t)\n if (best && t >= best.t) continue\n const p = ballistic(origin, velocity, gravity, t)\n const rel = sub(p, s.point)\n if (Math.abs(dot(rel, s.t1)) > s.half[0] || Math.abs(dot(rel, s.t2)) > s.half[1]) continue\n best = { t, point: p, normal: n, surface: s.id, velocity: velocityAt(velocity, gravity, t) }\n }\n\n // Ground: march the path and refine the crossing.\n const step = 0.02\n let prevT = 0\n const startOver = origin[1] - groundAt(origin[0], origin[2])\n const limit = best ? best.t : MAX_FLIGHT\n if (startOver <= 0) {\n return best && best.t <= 0 ? best : { t: 0, point: [origin[0], groundAt(origin[0], origin[2]), origin[2]], normal: [0, 1, 0], surface: GROUND_ID, velocity }\n }\n for (let t = step; t <= limit + step; t += step) {\n const tt = Math.min(t, limit)\n const p = ballistic(origin, velocity, gravity, tt)\n const over = p[1] - groundAt(p[0], p[2])\n if (over <= 0) {\n let lo = prevT\n let hi = tt\n for (let i = 0; i < 18; i++) {\n const mid = (lo + hi) / 2\n const q = ballistic(origin, velocity, gravity, mid)\n if (q[1] - groundAt(q[0], q[2]) > 0) lo = mid\n else hi = mid\n }\n if (best && hi >= best.t - 1e-3) return best\n const q = ballistic(origin, velocity, gravity, hi)\n return { t: hi, point: [q[0], groundAt(q[0], q[2]), q[2]], normal: [0, 1, 0], surface: GROUND_ID, velocity: velocityAt(velocity, gravity, hi) }\n }\n prevT = tt\n if (tt >= limit) break\n }\n return best\n}\n","import type { FluidEvent, LiquidId } from './types'\n\n/** Locales shipped with the package. Unknown locales fall back to `en`. */\nexport type FluidLocale = 'en' | 'pt-BR'\n\nexport interface FluidStrings {\n /** Display name per liquid id (unknown ids fall back to the id itself). */\n liquids: Record<LiquidId, string>\n /** Short label per event type. */\n events: Record<FluidEvent['type'], string>\n on: string\n off: string\n}\n\nexport const locales: Record<FluidLocale, FluidStrings> = {\n en: {\n liquids: {\n water: 'water',\n coffee: 'coffee',\n tea: 'tea',\n milk: 'milk',\n soda: 'soda',\n juice: 'juice',\n beer: 'beer',\n wine: 'wine',\n spirits: 'spirits',\n fuel: 'gasoline',\n diesel: 'diesel',\n motor_oil: 'motor oil',\n cooking_oil: 'cooking oil',\n blood: 'blood',\n old_blood: 'old blood',\n bile: 'bile',\n sap: 'sap',\n acid: 'acid',\n paint: 'paint',\n bleach: 'bleach',\n honey: 'honey',\n mud: 'mud',\n },\n events: {\n fill: 'filled',\n pour: 'poured',\n spill: 'spilled',\n leak: 'leaking',\n drink: 'drank',\n empty: 'emptied',\n stream_end: 'stream ended',\n splash: 'splash',\n stain: 'stain',\n dried: 'dried',\n steam: 'steam',\n mix: 'mixed',\n tap: 'tap',\n },\n on: 'on',\n off: 'off',\n },\n 'pt-BR': {\n liquids: {\n water: 'água',\n coffee: 'café',\n tea: 'chá',\n milk: 'leite',\n soda: 'refrigerante',\n juice: 'suco',\n beer: 'cerveja',\n wine: 'vinho',\n spirits: 'destilado',\n fuel: 'gasolina',\n diesel: 'diesel',\n motor_oil: 'óleo de motor',\n cooking_oil: 'óleo de cozinha',\n blood: 'sangue',\n old_blood: 'sangue antigo',\n bile: 'bile',\n sap: 'seiva',\n acid: 'ácido',\n paint: 'tinta',\n bleach: 'água sanitária',\n honey: 'mel',\n mud: 'lama',\n },\n events: {\n fill: 'encheu',\n pour: 'despejou',\n spill: 'derramou',\n leak: 'vazando',\n drink: 'bebeu',\n empty: 'esvaziou',\n stream_end: 'parou de escorrer',\n splash: 'respingo',\n stain: 'mancha',\n dried: 'secou',\n steam: 'vapor',\n mix: 'misturou',\n tap: 'torneira',\n },\n on: 'ligado',\n off: 'desligado',\n },\n}\n\nexport const resolveStrings = (locale: string | undefined): FluidStrings => locales[(locale as FluidLocale) ?? 'en'] ?? locales.en\n\nconst fmt = (n: number): string => `${(Math.round(n * 1000) / 1000).toString()} l`\nconst pt = (p: [number, number, number]): string => `(${p.map((v) => Math.round(v * 100) / 100).join(', ')})`\n\n/** One-line description of an event for logs and debug panels, e.g. `drank: coffee 0.03 l`. */\nexport const describeEvent = (strings: FluidStrings, event: FluidEvent): string => {\n const label = strings.events[event.type]\n const name = (id: LiquidId) => strings.liquids[id] ?? id\n switch (event.type) {\n case 'fill':\n return `${label}: ${event.container} ${name(event.liquid)} ${fmt(event.liters)}`\n case 'pour':\n case 'spill':\n return `${label}: ${event.container} ${name(event.liquid)} ${fmt(event.rate)}/s`\n case 'leak':\n return `${label}: ${event.container} ${name(event.liquid)} ${fmt(event.rate)}/s ${pt(event.point)}`\n case 'drink':\n return `${label}: ${event.container} ${name(event.liquid)} ${fmt(event.liters)}${event.effects.length ? ` [${event.effects.join(', ')}]` : ''}${event.burn ? ' !' : ''}`\n case 'empty':\n return `${label}: ${event.container}`\n case 'stream_end':\n return `${label}: ${event.stream}`\n case 'splash':\n return `${label}: ${name(event.liquid)} ${pt(event.point)}`\n case 'stain':\n return `${label}: ${event.stain} ${name(event.liquid)} ${event.surface} ${pt(event.point)}`\n case 'dried':\n return `${label}: ${event.stain}${event.mark ? ' (mark)' : ''}`\n case 'steam':\n return `${label}: ${event.container} ${event.on ? strings.on : strings.off}`\n case 'mix':\n return `${label}: ${event.container} ${name(event.from)} -> ${name(event.into)}`\n case 'tap':\n return `${label}: ${event.tap} ${event.on ? strings.on : strings.off}`\n }\n}\n","import type { ContainerSpec, Vec3 } from './types'\nimport { clamp, normalize } from './math'\n\nexport type Shape = ContainerSpec['shape']\n\n/** Sample columns of a container's inner volume: equal-weight (x, z) positions with the full height `h`. */\nexport interface Columns {\n x: Float64Array\n z: Float64Array\n h: number\n /** Radius (cylinder) or half extents (box) used for the extent of a plane. */\n kind: 'cylinder' | 'box'\n r: number\n hx: number\n hz: number\n}\n\nconst RINGS = 8\nconst SEGMENTS = 16\nconst GRID = 12\n\nexport const makeColumns = (shape: Shape): Columns => {\n if (shape.kind === 'cylinder') {\n const x = new Float64Array(RINGS * SEGMENTS)\n const z = new Float64Array(RINGS * SEGMENTS)\n let n = 0\n for (let k = 0; k < RINGS; k++) {\n const rr = shape.radius * Math.sqrt((k + 0.5) / RINGS)\n for (let m = 0; m < SEGMENTS; m++) {\n // Offset every other ring so the samples do not line up radially.\n const a = ((m + (k % 2) * 0.5) / SEGMENTS) * Math.PI * 2\n x[n] = Math.cos(a) * rr\n z[n] = Math.sin(a) * rr\n n++\n }\n }\n return { x, z, h: shape.height, kind: 'cylinder', r: shape.radius, hx: shape.radius, hz: shape.radius }\n }\n const [sx, sy, sz] = shape.size\n const x = new Float64Array(GRID * GRID)\n const z = new Float64Array(GRID * GRID)\n let n = 0\n for (let i = 0; i < GRID; i++) {\n for (let j = 0; j < GRID; j++) {\n x[n] = ((i + 0.5) / GRID - 0.5) * sx\n z[n] = ((j + 0.5) / GRID - 0.5) * sz\n n++\n }\n }\n return { x, z, h: sy, kind: 'box', r: Math.hypot(sx, sz) / 2, hx: sx / 2, hz: sz / 2 }\n}\n\n/** Range of `u · p` over the container: below `lo` it is empty, above `hi` it is full. */\nexport const planeRange = (c: Columns, u: Vec3): [number, number] => {\n const horizontal = c.kind === 'cylinder' ? c.r * Math.hypot(u[0], u[2]) : Math.abs(u[0]) * c.hx + Math.abs(u[2]) * c.hz\n const top = u[1] * c.h\n return [-horizontal + Math.min(0, top), horizontal + Math.max(0, top)]\n}\n\n/** Fraction (0..1) of the inner volume with `u · p <= d` (the liquid for a surface plane with normal `u` at offset `d`). */\nexport const planeFraction = (c: Columns, u: Vec3, d: number): number => {\n const uy = u[1]\n let total = 0\n const n = c.x.length\n for (let i = 0; i < n; i++) {\n const s0 = u[0] * c.x[i] + u[2] * c.z[i]\n let len: number\n if (uy > 1e-6) len = clamp((d - s0) / uy, 0, c.h)\n else if (uy < -1e-6) len = c.h - clamp((d - s0) / uy, 0, c.h)\n else len = s0 <= d ? c.h : 0\n total += len\n }\n return total / (n * c.h)\n}\n\n/** Plane offset `d` along unit normal `u` for which the liquid takes the volume fraction `f`. */\nexport const levelFor = (c: Columns, u: Vec3, f: number): number => {\n const [lo0, hi0] = planeRange(c, u)\n if (f <= 0) return lo0\n if (f >= 1) return hi0\n if (Math.abs(u[0]) + Math.abs(u[2]) < 1e-9) {\n return u[1] > 0 ? f * c.h * u[1] : u[1] * c.h - f * c.h * u[1]\n }\n let lo = lo0\n let hi = hi0\n for (let i = 0; i < 28; i++) {\n const mid = (lo + hi) / 2\n if (planeFraction(c, u, mid) < f) lo = mid\n else hi = mid\n }\n return (lo + hi) / 2\n}\n\n/** Radius of the lip circle (the opening); a closed spec (`opening` 0) uses half the container width once opened. */\nexport const lipRadius = (shape: Shape, opening: number): number => {\n const limit = shape.kind === 'cylinder' ? shape.radius : Math.min(shape.size[0], shape.size[2]) / 2\n return opening > 0 ? Math.min(opening, limit) : limit * 0.5\n}\n\nexport const shapeHeight = (shape: Shape): number => (shape.kind === 'cylinder' ? shape.height : shape.size[1])\n\nexport interface Lip {\n /** Lowest lip point along the surface normal, container space. */\n point: Vec3\n /** Centre of the lip circle, container space. */\n center: Vec3\n /** Outward direction (container space, horizontal in the container frame) the liquid leaves along, or null when upright. */\n outward: Vec3 | null\n /** `u · point`: the surface offset above which the liquid spills. */\n level: number\n}\n\nexport const lipOf = (shape: Shape, opening: number, u: Vec3): Lip => {\n const h = shapeHeight(shape)\n const ro = lipRadius(shape, opening)\n const center: Vec3 = [0, h, 0]\n const uh = Math.hypot(u[0], u[2])\n if (uh < 1e-6) return { point: center, center, outward: null, level: u[1] * h }\n const out: Vec3 = normalize([-u[0], 0, -u[2]])\n const point: Vec3 = [out[0] * ro, h, out[2] * ro]\n return { point, center, outward: out, level: u[0] * point[0] + u[1] * point[1] + u[2] * point[2] }\n}\n","import type { LiquidDef, StainState, Vec3 } from './types'\nimport { Rng, add, clamp, cross, dot, length, normalize, scale, sub } from './math'\n\n/** Number of radial samples of the flow front. */\nexport const SAMPLES = 16\n\nconst COS: number[] = []\nconst SIN: number[] = []\nfor (let i = 0; i < SAMPLES; i++) {\n COS.push(Math.cos((i / SAMPLES) * Math.PI * 2))\n SIN.push(Math.sin((i / SAMPLES) * Math.PI * 2))\n}\n\n/** Orthonormal frame of a surface: `normal`, `t1` (tangent) and `t2 = normal × t1`. */\nexport interface Basis {\n normal: Vec3\n t1: Vec3\n t2: Vec3\n}\n\nexport const makeBasis = (normalIn: Vec3, tangentIn?: Vec3): Basis => {\n const normal = normalize(normalIn)\n const ref: Vec3 = tangentIn && length(tangentIn) > 1e-6 ? tangentIn : Math.abs(normal[1]) > 0.9 ? [1, 0, 0] : [0, 1, 0]\n const t1 = normalize(sub(ref, scale(normal, dot(ref, normal))), [1, 0, 0])\n return { normal, t1, t2: cross(normal, t1) }\n}\n\n/** What a stain needs to know about the surface it lies on. */\nexport interface StainSurface extends Basis {\n point: Vec3\n half: [number, number]\n porosity: number\n}\n\nexport interface StainInt extends StainState {\n normal: Vec3\n tangent: Vec3\n noise: number[]\n /** Seconds since the last inflow. */\n sinceInflow: number\n /** Drying progress 0..1. */\n dry: number\n mark: boolean\n age: number\n}\n\n/** Direction (world space) of radial sample `i` on a surface frame. */\nexport const sampleDir = (b: Basis, i: number): Vec3 => [\n b.t1[0] * COS[i] + b.t2[0] * SIN[i],\n b.t1[1] * COS[i] + b.t2[1] * SIN[i],\n b.t1[2] * COS[i] + b.t2[2] * SIN[i],\n]\n\nexport const stainArea = (front: number[]): number => {\n let a = 0\n for (let i = 0; i < SAMPLES; i++) a += front[i] * front[(i + 1) % SAMPLES]\n return 0.5 * Math.sin((Math.PI * 2) / SAMPLES) * a\n}\n\nexport const meanRadius = (front: number[]): number => front.reduce((s, v) => s + v, 0) / front.length\n\n/** Thickness (m) a puddle of this liquid cannot get thinner than: 1 mm for water, thicker for viscous liquids. */\nexport const minFilm = (def: LiquidDef): number => 0.001 * (1 + 0.8 * Math.log10(Math.max(1, def.viscosity)))\n\n/** Per-direction growth multipliers: low harmonics plus smoothed seeded noise, so the outline is never a disc. */\nexport const makeNoise = (rng: Rng): number[] => {\n const amp = [0.12 + rng.next() * 0.18, 0.08 + rng.next() * 0.14, 0.05 + rng.next() * 0.08]\n const phase = [rng.next() * Math.PI * 2, rng.next() * Math.PI * 2, rng.next() * Math.PI * 2]\n const raw: number[] = []\n for (let i = 0; i < SAMPLES; i++) {\n const a = (i / SAMPLES) * Math.PI * 2\n let v = 1 + (rng.next() - 0.5) * 0.3\n for (let k = 0; k < 3; k++) v += amp[k] * Math.sin((k + 2) * a + phase[k])\n raw.push(v)\n }\n const out = raw.map((v, i) => 0.25 * raw[(i + SAMPLES - 1) % SAMPLES] + 0.5 * v + 0.25 * raw[(i + 1) % SAMPLES])\n return out.map((v) => clamp(v, 0.45, 1.7))\n}\n\n/** Horizontal run direction on a surface (downhill, unit, in the plane) and the slope strength 0..1 (sin of the angle). */\nexport const downhill = (normal: Vec3): { dir: Vec3; slope: number } => {\n const d = add([0, -1, 0], scale(normal, normal[1]))\n const slope = length(d)\n return slope < 1e-6 ? { dir: [0, 0, 0], slope: 0 } : { dir: scale(d, 1 / slope), slope }\n}\n\n/** Creates a stain at `center` (on the surface) with a small starting front. */\nexport const createStain = (\n id: string,\n surfaceId: string,\n def: LiquidDef,\n basis: Basis,\n center: Vec3,\n liters: number,\n rng: Rng,\n): StainInt => {\n const r0 = clamp(Math.sqrt(liters / 1000 / minFilm(def) / Math.PI) * 0.4, 0.012, 0.12)\n return {\n id,\n surface: surfaceId,\n liquid: def.id,\n center: [center[0], center[1], center[2]],\n front: new Array(SAMPLES).fill(r0),\n liters,\n soaked: 0,\n wetness: 1,\n wetRadius: 1,\n normal: basis.normal,\n tangent: basis.t1,\n noise: makeNoise(rng),\n sinceInflow: 0,\n dry: 0,\n mark: false,\n age: 0,\n }\n}\n\n/** Adds liquid to a stain (rewets a dried mark). `velocity` makes the front stretch the way the liquid came in. */\nexport const addInflow = (s: StainInt, liters: number, velocity: Vec3 | null): void => {\n s.liters += liters\n s.sinceInflow = 0\n if (s.dry > 0 || s.mark) {\n s.dry = 0\n s.mark = false\n s.wetness = 1\n s.wetRadius = 1\n }\n if (velocity) {\n const n = s.normal\n const tangential = sub(velocity, scale(n, dot(velocity, n)))\n if (length(tangential) > 0.2) s.flow = normalize(tangential)\n }\n}\n\n/** Moves the centre towards an inflow point without moving the outline. */\nexport const nudgeCenter = (s: StainInt, point: Vec3, weight: number, basis: Basis): void => {\n const delta = scale(sub(point, s.center), weight)\n if (length(delta) < 1e-6) return\n s.center = add(s.center, delta)\n for (let i = 0; i < SAMPLES; i++) s.front[i] = Math.max(0.008, s.front[i] - dot(delta, sampleDir(basis, i)))\n}\n\nexport type StainStatus = 'alive' | 'dried_mark' | 'dried_gone'\n\n/** Largest radius along each sample direction before the centre's surface rectangle ends. */\nconst edgeLimit = (s: StainInt, surface: StainSurface, i: number): number => {\n if (!Number.isFinite(surface.half[0]) && !Number.isFinite(surface.half[1])) return Infinity\n const rel = sub(s.center, surface.point)\n const cx = dot(rel, surface.t1)\n const cy = dot(rel, surface.t2)\n let limit = Infinity\n if (COS[i] > 1e-6) limit = Math.min(limit, (surface.half[0] - cx) / COS[i])\n else if (COS[i] < -1e-6) limit = Math.min(limit, (-surface.half[0] - cx) / COS[i])\n if (SIN[i] > 1e-6) limit = Math.min(limit, (surface.half[1] - cy) / SIN[i])\n else if (SIN[i] < -1e-6) limit = Math.min(limit, (-surface.half[1] - cy) / SIN[i])\n return Math.max(0.01, limit)\n}\n\n/**\n * Advances a stain: the front grows (faster downhill, with seeded noise, tapering as the area approaches what the liquid can cover at its\n * minimum film thickness), porous surfaces soak the pool, and once the inflow stopped the stain dries from the edge in.\n */\nexport const stepStain = (s: StainInt, def: LiquidDef, surface: StainSurface, ambientC: number, dt: number): StainStatus => {\n s.age += dt\n s.sinceInflow += dt\n const basis: Basis = surface\n const { dir: down, slope } = downhill(s.normal)\n\n // Soak into porous surfaces.\n if (s.liters > 0 && surface.porosity > 0) {\n const soak = Math.min(s.liters, surface.porosity * 0.2 * stainArea(s.front) * dt)\n s.liters -= soak\n s.soaked += soak\n }\n\n // Grow the flow front.\n if (s.liters > 1e-7 && s.wetness > 0) {\n const area = stainArea(s.front)\n const cover = s.liters / 1000 / (minFilm(def) * (1 - 0.7 * slope))\n if (area < cover) {\n const taper = clamp(1 - area / cover, 0, 1)\n const v0 = (0.02 + 0.2 * Math.sqrt(s.liters)) / Math.sqrt(Math.max(1, def.viscosity))\n const delta: number[] = []\n for (let i = 0; i < SAMPLES; i++) {\n let m = s.noise[i]\n if (s.flow) m *= 1 + 0.5 * Math.max(0, dot(sampleDir(basis, i), s.flow))\n if (slope > 0.02) {\n const a = dot(sampleDir(basis, i), down)\n m *= a > 0 ? 1 + 14 * slope * a : Math.max(0.1, 1 + 2.5 * slope * a)\n }\n delta.push(Math.max(0, Math.min(s.front[i] + v0 * m * taper * dt, edgeLimit(s, surface, i)) - s.front[i]))\n }\n // Never overshoot the area the liquid can cover: scale the growth (not the outline) down to fit.\n let lambda = 1\n const apply = (k: number) => s.front.map((r, i) => r + delta[i] * k)\n if (stainArea(apply(1)) > cover) {\n let lo = 0\n let hi = 1\n for (let i = 0; i < 14; i++) {\n const mid = (lo + hi) / 2\n if (stainArea(apply(mid)) > cover) hi = mid\n else lo = mid\n }\n lambda = lo\n }\n s.front = apply(lambda)\n }\n }\n\n // Dry from the edge in once the inflow stopped.\n if (s.sinceInflow > 1 && def.dryTime > 0 && s.dry < 1) {\n const warm = Math.pow(2, (ambientC - 20) / 12)\n const ds = (dt * warm * (1 + 0.5 * surface.porosity)) / def.dryTime\n const before = s.dry\n s.dry = Math.min(1, s.dry + ds)\n if (before < 1) s.liters *= 1 - (s.dry - before) / (1 - before)\n s.wetness = 1 - s.dry\n s.wetRadius = Math.sqrt(Math.max(0, 1 - s.dry))\n if (s.dry >= 1) {\n s.liters = 0\n s.wetness = 0\n s.wetRadius = 0\n if (def.leavesMark) {\n s.mark = true\n return 'dried_mark'\n }\n return 'dried_gone'\n }\n }\n return 'alive'\n}\n\n/** Unit direction (world space) of front sample `i` of a stain, from its `normal` and `tangent`. */\nexport const stainDirection = (s: Pick<StainState, 'normal' | 'tangent'>, i: number): Vec3 => sampleDir(makeBasis(s.normal ?? [0, 1, 0], s.tangent), i)\n","// The pose of a surface that moves with the object it belongs to (a table top that tips over) and what that does to the liquid on it.\nimport { add, clamp, dot, quatConjugate, quatMultiply, quatRotate, scale, sub } from './math'\nimport { downhill } from './stains'\nimport type { Basis, StainInt } from './stains'\nimport type { LiquidDef, Quat, SurfacePose, Vec3 } from './types'\n\n/** A surface as it was added: the rest the pose moves. */\nexport interface SurfaceRest {\n readonly point: Vec3\n readonly normal: Vec3\n readonly tangent: Vec3\n}\n\nexport const IDENTITY_POSE: SurfacePose = { position: [0, 0, 0], rotation: [0, 0, 0, 1] }\n\n/** Tilt (rad) from its rest a surface holds a water-like pool at; a thicker liquid clings longer. */\nconst RUNOFF_TILT = (6 * Math.PI) / 180\nconst RUNOFF_TILT_MAX = (60 * Math.PI) / 180\n/** How far past the rim (m) and how fast (m/s) the liquid that runs off leaves it. */\nconst RUNOFF_CLEARANCE = 0.02\nconst RUNOFF_SPEED = 0.6\n/** A surface whose normal points this far down holds nothing: what is on it falls straight off. */\nconst UPSIDE_DOWN_Y = -0.2\n\nconst applyPose = (pose: SurfacePose, point: Vec3): Vec3 => add(pose.position, quatRotate(pose.rotation, point))\nconst undoPose = (pose: SurfacePose, point: Vec3): Vec3 => quatRotate(quatConjugate(pose.rotation), sub(point, pose.position))\n\n/** The point, normal and tangent of the surface at `pose`. */\nexport function posedFrame(rest: SurfaceRest, pose: SurfacePose): SurfaceRest {\n return { point: applyPose(pose, rest.point), normal: quatRotate(pose.rotation, rest.normal), tangent: quatRotate(pose.rotation, rest.tangent) }\n}\n\nexport interface CarryStainParams {\n readonly stain: StainInt\n readonly from: SurfacePose\n readonly to: SurfacePose\n}\n\n/** The stain goes with the surface from one pose to the next: its centre, its plane and the way it ran. */\nexport function carryStain({ stain, from, to }: CarryStainParams): void {\n const turn: Quat = quatMultiply(to.rotation, quatConjugate(from.rotation))\n stain.center = applyPose(to, undoPose(from, stain.center))\n stain.normal = quatRotate(turn, stain.normal)\n stain.tangent = quatRotate(turn, stain.tangent)\n if (stain.flow) stain.flow = quatRotate(turn, stain.flow)\n}\n\n/** The tilt (rad) from its rest at which a pool of this liquid runs off a surface. */\nexport const runoffTilt = (def: LiquidDef): number => clamp(RUNOFF_TILT * Math.sqrt(Math.max(1, def.viscosity)), RUNOFF_TILT, RUNOFF_TILT_MAX)\n\n/** The angle (rad) the surface turned from its rest. */\nexport const tiltOf = (rest: SurfaceRest, normal: Vec3): number => Math.acos(clamp(dot(rest.normal, normal), -1, 1))\n\nexport interface RunoffParams {\n readonly center: Vec3\n readonly surface: Basis & { readonly point: Vec3; readonly half: readonly [number, number] }\n}\n\n/** Where the pool leaves the surface and how: from the lowest rim downhill of it, or straight down from under a surface turned over. */\nexport function runoffStart({ center, surface }: RunoffParams): { origin: Vec3; velocity: Vec3 } {\n const { dir, slope } = downhill(surface.normal)\n if (surface.normal[1] < UPSIDE_DOWN_Y || slope < 1e-3) return { origin: add(center, scale(surface.normal, RUNOFF_CLEARANCE)), velocity: [0, -RUNOFF_SPEED, 0] }\n const rel = sub(center, surface.point)\n const room = (half: number, at: number, along: number): number => (along > 1e-6 ? (half - at) / along : along < -1e-6 ? (-half - at) / along : Infinity)\n const reach = Math.max(0, Math.min(room(surface.half[0], dot(rel, surface.t1), dot(dir, surface.t1)), room(surface.half[1], dot(rel, surface.t2), dot(dir, surface.t2))))\n const rim = add(center, scale(dir, Number.isFinite(reach) ? reach + RUNOFF_CLEARANCE : RUNOFF_CLEARANCE))\n return { origin: add(rim, scale(surface.normal, RUNOFF_CLEARANCE)), velocity: scale(dir, RUNOFF_SPEED) }\n}\n","import { LIQUIDS } from './liquids'\nimport { GROUND_ID, MAX_FLIGHT, ballistic, trace } from './landing'\nimport type { Hit, LandingSurface } from './landing'\nimport { describeEvent, resolveStrings } from './locale'\nimport { GRAVITY, Rng, add, clamp, copy3, cross, distance, dot, length, normalize, quatConjugate, quatRotate, scale } from './math'\nimport { levelFor, lipOf, lipRadius, makeColumns, planeFraction, planeRange, shapeHeight } from './shapes'\nimport type { Columns } from './shapes'\nimport { addInflow, createStain, makeBasis, meanRadius, nudgeCenter, stepStain } from './stains'\nimport type { Basis, StainInt, StainSurface } from './stains'\nimport type {\n ContainerSpec,\n ContainerState,\n FluidEvent,\n FluidOptions,\n FluidWorld,\n LiquidDef,\n LiquidId,\n Quat,\n StainState,\n StainTint,\n StreamCause,\n StreamState,\n SurfacePose,\n SurfaceSpec,\n Vec3,\n} from './types'\nimport { IDENTITY_POSE, carryStain, posedFrame, runoffStart, runoffTilt, tiltOf } from './surface-pose'\nimport type { SurfaceRest } from './surface-pose'\n\ninterface Hole {\n point: Vec3\n normal: Vec3\n diameter: number\n}\n\ninterface ContainerInt {\n id: string\n spec: ContainerSpec\n cols: Columns\n liquid: LiquidId | null\n liters: number\n temperature: number\n closed: boolean\n position: Vec3\n rotation: Quat\n velocity: Vec3\n prevVelocity: Vec3\n hasPrev: boolean\n holes: Hole[]\n /** Slosh of the liquid surface: tilt offsets and their rates (x, z, vx, vz). */\n slosh: [number, number, number, number]\n /** Surface normal in world space (up plus slosh) and in container space, and the surface offset along it. */\n normal: Vec3\n u: Vec3\n d: number\n steaming: boolean\n outflow: number\n /** Stream key (`spill`, `pour`, `leak:<n>`) to stream id. */\n streams: Record<string, string>\n pourRate: number\n pourTTL: number\n pourVisual: boolean\n lastMix: number\n}\n\ninterface TapInt {\n id: string\n position: Vec3\n direction: Vec3\n liquid: LiquidId\n rate: number\n temperature: number\n on: boolean\n stream?: string\n}\n\ninterface StreamInt extends StreamState {\n key: string\n lastSplash: number\n visualOnly: boolean\n temperature: number\n}\n\ninterface SurfaceInt extends SurfaceSpec, StainSurface {\n /** Where it was added, and the move of it since (`setSurfacePose`, `moveSurface`). */\n rest: SurfaceRest\n pose: SurfacePose\n}\n\n/** A surface of a snapshot: as it was added, and its pose when it was moved. */\ntype SnapshotSurface = SurfaceSpec & { pose?: SurfacePose }\n\ninterface Snapshot {\n version: 1\n time: number\n rng: number\n counters: { container: number; stream: number; stain: number; tap?: number }\n taps?: TapInt[]\n containers: Array<Omit<ContainerInt, 'cols'>>\n surfaces: SnapshotSurface[]\n streams: StreamInt[]\n stains: StainInt[]\n}\n\nconst GROUND_POROSITY = 0.2\nconst MAX_STEP = 0.1\nconst MAX_SUBSTEPS = 50\nconst MAX_HOLES = 32\n\nconst clone = <T>(v: T): T => JSON.parse(JSON.stringify(v)) as T\n\nexport function createFluids(options: FluidOptions = {}): FluidWorld {\n const strings = resolveStrings(options.locale)\n const liquids = new Map<LiquidId, LiquidDef>()\n for (const def of LIQUIDS) liquids.set(def.id, def)\n for (const def of options.liquids ?? []) liquids.set(def.id, def)\n const ambientC = options.ambientC ?? 20\n const gravity = options.gravity ?? GRAVITY\n const groundAt = options.groundAt ?? (() => 0)\n const mergeDistance = options.mergeDistance ?? 0.15\n const maxStains = options.maxStains ?? 64\n\n let rng = new Rng(options.seed ?? 1)\n let time = 0\n const counters = { container: 0, stream: 0, stain: 0, tap: 0 }\n let containers = new Map<string, ContainerInt>()\n let surfaces = new Map<string, SurfaceInt>()\n let streams = new Map<string, StreamInt>()\n let taps = new Map<string, TapInt>()\n let stains = new Map<string, StainInt>()\n const listeners = new Map<string, Set<(e: FluidEvent) => void>>()\n let queue: FluidEvent[] = []\n /** Only events produced by `update` are queued and returned by it; direct calls just notify the listeners. */\n let updating = false\n\n const groundSurface: StainSurface = {\n normal: [0, 1, 0],\n t1: [1, 0, 0],\n t2: [0, 0, -1],\n point: [0, 0, 0],\n half: [Infinity, Infinity],\n porosity: GROUND_POROSITY,\n }\n\n // ---- events ----\n\n const emit = (e: FluidEvent): void => {\n if (updating) queue.push(e)\n options.onEvent?.(e)\n listeners.get(e.type)?.forEach((fn) => fn(e))\n listeners.get('*')?.forEach((fn) => fn(e))\n }\n\n // ---- helpers ----\n\n const toWorld = (c: ContainerInt, p: Vec3): Vec3 => add(c.position, quatRotate(c.rotation, p))\n const defOf = (c: ContainerInt): LiquidDef | null => (c.liquid ? (liquids.get(c.liquid) ?? null) : null)\n const viscScale = (def: LiquidDef): number => 1 / Math.sqrt(Math.max(1, def.viscosity))\n\n const refreshLevel = (c: ContainerInt): void => {\n c.normal = normalize([c.slosh[0], 1, c.slosh[1]])\n c.u = normalize(quatRotate(quatConjugate(c.rotation), c.normal))\n c.d = levelFor(c.cols, c.u, c.spec.capacity > 0 ? c.liters / c.spec.capacity : 0)\n }\n\n const surfaceFor = (id: string): StainSurface => (id === GROUND_ID ? groundSurface : (surfaces.get(id) ?? groundSurface))\n\n const landingSurfaces = (except?: string): LandingSurface[] => {\n const list: LandingSurface[] = []\n for (const [id, s] of surfaces) if (id !== except) list.push({ id, normal: s.normal, t1: s.t1, t2: s.t2, point: s.point, half: s.half })\n return list\n }\n\n /** Moves a surface to `pose` from its rest; the stains on it go along when `carry` (a snapshot loads them where they already are). */\n const poseSurface = (surface: SurfaceInt, pose: SurfacePose, carry: boolean): void => {\n const from = surface.pose\n const to: SurfacePose = { position: copy3(pose.position), rotation: [pose.rotation[0], pose.rotation[1], pose.rotation[2], pose.rotation[3]] }\n if (carry) for (const st of stains.values()) if (st.surface === surface.id) carryStain({ stain: st, from, to })\n const frame = posedFrame(surface.rest, to)\n Object.assign(surface, makeBasis(frame.normal, frame.tangent), { point: frame.point, normal: frame.normal, pose: to })\n }\n\n /** The pool of a stain on a surface turned past what its liquid holds on leaves by the low rim and lands on what is under it; the soaked part stays. */\n const runOff = (st: StainInt, def: LiquidDef): void => {\n const surface = surfaces.get(st.surface)\n if (!surface || st.liters <= 1e-6 || tiltOf(surface.rest, surface.normal) <= runoffTilt(def)) return\n const { origin, velocity } = runoffStart({ center: st.center, surface })\n const liters = st.liters\n st.liters = 0\n const hit = trace(landingSurfaces(surface.id), groundAt, origin, velocity, gravity)\n if (hit) deposit(st.liquid, hit, liters, hit.velocity, st.tint)\n }\n\n const stopStream = (id: string): void => {\n const s = streams.get(id)\n if (!s) return\n streams.delete(id)\n const c = s.container ? containers.get(s.container) : undefined\n if (c) delete c.streams[s.key]\n const tap = s.tap ? taps.get(s.tap) : undefined\n if (tap && tap.stream === id) tap.stream = undefined\n emit({ type: 'stream_end', stream: id })\n }\n\n const endStreamKey = (c: ContainerInt, key: string): void => {\n const id = c.streams[key]\n if (id) stopStream(id)\n }\n\n /** Create or update the stream under `key` of a container; creating one emits the matching cause event. */\n const syncStream = (\n c: ContainerInt,\n key: string,\n cause: StreamCause,\n rate: number,\n origin: Vec3,\n velocity: Vec3,\n visualOnly = false,\n ): void => {\n if (rate < 1e-5 || !c.liquid) {\n endStreamKey(c, key)\n return\n }\n const existing = c.streams[key] ? streams.get(c.streams[key]) : undefined\n if (existing) {\n existing.rate = rate\n existing.origin = origin\n existing.velocity = velocity\n existing.thin = rate < 0.04\n existing.visualOnly = visualOnly\n existing.temperature = c.temperature\n return\n }\n const id = `stream_${++counters.stream}`\n const stream: StreamInt = {\n id,\n liquid: c.liquid,\n cause,\n container: c.id,\n origin,\n velocity,\n rate,\n landing: null,\n thin: rate < 0.04,\n flightTime: MAX_FLIGHT,\n key,\n lastSplash: -1,\n visualOnly,\n temperature: c.temperature,\n }\n streams.set(id, stream)\n c.streams[key] = id\n if (cause === 'leak') emit({ type: 'leak', container: c.id, liquid: c.liquid, rate, stream: id, point: copy3(origin) })\n else if (cause === 'spill') emit({ type: 'spill', container: c.id, liquid: c.liquid, rate, stream: id })\n else emit({ type: 'pour', container: c.id, liquid: c.liquid, rate, stream: id })\n }\n\n /** Speed (m/s) at which a tap's liquid leaves the nozzle. */\n const TAP_SPEED = 1.2\n\n /** Create or update the `tap` stream of a tap that is on; end it when it is off. */\n const syncTap = (t: TapInt): void => {\n if (!t.on || t.rate < 1e-5 || !liquids.has(t.liquid)) {\n if (t.stream) stopStream(t.stream)\n return\n }\n const velocity: Vec3 = [t.direction[0] * TAP_SPEED, t.direction[1] * TAP_SPEED, t.direction[2] * TAP_SPEED]\n const existing = t.stream ? streams.get(t.stream) : undefined\n if (existing) {\n existing.rate = t.rate\n existing.thin = t.rate < 0.04\n existing.temperature = t.temperature\n existing.velocity = velocity\n return\n }\n const id = `stream_${++counters.stream}`\n streams.set(id, {\n id,\n liquid: t.liquid,\n cause: 'tap',\n tap: t.id,\n origin: copy3(t.position),\n velocity,\n rate: t.rate,\n landing: null,\n thin: t.rate < 0.04,\n flightTime: MAX_FLIGHT,\n key: `tap:${t.id}`,\n lastSplash: -1,\n visualOnly: false,\n temperature: t.temperature,\n })\n t.stream = id\n }\n\n /** Where and how fast the liquid leaves over the lowest lip point. */\n const lipFlow = (c: ContainerInt, head: number): { origin: Vec3; velocity: Vec3 } => {\n const lip = lipOf(c.spec.shape, c.spec.opening, c.u)\n const origin = toWorld(c, lip.point)\n let dir: Vec3 = [1, 0, 0]\n const horizontal = (v: Vec3): Vec3 | null => (Math.hypot(v[0], v[2]) > 1e-3 ? normalize([v[0], 0, v[2]]) : null)\n if (lip.outward) dir = horizontal(quatRotate(c.rotation, lip.outward)) ?? horizontal(quatRotate(c.rotation, [1, 0, 0])) ?? dir\n else dir = horizontal(quatRotate(c.rotation, [1, 0, 0])) ?? dir\n const speed = clamp(0.3 + 0.5 * Math.sqrt(2 * gravity * Math.max(0, head)), 0.2, 2.5)\n return { origin, velocity: [dir[0] * speed, -0.1, dir[2] * speed] }\n }\n\n const removeLiters = (c: ContainerInt, amount: number): void => {\n c.liters = Math.max(0, c.liters - amount)\n }\n\n /** Clear a container that ran out and emit `empty` once. */\n const settle = (c: ContainerInt): void => {\n if (c.liquid && c.liters <= 1e-6) {\n c.liters = 0\n c.liquid = null\n emit({ type: 'empty', container: c.id })\n }\n }\n\n const fillInternal = (c: ContainerInt, liquid: LiquidId, liters: number, temperature: number | undefined, announce: boolean): number => {\n if (!(liters > 0) || !liquids.has(liquid)) return 0\n const room = c.spec.capacity - c.liters\n const accepted = Math.min(liters, Math.max(0, room))\n if (accepted <= 0) return 0\n const t = temperature ?? ambientC\n if (c.liquid && c.liquid !== liquid && c.liters > 1e-6) {\n const incomingWins = accepted > c.liters\n const into = incomingWins ? liquid : c.liquid\n const from = incomingWins ? c.liquid : liquid\n if (announce || time - c.lastMix > 0.5) {\n c.lastMix = time\n emit({ type: 'mix', container: c.id, from, into })\n }\n c.liquid = into\n } else if (!c.liquid || c.liters <= 1e-6) {\n c.liquid = liquid\n }\n c.temperature = c.liters > 1e-6 ? (c.temperature * c.liters + t * accepted) / (c.liters + accepted) : t\n c.liters += accepted\n if (announce) emit({ type: 'fill', container: c.id, liquid, liters: accepted })\n return accepted\n }\n\n // ---- stains ----\n\n const stainAt = (surfaceId: string, liquid: LiquidId, point: Vec3): StainInt | null => {\n let best: StainInt | null = null\n let bestD = Infinity\n for (const s of stains.values()) {\n if (s.surface !== surfaceId || s.liquid !== liquid) continue\n const d = distance(point, s.center)\n if (d < mergeDistance + 0.5 * meanRadius(s.front) && d < bestD) {\n best = s\n bestD = d\n }\n }\n return best\n }\n\n const evictStain = (): void => {\n let victim: StainInt | null = null\n for (const s of stains.values()) {\n const rank = (x: StainInt) => (x.wetness <= 0 ? 0 : 1) * 1e9 - x.age\n if (!victim || rank(s) < rank(victim)) victim = s\n }\n if (victim) stains.delete(victim.id)\n }\n\n const deposit = (liquid: LiquidId, hit: Pick<Hit, 'point' | 'surface' | 'normal'>, liters: number, velocity: Vec3 | null, tint?: StainTint): void => {\n const def = liquids.get(liquid)\n if (!def || liters <= 0) return\n let s = stainAt(hit.surface, liquid, hit.point)\n if (s) {\n const basis: Basis = { normal: s.normal, t1: s.tangent, t2: cross(s.normal, s.tangent) }\n nudgeCenter(s, hit.point, clamp((liters / (s.liters + liters)) * 0.5, 0, 0.5), basis)\n addInflow(s, liters, velocity)\n if (tint) s.tint = { ...tint }\n return\n }\n while (stains.size >= maxStains) evictStain()\n const surface = surfaceFor(hit.surface)\n const basis: Basis = hit.surface === GROUND_ID ? makeBasis(hit.normal) : surface\n s = createStain(`stain_${++counters.stain}`, hit.surface, def, basis, hit.point, liters, rng)\n if (velocity) addInflow(s, 0, velocity)\n if (tint) s.tint = { ...tint }\n s.sinceInflow = 0\n stains.set(s.id, s)\n emit({ type: 'stain', stain: s.id, surface: hit.surface, liquid, point: copy3(hit.point) })\n }\n\n // ---- streams ----\n\n const lipCenterWorld = (c: ContainerInt): Vec3 => toWorld(c, [0, shapeHeight(c.spec.shape), 0])\n\n /** A container whose opening the jet passes through before it lands (pouring into a cup). */\n const catcher = (s: StreamInt, landingT: number): { container: ContainerInt; t: number; point: Vec3 } | null => {\n let best: { container: ContainerInt; t: number; point: Vec3 } | null = null\n for (const oc of containers.values()) {\n if (oc.id === s.container || oc.closed || oc.liters >= oc.spec.capacity) continue\n const lip = lipCenterWorld(oc)\n const disc = s.velocity[1] * s.velocity[1] - 2 * gravity * (lip[1] - s.origin[1])\n if (disc < 0) continue\n const t = (s.velocity[1] + Math.sqrt(disc)) / gravity\n if (t <= 0 || t >= landingT || (best && t >= best.t)) continue\n const p = ballistic(s.origin, s.velocity, gravity, t)\n if (Math.hypot(p[0] - lip[0], p[2] - lip[2]) <= lipRadius(oc.spec.shape, oc.spec.opening) + 0.01) best = { container: oc, t, point: p }\n }\n return best\n }\n\n const stepStream = (s: StreamInt, dt: number): void => {\n const hit = trace(landingSurfaces(), groundAt, s.origin, s.velocity, gravity)\n const caught = catcher(s, hit ? hit.t : MAX_FLIGHT)\n if (caught) {\n s.landing = caught.point\n s.flightTime = caught.t\n if (!s.visualOnly) fillInternal(caught.container, s.liquid, s.rate * dt, s.temperature, false)\n return\n }\n s.landing = hit ? copy3(hit.point) : null\n s.flightTime = hit ? hit.t : MAX_FLIGHT\n if (!hit || s.visualOnly) return\n const speed = length(hit.velocity)\n if (time - s.lastSplash >= 0.12) {\n s.lastSplash = time\n emit({ type: 'splash', liquid: s.liquid, point: copy3(hit.point), intensity: clamp(0.15 + s.rate * 1.2 + speed * 0.05, 0, 1) })\n }\n deposit(s.liquid, hit, s.rate * dt, hit.velocity)\n }\n\n // ---- containers ----\n\n const spillRate = (c: ContainerInt, def: LiquidDef, h: number): number => {\n const ro = lipRadius(c.spec.shape, c.spec.opening)\n const area = 2 * ro * Math.min(h, ro)\n return Math.max(0.6 * area * Math.sqrt(2 * gravity * h) * 1000 * viscScale(def), 0.004)\n }\n\n const steamThreshold = (def: LiquidDef): number => def.steamC ?? (def.drink && def.drink.thirst > 0 ? 60 : Infinity)\n\n const stepContainer = (c: ContainerInt, dt: number): void => {\n // Slosh: the surface tilts towards the horizontal acceleration and settles with a damped spring.\n if (c.hasPrev && dt > 0) {\n const ax = (c.velocity[0] - c.prevVelocity[0]) / dt\n const az = (c.velocity[2] - c.prevVelocity[2]) / dt\n const tx = clamp(ax / gravity, -0.35, 0.35)\n const tz = clamp(az / gravity, -0.35, 0.35)\n const w = 9\n const z = 0.12\n c.slosh[2] += (w * w * (tx - c.slosh[0]) - 2 * z * w * c.slosh[2]) * dt\n c.slosh[3] += (w * w * (tz - c.slosh[1]) - 2 * z * w * c.slosh[3]) * dt\n } else {\n c.slosh[2] *= 0.5\n c.slosh[3] *= 0.5\n }\n c.slosh[0] += c.slosh[2] * dt\n c.slosh[1] += c.slosh[3] * dt\n if (Math.abs(c.slosh[0]) + Math.abs(c.slosh[1]) + Math.abs(c.slosh[2]) + Math.abs(c.slosh[3]) < 1e-5) c.slosh = [0, 0, 0, 0]\n c.prevVelocity = copy3(c.velocity)\n c.hasPrev = true\n\n // Cooling towards ambient (insulated containers 10× slower).\n if (c.temperature !== ambientC) {\n const tau = (600 + 2400 * c.liters) * (c.spec.insulated ? 10 : 1)\n c.temperature = ambientC + (c.temperature - ambientC) * Math.exp(-dt / tau)\n if (Math.abs(c.temperature - ambientC) < 0.01) c.temperature = ambientC\n }\n\n refreshLevel(c)\n const def = defOf(c)\n\n const steaming = !!def && c.liters > 1e-6 && !c.closed && c.temperature > steamThreshold(def)\n if (steaming !== c.steaming) {\n c.steaming = steaming\n emit({ type: 'steam', container: c.id, on: steaming })\n }\n\n c.outflow = 0\n if (!def || c.liters <= 1e-6) {\n for (const key of Object.keys(c.streams)) endStreamKey(c, key)\n c.pourTTL = 0\n settle(c)\n return\n }\n\n // Pour (driven by `pour()`), else spill over the lip when the tilted surface rises above it.\n if (c.pourTTL > 0) {\n c.pourTTL -= dt\n if (c.pourTTL > 0) {\n const flow = lipFlow(c, 0.05)\n syncStream(c, 'pour', 'pour', c.pourRate, flow.origin, flow.velocity, c.pourVisual)\n c.outflow += c.pourRate\n } else endStreamKey(c, 'pour')\n endStreamKey(c, 'spill')\n } else {\n endStreamKey(c, 'pour')\n const lip = lipOf(c.spec.shape, c.spec.opening, c.u)\n const h = c.d - lip.level\n let handled = false\n if (!c.closed && h > 1e-5) {\n const excess = c.liters - c.spec.capacity * planeFraction(c.cols, c.u, lip.level)\n if (excess > 1e-6) {\n const rate = Math.min(spillRate(c, def, h), excess / Math.max(dt, 1e-6))\n removeLiters(c, Math.min(rate * dt, excess, c.liters))\n const flow = lipFlow(c, h)\n syncStream(c, 'spill', 'spill', rate, flow.origin, flow.velocity)\n c.outflow += rate\n handled = true\n }\n }\n if (!handled) endStreamKey(c, 'spill')\n }\n\n // Holes leak by Torricelli with the head above each hole.\n for (let i = 0; i < c.holes.length; i++) {\n const hole = c.holes[i]\n const key = `leak:${i}`\n const hh = dot(c.u, hole.point)\n const head = c.d - hh\n if (c.liters > 1e-6 && head > 1e-4) {\n const area = Math.PI * (hole.diameter / 2) ** 2\n const natural = 0.6 * area * Math.sqrt(2 * gravity * head) * 1000 * viscScale(def)\n const avail = c.liters - c.spec.capacity * planeFraction(c.cols, c.u, hh)\n if (avail > 1e-7) {\n const rate = Math.min(natural, avail / Math.max(dt, 1e-6))\n removeLiters(c, Math.min(rate * dt, avail))\n const nW = normalize(quatRotate(c.rotation, hole.normal))\n const v = Math.min(3, 0.6 * Math.sqrt(2 * gravity * head))\n syncStream(c, key, 'leak', rate, toWorld(c, hole.point), [nW[0] * v, nW[1] * v - 0.05, nW[2] * v])\n c.outflow += rate\n continue\n }\n }\n endStreamKey(c, key)\n }\n if (c.holes.length > 0 || c.outflow > 0) refreshLevel(c)\n settle(c)\n }\n\n const step = (dt: number): void => {\n time += dt\n for (const c of [...containers.values()]) stepContainer(c, dt)\n for (const s of [...streams.values()]) stepStream(s, dt)\n for (const st of [...stains.values()]) {\n const def = liquids.get(st.liquid)\n if (!def) continue\n runOff(st, def)\n const status = stepStain(st, def, surfaceFor(st.surface), ambientC, dt)\n if (status === 'dried_mark') emit({ type: 'dried', stain: st.id, mark: true })\n else if (status === 'dried_gone') {\n stains.delete(st.id)\n emit({ type: 'dried', stain: st.id, mark: false })\n }\n }\n }\n\n // ---- public state views ----\n\n const stateOf = (c: ContainerInt): ContainerState => ({\n id: c.id,\n liquid: c.liquid,\n liters: c.liters,\n capacity: c.spec.capacity,\n temperature: c.temperature,\n closed: c.closed,\n surfaceHeight: c.liters > 0 ? c.d : 0,\n surfacePoint: add(c.position, scale(c.normal, c.liters > 0 ? c.d : 0)),\n surfaceNormal: copy3(c.normal),\n holes: c.holes.map((h) => ({ point: copy3(h.point), normal: copy3(h.normal), diameter: h.diameter })),\n outflow: c.outflow,\n steaming: c.steaming,\n shape: c.spec.shape,\n lipRadius: lipRadius(c.spec.shape, c.spec.opening),\n position: copy3(c.position),\n rotation: [...c.rotation] as Quat,\n })\n\n const streamView = (s: StreamInt): StreamState => ({\n id: s.id,\n liquid: s.liquid,\n cause: s.cause,\n container: s.container,\n tap: s.tap,\n origin: copy3(s.origin),\n velocity: copy3(s.velocity),\n rate: s.rate,\n landing: s.landing ? copy3(s.landing) : null,\n thin: s.thin,\n flightTime: s.flightTime,\n })\n\n const stainView = (s: StainInt): StainState => ({\n id: s.id,\n surface: s.surface,\n liquid: s.liquid,\n center: copy3(s.center),\n front: [...s.front],\n liters: s.liters,\n soaked: s.soaked,\n wetness: s.wetness,\n wetRadius: s.wetRadius,\n normal: copy3(s.normal),\n tangent: copy3(s.tangent),\n flow: s.flow ? copy3(s.flow) : undefined,\n mark: s.mark,\n age: s.age,\n tint: s.tint ? { ...s.tint } : undefined,\n })\n\n // ---- world API ----\n\n const world: FluidWorld = {\n liquids,\n gravity,\n describe: (event) => describeEvent(strings, event),\n\n addContainer(spec, opts = {}) {\n const id = opts.id ?? `container_${++counters.container}`\n if (containers.has(id)) world.removeContainer(id)\n const liquid = spec.liquid && liquids.has(spec.liquid) ? spec.liquid : null\n const liters = liquid ? clamp(spec.liters ?? 0, 0, spec.capacity) : 0\n const c: ContainerInt = {\n id,\n spec: clone(spec),\n cols: makeColumns(spec.shape),\n liquid: liters > 0 ? liquid : null,\n liters,\n temperature: spec.temperature ?? ambientC,\n closed: spec.closed ?? spec.opening <= 0,\n position: copy3(opts.position ?? [0, 0, 0]),\n rotation: opts.rotation ? ([...opts.rotation] as Quat) : [0, 0, 0, 1],\n velocity: [0, 0, 0],\n prevVelocity: [0, 0, 0],\n hasPrev: false,\n holes: [],\n slosh: [0, 0, 0, 0],\n normal: [0, 1, 0],\n u: [0, 1, 0],\n d: 0,\n steaming: false,\n outflow: 0,\n streams: {},\n pourRate: 0,\n pourTTL: 0,\n pourVisual: false,\n lastMix: -10,\n }\n containers.set(id, c)\n refreshLevel(c)\n return id\n },\n\n addTap(spec) {\n const id = spec.id ?? `tap_${++counters.tap}`\n if (taps.has(id)) world.removeTap(id)\n const d = spec.direction ?? [0, -1, 0]\n const len = Math.hypot(d[0], d[1], d[2]) || 1\n const t: TapInt = {\n id,\n position: copy3(spec.position),\n direction: [d[0] / len, d[1] / len, d[2] / len],\n liquid: spec.liquid,\n rate: Math.max(0, spec.rate),\n temperature: spec.temperature ?? ambientC,\n on: false,\n }\n taps.set(id, t)\n if (spec.on ?? true) world.setTap(id, true)\n return id\n },\n\n setTap(id, on, rate) {\n const t = taps.get(id)\n if (!t) return\n if (rate !== undefined) t.rate = Math.max(0, rate)\n const changed = t.on !== on\n t.on = on\n syncTap(t)\n if (changed) emit({ type: 'tap', tap: id, on })\n },\n\n removeTap(id) {\n const t = taps.get(id)\n if (!t) return\n t.on = false\n syncTap(t)\n taps.delete(id)\n },\n\n taps: () => [...taps.values()].map((t) => ({ id: t.id, position: copy3(t.position), direction: copy3(t.direction), liquid: t.liquid, rate: t.rate, temperature: t.temperature, on: t.on, stream: t.stream })),\n\n removeContainer(id) {\n const c = containers.get(id)\n if (!c) return\n for (const key of Object.keys(c.streams)) endStreamKey(c, key)\n containers.delete(id)\n },\n\n setTransform(id, position, rotation, velocity) {\n const c = containers.get(id)\n if (!c) return\n c.position = copy3(position)\n c.rotation = [...rotation] as Quat\n if (velocity) c.velocity = copy3(velocity)\n refreshLevel(c)\n },\n\n open(id) {\n const c = containers.get(id)\n if (c) c.closed = false\n },\n\n close(id) {\n const c = containers.get(id)\n if (!c) return\n c.closed = true\n for (const key of ['pour', 'spill']) endStreamKey(c, key)\n c.pourTTL = 0\n },\n\n fill(id, liquid, liters, temperature) {\n const c = containers.get(id)\n if (!c || c.closed) return 0\n const accepted = fillInternal(c, liquid, liters, temperature, true)\n refreshLevel(c)\n return accepted\n },\n\n pour(id, dt, into) {\n const c = containers.get(id)\n const def = c ? defOf(c) : null\n if (!c || !def || c.closed || c.liters <= 1e-6 || !(dt > 0)) return 0\n refreshLevel(c)\n const lip = lipOf(c.spec.shape, c.spec.opening, c.u)\n const depth = Math.max(0, c.d - planeRange(c.cols, c.u)[0])\n const head = Math.max(c.d - lip.level, 0.02 + 0.5 * depth)\n const ro = lipRadius(c.spec.shape, c.spec.opening)\n const natural = 0.6 * Math.PI * ro * ro * Math.sqrt(2 * gravity * head) * 1000\n const rate = Math.min(natural, 0.15 + 12 * ro) * viscScale(def)\n const out = Math.min(rate * dt, c.liters)\n const target = into ? containers.get(into) : undefined\n let delivered = out\n if (target) {\n delivered = fillInternal(target, c.liquid as LiquidId, out, c.temperature, false)\n refreshLevel(target)\n const overflow = out - delivered\n if (overflow > 1e-6) {\n const flow = lipFlow(c, head)\n const hit = trace(landingSurfaces(), groundAt, flow.origin, flow.velocity, gravity)\n if (hit) deposit(c.liquid as LiquidId, hit, overflow, hit.velocity)\n }\n }\n removeLiters(c, out)\n c.pourRate = out / dt\n c.pourTTL = Math.max(0.12, dt * 1.5)\n c.pourVisual = !!target\n const flow = lipFlow(c, head)\n syncStream(c, 'pour', 'pour', c.pourRate, flow.origin, flow.velocity, c.pourVisual)\n refreshLevel(c)\n settle(c)\n return out\n },\n\n drink(id, liters, options) {\n const c = containers.get(id)\n const def = c ? defOf(c) : null\n if (!c || !def || c.closed || c.liters <= 1e-6 || !(liters > 0)) return null\n const amount = Math.min(liters, c.liters)\n removeLiters(c, amount)\n const event: Extract<FluidEvent, { type: 'drink' }> = {\n type: 'drink',\n container: c.id,\n liquid: def.id,\n liters: amount,\n temperature: c.temperature,\n thirst: (def.drink?.thirst ?? 0) * amount,\n effects: options?.eaten ? [] : [...(def.drink?.effects ?? [])],\n burn: c.temperature > 65,\n ...(options?.eaten ? { eaten: true } : {}),\n }\n emit(event)\n refreshLevel(c)\n settle(c)\n return event\n },\n\n puncture(id, point, normal, diameter) {\n const c = containers.get(id)\n if (!c || !(diameter > 0) || c.holes.length >= MAX_HOLES) return\n c.holes.push({ point: copy3(point), normal: normalize(normal), diameter })\n },\n\n heat(id, deltaC) {\n const c = containers.get(id)\n if (c) c.temperature = clamp(c.temperature + deltaC, -50, 1000)\n },\n\n addSurface(spec) {\n const basis = makeBasis(spec.normal, spec.tangent)\n surfaces.set(spec.id, {\n ...clone(spec),\n ...basis,\n point: copy3(spec.point),\n half: [spec.halfSize[0], spec.halfSize[1]],\n rest: { point: copy3(spec.point), normal: copy3(basis.normal), tangent: copy3(basis.t1) },\n pose: IDENTITY_POSE,\n })\n },\n\n removeSurface(id) {\n surfaces.delete(id)\n for (const s of [...stains.values()]) if (s.surface === id) stains.delete(s.id)\n },\n\n moveSurface(id, offset) {\n const surface = surfaces.get(id)\n if (surface) poseSurface(surface, { position: add(surface.pose.position, offset), rotation: surface.pose.rotation }, true)\n },\n\n setSurfacePose(id, pose) {\n const surface = surfaces.get(id)\n if (surface) poseSurface(surface, pose, true)\n },\n\n splash(liquid, point, liters, velocity, options) {\n if (!liquids.has(liquid) || !(liters > 0)) return\n const v: Vec3 = velocity ?? [0, -0.1, 0]\n const origin = add(point, [0, 0.02, 0])\n const hit = trace(landingSurfaces(), groundAt, origin, v, gravity)\n if (!hit) return\n emit({ type: 'splash', liquid, point: copy3(hit.point), intensity: clamp(0.3 + liters * 2, 0, 1) })\n deposit(liquid, hit, liters, length(v) > 0.3 ? hit.velocity : null, options?.tint)\n },\n\n clearStains(point, radius) {\n for (const s of [...stains.values()]) {\n if (distance(point, s.center) <= radius + 0.5 * meanRadius(s.front)) {\n stains.delete(s.id)\n emit({ type: 'dried', stain: s.id, mark: false })\n }\n }\n },\n\n update(dt) {\n if (dt > 0) {\n const n = clamp(Math.ceil(dt / MAX_STEP), 1, MAX_SUBSTEPS)\n updating = true\n try {\n for (let i = 0; i < n; i++) step(dt / n)\n } finally {\n updating = false\n }\n }\n const out = queue\n queue = []\n return out\n },\n\n container: (id) => {\n const c = containers.get(id)\n return c ? stateOf(c) : null\n },\n containers: () => [...containers.values()].map(stateOf),\n streams: () => [...streams.values()].map(streamView),\n stains: () => [...stains.values()].map(stainView),\n\n on(type, fn) {\n let set = listeners.get(type)\n if (!set) listeners.set(type, (set = new Set()))\n set.add(fn)\n return () => {\n set?.delete(fn)\n }\n },\n\n serialize() {\n const snapshot: Snapshot = {\n version: 1,\n time,\n rng: rng.state,\n counters: { ...counters },\n containers: [...containers.values()].map((c) => {\n const { cols: _cols, ...rest } = c\n return clone(rest)\n }),\n surfaces: [...surfaces.values()].map((s) => {\n const moved = s.pose !== IDENTITY_POSE\n return clone({ id: s.id, point: s.rest.point, normal: s.rest.normal, halfSize: s.half, tangent: s.rest.tangent, porosity: s.porosity, ...(moved ? { pose: s.pose } : {}) })\n }),\n streams: [...streams.values()].map((s) => clone(s)),\n taps: [...taps.values()].map((t) => clone(t)),\n stains: [...stains.values()].map((s) => clone(s)),\n }\n return snapshot\n },\n\n load(input) {\n const snap = clone(input) as Snapshot\n if (!snap || snap.version !== 1) throw new Error('game-fluids: unsupported snapshot')\n time = snap.time\n rng = new Rng(0)\n rng.state = snap.rng\n counters.container = snap.counters.container\n counters.stream = snap.counters.stream\n counters.stain = snap.counters.stain\n containers = new Map()\n for (const raw of snap.containers) containers.set(raw.id, { ...raw, cols: makeColumns(raw.spec.shape) })\n surfaces = new Map()\n for (const { pose, ...spec } of snap.surfaces) {\n world.addSurface(spec)\n const surface = surfaces.get(spec.id)\n if (pose && surface) poseSurface(surface, pose, false)\n }\n counters.tap = snap.counters.tap ?? 0\n streams = new Map(snap.streams.map((s) => [s.id, s]))\n taps = new Map((snap.taps ?? []).map((t) => [t.id, t]))\n stains = new Map(snap.stains.map((s) => [s.id, s]))\n queue = []\n },\n }\n\n return world\n}\n","[\n {\n \"id\": \"sip\",\n \"duration\": 1.2,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.35,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.45,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -0.9,\n 0,\n 0\n ],\n \"action\": \"drink\",\n \"rate\": 0.06\n },\n {\n \"t\": 0.95,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -0.9,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 1.2,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"drink\",\n \"duration\": 2.5,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.5,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.8,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -1.22,\n 0,\n 0\n ],\n \"action\": \"drink\",\n \"rate\": 0.1667\n },\n {\n \"t\": 2.0,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -1.22,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 2.5,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"chug\",\n \"duration\": 4,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.5,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.9,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -1.45,\n 0,\n 0\n ],\n \"action\": \"drink\",\n \"rate\": 0.2\n },\n {\n \"t\": 3.4,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -1.45,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 4,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"eat\",\n \"duration\": 3.6,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.4,\n \"position\": [\n 0.04,\n -0.12,\n -0.28\n ],\n \"rotation\": [\n -0.35,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.6,\n \"position\": [\n 0.04,\n -0.1,\n -0.26\n ],\n \"rotation\": [\n -0.45,\n 0,\n 0\n ],\n \"action\": \"eat\",\n \"rate\": 0.06\n },\n {\n \"t\": 1.3,\n \"position\": [\n 0.04,\n -0.12,\n -0.28\n ],\n \"rotation\": [\n -0.35,\n 0,\n 0\n ],\n \"action\": \"eat\",\n \"rate\": 0.06\n },\n {\n \"t\": 2.0,\n \"position\": [\n 0.04,\n -0.1,\n -0.26\n ],\n \"rotation\": [\n -0.45,\n 0,\n 0\n ],\n \"action\": \"eat\",\n \"rate\": 0.06\n },\n {\n \"t\": 2.7,\n \"position\": [\n 0.04,\n -0.12,\n -0.28\n ],\n \"rotation\": [\n -0.35,\n 0,\n 0\n ],\n \"action\": \"eat\",\n \"rate\": 0.06\n },\n {\n \"t\": 3.1,\n \"position\": [\n 0.04,\n -0.12,\n -0.28\n ],\n \"rotation\": [\n -0.35,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 3.6,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"pour\",\n \"duration\": 3,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.4,\n \"position\": [\n 0.1,\n 0.0,\n -0.35\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.8,\n \"position\": [\n 0.1,\n 0.0,\n -0.35\n ],\n \"rotation\": [\n -1.745,\n 0,\n 0\n ],\n \"action\": \"pour\",\n \"rate\": 1\n },\n {\n \"t\": 2.4,\n \"position\": [\n 0.1,\n 0.0,\n -0.35\n ],\n \"rotation\": [\n -1.745,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 3,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"pour_out\",\n \"duration\": 4,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.5,\n \"position\": [\n 0.1,\n 0.1,\n -0.35\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 1.0,\n \"position\": [\n 0.1,\n 0.1,\n -0.35\n ],\n \"rotation\": [\n -2.2,\n 0,\n 0\n ],\n \"action\": \"pour\",\n \"rate\": 40\n },\n {\n \"t\": 3.2,\n \"position\": [\n 0.1,\n 0.1,\n -0.35\n ],\n \"rotation\": [\n -2.2,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 4,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"open\",\n \"duration\": 1,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.25,\n \"position\": [\n 0.1,\n 0,\n -0.3\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"open\"\n },\n {\n \"t\": 0.7,\n \"position\": [\n 0.1,\n 0,\n -0.3\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 1,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"close\",\n \"duration\": 1,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.25,\n \"position\": [\n 0.1,\n 0,\n -0.3\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"close\"\n },\n {\n \"t\": 0.7,\n \"position\": [\n 0.1,\n 0,\n -0.3\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 1,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"unscrew\",\n \"duration\": 2.6,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.35,\n \"position\": [\n 0.06,\n -0.09,\n -0.34\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"turn\"\n },\n {\n \"t\": 1.95,\n \"position\": [\n 0.06,\n -0.09,\n -0.34\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 2.2,\n \"position\": [\n 0.06,\n -0.09,\n -0.34\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"open\"\n },\n {\n \"t\": 2.6,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n }\n]\n","import itemUsesData from './data/item-uses.json'\nimport { lerp3, quatFromEuler, quatMultiply, quatRotate, add } from './math'\nimport type { FluidEvent, FluidWorld, ItemUseDef, ItemUsePlayer, Quat, Vec3 } from './types'\n\n/** Built-in scripted uses of a held item (data in `data/item-uses.json`): `sip`, `drink`, `chug`, `eat` (spoonfuls from an open tin), `pour`, `pour_out`, `open`, `close`,\n * `unscrew` (the other hand turns a screw cap off, `turn` keys, before the `open` key). */\nexport const ITEM_USES: ItemUseDef[] = itemUsesData as unknown as ItemUseDef[]\n\n/** World transform of the hand (or any holder) the item pose is relative to. */\nexport type HandTransform = () => { position: Vec3; rotation: Quat }\n\nconst DEFAULT_DRINK_RATE = 0.1\n\n/**\n * Plays an item use on a container: interpolates the keys, applies `drink` and `eat` (rate × dt litres) and `pour` (`world.pour`, `rate` multiplies the\n * time) while the current key has that action, and fires `open` / `close` once when their key is reached. When `getHandTransform` is given, the\n * container's world transform follows hand ∘ pose every update; otherwise the host animates the viewmodel from `pose()`.\n */\nexport function createItemUse(world: FluidWorld, containerId: string, def: ItemUseDef, getHandTransform?: HandTransform): ItemUsePlayer {\n const keys = [...def.keys].sort((a, b) => a.t - b.t)\n let time = 0\n let done = keys.length === 0 || def.duration <= 0\n let checked = false\n let lastPos: Vec3 | null = null\n const fired = new Set<number>()\n\n const pose = (): { position: Vec3; rotation: Vec3 } => {\n if (keys.length === 0) return { position: [0, 0, 0], rotation: [0, 0, 0] }\n if (time <= keys[0].t) return { position: [...keys[0].position], rotation: [...keys[0].rotation] }\n for (let i = 0; i < keys.length - 1; i++) {\n const a = keys[i]\n const b = keys[i + 1]\n if (time <= b.t) {\n const k = b.t > a.t ? (time - a.t) / (b.t - a.t) : 1\n return { position: lerp3(a.position, b.position, k), rotation: lerp3(a.rotation, b.rotation, k) }\n }\n }\n const last = keys[keys.length - 1]\n return { position: [...last.position], rotation: [...last.rotation] }\n }\n\n const follow = (dt: number): void => {\n if (!getHandTransform) return\n const hand = getHandTransform()\n const p = pose()\n const position = add(hand.position, quatRotate(hand.rotation, p.position))\n const rotation = quatMultiply(hand.rotation, quatFromEuler(p.rotation[0], p.rotation[1], p.rotation[2]))\n const velocity: Vec3 | undefined =\n lastPos && dt > 0 ? [(position[0] - lastPos[0]) / dt, (position[1] - lastPos[1]) / dt, (position[2] - lastPos[2]) / dt] : undefined\n lastPos = position\n world.setTransform(containerId, position, rotation, velocity)\n }\n\n const player: ItemUsePlayer = {\n def,\n get time() {\n return time\n },\n get done() {\n return done\n },\n pose,\n update(dt) {\n if (done) return []\n const events: FluidEvent[] = []\n const off = world.on('*', (e) => events.push(e))\n try {\n if (!checked) {\n checked = true\n const state = world.container(containerId)\n if (!state || (def.liquids && def.liquids.length > 0 && (!state.liquid || !def.liquids.includes(state.liquid)))) {\n done = true\n return events\n }\n }\n const start = time\n const end = Math.min(def.duration, time + Math.max(0, dt))\n for (let i = 0; i < keys.length && !done; i++) {\n const key = keys[i]\n const spanStart = key.t\n const spanEnd = i + 1 < keys.length ? keys[i + 1].t : def.duration\n if ((key.action === 'open' || key.action === 'close') && !fired.has(i) && end >= spanStart) {\n fired.add(i)\n if (key.action === 'open') world.open(containerId)\n else world.close(containerId)\n }\n const overlap = Math.min(end, spanEnd) - Math.max(start, spanStart)\n if (overlap <= 0) continue\n if (key.action === 'drink' || key.action === 'eat') {\n const ev = world.drink(containerId, (key.rate ?? DEFAULT_DRINK_RATE) * overlap, key.action === 'eat' ? { eaten: true } : undefined)\n const left = world.container(containerId)\n if (!ev || !left || left.liters <= 1e-6) {\n time = def.duration\n done = true\n }\n } else if (key.action === 'pour') {\n world.pour(containerId, overlap * (key.rate ?? 1))\n }\n }\n if (!done) {\n time = end\n done = time >= def.duration\n }\n follow(dt)\n } finally {\n off()\n }\n return events\n },\n cancel() {\n done = true\n },\n }\n return player\n}\n","import type { FilmField, FilmProfile, FilmRandom } from './types'\n\nexport interface DepositContext {\n readonly field: FilmField\n readonly random: FilmRandom\n readonly profile: () => FilmProfile\n}\n\nconst VISIBLE_THICKNESS = 0.035\n\nexport function depositCell(context: DepositContext, rowIn: number, columnIn: number, amount: number): void {\n const { field } = context\n const row = Math.round(rowIn)\n const column = Math.round(columnIn)\n if (row < 0 || column < 0 || row >= field.height || column >= field.width || !(amount > 0)) return\n const index = row * field.width + column\n field.thickness[index]! += amount\n if (amount > 0.02) field.dryness[index]! *= 0.15\n field.dampness[index] = 1\n}\n\nexport function wetCellCount(field: FilmField): number {\n let cells = 0\n for (let index = 0; index < field.thickness.length; index++) if (field.thickness[index]! > VISIBLE_THICKNESS) cells++\n return cells\n}\n\n/** A filled ellipse with a noisy outline; `along` runs along (directionColumn, directionRow) and `across` is the other half axis, `amount` is the thickness at the centre in mm. */\nexport function depositBlob(context: DepositContext, centerRow: number, centerColumn: number, along: number, across: number, directionColumn: number, directionRow: number, amount: number, roughness: number): void {\n const random = context.random\n const phaseA = random() * 6.28\n const phaseB = random() * 6.28\n const phaseC = random() * 6.28\n const phaseD = random() * 6.28\n const reach = Math.ceil(Math.max(along, across) * (1 + roughness) + 1.5)\n for (let row = Math.floor(centerRow - reach); row <= centerRow + reach; row++) {\n for (let column = Math.floor(centerColumn - reach); column <= centerColumn + reach; column++) {\n const dx = column + 0.5 - centerColumn\n const dy = row + 0.5 - centerRow\n const alongDistance = dx * directionColumn + dy * directionRow\n const acrossDistance = -dx * directionRow + dy * directionColumn\n const angle = Math.atan2(acrossDistance / across, alongDistance / along)\n const edge = 1 + roughness * (0.45 * Math.sin(3 * angle + phaseA) + 0.3 * Math.sin(5 * angle + phaseB) + 0.18 * Math.sin(8 * angle + phaseC) + 0.12 * Math.sin(13 * angle + phaseD))\n const squared = ((alongDistance / along) * (alongDistance / along) + (acrossDistance / across) * (acrossDistance / across)) / (edge * edge)\n if (squared < 1) depositCell(context, row, column, amount * Math.sqrt(1 - squared))\n }\n }\n}\n\n/** A tapered stroke from one cell to another. */\nexport function depositStroke(context: DepositContext, fromRow: number, fromColumn: number, toRow: number, toColumn: number, startWidth: number, endWidth: number, amount: number): void {\n const { field } = context\n const length = Math.hypot(toRow - fromRow, toColumn - fromColumn)\n const samples = Math.max(2, Math.ceil(length * 2.5))\n for (let sample = 0; sample <= samples; sample++) {\n const progress = sample / samples\n const row = fromRow + (toRow - fromRow) * progress\n const column = fromColumn + (toColumn - fromColumn) * progress\n const width = startWidth + (endWidth - startWidth) * progress\n const reach = Math.ceil(width + 1)\n for (let cellRow = Math.floor(row - reach); cellRow <= row + reach; cellRow++) {\n for (let cellColumn = Math.floor(column - reach); cellColumn <= column + reach; cellColumn++) {\n if (cellRow < 0 || cellColumn < 0 || cellRow >= field.height || cellColumn >= field.width) continue\n const distance = Math.hypot(cellRow + 0.5 - row, cellColumn + 0.5 - column)\n if (distance >= width) continue\n const index = cellRow * field.width + cellColumn\n const target = amount * (1 - distance / width) * 0.5\n if (field.thickness[index]! < target) depositCell(context, cellRow, cellColumn, target - field.thickness[index]!)\n }\n }\n }\n}\n\n/**\n * The impact: the body is stretched by 1 / sin(angle), with spikes (long only along the travel), satellites and tails.\n * `size` is the radius in cells of the main body; `profile.spikes` below 1 turns the spikes short and the blobs thick.\n */\nexport function depositSplat(context: DepositContext, row: number, column: number, size: number, directionColumn: number, directionRow: number, sinAngleIn: number, amount: number): void {\n const random = context.random\n const spikes = context.profile().spikes\n const sinAngle = Math.max(0.17, Math.min(1, sinAngleIn))\n const stretch = Math.min(5.5, 1 / sinAngle)\n const along = size * Math.pow(stretch, 0.75)\n const across = size / Math.pow(stretch, 0.25)\n const frontRow = row + directionRow * along * 0.25\n const frontColumn = column + directionColumn * along * 0.25\n depositBlob(context, frontRow, frontColumn, along, across, directionColumn, directionRow, amount, 0.1 + 0.12 * (1 - sinAngle) + (size < 1.4 ? 0 : 0.06))\n const sideColumn = -directionRow\n const sideRow = directionColumn\n const spikeCount = Math.round(Math.min(18, (size < 1.2 ? 1 : 4) + size * 1.6 + 5 * (1 - sinAngle)) * spikes)\n for (let spike = 0; spike < spikeCount; spike++) {\n const spread = Math.PI * (0.25 + 0.75 * sinAngle * sinAngle)\n let theta = (random() * 2 - 1) * spread\n if (sinAngle > 0.9) theta = random() * 6.283\n const cosine = Math.cos(theta)\n const sine = Math.sin(theta)\n const dx = cosine * directionColumn + sine * sideColumn\n const dy = cosine * directionRow + sine * sideRow\n const length = size * (0.25 + random() * 0.55) * (1 + 2.6 * (1 - sinAngle) * Math.max(0, cosine)) * (sinAngle > 0.9 ? 0.6 : 1) * (0.5 + 0.5 * spikes)\n const startRow = frontRow + (along * cosine * directionRow + across * sine * sideRow) * 0.75\n const startColumn = frontColumn + (along * cosine * directionColumn + across * sine * sideColumn) * 0.75\n const endRow = startRow + dy * length\n const endColumn = startColumn + dx * length\n depositStroke(context, startRow, startColumn, endRow, endColumn, Math.max(0.55, size * 0.22), 0.42, amount * 0.75)\n if (random() < 0.5) {\n const gap = 1 + random() * 2.2\n depositBlob(context, endRow + dy * gap, endColumn + dx * gap, 0.55 + random() * 0.7, 0.5 + random() * 0.4, dx, dy, amount * 0.55, 0.08)\n }\n }\n const satelliteCount = Math.round((1 + size * 0.9) * (1.4 - sinAngle * 0.6) * (0.5 + 0.5 * spikes))\n for (let satellite = 0; satellite < satelliteCount; satellite++) {\n const cone = sinAngle > 0.9 ? Math.PI : 0.18 + 0.6 * sinAngle\n const theta = (random() * 2 - 1) * cone\n const cosine = Math.cos(theta)\n const sine = Math.sin(theta)\n const dx = cosine * directionColumn + sine * sideColumn\n const dy = cosine * directionRow + sine * sideRow\n const distance = along + size * (0.8 + random() * 3.2)\n const radius = 0.45 + random() * Math.min(1.2, size * 0.22)\n const satelliteRow = frontRow + dy * distance\n const satelliteColumn = frontColumn + dx * distance\n depositBlob(context, satelliteRow, satelliteColumn, radius * Math.sqrt(stretch), radius, dx, dy, amount * 0.6, 0.08)\n if (sinAngle < 0.8) depositStroke(context, satelliteRow + dy * radius * stretch * 0.7, satelliteColumn + dx * radius * stretch * 0.7, satelliteRow + dy * radius * stretch * 1.8, satelliteColumn + dx * radius * stretch * 1.8, 0.5, 0.3, amount * 0.35)\n }\n}\n","import type { Vec3 } from '../types'\nimport { depositBlob, depositSplat } from './deposit'\nimport type { DepositContext } from './deposit'\nimport type { FilmDropState, FilmLayout } from './types'\n\nconst GRAVITY = 9.8\nconst AIR_DRAG = 0.25\nconst MIN_SIZE_CELLS = 0.6\n\nexport interface DropPool {\n readonly state: FilmDropState\n launch(position: Vec3, velocity: Vec3, radius: number): void\n update(dt: number): void\n clear(): void\n}\n\n/** Drops in flight: a ring of slots (the oldest is overwritten), a ballistic flight and a landing that makes an impact shaped by the angle and direction (F250-278). */\nexport function createDropPool(layout: FilmLayout, context: DepositContext): DropPool {\n const capacity = layout.rules.dropCapacity\n let cursor = 0\n const state: FilmDropState = {\n capacity,\n get launched() {\n return cursor\n },\n active: new Uint8Array(capacity),\n position: new Float64Array(capacity * 3),\n velocity: new Float64Array(capacity * 3),\n radius: new Float64Array(capacity),\n }\n const { active, position, velocity, radius } = state\n const cellMillimetres = layout.cellSize * 1000\n const previous: Vec3 = [0, 0, 0]\n const point: Vec3 = [0, 0, 0]\n const speed: Vec3 = [0, 0, 0]\n\n function land(region: number, dropRadius: number): void {\n const profile = context.profile()\n const impact = layout.impact(region, point, speed)\n const [alongColumn, alongRow] = impact.along\n const travel = Math.hypot(alongColumn, alongRow) || 1e-6\n const sinAngle = Math.abs(impact.normalSpeed) / Math.hypot(travel, impact.normalSpeed)\n const volume = ((4 / 3) * Math.PI * dropRadius * dropRadius * dropRadius) / (cellMillimetres * cellMillimetres) * (dropRadius > 3 ? 7 : 4) * profile.volume\n const totalSpeed = Math.sqrt(speed[0] * speed[0] + speed[1] * speed[1] + speed[2] * speed[2])\n const size = Math.max(MIN_SIZE_CELLS, (dropRadius * 2) / cellMillimetres * (1 + 0.2 * totalSpeed))\n const amount = Math.min(profile.maxAmount, Math.max(0.25, volume / ((Math.PI * size * size * 1.6) / (sinAngle < 0.3 ? 0.6 : 1))))\n if (profile.landsAsBlob) {\n depositBlob(context, impact.row, impact.column, size * 1.3, size * 1.1, alongColumn / travel, alongRow / travel, amount, 0.2)\n return\n }\n depositSplat(context, impact.row, impact.column, size, alongColumn / travel, alongRow / travel, sinAngle, amount)\n }\n\n return {\n state,\n launch(origin, direction, dropRadius) {\n const slot = cursor++ % capacity\n const offset = slot * 3\n active[slot] = 1\n position[offset] = origin[0]\n position[offset + 1] = origin[1]\n position[offset + 2] = origin[2]\n velocity[offset] = direction[0]\n velocity[offset + 1] = direction[1]\n velocity[offset + 2] = direction[2]\n radius[slot] = dropRadius\n },\n update(dt) {\n for (let slot = 0; slot < capacity; slot++) {\n if (!active[slot]) continue\n const offset = slot * 3\n previous[0] = position[offset]!\n previous[1] = position[offset + 1]!\n previous[2] = position[offset + 2]!\n velocity[offset + 1]! -= GRAVITY * dt\n const drag = 1 - dt * AIR_DRAG\n velocity[offset]! *= drag\n velocity[offset + 1]! *= drag\n velocity[offset + 2]! *= drag\n point[0] = position[offset]! + velocity[offset]! * dt\n point[1] = position[offset + 1]! + velocity[offset + 1]! * dt\n point[2] = position[offset + 2]! + velocity[offset + 2]! * dt\n const region = layout.collide(previous, point)\n position[offset] = point[0]\n position[offset + 1] = point[1]\n position[offset + 2] = point[2]\n if (region >= 0) {\n if (layout.contains(point)) {\n speed[0] = velocity[offset]!\n speed[1] = velocity[offset + 1]!\n speed[2] = velocity[offset + 2]!\n land(region, radius[slot]!)\n }\n active[slot] = 0\n continue\n }\n if (layout.escaped(point)) active[slot] = 0\n }\n },\n clear() {\n active.fill(0)\n },\n }\n}\n","import type { FilmAdvanceInput, FilmBounds, FilmField, FilmLayout, FilmProfile, FilmSimulator, FilmWeather } from './types'\n\nexport interface CpuSimulatorOptions {\n /** Flow steps per second of real time (the pages use 180). */\n stepRate: number\n /** Most flow steps in one advance (6 in the Fluid Standard, 9 in the Workshop). */\n maxSteps: number\n weather: () => FilmWeather\n}\n\nconst RAIN_SPREAD = 0.5\nconst BOUNDS_MARGIN = 8\n\n/**\n * The thin-film step of the Fluid Standard (F94-114), literal: only film above the pin moves, a dry cell needs the front thickness,\n * walls run sideways at 0.22 and the flow is limited to the wet bounding box. Drying starts from the thin edge.\n */\nexport function createCpuSimulator(field: FilmField, layout: FilmLayout, profileOf: () => FilmProfile, options: CpuSimulatorOptions): FilmSimulator {\n const { width, height, thickness, dryness, dampness } = field\n const { bed, pin: pinning, vertical } = layout\n const delta = new Float32Array(width * height)\n const bounds: FilmBounds = { firstRow: 0, lastRow: -1, firstColumn: 0, lastColumn: -1 }\n let accumulated = 0\n\n function refreshBounds(): void {\n let firstRow = height\n let lastRow = -1\n let firstColumn = width\n let lastColumn = -1\n for (let row = 0; row < height; row++) {\n const offset = row * width\n let isWet = false\n for (let column = 0; column < width; column++) {\n if (thickness[offset + column]! > 0) {\n isWet = true\n if (column < firstColumn) firstColumn = column\n if (column > lastColumn) lastColumn = column\n }\n }\n if (isWet) {\n if (row < firstRow) firstRow = row\n lastRow = row\n }\n }\n if (lastRow < 0) {\n bounds.firstRow = 0\n bounds.lastRow = -1\n bounds.firstColumn = 0\n bounds.lastColumn = -1\n return\n }\n bounds.firstRow = Math.max(0, firstRow - BOUNDS_MARGIN)\n bounds.lastRow = Math.min(height - 1, lastRow + BOUNDS_MARGIN)\n bounds.firstColumn = Math.max(0, firstColumn - BOUNDS_MARGIN)\n bounds.lastColumn = Math.min(width - 1, lastColumn + BOUNDS_MARGIN)\n }\n\n const mobility = (index: number): number => {\n const dry = dryness[index]!\n return dry < 0.25 ? 1 : dry > 0.6 ? 0 : 1 - (dry - 0.25) / 0.35\n }\n\n function flowStep(): void {\n const { firstRow, lastRow, firstColumn, lastColumn } = bounds\n if (lastRow < 0) return\n const profile = profileOf()\n const flow = profile.flow * (1 + RAIN_SPREAD * options.weather().rain)\n const referenceSquared = profile.referenceThickness * profile.referenceThickness\n const slopeCap = profile.slopeCap\n const pinLevel = profile.pin\n const front = profile.front\n for (let row = firstRow; row <= lastRow; row++) {\n const offset = row * width\n for (let column = firstColumn; column <= lastColumn; column++) delta[offset + column] = 0\n }\n for (let row = firstRow; row <= lastRow; row++) {\n const offset = row * width\n for (let column = firstColumn; column <= lastColumn; column++) {\n const index = offset + column\n const own = thickness[index]!\n for (let edge = 0; edge < 2; edge++) {\n let neighbour: number\n if (edge === 0) {\n if (column >= lastColumn) continue\n neighbour = index + 1\n } else {\n if (row >= lastRow) continue\n neighbour = index + width\n }\n const other = thickness[neighbour]!\n if (own < 0.005 && other < 0.005) continue\n let bedDrop = bed[index]! - bed[neighbour]!\n if (bedDrop > slopeCap) bedDrop = slopeCap\n else if (bedDrop < -slopeCap) bedDrop = -slopeCap\n let head = bedDrop + own - other\n let source = index\n let destination = neighbour\n if (head < 0) {\n head = -head\n source = neighbour\n destination = index\n }\n const sourceThickness = thickness[source]!\n const verticalFactor = vertical[source]!\n const pinThreshold = pinLevel * pinning[source]! * (verticalFactor < 1 ? 0.5 : 1)\n if (sourceThickness <= pinThreshold) continue\n if (thickness[destination]! < 0.03 && sourceThickness < front * pinning[source]! * verticalFactor) continue\n const mobile = mobility(source)\n if (mobile <= 0) continue\n let moved = flow * mobile * ((sourceThickness * sourceThickness) / (sourceThickness * sourceThickness + referenceSquared)) * head * (verticalFactor < 1 ? (edge === 0 ? 0.22 : 1) : 4)\n const limit = (sourceThickness - pinThreshold) * 0.24\n if (moved > limit) moved = limit\n delta[source]! -= moved\n delta[destination]! += moved\n }\n }\n }\n for (let row = firstRow; row <= lastRow; row++) {\n const offset = row * width\n for (let column = firstColumn; column <= lastColumn; column++) {\n const index = offset + column\n let next = thickness[index]! + delta[index]!\n if (next < 1e-4) next = 0\n else dampness[index] = 1\n thickness[index] = next\n }\n }\n }\n\n function age(dryingSeconds: number): void {\n const { firstRow, lastRow, firstColumn, lastColumn } = bounds\n if (lastRow < 0) return\n const profile = profileOf()\n const rainScale = 1 - options.weather().rain\n const seconds = dryingSeconds * rainScale * (options.weather().drying ?? 1)\n for (let row = firstRow; row <= lastRow; row++) {\n const offset = row * width\n for (let column = firstColumn; column <= lastColumn; column++) {\n const index = offset + column\n const own = thickness[index]!\n if (own > 0) {\n const thin = 1 - Math.min(1, own / 1.6)\n if (profile.dryTime > 0 && dryness[index]! < 1) dryness[index] = Math.min(1, dryness[index]! + (seconds / profile.dryTime) * (0.45 + 1.7 * thin))\n if (profile.evaporation > 0) {\n const next = own - profile.evaporation * seconds * (0.5 + 1.5 * thin)\n thickness[index] = next > 0.004 ? next : 0\n }\n } else if (dampness[index]! > 0) {\n dampness[index] = Math.max(0, dampness[index]! - seconds / (profile.evaporation > 0 ? 25 : 1e9))\n }\n }\n }\n }\n\n return {\n bounds,\n refreshBounds,\n advance({ dt, dryingSeconds }: FilmAdvanceInput): number {\n accumulated += dt\n let steps = 0\n refreshBounds()\n while (accumulated >= 1 / options.stepRate && steps < options.maxSteps) {\n flowStep()\n accumulated -= 1 / options.stepRate\n steps++\n }\n if (steps === options.maxSteps) accumulated = 0\n age(dryingSeconds)\n return steps\n },\n resetClock() {\n accumulated = 0\n },\n }\n}\n","import type { Vec3 } from '../types'\nimport { depositCell } from './deposit'\nimport type { DepositContext } from './deposit'\nimport type { FilmBead, FilmDrag, FilmDrip, FilmLayout, FilmRandom, FilmSource } from './types'\n\ntype Launch = (position: Vec3, velocity: Vec3, radius: number) => void\n\nconst range = (random: FilmRandom, from: number, to: number): number => from + random() * (to - from)\n\n/** The drip (F282, W-style): a bead swells at the fingertip, detaches and falls. Updates `bead` for the renderer and returns nothing. */\nexport function updateDrip(drip: FilmDrip | undefined, bead: FilmBead, layout: FilmLayout, random: FilmRandom, launch: Launch, dt: number): void {\n if (!drip) {\n bead.visible = false\n return\n }\n drip.elapsed += dt\n const swell = Math.min(1, drip.elapsed / drip.every)\n const radius = drip.radius * (0.35 + 0.65 * swell)\n const isWorkshop = layout.rules.dripStyle === 'workshop'\n bead.visible = true\n bead.swell = swell\n bead.radius = radius\n bead.position[0] = drip.position[0]\n bead.position[1] = drip.position[1] + (isWorkshop ? -radius * 0.0012 * (1 + swell * 0.7) : -radius * 0.0012)\n bead.position[2] = drip.position[2]\n if (drip.elapsed < drip.every) return\n const origin: Vec3 = [bead.position[0], bead.position[1] + -radius * 0.001, bead.position[2]]\n if (isWorkshop) {\n const sideX = range(random, -0.025, 0.025)\n const sideZ = range(random, -0.025, 0.025)\n launch(origin, [sideX, -0.2, sideZ], drip.radius * range(random, 0.85, 1.15))\n drip.elapsed = 0\n drip.every = drip.base * range(random, 0.75, 1.25)\n return\n }\n const sideX = (random() - 0.5) * 0.05\n const sideZ = (random() - 0.5) * 0.05\n launch(origin, [sideX, -0.2, sideZ], drip.radius * (0.85 + random() * 0.3))\n drip.elapsed = 0\n drip.every = drip.base * (0.75 + random() * 0.5)\n}\n\n/** Continuous sources (a wound at the feet, a tipped can): a pulsing thickness added over a small disc (F288). */\nexport function updateSources(sources: readonly FilmSource[], context: DepositContext, dt: number): void {\n const random = context.random\n for (const source of sources) {\n source.elapsed += dt\n if (source.elapsed < 0 || source.elapsed > source.duration) continue\n const pulse = 0.6 + 0.4 * Math.max(0, Math.sin(source.elapsed * 5.2))\n const amount = source.rate * dt * pulse\n for (let part = 0; part < 3; part++) {\n const angle = random() * 6.28\n const distance = random() * source.radius\n depositCell(context, source.row + Math.sin(angle) * distance, source.column + Math.cos(angle) * distance, amount / 3)\n }\n }\n}\n\n/** Drag smears (F291): a striped band that loses load and crumbles at the end, with side drops stretched along the travel. */\nexport function updateDrags(drags: readonly FilmDrag[], context: DepositContext, layout: FilmLayout, launch: Launch, dt: number): void {\n const random = context.random\n for (const drag of drags) {\n if (drag.done) continue\n drag.elapsed += dt\n const progress = Math.min(1, drag.elapsed / drag.duration)\n const here = drag.path(progress)\n const ahead = drag.path(Math.min(1, progress + 0.01))\n let directionColumn = ahead.column - here.column\n let directionRow = ahead.row - here.row\n const length = Math.hypot(directionColumn, directionRow) || 1\n directionColumn /= length\n directionRow /= length\n const sideColumn = -directionRow\n const sideRow = directionColumn\n const load = Math.pow(1 - progress, 1.3)\n for (let offset = -drag.width; offset <= drag.width; offset += 0.5) {\n const across = offset / drag.width\n const stripe = drag.stripes[Math.round((offset + drag.width) * 2)]!\n const edge = 1 - across * across\n const amount = drag.amount * load * (0.25 + 0.75 * stripe) * edge\n if (load < 0.45 && random() > load * 2.2) continue\n depositCell(context, Math.round(here.row + sideRow * offset), Math.round(here.column + sideColumn * offset), amount * dt * 30)\n }\n if (drag.hand && random() < dt * 14 * load + 0.02) {\n const world = layout.cellToWorld(here.row, here.column)\n const origin: Vec3 = [world[0] + (random() - 0.5) * 0.06, drag.hand.height + random() * 0.3, world[2] + (random() - 0.5) * 0.06]\n const velocity: Vec3 = [directionColumn * drag.hand.speed, 0 * drag.hand.speed, directionRow * drag.hand.speed]\n velocity[0] += (random() - 0.5) * 0.3\n velocity[1] += 0.2\n velocity[2] += (random() - 0.5) * 0.3\n launch(origin, velocity, 2 + random() * 2.2)\n }\n if (progress >= 1) drag.done = true\n }\n}\n","import { depositBlob, depositCell, depositSplat, depositStroke, wetCellCount } from './deposit'\nimport type { DepositContext } from './deposit'\nimport { createDropPool } from './drops'\nimport { createCpuSimulator } from './simulate'\nimport { updateDrags, updateDrip, updateSources } from './sources'\nimport type { Film, FilmField, FilmOptions, FilmProfile, FilmWeather } from './types'\n\nconst DEFAULT_STEP_RATE = 180\nconst DEFAULT_MAX_STEPS = 6\n/** The visor's `ZG.wipe`: rain removes only the stain that is less than half dry. */\nconst WASH_BELOW_DRYNESS = 0.5\n\n/**\n * A running film of one liquid over one layout: drops land as impacts, a drip, sources and drag smears add to it, and a 180 Hz\n * thin-film step spreads it limited to the wet box, at most `maxSteps` per frame. It never calls `Math.random`: the host gives the random stream.\n */\nexport function createFilm(options: FilmOptions): Film {\n const { layout, random } = options\n const cellCount = layout.width * layout.height\n const field: FilmField = {\n width: layout.width,\n height: layout.height,\n thickness: new Float32Array(cellCount),\n dryness: new Float32Array(cellCount),\n dampness: new Float32Array(cellCount),\n }\n let weatherState: FilmWeather = { rain: 0, drying: 1 }\n let currentProfile: FilmProfile = options.profile\n const context: DepositContext = { field, random, profile: () => currentProfile }\n const drops = createDropPool(layout, context)\n const createSimulator = options.simulator ?? createCpuSimulator\n const simulator = createSimulator(field, layout, () => currentProfile, {\n stepRate: options.stepRate ?? DEFAULT_STEP_RATE,\n maxSteps: options.maxSteps ?? DEFAULT_MAX_STEPS,\n weather: () => weatherState,\n })\n\n const film: Film = {\n layout,\n field,\n drops: drops.state,\n bead: { visible: false, position: [0, 0, 0], radius: 0, swell: 0 },\n simulator,\n get profile() {\n return currentProfile\n },\n set profile(profile: FilmProfile) {\n currentProfile = profile\n },\n drip: undefined,\n sources: [],\n drags: [],\n launch: (position, velocity, radius) => drops.launch(position, velocity, radius),\n splat: (row, column, size, directionColumn, directionRow, sinAngle, amount) => depositSplat(context, row, column, size, directionColumn, directionRow, sinAngle, amount),\n blob: (row, column, along, across, directionColumn, directionRow, amount, roughness) => depositBlob(context, row, column, along, across, directionColumn, directionRow, amount, roughness),\n stroke: (fromRow, fromColumn, toRow, toColumn, startWidth, endWidth, amount) => depositStroke(context, fromRow, fromColumn, toRow, toColumn, startWidth, endWidth, amount),\n deposit: (row, column, amount) => depositCell(context, row, column, amount),\n update({ dt, dryingSeconds }) {\n drops.update(dt)\n updateDrip(film.drip, film.bead, layout, random, drops.launch, dt)\n updateSources(film.sources, context, dt)\n updateDrags(film.drags, context, layout, drops.launch, dt)\n simulator.advance({ dt, dryingSeconds })\n },\n setWeather(weather) {\n weatherState = {\n rain: Math.min(1, Math.max(0, weather.rain ?? weatherState.rain)),\n drying: Math.max(0, weather.drying ?? weatherState.drying ?? 1),\n }\n },\n weather: () => ({ ...weatherState }),\n wash(maxDryness = WASH_BELOW_DRYNESS) {\n simulator.refreshBounds()\n const { firstRow, lastRow, firstColumn, lastColumn } = simulator.bounds\n let cleared = 0\n for (let row = firstRow; row <= lastRow; row++) {\n for (let column = firstColumn; column <= lastColumn; column++) {\n const index = row * layout.width + column\n if (field.thickness[index]! > 0 && field.dryness[index]! < maxDryness) {\n field.thickness[index] = 0\n field.dryness[index] = 0\n field.dampness[index] = 0\n cleared++\n }\n }\n }\n // the bounds shrink on the next advance, which the grid's upload rectangle (union with the previous one) already covers\n return cleared\n },\n clear() {\n field.thickness.fill(0)\n field.dryness.fill(0)\n field.dampness.fill(0)\n drops.clear()\n film.drip = undefined\n film.bead.visible = false\n film.sources.length = 0\n film.drags.length = 0\n simulator.refreshBounds()\n },\n wetCells: () => wetCellCount(field),\n }\n return film\n}\n","import type { FilmRandom } from './types'\n\nexport type FilmLcg = FilmRandom & { seed: number }\n\n/** The Fluid Standard's generator (LCG 1664525 / 1013904223). `seed` can be read and set, so a scene can be restarted from a number. */\nexport function createFilmLcg(seed: number): FilmLcg {\n const lcg = (() => {\n lcg.seed = (lcg.seed * 1664525 + 1013904223) >>> 0\n return lcg.seed / 4294967296\n }) as FilmLcg\n lcg.seed = seed >>> 0\n return lcg\n}\n","// The product is taken in doubles on purpose (not `Math.imul`): the recorded pages round it the same way, and the grids depend on it.\nexport function hashCell(x: number, y: number): number {\n let value = (x * 374761393 + y * 668265263) | 0\n value = ((value ^ (value >>> 13)) * 1274126177) | 0\n return ((value ^ (value >>> 16)) >>> 0) / 4294967296\n}\n\nexport function valueNoise(x: number, y: number): number {\n const xi = Math.floor(x)\n const yi = Math.floor(y)\n const xf = x - xi\n const yf = y - yi\n const u = xf * xf * (3 - 2 * xf)\n const v = yf * yf * (3 - 2 * yf)\n const a = hashCell(xi, yi)\n const b = hashCell(xi + 1, yi)\n const c = hashCell(xi, yi + 1)\n const d = hashCell(xi + 1, yi + 1)\n return a + (b - a) * u + (c - a) * v + (a - b - c + d) * u * v\n}\n","import type { Vec3 } from '../types'\nimport { hashCell, valueNoise } from './noise'\nimport type { FilmImpact, FilmLayout, FilmRegion, FilmRules } from './types'\n\nexport interface FoldedLayoutParams {\n id: string\n columns: number\n /** Metres per cell. */\n cellSize: number\n /** World x of the left edge. */\n originX: number\n wallRows: number\n sidewalkRows: number\n curbRows: number\n roadRows: number\n /** World y of the top of the wall strip and of the sidewalk and road planes. */\n wallTopY: number\n sidewalkY: number\n roadY: number\n /** World z of the wall plane (the sidewalk starts here and runs towards +z). */\n wallZ: number\n /** Metres the curb face drops per row. Default `(sidewalkY - roadY) / curbRows`. */\n curbStep?: number\n /** x that the road's cross slope is measured from (the road falls `5 mm / m` towards +x from here). */\n roadSlopeAnchorX: number\n rules: FilmRules\n}\n\nconst REGION_NAMES = ['wall', 'sidewalk', 'curb', 'road'] as const\n\nconst dot3 = (a: Vec3, b: Vec3): number => a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n\nfunction impactOf(region: FilmRegion, position: Vec3, velocity: Vec3, cellSize: number): FilmImpact {\n const local: Vec3 = [position[0] - region.origin[0], position[1] - region.origin[1], position[2] - region.origin[2]]\n return {\n row: region.firstRow + dot3(local, region.rowAxis) / cellSize,\n column: dot3(local, region.columnAxis) / cellSize,\n along: [dot3(velocity, region.columnAxis), dot3(velocity, region.rowAxis)],\n normalSpeed: -dot3(velocity, region.normal),\n }\n}\n\nfunction cellToWorldOf(regions: readonly FilmRegion[], cellSize: number, row: number, column: number): Vec3 {\n let region = regions[regions.length - 1]!\n for (const candidate of regions) {\n if (row < candidate.firstRow + candidate.rowCount) {\n region = candidate\n break\n }\n }\n const across = column * cellSize\n const down = (row - region.firstRow) * cellSize\n return [\n region.origin[0] + region.columnAxis[0] * across + region.rowAxis[0] * down,\n region.origin[1] + region.columnAxis[1] * across + region.rowAxis[1] * down,\n region.origin[2] + region.columnAxis[2] * across + region.rowAxis[2] * down,\n ]\n}\n\n/**\n * One strip folded over a wall, the sidewalk in front of it, the curb face and the road: the Fluid Standard's grid (F12-42) and the\n * Workshop's (W562-582) are two settings of it. Bed height (mm), pinning noise and the vertical flag are filled per cell.\n */\nexport function createFoldedLayout(params: FoldedLayoutParams): FilmLayout {\n const { columns, cellSize, originX, wallRows, sidewalkRows, curbRows, roadRows, wallTopY, sidewalkY, roadY, wallZ, rules } = params\n const curbStep = params.curbStep ?? (sidewalkY - roadY) / curbRows\n const height = wallRows + sidewalkRows + curbRows + roadRows\n const cellCount = columns * height\n const bed = new Float32Array(cellCount)\n const pin = new Float32Array(cellCount)\n const vertical = new Float32Array(cellCount)\n const sidewalkEnd = wallRows + sidewalkRows\n const curbEnd = sidewalkEnd + curbRows\n const regionOfRow = (row: number): number => (row < wallRows ? 0 : row < sidewalkEnd ? 1 : row < curbEnd ? 2 : 3)\n\n for (let row = 0; row < height; row++) {\n for (let column = 0; column < columns; column++) {\n const index = row * columns + column\n const region = regionOfRow(row)\n const x = originX + (column + 0.5) * cellSize\n let bedHeight: number\n let roughness = 0.2\n if (region === 0) {\n bedHeight = (wallTopY - (row + 0.5) * cellSize) * 1000\n roughness = 0.3\n } else if (region === 1) {\n const z = (row - wallRows + 0.5) * cellSize\n bedHeight = sidewalkY * 1000 - z * 6\n const jointX = Math.abs((((x - originX) % 0.5) + 0.5) % 0.5 - 0.25)\n const jointZ = Math.abs(((z % 0.5) + 0.5) % 0.5 - 0.25)\n if (jointX > 0.25 - cellSize * 0.6 || jointZ > 0.25 - cellSize * 0.6) bedHeight -= 0.9\n roughness = 0.18\n } else if (region === 2) {\n bedHeight = sidewalkY * 1000 - (row - sidewalkEnd + 0.5) * curbStep * 1000\n } else {\n const z = (row - curbEnd + 0.5) * cellSize\n bedHeight = roadY * 1000 + z * 14 - (x - params.roadSlopeAnchorX) * 5\n roughness = 0.55\n }\n const noise = valueNoise(column * 0.35, row * 0.35) * 0.6 + valueNoise(column * 1.3, row * 1.3) * 0.4\n bed[index] = bedHeight + (noise - 0.5) * roughness * 2\n vertical[index] = region === 0 || region === 2 ? 0.95 : 1\n pin[index] = 0.62 + 0.76 * (valueNoise(column * 0.21 + 40, row * 0.21) * 0.5 + hashCell(column, row) * 0.5) * (region === 3 ? 1.25 : 1)\n }\n }\n\n const curbZ = wallZ + sidewalkRows * cellSize\n const roadEndZ = curbZ + roadRows * cellSize\n const right = [1, 0, 0] as Vec3\n const regions: FilmRegion[] = [\n { id: REGION_NAMES[0], firstRow: 0, rowCount: wallRows, origin: [originX, wallTopY, wallZ], columnAxis: right, rowAxis: [0, -1, 0], normal: [0, 0, 1], isVertical: true },\n { id: REGION_NAMES[1], firstRow: wallRows, rowCount: sidewalkRows, origin: [originX, sidewalkY, wallZ], columnAxis: right, rowAxis: [0, 0, 1], normal: [0, 1, 0], isVertical: false },\n { id: REGION_NAMES[2], firstRow: sidewalkEnd, rowCount: curbRows, origin: [originX, sidewalkY, curbZ], columnAxis: right, rowAxis: [0, -1, 0], normal: [0, 0, 1], isVertical: true },\n { id: REGION_NAMES[3], firstRow: curbEnd, rowCount: roadRows, origin: [originX, roadY, curbZ], columnAxis: right, rowAxis: [0, 0, 1], normal: [0, 1, 0], isVertical: false },\n ]\n const maxX = originX + columns * cellSize\n\n return {\n id: params.id,\n width: columns,\n height,\n cellSize,\n bed,\n pin,\n vertical,\n regions,\n rules,\n cellToWorld: (row, column) => cellToWorldOf(regions, cellSize, row, column),\n collide(previous, position) {\n if (position[2] <= wallZ && position[1] > sidewalkY) {\n position[2] = wallZ\n return 0\n }\n if (position[2] < curbZ && (!rules.guardBehindWall || position[2] >= wallZ) && position[1] <= sidewalkY) {\n position[1] = sidewalkY\n return 1\n }\n if (rules.curbCatch && position[2] >= curbZ && previous[2] < curbZ && position[1] < sidewalkY) {\n position[2] = curbZ\n return 2\n }\n if (position[2] >= curbZ && position[1] <= roadY) {\n position[1] = roadY\n return 3\n }\n return -1\n },\n impact: (region, position, velocity) => impactOf(regions[region]!, position, velocity, cellSize),\n contains: (position) => position[0] > originX && position[0] < maxX && (!rules.clipRoadEnd || position[2] < roadEndZ),\n escaped(position) {\n if (position[1] < -1) return true\n const box = rules.escapeBox\n return box !== undefined && (position[0] < box.minX || position[0] > box.maxX || position[2] > box.maxZ)\n },\n }\n}\n\nconst PADRAO_CELL = 0.0125\nconst PADRAO_WALL_Z = 0\n\n/** The Fluid Standard's grid: 256 x 396 cells of 1.25 cm over a 1.95 m wall, a 1.6 m sidewalk, a 15 cm curb and a 1.4 m road. */\nexport const PADRAO_LAYOUT: FilmLayout = createFoldedLayout({\n id: 'padrao',\n columns: 256,\n cellSize: PADRAO_CELL,\n originX: -1.6,\n wallRows: 144,\n sidewalkRows: 128,\n curbRows: 12,\n roadRows: 112,\n wallTopY: 1.95,\n sidewalkY: 0.15,\n roadY: 0,\n wallZ: PADRAO_WALL_Z,\n curbStep: PADRAO_CELL,\n roadSlopeAnchorX: 0,\n rules: {\n dropCapacity: 600,\n curbCatch: true,\n guardBehindWall: true,\n clipRoadEnd: true,\n escapeBox: { minX: -3, maxX: 3, maxZ: PADRAO_WALL_Z + 128 * PADRAO_CELL + 112 * PADRAO_CELL + 1 },\n dripStyle: 'padrao',\n },\n})\n\nconst WORKSHOP_CELL = 0.0125\n\n/** The Workshop's grid: 160 x 448 cells (wall 160, sidewalk 128, curb 9, road 151) at the foot of the workshop's wall. */\nexport const WORKSHOP_LAYOUT: FilmLayout = createFoldedLayout({\n id: 'workshop',\n columns: 160,\n cellSize: WORKSHOP_CELL,\n originX: -2.2,\n wallRows: 160,\n sidewalkRows: 128,\n curbRows: 9,\n roadRows: 151,\n wallTopY: 2.12,\n sidewalkY: 0.1235,\n roadY: 0.009,\n wallZ: -4.497,\n roadSlopeAnchorX: -1.2,\n rules: { dropCapacity: 400, curbCatch: false, guardBehindWall: false, clipRoadEnd: false, dripStyle: 'workshop' },\n})\n","import { add, cross, dot, normalize, scale, sub } from '../math'\nimport { makeBasis } from '../stains'\nimport type { SurfaceSpec, Vec3 } from '../types'\nimport { valueNoise } from './noise'\nimport type { FilmLayout, FilmRegion, FilmRules } from './types'\n\nexport interface SurfaceLayoutOptions {\n /** The surface the film lies on (a floor, a table, a ramp). */\n floor: SurfaceSpec\n /** A wall that meets the floor: the film folds up it, so a splash on the wall runs down onto the floor. */\n wall?: SurfaceSpec\n /** The lower surface beyond the floor's far edge: the film folds down a curb face to it. Needs the wall or the floor's tangent to say where the edge is. */\n curb?: SurfaceSpec\n /** World point the grid is centred on (sideways; and along the floor when there is no wall). */\n center: Vec3\n /** Cells across (default 160: 2 m of 1.25 cm cells, the grid of the near-player manager). */\n columns?: number\n /** Cells along all strips together (default 160). */\n rows?: number\n /** Metres per cell (default 0.0125). */\n cellSize?: number\n /** Rows of the wall strip (default 48 with a wall, else 0) and cap of the curb face rows (default 12). */\n wallRows?: number\n curbRows?: number\n}\n\nconst DEFAULT_COLUMNS = 160\nconst DEFAULT_ROWS = 160\nconst DEFAULT_CELL = 0.0125\nconst DEFAULT_WALL_ROWS = 48\nconst DEFAULT_CURB_ROWS = 12\nconst RULES: FilmRules = { dropCapacity: 160, curbCatch: false, guardBehindWall: false, clipRoadEnd: false, dripStyle: 'padrao' }\n\nconst along3 = (origin: Vec3, axis: Vec3, distance: number): Vec3 => add(origin, scale(axis, distance))\n\n/** Removes the part of `vector` along the unit `axis`. */\nconst reject = (vector: Vec3, axis: Vec3): Vec3 => sub(vector, scale(axis, dot(vector, axis)))\n\ninterface Strip {\n id: string\n rows: number\n origin: Vec3\n rowAxis: Vec3\n normal: Vec3\n isVertical: boolean\n roughness: number\n}\n\n/**\n * Builds the folded grid from the host's surfaces: `wall` (optional) hangs above the fold line, `floor` runs away from the wall, and\n * `curb` (optional) is the lower surface the floor drops to over a curb face. Without a wall the grid is a flat patch of the floor around `center`.\n * Bed heights come from world y, so a tilted floor makes the film run downhill.\n */\nexport function layoutFromSurfaces(options: SurfaceLayoutOptions): FilmLayout {\n const columns = options.columns ?? DEFAULT_COLUMNS\n const totalRows = options.rows ?? DEFAULT_ROWS\n const cell = options.cellSize ?? DEFAULT_CELL\n const floorBasis = makeBasis(options.floor.normal, options.floor.tangent)\n const floorNormal = floorBasis.normal\n const projected = sub(options.center, scale(floorNormal, dot(sub(options.center, options.floor.point), floorNormal)))\n const wallNormal = options.wall ? normalize(reject(options.wall.normal, floorNormal), floorBasis.t2) : undefined\n const awayAxis = wallNormal ?? floorBasis.t2\n const columnAxis = wallNormal ? normalize(cross(floorNormal, wallNormal), floorBasis.t1) : floorBasis.t1\n const wallRows = options.wall ? Math.min(totalRows - 1, options.wallRows ?? DEFAULT_WALL_ROWS) : 0\n\n let fold = projected\n if (options.wall && wallNormal) {\n const toWall = dot(sub(projected, options.wall.point), wallNormal) / (dot(awayAxis, wallNormal) || 1)\n fold = sub(projected, scale(awayAxis, toWall))\n } else {\n fold = along3(projected, awayAxis, -(totalRows * cell) / 2)\n }\n const lateral = dot(sub(projected, fold), columnAxis) - (columns * cell) / 2\n const base = along3(fold, columnAxis, lateral)\n\n const strips: Strip[] = []\n const roughness = 0.18 + 0.4 * options.floor.porosity\n if (options.wall && wallNormal) {\n strips.push({ id: 'wall', rows: wallRows, origin: along3(base, floorNormal, wallRows * cell), rowAxis: scale(floorNormal, -1), normal: wallNormal, isVertical: true, roughness: 0.3 })\n }\n const lowerRows = totalRows - wallRows\n const dropMetres = options.curb ? Math.max(0, dot(sub(options.floor.point, options.curb.point), floorNormal)) : 0\n const curbRows = options.curb ? Math.min(options.curbRows ?? DEFAULT_CURB_ROWS, Math.max(1, Math.ceil(dropMetres / cell)), lowerRows - 2) : 0\n const floorRows = options.curb ? Math.max(1, Math.floor((lowerRows - curbRows) / 2)) : lowerRows\n strips.push({ id: 'floor', rows: floorRows, origin: base, rowAxis: awayAxis, normal: floorNormal, isVertical: false, roughness })\n if (options.curb) {\n const edge = along3(base, awayAxis, floorRows * cell)\n strips.push({ id: 'curb', rows: curbRows, origin: edge, rowAxis: scale(floorNormal, -1), normal: awayAxis, isVertical: true, roughness: 0.2 })\n const lowerOrigin = along3(edge, floorNormal, -curbRows * cell)\n strips.push({ id: 'low', rows: lowerRows - floorRows - curbRows, origin: lowerOrigin, rowAxis: awayAxis, normal: floorNormal, isVertical: false, roughness: 0.55 })\n }\n\n const regions: FilmRegion[] = []\n let firstRow = 0\n for (const strip of strips) {\n regions.push({ id: strip.id, firstRow, rowCount: strip.rows, origin: strip.origin, columnAxis, rowAxis: strip.rowAxis, normal: strip.normal, isVertical: strip.isVertical })\n firstRow += strip.rows\n }\n\n const height = firstRow\n const bed = new Float32Array(columns * height)\n const pin = new Float32Array(columns * height)\n const vertical = new Float32Array(columns * height)\n regions.forEach((region, regionIndex) => {\n const strip = strips[regionIndex]!\n for (let row = 0; row < region.rowCount; row++) {\n for (let column = 0; column < columns; column++) {\n const index = (region.firstRow + row) * columns + column\n const centre = add(add(region.origin, scale(columnAxis, (column + 0.5) * cell)), scale(region.rowAxis, (row + 0.5) * cell))\n const noise = valueNoise(column * 0.35, (region.firstRow + row) * 0.35) * 0.6 + valueNoise(column * 1.3, (region.firstRow + row) * 1.3) * 0.4\n bed[index] = centre[1] * 1000 + (noise - 0.5) * strip.roughness * 2\n vertical[index] = region.isVertical ? 0.95 : 1\n pin[index] = 0.62 + 0.76 * (valueNoise(column * 0.21 + 40, (region.firstRow + row) * 0.21) * 0.5 + valueNoise(column * 0.9, row * 0.9) * 0.5)\n }\n }\n })\n\n const lowestY = Math.min(...regions.map((region) => region.origin[1] - (region.rowAxis[1] > 0 ? 0 : region.rowCount * cell * Math.abs(region.rowAxis[1])))) - 1\n const width = columns * cell\n const cellToWorld = (row: number, column: number): Vec3 => {\n const region = regions.find((candidate) => row < candidate.firstRow + candidate.rowCount) ?? regions[regions.length - 1]!\n return add(add(region.origin, scale(region.columnAxis, column * cell)), scale(region.rowAxis, (row - region.firstRow) * cell))\n }\n\n return {\n id: 'surfaces',\n width: columns,\n height,\n cellSize: cell,\n bed,\n pin,\n vertical,\n regions,\n rules: RULES,\n cellToWorld,\n collide(previous, position) {\n for (let index = 0; index < regions.length; index++) {\n const region = regions[index]!\n const before = dot(sub(previous, region.origin), region.normal)\n const after = dot(sub(position, region.origin), region.normal)\n if (before < 0 || after > 0) continue\n const local = sub(position, region.origin)\n const sideways = dot(local, region.columnAxis)\n const downward = dot(local, region.rowAxis)\n if (sideways < 0 || sideways >= width || downward < 0 || downward >= region.rowCount * cell) continue\n position[0] -= region.normal[0] * after\n position[1] -= region.normal[1] * after\n position[2] -= region.normal[2] * after\n return index\n }\n return -1\n },\n impact(regionIndex, position, velocity) {\n const region = regions[regionIndex]!\n const local = sub(position, region.origin)\n return {\n row: region.firstRow + dot(local, region.rowAxis) / cell,\n column: dot(local, region.columnAxis) / cell,\n along: [dot(velocity, region.columnAxis), dot(velocity, region.rowAxis)],\n normalSpeed: -dot(velocity, region.normal),\n }\n },\n contains: () => true,\n escaped: (position) => position[1] < lowestY,\n }\n}\n","[\n {\n \"id\": \"blood\",\n \"look\": \"blood\",\n \"flow\": 0.05,\n \"pin\": 0.33,\n \"front\": 0.58,\n \"referenceThickness\": 0.6,\n \"slopeCap\": 1.1,\n \"dryTime\": 600,\n \"evaporation\": 0,\n \"opacityRate\": 3.2,\n \"reflectance\": 0.045,\n \"normalScale\": 16,\n \"thin\": 7997966,\n \"thick\": 2753028,\n \"dry\": 3874068,\n \"dryThin\": 6960678,\n \"dropColor\": 7997965,\n \"dropOpacity\": 1,\n \"volume\": 1,\n \"spikes\": 1,\n \"landsAsBlob\": false,\n \"maxAmount\": 2.6,\n \"sources\": {\n \"padrao\": \"F46\",\n \"oficina\": \"W583\"\n }\n },\n {\n \"id\": \"old_blood\",\n \"look\": \"blood\",\n \"flow\": 0.032,\n \"pin\": 0.42,\n \"front\": 0.7,\n \"referenceThickness\": 0.7,\n \"slopeCap\": 1,\n \"dryTime\": 360,\n \"evaporation\": 0,\n \"opacityRate\": 3.8,\n \"reflectance\": 0.03,\n \"normalScale\": 14,\n \"thin\": 7085078,\n \"thick\": 2888717,\n \"dry\": 2758158,\n \"dryThin\": 4860444,\n \"dropColor\": 4854286,\n \"dropOpacity\": 1,\n \"volume\": 0.6,\n \"spikes\": 1,\n \"landsAsBlob\": false,\n \"maxAmount\": 2.6,\n \"sources\": {\n \"padrao\": \"F48\"\n }\n },\n {\n \"id\": \"bile\",\n \"look\": \"bile\",\n \"flow\": 0.02,\n \"pin\": 0.8,\n \"front\": 1.2,\n \"referenceThickness\": 1.2,\n \"slopeCap\": 0.9,\n \"dryTime\": 900,\n \"evaporation\": 0,\n \"opacityRate\": 7,\n \"reflectance\": 0.04,\n \"normalScale\": 12,\n \"thin\": 11121724,\n \"thick\": 7174171,\n \"dry\": 4080160,\n \"dryThin\": 5659180,\n \"dropColor\": 9083434,\n \"dropOpacity\": 1,\n \"volume\": 1.3,\n \"spikes\": 0.3,\n \"landsAsBlob\": false,\n \"maxAmount\": 4,\n \"sources\": {\n \"padrao\": \"F50\",\n \"oficina\": \"W584 (spikes 0.3 W578, cap 4 W691)\"\n }\n },\n {\n \"id\": \"motor_oil\",\n \"look\": \"oil\",\n \"flow\": 0.03,\n \"pin\": 0.12,\n \"front\": 0.22,\n \"referenceThickness\": 0.5,\n \"slopeCap\": 1,\n \"dryTime\": 0,\n \"evaporation\": 0,\n \"opacityRate\": 4.5,\n \"reflectance\": 0.06,\n \"normalScale\": 18,\n \"thin\": 1381135,\n \"thick\": 263173,\n \"dry\": 263173,\n \"dryThin\": 1381135,\n \"dropColor\": 657932,\n \"dropOpacity\": 1,\n \"volume\": 1,\n \"spikes\": 1,\n \"landsAsBlob\": true,\n \"maxAmount\": 2.6,\n \"sources\": {\n \"padrao\": \"F52\",\n \"oficina\": \"W585 (blob W691)\"\n }\n },\n {\n \"id\": \"fuel\",\n \"look\": \"fuel\",\n \"flow\": 0.2,\n \"pin\": 0.035,\n \"front\": 0.07,\n \"referenceThickness\": 0.2,\n \"slopeCap\": 1.2,\n \"dryTime\": 0,\n \"evaporation\": 0.02,\n \"opacityRate\": 0.25,\n \"reflectance\": 0.04,\n \"normalScale\": 0,\n \"thin\": 10129520,\n \"thick\": 7234630,\n \"dry\": 0,\n \"dryThin\": 0,\n \"dropColor\": 12103824,\n \"dropOpacity\": 0.45,\n \"volume\": 1.4,\n \"spikes\": 1,\n \"landsAsBlob\": true,\n \"maxAmount\": 2.6,\n \"sources\": {\n \"padrao\": \"F54\",\n \"oficina\": \"W586 (blob W691)\"\n }\n }\n]\n","import profilesData from '../data/film-profiles.json'\nimport type { LiquidId } from '../types'\nimport type { FilmProfile } from './types'\n\n/** Film profiles of the liquids that run as a film (F46-55, plus the Workshop's `spikes` and `landsAsBlob`). Data in `data/film-profiles.json`. */\nexport const FILM_PROFILES: FilmProfile[] = profilesData as unknown as FilmProfile[]\n\n/** The profile of a liquid with the given overrides, or undefined when the liquid has no film. */\nexport function filmProfileOf(id: LiquidId, overrides: Partial<FilmProfile> = {}): FilmProfile | undefined {\n const profile = FILM_PROFILES.find((entry) => entry.id === id)\n return profile ? { ...profile, ...overrides } : undefined\n}\n"],"mappings":";;;;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;AAAA,MACf,WAAa;AAAA,MACb,SAAW;AAAA,QACT,QAAU;AAAA,QACV,SAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA;AAAA,MACE,IAAM;AAAA,MACN,MAAQ;AAAA,MACR,MAAQ;AAAA,MACR,KAAO;AAAA,MACP,OAAS;AAAA,MACT,oBAAsB;AAAA,MACtB,UAAY;AAAA,MACZ,SAAW;AAAA,MACX,aAAe;AAAA,MACf,aAAe;AAAA,MACf,aAAe;AAAA,MACf,aAAe;AAAA,MACf,MAAQ;AAAA,MACR,OAAS;AAAA,MACT,KAAO;AAAA,MACP,SAAW;AAAA,MACX,WAAa;AAAA,MACb,aAAe;AAAA,MACf,QAAU;AAAA,MACV,QAAU;AAAA,MACV,aAAe;AAAA,MACf,WAAa;AAAA,MACb,SAAW;AAAA,QACT,QAAU;AAAA,QACV,SAAW;AAAA,MACb;AAAA,IACF;AAAA,EACF;;;ACvIO,MAAM,gBAA+B;AAGrC,WAAS,cAAc,IAAc,YAAkC,CAAC,GAA4B;AACzG,UAAM,UAAU,cAAc,KAAK,CAAC,UAAU,MAAM,OAAO,EAAE;AAC7D,WAAO,UAAU,EAAE,GAAG,SAAS,GAAG,UAAU,IAAI;AAAA,EAClD;","names":["q","x","z","n","basis","flow","options","length","distance","GRAVITY","sideX","sideZ","distance","length","distance"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/data/liquids.json","../src/liquids.ts","../src/math.ts","../src/landing.ts","../src/locale.ts","../src/shapes.ts","../src/stains.ts","../src/surface-pose.ts","../src/world.ts","../src/data/item-uses.json","../src/item-use.ts","../src/film/deposit.ts","../src/film/drops.ts","../src/film/simulate.ts","../src/film/sources.ts","../src/film/film.ts","../src/film/random.ts","../src/film/noise.ts","../src/film/layout.ts","../src/film/surface-layout.ts","../src/data/film-profiles.json","../src/film/profiles.ts"],"sourcesContent":["export { createFluids } from './world'\nexport { LIQUIDS } from './liquids'\nexport { ITEM_USES, createItemUse } from './item-use'\nexport type { HandTransform } from './item-use'\nexport { describeEvent, locales, resolveStrings } from './locale'\nexport type { FluidLocale, FluidStrings } from './locale'\nexport { ballistic, sampleStream } from './landing'\nexport { SAMPLES as STAIN_SAMPLES, stainDirection } from './stains'\nexport * from './film/index'\nexport type {\n ContainerSpec,\n ContainerState,\n FluidEvent,\n FluidOptions,\n FluidWorld,\n ItemUseDef,\n ItemUsePlayer,\n LiquidDef,\n LiquidId,\n Quat,\n SplashOptions,\n StainState,\n StainTint,\n StreamCause,\n StreamState,\n SurfacePose,\n SurfaceSpec,\n TapSpec,\n TapState,\n Vec3,\n} from './types'\n","[\n {\n \"id\": \"water\",\n \"color\": 11064558,\n \"opacity\": 0.35,\n \"stainColor\": 7309206,\n \"viscosity\": 1,\n \"density\": 1000,\n \"dryTime\": 180,\n \"gloss\": 0.9,\n \"drink\": {\n \"thirst\": 100,\n \"effects\": []\n },\n \"tags\": [\n \"drink\",\n \"clear\"\n ]\n },\n {\n \"id\": \"coffee\",\n \"color\": 3875604,\n \"opacity\": 0.95,\n \"stainColor\": 2824202,\n \"viscosity\": 1.5,\n \"density\": 1005,\n \"dryTime\": 900,\n \"gloss\": 0.8,\n \"leavesMark\": true,\n \"steamC\": 60,\n \"drink\": {\n \"thirst\": 80,\n \"effects\": [\n \"caffeine\"\n ]\n },\n \"tags\": [\n \"drink\",\n \"hot\"\n ]\n },\n {\n \"id\": \"tea\",\n \"color\": 9063188,\n \"opacity\": 0.8,\n \"stainColor\": 6961682,\n \"viscosity\": 1.4,\n \"density\": 1005,\n \"dryTime\": 800,\n \"gloss\": 0.8,\n \"leavesMark\": true,\n \"steamC\": 60,\n \"drink\": {\n \"thirst\": 90,\n \"effects\": []\n },\n \"tags\": [\n \"drink\",\n \"hot\"\n ]\n },\n {\n \"id\": \"milk\",\n \"color\": 16052712,\n \"opacity\": 0.98,\n \"stainColor\": 14473160,\n \"viscosity\": 2,\n \"density\": 1030,\n \"dryTime\": 900,\n \"gloss\": 0.5,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 70,\n \"effects\": []\n },\n \"tags\": [\n \"drink\"\n ]\n },\n {\n \"id\": \"soda\",\n \"color\": 3808530,\n \"opacity\": 0.85,\n \"stainColor\": 2757901,\n \"viscosity\": 1.3,\n \"density\": 1040,\n \"dryTime\": 1200,\n \"gloss\": 0.85,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 60,\n \"effects\": []\n },\n \"tags\": [\n \"drink\",\n \"sticky\"\n ]\n },\n {\n \"id\": \"juice\",\n \"color\": 15239467,\n \"opacity\": 0.9,\n \"stainColor\": 12741916,\n \"viscosity\": 2,\n \"density\": 1045,\n \"dryTime\": 1100,\n \"gloss\": 0.8,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 75,\n \"effects\": []\n },\n \"tags\": [\n \"drink\",\n \"sticky\"\n ]\n },\n {\n \"id\": \"beer\",\n \"color\": 14259740,\n \"opacity\": 0.8,\n \"stainColor\": 11039764,\n \"viscosity\": 1.4,\n \"density\": 1010,\n \"dryTime\": 900,\n \"gloss\": 0.8,\n \"drink\": {\n \"thirst\": 50,\n \"effects\": [\n \"alcohol\"\n ]\n },\n \"tags\": [\n \"drink\",\n \"alcohol\"\n ]\n },\n {\n \"id\": \"wine\",\n \"color\": 7016223,\n \"opacity\": 0.9,\n \"stainColor\": 5048854,\n \"viscosity\": 1.6,\n \"density\": 990,\n \"dryTime\": 800,\n \"gloss\": 0.85,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 40,\n \"effects\": [\n \"alcohol\"\n ]\n },\n \"tags\": [\n \"drink\",\n \"alcohol\"\n ]\n },\n {\n \"id\": \"spirits\",\n \"color\": 13214042,\n \"opacity\": 0.6,\n \"stainColor\": 10320959,\n \"viscosity\": 1.8,\n \"density\": 940,\n \"dryTime\": 200,\n \"gloss\": 0.85,\n \"flammable\": true,\n \"drink\": {\n \"thirst\": 5,\n \"effects\": [\n \"alcohol\"\n ]\n },\n \"tags\": [\n \"drink\",\n \"alcohol\"\n ]\n },\n {\n \"id\": \"fuel\",\n \"color\": 14926682,\n \"opacity\": 0.6,\n \"stainColor\": 7232298,\n \"viscosity\": 0.6,\n \"density\": 740,\n \"dryTime\": 60,\n \"gloss\": 0.95,\n \"leavesMark\": false,\n \"flammable\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"fuel\",\n \"gasoline\"\n ]\n },\n {\n \"id\": \"diesel\",\n \"color\": 12098094,\n \"opacity\": 0.8,\n \"stainColor\": 5917208,\n \"viscosity\": 3,\n \"density\": 830,\n \"dryTime\": 3600,\n \"gloss\": 0.95,\n \"leavesMark\": true,\n \"flammable\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"fuel\"\n ]\n },\n {\n \"id\": \"motor_oil\",\n \"color\": 3877388,\n \"opacity\": 0.95,\n \"stainColor\": 1840134,\n \"viscosity\": 100,\n \"density\": 880,\n \"dryTime\": 0,\n \"gloss\": 1,\n \"leavesMark\": true,\n \"flammable\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"oil\"\n ]\n },\n {\n \"id\": \"cooking_oil\",\n \"color\": 14267708,\n \"opacity\": 0.85,\n \"stainColor\": 11110698,\n \"viscosity\": 60,\n \"density\": 920,\n \"dryTime\": 0,\n \"gloss\": 1,\n \"leavesMark\": true,\n \"flammable\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"oil\",\n \"food\"\n ]\n },\n {\n \"id\": \"blood\",\n \"color\": 7997964,\n \"opacity\": 0.92,\n \"stainColor\": 3874068,\n \"viscosity\": 4,\n \"density\": 1060,\n \"dryTime\": 600,\n \"gloss\": 0.75,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 10,\n \"effects\": [\n \"disgust\"\n ]\n },\n \"tags\": [\n \"organic\"\n ]\n },\n {\n \"id\": \"old_blood\",\n \"color\": 7085078,\n \"opacity\": 0.92,\n \"stainColor\": 2758158,\n \"viscosity\": 4,\n \"density\": 1060,\n \"dryTime\": 360,\n \"gloss\": 0.7,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 10,\n \"effects\": [\n \"disgust\"\n ]\n },\n \"tags\": [\n \"organic\"\n ]\n },\n {\n \"id\": \"bile\",\n \"color\": 9083434,\n \"opacity\": 0.9,\n \"stainColor\": 4080160,\n \"viscosity\": 6,\n \"density\": 1020,\n \"dryTime\": 900,\n \"gloss\": 0.75,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"disgust\"\n ]\n },\n \"tags\": [\n \"organic\"\n ]\n },\n {\n \"id\": \"sap\",\n \"color\": 13146940,\n \"opacity\": 0.8,\n \"stainColor\": 10122282,\n \"viscosity\": 200,\n \"density\": 1100,\n \"dryTime\": 3600,\n \"gloss\": 0.8,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 20,\n \"effects\": []\n },\n \"tags\": [\n \"organic\",\n \"sticky\"\n ]\n },\n {\n \"id\": \"acid\",\n \"color\": 10146378,\n \"opacity\": 0.6,\n \"stainColor\": 7313970,\n \"viscosity\": 1.5,\n \"density\": 1200,\n \"dryTime\": 900,\n \"gloss\": 0.9,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"corrosive\"\n ]\n },\n {\n \"id\": \"paint\",\n \"color\": 11740715,\n \"opacity\": 0.98,\n \"stainColor\": 9050655,\n \"viscosity\": 300,\n \"density\": 1300,\n \"dryTime\": 1800,\n \"gloss\": 0.6,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"paint\"\n ]\n },\n {\n \"id\": \"bleach\",\n \"color\": 15134688,\n \"opacity\": 0.7,\n \"stainColor\": 13621446,\n \"viscosity\": 1.2,\n \"density\": 1100,\n \"dryTime\": 900,\n \"gloss\": 0.85,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"corrosive\"\n ]\n },\n {\n \"id\": \"sewage\",\n \"color\": 5921582,\n \"opacity\": 0.92,\n \"stainColor\": 3093273,\n \"viscosity\": 4,\n \"density\": 1010,\n \"dryTime\": 1800,\n \"gloss\": 0.8,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"disgust\",\n \"poison\"\n ]\n },\n \"tags\": [\n \"organic\",\n \"waste\"\n ]\n },\n {\n \"id\": \"honey\",\n \"color\": 14193162,\n \"opacity\": 0.9,\n \"stainColor\": 12089350,\n \"viscosity\": 3000,\n \"density\": 1420,\n \"dryTime\": 14400,\n \"gloss\": 0.95,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 10,\n \"effects\": []\n },\n \"tags\": [\n \"drink\",\n \"sticky\"\n ]\n },\n {\n \"id\": \"mud\",\n \"color\": 4008988,\n \"opacity\": 0.95,\n \"stainColor\": 3811866,\n \"viscosity\": 40,\n \"density\": 1600,\n \"dryTime\": 900,\n \"gloss\": 0.4,\n \"tags\": [\n \"dirty\"\n ]\n },\n {\n \"id\": \"coolant\",\n \"color\": 3455050,\n \"opacity\": 0.7,\n \"stainColor\": 2783796,\n \"viscosity\": 4,\n \"density\": 1070,\n \"dryTime\": 1200,\n \"gloss\": 0.85,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"coolant\"\n ]\n },\n {\n \"id\": \"brake_fluid\",\n \"color\": 13145646,\n \"opacity\": 0.8,\n \"stainColor\": 9069600,\n \"viscosity\": 8,\n \"density\": 1050,\n \"dryTime\": 3600,\n \"gloss\": 0.9,\n \"leavesMark\": true,\n \"drink\": {\n \"thirst\": 0,\n \"effects\": [\n \"poison\"\n ]\n },\n \"tags\": [\n \"brake_fluid\"\n ]\n }\n]\n","import liquidsData from './data/liquids.json'\nimport type { LiquidDef } from './types'\n\n/**\n * Built-in liquids (data in `data/liquids.json`; colours are `0xRRGGBB` stored as integers).\n * Viscosity is relative to water, density in kg/m³, `dryTime` in seconds for a thin film at 20 °C (0 = never dries).\n */\nexport const LIQUIDS: LiquidDef[] = liquidsData as unknown as LiquidDef[]\n","import type { Quat, Vec3 } from './types'\n\nexport const GRAVITY = 9.81\nexport const EPS = 1e-7\n\nexport const clamp = (v: number, lo: number, hi: number): number => (v < lo ? lo : v > hi ? hi : v)\nexport const lerp = (a: number, b: number, t: number): number => a + (b - a) * t\n\nexport const add = (a: Vec3, b: Vec3): Vec3 => [a[0] + b[0], a[1] + b[1], a[2] + b[2]]\nexport const sub = (a: Vec3, b: Vec3): Vec3 => [a[0] - b[0], a[1] - b[1], a[2] - b[2]]\nexport const scale = (a: Vec3, s: number): Vec3 => [a[0] * s, a[1] * s, a[2] * s]\nexport const dot = (a: Vec3, b: Vec3): number => a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\nexport const cross = (a: Vec3, b: Vec3): Vec3 => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]\nexport const length = (a: Vec3): number => Math.hypot(a[0], a[1], a[2])\nexport const distance = (a: Vec3, b: Vec3): number => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2])\nexport const normalize = (a: Vec3, fallback: Vec3 = [0, 1, 0]): Vec3 => {\n const l = length(a)\n return l < 1e-9 ? [fallback[0], fallback[1], fallback[2]] : [a[0] / l, a[1] / l, a[2] / l]\n}\nexport const copy3 = (a: Vec3): Vec3 => [a[0], a[1], a[2]]\nexport const lerp3 = (a: Vec3, b: Vec3, t: number): Vec3 => [lerp(a[0], b[0], t), lerp(a[1], b[1], t), lerp(a[2], b[2], t)]\n\n/** Rotate `v` by the unit quaternion `q` (x, y, z, w). */\nexport const quatRotate = (q: Quat, v: Vec3): Vec3 => {\n const u: Vec3 = [q[0], q[1], q[2]]\n const c1 = cross(u, v)\n const c2 = cross(u, c1)\n return [v[0] + 2 * (q[3] * c1[0] + c2[0]), v[1] + 2 * (q[3] * c1[1] + c2[1]), v[2] + 2 * (q[3] * c1[2] + c2[2])]\n}\nexport const quatConjugate = (q: Quat): Quat => [-q[0], -q[1], -q[2], q[3]]\nexport const quatMultiply = (a: Quat, b: Quat): Quat => [\n a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1],\n a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0],\n a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3],\n a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2],\n]\nexport const quatNormalize = (q: Quat): Quat => {\n const l = Math.hypot(q[0], q[1], q[2], q[3])\n return l < 1e-9 ? [0, 0, 0, 1] : [q[0] / l, q[1] / l, q[2] / l, q[3] / l]\n}\n/** Quaternion from Euler angles in XYZ order (the same convention as three.js). */\nexport const quatFromEuler = (x: number, y: number, z: number): Quat => {\n const c1 = Math.cos(x / 2)\n const c2 = Math.cos(y / 2)\n const c3 = Math.cos(z / 2)\n const s1 = Math.sin(x / 2)\n const s2 = Math.sin(y / 2)\n const s3 = Math.sin(z / 2)\n return [s1 * c2 * c3 + c1 * s2 * s3, c1 * s2 * c3 - s1 * c2 * s3, c1 * c2 * s3 + s1 * s2 * c3, c1 * c2 * c3 - s1 * s2 * s3]\n}\n\n/** Small seeded generator (mulberry32). Its whole state is one integer, so it serialises trivially. */\nexport class Rng {\n state: number\n constructor(seed: number) {\n this.state = (Math.imul((seed | 0) ^ 0x9e3779b9, 0x85ebca6b) >>> 0) || 1\n }\n next(): number {\n this.state = (this.state + 0x6d2b79f5) >>> 0\n let t = this.state\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n","import type { StreamState, Vec3 } from './types'\nimport { dot, sub } from './math'\nimport type { Basis } from './stains'\n\nexport const GROUND_ID = 'ground'\n/** Longest flight simulated for a stream before it counts as landing nowhere. */\nexport const MAX_FLIGHT = 3\n\n/** Position of a ballistic jet `t` seconds after leaving its origin. */\nexport const ballistic = (origin: Vec3, velocity: Vec3, gravity: number, t: number): Vec3 => [\n origin[0] + velocity[0] * t,\n origin[1] + velocity[1] * t - 0.5 * gravity * t * t,\n origin[2] + velocity[2] * t,\n]\n\n/** Point of a stream's path `t` seconds after its origin (use with `StreamState.flightTime` and the world's `gravity`). */\nexport const sampleStream = (stream: Pick<StreamState, 'origin' | 'velocity'>, gravity: number, t: number): Vec3 =>\n ballistic(stream.origin, stream.velocity, gravity, t)\n\nexport interface LandingSurface extends Basis {\n id: string\n point: Vec3\n half: [number, number]\n}\n\nexport interface Hit {\n t: number\n point: Vec3\n normal: Vec3\n surface: string\n /** Velocity of the jet at impact. */\n velocity: Vec3\n}\n\nconst velocityAt = (velocity: Vec3, gravity: number, t: number): Vec3 => [velocity[0], velocity[1] - gravity * t, velocity[2]]\n\n/** First thing a jet hits: an authored surface (plane with half extents) or else the ground. */\nexport const trace = (\n surfaces: Iterable<LandingSurface>,\n groundAt: (x: number, z: number) => number,\n origin: Vec3,\n velocity: Vec3,\n gravity: number,\n): Hit | null => {\n let best: Hit | null = null\n for (const s of surfaces) {\n const n = s.normal\n const c = dot(n, sub(origin, s.point))\n if (c < -0.005) continue\n const a = -0.5 * gravity * n[1]\n const b = dot(n, velocity)\n let t = Infinity\n if (Math.abs(a) < 1e-9) {\n if (b < -1e-9) t = -c / b\n } else {\n const disc = b * b - 4 * a * c\n if (disc >= 0) {\n const sq = Math.sqrt(disc)\n for (const root of [(-b - sq) / (2 * a), (-b + sq) / (2 * a)]) {\n if (root >= -1e-6 && b + 2 * a * root < 0 && root < t) t = root\n }\n }\n }\n if (!Number.isFinite(t) || t > MAX_FLIGHT) continue\n t = Math.max(0, t)\n if (best && t >= best.t) continue\n const p = ballistic(origin, velocity, gravity, t)\n const rel = sub(p, s.point)\n if (Math.abs(dot(rel, s.t1)) > s.half[0] || Math.abs(dot(rel, s.t2)) > s.half[1]) continue\n best = { t, point: p, normal: n, surface: s.id, velocity: velocityAt(velocity, gravity, t) }\n }\n\n // Ground: march the path and refine the crossing.\n const step = 0.02\n let prevT = 0\n const startOver = origin[1] - groundAt(origin[0], origin[2])\n const limit = best ? best.t : MAX_FLIGHT\n if (startOver <= 0) {\n return best && best.t <= 0 ? best : { t: 0, point: [origin[0], groundAt(origin[0], origin[2]), origin[2]], normal: [0, 1, 0], surface: GROUND_ID, velocity }\n }\n for (let t = step; t <= limit + step; t += step) {\n const tt = Math.min(t, limit)\n const p = ballistic(origin, velocity, gravity, tt)\n const over = p[1] - groundAt(p[0], p[2])\n if (over <= 0) {\n let lo = prevT\n let hi = tt\n for (let i = 0; i < 18; i++) {\n const mid = (lo + hi) / 2\n const q = ballistic(origin, velocity, gravity, mid)\n if (q[1] - groundAt(q[0], q[2]) > 0) lo = mid\n else hi = mid\n }\n if (best && hi >= best.t - 1e-3) return best\n const q = ballistic(origin, velocity, gravity, hi)\n return { t: hi, point: [q[0], groundAt(q[0], q[2]), q[2]], normal: [0, 1, 0], surface: GROUND_ID, velocity: velocityAt(velocity, gravity, hi) }\n }\n prevT = tt\n if (tt >= limit) break\n }\n return best\n}\n","import type { FluidEvent, LiquidId } from './types'\n\n/** Locales shipped with the package. Unknown locales fall back to `en`. */\nexport type FluidLocale = 'en' | 'pt-BR'\n\nexport interface FluidStrings {\n /** Display name per liquid id (unknown ids fall back to the id itself). */\n liquids: Record<LiquidId, string>\n /** Short label per event type. */\n events: Record<FluidEvent['type'], string>\n on: string\n off: string\n}\n\nexport const locales: Record<FluidLocale, FluidStrings> = {\n en: {\n liquids: {\n water: 'water',\n coffee: 'coffee',\n tea: 'tea',\n milk: 'milk',\n soda: 'soda',\n juice: 'juice',\n beer: 'beer',\n wine: 'wine',\n spirits: 'spirits',\n fuel: 'gasoline',\n diesel: 'diesel',\n motor_oil: 'motor oil',\n cooking_oil: 'cooking oil',\n blood: 'blood',\n old_blood: 'old blood',\n bile: 'bile',\n sap: 'sap',\n acid: 'acid',\n paint: 'paint',\n bleach: 'bleach',\n sewage: 'sewage',\n honey: 'honey',\n mud: 'mud',\n coolant: 'coolant',\n brake_fluid: 'brake fluid',\n },\n events: {\n fill: 'filled',\n pour: 'poured',\n spill: 'spilled',\n leak: 'leaking',\n drink: 'drank',\n empty: 'emptied',\n stream_end: 'stream ended',\n splash: 'splash',\n stain: 'stain',\n dried: 'dried',\n steam: 'steam',\n mix: 'mixed',\n tap: 'tap',\n },\n on: 'on',\n off: 'off',\n },\n 'pt-BR': {\n liquids: {\n water: 'água',\n coffee: 'café',\n tea: 'chá',\n milk: 'leite',\n soda: 'refrigerante',\n juice: 'suco',\n beer: 'cerveja',\n wine: 'vinho',\n spirits: 'destilado',\n fuel: 'gasolina',\n diesel: 'diesel',\n motor_oil: 'óleo de motor',\n cooking_oil: 'óleo de cozinha',\n blood: 'sangue',\n old_blood: 'sangue antigo',\n bile: 'bile',\n sap: 'seiva',\n acid: 'ácido',\n paint: 'tinta',\n bleach: 'água sanitária',\n sewage: 'esgoto',\n honey: 'mel',\n mud: 'lama',\n coolant: 'líquido de arrefecimento',\n brake_fluid: 'fluido de freio',\n },\n events: {\n fill: 'encheu',\n pour: 'despejou',\n spill: 'derramou',\n leak: 'vazando',\n drink: 'bebeu',\n empty: 'esvaziou',\n stream_end: 'parou de escorrer',\n splash: 'respingo',\n stain: 'mancha',\n dried: 'secou',\n steam: 'vapor',\n mix: 'misturou',\n tap: 'torneira',\n },\n on: 'ligado',\n off: 'desligado',\n },\n}\n\nexport const resolveStrings = (locale: string | undefined): FluidStrings => locales[(locale as FluidLocale) ?? 'en'] ?? locales.en\n\nconst fmt = (n: number): string => `${(Math.round(n * 1000) / 1000).toString()} l`\nconst pt = (p: [number, number, number]): string => `(${p.map((v) => Math.round(v * 100) / 100).join(', ')})`\n\n/** One-line description of an event for logs and debug panels, e.g. `drank: coffee 0.03 l`. */\nexport const describeEvent = (strings: FluidStrings, event: FluidEvent): string => {\n const label = strings.events[event.type]\n const name = (id: LiquidId) => strings.liquids[id] ?? id\n switch (event.type) {\n case 'fill':\n return `${label}: ${event.container} ${name(event.liquid)} ${fmt(event.liters)}`\n case 'pour':\n case 'spill':\n return `${label}: ${event.container} ${name(event.liquid)} ${fmt(event.rate)}/s`\n case 'leak':\n return `${label}: ${event.container} ${name(event.liquid)} ${fmt(event.rate)}/s ${pt(event.point)}`\n case 'drink':\n return `${label}: ${event.container} ${name(event.liquid)} ${fmt(event.liters)}${event.effects.length ? ` [${event.effects.join(', ')}]` : ''}${event.burn ? ' !' : ''}`\n case 'empty':\n return `${label}: ${event.container}`\n case 'stream_end':\n return `${label}: ${event.stream}`\n case 'splash':\n return `${label}: ${name(event.liquid)} ${pt(event.point)}`\n case 'stain':\n return `${label}: ${event.stain} ${name(event.liquid)} ${event.surface} ${pt(event.point)}`\n case 'dried':\n return `${label}: ${event.stain}${event.mark ? ' (mark)' : ''}`\n case 'steam':\n return `${label}: ${event.container} ${event.on ? strings.on : strings.off}`\n case 'mix':\n return `${label}: ${event.container} ${name(event.from)} -> ${name(event.into)}`\n case 'tap':\n return `${label}: ${event.tap} ${event.on ? strings.on : strings.off}`\n }\n}\n","import type { ContainerSpec, Vec3 } from './types'\nimport { clamp, normalize } from './math'\n\nexport type Shape = ContainerSpec['shape']\n\n/** Sample columns of a container's inner volume: equal-weight (x, z) positions with the full height `h`. */\nexport interface Columns {\n x: Float64Array\n z: Float64Array\n h: number\n /** Radius (cylinder) or half extents (box) used for the extent of a plane. */\n kind: 'cylinder' | 'box'\n r: number\n hx: number\n hz: number\n}\n\nconst RINGS = 8\nconst SEGMENTS = 16\nconst GRID = 12\n\nexport const makeColumns = (shape: Shape): Columns => {\n if (shape.kind === 'cylinder') {\n const x = new Float64Array(RINGS * SEGMENTS)\n const z = new Float64Array(RINGS * SEGMENTS)\n let n = 0\n for (let k = 0; k < RINGS; k++) {\n const rr = shape.radius * Math.sqrt((k + 0.5) / RINGS)\n for (let m = 0; m < SEGMENTS; m++) {\n // Offset every other ring so the samples do not line up radially.\n const a = ((m + (k % 2) * 0.5) / SEGMENTS) * Math.PI * 2\n x[n] = Math.cos(a) * rr\n z[n] = Math.sin(a) * rr\n n++\n }\n }\n return { x, z, h: shape.height, kind: 'cylinder', r: shape.radius, hx: shape.radius, hz: shape.radius }\n }\n const [sx, sy, sz] = shape.size\n const x = new Float64Array(GRID * GRID)\n const z = new Float64Array(GRID * GRID)\n let n = 0\n for (let i = 0; i < GRID; i++) {\n for (let j = 0; j < GRID; j++) {\n x[n] = ((i + 0.5) / GRID - 0.5) * sx\n z[n] = ((j + 0.5) / GRID - 0.5) * sz\n n++\n }\n }\n return { x, z, h: sy, kind: 'box', r: Math.hypot(sx, sz) / 2, hx: sx / 2, hz: sz / 2 }\n}\n\n/** Range of `u · p` over the container: below `lo` it is empty, above `hi` it is full. */\nexport const planeRange = (c: Columns, u: Vec3): [number, number] => {\n const horizontal = c.kind === 'cylinder' ? c.r * Math.hypot(u[0], u[2]) : Math.abs(u[0]) * c.hx + Math.abs(u[2]) * c.hz\n const top = u[1] * c.h\n return [-horizontal + Math.min(0, top), horizontal + Math.max(0, top)]\n}\n\n/** Fraction (0..1) of the inner volume with `u · p <= d` (the liquid for a surface plane with normal `u` at offset `d`). */\nexport const planeFraction = (c: Columns, u: Vec3, d: number): number => {\n const uy = u[1]\n let total = 0\n const n = c.x.length\n for (let i = 0; i < n; i++) {\n const s0 = u[0] * c.x[i] + u[2] * c.z[i]\n let len: number\n if (uy > 1e-6) len = clamp((d - s0) / uy, 0, c.h)\n else if (uy < -1e-6) len = c.h - clamp((d - s0) / uy, 0, c.h)\n else len = s0 <= d ? c.h : 0\n total += len\n }\n return total / (n * c.h)\n}\n\n/** Plane offset `d` along unit normal `u` for which the liquid takes the volume fraction `f`. */\nexport const levelFor = (c: Columns, u: Vec3, f: number): number => {\n const [lo0, hi0] = planeRange(c, u)\n if (f <= 0) return lo0\n if (f >= 1) return hi0\n if (Math.abs(u[0]) + Math.abs(u[2]) < 1e-9) {\n return u[1] > 0 ? f * c.h * u[1] : u[1] * c.h - f * c.h * u[1]\n }\n let lo = lo0\n let hi = hi0\n for (let i = 0; i < 28; i++) {\n const mid = (lo + hi) / 2\n if (planeFraction(c, u, mid) < f) lo = mid\n else hi = mid\n }\n return (lo + hi) / 2\n}\n\n/** Radius of the lip circle (the opening); a closed spec (`opening` 0) uses half the container width once opened. */\nexport const lipRadius = (shape: Shape, opening: number): number => {\n const limit = shape.kind === 'cylinder' ? shape.radius : Math.min(shape.size[0], shape.size[2]) / 2\n return opening > 0 ? Math.min(opening, limit) : limit * 0.5\n}\n\nexport const shapeHeight = (shape: Shape): number => (shape.kind === 'cylinder' ? shape.height : shape.size[1])\n\nexport interface Lip {\n /** Lowest lip point along the surface normal, container space. */\n point: Vec3\n /** Centre of the lip circle, container space. */\n center: Vec3\n /** Outward direction (container space, horizontal in the container frame) the liquid leaves along, or null when upright. */\n outward: Vec3 | null\n /** `u · point`: the surface offset above which the liquid spills. */\n level: number\n}\n\nexport const lipOf = (shape: Shape, opening: number, u: Vec3): Lip => {\n const h = shapeHeight(shape)\n const ro = lipRadius(shape, opening)\n const center: Vec3 = [0, h, 0]\n const uh = Math.hypot(u[0], u[2])\n if (uh < 1e-6) return { point: center, center, outward: null, level: u[1] * h }\n const out: Vec3 = normalize([-u[0], 0, -u[2]])\n const point: Vec3 = [out[0] * ro, h, out[2] * ro]\n return { point, center, outward: out, level: u[0] * point[0] + u[1] * point[1] + u[2] * point[2] }\n}\n","import type { LiquidDef, StainState, Vec3 } from './types'\nimport { Rng, add, clamp, cross, dot, length, normalize, scale, sub } from './math'\n\n/** Number of radial samples of the flow front. */\nexport const SAMPLES = 16\n\nconst COS: number[] = []\nconst SIN: number[] = []\nfor (let i = 0; i < SAMPLES; i++) {\n COS.push(Math.cos((i / SAMPLES) * Math.PI * 2))\n SIN.push(Math.sin((i / SAMPLES) * Math.PI * 2))\n}\n\n/** Orthonormal frame of a surface: `normal`, `t1` (tangent) and `t2 = normal × t1`. */\nexport interface Basis {\n normal: Vec3\n t1: Vec3\n t2: Vec3\n}\n\nexport const makeBasis = (normalIn: Vec3, tangentIn?: Vec3): Basis => {\n const normal = normalize(normalIn)\n const ref: Vec3 = tangentIn && length(tangentIn) > 1e-6 ? tangentIn : Math.abs(normal[1]) > 0.9 ? [1, 0, 0] : [0, 1, 0]\n const t1 = normalize(sub(ref, scale(normal, dot(ref, normal))), [1, 0, 0])\n return { normal, t1, t2: cross(normal, t1) }\n}\n\n/** What a stain needs to know about the surface it lies on. */\nexport interface StainSurface extends Basis {\n point: Vec3\n half: [number, number]\n porosity: number\n}\n\nexport interface StainInt extends StainState {\n normal: Vec3\n tangent: Vec3\n noise: number[]\n /** Seconds since the last inflow. */\n sinceInflow: number\n /** Drying progress 0..1. */\n dry: number\n mark: boolean\n age: number\n}\n\n/** Direction (world space) of radial sample `i` on a surface frame. */\nexport const sampleDir = (b: Basis, i: number): Vec3 => [\n b.t1[0] * COS[i] + b.t2[0] * SIN[i],\n b.t1[1] * COS[i] + b.t2[1] * SIN[i],\n b.t1[2] * COS[i] + b.t2[2] * SIN[i],\n]\n\nexport const stainArea = (front: number[]): number => {\n let a = 0\n for (let i = 0; i < SAMPLES; i++) a += front[i] * front[(i + 1) % SAMPLES]\n return 0.5 * Math.sin((Math.PI * 2) / SAMPLES) * a\n}\n\nexport const meanRadius = (front: number[]): number => front.reduce((s, v) => s + v, 0) / front.length\n\n/** Thickness (m) a puddle of this liquid cannot get thinner than: 1 mm for water, thicker for viscous liquids. */\nexport const minFilm = (def: LiquidDef): number => 0.001 * (1 + 0.8 * Math.log10(Math.max(1, def.viscosity)))\n\n/** Per-direction growth multipliers: low harmonics plus smoothed seeded noise, so the outline is never a disc. */\nexport const makeNoise = (rng: Rng): number[] => {\n const amp = [0.12 + rng.next() * 0.18, 0.08 + rng.next() * 0.14, 0.05 + rng.next() * 0.08]\n const phase = [rng.next() * Math.PI * 2, rng.next() * Math.PI * 2, rng.next() * Math.PI * 2]\n const raw: number[] = []\n for (let i = 0; i < SAMPLES; i++) {\n const a = (i / SAMPLES) * Math.PI * 2\n let v = 1 + (rng.next() - 0.5) * 0.3\n for (let k = 0; k < 3; k++) v += amp[k] * Math.sin((k + 2) * a + phase[k])\n raw.push(v)\n }\n const out = raw.map((v, i) => 0.25 * raw[(i + SAMPLES - 1) % SAMPLES] + 0.5 * v + 0.25 * raw[(i + 1) % SAMPLES])\n return out.map((v) => clamp(v, 0.45, 1.7))\n}\n\n/** Horizontal run direction on a surface (downhill, unit, in the plane) and the slope strength 0..1 (sin of the angle). */\nexport const downhill = (normal: Vec3): { dir: Vec3; slope: number } => {\n const d = add([0, -1, 0], scale(normal, normal[1]))\n const slope = length(d)\n return slope < 1e-6 ? { dir: [0, 0, 0], slope: 0 } : { dir: scale(d, 1 / slope), slope }\n}\n\n/** Creates a stain at `center` (on the surface) with a small starting front. */\nexport const createStain = (\n id: string,\n surfaceId: string,\n def: LiquidDef,\n basis: Basis,\n center: Vec3,\n liters: number,\n rng: Rng,\n): StainInt => {\n const r0 = clamp(Math.sqrt(liters / 1000 / minFilm(def) / Math.PI) * 0.4, 0.012, 0.12)\n return {\n id,\n surface: surfaceId,\n liquid: def.id,\n center: [center[0], center[1], center[2]],\n front: new Array(SAMPLES).fill(r0),\n liters,\n soaked: 0,\n wetness: 1,\n wetRadius: 1,\n normal: basis.normal,\n tangent: basis.t1,\n noise: makeNoise(rng),\n sinceInflow: 0,\n dry: 0,\n mark: false,\n age: 0,\n }\n}\n\n/** Adds liquid to a stain (rewets a dried mark). `velocity` makes the front stretch the way the liquid came in. */\nexport const addInflow = (s: StainInt, liters: number, velocity: Vec3 | null): void => {\n s.liters += liters\n s.sinceInflow = 0\n if (s.dry > 0 || s.mark) {\n s.dry = 0\n s.mark = false\n s.wetness = 1\n s.wetRadius = 1\n }\n if (velocity) {\n const n = s.normal\n const tangential = sub(velocity, scale(n, dot(velocity, n)))\n if (length(tangential) > 0.2) s.flow = normalize(tangential)\n }\n}\n\n/** Moves the centre towards an inflow point without moving the outline. */\nexport const nudgeCenter = (s: StainInt, point: Vec3, weight: number, basis: Basis): void => {\n const delta = scale(sub(point, s.center), weight)\n if (length(delta) < 1e-6) return\n s.center = add(s.center, delta)\n for (let i = 0; i < SAMPLES; i++) s.front[i] = Math.max(0.008, s.front[i] - dot(delta, sampleDir(basis, i)))\n}\n\nexport type StainStatus = 'alive' | 'dried_mark' | 'dried_gone'\n\n/** Largest radius along each sample direction before the centre's surface rectangle ends. */\nconst edgeLimit = (s: StainInt, surface: StainSurface, i: number): number => {\n if (!Number.isFinite(surface.half[0]) && !Number.isFinite(surface.half[1])) return Infinity\n const rel = sub(s.center, surface.point)\n const cx = dot(rel, surface.t1)\n const cy = dot(rel, surface.t2)\n let limit = Infinity\n if (COS[i] > 1e-6) limit = Math.min(limit, (surface.half[0] - cx) / COS[i])\n else if (COS[i] < -1e-6) limit = Math.min(limit, (-surface.half[0] - cx) / COS[i])\n if (SIN[i] > 1e-6) limit = Math.min(limit, (surface.half[1] - cy) / SIN[i])\n else if (SIN[i] < -1e-6) limit = Math.min(limit, (-surface.half[1] - cy) / SIN[i])\n return Math.max(0.01, limit)\n}\n\n/**\n * Advances a stain: the front grows (faster downhill, with seeded noise, tapering as the area approaches what the liquid can cover at its\n * minimum film thickness), porous surfaces soak the pool, and once the inflow stopped the stain dries from the edge in.\n */\nexport const stepStain = (s: StainInt, def: LiquidDef, surface: StainSurface, ambientC: number, dt: number): StainStatus => {\n s.age += dt\n s.sinceInflow += dt\n const basis: Basis = surface\n const { dir: down, slope } = downhill(s.normal)\n\n // Soak into porous surfaces.\n if (s.liters > 0 && surface.porosity > 0) {\n const soak = Math.min(s.liters, surface.porosity * 0.2 * stainArea(s.front) * dt)\n s.liters -= soak\n s.soaked += soak\n }\n\n // Grow the flow front.\n if (s.liters > 1e-7 && s.wetness > 0) {\n const area = stainArea(s.front)\n const cover = s.liters / 1000 / (minFilm(def) * (1 - 0.7 * slope))\n if (area < cover) {\n const taper = clamp(1 - area / cover, 0, 1)\n const v0 = (0.02 + 0.2 * Math.sqrt(s.liters)) / Math.sqrt(Math.max(1, def.viscosity))\n const delta: number[] = []\n for (let i = 0; i < SAMPLES; i++) {\n let m = s.noise[i]\n if (s.flow) m *= 1 + 0.5 * Math.max(0, dot(sampleDir(basis, i), s.flow))\n if (slope > 0.02) {\n const a = dot(sampleDir(basis, i), down)\n m *= a > 0 ? 1 + 14 * slope * a : Math.max(0.1, 1 + 2.5 * slope * a)\n }\n delta.push(Math.max(0, Math.min(s.front[i] + v0 * m * taper * dt, edgeLimit(s, surface, i)) - s.front[i]))\n }\n // Never overshoot the area the liquid can cover: scale the growth (not the outline) down to fit.\n let lambda = 1\n const apply = (k: number) => s.front.map((r, i) => r + delta[i] * k)\n if (stainArea(apply(1)) > cover) {\n let lo = 0\n let hi = 1\n for (let i = 0; i < 14; i++) {\n const mid = (lo + hi) / 2\n if (stainArea(apply(mid)) > cover) hi = mid\n else lo = mid\n }\n lambda = lo\n }\n s.front = apply(lambda)\n }\n }\n\n // Dry from the edge in once the inflow stopped.\n if (s.sinceInflow > 1 && def.dryTime > 0 && s.dry < 1) {\n const warm = Math.pow(2, (ambientC - 20) / 12)\n const ds = (dt * warm * (1 + 0.5 * surface.porosity)) / def.dryTime\n const before = s.dry\n s.dry = Math.min(1, s.dry + ds)\n if (before < 1) s.liters *= 1 - (s.dry - before) / (1 - before)\n s.wetness = 1 - s.dry\n s.wetRadius = Math.sqrt(Math.max(0, 1 - s.dry))\n if (s.dry >= 1) {\n s.liters = 0\n s.wetness = 0\n s.wetRadius = 0\n if (def.leavesMark) {\n s.mark = true\n return 'dried_mark'\n }\n return 'dried_gone'\n }\n }\n return 'alive'\n}\n\n/** Unit direction (world space) of front sample `i` of a stain, from its `normal` and `tangent`. */\nexport const stainDirection = (s: Pick<StainState, 'normal' | 'tangent'>, i: number): Vec3 => sampleDir(makeBasis(s.normal ?? [0, 1, 0], s.tangent), i)\n","// The pose of a surface that moves with the object it belongs to (a table top that tips over) and what that does to the liquid on it.\nimport { add, clamp, dot, quatConjugate, quatMultiply, quatRotate, scale, sub } from './math'\nimport { downhill } from './stains'\nimport type { Basis, StainInt } from './stains'\nimport type { LiquidDef, Quat, SurfacePose, Vec3 } from './types'\n\n/** A surface as it was added: the rest the pose moves. */\nexport interface SurfaceRest {\n readonly point: Vec3\n readonly normal: Vec3\n readonly tangent: Vec3\n}\n\nexport const IDENTITY_POSE: SurfacePose = { position: [0, 0, 0], rotation: [0, 0, 0, 1] }\n\n/** Tilt (rad) from its rest a surface holds a water-like pool at; a thicker liquid clings longer. */\nconst RUNOFF_TILT = (6 * Math.PI) / 180\nconst RUNOFF_TILT_MAX = (60 * Math.PI) / 180\n/** How far past the rim (m) and how fast (m/s) the liquid that runs off leaves it. */\nconst RUNOFF_CLEARANCE = 0.02\nconst RUNOFF_SPEED = 0.6\n/** A surface whose normal points this far down holds nothing: what is on it falls straight off. */\nconst UPSIDE_DOWN_Y = -0.2\n\nconst applyPose = (pose: SurfacePose, point: Vec3): Vec3 => add(pose.position, quatRotate(pose.rotation, point))\nconst undoPose = (pose: SurfacePose, point: Vec3): Vec3 => quatRotate(quatConjugate(pose.rotation), sub(point, pose.position))\n\n/** The point, normal and tangent of the surface at `pose`. */\nexport function posedFrame(rest: SurfaceRest, pose: SurfacePose): SurfaceRest {\n return { point: applyPose(pose, rest.point), normal: quatRotate(pose.rotation, rest.normal), tangent: quatRotate(pose.rotation, rest.tangent) }\n}\n\nexport interface CarryStainParams {\n readonly stain: StainInt\n readonly from: SurfacePose\n readonly to: SurfacePose\n}\n\n/** The stain goes with the surface from one pose to the next: its centre, its plane and the way it ran. */\nexport function carryStain({ stain, from, to }: CarryStainParams): void {\n const turn: Quat = quatMultiply(to.rotation, quatConjugate(from.rotation))\n stain.center = applyPose(to, undoPose(from, stain.center))\n stain.normal = quatRotate(turn, stain.normal)\n stain.tangent = quatRotate(turn, stain.tangent)\n if (stain.flow) stain.flow = quatRotate(turn, stain.flow)\n}\n\n/** The tilt (rad) from its rest at which a pool of this liquid runs off a surface. */\nexport const runoffTilt = (def: LiquidDef): number => clamp(RUNOFF_TILT * Math.sqrt(Math.max(1, def.viscosity)), RUNOFF_TILT, RUNOFF_TILT_MAX)\n\n/** The angle (rad) the surface turned from its rest. */\nexport const tiltOf = (rest: SurfaceRest, normal: Vec3): number => Math.acos(clamp(dot(rest.normal, normal), -1, 1))\n\nexport interface RunoffParams {\n readonly center: Vec3\n readonly surface: Basis & { readonly point: Vec3; readonly half: readonly [number, number] }\n}\n\n/** Where the pool leaves the surface and how: from the lowest rim downhill of it, or straight down from under a surface turned over. */\nexport function runoffStart({ center, surface }: RunoffParams): { origin: Vec3; velocity: Vec3 } {\n const { dir, slope } = downhill(surface.normal)\n if (surface.normal[1] < UPSIDE_DOWN_Y || slope < 1e-3) return { origin: add(center, scale(surface.normal, RUNOFF_CLEARANCE)), velocity: [0, -RUNOFF_SPEED, 0] }\n const rel = sub(center, surface.point)\n const room = (half: number, at: number, along: number): number => (along > 1e-6 ? (half - at) / along : along < -1e-6 ? (-half - at) / along : Infinity)\n const reach = Math.max(0, Math.min(room(surface.half[0], dot(rel, surface.t1), dot(dir, surface.t1)), room(surface.half[1], dot(rel, surface.t2), dot(dir, surface.t2))))\n const rim = add(center, scale(dir, Number.isFinite(reach) ? reach + RUNOFF_CLEARANCE : RUNOFF_CLEARANCE))\n return { origin: add(rim, scale(surface.normal, RUNOFF_CLEARANCE)), velocity: scale(dir, RUNOFF_SPEED) }\n}\n","import { LIQUIDS } from './liquids'\nimport { GROUND_ID, MAX_FLIGHT, ballistic, trace } from './landing'\nimport type { Hit, LandingSurface } from './landing'\nimport { describeEvent, resolveStrings } from './locale'\nimport { GRAVITY, Rng, add, clamp, copy3, cross, distance, dot, length, normalize, quatConjugate, quatRotate, scale } from './math'\nimport { levelFor, lipOf, lipRadius, makeColumns, planeFraction, planeRange, shapeHeight } from './shapes'\nimport type { Columns } from './shapes'\nimport { addInflow, createStain, makeBasis, meanRadius, nudgeCenter, stepStain } from './stains'\nimport type { Basis, StainInt, StainSurface } from './stains'\nimport type {\n ContainerSpec,\n ContainerState,\n FluidEvent,\n FluidOptions,\n FluidWorld,\n LiquidDef,\n LiquidId,\n Quat,\n StainState,\n StainTint,\n StreamCause,\n StreamState,\n SurfacePose,\n SurfaceSpec,\n Vec3,\n} from './types'\nimport { IDENTITY_POSE, carryStain, posedFrame, runoffStart, runoffTilt, tiltOf } from './surface-pose'\nimport type { SurfaceRest } from './surface-pose'\n\ninterface Hole {\n point: Vec3\n normal: Vec3\n diameter: number\n}\n\ninterface ContainerInt {\n id: string\n spec: ContainerSpec\n cols: Columns\n liquid: LiquidId | null\n liters: number\n temperature: number\n closed: boolean\n position: Vec3\n rotation: Quat\n velocity: Vec3\n prevVelocity: Vec3\n hasPrev: boolean\n holes: Hole[]\n /** Slosh of the liquid surface: tilt offsets and their rates (x, z, vx, vz). */\n slosh: [number, number, number, number]\n /** Surface normal in world space (up plus slosh) and in container space, and the surface offset along it. */\n normal: Vec3\n u: Vec3\n d: number\n steaming: boolean\n outflow: number\n /** Stream key (`spill`, `pour`, `leak:<n>`) to stream id. */\n streams: Record<string, string>\n pourRate: number\n pourTTL: number\n pourVisual: boolean\n lastMix: number\n}\n\ninterface TapInt {\n id: string\n position: Vec3\n direction: Vec3\n liquid: LiquidId\n rate: number\n temperature: number\n on: boolean\n stream?: string\n}\n\ninterface StreamInt extends StreamState {\n key: string\n lastSplash: number\n visualOnly: boolean\n temperature: number\n}\n\ninterface SurfaceInt extends SurfaceSpec, StainSurface {\n /** Where it was added, and the move of it since (`setSurfacePose`, `moveSurface`). */\n rest: SurfaceRest\n pose: SurfacePose\n}\n\n/** A surface of a snapshot: as it was added, and its pose when it was moved. */\ntype SnapshotSurface = SurfaceSpec & { pose?: SurfacePose }\n\ninterface Snapshot {\n version: 1\n time: number\n rng: number\n counters: { container: number; stream: number; stain: number; tap?: number }\n taps?: TapInt[]\n containers: Array<Omit<ContainerInt, 'cols'>>\n surfaces: SnapshotSurface[]\n streams: StreamInt[]\n stains: StainInt[]\n}\n\nconst GROUND_POROSITY = 0.2\nconst MAX_STEP = 0.1\nconst MAX_SUBSTEPS = 50\nconst MAX_HOLES = 32\n\nconst clone = <T>(v: T): T => JSON.parse(JSON.stringify(v)) as T\n\nexport function createFluids(options: FluidOptions = {}): FluidWorld {\n const strings = resolveStrings(options.locale)\n const liquids = new Map<LiquidId, LiquidDef>()\n for (const def of LIQUIDS) liquids.set(def.id, def)\n for (const def of options.liquids ?? []) liquids.set(def.id, def)\n const ambientC = options.ambientC ?? 20\n const gravity = options.gravity ?? GRAVITY\n const groundAt = options.groundAt ?? (() => 0)\n const mergeDistance = options.mergeDistance ?? 0.15\n const maxStains = options.maxStains ?? 64\n\n let rng = new Rng(options.seed ?? 1)\n let time = 0\n const counters = { container: 0, stream: 0, stain: 0, tap: 0 }\n let containers = new Map<string, ContainerInt>()\n let surfaces = new Map<string, SurfaceInt>()\n let streams = new Map<string, StreamInt>()\n let taps = new Map<string, TapInt>()\n let stains = new Map<string, StainInt>()\n const listeners = new Map<string, Set<(e: FluidEvent) => void>>()\n let queue: FluidEvent[] = []\n /** Only events produced by `update` are queued and returned by it; direct calls just notify the listeners. */\n let updating = false\n\n const groundSurface: StainSurface = {\n normal: [0, 1, 0],\n t1: [1, 0, 0],\n t2: [0, 0, -1],\n point: [0, 0, 0],\n half: [Infinity, Infinity],\n porosity: GROUND_POROSITY,\n }\n\n // ---- events ----\n\n const emit = (e: FluidEvent): void => {\n if (updating) queue.push(e)\n options.onEvent?.(e)\n listeners.get(e.type)?.forEach((fn) => fn(e))\n listeners.get('*')?.forEach((fn) => fn(e))\n }\n\n // ---- helpers ----\n\n const toWorld = (c: ContainerInt, p: Vec3): Vec3 => add(c.position, quatRotate(c.rotation, p))\n const defOf = (c: ContainerInt): LiquidDef | null => (c.liquid ? (liquids.get(c.liquid) ?? null) : null)\n const viscScale = (def: LiquidDef): number => 1 / Math.sqrt(Math.max(1, def.viscosity))\n\n const refreshLevel = (c: ContainerInt): void => {\n c.normal = normalize([c.slosh[0], 1, c.slosh[1]])\n c.u = normalize(quatRotate(quatConjugate(c.rotation), c.normal))\n c.d = levelFor(c.cols, c.u, c.spec.capacity > 0 ? c.liters / c.spec.capacity : 0)\n }\n\n const surfaceFor = (id: string): StainSurface => (id === GROUND_ID ? groundSurface : (surfaces.get(id) ?? groundSurface))\n\n const landingSurfaces = (except?: string): LandingSurface[] => {\n const list: LandingSurface[] = []\n for (const [id, s] of surfaces) if (id !== except) list.push({ id, normal: s.normal, t1: s.t1, t2: s.t2, point: s.point, half: s.half })\n return list\n }\n\n /** Moves a surface to `pose` from its rest; the stains on it go along when `carry` (a snapshot loads them where they already are). */\n const poseSurface = (surface: SurfaceInt, pose: SurfacePose, carry: boolean): void => {\n const from = surface.pose\n const to: SurfacePose = { position: copy3(pose.position), rotation: [pose.rotation[0], pose.rotation[1], pose.rotation[2], pose.rotation[3]] }\n if (carry) for (const st of stains.values()) if (st.surface === surface.id) carryStain({ stain: st, from, to })\n const frame = posedFrame(surface.rest, to)\n Object.assign(surface, makeBasis(frame.normal, frame.tangent), { point: frame.point, normal: frame.normal, pose: to })\n }\n\n /** The pool of a stain on a surface turned past what its liquid holds on leaves by the low rim and lands on what is under it; the soaked part stays. */\n const runOff = (st: StainInt, def: LiquidDef): void => {\n const surface = surfaces.get(st.surface)\n if (!surface || st.liters <= 1e-6 || tiltOf(surface.rest, surface.normal) <= runoffTilt(def)) return\n const { origin, velocity } = runoffStart({ center: st.center, surface })\n const liters = st.liters\n st.liters = 0\n const hit = trace(landingSurfaces(surface.id), groundAt, origin, velocity, gravity)\n if (hit) deposit(st.liquid, hit, liters, hit.velocity, st.tint)\n }\n\n const stopStream = (id: string): void => {\n const s = streams.get(id)\n if (!s) return\n streams.delete(id)\n const c = s.container ? containers.get(s.container) : undefined\n if (c) delete c.streams[s.key]\n const tap = s.tap ? taps.get(s.tap) : undefined\n if (tap && tap.stream === id) tap.stream = undefined\n emit({ type: 'stream_end', stream: id })\n }\n\n const endStreamKey = (c: ContainerInt, key: string): void => {\n const id = c.streams[key]\n if (id) stopStream(id)\n }\n\n /** Create or update the stream under `key` of a container; creating one emits the matching cause event. */\n const syncStream = (\n c: ContainerInt,\n key: string,\n cause: StreamCause,\n rate: number,\n origin: Vec3,\n velocity: Vec3,\n visualOnly = false,\n ): void => {\n if (rate < 1e-5 || !c.liquid) {\n endStreamKey(c, key)\n return\n }\n const existing = c.streams[key] ? streams.get(c.streams[key]) : undefined\n if (existing) {\n existing.rate = rate\n existing.origin = origin\n existing.velocity = velocity\n existing.thin = rate < 0.04\n existing.visualOnly = visualOnly\n existing.temperature = c.temperature\n return\n }\n const id = `stream_${++counters.stream}`\n const stream: StreamInt = {\n id,\n liquid: c.liquid,\n cause,\n container: c.id,\n origin,\n velocity,\n rate,\n landing: null,\n thin: rate < 0.04,\n flightTime: MAX_FLIGHT,\n key,\n lastSplash: -1,\n visualOnly,\n temperature: c.temperature,\n }\n streams.set(id, stream)\n c.streams[key] = id\n if (cause === 'leak') emit({ type: 'leak', container: c.id, liquid: c.liquid, rate, stream: id, point: copy3(origin) })\n else if (cause === 'spill') emit({ type: 'spill', container: c.id, liquid: c.liquid, rate, stream: id })\n else emit({ type: 'pour', container: c.id, liquid: c.liquid, rate, stream: id })\n }\n\n /** Speed (m/s) at which a tap's liquid leaves the nozzle. */\n const TAP_SPEED = 1.2\n\n /** Create or update the `tap` stream of a tap that is on; end it when it is off. */\n const syncTap = (t: TapInt): void => {\n if (!t.on || t.rate < 1e-5 || !liquids.has(t.liquid)) {\n if (t.stream) stopStream(t.stream)\n return\n }\n const velocity: Vec3 = [t.direction[0] * TAP_SPEED, t.direction[1] * TAP_SPEED, t.direction[2] * TAP_SPEED]\n const existing = t.stream ? streams.get(t.stream) : undefined\n if (existing) {\n existing.rate = t.rate\n existing.thin = t.rate < 0.04\n existing.temperature = t.temperature\n existing.velocity = velocity\n return\n }\n const id = `stream_${++counters.stream}`\n streams.set(id, {\n id,\n liquid: t.liquid,\n cause: 'tap',\n tap: t.id,\n origin: copy3(t.position),\n velocity,\n rate: t.rate,\n landing: null,\n thin: t.rate < 0.04,\n flightTime: MAX_FLIGHT,\n key: `tap:${t.id}`,\n lastSplash: -1,\n visualOnly: false,\n temperature: t.temperature,\n })\n t.stream = id\n }\n\n /** Where and how fast the liquid leaves over the lowest lip point. */\n const lipFlow = (c: ContainerInt, head: number): { origin: Vec3; velocity: Vec3 } => {\n const lip = lipOf(c.spec.shape, c.spec.opening, c.u)\n const origin = toWorld(c, lip.point)\n let dir: Vec3 = [1, 0, 0]\n const horizontal = (v: Vec3): Vec3 | null => (Math.hypot(v[0], v[2]) > 1e-3 ? normalize([v[0], 0, v[2]]) : null)\n if (lip.outward) dir = horizontal(quatRotate(c.rotation, lip.outward)) ?? horizontal(quatRotate(c.rotation, [1, 0, 0])) ?? dir\n else dir = horizontal(quatRotate(c.rotation, [1, 0, 0])) ?? dir\n const speed = clamp(0.3 + 0.5 * Math.sqrt(2 * gravity * Math.max(0, head)), 0.2, 2.5)\n return { origin, velocity: [dir[0] * speed, -0.1, dir[2] * speed] }\n }\n\n const removeLiters = (c: ContainerInt, amount: number): void => {\n c.liters = Math.max(0, c.liters - amount)\n }\n\n /** Clear a container that ran out and emit `empty` once. */\n const settle = (c: ContainerInt): void => {\n if (c.liquid && c.liters <= 1e-6) {\n c.liters = 0\n c.liquid = null\n emit({ type: 'empty', container: c.id })\n }\n }\n\n const fillInternal = (c: ContainerInt, liquid: LiquidId, liters: number, temperature: number | undefined, announce: boolean): number => {\n if (!(liters > 0) || !liquids.has(liquid)) return 0\n const room = c.spec.capacity - c.liters\n const accepted = Math.min(liters, Math.max(0, room))\n if (accepted <= 0) return 0\n const t = temperature ?? ambientC\n if (c.liquid && c.liquid !== liquid && c.liters > 1e-6) {\n const incomingWins = accepted > c.liters\n const into = incomingWins ? liquid : c.liquid\n const from = incomingWins ? c.liquid : liquid\n if (announce || time - c.lastMix > 0.5) {\n c.lastMix = time\n emit({ type: 'mix', container: c.id, from, into })\n }\n c.liquid = into\n } else if (!c.liquid || c.liters <= 1e-6) {\n c.liquid = liquid\n }\n c.temperature = c.liters > 1e-6 ? (c.temperature * c.liters + t * accepted) / (c.liters + accepted) : t\n c.liters += accepted\n if (announce) emit({ type: 'fill', container: c.id, liquid, liters: accepted })\n return accepted\n }\n\n // ---- stains ----\n\n const stainAt = (surfaceId: string, liquid: LiquidId, point: Vec3): StainInt | null => {\n let best: StainInt | null = null\n let bestD = Infinity\n for (const s of stains.values()) {\n if (s.surface !== surfaceId || s.liquid !== liquid) continue\n const d = distance(point, s.center)\n if (d < mergeDistance + 0.5 * meanRadius(s.front) && d < bestD) {\n best = s\n bestD = d\n }\n }\n return best\n }\n\n const evictStain = (): void => {\n let victim: StainInt | null = null\n for (const s of stains.values()) {\n const rank = (x: StainInt) => (x.wetness <= 0 ? 0 : 1) * 1e9 - x.age\n if (!victim || rank(s) < rank(victim)) victim = s\n }\n if (victim) stains.delete(victim.id)\n }\n\n const deposit = (liquid: LiquidId, hit: Pick<Hit, 'point' | 'surface' | 'normal'>, liters: number, velocity: Vec3 | null, tint?: StainTint): void => {\n const def = liquids.get(liquid)\n if (!def || liters <= 0) return\n let s = stainAt(hit.surface, liquid, hit.point)\n if (s) {\n const basis: Basis = { normal: s.normal, t1: s.tangent, t2: cross(s.normal, s.tangent) }\n nudgeCenter(s, hit.point, clamp((liters / (s.liters + liters)) * 0.5, 0, 0.5), basis)\n addInflow(s, liters, velocity)\n if (tint) s.tint = { ...tint }\n return\n }\n while (stains.size >= maxStains) evictStain()\n const surface = surfaceFor(hit.surface)\n const basis: Basis = hit.surface === GROUND_ID ? makeBasis(hit.normal) : surface\n s = createStain(`stain_${++counters.stain}`, hit.surface, def, basis, hit.point, liters, rng)\n if (velocity) addInflow(s, 0, velocity)\n if (tint) s.tint = { ...tint }\n s.sinceInflow = 0\n stains.set(s.id, s)\n emit({ type: 'stain', stain: s.id, surface: hit.surface, liquid, point: copy3(hit.point) })\n }\n\n // ---- streams ----\n\n const lipCenterWorld = (c: ContainerInt): Vec3 => toWorld(c, [0, shapeHeight(c.spec.shape), 0])\n\n /** A container whose opening the jet passes through before it lands (pouring into a cup). */\n const catcher = (s: StreamInt, landingT: number): { container: ContainerInt; t: number; point: Vec3 } | null => {\n let best: { container: ContainerInt; t: number; point: Vec3 } | null = null\n for (const oc of containers.values()) {\n if (oc.id === s.container || oc.closed || oc.liters >= oc.spec.capacity) continue\n const lip = lipCenterWorld(oc)\n const disc = s.velocity[1] * s.velocity[1] - 2 * gravity * (lip[1] - s.origin[1])\n if (disc < 0) continue\n const t = (s.velocity[1] + Math.sqrt(disc)) / gravity\n if (t <= 0 || t >= landingT || (best && t >= best.t)) continue\n const p = ballistic(s.origin, s.velocity, gravity, t)\n if (Math.hypot(p[0] - lip[0], p[2] - lip[2]) <= lipRadius(oc.spec.shape, oc.spec.opening) + 0.01) best = { container: oc, t, point: p }\n }\n return best\n }\n\n const stepStream = (s: StreamInt, dt: number): void => {\n const hit = trace(landingSurfaces(), groundAt, s.origin, s.velocity, gravity)\n const caught = catcher(s, hit ? hit.t : MAX_FLIGHT)\n if (caught) {\n s.landing = caught.point\n s.flightTime = caught.t\n if (!s.visualOnly) fillInternal(caught.container, s.liquid, s.rate * dt, s.temperature, false)\n return\n }\n s.landing = hit ? copy3(hit.point) : null\n s.flightTime = hit ? hit.t : MAX_FLIGHT\n if (!hit || s.visualOnly) return\n const speed = length(hit.velocity)\n if (time - s.lastSplash >= 0.12) {\n s.lastSplash = time\n emit({ type: 'splash', liquid: s.liquid, point: copy3(hit.point), intensity: clamp(0.15 + s.rate * 1.2 + speed * 0.05, 0, 1) })\n }\n deposit(s.liquid, hit, s.rate * dt, hit.velocity)\n }\n\n // ---- containers ----\n\n const spillRate = (c: ContainerInt, def: LiquidDef, h: number): number => {\n const ro = lipRadius(c.spec.shape, c.spec.opening)\n const area = 2 * ro * Math.min(h, ro)\n return Math.max(0.6 * area * Math.sqrt(2 * gravity * h) * 1000 * viscScale(def), 0.004)\n }\n\n const steamThreshold = (def: LiquidDef): number => def.steamC ?? (def.drink && def.drink.thirst > 0 ? 60 : Infinity)\n\n const stepContainer = (c: ContainerInt, dt: number): void => {\n // Slosh: the surface tilts towards the horizontal acceleration and settles with a damped spring.\n if (c.hasPrev && dt > 0) {\n const ax = (c.velocity[0] - c.prevVelocity[0]) / dt\n const az = (c.velocity[2] - c.prevVelocity[2]) / dt\n const tx = clamp(ax / gravity, -0.35, 0.35)\n const tz = clamp(az / gravity, -0.35, 0.35)\n const w = 9\n const z = 0.12\n c.slosh[2] += (w * w * (tx - c.slosh[0]) - 2 * z * w * c.slosh[2]) * dt\n c.slosh[3] += (w * w * (tz - c.slosh[1]) - 2 * z * w * c.slosh[3]) * dt\n } else {\n c.slosh[2] *= 0.5\n c.slosh[3] *= 0.5\n }\n c.slosh[0] += c.slosh[2] * dt\n c.slosh[1] += c.slosh[3] * dt\n if (Math.abs(c.slosh[0]) + Math.abs(c.slosh[1]) + Math.abs(c.slosh[2]) + Math.abs(c.slosh[3]) < 1e-5) c.slosh = [0, 0, 0, 0]\n c.prevVelocity = copy3(c.velocity)\n c.hasPrev = true\n\n // Cooling towards ambient (insulated containers 10× slower).\n if (c.temperature !== ambientC) {\n const tau = (600 + 2400 * c.liters) * (c.spec.insulated ? 10 : 1)\n c.temperature = ambientC + (c.temperature - ambientC) * Math.exp(-dt / tau)\n if (Math.abs(c.temperature - ambientC) < 0.01) c.temperature = ambientC\n }\n\n refreshLevel(c)\n const def = defOf(c)\n\n const steaming = !!def && c.liters > 1e-6 && !c.closed && c.temperature > steamThreshold(def)\n if (steaming !== c.steaming) {\n c.steaming = steaming\n emit({ type: 'steam', container: c.id, on: steaming })\n }\n\n c.outflow = 0\n if (!def || c.liters <= 1e-6) {\n for (const key of Object.keys(c.streams)) endStreamKey(c, key)\n c.pourTTL = 0\n settle(c)\n return\n }\n\n // Pour (driven by `pour()`), else spill over the lip when the tilted surface rises above it.\n if (c.pourTTL > 0) {\n c.pourTTL -= dt\n if (c.pourTTL > 0) {\n const flow = lipFlow(c, 0.05)\n syncStream(c, 'pour', 'pour', c.pourRate, flow.origin, flow.velocity, c.pourVisual)\n c.outflow += c.pourRate\n } else endStreamKey(c, 'pour')\n endStreamKey(c, 'spill')\n } else {\n endStreamKey(c, 'pour')\n const lip = lipOf(c.spec.shape, c.spec.opening, c.u)\n const h = c.d - lip.level\n let handled = false\n if (!c.closed && h > 1e-5) {\n const excess = c.liters - c.spec.capacity * planeFraction(c.cols, c.u, lip.level)\n if (excess > 1e-6) {\n const rate = Math.min(spillRate(c, def, h), excess / Math.max(dt, 1e-6))\n removeLiters(c, Math.min(rate * dt, excess, c.liters))\n const flow = lipFlow(c, h)\n syncStream(c, 'spill', 'spill', rate, flow.origin, flow.velocity)\n c.outflow += rate\n handled = true\n }\n }\n if (!handled) endStreamKey(c, 'spill')\n }\n\n // Holes leak by Torricelli with the head above each hole.\n for (let i = 0; i < c.holes.length; i++) {\n const hole = c.holes[i]\n const key = `leak:${i}`\n const hh = dot(c.u, hole.point)\n const head = c.d - hh\n if (c.liters > 1e-6 && head > 1e-4) {\n const area = Math.PI * (hole.diameter / 2) ** 2\n const natural = 0.6 * area * Math.sqrt(2 * gravity * head) * 1000 * viscScale(def)\n const avail = c.liters - c.spec.capacity * planeFraction(c.cols, c.u, hh)\n if (avail > 1e-7) {\n const rate = Math.min(natural, avail / Math.max(dt, 1e-6))\n removeLiters(c, Math.min(rate * dt, avail))\n const nW = normalize(quatRotate(c.rotation, hole.normal))\n const v = Math.min(3, 0.6 * Math.sqrt(2 * gravity * head))\n syncStream(c, key, 'leak', rate, toWorld(c, hole.point), [nW[0] * v, nW[1] * v - 0.05, nW[2] * v])\n c.outflow += rate\n continue\n }\n }\n endStreamKey(c, key)\n }\n if (c.holes.length > 0 || c.outflow > 0) refreshLevel(c)\n settle(c)\n }\n\n const step = (dt: number): void => {\n time += dt\n for (const c of [...containers.values()]) stepContainer(c, dt)\n for (const s of [...streams.values()]) stepStream(s, dt)\n for (const st of [...stains.values()]) {\n const def = liquids.get(st.liquid)\n if (!def) continue\n runOff(st, def)\n const status = stepStain(st, def, surfaceFor(st.surface), ambientC, dt)\n if (status === 'dried_mark') emit({ type: 'dried', stain: st.id, mark: true })\n else if (status === 'dried_gone') {\n stains.delete(st.id)\n emit({ type: 'dried', stain: st.id, mark: false })\n }\n }\n }\n\n // ---- public state views ----\n\n const stateOf = (c: ContainerInt): ContainerState => ({\n id: c.id,\n liquid: c.liquid,\n liters: c.liters,\n capacity: c.spec.capacity,\n temperature: c.temperature,\n closed: c.closed,\n surfaceHeight: c.liters > 0 ? c.d : 0,\n surfacePoint: add(c.position, scale(c.normal, c.liters > 0 ? c.d : 0)),\n surfaceNormal: copy3(c.normal),\n holes: c.holes.map((h) => ({ point: copy3(h.point), normal: copy3(h.normal), diameter: h.diameter })),\n outflow: c.outflow,\n steaming: c.steaming,\n shape: c.spec.shape,\n lipRadius: lipRadius(c.spec.shape, c.spec.opening),\n position: copy3(c.position),\n rotation: [...c.rotation] as Quat,\n })\n\n const streamView = (s: StreamInt): StreamState => ({\n id: s.id,\n liquid: s.liquid,\n cause: s.cause,\n container: s.container,\n tap: s.tap,\n origin: copy3(s.origin),\n velocity: copy3(s.velocity),\n rate: s.rate,\n landing: s.landing ? copy3(s.landing) : null,\n thin: s.thin,\n flightTime: s.flightTime,\n })\n\n const stainView = (s: StainInt): StainState => ({\n id: s.id,\n surface: s.surface,\n liquid: s.liquid,\n center: copy3(s.center),\n front: [...s.front],\n liters: s.liters,\n soaked: s.soaked,\n wetness: s.wetness,\n wetRadius: s.wetRadius,\n normal: copy3(s.normal),\n tangent: copy3(s.tangent),\n flow: s.flow ? copy3(s.flow) : undefined,\n mark: s.mark,\n age: s.age,\n tint: s.tint ? { ...s.tint } : undefined,\n })\n\n // ---- world API ----\n\n const world: FluidWorld = {\n liquids,\n gravity,\n describe: (event) => describeEvent(strings, event),\n\n addContainer(spec, opts = {}) {\n const id = opts.id ?? `container_${++counters.container}`\n if (containers.has(id)) world.removeContainer(id)\n const liquid = spec.liquid && liquids.has(spec.liquid) ? spec.liquid : null\n const liters = liquid ? clamp(spec.liters ?? 0, 0, spec.capacity) : 0\n const c: ContainerInt = {\n id,\n spec: clone(spec),\n cols: makeColumns(spec.shape),\n liquid: liters > 0 ? liquid : null,\n liters,\n temperature: spec.temperature ?? ambientC,\n closed: spec.closed ?? spec.opening <= 0,\n position: copy3(opts.position ?? [0, 0, 0]),\n rotation: opts.rotation ? ([...opts.rotation] as Quat) : [0, 0, 0, 1],\n velocity: [0, 0, 0],\n prevVelocity: [0, 0, 0],\n hasPrev: false,\n holes: [],\n slosh: [0, 0, 0, 0],\n normal: [0, 1, 0],\n u: [0, 1, 0],\n d: 0,\n steaming: false,\n outflow: 0,\n streams: {},\n pourRate: 0,\n pourTTL: 0,\n pourVisual: false,\n lastMix: -10,\n }\n containers.set(id, c)\n refreshLevel(c)\n return id\n },\n\n addTap(spec) {\n const id = spec.id ?? `tap_${++counters.tap}`\n if (taps.has(id)) world.removeTap(id)\n const d = spec.direction ?? [0, -1, 0]\n const len = Math.hypot(d[0], d[1], d[2]) || 1\n const t: TapInt = {\n id,\n position: copy3(spec.position),\n direction: [d[0] / len, d[1] / len, d[2] / len],\n liquid: spec.liquid,\n rate: Math.max(0, spec.rate),\n temperature: spec.temperature ?? ambientC,\n on: false,\n }\n taps.set(id, t)\n if (spec.on ?? true) world.setTap(id, true)\n return id\n },\n\n setTap(id, on, rate) {\n const t = taps.get(id)\n if (!t) return\n if (rate !== undefined) t.rate = Math.max(0, rate)\n const changed = t.on !== on\n t.on = on\n syncTap(t)\n if (changed) emit({ type: 'tap', tap: id, on })\n },\n\n removeTap(id) {\n const t = taps.get(id)\n if (!t) return\n t.on = false\n syncTap(t)\n taps.delete(id)\n },\n\n taps: () => [...taps.values()].map((t) => ({ id: t.id, position: copy3(t.position), direction: copy3(t.direction), liquid: t.liquid, rate: t.rate, temperature: t.temperature, on: t.on, stream: t.stream })),\n\n removeContainer(id) {\n const c = containers.get(id)\n if (!c) return\n for (const key of Object.keys(c.streams)) endStreamKey(c, key)\n containers.delete(id)\n },\n\n shatter(id) {\n const c = containers.get(id)\n if (!c) return\n const liquid = c.liquid\n const liters = c.liters\n const at = add(c.position, scale(c.normal, c.liters > 0 ? c.d : 0))\n world.removeContainer(id)\n if (liquid && liters > 0) world.splash(liquid, at, liters, c.velocity)\n },\n\n setTransform(id, position, rotation, velocity) {\n const c = containers.get(id)\n if (!c) return\n c.position = copy3(position)\n c.rotation = [...rotation] as Quat\n if (velocity) c.velocity = copy3(velocity)\n refreshLevel(c)\n },\n\n open(id) {\n const c = containers.get(id)\n if (c) c.closed = false\n },\n\n close(id) {\n const c = containers.get(id)\n if (!c) return\n c.closed = true\n for (const key of ['pour', 'spill']) endStreamKey(c, key)\n c.pourTTL = 0\n },\n\n fill(id, liquid, liters, temperature) {\n const c = containers.get(id)\n if (!c || c.closed) return 0\n const accepted = fillInternal(c, liquid, liters, temperature, true)\n refreshLevel(c)\n return accepted\n },\n\n pour(id, dt, into) {\n const c = containers.get(id)\n const def = c ? defOf(c) : null\n if (!c || !def || c.closed || c.liters <= 1e-6 || !(dt > 0)) return 0\n refreshLevel(c)\n const lip = lipOf(c.spec.shape, c.spec.opening, c.u)\n const depth = Math.max(0, c.d - planeRange(c.cols, c.u)[0])\n const head = Math.max(c.d - lip.level, 0.02 + 0.5 * depth)\n const ro = lipRadius(c.spec.shape, c.spec.opening)\n const natural = 0.6 * Math.PI * ro * ro * Math.sqrt(2 * gravity * head) * 1000\n const rate = Math.min(natural, 0.15 + 12 * ro) * viscScale(def)\n const out = Math.min(rate * dt, c.liters)\n const target = into ? containers.get(into) : undefined\n let delivered = out\n if (target) {\n delivered = fillInternal(target, c.liquid as LiquidId, out, c.temperature, false)\n refreshLevel(target)\n const overflow = out - delivered\n if (overflow > 1e-6) {\n const flow = lipFlow(c, head)\n const hit = trace(landingSurfaces(), groundAt, flow.origin, flow.velocity, gravity)\n if (hit) deposit(c.liquid as LiquidId, hit, overflow, hit.velocity)\n }\n }\n removeLiters(c, out)\n c.pourRate = out / dt\n c.pourTTL = Math.max(0.12, dt * 1.5)\n c.pourVisual = !!target\n const flow = lipFlow(c, head)\n syncStream(c, 'pour', 'pour', c.pourRate, flow.origin, flow.velocity, c.pourVisual)\n refreshLevel(c)\n settle(c)\n return out\n },\n\n drink(id, liters, options) {\n const c = containers.get(id)\n const def = c ? defOf(c) : null\n if (!c || !def || c.closed || c.liters <= 1e-6 || !(liters > 0)) return null\n const amount = Math.min(liters, c.liters)\n removeLiters(c, amount)\n const event: Extract<FluidEvent, { type: 'drink' }> = {\n type: 'drink',\n container: c.id,\n liquid: def.id,\n liters: amount,\n temperature: c.temperature,\n thirst: (def.drink?.thirst ?? 0) * amount,\n effects: options?.eaten ? [] : [...(def.drink?.effects ?? [])],\n burn: c.temperature > 65,\n ...(options?.eaten ? { eaten: true } : {}),\n }\n emit(event)\n refreshLevel(c)\n settle(c)\n return event\n },\n\n puncture(id, point, normal, diameter) {\n const c = containers.get(id)\n if (!c || !(diameter > 0) || c.holes.length >= MAX_HOLES) return\n c.holes.push({ point: copy3(point), normal: normalize(normal), diameter })\n },\n\n heat(id, deltaC) {\n const c = containers.get(id)\n if (c) c.temperature = clamp(c.temperature + deltaC, -50, 1000)\n },\n\n addSurface(spec) {\n const basis = makeBasis(spec.normal, spec.tangent)\n surfaces.set(spec.id, {\n ...clone(spec),\n ...basis,\n point: copy3(spec.point),\n half: [spec.halfSize[0], spec.halfSize[1]],\n rest: { point: copy3(spec.point), normal: copy3(basis.normal), tangent: copy3(basis.t1) },\n pose: IDENTITY_POSE,\n })\n },\n\n removeSurface(id) {\n surfaces.delete(id)\n for (const s of [...stains.values()]) if (s.surface === id) stains.delete(s.id)\n },\n\n moveSurface(id, offset) {\n const surface = surfaces.get(id)\n if (surface) poseSurface(surface, { position: add(surface.pose.position, offset), rotation: surface.pose.rotation }, true)\n },\n\n setSurfacePose(id, pose) {\n const surface = surfaces.get(id)\n if (surface) poseSurface(surface, pose, true)\n },\n\n splash(liquid, point, liters, velocity, options) {\n if (!liquids.has(liquid) || !(liters > 0)) return\n const v: Vec3 = velocity ?? [0, -0.1, 0]\n const origin = add(point, [0, 0.02, 0])\n const hit = trace(landingSurfaces(), groundAt, origin, v, gravity)\n if (!hit) return\n emit({ type: 'splash', liquid, point: copy3(hit.point), intensity: clamp(0.3 + liters * 2, 0, 1) })\n deposit(liquid, hit, liters, length(v) > 0.3 ? hit.velocity : null, options?.tint)\n },\n\n clearStains(point, radius) {\n for (const s of [...stains.values()]) {\n if (distance(point, s.center) <= radius + 0.5 * meanRadius(s.front)) {\n stains.delete(s.id)\n emit({ type: 'dried', stain: s.id, mark: false })\n }\n }\n },\n\n update(dt) {\n if (dt > 0) {\n const n = clamp(Math.ceil(dt / MAX_STEP), 1, MAX_SUBSTEPS)\n updating = true\n try {\n for (let i = 0; i < n; i++) step(dt / n)\n } finally {\n updating = false\n }\n }\n const out = queue\n queue = []\n return out\n },\n\n container: (id) => {\n const c = containers.get(id)\n return c ? stateOf(c) : null\n },\n containers: () => [...containers.values()].map(stateOf),\n streams: () => [...streams.values()].map(streamView),\n stains: () => [...stains.values()].map(stainView),\n\n on(type, fn) {\n let set = listeners.get(type)\n if (!set) listeners.set(type, (set = new Set()))\n set.add(fn)\n return () => {\n set?.delete(fn)\n }\n },\n\n serialize() {\n const snapshot: Snapshot = {\n version: 1,\n time,\n rng: rng.state,\n counters: { ...counters },\n containers: [...containers.values()].map((c) => {\n const { cols: _cols, ...rest } = c\n return clone(rest)\n }),\n surfaces: [...surfaces.values()].map((s) => {\n const moved = s.pose !== IDENTITY_POSE\n return clone({ id: s.id, point: s.rest.point, normal: s.rest.normal, halfSize: s.half, tangent: s.rest.tangent, porosity: s.porosity, ...(moved ? { pose: s.pose } : {}) })\n }),\n streams: [...streams.values()].map((s) => clone(s)),\n taps: [...taps.values()].map((t) => clone(t)),\n stains: [...stains.values()].map((s) => clone(s)),\n }\n return snapshot\n },\n\n load(input) {\n const snap = clone(input) as Snapshot\n if (!snap || snap.version !== 1) throw new Error('game-fluids: unsupported snapshot')\n time = snap.time\n rng = new Rng(0)\n rng.state = snap.rng\n counters.container = snap.counters.container\n counters.stream = snap.counters.stream\n counters.stain = snap.counters.stain\n containers = new Map()\n for (const raw of snap.containers) containers.set(raw.id, { ...raw, cols: makeColumns(raw.spec.shape) })\n surfaces = new Map()\n for (const { pose, ...spec } of snap.surfaces) {\n world.addSurface(spec)\n const surface = surfaces.get(spec.id)\n if (pose && surface) poseSurface(surface, pose, false)\n }\n counters.tap = snap.counters.tap ?? 0\n streams = new Map(snap.streams.map((s) => [s.id, s]))\n taps = new Map((snap.taps ?? []).map((t) => [t.id, t]))\n stains = new Map(snap.stains.map((s) => [s.id, s]))\n queue = []\n },\n }\n\n return world\n}\n","[\n {\n \"id\": \"sip\",\n \"duration\": 1.2,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.35,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.45,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -0.9,\n 0,\n 0\n ],\n \"action\": \"drink\",\n \"rate\": 0.06\n },\n {\n \"t\": 0.95,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -0.9,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 1.2,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"drink\",\n \"duration\": 2.5,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.5,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.8,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -1.22,\n 0,\n 0\n ],\n \"action\": \"drink\",\n \"rate\": 0.1667\n },\n {\n \"t\": 2.0,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -1.22,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 2.5,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"chug\",\n \"duration\": 4,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.5,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.9,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -1.45,\n 0,\n 0\n ],\n \"action\": \"drink\",\n \"rate\": 0.2\n },\n {\n \"t\": 3.4,\n \"position\": [\n 0.0,\n 0.02,\n -0.2\n ],\n \"rotation\": [\n -1.45,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 4,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"eat\",\n \"duration\": 3.6,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.4,\n \"position\": [\n 0.04,\n -0.12,\n -0.28\n ],\n \"rotation\": [\n -0.35,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.6,\n \"position\": [\n 0.04,\n -0.1,\n -0.26\n ],\n \"rotation\": [\n -0.45,\n 0,\n 0\n ],\n \"action\": \"eat\",\n \"rate\": 0.06\n },\n {\n \"t\": 1.3,\n \"position\": [\n 0.04,\n -0.12,\n -0.28\n ],\n \"rotation\": [\n -0.35,\n 0,\n 0\n ],\n \"action\": \"eat\",\n \"rate\": 0.06\n },\n {\n \"t\": 2.0,\n \"position\": [\n 0.04,\n -0.1,\n -0.26\n ],\n \"rotation\": [\n -0.45,\n 0,\n 0\n ],\n \"action\": \"eat\",\n \"rate\": 0.06\n },\n {\n \"t\": 2.7,\n \"position\": [\n 0.04,\n -0.12,\n -0.28\n ],\n \"rotation\": [\n -0.35,\n 0,\n 0\n ],\n \"action\": \"eat\",\n \"rate\": 0.06\n },\n {\n \"t\": 3.1,\n \"position\": [\n 0.04,\n -0.12,\n -0.28\n ],\n \"rotation\": [\n -0.35,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 3.6,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"pour\",\n \"duration\": 3,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.4,\n \"position\": [\n 0.1,\n 0.0,\n -0.35\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.8,\n \"position\": [\n 0.1,\n 0.0,\n -0.35\n ],\n \"rotation\": [\n -1.745,\n 0,\n 0\n ],\n \"action\": \"pour\",\n \"rate\": 1\n },\n {\n \"t\": 2.4,\n \"position\": [\n 0.1,\n 0.0,\n -0.35\n ],\n \"rotation\": [\n -1.745,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 3,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"pour_out\",\n \"duration\": 4,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.5,\n \"position\": [\n 0.1,\n 0.1,\n -0.35\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 1.0,\n \"position\": [\n 0.1,\n 0.1,\n -0.35\n ],\n \"rotation\": [\n -2.2,\n 0,\n 0\n ],\n \"action\": \"pour\",\n \"rate\": 40\n },\n {\n \"t\": 3.2,\n \"position\": [\n 0.1,\n 0.1,\n -0.35\n ],\n \"rotation\": [\n -2.2,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 4,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"open\",\n \"duration\": 1,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.25,\n \"position\": [\n 0.1,\n 0,\n -0.3\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"open\"\n },\n {\n \"t\": 0.7,\n \"position\": [\n 0.1,\n 0,\n -0.3\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 1,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"close\",\n \"duration\": 1,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.25,\n \"position\": [\n 0.1,\n 0,\n -0.3\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"close\"\n },\n {\n \"t\": 0.7,\n \"position\": [\n 0.1,\n 0,\n -0.3\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 1,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n },\n {\n \"id\": \"unscrew\",\n \"duration\": 2.6,\n \"keys\": [\n {\n \"t\": 0,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 0.35,\n \"position\": [\n 0.06,\n -0.09,\n -0.34\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"turn\"\n },\n {\n \"t\": 1.95,\n \"position\": [\n 0.06,\n -0.09,\n -0.34\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n },\n {\n \"t\": 2.2,\n \"position\": [\n 0.06,\n -0.09,\n -0.34\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"open\"\n },\n {\n \"t\": 2.6,\n \"position\": [\n 0.22,\n -0.2,\n -0.4\n ],\n \"rotation\": [\n 0,\n 0,\n 0\n ],\n \"action\": \"none\"\n }\n ]\n }\n]\n","import itemUsesData from './data/item-uses.json'\nimport { lerp3, quatFromEuler, quatMultiply, quatRotate, add } from './math'\nimport type { FluidEvent, FluidWorld, ItemUseDef, ItemUsePlayer, Quat, Vec3 } from './types'\n\n/** Built-in scripted uses of a held item (data in `data/item-uses.json`): `sip`, `drink`, `chug`, `eat` (spoonfuls from an open tin), `pour`, `pour_out`, `open`, `close`,\n * `unscrew` (the other hand turns a screw cap off, `turn` keys, before the `open` key). */\nexport const ITEM_USES: ItemUseDef[] = itemUsesData as unknown as ItemUseDef[]\n\n/** World transform of the hand (or any holder) the item pose is relative to. */\nexport type HandTransform = () => { position: Vec3; rotation: Quat }\n\nconst DEFAULT_DRINK_RATE = 0.1\n\n/**\n * Plays an item use on a container: interpolates the keys, applies `drink` and `eat` (rate × dt litres) and `pour` (`world.pour`, `rate` multiplies the\n * time) while the current key has that action, and fires `open` / `close` once when their key is reached. When `getHandTransform` is given, the\n * container's world transform follows hand ∘ pose every update; otherwise the host animates the viewmodel from `pose()`.\n */\nexport function createItemUse(world: FluidWorld, containerId: string, def: ItemUseDef, getHandTransform?: HandTransform): ItemUsePlayer {\n const keys = [...def.keys].sort((a, b) => a.t - b.t)\n let time = 0\n let done = keys.length === 0 || def.duration <= 0\n let checked = false\n let lastPos: Vec3 | null = null\n const fired = new Set<number>()\n\n const pose = (): { position: Vec3; rotation: Vec3 } => {\n if (keys.length === 0) return { position: [0, 0, 0], rotation: [0, 0, 0] }\n if (time <= keys[0].t) return { position: [...keys[0].position], rotation: [...keys[0].rotation] }\n for (let i = 0; i < keys.length - 1; i++) {\n const a = keys[i]\n const b = keys[i + 1]\n if (time <= b.t) {\n const k = b.t > a.t ? (time - a.t) / (b.t - a.t) : 1\n return { position: lerp3(a.position, b.position, k), rotation: lerp3(a.rotation, b.rotation, k) }\n }\n }\n const last = keys[keys.length - 1]\n return { position: [...last.position], rotation: [...last.rotation] }\n }\n\n const follow = (dt: number): void => {\n if (!getHandTransform) return\n const hand = getHandTransform()\n const p = pose()\n const position = add(hand.position, quatRotate(hand.rotation, p.position))\n const rotation = quatMultiply(hand.rotation, quatFromEuler(p.rotation[0], p.rotation[1], p.rotation[2]))\n const velocity: Vec3 | undefined =\n lastPos && dt > 0 ? [(position[0] - lastPos[0]) / dt, (position[1] - lastPos[1]) / dt, (position[2] - lastPos[2]) / dt] : undefined\n lastPos = position\n world.setTransform(containerId, position, rotation, velocity)\n }\n\n const player: ItemUsePlayer = {\n def,\n get time() {\n return time\n },\n get done() {\n return done\n },\n pose,\n update(dt) {\n if (done) return []\n const events: FluidEvent[] = []\n const off = world.on('*', (e) => events.push(e))\n try {\n if (!checked) {\n checked = true\n const state = world.container(containerId)\n if (!state || (def.liquids && def.liquids.length > 0 && (!state.liquid || !def.liquids.includes(state.liquid)))) {\n done = true\n return events\n }\n }\n const start = time\n const end = Math.min(def.duration, time + Math.max(0, dt))\n for (let i = 0; i < keys.length && !done; i++) {\n const key = keys[i]\n const spanStart = key.t\n const spanEnd = i + 1 < keys.length ? keys[i + 1].t : def.duration\n if ((key.action === 'open' || key.action === 'close') && !fired.has(i) && end >= spanStart) {\n fired.add(i)\n if (key.action === 'open') world.open(containerId)\n else world.close(containerId)\n }\n const overlap = Math.min(end, spanEnd) - Math.max(start, spanStart)\n if (overlap <= 0) continue\n if (key.action === 'drink' || key.action === 'eat') {\n const ev = world.drink(containerId, (key.rate ?? DEFAULT_DRINK_RATE) * overlap, key.action === 'eat' ? { eaten: true } : undefined)\n const left = world.container(containerId)\n if (!ev || !left || left.liters <= 1e-6) {\n time = def.duration\n done = true\n }\n } else if (key.action === 'pour') {\n world.pour(containerId, overlap * (key.rate ?? 1))\n }\n }\n if (!done) {\n time = end\n done = time >= def.duration\n }\n follow(dt)\n } finally {\n off()\n }\n return events\n },\n cancel() {\n done = true\n },\n }\n return player\n}\n","import type { FilmField, FilmProfile, FilmRandom } from './types'\n\nexport interface DepositContext {\n readonly field: FilmField\n readonly random: FilmRandom\n readonly profile: () => FilmProfile\n}\n\nconst VISIBLE_THICKNESS = 0.035\n\nexport function depositCell(context: DepositContext, rowIn: number, columnIn: number, amount: number): void {\n const { field } = context\n const row = Math.round(rowIn)\n const column = Math.round(columnIn)\n if (row < 0 || column < 0 || row >= field.height || column >= field.width || !(amount > 0)) return\n const index = row * field.width + column\n field.thickness[index]! += amount\n if (amount > 0.02) field.dryness[index]! *= 0.15\n field.dampness[index] = 1\n}\n\nexport function wetCellCount(field: FilmField): number {\n let cells = 0\n for (let index = 0; index < field.thickness.length; index++) if (field.thickness[index]! > VISIBLE_THICKNESS) cells++\n return cells\n}\n\n/** A filled ellipse with a noisy outline; `along` runs along (directionColumn, directionRow) and `across` is the other half axis, `amount` is the thickness at the centre in mm. */\nexport function depositBlob(context: DepositContext, centerRow: number, centerColumn: number, along: number, across: number, directionColumn: number, directionRow: number, amount: number, roughness: number): void {\n const random = context.random\n const phaseA = random() * 6.28\n const phaseB = random() * 6.28\n const phaseC = random() * 6.28\n const phaseD = random() * 6.28\n const reach = Math.ceil(Math.max(along, across) * (1 + roughness) + 1.5)\n for (let row = Math.floor(centerRow - reach); row <= centerRow + reach; row++) {\n for (let column = Math.floor(centerColumn - reach); column <= centerColumn + reach; column++) {\n const dx = column + 0.5 - centerColumn\n const dy = row + 0.5 - centerRow\n const alongDistance = dx * directionColumn + dy * directionRow\n const acrossDistance = -dx * directionRow + dy * directionColumn\n const angle = Math.atan2(acrossDistance / across, alongDistance / along)\n const edge = 1 + roughness * (0.45 * Math.sin(3 * angle + phaseA) + 0.3 * Math.sin(5 * angle + phaseB) + 0.18 * Math.sin(8 * angle + phaseC) + 0.12 * Math.sin(13 * angle + phaseD))\n const squared = ((alongDistance / along) * (alongDistance / along) + (acrossDistance / across) * (acrossDistance / across)) / (edge * edge)\n if (squared < 1) depositCell(context, row, column, amount * Math.sqrt(1 - squared))\n }\n }\n}\n\n/** A tapered stroke from one cell to another. */\nexport function depositStroke(context: DepositContext, fromRow: number, fromColumn: number, toRow: number, toColumn: number, startWidth: number, endWidth: number, amount: number): void {\n const { field } = context\n const length = Math.hypot(toRow - fromRow, toColumn - fromColumn)\n const samples = Math.max(2, Math.ceil(length * 2.5))\n for (let sample = 0; sample <= samples; sample++) {\n const progress = sample / samples\n const row = fromRow + (toRow - fromRow) * progress\n const column = fromColumn + (toColumn - fromColumn) * progress\n const width = startWidth + (endWidth - startWidth) * progress\n const reach = Math.ceil(width + 1)\n for (let cellRow = Math.floor(row - reach); cellRow <= row + reach; cellRow++) {\n for (let cellColumn = Math.floor(column - reach); cellColumn <= column + reach; cellColumn++) {\n if (cellRow < 0 || cellColumn < 0 || cellRow >= field.height || cellColumn >= field.width) continue\n const distance = Math.hypot(cellRow + 0.5 - row, cellColumn + 0.5 - column)\n if (distance >= width) continue\n const index = cellRow * field.width + cellColumn\n const target = amount * (1 - distance / width) * 0.5\n if (field.thickness[index]! < target) depositCell(context, cellRow, cellColumn, target - field.thickness[index]!)\n }\n }\n }\n}\n\n/**\n * The impact: the body is stretched by 1 / sin(angle), with spikes (long only along the travel), satellites and tails.\n * `size` is the radius in cells of the main body; `profile.spikes` below 1 turns the spikes short and the blobs thick.\n */\nexport function depositSplat(context: DepositContext, row: number, column: number, size: number, directionColumn: number, directionRow: number, sinAngleIn: number, amount: number): void {\n const random = context.random\n const spikes = context.profile().spikes\n const sinAngle = Math.max(0.17, Math.min(1, sinAngleIn))\n const stretch = Math.min(5.5, 1 / sinAngle)\n const along = size * Math.pow(stretch, 0.75)\n const across = size / Math.pow(stretch, 0.25)\n const frontRow = row + directionRow * along * 0.25\n const frontColumn = column + directionColumn * along * 0.25\n depositBlob(context, frontRow, frontColumn, along, across, directionColumn, directionRow, amount, 0.1 + 0.12 * (1 - sinAngle) + (size < 1.4 ? 0 : 0.06))\n const sideColumn = -directionRow\n const sideRow = directionColumn\n const spikeCount = Math.round(Math.min(18, (size < 1.2 ? 1 : 4) + size * 1.6 + 5 * (1 - sinAngle)) * spikes)\n for (let spike = 0; spike < spikeCount; spike++) {\n const spread = Math.PI * (0.25 + 0.75 * sinAngle * sinAngle)\n let theta = (random() * 2 - 1) * spread\n if (sinAngle > 0.9) theta = random() * 6.283\n const cosine = Math.cos(theta)\n const sine = Math.sin(theta)\n const dx = cosine * directionColumn + sine * sideColumn\n const dy = cosine * directionRow + sine * sideRow\n const length = size * (0.25 + random() * 0.55) * (1 + 2.6 * (1 - sinAngle) * Math.max(0, cosine)) * (sinAngle > 0.9 ? 0.6 : 1) * (0.5 + 0.5 * spikes)\n const startRow = frontRow + (along * cosine * directionRow + across * sine * sideRow) * 0.75\n const startColumn = frontColumn + (along * cosine * directionColumn + across * sine * sideColumn) * 0.75\n const endRow = startRow + dy * length\n const endColumn = startColumn + dx * length\n depositStroke(context, startRow, startColumn, endRow, endColumn, Math.max(0.55, size * 0.22), 0.42, amount * 0.75)\n if (random() < 0.5) {\n const gap = 1 + random() * 2.2\n depositBlob(context, endRow + dy * gap, endColumn + dx * gap, 0.55 + random() * 0.7, 0.5 + random() * 0.4, dx, dy, amount * 0.55, 0.08)\n }\n }\n const satelliteCount = Math.round((1 + size * 0.9) * (1.4 - sinAngle * 0.6) * (0.5 + 0.5 * spikes))\n for (let satellite = 0; satellite < satelliteCount; satellite++) {\n const cone = sinAngle > 0.9 ? Math.PI : 0.18 + 0.6 * sinAngle\n const theta = (random() * 2 - 1) * cone\n const cosine = Math.cos(theta)\n const sine = Math.sin(theta)\n const dx = cosine * directionColumn + sine * sideColumn\n const dy = cosine * directionRow + sine * sideRow\n const distance = along + size * (0.8 + random() * 3.2)\n const radius = 0.45 + random() * Math.min(1.2, size * 0.22)\n const satelliteRow = frontRow + dy * distance\n const satelliteColumn = frontColumn + dx * distance\n depositBlob(context, satelliteRow, satelliteColumn, radius * Math.sqrt(stretch), radius, dx, dy, amount * 0.6, 0.08)\n if (sinAngle < 0.8) depositStroke(context, satelliteRow + dy * radius * stretch * 0.7, satelliteColumn + dx * radius * stretch * 0.7, satelliteRow + dy * radius * stretch * 1.8, satelliteColumn + dx * radius * stretch * 1.8, 0.5, 0.3, amount * 0.35)\n }\n}\n","import type { Vec3 } from '../types'\nimport { depositBlob, depositSplat } from './deposit'\nimport type { DepositContext } from './deposit'\nimport type { FilmDropState, FilmLayout } from './types'\n\nconst GRAVITY = 9.8\nconst AIR_DRAG = 0.25\nconst MIN_SIZE_CELLS = 0.6\n\nexport interface DropPool {\n readonly state: FilmDropState\n launch(position: Vec3, velocity: Vec3, radius: number): void\n update(dt: number): void\n clear(): void\n}\n\n/** Drops in flight: a ring of slots (the oldest is overwritten), a ballistic flight and a landing that makes an impact shaped by the angle and direction (F250-278). */\nexport function createDropPool(layout: FilmLayout, context: DepositContext): DropPool {\n const capacity = layout.rules.dropCapacity\n let cursor = 0\n const state: FilmDropState = {\n capacity,\n get launched() {\n return cursor\n },\n active: new Uint8Array(capacity),\n position: new Float64Array(capacity * 3),\n velocity: new Float64Array(capacity * 3),\n radius: new Float64Array(capacity),\n }\n const { active, position, velocity, radius } = state\n const cellMillimetres = layout.cellSize * 1000\n const previous: Vec3 = [0, 0, 0]\n const point: Vec3 = [0, 0, 0]\n const speed: Vec3 = [0, 0, 0]\n\n function land(region: number, dropRadius: number): void {\n const profile = context.profile()\n const impact = layout.impact(region, point, speed)\n const [alongColumn, alongRow] = impact.along\n const travel = Math.hypot(alongColumn, alongRow) || 1e-6\n const sinAngle = Math.abs(impact.normalSpeed) / Math.hypot(travel, impact.normalSpeed)\n const volume = ((4 / 3) * Math.PI * dropRadius * dropRadius * dropRadius) / (cellMillimetres * cellMillimetres) * (dropRadius > 3 ? 7 : 4) * profile.volume\n const totalSpeed = Math.sqrt(speed[0] * speed[0] + speed[1] * speed[1] + speed[2] * speed[2])\n const size = Math.max(MIN_SIZE_CELLS, (dropRadius * 2) / cellMillimetres * (1 + 0.2 * totalSpeed))\n const amount = Math.min(profile.maxAmount, Math.max(0.25, volume / ((Math.PI * size * size * 1.6) / (sinAngle < 0.3 ? 0.6 : 1))))\n if (profile.landsAsBlob) {\n depositBlob(context, impact.row, impact.column, size * 1.3, size * 1.1, alongColumn / travel, alongRow / travel, amount, 0.2)\n return\n }\n depositSplat(context, impact.row, impact.column, size, alongColumn / travel, alongRow / travel, sinAngle, amount)\n }\n\n return {\n state,\n launch(origin, direction, dropRadius) {\n const slot = cursor++ % capacity\n const offset = slot * 3\n active[slot] = 1\n position[offset] = origin[0]\n position[offset + 1] = origin[1]\n position[offset + 2] = origin[2]\n velocity[offset] = direction[0]\n velocity[offset + 1] = direction[1]\n velocity[offset + 2] = direction[2]\n radius[slot] = dropRadius\n },\n update(dt) {\n for (let slot = 0; slot < capacity; slot++) {\n if (!active[slot]) continue\n const offset = slot * 3\n previous[0] = position[offset]!\n previous[1] = position[offset + 1]!\n previous[2] = position[offset + 2]!\n velocity[offset + 1]! -= GRAVITY * dt\n const drag = 1 - dt * AIR_DRAG\n velocity[offset]! *= drag\n velocity[offset + 1]! *= drag\n velocity[offset + 2]! *= drag\n point[0] = position[offset]! + velocity[offset]! * dt\n point[1] = position[offset + 1]! + velocity[offset + 1]! * dt\n point[2] = position[offset + 2]! + velocity[offset + 2]! * dt\n const region = layout.collide(previous, point)\n position[offset] = point[0]\n position[offset + 1] = point[1]\n position[offset + 2] = point[2]\n if (region >= 0) {\n if (layout.contains(point)) {\n speed[0] = velocity[offset]!\n speed[1] = velocity[offset + 1]!\n speed[2] = velocity[offset + 2]!\n land(region, radius[slot]!)\n }\n active[slot] = 0\n continue\n }\n if (layout.escaped(point)) active[slot] = 0\n }\n },\n clear() {\n active.fill(0)\n },\n }\n}\n","import type { FilmAdvanceInput, FilmBounds, FilmField, FilmLayout, FilmProfile, FilmSimulator, FilmWeather } from './types'\n\nexport interface CpuSimulatorOptions {\n /** Flow steps per second of real time (the pages use 180). */\n stepRate: number\n /** Most flow steps in one advance (6 in the Fluid Standard, 9 in the Workshop). */\n maxSteps: number\n weather: () => FilmWeather\n}\n\nconst RAIN_SPREAD = 0.5\nconst BOUNDS_MARGIN = 8\n\n/**\n * The thin-film step of the Fluid Standard (F94-114), literal: only film above the pin moves, a dry cell needs the front thickness,\n * walls run sideways at 0.22 and the flow is limited to the wet bounding box. Drying starts from the thin edge.\n */\nexport function createCpuSimulator(field: FilmField, layout: FilmLayout, profileOf: () => FilmProfile, options: CpuSimulatorOptions): FilmSimulator {\n const { width, height, thickness, dryness, dampness } = field\n const { bed, pin: pinning, vertical } = layout\n const delta = new Float32Array(width * height)\n const bounds: FilmBounds = { firstRow: 0, lastRow: -1, firstColumn: 0, lastColumn: -1 }\n let accumulated = 0\n\n function refreshBounds(): void {\n let firstRow = height\n let lastRow = -1\n let firstColumn = width\n let lastColumn = -1\n for (let row = 0; row < height; row++) {\n const offset = row * width\n let isWet = false\n for (let column = 0; column < width; column++) {\n if (thickness[offset + column]! > 0) {\n isWet = true\n if (column < firstColumn) firstColumn = column\n if (column > lastColumn) lastColumn = column\n }\n }\n if (isWet) {\n if (row < firstRow) firstRow = row\n lastRow = row\n }\n }\n if (lastRow < 0) {\n bounds.firstRow = 0\n bounds.lastRow = -1\n bounds.firstColumn = 0\n bounds.lastColumn = -1\n return\n }\n bounds.firstRow = Math.max(0, firstRow - BOUNDS_MARGIN)\n bounds.lastRow = Math.min(height - 1, lastRow + BOUNDS_MARGIN)\n bounds.firstColumn = Math.max(0, firstColumn - BOUNDS_MARGIN)\n bounds.lastColumn = Math.min(width - 1, lastColumn + BOUNDS_MARGIN)\n }\n\n const mobility = (index: number): number => {\n const dry = dryness[index]!\n return dry < 0.25 ? 1 : dry > 0.6 ? 0 : 1 - (dry - 0.25) / 0.35\n }\n\n function flowStep(): void {\n const { firstRow, lastRow, firstColumn, lastColumn } = bounds\n if (lastRow < 0) return\n const profile = profileOf()\n const flow = profile.flow * (1 + RAIN_SPREAD * options.weather().rain)\n const referenceSquared = profile.referenceThickness * profile.referenceThickness\n const slopeCap = profile.slopeCap\n const pinLevel = profile.pin\n const front = profile.front\n for (let row = firstRow; row <= lastRow; row++) {\n const offset = row * width\n for (let column = firstColumn; column <= lastColumn; column++) delta[offset + column] = 0\n }\n for (let row = firstRow; row <= lastRow; row++) {\n const offset = row * width\n for (let column = firstColumn; column <= lastColumn; column++) {\n const index = offset + column\n const own = thickness[index]!\n for (let edge = 0; edge < 2; edge++) {\n let neighbour: number\n if (edge === 0) {\n if (column >= lastColumn) continue\n neighbour = index + 1\n } else {\n if (row >= lastRow) continue\n neighbour = index + width\n }\n const other = thickness[neighbour]!\n if (own < 0.005 && other < 0.005) continue\n let bedDrop = bed[index]! - bed[neighbour]!\n if (bedDrop > slopeCap) bedDrop = slopeCap\n else if (bedDrop < -slopeCap) bedDrop = -slopeCap\n let head = bedDrop + own - other\n let source = index\n let destination = neighbour\n if (head < 0) {\n head = -head\n source = neighbour\n destination = index\n }\n const sourceThickness = thickness[source]!\n const verticalFactor = vertical[source]!\n const pinThreshold = pinLevel * pinning[source]! * (verticalFactor < 1 ? 0.5 : 1)\n if (sourceThickness <= pinThreshold) continue\n if (thickness[destination]! < 0.03 && sourceThickness < front * pinning[source]! * verticalFactor) continue\n const mobile = mobility(source)\n if (mobile <= 0) continue\n let moved = flow * mobile * ((sourceThickness * sourceThickness) / (sourceThickness * sourceThickness + referenceSquared)) * head * (verticalFactor < 1 ? (edge === 0 ? 0.22 : 1) : 4)\n const limit = (sourceThickness - pinThreshold) * 0.24\n if (moved > limit) moved = limit\n delta[source]! -= moved\n delta[destination]! += moved\n }\n }\n }\n for (let row = firstRow; row <= lastRow; row++) {\n const offset = row * width\n for (let column = firstColumn; column <= lastColumn; column++) {\n const index = offset + column\n let next = thickness[index]! + delta[index]!\n if (next < 1e-4) next = 0\n else dampness[index] = 1\n thickness[index] = next\n }\n }\n }\n\n function age(dryingSeconds: number): void {\n const { firstRow, lastRow, firstColumn, lastColumn } = bounds\n if (lastRow < 0) return\n const profile = profileOf()\n const rainScale = 1 - options.weather().rain\n const seconds = dryingSeconds * rainScale * (options.weather().drying ?? 1)\n for (let row = firstRow; row <= lastRow; row++) {\n const offset = row * width\n for (let column = firstColumn; column <= lastColumn; column++) {\n const index = offset + column\n const own = thickness[index]!\n if (own > 0) {\n const thin = 1 - Math.min(1, own / 1.6)\n if (profile.dryTime > 0 && dryness[index]! < 1) dryness[index] = Math.min(1, dryness[index]! + (seconds / profile.dryTime) * (0.45 + 1.7 * thin))\n if (profile.evaporation > 0) {\n const next = own - profile.evaporation * seconds * (0.5 + 1.5 * thin)\n thickness[index] = next > 0.004 ? next : 0\n }\n } else if (dampness[index]! > 0) {\n dampness[index] = Math.max(0, dampness[index]! - seconds / (profile.evaporation > 0 ? 25 : 1e9))\n }\n }\n }\n }\n\n return {\n bounds,\n refreshBounds,\n advance({ dt, dryingSeconds }: FilmAdvanceInput): number {\n accumulated += dt\n let steps = 0\n refreshBounds()\n while (accumulated >= 1 / options.stepRate && steps < options.maxSteps) {\n flowStep()\n accumulated -= 1 / options.stepRate\n steps++\n }\n if (steps === options.maxSteps) accumulated = 0\n age(dryingSeconds)\n return steps\n },\n resetClock() {\n accumulated = 0\n },\n }\n}\n","import type { Vec3 } from '../types'\nimport { depositCell } from './deposit'\nimport type { DepositContext } from './deposit'\nimport type { FilmBead, FilmDrag, FilmDrip, FilmLayout, FilmRandom, FilmSource } from './types'\n\ntype Launch = (position: Vec3, velocity: Vec3, radius: number) => void\n\nconst range = (random: FilmRandom, from: number, to: number): number => from + random() * (to - from)\n\n/** The drip (F282, W-style): a bead swells at the fingertip, detaches and falls. Updates `bead` for the renderer and returns nothing. */\nexport function updateDrip(drip: FilmDrip | undefined, bead: FilmBead, layout: FilmLayout, random: FilmRandom, launch: Launch, dt: number): void {\n if (!drip) {\n bead.visible = false\n return\n }\n drip.elapsed += dt\n const swell = Math.min(1, drip.elapsed / drip.every)\n const radius = drip.radius * (0.35 + 0.65 * swell)\n const isWorkshop = layout.rules.dripStyle === 'workshop'\n bead.visible = true\n bead.swell = swell\n bead.radius = radius\n bead.position[0] = drip.position[0]\n bead.position[1] = drip.position[1] + (isWorkshop ? -radius * 0.0012 * (1 + swell * 0.7) : -radius * 0.0012)\n bead.position[2] = drip.position[2]\n if (drip.elapsed < drip.every) return\n const origin: Vec3 = [bead.position[0], bead.position[1] + -radius * 0.001, bead.position[2]]\n if (isWorkshop) {\n const sideX = range(random, -0.025, 0.025)\n const sideZ = range(random, -0.025, 0.025)\n launch(origin, [sideX, -0.2, sideZ], drip.radius * range(random, 0.85, 1.15))\n drip.elapsed = 0\n drip.every = drip.base * range(random, 0.75, 1.25)\n return\n }\n const sideX = (random() - 0.5) * 0.05\n const sideZ = (random() - 0.5) * 0.05\n launch(origin, [sideX, -0.2, sideZ], drip.radius * (0.85 + random() * 0.3))\n drip.elapsed = 0\n drip.every = drip.base * (0.75 + random() * 0.5)\n}\n\n/** Continuous sources (a wound at the feet, a tipped can): a pulsing thickness added over a small disc (F288). */\nexport function updateSources(sources: readonly FilmSource[], context: DepositContext, dt: number): void {\n const random = context.random\n for (const source of sources) {\n source.elapsed += dt\n if (source.elapsed < 0 || source.elapsed > source.duration) continue\n const pulse = 0.6 + 0.4 * Math.max(0, Math.sin(source.elapsed * 5.2))\n const amount = source.rate * dt * pulse\n for (let part = 0; part < 3; part++) {\n const angle = random() * 6.28\n const distance = random() * source.radius\n depositCell(context, source.row + Math.sin(angle) * distance, source.column + Math.cos(angle) * distance, amount / 3)\n }\n }\n}\n\n/** Drag smears (F291): a striped band that loses load and crumbles at the end, with side drops stretched along the travel. */\nexport function updateDrags(drags: readonly FilmDrag[], context: DepositContext, layout: FilmLayout, launch: Launch, dt: number): void {\n const random = context.random\n for (const drag of drags) {\n if (drag.done) continue\n drag.elapsed += dt\n const progress = Math.min(1, drag.elapsed / drag.duration)\n const here = drag.path(progress)\n const ahead = drag.path(Math.min(1, progress + 0.01))\n let directionColumn = ahead.column - here.column\n let directionRow = ahead.row - here.row\n const length = Math.hypot(directionColumn, directionRow) || 1\n directionColumn /= length\n directionRow /= length\n const sideColumn = -directionRow\n const sideRow = directionColumn\n const load = Math.pow(1 - progress, 1.3)\n for (let offset = -drag.width; offset <= drag.width; offset += 0.5) {\n const across = offset / drag.width\n const stripe = drag.stripes[Math.round((offset + drag.width) * 2)]!\n const edge = 1 - across * across\n const amount = drag.amount * load * (0.25 + 0.75 * stripe) * edge\n if (load < 0.45 && random() > load * 2.2) continue\n depositCell(context, Math.round(here.row + sideRow * offset), Math.round(here.column + sideColumn * offset), amount * dt * 30)\n }\n if (drag.hand && random() < dt * 14 * load + 0.02) {\n const world = layout.cellToWorld(here.row, here.column)\n const origin: Vec3 = [world[0] + (random() - 0.5) * 0.06, drag.hand.height + random() * 0.3, world[2] + (random() - 0.5) * 0.06]\n const velocity: Vec3 = [directionColumn * drag.hand.speed, 0 * drag.hand.speed, directionRow * drag.hand.speed]\n velocity[0] += (random() - 0.5) * 0.3\n velocity[1] += 0.2\n velocity[2] += (random() - 0.5) * 0.3\n launch(origin, velocity, 2 + random() * 2.2)\n }\n if (progress >= 1) drag.done = true\n }\n}\n","import { depositBlob, depositCell, depositSplat, depositStroke, wetCellCount } from './deposit'\nimport type { DepositContext } from './deposit'\nimport { createDropPool } from './drops'\nimport { createCpuSimulator } from './simulate'\nimport { updateDrags, updateDrip, updateSources } from './sources'\nimport type { Film, FilmField, FilmOptions, FilmProfile, FilmWeather } from './types'\n\nconst DEFAULT_STEP_RATE = 180\nconst DEFAULT_MAX_STEPS = 6\n/** The visor's `ZG.wipe`: rain removes only the stain that is less than half dry. */\nconst WASH_BELOW_DRYNESS = 0.5\n\n/**\n * A running film of one liquid over one layout: drops land as impacts, a drip, sources and drag smears add to it, and a 180 Hz\n * thin-film step spreads it limited to the wet box, at most `maxSteps` per frame. It never calls `Math.random`: the host gives the random stream.\n */\nexport function createFilm(options: FilmOptions): Film {\n const { layout, random } = options\n const cellCount = layout.width * layout.height\n const field: FilmField = {\n width: layout.width,\n height: layout.height,\n thickness: new Float32Array(cellCount),\n dryness: new Float32Array(cellCount),\n dampness: new Float32Array(cellCount),\n }\n let weatherState: FilmWeather = { rain: 0, drying: 1 }\n let currentProfile: FilmProfile = options.profile\n const context: DepositContext = { field, random, profile: () => currentProfile }\n const drops = createDropPool(layout, context)\n const createSimulator = options.simulator ?? createCpuSimulator\n const simulator = createSimulator(field, layout, () => currentProfile, {\n stepRate: options.stepRate ?? DEFAULT_STEP_RATE,\n maxSteps: options.maxSteps ?? DEFAULT_MAX_STEPS,\n weather: () => weatherState,\n })\n\n const film: Film = {\n layout,\n field,\n drops: drops.state,\n bead: { visible: false, position: [0, 0, 0], radius: 0, swell: 0 },\n simulator,\n get profile() {\n return currentProfile\n },\n set profile(profile: FilmProfile) {\n currentProfile = profile\n },\n drip: undefined,\n sources: [],\n drags: [],\n launch: (position, velocity, radius) => drops.launch(position, velocity, radius),\n splat: (row, column, size, directionColumn, directionRow, sinAngle, amount) => depositSplat(context, row, column, size, directionColumn, directionRow, sinAngle, amount),\n blob: (row, column, along, across, directionColumn, directionRow, amount, roughness) => depositBlob(context, row, column, along, across, directionColumn, directionRow, amount, roughness),\n stroke: (fromRow, fromColumn, toRow, toColumn, startWidth, endWidth, amount) => depositStroke(context, fromRow, fromColumn, toRow, toColumn, startWidth, endWidth, amount),\n deposit: (row, column, amount) => depositCell(context, row, column, amount),\n update({ dt, dryingSeconds }) {\n drops.update(dt)\n updateDrip(film.drip, film.bead, layout, random, drops.launch, dt)\n updateSources(film.sources, context, dt)\n updateDrags(film.drags, context, layout, drops.launch, dt)\n simulator.advance({ dt, dryingSeconds })\n },\n setWeather(weather) {\n weatherState = {\n rain: Math.min(1, Math.max(0, weather.rain ?? weatherState.rain)),\n drying: Math.max(0, weather.drying ?? weatherState.drying ?? 1),\n }\n },\n weather: () => ({ ...weatherState }),\n wash(maxDryness = WASH_BELOW_DRYNESS) {\n simulator.refreshBounds()\n const { firstRow, lastRow, firstColumn, lastColumn } = simulator.bounds\n let cleared = 0\n for (let row = firstRow; row <= lastRow; row++) {\n for (let column = firstColumn; column <= lastColumn; column++) {\n const index = row * layout.width + column\n if (field.thickness[index]! > 0 && field.dryness[index]! < maxDryness) {\n field.thickness[index] = 0\n field.dryness[index] = 0\n field.dampness[index] = 0\n cleared++\n }\n }\n }\n // the bounds shrink on the next advance, which the grid's upload rectangle (union with the previous one) already covers\n return cleared\n },\n clear() {\n field.thickness.fill(0)\n field.dryness.fill(0)\n field.dampness.fill(0)\n drops.clear()\n film.drip = undefined\n film.bead.visible = false\n film.sources.length = 0\n film.drags.length = 0\n simulator.refreshBounds()\n },\n wetCells: () => wetCellCount(field),\n }\n return film\n}\n","import type { FilmRandom } from './types'\n\nexport type FilmLcg = FilmRandom & { seed: number }\n\n/** The Fluid Standard's generator (LCG 1664525 / 1013904223). `seed` can be read and set, so a scene can be restarted from a number. */\nexport function createFilmLcg(seed: number): FilmLcg {\n const lcg = (() => {\n lcg.seed = (lcg.seed * 1664525 + 1013904223) >>> 0\n return lcg.seed / 4294967296\n }) as FilmLcg\n lcg.seed = seed >>> 0\n return lcg\n}\n","// The product is taken in doubles on purpose (not `Math.imul`): the recorded pages round it the same way, and the grids depend on it.\nexport function hashCell(x: number, y: number): number {\n let value = (x * 374761393 + y * 668265263) | 0\n value = ((value ^ (value >>> 13)) * 1274126177) | 0\n return ((value ^ (value >>> 16)) >>> 0) / 4294967296\n}\n\nexport function valueNoise(x: number, y: number): number {\n const xi = Math.floor(x)\n const yi = Math.floor(y)\n const xf = x - xi\n const yf = y - yi\n const u = xf * xf * (3 - 2 * xf)\n const v = yf * yf * (3 - 2 * yf)\n const a = hashCell(xi, yi)\n const b = hashCell(xi + 1, yi)\n const c = hashCell(xi, yi + 1)\n const d = hashCell(xi + 1, yi + 1)\n return a + (b - a) * u + (c - a) * v + (a - b - c + d) * u * v\n}\n","import type { Vec3 } from '../types'\nimport { hashCell, valueNoise } from './noise'\nimport type { FilmImpact, FilmLayout, FilmRegion, FilmRules } from './types'\n\nexport interface FoldedLayoutParams {\n id: string\n columns: number\n /** Metres per cell. */\n cellSize: number\n /** World x of the left edge. */\n originX: number\n wallRows: number\n sidewalkRows: number\n curbRows: number\n roadRows: number\n /** World y of the top of the wall strip and of the sidewalk and road planes. */\n wallTopY: number\n sidewalkY: number\n roadY: number\n /** World z of the wall plane (the sidewalk starts here and runs towards +z). */\n wallZ: number\n /** Metres the curb face drops per row. Default `(sidewalkY - roadY) / curbRows`. */\n curbStep?: number\n /** x that the road's cross slope is measured from (the road falls `5 mm / m` towards +x from here). */\n roadSlopeAnchorX: number\n rules: FilmRules\n}\n\nconst REGION_NAMES = ['wall', 'sidewalk', 'curb', 'road'] as const\n\nconst dot3 = (a: Vec3, b: Vec3): number => a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n\nfunction impactOf(region: FilmRegion, position: Vec3, velocity: Vec3, cellSize: number): FilmImpact {\n const local: Vec3 = [position[0] - region.origin[0], position[1] - region.origin[1], position[2] - region.origin[2]]\n return {\n row: region.firstRow + dot3(local, region.rowAxis) / cellSize,\n column: dot3(local, region.columnAxis) / cellSize,\n along: [dot3(velocity, region.columnAxis), dot3(velocity, region.rowAxis)],\n normalSpeed: -dot3(velocity, region.normal),\n }\n}\n\nfunction cellToWorldOf(regions: readonly FilmRegion[], cellSize: number, row: number, column: number): Vec3 {\n let region = regions[regions.length - 1]!\n for (const candidate of regions) {\n if (row < candidate.firstRow + candidate.rowCount) {\n region = candidate\n break\n }\n }\n const across = column * cellSize\n const down = (row - region.firstRow) * cellSize\n return [\n region.origin[0] + region.columnAxis[0] * across + region.rowAxis[0] * down,\n region.origin[1] + region.columnAxis[1] * across + region.rowAxis[1] * down,\n region.origin[2] + region.columnAxis[2] * across + region.rowAxis[2] * down,\n ]\n}\n\n/**\n * One strip folded over a wall, the sidewalk in front of it, the curb face and the road: the Fluid Standard's grid (F12-42) and the\n * Workshop's (W562-582) are two settings of it. Bed height (mm), pinning noise and the vertical flag are filled per cell.\n */\nexport function createFoldedLayout(params: FoldedLayoutParams): FilmLayout {\n const { columns, cellSize, originX, wallRows, sidewalkRows, curbRows, roadRows, wallTopY, sidewalkY, roadY, wallZ, rules } = params\n const curbStep = params.curbStep ?? (sidewalkY - roadY) / curbRows\n const height = wallRows + sidewalkRows + curbRows + roadRows\n const cellCount = columns * height\n const bed = new Float32Array(cellCount)\n const pin = new Float32Array(cellCount)\n const vertical = new Float32Array(cellCount)\n const sidewalkEnd = wallRows + sidewalkRows\n const curbEnd = sidewalkEnd + curbRows\n const regionOfRow = (row: number): number => (row < wallRows ? 0 : row < sidewalkEnd ? 1 : row < curbEnd ? 2 : 3)\n\n for (let row = 0; row < height; row++) {\n for (let column = 0; column < columns; column++) {\n const index = row * columns + column\n const region = regionOfRow(row)\n const x = originX + (column + 0.5) * cellSize\n let bedHeight: number\n let roughness = 0.2\n if (region === 0) {\n bedHeight = (wallTopY - (row + 0.5) * cellSize) * 1000\n roughness = 0.3\n } else if (region === 1) {\n const z = (row - wallRows + 0.5) * cellSize\n bedHeight = sidewalkY * 1000 - z * 6\n const jointX = Math.abs((((x - originX) % 0.5) + 0.5) % 0.5 - 0.25)\n const jointZ = Math.abs(((z % 0.5) + 0.5) % 0.5 - 0.25)\n if (jointX > 0.25 - cellSize * 0.6 || jointZ > 0.25 - cellSize * 0.6) bedHeight -= 0.9\n roughness = 0.18\n } else if (region === 2) {\n bedHeight = sidewalkY * 1000 - (row - sidewalkEnd + 0.5) * curbStep * 1000\n } else {\n const z = (row - curbEnd + 0.5) * cellSize\n bedHeight = roadY * 1000 + z * 14 - (x - params.roadSlopeAnchorX) * 5\n roughness = 0.55\n }\n const noise = valueNoise(column * 0.35, row * 0.35) * 0.6 + valueNoise(column * 1.3, row * 1.3) * 0.4\n bed[index] = bedHeight + (noise - 0.5) * roughness * 2\n vertical[index] = region === 0 || region === 2 ? 0.95 : 1\n pin[index] = 0.62 + 0.76 * (valueNoise(column * 0.21 + 40, row * 0.21) * 0.5 + hashCell(column, row) * 0.5) * (region === 3 ? 1.25 : 1)\n }\n }\n\n const curbZ = wallZ + sidewalkRows * cellSize\n const roadEndZ = curbZ + roadRows * cellSize\n const right = [1, 0, 0] as Vec3\n const regions: FilmRegion[] = [\n { id: REGION_NAMES[0], firstRow: 0, rowCount: wallRows, origin: [originX, wallTopY, wallZ], columnAxis: right, rowAxis: [0, -1, 0], normal: [0, 0, 1], isVertical: true },\n { id: REGION_NAMES[1], firstRow: wallRows, rowCount: sidewalkRows, origin: [originX, sidewalkY, wallZ], columnAxis: right, rowAxis: [0, 0, 1], normal: [0, 1, 0], isVertical: false },\n { id: REGION_NAMES[2], firstRow: sidewalkEnd, rowCount: curbRows, origin: [originX, sidewalkY, curbZ], columnAxis: right, rowAxis: [0, -1, 0], normal: [0, 0, 1], isVertical: true },\n { id: REGION_NAMES[3], firstRow: curbEnd, rowCount: roadRows, origin: [originX, roadY, curbZ], columnAxis: right, rowAxis: [0, 0, 1], normal: [0, 1, 0], isVertical: false },\n ]\n const maxX = originX + columns * cellSize\n\n return {\n id: params.id,\n width: columns,\n height,\n cellSize,\n bed,\n pin,\n vertical,\n regions,\n rules,\n cellToWorld: (row, column) => cellToWorldOf(regions, cellSize, row, column),\n collide(previous, position) {\n if (position[2] <= wallZ && position[1] > sidewalkY) {\n position[2] = wallZ\n return 0\n }\n if (position[2] < curbZ && (!rules.guardBehindWall || position[2] >= wallZ) && position[1] <= sidewalkY) {\n position[1] = sidewalkY\n return 1\n }\n if (rules.curbCatch && position[2] >= curbZ && previous[2] < curbZ && position[1] < sidewalkY) {\n position[2] = curbZ\n return 2\n }\n if (position[2] >= curbZ && position[1] <= roadY) {\n position[1] = roadY\n return 3\n }\n return -1\n },\n impact: (region, position, velocity) => impactOf(regions[region]!, position, velocity, cellSize),\n contains: (position) => position[0] > originX && position[0] < maxX && (!rules.clipRoadEnd || position[2] < roadEndZ),\n escaped(position) {\n if (position[1] < -1) return true\n const box = rules.escapeBox\n return box !== undefined && (position[0] < box.minX || position[0] > box.maxX || position[2] > box.maxZ)\n },\n }\n}\n\nconst PADRAO_CELL = 0.0125\nconst PADRAO_WALL_Z = 0\n\n/** The Fluid Standard's grid: 256 x 396 cells of 1.25 cm over a 1.95 m wall, a 1.6 m sidewalk, a 15 cm curb and a 1.4 m road. */\nexport const PADRAO_LAYOUT: FilmLayout = createFoldedLayout({\n id: 'padrao',\n columns: 256,\n cellSize: PADRAO_CELL,\n originX: -1.6,\n wallRows: 144,\n sidewalkRows: 128,\n curbRows: 12,\n roadRows: 112,\n wallTopY: 1.95,\n sidewalkY: 0.15,\n roadY: 0,\n wallZ: PADRAO_WALL_Z,\n curbStep: PADRAO_CELL,\n roadSlopeAnchorX: 0,\n rules: {\n dropCapacity: 600,\n curbCatch: true,\n guardBehindWall: true,\n clipRoadEnd: true,\n escapeBox: { minX: -3, maxX: 3, maxZ: PADRAO_WALL_Z + 128 * PADRAO_CELL + 112 * PADRAO_CELL + 1 },\n dripStyle: 'padrao',\n },\n})\n\nconst WORKSHOP_CELL = 0.0125\n\n/** The Workshop's grid: 160 x 448 cells (wall 160, sidewalk 128, curb 9, road 151) at the foot of the workshop's wall. */\nexport const WORKSHOP_LAYOUT: FilmLayout = createFoldedLayout({\n id: 'workshop',\n columns: 160,\n cellSize: WORKSHOP_CELL,\n originX: -2.2,\n wallRows: 160,\n sidewalkRows: 128,\n curbRows: 9,\n roadRows: 151,\n wallTopY: 2.12,\n sidewalkY: 0.1235,\n roadY: 0.009,\n wallZ: -4.497,\n roadSlopeAnchorX: -1.2,\n rules: { dropCapacity: 400, curbCatch: false, guardBehindWall: false, clipRoadEnd: false, dripStyle: 'workshop' },\n})\n","import { add, cross, dot, normalize, scale, sub } from '../math'\nimport { makeBasis } from '../stains'\nimport type { SurfaceSpec, Vec3 } from '../types'\nimport { valueNoise } from './noise'\nimport type { FilmLayout, FilmRegion, FilmRules } from './types'\n\nexport interface SurfaceLayoutOptions {\n /** The surface the film lies on (a floor, a table, a ramp). */\n floor: SurfaceSpec\n /** A wall that meets the floor: the film folds up it, so a splash on the wall runs down onto the floor. */\n wall?: SurfaceSpec\n /** The lower surface beyond the floor's far edge: the film folds down a curb face to it. Needs the wall or the floor's tangent to say where the edge is. */\n curb?: SurfaceSpec\n /** World point the grid is centred on (sideways; and along the floor when there is no wall). */\n center: Vec3\n /** Cells across (default 160: 2 m of 1.25 cm cells, the grid of the near-player manager). */\n columns?: number\n /** Cells along all strips together (default 160). */\n rows?: number\n /** Metres per cell (default 0.0125). */\n cellSize?: number\n /** Rows of the wall strip (default 48 with a wall, else 0) and cap of the curb face rows (default 12). */\n wallRows?: number\n curbRows?: number\n}\n\nconst DEFAULT_COLUMNS = 160\nconst DEFAULT_ROWS = 160\nconst DEFAULT_CELL = 0.0125\nconst DEFAULT_WALL_ROWS = 48\nconst DEFAULT_CURB_ROWS = 12\nconst RULES: FilmRules = { dropCapacity: 160, curbCatch: false, guardBehindWall: false, clipRoadEnd: false, dripStyle: 'padrao' }\n\nconst along3 = (origin: Vec3, axis: Vec3, distance: number): Vec3 => add(origin, scale(axis, distance))\n\n/** Removes the part of `vector` along the unit `axis`. */\nconst reject = (vector: Vec3, axis: Vec3): Vec3 => sub(vector, scale(axis, dot(vector, axis)))\n\ninterface Strip {\n id: string\n rows: number\n origin: Vec3\n rowAxis: Vec3\n normal: Vec3\n isVertical: boolean\n roughness: number\n}\n\n/**\n * Builds the folded grid from the host's surfaces: `wall` (optional) hangs above the fold line, `floor` runs away from the wall, and\n * `curb` (optional) is the lower surface the floor drops to over a curb face. Without a wall the grid is a flat patch of the floor around `center`.\n * Bed heights come from world y, so a tilted floor makes the film run downhill.\n */\nexport function layoutFromSurfaces(options: SurfaceLayoutOptions): FilmLayout {\n const columns = options.columns ?? DEFAULT_COLUMNS\n const totalRows = options.rows ?? DEFAULT_ROWS\n const cell = options.cellSize ?? DEFAULT_CELL\n const floorBasis = makeBasis(options.floor.normal, options.floor.tangent)\n const floorNormal = floorBasis.normal\n const projected = sub(options.center, scale(floorNormal, dot(sub(options.center, options.floor.point), floorNormal)))\n const wallNormal = options.wall ? normalize(reject(options.wall.normal, floorNormal), floorBasis.t2) : undefined\n const awayAxis = wallNormal ?? floorBasis.t2\n const columnAxis = wallNormal ? normalize(cross(floorNormal, wallNormal), floorBasis.t1) : floorBasis.t1\n const wallRows = options.wall ? Math.min(totalRows - 1, options.wallRows ?? DEFAULT_WALL_ROWS) : 0\n\n let fold = projected\n if (options.wall && wallNormal) {\n const toWall = dot(sub(projected, options.wall.point), wallNormal) / (dot(awayAxis, wallNormal) || 1)\n fold = sub(projected, scale(awayAxis, toWall))\n } else {\n fold = along3(projected, awayAxis, -(totalRows * cell) / 2)\n }\n const lateral = dot(sub(projected, fold), columnAxis) - (columns * cell) / 2\n const base = along3(fold, columnAxis, lateral)\n\n const strips: Strip[] = []\n const roughness = 0.18 + 0.4 * options.floor.porosity\n if (options.wall && wallNormal) {\n strips.push({ id: 'wall', rows: wallRows, origin: along3(base, floorNormal, wallRows * cell), rowAxis: scale(floorNormal, -1), normal: wallNormal, isVertical: true, roughness: 0.3 })\n }\n const lowerRows = totalRows - wallRows\n const dropMetres = options.curb ? Math.max(0, dot(sub(options.floor.point, options.curb.point), floorNormal)) : 0\n const curbRows = options.curb ? Math.min(options.curbRows ?? DEFAULT_CURB_ROWS, Math.max(1, Math.ceil(dropMetres / cell)), lowerRows - 2) : 0\n const floorRows = options.curb ? Math.max(1, Math.floor((lowerRows - curbRows) / 2)) : lowerRows\n strips.push({ id: 'floor', rows: floorRows, origin: base, rowAxis: awayAxis, normal: floorNormal, isVertical: false, roughness })\n if (options.curb) {\n const edge = along3(base, awayAxis, floorRows * cell)\n strips.push({ id: 'curb', rows: curbRows, origin: edge, rowAxis: scale(floorNormal, -1), normal: awayAxis, isVertical: true, roughness: 0.2 })\n const lowerOrigin = along3(edge, floorNormal, -curbRows * cell)\n strips.push({ id: 'low', rows: lowerRows - floorRows - curbRows, origin: lowerOrigin, rowAxis: awayAxis, normal: floorNormal, isVertical: false, roughness: 0.55 })\n }\n\n const regions: FilmRegion[] = []\n let firstRow = 0\n for (const strip of strips) {\n regions.push({ id: strip.id, firstRow, rowCount: strip.rows, origin: strip.origin, columnAxis, rowAxis: strip.rowAxis, normal: strip.normal, isVertical: strip.isVertical })\n firstRow += strip.rows\n }\n\n const height = firstRow\n const bed = new Float32Array(columns * height)\n const pin = new Float32Array(columns * height)\n const vertical = new Float32Array(columns * height)\n regions.forEach((region, regionIndex) => {\n const strip = strips[regionIndex]!\n for (let row = 0; row < region.rowCount; row++) {\n for (let column = 0; column < columns; column++) {\n const index = (region.firstRow + row) * columns + column\n const centre = add(add(region.origin, scale(columnAxis, (column + 0.5) * cell)), scale(region.rowAxis, (row + 0.5) * cell))\n const noise = valueNoise(column * 0.35, (region.firstRow + row) * 0.35) * 0.6 + valueNoise(column * 1.3, (region.firstRow + row) * 1.3) * 0.4\n bed[index] = centre[1] * 1000 + (noise - 0.5) * strip.roughness * 2\n vertical[index] = region.isVertical ? 0.95 : 1\n pin[index] = 0.62 + 0.76 * (valueNoise(column * 0.21 + 40, (region.firstRow + row) * 0.21) * 0.5 + valueNoise(column * 0.9, row * 0.9) * 0.5)\n }\n }\n })\n\n const lowestY = Math.min(...regions.map((region) => region.origin[1] - (region.rowAxis[1] > 0 ? 0 : region.rowCount * cell * Math.abs(region.rowAxis[1])))) - 1\n const width = columns * cell\n const cellToWorld = (row: number, column: number): Vec3 => {\n const region = regions.find((candidate) => row < candidate.firstRow + candidate.rowCount) ?? regions[regions.length - 1]!\n return add(add(region.origin, scale(region.columnAxis, column * cell)), scale(region.rowAxis, (row - region.firstRow) * cell))\n }\n\n return {\n id: 'surfaces',\n width: columns,\n height,\n cellSize: cell,\n bed,\n pin,\n vertical,\n regions,\n rules: RULES,\n cellToWorld,\n collide(previous, position) {\n for (let index = 0; index < regions.length; index++) {\n const region = regions[index]!\n const before = dot(sub(previous, region.origin), region.normal)\n const after = dot(sub(position, region.origin), region.normal)\n if (before < 0 || after > 0) continue\n const local = sub(position, region.origin)\n const sideways = dot(local, region.columnAxis)\n const downward = dot(local, region.rowAxis)\n if (sideways < 0 || sideways >= width || downward < 0 || downward >= region.rowCount * cell) continue\n position[0] -= region.normal[0] * after\n position[1] -= region.normal[1] * after\n position[2] -= region.normal[2] * after\n return index\n }\n return -1\n },\n impact(regionIndex, position, velocity) {\n const region = regions[regionIndex]!\n const local = sub(position, region.origin)\n return {\n row: region.firstRow + dot(local, region.rowAxis) / cell,\n column: dot(local, region.columnAxis) / cell,\n along: [dot(velocity, region.columnAxis), dot(velocity, region.rowAxis)],\n normalSpeed: -dot(velocity, region.normal),\n }\n },\n contains: () => true,\n escaped: (position) => position[1] < lowestY,\n }\n}\n","[\n {\n \"id\": \"blood\",\n \"look\": \"blood\",\n \"flow\": 0.05,\n \"pin\": 0.33,\n \"front\": 0.58,\n \"referenceThickness\": 0.6,\n \"slopeCap\": 1.1,\n \"dryTime\": 600,\n \"evaporation\": 0,\n \"opacityRate\": 3.2,\n \"reflectance\": 0.045,\n \"normalScale\": 16,\n \"thin\": 7997966,\n \"thick\": 2753028,\n \"dry\": 3874068,\n \"dryThin\": 6960678,\n \"dropColor\": 7997965,\n \"dropOpacity\": 1,\n \"volume\": 1,\n \"spikes\": 1,\n \"landsAsBlob\": false,\n \"maxAmount\": 2.6,\n \"sources\": {\n \"padrao\": \"F46\",\n \"oficina\": \"W583\"\n }\n },\n {\n \"id\": \"old_blood\",\n \"look\": \"blood\",\n \"flow\": 0.032,\n \"pin\": 0.42,\n \"front\": 0.7,\n \"referenceThickness\": 0.7,\n \"slopeCap\": 1,\n \"dryTime\": 360,\n \"evaporation\": 0,\n \"opacityRate\": 3.8,\n \"reflectance\": 0.03,\n \"normalScale\": 14,\n \"thin\": 7085078,\n \"thick\": 2888717,\n \"dry\": 2758158,\n \"dryThin\": 4860444,\n \"dropColor\": 4854286,\n \"dropOpacity\": 1,\n \"volume\": 0.6,\n \"spikes\": 1,\n \"landsAsBlob\": false,\n \"maxAmount\": 2.6,\n \"sources\": {\n \"padrao\": \"F48\"\n }\n },\n {\n \"id\": \"bile\",\n \"look\": \"bile\",\n \"flow\": 0.02,\n \"pin\": 0.8,\n \"front\": 1.2,\n \"referenceThickness\": 1.2,\n \"slopeCap\": 0.9,\n \"dryTime\": 900,\n \"evaporation\": 0,\n \"opacityRate\": 7,\n \"reflectance\": 0.04,\n \"normalScale\": 12,\n \"thin\": 11121724,\n \"thick\": 7174171,\n \"dry\": 4080160,\n \"dryThin\": 5659180,\n \"dropColor\": 9083434,\n \"dropOpacity\": 1,\n \"volume\": 1.3,\n \"spikes\": 0.3,\n \"landsAsBlob\": false,\n \"maxAmount\": 4,\n \"sources\": {\n \"padrao\": \"F50\",\n \"oficina\": \"W584 (spikes 0.3 W578, cap 4 W691)\"\n }\n },\n {\n \"id\": \"motor_oil\",\n \"look\": \"oil\",\n \"flow\": 0.03,\n \"pin\": 0.12,\n \"front\": 0.22,\n \"referenceThickness\": 0.5,\n \"slopeCap\": 1,\n \"dryTime\": 0,\n \"evaporation\": 0,\n \"opacityRate\": 4.5,\n \"reflectance\": 0.06,\n \"normalScale\": 18,\n \"thin\": 1381135,\n \"thick\": 263173,\n \"dry\": 263173,\n \"dryThin\": 1381135,\n \"dropColor\": 657932,\n \"dropOpacity\": 1,\n \"volume\": 1,\n \"spikes\": 1,\n \"landsAsBlob\": true,\n \"maxAmount\": 2.6,\n \"sources\": {\n \"padrao\": \"F52\",\n \"oficina\": \"W585 (blob W691)\"\n }\n },\n {\n \"id\": \"fuel\",\n \"look\": \"fuel\",\n \"flow\": 0.2,\n \"pin\": 0.035,\n \"front\": 0.07,\n \"referenceThickness\": 0.2,\n \"slopeCap\": 1.2,\n \"dryTime\": 0,\n \"evaporation\": 0.02,\n \"opacityRate\": 0.25,\n \"reflectance\": 0.04,\n \"normalScale\": 0,\n \"thin\": 10129520,\n \"thick\": 7234630,\n \"dry\": 0,\n \"dryThin\": 0,\n \"dropColor\": 12103824,\n \"dropOpacity\": 0.45,\n \"volume\": 1.4,\n \"spikes\": 1,\n \"landsAsBlob\": true,\n \"maxAmount\": 2.6,\n \"sources\": {\n \"padrao\": \"F54\",\n \"oficina\": \"W586 (blob W691)\"\n }\n }\n]\n","import profilesData from '../data/film-profiles.json'\nimport type { LiquidId } from '../types'\nimport type { FilmProfile } from './types'\n\n/** Film profiles of the liquids that run as a film (F46-55, plus the Workshop's `spikes` and `landsAsBlob`). Data in `data/film-profiles.json`. */\nexport const FILM_PROFILES: FilmProfile[] = profilesData as unknown as FilmProfile[]\n\n/** The profile of a liquid with the given overrides, or undefined when the liquid has no film. */\nexport function filmProfileOf(id: LiquidId, overrides: Partial<FilmProfile> = {}): FilmProfile | undefined {\n const profile = FILM_PROFILES.find((entry) => entry.id === id)\n return profile ? { ...profile, ...overrides } : undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA,IACE;AAAA,MACE,IAAM;AAAA,MACN,OAAS;AAAA,MACT,SAAW;AAAA,MACX,YAAc;AAAA,MACd,WAAa;AAAA,MACb,SAAW;AAAA,MACX,SAAW;AAAA,MACX,OAAS;AAAA,MACT,OAAS;AAAA,QACP,QAAU;AAAA,QACV,SAAW,CAAC;AAAA,MACd;AAAA,MACA,MAAQ;AAAA,QACN;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,IAAM;AAAA,MACN,OAAS;AAAA,MACT,SAAW;AAAA,MACX,YAAc;AAAA,MACd,WAAa;AAAA,MACb,SAAW;AAAA,MACX,SAAW;AAAA,MACX,OAAS;AAAA,MACT,YAAc;AAAA,MACd,QAAU;AAAA,MACV,OAAS;AAAA,QACP,QAAU;AAAA,QACV,SAAW;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,MACA,MAAQ;AAAA,QACN;AAAA,QACA;AAAA,MACF;AA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AAU,cAAc,KAAK,CAAC,UAAU,MAAM,OAAO,EAAE;AAC7D,WAAO,UAAU,EAAE,GAAG,SAAS,GAAG,UAAU,IAAI;AAAA,EAClD;","names":["q","x","z","n","basis","flow","options","length","distance","GRAVITY","sideX","sideZ","distance","length","distance"]}