/** * Base class for Gaussian splat resources, with the properties all of them share. The resource of * a loaded gsplat {@link Asset} is one of its subclasses, except for streamed level-of-detail data, * which uses {@link GSplatOctreeResource}. {@link GSplatContainer} creates one procedurally. * * @category Graphics */ export class GSplatResourceBase { static createMesh(device: any): Mesh; static get instanceSize(): number; /** * @param {GraphicsDevice} device - The graphics device. * @param {object} gsplatData - Data source with getCenters(), calcAabb(), numSplats, etc. * @param {object} [options] - Construction options. * @param {boolean} [options.prepareCenters] - When omitted or true, calls gsplatData.getCenters() * and stores the result. When false, `centers` stays null until set or * materialized by a subclass (e.g. lazy allocation in GSplatContainer). * @ignore */ constructor(device: GraphicsDevice, gsplatData: object, options?: { prepareCenters?: boolean; }); /** * @type {GraphicsDevice} * @ignore */ device: GraphicsDevice; /** * @type {GSplatData | GSplatCompressedData | GSplatSogData} * @ignore */ gsplatData: GSplatData | GSplatCompressedData | GSplatSogData; /** * CPU-side splat center positions (xyz per splat), or null when not built for this resource. * * @type {Float32Array|null} */ set centers(value: Float32Array); get centers(): Float32Array; /** * @type {Float32Array|null} * @protected */ protected _centers: Float32Array | null; /** * True when a centers buffer has been allocated (`centers` is non-null). * Reads internal storage only so checks do not trigger lazy allocation in {@link GSplatContainer}. * * @type {boolean} * @ignore */ get hasCenters(): boolean; /** * Version counter for centers array changes. Remains 0 for static resources. * Only GSplatContainer increments this via its update() method. * * @ignore */ centersVersion: number; /** * @type {BoundingBox} * @protected */ protected _aabb: BoundingBox; /** * @type {Mesh|null} * @ignore */ mesh: Mesh | null; /** * @type {number} * @ignore */ id: number; /** * Cache for work buffer render materials/shaders. Keyed by configuration hash. * Stored per-resource because materials depend on resource-specific configuration * (SH bands, textures, defines). Cleaned up when resource is destroyed. * * @type {Map} * @ignore */ workBufferRenderInfos: Map; /** * Format descriptor for this resource. Assigned by derived classes. * * @type {GSplatFormat} * @protected */ protected _format: GSplatFormat; /** * Manages textures for this resource based on format streams. * * @type {GSplatStreams} * @ignore */ streams: GSplatStreams; /** * Non-texture uniform parameters required by this resource's format. * This is the single source of truth for format-specific uniforms (e.g., dequantization * parameters) used by both material configuration and processing. * * @type {Map} * @ignore */ parameters: Map; /** @private */ private _antiAlias; /** @private */ private _refCount; /** @private */ private _meshRefCount; /** * Destroys this resource. If the resource is still in use by the sorter, destruction is * automatically deferred until it's safe. */ destroy(): void; /** * Actually destroys this resource and releases all GPU resources. * Derived classes should override this method instead of destroy(). * * @protected */ protected _actualDestroy(): void; /** * Increments the reference count. * * @ignore */ incRefCount(): void; /** * Decrements the reference count. * * @ignore */ decRefCount(): void; /** * Gets the current reference count. This represents how many times this resource is currently * being used internally by the engine. For {@link GSplatComponent#asset|assets} assigned to * {@link GSplatComponent#unified|unified} gsplat components, this tracks active usage during * rendering and sorting operations. * * Resources should not be unloaded while the reference count is non-zero, as they are still * in use by the rendering pipeline. * * @type {number} * @ignore */ get refCount(): number; /** * Ensures mesh and instanceIndices exist. Creates them lazily on first call. Must be paired * with a call to releaseMesh() when done. * * @ignore */ ensureMesh(): void; /** * Releases reference to mesh. When all references are released, cleans up instanceIndices. * The mesh itself is destroyed by MeshInstance when its internal refCount reaches zero. * * @ignore */ releaseMesh(): void; /** * True when this resource's color-only work buffer updates (spherical harmonics refresh) can * source geometry from the work buffer itself instead of re-reading the source textures. The * resource format's read chunk must compile out getCenter/getRotation/getScale when * GSPLAT_WORKBUFFER_GEOMETRY is defined (see gsplatWorkBufferGeometryPS chunk). * * @type {boolean} * @ignore */ get supportsWorkBufferGeometry(): boolean; /** * 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. * * @type {*} */ get extras(): any; /** * Gets the number of splats in the resource. * * @type {number} */ get numSplats(): number; /** * Gets the bounding box of the splats, in the local space of the resource. It is computed from * the splat data; use {@link GSplatComponent#customAabb} to override the bounds of a component. * * @type {BoundingBox} */ get aabb(): BoundingBox; /** * 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 * `postshot.anti_aliasing=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 {@link GSplatParams#antiAlias} is undefined, its default. Defaults to false. * * @type {boolean} */ set antiAlias(value: boolean); /** * Gets whether the splats were trained with anti-aliasing. * * @type {boolean} */ get antiAlias(): boolean; /** * Gets the format descriptor for this resource. The format defines texture streams and * shader code for reading splat data. Use this to add extra streams. * * @type {GSplatFormat} */ get format(): GSplatFormat; /** * Gets a texture by name. * * @param {string} name - The name of the texture. * @returns {Texture|null} The texture, or null if not found. */ getTexture(name: string): Texture | null; /** * Gets the texture dimensions (width and height) used by this resource's data textures. * * @type {Vec2} */ get textureDimensions(): Vec2; /** * Configures a material to use this resource's data. Base implementation injects format's * shader chunks and binds textures from the streams. * * @param {ShaderMaterial} material - The material to configure. * @param {{ code: string, hash: number }|null} workBufferModifier - Optional custom modifier (object with code and pre-computed hash). * @param {string} formatDeclarations - Captured format declarations for shader compilation. * @ignore */ configureMaterial(material: ShaderMaterial, workBufferModifier: { code: string; hash: number; } | null, formatDeclarations: string): void; /** * Configures material defines for this resource. Derived classes should override this. * * @param {Map} defines - The defines map to configure. * @ignore */ configureMaterialDefines(defines: Map): void; instantiate(): void; } import type { GraphicsDevice } from '../../platform/graphics/graphics-device.js'; import type { GSplatData } from './gsplat-data.js'; import type { GSplatCompressedData } from './gsplat-compressed-data.js'; import type { GSplatSogData } from './gsplat-sog-data.js'; import { BoundingBox } from '../../core/shape/bounding-box.js'; import { Mesh } from '../mesh.js'; import type { WorkBufferRenderInfo } from '../gsplat-unified/gsplat-work-buffer.js'; import type { GSplatFormat } from './gsplat-format.js'; import { GSplatStreams } from './gsplat-streams.js'; import type { Texture } from '../../platform/graphics/texture.js'; import type { Vec2 } from '../../core/math/vec2.js'; import type { ShaderMaterial } from '../materials/shader-material.js';