Manager Module API Reference
This document collects the public APIs for all manager classes.
ModelManager
Maintains every loaded model and offers a unified interface for model storage, tracking, and querying.
constructor(maxModels: number = 10000)
Key methods
Model Management:
- addModel(model: Omit<ModelEntry, 'id'>): ModelEntry – Adds a model and generates unique ID. Throws if capacity is reached.
- removeModel(id: string): boolean – Removes a model by ID
- clearAllModels(): void – Removes all models
Model Queries:
- getModels(): ModelInfo[] – Returns simplified metadata (safe for UI/React rendering)
- getFullModels(): ModelEntry[] – Returns all model entries with full pointCloud references
- getModelWithPointCloud(modelType: 'ply' | 'onnx' | 'fbx', id?: string): ModelEntry | null – Gets specific model entry
- getModelsByType(modelType: 'ply' | 'onnx' | 'fbx'): ModelEntry[] – Gets models by type
- getVisibleModels(): ModelEntry[] – Gets only visible models
- getDynamicModels(): ModelEntry[] – Gets only dynamic models
- findModelByName(name: string): ModelEntry | null – Finds model by name (first match)
Statistics:
- getModelCount(): number – Gets total model count
- getRemainingCapacity(): number – Gets remaining model capacity
- getTotalPoints(): number – Gets total point count across all models
- getTotalVisiblePoints(): number – Gets total visible point count
- isAtCapacity(): boolean – Checks if at model limit
Visibility:
- setModelVisibility(id: string, visible: boolean): boolean – Sets model visibility
Transform:
Legacy Methods (Not Recommended): These methods operate on transforms by separately setting position, rotation, and scale, which are then internally composed into a transform matrix. They are early APIs retained for backward compatibility.
setModelPosition(id: string, x: number, y: number, z: number): boolean– Sets model position (legacy, creates transform matrix from TRS composition)getModelPosition(id: string): [number, number, number] | null– Gets model position (extracted from transform matrix)setModelRotation(id: string, x: number, y: number, z: number): boolean– Sets model rotation (legacy, limited, only supports Euler angles)getModelRotation(id: string): [number, number, number] | null– Gets model rotation (legacy, limited, extraction from matrix may be inaccurate)setModelScale(id: string, scale: number | [number, number, number]): boolean– Sets model scale (legacy, limited)getModelScale(id: string): [number, number, number] | null– Gets model scale (legacy, limited, extraction from matrix may be inaccurate)
Recommended Methods: Directly operate on transform matrices, which is the more modern, flexible, and accurate approach.
setModelTransform(id: string, transform: Float32Array | number[]): boolean– Sets the complete 4×4 transform matrix directly (recommended)getModelTransform(id: string): Float32Array | null– Gets the complete 4×4 transform matrix (recommended)
Name Management:
- hasModelWithName(name: string): boolean – Checks if model name exists
- generateUniqueName(baseName: string): string – Generates unique name based on base name
FileLoader
Loads and parses multiple Gaussian formats (PLY, SPZ, KSplat, SPLAT, SOG, Compressed PLY) and FBX files.
constructor(modelManager: ModelManager, callbacks: LoadingCallbacks)
Key methods
Loading:
- loadFile(file: File, device: GPUDevice): Promise<ModelEntry | null> – Loads from File object. Auto-detects format (Gaussian or FBX).
- loadSample(filename: string, device: GPUDevice, expectedType?: string): Promise<ModelEntry | null> – Loads from URL. Supports all Gaussian formats.
Format Detection:
- isFileTypeSupported(filename: string): boolean – Checks if file format is supported
- getSupportedExtensions(): string[] – Returns all supported file extensions
- getFileType(filename: string): string | null – Detects file type from filename
- getGaussianFormat(filename: string): string | null – Gets specific Gaussian format (ply, spz, ksplat, etc.)
Supported Formats:
- Gaussian: .ply, .spz, .ksplat, .splat, .sog, .compressed.ply
- Mesh: .fbx
- Note: ONNX files should be loaded through ONNXManager, not FileLoader
ONNXManager
Loads ONNX models and manages GPU-side inference for dynamic point clouds.
constructor(modelManager: ModelManager)
Key methods
Loading:
- loadONNXModel(device: GPUDevice, modelPath: string, cameraMatrix: Float32Array, projectionMatrix: Float32Array, name?: string, options?: ONNXLoadOptions): Promise<ModelEntry> – Loads ONNX model and creates DynamicPointCloud
- loadONNXFromFile(device: GPUDevice, file: File, cameraMatrix?: Float32Array | null, projectionMatrix?: Float32Array | null): Promise<ModelEntry> – Loads ONNX from File object
Management:
- disposeModel(modelId: string): void – Cleans up GPU buffers and ORT sessions
- dispose(): void – Disposes all ONNX models
Camera Updates:
- updateCameraMatrices(modelName: string, cameraMatrix: Float32Array, projectionMatrix: Float32Array): Promise<void> – Updates camera matrices for ONNX inference
Queries:
- hasONNXModels(): boolean – Checks if any ONNX models are loaded
- getONNXModels(): ModelEntry[] – Returns all ONNX model entries
- getGenerator(id: string): ONNXGenerator | undefined – Gets ONNXGenerator by model ID
- getPointCloud(id: string): DynamicPointCloud | undefined – Gets DynamicPointCloud by model ID
Performance:
- getONNXPerformanceStats(): { modelCount: number; totalGenerators: number; totalPointClouds: number } – Returns performance statistics
CameraManager
Initialises and updates the active camera/controller.
constructor()
Key methods
initCamera(canvas: HTMLCanvasElement): voidswitchController(type: 'orbit' | 'fps'): voidupdate(deltaTime: number): voidresize(canvas: HTMLCanvasElement): voidresetCamera(): voidgetCameraMatrix(): mat4getProjectionMatrix(): mat4getController(): CameraControllersetupCameraForPointCloud(pointCloud: PointCloud): voidsetOrbitCenter(center: vec3): voidgetDebugInfo(): anygetControllerType(): ControllerTypegetCamera(): PerspectiveCamera | nullgetPosition(): vec3getRotation(): quatsetPosition(position: vec3): voidsetRotation(rotation: quat): voidgetViewMatrix(): mat4getViewProjectionMatrix(): mat4getFrustumPlanes(): Float32ArrayisControllerType(type: ControllerType): boolean
AnimationManager
Updates dynamic models each frame.
constructor(modelManager: ModelManager)
Key methods
updateDynamicPointClouds(view: mat4, proj: mat4, time: number): voidcontrolDynamicAnimation(action: 'start' | 'pause' | 'resume' | 'stop', speed?: number): voidsetDynamicAnimationTime(time: number): voidgetDynamicPerformanceStats(): Array<{ modelName: string; stats: any }>getDebugInfo(): anygetAnimationStats(): AnimationStatssetDebugLogging(enabled: boolean): voidgetLastUpdateTime(): numbergetUpdateCount(): numbergetTotalUpdateTime(): numbergetAverageUpdateTime(): numberforceUpdate(): void
RenderLoop
Owns the render/update loop, frame scheduling, and performance tracking.
constructor(modelManager: ModelManager, animationManager: AnimationManager, cameraManager: CameraManager)
Key methods
Lifecycle:
- init(gpu: WebGPUContext, renderer: GaussianRenderer, canvas: HTMLCanvasElement): void – Initializes with GPU context and renderer
- start(): void – Starts the render loop
- stop(): void – Stops the render loop
- isRunning(): boolean – Checks if loop is running
Rendering State:
- setGaussianScale(scale: number): void – Sets global Gaussian scale
- getGaussianScale(): number – Gets current Gaussian scale
- setBackgroundColor(color: [number, number, number, number]): void – Sets background color
- getBackgroundColor(): [number, number, number, number] – Gets current background color
Callbacks:
- setCallbacks(callbacks: FPSCallbacks): void – Sets FPS and point count update callbacks
State & Performance:
- getState(): AppState – Gets current render state
- getPerformanceInfo(): object – Returns performance information
- getFPS(): number – Gets current FPS
- getFrameCount(): number – Gets total frame count
- getLastFrameTime(): number – Gets last frame time in milliseconds
- getAverageFrameTime(): number – Gets average frame time
- setTargetFPS(fps: number): void – Sets target FPS (for throttling)
- getTargetFPS(): number – Gets target FPS
- getDebugInfo(): any – Returns debug information
GaussianLoader
High-level convenience service that combines FileLoader and ONNXManager to build GaussianModel instances. Simplifies model loading when working with Three.js integration.
constructor(fileLoader: FileLoader, onnxManager: ONNXManager)
GaussianLoadOptions
Key methods
Format-Specific Creation:
- createFromPLY(renderer, modelPath, options?): Promise<GaussianModel> – Create from PLY file
- createFromSPZ(renderer, modelPath, options?): Promise<GaussianModel> – Create from SPZ file
- createFromKSplat(renderer, modelPath, options?): Promise<GaussianModel> – Create from KSplat file
- createFromSplat(renderer, modelPath, options?): Promise<GaussianModel> – Create from SPLAT file
- createFromSOG(renderer, modelPath, options?): Promise<GaussianModel> – Create from SOG file
- createFromGaussian(renderer, modelPath, options?, formatHint?): Promise<GaussianModel> – Create from any Gaussian format (auto-detects)
ONNX Creation:
- createFromONNX(renderer, modelPath, cameraMatrix, projectionMatrix, options?): Promise<GaussianModel> – Create from ONNX model
Auto-Detection:
- createFromFile(renderer, modelPath, cameraMatrices?, options?, fileType?): Promise<GaussianModel> – Auto-detect format and create model
Utilities:
- createFromEntry(entry: ModelEntry): GaussianModel – Create from existing ModelEntry
- isFormatSupported(filename: string): boolean – Check if format is supported
- getSupportedFormats(): string[] – Get all supported formats
- detectFormat(filename: string): string | null – Detect format from filename
FBXLoaderManager
Loads FBX files and registers them with ModelManager.
constructor(modelManager: ModelManager, callbacks?: FBXLoaderCallbacks)
interface FBXLoaderCallbacks {
onProgress?: (progress: number, message: string) => void;
onError?: (error: string) => void;
onSuccess?: (model: ModelEntry) => void;
}
Key methods
loadFromFile(file, options?): Promise<ModelEntry>loadFromUrl(url, options?): Promise<ModelEntry>dispose(): void
Note: FBX + WebGPU compatibility is limited; GLTF/GLB is recommended.
Supporting types
interface ModelInfo {
id: string;
name: string;
visible: boolean;
pointCount: number;
isDynamic: boolean;
modelType: 'ply' | 'onnx' | 'fbx';
colorMode?: 'sh' | 'rgb';
colorChannels?: number;
}
interface LoadingCallbacks {
onProgress: (show: boolean, text?: string, pct?: number) => void;
onError: (msg: string) => void;
}
interface ONNXLoadOptions {
staticInference?: boolean;
debugLogging?: boolean;
}
interface FPSCallbacks {
onFPSUpdate: (fps: number) => void;
onPointCountUpdate: (count: number) => void;
}
interface AppState {
background: [number, number, number, number];
gaussianScale: number;
animationId: number;
lastTime: number;
frames: number;
fpsAccumStart: number;
}
interface AnimationStats {
updateCount: number;
totalUpdateTime: number;
averageUpdateTime: number;
totalDynamicModels: number;
activeDynamicModels: number;
}
type ControllerType = 'orbit' | 'fps';
interface LoadProgress {
stage: string;
progress: number;
message?: string;
}