Documentation
    Preparing search index...

    Module @fourjs/particles

    @fourjs/particles

    Particle systems — deterministic CPU simulation with force fields. Part of fourJS.

    Implements §27 and §36 of docs/SPECIFICATION.md; shipped in Phase 9 (§112). Simulation is seeded and deterministic: emitters burn a fixed PARTICLE_DRAWS_PER_SPAWN RNG draws per spawn slot, so the stream is a function of history.

    • ParticleEmitter — spawn rate, bursts (ParticleBurst), ranges/ramps (ParticleRange, ParticleLifetimeRamp), seeded via SeededRandom (re-exported from @fourjs/core).
    • ParticlePool — structure-of-arrays Float32Array storage with swap-remove; capacity is part of the deterministic contract.
    • Force fields (§27) — factories uniformGravityField, dragField, windField, radialField (inverse-square), vortexField, turbulenceField (bounded hash-noise curl; honestly not divergence-free), and volumeField over box/sphere volumes.
    • ParticleSystem — the fixed-step system (PRIORITY_PARTICLES = 500) advancing emitters and fields.
    • ParticleRenderable — bridges to @fourjs/render's instanced particle path (PARTICLE_INSTANCE_FLOATS stride-8 interleaved instances; the ParticleDrawable contract is deliberately duck-typed — the dependency matrix forbids the edge).

    100k particles + 3 fields measured at ~16.5 ms/step on CI hardware (recorded benchmark, not a 60 fps claim).

    • GPU compute simulation, particle-vs-physics collision, and trails.

    Unit tests are colocated in tests/ per §92.

    Workspace name @fourjs/particles; publishes as @danielsimonjr/fourjs-particles.

    ParticleEmitter
    ParticlePool
    ParticleRenderable
    ParticleSystem
    ParticleTrailStore
    SeededRandom
    BoxFieldVolume
    ParticleBurst
    ParticleColor
    ParticleEmitterOptions
    ParticleFixedUpdateContext
    ParticleForceField
    ParticleGpuIntegrateExtras
    ParticleGpuRadialField
    ParticleGpuSimulation
    ParticleLifetimeRamp
    ParticleLifetimeStop
    ParticleRange
    ParticleRenderableOptions
    ParticleStepTime
    ParticleSystemOptions
    ParticleTrailOptions
    RadialFieldOptions
    SphereFieldVolume
    SteppableEmitter
    TurbulenceFieldOptions
    VortexFieldOptions
    FieldVolume
    ParticleCollisionMode
    ParticleSimulationMode
    ParticleTexture
    DEFAULT_GRAVITY_Y
    DEFAULT_PARTICLE_LIFETIME_SECONDS
    DEFAULT_PARTICLE_RESTITUTION
    DEFAULT_PARTICLE_SEED
    DEFAULT_PARTICLE_SIZE
    DEFAULT_RADIAL_MIN_DISTANCE
    DEFAULT_TRAIL_LENGTH
    DEFAULT_TRAIL_MIN_DISTANCE
    DEFAULT_TRAIL_TAIL_WIDTH_FACTOR
    DEFAULT_TRAIL_WIDTH
    DEFAULT_TURBULENCE_AMPLITUDE
    DEFAULT_TURBULENCE_FREQUENCY
    DEFAULT_VORTEX_MIN_DISTANCE
    PACKAGE_NAME
    PARTICLE_DRAWS_PER_SPAWN
    PARTICLE_INSTANCE_FLOATS
    PARTICLE_ROTATION_OFFSET
    PARTICLE_SOFTNESS_OFFSET
    PARTICLE_TRAIL_VERTEX_FLOATS
    PARTICLE_WIDE_INSTANCE_FLOATS
    PRIORITY_PARTICLES
    TRAIL_VERTEX_FLOATS
    TURBULENCE_DIFFERENCE_CELLS
    buildTrailRibbonMesh
    dragField
    evaluateLifetimeRampColor
    evaluateLifetimeRampNumber
    radialField
    resolveTrailOptions
    turbulenceField
    uniformGravityField
    volumeField
    vortexField
    windField