Documentation
    Preparing search index...

    Class WgpuParticleSimulation

    The device residency of one simulation: "gpu" particle system — see the module header. Created by WebgpuRenderer.createParticleSimulation; the caller owns it and disposes it (§83, the createPickingService ownership rule), and its buffers die with the device either way (a destroyed device makes destroy() a defined no-op).

    Index
    • Internal — obtain instances through WebgpuRenderer.createParticleSimulation, which supplies the device, the shared compute cache, and the registry unhook.

      Parameters

      Returns WgpuParticleSimulation

      FourError INVALID_APPLICATION_STATE for a capacity that is not a positive safe integer; UNSUPPORTED_GPU_FEATURE when the device surface lacks the compute entry points or copyBufferToBuffer — probed here, up front, so the refusal lands at authoring time (§85).

    capacity: number

    Slots the device buffers hold.

    isParticleGpuSimulation: true

    @fourjs/particles' structural brand — a literal true.

    Flat x,y,z position lanes, capacity × 12 bytes — the buffer the §36 draw binds as the per-instance position stream (module header), and a readable §82 buffer (readComputeBuffer) for diagnostics and tests.

    systemId: string

    The emitting node's id this simulation is registered under.

    velocities: WgpuComputeBuffer

    Flat x,y,z velocity lanes, capacity × 12 bytes. Readable likewise.

    • get disposed(): boolean

      Returns boolean

    • Releases the four allocations (§83). Idempotent, safe after device loss (destroy() on an invalidated buffer is a defined no-op), and unhooks this simulation from the renderer's draw-time registry so a later frame falls back to the CPU instance stream rather than binding a destroyed buffer.

      Returns void

    • One integrator dispatch over the first count slots — params packed whole (count as f32, the WP-R1.8 precedent), then the WP-R1.8 kernel at particleIntegratorWorkgroups(count).

      Parameters

      • count: number
      • deltaSeconds: number
      • gravityX: number
      • gravityY: number
      • gravityZ: number
      • Optionalextras: {
            collisionGroundY?: number;
            collisions?: "none" | "depth-buffer";
            radial?: {
                minDistance: number;
                originX: number;
                originY: number;
                originZ: number;
                strength: number;
            };
        }

      Returns void

      FourError INVALID_APPLICATION_STATE after dispose, or for a count outside (0, capacity] — the emitter never sends zero, and a count beyond the buffers would integrate garbage lanes.

    • Copies slot from's position and velocity over slot to — four recorded copies through the scratch (module header), one submit.

      Parameters

      • from: number
      • to: number

      Returns void

      FourError INVALID_APPLICATION_STATE after dispose, for an index outside [0, capacity), or for from === to (the emitter never sends it, and a self-move is a call-contract violation worth naming).

    • Writes one spawned particle's position and velocity into slot index — two 12-byte writeBuffers from a reused staging triple (writeBuffer copies at call time, so reuse is safe).

      Parameters

      • index: number
      • positionX: number
      • positionY: number
      • positionZ: number
      • velocityX: number
      • velocityY: number
      • velocityZ: number

      Returns void

      FourError INVALID_APPLICATION_STATE after dispose or for an index outside [0, capacity).