three-vat 1.0.0 → 2.0.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/README.md +164 -308
- package/dist/carrier-BFCPmcQK.d.ts +472 -0
- package/dist/chunk-2PGZ44TP.js +202 -0
- package/dist/chunk-W2ZAFMPB.js +53 -0
- package/dist/index.d.ts +78 -14
- package/dist/index.js +137 -47
- package/dist/tsl.d.ts +43 -31
- package/dist/tsl.js +94 -38
- package/dist/webgl.d.ts +31 -26
- package/dist/webgl.js +135 -33
- package/package.json +24 -21
- package/dist/chunk-SXTVASKG.js +0 -40
- package/dist/instance-playback-BrGBIKLe.d.ts +0 -109
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { DataTexture, BufferGeometry, Material, Box3, InstancedMesh } from 'three';
|
|
2
|
-
|
|
3
|
-
/** One baked animation range within a VAT's stacked frame rows. */
|
|
4
|
-
interface VATClip {
|
|
5
|
-
/** Clip name, taken from the source `AnimationClip`. */
|
|
6
|
-
name: string;
|
|
7
|
-
/** First frame row (y) of this clip in the texture. */
|
|
8
|
-
startFrame: number;
|
|
9
|
-
/** Number of frame rows baked for this clip. */
|
|
10
|
-
frames: number;
|
|
11
|
-
/** Effective frames-per-second of the bake (`frames / duration`). */
|
|
12
|
-
fps: number;
|
|
13
|
-
/** Source clip duration in seconds. */
|
|
14
|
-
duration: number;
|
|
15
|
-
/**
|
|
16
|
-
* Largest per-vertex position-delta magnitude (metres) across the clip.
|
|
17
|
-
* Near-zero means the clip baked as a frozen pose — the diagnostic for a
|
|
18
|
-
* mis-targeted or genuinely static clip.
|
|
19
|
-
*/
|
|
20
|
-
maxDelta: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* A baked Vertex Animation Texture: the position/normal `DataTexture`s, the
|
|
24
|
-
* geometry they are indexed by, and the clip table and bounds needed to decode
|
|
25
|
-
* and render them. Produced exactly one way — {@link bakeVAT}, at runtime, from
|
|
26
|
-
* a loaded glTF (ADR-0010).
|
|
27
|
-
*
|
|
28
|
-
* The merged vertex ordering is the baker's own invention and the textures are
|
|
29
|
-
* indexed by it (`x = gl_VertexID`), so the caller cannot bring its own
|
|
30
|
-
* geometry — it must render the one baked here. `materials` is ordered to match
|
|
31
|
-
* `geometry.groups[].materialIndex`, giving one draw call per material.
|
|
32
|
-
*/
|
|
33
|
-
interface VAT {
|
|
34
|
-
/** RGBA float texture of per-vertex position deltas (`x = vertex`, `y = frame`). */
|
|
35
|
-
positionTexture: DataTexture;
|
|
36
|
-
/** RGBA float texture of per-vertex absolute normals (`x = vertex`, `y = frame`). */
|
|
37
|
-
normalTexture: DataTexture;
|
|
38
|
-
/** Merged, root-space rest-pose geometry. Its `position` is the delta reference. */
|
|
39
|
-
geometry: BufferGeometry;
|
|
40
|
-
/** Source materials, indexed by `geometry.groups[].materialIndex`. */
|
|
41
|
-
materials: Material[];
|
|
42
|
-
/** Clip table: name → `{ startFrame, frames, fps, ... }`. */
|
|
43
|
-
clips: VATClip[];
|
|
44
|
-
/** Union of every baked frame's bounds; use as the geometry bounding box. */
|
|
45
|
-
bounds: Box3;
|
|
46
|
-
/** Vertex count (texture width). */
|
|
47
|
-
vertexCount: number;
|
|
48
|
-
/** Total frame rows across all clips (texture height). */
|
|
49
|
-
totalFrames: number;
|
|
50
|
-
/** Position encoding. Only `'delta'` in v1. */
|
|
51
|
-
encoding: 'delta';
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* The shared playback clock: one `{ value }` in seconds, read by every material
|
|
55
|
-
* of every VAT mesh driven by it. Set it once per frame. Deliberately the
|
|
56
|
-
* narrowest shape both decode paths satisfy — a WebGL `IUniform<number>` and a
|
|
57
|
-
* TSL uniform node are both one of these — so `createVATMesh` returns the same
|
|
58
|
-
* thing on either renderer.
|
|
59
|
-
*/
|
|
60
|
-
interface VATClock {
|
|
61
|
-
value: number;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* A **crowd** ready to render: the mesh to add to the scene, and the clock to
|
|
65
|
-
* advance. What `createVATMesh` returns on either decode path, so moving a
|
|
66
|
-
* crowd between renderers is an import change and nothing else. Named for what
|
|
67
|
-
* it is rather than for its `mesh` field — the clock is half of it.
|
|
68
|
-
*/
|
|
69
|
-
interface VATCrowd {
|
|
70
|
-
/** Add to the scene. Its instance matrices are yours to write. */
|
|
71
|
-
mesh: InstancedMesh;
|
|
72
|
-
/** The shared playback clock — set `.value` once per frame. */
|
|
73
|
-
time: VATClock;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** Per-instance playback state consumed by both decode paths. */
|
|
77
|
-
interface VATInstance {
|
|
78
|
-
clip: Pick<VAT['clips'][number], 'startFrame' | 'frames' | 'fps'>;
|
|
79
|
-
/** Phase offset in seconds — desyncs the crowd. */
|
|
80
|
-
timeOffset: number;
|
|
81
|
-
/** Playback rate multiplier. */
|
|
82
|
-
speed: number;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Attach the instance-playback attributes to an instanced geometry. Call once
|
|
86
|
-
* before rendering, on the geometry you hand to the `InstancedMesh`.
|
|
87
|
-
*
|
|
88
|
-
* The attribute names and layout below are the shared contract, spelled once in
|
|
89
|
-
* {@link PLAYBACK_ATTRIBUTES}. Both decode paths read exactly these five —
|
|
90
|
-
* `DECODE_PRELUDE` in `src/webgl.ts` as GLSL attributes, `vatNodes` in
|
|
91
|
-
* `src/tsl.ts` as TSL attribute nodes, when it is handed this geometry.
|
|
92
|
-
*
|
|
93
|
-
* | Attribute | Type | Source |
|
|
94
|
-
* | ------------- | ------------- | --------------------- |
|
|
95
|
-
* | `aClipStart` | `float` (x 1) | `instance.clip.startFrame` — first texture row of the clip's frame band |
|
|
96
|
-
* | `aClipFrames` | `float` (x 1) | `instance.clip.frames` — rows in the band |
|
|
97
|
-
* | `aClipFps` | `float` (x 1) | `instance.clip.fps` — with `frames`, the clip's duration |
|
|
98
|
-
* | `aTimeOffset` | `float` (x 1) | `instance.timeOffset` — phase, in seconds |
|
|
99
|
-
* | `aSpeed` | `float` (x 1) | `instance.speed` — rate multiplier |
|
|
100
|
-
*
|
|
101
|
-
* Every entry is a one-component `InstancedBufferAttribute` of `Float32Array`,
|
|
102
|
-
* one element per instance, in instance order. Adding a field — crossfade's
|
|
103
|
-
* reserved second clip index being the known case (ADR-0007) — means adding it
|
|
104
|
-
* here, in the table above, and in each decode path's own attribute
|
|
105
|
-
* declarations.
|
|
106
|
-
*/
|
|
107
|
-
declare function addVATInstanceAttributes(geometry: BufferGeometry, instances: VATInstance[]): void;
|
|
108
|
-
|
|
109
|
-
export { type VAT as V, type VATClip as a, type VATClock as b, type VATCrowd as c, type VATInstance as d, addVATInstanceAttributes as e };
|