Engine API Reference - v2.24.0-beta.33
    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 = GSplatFormat.createDefaultFormat(device);
    const container = new 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
    container.aabb = new BoundingBox();

    // fill centers only if you need CPU sorting
    container.centers.set([x0, y0, z0, x1, y1, z1, ...]); // xyz per splat

    // Add to scene
    entity.addComponent('gsplat', { resource: container });
    // Example 2: Using a custom format
    const format = new GSplatFormat(device, [
    { name: 'data', format: 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 GSplatContainer(device, 100, format);

    Hierarchy (View Summary)

    Index
    _centers: Float32Array<ArrayBufferLike> | null
    • get antiAlias(): boolean

      Gets whether the splats were trained with anti-aliasing.

      Returns boolean

    • set antiAlias(value: boolean): void

      Sets whether the splats were trained with anti-aliasing (a screen-space filter with opacity compensation, as in Mip-Splatting), which they need to be rendered with to look right. Loaded resources set this from the file, when it records the training mode: the antialiased 1 or SplatRenderMode: mip PLY header comment, the model field of a SOG file, or the anti-aliased flag of an SPZ file. Set it for files that do not record the training mode. Used when GSplatParams#antiAlias is undefined, its default. Defaults to false.

      Parameters

      • value: boolean

      Returns void

    • get extras(): any

      Application-defined data stored with the splat file, as in glTF's extras: the extras value of a SOG's meta.json. The engine attaches no meaning to it. Undefined when the file has none, and for formats that cannot carry it.

      Returns any

    • 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