initLJBindGroups(system, device, positionBuffer, velocityBuffer, gridBuffers, elementTable, thermalBuffer)

executeLennardJones(system, device, particleCount, dt)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleLennardJones.js Lennard Jones Intermolecular Potential (GAP 34) GPU compute shader implementing the Lennard Jones 12 6 potential: V(r) = 4ε[(σ/r)¹² (σ/r)⁶] F(r) = 24ε/r [2(σ/r)¹² (σ/r)⁶] This single equation creates realistic solid/liquid/gas behavior: r < σ: strong repulsion (Pauli exclusion) r = σ·2^(1/6): equilibrium (minimum energy) r σ·2^(1/6): weak attraction (van der Waals) r 2.5σ: effectively zero (cutoff) Per element ε and σ from element table (GAP 33). Cross element interactions use Lorentz Berthelot mixing rules. Uses neighbor grid (GAP 25) for O(N) spatial queries. Usage: const lj = createLennardJonesSystem(device, maxParticles); initLJBindGroups(lj, device, positionBuffer, velocityBuffer, gridBuffers, elementTable); executeLennardJones(lj, device, particleCount, dt); Functions Create the Lennard Jones system. Initialize bind groups. Requires neighbor grid + element table buffers. Execute the Lennard Jones compute pass. Destroy the system. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs


step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


createCurveLUTTexture(device, config = {})

updateCurveLUTTexture(device, texture, config = {})

createLifetimeCurvesSystem(device, config = {})

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleLifetimeCurves.js GPU N point Bezier curves for particle properties over lifetime Extends the color gradient LUT pattern to size, alpha, and velocity. Generates a 1D RGBA16float texture (256 texels): R = size multiplier G = alpha multiplier B = velocity multiplier A = reserved (1.0) Sampled in vertex shader (size), fragment shader (alpha), and optionally sim shader (velocity). Supports N point curves with Catmull Rom interpolation for smooth results. Functions Convert a legacy 3 point array [start, mid, end] to a curve. Generate the RGBA LUT data (Float16 or Float32 depending on use). Parameters: (Object) — No description in source JSDoc. (Array) — N point size curve (default: constant) (Array) — N point alpha curve (default: fadeInOut) (Array) — N point velocity curve (default: constant) Returns: 256 × 4 floats (RGBA) Create a GPU 1D LUT texture for lifetime curves. Parameters: (GPUDevice) — No description in source JSDoc. (Object) — { sizeCurve, alphaCurve, velocityCurve } Returns: { texture, textureView, sampler } Update an existing LUT texture with new curve data. Create a lifetime curves system for a particle world. Parameters: (GPUDevice) — No description in source JSDoc. (Object) — No description in source JSDoc. Returns: System handle Update curves at runtime. Destroy the system. Constants <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and


The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


createParticleLightSystem(device, options = {})

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleLightEmission.js Particles as dynamic point lights Niagara/PopcornFX parity: emissive particles contribute point lights to the scene. Pipeline: 1. GPU compute shader finds the top N brightest/hottest particles 2. Results are read back to CPU as an array of point light descriptors 3. Any lighting system can consume these as dynamic lights This avoids tight coupling to a specific lighting implementation. The consumer (LightingPass, voxel lighting, etc.) reads the light array each frame. Functions Create particle light emission system Parameters: (GPUDevice) — No description in source JSDoc. (Object) — No description in source JSDoc. (number) — Max particle lights per frame (default 32) (number) — Min temp to emit light (default 800K) (number) — Light intensity multiplier (default 1.0) Initialize bind group (call once when particle buffers are ready) Execute the light extraction compute pass Parameters: (GPUCommandEncoder) — No description in source JSDoc. (Object) — No description in source JSDoc. (number) — Active particle count Read back extracted lights from GPU (async, call after command buffer submit) Returns array of { position: [x,y,z], radius, color: [r,g,b], intensity } Get the current particle lights (non async, returns last readback result) Destroy particle light system <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced:


accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


initLocalSpaceBindGroups(system, device, positionBuffer, velocityBuffer)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleLocalSpace.js Local/World Space Toggle (GAP 30) Per emitter transform for local space simulation. When enabled, particles are simulated in the emitter's local coordinate frame and transformed to world space only for rendering. Moving the emitter moves all its particles. When disabled (default), particles are emitted in world space and the emitter can move without affecting existing particles. GPU compute shader transforms between local and world space using the emitter's model matrix each frame. Matches PopcornFX CParticleEvolver Localspace. Usage: const ls = createLocalSpaceSystem(device, maxParticles); initLocalSpaceBindGroups(ls, device, positionBuffer, velocityBuffer); setEmitterTransform(ls, modelMatrix); // Before sim step: transform world→local executeWorldToLocal(ls, device, particleCount); // ... run simulation in local space ... // After sim step: transform local→world executeLocalToWorld(ls, device, particleCount); Functions Create local space transform system. Initialize bind groups. Set the emitter transform (4x4 column major matrix). Automatically computes the inverse. Parameters: (Object) — No description in source JSDoc. (Float32Array number[]) — 16 element column major 4x4 matrix Set emitter transform from position + rotation (Euler angles in radians). Transform particles from world space to local space (run before sim step). Transform particles from local space to world space (run after sim step). Destroy the system. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine


rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


fmmSelectDepth(particleCount, options = {})

directLongRangeAccelerations(positions, sources, options = {})

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: Pure configuration, layout, and validation math shared by long range particle solvers. Functions Samples the positive, even, order zero PSWF. Inverse iteration solves the spheroidal Sturm Liouville operator in an orthonormal even Legendre basis; the GPU linearly interpolates the resulting half window. Builds the normalized radial density and complementary local kernel used by the PSWF Ewald split. The density integrates to one on [0, 1], while the complement falls from one to zero at the real space cutoff. Cosine transform of the normalized even PSWF splitting kernel. Constants — Pure configuration, layout, and validation math shared by long range particle solvers. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


createParticleMeshEwaldSystem(device, maxParticles, options = {})

initParticleMeshEwaldBindGroups(system, device, positionBuffer, velocityBuffer, metaBuffer, thermalBuffer,)

setParticleMeshEwaldParams(system, config = {})

executeParticleMeshEwald(system, device, particleCount, dt, options = {})

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: Periodic particle mesh Ewald solver with cubic B spline PME and an experimental numerically sampled prolate spheroidal (ESP) split and window. The solver uses exact integer cell counting/scatter, a separable 3D complex FFT, reciprocal space screened Poisson solve, interpolated mesh gradients, and the complementary short range Ewald force. Functions <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


