Documentation
    Preparing search index...

    Class ParticleBatchCache

    Per-context store of particle vertex arrays and instance buffers (§61, §64 stage 7).

    One cache belongs to one GL context, like GeometryCache and TextureCache: the renderer builds it during initialize and builds a new one on context restore, since every handle the old one held died with the context.

    const record = cache.acquire(item, geometryRecord.positionBuffer);
    if (record !== null) {
    cache.upload(record, item);
    gl.bindVertexArray(record.vertexArray);
    gl.drawArraysInstanced(mode, 0, 6, item.count);
    }

    Records are keyed by the emitting node's id and rebuilt lazily, on the next acquire, whenever the instance array's capacity or the shared corner buffer has changed. There is no background sweep and no finalization hook, so a particle system removed from the scene and never submitted again keeps its vertex array until the renderer is disposed — the same documented leak window GeometryCache carries, for the same reasons (§83 puts resource ownership on whoever created the object; a renderer that is done with a scene disposes).

    Index
    • get disposed(): boolean

      Whether ParticleBatchCache.dispose has run.

      Returns boolean

    • get size(): number

      Number of particle systems currently holding GPU buffers (§83, §84).

      Returns number

    • Returns the vertex array for item, creating it on first use and re-creating it when the system's capacity or the shared cornerBuffer has changed.

      Returns null — and creates no entry — when the system has no capacity at all or when GL refuses to allocate an object. Never throws: this runs inside Renderer.render, where §61 forbids it (see GeometryCache.acquire for the whole argument).

      Parameters

      Returns ParticleBatchRecord | null

    • Deletes every vertex array and buffer this cache created (§83). Idempotent, and valid only on a live context — the renderer calls ParticleBatchCache.forget instead when the context is lost.

      Returns void

    • Drops every record without touching the context — the context-loss path (§61). The handles are already invalid.

      Returns void

    • Uploads item's live instances into record's buffer — the frame's only particle traffic, count × 32 bytes.

      The five-argument bufferSubData is what keeps this allocation-free: the three-argument form would need instances.subarray(0, n), i.e. a fresh typed-array view per system per frame (plan D7).

      A zero-particle system is not uploaded at all: an empty range is a GL call that moves no bytes, and the caller skips the draw anyway.

      Parameters

      Returns void