mirror of
https://github.com/storytold/spark.git
synced 2026-11-28 09:09:24 +01:00
88 lines
3.4 KiB
TypeScript
88 lines
3.4 KiB
TypeScript
import { GsplatGenerator } from './SplatGenerator';
|
|
import { SplatFileType } from './SplatLoader';
|
|
import { DynoProgram, DynoProgramTemplate, DynoUniform } from './dyno';
|
|
import { TPackedSplats } from './dyno/splats';
|
|
import * as THREE from "three";
|
|
export type PackedSplatsOptions = {
|
|
url?: string;
|
|
fileBytes?: Uint8Array | ArrayBuffer;
|
|
fileType?: SplatFileType;
|
|
fileName?: string;
|
|
maxSplats?: number;
|
|
packedArray?: Uint32Array;
|
|
numSplats?: number;
|
|
construct?: (splats: PackedSplats) => Promise<void> | void;
|
|
extra?: Record<string, unknown>;
|
|
};
|
|
export declare class PackedSplats {
|
|
maxSplats: number;
|
|
numSplats: number;
|
|
packedArray: Uint32Array | null;
|
|
extra: Record<string, unknown>;
|
|
initialized: Promise<PackedSplats>;
|
|
isInitialized: boolean;
|
|
target: THREE.WebGLArrayRenderTarget | null;
|
|
source: THREE.DataArrayTexture | null;
|
|
needsUpdate: boolean;
|
|
dyno: DynoUniform<typeof TPackedSplats, "packedSplats">;
|
|
constructor(options?: PackedSplatsOptions);
|
|
reinitialize(options: PackedSplatsOptions): void;
|
|
initialize(options: PackedSplatsOptions): void;
|
|
asyncInitialize(options: PackedSplatsOptions): Promise<void>;
|
|
dispose(): void;
|
|
ensureSplats(numSplats: number): Uint32Array;
|
|
ensureSplatsSh(level: number, numSplats: number): Uint32Array;
|
|
getSplat(index: number): {
|
|
center: THREE.Vector3;
|
|
scales: THREE.Vector3;
|
|
quaternion: THREE.Quaternion;
|
|
opacity: number;
|
|
color: THREE.Color;
|
|
};
|
|
setSplat(index: number, center: THREE.Vector3, scales: THREE.Vector3, quaternion: THREE.Quaternion, opacity: number, color: THREE.Color): void;
|
|
pushSplat(center: THREE.Vector3, scales: THREE.Vector3, quaternion: THREE.Quaternion, opacity: number, color: THREE.Color): void;
|
|
forEachSplat(callback: (index: number, center: THREE.Vector3, scales: THREE.Vector3, quaternion: THREE.Quaternion, opacity: number, color: THREE.Color) => void): void;
|
|
ensureGenerate(maxSplats: number): boolean;
|
|
generateMapping(splatCounts: number[]): {
|
|
maxSplats: number;
|
|
mapping: {
|
|
base: number;
|
|
count: number;
|
|
}[];
|
|
};
|
|
getTexture(): THREE.DataArrayTexture;
|
|
private maybeUpdateSource;
|
|
private static emptySource;
|
|
static getEmpty(): THREE.DataArrayTexture;
|
|
prepareProgramMaterial(generator: GsplatGenerator): {
|
|
program: DynoProgram;
|
|
material: THREE.RawShaderMaterial;
|
|
};
|
|
private saveRenderState;
|
|
private resetRenderState;
|
|
generate({ generator, base, count, renderer, }: {
|
|
generator: GsplatGenerator;
|
|
base: number;
|
|
count: number;
|
|
renderer: THREE.WebGLRenderer;
|
|
}): {
|
|
nextBase: number;
|
|
};
|
|
static programTemplate: DynoProgramTemplate | null;
|
|
static generatorProgram: Map<GsplatGenerator, DynoProgram>;
|
|
static geometry: THREE.PlaneGeometry;
|
|
static mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.RawShaderMaterial, THREE.Object3DEventMap>;
|
|
static scene: THREE.Scene;
|
|
static camera: THREE.Camera;
|
|
}
|
|
export declare const dynoPackedSplats: (packedSplats?: PackedSplats) => DynoPackedSplats;
|
|
export declare class DynoPackedSplats extends DynoUniform<typeof TPackedSplats, "packedSplats", {
|
|
texture: THREE.DataArrayTexture;
|
|
numSplats: number;
|
|
}> {
|
|
packedSplats?: PackedSplats;
|
|
constructor({ packedSplats }?: {
|
|
packedSplats?: PackedSplats;
|
|
});
|
|
}
|