initNBodyBindGroups(system, device, positionBuffer, velocityBuffer, metaBuffer, thermalBuffer)

executeNBody(system, device, particleCount, dt, options = {})

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleNBody.js N Body Gravitational Dynamics (GAP 37) GPU compute: every particle attracts every other via gravity. F = G · m₁·m₂ / (r² + ε²)^(3/2) Direct summation O(N²) — suitable for up to 100K particles on modern GPUs. Softening parameter ε prevents singularities at close range. Configurable G for different scales (molecular, macro, celestial). Uses tiled shared memory approach: each workgroup loads a tile of particles into shared memory, computes interactions, then loads next tile. Usage: const nb = createNBodySystem(device, maxParticles); initNBodyBindGroups(nb, device, positionBuffer, velocityBuffer, metaBuffer); executeNBody(nb, device, particleCount, dt); Functions Create the N body gravity system. Initialize bind groups. Set N body parameters at runtime. Execute the N body compute pass. Destroy. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


createNeighborGridSystem(device, config = {})

initNeighborGridBindGroups(system, device, positionBuffer, velocityBuffer)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleNeighborGrid.js General Purpose Neighbor Grid (GAP 25) GPU spatial query structure for arbitrary particle to particle interactions. Unlike the collision specific spatial grid, this is a general purpose 3D grid that any system can query: flocking, color transfer, interaction, etc. Matches Niagara Neighbor Grid 3D and PopcornFX Spatial Layers. Architecture (hash modulo bucket approach — inspired by NVIDIA CUDA Particles): 1. Clear cell counts via encoder.clearBuffer (GPU memset, no dispatch limit) 2. Insert particles into hash buckets (compute pass, atomic append) 3. Query neighbors from any other compute pass via grid lookup Instead of allocating one bucket per 3D cell (can exceed millions), we use numBuckets = min(totalCells, maxParticles). The flat cell index is modulo'd into this smaller range. Hash collisions are harmless — consumer shaders already do distance checks that filter false positives. Grid stores up to maxNeighborsPerCell particle indices per bucket. Query returns indices of particles in same + adjacent cells (27 cell neighborhood). Functions Create a general purpose neighbor grid. Parameters: (GPUDevice) — No description in source JSDoc. (Object) — No description in source JSDoc. (number[]) — Grid world origin [x, y, z] (default [ 50, 50, 50]) (number[]) — Grid world extent [x, y, z] (default [50, 50, 50]) (number) — Cell size in world units (default 2.0) (number) — Max particles per cell (default 16) (number) — Max particle count for insert Initialize bind groups (call after particle buffers are created). Update the particle count in params (call each frame if count changes). Execute clear + insert passes. Call once per frame before any queries.


are created). Update the particle count in params (call each frame if count changes). Execute clear + insert passes. Call once per frame before any queries. Parameters: (Object) — No description in source JSDoc. (GPUDevice) — No description in source JSDoc. (number) — No description in source JSDoc. Get the grid buffers for use in consumer compute shaders. Consumer shaders should bind cellCountsBuffer and cellEntriesBuffer as read only storage. Returns: } Destroy the system. Constants <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


async createNoiseTextureSystem(device, resolution = 64, period = DEFAULTNOISEPERIOD)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleNoiseTexture.js Pre baked 3D curl noise volume texture Replaces expensive per particle gradientNoise calls with one filtered sample from a two pass vector potential discrete curl 3D texture bake. 6 24× cheaper turbulence depending on octave count. The noise is tileable: baked with periodic boundary conditions and sampled with repeat addressing mode for seamless spatial tiling. Ref: GPU Gems 3 Ch.1 "Generating Complex Procedural Terrains Using the GPU" Functions Create the 3D noise texture system. Parameters: (GPUDevice) — No description in source JSDoc. (number) — Texture resolution (64 or 128) (number) — World space tiling period Returns: Validated noise volume resources Bake the noise volume texture. Call once after creation. This is a one time GPU operation ( 1ms for 64³, 8ms for 128³). Create a 1×1×1 dummy noise texture for use when the real texture isn't ready. Returns { textureView, sampler, paramsBuffer } suitable for bind group creation. Destroy noise texture system resources. Constants <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter


cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


executeRadixSort(system, device, particleCount, cameraPos)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleRadixSort.js GPU 4 way radix sort for particle distance sorting Replaces bitonic sort (O(n log²n) dispatches) with radix sort (O(n), fixed 8 passes). For 100K particles: bitonic = 289 dispatches, radix = 24 dispatches (12× fewer). Architecture: 4 bit radix: 16 buckets per pass, 8 passes for 32 bit keys Float to sortable uint conversion for correct float ordering Per pass: histogram → prefix sum → scatter (3 dispatches) Double buffered keys+values for ping pong between passes "Order check" optimization: skip sort when data is already sorted Ref: "Fast 4 way parallel radix sorting on GPUs" (Ha et al.) kishimisu/WebGPU Radix Sort Functions Create GPU radix sort system for transparent particle rendering. Drop in replacement for the bitonic sort system. Execute GPU radix sort. Drop in replacement for executeGPUSort. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


addReaction(table, matA, matB, config = {})

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleReactionTable.js Cross Emitter Particle Reaction System GPU driven reaction table: when particles with different materialIdx collide, the collision shader scans this table for a matching (matA, matB) rule. If found: apply energy, optionally kill reactants, emit reaction event (type 5). EventSpawn reads the rule index to spawn product particles with correct properties. Exceeds Niagara/PopcornFX/Unity VFX Graph — none support particle particle reactions. Usage: const table = createReactionTable(device); addReaction(table, MATERIAL.FIRE, MATERIAL.WATER, { ... }); registerDefaultReactions(table); // Bind table.buffer to sim shader group Functions Create a reaction table with GPU uniform buffer. Parameters: (GPUDevice) — No description in source JSDoc. Returns: Reaction table instance Destroy the reaction table and release GPU resources. Add a reaction rule to the table. Parameters: (Object) — Reaction table (number) — Material ID of reactant A (number) — Material ID of reactant B (Object) — Reaction configuration: Returns: Rule index, or 1 if table is full Remove a reaction rule by index. Remove all reaction rules. Upload the reaction table to the GPU uniform buffer. Call once after adding/removing reactions (not every frame). Register built in reaction presets. Parameters: (Object) — Reaction table Get the current reaction rules. Get a material name from its ID. Look up the material ID for a substance preset key. Parameters: (string) — e.g. 'fire', 'water', 'lava' Returns: Material ID (0 if not found) Constants <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes


NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


createRibbonTrailSystem(device, maxParticles, historyLength = 8, targetFormat = 'bgra8unorm', options = {})

