Engine API Reference - v2.16.1
    Preparing search index...

    Class GSplatContainer

    A container for procedural Gaussian Splat data. This class allows you to create splat data programmatically using either a built-in format or a custom format with your own texture streams and read code.

    A default format is provided via GSplatFormat.createDefaultFormat which uses float textures for easy CPU population.

    // Example 1: Using the default format (easy CPU population)
    const format = pc.GSplatFormat.createDefaultFormat(device);
    const container = new pc.GSplatContainer(device, 100, format);

    // Float format textures are straightforward to fill
    const centerTex = container.getTexture('dataCenter');
    const pixels = centerTex.lock();
    // pixels is Float32Array, fill with [x, y, z, 0, x, y, z, 0, ...]
    centerTex.unlock();

    // Set bounding box and centers (required for culling/sorting)
    container.aabb = new pc.BoundingBox();
    container.centers.set([x0, y0, z0, x1, y1, z1, ...]); // xyz per splat

    // Add to scene
    entity.addComponent('gsplat', { resource: container, unified: true });
    // Example 2: Using a custom format
    const format = new pc.GSplatFormat(device, [
    { name: 'data', format: pc.PIXELFORMAT_RGBA32F }
    ], {
    // Shader code to read splat attributes from the texture
    readGLSL: `
    vec4 d = loadData();
    splatCenter = d.xyz;
    splatColor = vec4(1.0);
    splatScale = vec3(d.w);
    splatRotation = vec4(0, 0, 0, 1);
    `,
    readWGSL: `
    let d = loadData();
    splatCenter = d.xyz;
    splatColor = vec4f(1.0);
    splatScale = vec3f(d.w);
    splatRotation = vec4f(0, 0, 0, 1);
    `
    });

    const container = new pc.GSplatContainer(device, 100, format);
    Index

    Constructors

    Properties

    centers: Float32Array<ArrayBufferLike>

    Accessors

    Methods

    • Protected

      Actually destroys this resource and releases all GPU resources. Derived classes should override this method instead of destroy().

      Returns void

    • Destroys this resource. If the resource is still in use by the sorter, destruction is automatically deferred until it's safe.

      Returns void

    • Updates the container after modifying texture data and centers. Call this after filling data to signal that the container contents have changed.

      Parameters

      • OptionalnumSplats: number = ...

        Number of splats to render. Defaults to current value. Must be between 0 and maxSplats.

      • OptionalcentersUpdated: boolean = true

        Whether the centers array was modified. Set to false when only numSplats changes but center positions remain the same, to avoid the cost of re-cloning centers in the sorter (can be significant for large containers).

      Returns void