@viggle/splat-engine-three 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +306 -33
- package/dist/chunks/chunk-BHNNSHJG.js +22298 -0
- package/dist/chunks/chunk-BHNNSHJG.js.map +7 -0
- package/dist/index.js +225 -3
- package/dist/types/anim/animation-conversion.d.ts +2 -2
- package/dist/types/anim/keyframe-splines.d.ts +17 -41
- package/dist/types/animation.d.ts +84 -28
- package/dist/types/armature.d.ts +280 -2
- package/dist/types/character.d.ts +163 -3
- package/dist/types/effects/index.d.ts +12 -0
- package/dist/types/effects/outlines/outline-effect.d.ts +98 -0
- package/dist/types/effects/outlines/outline-shaders.d.ts +14 -0
- package/dist/types/effects/pixelart/pixelart-effect.d.ts +152 -0
- package/dist/types/effects/pixelart/pixelart-shaders.d.ts +31 -0
- package/dist/types/effects/postfx/base-capturing-pass.d.ts +109 -0
- package/dist/types/effects/postfx/camera-frame.d.ts +103 -0
- package/dist/types/effects/postfx/frame-renderer.d.ts +32 -0
- package/dist/types/effects/postfx/frame-shaders.d.ts +19 -0
- package/dist/types/effects/postfx/mask.d.ts +44 -0
- package/dist/types/effects/postfx/postfx.d.ts +144 -0
- package/dist/types/effects/postfx/program.d.ts +74 -0
- package/dist/types/effects/postfx/uniforms.d.ts +24 -0
- package/dist/types/effects/postfx/webgl-program.d.ts +6 -0
- package/dist/types/effects/postfx/webgpu-program.d.ts +3 -0
- package/dist/types/effects/vfx/data-types.d.ts +100 -0
- package/dist/types/effects/vfx/index.d.ts +37 -0
- package/dist/types/effects/vfx/json-vfx-prefab.d.ts +94 -0
- package/dist/types/effects/vfx/layer-renderer.d.ts +118 -0
- package/dist/types/effects/vfx/layers/mesh.d.ts +124 -0
- package/dist/types/effects/vfx/layers/particle.d.ts +90 -0
- package/dist/types/effects/vfx/layers/shader.d.ts +130 -0
- package/dist/types/effects/vfx/layers/shared.d.ts +40 -0
- package/dist/types/effects/vfx/layers/sprite.d.ts +45 -0
- package/dist/types/effects/vfx/pool.d.ts +51 -0
- package/dist/types/effects/vfx/prefab.d.ts +48 -0
- package/dist/types/effects/vfx/prewarm.d.ts +17 -0
- package/dist/types/effects/vfx/stage.d.ts +115 -0
- package/dist/types/effects/vfx/webgpu-register.d.ts +2 -0
- package/dist/types/effects/webgpu-register.d.ts +2 -0
- package/dist/types/engine.d.ts +18 -0
- package/dist/types/environment.d.ts +96 -8
- package/dist/types/index.d.ts +36 -6
- package/dist/types/loader/animation/animation-glb.d.ts +4 -4
- package/dist/types/loader/character/load.d.ts +6 -1
- package/dist/types/loader/environment/lod-bundle.d.ts +123 -0
- package/dist/types/loader/environment/spz-decode.d.ts +88 -0
- package/dist/types/loader/environment/spz.d.ts +28 -0
- package/dist/types/loader/shared/asset-fetch.d.ts +11 -0
- package/dist/types/loader/shared/asset-loader.d.ts +86 -0
- package/dist/types/loader/shared/bin-cache.d.ts +41 -14
- package/dist/types/loader/shared/decode-worker.d.ts +27 -0
- package/dist/types/loader/shared/glb.d.ts +30 -0
- package/dist/types/loader/shared/inflate.d.ts +9 -0
- package/dist/types/loader/shared/pack-splats-task.d.ts +17 -0
- package/dist/types/loader/shared/sog-decode.d.ts +81 -0
- package/dist/types/loader/shared/sog.d.ts +17 -0
- package/dist/types/math.d.ts +7 -0
- package/dist/types/physics/ammo.d.ts +210 -0
- package/dist/types/physics/index.d.ts +11 -0
- package/dist/types/physics/joints.d.ts +157 -0
- package/dist/types/physics/physics-world.d.ts +193 -0
- package/dist/types/physics/rigid-body.d.ts +361 -0
- package/dist/types/presets/camera/camera-preset.d.ts +43 -0
- package/dist/types/presets/camera/third-person-camera.d.ts +63 -0
- package/dist/types/presets/character/body-shape.d.ts +109 -0
- package/dist/types/presets/character/character-reveal.d.ts +90 -0
- package/dist/types/presets/character/socket-loadout.d.ts +61 -0
- package/dist/types/presets/index.d.ts +13 -0
- package/dist/types/presets/vfx/mesh-flash.d.ts +51 -0
- package/dist/types/presets/visual/bone-overlay.d.ts +57 -0
- package/dist/types/proxy/environment-input.d.ts +30 -0
- package/dist/types/proxy/environment-source.d.ts +39 -0
- package/dist/types/proxy/proxy-debug.d.ts +106 -0
- package/dist/types/proxy/splat-source.d.ts +42 -0
- package/dist/types/proxy/voxelizer.d.ts +383 -0
- package/dist/types/relight/backend.d.ts +101 -0
- package/dist/types/relight/index.d.ts +6 -0
- package/dist/types/relight/relight-pass.d.ts +367 -0
- package/dist/types/relight/relight-placeholder.d.ts +2 -0
- package/dist/types/relight/relight-shaders.d.ts +4 -0
- package/dist/types/relight/shadow-bias.d.ts +26 -0
- package/dist/types/relight/splat-relight.d.ts +741 -0
- package/dist/types/relight/webgl-backend.d.ts +3 -0
- package/dist/types/relight/webgpu/backend.d.ts +3 -0
- package/dist/types/relight/webgpu-register.d.ts +2 -0
- package/dist/types/scene.d.ts +241 -0
- package/dist/types/skeletal/animation-player.d.ts +31 -3
- package/dist/types/skeletal/body-parts.d.ts +55 -0
- package/dist/types/skeletal/ragdoll-config.d.ts +115 -0
- package/dist/types/skeletal/ragdoll.d.ts +283 -0
- package/dist/types/skeletal/skeleton.d.ts +9 -2
- package/dist/types/splat/backend.d.ts +2 -0
- package/dist/types/splat/bone-binding.d.ts +1 -1
- package/dist/types/splat/color-modifier.d.ts +78 -0
- package/dist/types/splat/cut-groups.d.ts +27 -0
- package/dist/types/splat/depth-sort.d.ts +23 -5
- package/dist/types/splat/importance.d.ts +60 -0
- package/dist/types/splat/prune.d.ts +60 -0
- package/dist/types/splat/quality.d.ts +175 -0
- package/dist/types/splat/relight-binding.d.ts +39 -0
- package/dist/types/splat/reveal-bake.d.ts +43 -0
- package/dist/types/splat/reveal-look.d.ts +64 -0
- package/dist/types/splat/splat-mesh.d.ts +1 -0
- package/dist/types/splat/splat.d.ts +220 -0
- package/dist/types/splat/webgl/shaders.d.ts +5 -1
- package/dist/types/splat/webgl/splat-mesh.d.ts +6 -0
- package/dist/types/splat/webgpu/radix-sort.d.ts +3 -0
- package/dist/types/splat/webgpu/splat-mesh.d.ts +25 -0
- package/dist/types/three/splat-character.d.ts +56 -0
- package/dist/types/three/spz-loader.d.ts +35 -0
- package/dist/types/types.d.ts +6 -0
- package/dist/webgpu.js +1155 -156
- package/dist/webgpu.js.map +4 -4
- package/package.json +6 -2
- package/dist/chunks/chunk-MM6DJU6S.js +0 -7801
- package/dist/chunks/chunk-MM6DJU6S.js.map +0 -7
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StorageBufferAttribute } from 'three/webgpu';
|
|
1
2
|
type Node = any;
|
|
2
3
|
/** Sort keys are 16 bits, sorted as two 8-bit digits. */
|
|
3
4
|
export declare const SORT_KEY_BITS = 16;
|
|
@@ -35,6 +36,8 @@ export declare class GpuRadixSort {
|
|
|
35
36
|
readonly resetNode: Node;
|
|
36
37
|
/** Run, in order, after the pass that writes keys. */
|
|
37
38
|
readonly sortNodes: Node[];
|
|
39
|
+
/** Every buffer the sort allocated, for the owner to free with its nodes. */
|
|
40
|
+
readonly attributes: StorageBufferAttribute[];
|
|
38
41
|
private readonly _firstHistogram;
|
|
39
42
|
constructor(count: number);
|
|
40
43
|
/**
|
|
@@ -44,12 +44,27 @@ export declare class WebGPUSplatImpl implements SplatRenderImpl {
|
|
|
44
44
|
private _projectNodes;
|
|
45
45
|
/** The sort proper - needed only when the depth ORDER may have changed. */
|
|
46
46
|
private _sortNodes;
|
|
47
|
+
/** Storage buffers the current build allocated. */
|
|
48
|
+
private _buffers;
|
|
49
|
+
/** Nodes and buffers of builds since replaced, freed on the next frame. */
|
|
50
|
+
private _retired;
|
|
51
|
+
/** The renderer that drew this splat, which owns its GPU buffers. */
|
|
52
|
+
private _renderer;
|
|
47
53
|
private readonly _lastInputs;
|
|
48
54
|
private readonly _inputs;
|
|
49
55
|
private readonly _lastSortDirection;
|
|
50
56
|
private _buildId;
|
|
51
57
|
private _sortedBuildId;
|
|
52
58
|
private _allNodes;
|
|
59
|
+
/** Relight texture nodes, re-pointed when the binding's textures change. */
|
|
60
|
+
private _relightTex;
|
|
61
|
+
private _relightShadowTex;
|
|
62
|
+
/** Cut texture nodes [offsets, pivots, rotations], re-pointed when a re-cut reallocates them. */
|
|
63
|
+
private _cutTex;
|
|
64
|
+
/** True when the colour can change with no input this backend can see (a game hook). */
|
|
65
|
+
private _alwaysProject;
|
|
66
|
+
/** Copies the game hook's uniform values into their nodes. */
|
|
67
|
+
private _syncHook;
|
|
53
68
|
private readonly _u;
|
|
54
69
|
constructor(host: Mesh, splat: Splat, lighting: WebGPULighting);
|
|
55
70
|
/** The sort runs in the same frame as the draw; the order is never stale. */
|
|
@@ -59,6 +74,8 @@ export declare class WebGPUSplatImpl implements SplatRenderImpl {
|
|
|
59
74
|
syncDefines(): void;
|
|
60
75
|
syncBounds(): void;
|
|
61
76
|
syncBoneData(): void;
|
|
77
|
+
/** The relight textures are re-pointed every frame; a new binding only needs a rebuild when one turns on or off. */
|
|
78
|
+
syncRelight(): void;
|
|
62
79
|
syncVariantGroups(): void;
|
|
63
80
|
/**
|
|
64
81
|
* (Re)create the storage buffers, compute nodes and material nodes. Runs at
|
|
@@ -67,5 +84,13 @@ export declare class WebGPUSplatImpl implements SplatRenderImpl {
|
|
|
67
84
|
*/
|
|
68
85
|
private _build;
|
|
69
86
|
beforeRender(renderer: any, camera: Camera): void;
|
|
87
|
+
/** Refresh this splat's uniforms and run whatever compute this frame needs. */
|
|
88
|
+
private _prepare;
|
|
70
89
|
dispose(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Dispose replaced compute nodes and free their storage buffers. three.js
|
|
92
|
+
* frees a compute node's pipeline and bindings on dispose, but not the
|
|
93
|
+
* buffers they read; those it only frees with a geometry they belong to.
|
|
94
|
+
*/
|
|
95
|
+
private _freeRetired;
|
|
71
96
|
}
|
|
@@ -6,6 +6,8 @@ import { Character } from '../character';
|
|
|
6
6
|
import type { SplatEngine } from '../engine';
|
|
7
7
|
import type { CharacterBundle } from '../loader/character/load';
|
|
8
8
|
import type { BodyRegion, BoneMask } from '../skeletal/bone-mask';
|
|
9
|
+
import type { SplatColorModifier } from '../splat/color-modifier';
|
|
10
|
+
import type { RevealLook } from '../splat/reveal-look';
|
|
9
11
|
import type { Splat } from '../splat/splat';
|
|
10
12
|
/**
|
|
11
13
|
* What a clip's horizontal travel does to the character.
|
|
@@ -109,6 +111,10 @@ export declare class SplatCharacter extends Object3D<SplatCharacterEventMap> {
|
|
|
109
111
|
private _loop;
|
|
110
112
|
private _finishedSent;
|
|
111
113
|
private _rootMotion;
|
|
114
|
+
/** Optional world-space floor height. When set, the lowest visible splats
|
|
115
|
+
* are aligned to it after each pose. Useful for dances with no airborne
|
|
116
|
+
* phase; leave null for clips with intentional jumps or flight. */
|
|
117
|
+
groundLockY: number | null;
|
|
112
118
|
private _disposed;
|
|
113
119
|
/**
|
|
114
120
|
* @param bundles - Decoded character bundles, finest level of detail first.
|
|
@@ -165,8 +171,58 @@ export declare class SplatCharacter extends Object3D<SplatCharacterEventMap> {
|
|
|
165
171
|
* flash, a selection highlight. `amount = 0` restores the authored colour.
|
|
166
172
|
*/
|
|
167
173
|
setTint(color: ColorRepresentation, amount?: number): this;
|
|
174
|
+
/**
|
|
175
|
+
* Multiply the character's colour by `color`, by `amount` (0..1): darkens or
|
|
176
|
+
* browns while keeping the character's own variation. {@link setTint}
|
|
177
|
+
* returns to the blend.
|
|
178
|
+
*/
|
|
179
|
+
setTintMultiply(color: ColorRepresentation, amount?: number): this;
|
|
168
180
|
/** Contrast and saturation multipliers for the character's colour. `(1, 1)` is unchanged. */
|
|
169
181
|
setGrade(contrast: number, saturation: number): this;
|
|
182
|
+
/** Alpha multiplier for the whole character, 0..1. `1` draws it unchanged. */
|
|
183
|
+
get opacity(): number;
|
|
184
|
+
set opacity(value: number);
|
|
185
|
+
/**
|
|
186
|
+
* Reveal the character with a bright front walking from feet to head:
|
|
187
|
+
* `amount` 0 is hidden, 1 is the character unchanged. `inverse` keeps the
|
|
188
|
+
* part ahead of the front, for a character going out. The first call below
|
|
189
|
+
* 1 prepares the effect, which costs a frame on a large character; call
|
|
190
|
+
* {@link prepareReveal} after loading to pay it up front.
|
|
191
|
+
*/
|
|
192
|
+
setReveal(amount: number, inverse?: boolean): this;
|
|
193
|
+
/** How the reveal looks; unset fields keep their value. See {@link RevealLook}. */
|
|
194
|
+
setRevealLook(look: RevealLook): this;
|
|
195
|
+
/** Pay the reveal's one-time setup now rather than on its first frame. */
|
|
196
|
+
prepareReveal(): this;
|
|
197
|
+
/**
|
|
198
|
+
* Run a colour function of your own on every splat after the engine's
|
|
199
|
+
* colour work; `null` removes it. See {@link SplatColorModifier}.
|
|
200
|
+
*/
|
|
201
|
+
setColorModifier(modifier: SplatColorModifier | null): this;
|
|
202
|
+
/**
|
|
203
|
+
* Draw fewer of this character's splats as it gets further away.
|
|
204
|
+
*
|
|
205
|
+
* `nearFraction` of them at `nearDist` and closer, `farFraction` at
|
|
206
|
+
* `farDist` and beyond, interpolated in between. Which splats those are is
|
|
207
|
+
* decided by importance within each 4 cm cell, so the character thins evenly
|
|
208
|
+
* rather than losing a region of itself. See {@link Character.setSplatCountLod}.
|
|
209
|
+
*
|
|
210
|
+
* Needs a camera on the engine to measure distance from - the same one the
|
|
211
|
+
* other distance throttles use:
|
|
212
|
+
*
|
|
213
|
+
* ```ts
|
|
214
|
+
* SplatEngine.shared.camera = camera;
|
|
215
|
+
* character.setSplatCountLod({ nearDist: 4, farDist: 16, farFraction: 0.25 });
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
setSplatCountLod(opts: {
|
|
219
|
+
nearDist: number;
|
|
220
|
+
farDist: number;
|
|
221
|
+
nearFraction?: number;
|
|
222
|
+
farFraction?: number;
|
|
223
|
+
}): this;
|
|
224
|
+
/** Stop thinning: every splat is drawn again, at any distance. */
|
|
225
|
+
disableSplatCountLod(): this;
|
|
170
226
|
/** Bone names, in rig order. */
|
|
171
227
|
get boneNames(): readonly string[];
|
|
172
228
|
/**
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Loader } from 'three';
|
|
2
|
+
import type { LoadingManager } from 'three';
|
|
3
|
+
import { SplatEngine } from '../engine';
|
|
4
|
+
import type { SplatMesh } from '../splat/splat-mesh';
|
|
5
|
+
/**
|
|
6
|
+
* Loads an `.spz` Gaussian-splat capture (versions 1 to 4) as a static
|
|
7
|
+
* {@link SplatMesh}, the way {@link SplatPLYLoader} loads a `.ply`.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const field = await new SplatSPZLoader().loadAsync('/assets/field.spz');
|
|
11
|
+
* scene.add(field);
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* The file decodes and packs in a worker; version 4's zstd streams are
|
|
15
|
+
* inflated on the calling thread first, since no browser offers zstd to
|
|
16
|
+
* script. The mesh is given `renderOrder = -1` so it draws before characters,
|
|
17
|
+
* as {@link SplatPLYLoader}'s is.
|
|
18
|
+
*
|
|
19
|
+
* SPZ stores no coordinate convention of its own and none is applied here:
|
|
20
|
+
* the splats come out in the file's axes, as the PlayCanvas build reads them.
|
|
21
|
+
*
|
|
22
|
+
* @group Loaders
|
|
23
|
+
*/
|
|
24
|
+
export declare class SplatSPZLoader extends Loader<SplatMesh> {
|
|
25
|
+
/**
|
|
26
|
+
* The engine loaded meshes belong to: the lights they respond to. Leave
|
|
27
|
+
* unset to use {@link SplatEngine.shared}.
|
|
28
|
+
*/
|
|
29
|
+
engine: SplatEngine | null;
|
|
30
|
+
constructor(manager?: LoadingManager);
|
|
31
|
+
setEngine(engine: SplatEngine | null): this;
|
|
32
|
+
/** Decode bytes already in memory. `name` labels the mesh; for a loaded file it is the file's base name. */
|
|
33
|
+
parseAsync(data: ArrayBuffer, name?: string): Promise<SplatMesh>;
|
|
34
|
+
load(url: string, onLoad: (result: SplatMesh) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): void;
|
|
35
|
+
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -19,6 +19,12 @@ export interface ArmatureData {
|
|
|
19
19
|
stdMaleRestTranslations?: Float32Array;
|
|
20
20
|
stdMaleRestRotations?: Float32Array;
|
|
21
21
|
stdMaleParents?: Int32Array;
|
|
22
|
+
/**
|
|
23
|
+
* This rig's own bone names, index-aligned with the arrays above. Set for a
|
|
24
|
+
* rig that is not one of the bundled skeletons (a mesh character's GLB
|
|
25
|
+
* skeleton); name lookups then read these instead of the scene's library.
|
|
26
|
+
*/
|
|
27
|
+
boneNames?: string[];
|
|
22
28
|
}
|
|
23
29
|
/** Per-splat skinning influences, `K` slots per splat. */
|
|
24
30
|
export interface SplatWeights {
|