initRibbonTrailBindGroups(system, device, positionsBuffer, velocitiesBuffer)

renderRibbonTrails(pass, system, viewProjMatrix, cameraPos, instanceCount)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleRibbonTrail.js GPU ribbon/trail rendering for particles Connects particle position history into continuous camera facing triangle strips for smoke trails, magic effects, and motion streaks. Architecture: 1. Trail Update (compute): shifts history ring buffer back, inserts current position 2. Ribbon Render (vertex+fragment): reads trail history, generates camera facing triangle strip with width tapering and alpha fade Each particle trail is rendered as one triangle strip instance. Vertex count per instance = historyLength × 2. No intermediate vertex buffer needed — the vertex shader reads history directly. Ref: GPU Gems 3 Ch.23, UE5 Niagara ribbon renderer Functions Create ribbon trail system. Parameters: (GPUDevice) — No description in source JSDoc. (number) — No description in source JSDoc. (number) — Number of position history frames per particle (default 8) (string) — Render target format (e.g. 'bgra8unorm', 'rgba16float') (object) — { depthFormat, blendMode } Initialize bind groups for the trail system. Call after the position buffer is available. Update trail history for all particles (compute pass). Call once per frame AFTER the main sim step. Render ribbon trails into the current render pass. Parameters: (GPURenderPassEncoder) — Active render pass (Object) — Ribbon trail system (Float32Array) — 4×4 view projection matrix (16 floats) (Array Float32Array) — Camera position [x, y, z] (number) — Number of particles to render trails for Destroy ribbon trail system resources. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass


Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


initSDFAttractionBindGroup(system, device, positionBuffer, velocityBuffer)

executeSDFAttraction(system, device, particleCount, dt = 1/60, time = 0)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleSDFAttraction.js SDF Attraction/Repulsion Force (GAP 15) Attract or repel particles toward/from SDF surfaces. Unlike SDF collision (hard boundary), this applies a smooth force field based on signed distance, so particles orbit, hover near, or flee from surfaces. Force = gradient(SDF) × strength / ( SDF + softness) Modes: attract: particles pulled toward surface (strength 0) repel: particles pushed away from surface (strength < 0) orbit: attract + tangential velocity (strength 0, orbitalFactor 0) surface lock: very strong attraction with damping (particles stick to surface) Uses a GPU compute shader that evaluates SDF primitives and applies forces. Functions Create an SDF attraction system. Parameters: (GPUDevice) — No description in source JSDoc. Add an SDF attractor. Parameters: (Object) — No description in source JSDoc. (Object) — No description in source JSDoc. (string) — 'sphere', 'box', 'torus', 'cylinder' (number[]) — [x, y, z] (number) — No description in source JSDoc. (number) — positive = attract, negative = repel (number) — prevents singularity (default 0.1) (number) — tangential force (default 0) (number) — velocity damping near surface (default 0) (number[]) — for box/torus/cylinder Returns: Attractor index, or 1 if full Update an existing attractor. Initialize bind group (call after particle buffers are created). Execute SDF attraction compute pass. Clear all attractors. Destroy the system. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase


collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


initSPHBindGroups(system, device, positionBuffer, velocityBuffer, gridBuffers, thermalBuffer)

executeSPH(system, device, particleCount, dt)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleSPH.js Smoothed Particle Hydrodynamics (GAP 36) True Lagrangian particle based fluid simulation where particles ARE the fluid. Complements Eulerian grid solver (GAP 32) for free surface liquids. Two pass GPU compute: Pass 1 (density): estimate density at each particle via Poly6 kernel Pass 2 (forces): pressure (Spiky), viscosity, surface tension, XSPH correction Navier Stokes in SPH form: ρᵢ = Σⱼ mⱼ W(rᵢ rⱼ, h) (density) aᵢ = Σⱼ mⱼ(Pᵢ/ρᵢ² + Pⱼ/ρⱼ²)∇W (pressure) aᵢ += μ Σⱼ mⱼ(vⱼ vᵢ)/ρⱼ ∇²W (viscosity) Per element rest density and viscosity from element table (GAP 33). Uses neighbor grid (GAP 25) for O(N) spatial queries. Usage: const sph = createSPHSystem(device, maxParticles); initSPHBindGroups(sph, device, posBuffer, velBuffer, gridBuffers); executeSPH(sph, device, particleCount, dt); Functions Create the SPH fluid system. Initialize bind groups. Requires neighbor grid buffers. Set SPH parameters at runtime. Execute the two pass SPH compute. Get the density/pressure buffer for use by surface renderers. Destroy. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use


kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


packParticleMeta(size, renderMode, shape, behavior = 0, mass = 1.0, drag = 0.02)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Pack meta.w value from individual components (full format with physics) Format: mass 1e8 + drag 1e6 + size 1e4 + renderMode 1e3 + shape 10 + behavior Parameters: (number) — Particle size (0 99) (number) — Render mode ID (0 9) (number) — Shape ID (0 9) (number) — Behavior ID (0 9) (number) — Particle mass (0.0 9.9, encoded as 0 99) (number) — Air resistance (0.0 0.99, encoded as 0 99) Unpack meta.w value to individual components Get behavior ID from behavior name Validate a value against a schema field Validate an emitter config against schema Create a default emitter config Create a default particle params uniform buffer data Create an empty particle snapshot Create an emitter snapshot from live emitter state Get shape ID from shape name Get render mode ID from mode name Get shape name from ID Get render mode name from ID Serialize emitter config to JSON safe object Deserialize emitter config from JSON Serialize particle snapshot to JSON safe object Deserialize particle snapshot from JSON Constants — Per particle data layout in GPU buffers. Each particle uses 3 vec4s (48 bytes total). — Frame uniforms passed to all particle shaders — Per draw particle parameters — Force parameters uniform (group 2 binding 0 in main particle compute shader) Controls global wind, turbulence, force points, vortex, and velocity clamping. — Shape types for particle rendering — Render modes for particle blending — Behavior types for particle movement patterns — Complete emitter configuration schema — Element layer for emitter mixing — Single particle snapshot entry — Emitter state snapshot —


movement patterns — Complete emitter configuration schema — Element layer for emitter mixing — Single particle snapshot entry — Emitter state snapshot — Complete particle system snapshot <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


createSharedMemCollidePipeline(device, bindGroupLayout, tileSize = 256)

