/** * {@link loadSplatGltf}: Gaussian splats from a glTF under the ratified * `KHR_gaussian_splatting` extension, skinned and animated through glTF's own * skins and animations. */ import * as THREE from 'three/webgpu'; import { GLTFLoader, type GLTF } from 'three/addons/loaders/GLTFLoader.js'; import { SplatMesh } from '../core/splat-mesh'; import type { SplatMeshOptions } from '../core/splat-mesh-types'; /** * Playback hints a clip may carry in its glTF `extras.vlam` (kept on * `clip.userData.vlam`): how the clip is meant to be played. * * @experimental */ export interface SplatGltfClipHints { /** `'repeat'` (an `AnimationAction`'s default) or `'once'` (`LoopOnce`). */ readonly loop?: 'repeat' | 'once'; /** With `loop: 'repeat'`, how many times. */ readonly repetitions?: number; /** Layered on top of other clips; the loader already made the clip additive. */ readonly additive?: boolean; } /** * Options of {@link loadSplatGltf}: those of the splat meshes it makes, and * the glTF loader to parse with. * * @experimental */ export interface LoadSplatGltfOptions extends SplatMeshOptions { /** * A configured `GLTFLoader` (a `LoadingManager`, a meshopt decoder for * `EXT_meshopt_compression`); a plain one by default. */ readonly loader?: GLTFLoader; /** * Skin the splats of skinned primitives (default `true`). With `false` they * load as plain `SplatMesh`es in the bind pose, for a draw path that cannot * run the skin modifier (a pooled WebGL2 unified draw). */ readonly skinning?: boolean; } /** * A loaded splat glTF. * * @experimental */ export interface SplatGltf { /** The glTF's scene, its splat primitives replaced by {@link meshes}. */ readonly scene: THREE.Group; /** * The splat meshes, in the order of the file's primitives: * {@link SkinnedSplatMesh}es bound to their skeleton where the file skins * them, plain `SplatMesh`es otherwise. */ readonly meshes: SplatMesh[]; /** * The file's animations, for an `AnimationMixer` rooted at {@link scene}. * Clips flagged additive are already additive; hints are on `userData.vlam`. */ readonly animations: THREE.AnimationClip[]; /** What GLTFLoader returned, for anything else in the file. */ readonly gltf: GLTF; } /** * Loads Gaussian splats from a glTF (`.glb` or `.gltf`) under the ratified * `KHR_gaussian_splatting` extension: each splat primitive becomes a * `SplatMesh` in its place in the scene. A primitive with `JOINTS_0` / * `WEIGHTS_0` on a skinned node becomes a {@link SkinnedSplatMesh} bound to * that node's skeleton, as `GLTFLoader` binds a `SkinnedMesh`, so the file's * animations under an `AnimationMixer` move the splats. * * Clips whose `extras.vlam.additive` is set are made additive * (`AnimationUtils.makeClipAdditive`, from their first frame); their hints * stay on `clip.userData.vlam` ({@link SplatGltfClipHints}). * * `source` is a URL, the file's bytes, or a glTF your own `GLTFLoader` * already parsed, whose scene is then changed in place. * * Limits: degree-0 color only (higher SH degrees in the file are ignored), * and an unskinned primitive keeps its node's transform but not its node's * parent skin. Splats are kept in the file's axes (glTF is Y-up), so * `orientation` defaults to `'source'`. * * @example * ```ts * import * as THREE from 'three/webgpu'; * import { loadSplatGltf } from '@voluma/vlam/dynamic'; * * const model = await loadSplatGltf('/character.glb'); * scene.add(model.scene); * const mixer = new THREE.AnimationMixer(model.scene); * mixer.clipAction(THREE.AnimationClip.findByName(model.animations, 'idle')!).play(); * * renderer.setAnimationLoop(() => { * mixer.update(timer.getDelta()); * for (const mesh of model.meshes) mesh.update(camera, renderer); * renderer.render(scene, camera); * }); * ``` * * @experimental The API may change in a minor release. */ export declare function loadSplatGltf(source: string | ArrayBuffer | GLTF, options?: LoadSplatGltfOptions): Promise;