playcanvas
Version:
PlayCanvas WebGL game engine
154 lines (153 loc) • 5.51 kB
TypeScript
/**
* GSplatManager manages the rendering of splats using a work buffer, where all active splats are
* stored and rendered from.
*
* @ignore
*/
export class GSplatManager {
constructor(device: any, director: any, layer: any, cameraNode: any);
/** @type {GraphicsDevice} */
device: GraphicsDevice;
/** @type {GraphNode} */
node: GraphNode;
/** @type {GSplatWorkBuffer} */
workBuffer: GSplatWorkBuffer;
/** @type {GSplatRenderer} */
renderer: GSplatRenderer;
/**
* A map of versioned world states, keyed by version.
*
* @type {Map<number, GSplatWorldState>}
*/
worldStates: Map<number, GSplatWorldState>;
/**
* The version of the last world state.
*
* @type {number}
*/
lastWorldStateVersion: number;
/** @type {GSplatUnifiedSorter} */
sorter: GSplatUnifiedSorter;
/** @type {number} */
sortedVersion: number;
/** @type {number} */
framesTillFullUpdate: number;
/** @type {Vec3} */
lastLodCameraPos: Vec3;
/** @type {Vec3} */
lastLodCameraFwd: Vec3;
/** @type {Vec3} */
lastSortCameraPos: Vec3;
/** @type {Vec3} */
lastSortCameraFwd: Vec3;
/** @type {boolean} */
sortNeeded: boolean;
/** @type {Vec3} */
lastColorUpdateCameraPos: Vec3;
/** @type {Vec3} */
lastColorUpdateCameraFwd: Vec3;
/** @type {GraphNode} */
cameraNode: GraphNode;
/** @type {Scene} */
scene: Scene;
/**
* Layer placements, only non-octree placements are included.
*
* @type {GSplatPlacement[]}
*/
layerPlacements: GSplatPlacement[];
/** @type {boolean} */
layerPlacementsDirty: boolean;
/** @type {Map<GSplatPlacement, GSplatOctreeInstance>} */
octreeInstances: Map<GSplatPlacement, GSplatOctreeInstance>;
/**
* Octree instances scheduled for destruction. We collect their releases and destroy them
* when creating the next world state
*
* @type {GSplatOctreeInstance[]}
*/
octreeInstancesToDestroy: GSplatOctreeInstance[];
/**
* Flag set when new octree instances are added, to trigger immediate LOD evaluation.
*
* @type {boolean}
*/
hasNewOctreeInstances: boolean;
director: any;
destroy(): void;
_destroyed: boolean;
get material(): import("../materials/shader-material.js").ShaderMaterial;
createSorter(): GSplatUnifiedSorter;
/**
* Supply the manager with the placements to use. This is used to update the manager when the
* layer's placements have changed, called infrequently.
*
* @param {GSplatPlacement[]} placements - The placements to reconcile with.
*/
reconcile(placements: GSplatPlacement[]): void;
updateWorldState(): void;
onSorted(count: any, version: any, orderData: any): void;
/**
* Tests if the camera has moved or rotated enough to require LOD update.
*
* @returns {boolean} True if camera moved/rotated over thresholds, otherwise false.
*/
testCameraMovedForLod(): boolean;
/**
* Tests if the camera has moved enough to require re-sorting.
* - For radial sorting: only position matters (rotation doesn't affect sort order)
* - For directional sorting: only forward direction matters (position doesn't affect sort order)
*
* @returns {boolean} True if camera moved enough to require re-sorting, otherwise false.
*/
testCameraMovedForSort(): boolean;
/**
* Updates the camera tracking state for color accumulation calculations.
* Called after any render that updates colors (full or color-only).
*/
updateColorCameraTracking(): void;
/**
* Determines the colorization mode for rendering based on debug flags.
*
* @returns {Array<number[]>|undefined} Color array for debug visualization, or undefined for normal rendering
*/
getDebugColors(): Array<number[]> | undefined;
/**
* Calculates camera movement deltas since last color update.
* Updates and returns the shared _cameraDeltas object.
*
* @returns {{ rotationDelta: number, translationDelta: number }} Shared camera movement deltas object
*/
calculateColorCameraDeltas(): {
rotationDelta: number;
translationDelta: number;
};
/**
* Fires the frame:ready event with current sorting and loading state.
*/
fireFrameReadyEvent(): void;
update(): number;
/**
* Sorts the splats of the given world state.
*
* @param {GSplatWorldState} lastState - The last world state.
*/
sort(lastState: GSplatWorldState): void;
/**
* Prepares sort parameters data for the sorter worker.
*
* @param {GSplatWorldState} worldState - The world state containing all needed data.
* @returns {object} - Data for sorter worker.
*/
prepareSortParameters(worldState: GSplatWorldState): object;
}
import type { GraphicsDevice } from '../../platform/graphics/graphics-device.js';
import { GraphNode } from '../graph-node.js';
import { GSplatWorkBuffer } from './gsplat-work-buffer.js';
import { GSplatRenderer } from './gsplat-renderer.js';
import { GSplatWorldState } from './gsplat-world-state.js';
import { GSplatUnifiedSorter } from './gsplat-unified-sorter.js';
import { Vec3 } from '../../core/math/vec3.js';
import type { Scene } from '../scene.js';
import type { GSplatPlacement } from './gsplat-placement.js';
import { GSplatOctreeInstance } from './gsplat-octree-instance.js';