dispatchSharedMemCollide(pipeline, bindGroup, pass, gridDims)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleSharedMemCollision.js Workgroup shared memory particle collision Drop in replacement for the grid collision pass that uses workgroup shared memory to eliminate random global memory reads. Architecture: Uses the same grid infrastructure (clearGrid + binParticles are unchanged) Dispatches one workgroup PER grid cell (cell centric) All threads in a workgroup share the same cell → same neighbor cells Neighbor particles loaded into shared memory in tiles of TILE SIZE Each thread checks its particle against shared memory (fast L1/register access) Memory access improvement: Old: Each thread reads random global positions/velocities for neighbors New: Workgroup cooperatively loads sequential global reads → shared memory Then all threads read from shared memory (100× faster than global) Uses the SAME bind group layout as the existing grid collision system, so the existing bind group can be reused directly. Ref: GPU Gems 3 Ch.31 "Fast N Body Simulation with CUDA" Functions Create the shared memory collide pipeline. This pipeline uses the SAME bind group layout as the existing grid collision system. Parameters: (GPUDevice) — No description in source JSDoc. (GPUBindGroupLayout) — From the existing grid collision system (number) — Workgroup/tile size (default 256) Execute the shared memory collide pass. Dispatches one workgroup per grid cell. Uses the existing grid bind group. Parameters: (GPUComputePipeline) — From createSharedMemCollidePipeline (GPUBindGroup) — Existing grid collision bind group (GPUComputePassEncoder) — Active compute pass (number) — Grid dimensions (e.g. 32) <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics,


compute pass (number) — Grid dimensions (e.g. 32) <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


async createParticleSimWorld(gpuDevice, options = {})

initAdvancedParticleBuffers(world, options = {})

async initAllAdvancedSystems(world, options = {})

stepAdvancedSystems(world, dt, options = {})

renderWorldRibbonTrails(pass, world, viewProjMatrix, cameraPos, instanceCount)

addParticleWire(world, particleA, particleB, restLength, stiffness = 0.5)

createGPURope(world, startPos, endPos, segments, opts = {})

updateRopeAttachment(world, entityId, which, worldPos)

addParticleCollider(world, type, center, radius, halfExtents)

seedParticles(world, count, options = {})

async readbackPositionsFromGPU(world, targetPositions, particleCount)

async readbackVelocitiesFromGPU(world, targetVelocities, particleCount)

async readbackThermalFromGPU(world, targetThermal, particleCount)

attachFluidWorld(particleWorld, fluidWorld, worldMin, worldMax)

stepParticleSimWorld(world, deltaSeconds, options = {})

updateMouseInteraction(ndcX, ndcY, active = true)

updateForcePoint(index, x, y, z, strength)

startDissolve(groupId, duration = 1.0, direction = 'out')

sampleCurlNoise(x, y, z, scale = 1, time = 0)

initTrailSystem(world, historyLength = 8)

configureParticleLongRange(world, config = {})

warmUpParticleWorld(world, warmUpSeconds = 2.0, options = {})

reserveParticles(particleWorld, count, backend = 'free')

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Initialize spatial grid and line buffers for advanced particle features. Call this after createParticleSimWorld to enable line connections and neighbor lookups. Initialize all advanced particle systems (sorting, wire constraints, SDF collision, etc.) Call after createParticleSimWorld and initAdvancedParticleBuffers. Create heat conduction + phase transition compute system. Requires spatial grid to be initialized (gridCountsBuffer, gridIndicesBuffer). Execute heat conduction compute pass. Execute all active advanced particle systems in the simulation step. Render ribbon trails into the given render pass. Call during the render loop AFTER particle rendering. Parameters: (GPURenderPassEncoder) — No description in source JSDoc. (Object) — No description in source JSDoc. (Float32Array) — 4×4 view projection matrix (Array Float32Array) — [x, y, z] (number) — particle count to render trails for Execute GPU sorting for transparent particle rendering. Call before rendering particles back to front. Respects world.sortFrameInterval to skip sorting on intermediate frames (e.g. interval=2 sorts every other frame, reducing GPU cost for large counts). Add a wire constraint between two particles. Create a GPU simulated rope with particles and constraints Parameters: (Object) — Particle world (Array<number ) — [x, y, z] start position (Array<number ) — [x, y, z] end position (number) — Number of rope segments (Object) — Options { stiffness, fixStart, fixEnd, entityId, color, radius } Returns: { particleStart, particleCount, constraintStart, constraintCount } Upload particle velocities to


async createParticleSimWorld(gpuDevice, options = {})

initAdvancedParticleBuffers(world, options = {})

async initAllAdvancedSystems(world, options = {})

stepAdvancedSystems(world, dt, options = {})

renderWorldRibbonTrails(pass, world, viewProjMatrix, cameraPos, instanceCount)

addParticleWire(world, particleA, particleB, restLength, stiffness = 0.5)

createGPURope(world, startPos, endPos, segments, opts = {})

updateRopeAttachment(world, entityId, which, worldPos)

addParticleCollider(world, type, center, radius, halfExtents)

seedParticles(world, count, options = {})

async readbackPositionsFromGPU(world, targetPositions, particleCount)

async readbackVelocitiesFromGPU(world, targetVelocities, particleCount)

async readbackThermalFromGPU(world, targetThermal, particleCount)

attachFluidWorld(particleWorld, fluidWorld, worldMin, worldMax)

stepParticleSimWorld(world, deltaSeconds, options = {})

updateMouseInteraction(ndcX, ndcY, active = true)

updateForcePoint(index, x, y, z, strength)

startDissolve(groupId, duration = 1.0, direction = 'out')

sampleCurlNoise(x, y, z, scale = 1, time = 0)

initTrailSystem(world, historyLength = 8)

configureParticleLongRange(world, config = {})

warmUpParticleWorld(world, warmUpSeconds = 2.0, options = {})

reserveParticles(particleWorld, count, backend = 'free')

fixStart, fixEnd, entityId, color, radius } Returns: { particleStart, particleCount, constraintStart, constraintCount } Upload particle velocities to GPU buffer Parameters: (Object) — Particle world (number) — Start index (Array<Array<number ) — Array of [vx, vy, vz] Update attachment constraint target position Parameters: (Object) — Particle world (number) — Rope entity ID (string) — 'start' or 'end' (Array<number ) — New [x, y, z] position Destroy a GPU rope and release its resources Parameters: (Object) — Particle world (number) — Entity ID of the rope Add an SDF collider to the particle system. Clear all SDF colliders (call before per frame rebuild). Batch rebuild SDF colliders from an array of descriptors. Call each frame with entity SDF shapes for proper mesh collision. Parameters: (Object) — Particle world Seed particles on GPU with random positions/velocities. Set texture atlas sprite assignment mode. Initialize snapshot system for time rewind. Parameters: (Object) — Particle world (Object) — { historySeconds, snapshotRate } Auto capture snapshots during simulation (call each frame). Manually take a snapshot. Start time rewind mode. Stop time rewind and resume simulation. Step rewind playback (call each frame while rewinding). Seek to a specific time in history. Restore a specific frame from history. Set rewind playback speed ( 1 = reverse, 1 = forward, 0.5 = slow, etc.) Get snapshot/rewind status info. Check if currently in rewind mode. Clear all snapshot history. Update adaptive quality based on frame time. Automatically adjusts activeParticleCount to maintain target FPS. TECHNIQUES FROM AAA GAME INDUSTRY (DRS Best Practices): 1. Frame rate independent exponential smoothing 2. Spike filtering only reduce after sustained poor performance 3. Panic mode


