@viggle/splat-engine-three 0.1.1 → 0.3.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 +58 -0
- package/README.md +158 -20
- package/dist/chunks/chunk-2GKWT24B.js +23182 -0
- package/dist/chunks/chunk-2GKWT24B.js.map +7 -0
- package/dist/index.js +235 -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 +120 -2
- 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 +35 -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 +198 -13
- package/dist/types/physics/ammo.d.ts +217 -0
- package/dist/types/physics/index.d.ts +11 -0
- package/dist/types/physics/joints.d.ts +206 -0
- package/dist/types/physics/physics-world.d.ts +194 -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 +760 -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 +291 -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/color-modifier.d.ts +78 -0
- package/dist/types/splat/cut-groups.d.ts +27 -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 +154 -0
- package/dist/types/splat/webgl/shaders.d.ts +5 -1
- package/dist/types/splat/webgl/splat-mesh.d.ts +4 -0
- package/dist/types/splat/webgpu/radix-sort.d.ts +3 -0
- package/dist/types/splat/webgpu/splat-mesh.d.ts +23 -0
- package/dist/types/three/splat-character.d.ts +28 -0
- package/dist/types/three/spz-loader.d.ts +35 -0
- package/dist/types/types.d.ts +6 -0
- package/dist/webgpu.js +1137 -154
- package/dist/webgpu.js.map +4 -4
- package/package.json +6 -2
- package/dist/chunks/chunk-WN5WBKM4.js +0 -8606
- package/dist/chunks/chunk-WN5WBKM4.js.map +0 -7
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A character's global socket loadout: socket name → item name. This is the
|
|
3
|
+
* BASE layer, applied across every game, and is whatever map the host serves
|
|
4
|
+
* alongside the character record.
|
|
5
|
+
*
|
|
6
|
+
* @group Characters & Animation
|
|
7
|
+
*/
|
|
8
|
+
export type SocketLoadout = Record<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* One per-clip socket override, as authored on an animation's `socketItems[]`.
|
|
11
|
+
* Accepts every in-the-wild shape:
|
|
12
|
+
* • `{ socket, item }` - replace the socket's item for this clip.
|
|
13
|
+
* • `{ socket, hide: true }` - remove the socket's item (canonical form).
|
|
14
|
+
* • `{ socket, item: null }` - remove (legacy form).
|
|
15
|
+
*
|
|
16
|
+
* @group Characters & Animation
|
|
17
|
+
*/
|
|
18
|
+
export interface SocketOverride {
|
|
19
|
+
socket: string;
|
|
20
|
+
/** Item name to place on the socket; `null`/absent (with no explicit item) reads as a removal. */
|
|
21
|
+
item?: string | null;
|
|
22
|
+
/** When true, remove this socket's item for the clip regardless of `item`. */
|
|
23
|
+
hide?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The resolved item to attach to a socket for the current clip - always a
|
|
27
|
+
* concrete item name (removals are already dropped).
|
|
28
|
+
*
|
|
29
|
+
* @group Characters & Animation
|
|
30
|
+
*/
|
|
31
|
+
export interface ResolvedSocketItem {
|
|
32
|
+
socket: string;
|
|
33
|
+
item: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* True when an override entry means "remove this socket" rather than replace it.
|
|
37
|
+
*
|
|
38
|
+
* @group Characters & Animation
|
|
39
|
+
*/
|
|
40
|
+
export declare function isSocketRemoval(o: SocketOverride): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Merge a character's global base loadout with a clip's per-clip socket
|
|
43
|
+
* overrides, returning the effective set of items to attach while that clip
|
|
44
|
+
* plays. Override wins per socket (replace, or remove via `hide:true`/`item:null`);
|
|
45
|
+
* sockets untouched by the clip keep their base item.
|
|
46
|
+
*
|
|
47
|
+
* Order-independent by socket (one item per socket). Passing `base = null`
|
|
48
|
+
* yields the clip's own items minus any removals - a safe drop-in for a game
|
|
49
|
+
* that has no base loadout yet.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // base: hat on head; clip swaps in a crown and removes the hat's socket via a helmet
|
|
53
|
+
* mergeSocketLoadout(
|
|
54
|
+
* { head: 'wizard_hat', back: 'cape' },
|
|
55
|
+
* [{ socket: 'head', item: 'gold_crown' }, { socket: 'hand_r', item: 'sword' }],
|
|
56
|
+
* )
|
|
57
|
+
* // => [{socket:'head',item:'gold_crown'}, {socket:'back',item:'cape'}, {socket:'hand_r',item:'sword'}]
|
|
58
|
+
*
|
|
59
|
+
* @group Characters & Animation
|
|
60
|
+
*/
|
|
61
|
+
export declare function mergeSocketLoadout(base: SocketLoadout | null | undefined, overrides: readonly SocketOverride[] | null | undefined): ResolvedSocketItem[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { ThirdPersonCamera } from './camera/third-person-camera';
|
|
2
|
+
export type { ThirdPersonCameraOptions } from './camera/third-person-camera';
|
|
3
|
+
export type { CameraHost, CameraPreset, TargetSupplier, Vec3Like } from './camera/camera-preset';
|
|
4
|
+
export { playReveal, DEFAULT_REVEAL_PRESET } from './character/character-reveal';
|
|
5
|
+
export type { RevealPreset, PlayRevealOptions, RevealRun, RevealTarget } from './character/character-reveal';
|
|
6
|
+
export { BodyShapeVariant, BODY_PART_SLUGS, buildStretch } from './character/body-shape';
|
|
7
|
+
export type { ProportionSpec } from './character/body-shape';
|
|
8
|
+
export { mergeSocketLoadout, isSocketRemoval } from './character/socket-loadout';
|
|
9
|
+
export type { SocketLoadout, SocketOverride, ResolvedSocketItem } from './character/socket-loadout';
|
|
10
|
+
export { BoneOverlay } from './visual/bone-overlay';
|
|
11
|
+
export type { BoneOverlayOptions } from './visual/bone-overlay';
|
|
12
|
+
export { MeshFlash } from './vfx/mesh-flash';
|
|
13
|
+
export type { MeshFlashOptions } from './vfx/mesh-flash';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Object3D } from 'three';
|
|
2
|
+
import type { IVfxInstance, IVfxPrefab } from '../../effects/vfx/prefab';
|
|
3
|
+
import type { Scene } from '../../scene';
|
|
4
|
+
/**
|
|
5
|
+
* Options for {@link MeshFlash}.
|
|
6
|
+
*
|
|
7
|
+
* @group Effects
|
|
8
|
+
*/
|
|
9
|
+
export interface MeshFlashOptions {
|
|
10
|
+
/** Total lifetime in seconds. Default 0.4. */
|
|
11
|
+
duration?: number;
|
|
12
|
+
/** Base RGB emissive color (0..1). Default `[1.0, 0.8, 0.4]` (warm spark). */
|
|
13
|
+
color?: [number, number, number];
|
|
14
|
+
/** Peak radius the sphere grows to. Default 0.5 (world units). */
|
|
15
|
+
peakRadius?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generic VFX builtin: an additively-blended sphere that grows from a tiny
|
|
19
|
+
* point to {@link MeshFlashOptions.peakRadius peakRadius}, then vanishes.
|
|
20
|
+
* Useful for hit-sparks, pickup glows, small impact highlights.
|
|
21
|
+
*
|
|
22
|
+
* Its opacity ramps down over the lifetime, as in the PlayCanvas build,
|
|
23
|
+
* where additive blending ignores opacity: the flash draws at full colour
|
|
24
|
+
* until it ends. Kept, since that is the look effects were tuned against.
|
|
25
|
+
*
|
|
26
|
+
* Single shared material per pool - `setColor` mutates it, so all currently
|
|
27
|
+
* active flashes in one pool render the same tint. That keeps the cost flat
|
|
28
|
+
* and is the right trade-off for one-shot effects.
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { VfxStage, MeshFlash } from '@viggle/splat-engine-three';
|
|
32
|
+
*
|
|
33
|
+
* const stage = new VfxStage(scene);
|
|
34
|
+
* stage.register('flash', new MeshFlash({ color: [1, 0.6, 0.2] }));
|
|
35
|
+
* stage.play('flash', somePosition);
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @group Effects
|
|
39
|
+
*/
|
|
40
|
+
export declare class MeshFlash implements IVfxPrefab {
|
|
41
|
+
private readonly _duration;
|
|
42
|
+
private readonly _peakRadius;
|
|
43
|
+
private readonly _material;
|
|
44
|
+
/** PlayCanvas's sphere primitive: radius 0.5, 16 x 16 bands. */
|
|
45
|
+
private readonly _geometry;
|
|
46
|
+
constructor(opts?: MeshFlashOptions);
|
|
47
|
+
create(_scene: Scene, parent: Object3D): IVfxInstance;
|
|
48
|
+
/** Update the shared emissive color in-place. Affects all active instances. */
|
|
49
|
+
setColor(rgb: [number, number, number]): void;
|
|
50
|
+
dispose(): void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Armature } from '../../armature';
|
|
2
|
+
import type { Scene } from '../../scene';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for {@link BoneOverlay.create}.
|
|
5
|
+
*
|
|
6
|
+
* @group Presets
|
|
7
|
+
*/
|
|
8
|
+
export interface BoneOverlayOptions {
|
|
9
|
+
/** Line color as CSS hex (e.g. `#40ffa0`). Default `#40ffa0`. */
|
|
10
|
+
color?: string;
|
|
11
|
+
/** Include `FACIAL_*` bones from the full 441-bone rig. Default `false` -
|
|
12
|
+
* the ~356 facial bones collapse into an unreadable blob at body scale. */
|
|
13
|
+
includeFacial?: boolean;
|
|
14
|
+
/** Start enabled. Default `false`. */
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Debug skeleton visualization: draws one line per parent→child bone pair of
|
|
19
|
+
* an {@link Armature}, on top of everything (no depth test), refreshed every
|
|
20
|
+
* frame from the armature's bone matrices.
|
|
21
|
+
*
|
|
22
|
+
* Attach/detach armatures freely - the overlay survives character swaps:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const bones = BoneOverlay.create(scene, { color: '#40ffa0' });
|
|
26
|
+
* bones.armature = character.armature;
|
|
27
|
+
* bones.enabled = true;
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @group Presets
|
|
31
|
+
*/
|
|
32
|
+
export declare class BoneOverlay {
|
|
33
|
+
/** Draw the overlay this frame? Cheap to toggle - no scene graph churn. */
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
private _armature;
|
|
36
|
+
private readonly _material;
|
|
37
|
+
private readonly _lines;
|
|
38
|
+
private readonly _includeFacial;
|
|
39
|
+
/** Per-bone draw filter, rebuilt when the armature (rig) changes. */
|
|
40
|
+
private _boneVisible;
|
|
41
|
+
private readonly _offUpdate;
|
|
42
|
+
/** Create a bone overlay bound to `scene`. Assign {@link armature} to pick
|
|
43
|
+
* which rig it draws. */
|
|
44
|
+
static create(scene: Scene, opts?: BoneOverlayOptions): BoneOverlay;
|
|
45
|
+
private constructor();
|
|
46
|
+
/** The rig being visualized. Set `null` to blank the overlay (e.g. between
|
|
47
|
+
* character swaps) without destroying it. */
|
|
48
|
+
get armature(): Armature | null;
|
|
49
|
+
set armature(a: Armature | null);
|
|
50
|
+
/** Change the line color at runtime. */
|
|
51
|
+
setColor(hex: string): void;
|
|
52
|
+
/** Unhook from the scene's update loop and remove the lines. The overlay is unusable afterwards. */
|
|
53
|
+
destroy(): void;
|
|
54
|
+
/** Which bones to draw: all, or all but the facial ones. */
|
|
55
|
+
private _resolveFilter;
|
|
56
|
+
private _draw;
|
|
57
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pure half of reading an environment for its proxy: the world-space
|
|
3
|
+
* crop. No three.js and no I/O, so it runs under `node --test`.
|
|
4
|
+
* `environment-source.ts` is the half that touches the splat.
|
|
5
|
+
*
|
|
6
|
+
* The PlayCanvas build also keeps its LOD-bundle slicing here; this port loads
|
|
7
|
+
* monolithic captures only, so that half has nothing to read yet.
|
|
8
|
+
*
|
|
9
|
+
* Internal.
|
|
10
|
+
*/
|
|
11
|
+
import type { ProxyMeshInput } from './voxelizer';
|
|
12
|
+
/**
|
|
13
|
+
* Keep only the splats whose WORLD position is inside `[min, max]`, given the
|
|
14
|
+
* local-to-world matrix of the node the positions are local to. Returns the
|
|
15
|
+
* input itself when nothing is dropped. Pure.
|
|
16
|
+
*
|
|
17
|
+
* Why a crop exists at all: the voxelizer sizes one dense grid to the bounds of
|
|
18
|
+
* everything it is given, and a capture's bounds are set by its floaters, not
|
|
19
|
+
* its floor. A room whose walls span 6 m can carry wisps 20 m out, and the
|
|
20
|
+
* grid ceiling then coarsens the whole room to fit them.
|
|
21
|
+
*/
|
|
22
|
+
export declare function cropInputToWorldBox(input: ProxyMeshInput, localToWorld: ArrayLike<number>, min: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
z: number;
|
|
26
|
+
}, max: {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
z: number;
|
|
30
|
+
}): ProxyMeshInput;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment -> {@link ProxyMeshInput}.
|
|
3
|
+
*
|
|
4
|
+
* Reads the splat that draws the environment: its rest centres and alphas,
|
|
5
|
+
* with no network and no decompress. For a monolithic capture that is the
|
|
6
|
+
* whole capture. For a streaming LOD bundle it is whatever the bundle had
|
|
7
|
+
* streamed in when the proxy was first built - the PlayCanvas build instead
|
|
8
|
+
* fetches one chosen level's chunk files itself, which this port's bundle
|
|
9
|
+
* loader does not expose yet.
|
|
10
|
+
*
|
|
11
|
+
* Positions come out in the environment object's LOCAL space - the proxy is
|
|
12
|
+
* parented to that object, so any authored transform applies to it exactly as
|
|
13
|
+
* it applies to the splats. No skinning.
|
|
14
|
+
*
|
|
15
|
+
* Internal. `SplatRelight` is the consumer.
|
|
16
|
+
*/
|
|
17
|
+
import { Matrix4 } from 'three';
|
|
18
|
+
import type { Environment } from '../environment';
|
|
19
|
+
import type { ProxyMeshInput } from './voxelizer';
|
|
20
|
+
/** What {@link proxyInputFromEnvironment} read, and from where. */
|
|
21
|
+
export interface EnvironmentProxySource {
|
|
22
|
+
input: ProxyMeshInput;
|
|
23
|
+
/** LOD level read, `null` for a monolithic capture. `0` is the finest. */
|
|
24
|
+
lodLevel: number | null;
|
|
25
|
+
/** Levels the capture has; `1` for a monolithic capture. */
|
|
26
|
+
lodLevels: number;
|
|
27
|
+
/** Milliseconds from the call to the input being ready. */
|
|
28
|
+
loadMs: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The largest axis scale of a local-to-world matrix - what turns a voxel size
|
|
32
|
+
* in world metres into the local units the proxy is built in.
|
|
33
|
+
*/
|
|
34
|
+
export declare function maxAxisScale(localToWorld: Matrix4): number;
|
|
35
|
+
/**
|
|
36
|
+
* Read an environment's splat centres and alphas, in its local space. `null`
|
|
37
|
+
* while a LOD bundle has not streamed anything in yet.
|
|
38
|
+
*/
|
|
39
|
+
export declare function proxyInputFromEnvironment(env: Environment): EnvironmentProxySource | null;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Object3D } from 'three';
|
|
2
|
+
import type { Armature } from '../armature';
|
|
3
|
+
import type { Scene } from '../scene';
|
|
4
|
+
import type { ProxyMeshResult } from './voxelizer';
|
|
5
|
+
/**
|
|
6
|
+
* What the overlay draws.
|
|
7
|
+
*
|
|
8
|
+
* - `off` - nothing. Consumers still get the mesh; only the preview stops.
|
|
9
|
+
* - `voxels` - the exact cell boundary, blocky on purpose. This is what you
|
|
10
|
+
* judge {@link ProxySettings.voxelSize} against, and it stays blocky
|
|
11
|
+
* whatever finish the real mesh is using.
|
|
12
|
+
* - `mesh` - the reconstructed surface, i.e. exactly what a consumer gets.
|
|
13
|
+
*/
|
|
14
|
+
export type ProxyDebugMode = 'off' | 'voxels' | 'mesh';
|
|
15
|
+
/** Configuration for {@link ProxyMeshDebug.create}. */
|
|
16
|
+
export interface ProxyMeshDebugOptions {
|
|
17
|
+
/** `mesh` mode line colour, CSS hex. Default `#22d3ee`. */
|
|
18
|
+
color?: string;
|
|
19
|
+
/** `voxels` mode line colour, CSS hex. Default `#f59e0b`. */
|
|
20
|
+
voxelColor?: string;
|
|
21
|
+
/** Start in this mode. Default `off`. */
|
|
22
|
+
mode?: ProxyDebugMode;
|
|
23
|
+
/**
|
|
24
|
+
* Hide lines behind geometry. Default `false` - the overlay reads as an
|
|
25
|
+
* overlay, and splats write no depth to test against anyway.
|
|
26
|
+
*/
|
|
27
|
+
depthTest?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Wireframe preview of a proxy mesh, skinned on the CPU by the same rig the
|
|
31
|
+
* mesh is.
|
|
32
|
+
*
|
|
33
|
+
* The whole surface is ONE `LineSegments` whose positions are refilled each
|
|
34
|
+
* drawn frame: a character proxy is thousands of quads, and an object per
|
|
35
|
+
* voxel would be thousands of draws a frame.
|
|
36
|
+
*
|
|
37
|
+
* Edges come from {@link ProxyMeshResult.quads}, not from the triangle list.
|
|
38
|
+
* The triangulation diagonals are an artefact of the index buffer, and drawing
|
|
39
|
+
* them turns a readable voxel boundary into a hatched mess that hides the
|
|
40
|
+
* thing you switched the overlay on to see.
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* const debug = ProxyMeshDebug.create(scene);
|
|
44
|
+
* debug.setMesh(buildProxyMesh(input, settings));
|
|
45
|
+
* debug.setVoxels(buildProxyMesh(input, { ...settings, surface: 'blocky', smoothIterations: 0 }));
|
|
46
|
+
* debug.armature = character.armature;
|
|
47
|
+
* debug.mode = 'voxels';
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* Internal. Not part of the published surface.
|
|
51
|
+
*/
|
|
52
|
+
export declare class ProxyMeshDebug {
|
|
53
|
+
/** What to draw. Cheap to flip - no rebuild, no scene-graph churn. */
|
|
54
|
+
mode: ProxyDebugMode;
|
|
55
|
+
/**
|
|
56
|
+
* Rig to skin the lines by. `null` draws the geometry where it was built,
|
|
57
|
+
* which is right for a static capture and wrong for a character.
|
|
58
|
+
*
|
|
59
|
+
* The surface must be in BIND space, which is what the voxelizer produces
|
|
60
|
+
* when it is fed the splats' rest positions.
|
|
61
|
+
*/
|
|
62
|
+
armature: Armature | null;
|
|
63
|
+
/**
|
|
64
|
+
* Object the surface was built in the local space of, for a static proxy -
|
|
65
|
+
* a splat that no armature drives. Ignored while {@link armature} is set,
|
|
66
|
+
* whose chain already ends in world space. `null` draws the positions as
|
|
67
|
+
* world-space.
|
|
68
|
+
*/
|
|
69
|
+
node: Object3D | null;
|
|
70
|
+
private readonly _color;
|
|
71
|
+
private readonly _voxelColor;
|
|
72
|
+
private readonly _material;
|
|
73
|
+
private readonly _lines;
|
|
74
|
+
private readonly _offPreRender;
|
|
75
|
+
private _mesh;
|
|
76
|
+
private _voxels;
|
|
77
|
+
/** The set {@link _lines} currently holds a buffer for. */
|
|
78
|
+
private _shown;
|
|
79
|
+
/** `boneWorld[i] * inverseBindPose[i]`, rebuilt each drawn frame. */
|
|
80
|
+
private readonly _skin;
|
|
81
|
+
static create(scene: Scene, opts?: ProxyMeshDebugOptions): ProxyMeshDebug;
|
|
82
|
+
private constructor();
|
|
83
|
+
/** The reconstructed surface, for `mesh` mode. `null` blanks that mode. */
|
|
84
|
+
setMesh(result: ProxyMeshResult | null): void;
|
|
85
|
+
/**
|
|
86
|
+
* The blocky cell boundary, for `voxels` mode. Pass a build made with
|
|
87
|
+
* `{ surface: 'blocky', smoothIterations: 0 }` over the SAME input and voxel
|
|
88
|
+
* size - previewing the cells means showing the cells, whatever finish the
|
|
89
|
+
* real mesh is using.
|
|
90
|
+
*/
|
|
91
|
+
setVoxels(result: ProxyMeshResult | null): void;
|
|
92
|
+
/** Line segments the current mode would submit. For a HUD. */
|
|
93
|
+
get lineCount(): number;
|
|
94
|
+
destroy(): void;
|
|
95
|
+
private _draw;
|
|
96
|
+
/**
|
|
97
|
+
* Bind-space vertices to world, by linear blend skinning.
|
|
98
|
+
*
|
|
99
|
+
* The chain is `boneWorld * inverseBindPose * v`, with no object transform
|
|
100
|
+
* in it: the relight's skinned proxy evaluates
|
|
101
|
+
* `objectWorld * inv(objectWorld) * boneWorld * invBind * v`, in which the
|
|
102
|
+
* object transform cancels. Applying it here as well would put the overlay
|
|
103
|
+
* somewhere the mesh is not, by exactly that transform.
|
|
104
|
+
*/
|
|
105
|
+
private _deform;
|
|
106
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splat cloud -> {@link ProxyMeshInput}.
|
|
3
|
+
*
|
|
4
|
+
* Three conversions the voxelizer deliberately does NOT do for you, because
|
|
5
|
+
* doing them would give a pure geometry module opinions about our container
|
|
6
|
+
* format:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Unpack.** A {@link Splat} keeps its gaussians in the texel streams the
|
|
9
|
+
* shaders read; the voxelizer wants one `[x,y,z]` stream and one alpha per
|
|
10
|
+
* splat, because that is what every other mesh pipeline in the world wants.
|
|
11
|
+
* 2. **Decode the alpha.** `packSplats` already ran the sigmoid and stored the
|
|
12
|
+
* ALPHA as a half float, so it is decoded here, never pushed through
|
|
13
|
+
* {@link alphaFromLogits} a second time - thresholding a twice-sigmoided
|
|
14
|
+
* value against 0.04 keeps every splat, and fails silently by producing a
|
|
15
|
+
* mesh that is merely a bit too fat.
|
|
16
|
+
* 3. **Remap the bone indices.** A bundle's weights are authored against the
|
|
17
|
+
* SOURCE rig (often 1185 or 441 bones); the armature the proxy will be
|
|
18
|
+
* skinned by is usually the 86-bone body rig. `buildSourceBoneRemap` is the
|
|
19
|
+
* same mapping `initializeSplatBoneMapping` applies to the GPU bone
|
|
20
|
+
* textures, so the proxy and the splats end up following the same bones.
|
|
21
|
+
*
|
|
22
|
+
* Internal. `SplatRelight` is the consumer.
|
|
23
|
+
*/
|
|
24
|
+
import type { Armature } from '../armature';
|
|
25
|
+
import type { SplatEngine } from '../engine';
|
|
26
|
+
import type { PackedSplats } from '../splat/packed-splats';
|
|
27
|
+
import type { Splat } from '../splat/splat';
|
|
28
|
+
import type { ProxyMeshInput } from './voxelizer';
|
|
29
|
+
/**
|
|
30
|
+
* Pull the rest positions, alpha and (when the splat is skinned) armature-space
|
|
31
|
+
* bone influences out of a loaded splat.
|
|
32
|
+
*
|
|
33
|
+
* Positions come out in BIND space - the space `Armature.inverseBindPose`
|
|
34
|
+
* undoes - so a mesh built from them is skinned by `boneWorld * inverseBind`
|
|
35
|
+
* straight into world space.
|
|
36
|
+
*
|
|
37
|
+
* Allocates the whole input. Call it once per character, not once per rebuild:
|
|
38
|
+
* the voxel knobs are what move while tuning and none of this depends on them.
|
|
39
|
+
*/
|
|
40
|
+
export declare function proxyInputFromSplat(splat: Splat, armature: Armature | null, engine: SplatEngine): ProxyMeshInput;
|
|
41
|
+
/** Every splat's alpha, decoded from the half float `packSplats` stored. */
|
|
42
|
+
export declare function alphasOf(packed: PackedSplats): Float32Array;
|