@ignifx/particles 0.21.0 → 0.21.1
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.
- package/README.md +22 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/skills/particles/SKILL.md +74 -74
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["TEXEL_BYTES","DEG_TO_RAD","DEG_TO_RAD","f32","vec3"],"sources":["../src/augmentation.ts","../src/definition/types.ts","../src/assets/particle-asset.ts","../src/errors.ts","../src/definition/values.ts","../src/definition/define-particles.ts","../src/assets/loader.ts","../src/definition/presets/dust.ts","../src/definition/presets/explosion.ts","../src/definition/presets/fire.ts","../src/definition/presets/leaves.ts","../src/definition/presets/rain.ts","../src/definition/presets/smoke.ts","../src/definition/presets/snow.ts","../src/definition/presets/sparkle.ts","../src/definition/presets/sparks.ts","../src/definition/presets/index.ts","../src/emitter/pcg3d.ts","../src/emitter/record-ring.ts","../src/evaluate/noise.ts","../src/evaluate/particle-math.ts","../src/emitter/shapes.ts","../src/emitter/emitter-core.ts","../src/gpu/wgsl.ts","../src/service/particles-service.ts","../src/gpu/particle-system.ts","../src/gpu/particle-systems.ts","../src/settings.ts","../src/version.ts","../src/extension.ts","../src/file-schemas.ts","../src/schemas.ts"],"sourcesContent":["import type { ParticlesService } from \"./service/particles-service.js\";\nimport type { ExtensionContext } from \"@ignifx/core\";\n\n// Declaration merging is what types `app.particles`. The module must import something from\n// `@ignifx/core` or the `declare module` block is `TS2664`, and the barrel must keep its bare\n// `import \"./augmentation.js\"` so declaration bundling does not drop it.\n\ndeclare module \"@ignifx/core\" {\n interface App {\n /**\n * Particles (`docs/plan/2026-09-terrain-particles-shaders.md` §4.3): the budget, the quality\n * multiplier, the gravity, the counters, and the live list of `ParticleSystem` components.\n */\n readonly particles: ParticlesService;\n }\n}\n\n/**\n * Defines `app.particles`, pairing with the augmentation above.\n *\n * @param ctx - The extension registration surface.\n * @param service - The service the property returns.\n * @throws IgnifxError with code `IGX-0401` when something already defined `app.particles`.\n *\n * @internal\n */\nexport function defineParticlesAppProperty(ctx: ExtensionContext, service: ParticlesService): void {\n ctx.defineAppProperty(\"particles\", (): unknown => service);\n}\n","import type { ColorLike, CurveValue, Vec2Like, Vec3Like } from \"@ignifx/core\";\n\n// The `ignifx.particles` document (`docs/plan/2026-09-terrain-particles-shaders.md` §4.2) as\n// `defineParticles` hands it back: every module present, every default filled in, every curve and\n// gradient baked. It is pure data, and both evaluators read it.\n\n/**\n * The `format` discriminator every `.particles.json` document carries.\n *\n * @public\n */\nexport const PARTICLES_FORMAT = \"ignifx.particles\";\n\n/**\n * The document version this build reads and writes.\n *\n * @public\n */\nexport const PARTICLES_FORMAT_VERSION = 1;\n\n/**\n * The asset type name the loader registers.\n *\n * @public\n */\nexport const PARTICLE_ASSET_TYPE = \"particles\";\n\n/**\n * The address suffixes that select the particle loader.\n *\n * @public\n */\nexport const PARTICLE_FILE_EXTENSIONS: readonly string[] = Object.freeze([\".particles.json\"]);\n\n/**\n * How many samples a baked curve or gradient row holds. Both evaluators read the same 64 samples\n * with the same linear rule, which is what makes the lookup the contract between them.\n *\n * @public\n */\nexport const LOOKUP_SAMPLES = 64;\n\n/**\n * Where a particle's position is integrated: in the emitter's space and transformed by the emitter's\n * current world matrix at draw (`\"local\"`, so the effect follows its entity), or baked into world\n * space at spawn (`\"world\"`, so a trail stays where it was emitted).\n *\n * @public\n */\nexport const PARTICLE_SIMULATION_SPACES = [\"local\", \"world\"] as const;\n\n/**\n * The union of {@link PARTICLE_SIMULATION_SPACES}.\n *\n * @public\n */\nexport type ParticleSimulationSpace = (typeof PARTICLE_SIMULATION_SPACES)[number];\n\n/**\n * Every emitter shape. Directional shapes emit along the emitter's local `+Y`.\n *\n * @public\n */\nexport const PARTICLE_SHAPE_KINDS = [\"point\", \"sphere\", \"hemisphere\", \"cone\", \"box\", \"circle\", \"edge\", \"mesh\"] as const;\n\n/**\n * The union of {@link PARTICLE_SHAPE_KINDS}.\n *\n * @public\n */\nexport type ParticleShapeKind = (typeof PARTICLE_SHAPE_KINDS)[number];\n\n/**\n * Where inside a shape particles start: anywhere in it, on its surface, or — for a cone — on its\n * base disc.\n *\n * @public\n */\nexport const PARTICLE_EMIT_FROM = [\"volume\", \"shell\", \"base\"] as const;\n\n/**\n * The union of {@link PARTICLE_EMIT_FROM}.\n *\n * @public\n */\nexport type ParticleEmitFrom = (typeof PARTICLE_EMIT_FROM)[number];\n\n/**\n * How a particle is oriented when drawn.\n *\n * @public\n */\nexport const PARTICLE_RENDER_MODES = [\"billboard\", \"stretched\", \"horizontal\", \"vertical\", \"mesh\"] as const;\n\n/**\n * The union of {@link PARTICLE_RENDER_MODES}.\n *\n * @public\n */\nexport type ParticleRenderMode = (typeof PARTICLE_RENDER_MODES)[number];\n\n/**\n * How particles composite over what is behind them. `premultiplied` is the default: fire and smoke\n * share one draw and blend front-to-back correctly.\n *\n * @public\n */\nexport const PARTICLE_BLEND_MODES = [\"premultiplied\", \"additive\", \"alpha\"] as const;\n\n/**\n * The union of {@link PARTICLE_BLEND_MODES}.\n *\n * @public\n */\nexport type ParticleBlendMode = (typeof PARTICLE_BLEND_MODES)[number];\n\n/**\n * The core primitives a `\"mesh\"` renderer may draw, each built at unit size.\n *\n * @public\n */\nexport const PARTICLE_MESHES = [\"box\", \"sphere\", \"plane\", \"cylinder\", \"capsule\", \"torus\"] as const;\n\n/**\n * The union of {@link PARTICLE_MESHES}.\n *\n * @public\n */\nexport type ParticleMeshName = (typeof PARTICLE_MESHES)[number];\n\n/**\n * How a sprite sheet picks its frame: from a curve over the particle's life, at random per particle,\n * or advancing at a fixed rate.\n *\n * @public\n */\nexport const PARTICLE_FRAME_MODES = [\"curve\", \"random\", \"fps\"] as const;\n\n/**\n * The union of {@link PARTICLE_FRAME_MODES}.\n *\n * @public\n */\nexport type ParticleFrameMode = (typeof PARTICLE_FRAME_MODES)[number];\n\n/**\n * One stop of a colour gradient: normalized time, then sRGB red, green, blue, and alpha in `0`–`1`.\n *\n * @public\n */\nexport type GradientStop = readonly [t: number, r: number, g: number, b: number, a: number];\n\n/**\n * A number a document may give as a constant, a range, or a curve. As authored:\n * `2`, `{ \"min\": 1, \"max\": 3 }`, or `{ \"curve\": { \"keys\": [[0, 1, 0, 0], [1, 0, 0, 0]] } }`.\n *\n * @public\n */\nexport type ScalarValueInput = number | { readonly min: number; readonly max: number } | { readonly curve: CurveValue };\n\n/**\n * A colour as a document may write it: an `{ r, g, b, a }` object or an `[r, g, b, a]` array, both\n * sRGB in `0`–`1`.\n *\n * @public\n */\nexport type ColorInput = ColorLike | readonly [r: number, g: number, b: number, a: number];\n\n/**\n * A colour a document may give as a constant, a random pick between two, or a gradient.\n *\n * @public\n */\nexport type ColorValueInput =\n | ColorInput\n | { readonly min: ColorInput; readonly max: ColorInput }\n | { readonly gradient: readonly GradientStop[] };\n\n/**\n * A resolved scalar value. A `\"curve\"` carries its {@link LOOKUP_SAMPLES} baked samples so the CPU\n * side never re-evaluates the Hermite spline.\n *\n * @public\n */\nexport type ScalarValue =\n | { readonly kind: \"constant\"; readonly value: number }\n | { readonly kind: \"random\"; readonly min: number; readonly max: number }\n | { readonly kind: \"curve\"; readonly curve: CurveValue; readonly samples: Float32Array };\n\n/**\n * A resolved colour value. A `\"gradient\"` carries its baked RGBA samples, sRGB, four floats per\n * sample.\n *\n * @public\n */\nexport type ColorValue =\n | { readonly kind: \"constant\"; readonly value: ColorLike }\n | { readonly kind: \"random\"; readonly min: ColorLike; readonly max: ColorLike }\n | { readonly kind: \"gradient\"; readonly stops: readonly GradientStop[]; readonly samples: Float32Array };\n\n/**\n * The `main` module: capacity, timing, space, and playback.\n *\n * @public\n */\nexport interface ParticleMain {\n /** How many spawn records the ring holds. Older records are overwritten, alive or not. */\n readonly capacity: number;\n /** How long one emission cycle lasts, in seconds. */\n readonly duration: number;\n /** Whether the cycle repeats. A non-looping system stops when the cycle ends and the last particle dies. */\n readonly looping: boolean;\n /** Whether `play()` fast-forwards one full cycle first, so a looping effect starts steady. */\n readonly prewarm: boolean;\n /** Seconds after `play()` before emission starts. */\n readonly startDelay: number;\n /** Where positions live. */\n readonly simulationSpace: ParticleSimulationSpace;\n /** The emission seed; `0` picks one at random on `play()`. A component's `seed` field overrides it. */\n readonly seed: number;\n /** Whether a `ParticleSystem` starts playing the first frame it is enabled. */\n readonly playOnAwake: boolean;\n /** A multiplier on the system's own clock. */\n readonly timeScale: number;\n /** The renderer's sort key within the transparent phase; lower draws first. */\n readonly renderOrder: number;\n}\n\n/**\n * One burst: `count` particles at `time` into the cycle, repeated `cycles` times every `interval`\n * seconds with `probability`.\n *\n * @public\n */\nexport interface ParticleBurst {\n /** Seconds into the cycle. */\n readonly time: number;\n /** How many particles; a random count is rolled per firing. */\n readonly count: ScalarValue;\n /** How many times the burst fires per cycle; `0` means until the cycle ends. */\n readonly cycles: number;\n /** Seconds between firings. */\n readonly interval: number;\n /** The chance a firing happens, `0`–`1`. */\n readonly probability: number;\n}\n\n/**\n * The `emission` module.\n *\n * @public\n */\nexport interface ParticleEmission {\n /** Particles per second while the cycle runs. */\n readonly rateOverTime: number;\n /** Particles per metre the emitter moves. */\n readonly rateOverDistance: number;\n /** The bursts, in declaration order. */\n readonly bursts: readonly ParticleBurst[];\n}\n\n/**\n * The `shape` module. Every field is present; a shape reads the ones that apply to it.\n *\n * @public\n */\nexport interface ParticleShape {\n /** Which shape. */\n readonly kind: ParticleShapeKind;\n /** The radius of a sphere, hemisphere, circle, or cone base; half the length of an edge. */\n readonly radius: number;\n /** How much of a sphere, hemisphere, or circle's radius emits, `0` (surface only) to `1` (whole). */\n readonly thickness: number;\n /** The angular span of a sphere, hemisphere, circle, or cone, in degrees. */\n readonly arc: number;\n /** A cone's half-angle in degrees. */\n readonly angle: number;\n /** A cone's height, or an edge's length. */\n readonly length: number;\n /** A box's full extents. */\n readonly size: Vec3Like;\n /** Where inside the shape particles start. */\n readonly emitFrom: ParticleEmitFrom;\n /** How much of the start direction is random, `0`–`1`. */\n readonly randomDirection: number;\n /** How much of the start direction points away from the shape's centre, `0`–`1`. */\n readonly spherizeDirection: number;\n /** A `\"mesh\"` shape's triangle soup: three floats per vertex, three vertices per triangle. */\n readonly vertices: Float32Array;\n}\n\n/**\n * The `start` module: what a particle is born with.\n *\n * @public\n */\nexport interface ParticleStart {\n /** Seconds a particle lives. */\n readonly lifetime: ScalarValue;\n /** Metres per second along the start direction. */\n readonly speed: ScalarValue;\n /** The particle's size, in metres. */\n readonly size: ScalarValue;\n /** Optional per-axis multipliers on `size`, or `null` for a uniform size. */\n readonly size3D: Vec3Like | null;\n /** The start rotation, in degrees. */\n readonly rotation: ScalarValue;\n /** The start colour, sRGB. A random value picks between two colours per particle. */\n readonly color: ColorValue;\n}\n\n/**\n * A rotation about a fixed axis through the emitter.\n *\n * @public\n */\nexport interface ParticleOrbit {\n /** The axis, normalized at definition time. */\n readonly axis: Vec3Like;\n /** Degrees per second. */\n readonly speed: number;\n}\n\n/**\n * A positional noise offset sampled at the analytic position.\n *\n * @public\n */\nexport interface ParticleNoise {\n /** The largest offset, in metres. */\n readonly strength: number;\n /** How quickly the field varies with position. */\n readonly frequency: number;\n /** How the field drifts with time, in field units per second. */\n readonly scroll: Vec3Like;\n /** How many octaves are summed, `1` or `2`. */\n readonly octaves: number;\n /** A multiplier on `strength` over the particle's life. */\n readonly influenceOverLife: ScalarValue;\n}\n\n/**\n * The `forces` module.\n *\n * @public\n */\nexport interface ParticleForces {\n /** An explicit world gravity, or `null` to use `gravityMultiplier` times the app's gravity. */\n readonly gravity: Vec3Like | null;\n /** How much of the app's gravity applies when `gravity` is `null`. */\n readonly gravityMultiplier: number;\n /** Linear drag; `0` is none. */\n readonly drag: number;\n /** A constant acceleration, in metres per second squared, folded into gravity. */\n readonly constantForce: Vec3Like;\n /** A rotation about an axis, or `null`. */\n readonly orbit: ParticleOrbit | null;\n /** A noise offset, or `null`. */\n readonly noise: ParticleNoise | null;\n}\n\n/**\n * The `overLifetime` module.\n *\n * @public\n */\nexport interface ParticleOverLifetime {\n /** A colour multiplied onto the start colour over the particle's life, or `null`. */\n readonly color: ColorValue | null;\n /** A multiplier on the start size (the X axis when `sizeY` or `sizeZ` is set), or `null`. */\n readonly size: ScalarValue | null;\n /** A separate multiplier for the Y axis, or `null` to follow `size`. */\n readonly sizeY: ScalarValue | null;\n /** A separate multiplier for the Z axis, or `null` to follow `size`. */\n readonly sizeZ: ScalarValue | null;\n /** The angular speed, in degrees per second, or `null` for none. */\n readonly rotation: ScalarValue | null;\n}\n\n/**\n * A sprite sheet laid out in a grid.\n *\n * @public\n */\nexport interface ParticleSheet {\n /** Columns and rows of the grid. */\n readonly tiles: Vec2Like;\n /** How the frame is chosen. */\n readonly mode: ParticleFrameMode;\n /** The frame over the particle's life as a fraction of the sheet, for `\"curve\"`. */\n readonly frameOverTime: ScalarValue;\n /** Frames per second, for `\"fps\"`. */\n readonly fps: number;\n}\n\n/**\n * The `renderer` module.\n *\n * @public\n */\nexport interface ParticleRenderer {\n /** How particles are oriented. */\n readonly mode: ParticleRenderMode;\n /** The primitive a `\"mesh\"` renderer draws. */\n readonly mesh: ParticleMeshName;\n /** The texture's asset address, or `null` for a procedural soft disc. */\n readonly texture: string | null;\n /** The sprite-sheet layout of `texture`, or `null` for a single image. */\n readonly sheet: ParticleSheet | null;\n /** How particles composite. */\n readonly blend: ParticleBlendMode;\n /** Whether particles are shaded with the main light and the ambient colour. */\n readonly lit: boolean;\n /** Where the particle's origin sits inside its quad, in size units; `(0, 0)` is the centre. */\n readonly pivot: Vec2Like;\n /** How much of the speed a `\"stretched\"` particle adds to its length. */\n readonly speedScale: number;\n /** A multiplier on a `\"stretched\"` particle's length. */\n readonly lengthScale: number;\n}\n\n/**\n * One row of the lookup texture: which row it is and how its bytes map back to values.\n *\n * @public\n */\nexport interface LookupRow {\n /** The row index in the texture. */\n readonly index: number;\n /** The value a byte of `0` decodes to. */\n readonly min: number;\n /** The value a byte of `255` decodes to. */\n readonly max: number;\n}\n\n/**\n * The baked lookup texture both evaluators sample: {@link LOOKUP_SAMPLES} texels wide, RGBA8, one\n * row per curve or gradient the definition uses, in the order colour, size, rotation, noise\n * influence, sheet frame. The GPU reads the bytes the CPU decodes, to the filter's precision.\n *\n * @public\n */\nexport interface ParticleLookup {\n /** How many rows the texture has; at least `1`. */\n readonly rows: number;\n /** The texels, `rows * LOOKUP_SAMPLES * 4` bytes, top row first. */\n readonly pixels: Uint8Array;\n /** The colour-over-life gradient row, or `null`. */\n readonly color: LookupRow | null;\n /** The size-over-life row, or `null`. Per-axis sizes use R, G, and B. */\n readonly size: LookupRow | null;\n /** The angular-speed-over-life row, or `null`. */\n readonly rotation: LookupRow | null;\n /** The noise-influence-over-life row, or `null`. */\n readonly noise: LookupRow | null;\n /** The frame-over-life row, or `null`. */\n readonly frame: LookupRow | null;\n}\n\n/**\n * The parsed and baked `.particles.json` document.\n *\n * @public\n */\nexport interface ParticleDefinition {\n /** Always `\"ignifx.particles\"`. */\n readonly format: typeof PARTICLES_FORMAT;\n /** Always `1` in this build. */\n readonly formatVersion: number;\n /** Capacity, timing, space, and playback. */\n readonly main: ParticleMain;\n /** Rates and bursts. */\n readonly emission: ParticleEmission;\n /** Where particles start and which way they go. */\n readonly shape: ParticleShape;\n /** What a particle is born with. */\n readonly start: ParticleStart;\n /** What acts on it. */\n readonly forces: ParticleForces;\n /** How it changes over its life. */\n readonly overLifetime: ParticleOverLifetime;\n /** How it is drawn. */\n readonly renderer: ParticleRenderer;\n /** The baked lookup texture. */\n readonly lookup: ParticleLookup;\n}\n\n/**\n * What {@link defineParticles} accepts: the document as authored, every key optional. Unknown keys\n * are reported, because a misspelled module silently doing nothing is the worst outcome for an\n * effect file.\n *\n * @public\n */\nexport interface ParticleDefinitionInput {\n /** Always `\"ignifx.particles\"` when present. */\n readonly format?: string;\n /** The document version. */\n readonly formatVersion?: number;\n /** The `main` module. */\n readonly main?: ParticleMainInput;\n /** The `emission` module. */\n readonly emission?: ParticleEmissionInput;\n /** The `shape` module. */\n readonly shape?: ParticleShapeInput;\n /** The `start` module. */\n readonly start?: ParticleStartInput;\n /** The `forces` module. */\n readonly forces?: ParticleForcesInput;\n /** The `overLifetime` module. */\n readonly overLifetime?: ParticleOverLifetimeInput;\n /** The `renderer` module. */\n readonly renderer?: ParticleRendererInput;\n}\n\n/**\n * The `main` module as authored.\n *\n * @public\n */\nexport interface ParticleMainInput {\n /** See {@link ParticleMain.capacity}. Defaults to `1000`. */\n readonly capacity?: number;\n /** See {@link ParticleMain.duration}. Defaults to `5`. */\n readonly duration?: number;\n /** See {@link ParticleMain.looping}. Defaults to `true`. */\n readonly looping?: boolean;\n /** See {@link ParticleMain.prewarm}. Defaults to `false`. */\n readonly prewarm?: boolean;\n /** See {@link ParticleMain.startDelay}. Defaults to `0`. */\n readonly startDelay?: number;\n /** See {@link ParticleMain.simulationSpace}. Defaults to `\"local\"`. */\n readonly simulationSpace?: ParticleSimulationSpace;\n /** See {@link ParticleMain.seed}. Defaults to `0`. */\n readonly seed?: number;\n /** See {@link ParticleMain.playOnAwake}. Defaults to `true`. */\n readonly playOnAwake?: boolean;\n /** See {@link ParticleMain.timeScale}. Defaults to `1`. */\n readonly timeScale?: number;\n /** See {@link ParticleMain.renderOrder}. Defaults to `0`. */\n readonly renderOrder?: number;\n}\n\n/**\n * One burst as authored.\n *\n * @public\n */\nexport interface ParticleBurstInput {\n /** Seconds into the cycle. Defaults to `0`. */\n readonly time?: number;\n /** How many particles. Defaults to `10`. */\n readonly count?: ScalarValueInput;\n /** Firings per cycle; `0` means until the cycle ends. Defaults to `1`. */\n readonly cycles?: number;\n /** Seconds between firings. Defaults to `0.1`. */\n readonly interval?: number;\n /** The chance a firing happens. Defaults to `1`. */\n readonly probability?: number;\n}\n\n/**\n * The `emission` module as authored.\n *\n * @public\n */\nexport interface ParticleEmissionInput {\n /** Particles per second. Defaults to `10`. */\n readonly rateOverTime?: number;\n /** Particles per metre moved. Defaults to `0`. */\n readonly rateOverDistance?: number;\n /** The bursts. Defaults to none. */\n readonly bursts?: readonly ParticleBurstInput[];\n}\n\n/**\n * The `shape` module as authored.\n *\n * @public\n */\nexport interface ParticleShapeInput {\n /** Which shape. Defaults to `\"cone\"`. */\n readonly kind?: ParticleShapeKind;\n /** See {@link ParticleShape.radius}. Defaults to `0.2`. */\n readonly radius?: number;\n /** See {@link ParticleShape.thickness}. Defaults to `1`. */\n readonly thickness?: number;\n /** See {@link ParticleShape.arc}. Defaults to `360`. */\n readonly arc?: number;\n /** See {@link ParticleShape.angle}. Defaults to `25`. */\n readonly angle?: number;\n /** See {@link ParticleShape.length}. Defaults to `1`. */\n readonly length?: number;\n /** See {@link ParticleShape.size}. Defaults to `(1, 1, 1)`. */\n readonly size?: Vec3Like;\n /** See {@link ParticleShape.emitFrom}. Defaults to `\"base\"` for a cone and `\"volume\"` otherwise. */\n readonly emitFrom?: ParticleEmitFrom;\n /** See {@link ParticleShape.randomDirection}. Defaults to `0`. */\n readonly randomDirection?: number;\n /** See {@link ParticleShape.spherizeDirection}. Defaults to `0`. */\n readonly spherizeDirection?: number;\n /** A `\"mesh\"` shape's triangles, nine numbers per triangle. */\n readonly vertices?: readonly number[];\n}\n\n/**\n * The `start` module as authored.\n *\n * @public\n */\nexport interface ParticleStartInput {\n /** Defaults to `2`. */\n readonly lifetime?: ScalarValueInput;\n /** Defaults to `2`. */\n readonly speed?: ScalarValueInput;\n /** Defaults to `0.2`. */\n readonly size?: ScalarValueInput;\n /** Defaults to `null`. */\n readonly size3D?: Vec3Like | null;\n /** Defaults to `0`. */\n readonly rotation?: ScalarValueInput;\n /** Defaults to opaque white. */\n readonly color?: ColorValueInput;\n}\n\n/**\n * The `forces` module as authored.\n *\n * @public\n */\nexport interface ParticleForcesInput {\n /** An explicit gravity, or `null`/omitted to scale the app's. */\n readonly gravity?: Vec3Like | null;\n /** Defaults to `0`. */\n readonly gravityMultiplier?: number;\n /** Defaults to `0`. */\n readonly drag?: number;\n /** Defaults to `(0, 0, 0)`. */\n readonly constantForce?: Vec3Like;\n /** Defaults to none. */\n readonly orbit?: { readonly axis?: Vec3Like; readonly speed?: number } | null;\n /** Defaults to none. */\n readonly noise?: {\n readonly strength?: number;\n readonly frequency?: number;\n readonly scroll?: Vec3Like;\n readonly octaves?: number;\n readonly influenceOverLife?: ScalarValueInput;\n } | null;\n}\n\n/**\n * The `overLifetime` module as authored.\n *\n * @public\n */\nexport interface ParticleOverLifetimeInput {\n /** A gradient, or a constant tint. */\n readonly color?: ColorValueInput | null;\n /** A curve or constant multiplier. */\n readonly size?: ScalarValueInput | null;\n /** A separate Y multiplier. */\n readonly sizeY?: ScalarValueInput | null;\n /** A separate Z multiplier. */\n readonly sizeZ?: ScalarValueInput | null;\n /** Angular speed in degrees per second. */\n readonly rotation?: ScalarValueInput | null;\n}\n\n/**\n * A sprite sheet as authored.\n *\n * @public\n */\nexport interface ParticleSheetInput {\n /** Columns and rows. Defaults to `(1, 1)`. */\n readonly tiles?: Vec2Like;\n /** A curve over life, `\"random\"`, or `{ fps }`. Defaults to a linear curve over the whole sheet. */\n readonly frameOverTime?: ScalarValueInput | \"random\" | { readonly fps: number };\n}\n\n/**\n * The `renderer` module as authored.\n *\n * @public\n */\nexport interface ParticleRendererInput {\n /** Defaults to `\"billboard\"`. */\n readonly mode?: ParticleRenderMode;\n /** Defaults to `\"box\"`. */\n readonly mesh?: ParticleMeshName;\n /** Defaults to `null`. */\n readonly texture?: string | null;\n /** Defaults to `null`. */\n readonly sheet?: ParticleSheetInput | null;\n /** Defaults to `\"premultiplied\"`. */\n readonly blend?: ParticleBlendMode;\n /** Defaults to `false`. */\n readonly lit?: boolean;\n /** Defaults to `(0, 0)`. */\n readonly pivot?: Vec2Like;\n /** Defaults to `0`. */\n readonly speedScale?: number;\n /** Defaults to `1`. */\n readonly lengthScale?: number;\n}\n","import { PARTICLE_ASSET_TYPE } from \"../definition/types.js\";\nimport type { ParticleDefinition } from \"../definition/types.js\";\nimport type { AssetHandle, TextureAsset } from \"@ignifx/core\";\n\n// The loaded `.particles.json` document (`docs/architecture/05-assets-and-loading.md` §5). It owns\n// no device resources: `app.particles` builds the shader, the lookup texture and the material on\n// first use and shares them between every system playing the same asset.\n\n/**\n * A parsed particle document.\n *\n * @example\n * ```ts\n * const handle = app.assets.load<ParticleAsset>(\"fx/fire.particles.json\");\n * await handle.promise;\n * handle.value.definition.main.capacity; // 1000\n * ```\n *\n * @public\n */\nexport class ParticleAsset {\n /** The asset type name, so `assetRef` and the inspector can round-trip a reference. */\n static assetType: string = PARTICLE_ASSET_TYPE;\n\n /** Where the document was loaded from, or the `memory:` address it was published at. */\n readonly address: string;\n\n /** The parsed, baked document. */\n readonly definition: ParticleDefinition;\n\n /** The texture the renderer samples, or `null` for the procedural soft disc. */\n readonly texture: AssetHandle<TextureAsset> | null;\n\n readonly #ownsTexture: boolean;\n\n /**\n * Wraps a parsed document.\n *\n * @param address - Where it came from.\n * @param definition - The parsed document.\n * @param texture - The renderer's texture handle, or `null`.\n * @param ownsTexture - Whether {@link ParticleAsset.dispose} releases the texture handle. The\n * loader's dependency is released by the asset service; an in-memory asset holds its own.\n *\n * @internal\n */\n constructor(\n address: string,\n definition: ParticleDefinition,\n texture: AssetHandle<TextureAsset> | null = null,\n ownsTexture: boolean = false,\n ) {\n this.address = address;\n this.definition = definition;\n this.texture = texture;\n this.#ownsTexture = ownsTexture;\n }\n\n /**\n * Releases what the asset holds beyond its data. The `particles` asset type's `unload` runs it\n * when the last holder releases the handle.\n */\n dispose(): void {\n if (this.#ownsTexture) {\n this.texture?.release();\n }\n }\n}\n","import { IgnifxError } from \"@ignifx/core\";\nimport type { ErrorContext } from \"@ignifx/core\";\n\n// This package owns `IGX-1700`-`1749` (`@ignifx/particles-2d` has `1750`-`1799`;\n// `docs/architecture/15-devtools-and-diagnostics.md` §1). An extension keeps its own table and\n// hands it to the app through `ExtensionContext.registerErrorCodes`.\n\n/**\n * Every diagnostic code `@ignifx/particles` can throw or log, keyed by an intention-revealing name\n * so call sites read as prose and the compiler catches typos (coding standards §5.2).\n *\n * @example\n * ```ts\n * throw particlesError(ParticlesErrorCode.invalidParticlesFile, \"fire.particles.json declares no main.\", {\n * context: { file: \"fire.particles.json\", reason: \"main is missing\" },\n * });\n * ```\n *\n * @public\n */\nexport const ParticlesErrorCode = {\n /** A `.particles.json` document, or a `defineParticles` input, is not an `ignifx.particles` document this build can read. */\n invalidParticlesFile: \"IGX-1701\",\n /** A `ParticleSystem` asked for more capacity than the `app.particles.maxParticles` budget has left; it was clamped. */\n budgetExceeded: \"IGX-1702\",\n /** A second `particles()` extension was registered on one app. */\n duplicateExtension: \"IGX-1703\",\n /** `particleDefinition` named a preset that does not exist. */\n unknownPreset: \"IGX-1704\",\n /** A `ParticleSystem` method that needs a definition ran without one. */\n noDefinition: \"IGX-1705\",\n /** The generated particle shader failed to load or to build a material. */\n shaderFailed: \"IGX-1706\",\n /** `emit`, `simulate`, or a value argument was not a finite number in range. */\n invalidArgument: \"IGX-1707\",\n} as const;\n\n/**\n * The union of the codes the `ParticlesErrorCode` table declares.\n *\n * @public\n */\nexport type ParticlesErrorCode = (typeof ParticlesErrorCode)[keyof typeof ParticlesErrorCode];\n\n/**\n * The one-line message template of every code, as `ExtensionContext.registerErrorCodes` wants it.\n * Context keys appear in braces, matching the core table's convention.\n *\n * @public\n */\nexport const PARTICLES_ERROR_MESSAGES: Readonly<Record<string, string>> = Object.freeze({\n \"IGX-1701\": \"{file} is not an ignifx.particles document this build can read: {reason}.\",\n \"IGX-1702\":\n \"{entity} asked for {capacity} particles, but only {available} of the {budget} particle budget remain; the system was clamped.\",\n \"IGX-1703\": \"The particles() extension is already registered on this app.\",\n \"IGX-1704\": \"{preset} is not a particle preset; the presets are {presets}.\",\n \"IGX-1705\": \"{entity} has a ParticleSystem with no definition, so {method}() cannot run.\",\n \"IGX-1706\": \"The particle shader for {definition} could not be built: {message}.\",\n \"IGX-1707\": \"{method} needs {expected}, not {value}.\",\n});\n\n/**\n * Options accepted by {@link particlesError}: the same subset of `IgnifxErrorOptions` this package\n * uses.\n *\n * @public\n */\nexport interface ParticlesErrorOptions {\n /** Identifiers that locate the failure. */\n readonly context?: ErrorContext;\n /** One sentence telling the developer what to do about it. */\n readonly hint?: string;\n /** The failure being wrapped, when there is one. */\n readonly cause?: unknown;\n}\n\n/**\n * Builds an `IgnifxError` carrying one of this package's codes.\n *\n * @param code - The code from the `ParticlesErrorCode` table.\n * @param message - The actionable development sentence.\n * @param options - Context identifiers, a remedy hint, and the wrapped cause.\n * @returns The error to throw or to reject with.\n *\n * @example\n * ```ts\n * throw particlesError(ParticlesErrorCode.unknownPreset, \"lava is not a particle preset.\", {\n * context: { preset: \"lava\" },\n * });\n * ```\n *\n * @public\n */\nexport function particlesError(\n code: ParticlesErrorCode,\n message: string,\n options?: ParticlesErrorOptions,\n): IgnifxError {\n return new IgnifxError(code, message, {\n ...(options?.context === undefined ? {} : { context: options.context }),\n ...(options?.hint === undefined ? {} : { hint: options.hint }),\n ...(options?.cause === undefined ? {} : { cause: options.cause }),\n });\n}\n","import { assertNever } from \"@ignifx/core\";\nimport { LOOKUP_SAMPLES } from \"./types.js\";\nimport type { ColorValue, GradientStop, ScalarValue } from \"./types.js\";\nimport type { ColorLike, CurveKey, CurveValue } from \"@ignifx/core\";\n\n// Hermite curves, gradients, and the 64-sample lookup rows both evaluators read\n// (`docs/plan/2026-09-terrain-particles-shaders.md` §4.1). The baking functions run once inside\n// `defineParticles`; the sampling functions read preallocated rows through `out` parameters.\n\n/** Floats per colour sample. */\nconst COLOR_FLOATS = 4;\n\n/**\n * Evaluates a cubic Hermite curve at `t`, clamping to the end keys outside the key range\n * (`docs/architecture/06-serialization-and-scene-format.md` §3: keys are\n * `[time, value, inTangent, outTangent]`).\n *\n * @param curve - The curve; its keys must be sorted by time and non-empty.\n * @param t - Where to evaluate.\n * @returns The value; `0` for a curve with no keys.\n *\n * @public\n */\nexport function evaluateCurve(curve: CurveValue, t: number): number {\n const keys = curve.keys;\n const count = keys.length;\n const first = keys[0];\n if (first === undefined) {\n return 0;\n }\n if (t <= first[0]) {\n return first[1];\n }\n const last = keys[count - 1];\n if (last === undefined || t >= last[0]) {\n return last?.[1] ?? first[1];\n }\n let index = 1;\n while (index < count) {\n const key = keys[index];\n if (key !== undefined && key[0] >= t) {\n break;\n }\n index += 1;\n }\n const k0 = keys[index - 1];\n const k1 = keys[index];\n if (k0 === undefined || k1 === undefined) {\n return first[1];\n }\n return hermite(k0, k1, t);\n}\n\n/**\n * Interpolates between two keys.\n *\n * @param k0 - The key before `t`.\n * @param k1 - The key after `t`.\n * @param t - Where to evaluate.\n * @returns The interpolated value.\n */\nfunction hermite(k0: CurveKey, k1: CurveKey, t: number): number {\n const dt = k1[0] - k0[0];\n if (dt <= 0) {\n return k1[1];\n }\n const s = (t - k0[0]) / dt;\n const s2 = s * s;\n const s3 = s2 * s;\n const h00 = 2 * s3 - 3 * s2 + 1;\n const h10 = s3 - 2 * s2 + s;\n const h01 = -2 * s3 + 3 * s2;\n const h11 = s3 - s2;\n return h00 * k0[1] + h10 * dt * k0[3] + h01 * k1[1] + h11 * dt * k1[2];\n}\n\n/**\n * Bakes a curve into {@link LOOKUP_SAMPLES} samples over `[0, 1]`.\n *\n * @param curve - The curve.\n * @returns The samples; sample `i` is the curve at `i / 63`.\n *\n * @public\n */\nexport function bakeCurve(curve: CurveValue): Float32Array {\n const samples = new Float32Array(LOOKUP_SAMPLES);\n for (let index = 0; index < LOOKUP_SAMPLES; index += 1) {\n samples[index] = evaluateCurve(curve, index / (LOOKUP_SAMPLES - 1));\n }\n return samples;\n}\n\n/**\n * Evaluates a gradient at `t` by linear interpolation between stops, clamping outside them.\n *\n * @param stops - The stops, sorted by time and non-empty.\n * @param t - Where to evaluate.\n * @param out - Receives the sRGB colour.\n * @returns `out`.\n *\n * @public\n */\nexport function evaluateGradient(stops: readonly GradientStop[], t: number, out: Float32Array): Float32Array {\n const first = stops[0];\n if (first === undefined) {\n out[0] = 1;\n out[1] = 1;\n out[2] = 1;\n out[3] = 1;\n return out;\n }\n const last = stops[stops.length - 1] ?? first;\n if (t <= first[0]) {\n return writeStop(first, out);\n }\n if (t >= last[0]) {\n return writeStop(last, out);\n }\n let index = 1;\n while (index < stops.length) {\n const stop = stops[index];\n if (stop !== undefined && stop[0] >= t) {\n break;\n }\n index += 1;\n }\n const a = stops[index - 1];\n const b = stops[index];\n if (a === undefined || b === undefined) {\n return writeStop(first, out);\n }\n const span = b[0] - a[0];\n const s = span <= 0 ? 1 : (t - a[0]) / span;\n out[0] = a[1] + (b[1] - a[1]) * s;\n out[1] = a[2] + (b[2] - a[2]) * s;\n out[2] = a[3] + (b[3] - a[3]) * s;\n out[3] = a[4] + (b[4] - a[4]) * s;\n return out;\n}\n\n/**\n * Copies a stop's colour.\n *\n * @param stop - The stop.\n * @param out - Receives the colour.\n * @returns `out`.\n */\nfunction writeStop(stop: GradientStop, out: Float32Array): Float32Array {\n out[0] = stop[1];\n out[1] = stop[2];\n out[2] = stop[3];\n out[3] = stop[4];\n return out;\n}\n\n/**\n * Bakes a gradient into {@link LOOKUP_SAMPLES} RGBA samples.\n *\n * @param stops - The stops.\n * @returns `LOOKUP_SAMPLES * 4` floats, sRGB.\n *\n * @public\n */\nexport function bakeGradient(stops: readonly GradientStop[]): Float32Array {\n const samples = new Float32Array(LOOKUP_SAMPLES * COLOR_FLOATS);\n const scratch = new Float32Array(COLOR_FLOATS);\n for (let index = 0; index < LOOKUP_SAMPLES; index += 1) {\n evaluateGradient(stops, index / (LOOKUP_SAMPLES - 1), scratch);\n samples.set(scratch, index * COLOR_FLOATS);\n }\n return samples;\n}\n\n/**\n * Samples a baked scalar row with the linear rule both evaluators share: `x = t * 63`, then a lerp\n * between samples `floor(x)` and `floor(x) + 1`.\n *\n * @param samples - A row of {@link LOOKUP_SAMPLES} floats.\n * @param t - The normalized time, clamped to `[0, 1]`.\n * @returns The interpolated value.\n *\n * @public\n */\nexport function sampleRow(samples: Float32Array, t: number): number {\n const clamped = t <= 0 ? 0 : t >= 1 ? 1 : t;\n const x = clamped * (LOOKUP_SAMPLES - 1);\n const index = Math.floor(x);\n const next = index + 1 >= LOOKUP_SAMPLES ? index : index + 1;\n const a = samples[index] ?? 0;\n const b = samples[next] ?? a;\n return a + (b - a) * (x - index);\n}\n\n/**\n * The smallest value a scalar can produce: the constant, the range's `min`, or the curve's minimum.\n *\n * @param value - The scalar.\n * @returns The minimum.\n *\n * @public\n */\nexport function scalarMin(value: ScalarValue): number {\n switch (value.kind) {\n case \"constant\":\n return value.value;\n case \"random\":\n return Math.min(value.min, value.max);\n case \"curve\":\n return rowMin(value.samples);\n default:\n return assertNever(value, \"scalar value\");\n }\n}\n\n/**\n * The largest value a scalar can produce.\n *\n * @param value - The scalar.\n * @returns The maximum.\n *\n * @public\n */\nexport function scalarMax(value: ScalarValue): number {\n switch (value.kind) {\n case \"constant\":\n return value.value;\n case \"random\":\n return Math.max(value.min, value.max);\n case \"curve\":\n return rowMax(value.samples);\n default:\n return assertNever(value, \"scalar value\");\n }\n}\n\n/**\n * The smallest sample of a row.\n *\n * @param samples - The row.\n * @returns The minimum, or `0` for an empty row.\n */\nexport function rowMin(samples: Float32Array): number {\n let min = Number.POSITIVE_INFINITY;\n for (let index = 0; index < samples.length; index += 1) {\n const sample = samples[index] ?? 0;\n if (sample < min) {\n min = sample;\n }\n }\n return min === Number.POSITIVE_INFINITY ? 0 : min;\n}\n\n/**\n * The largest sample of a row.\n *\n * @param samples - The row.\n * @returns The maximum, or `0` for an empty row.\n */\nexport function rowMax(samples: Float32Array): number {\n let max = Number.NEGATIVE_INFINITY;\n for (let index = 0; index < samples.length; index += 1) {\n const sample = samples[index] ?? 0;\n if (sample > max) {\n max = sample;\n }\n }\n return max === Number.NEGATIVE_INFINITY ? 0 : max;\n}\n\n/**\n * Resolves a scalar at spawn: the constant, a pick inside the range by `unit`, or the curve sampled\n * at `t` (the normalized position in the emission cycle).\n *\n * @param value - The scalar.\n * @param unit - A uniform random number in `[0, 1)`.\n * @param t - The normalized cycle time, for a curve.\n * @returns The resolved number.\n *\n * @public\n */\nexport function resolveScalar(value: ScalarValue, unit: number, t: number): number {\n switch (value.kind) {\n case \"constant\":\n return value.value;\n case \"random\":\n return value.min + (value.max - value.min) * unit;\n case \"curve\":\n return sampleRow(value.samples, t);\n default:\n return assertNever(value, \"scalar value\");\n }\n}\n\n/**\n * Whether a scalar is a constant `1`, so a module can skip it entirely.\n *\n * @param value - The scalar.\n * @returns `true` for a constant equal to one.\n *\n * @public\n */\nexport function isUnitScalar(value: ScalarValue): boolean {\n return value.kind === \"constant\" && value.value === 1;\n}\n\n/**\n * The colour a random or constant start colour resolves to for one particle, in sRGB, without\n * allocating. A gradient start colour samples at `t`.\n *\n * @param value - The colour value.\n * @param unit - A uniform random number in `[0, 1)`; picks between `min` and `max`.\n * @param t - The normalized cycle time, for a gradient.\n * @param out - Receives `r, g, b, a`.\n * @returns `out`.\n *\n * @public\n */\nexport function resolveColor(value: ColorValue, unit: number, t: number, out: Float32Array): Float32Array {\n switch (value.kind) {\n case \"constant\":\n return writeColor(value.value, out);\n case \"random\":\n out[0] = value.min.r + (value.max.r - value.min.r) * unit;\n out[1] = value.min.g + (value.max.g - value.min.g) * unit;\n out[2] = value.min.b + (value.max.b - value.min.b) * unit;\n out[3] = value.min.a + (value.max.a - value.min.a) * unit;\n return out;\n case \"gradient\":\n return evaluateGradient(value.stops, t, out);\n default:\n return assertNever(value, \"colour value\");\n }\n}\n\n/**\n * Copies a colour into four floats.\n *\n * @param color - The colour.\n * @param out - Receives it.\n * @returns `out`.\n */\nfunction writeColor(color: ColorLike, out: Float32Array): Float32Array {\n out[0] = color.r;\n out[1] = color.g;\n out[2] = color.b;\n out[3] = color.a;\n return out;\n}\n\n/**\n * Decodes an sRGB channel to linear — the exact formula the generated WGSL uses, so the CPU\n * evaluator and the shader agree (`Color.srgbToLinear` in core is the same function; it is\n * restated here so the two hosts can be read side by side).\n *\n * @param value - The sRGB channel in `0`–`1`.\n * @returns The linear channel.\n *\n * @public\n */\nexport function srgbToLinear(value: number): number {\n return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n}\n","import { ParticlesErrorCode, particlesError } from \"../errors.js\";\nimport {\n LOOKUP_SAMPLES,\n PARTICLE_BLEND_MODES,\n PARTICLE_EMIT_FROM,\n PARTICLE_MESHES,\n PARTICLE_RENDER_MODES,\n PARTICLE_SHAPE_KINDS,\n PARTICLE_SIMULATION_SPACES,\n PARTICLES_FORMAT,\n PARTICLES_FORMAT_VERSION,\n} from \"./types.js\";\nimport { bakeCurve, bakeGradient, rowMax, rowMin, scalarMin } from \"./values.js\";\nimport type {\n ColorValue,\n GradientStop,\n LookupRow,\n ParticleBurst,\n ParticleDefinition,\n ParticleDefinitionInput,\n ParticleEmission,\n ParticleForces,\n ParticleLookup,\n ParticleMain,\n ParticleNoise,\n ParticleOrbit,\n ParticleOverLifetime,\n ParticleRenderer,\n ParticleShape,\n ParticleSheet,\n ParticleStart,\n ScalarValue,\n} from \"./types.js\";\nimport type { ColorLike, CurveKey, CurveValue, IgnifxError, Vec2Like, Vec3Like } from \"@ignifx/core\";\n\n// The one place a `.particles.json` is validated, defaulted and baked\n// (`docs/plan/2026-09-terrain-particles-shaders.md` §4.2). The checks are hand-written so a failure\n// names the exact path it broke; `src/file-schemas.ts` is the declarative copy, for documentation.\n\n/** The largest capacity one definition may ask for; the budget in `app.particles` is what really limits it. */\nconst MAX_CAPACITY = 1_000_000;\n\n/** The largest seed a `u32` holds. */\nconst MAX_SEED = 0xff_ff_ff_ff;\n\n/** How many numbers one `\"mesh\"` triangle takes. */\nconst TRIANGLE_NUMBERS = 9;\n\n/** Bytes per lookup texel. */\nconst TEXEL_BYTES = 4;\n\n/** The keys a document may carry at the top level. */\nconst TOP_LEVEL_KEYS: readonly string[] = Object.freeze([\n \"format\",\n \"formatVersion\",\n \"main\",\n \"emission\",\n \"shape\",\n \"start\",\n \"forces\",\n \"overLifetime\",\n \"renderer\",\n]);\n\n/** The keys of the linear ramp a sheet's `frameOverTime` defaults to. */\nconst LINEAR_RAMP_KEYS: readonly CurveKey[] = Object.freeze([\n Object.freeze([0, 0, 1, 1] as const),\n Object.freeze([1, 1, 1, 1] as const),\n]);\n\n/** The linear ramp a sheet's `frameOverTime` defaults to. */\nconst LINEAR_RAMP: CurveValue = Object.freeze({ keys: LINEAR_RAMP_KEYS });\n\n/** Opaque white, the start colour a document that names none gets. */\nconst WHITE: ColorLike = Object.freeze({ r: 1, g: 1, b: 1, a: 1 });\n\n/** What a number reader enforces. */\ninterface NumberRule {\n /** The smallest accepted value, inclusive. */\n readonly min?: number;\n /** The largest accepted value, inclusive. */\n readonly max?: number;\n /** Whether only integers are accepted. */\n readonly integer?: boolean;\n}\n\n/**\n * Fills in the defaults of a particle document, checks every rule the evaluators rely on, and bakes\n * its curves and gradients into the lookup rows both hosts sample.\n *\n * @param input - The document, as authored.\n * @param address - What to name in an error; defaults to `\"<inline>\"`.\n * @returns The complete, frozen definition.\n * @throws IgnifxError with code `IGX-1701`, naming the offending path, when the document is not\n * readable.\n *\n * @example\n * ```ts\n * const sparks = defineParticles({\n * main: { capacity: 200, duration: 1, looping: false },\n * emission: { rateOverTime: 0, bursts: [{ time: 0, count: 120 }] },\n * start: { lifetime: { min: 0.4, max: 1 }, speed: { min: 3, max: 6 }, size: 0.04 },\n * forces: { gravityMultiplier: 1, drag: 0.5 },\n * renderer: { mode: \"stretched\", blend: \"additive\" },\n * });\n * ```\n *\n * @public\n */\nexport function defineParticles(input: ParticleDefinitionInput, address: string = \"<inline>\"): ParticleDefinition {\n const root = readObject(input, address, \"document\");\n assertKeys(root, TOP_LEVEL_KEYS, address, \"\");\n if (root[\"format\"] !== undefined && root[\"format\"] !== PARTICLES_FORMAT) {\n throw invalid(address, `format is ${show(root[\"format\"])}, not ${PARTICLES_FORMAT}`);\n }\n const version = root[\"formatVersion\"] ?? PARTICLES_FORMAT_VERSION;\n if (version !== PARTICLES_FORMAT_VERSION) {\n throw invalid(\n address,\n `formatVersion is ${show(version)}, and this build reads ${String(PARTICLES_FORMAT_VERSION)}`,\n );\n }\n const main = readMain(root[\"main\"], address);\n const emission = readEmission(root[\"emission\"], address);\n const shape = readShape(root[\"shape\"], address);\n const start = readStart(root[\"start\"], address);\n const forces = readForces(root[\"forces\"], address);\n const overLifetime = readOverLifetime(root[\"overLifetime\"], address);\n const renderer = readRenderer(root[\"renderer\"], address);\n const lookup = bakeLookup(overLifetime, forces, renderer);\n return Object.freeze({\n format: PARTICLES_FORMAT,\n formatVersion: PARTICLES_FORMAT_VERSION,\n main,\n emission,\n shape,\n start,\n forces,\n overLifetime,\n renderer,\n lookup,\n });\n}\n\n/**\n * Builds the failure an invalid document produces.\n *\n * @param address - What to name in the message.\n * @param reason - The specific problem, as a sentence fragment.\n * @returns The error to throw.\n */\nfunction invalid(address: string, reason: string): IgnifxError {\n return particlesError(\n ParticlesErrorCode.invalidParticlesFile,\n `${address} is not a valid ignifx.particles document: ${reason}.`,\n {\n context: { file: address, reason },\n hint: \"See skills/ignifx/references/formats/ignifx.particles.md for the document shape.\",\n },\n );\n}\n\n/**\n * Renders a rejected value for an error message, without an object stringifying to `[object Object]`.\n *\n * @param value - The raw value.\n * @returns A short description.\n */\nfunction show(value: unknown): string {\n return typeof value === \"string\" ? value : JSON.stringify(value);\n}\n\n/**\n * Whether a value is a plain object.\n *\n * @param value - The value read out of the document.\n * @returns `true` when the value can be read as a record.\n */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Narrows a raw value to an object.\n *\n * @param value - The raw value.\n * @param address - The document address, for the error.\n * @param path - What the value is, for the error.\n * @returns The record.\n */\nfunction readObject(value: unknown, address: string, path: string): Record<string, unknown> {\n if (!isRecord(value)) {\n throw invalid(address, `${path} must be an object`);\n }\n return value;\n}\n\n/**\n * Refuses keys a module does not declare.\n *\n * @param record - The module.\n * @param allowed - Its keys.\n * @param address - The document address, for the error.\n * @param path - The module path, for the error.\n */\nfunction assertKeys(record: Record<string, unknown>, allowed: readonly string[], address: string, path: string): void {\n for (const key of Object.keys(record)) {\n if (!allowed.includes(key)) {\n const where = path === \"\" ? key : `${path}.${key}`;\n throw invalid(address, `${where} is not a field; the fields are ${allowed.join(\", \")}`);\n }\n }\n}\n\n/**\n * Reads an optional number.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @param rule - The range and integrality to enforce.\n * @returns The number.\n */\nfunction readNumber(value: unknown, fallback: number, address: string, path: string, rule: NumberRule = {}): number {\n if (value === undefined) {\n return fallback;\n }\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw invalid(address, `${path} must be a finite number`);\n }\n checkNumber(value, address, path, rule);\n return value;\n}\n\n/**\n * Checks a number against a rule.\n *\n * @param value - The number.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @param rule - The range and integrality to enforce.\n */\nfunction checkNumber(value: number, address: string, path: string, rule: NumberRule): void {\n if (rule.integer === true && !Number.isInteger(value)) {\n throw invalid(address, `${path} must be an integer`);\n }\n if (rule.min !== undefined && value < rule.min) {\n throw invalid(address, `${path} must be at least ${String(rule.min)}, not ${String(value)}`);\n }\n if (rule.max !== undefined && value > rule.max) {\n throw invalid(address, `${path} must be at most ${String(rule.max)}, not ${String(value)}`);\n }\n}\n\n/**\n * Reads an optional boolean.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns The boolean.\n */\nfunction readBoolean(value: unknown, fallback: boolean, address: string, path: string): boolean {\n if (value === undefined) {\n return fallback;\n }\n if (typeof value !== \"boolean\") {\n throw invalid(address, `${path} must be true or false`);\n }\n return value;\n}\n\n/**\n * Reads an optional string out of a fixed set.\n *\n * @typeParam T - The literal union.\n * @param value - The raw value.\n * @param allowed - The accepted values.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns The literal.\n */\nfunction readEnum<T extends string>(\n value: unknown,\n allowed: readonly T[],\n fallback: T,\n address: string,\n path: string,\n): T {\n if (value === undefined) {\n return fallback;\n }\n for (let index = 0; index < allowed.length; index += 1) {\n const candidate = allowed[index];\n if (candidate !== undefined && candidate === value) {\n return candidate;\n }\n }\n throw invalid(address, `${path} must be one of ${allowed.join(\", \")}, not ${JSON.stringify(value)}`);\n}\n\n/**\n * Reads an optional 3D vector.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns A fresh, frozen vector.\n */\nfunction readVec3(value: unknown, fallback: Vec3Like, address: string, path: string): Vec3Like {\n if (value === undefined) {\n return Object.freeze({ x: fallback.x, y: fallback.y, z: fallback.z });\n }\n const record = readObject(value, address, path);\n assertKeys(record, [\"x\", \"y\", \"z\"], address, path);\n return Object.freeze({\n x: readNumber(record[\"x\"], 0, address, `${path}.x`),\n y: readNumber(record[\"y\"], 0, address, `${path}.y`),\n z: readNumber(record[\"z\"], 0, address, `${path}.z`),\n });\n}\n\n/**\n * Reads an optional 2D vector.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns A fresh, frozen vector.\n */\nfunction readVec2(value: unknown, fallback: Vec2Like, address: string, path: string): Vec2Like {\n if (value === undefined) {\n return Object.freeze({ x: fallback.x, y: fallback.y });\n }\n const record = readObject(value, address, path);\n assertKeys(record, [\"x\", \"y\"], address, path);\n return Object.freeze({\n x: readNumber(record[\"x\"], 0, address, `${path}.x`),\n y: readNumber(record[\"y\"], 0, address, `${path}.y`),\n });\n}\n\n/**\n * Reads a curve: `{ keys: [[t, v, in, out], …] }` with at least one key, sorted by time.\n *\n * @param value - The raw value.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns The curve, frozen.\n */\nfunction readCurve(value: unknown, address: string, path: string): CurveValue {\n const record = readObject(value, address, path);\n assertKeys(record, [\"keys\"], address, path);\n const raw = record[\"keys\"];\n if (!Array.isArray(raw) || raw.length === 0) {\n throw invalid(address, `${path}.keys must be a non-empty array of [time, value, inTangent, outTangent]`);\n }\n const keys: CurveKey[] = [];\n let previous = Number.NEGATIVE_INFINITY;\n for (let index = 0; index < raw.length; index += 1) {\n const key: unknown = raw[index];\n if (!Array.isArray(key) || key.length !== 4) {\n throw invalid(address, `${path}.keys[${String(index)}] must be [time, value, inTangent, outTangent]`);\n }\n const numbers: number[] = [];\n for (let component = 0; component < 4; component += 1) {\n const element: unknown = key[component];\n if (typeof element !== \"number\" || !Number.isFinite(element)) {\n throw invalid(address, `${path}.keys[${String(index)}] must hold finite numbers`);\n }\n numbers.push(element);\n }\n const time = numbers[0] ?? 0;\n if (time < previous) {\n throw invalid(address, `${path}.keys must be sorted by time`);\n }\n previous = time;\n keys.push(Object.freeze([time, numbers[1] ?? 0, numbers[2] ?? 0, numbers[3] ?? 0]));\n }\n return Object.freeze({ keys: Object.freeze(keys) });\n}\n\n/**\n * Reads a scalar value: a number, `{ min, max }`, or `{ curve }`.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @param rule - The range every produced value must stay inside.\n * @returns The resolved scalar.\n */\nfunction readScalar(\n value: unknown,\n fallback: number,\n address: string,\n path: string,\n rule: NumberRule = {},\n): ScalarValue {\n if (value === undefined) {\n return Object.freeze({ kind: \"constant\", value: fallback });\n }\n if (typeof value === \"number\") {\n return Object.freeze({ kind: \"constant\", value: readNumber(value, fallback, address, path, rule) });\n }\n const record = readObject(value, address, path);\n if (\"curve\" in record) {\n assertKeys(record, [\"curve\"], address, path);\n const curve = readCurve(record[\"curve\"], address, `${path}.curve`);\n const samples = bakeCurve(curve);\n checkNumber(rowMin(samples), address, `${path}.curve`, { ...rule, integer: false });\n checkNumber(rowMax(samples), address, `${path}.curve`, { ...rule, integer: false });\n return Object.freeze({ kind: \"curve\", curve, samples });\n }\n assertKeys(record, [\"min\", \"max\"], address, path);\n if (record[\"min\"] === undefined || record[\"max\"] === undefined) {\n throw invalid(address, `${path} must be a number, { min, max }, or { curve }`);\n }\n return Object.freeze({\n kind: \"random\",\n min: readNumber(record[\"min\"], 0, address, `${path}.min`, rule),\n max: readNumber(record[\"max\"], 0, address, `${path}.max`, rule),\n });\n}\n\n/**\n * Reads one colour: `[r, g, b, a]` or `{ r, g, b, a }`, sRGB.\n *\n * @param value - The raw value.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @param max - The largest accepted channel, or `undefined` for HDR-friendly no bound.\n * @returns The colour, frozen.\n */\nfunction readColor(value: unknown, address: string, path: string, max?: number): ColorLike {\n const channel = (raw: unknown, name: string, fallback: number, cap: number | undefined): number => {\n const rule: NumberRule = cap === undefined ? { min: 0 } : { min: 0, max: cap };\n return readNumber(raw, fallback, address, `${path}.${name}`, rule);\n };\n if (Array.isArray(value)) {\n if (value.length !== 4 && value.length !== 3) {\n throw invalid(address, `${path} must be [r, g, b, a]`);\n }\n return Object.freeze({\n r: channel(value[0], \"r\", 1, max),\n g: channel(value[1], \"g\", 1, max),\n b: channel(value[2], \"b\", 1, max),\n a: channel(value[3], \"a\", 1, 1),\n });\n }\n const record = readObject(value, address, path);\n assertKeys(record, [\"r\", \"g\", \"b\", \"a\"], address, path);\n return Object.freeze({\n r: channel(record[\"r\"], \"r\", 1, max),\n g: channel(record[\"g\"], \"g\", 1, max),\n b: channel(record[\"b\"], \"b\", 1, max),\n a: channel(record[\"a\"], \"a\", 1, 1),\n });\n}\n\n/**\n * Reads a gradient's stops.\n *\n * @param value - The raw value.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns The stops, frozen and sorted.\n */\nfunction readGradient(value: unknown, address: string, path: string): readonly GradientStop[] {\n if (!Array.isArray(value) || value.length === 0) {\n throw invalid(address, `${path} must be a non-empty array of [t, r, g, b, a] stops`);\n }\n const stops: GradientStop[] = [];\n let previous = Number.NEGATIVE_INFINITY;\n for (let index = 0; index < value.length; index += 1) {\n const stop: unknown = value[index];\n if (!Array.isArray(stop) || stop.length !== 5) {\n throw invalid(address, `${path}[${String(index)}] must be [t, r, g, b, a]`);\n }\n const numbers: number[] = [];\n for (let component = 0; component < 5; component += 1) {\n const element: unknown = stop[component];\n if (typeof element !== \"number\" || !Number.isFinite(element) || element < 0 || element > 1) {\n throw invalid(address, `${path}[${String(index)}] must hold numbers in 0..1`);\n }\n numbers.push(element);\n }\n const time = numbers[0] ?? 0;\n if (time < previous) {\n throw invalid(address, `${path} stops must be sorted by time`);\n }\n previous = time;\n stops.push(Object.freeze([time, numbers[1] ?? 0, numbers[2] ?? 0, numbers[3] ?? 0, numbers[4] ?? 1]));\n }\n return Object.freeze(stops);\n}\n\n/**\n * Reads a colour value: a colour, `{ min, max }`, or `{ gradient }`.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @param allowRandom - Whether `{ min, max }` is meaningful here.\n * @returns The resolved colour value.\n */\nfunction readColorValue(\n value: unknown,\n fallback: ColorLike,\n address: string,\n path: string,\n allowRandom: boolean,\n): ColorValue {\n if (value === undefined) {\n return Object.freeze({ kind: \"constant\", value: fallback });\n }\n if (isRecord(value) && \"gradient\" in value) {\n assertKeys(value, [\"gradient\"], address, path);\n const stops = readGradient(value[\"gradient\"], address, `${path}.gradient`);\n return Object.freeze({ kind: \"gradient\", stops, samples: bakeGradient(stops) });\n }\n if (isRecord(value) && (\"min\" in value || \"max\" in value)) {\n if (!allowRandom) {\n throw invalid(address, `${path} must be a colour or a gradient; a random colour has no meaning over a lifetime`);\n }\n assertKeys(value, [\"min\", \"max\"], address, path);\n return Object.freeze({\n kind: \"random\",\n min: readColor(value[\"min\"], address, `${path}.min`),\n max: readColor(value[\"max\"], address, `${path}.max`),\n });\n }\n return Object.freeze({ kind: \"constant\", value: readColor(value, address, path, allowRandom ? undefined : 1) });\n}\n\n/**\n * Reads the `main` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readMain(value: unknown, address: string): ParticleMain {\n const record = value === undefined ? {} : readObject(value, address, \"main\");\n assertKeys(\n record,\n [\n \"capacity\",\n \"duration\",\n \"looping\",\n \"prewarm\",\n \"startDelay\",\n \"simulationSpace\",\n \"seed\",\n \"playOnAwake\",\n \"timeScale\",\n \"renderOrder\",\n ],\n address,\n \"main\",\n );\n return Object.freeze({\n capacity: readNumber(record[\"capacity\"], 1000, address, \"main.capacity\", {\n min: 1,\n max: MAX_CAPACITY,\n integer: true,\n }),\n duration: readNumber(record[\"duration\"], 5, address, \"main.duration\", { min: 0.001 }),\n looping: readBoolean(record[\"looping\"], true, address, \"main.looping\"),\n prewarm: readBoolean(record[\"prewarm\"], false, address, \"main.prewarm\"),\n startDelay: readNumber(record[\"startDelay\"], 0, address, \"main.startDelay\", { min: 0 }),\n simulationSpace: readEnum(\n record[\"simulationSpace\"],\n PARTICLE_SIMULATION_SPACES,\n \"local\",\n address,\n \"main.simulationSpace\",\n ),\n seed: readNumber(record[\"seed\"], 0, address, \"main.seed\", { min: 0, max: MAX_SEED, integer: true }),\n playOnAwake: readBoolean(record[\"playOnAwake\"], true, address, \"main.playOnAwake\"),\n timeScale: readNumber(record[\"timeScale\"], 1, address, \"main.timeScale\", { min: 0 }),\n renderOrder: readNumber(record[\"renderOrder\"], 0, address, \"main.renderOrder\", { integer: true }),\n });\n}\n\n/**\n * Reads the `emission` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readEmission(value: unknown, address: string): ParticleEmission {\n const record = value === undefined ? {} : readObject(value, address, \"emission\");\n assertKeys(record, [\"rateOverTime\", \"rateOverDistance\", \"bursts\"], address, \"emission\");\n const rawBursts = record[\"bursts\"];\n const bursts: ParticleBurst[] = [];\n if (rawBursts !== undefined) {\n if (!Array.isArray(rawBursts)) {\n throw invalid(address, \"emission.bursts must be an array\");\n }\n for (let index = 0; index < rawBursts.length; index += 1) {\n const path = `emission.bursts[${String(index)}]`;\n const burst = readObject(rawBursts[index], address, path);\n assertKeys(burst, [\"time\", \"count\", \"cycles\", \"interval\", \"probability\"], address, path);\n bursts.push(\n Object.freeze({\n time: readNumber(burst[\"time\"], 0, address, `${path}.time`, { min: 0 }),\n count: readScalar(burst[\"count\"], 10, address, `${path}.count`, { min: 0 }),\n cycles: readNumber(burst[\"cycles\"], 1, address, `${path}.cycles`, { min: 0, integer: true }),\n interval: readNumber(burst[\"interval\"], 0.1, address, `${path}.interval`, { min: 0 }),\n probability: readNumber(burst[\"probability\"], 1, address, `${path}.probability`, { min: 0, max: 1 }),\n }),\n );\n }\n }\n return Object.freeze({\n rateOverTime: readNumber(record[\"rateOverTime\"], 10, address, \"emission.rateOverTime\", { min: 0 }),\n rateOverDistance: readNumber(record[\"rateOverDistance\"], 0, address, \"emission.rateOverDistance\", { min: 0 }),\n bursts: Object.freeze(bursts),\n });\n}\n\n/**\n * Reads the `shape` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readShape(value: unknown, address: string): ParticleShape {\n const record = value === undefined ? {} : readObject(value, address, \"shape\");\n assertKeys(\n record,\n [\n \"kind\",\n \"radius\",\n \"thickness\",\n \"arc\",\n \"angle\",\n \"length\",\n \"size\",\n \"emitFrom\",\n \"randomDirection\",\n \"spherizeDirection\",\n \"vertices\",\n ],\n address,\n \"shape\",\n );\n const kind = readEnum(record[\"kind\"], PARTICLE_SHAPE_KINDS, \"cone\", address, \"shape.kind\");\n const rawVertices = record[\"vertices\"];\n let vertices = new Float32Array(0);\n if (rawVertices !== undefined) {\n if (!Array.isArray(rawVertices) || rawVertices.length % TRIANGLE_NUMBERS !== 0) {\n throw invalid(address, \"shape.vertices must hold nine numbers per triangle\");\n }\n vertices = new Float32Array(rawVertices.length);\n for (let index = 0; index < rawVertices.length; index += 1) {\n const element: unknown = rawVertices[index];\n if (typeof element !== \"number\" || !Number.isFinite(element)) {\n throw invalid(address, `shape.vertices[${String(index)}] must be a finite number`);\n }\n vertices[index] = element;\n }\n }\n if (kind === \"mesh\" && vertices.length === 0) {\n throw invalid(address, \"a mesh shape needs shape.vertices with at least one triangle\");\n }\n return Object.freeze({\n kind,\n radius: readNumber(record[\"radius\"], 0.2, address, \"shape.radius\", { min: 0 }),\n thickness: readNumber(record[\"thickness\"], 1, address, \"shape.thickness\", { min: 0, max: 1 }),\n arc: readNumber(record[\"arc\"], 360, address, \"shape.arc\", { min: 0, max: 360 }),\n angle: readNumber(record[\"angle\"], 25, address, \"shape.angle\", { min: 0, max: 90 }),\n length: readNumber(record[\"length\"], 1, address, \"shape.length\", { min: 0 }),\n size: readVec3(record[\"size\"], { x: 1, y: 1, z: 1 }, address, \"shape.size\"),\n emitFrom: readEnum(\n record[\"emitFrom\"],\n PARTICLE_EMIT_FROM,\n kind === \"cone\" ? \"base\" : \"volume\",\n address,\n \"shape.emitFrom\",\n ),\n randomDirection: readNumber(record[\"randomDirection\"], 0, address, \"shape.randomDirection\", { min: 0, max: 1 }),\n spherizeDirection: readNumber(record[\"spherizeDirection\"], 0, address, \"shape.spherizeDirection\", {\n min: 0,\n max: 1,\n }),\n vertices,\n });\n}\n\n/**\n * Reads the `start` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readStart(value: unknown, address: string): ParticleStart {\n const record = value === undefined ? {} : readObject(value, address, \"start\");\n assertKeys(record, [\"lifetime\", \"speed\", \"size\", \"size3D\", \"rotation\", \"color\"], address, \"start\");\n const lifetime = readScalar(record[\"lifetime\"], 2, address, \"start.lifetime\", { min: 0 });\n if (scalarMin(lifetime) <= 0) {\n throw invalid(address, \"start.lifetime must stay above zero\");\n }\n const rawSize3D = record[\"size3D\"];\n return Object.freeze({\n lifetime,\n speed: readScalar(record[\"speed\"], 2, address, \"start.speed\"),\n size: readScalar(record[\"size\"], 0.2, address, \"start.size\", { min: 0 }),\n size3D:\n rawSize3D === undefined || rawSize3D === null\n ? null\n : readVec3(rawSize3D, { x: 1, y: 1, z: 1 }, address, \"start.size3D\"),\n rotation: readScalar(record[\"rotation\"], 0, address, \"start.rotation\"),\n color: readColorValue(record[\"color\"], WHITE, address, \"start.color\", true),\n });\n}\n\n/**\n * Reads the `forces` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readForces(value: unknown, address: string): ParticleForces {\n const record = value === undefined ? {} : readObject(value, address, \"forces\");\n assertKeys(record, [\"gravity\", \"gravityMultiplier\", \"drag\", \"constantForce\", \"orbit\", \"noise\"], address, \"forces\");\n const rawGravity = record[\"gravity\"];\n const rawOrbit = record[\"orbit\"];\n const rawNoise = record[\"noise\"];\n return Object.freeze({\n gravity:\n rawGravity === undefined || rawGravity === null\n ? null\n : readVec3(rawGravity, { x: 0, y: 0, z: 0 }, address, \"forces.gravity\"),\n gravityMultiplier: readNumber(record[\"gravityMultiplier\"], 0, address, \"forces.gravityMultiplier\"),\n drag: readNumber(record[\"drag\"], 0, address, \"forces.drag\", { min: 0 }),\n constantForce: readVec3(record[\"constantForce\"], { x: 0, y: 0, z: 0 }, address, \"forces.constantForce\"),\n orbit: rawOrbit === undefined || rawOrbit === null ? null : readOrbit(rawOrbit, address),\n noise: rawNoise === undefined || rawNoise === null ? null : readNoise(rawNoise, address),\n });\n}\n\n/**\n * Reads `forces.orbit`.\n *\n * @param value - The raw record.\n * @param address - The document address, for errors.\n * @returns The orbit, with its axis normalized.\n */\nfunction readOrbit(value: unknown, address: string): ParticleOrbit {\n const record = readObject(value, address, \"forces.orbit\");\n assertKeys(record, [\"axis\", \"speed\"], address, \"forces.orbit\");\n const axis = readVec3(record[\"axis\"], { x: 0, y: 1, z: 0 }, address, \"forces.orbit.axis\");\n const length = Math.hypot(axis.x, axis.y, axis.z);\n if (length === 0) {\n throw invalid(address, \"forces.orbit.axis must not be the zero vector\");\n }\n return Object.freeze({\n axis: Object.freeze({ x: axis.x / length, y: axis.y / length, z: axis.z / length }),\n speed: readNumber(record[\"speed\"], 90, address, \"forces.orbit.speed\"),\n });\n}\n\n/**\n * Reads `forces.noise`.\n *\n * @param value - The raw record.\n * @param address - The document address, for errors.\n * @returns The noise settings.\n */\nfunction readNoise(value: unknown, address: string): ParticleNoise {\n const record = readObject(value, address, \"forces.noise\");\n assertKeys(record, [\"strength\", \"frequency\", \"scroll\", \"octaves\", \"influenceOverLife\"], address, \"forces.noise\");\n const influence = readScalar(record[\"influenceOverLife\"], 1, address, \"forces.noise.influenceOverLife\", { min: 0 });\n if (influence.kind === \"random\") {\n throw invalid(address, \"forces.noise.influenceOverLife must be a number or a curve\");\n }\n return Object.freeze({\n strength: readNumber(record[\"strength\"], 0.5, address, \"forces.noise.strength\", { min: 0 }),\n frequency: readNumber(record[\"frequency\"], 1, address, \"forces.noise.frequency\", { min: 0 }),\n scroll: readVec3(record[\"scroll\"], { x: 0, y: 0, z: 0 }, address, \"forces.noise.scroll\"),\n octaves: readNumber(record[\"octaves\"], 1, address, \"forces.noise.octaves\", { min: 1, max: 2, integer: true }),\n influenceOverLife: influence,\n });\n}\n\n/**\n * Reads the `overLifetime` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readOverLifetime(value: unknown, address: string): ParticleOverLifetime {\n const record = value === undefined ? {} : readObject(value, address, \"overLifetime\");\n assertKeys(record, [\"color\", \"size\", \"sizeY\", \"sizeZ\", \"rotation\"], address, \"overLifetime\");\n // Size and colour are read at the particle's age, so a random pick there would mean nothing.\n // Angular speed is picked once at spawn, so `{ min, max }` is meaningful and allowed.\n const optionalScalar = (key: string, rule: NumberRule, allowRandom: boolean): ScalarValue | null => {\n const raw = record[key];\n if (raw === undefined || raw === null) {\n return null;\n }\n const scalar = readScalar(raw, 1, address, `overLifetime.${key}`, rule);\n if (!allowRandom && scalar.kind === \"random\") {\n throw invalid(address, `overLifetime.${key} must be a number or a curve; it is a function of the particle's age`);\n }\n return scalar;\n };\n const rawColor = record[\"color\"];\n return Object.freeze({\n color:\n rawColor === undefined || rawColor === null\n ? null\n : readColorValue(rawColor, WHITE, address, \"overLifetime.color\", false),\n size: optionalScalar(\"size\", { min: 0 }, false),\n sizeY: optionalScalar(\"sizeY\", { min: 0 }, false),\n sizeZ: optionalScalar(\"sizeZ\", { min: 0 }, false),\n rotation: optionalScalar(\"rotation\", {}, true),\n });\n}\n\n/**\n * Reads the `renderer` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readRenderer(value: unknown, address: string): ParticleRenderer {\n const record = value === undefined ? {} : readObject(value, address, \"renderer\");\n assertKeys(\n record,\n [\"mode\", \"mesh\", \"texture\", \"sheet\", \"blend\", \"lit\", \"pivot\", \"speedScale\", \"lengthScale\"],\n address,\n \"renderer\",\n );\n const rawTexture = record[\"texture\"];\n if (rawTexture !== undefined && rawTexture !== null && (typeof rawTexture !== \"string\" || rawTexture.length === 0)) {\n throw invalid(address, \"renderer.texture must be a non-empty asset address or null\");\n }\n const rawSheet = record[\"sheet\"];\n return Object.freeze({\n mode: readEnum(record[\"mode\"], PARTICLE_RENDER_MODES, \"billboard\", address, \"renderer.mode\"),\n mesh: readEnum(record[\"mesh\"], PARTICLE_MESHES, \"box\", address, \"renderer.mesh\"),\n texture: typeof rawTexture === \"string\" ? rawTexture : null,\n sheet: rawSheet === undefined || rawSheet === null ? null : readSheet(rawSheet, address),\n blend: readEnum(record[\"blend\"], PARTICLE_BLEND_MODES, \"premultiplied\", address, \"renderer.blend\"),\n lit: readBoolean(record[\"lit\"], false, address, \"renderer.lit\"),\n pivot: readVec2(record[\"pivot\"], { x: 0, y: 0 }, address, \"renderer.pivot\"),\n speedScale: readNumber(record[\"speedScale\"], 0, address, \"renderer.speedScale\", { min: 0 }),\n lengthScale: readNumber(record[\"lengthScale\"], 1, address, \"renderer.lengthScale\", { min: 0 }),\n });\n}\n\n/**\n * Reads `renderer.sheet`.\n *\n * @param value - The raw record.\n * @param address - The document address, for errors.\n * @returns The sheet.\n */\nfunction readSheet(value: unknown, address: string): ParticleSheet {\n const record = readObject(value, address, \"renderer.sheet\");\n assertKeys(record, [\"tiles\", \"frameOverTime\"], address, \"renderer.sheet\");\n const tiles = readVec2(record[\"tiles\"], { x: 1, y: 1 }, address, \"renderer.sheet.tiles\");\n checkNumber(tiles.x, address, \"renderer.sheet.tiles.x\", { min: 1, integer: true });\n checkNumber(tiles.y, address, \"renderer.sheet.tiles.y\", { min: 1, integer: true });\n const raw = record[\"frameOverTime\"];\n if (raw === \"random\") {\n return Object.freeze({ tiles, mode: \"random\", frameOverTime: linearRamp(), fps: 0 });\n }\n if (isRecord(raw) && \"fps\" in raw) {\n assertKeys(raw, [\"fps\"], address, \"renderer.sheet.frameOverTime\");\n return Object.freeze({\n tiles,\n mode: \"fps\",\n frameOverTime: linearRamp(),\n fps: readNumber(raw[\"fps\"], 12, address, \"renderer.sheet.frameOverTime.fps\", { min: 0 }),\n });\n }\n const frame =\n raw === undefined ? linearRamp() : readScalar(raw, 0, address, \"renderer.sheet.frameOverTime\", { min: 0, max: 1 });\n if (frame.kind === \"random\") {\n throw invalid(address, 'renderer.sheet.frameOverTime must be a curve, a number, \"random\", or { fps }');\n }\n return Object.freeze({ tiles, mode: \"curve\", frameOverTime: frame, fps: 0 });\n}\n\n/**\n * The default sheet ramp, as a baked scalar.\n *\n * @returns A fresh curve scalar running linearly from `0` to `1`.\n */\nfunction linearRamp(): ScalarValue {\n return Object.freeze({ kind: \"curve\", curve: LINEAR_RAMP, samples: bakeCurve(LINEAR_RAMP) });\n}\n\n/** A row waiting to be written into the lookup texture. */\ninterface PendingRow {\n /** The bytes of the row, `LOOKUP_SAMPLES * 4`. */\n readonly bytes: Uint8Array;\n /** The decode range. */\n readonly min: number;\n /** The decode range. */\n readonly max: number;\n}\n\n/**\n * Bakes the lookup texture: one row per curve or gradient the definition uses, in the fixed order\n * colour, size, rotation, noise influence, sheet frame.\n *\n * @param overLifetime - The over-lifetime module.\n * @param forces - The forces module, for the noise influence.\n * @param renderer - The renderer module, for the sheet frame.\n * @returns The lookup.\n */\nfunction bakeLookup(\n overLifetime: ParticleOverLifetime,\n forces: ParticleForces,\n renderer: ParticleRenderer,\n): ParticleLookup {\n const pending: PendingRow[] = [];\n const color = overLifetime.color === null ? null : pushRow(pending, colorRow(overLifetime.color));\n const size =\n overLifetime.size === null && overLifetime.sizeY === null && overLifetime.sizeZ === null\n ? null\n : pushRow(pending, sizeRow(overLifetime.size, overLifetime.sizeY, overLifetime.sizeZ));\n const rotation =\n overLifetime.rotation === null || overLifetime.rotation.kind !== \"curve\"\n ? null\n : pushRow(pending, scalarRow(overLifetime.rotation.samples));\n const noise =\n forces.noise === null || forces.noise.influenceOverLife.kind !== \"curve\"\n ? null\n : pushRow(pending, scalarRow(forces.noise.influenceOverLife.samples));\n const sheet = renderer.sheet;\n const frame =\n sheet === null || sheet.mode !== \"curve\"\n ? null\n : pushRow(\n pending,\n scalarRow(\n sheet.frameOverTime.kind === \"curve\" ? sheet.frameOverTime.samples : constantSamples(sheet.frameOverTime),\n ),\n );\n if (pending.length === 0) {\n const white = new Uint8Array(LOOKUP_SAMPLES * TEXEL_BYTES);\n white.fill(255);\n pending.push({ bytes: white, min: 0, max: 1 });\n }\n const pixels = new Uint8Array(pending.length * LOOKUP_SAMPLES * TEXEL_BYTES);\n for (let index = 0; index < pending.length; index += 1) {\n const row = pending[index];\n if (row !== undefined) {\n pixels.set(row.bytes, index * LOOKUP_SAMPLES * TEXEL_BYTES);\n }\n }\n return Object.freeze({ rows: pending.length, pixels, color, size, rotation, noise, frame });\n}\n\n/**\n * Appends a row and returns its descriptor.\n *\n * @param pending - The rows so far.\n * @param row - The row to add.\n * @returns The descriptor naming the row's index and decode range.\n */\nfunction pushRow(pending: PendingRow[], row: PendingRow): LookupRow {\n const index = pending.length;\n pending.push(row);\n return Object.freeze({ index, min: row.min, max: row.max });\n}\n\n/**\n * The samples a constant or curve scalar produces over `[0, 1]`.\n *\n * @param value - The scalar; a `\"random\"` value never reaches here.\n * @returns The samples.\n */\nfunction constantSamples(value: ScalarValue): Float32Array {\n const samples = new Float32Array(LOOKUP_SAMPLES);\n const constant = value.kind === \"constant\" ? value.value : value.kind === \"random\" ? value.min : 0;\n samples.fill(constant);\n return samples;\n}\n\n/**\n * Builds a colour row: sRGB bytes and straight alpha, one gradient sample per texel.\n *\n * @param value - The colour value.\n * @returns The row.\n */\nfunction colorRow(value: ColorValue): PendingRow {\n const bytes = new Uint8Array(LOOKUP_SAMPLES * TEXEL_BYTES);\n for (let index = 0; index < LOOKUP_SAMPLES; index += 1) {\n const base = index * TEXEL_BYTES;\n if (value.kind === \"gradient\") {\n bytes[base] = toByte(value.samples[base] ?? 0);\n bytes[base + 1] = toByte(value.samples[base + 1] ?? 0);\n bytes[base + 2] = toByte(value.samples[base + 2] ?? 0);\n bytes[base + 3] = toByte(value.samples[base + 3] ?? 1);\n } else {\n const color = value.kind === \"constant\" ? value.value : value.min;\n bytes[base] = toByte(color.r);\n bytes[base + 1] = toByte(color.g);\n bytes[base + 2] = toByte(color.b);\n bytes[base + 3] = toByte(color.a);\n }\n }\n return { bytes, min: 0, max: 1 };\n}\n\n/**\n * Builds the size row: X in red, Y in green, Z in blue, all quantized between the shared range.\n *\n * @param size - The X (or uniform) multiplier, or `null` for one.\n * @param sizeY - The Y multiplier, or `null` to follow X.\n * @param sizeZ - The Z multiplier, or `null` to follow X.\n * @returns The row.\n */\nfunction sizeRow(size: ScalarValue | null, sizeY: ScalarValue | null, sizeZ: ScalarValue | null): PendingRow {\n const x = size === null ? filled(1) : samplesOf(size);\n const y = sizeY === null ? x : samplesOf(sizeY);\n const z = sizeZ === null ? x : samplesOf(sizeZ);\n const min = Math.min(rowMin(x), rowMin(y), rowMin(z));\n const max = Math.max(rowMax(x), rowMax(y), rowMax(z));\n const range = decodeRange(min, max);\n const bytes = new Uint8Array(LOOKUP_SAMPLES * TEXEL_BYTES);\n for (let index = 0; index < LOOKUP_SAMPLES; index += 1) {\n const base = index * TEXEL_BYTES;\n bytes[base] = quantize(x[index] ?? 0, range.min, range.max);\n bytes[base + 1] = quantize(y[index] ?? 0, range.min, range.max);\n bytes[base + 2] = quantize(z[index] ?? 0, range.min, range.max);\n bytes[base + 3] = 255;\n }\n return { bytes, min: range.min, max: range.max };\n}\n\n/**\n * Builds a scalar row: the value quantized between its own minimum and maximum in every channel.\n *\n * @param samples - The baked samples.\n * @returns The row.\n */\nfunction scalarRow(samples: Float32Array): PendingRow {\n const range = decodeRange(rowMin(samples), rowMax(samples));\n const bytes = new Uint8Array(LOOKUP_SAMPLES * TEXEL_BYTES);\n for (let index = 0; index < LOOKUP_SAMPLES; index += 1) {\n const byte = quantize(samples[index] ?? 0, range.min, range.max);\n const base = index * TEXEL_BYTES;\n bytes[base] = byte;\n bytes[base + 1] = byte;\n bytes[base + 2] = byte;\n bytes[base + 3] = 255;\n }\n return { bytes, min: range.min, max: range.max };\n}\n\n/**\n * The samples of a constant or curve scalar.\n *\n * @param value - The scalar.\n * @returns Its samples.\n */\nfunction samplesOf(value: ScalarValue): Float32Array {\n return value.kind === \"curve\" ? value.samples : constantSamples(value);\n}\n\n/**\n * A row filled with one value.\n *\n * @param value - The value.\n * @returns The samples.\n */\nfunction filled(value: number): Float32Array {\n const samples = new Float32Array(LOOKUP_SAMPLES);\n samples.fill(value);\n return samples;\n}\n\n/**\n * A decode range that never divides by zero: a flat row decodes to its constant.\n *\n * @param min - The row's minimum.\n * @param max - The row's maximum.\n * @returns The range.\n */\nfunction decodeRange(min: number, max: number): { readonly min: number; readonly max: number } {\n return max > min ? { min, max } : { min, max: min + 1 };\n}\n\n/**\n * Quantizes a value into a byte between a range.\n *\n * @param value - The value.\n * @param min - What `0` means.\n * @param max - What `255` means.\n * @returns The byte.\n */\nfunction quantize(value: number, min: number, max: number): number {\n return toByte((value - min) / (max - min));\n}\n\n/**\n * Rounds a `0`–`1` fraction to a byte.\n *\n * @param fraction - The fraction.\n * @returns The byte, clamped.\n */\nfunction toByte(fraction: number): number {\n const scaled = Math.round(fraction * 255);\n return scaled < 0 ? 0 : scaled > 255 ? 255 : scaled;\n}\n","import { defineParticles } from \"../definition/define-particles.js\";\nimport { PARTICLE_ASSET_TYPE, PARTICLE_FILE_EXTENSIONS } from \"../definition/types.js\";\nimport { ParticleAsset } from \"./particle-asset.js\";\nimport type { ParticleDefinition, ParticleDefinitionInput } from \"../definition/types.js\";\nimport type { App, AssetHandle, AssetLoader, LoaderContext, TextureAsset } from \"@ignifx/core\";\n\n// The `particles` asset loader (`docs/architecture/05-assets-and-loading.md` §5) and the in-memory\n// factory that skips the file. The one dependency it pulls in is the renderer's texture, so that\n// texture's reference count and load progress follow the document's.\n\n/**\n * Builds the loader for `.particles.json` addresses.\n *\n * @returns The loader to register with `ctx.registerAssetLoader`.\n *\n * @example\n * ```ts\n * ctx.registerAssetLoader(createParticleLoader());\n * ```\n *\n * @public\n */\nexport function createParticleLoader(): AssetLoader<ParticleAsset> {\n return {\n type: PARTICLE_ASSET_TYPE,\n extensions: PARTICLE_FILE_EXTENSIONS,\n async load(ctx: LoaderContext): Promise<ParticleAsset> {\n const raw = await ctx.fetchJson<ParticleDefinitionInput>();\n const definition = defineParticles(raw, ctx.address);\n const texture = definition.renderer.texture;\n const handle = texture === null ? null : await ctx.loadDependency<TextureAsset>(texture);\n return new ParticleAsset(ctx.address, definition, handle, false);\n },\n unload(value: ParticleAsset): void {\n value.dispose();\n },\n };\n}\n\n/**\n * Publishes a definition built in code as a `particles` asset, so a `ParticleSystem`'s `definition`\n * field can hold it without a file. A `renderer.texture` starts loading here; the system draws the\n * procedural disc until it arrives. The handle has one holder, the caller.\n *\n * @param app - The app whose asset service publishes it.\n * @param definition - The definition, from {@link defineParticles} or a preset.\n * @param name - A human-readable name for diagnostics; defaults to `\"particles\"`.\n * @returns The handle, already loaded.\n *\n * @example\n * ```ts\n * const fire = particleAssetFromDefinition(app, particleDefinition(\"fire\"));\n * campfire.addComponent(ParticleSystem, { definition: fire });\n * ```\n *\n * @public\n */\nexport function particleAssetFromDefinition(\n app: App,\n definition: ParticleDefinition,\n name: string = \"particles\",\n): AssetHandle<ParticleAsset> {\n const address = definition.renderer.texture;\n const texture = address === null ? null : app.assets.load<TextureAsset>(address);\n return app.assets.register(new ParticleAsset(name, definition, texture, true), { type: PARTICLE_ASSET_TYPE });\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Motes in a shaft of light: tiny, slow, long-lived specks wandering on noise inside a flat box.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function dustPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 200, duration: 6, looping: true, prewarm: true },\n emission: { rateOverTime: 12 },\n shape: { kind: \"box\", size: { x: 4, y: 2, z: 4 }, randomDirection: 1 },\n start: {\n lifetime: { min: 4, max: 8 },\n speed: { min: 0.05, max: 0.15 },\n size: { min: 0.02, max: 0.05 },\n color: [0.9, 0.88, 0.8, 0.6],\n },\n forces: {\n noise: { strength: 0.2, frequency: 0.5, scroll: { x: 0.05, y: 0.02, z: 0.05 }, octaves: 2 },\n },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 0],\n [0.2, 1, 1, 1, 1],\n [0.8, 1, 1, 1, 1],\n [1, 1, 1, 1, 0],\n ],\n },\n },\n renderer: { mode: \"billboard\", blend: \"alpha\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * One blast: a single burst of fast fireballs from a small sphere that brake hard, swell, and fade.\n * Non-looping; `onStopped` fires when the last one is gone.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function explosionPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 256, duration: 1, looping: false },\n emission: { rateOverTime: 0, bursts: [{ time: 0, count: 150, cycles: 1 }] },\n shape: { kind: \"sphere\", radius: 0.15, randomDirection: 0.2 },\n start: {\n lifetime: { min: 0.6, max: 1.4 },\n speed: { min: 4, max: 9 },\n size: { min: 0.3, max: 0.7 },\n rotation: { min: -180, max: 180 },\n color: { min: [1, 0.3, 0.05, 1], max: [1, 0.7, 0.2, 1] },\n },\n forces: { gravityMultiplier: 0.3, drag: 2.5 },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 1],\n [0.5, 1, 0.8, 0.6, 0.8],\n [1, 0.3, 0.3, 0.3, 0],\n ],\n },\n size: {\n curve: {\n keys: [\n [0, 0.4, 0, 3],\n [0.3, 1, 0, 0],\n [1, 0.7, -0.5, 0],\n ],\n },\n },\n rotation: { min: -60, max: 60 },\n },\n renderer: { mode: \"billboard\", blend: \"additive\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * A campfire flame: a narrow upward cone of soft, additive, orange-to-yellow puffs that rise, shrink\n * and fade.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function firePresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 256, duration: 2, looping: true, prewarm: true },\n emission: { rateOverTime: 40 },\n shape: { kind: \"cone\", radius: 0.25, angle: 12 },\n start: {\n lifetime: { min: 0.8, max: 1.4 },\n speed: { min: 1, max: 2 },\n size: { min: 0.35, max: 0.6 },\n rotation: { min: -180, max: 180 },\n color: { min: [1, 0.35, 0.05, 1], max: [1, 0.85, 0.2, 1] },\n },\n forces: {\n gravityMultiplier: -0.25,\n drag: 1,\n noise: { strength: 0.15, frequency: 1.5, scroll: { x: 0, y: 0.6, z: 0 }, octaves: 1 },\n },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 0],\n [0.15, 1, 1, 1, 1],\n [1, 1, 0.6, 0.3, 0],\n ],\n },\n size: {\n curve: {\n keys: [\n [0, 1, 0, 0],\n [1, 0.15, -1, -1],\n ],\n },\n },\n },\n renderer: { mode: \"billboard\", blend: \"additive\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Autumn leaves over a six-metre patch: few, tumbling, orange-to-brown flakes that fall slowly and\n * wander on noise, in world space.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function leavesPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 128, duration: 6, looping: true, prewarm: true, simulationSpace: \"world\" },\n emission: { rateOverTime: 6 },\n shape: { kind: \"box\", size: { x: 6, y: 0.1, z: 6 } },\n start: {\n lifetime: { min: 4, max: 7 },\n speed: { min: -0.4, max: -0.8 },\n size: { min: 0.1, max: 0.18 },\n rotation: { min: -180, max: 180 },\n color: { min: [0.9, 0.45, 0.1, 1], max: [0.45, 0.25, 0.08, 1] },\n },\n forces: {\n gravityMultiplier: 0.05,\n drag: 0.5,\n noise: { strength: 0.6, frequency: 0.6, scroll: { x: 0.2, y: 0, z: 0.1 }, octaves: 2 },\n },\n overLifetime: {\n rotation: { min: -120, max: 120 },\n color: {\n gradient: [\n [0, 1, 1, 1, 1],\n [0.9, 1, 1, 1, 1],\n [1, 1, 1, 1, 0],\n ],\n },\n },\n renderer: { mode: \"billboard\", blend: \"alpha\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Rain over a twelve-metre patch: fast, thin, stretched drops falling straight down in world space.\n * Place the emitter entity above the ground.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function rainPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 2000, duration: 2, looping: true, prewarm: true, simulationSpace: \"world\" },\n emission: { rateOverTime: 600 },\n shape: { kind: \"box\", size: { x: 12, y: 0.1, z: 12 } },\n start: {\n lifetime: 1.2,\n speed: { min: -9, max: -11 },\n size: 0.02,\n color: [0.7, 0.8, 1, 0.5],\n },\n forces: { gravityMultiplier: 1 },\n renderer: { mode: \"stretched\", blend: \"alpha\", speedScale: 0.03, lengthScale: 1 },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * A slow grey plume: a wider cone than the fire, buoyant, drifting on noise, growing as it thins.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function smokePresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 128, duration: 4, looping: true, prewarm: true, renderOrder: 1 },\n emission: { rateOverTime: 12 },\n shape: { kind: \"cone\", radius: 0.3, angle: 20 },\n start: {\n lifetime: { min: 2, max: 3.5 },\n speed: { min: 0.6, max: 1.2 },\n size: { min: 0.5, max: 0.9 },\n rotation: { min: -180, max: 180 },\n color: { min: [0.35, 0.35, 0.38, 1], max: [0.6, 0.6, 0.62, 1] },\n },\n forces: {\n gravityMultiplier: -0.05,\n drag: 0.6,\n noise: { strength: 0.35, frequency: 0.8, scroll: { x: 0.1, y: 0.3, z: 0 }, octaves: 2 },\n },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 0],\n [0.2, 1, 1, 1, 0.5],\n [1, 1, 1, 1, 0],\n ],\n },\n size: {\n curve: {\n keys: [\n [0, 0.6, 0, 1],\n [1, 1.6, 1, 0],\n ],\n },\n },\n rotation: { min: -20, max: 20 },\n },\n renderer: { mode: \"billboard\", blend: \"premultiplied\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Snow over a ten-metre patch: slow, soft flakes that drift sideways on noise as they fall, in world\n * space. Place the emitter entity above the ground.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function snowPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 1000, duration: 6, looping: true, prewarm: true, simulationSpace: \"world\" },\n emission: { rateOverTime: 80 },\n shape: { kind: \"box\", size: { x: 10, y: 0.1, z: 10 } },\n start: {\n lifetime: { min: 5, max: 8 },\n speed: { min: -0.6, max: -1.2 },\n size: { min: 0.03, max: 0.07 },\n rotation: { min: -180, max: 180 },\n color: [1, 1, 1, 0.9],\n },\n forces: {\n noise: { strength: 0.4, frequency: 0.4, scroll: { x: 0.1, y: 0, z: 0.05 }, octaves: 1 },\n },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 0],\n [0.1, 1, 1, 1, 1],\n [0.9, 1, 1, 1, 1],\n [1, 1, 1, 1, 0],\n ],\n },\n rotation: { min: -45, max: 45 },\n },\n renderer: { mode: \"billboard\", blend: \"alpha\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Glints on a pickup: still, short-lived, spinning stars that pop in and out over a small sphere.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function sparklePresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 64, duration: 1, looping: true, prewarm: true },\n emission: { rateOverTime: 20 },\n shape: { kind: \"sphere\", radius: 0.6, thickness: 0.5 },\n start: {\n lifetime: { min: 0.3, max: 0.8 },\n speed: 0,\n size: { min: 0.05, max: 0.12 },\n rotation: { min: -180, max: 180 },\n color: { min: [1, 1, 1, 1], max: [0.6, 0.9, 1, 1] },\n },\n overLifetime: {\n size: {\n curve: {\n keys: [\n [0, 0, 0, 4],\n [0.5, 1, 0, 0],\n [1, 0, -4, 0],\n ],\n },\n },\n rotation: { min: -90, max: 90 },\n },\n renderer: { mode: \"billboard\", blend: \"additive\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Embers thrown from a fire: bright stretched streaks in bursts every half second, pulled down by\n * gravity and slowed by drag.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function sparksPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 200, duration: 2, looping: true },\n emission: {\n rateOverTime: 6,\n bursts: [{ time: 0, count: { min: 12, max: 24 }, cycles: 0, interval: 0.5, probability: 0.8 }],\n },\n shape: { kind: \"cone\", radius: 0.08, angle: 35 },\n start: {\n lifetime: { min: 0.4, max: 1.2 },\n speed: { min: 3, max: 7 },\n size: 0.035,\n color: { min: [1, 0.75, 0.3, 1], max: [1, 0.95, 0.7, 1] },\n },\n forces: { gravityMultiplier: 1, drag: 0.8 },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 1],\n [0.7, 1, 1, 1, 1],\n [1, 1, 0.4, 0.1, 0],\n ],\n },\n },\n renderer: { mode: \"stretched\", blend: \"additive\", speedScale: 0.04, lengthScale: 1.5 },\n };\n}\n","import { ParticlesErrorCode, particlesError } from \"../../errors.js\";\nimport { defineParticles } from \"../define-particles.js\";\nimport { dustPresetInput } from \"./dust.js\";\nimport { explosionPresetInput } from \"./explosion.js\";\nimport { firePresetInput } from \"./fire.js\";\nimport { leavesPresetInput } from \"./leaves.js\";\nimport { rainPresetInput } from \"./rain.js\";\nimport { smokePresetInput } from \"./smoke.js\";\nimport { snowPresetInput } from \"./snow.js\";\nimport { sparklePresetInput } from \"./sparkle.js\";\nimport { sparksPresetInput } from \"./sparks.js\";\nimport type { ParticleDefinition, ParticleDefinitionInput } from \"../types.js\";\n\n// The nine shipped presets (`docs/plan/2026-09-terrain-particles-shaders.md` §4.3): complete\n// documents a fresh project can play with no asset file at all.\n\n/**\n * Every preset name, in the order the documentation lists them.\n *\n * @public\n */\nexport const PARTICLE_PRESETS = [\n \"fire\",\n \"smoke\",\n \"sparks\",\n \"explosion\",\n \"dust\",\n \"sparkle\",\n \"rain\",\n \"snow\",\n \"leaves\",\n] as const;\n\n/**\n * The union of {@link PARTICLE_PRESETS}.\n *\n * @public\n */\nexport type ParticlePreset = (typeof PARTICLE_PRESETS)[number];\n\n/**\n * A recursively optional view of a type: what an override of a preset looks like.\n *\n * @typeParam T - The type being made optional.\n *\n * @public\n */\nexport type DeepPartial<T> = T extends readonly unknown[]\n ? T\n : T extends object\n ? { readonly [K in keyof T]?: DeepPartial<T[K]> }\n : T;\n\n/**\n * The document a preset starts from, before any override.\n *\n * @param name - The preset.\n * @returns A fresh copy of the authored document.\n * @throws IgnifxError with code `IGX-1704` for a name that is not a preset.\n *\n * @public\n */\nexport function particlePresetInput(name: ParticlePreset): ParticleDefinitionInput {\n switch (name) {\n case \"fire\":\n return firePresetInput();\n case \"smoke\":\n return smokePresetInput();\n case \"sparks\":\n return sparksPresetInput();\n case \"explosion\":\n return explosionPresetInput();\n case \"dust\":\n return dustPresetInput();\n case \"sparkle\":\n return sparklePresetInput();\n case \"rain\":\n return rainPresetInput();\n case \"snow\":\n return snowPresetInput();\n case \"leaves\":\n return leavesPresetInput();\n default:\n throw particlesError(ParticlesErrorCode.unknownPreset, `${String(name)} is not a particle preset.`, {\n context: { preset: String(name), presets: PARTICLE_PRESETS.join(\", \") },\n hint: `The presets are ${PARTICLE_PRESETS.join(\", \")}.`,\n });\n }\n}\n\n/**\n * A preset, with any part of it overridden, as a complete definition. An object override merges key\n * by key; an array or a primitive replaces the whole value.\n *\n * @param name - The preset.\n * @param overrides - What to change.\n * @returns The definition, validated and baked.\n * @throws IgnifxError with code `IGX-1704` for an unknown preset, or `IGX-1701` when the overrides\n * make the document invalid.\n *\n * @example\n * ```ts\n * const bigFire = particleDefinition(\"fire\", { start: { size: { min: 0.8, max: 1.2 } } });\n * ```\n *\n * @public\n */\nexport function particleDefinition(\n name: ParticlePreset,\n overrides?: DeepPartial<ParticleDefinitionInput>,\n): ParticleDefinition {\n const base = particlePresetInput(name);\n const merged = overrides === undefined ? base : mergeDeep(base, overrides);\n return defineParticles(merged, `preset:${name}`);\n}\n\n/**\n * Merges an override onto a document, object by object.\n *\n * @param base - The document.\n * @param overrides - The changes.\n * @returns The merged document.\n */\nfunction mergeDeep(\n base: ParticleDefinitionInput,\n overrides: DeepPartial<ParticleDefinitionInput>,\n): ParticleDefinitionInput {\n // Boundary assertion (coding standards §5.2): the merge walks plain JSON, and `defineParticles`\n // validates every field of the result before anything reads it.\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion -- see above.\n return mergeRecords(base, overrides) as ParticleDefinitionInput;\n}\n\n/**\n * Merges two plain records recursively: objects merge, everything else is replaced. Only own keys\n * are read, and each result is defined rather than assigned, so an override key such as\n * `__proto__` (an own key in parsed JSON) stays a field that `defineParticles` then refuses,\n * instead of merging with `Object.prototype` and replacing the result's prototype.\n *\n * @param base - The record being overridden.\n * @param overrides - The overrides.\n * @returns A new record.\n */\nfunction mergeRecords(base: object, overrides: object): Record<string, unknown> {\n const out: Record<string, unknown> = { ...base };\n const source: Record<string, unknown> = { ...overrides };\n for (const key of Object.keys(source)) {\n const value = source[key];\n if (value === undefined) {\n continue;\n }\n const existing = Object.hasOwn(out, key) ? out[key] : undefined;\n const merged = isPlainRecord(value) && isPlainRecord(existing) ? mergeRecords(existing, value) : value;\n Object.defineProperty(out, key, { value: merged, enumerable: true, writable: true, configurable: true });\n }\n return out;\n}\n\n/**\n * Whether a value is a plain object rather than an array, a primitive, or `null`.\n *\n * @param value - The value.\n * @returns `true` for a record.\n */\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","// `pcg3d` (Jarzynski & Olano, JCGT 2020), the randomness both evaluators share\n// (`docs/plan/2026-09-terrain-particles-shaders.md` §4.1). `Math.imul` and `>>> 0` keep every\n// intermediate a `u32`, so this and the WGSL copy in `src/gpu/wgsl.ts` produce identical bits.\n\n/** The LCG multiplier. */\nconst MULTIPLIER = 1664525;\n\n/** The LCG increment. */\nconst INCREMENT = 1013904223;\n\n/** `2^-32`, the factor that turns a `u32` into a unit float in `[0, 1)`. */\nconst UNIT_SCALE = 2.3283064365386963e-10;\n\n/** The second lane every per-particle hash is salted with. */\nexport const PARTICLE_SALT_Y = 0x9e3779b9;\n\n/** The third lane every per-particle hash is salted with. */\nexport const PARTICLE_SALT_Z = 0x85ebca6b;\n\n/** The salt the per-record `seed` is derived from the system seed and record index with. */\nexport const RECORD_SEED_SALT = 0x1b873593;\n\n/**\n * Hashes three 32-bit words into three others, bit-identically to the WGSL `pcg3d`.\n *\n * @param x - The first lane; any number, wrapped to `u32`.\n * @param y - The second lane.\n * @param z - The third lane.\n * @param out - Receives the three hashed words.\n * @returns `out`.\n *\n * @beta\n */\nexport function pcg3d(x: number, y: number, z: number, out: Uint32Array): Uint32Array {\n let vx = (Math.imul(x >>> 0, MULTIPLIER) + INCREMENT) >>> 0;\n let vy = (Math.imul(y >>> 0, MULTIPLIER) + INCREMENT) >>> 0;\n let vz = (Math.imul(z >>> 0, MULTIPLIER) + INCREMENT) >>> 0;\n vx = (vx + Math.imul(vy, vz)) >>> 0;\n vy = (vy + Math.imul(vz, vx)) >>> 0;\n vz = (vz + Math.imul(vx, vy)) >>> 0;\n vx = (vx ^ (vx >>> 16)) >>> 0;\n vy = (vy ^ (vy >>> 16)) >>> 0;\n vz = (vz ^ (vz >>> 16)) >>> 0;\n vx = (vx + Math.imul(vy, vz)) >>> 0;\n vy = (vy + Math.imul(vz, vx)) >>> 0;\n vz = (vz + Math.imul(vx, vy)) >>> 0;\n out[0] = vx;\n out[1] = vy;\n out[2] = vz;\n return out;\n}\n\n/**\n * Turns a hashed word into a unit float in `[0, 1)` — the same `f32(h) * 2^-32` the shader uses.\n *\n * @param word - A `u32`.\n * @returns The unit float.\n *\n * @beta\n */\nexport function hashToUnit(word: number): number {\n return (word >>> 0) * UNIT_SCALE;\n}\n\n/**\n * The three unit floats every per-particle derivation reads from a record's `seed`: the start\n * colour pick, the angular speed pick, and the sheet's random frame.\n *\n * @param seed - The record's `seed` word.\n * @param out - Receives three floats in `[0, 1)`.\n * @param scratch - Three words of scratch space.\n * @returns `out`.\n *\n * @beta\n */\nexport function particleUnits(seed: number, out: Float32Array, scratch: Uint32Array): Float32Array {\n pcg3d(seed, PARTICLE_SALT_Y, PARTICLE_SALT_Z, scratch);\n out[0] = hashToUnit(scratch[0] ?? 0);\n out[1] = hashToUnit(scratch[1] ?? 0);\n out[2] = hashToUnit(scratch[2] ?? 0);\n return out;\n}\n\n/**\n * The `seed` word a record gets from the system seed and its index.\n *\n * @param systemSeed - The system's seed.\n * @param index - The record's index since `play()`.\n * @param scratch - Three words of scratch space.\n * @returns The record seed.\n *\n * @beta\n */\nexport function recordSeed(systemSeed: number, index: number, scratch: Uint32Array): number {\n pcg3d(systemSeed, index, RECORD_SEED_SALT, scratch);\n return scratch[0] ?? 0;\n}\n\n/**\n * A deterministic stream of unit floats for the emission scheduler, drawn from `pcg3d` over a\n * counter so two systems with the same seed and the same frame deltas roll the same numbers.\n *\n * @beta\n */\nexport class EmitterRandom {\n readonly #words = new Uint32Array(3);\n\n #seed = 0;\n\n #counter = 0;\n\n #remaining = 0;\n\n /**\n * Creates a stream.\n *\n * @param seed - The seed to start from.\n */\n constructor(seed: number) {\n this.reseed(seed);\n }\n\n /**\n * The seed the stream runs on.\n *\n * @returns The seed.\n */\n get seed(): number {\n return this.#seed;\n }\n\n /**\n * Restarts the stream from a seed.\n *\n * @param seed - The new seed.\n */\n reseed(seed: number): void {\n this.#seed = seed >>> 0;\n this.#counter = 0;\n this.#remaining = 0;\n }\n\n /**\n * The next unit float in `[0, 1)`.\n *\n * @returns The number.\n */\n next(): number {\n if (this.#remaining === 0) {\n pcg3d(this.#seed, this.#counter, PARTICLE_SALT_Z, this.#words);\n this.#counter = (this.#counter + 1) >>> 0;\n this.#remaining = 3;\n }\n this.#remaining -= 1;\n return hashToUnit(this.#words[this.#remaining] ?? 0);\n }\n}\n","// The CPU mirror of the storage buffer the vertex shader indexes\n// (`docs/plan/2026-09-terrain-particles-shaders.md` §4.4). A record is 48 bytes in the byte order\n// the WGSL `Particle` struct declares, so it uploads unchanged.\n\n/**\n * Floats per record.\n *\n * @beta\n */\nexport const RECORD_FLOATS = 12;\n\n/**\n * Bytes per record, matching the WGSL `Particle` struct's size.\n *\n * @beta\n */\nexport const RECORD_BYTES: number = RECORD_FLOATS * 4;\n\n/**\n * The float index of `spawnTime` inside a record.\n *\n * @beta\n */\nexport const RECORD_SPAWN_TIME = 0;\n\n/**\n * The float index of `lifetime` inside a record.\n *\n * @beta\n */\nexport const RECORD_LIFETIME = 1;\n\n/**\n * The word index of `seed` inside a record; read it from the ring's `words`, not its floats.\n *\n * @beta\n */\nexport const RECORD_SEED = 2;\n\n/** The word index of `flags` inside a record. */\nexport const RECORD_FLAGS = 3;\n\n/**\n * The float index of `position.x` inside a record.\n *\n * @beta\n */\nexport const RECORD_POSITION = 4;\n\n/**\n * The float index of `size` inside a record.\n *\n * @beta\n */\nexport const RECORD_SIZE = 7;\n\n/**\n * The float index of `velocity.x` inside a record.\n *\n * @beta\n */\nexport const RECORD_VELOCITY = 8;\n\n/**\n * The float index of `rotation` inside a record, in radians.\n *\n * @beta\n */\nexport const RECORD_ROTATION = 11;\n\n/**\n * A contiguous run of records to upload, in slots.\n *\n * @beta\n */\nexport interface UploadRange {\n /** The first slot. */\n readonly start: number;\n /** How many records. */\n readonly count: number;\n}\n\n/**\n * What one reconciliation pass found.\n *\n * @beta\n */\nexport interface RingCensus {\n /** Records whose age is inside their lifetime. Exact. */\n alive: number;\n /** Records from the newest back to the oldest still alive: what the GPU draws. */\n drawCount: number;\n}\n\n/**\n * The CPU copy of a system's spawn records. Record `n` lives in slot `n % capacity`, so the newest\n * record is the one the shader draws first and an overwritten record simply disappears.\n *\n * @beta\n */\nexport class SpawnRecordRing {\n /** How many records the ring holds. */\n readonly capacity: number;\n\n /** The records as floats, `capacity * RECORD_FLOATS` long. */\n readonly floats: Float32Array;\n\n /** The same bytes as words, for `seed` and `flags`. */\n readonly words: Uint32Array;\n\n #written = 0;\n\n #uploaded = 0;\n\n #tail = 0;\n\n readonly #rangeA: { start: number; count: number } = { start: 0, count: 0 };\n\n readonly #rangeB: { start: number; count: number } = { start: 0, count: 0 };\n\n /**\n * Allocates a ring.\n *\n * @param capacity - How many records it holds; at least one.\n */\n constructor(capacity: number) {\n this.capacity = Math.max(1, Math.trunc(capacity));\n const buffer = new ArrayBuffer(this.capacity * RECORD_BYTES);\n this.floats = new Float32Array(buffer);\n this.words = new Uint32Array(buffer);\n }\n\n /**\n * How many records have been written since the last clear.\n *\n * @returns The count; it never decreases except through {@link SpawnRecordRing.clear}.\n */\n get written(): number {\n return this.#written;\n }\n\n /**\n * The slot the next record goes into.\n *\n * @returns `written % capacity`.\n */\n get head(): number {\n return this.#written % this.capacity;\n }\n\n /**\n * The index of the oldest record still inside the draw window.\n *\n * @returns The record index, not the slot.\n */\n get tail(): number {\n return this.#tail;\n }\n\n /**\n * How many records have been written and not yet uploaded, capped at the capacity because older\n * ones were overwritten anyway.\n *\n * @returns The pending count.\n */\n get pendingCount(): number {\n return Math.min(this.#written - this.#uploaded, this.capacity);\n }\n\n /**\n * The slot of a record.\n *\n * @param index - The record index.\n * @returns The slot.\n */\n slotOf(index: number): number {\n return index % this.capacity;\n }\n\n /**\n * Writes one record and returns its slot.\n *\n * @param spawnTime - The system clock at spawn.\n * @param lifetime - Seconds the particle lives.\n * @param seed - The per-record hash seed.\n * @param flags - Reserved; write `0`.\n * @param px - Start position X.\n * @param py - Start position Y.\n * @param pz - Start position Z.\n * @param size - Start size.\n * @param vx - Start velocity X.\n * @param vy - Start velocity Y.\n * @param vz - Start velocity Z.\n * @param rotation - Start rotation, in radians.\n * @returns The slot written.\n */\n write(\n spawnTime: number,\n lifetime: number,\n seed: number,\n flags: number,\n px: number,\n py: number,\n pz: number,\n size: number,\n vx: number,\n vy: number,\n vz: number,\n rotation: number,\n ): number {\n const slot = this.#written % this.capacity;\n const base = slot * RECORD_FLOATS;\n const floats = this.floats;\n const words = this.words;\n floats[base + RECORD_SPAWN_TIME] = spawnTime;\n floats[base + RECORD_LIFETIME] = lifetime;\n words[base + RECORD_SEED] = seed >>> 0;\n words[base + RECORD_FLAGS] = flags >>> 0;\n floats[base + RECORD_POSITION] = px;\n floats[base + RECORD_POSITION + 1] = py;\n floats[base + RECORD_POSITION + 2] = pz;\n floats[base + RECORD_SIZE] = size;\n floats[base + RECORD_VELOCITY] = vx;\n floats[base + RECORD_VELOCITY + 1] = vy;\n floats[base + RECORD_VELOCITY + 2] = vz;\n floats[base + RECORD_ROTATION] = rotation;\n this.#written += 1;\n return slot;\n }\n\n /**\n * The runs of slots written since the last upload, at most two because a ring wraps at most once\n * per frame that matters — anything older than a whole ring was overwritten.\n *\n * @param out - Receives up to two ranges.\n * @returns How many of `out`'s entries are meaningful: `0`, `1`, or `2`.\n */\n pendingRanges(out: [UploadRange, UploadRange]): number {\n const pending = this.pendingCount;\n if (pending === 0) {\n return 0;\n }\n if (pending >= this.capacity) {\n this.#rangeA.start = 0;\n this.#rangeA.count = this.capacity;\n out[0] = this.#rangeA;\n return 1;\n }\n const startIndex = this.#written - pending;\n const startSlot = startIndex % this.capacity;\n const endSlot = startSlot + pending;\n if (endSlot <= this.capacity) {\n this.#rangeA.start = startSlot;\n this.#rangeA.count = pending;\n out[0] = this.#rangeA;\n return 1;\n }\n this.#rangeA.start = startSlot;\n this.#rangeA.count = this.capacity - startSlot;\n this.#rangeB.start = 0;\n this.#rangeB.count = endSlot - this.capacity;\n out[0] = this.#rangeA;\n out[1] = this.#rangeB;\n return 2;\n }\n\n /** Records that everything written so far has reached the GPU. */\n markUploaded(): void {\n this.#uploaded = this.#written;\n }\n\n /**\n * Advances the tail past leading dead records and counts the alive ones behind it. One pass over\n * the draw window, no allocation.\n *\n * @param clock - The system clock.\n * @param out - Receives the counts.\n * @returns `out`.\n */\n reconcile(clock: number, out: RingCensus): RingCensus {\n const written = this.#written;\n const capacity = this.capacity;\n const floats = this.floats;\n // The shader reads the clock as an `f32` uniform, and a spawn time is rounded to `f32` on the\n // way into the ring. Comparing in `f32` here is what stops a particle born this frame from\n // looking unborn and being left behind the tail for ever.\n const now = Math.fround(clock);\n let tail = Math.max(this.#tail, written - capacity);\n while (tail < written && isDead(floats, (tail % capacity) * RECORD_FLOATS, now)) {\n tail += 1;\n }\n this.#tail = tail;\n let alive = 0;\n for (let index = tail; index < written; index += 1) {\n if (!isDead(floats, (index % capacity) * RECORD_FLOATS, now)) {\n alive += 1;\n }\n }\n out.alive = alive;\n out.drawCount = written - tail;\n return out;\n }\n\n /** Forgets every record, so the next frame draws nothing and uploads nothing. */\n clear(): void {\n this.#written = 0;\n this.#uploaded = 0;\n this.#tail = 0;\n }\n}\n\n/**\n * Whether a record is dead at a clock: the same rule the shader applies, `age < 0 || age > lifetime`.\n *\n * @param floats - The ring's floats.\n * @param base - The record's first float index.\n * @param clock - The system clock, already rounded to `f32` by the caller.\n * @returns `true` when the shader would collapse the record.\n */\nexport function isDead(floats: Float32Array, base: number, clock: number): boolean {\n const age = clock - (floats[base + RECORD_SPAWN_TIME] ?? 0);\n return age < 0 || age > (floats[base + RECORD_LIFETIME] ?? 0);\n}\n","import { hashToUnit, pcg3d } from \"../emitter/pcg3d.js\";\n\n// The positional noise both evaluators add (`docs/plan/2026-09-terrain-particles-shaders.md` §4.1):\n// classic lattice gradient noise with a quintic fade, hashed per corner with `pcg3d`. The WGSL in\n// `src/gpu/wgsl.ts` is the same code, and negative cells hash the same on both hosts.\n\n/** The offset of the second noise channel. */\nconst OFFSET_Y: readonly number[] = Object.freeze([31.4, 47.2, 12.9]);\n\n/** The offset of the third noise channel. */\nconst OFFSET_Z: readonly number[] = Object.freeze([-17.3, 8.6, 53.1]);\n\n/**\n * The quintic fade both hosts blend with.\n *\n * @param t - The fraction inside the cell.\n * @returns The eased fraction.\n */\nfunction fade(t: number): number {\n return t * t * t * (t * (t * 6 - 15) + 10);\n}\n\n/**\n * The dot product of a corner's hashed gradient with the offset from that corner.\n *\n * @param ix - The corner's lattice X.\n * @param iy - The corner's lattice Y.\n * @param iz - The corner's lattice Z.\n * @param dx - The offset from the corner.\n * @param dy - The offset from the corner.\n * @param dz - The offset from the corner.\n * @param scratch - Three words of scratch space.\n * @returns The corner's contribution before blending.\n */\nfunction corner(ix: number, iy: number, iz: number, dx: number, dy: number, dz: number, scratch: Uint32Array): number {\n pcg3d(ix >>> 0, iy >>> 0, iz >>> 0, scratch);\n const gx = hashToUnit(scratch[0] ?? 0) * 2 - 1;\n const gy = hashToUnit(scratch[1] ?? 0) * 2 - 1;\n const gz = hashToUnit(scratch[2] ?? 0) * 2 - 1;\n return gx * dx + gy * dy + gz * dz;\n}\n\n/**\n * One scalar of lattice gradient noise at a point.\n *\n * @param x - The sample position.\n * @param y - The sample position.\n * @param z - The sample position.\n * @param scratch - Three words of scratch space.\n * @returns The noise value, in roughly `[-1, 1]`.\n *\n * @beta\n */\nexport function gradientNoise(x: number, y: number, z: number, scratch: Uint32Array): number {\n const ix = Math.floor(x);\n const iy = Math.floor(y);\n const iz = Math.floor(z);\n const fx = x - ix;\n const fy = y - iy;\n const fz = z - iz;\n const ux = fade(fx);\n const uy = fade(fy);\n const uz = fade(fz);\n const c000 = corner(ix, iy, iz, fx, fy, fz, scratch);\n const c100 = corner(ix + 1, iy, iz, fx - 1, fy, fz, scratch);\n const c010 = corner(ix, iy + 1, iz, fx, fy - 1, fz, scratch);\n const c110 = corner(ix + 1, iy + 1, iz, fx - 1, fy - 1, fz, scratch);\n const c001 = corner(ix, iy, iz + 1, fx, fy, fz - 1, scratch);\n const c101 = corner(ix + 1, iy, iz + 1, fx - 1, fy, fz - 1, scratch);\n const c011 = corner(ix, iy + 1, iz + 1, fx, fy - 1, fz - 1, scratch);\n const c111 = corner(ix + 1, iy + 1, iz + 1, fx - 1, fy - 1, fz - 1, scratch);\n const x00 = c000 + (c100 - c000) * ux;\n const x10 = c010 + (c110 - c010) * ux;\n const x01 = c001 + (c101 - c001) * ux;\n const x11 = c011 + (c111 - c011) * ux;\n const y0 = x00 + (x10 - x00) * uy;\n const y1 = x01 + (x11 - x01) * uy;\n return y0 + (y1 - y0) * uz;\n}\n\n/**\n * Three decorrelated noise channels at a point, summed over one or two octaves.\n *\n * @param x - The sample position.\n * @param y - The sample position.\n * @param z - The sample position.\n * @param octaves - `1` or `2`.\n * @param scratch - Three words of scratch space.\n * @param out - Receives the three channels.\n * @returns `out`.\n *\n * @beta\n */\nexport function noise3(\n x: number,\n y: number,\n z: number,\n octaves: number,\n scratch: Uint32Array,\n out: Float32Array,\n): Float32Array {\n let nx = gradientNoise(x, y, z, scratch);\n let ny = gradientNoise(x + (OFFSET_Y[0] ?? 0), y + (OFFSET_Y[1] ?? 0), z + (OFFSET_Y[2] ?? 0), scratch);\n let nz = gradientNoise(x + (OFFSET_Z[0] ?? 0), y + (OFFSET_Z[1] ?? 0), z + (OFFSET_Z[2] ?? 0), scratch);\n if (octaves >= 2) {\n const x2 = x * 2;\n const y2 = y * 2;\n const z2 = z * 2;\n nx += 0.5 * gradientNoise(x2, y2, z2, scratch);\n ny += 0.5 * gradientNoise(x2 + (OFFSET_Y[0] ?? 0), y2 + (OFFSET_Y[1] ?? 0), z2 + (OFFSET_Y[2] ?? 0), scratch);\n nz += 0.5 * gradientNoise(x2 + (OFFSET_Z[0] ?? 0), y2 + (OFFSET_Z[1] ?? 0), z2 + (OFFSET_Z[2] ?? 0), scratch);\n }\n out[0] = nx;\n out[1] = ny;\n out[2] = nz;\n return out;\n}\n","import { LOOKUP_SAMPLES } from \"../definition/types.js\";\nimport { srgbToLinear } from \"../definition/values.js\";\nimport { particleUnits } from \"../emitter/pcg3d.js\";\nimport {\n RECORD_FLOATS,\n RECORD_LIFETIME,\n RECORD_POSITION,\n RECORD_ROTATION,\n RECORD_SEED,\n RECORD_SIZE,\n RECORD_SPAWN_TIME,\n RECORD_VELOCITY,\n} from \"../emitter/record-ring.js\";\nimport { noise3 } from \"./noise.js\";\nimport type { LookupRow, ParticleDefinition } from \"../definition/types.js\";\n\n// The CPU evaluator: one spawn record and a clock in, the particle's whole state out\n// (`docs/plan/2026-09-terrain-particles-shaders.md` §4.1). The WGSL in `src/gpu/wgsl.ts` computes\n// exactly this from the same bytes; `test/gpu/conformance.browser.test.ts` holds the two together.\n\n/** Degrees to radians. */\nconst DEG_TO_RAD = Math.PI / 180;\n\n/** Bytes per lookup texel. */\nconst TEXEL_BYTES = 4;\n\n/** The reciprocal of a byte's range. */\nconst BYTE_SCALE = 1 / 255;\n\n/**\n * Everything a particle is at one instant.\n *\n * @beta\n */\nexport interface ParticleState {\n /** The world position. */\n readonly position: Float32Array;\n /** The world velocity. */\n readonly velocity: Float32Array;\n /** The size along each axis, in metres. */\n readonly size: Float32Array;\n /** Linear red, green, blue, and straight alpha. */\n readonly color: Float32Array;\n /** The rotation about the view axis (or the mesh's spin axis), in radians. */\n rotation: number;\n /** The sprite-sheet frame, or `0` without a sheet. */\n frame: number;\n /** Seconds since spawn. */\n age: number;\n /** `age / lifetime`, in `[0, 1]`. */\n life: number;\n}\n\n/**\n * Allocates an empty state.\n *\n * @returns A state with every field zeroed.\n *\n * @beta\n */\nexport function createParticleState(): ParticleState {\n return {\n position: new Float32Array(3),\n velocity: new Float32Array(3),\n size: new Float32Array(3),\n color: new Float32Array(4),\n rotation: 0,\n frame: 0,\n age: 0,\n life: 0,\n };\n}\n\n/**\n * The per-system inputs the evaluator needs beyond the definition.\n *\n * @beta\n */\nexport interface ParticleEvaluationInputs {\n /** The definition every record was written from. */\n readonly definition: ParticleDefinition;\n /** The effective gravity plus constant force, in the simulation space. */\n readonly gravity: Float32Array;\n /** The emitter's current world matrix, for a `\"local\"` definition; ignored for `\"world\"`. */\n readonly emitterWorld: Float32Array;\n /** The orbit centre in the simulation space: the origin for `\"local\"`, the emitter's position for `\"world\"`. */\n readonly orbitCenter: Float32Array;\n}\n\n/** Scratch space the evaluator reuses; created once per module use, never per call. */\ninterface EvaluatorScratch {\n readonly words: Uint32Array;\n readonly units: Float32Array;\n readonly rgba: Float32Array;\n readonly noise: Float32Array;\n}\n\n/** The scratch, allocated on first use. */\nlet scratch: EvaluatorScratch | null = null;\n\n/**\n * The shared scratch space.\n *\n * @returns The scratch arrays.\n */\nfunction scratchSpace(): EvaluatorScratch {\n scratch ??= {\n words: new Uint32Array(3),\n units: new Float32Array(3),\n rgba: new Float32Array(4),\n noise: new Float32Array(3),\n };\n return scratch;\n}\n\n/**\n * Evaluates one record at a clock.\n *\n * @param inputs - The definition and the per-system values.\n * @param floats - The ring's floats.\n * @param words - The ring's words.\n * @param slot - Which record.\n * @param clock - The system clock.\n * @param out - Receives the state.\n * @returns `true` when the particle is alive; `false` leaves `out` untouched.\n *\n * @beta\n */\nexport function evaluateParticle(\n inputs: ParticleEvaluationInputs,\n floats: Float32Array,\n words: Uint32Array,\n slot: number,\n clock: number,\n out: ParticleState,\n): boolean {\n const base = slot * RECORD_FLOATS;\n const spawn = floats[base + RECORD_SPAWN_TIME] ?? 0;\n const lifetime = floats[base + RECORD_LIFETIME] ?? 0;\n // The shader's `clock` uniform is an `f32`, and so is the record; rounding here is what keeps the\n // two evaluators agreeing about which particles exist.\n const age = Math.fround(clock) - spawn;\n if (age < 0 || age > lifetime || lifetime <= 0) {\n return false;\n }\n const definition = inputs.definition;\n const life = age / lifetime;\n const t = age;\n const s = scratchSpace();\n const position = out.position;\n const velocity = out.velocity;\n\n const gx = inputs.gravity[0] ?? 0;\n const gy = inputs.gravity[1] ?? 0;\n const gz = inputs.gravity[2] ?? 0;\n const p0x = floats[base + RECORD_POSITION] ?? 0;\n const p0y = floats[base + RECORD_POSITION + 1] ?? 0;\n const p0z = floats[base + RECORD_POSITION + 2] ?? 0;\n const v0x = floats[base + RECORD_VELOCITY] ?? 0;\n const v0y = floats[base + RECORD_VELOCITY + 1] ?? 0;\n const v0z = floats[base + RECORD_VELOCITY + 2] ?? 0;\n const k = definition.forces.drag;\n if (k > 0) {\n const inverse = 1 / k;\n const e = Math.exp(-k * t);\n const ax = v0x - gx * inverse;\n const ay = v0y - gy * inverse;\n const az = v0z - gz * inverse;\n const settle = (1 - e) * inverse;\n position[0] = p0x + ax * settle + gx * inverse * t;\n position[1] = p0y + ay * settle + gy * inverse * t;\n position[2] = p0z + az * settle + gz * inverse * t;\n velocity[0] = ax * e + gx * inverse;\n velocity[1] = ay * e + gy * inverse;\n velocity[2] = az * e + gz * inverse;\n } else {\n const half = 0.5 * t * t;\n position[0] = p0x + v0x * t + gx * half;\n position[1] = p0y + v0y * t + gy * half;\n position[2] = p0z + v0z * t + gz * half;\n velocity[0] = v0x + gx * t;\n velocity[1] = v0y + gy * t;\n velocity[2] = v0z + gz * t;\n }\n\n const orbit = definition.forces.orbit;\n if (orbit !== null) {\n const angle = orbit.speed * DEG_TO_RAD * t;\n rotateAbout(position, inputs.orbitCenter, orbit.axis.x, orbit.axis.y, orbit.axis.z, angle);\n rotateAbout(velocity, null, orbit.axis.x, orbit.axis.y, orbit.axis.z, angle);\n }\n\n const noise = definition.forces.noise;\n if (noise !== null) {\n const fallback = noise.influenceOverLife.kind === \"constant\" ? noise.influenceOverLife.value : 1;\n const amount = noise.strength * readScalarRow(definition, definition.lookup.noise, life, 0, fallback);\n if (amount !== 0) {\n const frequency = noise.frequency;\n noise3(\n position[0] * frequency + noise.scroll.x * t,\n position[1] * frequency + noise.scroll.y * t,\n position[2] * frequency + noise.scroll.z * t,\n noise.octaves,\n s.words,\n s.noise,\n );\n position[0] += amount * (s.noise[0] ?? 0);\n position[1] += amount * (s.noise[1] ?? 0);\n position[2] += amount * (s.noise[2] ?? 0);\n }\n }\n\n if (definition.main.simulationSpace === \"local\") {\n transformPoint(inputs.emitterWorld, position);\n transformDirection(inputs.emitterWorld, velocity);\n }\n\n const seed = words[base + RECORD_SEED] ?? 0;\n particleUnits(seed, s.units, s.words);\n\n // Colour: the start colour (a constant or a pick between two) times the gradient row, both sRGB,\n // decoded to linear once multiplied.\n const start = definition.start.color;\n if (start.kind === \"random\") {\n const u = s.units[0] ?? 0;\n s.rgba[0] = start.min.r + (start.max.r - start.min.r) * u;\n s.rgba[1] = start.min.g + (start.max.g - start.min.g) * u;\n s.rgba[2] = start.min.b + (start.max.b - start.min.b) * u;\n s.rgba[3] = start.min.a + (start.max.a - start.min.a) * u;\n } else {\n const value = start.kind === \"constant\" ? start.value : { r: 1, g: 1, b: 1, a: 1 };\n s.rgba[0] = value.r;\n s.rgba[1] = value.g;\n s.rgba[2] = value.b;\n s.rgba[3] = value.a;\n }\n const colorRow = definition.lookup.color;\n if (colorRow !== null) {\n const texel = sampleTexel(life);\n const pixels = definition.lookup.pixels;\n const rowBase = colorRow.index * LOOKUP_SAMPLES * TEXEL_BYTES;\n s.rgba[0] *= lerpByte(pixels, rowBase, texel, 0);\n s.rgba[1] *= lerpByte(pixels, rowBase, texel, 1);\n s.rgba[2] *= lerpByte(pixels, rowBase, texel, 2);\n s.rgba[3] *= lerpByte(pixels, rowBase, texel, 3);\n }\n out.color[0] = srgbToLinear(s.rgba[0]);\n out.color[1] = srgbToLinear(s.rgba[1]);\n out.color[2] = srgbToLinear(s.rgba[2]);\n out.color[3] = s.rgba[3];\n\n // Size: the record's size, the per-axis multipliers, and the size row per axis.\n const size0 = floats[base + RECORD_SIZE] ?? 0;\n const size3D = definition.start.size3D;\n out.size[0] = size0 * (size3D?.x ?? 1);\n out.size[1] = size0 * (size3D?.y ?? 1);\n out.size[2] = size0 * (size3D?.z ?? 1);\n const sizeRow = definition.lookup.size;\n if (sizeRow !== null) {\n out.size[0] *= readScalarRow(definition, sizeRow, life, 0, 1);\n out.size[1] *= readScalarRow(definition, sizeRow, life, 1, 1);\n out.size[2] *= readScalarRow(definition, sizeRow, life, 2, 1);\n }\n\n // Rotation: the start rotation plus the angular speed, which is a constant, a pick between two, or\n // a row sampled at this instant.\n let angular = 0;\n const rotation = definition.overLifetime.rotation;\n if (rotation !== null) {\n if (rotation.kind === \"constant\") {\n angular = rotation.value;\n } else if (rotation.kind === \"random\") {\n angular = rotation.min + (rotation.max - rotation.min) * (s.units[1] ?? 0);\n } else {\n angular = readScalarRow(definition, definition.lookup.rotation, life, 0, 0);\n }\n }\n out.rotation = (floats[base + RECORD_ROTATION] ?? 0) + angular * DEG_TO_RAD * t;\n\n // Frame: the sheet rule.\n const sheet = definition.renderer.sheet;\n if (sheet === null) {\n out.frame = 0;\n } else {\n const count = sheet.tiles.x * sheet.tiles.y;\n if (sheet.mode === \"random\") {\n out.frame = Math.min(count - 1, Math.floor((s.units[2] ?? 0) * count));\n } else if (sheet.mode === \"fps\") {\n out.frame = Math.floor((s.units[2] ?? 0) * count + sheet.fps * t) % count;\n } else {\n const fraction = readScalarRow(definition, definition.lookup.frame, life, 0, 0);\n out.frame = Math.max(0, Math.min(count - 1, Math.floor(fraction * count)));\n }\n }\n out.age = age;\n out.life = life;\n return true;\n}\n\n/**\n * Rotates a vector about an axis through a centre by an angle (Rodrigues' formula), in place.\n *\n * @param vector - The vector, or a point when `center` is given.\n * @param center - The centre of rotation, or `null` to rotate a direction.\n * @param ax - The unit axis.\n * @param ay - The unit axis.\n * @param az - The unit axis.\n * @param angle - The angle in radians.\n */\nfunction rotateAbout(\n vector: Float32Array,\n center: Float32Array | null,\n ax: number,\n ay: number,\n az: number,\n angle: number,\n): void {\n const cx = center?.[0] ?? 0;\n const cy = center?.[1] ?? 0;\n const cz = center?.[2] ?? 0;\n const ox = (vector[0] ?? 0) - cx;\n const oy = (vector[1] ?? 0) - cy;\n const oz = (vector[2] ?? 0) - cz;\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n const dot = ax * ox + ay * oy + az * oz;\n const crossX = ay * oz - az * oy;\n const crossY = az * ox - ax * oz;\n const crossZ = ax * oy - ay * ox;\n const k = 1 - cos;\n vector[0] = cx + ox * cos + crossX * sin + ax * dot * k;\n vector[1] = cy + oy * cos + crossY * sin + ay * dot * k;\n vector[2] = cz + oz * cos + crossZ * sin + az * dot * k;\n}\n\n/**\n * Transforms a point by a column-major matrix, in place.\n *\n * @param m - Sixteen floats.\n * @param p - The point.\n */\nexport function transformPoint(m: Float32Array, p: Float32Array): void {\n const x = p[0] ?? 0;\n const y = p[1] ?? 0;\n const z = p[2] ?? 0;\n p[0] = (m[0] ?? 1) * x + (m[4] ?? 0) * y + (m[8] ?? 0) * z + (m[12] ?? 0);\n p[1] = (m[1] ?? 0) * x + (m[5] ?? 1) * y + (m[9] ?? 0) * z + (m[13] ?? 0);\n p[2] = (m[2] ?? 0) * x + (m[6] ?? 0) * y + (m[10] ?? 1) * z + (m[14] ?? 0);\n}\n\n/**\n * Transforms a direction by the upper-left 3x3 of a column-major matrix, in place.\n *\n * @param m - Sixteen floats.\n * @param d - The direction.\n */\nexport function transformDirection(m: Float32Array, d: Float32Array): void {\n const x = d[0] ?? 0;\n const y = d[1] ?? 0;\n const z = d[2] ?? 0;\n d[0] = (m[0] ?? 1) * x + (m[4] ?? 0) * y + (m[8] ?? 0) * z;\n d[1] = (m[1] ?? 0) * x + (m[5] ?? 1) * y + (m[9] ?? 0) * z;\n d[2] = (m[2] ?? 0) * x + (m[6] ?? 0) * y + (m[10] ?? 1) * z;\n}\n\n/** The two texels and the weight a lookup sample blends, reused across calls. */\nconst texelScratch = { index: 0, next: 0, weight: 0 };\n\n/**\n * Where along a row a normalized time lands: the same `x = t * 63` rule the shader's texture\n * coordinate `(t * 63 + 0.5) / 64` produces under linear filtering with clamp addressing.\n *\n * @param life - The normalized time.\n * @returns The scratch descriptor.\n */\nfunction sampleTexel(life: number): typeof texelScratch {\n const clamped = life <= 0 ? 0 : life >= 1 ? 1 : life;\n const x = clamped * (LOOKUP_SAMPLES - 1);\n const index = Math.floor(x);\n texelScratch.index = index;\n texelScratch.next = index + 1 >= LOOKUP_SAMPLES ? index : index + 1;\n texelScratch.weight = x - index;\n return texelScratch;\n}\n\n/**\n * Linearly interpolates one channel between two texels of a row, as a `0`–`1` fraction.\n *\n * @param pixels - The lookup bytes.\n * @param rowBase - The row's first byte.\n * @param texel - The sample descriptor.\n * @param channel - `0`–`3`.\n * @returns The blended channel.\n */\nfunction lerpByte(pixels: Uint8Array, rowBase: number, texel: typeof texelScratch, channel: number): number {\n const a = (pixels[rowBase + texel.index * TEXEL_BYTES + channel] ?? 0) * BYTE_SCALE;\n const b = (pixels[rowBase + texel.next * TEXEL_BYTES + channel] ?? 0) * BYTE_SCALE;\n return a + (b - a) * texel.weight;\n}\n\n/**\n * Reads a scalar row's decoded value at a normalized time.\n *\n * @param definition - The definition.\n * @param row - The row, or `null` to return `fallback`.\n * @param life - The normalized time.\n * @param channel - Which channel holds the value.\n * @param fallback - What to return when the row is absent.\n * @returns The decoded value.\n *\n * @beta\n */\nexport function readScalarRow(\n definition: ParticleDefinition,\n row: LookupRow | null,\n life: number,\n channel: number,\n fallback: number,\n): number {\n if (row === null) {\n return fallback;\n }\n const texel = sampleTexel(life);\n const fraction = lerpByte(definition.lookup.pixels, row.index * LOOKUP_SAMPLES * TEXEL_BYTES, texel, channel);\n return row.min + fraction * (row.max - row.min);\n}\n","import type { EmitterRandom } from \"./pcg3d.js\";\nimport type { ParticleShape } from \"../definition/types.js\";\n\n// The emitter shapes (`docs/plan/2026-09-terrain-particles-shaders.md` §4.2), in the emitter's\n// local space with `+Y` as the directional axis. Each draws its random numbers in a fixed order, so\n// two systems with one seed spawn identical particles.\n\n/** Degrees to radians. */\nconst DEG_TO_RAD = Math.PI / 180;\n\n/** Two pi. */\nconst TAU = Math.PI * 2;\n\n/** The smallest length a direction is normalized from. */\nconst EPSILON = 1e-8;\n\n/**\n * Precomputed data a `\"mesh\"` shape samples from: the cumulative area of its triangles.\n *\n * @beta\n */\nexport class MeshShapeTable {\n /** Cumulative areas, one per triangle, ending at the total. */\n readonly cumulative: Float32Array;\n\n /** The triangle soup, nine floats per triangle. */\n readonly vertices: Float32Array;\n\n /**\n * Builds the table.\n *\n * @param vertices - Nine floats per triangle.\n */\n constructor(vertices: Float32Array) {\n this.vertices = vertices;\n const count = Math.floor(vertices.length / 9);\n this.cumulative = new Float32Array(count);\n let total = 0;\n for (let index = 0; index < count; index += 1) {\n const base = index * 9;\n const ax = vertices[base] ?? 0;\n const ay = vertices[base + 1] ?? 0;\n const az = vertices[base + 2] ?? 0;\n const ux = (vertices[base + 3] ?? 0) - ax;\n const uy = (vertices[base + 4] ?? 0) - ay;\n const uz = (vertices[base + 5] ?? 0) - az;\n const vx = (vertices[base + 6] ?? 0) - ax;\n const vy = (vertices[base + 7] ?? 0) - ay;\n const vz = (vertices[base + 8] ?? 0) - az;\n const cx = uy * vz - uz * vy;\n const cy = uz * vx - ux * vz;\n const cz = ux * vy - uy * vx;\n total += 0.5 * Math.hypot(cx, cy, cz);\n this.cumulative[index] = total;\n }\n }\n\n /**\n * The total surface area.\n *\n * @returns The area.\n */\n get area(): number {\n return this.cumulative[this.cumulative.length - 1] ?? 0;\n }\n}\n\n/**\n * Samples a start position and direction from a shape.\n *\n * @param shape - The shape module.\n * @param rng - The emitter's random stream.\n * @param mesh - The triangle table, for a `\"mesh\"` shape; ignored otherwise.\n * @param position - Receives the local position.\n * @param direction - Receives the unit direction.\n *\n * @beta\n */\nexport function sampleShape(\n shape: ParticleShape,\n rng: EmitterRandom,\n mesh: MeshShapeTable | null,\n position: Float32Array,\n direction: Float32Array,\n): void {\n switch (shape.kind) {\n case \"point\":\n position[0] = 0;\n position[1] = 0;\n position[2] = 0;\n direction[0] = 0;\n direction[1] = 1;\n direction[2] = 0;\n break;\n case \"sphere\":\n sampleSphere(shape, rng, false, position, direction);\n break;\n case \"hemisphere\":\n sampleSphere(shape, rng, true, position, direction);\n break;\n case \"cone\":\n sampleCone(shape, rng, position, direction);\n break;\n case \"box\":\n sampleBox(shape, rng, position, direction);\n break;\n case \"circle\":\n sampleCircle(shape, rng, position, direction);\n break;\n case \"edge\":\n position[0] = (rng.next() - 0.5) * shape.length;\n position[1] = 0;\n position[2] = 0;\n direction[0] = 0;\n direction[1] = 1;\n direction[2] = 0;\n break;\n case \"mesh\":\n sampleMesh(mesh, rng, position, direction);\n break;\n }\n finishDirection(shape, rng, position, direction);\n}\n\n/**\n * Applies `randomDirection` and `spherizeDirection`, then normalizes.\n *\n * @param shape - The shape module.\n * @param rng - The random stream.\n * @param position - The sampled position.\n * @param direction - The direction to adjust in place.\n */\nfunction finishDirection(\n shape: ParticleShape,\n rng: EmitterRandom,\n position: Float32Array,\n direction: Float32Array,\n): void {\n const random = shape.randomDirection;\n if (random > 0) {\n const z = 1 - 2 * rng.next();\n const theta = TAU * rng.next();\n const r = Math.sqrt(Math.max(0, 1 - z * z));\n const rx = r * Math.cos(theta);\n const ry = r * Math.sin(theta);\n direction[0] = (direction[0] ?? 0) * (1 - random) + rx * random;\n direction[1] = (direction[1] ?? 0) * (1 - random) + ry * random;\n direction[2] = (direction[2] ?? 0) * (1 - random) + z * random;\n }\n const spherize = shape.spherizeDirection;\n if (spherize > 0) {\n const px = position[0] ?? 0;\n const py = position[1] ?? 0;\n const pz = position[2] ?? 0;\n const length = Math.hypot(px, py, pz);\n if (length > EPSILON) {\n direction[0] = (direction[0] ?? 0) * (1 - spherize) + (px / length) * spherize;\n direction[1] = (direction[1] ?? 0) * (1 - spherize) + (py / length) * spherize;\n direction[2] = (direction[2] ?? 0) * (1 - spherize) + (pz / length) * spherize;\n }\n }\n normalize(direction);\n}\n\n/**\n * Normalizes a direction in place, falling back to `+Y` for a zero vector.\n *\n * @param direction - The vector.\n */\nfunction normalize(direction: Float32Array): void {\n const x = direction[0] ?? 0;\n const y = direction[1] ?? 0;\n const z = direction[2] ?? 0;\n const length = Math.hypot(x, y, z);\n if (length <= EPSILON) {\n direction[0] = 0;\n direction[1] = 1;\n direction[2] = 0;\n return;\n }\n direction[0] = x / length;\n direction[1] = y / length;\n direction[2] = z / length;\n}\n\n/**\n * Samples a sphere or hemisphere: a direction inside the arc, then a radius by thickness.\n *\n * @param shape - The shape.\n * @param rng - The random stream.\n * @param upperHalf - Whether to mirror into `y >= 0`.\n * @param position - Receives the position.\n * @param direction - Receives the radial direction.\n */\nfunction sampleSphere(\n shape: ParticleShape,\n rng: EmitterRandom,\n upperHalf: boolean,\n position: Float32Array,\n direction: Float32Array,\n): void {\n const z = 1 - 2 * rng.next();\n const theta = shape.arc * DEG_TO_RAD * rng.next();\n const ring = Math.sqrt(Math.max(0, 1 - z * z));\n let dx = ring * Math.cos(theta);\n let dy = z;\n const dz = ring * Math.sin(theta);\n if (upperHalf && dy < 0) {\n dy = -dy;\n }\n const radius = shape.radius * radialFraction(shape, rng, 3);\n direction[0] = dx;\n direction[1] = dy;\n direction[2] = dz;\n dx *= radius;\n dy *= radius;\n position[0] = dx;\n position[1] = dy;\n position[2] = dz * radius;\n}\n\n/**\n * How far out a volume sample sits, in `[1 - thickness, 1]`, distributed uniformly by volume or area.\n *\n * @param shape - The shape, for `thickness` and `emitFrom`.\n * @param rng - The random stream.\n * @param dimensions - `3` for a ball, `2` for a disc.\n * @returns The fraction of the radius.\n */\nfunction radialFraction(shape: ParticleShape, rng: EmitterRandom, dimensions: number): number {\n if (shape.emitFrom === \"shell\" || shape.thickness <= 0) {\n return 1;\n }\n const inner = 1 - shape.thickness;\n const unit = rng.next();\n const innerPow = inner ** dimensions;\n return (innerPow + (1 - innerPow) * unit) ** (1 / dimensions);\n}\n\n/**\n * Samples a cone: a point on the base disc and a direction tilted by the half-angle at the rim.\n *\n * @param shape - The shape.\n * @param rng - The random stream.\n * @param position - Receives the position.\n * @param direction - Receives the direction.\n */\nfunction sampleCone(shape: ParticleShape, rng: EmitterRandom, position: Float32Array, direction: Float32Array): void {\n const theta = shape.arc * DEG_TO_RAD * rng.next();\n const fraction = radialFraction(shape, rng, 2);\n const rho = shape.radius * fraction;\n const cosTheta = Math.cos(theta);\n const sinTheta = Math.sin(theta);\n const angle = shape.angle * DEG_TO_RAD;\n const tilt = Math.sin(angle) * fraction;\n direction[0] = tilt * cosTheta;\n direction[1] = Math.cos(angle);\n direction[2] = tilt * sinTheta;\n normalize(direction);\n const height = shape.emitFrom === \"volume\" ? shape.length * rng.next() : 0;\n position[0] = rho * cosTheta + direction[0] * height;\n position[1] = direction[1] * height;\n position[2] = rho * sinTheta + direction[2] * height;\n}\n\n/**\n * Samples a box: anywhere inside, or on one of its six faces.\n *\n * @param shape - The shape.\n * @param rng - The random stream.\n * @param position - Receives the position.\n * @param direction - Receives `+Y`.\n */\nfunction sampleBox(shape: ParticleShape, rng: EmitterRandom, position: Float32Array, direction: Float32Array): void {\n const x = rng.next() - 0.5;\n const y = rng.next() - 0.5;\n const z = rng.next() - 0.5;\n position[0] = x * shape.size.x;\n position[1] = y * shape.size.y;\n position[2] = z * shape.size.z;\n if (shape.emitFrom === \"shell\") {\n const face = Math.min(5, Math.floor(rng.next() * 6));\n const sign = face % 2 === 0 ? -0.5 : 0.5;\n if (face < 2) {\n position[0] = sign * shape.size.x;\n } else if (face < 4) {\n position[1] = sign * shape.size.y;\n } else {\n position[2] = sign * shape.size.z;\n }\n }\n direction[0] = 0;\n direction[1] = 1;\n direction[2] = 0;\n}\n\n/**\n * Samples a circle in the XZ plane, emitting outward.\n *\n * @param shape - The shape.\n * @param rng - The random stream.\n * @param position - Receives the position.\n * @param direction - Receives the radial direction.\n */\nfunction sampleCircle(shape: ParticleShape, rng: EmitterRandom, position: Float32Array, direction: Float32Array): void {\n const theta = shape.arc * DEG_TO_RAD * rng.next();\n const fraction = radialFraction(shape, rng, 2);\n const dx = Math.cos(theta);\n const dz = Math.sin(theta);\n direction[0] = dx;\n direction[1] = 0;\n direction[2] = dz;\n position[0] = dx * shape.radius * fraction;\n position[1] = 0;\n position[2] = dz * shape.radius * fraction;\n}\n\n/**\n * Samples a triangle soup by area, emitting along the face normal.\n *\n * @param mesh - The triangle table.\n * @param rng - The random stream.\n * @param position - Receives the position.\n * @param direction - Receives the face normal.\n */\nfunction sampleMesh(\n mesh: MeshShapeTable | null,\n rng: EmitterRandom,\n position: Float32Array,\n direction: Float32Array,\n): void {\n if (mesh === null || mesh.cumulative.length === 0 || mesh.area <= 0) {\n position[0] = 0;\n position[1] = 0;\n position[2] = 0;\n direction[0] = 0;\n direction[1] = 1;\n direction[2] = 0;\n return;\n }\n const target = rng.next() * mesh.area;\n const cumulative = mesh.cumulative;\n let low = 0;\n let high = cumulative.length - 1;\n while (low < high) {\n const mid = (low + high) >> 1;\n if ((cumulative[mid] ?? 0) < target) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n const base = low * 9;\n const vertices = mesh.vertices;\n const ax = vertices[base] ?? 0;\n const ay = vertices[base + 1] ?? 0;\n const az = vertices[base + 2] ?? 0;\n const bx = vertices[base + 3] ?? 0;\n const by = vertices[base + 4] ?? 0;\n const bz = vertices[base + 5] ?? 0;\n const cx = vertices[base + 6] ?? 0;\n const cy = vertices[base + 7] ?? 0;\n const cz = vertices[base + 8] ?? 0;\n const r1 = Math.sqrt(rng.next());\n const r2 = rng.next();\n const wa = 1 - r1;\n const wb = r1 * (1 - r2);\n const wc = r1 * r2;\n position[0] = ax * wa + bx * wb + cx * wc;\n position[1] = ay * wa + by * wb + cy * wc;\n position[2] = az * wa + bz * wb + cz * wc;\n const ux = bx - ax;\n const uy = by - ay;\n const uz = bz - az;\n const vx = cx - ax;\n const vy = cy - ay;\n const vz = cz - az;\n direction[0] = uy * vz - uz * vy;\n direction[1] = uz * vx - ux * vz;\n direction[2] = ux * vy - uy * vx;\n normalize(direction);\n}\n","import { resolveScalar } from \"../definition/values.js\";\nimport { transformDirection, transformPoint } from \"../evaluate/particle-math.js\";\nimport { EmitterRandom, recordSeed } from \"./pcg3d.js\";\nimport { isDead, RECORD_FLOATS, SpawnRecordRing } from \"./record-ring.js\";\nimport { MeshShapeTable, sampleShape } from \"./shapes.js\";\nimport type { RingCensus } from \"./record-ring.js\";\nimport type { ParticleDefinition } from \"../definition/types.js\";\n\n// The whole CPU side of one particle system, with no app, no component and no GPU\n// (`docs/plan/2026-09-terrain-particles-shaders.md` §4.3). `ParticleSystem` drives it from the\n// frame loop; `@ignifx/particles-2d` drives the same object and draws the records itself.\n\n/** The sub-step `simulate()` advances in, in seconds. */\nconst SIMULATE_STEP = 1 / 60;\n\n/** Degrees to radians. */\nconst DEG_TO_RAD = Math.PI / 180;\n\n/** The largest seed a `u32` holds, plus one. */\nconst SEED_RANGE = 0x1_0000_0000;\n\n/** How many cycle boundaries one frame may cross before the loop gives up. */\nconst MAX_CYCLES_PER_FRAME = 1024;\n\n/** How many times one burst may fire inside one segment before the loop gives up. */\nconst MAX_BURST_FIRINGS = 4096;\n\n/**\n * What {@link ParticleEmitterCore.stop} accepts.\n *\n * @public\n */\nexport interface ParticleStopOptions {\n /** Whether to forget the live particles too. Defaults to `false`: they finish their lives. */\n readonly clear?: boolean;\n}\n\n/**\n * How {@link ParticleEmitterCore} is built.\n *\n * @beta\n */\nexport interface ParticleEmitterCoreOptions {\n /** The definition to emit. */\n readonly definition: ParticleDefinition;\n /** The ring capacity, after the app's budget clamped it. */\n readonly capacity: number;\n /** The seed; `0` picks a random one on `play()`. */\n readonly seed: number;\n}\n\n/**\n * The CPU half of a particle system: the spawn-record ring, the system clock, the seeded random\n * stream, and the emission scheduler.\n *\n * @example\n * ```ts\n * const core = new ParticleEmitterCore({ definition, capacity: 1000, seed: 7 });\n * core.play();\n * core.advance(1 / 60);\n * core.reconcile();\n * ```\n *\n * @beta\n */\nexport class ParticleEmitterCore {\n /** The definition every record is written from. */\n readonly definition: ParticleDefinition;\n\n /** The spawn records. */\n readonly ring: SpawnRecordRing;\n\n /**\n * The emitter's world matrix, column-major; write it before {@link ParticleEmitterCore.advance}.\n * A `\"world\"` definition bakes it into every record, and `rateOverDistance` reads its translation.\n */\n readonly emitterWorld: Float32Array = identity();\n\n /** A `0`–`1` multiplier on rates and burst counts; the app's `qualityScale`. */\n qualityScale = 1;\n\n /** Called once when a non-looping system runs out of cycle and particles. */\n onStopped: (() => void) | null = null;\n\n readonly #rng: EmitterRandom;\n\n readonly #declaredSeed: number;\n\n readonly #meshTable: MeshShapeTable | null;\n\n readonly #census: RingCensus = { alive: 0, drawCount: 0 };\n\n readonly #burstFired: Int32Array;\n\n readonly #position = new Float32Array(3);\n\n readonly #direction = new Float32Array(3);\n\n readonly #lastPosition = new Float32Array(3);\n\n readonly #words = new Uint32Array(3);\n\n #seed: number;\n\n #clock = 0;\n\n #cycleStart = 0;\n\n #isPlaying = false;\n\n #isPaused = false;\n\n #isEmitting = false;\n\n #rateCarry = 0;\n\n #distanceCarry = 0;\n\n #hasLastPosition = false;\n\n #emittedTotal = 0;\n\n #droppedTotal = 0;\n\n /**\n * Creates the core.\n *\n * @param options - The definition, the clamped capacity, and the seed.\n */\n constructor(options: ParticleEmitterCoreOptions) {\n this.definition = options.definition;\n this.ring = new SpawnRecordRing(options.capacity);\n this.#declaredSeed = options.seed >>> 0;\n this.#seed = this.#declaredSeed;\n this.#rng = new EmitterRandom(this.#seed);\n this.#meshTable =\n options.definition.shape.kind === \"mesh\" ? new MeshShapeTable(options.definition.shape.vertices) : null;\n this.#burstFired = new Int32Array(options.definition.emission.bursts.length);\n }\n\n /**\n * The system clock, in seconds: what every record's age is measured against.\n *\n * @returns The clock.\n */\n get time(): number {\n return this.#clock;\n }\n\n /**\n * Whether the system is playing, paused or not.\n *\n * @returns `true` between `play()` and the stop.\n */\n get isPlaying(): boolean {\n return this.#isPlaying;\n }\n\n /**\n * Whether the clock is held.\n *\n * @returns `true` after `pause()`.\n */\n get isPaused(): boolean {\n return this.#isPaused;\n }\n\n /**\n * Whether the current cycle still emits.\n *\n * @returns `true` while emission runs.\n */\n get isEmitting(): boolean {\n return this.#isEmitting;\n }\n\n /**\n * The seed in use: the declared one, or the random one `play()` picked for a declared `0`.\n *\n * @returns The seed.\n */\n get seed(): number {\n return this.#seed;\n }\n\n /**\n * How many particles are alive, as of the last {@link ParticleEmitterCore.reconcile}.\n *\n * @returns The exact count.\n */\n get aliveCount(): number {\n return this.#census.alive;\n }\n\n /**\n * How many records the GPU draws, newest first: from the newest back to the oldest still alive.\n *\n * @returns The draw count.\n */\n get drawCount(): number {\n return this.#census.drawCount;\n }\n\n /**\n * How many particles have been emitted since the last `play()` from an empty ring.\n *\n * @returns The total.\n */\n get emittedTotal(): number {\n return this.#emittedTotal;\n }\n\n /**\n * How many spawns landed on a slot whose particle was still alive, so that older particle\n * vanished. It is what \"over budget\" looks like from inside a system: the capacity the app's\n * `maxParticles` granted is smaller than `rate × lifetime`.\n *\n * @returns The total since the last `play()` from an empty ring.\n */\n get droppedTotal(): number {\n return this.#droppedTotal;\n }\n\n /**\n * Starts, or resumes after a `stop()`, emission. On an empty ring the clock restarts at zero and\n * a `prewarm` definition fast-forwards one cycle; otherwise the clock keeps counting.\n */\n play(): void {\n if (this.#isPlaying) {\n this.#isPaused = false;\n return;\n }\n if (this.ring.written === 0) {\n this.#clock = 0;\n this.#emittedTotal = 0;\n this.#droppedTotal = 0;\n this.#seed = this.#declaredSeed === 0 ? Math.floor(Math.random() * SEED_RANGE) >>> 0 : this.#declaredSeed;\n this.#rng.reseed(this.#seed);\n }\n this.#isPlaying = true;\n this.#isPaused = false;\n this.#startCycle(this.#clock);\n this.#hasLastPosition = false;\n const main = this.definition.main;\n if (main.prewarm && main.looping) {\n this.simulate(main.duration);\n }\n }\n\n /**\n * Stops emission. Live particles keep ageing until they die unless `clear` is set.\n *\n * @param options - Whether to clear the particles too.\n */\n stop(options?: ParticleStopOptions): void {\n this.#isPlaying = false;\n this.#isPaused = false;\n this.#isEmitting = false;\n if (options?.clear === true) {\n this.ring.clear();\n this.#clock = 0;\n this.#census.alive = 0;\n this.#census.drawCount = 0;\n }\n }\n\n /** Holds the clock; emission and ageing stop until {@link ParticleEmitterCore.resume}. */\n pause(): void {\n this.#isPaused = true;\n }\n\n /** Releases a `pause()`. */\n resume(): void {\n this.#isPaused = false;\n }\n\n /**\n * Spawns particles now, at the current clock, whether or not the system is playing.\n *\n * @param count - How many; a non-integer is floored, and `qualityScale` does not apply.\n */\n emit(count: number): void {\n const whole = Math.floor(count);\n for (let index = 0; index < whole; index += 1) {\n this.#spawn(this.#clock);\n }\n }\n\n /**\n * Fast-forwards the system by `seconds` in fixed sub-steps, emitting as it goes — what `prewarm`\n * does, and what a test does to reach a known state. The definition's `timeScale` does not apply.\n *\n * @param seconds - How far to advance the system clock.\n */\n simulate(seconds: number): void {\n // The whole sub-steps are counted up front rather than subtracted one at a time, so\n // `simulate(2)` really is 120 steps of a sixtieth and matches 120 frames record for record.\n const whole = Math.floor(seconds / SIMULATE_STEP);\n for (let index = 0; index < whole; index += 1) {\n this.#advanceClock(SIMULATE_STEP);\n }\n const rest = seconds - whole * SIMULATE_STEP;\n if (rest > SIMULATE_STEP * 1e-6) {\n this.#advanceClock(rest);\n }\n }\n\n /**\n * Advances one frame. It does nothing while paused, and nothing once a stopped system's last\n * particle has died.\n *\n * @param dt - The frame's scaled seconds; the definition's own `timeScale` is applied here.\n */\n advance(dt: number): void {\n if (this.#isPaused || dt <= 0) {\n return;\n }\n if (!this.#isPlaying && this.#census.alive === 0) {\n return;\n }\n this.#advanceClock(dt * this.definition.main.timeScale);\n }\n\n /**\n * Recounts the ring at the current clock and fires `onStopped` once a non-looping system has\n * nothing left to do.\n *\n * @returns The census.\n */\n reconcile(): RingCensus {\n const census = this.ring.reconcile(this.#clock, this.#census);\n if (this.#isPlaying && !this.#isEmitting && census.alive === 0) {\n this.#isPlaying = false;\n this.#isPaused = false;\n this.onStopped?.();\n }\n return census;\n }\n\n /**\n * Begins a cycle at a clock value.\n *\n * @param at - The clock the cycle starts at.\n */\n #startCycle(at: number): void {\n this.#cycleStart = at;\n this.#isEmitting = true;\n this.#rateCarry = 0;\n this.#burstFired.fill(0);\n }\n\n /**\n * Moves the clock forward and emits everything due.\n *\n * @param dt - The seconds to advance, already scaled.\n */\n #advanceClock(dt: number): void {\n const main = this.definition.main;\n let segmentStart = this.#clock;\n const target = this.#clock + dt;\n this.#clock = target;\n // One frame may cross the end of a cycle, and each segment has to be emitted inside its own.\n let guard = 0;\n while (segmentStart < target && guard < MAX_CYCLES_PER_FRAME) {\n guard += 1;\n const cycleEnd = this.#cycleStart + main.startDelay + main.duration;\n const segmentEnd = this.#isEmitting && target > cycleEnd ? cycleEnd : target;\n if (this.#isEmitting) {\n this.#emitSegment(segmentStart, segmentEnd);\n }\n if (this.#isEmitting && segmentEnd >= cycleEnd) {\n if (main.looping) {\n this.#startCycle(cycleEnd);\n } else {\n this.#isEmitting = false;\n }\n }\n segmentStart = segmentEnd;\n if (!this.#isEmitting) {\n break;\n }\n }\n this.#emitOverDistance();\n }\n\n /**\n * Emits what the rate and the bursts owe inside one segment of one cycle.\n *\n * @param from - The segment's start clock.\n * @param to - The segment's end clock.\n */\n #emitSegment(from: number, to: number): void {\n const main = this.definition.main;\n const emission = this.definition.emission;\n const emissionStart = this.#cycleStart + main.startDelay;\n const windowStart = from > emissionStart ? from : emissionStart;\n const rate = emission.rateOverTime * this.qualityScale;\n if (to > windowStart && rate > 0) {\n // The fractional part carries to the next frame, so the count over any run of steps is\n // exactly `floor(rate × elapsed)` and each particle gets its own sub-frame spawn time.\n const owed = this.#rateCarry + rate * (to - windowStart);\n const count = Math.floor(owed);\n const period = 1 / rate;\n for (let index = 0; index < count; index += 1) {\n const spawnTime = windowStart + (index + 1 - this.#rateCarry) * period;\n this.#spawn(spawnTime > to ? to : spawnTime);\n }\n this.#rateCarry = owed - count;\n }\n const bursts = emission.bursts;\n for (let index = 0; index < bursts.length; index += 1) {\n const burst = bursts[index];\n if (burst === undefined) {\n continue;\n }\n // `cycles: 0` means \"until the cycle ends\", which only makes sense with a gap between\n // firings; with no gap it is one firing, not an infinite loop at the same instant.\n const limit = burst.cycles === 0 && burst.interval > 0 ? MAX_BURST_FIRINGS : Math.max(1, burst.cycles);\n let fired = this.#burstFired[index] ?? 0;\n while (fired < limit) {\n const due = emissionStart + burst.time + fired * burst.interval;\n if (due > to) {\n break;\n }\n fired += 1;\n if (burst.probability >= 1 || this.#rng.next() < burst.probability) {\n const rolled = resolveScalar(burst.count, this.#rng.next(), this.#cycleFraction(due)) * this.qualityScale;\n const count = Math.floor(rolled);\n for (let spawned = 0; spawned < count; spawned += 1) {\n this.#spawn(due < windowStart ? windowStart : due);\n }\n }\n }\n this.#burstFired[index] = fired;\n }\n }\n\n /** Emits what the emitter's movement since the last frame owes. */\n #emitOverDistance(): void {\n const rate = this.definition.emission.rateOverDistance * this.qualityScale;\n const world = this.emitterWorld;\n const x = world[12] ?? 0;\n const y = world[13] ?? 0;\n const z = world[14] ?? 0;\n if (rate > 0 && this.#isEmitting && this.#hasLastPosition) {\n const dx = x - (this.#lastPosition[0] ?? 0);\n const dy = y - (this.#lastPosition[1] ?? 0);\n const dz = z - (this.#lastPosition[2] ?? 0);\n const owed = this.#distanceCarry + Math.hypot(dx, dy, dz) * rate;\n const count = Math.floor(owed);\n for (let index = 0; index < count; index += 1) {\n this.#spawn(this.#clock);\n }\n this.#distanceCarry = owed - count;\n }\n this.#lastPosition[0] = x;\n this.#lastPosition[1] = y;\n this.#lastPosition[2] = z;\n this.#hasLastPosition = true;\n }\n\n /**\n * Where a clock value sits inside the current cycle, for the start curves.\n *\n * @param at - The clock value.\n * @returns The fraction in `[0, 1]`.\n */\n #cycleFraction(at: number): number {\n const main = this.definition.main;\n const fraction = (at - this.#cycleStart - main.startDelay) / main.duration;\n return fraction <= 0 ? 0 : fraction >= 1 ? 1 : fraction;\n }\n\n /**\n * Writes one record, counting the live particle it displaced if the ring had wrapped.\n *\n * @param spawnTime - The clock the particle is born at.\n */\n #spawn(spawnTime: number): void {\n const definition = this.definition;\n const rng = this.#rng;\n const position = this.#position;\n const direction = this.#direction;\n const ring = this.ring;\n if (ring.written >= ring.capacity && !isDead(ring.floats, ring.head * RECORD_FLOATS, Math.fround(spawnTime))) {\n this.#droppedTotal += 1;\n }\n sampleShape(definition.shape, rng, this.#meshTable, position, direction);\n const t = this.#cycleFraction(spawnTime);\n const start = definition.start;\n const lifetime = resolveScalar(start.lifetime, rng.next(), t);\n const speed = resolveScalar(start.speed, rng.next(), t);\n const size = resolveScalar(start.size, rng.next(), t);\n const rotation = resolveScalar(start.rotation, rng.next(), t) * DEG_TO_RAD;\n direction[0] = (direction[0] ?? 0) * speed;\n direction[1] = (direction[1] ?? 0) * speed;\n direction[2] = (direction[2] ?? 0) * speed;\n if (definition.main.simulationSpace === \"world\") {\n transformPoint(this.emitterWorld, position);\n transformDirection(this.emitterWorld, direction);\n }\n const seed = recordSeed(this.#seed, ring.written, this.#words);\n ring.write(\n spawnTime,\n lifetime,\n seed,\n 0,\n component(position, 0),\n component(position, 1),\n component(position, 2),\n size,\n component(direction, 0),\n component(direction, 1),\n component(direction, 2),\n rotation,\n );\n this.#emittedTotal += 1;\n }\n}\n\n/**\n * Reads one component of a scratch vector `sampleShape` filled in.\n *\n * @param vector - The vector.\n * @param index - Which component.\n * @returns The component, or zero when the vector is shorter than the index.\n */\nfunction component(vector: Float32Array, index: number): number {\n return vector[index] ?? 0;\n}\n\n/**\n * A fresh identity matrix.\n *\n * @returns Sixteen column-major floats.\n */\nfunction identity(): Float32Array {\n const m = new Float32Array(16);\n m[0] = 1;\n m[5] = 1;\n m[10] = 1;\n m[15] = 1;\n return m;\n}\n","import { LOOKUP_SAMPLES } from \"../definition/types.js\";\nimport { PARTICLE_SALT_Y, PARTICLE_SALT_Z } from \"../emitter/pcg3d.js\";\nimport type { LookupRow, ParticleDefinition, ScalarValue } from \"../definition/types.js\";\n\n// The GPU evaluator: one `.wgsl` program generated per definition\n// (`docs/plan/2026-09-terrain-particles-shaders.md` §4.4), the second host of the specification\n// `src/evaluate/particle-math.ts` states in TypeScript. Read the two side by side.\n\n/** Degrees to radians, as a WGSL literal. */\nconst DEG_TO_RAD_WGSL = \"0.017453292519943295\";\n\n/** The offsets the second and third noise channels sample at. */\nconst NOISE_OFFSET_Y = \"vec3<f32>(31.4, 47.2, 12.9)\";\n\n/** The offsets the second and third noise channels sample at. */\nconst NOISE_OFFSET_Z = \"vec3<f32>(-17.3, 8.6, 53.1)\";\n\n/**\n * Formats a number as a WGSL `f32` literal.\n *\n * @param value - The number.\n * @returns The literal, always with a decimal point or an exponent.\n */\nfunction f32(value: number): string {\n if (!Number.isFinite(value)) {\n return \"0.0\";\n }\n const text = String(value);\n return text.includes(\".\") || text.includes(\"e\") ? text : `${text}.0`;\n}\n\n/**\n * Formats three numbers as a `vec3<f32>` literal.\n *\n * @param x - The first component.\n * @param y - The second component.\n * @param z - The third component.\n * @returns The literal.\n */\nfunction vec3(x: number, y: number, z: number): string {\n return `vec3<f32>(${f32(x)}, ${f32(y)}, ${f32(z)})`;\n}\n\n/**\n * The WGSL of the row constants a lookup row needs.\n *\n * @param name - The constant prefix.\n * @param row - The row.\n * @returns The declarations.\n */\nfunction rowConstants(name: string, row: LookupRow): string {\n return `const ${name}_ROW: f32 = ${f32(row.index)};\\nconst ${name}_MIN: f32 = ${f32(row.min)};\\nconst ${name}_MAX: f32 = ${f32(row.max)};\\n`;\n}\n\n/**\n * The WGSL that reads a decoded scalar row into a variable.\n *\n * @param name - The constant prefix used by {@link rowConstants}.\n * @param channel - The swizzle to read.\n * @returns An expression.\n */\nfunction decodeRow(name: string, channel: string): string {\n return `(${name}_MIN + lookupRow(${name}_ROW, life).${channel} * (${name}_MAX - ${name}_MIN))`;\n}\n\n/**\n * The WGSL expression for a constant or random scalar picked by a unit float.\n *\n * @param value - The scalar; a curve is handled by the caller through its row.\n * @param unit - The unit float expression.\n * @returns An expression.\n */\nfunction pickScalar(value: ScalarValue, unit: string): string {\n if (value.kind === \"constant\") {\n return f32(value.value);\n }\n if (value.kind === \"random\") {\n return `mix(${f32(value.min)}, ${f32(value.max)}, ${unit})`;\n }\n return \"0.0\";\n}\n\n/**\n * Generates the WGSL program that draws a definition.\n *\n * @param definition - The definition.\n * @returns The whole `.wgsl` source, pragmas included, ready for the shader loader.\n *\n * @example\n * ```ts\n * const source = generateParticleWgsl(particleDefinition(\"fire\"));\n * source.includes(\"@ignifx blend premultiplied\"); // true\n * ```\n *\n * @beta\n */\nexport function generateParticleWgsl(definition: ParticleDefinition): string {\n const { forces, renderer, start, lookup } = definition;\n const isMesh = renderer.mode === \"mesh\";\n const system: string[] = [\"view\", \"viewProjection\"];\n if (renderer.mode === \"vertical\") {\n system.push(\"cameraPosition\");\n }\n if (renderer.lit) {\n system.push(\"mainLightDirection\", \"mainLightColor\", \"ambientColor\");\n }\n const attributes = isMesh ? \"position, normal, uv\" : \"position, uv\";\n const parts: string[] = [];\n // Every binding and uniform below is declared only when the program reads it: Babylon Lite\n // demands that a declared sampler or storage buffer be bound before the material can draw.\n parts.push(\n \"// Generated by @ignifx/particles from an ignifx.particles definition. Do not edit.\",\n \"// @ignifx shader\",\n `// @ignifx attributes ${attributes}`,\n `// @ignifx system ${system.join(\", \")}`,\n \"// @ignifx storage particles: array<Particle>\",\n ...(renderer.texture === null ? [] : [\"// @ignifx texture sheet srgb default white\"]),\n \"// @ignifx texture lut default white\",\n \"// @ignifx uniform clock: f32 = 0\",\n \"// @ignifx uniform head: f32 = 0\",\n \"// @ignifx uniform capacity: f32 = 1\",\n ...(definition.main.simulationSpace === \"local\" ? [\"// @ignifx uniform emitterWorld: mat4x4<f32>\"] : []),\n ...(forces.orbit === null ? [] : [\"// @ignifx uniform orbitCenter: vec3<f32> = (0, 0, 0)\"]),\n \"// @ignifx uniform gravity: vec3<f32> = (0, 0, 0)\",\n `// @ignifx blend ${renderer.blend} cull none depthWrite off instancing matrices`,\n \"\",\n \"struct Particle {\",\n \" spawnTime: f32,\",\n \" lifetime: f32,\",\n \" seed: u32,\",\n \" flags: u32,\",\n \" @align(16) position: vec3<f32>,\",\n \" size: f32,\",\n \" @align(16) velocity: vec3<f32>,\",\n \" rotation: f32,\",\n \"}\",\n \"\",\n \"struct VertexOutput {\",\n \" @builtin(position) position: vec4<f32>,\",\n \" @location(0) uv: vec2<f32>,\",\n \" @location(1) color: vec4<f32>,\",\n \"}\",\n \"\",\n `const DEG_TO_RAD: f32 = ${DEG_TO_RAD_WGSL};`,\n `const LOOKUP_ROWS: f32 = ${f32(lookup.rows)};`,\n `const LOOKUP_LAST: f32 = ${f32(LOOKUP_SAMPLES - 1)};`,\n `const LOOKUP_WIDTH: f32 = ${f32(LOOKUP_SAMPLES)};`,\n `const SALT_Y: u32 = ${String(PARTICLE_SALT_Y)}u;`,\n `const SALT_Z: u32 = ${String(PARTICLE_SALT_Z)}u;`,\n \"const UNIT_SCALE: f32 = 2.3283064365386963e-10;\",\n \"const DEAD: vec4<f32> = vec4<f32>(0.0, 0.0, 2.0, 1.0);\",\n `const DRAG: f32 = ${f32(forces.drag)};`,\n `const SIZE_SCALE: vec3<f32> = ${vec3(start.size3D?.x ?? 1, start.size3D?.y ?? 1, start.size3D?.z ?? 1)};`,\n `const PIVOT: vec2<f32> = vec2<f32>(${f32(renderer.pivot.x)}, ${f32(renderer.pivot.y)});`,\n \"\",\n );\n const startColor = start.color;\n if (startColor.kind === \"random\") {\n parts.push(\n `const START_COLOR_MIN: vec4<f32> = vec4<f32>(${f32(startColor.min.r)}, ${f32(startColor.min.g)}, ${f32(startColor.min.b)}, ${f32(startColor.min.a)});`,\n `const START_COLOR_MAX: vec4<f32> = vec4<f32>(${f32(startColor.max.r)}, ${f32(startColor.max.g)}, ${f32(startColor.max.b)}, ${f32(startColor.max.a)});`,\n );\n } else {\n const c = startColor.kind === \"constant\" ? startColor.value : { r: 1, g: 1, b: 1, a: 1 };\n parts.push(`const START_COLOR: vec4<f32> = vec4<f32>(${f32(c.r)}, ${f32(c.g)}, ${f32(c.b)}, ${f32(c.a)});`);\n }\n if (lookup.color !== null) {\n parts.push(rowConstants(\"COLOR\", lookup.color));\n }\n if (lookup.size !== null) {\n parts.push(rowConstants(\"SIZE\", lookup.size));\n }\n if (lookup.rotation !== null) {\n parts.push(rowConstants(\"ROTATION\", lookup.rotation));\n }\n if (lookup.noise !== null) {\n parts.push(rowConstants(\"NOISE\", lookup.noise));\n }\n if (lookup.frame !== null) {\n parts.push(rowConstants(\"FRAME\", lookup.frame));\n }\n const orbit = forces.orbit;\n if (orbit !== null) {\n parts.push(\n `const ORBIT_AXIS: vec3<f32> = ${vec3(orbit.axis.x, orbit.axis.y, orbit.axis.z)};`,\n `const ORBIT_SPEED: f32 = ${f32(orbit.speed)};`,\n );\n }\n const noise = forces.noise;\n if (noise !== null) {\n parts.push(\n `const NOISE_STRENGTH: f32 = ${f32(noise.strength)};`,\n `const NOISE_FREQUENCY: f32 = ${f32(noise.frequency)};`,\n `const NOISE_SCROLL: vec3<f32> = ${vec3(noise.scroll.x, noise.scroll.y, noise.scroll.z)};`,\n `const NOISE_OCTAVES: i32 = ${String(noise.octaves)};`,\n `const NOISE_INFLUENCE: f32 = ${f32(noise.influenceOverLife.kind === \"constant\" ? noise.influenceOverLife.value : 1)};`,\n );\n }\n const sheet = renderer.sheet;\n if (sheet !== null) {\n parts.push(\n `const SHEET_TILES: vec2<f32> = vec2<f32>(${f32(sheet.tiles.x)}, ${f32(sheet.tiles.y)});`,\n `const SHEET_COUNT: f32 = ${f32(sheet.tiles.x * sheet.tiles.y)};`,\n `const SHEET_FPS: f32 = ${f32(sheet.fps)};`,\n );\n }\n if (renderer.mode === \"stretched\") {\n parts.push(\n `const SPEED_SCALE: f32 = ${f32(renderer.speedScale)};`,\n `const LENGTH_SCALE: f32 = ${f32(renderer.lengthScale)};`,\n );\n }\n parts.push(\"\", HELPERS);\n if (noise !== null) {\n parts.push(NOISE_HELPERS);\n }\n parts.push(vertexStage(definition), \"\", fragmentStage(definition));\n return `${parts.join(\"\\n\")}\\n`;\n}\n\n/** The helpers every program carries: `pcg3d`, sRGB decode, Rodrigues rotation, the row sampler. */\nconst HELPERS = `fn pcg3d(v0: vec3<u32>) -> vec3<u32> {\n var v = v0 * 1664525u + 1013904223u;\n v.x += v.y * v.z;\n v.y += v.z * v.x;\n v.z += v.x * v.y;\n v ^= v >> vec3<u32>(16u);\n v.x += v.y * v.z;\n v.y += v.z * v.x;\n v.z += v.x * v.y;\n return v;\n}\n\nfn srgbToLinear(c: vec3<f32>) -> vec3<f32> {\n let low = c / 12.92;\n let high = pow((c + vec3<f32>(0.055)) / 1.055, vec3<f32>(2.4));\n return select(high, low, c <= vec3<f32>(0.04045));\n}\n\nfn rotateAbout(v: vec3<f32>, axis: vec3<f32>, angle: f32) -> vec3<f32> {\n let c = cos(angle);\n let s = sin(angle);\n return v * c + cross(axis, v) * s + axis * dot(axis, v) * (1.0 - c);\n}\n\nfn lookupRow(row: f32, life: f32) -> vec4<f32> {\n let u = (clamp(life, 0.0, 1.0) * LOOKUP_LAST + 0.5) / LOOKUP_WIDTH;\n let v = (row + 0.5) / LOOKUP_ROWS;\n return textureSampleLevel(lut, lutSampler, vec2<f32>(u, v), 0.0);\n}\n`;\n\n/** The gradient noise, line for line the TypeScript in `src/evaluate/noise.ts`. */\nconst NOISE_HELPERS = `fn fade(t: vec3<f32>) -> vec3<f32> {\n return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfn cornerDot(cell: vec3<i32>, d: vec3<f32>) -> f32 {\n let h = pcg3d(bitcast<vec3<u32>>(cell));\n let g = vec3<f32>(h) * UNIT_SCALE * 2.0 - vec3<f32>(1.0);\n return dot(g, d);\n}\n\nfn gradientNoise(p: vec3<f32>) -> f32 {\n let i = floor(p);\n let f = p - i;\n let u = fade(f);\n let cell = vec3<i32>(i);\n let c000 = cornerDot(cell, f);\n let c100 = cornerDot(cell + vec3<i32>(1, 0, 0), f - vec3<f32>(1.0, 0.0, 0.0));\n let c010 = cornerDot(cell + vec3<i32>(0, 1, 0), f - vec3<f32>(0.0, 1.0, 0.0));\n let c110 = cornerDot(cell + vec3<i32>(1, 1, 0), f - vec3<f32>(1.0, 1.0, 0.0));\n let c001 = cornerDot(cell + vec3<i32>(0, 0, 1), f - vec3<f32>(0.0, 0.0, 1.0));\n let c101 = cornerDot(cell + vec3<i32>(1, 0, 1), f - vec3<f32>(1.0, 0.0, 1.0));\n let c011 = cornerDot(cell + vec3<i32>(0, 1, 1), f - vec3<f32>(0.0, 1.0, 1.0));\n let c111 = cornerDot(cell + vec3<i32>(1, 1, 1), f - vec3<f32>(1.0, 1.0, 1.0));\n let x00 = mix(c000, c100, u.x);\n let x10 = mix(c010, c110, u.x);\n let x01 = mix(c001, c101, u.x);\n let x11 = mix(c011, c111, u.x);\n let y0 = mix(x00, x10, u.y);\n let y1 = mix(x01, x11, u.y);\n return mix(y0, y1, u.z);\n}\n\nfn noise3(p: vec3<f32>) -> vec3<f32> {\n var n = vec3<f32>(gradientNoise(p), gradientNoise(p + ${NOISE_OFFSET_Y}), gradientNoise(p + ${NOISE_OFFSET_Z}));\n if (NOISE_OCTAVES >= 2) {\n let p2 = p * 2.0;\n n += 0.5 * vec3<f32>(gradientNoise(p2), gradientNoise(p2 + ${NOISE_OFFSET_Y}), gradientNoise(p2 + ${NOISE_OFFSET_Z}));\n }\n return n;\n}\n`;\n\n/**\n * The vertex stage: record lookup, the closed forms, and the orientation of the mode.\n *\n * @param definition - The definition.\n * @returns The `mainVertex` function.\n */\nfunction vertexStage(definition: ParticleDefinition): string {\n const { forces, renderer, start, overLifetime, lookup, main } = definition;\n const lines: string[] = [];\n lines.push(\n \"@vertex fn mainVertex(input: VertexInput, @builtin(instance_index) iid: u32) -> VertexOutput {\",\n \" var out: VertexOutput;\",\n \" let capacity = u32(shaderUniforms.capacity);\",\n \" let head = u32(shaderUniforms.head);\",\n \" let slot = (head + capacity - 1u - iid) % capacity;\",\n \" let record = particles[slot];\",\n \" let age = shaderUniforms.clock - record.spawnTime;\",\n \" if (age < 0.0 || age > record.lifetime || record.lifetime <= 0.0) {\",\n \" out.position = DEAD;\",\n \" out.uv = vec2<f32>(0.0);\",\n \" out.color = vec4<f32>(0.0);\",\n \" return out;\",\n \" }\",\n \" let life = age / record.lifetime;\",\n \" let t = age;\",\n \" let g = shaderUniforms.gravity;\",\n \" var p: vec3<f32>;\",\n \" var v: vec3<f32>;\",\n );\n if (forces.drag > 0) {\n lines.push(\n \" {\",\n \" let inverse = 1.0 / DRAG;\",\n \" let e = exp(-DRAG * t);\",\n \" let a = record.velocity - g * inverse;\",\n \" let settle = (1.0 - e) * inverse;\",\n \" p = record.position + a * settle + g * inverse * t;\",\n \" v = a * e + g * inverse;\",\n \" }\",\n );\n } else {\n lines.push(\" p = record.position + record.velocity * t + g * (0.5 * t * t);\", \" v = record.velocity + g * t;\");\n }\n if (forces.orbit !== null) {\n lines.push(\n \" {\",\n \" let angle = ORBIT_SPEED * DEG_TO_RAD * t;\",\n \" p = shaderUniforms.orbitCenter + rotateAbout(p - shaderUniforms.orbitCenter, ORBIT_AXIS, angle);\",\n \" v = rotateAbout(v, ORBIT_AXIS, angle);\",\n \" }\",\n );\n }\n if (forces.noise !== null) {\n const influence = lookup.noise === null ? \"NOISE_INFLUENCE\" : decodeRow(\"NOISE\", \"r\");\n lines.push(\n \" {\",\n ` let amount = NOISE_STRENGTH * ${influence};`,\n \" p += amount * noise3(p * NOISE_FREQUENCY + NOISE_SCROLL * t);\",\n \" }\",\n );\n }\n if (main.simulationSpace === \"local\") {\n lines.push(\n \" p = (shaderUniforms.emitterWorld * vec4<f32>(p, 1.0)).xyz;\",\n \" v = (shaderUniforms.emitterWorld * vec4<f32>(v, 0.0)).xyz;\",\n );\n }\n lines.push(\" let units = vec3<f32>(pcg3d(vec3<u32>(record.seed, SALT_Y, SALT_Z))) * UNIT_SCALE;\");\n lines.push(\n start.color.kind === \"random\"\n ? \" var rgba = mix(START_COLOR_MIN, START_COLOR_MAX, units.x);\"\n : \" var rgba = START_COLOR;\",\n );\n if (lookup.color !== null) {\n lines.push(\" rgba *= lookupRow(COLOR_ROW, life);\");\n }\n lines.push(\" out.color = vec4<f32>(srgbToLinear(rgba.rgb), rgba.a);\");\n lines.push(\" var size = vec3<f32>(record.size) * SIZE_SCALE;\");\n if (lookup.size !== null) {\n lines.push(\" size *= SIZE_MIN + lookupRow(SIZE_ROW, life).rgb * (SIZE_MAX - SIZE_MIN);\");\n }\n const rotation = overLifetime.rotation;\n let angular = \"0.0\";\n if (rotation !== null) {\n angular = rotation.kind === \"curve\" ? decodeRow(\"ROTATION\", \"r\") : pickScalar(rotation, \"units.y\");\n }\n lines.push(` let rotation = record.rotation + ${angular} * DEG_TO_RAD * t;`);\n lines.push(...orientation(renderer.mode, renderer.lit));\n lines.push(...sheetUv(definition));\n lines.push(\" return out;\", \"}\");\n return lines.join(\"\\n\");\n}\n\n/**\n * The lines that place the vertex in the world for a render mode and write `out.position`.\n *\n * @param mode - The render mode.\n * @param lit - Whether the light uniforms are declared.\n * @returns The lines.\n */\nfunction orientation(mode: ParticleDefinition[\"renderer\"][\"mode\"], lit: boolean): string[] {\n const lines: string[] = [\n \" let view = shaderSystem.view;\",\n \" let viewRight = vec3<f32>(view[0].x, view[1].x, view[2].x);\",\n \" let viewUp = vec3<f32>(view[0].y, view[1].y, view[2].y);\",\n \" let viewForward = vec3<f32>(view[0].z, view[1].z, view[2].z);\",\n ];\n if (mode === \"mesh\") {\n lines.push(\n \" let spin = normalize(vec3<f32>(pcg3d(vec3<u32>(record.seed, SALT_Z, SALT_Y))) * UNIT_SCALE * 2.0 - vec3<f32>(1.0));\",\n \" let world = p + rotateAbout(input.position * size, spin, rotation);\",\n );\n if (lit) {\n lines.push(\" let normal = rotateAbout(input.normal, spin, rotation);\");\n }\n } else {\n lines.push(\" let corner = input.position.xy - PIVOT;\");\n if (mode === \"stretched\") {\n lines.push(\n \" let speed = length(v);\",\n \" var axis = viewUp;\",\n \" if (speed > 1e-6) { axis = v / speed; }\",\n \" var right = cross(viewForward, axis);\",\n \" if (dot(right, right) < 1e-8) { right = viewRight; } else { right = normalize(right); }\",\n \" let stretched = size.y * LENGTH_SCALE + speed * SPEED_SCALE;\",\n \" let world = p + right * (corner.x * size.x) + axis * (corner.y * stretched);\",\n );\n if (lit) {\n lines.push(\" let normal = -viewForward;\");\n }\n } else {\n lines.push(\n \" let cr = cos(rotation);\",\n \" let sr = sin(rotation);\",\n \" let spun = vec2<f32>(corner.x * cr - corner.y * sr, corner.x * sr + corner.y * cr);\",\n );\n lines.push(...billboardBasis(mode, lit));\n lines.push(\" let world = p + right * (spun.x * size.x) + up * (spun.y * size.y);\");\n }\n }\n if (lit) {\n lines.push(\n \" {\",\n \" let n = normalize(normal);\",\n \" let lambert = max(dot(n, -shaderUniforms.mainLightDirection), 0.0);\",\n \" out.color = vec4<f32>(out.color.rgb * (shaderUniforms.mainLightColor * lambert + shaderUniforms.ambientColor), out.color.a);\",\n \" }\",\n );\n }\n lines.push(\" out.position = shaderSystem.viewProjection * vec4<f32>(world, 1.0);\");\n return lines;\n}\n\n/**\n * The `right`, `up` and (for a lit definition) `normal` of a quad that is not stretched.\n *\n * @param mode - The render mode; never `\"mesh\"` or `\"stretched\"`.\n * @param lit - Whether the light uniforms are declared.\n * @returns The lines.\n */\nfunction billboardBasis(mode: ParticleDefinition[\"renderer\"][\"mode\"], lit: boolean): string[] {\n if (mode === \"horizontal\") {\n return [\n \" let right = vec3<f32>(1.0, 0.0, 0.0);\",\n \" let up = vec3<f32>(0.0, 0.0, 1.0);\",\n ...(lit ? [\" let normal = vec3<f32>(0.0, 1.0, 0.0);\"] : []),\n ];\n }\n if (mode === \"vertical\") {\n return [\n \" let up = vec3<f32>(0.0, 1.0, 0.0);\",\n \" let toCamera = shaderSystem.cameraPosition - p;\",\n \" let level = vec3<f32>(toCamera.x, 0.0, toCamera.z);\",\n \" var facing = vec3<f32>(0.0, 0.0, -1.0);\",\n \" if (dot(level, level) > 1e-8) { facing = normalize(level); }\",\n \" let right = normalize(cross(up, facing));\",\n ...(lit ? [\" let normal = facing;\"] : []),\n ];\n }\n return [\" let right = viewRight;\", \" let up = viewUp;\", ...(lit ? [\" let normal = -viewForward;\"] : [])];\n}\n\n/**\n * The lines that write `out.uv`, remapped into a sprite-sheet frame when the definition has one.\n *\n * @param definition - The definition.\n * @returns The lines.\n */\nfunction sheetUv(definition: ParticleDefinition): string[] {\n const sheet = definition.renderer.sheet;\n if (sheet === null) {\n return [\" out.uv = input.uv;\"];\n }\n let frame: string;\n if (sheet.mode === \"random\") {\n frame = \"min(SHEET_COUNT - 1.0, floor(units.z * SHEET_COUNT))\";\n } else if (sheet.mode === \"fps\") {\n frame = \"floor(units.z * SHEET_COUNT + SHEET_FPS * t) % SHEET_COUNT\";\n } else {\n const fraction = definition.lookup.frame === null ? \"0.0\" : decodeRow(\"FRAME\", \"r\");\n frame = `clamp(floor(${fraction} * SHEET_COUNT), 0.0, SHEET_COUNT - 1.0)`;\n }\n return [\n ` let frame = ${frame};`,\n \" let tile = vec2<f32>(frame % SHEET_TILES.x, floor(frame / SHEET_TILES.x));\",\n \" let flipped = vec2<f32>(input.uv.x, 1.0 - input.uv.y);\",\n \" let sheetUv = (flipped + tile) / SHEET_TILES;\",\n \" out.uv = vec2<f32>(sheetUv.x, 1.0 - sheetUv.y);\",\n ];\n}\n\n/**\n * The fragment stage: the sheet texel or a procedural soft disc, times the vertex colour, written\n * straight or premultiplied to match the blend state.\n *\n * @param definition - The definition.\n * @returns The `mainFragment` function.\n */\nfunction fragmentStage(definition: ParticleDefinition): string {\n const { renderer } = definition;\n const lines: string[] = [\"@fragment fn mainFragment(input: VertexOutput) -> @location(0) vec4<f32> {\"];\n if (renderer.texture !== null) {\n lines.push(\" let texel = textureSample(sheet, sheetSampler, input.uv);\");\n } else if (renderer.mode === \"mesh\") {\n lines.push(\" let texel = vec4<f32>(1.0);\");\n } else {\n lines.push(\n \" let d = length(input.uv * 2.0 - vec2<f32>(1.0));\",\n \" let mask = clamp(1.0 - d, 0.0, 1.0);\",\n \" let texel = vec4<f32>(1.0, 1.0, 1.0, mask * mask);\",\n );\n }\n lines.push(\" let color = input.color * texel;\");\n if (renderer.blend === \"premultiplied\") {\n lines.push(\" return vec4<f32>(color.rgb * color.a, color.a);\");\n } else {\n lines.push(\" return color;\");\n }\n lines.push(\"}\");\n return lines.join(\"\\n\");\n}\n\n/**\n * The `data:` address the generated program is published under, so the core shader loader — the\n * only path that also loads core's shader adapter — reads it with no file and no network. Two\n * definitions that generate the same program share one address, and so one `ShaderAsset`.\n *\n * @param source - The generated WGSL, which is ASCII.\n * @returns A `data:text/plain;base64,…` URL.\n *\n * @beta\n */\nexport function particleShaderAddress(source: string): string {\n return `data:text/plain;base64,${btoa(source)}`;\n}\n","import { createMaterialAsset, MeshAsset, shaderMaterialDefinition, TextureAsset } from \"@ignifx/core\";\nimport { LOOKUP_SAMPLES } from \"../definition/types.js\";\nimport { ParticlesErrorCode } from \"../errors.js\";\nimport { generateParticleWgsl, particleShaderAddress } from \"../gpu/wgsl.js\";\nimport type { ParticleAsset } from \"../assets/particle-asset.js\";\nimport type { ParticleMeshName } from \"../definition/types.js\";\nimport type { ParticleSystem } from \"../gpu/particle-system.js\";\nimport type { ParticlesSettings } from \"../settings.js\";\nimport type {\n App,\n AssetHandle,\n DiagnosticsGroup,\n MaterialAsset,\n ShaderAsset,\n ShaderMaterialDefinition,\n Vec3Like,\n} from \"@ignifx/core\";\n\n// `app.particles` (`docs/plan/2026-09-terrain-particles-shaders.md` §4.3): the budget, the quality\n// multiplier, the gravity, the counters, and the resources every system playing one definition\n// shares. The storage buffer and the material are per system; everything else is per definition.\n\n/**\n * The diagnostics group name.\n *\n * @public\n */\nexport const PARTICLES_DIAGNOSTICS_GROUP = \"particles\";\n\n/**\n * The counters the group carries, in index order.\n *\n * @public\n */\nexport const PARTICLES_DIAGNOSTICS_COUNTERS: readonly string[] = Object.freeze([\n \"systems\",\n \"alive\",\n \"emitted\",\n \"uploadBytes\",\n \"drawCalls\",\n]);\n\n/** Floats in one instance matrix. */\nconst MATRIX_FLOATS = 16;\n\n/**\n * The GPU-facing resources one definition's systems share.\n *\n * @public\n */\nexport interface ParticleDefinitionResources {\n /** The generated program. */\n readonly source: string;\n /** The program's asset, loading until the shader adapter is in place. */\n readonly shader: AssetHandle<ShaderAsset>;\n /** The baked lookup texture. */\n readonly lut: AssetHandle<TextureAsset>;\n /** The renderer's texture, or `null` for the procedural disc. */\n readonly sheet: AssetHandle<TextureAsset> | null;\n /** The quad, or the primitive a `\"mesh\"` renderer draws. */\n readonly mesh: AssetHandle<MeshAsset>;\n /** The material every system builds its own copy from. */\n readonly materialDefinition: ShaderMaterialDefinition;\n /** The texture handles in the order `materialDefinition.textures` names them. */\n readonly textures: readonly AssetHandle<TextureAsset>[];\n}\n\n/** A shared resource set plus the count of systems holding it. */\ninterface ResourceEntry {\n readonly resources: ParticleDefinitionResources;\n holders: number;\n hasReportedFailure: boolean;\n}\n\n/**\n * The particles service, reached as `app.particles`.\n *\n * @example\n * ```ts\n * app.particles.qualityScale = 0.5; // half the emission everywhere, for a low setting\n * app.particles.systems.length; // how many ParticleSystem components are attached\n * ```\n *\n * @public\n */\nexport class ParticlesService {\n /**\n * The budget every attached system's capacity is counted against. Raising it takes effect for\n * systems attached afterwards.\n */\n maxParticles: number;\n\n /** A `0`–`1` multiplier on every rate and burst count, read each frame. */\n qualityScale: number;\n\n readonly #app: App;\n\n readonly #gravity: { x: number; y: number; z: number };\n\n readonly #systems: ParticleSystem[] = [];\n\n readonly #resources = new Map<string, ResourceEntry>();\n\n readonly #meshes = new Map<string, AssetHandle<MeshAsset>>();\n\n #counters: DiagnosticsGroup | null = null;\n\n #identitySlab: Float32Array | null = null;\n\n #capacityInUse = 0;\n\n #isDisposed = false;\n\n /**\n * Creates the service.\n *\n * @param app - The app it belongs to.\n * @param settings - The resolved `particles` section, options already merged.\n */\n constructor(app: App, settings: ParticlesSettings) {\n this.#app = app;\n this.maxParticles = settings.maxParticles;\n this.qualityScale = settings.qualityScale;\n this.#gravity = { x: settings.gravity.x, y: settings.gravity.y, z: settings.gravity.z };\n }\n\n /**\n * The world gravity a definition's `gravityMultiplier` scales, in metres per second squared.\n *\n * @returns The service's own vector; assign to replace it.\n */\n get gravity(): Vec3Like {\n return this.#gravity;\n }\n\n /**\n * Copies a new world gravity in, so the caller's object is not retained.\n *\n * @param value - The gravity to copy.\n */\n set gravity(value: Vec3Like) {\n this.#gravity.x = value.x;\n this.#gravity.y = value.y;\n this.#gravity.z = value.z;\n }\n\n /**\n * Every attached `ParticleSystem`, in attach order.\n *\n * @returns The live list; iterate it without copying.\n */\n get systems(): readonly ParticleSystem[] {\n return this.#systems;\n }\n\n /**\n * How much of the budget attached systems hold.\n *\n * @returns The sum of every attached system's capacity.\n */\n get capacityInUse(): number {\n return this.#capacityInUse;\n }\n\n /**\n * The `particles` diagnostics group, once the extension registered it.\n *\n * @returns The group, or `null` before registration.\n */\n get counters(): DiagnosticsGroup | null {\n return this.#counters;\n }\n\n /**\n * Installs the counters group the extension registered.\n *\n * @param group - The group.\n *\n * @internal\n */\n setCounters(group: DiagnosticsGroup): void {\n this.#counters = group;\n }\n\n /**\n * Adds a system to the live list.\n *\n * @param system - The system.\n *\n * @internal\n */\n attach(system: ParticleSystem): void {\n if (!this.#systems.includes(system)) {\n this.#systems.push(system);\n }\n }\n\n /**\n * Removes a system from the live list.\n *\n * @param system - The system.\n *\n * @internal\n */\n detach(system: ParticleSystem): void {\n const index = this.#systems.indexOf(system);\n if (index >= 0) {\n this.#systems.splice(index, 1);\n }\n }\n\n /**\n * Takes capacity out of the budget, clamping to what is left and logging `IGX-1702` when it had\n * to. Every renderer that spends the particle budget goes through here, `@ignifx/particles-2d`\n * included; pair each call with {@link ParticlesService.release}.\n *\n * @param entity - The entity's name, for the warning.\n * @param requested - The definition's capacity, in records.\n * @returns The capacity granted, at least one record.\n *\n * @beta\n */\n reserve(entity: string, requested: number): number {\n const available = Math.max(0, this.maxParticles - this.#capacityInUse);\n let granted = requested;\n if (requested > available) {\n granted = Math.max(1, available);\n this.#app.log.warn(\n `${ParticlesErrorCode.budgetExceeded}: ${JSON.stringify(entity)} asked for ${String(requested)} particles, but only ${String(available)} of the ${String(this.maxParticles)} particle budget remain; the system was clamped.`,\n );\n }\n this.#capacityInUse += granted;\n return granted;\n }\n\n /**\n * Gives capacity back to the budget.\n *\n * @param granted - What {@link ParticlesService.reserve} returned.\n *\n * @beta\n */\n release(granted: number): void {\n this.#capacityInUse = Math.max(0, this.#capacityInUse - granted);\n }\n\n /**\n * The shared resources of a definition, built on first use.\n *\n * @param asset - The particle asset.\n * @returns The resources; pair every call with {@link ParticlesService.releaseResources}.\n *\n * @internal\n */\n acquireResources(asset: ParticleAsset): ParticleDefinitionResources {\n const existing = this.#resources.get(asset.address);\n if (existing !== undefined) {\n existing.holders += 1;\n return existing.resources;\n }\n const resources = this.#buildResources(asset);\n this.#resources.set(asset.address, { resources, holders: 1, hasReportedFailure: false });\n return resources;\n }\n\n /**\n * Lets go of a definition's resources, disposing them with the last holder.\n *\n * @param asset - The particle asset.\n *\n * @internal\n */\n releaseResources(asset: ParticleAsset): void {\n const entry = this.#resources.get(asset.address);\n if (entry === undefined) {\n return;\n }\n entry.holders -= 1;\n if (entry.holders <= 0) {\n this.#resources.delete(asset.address);\n disposeResources(entry.resources);\n }\n }\n\n /**\n * Reports, once per definition, that its shader failed to load.\n *\n * @param asset - The particle asset.\n * @param message - The failure.\n *\n * @internal\n */\n reportShaderFailure(asset: ParticleAsset, message: string): void {\n const entry = this.#resources.get(asset.address);\n if (entry === undefined || entry.hasReportedFailure) {\n return;\n }\n entry.hasReportedFailure = true;\n this.#app.log.error(\n `${ParticlesErrorCode.shaderFailed}: The particle shader for ${asset.address} could not be built: ${message}.`,\n );\n }\n\n /**\n * An identity matrix slab at least `capacity` instances long, shared by every renderer: the\n * particle shader never reads the instance matrices, so one read-only slab serves all.\n *\n * @param capacity - How many instances the caller needs.\n * @returns The slab.\n *\n * @internal\n */\n identitySlab(capacity: number): Float32Array {\n const needed = capacity * MATRIX_FLOATS;\n let slab = this.#identitySlab;\n if (slab === null || slab.length < needed) {\n slab = new Float32Array(needed);\n for (let index = 0; index < capacity; index += 1) {\n const base = index * MATRIX_FLOATS;\n slab[base] = 1;\n slab[base + 5] = 1;\n slab[base + 10] = 1;\n slab[base + 15] = 1;\n }\n this.#identitySlab = slab;\n }\n return slab;\n }\n\n /**\n * Builds a system's own material from a definition's shared resources.\n *\n * @param resources - The shared resources.\n * @returns The material handle, with one holder — the caller.\n *\n * @internal\n */\n createMaterial(resources: ParticleDefinitionResources): AssetHandle<MaterialAsset> {\n return createMaterialAsset(this.#app, resources.materialDefinition, resources.textures);\n }\n\n /** Releases every shared resource. The extension calls it on dispose. */\n dispose(): void {\n if (this.#isDisposed) {\n return;\n }\n this.#isDisposed = true;\n for (const entry of this.#resources.values()) {\n disposeResources(entry.resources);\n }\n this.#resources.clear();\n for (const mesh of this.#meshes.values()) {\n mesh.release();\n }\n this.#meshes.clear();\n this.#systems.length = 0;\n }\n\n /**\n * Generates and loads everything a definition's systems share.\n *\n * @param asset - The particle asset.\n * @returns The resources.\n */\n #buildResources(asset: ParticleAsset): ParticleDefinitionResources {\n const app = this.#app;\n const definition = asset.definition;\n const source = generateParticleWgsl(definition);\n const address = particleShaderAddress(source);\n const shader = app.assets.load<ShaderAsset>(address, { type: \"shader\" });\n const lut = TextureAsset.fromPixels(\n app,\n `particles:lut:${asset.address}`,\n definition.lookup.pixels,\n LOOKUP_SAMPLES,\n definition.lookup.rows,\n {\n filter: \"linear\",\n wrap: \"clamp\",\n },\n );\n const sheet = asset.texture === null ? null : asset.texture.retain();\n const mesh = this.#mesh(definition.renderer.mode === \"mesh\" ? definition.renderer.mesh : null);\n const textureAddresses: Record<string, string> = {};\n const textures: AssetHandle<TextureAsset>[] = [];\n if (sheet !== null) {\n textureAddresses[\"sheet\"] = sheet.address;\n textures.push(sheet);\n }\n textureAddresses[\"lut\"] = lut.address;\n textures.push(lut);\n const materialDefinition = shaderMaterialDefinition({\n shader: address,\n name: `particles:${asset.address}`,\n textures: textureAddresses,\n });\n return { source, shader, lut, sheet, mesh, materialDefinition, textures };\n }\n\n /**\n * The quad every billboard mode draws, or a unit primitive, built once per app.\n *\n * @param name - The primitive, or `null` for the quad.\n * @returns The mesh handle, retained for the caller.\n */\n #mesh(name: ParticleMeshName | null): AssetHandle<MeshAsset> {\n const key = name ?? \"quad\";\n const cached = this.#meshes.get(key);\n if (cached !== undefined) {\n return cached.retain();\n }\n const app = this.#app;\n let handle: AssetHandle<MeshAsset>;\n switch (name) {\n case null:\n handle = MeshAsset.fromData(app, \"particles:quad\", quadGeometry());\n break;\n case \"box\":\n handle = MeshAsset.box(app, { size: 1 });\n break;\n case \"sphere\":\n handle = MeshAsset.sphere(app, { diameter: 1, segments: 12 });\n break;\n case \"plane\":\n handle = MeshAsset.plane(app, { size: 1 });\n break;\n case \"cylinder\":\n handle = MeshAsset.cylinder(app, { height: 1, diameter: 1, tessellation: 12 });\n break;\n case \"capsule\":\n handle = MeshAsset.capsule(app, { height: 1, radius: 0.25, tessellation: 8 });\n break;\n case \"torus\":\n handle = MeshAsset.torus(app, { diameter: 1, thickness: 0.3, tessellation: 12 });\n break;\n }\n this.#meshes.set(key, handle);\n return handle.retain();\n }\n}\n\n/**\n * Releases a resource set's handles.\n *\n * @param resources - The set.\n */\nfunction disposeResources(resources: ParticleDefinitionResources): void {\n resources.shader.release();\n resources.lut.release();\n resources.sheet?.release();\n resources.mesh.release();\n}\n\n/**\n * The unit quad billboards are drawn from: corners at `±0.5` in XY, `uv` `(0, 0)` at the bottom\n * left, facing `-Z`.\n *\n * @returns The geometry.\n */\nfunction quadGeometry(): {\n readonly positions: Float32Array;\n readonly normals: Float32Array;\n readonly indices: Uint32Array;\n readonly uvs: Float32Array;\n} {\n return {\n positions: Float32Array.from([-0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0]),\n normals: Float32Array.from([0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1]),\n indices: Uint32Array.from([0, 1, 2, 0, 2, 3]),\n uvs: Float32Array.from([0, 0, 1, 0, 1, 1, 0, 1]),\n };\n}\n","import {\n asset,\n bool,\n Component,\n createDefaults,\n createStorageBufferAsset,\n defineSchema,\n InstancedMeshRenderer,\n Mat4,\n Signal,\n u32,\n Vec3,\n} from \"@ignifx/core\";\nimport { ParticleAsset } from \"../assets/particle-asset.js\";\nimport { ParticleEmitterCore } from \"../emitter/emitter-core.js\";\nimport { RECORD_BYTES, RECORD_FLOATS } from \"../emitter/record-ring.js\";\nimport { ParticlesErrorCode, particlesError } from \"../errors.js\";\nimport { createParticleState, evaluateParticle } from \"../evaluate/particle-math.js\";\nimport { ParticlesService } from \"../service/particles-service.js\";\nimport type { ParticleStopOptions } from \"../emitter/emitter-core.js\";\nimport type { UploadRange } from \"../emitter/record-ring.js\";\nimport type { ParticleEvaluationInputs, ParticleState } from \"../evaluate/particle-math.js\";\nimport type { ParticleDefinitionResources } from \"../service/particles-service.js\";\nimport type { AssetHandle, ComponentHooks, MaterialAsset, Schema, StorageBufferAsset } from \"@ignifx/core\";\n\n// The `ParticleSystem` component (`docs/plan/2026-09-terrain-particles-shaders.md` §4.3). It owns\n// an emitter core, a storage buffer for the records, a material built from the definition's shared\n// shader, and an `InstancedMeshRenderer` it adds to its own entity.\n\n/**\n * Where the update system sits in `Update`: after every script, so a script's `emit()` is drawn in\n * the same frame.\n *\n * @public\n */\nexport const PARTICLE_UPDATE_ORDER = 900;\n\n/**\n * Where the render system sits in `PreRender`: before core's shader-uniform (890) and render-sync\n * (900) systems, so this frame's records and uniforms are what the scene draws.\n *\n * @public\n */\nexport const PARTICLE_RENDER_ORDER = 880;\n\n/** How many floats a `vec3` uniform holds. */\nconst VEC3_FLOATS = 3;\n\n/**\n * Draws a particle effect on its entity.\n *\n * @example\n * ```ts\n * const fire = particleAssetFromDefinition(app, particleDefinition(\"fire\"));\n * const system = campfire.addComponent(ParticleSystem, { definition: fire });\n * system.emit(50);\n * ```\n *\n * @public\n */\nexport class ParticleSystem extends Component implements ComponentHooks {\n /** The registration id the serializer writes into scene files. */\n static typeId = \"ignifx/ParticleSystem\";\n\n /** The name an inspector shows for the component. */\n static title = \"Particle system\";\n\n /** Several effects may share one entity; each owns its own renderer. */\n static allowMultiple = true;\n\n /** The declarative fields (ADR-0004). */\n static schema: Schema = particleSystemSchema();\n\n /** The `.particles.json`, as a loaded handle. */\n declare definition: AssetHandle<ParticleAsset> | null;\n\n /** Whether the system plays the first frame it is enabled; the definition's `playOnAwake` must agree. */\n declare playOnAwake: boolean;\n\n /** The emission seed; `0` uses the definition's, and a definition seed of `0` picks at random. */\n declare seed: number;\n\n /** Emitted once when a non-looping system runs out of cycle and particles. */\n readonly onStopped: Signal<ParticleSystem> = new Signal<ParticleSystem>();\n\n readonly #census: { readonly ranges: [UploadRange, UploadRange] } = {\n ranges: [\n { start: 0, count: 0 },\n { start: 0, count: 0 },\n ],\n };\n\n readonly #gravity = new Float32Array(VEC3_FLOATS);\n\n readonly #gravityWritten = new Float32Array(VEC3_FLOATS);\n\n readonly #orbitCenter = new Float32Array(VEC3_FLOATS);\n\n readonly #orbitWritten = new Float32Array(VEC3_FLOATS);\n\n readonly #emitterWorld = new Float32Array(16);\n\n readonly #inverse = new Mat4();\n\n readonly #gravityWorld = new Vec3();\n\n readonly #gravityLocal = new Vec3();\n\n #inputs: ParticleEvaluationInputs | null = null;\n\n #service: ParticlesService | null = null;\n\n #core: ParticleEmitterCore | null = null;\n\n #applied: ParticleAsset | null = null;\n\n #resources: ParticleDefinitionResources | null = null;\n\n #renderer: InstancedMeshRenderer | null = null;\n\n #material: AssetHandle<MaterialAsset> | null = null;\n\n #storage: AssetHandle<StorageBufferAsset> | null = null;\n\n #reserved = 0;\n\n #hasAutoPlayed = false;\n\n #hasBoundSheet = false;\n\n #worldVersion = -1;\n\n #headWritten = -1;\n\n #capacityWritten = -1;\n\n #uploadedBytes = 0;\n\n #emittedBefore = 0;\n\n #emittedThisFrame = 0;\n\n #hasWarnedNoService = false;\n\n /** Applies the schema defaults, exactly as `Component.define` would. */\n constructor() {\n super();\n Object.assign(this, createDefaults(ParticleSystem.schema));\n this.#gravityWritten.fill(Number.NaN);\n this.#orbitWritten.fill(Number.NaN);\n }\n\n /**\n * The loaded document, or `null` while the handle is loading or unset.\n *\n * @returns The asset.\n */\n get asset(): ParticleAsset | null {\n const handle = this.definition;\n return handle?.state === \"loaded\" ? handle.value : null;\n }\n\n /**\n * Whether the system is playing, paused or not.\n *\n * @returns `true` between `play()` and the stop.\n */\n get isPlaying(): boolean {\n return this.#core?.isPlaying ?? false;\n }\n\n /**\n * Whether the clock is held by `pause()`.\n *\n * @returns `true` while paused.\n */\n get isPaused(): boolean {\n return this.#core?.isPaused ?? false;\n }\n\n /**\n * How many particles are alive, exactly, as of the last frame.\n *\n * @returns The count.\n */\n get aliveCount(): number {\n return this.#core?.aliveCount ?? 0;\n }\n\n /**\n * How many records the GPU draws this frame: from the newest back to the oldest still alive.\n *\n * @returns The draw count.\n */\n get drawCount(): number {\n return this.#core?.drawCount ?? 0;\n }\n\n /**\n * How many spawns displaced a particle that was still alive, because the capacity the app's\n * `maxParticles` budget granted is smaller than the definition's rate times its lifetime.\n *\n * @returns The total since the system last started from empty.\n */\n get droppedCount(): number {\n return this.#core?.droppedTotal ?? 0;\n }\n\n /**\n * The system-local clock, in seconds — what every particle's age is measured against and what the\n * shader reads as `clock`.\n *\n * @returns The clock.\n */\n get time(): number {\n return this.#core?.time ?? 0;\n }\n\n /**\n * The ring capacity in use, after the app's budget clamped the definition's.\n *\n * @returns The capacity, or `0` before a definition is applied.\n */\n get capacity(): number {\n return this.#core?.ring.capacity ?? 0;\n }\n\n /**\n * The CPU mirror of the spawn records: `capacity * 12` floats, one 48-byte record per slot, in\n * the layout `src/emitter/record-ring.ts` documents. Read-only; for tests and tools.\n *\n * @returns The mirror, or `null` before a definition is applied.\n *\n * @beta\n */\n get records(): Float32Array | null {\n return this.#core?.ring.floats ?? null;\n }\n\n /**\n * The emitter core the frame drives.\n *\n * @returns The core, or `null` before a definition is applied.\n *\n * @internal\n */\n get core(): ParticleEmitterCore | null {\n return this.#core;\n }\n\n /**\n * The renderer the system draws through.\n *\n * @returns The renderer, or `null` before the GPU side is built.\n *\n * @internal\n */\n get renderer(): InstancedMeshRenderer | null {\n return this.#renderer;\n }\n\n /**\n * The material the system draws with.\n *\n * @returns The handle, or `null` before the GPU side is built.\n *\n * @internal\n */\n get material(): AssetHandle<MaterialAsset> | null {\n return this.#material;\n }\n\n /**\n * The storage buffer the records are streamed into.\n *\n * @returns The handle, or `null` before the GPU side is built.\n *\n * @internal\n */\n get storage(): AssetHandle<StorageBufferAsset> | null {\n return this.#storage;\n }\n\n /**\n * Bytes uploaded in the last frame.\n *\n * @returns The byte count.\n *\n * @internal\n */\n get uploadedBytes(): number {\n return this.#uploadedBytes;\n }\n\n /**\n * Particles emitted in the last frame.\n *\n * @returns The count.\n *\n * @internal\n */\n get emittedThisFrame(): number {\n return this.#emittedThisFrame;\n }\n\n /** Starts emitting, or resumes after `stop()`. A `prewarm` definition fast-forwards one cycle. */\n play(): void {\n this.#hasAutoPlayed = true;\n this.#requireCore(\"play\").play();\n }\n\n /**\n * Stops emitting. Live particles finish their lives unless `clear` is set.\n *\n * @param options - Whether to clear the particles too.\n */\n stop(options?: ParticleStopOptions): void {\n this.#hasAutoPlayed = true;\n this.#requireCore(\"stop\").stop(options);\n }\n\n /** Holds the clock; every particle freezes in place. */\n pause(): void {\n this.#requireCore(\"pause\").pause();\n }\n\n /** Releases `pause()`. */\n resume(): void {\n this.#requireCore(\"resume\").resume();\n }\n\n /**\n * Spawns particles now, at the current clock, whether or not the system is playing. Called from a\n * script's `update`, they are drawn in the same frame.\n *\n * @param count - How many; floored.\n * @throws IgnifxError with code `IGX-1707` for a negative or non-finite count, or `IGX-1705`\n * when no definition is applied.\n */\n emit(count: number): void {\n if (!Number.isFinite(count) || count < 0) {\n throw this.#invalidArgument(\"emit\", \"a finite non-negative count\", count);\n }\n this.#requireCore(\"emit\").emit(count);\n }\n\n /**\n * Fast-forwards the system by `seconds`, emitting as it goes — what `prewarm` does.\n *\n * @param seconds - How far to advance.\n * @throws IgnifxError with code `IGX-1707` for a negative or non-finite duration, or `IGX-1705`\n * when no definition is applied.\n */\n simulate(seconds: number): void {\n if (!Number.isFinite(seconds) || seconds < 0) {\n throw this.#invalidArgument(\"simulate\", \"a finite non-negative number of seconds\", seconds);\n }\n this.#requireCore(\"simulate\").simulate(seconds);\n }\n\n /**\n * Evaluates one spawn record at the current clock with the CPU evaluator, in world space — the\n * same arithmetic the shader runs, for tests and tools.\n *\n * @param slot - The record's slot in the ring.\n * @param out - Receives the state; allocate one with `createParticleState()`.\n * @returns `true` when the record is alive.\n *\n * @beta\n */\n evaluate(slot: number, out: ParticleState = createParticleState()): boolean {\n const core = this.#core;\n const inputs = this.#inputs;\n if (core === null || inputs === null) {\n return false;\n }\n this.#refreshFrameInputs(core);\n return evaluateParticle(inputs, core.ring.floats, core.ring.words, slot, core.time, out);\n }\n\n /** Joins the service's live list. */\n onAttach(): void {\n const service = this.app.services.tryGet(ParticlesService);\n this.#service = service;\n if (service === null) {\n if (!this.#hasWarnedNoService) {\n this.#hasWarnedNoService = true;\n this.app.log.warn(\n `${JSON.stringify(this.entity.name)} has a ParticleSystem, but the particles() extension is not registered; it stays inert.`,\n );\n }\n return;\n }\n service.attach(this);\n }\n\n /** Releases the GPU side, the budget, and the shared resources. */\n onDetach(): void {\n this.#teardown();\n this.#service?.detach(this);\n this.#service = null;\n }\n\n /**\n * One frame of emission. The `Update` system calls it.\n *\n * @param dt - The frame's scaled delta, or `0` while the app is paused.\n *\n * @internal\n */\n tick(dt: number): void {\n const service = this.#service;\n if (service === null || this.isDestroyed) {\n return;\n }\n const core = this.#ensureCore(service);\n if (core === null) {\n return;\n }\n const enabled = this.isEnabledInHierarchy;\n if (!this.#hasAutoPlayed && enabled) {\n this.#hasAutoPlayed = true;\n const applied = this.#applied;\n if (this.playOnAwake && applied !== null && applied.definition.main.playOnAwake) {\n core.play();\n }\n }\n core.qualityScale = service.qualityScale;\n if (enabled) {\n core.advance(dt);\n }\n core.reconcile();\n const emitted = core.emittedTotal;\n this.#emittedThisFrame = Math.max(0, emitted - this.#emittedBefore);\n this.#emittedBefore = emitted;\n }\n\n /**\n * One frame of upload. The `PreRender` system calls it.\n *\n * @internal\n */\n sync(): void {\n this.#uploadedBytes = 0;\n const service = this.#service;\n const core = this.#core;\n const applied = this.#applied;\n if (service === null || core === null || applied === null || this.isDestroyed) {\n return;\n }\n this.#ensureGpu(service, core, applied);\n const renderer = this.#renderer;\n const material = this.#material;\n const storage = this.#storage;\n if (renderer === null || material === null || storage === null) {\n return;\n }\n this.#upload(core, storage);\n const values = material.value;\n values.setUniform(\"clock\", core.time);\n const head = core.ring.head;\n if (head !== this.#headWritten) {\n this.#headWritten = head;\n values.setUniform(\"head\", head);\n }\n if (core.ring.capacity !== this.#capacityWritten) {\n this.#capacityWritten = core.ring.capacity;\n values.setUniform(\"capacity\", core.ring.capacity);\n }\n if (applied.definition.main.simulationSpace === \"local\") {\n values.setUniform(\"emitterWorld\", this.#emitterWorld);\n }\n if (!sameVec3(this.#gravity, this.#gravityWritten)) {\n this.#gravityWritten.set(this.#gravity);\n values.setUniform(\"gravity\", this.#gravity);\n }\n // The generated program declares `orbitCenter` only when the definition orbits.\n if (applied.definition.forces.orbit !== null && !sameVec3(this.#orbitCenter, this.#orbitWritten)) {\n this.#orbitWritten.set(this.#orbitCenter);\n values.setUniform(\"orbitCenter\", this.#orbitCenter);\n }\n const sheet = this.#resources?.sheet ?? null;\n if (!this.#hasBoundSheet && sheet !== null && sheet.state === \"loaded\") {\n this.#hasBoundSheet = true;\n values.setTexture(\"sheet\", sheet);\n }\n const draw = Math.min(core.drawCount, core.ring.capacity);\n if (draw !== renderer.count) {\n renderer.setCount(draw);\n }\n renderer.enabled = this.isEnabledInHierarchy;\n }\n\n /**\n * Refreshes the emitter matrix, the simulation-space gravity, and the orbit centre from the entity's\n * transform and the service, only when something moved.\n *\n * @param core - The core to write the matrix into.\n */\n #refreshFrameInputs(core: ParticleEmitterCore): void {\n const applied = this.#applied;\n const service = this.#service;\n if (applied === null || service === null) {\n return;\n }\n const transform = this.transform;\n const version = transform.worldMatrixVersion;\n const moved = version !== this.#worldVersion;\n if (moved) {\n this.#worldVersion = version;\n const world = transform.worldMatrix;\n this.#emitterWorld.set(world);\n core.emitterWorld.set(world);\n }\n const forces = applied.definition.forces;\n const gravity = forces.gravity;\n const g = service.gravity;\n const world = this.#gravityWorld;\n if (gravity === null) {\n world.set(g.x * forces.gravityMultiplier, g.y * forces.gravityMultiplier, g.z * forces.gravityMultiplier);\n } else {\n world.set(gravity.x, gravity.y, gravity.z);\n }\n const local = this.#gravityLocal;\n if (applied.definition.main.simulationSpace === \"local\") {\n if (Mat4.invertToRef(transform.worldMatrix, this.#inverse)) {\n Mat4.transformDirectionToRef(this.#inverse.elements, world, local);\n } else {\n local.copyFrom(world);\n }\n this.#orbitCenter[0] = 0;\n this.#orbitCenter[1] = 0;\n this.#orbitCenter[2] = 0;\n } else {\n local.copyFrom(world);\n this.#orbitCenter[0] = this.#emitterWorld[12] ?? 0;\n this.#orbitCenter[1] = this.#emitterWorld[13] ?? 0;\n this.#orbitCenter[2] = this.#emitterWorld[14] ?? 0;\n }\n this.#gravity[0] = local.x + forces.constantForce.x;\n this.#gravity[1] = local.y + forces.constantForce.y;\n this.#gravity[2] = local.z + forces.constantForce.z;\n }\n\n /**\n * The core, ready to spawn: built if the definition changed, and always holding the entity's\n * current world matrix. The matrix has to be current *before* anything spawns, because `play()`\n * on a prewarmed document fast-forwards a whole cycle and a `\"world\"` record bakes the matrix in.\n *\n * @param service - The service.\n * @returns The core, or `null` while the definition is loading or unset.\n */\n #ensureCore(service: ParticlesService): ParticleEmitterCore | null {\n if (this.asset !== this.#applied) {\n this.#buildCore(service);\n }\n const core = this.#core;\n if (core !== null) {\n this.#refreshFrameInputs(core);\n }\n return core;\n }\n\n /**\n * Builds, or rebuilds, the core for the definition handle's loaded value.\n *\n * @param service - The service.\n */\n #buildCore(service: ParticlesService): void {\n const loaded = this.asset;\n this.#teardown();\n this.#applied = loaded;\n if (loaded === null) {\n return;\n }\n const definition = loaded.definition;\n this.#reserved = service.reserve(this.entity.name, definition.main.capacity);\n const seed = this.seed !== 0 ? this.seed : definition.main.seed;\n const core = new ParticleEmitterCore({ definition, capacity: this.#reserved, seed });\n core.onStopped = (): void => {\n this.onStopped.emit(this);\n };\n this.#core = core;\n this.#resources = service.acquireResources(loaded);\n this.#hasAutoPlayed = false;\n this.#emittedBefore = 0;\n this.#worldVersion = -1;\n this.#inputs = {\n definition,\n gravity: this.#gravity,\n emitterWorld: this.#emitterWorld,\n orbitCenter: this.#orbitCenter,\n };\n }\n\n /**\n * Builds the storage buffer, the material, and the renderer once the shared shader has loaded.\n *\n * @param service - The service.\n * @param core - The core whose ring is uploaded.\n * @param applied - The applied asset.\n */\n #ensureGpu(service: ParticlesService, core: ParticleEmitterCore, applied: ParticleAsset): void {\n if (this.#renderer !== null) {\n return;\n }\n const resources = this.#resources;\n if (resources === null) {\n return;\n }\n const shader = resources.shader;\n if (shader.state === \"failed\") {\n service.reportShaderFailure(applied, shader.error?.message ?? \"unknown failure\");\n return;\n }\n if (shader.state !== \"loaded\") {\n return;\n }\n const storage = createStorageBufferAsset(this.app, `particles:${this.entity.name}`, core.ring.floats);\n const material = service.createMaterial(resources);\n material.value.setStorageBuffer(\"particles\", storage);\n this.#storage = storage;\n this.#material = material;\n this.#headWritten = -1;\n this.#capacityWritten = -1;\n this.#gravityWritten.fill(Number.NaN);\n this.#orbitWritten.fill(Number.NaN);\n this.#hasBoundSheet = false;\n core.ring.markUploaded();\n const capacity = core.ring.capacity;\n const renderer = this.entity.addComponent(InstancedMeshRenderer, {\n mesh: resources.mesh,\n materials: [material],\n capacity,\n gpuCulling: false,\n castShadows: false,\n receiveShadows: false,\n pickable: false,\n renderOrder: applied.definition.main.renderOrder,\n });\n renderer.setMatrices(service.identitySlab(capacity), capacity);\n renderer.setCount(Math.min(core.drawCount, capacity));\n this.#renderer = renderer;\n }\n\n /**\n * Streams the records written since the last frame into the storage buffer: one update, or two\n * when the ring wrapped.\n *\n * @param core - The core whose ring is uploaded.\n * @param storage - The buffer.\n */\n #upload(core: ParticleEmitterCore, storage: AssetHandle<StorageBufferAsset>): void {\n const ring = core.ring;\n const ranges = this.#census.ranges;\n const count = ring.pendingRanges(ranges);\n if (count === 0) {\n return;\n }\n const buffer = storage.value;\n for (let index = 0; index < count; index += 1) {\n const range = ranges[index];\n if (range === undefined || range.count === 0) {\n continue;\n }\n const view = ring.floats.subarray(range.start * RECORD_FLOATS, (range.start + range.count) * RECORD_FLOATS);\n buffer.update(view, range.start * RECORD_BYTES);\n this.#uploadedBytes += range.count * RECORD_BYTES;\n }\n ring.markUploaded();\n }\n\n /** Releases everything the applied definition built. */\n #teardown(): void {\n const renderer = this.#renderer;\n this.#renderer = null;\n if (renderer !== null && !renderer.isDestroyed) {\n renderer.destroy();\n }\n this.#material?.release();\n this.#material = null;\n this.#storage?.release();\n this.#storage = null;\n const service = this.#service;\n const applied = this.#applied;\n if (service !== null) {\n if (applied !== null && this.#resources !== null) {\n service.releaseResources(applied);\n }\n service.release(this.#reserved);\n }\n this.#resources = null;\n this.#reserved = 0;\n this.#core = null;\n this.#applied = null;\n this.#inputs = null;\n }\n\n /**\n * The core, or a misuse error naming the method.\n *\n * @param method - The method being called.\n * @returns The core.\n * @throws IgnifxError with code `IGX-1705`.\n */\n #requireCore(method: string): ParticleEmitterCore {\n const service = this.#service;\n const core = service === null ? this.#core : this.#ensureCore(service);\n if (core !== null) {\n return core;\n }\n throw particlesError(\n ParticlesErrorCode.noDefinition,\n `${this.entity.name} has a ParticleSystem with no definition, so ${method}() cannot run.`,\n {\n context: { entity: this.entity.name, method },\n hint: \"Assign a loaded ParticleAsset handle to `definition` first.\",\n },\n );\n }\n\n /**\n * Builds the `IGX-1707` argument error.\n *\n * @param method - The method.\n * @param expected - What it wanted.\n * @param value - What it got.\n * @returns The error.\n */\n #invalidArgument(method: string, expected: string, value: number): ReturnType<typeof particlesError> {\n return particlesError(ParticlesErrorCode.invalidArgument, `${method} needs ${expected}, not ${String(value)}.`, {\n context: { method, expected, value },\n });\n }\n}\n\n/**\n * Whether two three-float arrays hold the same values.\n *\n * @param a - One array.\n * @param b - The other.\n * @returns `true` when every component matches.\n */\nfunction sameVec3(a: Float32Array, b: Float32Array): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n\n/**\n * Builds the component's declared fields.\n *\n * @returns The schema, built inside a function so module scope holds no calls (`CONSTITUTION.md` §3.5).\n */\nfunction particleSystemSchema(): Schema {\n return defineSchema({\n definition: asset(ParticleAsset, { tooltip: \"The .particles.json this system plays.\" }),\n playOnAwake: bool(true, { tooltip: \"Play the first frame the system is enabled, if the definition agrees.\" }),\n seed: u32(0, { tooltip: \"The emission seed; 0 uses the definition's, and 0 there picks at random.\" }),\n });\n}\n","import type { ParticlesService } from \"../service/particles-service.js\";\nimport type { System, SystemContext } from \"@ignifx/core\";\n\n// The two frame systems that drive every `ParticleSystem`\n// (`docs/plan/2026-09-terrain-particles-shaders.md` §4.3). Both walk the service's live list rather\n// than the world's components, so the order is attach order and a detached system is already gone.\n\n/** The counter indices, resolved once. */\ninterface CounterIndices {\n readonly systems: number;\n readonly alive: number;\n readonly emitted: number;\n readonly uploadBytes: number;\n readonly drawCalls: number;\n}\n\n/**\n * Advances every system's emitter core by the frame's scaled delta, or by nothing while the app is\n * paused. Runs late in `Update` so a script's `emit()` is drawn in the same frame.\n *\n * @beta\n */\nexport class ParticleUpdateSystem implements System {\n /** The name diagnostics and error reports use. */\n readonly name: string = \"ignifx/particles-update\";\n\n readonly #service: ParticlesService;\n\n /**\n * Creates the system.\n *\n * @param service - The service whose list it walks.\n */\n constructor(service: ParticlesService) {\n this.#service = service;\n }\n\n /**\n * Runs emission for one frame.\n *\n * @param ctx - The world, the clock, the phase, and the frame delta.\n */\n update(ctx: SystemContext): void {\n const dt = ctx.time.paused ? 0 : ctx.dt;\n const systems = this.#service.systems;\n for (let index = 0; index < systems.length; index += 1) {\n systems[index]?.tick(dt);\n }\n }\n}\n\n/**\n * Uploads every system's new records, writes its uniforms, bounds its draw count, and publishes the\n * `particles` counters. Runs in `PreRender` before core's render sync.\n *\n * @beta\n */\nexport class ParticleRenderSystem implements System {\n /** The name diagnostics and error reports use. */\n readonly name: string = \"ignifx/particles-render\";\n\n readonly #service: ParticlesService;\n\n #indices: CounterIndices | null = null;\n\n /**\n * Creates the system.\n *\n * @param service - The service whose list it walks.\n */\n constructor(service: ParticlesService) {\n this.#service = service;\n }\n\n /** Runs the upload for one frame. */\n update(): void {\n const service = this.#service;\n const systems = service.systems;\n let alive = 0;\n let emitted = 0;\n let uploadBytes = 0;\n let drawCalls = 0;\n for (let index = 0; index < systems.length; index += 1) {\n const system = systems[index];\n if (system === undefined) {\n continue;\n }\n system.sync();\n alive += system.aliveCount;\n emitted += system.emittedThisFrame;\n uploadBytes += system.uploadedBytes;\n if (system.drawCount > 0 && system.renderer !== null && system.renderer.isVisible) {\n drawCalls += 1;\n }\n }\n const counters = service.counters;\n if (counters === null) {\n return;\n }\n let indices = this.#indices;\n if (indices === null) {\n indices = {\n systems: counters.index(\"systems\"),\n alive: counters.index(\"alive\"),\n emitted: counters.index(\"emitted\"),\n uploadBytes: counters.index(\"uploadBytes\"),\n drawCalls: counters.index(\"drawCalls\"),\n };\n this.#indices = indices;\n }\n counters.set(indices.systems, systems.length);\n counters.set(indices.alive, alive);\n counters.set(indices.emitted, emitted);\n counters.set(indices.uploadBytes, uploadBytes);\n counters.set(indices.drawCalls, drawCalls);\n }\n}\n","import { defineSchema, f32, u32, vec3 } from \"@ignifx/core\";\nimport type { Schema, Vec3Like } from \"@ignifx/core\";\n\n// The `particles` project settings section (`docs/architecture/04-extensions.md` §5). Three\n// project-wide decisions live here — the budget, the quality multiplier, and the world gravity;\n// everything per effect is in the `.particles.json`.\n\n/**\n * The section name as it appears in `ignifx.config.ts`.\n *\n * @public\n */\nexport const PARTICLES_SETTINGS_SECTION = \"particles\";\n\n/** How many particles every system together may hold, unless the project says otherwise. */\nconst DEFAULT_MAX_PARTICLES = 100_000;\n\n/** Standard gravity, matching `@ignifx/physics`'s own default. */\nconst DEFAULT_GRAVITY: Vec3Like = Object.freeze({ x: 0, y: -9.81, z: 0 });\n\n/**\n * The resolved `particles` settings section.\n *\n * @example\n * ```ts\n * // ignifx.config.ts\n * export default defineConfig({\n * particles: { maxParticles: 50_000, qualityScale: 1 },\n * });\n * ```\n *\n * @public\n */\nexport interface ParticlesSettings {\n /**\n * The budget every `ParticleSystem`'s `capacity` is counted against. A system that would push the\n * total over it is clamped to what is left and `IGX-1702` is logged once.\n */\n readonly maxParticles: number;\n /** A `0`–`1` multiplier on every emission rate and burst count, for settings screens. */\n readonly qualityScale: number;\n /**\n * The world gravity, in metres per second squared, a definition's `forces.gravityMultiplier`\n * scales. When `@ignifx/physics` is registered and this stays at its default, the physics\n * section's gravity is used instead.\n */\n readonly gravity: Vec3Like;\n}\n\n/**\n * The values used for everything a project omits.\n *\n * @returns The default `particles` section.\n *\n * @public\n */\nexport function defaultParticlesSettings(): ParticlesSettings {\n return { maxParticles: DEFAULT_MAX_PARTICLES, qualityScale: 1, gravity: { ...DEFAULT_GRAVITY } };\n}\n\n/**\n * The schema the `particles` section is validated against.\n *\n * @returns The schema, built fresh so no module holds state (`CONSTITUTION.md` §3.5).\n *\n * @public\n */\nexport function particlesSettingsSchema(): Schema {\n return defineSchema({\n maxParticles: u32(DEFAULT_MAX_PARTICLES, {\n min: 0,\n tooltip: \"The particle budget every ParticleSystem capacity is counted against.\",\n }),\n qualityScale: f32(1, { min: 0, max: 1, tooltip: \"A 0-1 multiplier on emission rates and burst counts.\" }),\n gravity: vec3(DEFAULT_GRAVITY, { tooltip: \"The world gravity a gravityMultiplier scales, in m/s^2.\" }),\n });\n}\n","// The build replaces this with the version in `package.json` (`define` in `tsdown.config.ts`).\ndeclare const IGNIFX_BUILD_VERSION: string | undefined;\n\n/**\n * The `@ignifx/particles` version this build was cut from, reported as `Extension.version`\n * (`docs/architecture/04-extensions.md` §1).\n *\n * @remarks\n * The build stamps it from `package.json`; code run from source, such as this repository's tests,\n * sees `\"0.0.0\"`.\n *\n * @public\n */\nexport const VERSION: string = typeof IGNIFX_BUILD_VERSION === \"string\" ? IGNIFX_BUILD_VERSION : \"0.0.0\";\n","import { defineExtension, Phase } from \"@ignifx/core\";\nimport { createParticleLoader } from \"./assets/loader.js\";\nimport { defineParticlesAppProperty } from \"./augmentation.js\";\nimport { PARTICLES_ERROR_MESSAGES, ParticlesErrorCode, particlesError } from \"./errors.js\";\nimport { PARTICLE_RENDER_ORDER, PARTICLE_UPDATE_ORDER, ParticleSystem } from \"./gpu/particle-system.js\";\nimport { ParticleRenderSystem, ParticleUpdateSystem } from \"./gpu/particle-systems.js\";\nimport {\n PARTICLES_DIAGNOSTICS_COUNTERS,\n PARTICLES_DIAGNOSTICS_GROUP,\n ParticlesService,\n} from \"./service/particles-service.js\";\nimport { defaultParticlesSettings, PARTICLES_SETTINGS_SECTION, particlesSettingsSchema } from \"./settings.js\";\nimport { VERSION } from \"./version.js\";\nimport type { ParticlesSettings } from \"./settings.js\";\nimport type { App, Extension, ExtensionContext, Vec3Like } from \"@ignifx/core\";\n\n// The `@ignifx/particles` extension (`docs/architecture/04-extensions.md` §1). It requires nothing\n// but core: `@ignifx/physics` is read by data, through the `physics` settings section, so an effect\n// that says \"use the world's gravity\" agrees with the rigidbodies around it without a dependency.\n\n/**\n * What `particles()` accepts. Every field overrides the matching `particles` settings section value.\n *\n * @public\n */\nexport interface ParticlesOptions {\n /** The particle budget every system's capacity is counted against. */\n readonly maxParticles?: number;\n /** A `0`–`1` multiplier on every emission rate and burst count. */\n readonly qualityScale?: number;\n /** The world gravity a `gravityMultiplier` scales. */\n readonly gravity?: Vec3Like;\n}\n\n/** The shape of the `physics` settings section this package reads by data. */\ninterface PhysicsGravitySection {\n readonly gravity?: Vec3Like;\n}\n\n/**\n * Merges the extension's options over the resolved settings section.\n *\n * @param settings - The resolved `particles` section.\n * @param options - What the game passed to `particles(...)`.\n * @returns The effective settings.\n */\nfunction mergeSettings(settings: ParticlesSettings, options: ParticlesOptions): ParticlesSettings {\n return {\n maxParticles: options.maxParticles ?? settings.maxParticles,\n qualityScale: options.qualityScale ?? settings.qualityScale,\n gravity: options.gravity ?? settings.gravity,\n };\n}\n\n/**\n * Whether two gravity vectors are the same.\n *\n * @param a - One vector.\n * @param b - The other.\n * @returns `true` when every component matches.\n */\nfunction sameGravity(a: Vec3Like, b: Vec3Like): boolean {\n return a.x === b.x && a.y === b.y && a.z === b.z;\n}\n\n/**\n * Registers everything the package contributes.\n *\n * @param ctx - The registration surface.\n * @param options - What the game passed to `particles(...)`.\n * @returns The service, for `onStart`.\n */\nfunction registerParticles(ctx: ExtensionContext, options: ParticlesOptions): ParticlesService {\n if (ctx.tryGet(ParticlesService) !== null) {\n throw particlesError(\n ParticlesErrorCode.duplicateExtension,\n \"The particles() extension is already registered on this app.\",\n );\n }\n ctx.registerErrorCodes(PARTICLES_ERROR_MESSAGES);\n ctx.registerSettings<ParticlesSettings>(\n PARTICLES_SETTINGS_SECTION,\n particlesSettingsSchema(),\n defaultParticlesSettings(),\n );\n const settings = mergeSettings(ctx.settings<ParticlesSettings>(PARTICLES_SETTINGS_SECTION), options);\n const service = new ParticlesService(ctx.app, settings);\n service.setCounters(ctx.app.diagnostics.registerGroup(PARTICLES_DIAGNOSTICS_GROUP, PARTICLES_DIAGNOSTICS_COUNTERS));\n ctx.registerService(ParticlesService, service);\n defineParticlesAppProperty(ctx, service);\n ctx.registerAssetLoader(createParticleLoader());\n ctx.registerComponents([ParticleSystem]);\n // Held in edit mode: a system still starts and shows its first frame, but its clock stands still (ADR-0028).\n ctx.registerSystem(new ParticleUpdateSystem(service), {\n phase: Phase.Update,\n order: PARTICLE_UPDATE_ORDER,\n editMode: \"hold\",\n });\n ctx.registerSystem(new ParticleRenderSystem(service), { phase: Phase.PreRender, order: PARTICLE_RENDER_ORDER });\n ctx.onDispose((): void => {\n service.dispose();\n });\n return service;\n}\n\n/**\n * Adopts the physics gravity when the project left the particles gravity alone and `@ignifx/physics`\n * registered a section.\n *\n * @param app - The app being started.\n * @param service - The service to write into.\n * @param options - The extension options, which win over both sections.\n */\nfunction adoptPhysicsGravity(app: App, service: ParticlesService, options: ParticlesOptions): void {\n if (options.gravity !== undefined) {\n return;\n }\n const section = app.settings.section<ParticlesSettings>(PARTICLES_SETTINGS_SECTION);\n if (!sameGravity(section.gravity, defaultParticlesSettings().gravity)) {\n return;\n }\n let physics: PhysicsGravitySection | null;\n try {\n physics = app.settings.section<PhysicsGravitySection>(\"physics\");\n } catch {\n // `IGX-0407`: no physics extension is registered, which is the ordinary case for a particles-only app.\n physics = null;\n }\n const gravity = physics?.gravity;\n if (gravity !== undefined) {\n service.gravity = gravity;\n }\n}\n\n/**\n * The `@ignifx/particles` extension factory.\n *\n * @param options - Overrides for the `particles` settings section.\n * @returns The extension descriptor to pass to `createApp`.\n *\n * @example\n * ```ts\n * const app = await createApp({ canvas, extensions: [particles({ maxParticles: 50_000 })] });\n * ```\n *\n * @public\n */\nexport const particles: (options?: ParticlesOptions) => Extension = defineExtension<ParticlesOptions | undefined>(\n (raw) => {\n // `defineExtension` hands the factory whatever the caller passed, which is `undefined` when the\n // game wrote `particles()`; the typed signature cannot express that, so the default lands here.\n const options: ParticlesOptions = raw ?? {};\n let service: ParticlesService | null = null;\n return {\n name: \"@ignifx/particles\",\n version: VERSION,\n engine: \">=0.0.0 <1.0.0\",\n requires: [\"@ignifx/core\"],\n optional: [\"@ignifx/physics\"],\n register(ctx: ExtensionContext): void {\n service = registerParticles(ctx, options);\n },\n onStart(app: App): void {\n if (service !== null) {\n adoptPhysicsGravity(app, service, options);\n }\n },\n };\n },\n);\n","import { array, bool, custom, enumOf, f32, i32, record, str, u32, vec2, vec3 } from \"@ignifx/core\";\nimport {\n PARTICLE_BLEND_MODES,\n PARTICLE_EMIT_FROM,\n PARTICLE_MESHES,\n PARTICLE_RENDER_MODES,\n PARTICLE_SHAPE_KINDS,\n PARTICLE_SIMULATION_SPACES,\n PARTICLES_FORMAT,\n PARTICLES_FORMAT_VERSION,\n} from \"./definition/types.js\";\nimport type { FieldDefinition, JsonValue, Schema } from \"@ignifx/core\";\n\n// The declarative schema for `.particles.json`, for documentation and tooling only: the loader\n// validates with `defineParticles`, whose hand-written checks name the offending path. The \"value\"\n// unions have no built-in field kind, so they are `custom()` fields carrying a JSON Schema fragment.\n\n/** The JSON Schema fragment of a scalar value. */\nconst SCALAR_JSON_SCHEMA = {\n oneOf: [\n { type: \"number\" },\n {\n type: \"object\",\n properties: { min: { type: \"number\" }, max: { type: \"number\" } },\n required: [\"min\", \"max\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n curve: {\n type: \"object\",\n properties: {\n keys: {\n type: \"array\",\n items: { type: \"array\", items: { type: \"number\" }, minItems: 4, maxItems: 4 },\n minItems: 1,\n },\n },\n required: [\"keys\"],\n },\n },\n required: [\"curve\"],\n additionalProperties: false,\n },\n ],\n};\n\n/** The JSON Schema fragment of a colour. */\nconst COLOR_JSON_SCHEMA = {\n oneOf: [\n { type: \"array\", items: { type: \"number\" }, minItems: 3, maxItems: 4 },\n {\n type: \"object\",\n properties: { r: { type: \"number\" }, g: { type: \"number\" }, b: { type: \"number\" }, a: { type: \"number\" } },\n required: [\"r\", \"g\", \"b\"],\n },\n ],\n};\n\n/** The JSON Schema fragment of a colour value. */\nconst COLOR_VALUE_JSON_SCHEMA = {\n oneOf: [\n ...COLOR_JSON_SCHEMA.oneOf,\n {\n type: \"object\",\n properties: { min: COLOR_JSON_SCHEMA, max: COLOR_JSON_SCHEMA },\n required: [\"min\", \"max\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n gradient: {\n type: \"array\",\n items: { type: \"array\", items: { type: \"number\" }, minItems: 5, maxItems: 5 },\n minItems: 1,\n },\n },\n required: [\"gradient\"],\n additionalProperties: false,\n },\n ],\n};\n\n/**\n * A scalar value field: a number, a range, or a curve.\n *\n * @param defaultValue - The document default.\n * @param tooltip - What the value means.\n * @returns The field definition.\n */\nfunction scalarValue(defaultValue: JsonValue, tooltip: string): FieldDefinition<JsonValue> {\n return custom<JsonValue>(\n {\n createDefault: (): JsonValue => structuredClone(defaultValue),\n serialize: (value: JsonValue): JsonValue => value,\n deserialize: (json: JsonValue): JsonValue => json,\n jsonSchema: SCALAR_JSON_SCHEMA,\n },\n { tooltip },\n );\n}\n\n/**\n * A colour value field: a colour, a pair, or a gradient.\n *\n * @param defaultValue - The document default.\n * @param tooltip - What the value means.\n * @returns The field definition.\n */\nfunction colorValue(defaultValue: JsonValue, tooltip: string): FieldDefinition<JsonValue> {\n return custom<JsonValue>(\n {\n createDefault: (): JsonValue => structuredClone(defaultValue),\n serialize: (value: JsonValue): JsonValue => value,\n deserialize: (json: JsonValue): JsonValue => json,\n jsonSchema: COLOR_VALUE_JSON_SCHEMA,\n },\n { tooltip },\n );\n}\n\n/**\n * The `ignifx.particles` document schema.\n *\n * @returns The schema, built fresh so no module holds state (`CONSTITUTION.md` §3.5).\n *\n * @public\n */\nexport function particlesFileSchema(): Schema {\n // Not `defineSchema`: it refuses a field called `start` because a component schema becomes class\n // properties and `Script.start` already exists (`IGX-0607`). A file schema generates no class, and\n // `start` is the module name the format uses, so the check does not apply here.\n return {\n format: str(PARTICLES_FORMAT, { tooltip: \"Always ignifx.particles.\" }),\n formatVersion: u32(PARTICLES_FORMAT_VERSION, { tooltip: \"The document version this build reads.\" }),\n main: record(\n {\n capacity: u32(1000, {\n min: 1,\n tooltip: \"How many spawn records the ring holds; older records are overwritten.\",\n }),\n duration: f32(5, { min: 0.001, tooltip: \"How long one emission cycle lasts, in seconds.\" }),\n looping: bool(true, { tooltip: \"Whether the cycle repeats.\" }),\n prewarm: bool(false, { tooltip: \"Whether play() fast-forwards one cycle first.\" }),\n startDelay: f32(0, { min: 0, tooltip: \"Seconds after play() before emission starts.\" }),\n simulationSpace: enumOf(PARTICLE_SIMULATION_SPACES, \"local\", {\n tooltip: \"local follows the entity; world stays put.\",\n }),\n seed: u32(0, { tooltip: \"The emission seed; 0 picks one at random.\" }),\n playOnAwake: bool(true, { tooltip: \"Whether a ParticleSystem starts playing when enabled.\" }),\n timeScale: f32(1, { min: 0, tooltip: \"A multiplier on the system's own clock.\" }),\n renderOrder: i32(0, { tooltip: \"Sort key within the transparent phase; lower draws first.\" }),\n },\n { tooltip: \"Capacity, timing, space, and playback.\" },\n ),\n emission: record(\n {\n rateOverTime: f32(10, { min: 0, tooltip: \"Particles per second.\" }),\n rateOverDistance: f32(0, { min: 0, tooltip: \"Particles per metre the emitter moves.\" }),\n bursts: array(\n record({\n time: f32(0, { min: 0, tooltip: \"Seconds into the cycle.\" }),\n count: scalarValue(10, \"How many particles; a range is rolled per firing.\"),\n cycles: u32(1, { tooltip: \"Firings per cycle; 0 means until the cycle ends.\" }),\n interval: f32(0.1, { min: 0, tooltip: \"Seconds between firings.\" }),\n probability: f32(1, { min: 0, max: 1, tooltip: \"The chance a firing happens.\" }),\n }),\n [],\n { tooltip: \"The bursts, in order.\" },\n ),\n },\n { tooltip: \"Rates and bursts.\" },\n ),\n shape: record(\n {\n kind: enumOf(PARTICLE_SHAPE_KINDS, \"cone\", { tooltip: \"Which shape; directional shapes emit along local +Y.\" }),\n radius: f32(0.2, { min: 0, tooltip: \"Sphere, hemisphere, circle, or cone-base radius.\" }),\n thickness: f32(1, { min: 0, max: 1, tooltip: \"How much of the radius emits: 0 is the surface, 1 the whole.\" }),\n arc: f32(360, { min: 0, max: 360, tooltip: \"The angular span, in degrees.\" }),\n angle: f32(25, { min: 0, max: 90, tooltip: \"A cone's half-angle, in degrees.\" }),\n length: f32(1, { min: 0, tooltip: \"A cone's height, or an edge's length.\" }),\n size: vec3({ x: 1, y: 1, z: 1 }, { tooltip: \"A box's full extents.\" }),\n emitFrom: enumOf(PARTICLE_EMIT_FROM, \"volume\", { tooltip: \"volume, shell, or a cone's base.\" }),\n randomDirection: f32(0, { min: 0, max: 1, tooltip: \"How much of the start direction is random.\" }),\n spherizeDirection: f32(0, {\n min: 0,\n max: 1,\n tooltip: \"How much the start direction points away from the centre.\",\n }),\n vertices: array(f32(), [], { tooltip: \"A mesh shape's triangles, nine numbers per triangle.\" }),\n },\n { tooltip: \"Where particles start and which way they go.\" },\n ),\n start: record(\n {\n lifetime: scalarValue(2, \"Seconds a particle lives.\"),\n speed: scalarValue(2, \"Metres per second along the start direction.\"),\n size: scalarValue(0.2, \"The particle's size, in metres.\"),\n size3D: vec3({ x: 1, y: 1, z: 1 }, { tooltip: \"Optional per-axis size multipliers.\" }),\n rotation: scalarValue(0, \"The start rotation, in degrees.\"),\n color: colorValue([1, 1, 1, 1], \"The start colour, sRGB; a range picks between two per particle.\"),\n },\n { tooltip: \"What a particle is born with.\" },\n ),\n forces: record(\n {\n gravity: vec3({ x: 0, y: 0, z: 0 }, { tooltip: \"An explicit world gravity; omit to scale the app's.\" }),\n gravityMultiplier: f32(0, { tooltip: \"How much of the app's gravity applies.\" }),\n drag: f32(0, { min: 0, tooltip: \"Linear drag; 0 is none.\" }),\n constantForce: vec3({ x: 0, y: 0, z: 0 }, { tooltip: \"A constant acceleration in simulation space, m/s^2.\" }),\n orbit: record(\n {\n axis: vec3({ x: 0, y: 1, z: 0 }, { tooltip: \"The orbit axis.\" }),\n speed: f32(90, { tooltip: \"Degrees per second.\" }),\n },\n { tooltip: \"A rotation about an axis through the emitter.\" },\n ),\n noise: record(\n {\n strength: f32(0.5, { min: 0, tooltip: \"The largest offset, in metres.\" }),\n frequency: f32(1, { min: 0, tooltip: \"How quickly the field varies with position.\" }),\n scroll: vec3({ x: 0, y: 0, z: 0 }, { tooltip: \"How the field drifts with time.\" }),\n octaves: u32(1, { min: 1, max: 2, tooltip: \"How many octaves are summed.\" }),\n influenceOverLife: scalarValue(1, \"A multiplier on strength over the particle's life.\"),\n },\n { tooltip: \"A positional noise offset.\" },\n ),\n },\n { tooltip: \"What acts on a particle.\" },\n ),\n overLifetime: record(\n {\n color: colorValue([1, 1, 1, 1], \"A gradient multiplied onto the start colour over life.\"),\n size: scalarValue(1, \"A multiplier on the start size over life (X when sizeY or sizeZ is set).\"),\n sizeY: scalarValue(1, \"A separate Y multiplier over life.\"),\n sizeZ: scalarValue(1, \"A separate Z multiplier over life.\"),\n rotation: scalarValue(0, \"Angular speed in degrees per second.\"),\n },\n { tooltip: \"How a particle changes over its life.\" },\n ),\n renderer: record(\n {\n mode: enumOf(PARTICLE_RENDER_MODES, \"billboard\", { tooltip: \"How particles are oriented.\" }),\n mesh: enumOf(PARTICLE_MESHES, \"box\", { tooltip: \"The primitive a mesh renderer draws.\" }),\n texture: str(\"\", { tooltip: \"The texture's asset address, or omitted for a procedural soft disc.\" }),\n sheet: record(\n {\n tiles: vec2({ x: 1, y: 1 }, { tooltip: \"Columns and rows of the sprite sheet.\" }),\n frameOverTime: scalarValue(0, 'A curve over life, the string \"random\", or { fps }.'),\n },\n { tooltip: \"The sprite-sheet layout of the texture.\" },\n ),\n blend: enumOf(PARTICLE_BLEND_MODES, \"premultiplied\", { tooltip: \"How particles composite.\" }),\n lit: bool(false, { tooltip: \"Shade with the main light and the ambient colour.\" }),\n pivot: vec2({ x: 0, y: 0 }, { tooltip: \"Where the origin sits inside the quad, in size units.\" }),\n speedScale: f32(0, { min: 0, tooltip: \"How much of the speed a stretched particle adds to its length.\" }),\n lengthScale: f32(1, { min: 0, tooltip: \"A multiplier on a stretched particle's length.\" }),\n },\n { tooltip: \"How a particle is drawn.\" },\n ),\n };\n}\n","import { describeSchema } from \"@ignifx/core\";\nimport { PARTICLES_FORMAT } from \"./definition/types.js\";\nimport { particlesFileSchema } from \"./file-schemas.js\";\nimport { ParticleSystem } from \"./gpu/particle-system.js\";\nimport { particlesSettingsSchema } from \"./settings.js\";\nimport type { SchemaDescription } from \"@ignifx/core\";\n\n// What `pnpm docs:schemas` reads (`docs/architecture/16-docs-harness-and-skill.md` §3). These are\n// functions rather than a `schemas` object because building the record calls `describeSchema`, and\n// module scope holds declarations only (`CONSTITUTION.md` §3.5).\n\n/**\n * Describes the `ignifx.particles` file format.\n *\n * @returns The record `pnpm docs:schemas` renders.\n *\n * @public\n */\nexport function describeParticlesFormat(): SchemaDescription {\n return describeSchema(\"ignifx/particles-file\", particlesFileSchema(), {\n title: \"Particles\",\n format: PARTICLES_FORMAT,\n description:\n \"A stateless GPU particle effect: capacity and timing, emission rates and bursts, an emitter shape, start values, forces, over-lifetime curves, and the renderer.\",\n });\n}\n\n/**\n * Describes every component and settings section this package registers.\n *\n * @returns The record `pnpm docs:schemas` renders, keyed by schema id.\n *\n * @public\n */\nexport function describeSchemas(): Readonly<Record<string, SchemaDescription>> {\n return Object.freeze({\n \"ignifx/ParticleSystem\": describeSchema(\"ignifx/ParticleSystem\", ParticleSystem.schema, {\n title: ParticleSystem.title,\n }),\n \"ignifx/particles-settings\": describeSchema(\"ignifx/particles-settings\", particlesSettingsSchema(), {\n title: \"Particles settings\",\n description: \"The particles project settings section.\",\n }),\n \"ignifx/particles-file\": describeParticlesFormat(),\n });\n}\n"],"mappings":";;;;;;;;;;;AA0BA,SAAgB,2BAA2B,KAAuB,SAAiC;CACjG,IAAI,kBAAkB,mBAA4B,OAAO;AAC3D;;;;;;;;ACjBA,MAAa,mBAAmB;;;;;;AAOhC,MAAa,2BAA2B;;;;;;AAOxC,MAAa,sBAAsB;;;;;;AAOnC,MAAa,2BAA8C,OAAO,OAAO,CAAC,iBAAiB,CAAC;;;;;;;AAQ5F,MAAa,iBAAiB;;;;;;;;AAS9B,MAAa,6BAA6B,CAAC,SAAS,OAAO;;;;;;AAc3D,MAAa,uBAAuB;CAAC;CAAS;CAAU;CAAc;CAAQ;CAAO;CAAU;CAAQ;AAAM;;;;;;;AAe7G,MAAa,qBAAqB;CAAC;CAAU;CAAS;AAAM;;;;;;AAc5D,MAAa,wBAAwB;CAAC;CAAa;CAAa;CAAc;CAAY;AAAM;;;;;;;AAehG,MAAa,uBAAuB;CAAC;CAAiB;CAAY;AAAO;;;;;;AAczE,MAAa,kBAAkB;CAAC;CAAO;CAAU;CAAS;CAAY;CAAW;AAAO;;;;;;;AAexF,MAAa,uBAAuB;CAAC;CAAS;CAAU;AAAK;;;;;;;;;;;;;;;ACpH7D,IAAa,gBAAb,MAA2B;;CAEzB,OAAO,YAAoB;;CAG3B;;CAGA;;CAGA;CAEA;;;;;;;;;;;;CAaA,YACE,SACA,YACA,UAA4C,MAC5C,cAAuB,OACvB;EACA,KAAK,UAAU;EACf,KAAK,aAAa;EAClB,KAAK,UAAU;EACf,KAAK,eAAe;CACtB;;;;;CAMA,UAAgB;EACd,IAAI,KAAK,cACP,KAAK,SAAS,QAAQ;CAE1B;AACF;;;;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P,QAAQ;EACR,aACE;CACJ,CAAC;AACH;;;;;;;;AASA,SAAgB,kBAA+D;CAC7E,OAAO,OAAO,OAAO;EACnB,yBAAyB,eAAe,yBAAyB,eAAe,QAAQ,EACtF,OAAO,eAAe,MACxB,CAAC;EACD,6BAA6B,eAAe,6BAA6B,wBAAwB,GAAG;GAClG,OAAO;GACP,aAAa;EACf,CAAC;EACD,yBAAyB,wBAAwB;CACnD,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["TEXEL_BYTES","DEG_TO_RAD","DEG_TO_RAD","f32","vec3"],"sources":["../src/augmentation.ts","../src/definition/types.ts","../src/assets/particle-asset.ts","../src/errors.ts","../src/definition/values.ts","../src/definition/define-particles.ts","../src/assets/loader.ts","../src/definition/presets/dust.ts","../src/definition/presets/explosion.ts","../src/definition/presets/fire.ts","../src/definition/presets/leaves.ts","../src/definition/presets/rain.ts","../src/definition/presets/smoke.ts","../src/definition/presets/snow.ts","../src/definition/presets/sparkle.ts","../src/definition/presets/sparks.ts","../src/definition/presets/index.ts","../src/emitter/pcg3d.ts","../src/emitter/record-ring.ts","../src/evaluate/noise.ts","../src/evaluate/particle-math.ts","../src/emitter/shapes.ts","../src/emitter/emitter-core.ts","../src/gpu/wgsl.ts","../src/service/particles-service.ts","../src/gpu/particle-system.ts","../src/gpu/particle-systems.ts","../src/settings.ts","../src/version.ts","../src/extension.ts","../src/file-schemas.ts","../src/schemas.ts"],"sourcesContent":["import type { ParticlesService } from \"./service/particles-service.js\";\nimport type { ExtensionContext } from \"@ignifx/core\";\n\n// Declaration merging is what types `app.particles`. The module must import something from\n// `@ignifx/core` or the `declare module` block is `TS2664`, and the barrel must keep its bare\n// `import \"./augmentation.js\"` so declaration bundling does not drop it.\n\ndeclare module \"@ignifx/core\" {\n interface App {\n /**\n * Particles: the budget, the quality multiplier, the gravity, the counters, and the live list\n * of `ParticleSystem` components.\n */\n readonly particles: ParticlesService;\n }\n}\n\n/**\n * Defines `app.particles`, pairing with the augmentation above.\n *\n * @param ctx - The extension registration surface.\n * @param service - The service the property returns.\n * @throws IgnifxError with code `IGX-0401` when something already defined `app.particles`.\n *\n * @internal\n */\nexport function defineParticlesAppProperty(ctx: ExtensionContext, service: ParticlesService): void {\n ctx.defineAppProperty(\"particles\", (): unknown => service);\n}\n","import type { ColorLike, CurveValue, Vec2Like, Vec3Like } from \"@ignifx/core\";\n\n// The `ignifx.particles` document as `defineParticles` hands it back: every module present, every\n// default filled in, every curve and gradient baked. It is pure data, and both evaluators read it.\n\n/**\n * The `format` discriminator every `.particles.json` document carries.\n *\n * @public\n */\nexport const PARTICLES_FORMAT = \"ignifx.particles\";\n\n/**\n * The document version this build reads and writes.\n *\n * @public\n */\nexport const PARTICLES_FORMAT_VERSION = 1;\n\n/**\n * The asset type name the loader registers.\n *\n * @public\n */\nexport const PARTICLE_ASSET_TYPE = \"particles\";\n\n/**\n * The address suffixes that select the particle loader.\n *\n * @public\n */\nexport const PARTICLE_FILE_EXTENSIONS: readonly string[] = Object.freeze([\".particles.json\"]);\n\n/**\n * How many samples a baked curve or gradient row holds. Both evaluators read the same 64 samples\n * with the same linear rule, which is what makes the lookup the contract between them.\n *\n * @public\n */\nexport const LOOKUP_SAMPLES = 64;\n\n/**\n * Where a particle's position is integrated: in the emitter's space and transformed by the emitter's\n * current world matrix at draw (`\"local\"`, so the effect follows its entity), or baked into world\n * space at spawn (`\"world\"`, so a trail stays where it was emitted).\n *\n * @public\n */\nexport const PARTICLE_SIMULATION_SPACES = [\"local\", \"world\"] as const;\n\n/**\n * The union of {@link PARTICLE_SIMULATION_SPACES}.\n *\n * @public\n */\nexport type ParticleSimulationSpace = (typeof PARTICLE_SIMULATION_SPACES)[number];\n\n/**\n * Every emitter shape. Directional shapes emit along the emitter's local `+Y`.\n *\n * @public\n */\nexport const PARTICLE_SHAPE_KINDS = [\"point\", \"sphere\", \"hemisphere\", \"cone\", \"box\", \"circle\", \"edge\", \"mesh\"] as const;\n\n/**\n * The union of {@link PARTICLE_SHAPE_KINDS}.\n *\n * @public\n */\nexport type ParticleShapeKind = (typeof PARTICLE_SHAPE_KINDS)[number];\n\n/**\n * Where inside a shape particles start: anywhere in it, on its surface, or — for a cone — on its\n * base disc.\n *\n * @public\n */\nexport const PARTICLE_EMIT_FROM = [\"volume\", \"shell\", \"base\"] as const;\n\n/**\n * The union of {@link PARTICLE_EMIT_FROM}.\n *\n * @public\n */\nexport type ParticleEmitFrom = (typeof PARTICLE_EMIT_FROM)[number];\n\n/**\n * How a particle is oriented when drawn.\n *\n * @public\n */\nexport const PARTICLE_RENDER_MODES = [\"billboard\", \"stretched\", \"horizontal\", \"vertical\", \"mesh\"] as const;\n\n/**\n * The union of {@link PARTICLE_RENDER_MODES}.\n *\n * @public\n */\nexport type ParticleRenderMode = (typeof PARTICLE_RENDER_MODES)[number];\n\n/**\n * How particles composite over what is behind them. `premultiplied` is the default: fire and smoke\n * share one draw and blend front-to-back correctly.\n *\n * @public\n */\nexport const PARTICLE_BLEND_MODES = [\"premultiplied\", \"additive\", \"alpha\"] as const;\n\n/**\n * The union of {@link PARTICLE_BLEND_MODES}.\n *\n * @public\n */\nexport type ParticleBlendMode = (typeof PARTICLE_BLEND_MODES)[number];\n\n/**\n * The core primitives a `\"mesh\"` renderer may draw, each built at unit size.\n *\n * @public\n */\nexport const PARTICLE_MESHES = [\"box\", \"sphere\", \"plane\", \"cylinder\", \"capsule\", \"torus\"] as const;\n\n/**\n * The union of {@link PARTICLE_MESHES}.\n *\n * @public\n */\nexport type ParticleMeshName = (typeof PARTICLE_MESHES)[number];\n\n/**\n * How a sprite sheet picks its frame: from a curve over the particle's life, at random per particle,\n * or advancing at a fixed rate.\n *\n * @public\n */\nexport const PARTICLE_FRAME_MODES = [\"curve\", \"random\", \"fps\"] as const;\n\n/**\n * The union of {@link PARTICLE_FRAME_MODES}.\n *\n * @public\n */\nexport type ParticleFrameMode = (typeof PARTICLE_FRAME_MODES)[number];\n\n/**\n * One stop of a colour gradient: normalized time, then sRGB red, green, blue, and alpha in `0`–`1`.\n *\n * @public\n */\nexport type GradientStop = readonly [t: number, r: number, g: number, b: number, a: number];\n\n/**\n * A number a document may give as a constant, a range, or a curve. As authored:\n * `2`, `{ \"min\": 1, \"max\": 3 }`, or `{ \"curve\": { \"keys\": [[0, 1, 0, 0], [1, 0, 0, 0]] } }`.\n *\n * @public\n */\nexport type ScalarValueInput = number | { readonly min: number; readonly max: number } | { readonly curve: CurveValue };\n\n/**\n * A colour as a document may write it: an `{ r, g, b, a }` object or an `[r, g, b, a]` array, both\n * sRGB in `0`–`1`.\n *\n * @public\n */\nexport type ColorInput = ColorLike | readonly [r: number, g: number, b: number, a: number];\n\n/**\n * A colour a document may give as a constant, a random pick between two, or a gradient.\n *\n * @public\n */\nexport type ColorValueInput =\n | ColorInput\n | { readonly min: ColorInput; readonly max: ColorInput }\n | { readonly gradient: readonly GradientStop[] };\n\n/**\n * A resolved scalar value. A `\"curve\"` carries its {@link LOOKUP_SAMPLES} baked samples so the CPU\n * side never re-evaluates the Hermite spline.\n *\n * @public\n */\nexport type ScalarValue =\n | { readonly kind: \"constant\"; readonly value: number }\n | { readonly kind: \"random\"; readonly min: number; readonly max: number }\n | { readonly kind: \"curve\"; readonly curve: CurveValue; readonly samples: Float32Array };\n\n/**\n * A resolved colour value. A `\"gradient\"` carries its baked RGBA samples, sRGB, four floats per\n * sample.\n *\n * @public\n */\nexport type ColorValue =\n | { readonly kind: \"constant\"; readonly value: ColorLike }\n | { readonly kind: \"random\"; readonly min: ColorLike; readonly max: ColorLike }\n | { readonly kind: \"gradient\"; readonly stops: readonly GradientStop[]; readonly samples: Float32Array };\n\n/**\n * The `main` module: capacity, timing, space, and playback.\n *\n * @public\n */\nexport interface ParticleMain {\n /** How many spawn records the ring holds. Older records are overwritten, alive or not. */\n readonly capacity: number;\n /** How long one emission cycle lasts, in seconds. */\n readonly duration: number;\n /** Whether the cycle repeats. A non-looping system stops when the cycle ends and the last particle dies. */\n readonly looping: boolean;\n /** Whether `play()` fast-forwards one full cycle first, so a looping effect starts steady. */\n readonly prewarm: boolean;\n /** Seconds after `play()` before emission starts. */\n readonly startDelay: number;\n /** Where positions live. */\n readonly simulationSpace: ParticleSimulationSpace;\n /** The emission seed; `0` picks one at random on `play()`. A component's `seed` field overrides it. */\n readonly seed: number;\n /** Whether a `ParticleSystem` starts playing the first frame it is enabled. */\n readonly playOnAwake: boolean;\n /** A multiplier on the system's own clock. */\n readonly timeScale: number;\n /** The renderer's sort key within the transparent phase; lower draws first. */\n readonly renderOrder: number;\n}\n\n/**\n * One burst: `count` particles at `time` into the cycle, repeated `cycles` times every `interval`\n * seconds with `probability`.\n *\n * @public\n */\nexport interface ParticleBurst {\n /** Seconds into the cycle. */\n readonly time: number;\n /** How many particles; a random count is rolled per firing. */\n readonly count: ScalarValue;\n /** How many times the burst fires per cycle; `0` means until the cycle ends. */\n readonly cycles: number;\n /** Seconds between firings. */\n readonly interval: number;\n /** The chance a firing happens, `0`–`1`. */\n readonly probability: number;\n}\n\n/**\n * The `emission` module.\n *\n * @public\n */\nexport interface ParticleEmission {\n /** Particles per second while the cycle runs. */\n readonly rateOverTime: number;\n /** Particles per metre the emitter moves. */\n readonly rateOverDistance: number;\n /** The bursts, in declaration order. */\n readonly bursts: readonly ParticleBurst[];\n}\n\n/**\n * The `shape` module. Every field is present; a shape reads the ones that apply to it.\n *\n * @public\n */\nexport interface ParticleShape {\n /** Which shape. */\n readonly kind: ParticleShapeKind;\n /** The radius of a sphere, hemisphere, circle, or cone base; half the length of an edge. */\n readonly radius: number;\n /** How much of a sphere, hemisphere, or circle's radius emits, `0` (surface only) to `1` (whole). */\n readonly thickness: number;\n /** The angular span of a sphere, hemisphere, circle, or cone, in degrees. */\n readonly arc: number;\n /** A cone's half-angle in degrees. */\n readonly angle: number;\n /** A cone's height, or an edge's length. */\n readonly length: number;\n /** A box's full extents. */\n readonly size: Vec3Like;\n /** Where inside the shape particles start. */\n readonly emitFrom: ParticleEmitFrom;\n /** How much of the start direction is random, `0`–`1`. */\n readonly randomDirection: number;\n /** How much of the start direction points away from the shape's centre, `0`–`1`. */\n readonly spherizeDirection: number;\n /** A `\"mesh\"` shape's triangle soup: three floats per vertex, three vertices per triangle. */\n readonly vertices: Float32Array;\n}\n\n/**\n * The `start` module: what a particle is born with.\n *\n * @public\n */\nexport interface ParticleStart {\n /** Seconds a particle lives. */\n readonly lifetime: ScalarValue;\n /** Metres per second along the start direction. */\n readonly speed: ScalarValue;\n /** The particle's size, in metres. */\n readonly size: ScalarValue;\n /** Optional per-axis multipliers on `size`, or `null` for a uniform size. */\n readonly size3D: Vec3Like | null;\n /** The start rotation, in degrees. */\n readonly rotation: ScalarValue;\n /** The start colour, sRGB. A random value picks between two colours per particle. */\n readonly color: ColorValue;\n}\n\n/**\n * A rotation about a fixed axis through the emitter.\n *\n * @public\n */\nexport interface ParticleOrbit {\n /** The axis, normalized at definition time. */\n readonly axis: Vec3Like;\n /** Degrees per second. */\n readonly speed: number;\n}\n\n/**\n * A positional noise offset sampled at the analytic position.\n *\n * @public\n */\nexport interface ParticleNoise {\n /** The largest offset, in metres. */\n readonly strength: number;\n /** How quickly the field varies with position. */\n readonly frequency: number;\n /** How the field drifts with time, in field units per second. */\n readonly scroll: Vec3Like;\n /** How many octaves are summed, `1` or `2`. */\n readonly octaves: number;\n /** A multiplier on `strength` over the particle's life. */\n readonly influenceOverLife: ScalarValue;\n}\n\n/**\n * The `forces` module.\n *\n * @public\n */\nexport interface ParticleForces {\n /** An explicit world gravity, or `null` to use `gravityMultiplier` times the app's gravity. */\n readonly gravity: Vec3Like | null;\n /** How much of the app's gravity applies when `gravity` is `null`. */\n readonly gravityMultiplier: number;\n /** Linear drag; `0` is none. */\n readonly drag: number;\n /** A constant acceleration, in metres per second squared, folded into gravity. */\n readonly constantForce: Vec3Like;\n /** A rotation about an axis, or `null`. */\n readonly orbit: ParticleOrbit | null;\n /** A noise offset, or `null`. */\n readonly noise: ParticleNoise | null;\n}\n\n/**\n * The `overLifetime` module.\n *\n * @public\n */\nexport interface ParticleOverLifetime {\n /** A colour multiplied onto the start colour over the particle's life, or `null`. */\n readonly color: ColorValue | null;\n /** A multiplier on the start size (the X axis when `sizeY` or `sizeZ` is set), or `null`. */\n readonly size: ScalarValue | null;\n /** A separate multiplier for the Y axis, or `null` to follow `size`. */\n readonly sizeY: ScalarValue | null;\n /** A separate multiplier for the Z axis, or `null` to follow `size`. */\n readonly sizeZ: ScalarValue | null;\n /** The angular speed, in degrees per second, or `null` for none. */\n readonly rotation: ScalarValue | null;\n}\n\n/**\n * A sprite sheet laid out in a grid.\n *\n * @public\n */\nexport interface ParticleSheet {\n /** Columns and rows of the grid. */\n readonly tiles: Vec2Like;\n /** How the frame is chosen. */\n readonly mode: ParticleFrameMode;\n /** The frame over the particle's life as a fraction of the sheet, for `\"curve\"`. */\n readonly frameOverTime: ScalarValue;\n /** Frames per second, for `\"fps\"`. */\n readonly fps: number;\n}\n\n/**\n * The `renderer` module.\n *\n * @public\n */\nexport interface ParticleRenderer {\n /** How particles are oriented. */\n readonly mode: ParticleRenderMode;\n /** The primitive a `\"mesh\"` renderer draws. */\n readonly mesh: ParticleMeshName;\n /** The texture's asset address, or `null` for a procedural soft disc. */\n readonly texture: string | null;\n /** The sprite-sheet layout of `texture`, or `null` for a single image. */\n readonly sheet: ParticleSheet | null;\n /** How particles composite. */\n readonly blend: ParticleBlendMode;\n /** Whether particles are shaded with the main light and the ambient colour. */\n readonly lit: boolean;\n /** Where the particle's origin sits inside its quad, in size units; `(0, 0)` is the centre. */\n readonly pivot: Vec2Like;\n /** How much of the speed a `\"stretched\"` particle adds to its length. */\n readonly speedScale: number;\n /** A multiplier on a `\"stretched\"` particle's length. */\n readonly lengthScale: number;\n}\n\n/**\n * One row of the lookup texture: which row it is and how its bytes map back to values.\n *\n * @public\n */\nexport interface LookupRow {\n /** The row index in the texture. */\n readonly index: number;\n /** The value a byte of `0` decodes to. */\n readonly min: number;\n /** The value a byte of `255` decodes to. */\n readonly max: number;\n}\n\n/**\n * The baked lookup texture both evaluators sample: {@link LOOKUP_SAMPLES} texels wide, RGBA8, one\n * row per curve or gradient the definition uses, in the order colour, size, rotation, noise\n * influence, sheet frame. The GPU reads the bytes the CPU decodes, to the filter's precision.\n *\n * @public\n */\nexport interface ParticleLookup {\n /** How many rows the texture has; at least `1`. */\n readonly rows: number;\n /** The texels, `rows * LOOKUP_SAMPLES * 4` bytes, top row first. */\n readonly pixels: Uint8Array;\n /** The colour-over-life gradient row, or `null`. */\n readonly color: LookupRow | null;\n /** The size-over-life row, or `null`. Per-axis sizes use R, G, and B. */\n readonly size: LookupRow | null;\n /** The angular-speed-over-life row, or `null`. */\n readonly rotation: LookupRow | null;\n /** The noise-influence-over-life row, or `null`. */\n readonly noise: LookupRow | null;\n /** The frame-over-life row, or `null`. */\n readonly frame: LookupRow | null;\n}\n\n/**\n * The parsed and baked `.particles.json` document.\n *\n * @public\n */\nexport interface ParticleDefinition {\n /** Always `\"ignifx.particles\"`. */\n readonly format: typeof PARTICLES_FORMAT;\n /** Always `1` in this build. */\n readonly formatVersion: number;\n /** Capacity, timing, space, and playback. */\n readonly main: ParticleMain;\n /** Rates and bursts. */\n readonly emission: ParticleEmission;\n /** Where particles start and which way they go. */\n readonly shape: ParticleShape;\n /** What a particle is born with. */\n readonly start: ParticleStart;\n /** What acts on it. */\n readonly forces: ParticleForces;\n /** How it changes over its life. */\n readonly overLifetime: ParticleOverLifetime;\n /** How it is drawn. */\n readonly renderer: ParticleRenderer;\n /** The baked lookup texture. */\n readonly lookup: ParticleLookup;\n}\n\n/**\n * What {@link defineParticles} accepts: the document as authored, every key optional. Unknown keys\n * are reported, because a misspelled module silently doing nothing is the worst outcome for an\n * effect file.\n *\n * @public\n */\nexport interface ParticleDefinitionInput {\n /** Always `\"ignifx.particles\"` when present. */\n readonly format?: string;\n /** The document version. */\n readonly formatVersion?: number;\n /** The `main` module. */\n readonly main?: ParticleMainInput;\n /** The `emission` module. */\n readonly emission?: ParticleEmissionInput;\n /** The `shape` module. */\n readonly shape?: ParticleShapeInput;\n /** The `start` module. */\n readonly start?: ParticleStartInput;\n /** The `forces` module. */\n readonly forces?: ParticleForcesInput;\n /** The `overLifetime` module. */\n readonly overLifetime?: ParticleOverLifetimeInput;\n /** The `renderer` module. */\n readonly renderer?: ParticleRendererInput;\n}\n\n/**\n * The `main` module as authored.\n *\n * @public\n */\nexport interface ParticleMainInput {\n /** See {@link ParticleMain.capacity}. Defaults to `1000`. */\n readonly capacity?: number;\n /** See {@link ParticleMain.duration}. Defaults to `5`. */\n readonly duration?: number;\n /** See {@link ParticleMain.looping}. Defaults to `true`. */\n readonly looping?: boolean;\n /** See {@link ParticleMain.prewarm}. Defaults to `false`. */\n readonly prewarm?: boolean;\n /** See {@link ParticleMain.startDelay}. Defaults to `0`. */\n readonly startDelay?: number;\n /** See {@link ParticleMain.simulationSpace}. Defaults to `\"local\"`. */\n readonly simulationSpace?: ParticleSimulationSpace;\n /** See {@link ParticleMain.seed}. Defaults to `0`. */\n readonly seed?: number;\n /** See {@link ParticleMain.playOnAwake}. Defaults to `true`. */\n readonly playOnAwake?: boolean;\n /** See {@link ParticleMain.timeScale}. Defaults to `1`. */\n readonly timeScale?: number;\n /** See {@link ParticleMain.renderOrder}. Defaults to `0`. */\n readonly renderOrder?: number;\n}\n\n/**\n * One burst as authored.\n *\n * @public\n */\nexport interface ParticleBurstInput {\n /** Seconds into the cycle. Defaults to `0`. */\n readonly time?: number;\n /** How many particles. Defaults to `10`. */\n readonly count?: ScalarValueInput;\n /** Firings per cycle; `0` means until the cycle ends. Defaults to `1`. */\n readonly cycles?: number;\n /** Seconds between firings. Defaults to `0.1`. */\n readonly interval?: number;\n /** The chance a firing happens. Defaults to `1`. */\n readonly probability?: number;\n}\n\n/**\n * The `emission` module as authored.\n *\n * @public\n */\nexport interface ParticleEmissionInput {\n /** Particles per second. Defaults to `10`. */\n readonly rateOverTime?: number;\n /** Particles per metre moved. Defaults to `0`. */\n readonly rateOverDistance?: number;\n /** The bursts. Defaults to none. */\n readonly bursts?: readonly ParticleBurstInput[];\n}\n\n/**\n * The `shape` module as authored.\n *\n * @public\n */\nexport interface ParticleShapeInput {\n /** Which shape. Defaults to `\"cone\"`. */\n readonly kind?: ParticleShapeKind;\n /** See {@link ParticleShape.radius}. Defaults to `0.2`. */\n readonly radius?: number;\n /** See {@link ParticleShape.thickness}. Defaults to `1`. */\n readonly thickness?: number;\n /** See {@link ParticleShape.arc}. Defaults to `360`. */\n readonly arc?: number;\n /** See {@link ParticleShape.angle}. Defaults to `25`. */\n readonly angle?: number;\n /** See {@link ParticleShape.length}. Defaults to `1`. */\n readonly length?: number;\n /** See {@link ParticleShape.size}. Defaults to `(1, 1, 1)`. */\n readonly size?: Vec3Like;\n /** See {@link ParticleShape.emitFrom}. Defaults to `\"base\"` for a cone and `\"volume\"` otherwise. */\n readonly emitFrom?: ParticleEmitFrom;\n /** See {@link ParticleShape.randomDirection}. Defaults to `0`. */\n readonly randomDirection?: number;\n /** See {@link ParticleShape.spherizeDirection}. Defaults to `0`. */\n readonly spherizeDirection?: number;\n /** A `\"mesh\"` shape's triangles, nine numbers per triangle. */\n readonly vertices?: readonly number[];\n}\n\n/**\n * The `start` module as authored.\n *\n * @public\n */\nexport interface ParticleStartInput {\n /** Defaults to `2`. */\n readonly lifetime?: ScalarValueInput;\n /** Defaults to `2`. */\n readonly speed?: ScalarValueInput;\n /** Defaults to `0.2`. */\n readonly size?: ScalarValueInput;\n /** Defaults to `null`. */\n readonly size3D?: Vec3Like | null;\n /** Defaults to `0`. */\n readonly rotation?: ScalarValueInput;\n /** Defaults to opaque white. */\n readonly color?: ColorValueInput;\n}\n\n/**\n * The `forces` module as authored.\n *\n * @public\n */\nexport interface ParticleForcesInput {\n /** An explicit gravity, or `null`/omitted to scale the app's. */\n readonly gravity?: Vec3Like | null;\n /** Defaults to `0`. */\n readonly gravityMultiplier?: number;\n /** Defaults to `0`. */\n readonly drag?: number;\n /** Defaults to `(0, 0, 0)`. */\n readonly constantForce?: Vec3Like;\n /** Defaults to none. */\n readonly orbit?: { readonly axis?: Vec3Like; readonly speed?: number } | null;\n /** Defaults to none. */\n readonly noise?: {\n readonly strength?: number;\n readonly frequency?: number;\n readonly scroll?: Vec3Like;\n readonly octaves?: number;\n readonly influenceOverLife?: ScalarValueInput;\n } | null;\n}\n\n/**\n * The `overLifetime` module as authored.\n *\n * @public\n */\nexport interface ParticleOverLifetimeInput {\n /** A gradient, or a constant tint. */\n readonly color?: ColorValueInput | null;\n /** A curve or constant multiplier. */\n readonly size?: ScalarValueInput | null;\n /** A separate Y multiplier. */\n readonly sizeY?: ScalarValueInput | null;\n /** A separate Z multiplier. */\n readonly sizeZ?: ScalarValueInput | null;\n /** Angular speed in degrees per second. */\n readonly rotation?: ScalarValueInput | null;\n}\n\n/**\n * A sprite sheet as authored.\n *\n * @public\n */\nexport interface ParticleSheetInput {\n /** Columns and rows. Defaults to `(1, 1)`. */\n readonly tiles?: Vec2Like;\n /** A curve over life, `\"random\"`, or `{ fps }`. Defaults to a linear curve over the whole sheet. */\n readonly frameOverTime?: ScalarValueInput | \"random\" | { readonly fps: number };\n}\n\n/**\n * The `renderer` module as authored.\n *\n * @public\n */\nexport interface ParticleRendererInput {\n /** Defaults to `\"billboard\"`. */\n readonly mode?: ParticleRenderMode;\n /** Defaults to `\"box\"`. */\n readonly mesh?: ParticleMeshName;\n /** Defaults to `null`. */\n readonly texture?: string | null;\n /** Defaults to `null`. */\n readonly sheet?: ParticleSheetInput | null;\n /** Defaults to `\"premultiplied\"`. */\n readonly blend?: ParticleBlendMode;\n /** Defaults to `false`. */\n readonly lit?: boolean;\n /** Defaults to `(0, 0)`. */\n readonly pivot?: Vec2Like;\n /** Defaults to `0`. */\n readonly speedScale?: number;\n /** Defaults to `1`. */\n readonly lengthScale?: number;\n}\n","import { PARTICLE_ASSET_TYPE } from \"../definition/types.js\";\nimport type { ParticleDefinition } from \"../definition/types.js\";\nimport type { AssetHandle, TextureAsset } from \"@ignifx/core\";\n\n// The loaded `.particles.json` document (`docs/architecture/05-assets-and-loading.md` §5). It owns\n// no device resources: `app.particles` builds the shader, the lookup texture and the material on\n// first use and shares them between every system playing the same asset.\n\n/**\n * A parsed particle document.\n *\n * @example\n * ```ts\n * const handle = app.assets.load<ParticleAsset>(\"fx/fire.particles.json\");\n * await handle.promise;\n * handle.value.definition.main.capacity; // 1000\n * ```\n *\n * @public\n */\nexport class ParticleAsset {\n /** The asset type name, so `assetRef` and the inspector can round-trip a reference. */\n static assetType: string = PARTICLE_ASSET_TYPE;\n\n /** Where the document was loaded from, or the `memory:` address it was published at. */\n readonly address: string;\n\n /** The parsed, baked document. */\n readonly definition: ParticleDefinition;\n\n /** The texture the renderer samples, or `null` for the procedural soft disc. */\n readonly texture: AssetHandle<TextureAsset> | null;\n\n readonly #ownsTexture: boolean;\n\n /**\n * Wraps a parsed document.\n *\n * @param address - Where it came from.\n * @param definition - The parsed document.\n * @param texture - The renderer's texture handle, or `null`.\n * @param ownsTexture - Whether {@link ParticleAsset.dispose} releases the texture handle. The\n * loader's dependency is released by the asset service; an in-memory asset holds its own.\n *\n * @internal\n */\n constructor(\n address: string,\n definition: ParticleDefinition,\n texture: AssetHandle<TextureAsset> | null = null,\n ownsTexture: boolean = false,\n ) {\n this.address = address;\n this.definition = definition;\n this.texture = texture;\n this.#ownsTexture = ownsTexture;\n }\n\n /**\n * Releases what the asset holds beyond its data. The `particles` asset type's `unload` runs it\n * when the last holder releases the handle.\n */\n dispose(): void {\n if (this.#ownsTexture) {\n this.texture?.release();\n }\n }\n}\n","import { IgnifxError } from \"@ignifx/core\";\nimport type { ErrorContext } from \"@ignifx/core\";\n\n// This package owns `IGX-1700`-`1749` (`@ignifx/particles-2d` has `1750`-`1799`;\n// `docs/architecture/15-devtools-and-diagnostics.md` §1). An extension keeps its own table and\n// hands it to the app through `ExtensionContext.registerErrorCodes`.\n\n/**\n * Every diagnostic code `@ignifx/particles` can throw or log, keyed by an intention-revealing name\n * so call sites read as prose and the compiler catches typos (coding standards §5.2).\n *\n * @example\n * ```ts\n * throw particlesError(ParticlesErrorCode.invalidParticlesFile, \"fire.particles.json declares no main.\", {\n * context: { file: \"fire.particles.json\", reason: \"main is missing\" },\n * });\n * ```\n *\n * @public\n */\nexport const ParticlesErrorCode = {\n /** A `.particles.json` document, or a `defineParticles` input, is not an `ignifx.particles` document this build can read. */\n invalidParticlesFile: \"IGX-1701\",\n /** A `ParticleSystem` asked for more capacity than the `app.particles.maxParticles` budget has left; it was clamped. */\n budgetExceeded: \"IGX-1702\",\n /** A second `particles()` extension was registered on one app. */\n duplicateExtension: \"IGX-1703\",\n /** `particleDefinition` named a preset that does not exist. */\n unknownPreset: \"IGX-1704\",\n /** A `ParticleSystem` method that needs a definition ran without one. */\n noDefinition: \"IGX-1705\",\n /** The generated particle shader failed to load or to build a material. */\n shaderFailed: \"IGX-1706\",\n /** `emit`, `simulate`, or a value argument was not a finite number in range. */\n invalidArgument: \"IGX-1707\",\n} as const;\n\n/**\n * The union of the codes the `ParticlesErrorCode` table declares.\n *\n * @public\n */\nexport type ParticlesErrorCode = (typeof ParticlesErrorCode)[keyof typeof ParticlesErrorCode];\n\n/**\n * The one-line message template of every code, as `ExtensionContext.registerErrorCodes` wants it.\n * Context keys appear in braces, matching the core table's convention.\n *\n * @public\n */\nexport const PARTICLES_ERROR_MESSAGES: Readonly<Record<string, string>> = Object.freeze({\n \"IGX-1701\": \"{file} is not an ignifx.particles document this build can read: {reason}.\",\n \"IGX-1702\":\n \"{entity} asked for {capacity} particles, but only {available} of the {budget} particle budget remain; the system was clamped.\",\n \"IGX-1703\": \"The particles() extension is already registered on this app.\",\n \"IGX-1704\": \"{preset} is not a particle preset; the presets are {presets}.\",\n \"IGX-1705\": \"{entity} has a ParticleSystem with no definition, so {method}() cannot run.\",\n \"IGX-1706\": \"The particle shader for {definition} could not be built: {message}.\",\n \"IGX-1707\": \"{method} needs {expected}, not {value}.\",\n});\n\n/**\n * Options accepted by {@link particlesError}: the same subset of `IgnifxErrorOptions` this package\n * uses.\n *\n * @public\n */\nexport interface ParticlesErrorOptions {\n /** Identifiers that locate the failure. */\n readonly context?: ErrorContext;\n /** One sentence telling the developer what to do about it. */\n readonly hint?: string;\n /** The failure being wrapped, when there is one. */\n readonly cause?: unknown;\n}\n\n/**\n * Builds an `IgnifxError` carrying one of this package's codes.\n *\n * @param code - The code from the `ParticlesErrorCode` table.\n * @param message - The actionable development sentence.\n * @param options - Context identifiers, a remedy hint, and the wrapped cause.\n * @returns The error to throw or to reject with.\n *\n * @example\n * ```ts\n * throw particlesError(ParticlesErrorCode.unknownPreset, \"lava is not a particle preset.\", {\n * context: { preset: \"lava\" },\n * });\n * ```\n *\n * @public\n */\nexport function particlesError(\n code: ParticlesErrorCode,\n message: string,\n options?: ParticlesErrorOptions,\n): IgnifxError {\n return new IgnifxError(code, message, {\n ...(options?.context === undefined ? {} : { context: options.context }),\n ...(options?.hint === undefined ? {} : { hint: options.hint }),\n ...(options?.cause === undefined ? {} : { cause: options.cause }),\n });\n}\n","import { assertNever } from \"@ignifx/core\";\nimport { LOOKUP_SAMPLES } from \"./types.js\";\nimport type { ColorValue, GradientStop, ScalarValue } from \"./types.js\";\nimport type { ColorLike, CurveKey, CurveValue } from \"@ignifx/core\";\n\n// Hermite curves, gradients, and the 64-sample lookup rows both evaluators read\n// (ADR-0025). The baking functions run once inside `defineParticles`; the sampling functions read\n// preallocated rows through `out` parameters.\n\n/** Floats per colour sample. */\nconst COLOR_FLOATS = 4;\n\n/**\n * Evaluates a cubic Hermite curve at `t`, clamping to the end keys outside the key range\n * (`docs/architecture/06-serialization-and-scene-format.md` §3: keys are\n * `[time, value, inTangent, outTangent]`).\n *\n * @param curve - The curve; its keys must be sorted by time and non-empty.\n * @param t - Where to evaluate.\n * @returns The value; `0` for a curve with no keys.\n *\n * @public\n */\nexport function evaluateCurve(curve: CurveValue, t: number): number {\n const keys = curve.keys;\n const count = keys.length;\n const first = keys[0];\n if (first === undefined) {\n return 0;\n }\n if (t <= first[0]) {\n return first[1];\n }\n const last = keys[count - 1];\n if (last === undefined || t >= last[0]) {\n return last?.[1] ?? first[1];\n }\n let index = 1;\n while (index < count) {\n const key = keys[index];\n if (key !== undefined && key[0] >= t) {\n break;\n }\n index += 1;\n }\n const k0 = keys[index - 1];\n const k1 = keys[index];\n if (k0 === undefined || k1 === undefined) {\n return first[1];\n }\n return hermite(k0, k1, t);\n}\n\n/**\n * Interpolates between two keys.\n *\n * @param k0 - The key before `t`.\n * @param k1 - The key after `t`.\n * @param t - Where to evaluate.\n * @returns The interpolated value.\n */\nfunction hermite(k0: CurveKey, k1: CurveKey, t: number): number {\n const dt = k1[0] - k0[0];\n if (dt <= 0) {\n return k1[1];\n }\n const s = (t - k0[0]) / dt;\n const s2 = s * s;\n const s3 = s2 * s;\n const h00 = 2 * s3 - 3 * s2 + 1;\n const h10 = s3 - 2 * s2 + s;\n const h01 = -2 * s3 + 3 * s2;\n const h11 = s3 - s2;\n return h00 * k0[1] + h10 * dt * k0[3] + h01 * k1[1] + h11 * dt * k1[2];\n}\n\n/**\n * Bakes a curve into {@link LOOKUP_SAMPLES} samples over `[0, 1]`.\n *\n * @param curve - The curve.\n * @returns The samples; sample `i` is the curve at `i / 63`.\n *\n * @public\n */\nexport function bakeCurve(curve: CurveValue): Float32Array {\n const samples = new Float32Array(LOOKUP_SAMPLES);\n for (let index = 0; index < LOOKUP_SAMPLES; index += 1) {\n samples[index] = evaluateCurve(curve, index / (LOOKUP_SAMPLES - 1));\n }\n return samples;\n}\n\n/**\n * Evaluates a gradient at `t` by linear interpolation between stops, clamping outside them.\n *\n * @param stops - The stops, sorted by time and non-empty.\n * @param t - Where to evaluate.\n * @param out - Receives the sRGB colour.\n * @returns `out`.\n *\n * @public\n */\nexport function evaluateGradient(stops: readonly GradientStop[], t: number, out: Float32Array): Float32Array {\n const first = stops[0];\n if (first === undefined) {\n out[0] = 1;\n out[1] = 1;\n out[2] = 1;\n out[3] = 1;\n return out;\n }\n const last = stops[stops.length - 1] ?? first;\n if (t <= first[0]) {\n return writeStop(first, out);\n }\n if (t >= last[0]) {\n return writeStop(last, out);\n }\n let index = 1;\n while (index < stops.length) {\n const stop = stops[index];\n if (stop !== undefined && stop[0] >= t) {\n break;\n }\n index += 1;\n }\n const a = stops[index - 1];\n const b = stops[index];\n if (a === undefined || b === undefined) {\n return writeStop(first, out);\n }\n const span = b[0] - a[0];\n const s = span <= 0 ? 1 : (t - a[0]) / span;\n out[0] = a[1] + (b[1] - a[1]) * s;\n out[1] = a[2] + (b[2] - a[2]) * s;\n out[2] = a[3] + (b[3] - a[3]) * s;\n out[3] = a[4] + (b[4] - a[4]) * s;\n return out;\n}\n\n/**\n * Copies a stop's colour.\n *\n * @param stop - The stop.\n * @param out - Receives the colour.\n * @returns `out`.\n */\nfunction writeStop(stop: GradientStop, out: Float32Array): Float32Array {\n out[0] = stop[1];\n out[1] = stop[2];\n out[2] = stop[3];\n out[3] = stop[4];\n return out;\n}\n\n/**\n * Bakes a gradient into {@link LOOKUP_SAMPLES} RGBA samples.\n *\n * @param stops - The stops.\n * @returns `LOOKUP_SAMPLES * 4` floats, sRGB.\n *\n * @public\n */\nexport function bakeGradient(stops: readonly GradientStop[]): Float32Array {\n const samples = new Float32Array(LOOKUP_SAMPLES * COLOR_FLOATS);\n const scratch = new Float32Array(COLOR_FLOATS);\n for (let index = 0; index < LOOKUP_SAMPLES; index += 1) {\n evaluateGradient(stops, index / (LOOKUP_SAMPLES - 1), scratch);\n samples.set(scratch, index * COLOR_FLOATS);\n }\n return samples;\n}\n\n/**\n * Samples a baked scalar row with the linear rule both evaluators share: `x = t * 63`, then a lerp\n * between samples `floor(x)` and `floor(x) + 1`.\n *\n * @param samples - A row of {@link LOOKUP_SAMPLES} floats.\n * @param t - The normalized time, clamped to `[0, 1]`.\n * @returns The interpolated value.\n *\n * @public\n */\nexport function sampleRow(samples: Float32Array, t: number): number {\n const clamped = t <= 0 ? 0 : t >= 1 ? 1 : t;\n const x = clamped * (LOOKUP_SAMPLES - 1);\n const index = Math.floor(x);\n const next = index + 1 >= LOOKUP_SAMPLES ? index : index + 1;\n const a = samples[index] ?? 0;\n const b = samples[next] ?? a;\n return a + (b - a) * (x - index);\n}\n\n/**\n * The smallest value a scalar can produce: the constant, the range's `min`, or the curve's minimum.\n *\n * @param value - The scalar.\n * @returns The minimum.\n *\n * @public\n */\nexport function scalarMin(value: ScalarValue): number {\n switch (value.kind) {\n case \"constant\":\n return value.value;\n case \"random\":\n return Math.min(value.min, value.max);\n case \"curve\":\n return rowMin(value.samples);\n default:\n return assertNever(value, \"scalar value\");\n }\n}\n\n/**\n * The largest value a scalar can produce.\n *\n * @param value - The scalar.\n * @returns The maximum.\n *\n * @public\n */\nexport function scalarMax(value: ScalarValue): number {\n switch (value.kind) {\n case \"constant\":\n return value.value;\n case \"random\":\n return Math.max(value.min, value.max);\n case \"curve\":\n return rowMax(value.samples);\n default:\n return assertNever(value, \"scalar value\");\n }\n}\n\n/**\n * The smallest sample of a row.\n *\n * @param samples - The row.\n * @returns The minimum, or `0` for an empty row.\n */\nexport function rowMin(samples: Float32Array): number {\n let min = Number.POSITIVE_INFINITY;\n for (let index = 0; index < samples.length; index += 1) {\n const sample = samples[index] ?? 0;\n if (sample < min) {\n min = sample;\n }\n }\n return min === Number.POSITIVE_INFINITY ? 0 : min;\n}\n\n/**\n * The largest sample of a row.\n *\n * @param samples - The row.\n * @returns The maximum, or `0` for an empty row.\n */\nexport function rowMax(samples: Float32Array): number {\n let max = Number.NEGATIVE_INFINITY;\n for (let index = 0; index < samples.length; index += 1) {\n const sample = samples[index] ?? 0;\n if (sample > max) {\n max = sample;\n }\n }\n return max === Number.NEGATIVE_INFINITY ? 0 : max;\n}\n\n/**\n * Resolves a scalar at spawn: the constant, a pick inside the range by `unit`, or the curve sampled\n * at `t` (the normalized position in the emission cycle).\n *\n * @param value - The scalar.\n * @param unit - A uniform random number in `[0, 1)`.\n * @param t - The normalized cycle time, for a curve.\n * @returns The resolved number.\n *\n * @public\n */\nexport function resolveScalar(value: ScalarValue, unit: number, t: number): number {\n switch (value.kind) {\n case \"constant\":\n return value.value;\n case \"random\":\n return value.min + (value.max - value.min) * unit;\n case \"curve\":\n return sampleRow(value.samples, t);\n default:\n return assertNever(value, \"scalar value\");\n }\n}\n\n/**\n * Whether a scalar is a constant `1`, so a module can skip it entirely.\n *\n * @param value - The scalar.\n * @returns `true` for a constant equal to one.\n *\n * @public\n */\nexport function isUnitScalar(value: ScalarValue): boolean {\n return value.kind === \"constant\" && value.value === 1;\n}\n\n/**\n * The colour a random or constant start colour resolves to for one particle, in sRGB, without\n * allocating. A gradient start colour samples at `t`.\n *\n * @param value - The colour value.\n * @param unit - A uniform random number in `[0, 1)`; picks between `min` and `max`.\n * @param t - The normalized cycle time, for a gradient.\n * @param out - Receives `r, g, b, a`.\n * @returns `out`.\n *\n * @public\n */\nexport function resolveColor(value: ColorValue, unit: number, t: number, out: Float32Array): Float32Array {\n switch (value.kind) {\n case \"constant\":\n return writeColor(value.value, out);\n case \"random\":\n out[0] = value.min.r + (value.max.r - value.min.r) * unit;\n out[1] = value.min.g + (value.max.g - value.min.g) * unit;\n out[2] = value.min.b + (value.max.b - value.min.b) * unit;\n out[3] = value.min.a + (value.max.a - value.min.a) * unit;\n return out;\n case \"gradient\":\n return evaluateGradient(value.stops, t, out);\n default:\n return assertNever(value, \"colour value\");\n }\n}\n\n/**\n * Copies a colour into four floats.\n *\n * @param color - The colour.\n * @param out - Receives it.\n * @returns `out`.\n */\nfunction writeColor(color: ColorLike, out: Float32Array): Float32Array {\n out[0] = color.r;\n out[1] = color.g;\n out[2] = color.b;\n out[3] = color.a;\n return out;\n}\n\n/**\n * Decodes an sRGB channel to linear — the exact formula the generated WGSL uses, so the CPU\n * evaluator and the shader agree (`Color.srgbToLinear` in core is the same function; it is\n * restated here so the two hosts can be read side by side).\n *\n * @param value - The sRGB channel in `0`–`1`.\n * @returns The linear channel.\n *\n * @public\n */\nexport function srgbToLinear(value: number): number {\n return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n}\n","import { ParticlesErrorCode, particlesError } from \"../errors.js\";\nimport {\n LOOKUP_SAMPLES,\n PARTICLE_BLEND_MODES,\n PARTICLE_EMIT_FROM,\n PARTICLE_MESHES,\n PARTICLE_RENDER_MODES,\n PARTICLE_SHAPE_KINDS,\n PARTICLE_SIMULATION_SPACES,\n PARTICLES_FORMAT,\n PARTICLES_FORMAT_VERSION,\n} from \"./types.js\";\nimport { bakeCurve, bakeGradient, rowMax, rowMin, scalarMin } from \"./values.js\";\nimport type {\n ColorValue,\n GradientStop,\n LookupRow,\n ParticleBurst,\n ParticleDefinition,\n ParticleDefinitionInput,\n ParticleEmission,\n ParticleForces,\n ParticleLookup,\n ParticleMain,\n ParticleNoise,\n ParticleOrbit,\n ParticleOverLifetime,\n ParticleRenderer,\n ParticleShape,\n ParticleSheet,\n ParticleStart,\n ScalarValue,\n} from \"./types.js\";\nimport type { ColorLike, CurveKey, CurveValue, IgnifxError, Vec2Like, Vec3Like } from \"@ignifx/core\";\n\n// The one place a `.particles.json` is validated, defaulted and baked.\n// The checks are hand-written so a failure\n// names the exact path it broke; `src/file-schemas.ts` is the declarative copy, for documentation.\n\n/** The largest capacity one definition may ask for; the budget in `app.particles` is what really limits it. */\nconst MAX_CAPACITY = 1_000_000;\n\n/** The largest seed a `u32` holds. */\nconst MAX_SEED = 0xff_ff_ff_ff;\n\n/** How many numbers one `\"mesh\"` triangle takes. */\nconst TRIANGLE_NUMBERS = 9;\n\n/** Bytes per lookup texel. */\nconst TEXEL_BYTES = 4;\n\n/** The keys a document may carry at the top level. */\nconst TOP_LEVEL_KEYS: readonly string[] = Object.freeze([\n \"format\",\n \"formatVersion\",\n \"main\",\n \"emission\",\n \"shape\",\n \"start\",\n \"forces\",\n \"overLifetime\",\n \"renderer\",\n]);\n\n/** The keys of the linear ramp a sheet's `frameOverTime` defaults to. */\nconst LINEAR_RAMP_KEYS: readonly CurveKey[] = Object.freeze([\n Object.freeze([0, 0, 1, 1] as const),\n Object.freeze([1, 1, 1, 1] as const),\n]);\n\n/** The linear ramp a sheet's `frameOverTime` defaults to. */\nconst LINEAR_RAMP: CurveValue = Object.freeze({ keys: LINEAR_RAMP_KEYS });\n\n/** Opaque white, the start colour a document that names none gets. */\nconst WHITE: ColorLike = Object.freeze({ r: 1, g: 1, b: 1, a: 1 });\n\n/** What a number reader enforces. */\ninterface NumberRule {\n /** The smallest accepted value, inclusive. */\n readonly min?: number;\n /** The largest accepted value, inclusive. */\n readonly max?: number;\n /** Whether only integers are accepted. */\n readonly integer?: boolean;\n}\n\n/**\n * Fills in the defaults of a particle document, checks every rule the evaluators rely on, and bakes\n * its curves and gradients into the lookup rows both hosts sample.\n *\n * @param input - The document, as authored.\n * @param address - What to name in an error; defaults to `\"<inline>\"`.\n * @returns The complete, frozen definition.\n * @throws IgnifxError with code `IGX-1701`, naming the offending path, when the document is not\n * readable.\n *\n * @example\n * ```ts\n * const sparks = defineParticles({\n * main: { capacity: 200, duration: 1, looping: false },\n * emission: { rateOverTime: 0, bursts: [{ time: 0, count: 120 }] },\n * start: { lifetime: { min: 0.4, max: 1 }, speed: { min: 3, max: 6 }, size: 0.04 },\n * forces: { gravityMultiplier: 1, drag: 0.5 },\n * renderer: { mode: \"stretched\", blend: \"additive\" },\n * });\n * ```\n *\n * @public\n */\nexport function defineParticles(input: ParticleDefinitionInput, address: string = \"<inline>\"): ParticleDefinition {\n const root = readObject(input, address, \"document\");\n assertKeys(root, TOP_LEVEL_KEYS, address, \"\");\n if (root[\"format\"] !== undefined && root[\"format\"] !== PARTICLES_FORMAT) {\n throw invalid(address, `format is ${show(root[\"format\"])}, not ${PARTICLES_FORMAT}`);\n }\n const version = root[\"formatVersion\"] ?? PARTICLES_FORMAT_VERSION;\n if (version !== PARTICLES_FORMAT_VERSION) {\n throw invalid(\n address,\n `formatVersion is ${show(version)}, and this build reads ${String(PARTICLES_FORMAT_VERSION)}`,\n );\n }\n const main = readMain(root[\"main\"], address);\n const emission = readEmission(root[\"emission\"], address);\n const shape = readShape(root[\"shape\"], address);\n const start = readStart(root[\"start\"], address);\n const forces = readForces(root[\"forces\"], address);\n const overLifetime = readOverLifetime(root[\"overLifetime\"], address);\n const renderer = readRenderer(root[\"renderer\"], address);\n const lookup = bakeLookup(overLifetime, forces, renderer);\n return Object.freeze({\n format: PARTICLES_FORMAT,\n formatVersion: PARTICLES_FORMAT_VERSION,\n main,\n emission,\n shape,\n start,\n forces,\n overLifetime,\n renderer,\n lookup,\n });\n}\n\n/**\n * Builds the failure an invalid document produces.\n *\n * @param address - What to name in the message.\n * @param reason - The specific problem, as a sentence fragment.\n * @returns The error to throw.\n */\nfunction invalid(address: string, reason: string): IgnifxError {\n return particlesError(\n ParticlesErrorCode.invalidParticlesFile,\n `${address} is not a valid ignifx.particles document: ${reason}.`,\n {\n context: { file: address, reason },\n hint: \"See skills/ignifx/references/formats/ignifx.particles.md for the document shape.\",\n },\n );\n}\n\n/**\n * Renders a rejected value for an error message, without an object stringifying to `[object Object]`.\n *\n * @param value - The raw value.\n * @returns A short description.\n */\nfunction show(value: unknown): string {\n return typeof value === \"string\" ? value : JSON.stringify(value);\n}\n\n/**\n * Whether a value is a plain object.\n *\n * @param value - The value read out of the document.\n * @returns `true` when the value can be read as a record.\n */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Narrows a raw value to an object.\n *\n * @param value - The raw value.\n * @param address - The document address, for the error.\n * @param path - What the value is, for the error.\n * @returns The record.\n */\nfunction readObject(value: unknown, address: string, path: string): Record<string, unknown> {\n if (!isRecord(value)) {\n throw invalid(address, `${path} must be an object`);\n }\n return value;\n}\n\n/**\n * Refuses keys a module does not declare.\n *\n * @param record - The module.\n * @param allowed - Its keys.\n * @param address - The document address, for the error.\n * @param path - The module path, for the error.\n */\nfunction assertKeys(record: Record<string, unknown>, allowed: readonly string[], address: string, path: string): void {\n for (const key of Object.keys(record)) {\n if (!allowed.includes(key)) {\n const where = path === \"\" ? key : `${path}.${key}`;\n throw invalid(address, `${where} is not a field; the fields are ${allowed.join(\", \")}`);\n }\n }\n}\n\n/**\n * Reads an optional number.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @param rule - The range and integrality to enforce.\n * @returns The number.\n */\nfunction readNumber(value: unknown, fallback: number, address: string, path: string, rule: NumberRule = {}): number {\n if (value === undefined) {\n return fallback;\n }\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw invalid(address, `${path} must be a finite number`);\n }\n checkNumber(value, address, path, rule);\n return value;\n}\n\n/**\n * Checks a number against a rule.\n *\n * @param value - The number.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @param rule - The range and integrality to enforce.\n */\nfunction checkNumber(value: number, address: string, path: string, rule: NumberRule): void {\n if (rule.integer === true && !Number.isInteger(value)) {\n throw invalid(address, `${path} must be an integer`);\n }\n if (rule.min !== undefined && value < rule.min) {\n throw invalid(address, `${path} must be at least ${String(rule.min)}, not ${String(value)}`);\n }\n if (rule.max !== undefined && value > rule.max) {\n throw invalid(address, `${path} must be at most ${String(rule.max)}, not ${String(value)}`);\n }\n}\n\n/**\n * Reads an optional boolean.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns The boolean.\n */\nfunction readBoolean(value: unknown, fallback: boolean, address: string, path: string): boolean {\n if (value === undefined) {\n return fallback;\n }\n if (typeof value !== \"boolean\") {\n throw invalid(address, `${path} must be true or false`);\n }\n return value;\n}\n\n/**\n * Reads an optional string out of a fixed set.\n *\n * @typeParam T - The literal union.\n * @param value - The raw value.\n * @param allowed - The accepted values.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns The literal.\n */\nfunction readEnum<T extends string>(\n value: unknown,\n allowed: readonly T[],\n fallback: T,\n address: string,\n path: string,\n): T {\n if (value === undefined) {\n return fallback;\n }\n for (let index = 0; index < allowed.length; index += 1) {\n const candidate = allowed[index];\n if (candidate !== undefined && candidate === value) {\n return candidate;\n }\n }\n throw invalid(address, `${path} must be one of ${allowed.join(\", \")}, not ${JSON.stringify(value)}`);\n}\n\n/**\n * Reads an optional 3D vector.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns A fresh, frozen vector.\n */\nfunction readVec3(value: unknown, fallback: Vec3Like, address: string, path: string): Vec3Like {\n if (value === undefined) {\n return Object.freeze({ x: fallback.x, y: fallback.y, z: fallback.z });\n }\n const record = readObject(value, address, path);\n assertKeys(record, [\"x\", \"y\", \"z\"], address, path);\n return Object.freeze({\n x: readNumber(record[\"x\"], 0, address, `${path}.x`),\n y: readNumber(record[\"y\"], 0, address, `${path}.y`),\n z: readNumber(record[\"z\"], 0, address, `${path}.z`),\n });\n}\n\n/**\n * Reads an optional 2D vector.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns A fresh, frozen vector.\n */\nfunction readVec2(value: unknown, fallback: Vec2Like, address: string, path: string): Vec2Like {\n if (value === undefined) {\n return Object.freeze({ x: fallback.x, y: fallback.y });\n }\n const record = readObject(value, address, path);\n assertKeys(record, [\"x\", \"y\"], address, path);\n return Object.freeze({\n x: readNumber(record[\"x\"], 0, address, `${path}.x`),\n y: readNumber(record[\"y\"], 0, address, `${path}.y`),\n });\n}\n\n/**\n * Reads a curve: `{ keys: [[t, v, in, out], …] }` with at least one key, sorted by time.\n *\n * @param value - The raw value.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns The curve, frozen.\n */\nfunction readCurve(value: unknown, address: string, path: string): CurveValue {\n const record = readObject(value, address, path);\n assertKeys(record, [\"keys\"], address, path);\n const raw = record[\"keys\"];\n if (!Array.isArray(raw) || raw.length === 0) {\n throw invalid(address, `${path}.keys must be a non-empty array of [time, value, inTangent, outTangent]`);\n }\n const keys: CurveKey[] = [];\n let previous = Number.NEGATIVE_INFINITY;\n for (let index = 0; index < raw.length; index += 1) {\n const key: unknown = raw[index];\n if (!Array.isArray(key) || key.length !== 4) {\n throw invalid(address, `${path}.keys[${String(index)}] must be [time, value, inTangent, outTangent]`);\n }\n const numbers: number[] = [];\n for (let component = 0; component < 4; component += 1) {\n const element: unknown = key[component];\n if (typeof element !== \"number\" || !Number.isFinite(element)) {\n throw invalid(address, `${path}.keys[${String(index)}] must hold finite numbers`);\n }\n numbers.push(element);\n }\n const time = numbers[0] ?? 0;\n if (time < previous) {\n throw invalid(address, `${path}.keys must be sorted by time`);\n }\n previous = time;\n keys.push(Object.freeze([time, numbers[1] ?? 0, numbers[2] ?? 0, numbers[3] ?? 0]));\n }\n return Object.freeze({ keys: Object.freeze(keys) });\n}\n\n/**\n * Reads a scalar value: a number, `{ min, max }`, or `{ curve }`.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @param rule - The range every produced value must stay inside.\n * @returns The resolved scalar.\n */\nfunction readScalar(\n value: unknown,\n fallback: number,\n address: string,\n path: string,\n rule: NumberRule = {},\n): ScalarValue {\n if (value === undefined) {\n return Object.freeze({ kind: \"constant\", value: fallback });\n }\n if (typeof value === \"number\") {\n return Object.freeze({ kind: \"constant\", value: readNumber(value, fallback, address, path, rule) });\n }\n const record = readObject(value, address, path);\n if (\"curve\" in record) {\n assertKeys(record, [\"curve\"], address, path);\n const curve = readCurve(record[\"curve\"], address, `${path}.curve`);\n const samples = bakeCurve(curve);\n checkNumber(rowMin(samples), address, `${path}.curve`, { ...rule, integer: false });\n checkNumber(rowMax(samples), address, `${path}.curve`, { ...rule, integer: false });\n return Object.freeze({ kind: \"curve\", curve, samples });\n }\n assertKeys(record, [\"min\", \"max\"], address, path);\n if (record[\"min\"] === undefined || record[\"max\"] === undefined) {\n throw invalid(address, `${path} must be a number, { min, max }, or { curve }`);\n }\n return Object.freeze({\n kind: \"random\",\n min: readNumber(record[\"min\"], 0, address, `${path}.min`, rule),\n max: readNumber(record[\"max\"], 0, address, `${path}.max`, rule),\n });\n}\n\n/**\n * Reads one colour: `[r, g, b, a]` or `{ r, g, b, a }`, sRGB.\n *\n * @param value - The raw value.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @param max - The largest accepted channel, or `undefined` for HDR-friendly no bound.\n * @returns The colour, frozen.\n */\nfunction readColor(value: unknown, address: string, path: string, max?: number): ColorLike {\n const channel = (raw: unknown, name: string, fallback: number, cap: number | undefined): number => {\n const rule: NumberRule = cap === undefined ? { min: 0 } : { min: 0, max: cap };\n return readNumber(raw, fallback, address, `${path}.${name}`, rule);\n };\n if (Array.isArray(value)) {\n if (value.length !== 4 && value.length !== 3) {\n throw invalid(address, `${path} must be [r, g, b, a]`);\n }\n return Object.freeze({\n r: channel(value[0], \"r\", 1, max),\n g: channel(value[1], \"g\", 1, max),\n b: channel(value[2], \"b\", 1, max),\n a: channel(value[3], \"a\", 1, 1),\n });\n }\n const record = readObject(value, address, path);\n assertKeys(record, [\"r\", \"g\", \"b\", \"a\"], address, path);\n return Object.freeze({\n r: channel(record[\"r\"], \"r\", 1, max),\n g: channel(record[\"g\"], \"g\", 1, max),\n b: channel(record[\"b\"], \"b\", 1, max),\n a: channel(record[\"a\"], \"a\", 1, 1),\n });\n}\n\n/**\n * Reads a gradient's stops.\n *\n * @param value - The raw value.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @returns The stops, frozen and sorted.\n */\nfunction readGradient(value: unknown, address: string, path: string): readonly GradientStop[] {\n if (!Array.isArray(value) || value.length === 0) {\n throw invalid(address, `${path} must be a non-empty array of [t, r, g, b, a] stops`);\n }\n const stops: GradientStop[] = [];\n let previous = Number.NEGATIVE_INFINITY;\n for (let index = 0; index < value.length; index += 1) {\n const stop: unknown = value[index];\n if (!Array.isArray(stop) || stop.length !== 5) {\n throw invalid(address, `${path}[${String(index)}] must be [t, r, g, b, a]`);\n }\n const numbers: number[] = [];\n for (let component = 0; component < 5; component += 1) {\n const element: unknown = stop[component];\n if (typeof element !== \"number\" || !Number.isFinite(element) || element < 0 || element > 1) {\n throw invalid(address, `${path}[${String(index)}] must hold numbers in 0..1`);\n }\n numbers.push(element);\n }\n const time = numbers[0] ?? 0;\n if (time < previous) {\n throw invalid(address, `${path} stops must be sorted by time`);\n }\n previous = time;\n stops.push(Object.freeze([time, numbers[1] ?? 0, numbers[2] ?? 0, numbers[3] ?? 0, numbers[4] ?? 1]));\n }\n return Object.freeze(stops);\n}\n\n/**\n * Reads a colour value: a colour, `{ min, max }`, or `{ gradient }`.\n *\n * @param value - The raw value.\n * @param fallback - What an absent key means.\n * @param address - The document address, for the error.\n * @param path - The field path, for the error.\n * @param allowRandom - Whether `{ min, max }` is meaningful here.\n * @returns The resolved colour value.\n */\nfunction readColorValue(\n value: unknown,\n fallback: ColorLike,\n address: string,\n path: string,\n allowRandom: boolean,\n): ColorValue {\n if (value === undefined) {\n return Object.freeze({ kind: \"constant\", value: fallback });\n }\n if (isRecord(value) && \"gradient\" in value) {\n assertKeys(value, [\"gradient\"], address, path);\n const stops = readGradient(value[\"gradient\"], address, `${path}.gradient`);\n return Object.freeze({ kind: \"gradient\", stops, samples: bakeGradient(stops) });\n }\n if (isRecord(value) && (\"min\" in value || \"max\" in value)) {\n if (!allowRandom) {\n throw invalid(address, `${path} must be a colour or a gradient; a random colour has no meaning over a lifetime`);\n }\n assertKeys(value, [\"min\", \"max\"], address, path);\n return Object.freeze({\n kind: \"random\",\n min: readColor(value[\"min\"], address, `${path}.min`),\n max: readColor(value[\"max\"], address, `${path}.max`),\n });\n }\n return Object.freeze({ kind: \"constant\", value: readColor(value, address, path, allowRandom ? undefined : 1) });\n}\n\n/**\n * Reads the `main` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readMain(value: unknown, address: string): ParticleMain {\n const record = value === undefined ? {} : readObject(value, address, \"main\");\n assertKeys(\n record,\n [\n \"capacity\",\n \"duration\",\n \"looping\",\n \"prewarm\",\n \"startDelay\",\n \"simulationSpace\",\n \"seed\",\n \"playOnAwake\",\n \"timeScale\",\n \"renderOrder\",\n ],\n address,\n \"main\",\n );\n return Object.freeze({\n capacity: readNumber(record[\"capacity\"], 1000, address, \"main.capacity\", {\n min: 1,\n max: MAX_CAPACITY,\n integer: true,\n }),\n duration: readNumber(record[\"duration\"], 5, address, \"main.duration\", { min: 0.001 }),\n looping: readBoolean(record[\"looping\"], true, address, \"main.looping\"),\n prewarm: readBoolean(record[\"prewarm\"], false, address, \"main.prewarm\"),\n startDelay: readNumber(record[\"startDelay\"], 0, address, \"main.startDelay\", { min: 0 }),\n simulationSpace: readEnum(\n record[\"simulationSpace\"],\n PARTICLE_SIMULATION_SPACES,\n \"local\",\n address,\n \"main.simulationSpace\",\n ),\n seed: readNumber(record[\"seed\"], 0, address, \"main.seed\", { min: 0, max: MAX_SEED, integer: true }),\n playOnAwake: readBoolean(record[\"playOnAwake\"], true, address, \"main.playOnAwake\"),\n timeScale: readNumber(record[\"timeScale\"], 1, address, \"main.timeScale\", { min: 0 }),\n renderOrder: readNumber(record[\"renderOrder\"], 0, address, \"main.renderOrder\", { integer: true }),\n });\n}\n\n/**\n * Reads the `emission` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readEmission(value: unknown, address: string): ParticleEmission {\n const record = value === undefined ? {} : readObject(value, address, \"emission\");\n assertKeys(record, [\"rateOverTime\", \"rateOverDistance\", \"bursts\"], address, \"emission\");\n const rawBursts = record[\"bursts\"];\n const bursts: ParticleBurst[] = [];\n if (rawBursts !== undefined) {\n if (!Array.isArray(rawBursts)) {\n throw invalid(address, \"emission.bursts must be an array\");\n }\n for (let index = 0; index < rawBursts.length; index += 1) {\n const path = `emission.bursts[${String(index)}]`;\n const burst = readObject(rawBursts[index], address, path);\n assertKeys(burst, [\"time\", \"count\", \"cycles\", \"interval\", \"probability\"], address, path);\n bursts.push(\n Object.freeze({\n time: readNumber(burst[\"time\"], 0, address, `${path}.time`, { min: 0 }),\n count: readScalar(burst[\"count\"], 10, address, `${path}.count`, { min: 0 }),\n cycles: readNumber(burst[\"cycles\"], 1, address, `${path}.cycles`, { min: 0, integer: true }),\n interval: readNumber(burst[\"interval\"], 0.1, address, `${path}.interval`, { min: 0 }),\n probability: readNumber(burst[\"probability\"], 1, address, `${path}.probability`, { min: 0, max: 1 }),\n }),\n );\n }\n }\n return Object.freeze({\n rateOverTime: readNumber(record[\"rateOverTime\"], 10, address, \"emission.rateOverTime\", { min: 0 }),\n rateOverDistance: readNumber(record[\"rateOverDistance\"], 0, address, \"emission.rateOverDistance\", { min: 0 }),\n bursts: Object.freeze(bursts),\n });\n}\n\n/**\n * Reads the `shape` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readShape(value: unknown, address: string): ParticleShape {\n const record = value === undefined ? {} : readObject(value, address, \"shape\");\n assertKeys(\n record,\n [\n \"kind\",\n \"radius\",\n \"thickness\",\n \"arc\",\n \"angle\",\n \"length\",\n \"size\",\n \"emitFrom\",\n \"randomDirection\",\n \"spherizeDirection\",\n \"vertices\",\n ],\n address,\n \"shape\",\n );\n const kind = readEnum(record[\"kind\"], PARTICLE_SHAPE_KINDS, \"cone\", address, \"shape.kind\");\n const rawVertices = record[\"vertices\"];\n let vertices = new Float32Array(0);\n if (rawVertices !== undefined) {\n if (!Array.isArray(rawVertices) || rawVertices.length % TRIANGLE_NUMBERS !== 0) {\n throw invalid(address, \"shape.vertices must hold nine numbers per triangle\");\n }\n vertices = new Float32Array(rawVertices.length);\n for (let index = 0; index < rawVertices.length; index += 1) {\n const element: unknown = rawVertices[index];\n if (typeof element !== \"number\" || !Number.isFinite(element)) {\n throw invalid(address, `shape.vertices[${String(index)}] must be a finite number`);\n }\n vertices[index] = element;\n }\n }\n if (kind === \"mesh\" && vertices.length === 0) {\n throw invalid(address, \"a mesh shape needs shape.vertices with at least one triangle\");\n }\n return Object.freeze({\n kind,\n radius: readNumber(record[\"radius\"], 0.2, address, \"shape.radius\", { min: 0 }),\n thickness: readNumber(record[\"thickness\"], 1, address, \"shape.thickness\", { min: 0, max: 1 }),\n arc: readNumber(record[\"arc\"], 360, address, \"shape.arc\", { min: 0, max: 360 }),\n angle: readNumber(record[\"angle\"], 25, address, \"shape.angle\", { min: 0, max: 90 }),\n length: readNumber(record[\"length\"], 1, address, \"shape.length\", { min: 0 }),\n size: readVec3(record[\"size\"], { x: 1, y: 1, z: 1 }, address, \"shape.size\"),\n emitFrom: readEnum(\n record[\"emitFrom\"],\n PARTICLE_EMIT_FROM,\n kind === \"cone\" ? \"base\" : \"volume\",\n address,\n \"shape.emitFrom\",\n ),\n randomDirection: readNumber(record[\"randomDirection\"], 0, address, \"shape.randomDirection\", { min: 0, max: 1 }),\n spherizeDirection: readNumber(record[\"spherizeDirection\"], 0, address, \"shape.spherizeDirection\", {\n min: 0,\n max: 1,\n }),\n vertices,\n });\n}\n\n/**\n * Reads the `start` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readStart(value: unknown, address: string): ParticleStart {\n const record = value === undefined ? {} : readObject(value, address, \"start\");\n assertKeys(record, [\"lifetime\", \"speed\", \"size\", \"size3D\", \"rotation\", \"color\"], address, \"start\");\n const lifetime = readScalar(record[\"lifetime\"], 2, address, \"start.lifetime\", { min: 0 });\n if (scalarMin(lifetime) <= 0) {\n throw invalid(address, \"start.lifetime must stay above zero\");\n }\n const rawSize3D = record[\"size3D\"];\n return Object.freeze({\n lifetime,\n speed: readScalar(record[\"speed\"], 2, address, \"start.speed\"),\n size: readScalar(record[\"size\"], 0.2, address, \"start.size\", { min: 0 }),\n size3D:\n rawSize3D === undefined || rawSize3D === null\n ? null\n : readVec3(rawSize3D, { x: 1, y: 1, z: 1 }, address, \"start.size3D\"),\n rotation: readScalar(record[\"rotation\"], 0, address, \"start.rotation\"),\n color: readColorValue(record[\"color\"], WHITE, address, \"start.color\", true),\n });\n}\n\n/**\n * Reads the `forces` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readForces(value: unknown, address: string): ParticleForces {\n const record = value === undefined ? {} : readObject(value, address, \"forces\");\n assertKeys(record, [\"gravity\", \"gravityMultiplier\", \"drag\", \"constantForce\", \"orbit\", \"noise\"], address, \"forces\");\n const rawGravity = record[\"gravity\"];\n const rawOrbit = record[\"orbit\"];\n const rawNoise = record[\"noise\"];\n return Object.freeze({\n gravity:\n rawGravity === undefined || rawGravity === null\n ? null\n : readVec3(rawGravity, { x: 0, y: 0, z: 0 }, address, \"forces.gravity\"),\n gravityMultiplier: readNumber(record[\"gravityMultiplier\"], 0, address, \"forces.gravityMultiplier\"),\n drag: readNumber(record[\"drag\"], 0, address, \"forces.drag\", { min: 0 }),\n constantForce: readVec3(record[\"constantForce\"], { x: 0, y: 0, z: 0 }, address, \"forces.constantForce\"),\n orbit: rawOrbit === undefined || rawOrbit === null ? null : readOrbit(rawOrbit, address),\n noise: rawNoise === undefined || rawNoise === null ? null : readNoise(rawNoise, address),\n });\n}\n\n/**\n * Reads `forces.orbit`.\n *\n * @param value - The raw record.\n * @param address - The document address, for errors.\n * @returns The orbit, with its axis normalized.\n */\nfunction readOrbit(value: unknown, address: string): ParticleOrbit {\n const record = readObject(value, address, \"forces.orbit\");\n assertKeys(record, [\"axis\", \"speed\"], address, \"forces.orbit\");\n const axis = readVec3(record[\"axis\"], { x: 0, y: 1, z: 0 }, address, \"forces.orbit.axis\");\n const length = Math.hypot(axis.x, axis.y, axis.z);\n if (length === 0) {\n throw invalid(address, \"forces.orbit.axis must not be the zero vector\");\n }\n return Object.freeze({\n axis: Object.freeze({ x: axis.x / length, y: axis.y / length, z: axis.z / length }),\n speed: readNumber(record[\"speed\"], 90, address, \"forces.orbit.speed\"),\n });\n}\n\n/**\n * Reads `forces.noise`.\n *\n * @param value - The raw record.\n * @param address - The document address, for errors.\n * @returns The noise settings.\n */\nfunction readNoise(value: unknown, address: string): ParticleNoise {\n const record = readObject(value, address, \"forces.noise\");\n assertKeys(record, [\"strength\", \"frequency\", \"scroll\", \"octaves\", \"influenceOverLife\"], address, \"forces.noise\");\n const influence = readScalar(record[\"influenceOverLife\"], 1, address, \"forces.noise.influenceOverLife\", { min: 0 });\n if (influence.kind === \"random\") {\n throw invalid(address, \"forces.noise.influenceOverLife must be a number or a curve\");\n }\n return Object.freeze({\n strength: readNumber(record[\"strength\"], 0.5, address, \"forces.noise.strength\", { min: 0 }),\n frequency: readNumber(record[\"frequency\"], 1, address, \"forces.noise.frequency\", { min: 0 }),\n scroll: readVec3(record[\"scroll\"], { x: 0, y: 0, z: 0 }, address, \"forces.noise.scroll\"),\n octaves: readNumber(record[\"octaves\"], 1, address, \"forces.noise.octaves\", { min: 1, max: 2, integer: true }),\n influenceOverLife: influence,\n });\n}\n\n/**\n * Reads the `overLifetime` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readOverLifetime(value: unknown, address: string): ParticleOverLifetime {\n const record = value === undefined ? {} : readObject(value, address, \"overLifetime\");\n assertKeys(record, [\"color\", \"size\", \"sizeY\", \"sizeZ\", \"rotation\"], address, \"overLifetime\");\n // Size and colour are read at the particle's age, so a random pick there would mean nothing.\n // Angular speed is picked once at spawn, so `{ min, max }` is meaningful and allowed.\n const optionalScalar = (key: string, rule: NumberRule, allowRandom: boolean): ScalarValue | null => {\n const raw = record[key];\n if (raw === undefined || raw === null) {\n return null;\n }\n const scalar = readScalar(raw, 1, address, `overLifetime.${key}`, rule);\n if (!allowRandom && scalar.kind === \"random\") {\n throw invalid(address, `overLifetime.${key} must be a number or a curve; it is a function of the particle's age`);\n }\n return scalar;\n };\n const rawColor = record[\"color\"];\n return Object.freeze({\n color:\n rawColor === undefined || rawColor === null\n ? null\n : readColorValue(rawColor, WHITE, address, \"overLifetime.color\", false),\n size: optionalScalar(\"size\", { min: 0 }, false),\n sizeY: optionalScalar(\"sizeY\", { min: 0 }, false),\n sizeZ: optionalScalar(\"sizeZ\", { min: 0 }, false),\n rotation: optionalScalar(\"rotation\", {}, true),\n });\n}\n\n/**\n * Reads the `renderer` module.\n *\n * @param value - The raw module.\n * @param address - The document address, for errors.\n * @returns The module.\n */\nfunction readRenderer(value: unknown, address: string): ParticleRenderer {\n const record = value === undefined ? {} : readObject(value, address, \"renderer\");\n assertKeys(\n record,\n [\"mode\", \"mesh\", \"texture\", \"sheet\", \"blend\", \"lit\", \"pivot\", \"speedScale\", \"lengthScale\"],\n address,\n \"renderer\",\n );\n const rawTexture = record[\"texture\"];\n if (rawTexture !== undefined && rawTexture !== null && (typeof rawTexture !== \"string\" || rawTexture.length === 0)) {\n throw invalid(address, \"renderer.texture must be a non-empty asset address or null\");\n }\n const rawSheet = record[\"sheet\"];\n return Object.freeze({\n mode: readEnum(record[\"mode\"], PARTICLE_RENDER_MODES, \"billboard\", address, \"renderer.mode\"),\n mesh: readEnum(record[\"mesh\"], PARTICLE_MESHES, \"box\", address, \"renderer.mesh\"),\n texture: typeof rawTexture === \"string\" ? rawTexture : null,\n sheet: rawSheet === undefined || rawSheet === null ? null : readSheet(rawSheet, address),\n blend: readEnum(record[\"blend\"], PARTICLE_BLEND_MODES, \"premultiplied\", address, \"renderer.blend\"),\n lit: readBoolean(record[\"lit\"], false, address, \"renderer.lit\"),\n pivot: readVec2(record[\"pivot\"], { x: 0, y: 0 }, address, \"renderer.pivot\"),\n speedScale: readNumber(record[\"speedScale\"], 0, address, \"renderer.speedScale\", { min: 0 }),\n lengthScale: readNumber(record[\"lengthScale\"], 1, address, \"renderer.lengthScale\", { min: 0 }),\n });\n}\n\n/**\n * Reads `renderer.sheet`.\n *\n * @param value - The raw record.\n * @param address - The document address, for errors.\n * @returns The sheet.\n */\nfunction readSheet(value: unknown, address: string): ParticleSheet {\n const record = readObject(value, address, \"renderer.sheet\");\n assertKeys(record, [\"tiles\", \"frameOverTime\"], address, \"renderer.sheet\");\n const tiles = readVec2(record[\"tiles\"], { x: 1, y: 1 }, address, \"renderer.sheet.tiles\");\n checkNumber(tiles.x, address, \"renderer.sheet.tiles.x\", { min: 1, integer: true });\n checkNumber(tiles.y, address, \"renderer.sheet.tiles.y\", { min: 1, integer: true });\n const raw = record[\"frameOverTime\"];\n if (raw === \"random\") {\n return Object.freeze({ tiles, mode: \"random\", frameOverTime: linearRamp(), fps: 0 });\n }\n if (isRecord(raw) && \"fps\" in raw) {\n assertKeys(raw, [\"fps\"], address, \"renderer.sheet.frameOverTime\");\n return Object.freeze({\n tiles,\n mode: \"fps\",\n frameOverTime: linearRamp(),\n fps: readNumber(raw[\"fps\"], 12, address, \"renderer.sheet.frameOverTime.fps\", { min: 0 }),\n });\n }\n const frame =\n raw === undefined ? linearRamp() : readScalar(raw, 0, address, \"renderer.sheet.frameOverTime\", { min: 0, max: 1 });\n if (frame.kind === \"random\") {\n throw invalid(address, 'renderer.sheet.frameOverTime must be a curve, a number, \"random\", or { fps }');\n }\n return Object.freeze({ tiles, mode: \"curve\", frameOverTime: frame, fps: 0 });\n}\n\n/**\n * The default sheet ramp, as a baked scalar.\n *\n * @returns A fresh curve scalar running linearly from `0` to `1`.\n */\nfunction linearRamp(): ScalarValue {\n return Object.freeze({ kind: \"curve\", curve: LINEAR_RAMP, samples: bakeCurve(LINEAR_RAMP) });\n}\n\n/** A row waiting to be written into the lookup texture. */\ninterface PendingRow {\n /** The bytes of the row, `LOOKUP_SAMPLES * 4`. */\n readonly bytes: Uint8Array;\n /** The decode range. */\n readonly min: number;\n /** The decode range. */\n readonly max: number;\n}\n\n/**\n * Bakes the lookup texture: one row per curve or gradient the definition uses, in the fixed order\n * colour, size, rotation, noise influence, sheet frame.\n *\n * @param overLifetime - The over-lifetime module.\n * @param forces - The forces module, for the noise influence.\n * @param renderer - The renderer module, for the sheet frame.\n * @returns The lookup.\n */\nfunction bakeLookup(\n overLifetime: ParticleOverLifetime,\n forces: ParticleForces,\n renderer: ParticleRenderer,\n): ParticleLookup {\n const pending: PendingRow[] = [];\n const color = overLifetime.color === null ? null : pushRow(pending, colorRow(overLifetime.color));\n const size =\n overLifetime.size === null && overLifetime.sizeY === null && overLifetime.sizeZ === null\n ? null\n : pushRow(pending, sizeRow(overLifetime.size, overLifetime.sizeY, overLifetime.sizeZ));\n const rotation =\n overLifetime.rotation === null || overLifetime.rotation.kind !== \"curve\"\n ? null\n : pushRow(pending, scalarRow(overLifetime.rotation.samples));\n const noise =\n forces.noise === null || forces.noise.influenceOverLife.kind !== \"curve\"\n ? null\n : pushRow(pending, scalarRow(forces.noise.influenceOverLife.samples));\n const sheet = renderer.sheet;\n const frame =\n sheet === null || sheet.mode !== \"curve\"\n ? null\n : pushRow(\n pending,\n scalarRow(\n sheet.frameOverTime.kind === \"curve\" ? sheet.frameOverTime.samples : constantSamples(sheet.frameOverTime),\n ),\n );\n if (pending.length === 0) {\n const white = new Uint8Array(LOOKUP_SAMPLES * TEXEL_BYTES);\n white.fill(255);\n pending.push({ bytes: white, min: 0, max: 1 });\n }\n const pixels = new Uint8Array(pending.length * LOOKUP_SAMPLES * TEXEL_BYTES);\n for (let index = 0; index < pending.length; index += 1) {\n const row = pending[index];\n if (row !== undefined) {\n pixels.set(row.bytes, index * LOOKUP_SAMPLES * TEXEL_BYTES);\n }\n }\n return Object.freeze({ rows: pending.length, pixels, color, size, rotation, noise, frame });\n}\n\n/**\n * Appends a row and returns its descriptor.\n *\n * @param pending - The rows so far.\n * @param row - The row to add.\n * @returns The descriptor naming the row's index and decode range.\n */\nfunction pushRow(pending: PendingRow[], row: PendingRow): LookupRow {\n const index = pending.length;\n pending.push(row);\n return Object.freeze({ index, min: row.min, max: row.max });\n}\n\n/**\n * The samples a constant or curve scalar produces over `[0, 1]`.\n *\n * @param value - The scalar; a `\"random\"` value never reaches here.\n * @returns The samples.\n */\nfunction constantSamples(value: ScalarValue): Float32Array {\n const samples = new Float32Array(LOOKUP_SAMPLES);\n const constant = value.kind === \"constant\" ? value.value : value.kind === \"random\" ? value.min : 0;\n samples.fill(constant);\n return samples;\n}\n\n/**\n * Builds a colour row: sRGB bytes and straight alpha, one gradient sample per texel.\n *\n * @param value - The colour value.\n * @returns The row.\n */\nfunction colorRow(value: ColorValue): PendingRow {\n const bytes = new Uint8Array(LOOKUP_SAMPLES * TEXEL_BYTES);\n for (let index = 0; index < LOOKUP_SAMPLES; index += 1) {\n const base = index * TEXEL_BYTES;\n if (value.kind === \"gradient\") {\n bytes[base] = toByte(value.samples[base] ?? 0);\n bytes[base + 1] = toByte(value.samples[base + 1] ?? 0);\n bytes[base + 2] = toByte(value.samples[base + 2] ?? 0);\n bytes[base + 3] = toByte(value.samples[base + 3] ?? 1);\n } else {\n const color = value.kind === \"constant\" ? value.value : value.min;\n bytes[base] = toByte(color.r);\n bytes[base + 1] = toByte(color.g);\n bytes[base + 2] = toByte(color.b);\n bytes[base + 3] = toByte(color.a);\n }\n }\n return { bytes, min: 0, max: 1 };\n}\n\n/**\n * Builds the size row: X in red, Y in green, Z in blue, all quantized between the shared range.\n *\n * @param size - The X (or uniform) multiplier, or `null` for one.\n * @param sizeY - The Y multiplier, or `null` to follow X.\n * @param sizeZ - The Z multiplier, or `null` to follow X.\n * @returns The row.\n */\nfunction sizeRow(size: ScalarValue | null, sizeY: ScalarValue | null, sizeZ: ScalarValue | null): PendingRow {\n const x = size === null ? filled(1) : samplesOf(size);\n const y = sizeY === null ? x : samplesOf(sizeY);\n const z = sizeZ === null ? x : samplesOf(sizeZ);\n const min = Math.min(rowMin(x), rowMin(y), rowMin(z));\n const max = Math.max(rowMax(x), rowMax(y), rowMax(z));\n const range = decodeRange(min, max);\n const bytes = new Uint8Array(LOOKUP_SAMPLES * TEXEL_BYTES);\n for (let index = 0; index < LOOKUP_SAMPLES; index += 1) {\n const base = index * TEXEL_BYTES;\n bytes[base] = quantize(x[index] ?? 0, range.min, range.max);\n bytes[base + 1] = quantize(y[index] ?? 0, range.min, range.max);\n bytes[base + 2] = quantize(z[index] ?? 0, range.min, range.max);\n bytes[base + 3] = 255;\n }\n return { bytes, min: range.min, max: range.max };\n}\n\n/**\n * Builds a scalar row: the value quantized between its own minimum and maximum in every channel.\n *\n * @param samples - The baked samples.\n * @returns The row.\n */\nfunction scalarRow(samples: Float32Array): PendingRow {\n const range = decodeRange(rowMin(samples), rowMax(samples));\n const bytes = new Uint8Array(LOOKUP_SAMPLES * TEXEL_BYTES);\n for (let index = 0; index < LOOKUP_SAMPLES; index += 1) {\n const byte = quantize(samples[index] ?? 0, range.min, range.max);\n const base = index * TEXEL_BYTES;\n bytes[base] = byte;\n bytes[base + 1] = byte;\n bytes[base + 2] = byte;\n bytes[base + 3] = 255;\n }\n return { bytes, min: range.min, max: range.max };\n}\n\n/**\n * The samples of a constant or curve scalar.\n *\n * @param value - The scalar.\n * @returns Its samples.\n */\nfunction samplesOf(value: ScalarValue): Float32Array {\n return value.kind === \"curve\" ? value.samples : constantSamples(value);\n}\n\n/**\n * A row filled with one value.\n *\n * @param value - The value.\n * @returns The samples.\n */\nfunction filled(value: number): Float32Array {\n const samples = new Float32Array(LOOKUP_SAMPLES);\n samples.fill(value);\n return samples;\n}\n\n/**\n * A decode range that never divides by zero: a flat row decodes to its constant.\n *\n * @param min - The row's minimum.\n * @param max - The row's maximum.\n * @returns The range.\n */\nfunction decodeRange(min: number, max: number): { readonly min: number; readonly max: number } {\n return max > min ? { min, max } : { min, max: min + 1 };\n}\n\n/**\n * Quantizes a value into a byte between a range.\n *\n * @param value - The value.\n * @param min - What `0` means.\n * @param max - What `255` means.\n * @returns The byte.\n */\nfunction quantize(value: number, min: number, max: number): number {\n return toByte((value - min) / (max - min));\n}\n\n/**\n * Rounds a `0`–`1` fraction to a byte.\n *\n * @param fraction - The fraction.\n * @returns The byte, clamped.\n */\nfunction toByte(fraction: number): number {\n const scaled = Math.round(fraction * 255);\n return scaled < 0 ? 0 : scaled > 255 ? 255 : scaled;\n}\n","import { defineParticles } from \"../definition/define-particles.js\";\nimport { PARTICLE_ASSET_TYPE, PARTICLE_FILE_EXTENSIONS } from \"../definition/types.js\";\nimport { ParticleAsset } from \"./particle-asset.js\";\nimport type { ParticleDefinition, ParticleDefinitionInput } from \"../definition/types.js\";\nimport type { App, AssetHandle, AssetLoader, LoaderContext, TextureAsset } from \"@ignifx/core\";\n\n// The `particles` asset loader (`docs/architecture/05-assets-and-loading.md` §5) and the in-memory\n// factory that skips the file. The one dependency it pulls in is the renderer's texture, so that\n// texture's reference count and load progress follow the document's.\n\n/**\n * Builds the loader for `.particles.json` addresses.\n *\n * @returns The loader to register with `ctx.registerAssetLoader`.\n *\n * @example\n * ```ts\n * ctx.registerAssetLoader(createParticleLoader());\n * ```\n *\n * @public\n */\nexport function createParticleLoader(): AssetLoader<ParticleAsset> {\n return {\n type: PARTICLE_ASSET_TYPE,\n extensions: PARTICLE_FILE_EXTENSIONS,\n async load(ctx: LoaderContext): Promise<ParticleAsset> {\n const raw = await ctx.fetchJson<ParticleDefinitionInput>();\n const definition = defineParticles(raw, ctx.address);\n const texture = definition.renderer.texture;\n const handle = texture === null ? null : await ctx.loadDependency<TextureAsset>(texture);\n return new ParticleAsset(ctx.address, definition, handle, false);\n },\n unload(value: ParticleAsset): void {\n value.dispose();\n },\n };\n}\n\n/**\n * Publishes a definition built in code as a `particles` asset, so a `ParticleSystem`'s `definition`\n * field can hold it without a file. A `renderer.texture` starts loading here; the system draws the\n * procedural disc until it arrives. The handle has one holder, the caller.\n *\n * @param app - The app whose asset service publishes it.\n * @param definition - The definition, from {@link defineParticles} or a preset.\n * @param name - A human-readable name for diagnostics; defaults to `\"particles\"`.\n * @returns The handle, already loaded.\n *\n * @example\n * ```ts\n * const fire = particleAssetFromDefinition(app, particleDefinition(\"fire\"));\n * campfire.addComponent(ParticleSystem, { definition: fire });\n * ```\n *\n * @public\n */\nexport function particleAssetFromDefinition(\n app: App,\n definition: ParticleDefinition,\n name: string = \"particles\",\n): AssetHandle<ParticleAsset> {\n const address = definition.renderer.texture;\n const texture = address === null ? null : app.assets.load<TextureAsset>(address);\n return app.assets.register(new ParticleAsset(name, definition, texture, true), { type: PARTICLE_ASSET_TYPE });\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Motes in a shaft of light: tiny, slow, long-lived specks wandering on noise inside a flat box.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function dustPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 200, duration: 6, looping: true, prewarm: true },\n emission: { rateOverTime: 12 },\n shape: { kind: \"box\", size: { x: 4, y: 2, z: 4 }, randomDirection: 1 },\n start: {\n lifetime: { min: 4, max: 8 },\n speed: { min: 0.05, max: 0.15 },\n size: { min: 0.02, max: 0.05 },\n color: [0.9, 0.88, 0.8, 0.6],\n },\n forces: {\n noise: { strength: 0.2, frequency: 0.5, scroll: { x: 0.05, y: 0.02, z: 0.05 }, octaves: 2 },\n },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 0],\n [0.2, 1, 1, 1, 1],\n [0.8, 1, 1, 1, 1],\n [1, 1, 1, 1, 0],\n ],\n },\n },\n renderer: { mode: \"billboard\", blend: \"alpha\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * One blast: a single burst of fast fireballs from a small sphere that brake hard, swell, and fade.\n * Non-looping; `onStopped` fires when the last one is gone.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function explosionPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 256, duration: 1, looping: false },\n emission: { rateOverTime: 0, bursts: [{ time: 0, count: 150, cycles: 1 }] },\n shape: { kind: \"sphere\", radius: 0.15, randomDirection: 0.2 },\n start: {\n lifetime: { min: 0.6, max: 1.4 },\n speed: { min: 4, max: 9 },\n size: { min: 0.3, max: 0.7 },\n rotation: { min: -180, max: 180 },\n color: { min: [1, 0.3, 0.05, 1], max: [1, 0.7, 0.2, 1] },\n },\n forces: { gravityMultiplier: 0.3, drag: 2.5 },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 1],\n [0.5, 1, 0.8, 0.6, 0.8],\n [1, 0.3, 0.3, 0.3, 0],\n ],\n },\n size: {\n curve: {\n keys: [\n [0, 0.4, 0, 3],\n [0.3, 1, 0, 0],\n [1, 0.7, -0.5, 0],\n ],\n },\n },\n rotation: { min: -60, max: 60 },\n },\n renderer: { mode: \"billboard\", blend: \"additive\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * A campfire flame: a narrow upward cone of soft, additive, orange-to-yellow puffs that rise, shrink\n * and fade.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function firePresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 256, duration: 2, looping: true, prewarm: true },\n emission: { rateOverTime: 40 },\n shape: { kind: \"cone\", radius: 0.25, angle: 12 },\n start: {\n lifetime: { min: 0.8, max: 1.4 },\n speed: { min: 1, max: 2 },\n size: { min: 0.35, max: 0.6 },\n rotation: { min: -180, max: 180 },\n color: { min: [1, 0.35, 0.05, 1], max: [1, 0.85, 0.2, 1] },\n },\n forces: {\n gravityMultiplier: -0.25,\n drag: 1,\n noise: { strength: 0.15, frequency: 1.5, scroll: { x: 0, y: 0.6, z: 0 }, octaves: 1 },\n },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 0],\n [0.15, 1, 1, 1, 1],\n [1, 1, 0.6, 0.3, 0],\n ],\n },\n size: {\n curve: {\n keys: [\n [0, 1, 0, 0],\n [1, 0.15, -1, -1],\n ],\n },\n },\n },\n renderer: { mode: \"billboard\", blend: \"additive\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Autumn leaves over a six-metre patch: few, tumbling, orange-to-brown flakes that fall slowly and\n * wander on noise, in world space.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function leavesPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 128, duration: 6, looping: true, prewarm: true, simulationSpace: \"world\" },\n emission: { rateOverTime: 6 },\n shape: { kind: \"box\", size: { x: 6, y: 0.1, z: 6 } },\n start: {\n lifetime: { min: 4, max: 7 },\n speed: { min: -0.4, max: -0.8 },\n size: { min: 0.1, max: 0.18 },\n rotation: { min: -180, max: 180 },\n color: { min: [0.9, 0.45, 0.1, 1], max: [0.45, 0.25, 0.08, 1] },\n },\n forces: {\n gravityMultiplier: 0.05,\n drag: 0.5,\n noise: { strength: 0.6, frequency: 0.6, scroll: { x: 0.2, y: 0, z: 0.1 }, octaves: 2 },\n },\n overLifetime: {\n rotation: { min: -120, max: 120 },\n color: {\n gradient: [\n [0, 1, 1, 1, 1],\n [0.9, 1, 1, 1, 1],\n [1, 1, 1, 1, 0],\n ],\n },\n },\n renderer: { mode: \"billboard\", blend: \"alpha\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Rain over a twelve-metre patch: fast, thin, stretched drops falling straight down in world space.\n * Place the emitter entity above the ground.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function rainPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 2000, duration: 2, looping: true, prewarm: true, simulationSpace: \"world\" },\n emission: { rateOverTime: 600 },\n shape: { kind: \"box\", size: { x: 12, y: 0.1, z: 12 } },\n start: {\n lifetime: 1.2,\n speed: { min: -9, max: -11 },\n size: 0.02,\n color: [0.7, 0.8, 1, 0.5],\n },\n forces: { gravityMultiplier: 1 },\n renderer: { mode: \"stretched\", blend: \"alpha\", speedScale: 0.03, lengthScale: 1 },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * A slow grey plume: a wider cone than the fire, buoyant, drifting on noise, growing as it thins.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function smokePresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 128, duration: 4, looping: true, prewarm: true, renderOrder: 1 },\n emission: { rateOverTime: 12 },\n shape: { kind: \"cone\", radius: 0.3, angle: 20 },\n start: {\n lifetime: { min: 2, max: 3.5 },\n speed: { min: 0.6, max: 1.2 },\n size: { min: 0.5, max: 0.9 },\n rotation: { min: -180, max: 180 },\n color: { min: [0.35, 0.35, 0.38, 1], max: [0.6, 0.6, 0.62, 1] },\n },\n forces: {\n gravityMultiplier: -0.05,\n drag: 0.6,\n noise: { strength: 0.35, frequency: 0.8, scroll: { x: 0.1, y: 0.3, z: 0 }, octaves: 2 },\n },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 0],\n [0.2, 1, 1, 1, 0.5],\n [1, 1, 1, 1, 0],\n ],\n },\n size: {\n curve: {\n keys: [\n [0, 0.6, 0, 1],\n [1, 1.6, 1, 0],\n ],\n },\n },\n rotation: { min: -20, max: 20 },\n },\n renderer: { mode: \"billboard\", blend: \"premultiplied\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Snow over a ten-metre patch: slow, soft flakes that drift sideways on noise as they fall, in world\n * space. Place the emitter entity above the ground.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function snowPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 1000, duration: 6, looping: true, prewarm: true, simulationSpace: \"world\" },\n emission: { rateOverTime: 80 },\n shape: { kind: \"box\", size: { x: 10, y: 0.1, z: 10 } },\n start: {\n lifetime: { min: 5, max: 8 },\n speed: { min: -0.6, max: -1.2 },\n size: { min: 0.03, max: 0.07 },\n rotation: { min: -180, max: 180 },\n color: [1, 1, 1, 0.9],\n },\n forces: {\n noise: { strength: 0.4, frequency: 0.4, scroll: { x: 0.1, y: 0, z: 0.05 }, octaves: 1 },\n },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 0],\n [0.1, 1, 1, 1, 1],\n [0.9, 1, 1, 1, 1],\n [1, 1, 1, 1, 0],\n ],\n },\n rotation: { min: -45, max: 45 },\n },\n renderer: { mode: \"billboard\", blend: \"alpha\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Glints on a pickup: still, short-lived, spinning stars that pop in and out over a small sphere.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function sparklePresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 64, duration: 1, looping: true, prewarm: true },\n emission: { rateOverTime: 20 },\n shape: { kind: \"sphere\", radius: 0.6, thickness: 0.5 },\n start: {\n lifetime: { min: 0.3, max: 0.8 },\n speed: 0,\n size: { min: 0.05, max: 0.12 },\n rotation: { min: -180, max: 180 },\n color: { min: [1, 1, 1, 1], max: [0.6, 0.9, 1, 1] },\n },\n overLifetime: {\n size: {\n curve: {\n keys: [\n [0, 0, 0, 4],\n [0.5, 1, 0, 0],\n [1, 0, -4, 0],\n ],\n },\n },\n rotation: { min: -90, max: 90 },\n },\n renderer: { mode: \"billboard\", blend: \"additive\" },\n };\n}\n","import type { ParticleDefinitionInput } from \"../types.js\";\n\n/**\n * Embers thrown from a fire: bright stretched streaks in bursts every half second, pulled down by\n * gravity and slowed by drag.\n *\n * @returns The preset's document, as authored.\n *\n * @public\n */\nexport function sparksPresetInput(): ParticleDefinitionInput {\n return {\n format: \"ignifx.particles\",\n formatVersion: 1,\n main: { capacity: 200, duration: 2, looping: true },\n emission: {\n rateOverTime: 6,\n bursts: [{ time: 0, count: { min: 12, max: 24 }, cycles: 0, interval: 0.5, probability: 0.8 }],\n },\n shape: { kind: \"cone\", radius: 0.08, angle: 35 },\n start: {\n lifetime: { min: 0.4, max: 1.2 },\n speed: { min: 3, max: 7 },\n size: 0.035,\n color: { min: [1, 0.75, 0.3, 1], max: [1, 0.95, 0.7, 1] },\n },\n forces: { gravityMultiplier: 1, drag: 0.8 },\n overLifetime: {\n color: {\n gradient: [\n [0, 1, 1, 1, 1],\n [0.7, 1, 1, 1, 1],\n [1, 1, 0.4, 0.1, 0],\n ],\n },\n },\n renderer: { mode: \"stretched\", blend: \"additive\", speedScale: 0.04, lengthScale: 1.5 },\n };\n}\n","import { ParticlesErrorCode, particlesError } from \"../../errors.js\";\nimport { defineParticles } from \"../define-particles.js\";\nimport { dustPresetInput } from \"./dust.js\";\nimport { explosionPresetInput } from \"./explosion.js\";\nimport { firePresetInput } from \"./fire.js\";\nimport { leavesPresetInput } from \"./leaves.js\";\nimport { rainPresetInput } from \"./rain.js\";\nimport { smokePresetInput } from \"./smoke.js\";\nimport { snowPresetInput } from \"./snow.js\";\nimport { sparklePresetInput } from \"./sparkle.js\";\nimport { sparksPresetInput } from \"./sparks.js\";\nimport type { ParticleDefinition, ParticleDefinitionInput } from \"../types.js\";\n\n// The nine shipped presets: complete documents a fresh project can play with no asset file at all.\n\n/**\n * Every preset name, in the order the documentation lists them.\n *\n * @public\n */\nexport const PARTICLE_PRESETS = [\n \"fire\",\n \"smoke\",\n \"sparks\",\n \"explosion\",\n \"dust\",\n \"sparkle\",\n \"rain\",\n \"snow\",\n \"leaves\",\n] as const;\n\n/**\n * The union of {@link PARTICLE_PRESETS}.\n *\n * @public\n */\nexport type ParticlePreset = (typeof PARTICLE_PRESETS)[number];\n\n/**\n * A recursively optional view of a type: what an override of a preset looks like.\n *\n * @typeParam T - The type being made optional.\n *\n * @public\n */\nexport type DeepPartial<T> = T extends readonly unknown[]\n ? T\n : T extends object\n ? { readonly [K in keyof T]?: DeepPartial<T[K]> }\n : T;\n\n/**\n * The document a preset starts from, before any override.\n *\n * @param name - The preset.\n * @returns A fresh copy of the authored document.\n * @throws IgnifxError with code `IGX-1704` for a name that is not a preset.\n *\n * @public\n */\nexport function particlePresetInput(name: ParticlePreset): ParticleDefinitionInput {\n switch (name) {\n case \"fire\":\n return firePresetInput();\n case \"smoke\":\n return smokePresetInput();\n case \"sparks\":\n return sparksPresetInput();\n case \"explosion\":\n return explosionPresetInput();\n case \"dust\":\n return dustPresetInput();\n case \"sparkle\":\n return sparklePresetInput();\n case \"rain\":\n return rainPresetInput();\n case \"snow\":\n return snowPresetInput();\n case \"leaves\":\n return leavesPresetInput();\n default:\n throw particlesError(ParticlesErrorCode.unknownPreset, `${String(name)} is not a particle preset.`, {\n context: { preset: String(name), presets: PARTICLE_PRESETS.join(\", \") },\n hint: `The presets are ${PARTICLE_PRESETS.join(\", \")}.`,\n });\n }\n}\n\n/**\n * A preset, with any part of it overridden, as a complete definition. An object override merges key\n * by key; an array or a primitive replaces the whole value.\n *\n * @param name - The preset.\n * @param overrides - What to change.\n * @returns The definition, validated and baked.\n * @throws IgnifxError with code `IGX-1704` for an unknown preset, or `IGX-1701` when the overrides\n * make the document invalid.\n *\n * @example\n * ```ts\n * const bigFire = particleDefinition(\"fire\", { start: { size: { min: 0.8, max: 1.2 } } });\n * ```\n *\n * @public\n */\nexport function particleDefinition(\n name: ParticlePreset,\n overrides?: DeepPartial<ParticleDefinitionInput>,\n): ParticleDefinition {\n const base = particlePresetInput(name);\n const merged = overrides === undefined ? base : mergeDeep(base, overrides);\n return defineParticles(merged, `preset:${name}`);\n}\n\n/**\n * Merges an override onto a document, object by object.\n *\n * @param base - The document.\n * @param overrides - The changes.\n * @returns The merged document.\n */\nfunction mergeDeep(\n base: ParticleDefinitionInput,\n overrides: DeepPartial<ParticleDefinitionInput>,\n): ParticleDefinitionInput {\n // Boundary assertion (coding standards §5.2): the merge walks plain JSON, and `defineParticles`\n // validates every field of the result before anything reads it.\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion -- see above.\n return mergeRecords(base, overrides) as ParticleDefinitionInput;\n}\n\n/**\n * Merges two plain records recursively: objects merge, everything else is replaced. Only own keys\n * are read, and each result is defined rather than assigned, so an override key such as\n * `__proto__` (an own key in parsed JSON) stays a field that `defineParticles` then refuses,\n * instead of merging with `Object.prototype` and replacing the result's prototype.\n *\n * @param base - The record being overridden.\n * @param overrides - The overrides.\n * @returns A new record.\n */\nfunction mergeRecords(base: object, overrides: object): Record<string, unknown> {\n const out: Record<string, unknown> = { ...base };\n const source: Record<string, unknown> = { ...overrides };\n for (const key of Object.keys(source)) {\n const value = source[key];\n if (value === undefined) {\n continue;\n }\n const existing = Object.hasOwn(out, key) ? out[key] : undefined;\n const merged = isPlainRecord(value) && isPlainRecord(existing) ? mergeRecords(existing, value) : value;\n Object.defineProperty(out, key, { value: merged, enumerable: true, writable: true, configurable: true });\n }\n return out;\n}\n\n/**\n * Whether a value is a plain object rather than an array, a primitive, or `null`.\n *\n * @param value - The value.\n * @returns `true` for a record.\n */\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","// `pcg3d` (Jarzynski & Olano, JCGT 2020), the randomness both evaluators share\n// (ADR-0025). `Math.imul` and `>>> 0` keep every intermediate a `u32`, so this and the WGSL copy in\n// `src/gpu/wgsl.ts` produce identical bits.\n\n/** The LCG multiplier. */\nconst MULTIPLIER = 1664525;\n\n/** The LCG increment. */\nconst INCREMENT = 1013904223;\n\n/** `2^-32`, the factor that turns a `u32` into a unit float in `[0, 1)`. */\nconst UNIT_SCALE = 2.3283064365386963e-10;\n\n/** The second lane every per-particle hash is salted with. */\nexport const PARTICLE_SALT_Y = 0x9e3779b9;\n\n/** The third lane every per-particle hash is salted with. */\nexport const PARTICLE_SALT_Z = 0x85ebca6b;\n\n/** The salt the per-record `seed` is derived from the system seed and record index with. */\nexport const RECORD_SEED_SALT = 0x1b873593;\n\n/**\n * Hashes three 32-bit words into three others, bit-identically to the WGSL `pcg3d`.\n *\n * @param x - The first lane; any number, wrapped to `u32`.\n * @param y - The second lane.\n * @param z - The third lane.\n * @param out - Receives the three hashed words.\n * @returns `out`.\n *\n * @beta\n */\nexport function pcg3d(x: number, y: number, z: number, out: Uint32Array): Uint32Array {\n let vx = (Math.imul(x >>> 0, MULTIPLIER) + INCREMENT) >>> 0;\n let vy = (Math.imul(y >>> 0, MULTIPLIER) + INCREMENT) >>> 0;\n let vz = (Math.imul(z >>> 0, MULTIPLIER) + INCREMENT) >>> 0;\n vx = (vx + Math.imul(vy, vz)) >>> 0;\n vy = (vy + Math.imul(vz, vx)) >>> 0;\n vz = (vz + Math.imul(vx, vy)) >>> 0;\n vx = (vx ^ (vx >>> 16)) >>> 0;\n vy = (vy ^ (vy >>> 16)) >>> 0;\n vz = (vz ^ (vz >>> 16)) >>> 0;\n vx = (vx + Math.imul(vy, vz)) >>> 0;\n vy = (vy + Math.imul(vz, vx)) >>> 0;\n vz = (vz + Math.imul(vx, vy)) >>> 0;\n out[0] = vx;\n out[1] = vy;\n out[2] = vz;\n return out;\n}\n\n/**\n * Turns a hashed word into a unit float in `[0, 1)` — the same `f32(h) * 2^-32` the shader uses.\n *\n * @param word - A `u32`.\n * @returns The unit float.\n *\n * @beta\n */\nexport function hashToUnit(word: number): number {\n return (word >>> 0) * UNIT_SCALE;\n}\n\n/**\n * The three unit floats every per-particle derivation reads from a record's `seed`: the start\n * colour pick, the angular speed pick, and the sheet's random frame.\n *\n * @param seed - The record's `seed` word.\n * @param out - Receives three floats in `[0, 1)`.\n * @param scratch - Three words of scratch space.\n * @returns `out`.\n *\n * @beta\n */\nexport function particleUnits(seed: number, out: Float32Array, scratch: Uint32Array): Float32Array {\n pcg3d(seed, PARTICLE_SALT_Y, PARTICLE_SALT_Z, scratch);\n out[0] = hashToUnit(scratch[0] ?? 0);\n out[1] = hashToUnit(scratch[1] ?? 0);\n out[2] = hashToUnit(scratch[2] ?? 0);\n return out;\n}\n\n/**\n * The `seed` word a record gets from the system seed and its index.\n *\n * @param systemSeed - The system's seed.\n * @param index - The record's index since `play()`.\n * @param scratch - Three words of scratch space.\n * @returns The record seed.\n *\n * @beta\n */\nexport function recordSeed(systemSeed: number, index: number, scratch: Uint32Array): number {\n pcg3d(systemSeed, index, RECORD_SEED_SALT, scratch);\n return scratch[0] ?? 0;\n}\n\n/**\n * A deterministic stream of unit floats for the emission scheduler, drawn from `pcg3d` over a\n * counter so two systems with the same seed and the same frame deltas roll the same numbers.\n *\n * @beta\n */\nexport class EmitterRandom {\n readonly #words = new Uint32Array(3);\n\n #seed = 0;\n\n #counter = 0;\n\n #remaining = 0;\n\n /**\n * Creates a stream.\n *\n * @param seed - The seed to start from.\n */\n constructor(seed: number) {\n this.reseed(seed);\n }\n\n /**\n * The seed the stream runs on.\n *\n * @returns The seed.\n */\n get seed(): number {\n return this.#seed;\n }\n\n /**\n * Restarts the stream from a seed.\n *\n * @param seed - The new seed.\n */\n reseed(seed: number): void {\n this.#seed = seed >>> 0;\n this.#counter = 0;\n this.#remaining = 0;\n }\n\n /**\n * The next unit float in `[0, 1)`.\n *\n * @returns The number.\n */\n next(): number {\n if (this.#remaining === 0) {\n pcg3d(this.#seed, this.#counter, PARTICLE_SALT_Z, this.#words);\n this.#counter = (this.#counter + 1) >>> 0;\n this.#remaining = 3;\n }\n this.#remaining -= 1;\n return hashToUnit(this.#words[this.#remaining] ?? 0);\n }\n}\n","// The CPU mirror of the storage buffer the vertex shader indexes\n// (ADR-0025). A record is 48 bytes in the byte order the WGSL `Particle` struct declares, so it\n// uploads unchanged.\n\n/**\n * Floats per record.\n *\n * @beta\n */\nexport const RECORD_FLOATS = 12;\n\n/**\n * Bytes per record, matching the WGSL `Particle` struct's size.\n *\n * @beta\n */\nexport const RECORD_BYTES: number = RECORD_FLOATS * 4;\n\n/**\n * The float index of `spawnTime` inside a record.\n *\n * @beta\n */\nexport const RECORD_SPAWN_TIME = 0;\n\n/**\n * The float index of `lifetime` inside a record.\n *\n * @beta\n */\nexport const RECORD_LIFETIME = 1;\n\n/**\n * The word index of `seed` inside a record; read it from the ring's `words`, not its floats.\n *\n * @beta\n */\nexport const RECORD_SEED = 2;\n\n/** The word index of `flags` inside a record. */\nexport const RECORD_FLAGS = 3;\n\n/**\n * The float index of `position.x` inside a record.\n *\n * @beta\n */\nexport const RECORD_POSITION = 4;\n\n/**\n * The float index of `size` inside a record.\n *\n * @beta\n */\nexport const RECORD_SIZE = 7;\n\n/**\n * The float index of `velocity.x` inside a record.\n *\n * @beta\n */\nexport const RECORD_VELOCITY = 8;\n\n/**\n * The float index of `rotation` inside a record, in radians.\n *\n * @beta\n */\nexport const RECORD_ROTATION = 11;\n\n/**\n * A contiguous run of records to upload, in slots.\n *\n * @beta\n */\nexport interface UploadRange {\n /** The first slot. */\n readonly start: number;\n /** How many records. */\n readonly count: number;\n}\n\n/**\n * What one reconciliation pass found.\n *\n * @beta\n */\nexport interface RingCensus {\n /** Records whose age is inside their lifetime. Exact. */\n alive: number;\n /** Records from the newest back to the oldest still alive: what the GPU draws. */\n drawCount: number;\n}\n\n/**\n * The CPU copy of a system's spawn records. Record `n` lives in slot `n % capacity`, so the newest\n * record is the one the shader draws first and an overwritten record simply disappears.\n *\n * @beta\n */\nexport class SpawnRecordRing {\n /** How many records the ring holds. */\n readonly capacity: number;\n\n /** The records as floats, `capacity * RECORD_FLOATS` long. */\n readonly floats: Float32Array;\n\n /** The same bytes as words, for `seed` and `flags`. */\n readonly words: Uint32Array;\n\n #written = 0;\n\n #uploaded = 0;\n\n #tail = 0;\n\n readonly #rangeA: { start: number; count: number } = { start: 0, count: 0 };\n\n readonly #rangeB: { start: number; count: number } = { start: 0, count: 0 };\n\n /**\n * Allocates a ring.\n *\n * @param capacity - How many records it holds; at least one.\n */\n constructor(capacity: number) {\n this.capacity = Math.max(1, Math.trunc(capacity));\n const buffer = new ArrayBuffer(this.capacity * RECORD_BYTES);\n this.floats = new Float32Array(buffer);\n this.words = new Uint32Array(buffer);\n }\n\n /**\n * How many records have been written since the last clear.\n *\n * @returns The count; it never decreases except through {@link SpawnRecordRing.clear}.\n */\n get written(): number {\n return this.#written;\n }\n\n /**\n * The slot the next record goes into.\n *\n * @returns `written % capacity`.\n */\n get head(): number {\n return this.#written % this.capacity;\n }\n\n /**\n * The index of the oldest record still inside the draw window.\n *\n * @returns The record index, not the slot.\n */\n get tail(): number {\n return this.#tail;\n }\n\n /**\n * How many records have been written and not yet uploaded, capped at the capacity because older\n * ones were overwritten anyway.\n *\n * @returns The pending count.\n */\n get pendingCount(): number {\n return Math.min(this.#written - this.#uploaded, this.capacity);\n }\n\n /**\n * The slot of a record.\n *\n * @param index - The record index.\n * @returns The slot.\n */\n slotOf(index: number): number {\n return index % this.capacity;\n }\n\n /**\n * Writes one record and returns its slot.\n *\n * @param spawnTime - The system clock at spawn.\n * @param lifetime - Seconds the particle lives.\n * @param seed - The per-record hash seed.\n * @param flags - Reserved; write `0`.\n * @param px - Start position X.\n * @param py - Start position Y.\n * @param pz - Start position Z.\n * @param size - Start size.\n * @param vx - Start velocity X.\n * @param vy - Start velocity Y.\n * @param vz - Start velocity Z.\n * @param rotation - Start rotation, in radians.\n * @returns The slot written.\n */\n write(\n spawnTime: number,\n lifetime: number,\n seed: number,\n flags: number,\n px: number,\n py: number,\n pz: number,\n size: number,\n vx: number,\n vy: number,\n vz: number,\n rotation: number,\n ): number {\n const slot = this.#written % this.capacity;\n const base = slot * RECORD_FLOATS;\n const floats = this.floats;\n const words = this.words;\n floats[base + RECORD_SPAWN_TIME] = spawnTime;\n floats[base + RECORD_LIFETIME] = lifetime;\n words[base + RECORD_SEED] = seed >>> 0;\n words[base + RECORD_FLAGS] = flags >>> 0;\n floats[base + RECORD_POSITION] = px;\n floats[base + RECORD_POSITION + 1] = py;\n floats[base + RECORD_POSITION + 2] = pz;\n floats[base + RECORD_SIZE] = size;\n floats[base + RECORD_VELOCITY] = vx;\n floats[base + RECORD_VELOCITY + 1] = vy;\n floats[base + RECORD_VELOCITY + 2] = vz;\n floats[base + RECORD_ROTATION] = rotation;\n this.#written += 1;\n return slot;\n }\n\n /**\n * The runs of slots written since the last upload, at most two because a ring wraps at most once\n * per frame that matters — anything older than a whole ring was overwritten.\n *\n * @param out - Receives up to two ranges.\n * @returns How many of `out`'s entries are meaningful: `0`, `1`, or `2`.\n */\n pendingRanges(out: [UploadRange, UploadRange]): number {\n const pending = this.pendingCount;\n if (pending === 0) {\n return 0;\n }\n if (pending >= this.capacity) {\n this.#rangeA.start = 0;\n this.#rangeA.count = this.capacity;\n out[0] = this.#rangeA;\n return 1;\n }\n const startIndex = this.#written - pending;\n const startSlot = startIndex % this.capacity;\n const endSlot = startSlot + pending;\n if (endSlot <= this.capacity) {\n this.#rangeA.start = startSlot;\n this.#rangeA.count = pending;\n out[0] = this.#rangeA;\n return 1;\n }\n this.#rangeA.start = startSlot;\n this.#rangeA.count = this.capacity - startSlot;\n this.#rangeB.start = 0;\n this.#rangeB.count = endSlot - this.capacity;\n out[0] = this.#rangeA;\n out[1] = this.#rangeB;\n return 2;\n }\n\n /** Records that everything written so far has reached the GPU. */\n markUploaded(): void {\n this.#uploaded = this.#written;\n }\n\n /**\n * Advances the tail past leading dead records and counts the alive ones behind it. One pass over\n * the draw window, no allocation.\n *\n * @param clock - The system clock.\n * @param out - Receives the counts.\n * @returns `out`.\n */\n reconcile(clock: number, out: RingCensus): RingCensus {\n const written = this.#written;\n const capacity = this.capacity;\n const floats = this.floats;\n // The shader reads the clock as an `f32` uniform, and a spawn time is rounded to `f32` on the\n // way into the ring. Comparing in `f32` here is what stops a particle born this frame from\n // looking unborn and being left behind the tail for ever.\n const now = Math.fround(clock);\n let tail = Math.max(this.#tail, written - capacity);\n while (tail < written && isDead(floats, (tail % capacity) * RECORD_FLOATS, now)) {\n tail += 1;\n }\n this.#tail = tail;\n let alive = 0;\n for (let index = tail; index < written; index += 1) {\n if (!isDead(floats, (index % capacity) * RECORD_FLOATS, now)) {\n alive += 1;\n }\n }\n out.alive = alive;\n out.drawCount = written - tail;\n return out;\n }\n\n /** Forgets every record, so the next frame draws nothing and uploads nothing. */\n clear(): void {\n this.#written = 0;\n this.#uploaded = 0;\n this.#tail = 0;\n }\n}\n\n/**\n * Whether a record is dead at a clock: the same rule the shader applies, `age < 0 || age > lifetime`.\n *\n * @param floats - The ring's floats.\n * @param base - The record's first float index.\n * @param clock - The system clock, already rounded to `f32` by the caller.\n * @returns `true` when the shader would collapse the record.\n */\nexport function isDead(floats: Float32Array, base: number, clock: number): boolean {\n const age = clock - (floats[base + RECORD_SPAWN_TIME] ?? 0);\n return age < 0 || age > (floats[base + RECORD_LIFETIME] ?? 0);\n}\n","import { hashToUnit, pcg3d } from \"../emitter/pcg3d.js\";\n\n// The positional noise both evaluators add (ADR-0025): classic lattice gradient noise with a\n// quintic fade, hashed per corner with `pcg3d`. The WGSL in `src/gpu/wgsl.ts` is the same code, and\n// negative cells hash the same on both hosts.\n\n/** The offset of the second noise channel. */\nconst OFFSET_Y: readonly number[] = Object.freeze([31.4, 47.2, 12.9]);\n\n/** The offset of the third noise channel. */\nconst OFFSET_Z: readonly number[] = Object.freeze([-17.3, 8.6, 53.1]);\n\n/**\n * The quintic fade both hosts blend with.\n *\n * @param t - The fraction inside the cell.\n * @returns The eased fraction.\n */\nfunction fade(t: number): number {\n return t * t * t * (t * (t * 6 - 15) + 10);\n}\n\n/**\n * The dot product of a corner's hashed gradient with the offset from that corner.\n *\n * @param ix - The corner's lattice X.\n * @param iy - The corner's lattice Y.\n * @param iz - The corner's lattice Z.\n * @param dx - The offset from the corner.\n * @param dy - The offset from the corner.\n * @param dz - The offset from the corner.\n * @param scratch - Three words of scratch space.\n * @returns The corner's contribution before blending.\n */\nfunction corner(ix: number, iy: number, iz: number, dx: number, dy: number, dz: number, scratch: Uint32Array): number {\n pcg3d(ix >>> 0, iy >>> 0, iz >>> 0, scratch);\n const gx = hashToUnit(scratch[0] ?? 0) * 2 - 1;\n const gy = hashToUnit(scratch[1] ?? 0) * 2 - 1;\n const gz = hashToUnit(scratch[2] ?? 0) * 2 - 1;\n return gx * dx + gy * dy + gz * dz;\n}\n\n/**\n * One scalar of lattice gradient noise at a point.\n *\n * @param x - The sample position.\n * @param y - The sample position.\n * @param z - The sample position.\n * @param scratch - Three words of scratch space.\n * @returns The noise value, in roughly `[-1, 1]`.\n *\n * @beta\n */\nexport function gradientNoise(x: number, y: number, z: number, scratch: Uint32Array): number {\n const ix = Math.floor(x);\n const iy = Math.floor(y);\n const iz = Math.floor(z);\n const fx = x - ix;\n const fy = y - iy;\n const fz = z - iz;\n const ux = fade(fx);\n const uy = fade(fy);\n const uz = fade(fz);\n const c000 = corner(ix, iy, iz, fx, fy, fz, scratch);\n const c100 = corner(ix + 1, iy, iz, fx - 1, fy, fz, scratch);\n const c010 = corner(ix, iy + 1, iz, fx, fy - 1, fz, scratch);\n const c110 = corner(ix + 1, iy + 1, iz, fx - 1, fy - 1, fz, scratch);\n const c001 = corner(ix, iy, iz + 1, fx, fy, fz - 1, scratch);\n const c101 = corner(ix + 1, iy, iz + 1, fx - 1, fy, fz - 1, scratch);\n const c011 = corner(ix, iy + 1, iz + 1, fx, fy - 1, fz - 1, scratch);\n const c111 = corner(ix + 1, iy + 1, iz + 1, fx - 1, fy - 1, fz - 1, scratch);\n const x00 = c000 + (c100 - c000) * ux;\n const x10 = c010 + (c110 - c010) * ux;\n const x01 = c001 + (c101 - c001) * ux;\n const x11 = c011 + (c111 - c011) * ux;\n const y0 = x00 + (x10 - x00) * uy;\n const y1 = x01 + (x11 - x01) * uy;\n return y0 + (y1 - y0) * uz;\n}\n\n/**\n * Three decorrelated noise channels at a point, summed over one or two octaves.\n *\n * @param x - The sample position.\n * @param y - The sample position.\n * @param z - The sample position.\n * @param octaves - `1` or `2`.\n * @param scratch - Three words of scratch space.\n * @param out - Receives the three channels.\n * @returns `out`.\n *\n * @beta\n */\nexport function noise3(\n x: number,\n y: number,\n z: number,\n octaves: number,\n scratch: Uint32Array,\n out: Float32Array,\n): Float32Array {\n let nx = gradientNoise(x, y, z, scratch);\n let ny = gradientNoise(x + (OFFSET_Y[0] ?? 0), y + (OFFSET_Y[1] ?? 0), z + (OFFSET_Y[2] ?? 0), scratch);\n let nz = gradientNoise(x + (OFFSET_Z[0] ?? 0), y + (OFFSET_Z[1] ?? 0), z + (OFFSET_Z[2] ?? 0), scratch);\n if (octaves >= 2) {\n const x2 = x * 2;\n const y2 = y * 2;\n const z2 = z * 2;\n nx += 0.5 * gradientNoise(x2, y2, z2, scratch);\n ny += 0.5 * gradientNoise(x2 + (OFFSET_Y[0] ?? 0), y2 + (OFFSET_Y[1] ?? 0), z2 + (OFFSET_Y[2] ?? 0), scratch);\n nz += 0.5 * gradientNoise(x2 + (OFFSET_Z[0] ?? 0), y2 + (OFFSET_Z[1] ?? 0), z2 + (OFFSET_Z[2] ?? 0), scratch);\n }\n out[0] = nx;\n out[1] = ny;\n out[2] = nz;\n return out;\n}\n","import { LOOKUP_SAMPLES } from \"../definition/types.js\";\nimport { srgbToLinear } from \"../definition/values.js\";\nimport { particleUnits } from \"../emitter/pcg3d.js\";\nimport {\n RECORD_FLOATS,\n RECORD_LIFETIME,\n RECORD_POSITION,\n RECORD_ROTATION,\n RECORD_SEED,\n RECORD_SIZE,\n RECORD_SPAWN_TIME,\n RECORD_VELOCITY,\n} from \"../emitter/record-ring.js\";\nimport { noise3 } from \"./noise.js\";\nimport type { LookupRow, ParticleDefinition } from \"../definition/types.js\";\n\n// The CPU evaluator: one spawn record and a clock in, the particle's whole state out\n// (ADR-0025). The WGSL in `src/gpu/wgsl.ts` computes exactly this from the same bytes;\n// `test/gpu/conformance.browser.test.ts` holds the two together.\n\n/** Degrees to radians. */\nconst DEG_TO_RAD = Math.PI / 180;\n\n/** Bytes per lookup texel. */\nconst TEXEL_BYTES = 4;\n\n/** The reciprocal of a byte's range. */\nconst BYTE_SCALE = 1 / 255;\n\n/**\n * Everything a particle is at one instant.\n *\n * @beta\n */\nexport interface ParticleState {\n /** The world position. */\n readonly position: Float32Array;\n /** The world velocity. */\n readonly velocity: Float32Array;\n /** The size along each axis, in metres. */\n readonly size: Float32Array;\n /** Linear red, green, blue, and straight alpha. */\n readonly color: Float32Array;\n /** The rotation about the view axis (or the mesh's spin axis), in radians. */\n rotation: number;\n /** The sprite-sheet frame, or `0` without a sheet. */\n frame: number;\n /** Seconds since spawn. */\n age: number;\n /** `age / lifetime`, in `[0, 1]`. */\n life: number;\n}\n\n/**\n * Allocates an empty state.\n *\n * @returns A state with every field zeroed.\n *\n * @beta\n */\nexport function createParticleState(): ParticleState {\n return {\n position: new Float32Array(3),\n velocity: new Float32Array(3),\n size: new Float32Array(3),\n color: new Float32Array(4),\n rotation: 0,\n frame: 0,\n age: 0,\n life: 0,\n };\n}\n\n/**\n * The per-system inputs the evaluator needs beyond the definition.\n *\n * @beta\n */\nexport interface ParticleEvaluationInputs {\n /** The definition every record was written from. */\n readonly definition: ParticleDefinition;\n /** The effective gravity plus constant force, in the simulation space. */\n readonly gravity: Float32Array;\n /** The emitter's current world matrix, for a `\"local\"` definition; ignored for `\"world\"`. */\n readonly emitterWorld: Float32Array;\n /** The orbit centre in the simulation space: the origin for `\"local\"`, the emitter's position for `\"world\"`. */\n readonly orbitCenter: Float32Array;\n}\n\n/** Scratch space the evaluator reuses; created once per module use, never per call. */\ninterface EvaluatorScratch {\n readonly words: Uint32Array;\n readonly units: Float32Array;\n readonly rgba: Float32Array;\n readonly noise: Float32Array;\n}\n\n/** The scratch, allocated on first use. */\nlet scratch: EvaluatorScratch | null = null;\n\n/**\n * The shared scratch space.\n *\n * @returns The scratch arrays.\n */\nfunction scratchSpace(): EvaluatorScratch {\n scratch ??= {\n words: new Uint32Array(3),\n units: new Float32Array(3),\n rgba: new Float32Array(4),\n noise: new Float32Array(3),\n };\n return scratch;\n}\n\n/**\n * Evaluates one record at a clock.\n *\n * @param inputs - The definition and the per-system values.\n * @param floats - The ring's floats.\n * @param words - The ring's words.\n * @param slot - Which record.\n * @param clock - The system clock.\n * @param out - Receives the state.\n * @returns `true` when the particle is alive; `false` leaves `out` untouched.\n *\n * @beta\n */\nexport function evaluateParticle(\n inputs: ParticleEvaluationInputs,\n floats: Float32Array,\n words: Uint32Array,\n slot: number,\n clock: number,\n out: ParticleState,\n): boolean {\n const base = slot * RECORD_FLOATS;\n const spawn = floats[base + RECORD_SPAWN_TIME] ?? 0;\n const lifetime = floats[base + RECORD_LIFETIME] ?? 0;\n // The shader's `clock` uniform is an `f32`, and so is the record; rounding here is what keeps the\n // two evaluators agreeing about which particles exist.\n const age = Math.fround(clock) - spawn;\n if (age < 0 || age > lifetime || lifetime <= 0) {\n return false;\n }\n const definition = inputs.definition;\n const life = age / lifetime;\n const t = age;\n const s = scratchSpace();\n const position = out.position;\n const velocity = out.velocity;\n\n const gx = inputs.gravity[0] ?? 0;\n const gy = inputs.gravity[1] ?? 0;\n const gz = inputs.gravity[2] ?? 0;\n const p0x = floats[base + RECORD_POSITION] ?? 0;\n const p0y = floats[base + RECORD_POSITION + 1] ?? 0;\n const p0z = floats[base + RECORD_POSITION + 2] ?? 0;\n const v0x = floats[base + RECORD_VELOCITY] ?? 0;\n const v0y = floats[base + RECORD_VELOCITY + 1] ?? 0;\n const v0z = floats[base + RECORD_VELOCITY + 2] ?? 0;\n const k = definition.forces.drag;\n if (k > 0) {\n const inverse = 1 / k;\n const e = Math.exp(-k * t);\n const ax = v0x - gx * inverse;\n const ay = v0y - gy * inverse;\n const az = v0z - gz * inverse;\n const settle = (1 - e) * inverse;\n position[0] = p0x + ax * settle + gx * inverse * t;\n position[1] = p0y + ay * settle + gy * inverse * t;\n position[2] = p0z + az * settle + gz * inverse * t;\n velocity[0] = ax * e + gx * inverse;\n velocity[1] = ay * e + gy * inverse;\n velocity[2] = az * e + gz * inverse;\n } else {\n const half = 0.5 * t * t;\n position[0] = p0x + v0x * t + gx * half;\n position[1] = p0y + v0y * t + gy * half;\n position[2] = p0z + v0z * t + gz * half;\n velocity[0] = v0x + gx * t;\n velocity[1] = v0y + gy * t;\n velocity[2] = v0z + gz * t;\n }\n\n const orbit = definition.forces.orbit;\n if (orbit !== null) {\n const angle = orbit.speed * DEG_TO_RAD * t;\n rotateAbout(position, inputs.orbitCenter, orbit.axis.x, orbit.axis.y, orbit.axis.z, angle);\n rotateAbout(velocity, null, orbit.axis.x, orbit.axis.y, orbit.axis.z, angle);\n }\n\n const noise = definition.forces.noise;\n if (noise !== null) {\n const fallback = noise.influenceOverLife.kind === \"constant\" ? noise.influenceOverLife.value : 1;\n const amount = noise.strength * readScalarRow(definition, definition.lookup.noise, life, 0, fallback);\n if (amount !== 0) {\n const frequency = noise.frequency;\n noise3(\n position[0] * frequency + noise.scroll.x * t,\n position[1] * frequency + noise.scroll.y * t,\n position[2] * frequency + noise.scroll.z * t,\n noise.octaves,\n s.words,\n s.noise,\n );\n position[0] += amount * (s.noise[0] ?? 0);\n position[1] += amount * (s.noise[1] ?? 0);\n position[2] += amount * (s.noise[2] ?? 0);\n }\n }\n\n if (definition.main.simulationSpace === \"local\") {\n transformPoint(inputs.emitterWorld, position);\n transformDirection(inputs.emitterWorld, velocity);\n }\n\n const seed = words[base + RECORD_SEED] ?? 0;\n particleUnits(seed, s.units, s.words);\n\n // Colour: the start colour (a constant or a pick between two) times the gradient row, both sRGB,\n // decoded to linear once multiplied.\n const start = definition.start.color;\n if (start.kind === \"random\") {\n const u = s.units[0] ?? 0;\n s.rgba[0] = start.min.r + (start.max.r - start.min.r) * u;\n s.rgba[1] = start.min.g + (start.max.g - start.min.g) * u;\n s.rgba[2] = start.min.b + (start.max.b - start.min.b) * u;\n s.rgba[3] = start.min.a + (start.max.a - start.min.a) * u;\n } else {\n const value = start.kind === \"constant\" ? start.value : { r: 1, g: 1, b: 1, a: 1 };\n s.rgba[0] = value.r;\n s.rgba[1] = value.g;\n s.rgba[2] = value.b;\n s.rgba[3] = value.a;\n }\n const colorRow = definition.lookup.color;\n if (colorRow !== null) {\n const texel = sampleTexel(life);\n const pixels = definition.lookup.pixels;\n const rowBase = colorRow.index * LOOKUP_SAMPLES * TEXEL_BYTES;\n s.rgba[0] *= lerpByte(pixels, rowBase, texel, 0);\n s.rgba[1] *= lerpByte(pixels, rowBase, texel, 1);\n s.rgba[2] *= lerpByte(pixels, rowBase, texel, 2);\n s.rgba[3] *= lerpByte(pixels, rowBase, texel, 3);\n }\n out.color[0] = srgbToLinear(s.rgba[0]);\n out.color[1] = srgbToLinear(s.rgba[1]);\n out.color[2] = srgbToLinear(s.rgba[2]);\n out.color[3] = s.rgba[3];\n\n // Size: the record's size, the per-axis multipliers, and the size row per axis.\n const size0 = floats[base + RECORD_SIZE] ?? 0;\n const size3D = definition.start.size3D;\n out.size[0] = size0 * (size3D?.x ?? 1);\n out.size[1] = size0 * (size3D?.y ?? 1);\n out.size[2] = size0 * (size3D?.z ?? 1);\n const sizeRow = definition.lookup.size;\n if (sizeRow !== null) {\n out.size[0] *= readScalarRow(definition, sizeRow, life, 0, 1);\n out.size[1] *= readScalarRow(definition, sizeRow, life, 1, 1);\n out.size[2] *= readScalarRow(definition, sizeRow, life, 2, 1);\n }\n\n // Rotation: the start rotation plus the angular speed, which is a constant, a pick between two, or\n // a row sampled at this instant.\n let angular = 0;\n const rotation = definition.overLifetime.rotation;\n if (rotation !== null) {\n if (rotation.kind === \"constant\") {\n angular = rotation.value;\n } else if (rotation.kind === \"random\") {\n angular = rotation.min + (rotation.max - rotation.min) * (s.units[1] ?? 0);\n } else {\n angular = readScalarRow(definition, definition.lookup.rotation, life, 0, 0);\n }\n }\n out.rotation = (floats[base + RECORD_ROTATION] ?? 0) + angular * DEG_TO_RAD * t;\n\n // Frame: the sheet rule.\n const sheet = definition.renderer.sheet;\n if (sheet === null) {\n out.frame = 0;\n } else {\n const count = sheet.tiles.x * sheet.tiles.y;\n if (sheet.mode === \"random\") {\n out.frame = Math.min(count - 1, Math.floor((s.units[2] ?? 0) * count));\n } else if (sheet.mode === \"fps\") {\n out.frame = Math.floor((s.units[2] ?? 0) * count + sheet.fps * t) % count;\n } else {\n const fraction = readScalarRow(definition, definition.lookup.frame, life, 0, 0);\n out.frame = Math.max(0, Math.min(count - 1, Math.floor(fraction * count)));\n }\n }\n out.age = age;\n out.life = life;\n return true;\n}\n\n/**\n * Rotates a vector about an axis through a centre by an angle (Rodrigues' formula), in place.\n *\n * @param vector - The vector, or a point when `center` is given.\n * @param center - The centre of rotation, or `null` to rotate a direction.\n * @param ax - The unit axis.\n * @param ay - The unit axis.\n * @param az - The unit axis.\n * @param angle - The angle in radians.\n */\nfunction rotateAbout(\n vector: Float32Array,\n center: Float32Array | null,\n ax: number,\n ay: number,\n az: number,\n angle: number,\n): void {\n const cx = center?.[0] ?? 0;\n const cy = center?.[1] ?? 0;\n const cz = center?.[2] ?? 0;\n const ox = (vector[0] ?? 0) - cx;\n const oy = (vector[1] ?? 0) - cy;\n const oz = (vector[2] ?? 0) - cz;\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n const dot = ax * ox + ay * oy + az * oz;\n const crossX = ay * oz - az * oy;\n const crossY = az * ox - ax * oz;\n const crossZ = ax * oy - ay * ox;\n const k = 1 - cos;\n vector[0] = cx + ox * cos + crossX * sin + ax * dot * k;\n vector[1] = cy + oy * cos + crossY * sin + ay * dot * k;\n vector[2] = cz + oz * cos + crossZ * sin + az * dot * k;\n}\n\n/**\n * Transforms a point by a column-major matrix, in place.\n *\n * @param m - Sixteen floats.\n * @param p - The point.\n */\nexport function transformPoint(m: Float32Array, p: Float32Array): void {\n const x = p[0] ?? 0;\n const y = p[1] ?? 0;\n const z = p[2] ?? 0;\n p[0] = (m[0] ?? 1) * x + (m[4] ?? 0) * y + (m[8] ?? 0) * z + (m[12] ?? 0);\n p[1] = (m[1] ?? 0) * x + (m[5] ?? 1) * y + (m[9] ?? 0) * z + (m[13] ?? 0);\n p[2] = (m[2] ?? 0) * x + (m[6] ?? 0) * y + (m[10] ?? 1) * z + (m[14] ?? 0);\n}\n\n/**\n * Transforms a direction by the upper-left 3x3 of a column-major matrix, in place.\n *\n * @param m - Sixteen floats.\n * @param d - The direction.\n */\nexport function transformDirection(m: Float32Array, d: Float32Array): void {\n const x = d[0] ?? 0;\n const y = d[1] ?? 0;\n const z = d[2] ?? 0;\n d[0] = (m[0] ?? 1) * x + (m[4] ?? 0) * y + (m[8] ?? 0) * z;\n d[1] = (m[1] ?? 0) * x + (m[5] ?? 1) * y + (m[9] ?? 0) * z;\n d[2] = (m[2] ?? 0) * x + (m[6] ?? 0) * y + (m[10] ?? 1) * z;\n}\n\n/** The two texels and the weight a lookup sample blends, reused across calls. */\nconst texelScratch = { index: 0, next: 0, weight: 0 };\n\n/**\n * Where along a row a normalized time lands: the same `x = t * 63` rule the shader's texture\n * coordinate `(t * 63 + 0.5) / 64` produces under linear filtering with clamp addressing.\n *\n * @param life - The normalized time.\n * @returns The scratch descriptor.\n */\nfunction sampleTexel(life: number): typeof texelScratch {\n const clamped = life <= 0 ? 0 : life >= 1 ? 1 : life;\n const x = clamped * (LOOKUP_SAMPLES - 1);\n const index = Math.floor(x);\n texelScratch.index = index;\n texelScratch.next = index + 1 >= LOOKUP_SAMPLES ? index : index + 1;\n texelScratch.weight = x - index;\n return texelScratch;\n}\n\n/**\n * Linearly interpolates one channel between two texels of a row, as a `0`–`1` fraction.\n *\n * @param pixels - The lookup bytes.\n * @param rowBase - The row's first byte.\n * @param texel - The sample descriptor.\n * @param channel - `0`–`3`.\n * @returns The blended channel.\n */\nfunction lerpByte(pixels: Uint8Array, rowBase: number, texel: typeof texelScratch, channel: number): number {\n const a = (pixels[rowBase + texel.index * TEXEL_BYTES + channel] ?? 0) * BYTE_SCALE;\n const b = (pixels[rowBase + texel.next * TEXEL_BYTES + channel] ?? 0) * BYTE_SCALE;\n return a + (b - a) * texel.weight;\n}\n\n/**\n * Reads a scalar row's decoded value at a normalized time.\n *\n * @param definition - The definition.\n * @param row - The row, or `null` to return `fallback`.\n * @param life - The normalized time.\n * @param channel - Which channel holds the value.\n * @param fallback - What to return when the row is absent.\n * @returns The decoded value.\n *\n * @beta\n */\nexport function readScalarRow(\n definition: ParticleDefinition,\n row: LookupRow | null,\n life: number,\n channel: number,\n fallback: number,\n): number {\n if (row === null) {\n return fallback;\n }\n const texel = sampleTexel(life);\n const fraction = lerpByte(definition.lookup.pixels, row.index * LOOKUP_SAMPLES * TEXEL_BYTES, texel, channel);\n return row.min + fraction * (row.max - row.min);\n}\n","import type { EmitterRandom } from \"./pcg3d.js\";\nimport type { ParticleShape } from \"../definition/types.js\";\n\n// The emitter shapes, in the emitter's local space with `+Y` as the directional axis. Each draws\n// its random numbers in a fixed order, so two systems with one seed spawn identical particles.\n\n/** Degrees to radians. */\nconst DEG_TO_RAD = Math.PI / 180;\n\n/** Two pi. */\nconst TAU = Math.PI * 2;\n\n/** The smallest length a direction is normalized from. */\nconst EPSILON = 1e-8;\n\n/**\n * Precomputed data a `\"mesh\"` shape samples from: the cumulative area of its triangles.\n *\n * @beta\n */\nexport class MeshShapeTable {\n /** Cumulative areas, one per triangle, ending at the total. */\n readonly cumulative: Float32Array;\n\n /** The triangle soup, nine floats per triangle. */\n readonly vertices: Float32Array;\n\n /**\n * Builds the table.\n *\n * @param vertices - Nine floats per triangle.\n */\n constructor(vertices: Float32Array) {\n this.vertices = vertices;\n const count = Math.floor(vertices.length / 9);\n this.cumulative = new Float32Array(count);\n let total = 0;\n for (let index = 0; index < count; index += 1) {\n const base = index * 9;\n const ax = vertices[base] ?? 0;\n const ay = vertices[base + 1] ?? 0;\n const az = vertices[base + 2] ?? 0;\n const ux = (vertices[base + 3] ?? 0) - ax;\n const uy = (vertices[base + 4] ?? 0) - ay;\n const uz = (vertices[base + 5] ?? 0) - az;\n const vx = (vertices[base + 6] ?? 0) - ax;\n const vy = (vertices[base + 7] ?? 0) - ay;\n const vz = (vertices[base + 8] ?? 0) - az;\n const cx = uy * vz - uz * vy;\n const cy = uz * vx - ux * vz;\n const cz = ux * vy - uy * vx;\n total += 0.5 * Math.hypot(cx, cy, cz);\n this.cumulative[index] = total;\n }\n }\n\n /**\n * The total surface area.\n *\n * @returns The area.\n */\n get area(): number {\n return this.cumulative[this.cumulative.length - 1] ?? 0;\n }\n}\n\n/**\n * Samples a start position and direction from a shape.\n *\n * @param shape - The shape module.\n * @param rng - The emitter's random stream.\n * @param mesh - The triangle table, for a `\"mesh\"` shape; ignored otherwise.\n * @param position - Receives the local position.\n * @param direction - Receives the unit direction.\n *\n * @beta\n */\nexport function sampleShape(\n shape: ParticleShape,\n rng: EmitterRandom,\n mesh: MeshShapeTable | null,\n position: Float32Array,\n direction: Float32Array,\n): void {\n switch (shape.kind) {\n case \"point\":\n position[0] = 0;\n position[1] = 0;\n position[2] = 0;\n direction[0] = 0;\n direction[1] = 1;\n direction[2] = 0;\n break;\n case \"sphere\":\n sampleSphere(shape, rng, false, position, direction);\n break;\n case \"hemisphere\":\n sampleSphere(shape, rng, true, position, direction);\n break;\n case \"cone\":\n sampleCone(shape, rng, position, direction);\n break;\n case \"box\":\n sampleBox(shape, rng, position, direction);\n break;\n case \"circle\":\n sampleCircle(shape, rng, position, direction);\n break;\n case \"edge\":\n position[0] = (rng.next() - 0.5) * shape.length;\n position[1] = 0;\n position[2] = 0;\n direction[0] = 0;\n direction[1] = 1;\n direction[2] = 0;\n break;\n case \"mesh\":\n sampleMesh(mesh, rng, position, direction);\n break;\n }\n finishDirection(shape, rng, position, direction);\n}\n\n/**\n * Applies `randomDirection` and `spherizeDirection`, then normalizes.\n *\n * @param shape - The shape module.\n * @param rng - The random stream.\n * @param position - The sampled position.\n * @param direction - The direction to adjust in place.\n */\nfunction finishDirection(\n shape: ParticleShape,\n rng: EmitterRandom,\n position: Float32Array,\n direction: Float32Array,\n): void {\n const random = shape.randomDirection;\n if (random > 0) {\n const z = 1 - 2 * rng.next();\n const theta = TAU * rng.next();\n const r = Math.sqrt(Math.max(0, 1 - z * z));\n const rx = r * Math.cos(theta);\n const ry = r * Math.sin(theta);\n direction[0] = (direction[0] ?? 0) * (1 - random) + rx * random;\n direction[1] = (direction[1] ?? 0) * (1 - random) + ry * random;\n direction[2] = (direction[2] ?? 0) * (1 - random) + z * random;\n }\n const spherize = shape.spherizeDirection;\n if (spherize > 0) {\n const px = position[0] ?? 0;\n const py = position[1] ?? 0;\n const pz = position[2] ?? 0;\n const length = Math.hypot(px, py, pz);\n if (length > EPSILON) {\n direction[0] = (direction[0] ?? 0) * (1 - spherize) + (px / length) * spherize;\n direction[1] = (direction[1] ?? 0) * (1 - spherize) + (py / length) * spherize;\n direction[2] = (direction[2] ?? 0) * (1 - spherize) + (pz / length) * spherize;\n }\n }\n normalize(direction);\n}\n\n/**\n * Normalizes a direction in place, falling back to `+Y` for a zero vector.\n *\n * @param direction - The vector.\n */\nfunction normalize(direction: Float32Array): void {\n const x = direction[0] ?? 0;\n const y = direction[1] ?? 0;\n const z = direction[2] ?? 0;\n const length = Math.hypot(x, y, z);\n if (length <= EPSILON) {\n direction[0] = 0;\n direction[1] = 1;\n direction[2] = 0;\n return;\n }\n direction[0] = x / length;\n direction[1] = y / length;\n direction[2] = z / length;\n}\n\n/**\n * Samples a sphere or hemisphere: a direction inside the arc, then a radius by thickness.\n *\n * @param shape - The shape.\n * @param rng - The random stream.\n * @param upperHalf - Whether to mirror into `y >= 0`.\n * @param position - Receives the position.\n * @param direction - Receives the radial direction.\n */\nfunction sampleSphere(\n shape: ParticleShape,\n rng: EmitterRandom,\n upperHalf: boolean,\n position: Float32Array,\n direction: Float32Array,\n): void {\n const z = 1 - 2 * rng.next();\n const theta = shape.arc * DEG_TO_RAD * rng.next();\n const ring = Math.sqrt(Math.max(0, 1 - z * z));\n let dx = ring * Math.cos(theta);\n let dy = z;\n const dz = ring * Math.sin(theta);\n if (upperHalf && dy < 0) {\n dy = -dy;\n }\n const radius = shape.radius * radialFraction(shape, rng, 3);\n direction[0] = dx;\n direction[1] = dy;\n direction[2] = dz;\n dx *= radius;\n dy *= radius;\n position[0] = dx;\n position[1] = dy;\n position[2] = dz * radius;\n}\n\n/**\n * How far out a volume sample sits, in `[1 - thickness, 1]`, distributed uniformly by volume or area.\n *\n * @param shape - The shape, for `thickness` and `emitFrom`.\n * @param rng - The random stream.\n * @param dimensions - `3` for a ball, `2` for a disc.\n * @returns The fraction of the radius.\n */\nfunction radialFraction(shape: ParticleShape, rng: EmitterRandom, dimensions: number): number {\n if (shape.emitFrom === \"shell\" || shape.thickness <= 0) {\n return 1;\n }\n const inner = 1 - shape.thickness;\n const unit = rng.next();\n const innerPow = inner ** dimensions;\n return (innerPow + (1 - innerPow) * unit) ** (1 / dimensions);\n}\n\n/**\n * Samples a cone: a point on the base disc and a direction tilted by the half-angle at the rim.\n *\n * @param shape - The shape.\n * @param rng - The random stream.\n * @param position - Receives the position.\n * @param direction - Receives the direction.\n */\nfunction sampleCone(shape: ParticleShape, rng: EmitterRandom, position: Float32Array, direction: Float32Array): void {\n const theta = shape.arc * DEG_TO_RAD * rng.next();\n const fraction = radialFraction(shape, rng, 2);\n const rho = shape.radius * fraction;\n const cosTheta = Math.cos(theta);\n const sinTheta = Math.sin(theta);\n const angle = shape.angle * DEG_TO_RAD;\n const tilt = Math.sin(angle) * fraction;\n direction[0] = tilt * cosTheta;\n direction[1] = Math.cos(angle);\n direction[2] = tilt * sinTheta;\n normalize(direction);\n const height = shape.emitFrom === \"volume\" ? shape.length * rng.next() : 0;\n position[0] = rho * cosTheta + direction[0] * height;\n position[1] = direction[1] * height;\n position[2] = rho * sinTheta + direction[2] * height;\n}\n\n/**\n * Samples a box: anywhere inside, or on one of its six faces.\n *\n * @param shape - The shape.\n * @param rng - The random stream.\n * @param position - Receives the position.\n * @param direction - Receives `+Y`.\n */\nfunction sampleBox(shape: ParticleShape, rng: EmitterRandom, position: Float32Array, direction: Float32Array): void {\n const x = rng.next() - 0.5;\n const y = rng.next() - 0.5;\n const z = rng.next() - 0.5;\n position[0] = x * shape.size.x;\n position[1] = y * shape.size.y;\n position[2] = z * shape.size.z;\n if (shape.emitFrom === \"shell\") {\n const face = Math.min(5, Math.floor(rng.next() * 6));\n const sign = face % 2 === 0 ? -0.5 : 0.5;\n if (face < 2) {\n position[0] = sign * shape.size.x;\n } else if (face < 4) {\n position[1] = sign * shape.size.y;\n } else {\n position[2] = sign * shape.size.z;\n }\n }\n direction[0] = 0;\n direction[1] = 1;\n direction[2] = 0;\n}\n\n/**\n * Samples a circle in the XZ plane, emitting outward.\n *\n * @param shape - The shape.\n * @param rng - The random stream.\n * @param position - Receives the position.\n * @param direction - Receives the radial direction.\n */\nfunction sampleCircle(shape: ParticleShape, rng: EmitterRandom, position: Float32Array, direction: Float32Array): void {\n const theta = shape.arc * DEG_TO_RAD * rng.next();\n const fraction = radialFraction(shape, rng, 2);\n const dx = Math.cos(theta);\n const dz = Math.sin(theta);\n direction[0] = dx;\n direction[1] = 0;\n direction[2] = dz;\n position[0] = dx * shape.radius * fraction;\n position[1] = 0;\n position[2] = dz * shape.radius * fraction;\n}\n\n/**\n * Samples a triangle soup by area, emitting along the face normal.\n *\n * @param mesh - The triangle table.\n * @param rng - The random stream.\n * @param position - Receives the position.\n * @param direction - Receives the face normal.\n */\nfunction sampleMesh(\n mesh: MeshShapeTable | null,\n rng: EmitterRandom,\n position: Float32Array,\n direction: Float32Array,\n): void {\n if (mesh === null || mesh.cumulative.length === 0 || mesh.area <= 0) {\n position[0] = 0;\n position[1] = 0;\n position[2] = 0;\n direction[0] = 0;\n direction[1] = 1;\n direction[2] = 0;\n return;\n }\n const target = rng.next() * mesh.area;\n const cumulative = mesh.cumulative;\n let low = 0;\n let high = cumulative.length - 1;\n while (low < high) {\n const mid = (low + high) >> 1;\n if ((cumulative[mid] ?? 0) < target) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n const base = low * 9;\n const vertices = mesh.vertices;\n const ax = vertices[base] ?? 0;\n const ay = vertices[base + 1] ?? 0;\n const az = vertices[base + 2] ?? 0;\n const bx = vertices[base + 3] ?? 0;\n const by = vertices[base + 4] ?? 0;\n const bz = vertices[base + 5] ?? 0;\n const cx = vertices[base + 6] ?? 0;\n const cy = vertices[base + 7] ?? 0;\n const cz = vertices[base + 8] ?? 0;\n const r1 = Math.sqrt(rng.next());\n const r2 = rng.next();\n const wa = 1 - r1;\n const wb = r1 * (1 - r2);\n const wc = r1 * r2;\n position[0] = ax * wa + bx * wb + cx * wc;\n position[1] = ay * wa + by * wb + cy * wc;\n position[2] = az * wa + bz * wb + cz * wc;\n const ux = bx - ax;\n const uy = by - ay;\n const uz = bz - az;\n const vx = cx - ax;\n const vy = cy - ay;\n const vz = cz - az;\n direction[0] = uy * vz - uz * vy;\n direction[1] = uz * vx - ux * vz;\n direction[2] = ux * vy - uy * vx;\n normalize(direction);\n}\n","import { resolveScalar } from \"../definition/values.js\";\nimport { transformDirection, transformPoint } from \"../evaluate/particle-math.js\";\nimport { EmitterRandom, recordSeed } from \"./pcg3d.js\";\nimport { isDead, RECORD_FLOATS, SpawnRecordRing } from \"./record-ring.js\";\nimport { MeshShapeTable, sampleShape } from \"./shapes.js\";\nimport type { RingCensus } from \"./record-ring.js\";\nimport type { ParticleDefinition } from \"../definition/types.js\";\n\n// The whole CPU side of one particle system, with no app, no component and no GPU.\n// `ParticleSystem` drives it from the\n// frame loop; `@ignifx/particles-2d` drives the same object and draws the records itself.\n\n/** The sub-step `simulate()` advances in, in seconds. */\nconst SIMULATE_STEP = 1 / 60;\n\n/** Degrees to radians. */\nconst DEG_TO_RAD = Math.PI / 180;\n\n/** The largest seed a `u32` holds, plus one. */\nconst SEED_RANGE = 0x1_0000_0000;\n\n/** How many cycle boundaries one frame may cross before the loop gives up. */\nconst MAX_CYCLES_PER_FRAME = 1024;\n\n/** How many times one burst may fire inside one segment before the loop gives up. */\nconst MAX_BURST_FIRINGS = 4096;\n\n/**\n * What {@link ParticleEmitterCore.stop} accepts.\n *\n * @public\n */\nexport interface ParticleStopOptions {\n /** Whether to forget the live particles too. Defaults to `false`: they finish their lives. */\n readonly clear?: boolean;\n}\n\n/**\n * How {@link ParticleEmitterCore} is built.\n *\n * @beta\n */\nexport interface ParticleEmitterCoreOptions {\n /** The definition to emit. */\n readonly definition: ParticleDefinition;\n /** The ring capacity, after the app's budget clamped it. */\n readonly capacity: number;\n /** The seed; `0` picks a random one on `play()`. */\n readonly seed: number;\n}\n\n/**\n * The CPU half of a particle system: the spawn-record ring, the system clock, the seeded random\n * stream, and the emission scheduler.\n *\n * @example\n * ```ts\n * const core = new ParticleEmitterCore({ definition, capacity: 1000, seed: 7 });\n * core.play();\n * core.advance(1 / 60);\n * core.reconcile();\n * ```\n *\n * @beta\n */\nexport class ParticleEmitterCore {\n /** The definition every record is written from. */\n readonly definition: ParticleDefinition;\n\n /** The spawn records. */\n readonly ring: SpawnRecordRing;\n\n /**\n * The emitter's world matrix, column-major; write it before {@link ParticleEmitterCore.advance}.\n * A `\"world\"` definition bakes it into every record, and `rateOverDistance` reads its translation.\n */\n readonly emitterWorld: Float32Array = identity();\n\n /** A `0`–`1` multiplier on rates and burst counts; the app's `qualityScale`. */\n qualityScale = 1;\n\n /** Called once when a non-looping system runs out of cycle and particles. */\n onStopped: (() => void) | null = null;\n\n readonly #rng: EmitterRandom;\n\n readonly #declaredSeed: number;\n\n readonly #meshTable: MeshShapeTable | null;\n\n readonly #census: RingCensus = { alive: 0, drawCount: 0 };\n\n readonly #burstFired: Int32Array;\n\n readonly #position = new Float32Array(3);\n\n readonly #direction = new Float32Array(3);\n\n readonly #lastPosition = new Float32Array(3);\n\n readonly #words = new Uint32Array(3);\n\n #seed: number;\n\n #clock = 0;\n\n #cycleStart = 0;\n\n #isPlaying = false;\n\n #isPaused = false;\n\n #isEmitting = false;\n\n #rateCarry = 0;\n\n #distanceCarry = 0;\n\n #hasLastPosition = false;\n\n #emittedTotal = 0;\n\n #droppedTotal = 0;\n\n /**\n * Creates the core.\n *\n * @param options - The definition, the clamped capacity, and the seed.\n */\n constructor(options: ParticleEmitterCoreOptions) {\n this.definition = options.definition;\n this.ring = new SpawnRecordRing(options.capacity);\n this.#declaredSeed = options.seed >>> 0;\n this.#seed = this.#declaredSeed;\n this.#rng = new EmitterRandom(this.#seed);\n this.#meshTable =\n options.definition.shape.kind === \"mesh\" ? new MeshShapeTable(options.definition.shape.vertices) : null;\n this.#burstFired = new Int32Array(options.definition.emission.bursts.length);\n }\n\n /**\n * The system clock, in seconds: what every record's age is measured against.\n *\n * @returns The clock.\n */\n get time(): number {\n return this.#clock;\n }\n\n /**\n * Whether the system is playing, paused or not.\n *\n * @returns `true` between `play()` and the stop.\n */\n get isPlaying(): boolean {\n return this.#isPlaying;\n }\n\n /**\n * Whether the clock is held.\n *\n * @returns `true` after `pause()`.\n */\n get isPaused(): boolean {\n return this.#isPaused;\n }\n\n /**\n * Whether the current cycle still emits.\n *\n * @returns `true` while emission runs.\n */\n get isEmitting(): boolean {\n return this.#isEmitting;\n }\n\n /**\n * The seed in use: the declared one, or the random one `play()` picked for a declared `0`.\n *\n * @returns The seed.\n */\n get seed(): number {\n return this.#seed;\n }\n\n /**\n * How many particles are alive, as of the last {@link ParticleEmitterCore.reconcile}.\n *\n * @returns The exact count.\n */\n get aliveCount(): number {\n return this.#census.alive;\n }\n\n /**\n * How many records the GPU draws, newest first: from the newest back to the oldest still alive.\n *\n * @returns The draw count.\n */\n get drawCount(): number {\n return this.#census.drawCount;\n }\n\n /**\n * How many particles have been emitted since the last `play()` from an empty ring.\n *\n * @returns The total.\n */\n get emittedTotal(): number {\n return this.#emittedTotal;\n }\n\n /**\n * How many spawns landed on a slot whose particle was still alive, so that older particle\n * vanished. It is what \"over budget\" looks like from inside a system: the capacity the app's\n * `maxParticles` granted is smaller than `rate × lifetime`.\n *\n * @returns The total since the last `play()` from an empty ring.\n */\n get droppedTotal(): number {\n return this.#droppedTotal;\n }\n\n /**\n * Starts, or resumes after a `stop()`, emission. On an empty ring the clock restarts at zero and\n * a `prewarm` definition fast-forwards one cycle; otherwise the clock keeps counting.\n */\n play(): void {\n if (this.#isPlaying) {\n this.#isPaused = false;\n return;\n }\n if (this.ring.written === 0) {\n this.#clock = 0;\n this.#emittedTotal = 0;\n this.#droppedTotal = 0;\n this.#seed = this.#declaredSeed === 0 ? Math.floor(Math.random() * SEED_RANGE) >>> 0 : this.#declaredSeed;\n this.#rng.reseed(this.#seed);\n }\n this.#isPlaying = true;\n this.#isPaused = false;\n this.#startCycle(this.#clock);\n this.#hasLastPosition = false;\n const main = this.definition.main;\n if (main.prewarm && main.looping) {\n this.simulate(main.duration);\n }\n }\n\n /**\n * Stops emission. Live particles keep ageing until they die unless `clear` is set.\n *\n * @param options - Whether to clear the particles too.\n */\n stop(options?: ParticleStopOptions): void {\n this.#isPlaying = false;\n this.#isPaused = false;\n this.#isEmitting = false;\n if (options?.clear === true) {\n this.ring.clear();\n this.#clock = 0;\n this.#census.alive = 0;\n this.#census.drawCount = 0;\n }\n }\n\n /** Holds the clock; emission and ageing stop until {@link ParticleEmitterCore.resume}. */\n pause(): void {\n this.#isPaused = true;\n }\n\n /** Releases a `pause()`. */\n resume(): void {\n this.#isPaused = false;\n }\n\n /**\n * Spawns particles now, at the current clock, whether or not the system is playing.\n *\n * @param count - How many; a non-integer is floored, and `qualityScale` does not apply.\n */\n emit(count: number): void {\n const whole = Math.floor(count);\n for (let index = 0; index < whole; index += 1) {\n this.#spawn(this.#clock);\n }\n }\n\n /**\n * Fast-forwards the system by `seconds` in fixed sub-steps, emitting as it goes — what `prewarm`\n * does, and what a test does to reach a known state. The definition's `timeScale` does not apply.\n *\n * @param seconds - How far to advance the system clock.\n */\n simulate(seconds: number): void {\n // The whole sub-steps are counted up front rather than subtracted one at a time, so\n // `simulate(2)` really is 120 steps of a sixtieth and matches 120 frames record for record.\n const whole = Math.floor(seconds / SIMULATE_STEP);\n for (let index = 0; index < whole; index += 1) {\n this.#advanceClock(SIMULATE_STEP);\n }\n const rest = seconds - whole * SIMULATE_STEP;\n if (rest > SIMULATE_STEP * 1e-6) {\n this.#advanceClock(rest);\n }\n }\n\n /**\n * Advances one frame. It does nothing while paused, and nothing once a stopped system's last\n * particle has died.\n *\n * @param dt - The frame's scaled seconds; the definition's own `timeScale` is applied here.\n */\n advance(dt: number): void {\n if (this.#isPaused || dt <= 0) {\n return;\n }\n if (!this.#isPlaying && this.#census.alive === 0) {\n return;\n }\n this.#advanceClock(dt * this.definition.main.timeScale);\n }\n\n /**\n * Recounts the ring at the current clock and fires `onStopped` once a non-looping system has\n * nothing left to do.\n *\n * @returns The census.\n */\n reconcile(): RingCensus {\n const census = this.ring.reconcile(this.#clock, this.#census);\n if (this.#isPlaying && !this.#isEmitting && census.alive === 0) {\n this.#isPlaying = false;\n this.#isPaused = false;\n this.onStopped?.();\n }\n return census;\n }\n\n /**\n * Begins a cycle at a clock value.\n *\n * @param at - The clock the cycle starts at.\n */\n #startCycle(at: number): void {\n this.#cycleStart = at;\n this.#isEmitting = true;\n this.#rateCarry = 0;\n this.#burstFired.fill(0);\n }\n\n /**\n * Moves the clock forward and emits everything due.\n *\n * @param dt - The seconds to advance, already scaled.\n */\n #advanceClock(dt: number): void {\n const main = this.definition.main;\n let segmentStart = this.#clock;\n const target = this.#clock + dt;\n this.#clock = target;\n // One frame may cross the end of a cycle, and each segment has to be emitted inside its own.\n let guard = 0;\n while (segmentStart < target && guard < MAX_CYCLES_PER_FRAME) {\n guard += 1;\n const cycleEnd = this.#cycleStart + main.startDelay + main.duration;\n const segmentEnd = this.#isEmitting && target > cycleEnd ? cycleEnd : target;\n if (this.#isEmitting) {\n this.#emitSegment(segmentStart, segmentEnd);\n }\n if (this.#isEmitting && segmentEnd >= cycleEnd) {\n if (main.looping) {\n this.#startCycle(cycleEnd);\n } else {\n this.#isEmitting = false;\n }\n }\n segmentStart = segmentEnd;\n if (!this.#isEmitting) {\n break;\n }\n }\n this.#emitOverDistance();\n }\n\n /**\n * Emits what the rate and the bursts owe inside one segment of one cycle.\n *\n * @param from - The segment's start clock.\n * @param to - The segment's end clock.\n */\n #emitSegment(from: number, to: number): void {\n const main = this.definition.main;\n const emission = this.definition.emission;\n const emissionStart = this.#cycleStart + main.startDelay;\n const windowStart = from > emissionStart ? from : emissionStart;\n const rate = emission.rateOverTime * this.qualityScale;\n if (to > windowStart && rate > 0) {\n // The fractional part carries to the next frame, so the count over any run of steps is\n // exactly `floor(rate × elapsed)` and each particle gets its own sub-frame spawn time.\n const owed = this.#rateCarry + rate * (to - windowStart);\n const count = Math.floor(owed);\n const period = 1 / rate;\n for (let index = 0; index < count; index += 1) {\n const spawnTime = windowStart + (index + 1 - this.#rateCarry) * period;\n this.#spawn(spawnTime > to ? to : spawnTime);\n }\n this.#rateCarry = owed - count;\n }\n const bursts = emission.bursts;\n for (let index = 0; index < bursts.length; index += 1) {\n const burst = bursts[index];\n if (burst === undefined) {\n continue;\n }\n // `cycles: 0` means \"until the cycle ends\", which only makes sense with a gap between\n // firings; with no gap it is one firing, not an infinite loop at the same instant.\n const limit = burst.cycles === 0 && burst.interval > 0 ? MAX_BURST_FIRINGS : Math.max(1, burst.cycles);\n let fired = this.#burstFired[index] ?? 0;\n while (fired < limit) {\n const due = emissionStart + burst.time + fired * burst.interval;\n if (due > to) {\n break;\n }\n fired += 1;\n if (burst.probability >= 1 || this.#rng.next() < burst.probability) {\n const rolled = resolveScalar(burst.count, this.#rng.next(), this.#cycleFraction(due)) * this.qualityScale;\n const count = Math.floor(rolled);\n for (let spawned = 0; spawned < count; spawned += 1) {\n this.#spawn(due < windowStart ? windowStart : due);\n }\n }\n }\n this.#burstFired[index] = fired;\n }\n }\n\n /** Emits what the emitter's movement since the last frame owes. */\n #emitOverDistance(): void {\n const rate = this.definition.emission.rateOverDistance * this.qualityScale;\n const world = this.emitterWorld;\n const x = world[12] ?? 0;\n const y = world[13] ?? 0;\n const z = world[14] ?? 0;\n if (rate > 0 && this.#isEmitting && this.#hasLastPosition) {\n const dx = x - (this.#lastPosition[0] ?? 0);\n const dy = y - (this.#lastPosition[1] ?? 0);\n const dz = z - (this.#lastPosition[2] ?? 0);\n const owed = this.#distanceCarry + Math.hypot(dx, dy, dz) * rate;\n const count = Math.floor(owed);\n for (let index = 0; index < count; index += 1) {\n this.#spawn(this.#clock);\n }\n this.#distanceCarry = owed - count;\n }\n this.#lastPosition[0] = x;\n this.#lastPosition[1] = y;\n this.#lastPosition[2] = z;\n this.#hasLastPosition = true;\n }\n\n /**\n * Where a clock value sits inside the current cycle, for the start curves.\n *\n * @param at - The clock value.\n * @returns The fraction in `[0, 1]`.\n */\n #cycleFraction(at: number): number {\n const main = this.definition.main;\n const fraction = (at - this.#cycleStart - main.startDelay) / main.duration;\n return fraction <= 0 ? 0 : fraction >= 1 ? 1 : fraction;\n }\n\n /**\n * Writes one record, counting the live particle it displaced if the ring had wrapped.\n *\n * @param spawnTime - The clock the particle is born at.\n */\n #spawn(spawnTime: number): void {\n const definition = this.definition;\n const rng = this.#rng;\n const position = this.#position;\n const direction = this.#direction;\n const ring = this.ring;\n if (ring.written >= ring.capacity && !isDead(ring.floats, ring.head * RECORD_FLOATS, Math.fround(spawnTime))) {\n this.#droppedTotal += 1;\n }\n sampleShape(definition.shape, rng, this.#meshTable, position, direction);\n const t = this.#cycleFraction(spawnTime);\n const start = definition.start;\n const lifetime = resolveScalar(start.lifetime, rng.next(), t);\n const speed = resolveScalar(start.speed, rng.next(), t);\n const size = resolveScalar(start.size, rng.next(), t);\n const rotation = resolveScalar(start.rotation, rng.next(), t) * DEG_TO_RAD;\n direction[0] = (direction[0] ?? 0) * speed;\n direction[1] = (direction[1] ?? 0) * speed;\n direction[2] = (direction[2] ?? 0) * speed;\n if (definition.main.simulationSpace === \"world\") {\n transformPoint(this.emitterWorld, position);\n transformDirection(this.emitterWorld, direction);\n }\n const seed = recordSeed(this.#seed, ring.written, this.#words);\n ring.write(\n spawnTime,\n lifetime,\n seed,\n 0,\n component(position, 0),\n component(position, 1),\n component(position, 2),\n size,\n component(direction, 0),\n component(direction, 1),\n component(direction, 2),\n rotation,\n );\n this.#emittedTotal += 1;\n }\n}\n\n/**\n * Reads one component of a scratch vector `sampleShape` filled in.\n *\n * @param vector - The vector.\n * @param index - Which component.\n * @returns The component, or zero when the vector is shorter than the index.\n */\nfunction component(vector: Float32Array, index: number): number {\n return vector[index] ?? 0;\n}\n\n/**\n * A fresh identity matrix.\n *\n * @returns Sixteen column-major floats.\n */\nfunction identity(): Float32Array {\n const m = new Float32Array(16);\n m[0] = 1;\n m[5] = 1;\n m[10] = 1;\n m[15] = 1;\n return m;\n}\n","import { LOOKUP_SAMPLES } from \"../definition/types.js\";\nimport { PARTICLE_SALT_Y, PARTICLE_SALT_Z } from \"../emitter/pcg3d.js\";\nimport type { LookupRow, ParticleDefinition, ScalarValue } from \"../definition/types.js\";\n\n// The GPU evaluator: one `.wgsl` program generated per definition\n// (ADR-0025), the second host of the specification `src/evaluate/particle-math.ts` states in\n// TypeScript. Read the two side by side.\n\n/** Degrees to radians, as a WGSL literal. */\nconst DEG_TO_RAD_WGSL = \"0.017453292519943295\";\n\n/** The offsets the second and third noise channels sample at. */\nconst NOISE_OFFSET_Y = \"vec3<f32>(31.4, 47.2, 12.9)\";\n\n/** The offsets the second and third noise channels sample at. */\nconst NOISE_OFFSET_Z = \"vec3<f32>(-17.3, 8.6, 53.1)\";\n\n/**\n * Formats a number as a WGSL `f32` literal.\n *\n * @param value - The number.\n * @returns The literal, always with a decimal point or an exponent.\n */\nfunction f32(value: number): string {\n if (!Number.isFinite(value)) {\n return \"0.0\";\n }\n const text = String(value);\n return text.includes(\".\") || text.includes(\"e\") ? text : `${text}.0`;\n}\n\n/**\n * Formats three numbers as a `vec3<f32>` literal.\n *\n * @param x - The first component.\n * @param y - The second component.\n * @param z - The third component.\n * @returns The literal.\n */\nfunction vec3(x: number, y: number, z: number): string {\n return `vec3<f32>(${f32(x)}, ${f32(y)}, ${f32(z)})`;\n}\n\n/**\n * The WGSL of the row constants a lookup row needs.\n *\n * @param name - The constant prefix.\n * @param row - The row.\n * @returns The declarations.\n */\nfunction rowConstants(name: string, row: LookupRow): string {\n return `const ${name}_ROW: f32 = ${f32(row.index)};\\nconst ${name}_MIN: f32 = ${f32(row.min)};\\nconst ${name}_MAX: f32 = ${f32(row.max)};\\n`;\n}\n\n/**\n * The WGSL that reads a decoded scalar row into a variable.\n *\n * @param name - The constant prefix used by {@link rowConstants}.\n * @param channel - The swizzle to read.\n * @returns An expression.\n */\nfunction decodeRow(name: string, channel: string): string {\n return `(${name}_MIN + lookupRow(${name}_ROW, life).${channel} * (${name}_MAX - ${name}_MIN))`;\n}\n\n/**\n * The WGSL expression for a constant or random scalar picked by a unit float.\n *\n * @param value - The scalar; a curve is handled by the caller through its row.\n * @param unit - The unit float expression.\n * @returns An expression.\n */\nfunction pickScalar(value: ScalarValue, unit: string): string {\n if (value.kind === \"constant\") {\n return f32(value.value);\n }\n if (value.kind === \"random\") {\n return `mix(${f32(value.min)}, ${f32(value.max)}, ${unit})`;\n }\n return \"0.0\";\n}\n\n/**\n * Generates the WGSL program that draws a definition.\n *\n * @param definition - The definition.\n * @returns The whole `.wgsl` source, pragmas included, ready for the shader loader.\n *\n * @example\n * ```ts\n * const source = generateParticleWgsl(particleDefinition(\"fire\"));\n * source.includes(\"@ignifx blend premultiplied\"); // true\n * ```\n *\n * @beta\n */\nexport function generateParticleWgsl(definition: ParticleDefinition): string {\n const { forces, renderer, start, lookup } = definition;\n const isMesh = renderer.mode === \"mesh\";\n const system: string[] = [\"view\", \"viewProjection\"];\n if (renderer.mode === \"vertical\") {\n system.push(\"cameraPosition\");\n }\n if (renderer.lit) {\n system.push(\"mainLightDirection\", \"mainLightColor\", \"ambientColor\");\n }\n const attributes = isMesh ? \"position, normal, uv\" : \"position, uv\";\n const parts: string[] = [];\n // Every binding and uniform below is declared only when the program reads it: Babylon Lite\n // demands that a declared sampler or storage buffer be bound before the material can draw.\n parts.push(\n \"// Generated by @ignifx/particles from an ignifx.particles definition. Do not edit.\",\n \"// @ignifx shader\",\n `// @ignifx attributes ${attributes}`,\n `// @ignifx system ${system.join(\", \")}`,\n \"// @ignifx storage particles: array<Particle>\",\n ...(renderer.texture === null ? [] : [\"// @ignifx texture sheet srgb default white\"]),\n \"// @ignifx texture lut default white\",\n \"// @ignifx uniform clock: f32 = 0\",\n \"// @ignifx uniform head: f32 = 0\",\n \"// @ignifx uniform capacity: f32 = 1\",\n ...(definition.main.simulationSpace === \"local\" ? [\"// @ignifx uniform emitterWorld: mat4x4<f32>\"] : []),\n ...(forces.orbit === null ? [] : [\"// @ignifx uniform orbitCenter: vec3<f32> = (0, 0, 0)\"]),\n \"// @ignifx uniform gravity: vec3<f32> = (0, 0, 0)\",\n `// @ignifx blend ${renderer.blend} cull none depthWrite off instancing matrices`,\n \"\",\n \"struct Particle {\",\n \" spawnTime: f32,\",\n \" lifetime: f32,\",\n \" seed: u32,\",\n \" flags: u32,\",\n \" @align(16) position: vec3<f32>,\",\n \" size: f32,\",\n \" @align(16) velocity: vec3<f32>,\",\n \" rotation: f32,\",\n \"}\",\n \"\",\n \"struct VertexOutput {\",\n \" @builtin(position) position: vec4<f32>,\",\n \" @location(0) uv: vec2<f32>,\",\n \" @location(1) color: vec4<f32>,\",\n \"}\",\n \"\",\n `const DEG_TO_RAD: f32 = ${DEG_TO_RAD_WGSL};`,\n `const LOOKUP_ROWS: f32 = ${f32(lookup.rows)};`,\n `const LOOKUP_LAST: f32 = ${f32(LOOKUP_SAMPLES - 1)};`,\n `const LOOKUP_WIDTH: f32 = ${f32(LOOKUP_SAMPLES)};`,\n `const SALT_Y: u32 = ${String(PARTICLE_SALT_Y)}u;`,\n `const SALT_Z: u32 = ${String(PARTICLE_SALT_Z)}u;`,\n \"const UNIT_SCALE: f32 = 2.3283064365386963e-10;\",\n \"const DEAD: vec4<f32> = vec4<f32>(0.0, 0.0, 2.0, 1.0);\",\n `const DRAG: f32 = ${f32(forces.drag)};`,\n `const SIZE_SCALE: vec3<f32> = ${vec3(start.size3D?.x ?? 1, start.size3D?.y ?? 1, start.size3D?.z ?? 1)};`,\n `const PIVOT: vec2<f32> = vec2<f32>(${f32(renderer.pivot.x)}, ${f32(renderer.pivot.y)});`,\n \"\",\n );\n const startColor = start.color;\n if (startColor.kind === \"random\") {\n parts.push(\n `const START_COLOR_MIN: vec4<f32> = vec4<f32>(${f32(startColor.min.r)}, ${f32(startColor.min.g)}, ${f32(startColor.min.b)}, ${f32(startColor.min.a)});`,\n `const START_COLOR_MAX: vec4<f32> = vec4<f32>(${f32(startColor.max.r)}, ${f32(startColor.max.g)}, ${f32(startColor.max.b)}, ${f32(startColor.max.a)});`,\n );\n } else {\n const c = startColor.kind === \"constant\" ? startColor.value : { r: 1, g: 1, b: 1, a: 1 };\n parts.push(`const START_COLOR: vec4<f32> = vec4<f32>(${f32(c.r)}, ${f32(c.g)}, ${f32(c.b)}, ${f32(c.a)});`);\n }\n if (lookup.color !== null) {\n parts.push(rowConstants(\"COLOR\", lookup.color));\n }\n if (lookup.size !== null) {\n parts.push(rowConstants(\"SIZE\", lookup.size));\n }\n if (lookup.rotation !== null) {\n parts.push(rowConstants(\"ROTATION\", lookup.rotation));\n }\n if (lookup.noise !== null) {\n parts.push(rowConstants(\"NOISE\", lookup.noise));\n }\n if (lookup.frame !== null) {\n parts.push(rowConstants(\"FRAME\", lookup.frame));\n }\n const orbit = forces.orbit;\n if (orbit !== null) {\n parts.push(\n `const ORBIT_AXIS: vec3<f32> = ${vec3(orbit.axis.x, orbit.axis.y, orbit.axis.z)};`,\n `const ORBIT_SPEED: f32 = ${f32(orbit.speed)};`,\n );\n }\n const noise = forces.noise;\n if (noise !== null) {\n parts.push(\n `const NOISE_STRENGTH: f32 = ${f32(noise.strength)};`,\n `const NOISE_FREQUENCY: f32 = ${f32(noise.frequency)};`,\n `const NOISE_SCROLL: vec3<f32> = ${vec3(noise.scroll.x, noise.scroll.y, noise.scroll.z)};`,\n `const NOISE_OCTAVES: i32 = ${String(noise.octaves)};`,\n `const NOISE_INFLUENCE: f32 = ${f32(noise.influenceOverLife.kind === \"constant\" ? noise.influenceOverLife.value : 1)};`,\n );\n }\n const sheet = renderer.sheet;\n if (sheet !== null) {\n parts.push(\n `const SHEET_TILES: vec2<f32> = vec2<f32>(${f32(sheet.tiles.x)}, ${f32(sheet.tiles.y)});`,\n `const SHEET_COUNT: f32 = ${f32(sheet.tiles.x * sheet.tiles.y)};`,\n `const SHEET_FPS: f32 = ${f32(sheet.fps)};`,\n );\n }\n if (renderer.mode === \"stretched\") {\n parts.push(\n `const SPEED_SCALE: f32 = ${f32(renderer.speedScale)};`,\n `const LENGTH_SCALE: f32 = ${f32(renderer.lengthScale)};`,\n );\n }\n parts.push(\"\", HELPERS);\n if (noise !== null) {\n parts.push(NOISE_HELPERS);\n }\n parts.push(vertexStage(definition), \"\", fragmentStage(definition));\n return `${parts.join(\"\\n\")}\\n`;\n}\n\n/** The helpers every program carries: `pcg3d`, sRGB decode, Rodrigues rotation, the row sampler. */\nconst HELPERS = `fn pcg3d(v0: vec3<u32>) -> vec3<u32> {\n var v = v0 * 1664525u + 1013904223u;\n v.x += v.y * v.z;\n v.y += v.z * v.x;\n v.z += v.x * v.y;\n v ^= v >> vec3<u32>(16u);\n v.x += v.y * v.z;\n v.y += v.z * v.x;\n v.z += v.x * v.y;\n return v;\n}\n\nfn srgbToLinear(c: vec3<f32>) -> vec3<f32> {\n let low = c / 12.92;\n let high = pow((c + vec3<f32>(0.055)) / 1.055, vec3<f32>(2.4));\n return select(high, low, c <= vec3<f32>(0.04045));\n}\n\nfn rotateAbout(v: vec3<f32>, axis: vec3<f32>, angle: f32) -> vec3<f32> {\n let c = cos(angle);\n let s = sin(angle);\n return v * c + cross(axis, v) * s + axis * dot(axis, v) * (1.0 - c);\n}\n\nfn lookupRow(row: f32, life: f32) -> vec4<f32> {\n let u = (clamp(life, 0.0, 1.0) * LOOKUP_LAST + 0.5) / LOOKUP_WIDTH;\n let v = (row + 0.5) / LOOKUP_ROWS;\n return textureSampleLevel(lut, lutSampler, vec2<f32>(u, v), 0.0);\n}\n`;\n\n/** The gradient noise, line for line the TypeScript in `src/evaluate/noise.ts`. */\nconst NOISE_HELPERS = `fn fade(t: vec3<f32>) -> vec3<f32> {\n return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfn cornerDot(cell: vec3<i32>, d: vec3<f32>) -> f32 {\n let h = pcg3d(bitcast<vec3<u32>>(cell));\n let g = vec3<f32>(h) * UNIT_SCALE * 2.0 - vec3<f32>(1.0);\n return dot(g, d);\n}\n\nfn gradientNoise(p: vec3<f32>) -> f32 {\n let i = floor(p);\n let f = p - i;\n let u = fade(f);\n let cell = vec3<i32>(i);\n let c000 = cornerDot(cell, f);\n let c100 = cornerDot(cell + vec3<i32>(1, 0, 0), f - vec3<f32>(1.0, 0.0, 0.0));\n let c010 = cornerDot(cell + vec3<i32>(0, 1, 0), f - vec3<f32>(0.0, 1.0, 0.0));\n let c110 = cornerDot(cell + vec3<i32>(1, 1, 0), f - vec3<f32>(1.0, 1.0, 0.0));\n let c001 = cornerDot(cell + vec3<i32>(0, 0, 1), f - vec3<f32>(0.0, 0.0, 1.0));\n let c101 = cornerDot(cell + vec3<i32>(1, 0, 1), f - vec3<f32>(1.0, 0.0, 1.0));\n let c011 = cornerDot(cell + vec3<i32>(0, 1, 1), f - vec3<f32>(0.0, 1.0, 1.0));\n let c111 = cornerDot(cell + vec3<i32>(1, 1, 1), f - vec3<f32>(1.0, 1.0, 1.0));\n let x00 = mix(c000, c100, u.x);\n let x10 = mix(c010, c110, u.x);\n let x01 = mix(c001, c101, u.x);\n let x11 = mix(c011, c111, u.x);\n let y0 = mix(x00, x10, u.y);\n let y1 = mix(x01, x11, u.y);\n return mix(y0, y1, u.z);\n}\n\nfn noise3(p: vec3<f32>) -> vec3<f32> {\n var n = vec3<f32>(gradientNoise(p), gradientNoise(p + ${NOISE_OFFSET_Y}), gradientNoise(p + ${NOISE_OFFSET_Z}));\n if (NOISE_OCTAVES >= 2) {\n let p2 = p * 2.0;\n n += 0.5 * vec3<f32>(gradientNoise(p2), gradientNoise(p2 + ${NOISE_OFFSET_Y}), gradientNoise(p2 + ${NOISE_OFFSET_Z}));\n }\n return n;\n}\n`;\n\n/**\n * The vertex stage: record lookup, the closed forms, and the orientation of the mode.\n *\n * @param definition - The definition.\n * @returns The `mainVertex` function.\n */\nfunction vertexStage(definition: ParticleDefinition): string {\n const { forces, renderer, start, overLifetime, lookup, main } = definition;\n const lines: string[] = [];\n lines.push(\n \"@vertex fn mainVertex(input: VertexInput, @builtin(instance_index) iid: u32) -> VertexOutput {\",\n \" var out: VertexOutput;\",\n \" let capacity = u32(shaderUniforms.capacity);\",\n \" let head = u32(shaderUniforms.head);\",\n \" let slot = (head + capacity - 1u - iid) % capacity;\",\n \" let record = particles[slot];\",\n \" let age = shaderUniforms.clock - record.spawnTime;\",\n \" if (age < 0.0 || age > record.lifetime || record.lifetime <= 0.0) {\",\n \" out.position = DEAD;\",\n \" out.uv = vec2<f32>(0.0);\",\n \" out.color = vec4<f32>(0.0);\",\n \" return out;\",\n \" }\",\n \" let life = age / record.lifetime;\",\n \" let t = age;\",\n \" let g = shaderUniforms.gravity;\",\n \" var p: vec3<f32>;\",\n \" var v: vec3<f32>;\",\n );\n if (forces.drag > 0) {\n lines.push(\n \" {\",\n \" let inverse = 1.0 / DRAG;\",\n \" let e = exp(-DRAG * t);\",\n \" let a = record.velocity - g * inverse;\",\n \" let settle = (1.0 - e) * inverse;\",\n \" p = record.position + a * settle + g * inverse * t;\",\n \" v = a * e + g * inverse;\",\n \" }\",\n );\n } else {\n lines.push(\" p = record.position + record.velocity * t + g * (0.5 * t * t);\", \" v = record.velocity + g * t;\");\n }\n if (forces.orbit !== null) {\n lines.push(\n \" {\",\n \" let angle = ORBIT_SPEED * DEG_TO_RAD * t;\",\n \" p = shaderUniforms.orbitCenter + rotateAbout(p - shaderUniforms.orbitCenter, ORBIT_AXIS, angle);\",\n \" v = rotateAbout(v, ORBIT_AXIS, angle);\",\n \" }\",\n );\n }\n if (forces.noise !== null) {\n const influence = lookup.noise === null ? \"NOISE_INFLUENCE\" : decodeRow(\"NOISE\", \"r\");\n lines.push(\n \" {\",\n ` let amount = NOISE_STRENGTH * ${influence};`,\n \" p += amount * noise3(p * NOISE_FREQUENCY + NOISE_SCROLL * t);\",\n \" }\",\n );\n }\n if (main.simulationSpace === \"local\") {\n lines.push(\n \" p = (shaderUniforms.emitterWorld * vec4<f32>(p, 1.0)).xyz;\",\n \" v = (shaderUniforms.emitterWorld * vec4<f32>(v, 0.0)).xyz;\",\n );\n }\n lines.push(\" let units = vec3<f32>(pcg3d(vec3<u32>(record.seed, SALT_Y, SALT_Z))) * UNIT_SCALE;\");\n lines.push(\n start.color.kind === \"random\"\n ? \" var rgba = mix(START_COLOR_MIN, START_COLOR_MAX, units.x);\"\n : \" var rgba = START_COLOR;\",\n );\n if (lookup.color !== null) {\n lines.push(\" rgba *= lookupRow(COLOR_ROW, life);\");\n }\n lines.push(\" out.color = vec4<f32>(srgbToLinear(rgba.rgb), rgba.a);\");\n lines.push(\" var size = vec3<f32>(record.size) * SIZE_SCALE;\");\n if (lookup.size !== null) {\n lines.push(\" size *= SIZE_MIN + lookupRow(SIZE_ROW, life).rgb * (SIZE_MAX - SIZE_MIN);\");\n }\n const rotation = overLifetime.rotation;\n let angular = \"0.0\";\n if (rotation !== null) {\n angular = rotation.kind === \"curve\" ? decodeRow(\"ROTATION\", \"r\") : pickScalar(rotation, \"units.y\");\n }\n lines.push(` let rotation = record.rotation + ${angular} * DEG_TO_RAD * t;`);\n lines.push(...orientation(renderer.mode, renderer.lit));\n lines.push(...sheetUv(definition));\n lines.push(\" return out;\", \"}\");\n return lines.join(\"\\n\");\n}\n\n/**\n * The lines that place the vertex in the world for a render mode and write `out.position`.\n *\n * @param mode - The render mode.\n * @param lit - Whether the light uniforms are declared.\n * @returns The lines.\n */\nfunction orientation(mode: ParticleDefinition[\"renderer\"][\"mode\"], lit: boolean): string[] {\n const lines: string[] = [\n \" let view = shaderSystem.view;\",\n \" let viewRight = vec3<f32>(view[0].x, view[1].x, view[2].x);\",\n \" let viewUp = vec3<f32>(view[0].y, view[1].y, view[2].y);\",\n \" let viewForward = vec3<f32>(view[0].z, view[1].z, view[2].z);\",\n ];\n if (mode === \"mesh\") {\n lines.push(\n \" let spin = normalize(vec3<f32>(pcg3d(vec3<u32>(record.seed, SALT_Z, SALT_Y))) * UNIT_SCALE * 2.0 - vec3<f32>(1.0));\",\n \" let world = p + rotateAbout(input.position * size, spin, rotation);\",\n );\n if (lit) {\n lines.push(\" let normal = rotateAbout(input.normal, spin, rotation);\");\n }\n } else {\n lines.push(\" let corner = input.position.xy - PIVOT;\");\n if (mode === \"stretched\") {\n lines.push(\n \" let speed = length(v);\",\n \" var axis = viewUp;\",\n \" if (speed > 1e-6) { axis = v / speed; }\",\n \" var right = cross(viewForward, axis);\",\n \" if (dot(right, right) < 1e-8) { right = viewRight; } else { right = normalize(right); }\",\n \" let stretched = size.y * LENGTH_SCALE + speed * SPEED_SCALE;\",\n \" let world = p + right * (corner.x * size.x) + axis * (corner.y * stretched);\",\n );\n if (lit) {\n lines.push(\" let normal = -viewForward;\");\n }\n } else {\n lines.push(\n \" let cr = cos(rotation);\",\n \" let sr = sin(rotation);\",\n \" let spun = vec2<f32>(corner.x * cr - corner.y * sr, corner.x * sr + corner.y * cr);\",\n );\n lines.push(...billboardBasis(mode, lit));\n lines.push(\" let world = p + right * (spun.x * size.x) + up * (spun.y * size.y);\");\n }\n }\n if (lit) {\n lines.push(\n \" {\",\n \" let n = normalize(normal);\",\n \" let lambert = max(dot(n, -shaderUniforms.mainLightDirection), 0.0);\",\n \" out.color = vec4<f32>(out.color.rgb * (shaderUniforms.mainLightColor * lambert + shaderUniforms.ambientColor), out.color.a);\",\n \" }\",\n );\n }\n lines.push(\" out.position = shaderSystem.viewProjection * vec4<f32>(world, 1.0);\");\n return lines;\n}\n\n/**\n * The `right`, `up` and (for a lit definition) `normal` of a quad that is not stretched.\n *\n * @param mode - The render mode; never `\"mesh\"` or `\"stretched\"`.\n * @param lit - Whether the light uniforms are declared.\n * @returns The lines.\n */\nfunction billboardBasis(mode: ParticleDefinition[\"renderer\"][\"mode\"], lit: boolean): string[] {\n if (mode === \"horizontal\") {\n return [\n \" let right = vec3<f32>(1.0, 0.0, 0.0);\",\n \" let up = vec3<f32>(0.0, 0.0, 1.0);\",\n ...(lit ? [\" let normal = vec3<f32>(0.0, 1.0, 0.0);\"] : []),\n ];\n }\n if (mode === \"vertical\") {\n return [\n \" let up = vec3<f32>(0.0, 1.0, 0.0);\",\n \" let toCamera = shaderSystem.cameraPosition - p;\",\n \" let level = vec3<f32>(toCamera.x, 0.0, toCamera.z);\",\n \" var facing = vec3<f32>(0.0, 0.0, -1.0);\",\n \" if (dot(level, level) > 1e-8) { facing = normalize(level); }\",\n \" let right = normalize(cross(up, facing));\",\n ...(lit ? [\" let normal = facing;\"] : []),\n ];\n }\n return [\" let right = viewRight;\", \" let up = viewUp;\", ...(lit ? [\" let normal = -viewForward;\"] : [])];\n}\n\n/**\n * The lines that write `out.uv`, remapped into a sprite-sheet frame when the definition has one.\n *\n * @param definition - The definition.\n * @returns The lines.\n */\nfunction sheetUv(definition: ParticleDefinition): string[] {\n const sheet = definition.renderer.sheet;\n if (sheet === null) {\n return [\" out.uv = input.uv;\"];\n }\n let frame: string;\n if (sheet.mode === \"random\") {\n frame = \"min(SHEET_COUNT - 1.0, floor(units.z * SHEET_COUNT))\";\n } else if (sheet.mode === \"fps\") {\n frame = \"floor(units.z * SHEET_COUNT + SHEET_FPS * t) % SHEET_COUNT\";\n } else {\n const fraction = definition.lookup.frame === null ? \"0.0\" : decodeRow(\"FRAME\", \"r\");\n frame = `clamp(floor(${fraction} * SHEET_COUNT), 0.0, SHEET_COUNT - 1.0)`;\n }\n return [\n ` let frame = ${frame};`,\n \" let tile = vec2<f32>(frame % SHEET_TILES.x, floor(frame / SHEET_TILES.x));\",\n \" let flipped = vec2<f32>(input.uv.x, 1.0 - input.uv.y);\",\n \" let sheetUv = (flipped + tile) / SHEET_TILES;\",\n \" out.uv = vec2<f32>(sheetUv.x, 1.0 - sheetUv.y);\",\n ];\n}\n\n/**\n * The fragment stage: the sheet texel or a procedural soft disc, times the vertex colour, written\n * straight or premultiplied to match the blend state.\n *\n * @param definition - The definition.\n * @returns The `mainFragment` function.\n */\nfunction fragmentStage(definition: ParticleDefinition): string {\n const { renderer } = definition;\n const lines: string[] = [\"@fragment fn mainFragment(input: VertexOutput) -> @location(0) vec4<f32> {\"];\n if (renderer.texture !== null) {\n lines.push(\" let texel = textureSample(sheet, sheetSampler, input.uv);\");\n } else if (renderer.mode === \"mesh\") {\n lines.push(\" let texel = vec4<f32>(1.0);\");\n } else {\n lines.push(\n \" let d = length(input.uv * 2.0 - vec2<f32>(1.0));\",\n \" let mask = clamp(1.0 - d, 0.0, 1.0);\",\n \" let texel = vec4<f32>(1.0, 1.0, 1.0, mask * mask);\",\n );\n }\n lines.push(\" let color = input.color * texel;\");\n if (renderer.blend === \"premultiplied\") {\n lines.push(\" return vec4<f32>(color.rgb * color.a, color.a);\");\n } else {\n lines.push(\" return color;\");\n }\n lines.push(\"}\");\n return lines.join(\"\\n\");\n}\n\n/**\n * The `data:` address the generated program is published under, so the core shader loader — the\n * only path that also loads core's shader adapter — reads it with no file and no network. Two\n * definitions that generate the same program share one address, and so one `ShaderAsset`.\n *\n * @param source - The generated WGSL, which is ASCII.\n * @returns A `data:text/plain;base64,…` URL.\n *\n * @beta\n */\nexport function particleShaderAddress(source: string): string {\n return `data:text/plain;base64,${btoa(source)}`;\n}\n","import { createMaterialAsset, MeshAsset, shaderMaterialDefinition, TextureAsset } from \"@ignifx/core\";\nimport { LOOKUP_SAMPLES } from \"../definition/types.js\";\nimport { ParticlesErrorCode } from \"../errors.js\";\nimport { generateParticleWgsl, particleShaderAddress } from \"../gpu/wgsl.js\";\nimport type { ParticleAsset } from \"../assets/particle-asset.js\";\nimport type { ParticleMeshName } from \"../definition/types.js\";\nimport type { ParticleSystem } from \"../gpu/particle-system.js\";\nimport type { ParticlesSettings } from \"../settings.js\";\nimport type {\n App,\n AssetHandle,\n DiagnosticsGroup,\n MaterialAsset,\n ShaderAsset,\n ShaderMaterialDefinition,\n Vec3Like,\n} from \"@ignifx/core\";\n\n// `app.particles`: the budget, the quality multiplier, the gravity, the counters, and the resources\n// every system playing one definition shares. The storage buffer and the material are per system;\n// everything else is per definition.\n\n/**\n * The diagnostics group name.\n *\n * @public\n */\nexport const PARTICLES_DIAGNOSTICS_GROUP = \"particles\";\n\n/**\n * The counters the group carries, in index order.\n *\n * @public\n */\nexport const PARTICLES_DIAGNOSTICS_COUNTERS: readonly string[] = Object.freeze([\n \"systems\",\n \"alive\",\n \"emitted\",\n \"uploadBytes\",\n \"drawCalls\",\n]);\n\n/** Floats in one instance matrix. */\nconst MATRIX_FLOATS = 16;\n\n/**\n * The GPU-facing resources one definition's systems share.\n *\n * @public\n */\nexport interface ParticleDefinitionResources {\n /** The generated program. */\n readonly source: string;\n /** The program's asset, loading until the shader adapter is in place. */\n readonly shader: AssetHandle<ShaderAsset>;\n /** The baked lookup texture. */\n readonly lut: AssetHandle<TextureAsset>;\n /** The renderer's texture, or `null` for the procedural disc. */\n readonly sheet: AssetHandle<TextureAsset> | null;\n /** The quad, or the primitive a `\"mesh\"` renderer draws. */\n readonly mesh: AssetHandle<MeshAsset>;\n /** The material every system builds its own copy from. */\n readonly materialDefinition: ShaderMaterialDefinition;\n /** The texture handles in the order `materialDefinition.textures` names them. */\n readonly textures: readonly AssetHandle<TextureAsset>[];\n}\n\n/** A shared resource set plus the count of systems holding it. */\ninterface ResourceEntry {\n readonly resources: ParticleDefinitionResources;\n holders: number;\n hasReportedFailure: boolean;\n}\n\n/**\n * The particles service, reached as `app.particles`.\n *\n * @example\n * ```ts\n * app.particles.qualityScale = 0.5; // half the emission everywhere, for a low setting\n * app.particles.systems.length; // how many ParticleSystem components are attached\n * ```\n *\n * @public\n */\nexport class ParticlesService {\n /**\n * The budget every attached system's capacity is counted against. Raising it takes effect for\n * systems attached afterwards.\n */\n maxParticles: number;\n\n /** A `0`–`1` multiplier on every rate and burst count, read each frame. */\n qualityScale: number;\n\n readonly #app: App;\n\n readonly #gravity: { x: number; y: number; z: number };\n\n readonly #systems: ParticleSystem[] = [];\n\n readonly #resources = new Map<string, ResourceEntry>();\n\n readonly #meshes = new Map<string, AssetHandle<MeshAsset>>();\n\n #counters: DiagnosticsGroup | null = null;\n\n #identitySlab: Float32Array | null = null;\n\n #capacityInUse = 0;\n\n #isDisposed = false;\n\n /**\n * Creates the service.\n *\n * @param app - The app it belongs to.\n * @param settings - The resolved `particles` section, options already merged.\n */\n constructor(app: App, settings: ParticlesSettings) {\n this.#app = app;\n this.maxParticles = settings.maxParticles;\n this.qualityScale = settings.qualityScale;\n this.#gravity = { x: settings.gravity.x, y: settings.gravity.y, z: settings.gravity.z };\n }\n\n /**\n * The world gravity a definition's `gravityMultiplier` scales, in metres per second squared.\n *\n * @returns The service's own vector; assign to replace it.\n */\n get gravity(): Vec3Like {\n return this.#gravity;\n }\n\n /**\n * Copies a new world gravity in, so the caller's object is not retained.\n *\n * @param value - The gravity to copy.\n */\n set gravity(value: Vec3Like) {\n this.#gravity.x = value.x;\n this.#gravity.y = value.y;\n this.#gravity.z = value.z;\n }\n\n /**\n * Every attached `ParticleSystem`, in attach order.\n *\n * @returns The live list; iterate it without copying.\n */\n get systems(): readonly ParticleSystem[] {\n return this.#systems;\n }\n\n /**\n * How much of the budget attached systems hold.\n *\n * @returns The sum of every attached system's capacity.\n */\n get capacityInUse(): number {\n return this.#capacityInUse;\n }\n\n /**\n * The `particles` diagnostics group, once the extension registered it.\n *\n * @returns The group, or `null` before registration.\n */\n get counters(): DiagnosticsGroup | null {\n return this.#counters;\n }\n\n /**\n * Installs the counters group the extension registered.\n *\n * @param group - The group.\n *\n * @internal\n */\n setCounters(group: DiagnosticsGroup): void {\n this.#counters = group;\n }\n\n /**\n * Adds a system to the live list.\n *\n * @param system - The system.\n *\n * @internal\n */\n attach(system: ParticleSystem): void {\n if (!this.#systems.includes(system)) {\n this.#systems.push(system);\n }\n }\n\n /**\n * Removes a system from the live list.\n *\n * @param system - The system.\n *\n * @internal\n */\n detach(system: ParticleSystem): void {\n const index = this.#systems.indexOf(system);\n if (index >= 0) {\n this.#systems.splice(index, 1);\n }\n }\n\n /**\n * Takes capacity out of the budget, clamping to what is left and logging `IGX-1702` when it had\n * to. Every renderer that spends the particle budget goes through here, `@ignifx/particles-2d`\n * included; pair each call with {@link ParticlesService.release}.\n *\n * @param entity - The entity's name, for the warning.\n * @param requested - The definition's capacity, in records.\n * @returns The capacity granted, at least one record.\n *\n * @beta\n */\n reserve(entity: string, requested: number): number {\n const available = Math.max(0, this.maxParticles - this.#capacityInUse);\n let granted = requested;\n if (requested > available) {\n granted = Math.max(1, available);\n this.#app.log.warn(\n `${ParticlesErrorCode.budgetExceeded}: ${JSON.stringify(entity)} asked for ${String(requested)} particles, but only ${String(available)} of the ${String(this.maxParticles)} particle budget remain; the system was clamped.`,\n );\n }\n this.#capacityInUse += granted;\n return granted;\n }\n\n /**\n * Gives capacity back to the budget.\n *\n * @param granted - What {@link ParticlesService.reserve} returned.\n *\n * @beta\n */\n release(granted: number): void {\n this.#capacityInUse = Math.max(0, this.#capacityInUse - granted);\n }\n\n /**\n * The shared resources of a definition, built on first use.\n *\n * @param asset - The particle asset.\n * @returns The resources; pair every call with {@link ParticlesService.releaseResources}.\n *\n * @internal\n */\n acquireResources(asset: ParticleAsset): ParticleDefinitionResources {\n const existing = this.#resources.get(asset.address);\n if (existing !== undefined) {\n existing.holders += 1;\n return existing.resources;\n }\n const resources = this.#buildResources(asset);\n this.#resources.set(asset.address, { resources, holders: 1, hasReportedFailure: false });\n return resources;\n }\n\n /**\n * Lets go of a definition's resources, disposing them with the last holder.\n *\n * @param asset - The particle asset.\n *\n * @internal\n */\n releaseResources(asset: ParticleAsset): void {\n const entry = this.#resources.get(asset.address);\n if (entry === undefined) {\n return;\n }\n entry.holders -= 1;\n if (entry.holders <= 0) {\n this.#resources.delete(asset.address);\n disposeResources(entry.resources);\n }\n }\n\n /**\n * Reports, once per definition, that its shader failed to load.\n *\n * @param asset - The particle asset.\n * @param message - The failure.\n *\n * @internal\n */\n reportShaderFailure(asset: ParticleAsset, message: string): void {\n const entry = this.#resources.get(asset.address);\n if (entry === undefined || entry.hasReportedFailure) {\n return;\n }\n entry.hasReportedFailure = true;\n this.#app.log.error(\n `${ParticlesErrorCode.shaderFailed}: The particle shader for ${asset.address} could not be built: ${message}.`,\n );\n }\n\n /**\n * An identity matrix slab at least `capacity` instances long, shared by every renderer: the\n * particle shader never reads the instance matrices, so one read-only slab serves all.\n *\n * @param capacity - How many instances the caller needs.\n * @returns The slab.\n *\n * @internal\n */\n identitySlab(capacity: number): Float32Array {\n const needed = capacity * MATRIX_FLOATS;\n let slab = this.#identitySlab;\n if (slab === null || slab.length < needed) {\n slab = new Float32Array(needed);\n for (let index = 0; index < capacity; index += 1) {\n const base = index * MATRIX_FLOATS;\n slab[base] = 1;\n slab[base + 5] = 1;\n slab[base + 10] = 1;\n slab[base + 15] = 1;\n }\n this.#identitySlab = slab;\n }\n return slab;\n }\n\n /**\n * Builds a system's own material from a definition's shared resources.\n *\n * @param resources - The shared resources.\n * @returns The material handle, with one holder — the caller.\n *\n * @internal\n */\n createMaterial(resources: ParticleDefinitionResources): AssetHandle<MaterialAsset> {\n return createMaterialAsset(this.#app, resources.materialDefinition, resources.textures);\n }\n\n /** Releases every shared resource. The extension calls it on dispose. */\n dispose(): void {\n if (this.#isDisposed) {\n return;\n }\n this.#isDisposed = true;\n for (const entry of this.#resources.values()) {\n disposeResources(entry.resources);\n }\n this.#resources.clear();\n for (const mesh of this.#meshes.values()) {\n mesh.release();\n }\n this.#meshes.clear();\n this.#systems.length = 0;\n }\n\n /**\n * Generates and loads everything a definition's systems share.\n *\n * @param asset - The particle asset.\n * @returns The resources.\n */\n #buildResources(asset: ParticleAsset): ParticleDefinitionResources {\n const app = this.#app;\n const definition = asset.definition;\n const source = generateParticleWgsl(definition);\n const address = particleShaderAddress(source);\n const shader = app.assets.load<ShaderAsset>(address, { type: \"shader\" });\n const lut = TextureAsset.fromPixels(\n app,\n `particles:lut:${asset.address}`,\n definition.lookup.pixels,\n LOOKUP_SAMPLES,\n definition.lookup.rows,\n {\n filter: \"linear\",\n wrap: \"clamp\",\n },\n );\n const sheet = asset.texture === null ? null : asset.texture.retain();\n const mesh = this.#mesh(definition.renderer.mode === \"mesh\" ? definition.renderer.mesh : null);\n const textureAddresses: Record<string, string> = {};\n const textures: AssetHandle<TextureAsset>[] = [];\n if (sheet !== null) {\n textureAddresses[\"sheet\"] = sheet.address;\n textures.push(sheet);\n }\n textureAddresses[\"lut\"] = lut.address;\n textures.push(lut);\n const materialDefinition = shaderMaterialDefinition({\n shader: address,\n name: `particles:${asset.address}`,\n textures: textureAddresses,\n });\n return { source, shader, lut, sheet, mesh, materialDefinition, textures };\n }\n\n /**\n * The quad every billboard mode draws, or a unit primitive, built once per app.\n *\n * @param name - The primitive, or `null` for the quad.\n * @returns The mesh handle, retained for the caller.\n */\n #mesh(name: ParticleMeshName | null): AssetHandle<MeshAsset> {\n const key = name ?? \"quad\";\n const cached = this.#meshes.get(key);\n if (cached !== undefined) {\n return cached.retain();\n }\n const app = this.#app;\n let handle: AssetHandle<MeshAsset>;\n switch (name) {\n case null:\n handle = MeshAsset.fromData(app, \"particles:quad\", quadGeometry());\n break;\n case \"box\":\n handle = MeshAsset.box(app, { size: 1 });\n break;\n case \"sphere\":\n handle = MeshAsset.sphere(app, { diameter: 1, segments: 12 });\n break;\n case \"plane\":\n handle = MeshAsset.plane(app, { size: 1 });\n break;\n case \"cylinder\":\n handle = MeshAsset.cylinder(app, { height: 1, diameter: 1, tessellation: 12 });\n break;\n case \"capsule\":\n handle = MeshAsset.capsule(app, { height: 1, radius: 0.25, tessellation: 8 });\n break;\n case \"torus\":\n handle = MeshAsset.torus(app, { diameter: 1, thickness: 0.3, tessellation: 12 });\n break;\n }\n this.#meshes.set(key, handle);\n return handle.retain();\n }\n}\n\n/**\n * Releases a resource set's handles.\n *\n * @param resources - The set.\n */\nfunction disposeResources(resources: ParticleDefinitionResources): void {\n resources.shader.release();\n resources.lut.release();\n resources.sheet?.release();\n resources.mesh.release();\n}\n\n/**\n * The unit quad billboards are drawn from: corners at `±0.5` in XY, `uv` `(0, 0)` at the bottom\n * left, facing `-Z`.\n *\n * @returns The geometry.\n */\nfunction quadGeometry(): {\n readonly positions: Float32Array;\n readonly normals: Float32Array;\n readonly indices: Uint32Array;\n readonly uvs: Float32Array;\n} {\n return {\n positions: Float32Array.from([-0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0]),\n normals: Float32Array.from([0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1]),\n indices: Uint32Array.from([0, 1, 2, 0, 2, 3]),\n uvs: Float32Array.from([0, 0, 1, 0, 1, 1, 0, 1]),\n };\n}\n","import {\n asset,\n bool,\n Component,\n createDefaults,\n createStorageBufferAsset,\n defineSchema,\n InstancedMeshRenderer,\n Mat4,\n Signal,\n u32,\n Vec3,\n} from \"@ignifx/core\";\nimport { ParticleAsset } from \"../assets/particle-asset.js\";\nimport { ParticleEmitterCore } from \"../emitter/emitter-core.js\";\nimport { RECORD_BYTES, RECORD_FLOATS } from \"../emitter/record-ring.js\";\nimport { ParticlesErrorCode, particlesError } from \"../errors.js\";\nimport { createParticleState, evaluateParticle } from \"../evaluate/particle-math.js\";\nimport { ParticlesService } from \"../service/particles-service.js\";\nimport type { ParticleStopOptions } from \"../emitter/emitter-core.js\";\nimport type { UploadRange } from \"../emitter/record-ring.js\";\nimport type { ParticleEvaluationInputs, ParticleState } from \"../evaluate/particle-math.js\";\nimport type { ParticleDefinitionResources } from \"../service/particles-service.js\";\nimport type { AssetHandle, ComponentHooks, MaterialAsset, Schema, StorageBufferAsset } from \"@ignifx/core\";\n\n// The `ParticleSystem` component. It owns an emitter core, a storage buffer for the records, a\n// material built from the definition's shared shader, and an `InstancedMeshRenderer` it adds to its\n// own entity.\n\n/**\n * Where the update system sits in `Update`: after every script, so a script's `emit()` is drawn in\n * the same frame.\n *\n * @public\n */\nexport const PARTICLE_UPDATE_ORDER = 900;\n\n/**\n * Where the render system sits in `PreRender`: before core's shader-uniform (890) and render-sync\n * (900) systems, so this frame's records and uniforms are what the scene draws.\n *\n * @public\n */\nexport const PARTICLE_RENDER_ORDER = 880;\n\n/** How many floats a `vec3` uniform holds. */\nconst VEC3_FLOATS = 3;\n\n/**\n * Draws a particle effect on its entity.\n *\n * @example\n * ```ts\n * const fire = particleAssetFromDefinition(app, particleDefinition(\"fire\"));\n * const system = campfire.addComponent(ParticleSystem, { definition: fire });\n * system.emit(50);\n * ```\n *\n * @public\n */\nexport class ParticleSystem extends Component implements ComponentHooks {\n /** The registration id the serializer writes into scene files. */\n static typeId = \"ignifx/ParticleSystem\";\n\n /** The name an inspector shows for the component. */\n static title = \"Particle system\";\n\n /** Several effects may share one entity; each owns its own renderer. */\n static allowMultiple = true;\n\n /** The declarative fields (ADR-0004). */\n static schema: Schema = particleSystemSchema();\n\n /** The `.particles.json`, as a loaded handle. */\n declare definition: AssetHandle<ParticleAsset> | null;\n\n /** Whether the system plays the first frame it is enabled; the definition's `playOnAwake` must agree. */\n declare playOnAwake: boolean;\n\n /** The emission seed; `0` uses the definition's, and a definition seed of `0` picks at random. */\n declare seed: number;\n\n /** Emitted once when a non-looping system runs out of cycle and particles. */\n readonly onStopped: Signal<ParticleSystem> = new Signal<ParticleSystem>();\n\n readonly #census: { readonly ranges: [UploadRange, UploadRange] } = {\n ranges: [\n { start: 0, count: 0 },\n { start: 0, count: 0 },\n ],\n };\n\n readonly #gravity = new Float32Array(VEC3_FLOATS);\n\n readonly #gravityWritten = new Float32Array(VEC3_FLOATS);\n\n readonly #orbitCenter = new Float32Array(VEC3_FLOATS);\n\n readonly #orbitWritten = new Float32Array(VEC3_FLOATS);\n\n readonly #emitterWorld = new Float32Array(16);\n\n readonly #inverse = new Mat4();\n\n readonly #gravityWorld = new Vec3();\n\n readonly #gravityLocal = new Vec3();\n\n #inputs: ParticleEvaluationInputs | null = null;\n\n #service: ParticlesService | null = null;\n\n #core: ParticleEmitterCore | null = null;\n\n #applied: ParticleAsset | null = null;\n\n #resources: ParticleDefinitionResources | null = null;\n\n #renderer: InstancedMeshRenderer | null = null;\n\n #material: AssetHandle<MaterialAsset> | null = null;\n\n #storage: AssetHandle<StorageBufferAsset> | null = null;\n\n #reserved = 0;\n\n #hasAutoPlayed = false;\n\n #hasBoundSheet = false;\n\n #worldVersion = -1;\n\n #headWritten = -1;\n\n #capacityWritten = -1;\n\n #uploadedBytes = 0;\n\n #emittedBefore = 0;\n\n #emittedThisFrame = 0;\n\n #hasWarnedNoService = false;\n\n /** Applies the schema defaults, exactly as `Component.define` would. */\n constructor() {\n super();\n Object.assign(this, createDefaults(ParticleSystem.schema));\n this.#gravityWritten.fill(Number.NaN);\n this.#orbitWritten.fill(Number.NaN);\n }\n\n /**\n * The loaded document, or `null` while the handle is loading or unset.\n *\n * @returns The asset.\n */\n get asset(): ParticleAsset | null {\n const handle = this.definition;\n return handle?.state === \"loaded\" ? handle.value : null;\n }\n\n /**\n * Whether the system is playing, paused or not.\n *\n * @returns `true` between `play()` and the stop.\n */\n get isPlaying(): boolean {\n return this.#core?.isPlaying ?? false;\n }\n\n /**\n * Whether the clock is held by `pause()`.\n *\n * @returns `true` while paused.\n */\n get isPaused(): boolean {\n return this.#core?.isPaused ?? false;\n }\n\n /**\n * How many particles are alive, exactly, as of the last frame.\n *\n * @returns The count.\n */\n get aliveCount(): number {\n return this.#core?.aliveCount ?? 0;\n }\n\n /**\n * How many records the GPU draws this frame: from the newest back to the oldest still alive.\n *\n * @returns The draw count.\n */\n get drawCount(): number {\n return this.#core?.drawCount ?? 0;\n }\n\n /**\n * How many spawns displaced a particle that was still alive, because the capacity the app's\n * `maxParticles` budget granted is smaller than the definition's rate times its lifetime.\n *\n * @returns The total since the system last started from empty.\n */\n get droppedCount(): number {\n return this.#core?.droppedTotal ?? 0;\n }\n\n /**\n * The system-local clock, in seconds — what every particle's age is measured against and what the\n * shader reads as `clock`.\n *\n * @returns The clock.\n */\n get time(): number {\n return this.#core?.time ?? 0;\n }\n\n /**\n * The ring capacity in use, after the app's budget clamped the definition's.\n *\n * @returns The capacity, or `0` before a definition is applied.\n */\n get capacity(): number {\n return this.#core?.ring.capacity ?? 0;\n }\n\n /**\n * The CPU mirror of the spawn records: `capacity * 12` floats, one 48-byte record per slot, in\n * the layout `src/emitter/record-ring.ts` documents. Read-only; for tests and tools.\n *\n * @returns The mirror, or `null` before a definition is applied.\n *\n * @beta\n */\n get records(): Float32Array | null {\n return this.#core?.ring.floats ?? null;\n }\n\n /**\n * The emitter core the frame drives.\n *\n * @returns The core, or `null` before a definition is applied.\n *\n * @internal\n */\n get core(): ParticleEmitterCore | null {\n return this.#core;\n }\n\n /**\n * The renderer the system draws through.\n *\n * @returns The renderer, or `null` before the GPU side is built.\n *\n * @internal\n */\n get renderer(): InstancedMeshRenderer | null {\n return this.#renderer;\n }\n\n /**\n * The material the system draws with.\n *\n * @returns The handle, or `null` before the GPU side is built.\n *\n * @internal\n */\n get material(): AssetHandle<MaterialAsset> | null {\n return this.#material;\n }\n\n /**\n * The storage buffer the records are streamed into.\n *\n * @returns The handle, or `null` before the GPU side is built.\n *\n * @internal\n */\n get storage(): AssetHandle<StorageBufferAsset> | null {\n return this.#storage;\n }\n\n /**\n * Bytes uploaded in the last frame.\n *\n * @returns The byte count.\n *\n * @internal\n */\n get uploadedBytes(): number {\n return this.#uploadedBytes;\n }\n\n /**\n * Particles emitted in the last frame.\n *\n * @returns The count.\n *\n * @internal\n */\n get emittedThisFrame(): number {\n return this.#emittedThisFrame;\n }\n\n /** Starts emitting, or resumes after `stop()`. A `prewarm` definition fast-forwards one cycle. */\n play(): void {\n this.#hasAutoPlayed = true;\n this.#requireCore(\"play\").play();\n }\n\n /**\n * Stops emitting. Live particles finish their lives unless `clear` is set.\n *\n * @param options - Whether to clear the particles too.\n */\n stop(options?: ParticleStopOptions): void {\n this.#hasAutoPlayed = true;\n this.#requireCore(\"stop\").stop(options);\n }\n\n /** Holds the clock; every particle freezes in place. */\n pause(): void {\n this.#requireCore(\"pause\").pause();\n }\n\n /** Releases `pause()`. */\n resume(): void {\n this.#requireCore(\"resume\").resume();\n }\n\n /**\n * Spawns particles now, at the current clock, whether or not the system is playing. Called from a\n * script's `update`, they are drawn in the same frame.\n *\n * @param count - How many; floored.\n * @throws IgnifxError with code `IGX-1707` for a negative or non-finite count, or `IGX-1705`\n * when no definition is applied.\n */\n emit(count: number): void {\n if (!Number.isFinite(count) || count < 0) {\n throw this.#invalidArgument(\"emit\", \"a finite non-negative count\", count);\n }\n this.#requireCore(\"emit\").emit(count);\n }\n\n /**\n * Fast-forwards the system by `seconds`, emitting as it goes — what `prewarm` does.\n *\n * @param seconds - How far to advance.\n * @throws IgnifxError with code `IGX-1707` for a negative or non-finite duration, or `IGX-1705`\n * when no definition is applied.\n */\n simulate(seconds: number): void {\n if (!Number.isFinite(seconds) || seconds < 0) {\n throw this.#invalidArgument(\"simulate\", \"a finite non-negative number of seconds\", seconds);\n }\n this.#requireCore(\"simulate\").simulate(seconds);\n }\n\n /**\n * Evaluates one spawn record at the current clock with the CPU evaluator, in world space — the\n * same arithmetic the shader runs, for tests and tools.\n *\n * @param slot - The record's slot in the ring.\n * @param out - Receives the state; allocate one with `createParticleState()`.\n * @returns `true` when the record is alive.\n *\n * @beta\n */\n evaluate(slot: number, out: ParticleState = createParticleState()): boolean {\n const core = this.#core;\n const inputs = this.#inputs;\n if (core === null || inputs === null) {\n return false;\n }\n this.#refreshFrameInputs(core);\n return evaluateParticle(inputs, core.ring.floats, core.ring.words, slot, core.time, out);\n }\n\n /** Joins the service's live list. */\n onAttach(): void {\n const service = this.app.services.tryGet(ParticlesService);\n this.#service = service;\n if (service === null) {\n if (!this.#hasWarnedNoService) {\n this.#hasWarnedNoService = true;\n this.app.log.warn(\n `${JSON.stringify(this.entity.name)} has a ParticleSystem, but the particles() extension is not registered; it stays inert.`,\n );\n }\n return;\n }\n service.attach(this);\n }\n\n /** Releases the GPU side, the budget, and the shared resources. */\n onDetach(): void {\n this.#teardown();\n this.#service?.detach(this);\n this.#service = null;\n }\n\n /**\n * One frame of emission. The `Update` system calls it.\n *\n * @param dt - The frame's scaled delta, or `0` while the app is paused.\n *\n * @internal\n */\n tick(dt: number): void {\n const service = this.#service;\n if (service === null || this.isDestroyed) {\n return;\n }\n const core = this.#ensureCore(service);\n if (core === null) {\n return;\n }\n const enabled = this.isEnabledInHierarchy;\n if (!this.#hasAutoPlayed && enabled) {\n this.#hasAutoPlayed = true;\n const applied = this.#applied;\n if (this.playOnAwake && applied !== null && applied.definition.main.playOnAwake) {\n core.play();\n }\n }\n core.qualityScale = service.qualityScale;\n if (enabled) {\n core.advance(dt);\n }\n core.reconcile();\n const emitted = core.emittedTotal;\n this.#emittedThisFrame = Math.max(0, emitted - this.#emittedBefore);\n this.#emittedBefore = emitted;\n }\n\n /**\n * One frame of upload. The `PreRender` system calls it.\n *\n * @internal\n */\n sync(): void {\n this.#uploadedBytes = 0;\n const service = this.#service;\n const core = this.#core;\n const applied = this.#applied;\n if (service === null || core === null || applied === null || this.isDestroyed) {\n return;\n }\n this.#ensureGpu(service, core, applied);\n const renderer = this.#renderer;\n const material = this.#material;\n const storage = this.#storage;\n if (renderer === null || material === null || storage === null) {\n return;\n }\n this.#upload(core, storage);\n const values = material.value;\n values.setUniform(\"clock\", core.time);\n const head = core.ring.head;\n if (head !== this.#headWritten) {\n this.#headWritten = head;\n values.setUniform(\"head\", head);\n }\n if (core.ring.capacity !== this.#capacityWritten) {\n this.#capacityWritten = core.ring.capacity;\n values.setUniform(\"capacity\", core.ring.capacity);\n }\n if (applied.definition.main.simulationSpace === \"local\") {\n values.setUniform(\"emitterWorld\", this.#emitterWorld);\n }\n if (!sameVec3(this.#gravity, this.#gravityWritten)) {\n this.#gravityWritten.set(this.#gravity);\n values.setUniform(\"gravity\", this.#gravity);\n }\n // The generated program declares `orbitCenter` only when the definition orbits.\n if (applied.definition.forces.orbit !== null && !sameVec3(this.#orbitCenter, this.#orbitWritten)) {\n this.#orbitWritten.set(this.#orbitCenter);\n values.setUniform(\"orbitCenter\", this.#orbitCenter);\n }\n const sheet = this.#resources?.sheet ?? null;\n if (!this.#hasBoundSheet && sheet !== null && sheet.state === \"loaded\") {\n this.#hasBoundSheet = true;\n values.setTexture(\"sheet\", sheet);\n }\n const draw = Math.min(core.drawCount, core.ring.capacity);\n if (draw !== renderer.count) {\n renderer.setCount(draw);\n }\n renderer.enabled = this.isEnabledInHierarchy;\n }\n\n /**\n * Refreshes the emitter matrix, the simulation-space gravity, and the orbit centre from the entity's\n * transform and the service, only when something moved.\n *\n * @param core - The core to write the matrix into.\n */\n #refreshFrameInputs(core: ParticleEmitterCore): void {\n const applied = this.#applied;\n const service = this.#service;\n if (applied === null || service === null) {\n return;\n }\n const transform = this.transform;\n const version = transform.worldMatrixVersion;\n const moved = version !== this.#worldVersion;\n if (moved) {\n this.#worldVersion = version;\n const world = transform.worldMatrix;\n this.#emitterWorld.set(world);\n core.emitterWorld.set(world);\n }\n const forces = applied.definition.forces;\n const gravity = forces.gravity;\n const g = service.gravity;\n const world = this.#gravityWorld;\n if (gravity === null) {\n world.set(g.x * forces.gravityMultiplier, g.y * forces.gravityMultiplier, g.z * forces.gravityMultiplier);\n } else {\n world.set(gravity.x, gravity.y, gravity.z);\n }\n const local = this.#gravityLocal;\n if (applied.definition.main.simulationSpace === \"local\") {\n if (Mat4.invertToRef(transform.worldMatrix, this.#inverse)) {\n Mat4.transformDirectionToRef(this.#inverse.elements, world, local);\n } else {\n local.copyFrom(world);\n }\n this.#orbitCenter[0] = 0;\n this.#orbitCenter[1] = 0;\n this.#orbitCenter[2] = 0;\n } else {\n local.copyFrom(world);\n this.#orbitCenter[0] = this.#emitterWorld[12] ?? 0;\n this.#orbitCenter[1] = this.#emitterWorld[13] ?? 0;\n this.#orbitCenter[2] = this.#emitterWorld[14] ?? 0;\n }\n this.#gravity[0] = local.x + forces.constantForce.x;\n this.#gravity[1] = local.y + forces.constantForce.y;\n this.#gravity[2] = local.z + forces.constantForce.z;\n }\n\n /**\n * The core, ready to spawn: built if the definition changed, and always holding the entity's\n * current world matrix. The matrix has to be current *before* anything spawns, because `play()`\n * on a prewarmed document fast-forwards a whole cycle and a `\"world\"` record bakes the matrix in.\n *\n * @param service - The service.\n * @returns The core, or `null` while the definition is loading or unset.\n */\n #ensureCore(service: ParticlesService): ParticleEmitterCore | null {\n if (this.asset !== this.#applied) {\n this.#buildCore(service);\n }\n const core = this.#core;\n if (core !== null) {\n this.#refreshFrameInputs(core);\n }\n return core;\n }\n\n /**\n * Builds, or rebuilds, the core for the definition handle's loaded value.\n *\n * @param service - The service.\n */\n #buildCore(service: ParticlesService): void {\n const loaded = this.asset;\n this.#teardown();\n this.#applied = loaded;\n if (loaded === null) {\n return;\n }\n const definition = loaded.definition;\n this.#reserved = service.reserve(this.entity.name, definition.main.capacity);\n const seed = this.seed !== 0 ? this.seed : definition.main.seed;\n const core = new ParticleEmitterCore({ definition, capacity: this.#reserved, seed });\n core.onStopped = (): void => {\n this.onStopped.emit(this);\n };\n this.#core = core;\n this.#resources = service.acquireResources(loaded);\n this.#hasAutoPlayed = false;\n this.#emittedBefore = 0;\n this.#worldVersion = -1;\n this.#inputs = {\n definition,\n gravity: this.#gravity,\n emitterWorld: this.#emitterWorld,\n orbitCenter: this.#orbitCenter,\n };\n }\n\n /**\n * Builds the storage buffer, the material, and the renderer once the shared shader has loaded.\n *\n * @param service - The service.\n * @param core - The core whose ring is uploaded.\n * @param applied - The applied asset.\n */\n #ensureGpu(service: ParticlesService, core: ParticleEmitterCore, applied: ParticleAsset): void {\n if (this.#renderer !== null) {\n return;\n }\n const resources = this.#resources;\n if (resources === null) {\n return;\n }\n const shader = resources.shader;\n if (shader.state === \"failed\") {\n service.reportShaderFailure(applied, shader.error?.message ?? \"unknown failure\");\n return;\n }\n if (shader.state !== \"loaded\") {\n return;\n }\n const storage = createStorageBufferAsset(this.app, `particles:${this.entity.name}`, core.ring.floats);\n const material = service.createMaterial(resources);\n material.value.setStorageBuffer(\"particles\", storage);\n this.#storage = storage;\n this.#material = material;\n this.#headWritten = -1;\n this.#capacityWritten = -1;\n this.#gravityWritten.fill(Number.NaN);\n this.#orbitWritten.fill(Number.NaN);\n this.#hasBoundSheet = false;\n core.ring.markUploaded();\n const capacity = core.ring.capacity;\n const renderer = this.entity.addComponent(InstancedMeshRenderer, {\n mesh: resources.mesh,\n materials: [material],\n capacity,\n gpuCulling: false,\n castShadows: false,\n receiveShadows: false,\n pickable: false,\n renderOrder: applied.definition.main.renderOrder,\n });\n renderer.setMatrices(service.identitySlab(capacity), capacity);\n renderer.setCount(Math.min(core.drawCount, capacity));\n this.#renderer = renderer;\n }\n\n /**\n * Streams the records written since the last frame into the storage buffer: one update, or two\n * when the ring wrapped.\n *\n * @param core - The core whose ring is uploaded.\n * @param storage - The buffer.\n */\n #upload(core: ParticleEmitterCore, storage: AssetHandle<StorageBufferAsset>): void {\n const ring = core.ring;\n const ranges = this.#census.ranges;\n const count = ring.pendingRanges(ranges);\n if (count === 0) {\n return;\n }\n const buffer = storage.value;\n for (let index = 0; index < count; index += 1) {\n const range = ranges[index];\n if (range === undefined || range.count === 0) {\n continue;\n }\n const view = ring.floats.subarray(range.start * RECORD_FLOATS, (range.start + range.count) * RECORD_FLOATS);\n buffer.update(view, range.start * RECORD_BYTES);\n this.#uploadedBytes += range.count * RECORD_BYTES;\n }\n ring.markUploaded();\n }\n\n /** Releases everything the applied definition built. */\n #teardown(): void {\n const renderer = this.#renderer;\n this.#renderer = null;\n if (renderer !== null && !renderer.isDestroyed) {\n renderer.destroy();\n }\n this.#material?.release();\n this.#material = null;\n this.#storage?.release();\n this.#storage = null;\n const service = this.#service;\n const applied = this.#applied;\n if (service !== null) {\n if (applied !== null && this.#resources !== null) {\n service.releaseResources(applied);\n }\n service.release(this.#reserved);\n }\n this.#resources = null;\n this.#reserved = 0;\n this.#core = null;\n this.#applied = null;\n this.#inputs = null;\n }\n\n /**\n * The core, or a misuse error naming the method.\n *\n * @param method - The method being called.\n * @returns The core.\n * @throws IgnifxError with code `IGX-1705`.\n */\n #requireCore(method: string): ParticleEmitterCore {\n const service = this.#service;\n const core = service === null ? this.#core : this.#ensureCore(service);\n if (core !== null) {\n return core;\n }\n throw particlesError(\n ParticlesErrorCode.noDefinition,\n `${this.entity.name} has a ParticleSystem with no definition, so ${method}() cannot run.`,\n {\n context: { entity: this.entity.name, method },\n hint: \"Assign a loaded ParticleAsset handle to `definition` first.\",\n },\n );\n }\n\n /**\n * Builds the `IGX-1707` argument error.\n *\n * @param method - The method.\n * @param expected - What it wanted.\n * @param value - What it got.\n * @returns The error.\n */\n #invalidArgument(method: string, expected: string, value: number): ReturnType<typeof particlesError> {\n return particlesError(ParticlesErrorCode.invalidArgument, `${method} needs ${expected}, not ${String(value)}.`, {\n context: { method, expected, value },\n });\n }\n}\n\n/**\n * Whether two three-float arrays hold the same values.\n *\n * @param a - One array.\n * @param b - The other.\n * @returns `true` when every component matches.\n */\nfunction sameVec3(a: Float32Array, b: Float32Array): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n\n/**\n * Builds the component's declared fields.\n *\n * @returns The schema, built inside a function so module scope holds no calls (`CONSTITUTION.md` §3.5).\n */\nfunction particleSystemSchema(): Schema {\n return defineSchema({\n definition: asset(ParticleAsset, { tooltip: \"The .particles.json this system plays.\" }),\n playOnAwake: bool(true, { tooltip: \"Play the first frame the system is enabled, if the definition agrees.\" }),\n seed: u32(0, { tooltip: \"The emission seed; 0 uses the definition's, and 0 there picks at random.\" }),\n });\n}\n","import type { ParticlesService } from \"../service/particles-service.js\";\nimport type { System, SystemContext } from \"@ignifx/core\";\n\n// The two frame systems that drive every `ParticleSystem`.\n// Both walk the service's live list rather\n// than the world's components, so the order is attach order and a detached system is already gone.\n\n/** The counter indices, resolved once. */\ninterface CounterIndices {\n readonly systems: number;\n readonly alive: number;\n readonly emitted: number;\n readonly uploadBytes: number;\n readonly drawCalls: number;\n}\n\n/**\n * Advances every system's emitter core by the frame's scaled delta, or by nothing while the app is\n * paused. Runs late in `Update` so a script's `emit()` is drawn in the same frame.\n *\n * @beta\n */\nexport class ParticleUpdateSystem implements System {\n /** The name diagnostics and error reports use. */\n readonly name: string = \"ignifx/particles-update\";\n\n readonly #service: ParticlesService;\n\n /**\n * Creates the system.\n *\n * @param service - The service whose list it walks.\n */\n constructor(service: ParticlesService) {\n this.#service = service;\n }\n\n /**\n * Runs emission for one frame.\n *\n * @param ctx - The world, the clock, the phase, and the frame delta.\n */\n update(ctx: SystemContext): void {\n const dt = ctx.time.paused ? 0 : ctx.dt;\n const systems = this.#service.systems;\n for (let index = 0; index < systems.length; index += 1) {\n systems[index]?.tick(dt);\n }\n }\n}\n\n/**\n * Uploads every system's new records, writes its uniforms, bounds its draw count, and publishes the\n * `particles` counters. Runs in `PreRender` before core's render sync.\n *\n * @beta\n */\nexport class ParticleRenderSystem implements System {\n /** The name diagnostics and error reports use. */\n readonly name: string = \"ignifx/particles-render\";\n\n readonly #service: ParticlesService;\n\n #indices: CounterIndices | null = null;\n\n /**\n * Creates the system.\n *\n * @param service - The service whose list it walks.\n */\n constructor(service: ParticlesService) {\n this.#service = service;\n }\n\n /** Runs the upload for one frame. */\n update(): void {\n const service = this.#service;\n const systems = service.systems;\n let alive = 0;\n let emitted = 0;\n let uploadBytes = 0;\n let drawCalls = 0;\n for (let index = 0; index < systems.length; index += 1) {\n const system = systems[index];\n if (system === undefined) {\n continue;\n }\n system.sync();\n alive += system.aliveCount;\n emitted += system.emittedThisFrame;\n uploadBytes += system.uploadedBytes;\n if (system.drawCount > 0 && system.renderer !== null && system.renderer.isVisible) {\n drawCalls += 1;\n }\n }\n const counters = service.counters;\n if (counters === null) {\n return;\n }\n let indices = this.#indices;\n if (indices === null) {\n indices = {\n systems: counters.index(\"systems\"),\n alive: counters.index(\"alive\"),\n emitted: counters.index(\"emitted\"),\n uploadBytes: counters.index(\"uploadBytes\"),\n drawCalls: counters.index(\"drawCalls\"),\n };\n this.#indices = indices;\n }\n counters.set(indices.systems, systems.length);\n counters.set(indices.alive, alive);\n counters.set(indices.emitted, emitted);\n counters.set(indices.uploadBytes, uploadBytes);\n counters.set(indices.drawCalls, drawCalls);\n }\n}\n","import { defineSchema, f32, u32, vec3 } from \"@ignifx/core\";\nimport type { Schema, Vec3Like } from \"@ignifx/core\";\n\n// The `particles` project settings section (`docs/architecture/04-extensions.md` §5). Three\n// project-wide decisions live here — the budget, the quality multiplier, and the world gravity;\n// everything per effect is in the `.particles.json`.\n\n/**\n * The section name as it appears in `ignifx.config.ts`.\n *\n * @public\n */\nexport const PARTICLES_SETTINGS_SECTION = \"particles\";\n\n/** How many particles every system together may hold, unless the project says otherwise. */\nconst DEFAULT_MAX_PARTICLES = 100_000;\n\n/** Standard gravity, matching `@ignifx/physics`'s own default. */\nconst DEFAULT_GRAVITY: Vec3Like = Object.freeze({ x: 0, y: -9.81, z: 0 });\n\n/**\n * The resolved `particles` settings section.\n *\n * @example\n * ```ts\n * // ignifx.config.ts\n * export default defineConfig({\n * particles: { maxParticles: 50_000, qualityScale: 1 },\n * });\n * ```\n *\n * @public\n */\nexport interface ParticlesSettings {\n /**\n * The budget every `ParticleSystem`'s `capacity` is counted against. A system that would push the\n * total over it is clamped to what is left and `IGX-1702` is logged once.\n */\n readonly maxParticles: number;\n /** A `0`–`1` multiplier on every emission rate and burst count, for settings screens. */\n readonly qualityScale: number;\n /**\n * The world gravity, in metres per second squared, a definition's `forces.gravityMultiplier`\n * scales. When `@ignifx/physics` is registered and this stays at its default, the physics\n * section's gravity is used instead.\n */\n readonly gravity: Vec3Like;\n}\n\n/**\n * The values used for everything a project omits.\n *\n * @returns The default `particles` section.\n *\n * @public\n */\nexport function defaultParticlesSettings(): ParticlesSettings {\n return { maxParticles: DEFAULT_MAX_PARTICLES, qualityScale: 1, gravity: { ...DEFAULT_GRAVITY } };\n}\n\n/**\n * The schema the `particles` section is validated against.\n *\n * @returns The schema, built fresh so no module holds state (`CONSTITUTION.md` §3.5).\n *\n * @public\n */\nexport function particlesSettingsSchema(): Schema {\n return defineSchema({\n maxParticles: u32(DEFAULT_MAX_PARTICLES, {\n min: 0,\n tooltip: \"The particle budget every ParticleSystem capacity is counted against.\",\n }),\n qualityScale: f32(1, { min: 0, max: 1, tooltip: \"A 0-1 multiplier on emission rates and burst counts.\" }),\n gravity: vec3(DEFAULT_GRAVITY, { tooltip: \"The world gravity a gravityMultiplier scales, in m/s^2.\" }),\n });\n}\n","// The build replaces this with the version in `package.json` (`define` in `tsdown.config.ts`).\ndeclare const IGNIFX_BUILD_VERSION: string | undefined;\n\n/**\n * The `@ignifx/particles` version this build was cut from, reported as `Extension.version`\n * (`docs/architecture/04-extensions.md` §1).\n *\n * @remarks\n * The build stamps it from `package.json`; code run from source, such as this repository's tests,\n * sees `\"0.0.0\"`.\n *\n * @public\n */\nexport const VERSION: string = typeof IGNIFX_BUILD_VERSION === \"string\" ? IGNIFX_BUILD_VERSION : \"0.0.0\";\n","import { defineExtension, Phase } from \"@ignifx/core\";\nimport { createParticleLoader } from \"./assets/loader.js\";\nimport { defineParticlesAppProperty } from \"./augmentation.js\";\nimport { PARTICLES_ERROR_MESSAGES, ParticlesErrorCode, particlesError } from \"./errors.js\";\nimport { PARTICLE_RENDER_ORDER, PARTICLE_UPDATE_ORDER, ParticleSystem } from \"./gpu/particle-system.js\";\nimport { ParticleRenderSystem, ParticleUpdateSystem } from \"./gpu/particle-systems.js\";\nimport {\n PARTICLES_DIAGNOSTICS_COUNTERS,\n PARTICLES_DIAGNOSTICS_GROUP,\n ParticlesService,\n} from \"./service/particles-service.js\";\nimport { defaultParticlesSettings, PARTICLES_SETTINGS_SECTION, particlesSettingsSchema } from \"./settings.js\";\nimport { VERSION } from \"./version.js\";\nimport type { ParticlesSettings } from \"./settings.js\";\nimport type { App, Extension, ExtensionContext, Vec3Like } from \"@ignifx/core\";\n\n// The `@ignifx/particles` extension (`docs/architecture/04-extensions.md` §1). It requires nothing\n// but core: `@ignifx/physics` is read by data, through the `physics` settings section, so an effect\n// that says \"use the world's gravity\" agrees with the rigidbodies around it without a dependency.\n\n/**\n * What `particles()` accepts. Every field overrides the matching `particles` settings section value.\n *\n * @public\n */\nexport interface ParticlesOptions {\n /** The particle budget every system's capacity is counted against. */\n readonly maxParticles?: number;\n /** A `0`–`1` multiplier on every emission rate and burst count. */\n readonly qualityScale?: number;\n /** The world gravity a `gravityMultiplier` scales. */\n readonly gravity?: Vec3Like;\n}\n\n/** The shape of the `physics` settings section this package reads by data. */\ninterface PhysicsGravitySection {\n readonly gravity?: Vec3Like;\n}\n\n/**\n * Merges the extension's options over the resolved settings section.\n *\n * @param settings - The resolved `particles` section.\n * @param options - What the game passed to `particles(...)`.\n * @returns The effective settings.\n */\nfunction mergeSettings(settings: ParticlesSettings, options: ParticlesOptions): ParticlesSettings {\n return {\n maxParticles: options.maxParticles ?? settings.maxParticles,\n qualityScale: options.qualityScale ?? settings.qualityScale,\n gravity: options.gravity ?? settings.gravity,\n };\n}\n\n/**\n * Whether two gravity vectors are the same.\n *\n * @param a - One vector.\n * @param b - The other.\n * @returns `true` when every component matches.\n */\nfunction sameGravity(a: Vec3Like, b: Vec3Like): boolean {\n return a.x === b.x && a.y === b.y && a.z === b.z;\n}\n\n/**\n * Registers everything the package contributes.\n *\n * @param ctx - The registration surface.\n * @param options - What the game passed to `particles(...)`.\n * @returns The service, for `onStart`.\n */\nfunction registerParticles(ctx: ExtensionContext, options: ParticlesOptions): ParticlesService {\n if (ctx.tryGet(ParticlesService) !== null) {\n throw particlesError(\n ParticlesErrorCode.duplicateExtension,\n \"The particles() extension is already registered on this app.\",\n );\n }\n ctx.registerErrorCodes(PARTICLES_ERROR_MESSAGES);\n ctx.registerSettings<ParticlesSettings>(\n PARTICLES_SETTINGS_SECTION,\n particlesSettingsSchema(),\n defaultParticlesSettings(),\n );\n const settings = mergeSettings(ctx.settings<ParticlesSettings>(PARTICLES_SETTINGS_SECTION), options);\n const service = new ParticlesService(ctx.app, settings);\n service.setCounters(ctx.app.diagnostics.registerGroup(PARTICLES_DIAGNOSTICS_GROUP, PARTICLES_DIAGNOSTICS_COUNTERS));\n ctx.registerService(ParticlesService, service);\n defineParticlesAppProperty(ctx, service);\n ctx.registerAssetLoader(createParticleLoader());\n ctx.registerComponents([ParticleSystem]);\n // Held in edit mode: a system still starts and shows its first frame, but its clock stands still (ADR-0028).\n ctx.registerSystem(new ParticleUpdateSystem(service), {\n phase: Phase.Update,\n order: PARTICLE_UPDATE_ORDER,\n editMode: \"hold\",\n });\n ctx.registerSystem(new ParticleRenderSystem(service), { phase: Phase.PreRender, order: PARTICLE_RENDER_ORDER });\n ctx.onDispose((): void => {\n service.dispose();\n });\n return service;\n}\n\n/**\n * Adopts the physics gravity when the project left the particles gravity alone and `@ignifx/physics`\n * registered a section.\n *\n * @param app - The app being started.\n * @param service - The service to write into.\n * @param options - The extension options, which win over both sections.\n */\nfunction adoptPhysicsGravity(app: App, service: ParticlesService, options: ParticlesOptions): void {\n if (options.gravity !== undefined) {\n return;\n }\n const section = app.settings.section<ParticlesSettings>(PARTICLES_SETTINGS_SECTION);\n if (!sameGravity(section.gravity, defaultParticlesSettings().gravity)) {\n return;\n }\n let physics: PhysicsGravitySection | null;\n try {\n physics = app.settings.section<PhysicsGravitySection>(\"physics\");\n } catch {\n // `IGX-0407`: no physics extension is registered, which is the ordinary case for a particles-only app.\n physics = null;\n }\n const gravity = physics?.gravity;\n if (gravity !== undefined) {\n service.gravity = gravity;\n }\n}\n\n/**\n * The `@ignifx/particles` extension factory.\n *\n * @param options - Overrides for the `particles` settings section.\n * @returns The extension descriptor to pass to `createApp`.\n *\n * @example\n * ```ts\n * const app = await createApp({ canvas, extensions: [particles({ maxParticles: 50_000 })] });\n * ```\n *\n * @public\n */\nexport const particles: (options?: ParticlesOptions) => Extension = defineExtension<ParticlesOptions | undefined>(\n (raw) => {\n // `defineExtension` hands the factory whatever the caller passed, which is `undefined` when the\n // game wrote `particles()`; the typed signature cannot express that, so the default lands here.\n const options: ParticlesOptions = raw ?? {};\n let service: ParticlesService | null = null;\n return {\n name: \"@ignifx/particles\",\n version: VERSION,\n engine: \">=0.0.0 <1.0.0\",\n requires: [\"@ignifx/core\"],\n optional: [\"@ignifx/physics\"],\n register(ctx: ExtensionContext): void {\n service = registerParticles(ctx, options);\n },\n onStart(app: App): void {\n if (service !== null) {\n adoptPhysicsGravity(app, service, options);\n }\n },\n };\n },\n);\n","import { array, bool, custom, enumOf, f32, i32, record, str, u32, vec2, vec3 } from \"@ignifx/core\";\nimport {\n PARTICLE_BLEND_MODES,\n PARTICLE_EMIT_FROM,\n PARTICLE_MESHES,\n PARTICLE_RENDER_MODES,\n PARTICLE_SHAPE_KINDS,\n PARTICLE_SIMULATION_SPACES,\n PARTICLES_FORMAT,\n PARTICLES_FORMAT_VERSION,\n} from \"./definition/types.js\";\nimport type { FieldDefinition, JsonValue, Schema } from \"@ignifx/core\";\n\n// The declarative schema for `.particles.json`, for documentation and tooling only: the loader\n// validates with `defineParticles`, whose hand-written checks name the offending path. The \"value\"\n// unions have no built-in field kind, so they are `custom()` fields carrying a JSON Schema fragment.\n\n/** The JSON Schema fragment of a scalar value. */\nconst SCALAR_JSON_SCHEMA = {\n oneOf: [\n { type: \"number\" },\n {\n type: \"object\",\n properties: { min: { type: \"number\" }, max: { type: \"number\" } },\n required: [\"min\", \"max\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n curve: {\n type: \"object\",\n properties: {\n keys: {\n type: \"array\",\n items: { type: \"array\", items: { type: \"number\" }, minItems: 4, maxItems: 4 },\n minItems: 1,\n },\n },\n required: [\"keys\"],\n },\n },\n required: [\"curve\"],\n additionalProperties: false,\n },\n ],\n};\n\n/** The JSON Schema fragment of a colour. */\nconst COLOR_JSON_SCHEMA = {\n oneOf: [\n { type: \"array\", items: { type: \"number\" }, minItems: 3, maxItems: 4 },\n {\n type: \"object\",\n properties: { r: { type: \"number\" }, g: { type: \"number\" }, b: { type: \"number\" }, a: { type: \"number\" } },\n required: [\"r\", \"g\", \"b\"],\n },\n ],\n};\n\n/** The JSON Schema fragment of a colour value. */\nconst COLOR_VALUE_JSON_SCHEMA = {\n oneOf: [\n ...COLOR_JSON_SCHEMA.oneOf,\n {\n type: \"object\",\n properties: { min: COLOR_JSON_SCHEMA, max: COLOR_JSON_SCHEMA },\n required: [\"min\", \"max\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n gradient: {\n type: \"array\",\n items: { type: \"array\", items: { type: \"number\" }, minItems: 5, maxItems: 5 },\n minItems: 1,\n },\n },\n required: [\"gradient\"],\n additionalProperties: false,\n },\n ],\n};\n\n/**\n * A scalar value field: a number, a range, or a curve.\n *\n * @param defaultValue - The document default.\n * @param tooltip - What the value means.\n * @returns The field definition.\n */\nfunction scalarValue(defaultValue: JsonValue, tooltip: string): FieldDefinition<JsonValue> {\n return custom<JsonValue>(\n {\n createDefault: (): JsonValue => structuredClone(defaultValue),\n serialize: (value: JsonValue): JsonValue => value,\n deserialize: (json: JsonValue): JsonValue => json,\n jsonSchema: SCALAR_JSON_SCHEMA,\n },\n { tooltip },\n );\n}\n\n/**\n * A colour value field: a colour, a pair, or a gradient.\n *\n * @param defaultValue - The document default.\n * @param tooltip - What the value means.\n * @returns The field definition.\n */\nfunction colorValue(defaultValue: JsonValue, tooltip: string): FieldDefinition<JsonValue> {\n return custom<JsonValue>(\n {\n createDefault: (): JsonValue => structuredClone(defaultValue),\n serialize: (value: JsonValue): JsonValue => value,\n deserialize: (json: JsonValue): JsonValue => json,\n jsonSchema: COLOR_VALUE_JSON_SCHEMA,\n },\n { tooltip },\n );\n}\n\n/**\n * The `ignifx.particles` document schema.\n *\n * @returns The schema, built fresh so no module holds state (`CONSTITUTION.md` §3.5).\n *\n * @public\n */\nexport function particlesFileSchema(): Schema {\n // Not `defineSchema`: it refuses a field called `start` because a component schema becomes class\n // properties and `Script.start` already exists (`IGX-0607`). A file schema generates no class, and\n // `start` is the module name the format uses, so the check does not apply here.\n return {\n format: str(PARTICLES_FORMAT, { tooltip: \"Always ignifx.particles.\" }),\n formatVersion: u32(PARTICLES_FORMAT_VERSION, { tooltip: \"The document version this build reads.\" }),\n main: record(\n {\n capacity: u32(1000, {\n min: 1,\n tooltip: \"How many spawn records the ring holds; older records are overwritten.\",\n }),\n duration: f32(5, { min: 0.001, tooltip: \"How long one emission cycle lasts, in seconds.\" }),\n looping: bool(true, { tooltip: \"Whether the cycle repeats.\" }),\n prewarm: bool(false, { tooltip: \"Whether play() fast-forwards one cycle first.\" }),\n startDelay: f32(0, { min: 0, tooltip: \"Seconds after play() before emission starts.\" }),\n simulationSpace: enumOf(PARTICLE_SIMULATION_SPACES, \"local\", {\n tooltip: \"local follows the entity; world stays put.\",\n }),\n seed: u32(0, { tooltip: \"The emission seed; 0 picks one at random.\" }),\n playOnAwake: bool(true, { tooltip: \"Whether a ParticleSystem starts playing when enabled.\" }),\n timeScale: f32(1, { min: 0, tooltip: \"A multiplier on the system's own clock.\" }),\n renderOrder: i32(0, { tooltip: \"Sort key within the transparent phase; lower draws first.\" }),\n },\n { tooltip: \"Capacity, timing, space, and playback.\" },\n ),\n emission: record(\n {\n rateOverTime: f32(10, { min: 0, tooltip: \"Particles per second.\" }),\n rateOverDistance: f32(0, { min: 0, tooltip: \"Particles per metre the emitter moves.\" }),\n bursts: array(\n record({\n time: f32(0, { min: 0, tooltip: \"Seconds into the cycle.\" }),\n count: scalarValue(10, \"How many particles; a range is rolled per firing.\"),\n cycles: u32(1, { tooltip: \"Firings per cycle; 0 means until the cycle ends.\" }),\n interval: f32(0.1, { min: 0, tooltip: \"Seconds between firings.\" }),\n probability: f32(1, { min: 0, max: 1, tooltip: \"The chance a firing happens.\" }),\n }),\n [],\n { tooltip: \"The bursts, in order.\" },\n ),\n },\n { tooltip: \"Rates and bursts.\" },\n ),\n shape: record(\n {\n kind: enumOf(PARTICLE_SHAPE_KINDS, \"cone\", { tooltip: \"Which shape; directional shapes emit along local +Y.\" }),\n radius: f32(0.2, { min: 0, tooltip: \"Sphere, hemisphere, circle, or cone-base radius.\" }),\n thickness: f32(1, { min: 0, max: 1, tooltip: \"How much of the radius emits: 0 is the surface, 1 the whole.\" }),\n arc: f32(360, { min: 0, max: 360, tooltip: \"The angular span, in degrees.\" }),\n angle: f32(25, { min: 0, max: 90, tooltip: \"A cone's half-angle, in degrees.\" }),\n length: f32(1, { min: 0, tooltip: \"A cone's height, or an edge's length.\" }),\n size: vec3({ x: 1, y: 1, z: 1 }, { tooltip: \"A box's full extents.\" }),\n emitFrom: enumOf(PARTICLE_EMIT_FROM, \"volume\", { tooltip: \"volume, shell, or a cone's base.\" }),\n randomDirection: f32(0, { min: 0, max: 1, tooltip: \"How much of the start direction is random.\" }),\n spherizeDirection: f32(0, {\n min: 0,\n max: 1,\n tooltip: \"How much the start direction points away from the centre.\",\n }),\n vertices: array(f32(), [], { tooltip: \"A mesh shape's triangles, nine numbers per triangle.\" }),\n },\n { tooltip: \"Where particles start and which way they go.\" },\n ),\n start: record(\n {\n lifetime: scalarValue(2, \"Seconds a particle lives.\"),\n speed: scalarValue(2, \"Metres per second along the start direction.\"),\n size: scalarValue(0.2, \"The particle's size, in metres.\"),\n size3D: vec3({ x: 1, y: 1, z: 1 }, { tooltip: \"Optional per-axis size multipliers.\" }),\n rotation: scalarValue(0, \"The start rotation, in degrees.\"),\n color: colorValue([1, 1, 1, 1], \"The start colour, sRGB; a range picks between two per particle.\"),\n },\n { tooltip: \"What a particle is born with.\" },\n ),\n forces: record(\n {\n gravity: vec3({ x: 0, y: 0, z: 0 }, { tooltip: \"An explicit world gravity; omit to scale the app's.\" }),\n gravityMultiplier: f32(0, { tooltip: \"How much of the app's gravity applies.\" }),\n drag: f32(0, { min: 0, tooltip: \"Linear drag; 0 is none.\" }),\n constantForce: vec3({ x: 0, y: 0, z: 0 }, { tooltip: \"A constant acceleration in simulation space, m/s^2.\" }),\n orbit: record(\n {\n axis: vec3({ x: 0, y: 1, z: 0 }, { tooltip: \"The orbit axis.\" }),\n speed: f32(90, { tooltip: \"Degrees per second.\" }),\n },\n { tooltip: \"A rotation about an axis through the emitter.\" },\n ),\n noise: record(\n {\n strength: f32(0.5, { min: 0, tooltip: \"The largest offset, in metres.\" }),\n frequency: f32(1, { min: 0, tooltip: \"How quickly the field varies with position.\" }),\n scroll: vec3({ x: 0, y: 0, z: 0 }, { tooltip: \"How the field drifts with time.\" }),\n octaves: u32(1, { min: 1, max: 2, tooltip: \"How many octaves are summed.\" }),\n influenceOverLife: scalarValue(1, \"A multiplier on strength over the particle's life.\"),\n },\n { tooltip: \"A positional noise offset.\" },\n ),\n },\n { tooltip: \"What acts on a particle.\" },\n ),\n overLifetime: record(\n {\n color: colorValue([1, 1, 1, 1], \"A gradient multiplied onto the start colour over life.\"),\n size: scalarValue(1, \"A multiplier on the start size over life (X when sizeY or sizeZ is set).\"),\n sizeY: scalarValue(1, \"A separate Y multiplier over life.\"),\n sizeZ: scalarValue(1, \"A separate Z multiplier over life.\"),\n rotation: scalarValue(0, \"Angular speed in degrees per second.\"),\n },\n { tooltip: \"How a particle changes over its life.\" },\n ),\n renderer: record(\n {\n mode: enumOf(PARTICLE_RENDER_MODES, \"billboard\", { tooltip: \"How particles are oriented.\" }),\n mesh: enumOf(PARTICLE_MESHES, \"box\", { tooltip: \"The primitive a mesh renderer draws.\" }),\n texture: str(\"\", { tooltip: \"The texture's asset address, or omitted for a procedural soft disc.\" }),\n sheet: record(\n {\n tiles: vec2({ x: 1, y: 1 }, { tooltip: \"Columns and rows of the sprite sheet.\" }),\n frameOverTime: scalarValue(0, 'A curve over life, the string \"random\", or { fps }.'),\n },\n { tooltip: \"The sprite-sheet layout of the texture.\" },\n ),\n blend: enumOf(PARTICLE_BLEND_MODES, \"premultiplied\", { tooltip: \"How particles composite.\" }),\n lit: bool(false, { tooltip: \"Shade with the main light and the ambient colour.\" }),\n pivot: vec2({ x: 0, y: 0 }, { tooltip: \"Where the origin sits inside the quad, in size units.\" }),\n speedScale: f32(0, { min: 0, tooltip: \"How much of the speed a stretched particle adds to its length.\" }),\n lengthScale: f32(1, { min: 0, tooltip: \"A multiplier on a stretched particle's length.\" }),\n },\n { tooltip: \"How a particle is drawn.\" },\n ),\n };\n}\n","import { describeSchema } from \"@ignifx/core\";\nimport { PARTICLES_FORMAT } from \"./definition/types.js\";\nimport { particlesFileSchema } from \"./file-schemas.js\";\nimport { ParticleSystem } from \"./gpu/particle-system.js\";\nimport { particlesSettingsSchema } from \"./settings.js\";\nimport type { SchemaDescription } from \"@ignifx/core\";\n\n// What `pnpm docs:schemas` reads (`docs/architecture/16-docs-harness-and-skill.md` §3). These are\n// functions rather than a `schemas` object because building the record calls `describeSchema`, and\n// module scope holds declarations only (`CONSTITUTION.md` §3.5).\n\n/**\n * Describes the `ignifx.particles` file format.\n *\n * @returns The record `pnpm docs:schemas` renders.\n *\n * @public\n */\nexport function describeParticlesFormat(): SchemaDescription {\n return describeSchema(\"ignifx/particles-file\", particlesFileSchema(), {\n title: \"Particles\",\n format: PARTICLES_FORMAT,\n description:\n \"A stateless GPU particle effect: capacity and timing, emission rates and bursts, an emitter shape, start values, forces, over-lifetime curves, and the renderer.\",\n });\n}\n\n/**\n * Describes every component and settings section this package registers.\n *\n * @returns The record `pnpm docs:schemas` renders, keyed by schema id.\n *\n * @public\n */\nexport function describeSchemas(): Readonly<Record<string, SchemaDescription>> {\n return Object.freeze({\n \"ignifx/ParticleSystem\": describeSchema(\"ignifx/ParticleSystem\", ParticleSystem.schema, {\n title: ParticleSystem.title,\n }),\n \"ignifx/particles-settings\": describeSchema(\"ignifx/particles-settings\", particlesSettingsSchema(), {\n title: \"Particles settings\",\n description: \"The particles project settings section.\",\n }),\n \"ignifx/particles-file\": describeParticlesFormat(),\n });\n}\n"],"mappings":";;;;;;;;;;;AA0BA,SAAgB,2BAA2B,KAAuB,SAAiC;CACjG,IAAI,kBAAkB,mBAA4B,OAAO;AAC3D;;;;;;;;AClBA,MAAa,mBAAmB;;;;;;AAOhC,MAAa,2BAA2B;;;;;;AAOxC,MAAa,sBAAsB;;;;;;AAOnC,MAAa,2BAA8C,OAAO,OAAO,CAAC,iBAAiB,CAAC;;;;;;;AAQ5F,MAAa,iBAAiB;;;;;;;;AA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