async createParticleSimWorld(gpuDevice, options = {})

initAdvancedParticleBuffers(world, options = {})

async initAllAdvancedSystems(world, options = {})

stepAdvancedSystems(world, dt, options = {})

renderWorldRibbonTrails(pass, world, viewProjMatrix, cameraPos, instanceCount)

addParticleWire(world, particleA, particleB, restLength, stiffness = 0.5)

createGPURope(world, startPos, endPos, segments, opts = {})

updateRopeAttachment(world, entityId, which, worldPos)

addParticleCollider(world, type, center, radius, halfExtents)

seedParticles(world, count, options = {})

async readbackPositionsFromGPU(world, targetPositions, particleCount)

async readbackVelocitiesFromGPU(world, targetVelocities, particleCount)

async readbackThermalFromGPU(world, targetThermal, particleCount)

attachFluidWorld(particleWorld, fluidWorld, worldMin, worldMax)

stepParticleSimWorld(world, deltaSeconds, options = {})

updateMouseInteraction(ndcX, ndcY, active = true)

updateForcePoint(index, x, y, z, strength)

startDissolve(groupId, duration = 1.0, direction = 'out')

sampleCurlNoise(x, y, z, scale = 1, time = 0)

initTrailSystem(world, historyLength = 8)

configureParticleLongRange(world, config = {})

warmUpParticleWorld(world, warmUpSeconds = 2.0, options = {})

reserveParticles(particleWorld, count, backend = 'free')

INDUSTRY (DRS Best Practices): 1. Frame rate independent exponential smoothing 2. Spike filtering only reduce after sustained poor performance 3. Panic mode aggressive drop when critically over budget 4. Fast recovery don't be over cautious when headroom exists 5. Proportional response bigger adjustments when further from target 6. Target slightly under budget for safety margin Get particle system stats for performance overlay. Attach a fluid world to the particle simulation. Particles will sample and follow the fluid velocity field. Create line rendering pipeline for particle connections Create line compute pipelines for spatial grid and line generation Create line uniform buffer for compute and render In


createSnapshotSystem(device, maxParticles, options = {})

initSnapshotBindGroups(snapshot, positionBuffer, velocityBuffer, metaBuffer, thermalBuffer)

restoreInterpolated(snapshot, emitters, frameA, frameB, t)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Create particle snapshot system for time rewind Initialize bind groups with particle buffers Take a snapshot of current state Auto snapshot based on interval (call every frame) Restore exact frame from history Restore with interpolation between two frames Seek to a specific time in history Start rewind mode Stop rewind and resume simulation Step rewind playback (call each frame while rewinding) Set playback speed ( 1 = reverse, 1 = forward, 0.5 = slow forward, etc.) Get current playback info Clear all history Destroy snapshot system <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


hashParticleKeyframeSemantic(frame, sampleVec4Count = 1024)

async captureFrame(snapshot, particleState, emitters, currentTimeMs)

async autoCapture(snapshot, particleState, emitters, currentTimeMs)

restoreToFrame(snapshot, particleState, emitters, frameIndex)

restoreInterpolated(snapshot, particleState, emitters, frameA, frameB, t)

seekToTime(snapshot, particleState, emitters, targetTimeMs)

stepRewind(snapshot, particleState, emitters, dtMs)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleSnapshotDelta.js Delta Compressed Particle State History Like the WorldTimeline system, uses delta compression to store only changes: Keyframes: Full state snapshots at intervals Delta frames: Only particles that moved significantly No max frame limit unlimited history with efficient storage Compression approach: Track which particles changed since last frame Store only changed particle indices + their new state Periodic keyframes for random access Functions Create delta compressed particle snapshot system Capture a snapshot (keyframe or delta based on interval) Captures EVERYTHING: positions, velocities, meta, slotInfo, liveCount, freeSlots Parameters: (Object) — Snapshot system (Object) — Full particle state { positions, velocities, meta, slotInfo, liveCount, instanceCount, freeSlots } (Array) — Emitter array (number) — Current time in milliseconds Auto capture based on interval NON BLOCKING version Uses double buffered GPU readback to avoid blocking the main thread Parameters: (Object) — Snapshot system (Object) — Full particle state object (Array) — Emitter array (number) — Current time in milliseconds Reconstruct FULL particle state at a specific frame by applying deltas from keyframe Includes positions, velocities, meta, slotInfo, liveCount, freeSlots everything needed for complete rewind Handles both quantized (Int16) and unquantized (Float32) data formats Restore FULL particle state to a specific frame Parameters: (Object) — Snapshot system (Object) — Target particle state object to restore into (Array) — Emitter array (number) — Target frame index Restore with interpolation between two frames Parameters: (Object) — Snapshot system (Object) — Target particle state


array (number) — Target frame index Restore with interpolation between two frames Parameters: (Object) — Snapshot system (Object) — Target particle state object (Array) — Emitter array (number) — First frame index (number) — Second frame index (number) — Interpolation factor (0 1) Seek to specific time Parameters: (Object) — Snapshot system (Object) — Target particle state object (Array) — Emitter array (number) — Target time in milliseconds Start rewind mode Stop rewind Step rewind playback restores FULL particle state including spawn/death Parameters: (Object) — Snapshot system (Object) — Target particle state object (Array) — Emitter array (number) — Delta time in milliseconds Set playback speed Set easing type for interpolation Parameters: (Object) — Snapshot system (string) — One of: linear, easeInQuad, easeOutQuad, easeInOutQuad, Get available easing types Get snapshot info Clear all history <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


initContainmentBindGroups(system, device, positionBuffer, velocityBuffer)

executeSoftContainment(system, device, particleCount, dt)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleSoftContainment.js Soft Containment Volumes (GAP 31) GPU compute shader that keeps particles inside shape volumes using soft bounce forces instead of hard kill zones. Particles approaching the boundary receive a proportional repulsion force pushing them back inside. Supports: sphere, box, cylinder containment volumes. Unlike kill zones (hard removal), soft containment preserves particles and creates natural looking bounded effects. Matches PopcornFX CParticleEvolver Containment. Usage: const cont = createSoftContainmentSystem(device, maxParticles); addContainmentVolume(cont, { type: 'sphere', center: [0,5,0], radius: 10 }); initContainmentBindGroups(cont, device, positionBuffer, velocityBuffer); executeSoftContainment(cont, device, particleCount, dt); Functions Create the soft containment system. Add a containment volume. Parameters: (Object) — No description in source JSDoc. (Object) — { type: 'sphere' 'box' 'cylinder', center, radius, halfExtent, halfHeight } Initialize bind groups. Execute the soft containment compute pass. Clear all volumes. Destroy the system. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable


(CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


spawnSphere(center, radius, surfaceOnly = false)

spawnHemisphere(center, radius, axis = [0, 1, 0], surfaceOnly = false)

spawnBoxCenter(center, halfExtents, surfaceOnly = false)

spawnCylinder(center, axis, radius, height, surfaceOnly = false)

spawnCone(apex, axis, angle, height, surfaceOnly = false)

spawnRing(center, axis, radius, thickness = 0)

spawnTorus(center, axis, majorRadius, minorRadius, surfaceOnly = false)

spawnDisc(center, normal, radius, innerRadius = 0)

spawnGrid(origin, axisU, axisV, countU, countV, index, jitter = 0)

spawnFromShape(shape, emitterPos, index = 0)

velocityFromNormal(normal, speed, spread = 0.2)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleSpawnShapes.js Spawn shape primitives for particle emission Niagara/PopcornFX/Houdini parity: spawn particles in structured shapes instead of just point + random spread. Each function returns { position: [x,y,z], normal: [nx,ny,nz] } Normal points outward from the shape surface — useful for initial velocity direction. ⚠ MULTIPLAYER: Uses deterministic RNG from AIRandom.js Functions Spawn inside or on a sphere Parameters: (number[]) — [x, y, z] (number) — No description in source JSDoc. (boolean) — true = on surface, false = inside volume Returns: } Spawn on a hemisphere (oriented along axis) Parameters: (number[]) — No description in source JSDoc. (number) — No description in source JSDoc. (number[]) — Hemisphere direction [x, y, z] (default up) (boolean) — No description in source JSDoc. Spawn inside or on a box (AABB) Parameters: (number[]) — [minX, minY, minZ] (number[]) — [maxX, maxY, maxZ] (boolean) — No description in source JSDoc. Spawn inside or on a box defined by center + half extents Spawn inside or on a cylinder Parameters: (number[]) — Center of cylinder (number[]) — Cylinder axis direction (will be normalized) (number) — No description in source JSDoc. (number) — Total height (extends height/2 each direction from center) (boolean) — No description in source JSDoc. Spawn inside or on a cone Parameters: (number[]) — Tip of the cone (number[]) — Cone axis direction (from apex toward base) (number) — Half angle in radians (number) — Height from apex to base (boolean) — No description in source JSDoc. Spawn on a ring (circle in 3D space) Parameters: (number[]) — No description in source JSDoc. (number[]) — Ring normal direction (number) — Ring radius (number) —


on a ring (circle in 3D space) Parameters: (number[]) — No description in source JSDoc. (number[]) — Ring normal direction (number) — Ring radius (number) — Spread around the ring (0 = thin line) Spawn inside or on a torus Parameters: (number[]) — No description in source JSDoc. (number[]) — Torus normal (number) — Distance from center to tube center (number) — Tube radius (boolean) — No description in source JSDoc. Spawn along a line segment Parameters: (number[]) — Start point (number[]) — End point (number) — Spread perpendicular to line (0 = on line) Spawn on a disc (filled circle in 3D space) Parameters: (number[]) — No description in source JSDoc. (number[]) — Disc facing direction (number) — No description in source JSDoc. (number) — Hollow inner radius (0 = solid disc) Spawn at grid positions (deterministic placement, good for walls/floors of particles) Parameters: (number[]) — Grid origin corner (number[]) — Direction + length of U axis (number[]) — Direction + length of V axis (number) — Points along U (number) — Points along V (number) — Which grid point (0 to countU countV 1) (number) — Random offset as fraction of cell size (0 = perfect grid) Spawn a particle using a shape configuration object Parameters: (Object) — Shape config from emitter: { type, ...params } (number[]) — Emitter world position (added as offset) (number) — Particle index (for grid shapes) Returns: } Generate initial velocity from spawn shape result Parameters: (number[]) — Outward normal from spawn shape (number) — Base speed (number) — Random spread angle (0 = perfectly aligned with normal, 1 = hemisphere) Returns: velocity [vx, vy, vz] <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies


vy, vz] <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (play


initSplineFollowBindGroups(system, device, positionBuffer, velocityBuffer)

executeSplineFollow(system, device, particleCount, dt)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleSplineFollow.js Spline/Path Following (GAP 28) GPU compute shader that steers particles along bezier or catmull rom spline paths. Each particle tracks its progress (t parameter) along the curve and applies a steering force toward the next point on the path. Supports: Cubic Bezier paths (4 control points per segment) Catmull Rom splines (N control points, smooth interpolation) Per particle speed along path Spread: particles can deviate from path center by a configurable radius Looping and ping pong modes Control points are uploaded as a storage buffer (max 64 points). Each particle stores its path progress in thermalData.w (repurposed when not using thermal system) or a dedicated progress buffer. Usage: const spline = createSplineFollowSystem(device, maxParticles); setSplineControlPoints(spline, device, points); initSplineFollowBindGroups(spline, device, positionBuffer, velocityBuffer); executeSplineFollow(spline, device, particleCount, dt); Functions Create the spline follow system. Upload control points (array of [x, y, z]). Initialize bind groups. Update spline follow parameters. Execute the spline follow compute pass. Destroy the system. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is


Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


initSplittingBindGroups(system, device, positionBuffer, velocityBuffer, thermalBuffer, metaBuffer, sphDensityBuffer)

executeSplitting(system, device, particleCount, dt)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleSplitting.js Adaptive Particle Refinement for Fluid When water stretches thin (low SPH density, high velocity, few neighbors), particles split into smaller child particles. When many small particles cluster in a dense area, they merge back. This is how water naturally breaks apart into spray/droplets and reforms. GPU compute shader scans liquid particles, identifies split candidates, and uses atomic counters to claim dead particle slots for children. Split trigger: density < threshold AND speed threshold Merge trigger: two particles within close range, both small, low relative velocity Mass conservation: Split: parent shrinks to 0.7× size, child spawns at 0.7× size (2 × 0.7³ ≈ 0.686 volume — slight loss acceptable for stability) Merge: surviving particle grows by merged particle's volume^(1/3) Usage: const split = createSplittingSystem(device, maxParticles); initSplittingBindGroups(split, device, posBuffer, velBuffer, thermalBuffer, metaBuffer, sphDensityBuffer); executeSplitting(split, device, particleCount, dt); Functions Create the splitting system. Initialize bind groups. Execute the splitting compute pass. Update splitting parameters at runtime. Destroy splitting system. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters,


Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


initProjectionBindGroups(system, device, positionBuffer, velocityBuffer)

executeSurfaceProjection(system, device, particleCount, dt)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: ParticleSurfaceProjection.js Surface Projection / Conform (GAP 29) GPU compute shader that projects particles onto shape surfaces. Particles are snapped or attracted to the nearest point on a surface, enabling effects like particles crawling along walls, flowing over terrain, or conforming to mesh silhouettes. Supports analytical shapes (sphere, box, plane, cylinder) on GPU. For arbitrary meshes, uses a signed distance field (SDF) with gradient descent to find the nearest surface point. Matches PopcornFX CParticleEvolver Projection. Usage: const proj = createSurfaceProjectionSystem(device, maxParticles); addProjectionSurface(proj, { type: 'sphere', center: [0,0,0], radius: 5 }); initProjectionBindGroups(proj, device, positionBuffer, velocityBuffer); executeSurfaceProjection(proj, device, particleCount, dt); Functions Create the surface projection system. Add a projection surface. Parameters: (Object) — No description in source JSDoc. (Object) — { type: 'sphere' 'box' 'plane' 'cylinder', center, radius, halfExtent, normal, axis } Initialize bind groups. Execute the surface projection compute pass. Clear all surfaces. Destroy the system. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time


Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


createTextureAtlasSystem(device, maxParticles, config = {})

async loadAtlasTexture(atlasSystem, device, imageUrl)

createProceduralAtlas(atlasSystem, device, options = {})

initAtlasBindGroup(atlasSystem, device, positionsBuffer, velocitiesBuffer)

assignSpritesGPU(atlasSystem, device, particleCount, time)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Create texture atlas configuration Create texture atlas system Load texture atlas from image Create procedural atlas texture (for testing) Initialize sprite assignment bind group Assign sprites to particles via GPU Get atlas uniforms for rendering Set sprite assignment mode Destroy texture atlas system Constants <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


createVectorFieldTexture(device, resolution, label = 'VectorField.texture')

createVectorFieldSystem(device, options = {})

generateProceduralVectorField(system, type = 'tornado')

setVectorFieldParams(system, params = {})

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions Create a filterable 3D vector field texture compatible with linear sampling. Create a vector field system. Parameters: (GPUDevice) — No description in source JSDoc. (Object) — { resolution, bounds } Load raw velocity data into the vector field. Parameters: (Object) — No description in source JSDoc. (Float32Array) — RGBA float data (res³ × 4 floats) (number[]) — [width, height, depth] Generate a procedural vector field. Parameters: (Object) — No description in source JSDoc. (string) — 'tornado', 'explosion', 'windTunnel', 'attractor' Update vector field parameters. Parameters: (Object) — No description in source JSDoc. (Object) — { center, halfExtent, strength, tiling, scroll } Parse FGA format (FluidNinja/Houdini vector field export). FGA is a simple text format: header lines then XYZ velocity per voxel. Parameters: (string) — Raw FGA file content Returns: } Destroy the vector field system. Constants <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to


A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/ParticlesStateRegistry.js
Functions
setActiveParticlesState(particlesState)
getActiveParticlesState()
clearActiveParticlesState()
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: No file level description found in source. Add one as a leading JSDoc comment, or document it below. Functions <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


createRopeNodeState(nodeCount, ambientTemp = 293)

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: RopeMaterial.js — Thermal & interaction properties for rope/chain fiber materials. Extends the visual only FIBER MATERIALS from RopeSchema with physics properties needed for particle↔rope interaction: flammability, moisture absorption, thermal conductivity, burn/break temperatures, mass modifiers. EVERY material (including steel and chain) participates in interactions — metal softens and breaks at high enough temperatures, organic materials burn, all materials conduct heat along the chain. Thresholds differ per material. Interaction types by substance: Fire/lava/plasma → heat transfer → softening → burning/melting → chain split Water/blood/honey → moisture absorption → heavier → sag → wet stiffness change Ice/snow → cooling → stiffening → freeze brittle Acid → corrosion → integrity loss → chain split Sparks/debris → minor heat transfer Functions Map particle substance to interaction type and intensity. Returns null if the substance doesn't interact with rope. Create per node interaction state for a rope. Parameters: (number) — Number of particles in the rope (number) — Starting temperature (K), default 293 (room temp) Returns: Per node state arrays Get the interaction material for a fiber material name. Falls back to hemp if unknown. Parameters: (string) — Material name (cotton, steel, chain, etc.) Returns: Interaction material properties Constants <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics


mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


registerRopeForInteraction(system, entityId, ropeMetadata, fiberMaterial, ambientTemp = 293)

stepRopeInteraction(system, world, positionsCPU, thermalCPU, metaCPU, dt, callbacks = {})

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: RopeParticleInteraction.js — CPU side per tick bridge between free particles and ropes. Runs each simulation frame and performs: 1. Spatial proximity query: find free particles near each rope node 2. Heat transfer: fire/lava/plasma → rope heats up; ice/snow → rope cools 3. Moisture absorption: water/blood/honey near rope → rope gets heavier, sags 4. Corrosion: acid particles eat away rope integrity 5. Thermal conduction: heat spreads along the rope between adjacent nodes 6. Burning: when node temperature exceeds burn threshold → ignite, char, break 7. Chain splitting: when integrity reaches 0 → break constraint → 2 separate chains Works with ALL materials including steel/chain — metal softens and eventually breaks at high enough temperatures (lava, plasma). Thresholds differ per material. This is a CPU side system because it needs to: Make topology decisions (break constraints, split chains) Spawn new emitters (fire/smoke on burning rope) Modify per constraint mass values (moisture → heavier) Functions Create the rope↔particle interaction system. Attach to the particle world and call stepRopeInteraction() each tick. Returns: Interaction system state Register a rope for interaction tracking. Call this after createGPURope. Parameters: (Object) — Interaction system (number) — Rope entity ID (Object) — From createGPURope (particleStart, particleCount, etc.) (string) — Material name (hemp, steel, chain, silk, etc.) (number) — =293] Starting temperature Unregister a rope (cleanup). Parameters: (Object) — No description in source JSDoc. (number) — No description in source JSDoc. Step the rope↔particle interaction system. Parameters: (Object) — Interaction system from


in source JSDoc. (number) — No description in source JSDoc. Step the rope↔particle interaction system. Parameters: (Object) — Interaction system from createRopeInteractionSystem() (Object) — Particle sim world (has ropeChains, position readback, etc.) (Float32Array) — CPU side particle positions (vec4 per particle) (Float32Array) — CPU side thermal data (vec4 per particle: temp, phase, packedGroupMat, latent) (Float32Array null) — CPU side meta buffer (vec4 per particle: r,g,b,packed) (number) — Time step in seconds (Object) — Optional callbacks for spawning effects (Function) — (entityId, nodeIndex, position) (Function) — (entityId, nodeIndex, position) (Function) — (entityId, nodeIndex, childA, childB) (Function) — (entityId, nodeIndex, newMass) Get the current interaction state for a rope. Parameters: (Object) — No description in source JSDoc. (number) — No description in source JSDoc. Returns: { temperature[], moisture[], integrity[], burning[], isBurning, burningNodes } Get average temperature of a rope. Parameters: (Object) — No description in source JSDoc. (number) — No description in source JSDoc. Returns: Average temperature in K, or 293 if not found Get average moisture saturation of a rope. Parameters: (Object) — No description in source JSDoc. (number) — No description in source JSDoc. Returns: Average moisture 0 1 Destroy the interaction system and release all state. Parameters: (Object) — No description in source JSDoc. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies


mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


createRopePhysicsSystem(device, options = {})

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: RopePhysics.js Advanced Rope Physics System GPU accelerated rope physics with: Tension/slack simulation Attachment constraints (fixed points, entity attachments) Rope cutting and rejoining Stretching/compression limits Wind/external force response Classes Method Signature Summary Register a rope for physics simulation Add attachment constraint to a rope Update attachment target position Cut a rope at specified particle index Create bind group for a rope Step rope physics simulation Get rope tension data (requires GPU readback) Functions <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/SnapshotWorker.js
Exports
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: SnapshotWorker.js Offload heavy snapshot compression to a separate thread This worker handles: Delta calculation between frames Quantization of position/velocity data Compression of frame data Memory management for snapshot history The main thread only does GPU readback (can't be done in workers) and sends the raw data here for processing. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


composeSpellEffect(elements, baseConfig = {}, options = {})

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: SpellEffectComposer.js — Auto blending multi layer VFX composition ==================== ARCHITECTURE (for future AI/developers) ==================== Industry VFX standard (Niagara, Unity VFX Graph, PopcornFX, Houdini POP): A spell/effect is composed of MULTIPLE visual layers, each serving a distinct role: 1. CORE — Main volumetric body (SDF particles, standard blend) 2. GLOW — Larger, softer aura around core (bright color, low alpha, additive feel) 3. ACCENT — Small bright particles: embers, snowflakes, sparkles, droplets 4. WISPS — Secondary volumetric layer: smoke tendrils, mist, steam 5. RING — Expanding shockwave/halo (burst spawn, grows outward) 6. TRAILS — Ribbon trails following particles 7. LIGHT — Dynamic point light matching effect color This system auto generates these layers from an element mix. Given elements like [fire(0.8), ice(0.6)], it produces an array of emitter configs — one per visual layer. Each config is a complete Emitter component that can be passed to editor.createEntity(). USAGE: import { composeSpellEffect } from './SpellEffectComposer.js'; const layers = composeSpellEffect(activeElements, baseEmitterConfig); // layers = [{ name, layerType, emitterConfig }, ...] // Each layer.emitterConfig is a full Emitter component for createEntity The "Create Spell From This" button in EmitterInspectorCard.js calls this, then EditorParticles.createComposedSpellEffect() creates child emitter entities. Functions Compose a multi layer spell effect from an element mix. Parameters: (Object) — Base emitter config from the parent emitter (rate, size, lifetime, etc.) (Object) — Additional options (string) — Custom name for the spell Returns: } Array of layer configs Get


from the parent emitter (rate, size, lifetime, etc.) (Object) — Additional options (string) — Custom name for the spell Returns: } Array of layer configs Get available element recipe IDs. Re exports , , <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/data/index.js
Exports
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: data/index.js — Re exports for schema, config, attributes, and compression. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/effects/index.js
Exports
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: effects/index.js — Re exports for visual effects, trails, and lines. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/emitters/index.js
Re-exports
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: emitters/index.js — Organized re exports for emitter creation, presets, and lifecycle. New code should import from here. Original files remain in parent directory. Re exports , , , , , , , , , , , , , , , <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/events/index.js
Exports
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: events/index.js — Re exports for event system, audio, and decals. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/mesh/index.js
Exports
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: mesh/index.js — Re exports for mesh to particle conversion and instancing. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: physics/collision/index.js — Re exports for collision systems. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/physics/compute/index.js
Exports
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: physics/compute/index.js — Re exports for compute utilities. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: physics/constraints/index.js — Re exports for constraint solvers. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/physics/fluids/index.js
Exports
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: physics/fluids/index.js — Re exports for fluid solvers. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/physics/forces/index.js
Exports
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: physics/forces/index.js — Re exports for force systems. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/physics/index.js
Exports
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: physics/index.js — Organized re exports for GPU physics compute solvers. New code should import from here. Original files remain in parent directory. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine


sim/particles/rope/index.js
Exports
Notes & Examples
Physics Engine Integration

<! AUTOGENERATED by tools/extract api.py — content above HUMAN NOTES is overwritten Source: rope/index.js — Re exports for rope/wire constraint systems. Exports No ES module exports detected in this file. <! HUMAN NOTES Notes & Examples Physics Engine Integration The physics system provides rigid body dynamics, collision detection, and raycasting. Bodies have shapes (box, sphere, mesh), mass properties, and constraints. The GPU physics engine accelerates broad phase collision detection and particle systems. Example: Creating physics bodies Advanced: Collision detection and raycasting Advanced: Constraints and joints Advanced: Continuous collision detection (CCD) Gotchas: Units : Physics uses meters, kilograms, seconds. A 1 unit cube is 1 meter. Time step : Fixed time step (1/60) gives stable simulation; variable dt causes explosions. Collision layers : Use collision masks to filter what collides (player vs enemy, bullet vs world). Sleeping : At rest bodies sleep to save CPU — wake them before applying forces. See also: Physics · GPU Physics Engine