@myned-ai/gsplat-flame-avatar-renderer 1.0.5 → 1.0.6
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 +130 -32
- package/dist/gsplat-flame-avatar-renderer.cjs.js +3478 -722
- package/dist/gsplat-flame-avatar-renderer.cjs.min.js +2 -0
- package/dist/gsplat-flame-avatar-renderer.cjs.min.js.map +1 -0
- package/dist/gsplat-flame-avatar-renderer.esm.js +3439 -724
- package/dist/gsplat-flame-avatar-renderer.esm.min.js +2 -0
- package/dist/gsplat-flame-avatar-renderer.esm.min.js.map +1 -0
- package/package.json +10 -6
- package/src/core/SplatMesh.js +53 -46
- package/src/core/Viewer.js +47 -196
- package/src/errors/ApplicationError.js +185 -0
- package/src/errors/index.js +17 -0
- package/src/flame/FlameAnimator.js +282 -57
- package/src/loaders/PlyLoader.js +302 -44
- package/src/materials/SplatMaterial.js +13 -10
- package/src/materials/SplatMaterial3D.js +72 -27
- package/src/renderer/AnimationManager.js +8 -5
- package/src/renderer/GaussianSplatRenderer.js +668 -217
- package/src/utils/BlobUrlManager.js +294 -0
- package/src/utils/EventEmitter.js +349 -0
- package/src/utils/LoaderUtils.js +2 -1
- package/src/utils/Logger.js +171 -0
- package/src/utils/ObjectPool.js +248 -0
- package/src/utils/RenderLoop.js +306 -0
- package/src/utils/Util.js +59 -18
- package/src/utils/ValidationUtils.js +331 -0
- package/src/utils/index.js +10 -1
- package/dist/gsplat-flame-avatar-renderer.cjs.js.map +0 -1
- package/dist/gsplat-flame-avatar-renderer.esm.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,16 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
A specialized Gaussian Splatting library for rendering animated 3D avatars with FLAME parametric head model support, LAM (Large Avatar Model) head avatars, and ARKit blendshape compatibility.
|
|
6
6
|
|
|
7
|
+
---
|
|
8
|
+
|
|
7
9
|
## Features
|
|
8
10
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
11
|
+
- **52 ARKit Blendshapes** — Complete facial expression control
|
|
12
|
+
- **FLAME Model Support** — Full integration with FLAME parametric head model
|
|
13
|
+
- **Animation State Machine** — Built-in states (Idle, Listening, Thinking, Responding)
|
|
14
|
+
- **GPU Optimized** — WebGL-based rendering with WebAssembly sorting
|
|
15
|
+
- **Three.js Integration** — Works seamlessly with Three.js
|
|
16
|
+
- **LAM Head Avatars** — Support for Large Avatar Model based head avatars
|
|
17
|
+
- **ZIP Asset Loading** — Load compressed avatar assets directly
|
|
18
|
+
- **Real-time Animation** — Smooth blendshape interpolation at 30fps
|
|
19
|
+
- **Conditional Iris Occlusion Fix** — Optional iris fade during eye blinks via iris_occlusion.json
|
|
17
20
|
|
|
18
21
|
---
|
|
19
22
|
|
|
@@ -32,7 +35,8 @@ import { GaussianSplatRenderer } from 'gsplat-flame-avatar-renderer';
|
|
|
32
35
|
|
|
33
36
|
const container = document.getElementById('avatar-container');
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
// Create a new renderer instance (v1.0.6+)
|
|
39
|
+
const renderer = await GaussianSplatRenderer.create(
|
|
36
40
|
container,
|
|
37
41
|
'./path/to/avatar.zip',
|
|
38
42
|
{
|
|
@@ -46,6 +50,9 @@ const renderer = await GaussianSplatRenderer.getInstance(
|
|
|
46
50
|
})
|
|
47
51
|
}
|
|
48
52
|
);
|
|
53
|
+
|
|
54
|
+
// Don't forget to clean up when done!
|
|
55
|
+
// renderer.dispose();
|
|
49
56
|
```
|
|
50
57
|
|
|
51
58
|
---
|
|
@@ -56,9 +63,9 @@ const renderer = await GaussianSplatRenderer.getInstance(
|
|
|
56
63
|
|
|
57
64
|
The main class for rendering Gaussian splat avatars.
|
|
58
65
|
|
|
59
|
-
#### `GaussianSplatRenderer.
|
|
66
|
+
#### `GaussianSplatRenderer.create(container, assetPath, options)`
|
|
60
67
|
|
|
61
|
-
Creates
|
|
68
|
+
Creates a new renderer instance with proper resource isolation.
|
|
62
69
|
|
|
63
70
|
| Parameter | Type | Description |
|
|
64
71
|
|-----------|------|-------------|
|
|
@@ -76,6 +83,35 @@ Creates or returns a singleton renderer instance.
|
|
|
76
83
|
| `loadProgress` | `(progress: number) => void` | Loading progress callback |
|
|
77
84
|
| `downloadProgress` | `(progress: number) => void` | Download progress callback |
|
|
78
85
|
|
|
86
|
+
#### `renderer.dispose()`
|
|
87
|
+
|
|
88
|
+
Cleans up all resources (WebGL context, textures, workers, event listeners). **Always call this when you're done with a renderer instance** to prevent memory leaks.
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
// Clean up when done
|
|
92
|
+
renderer.dispose();
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### Migration from v1.0.5
|
|
96
|
+
|
|
97
|
+
If you're upgrading from v1.0.5 or earlier:
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
// OLD (still works but deprecated)
|
|
101
|
+
const renderer = await GaussianSplatRenderer.getInstance(container, path, options);
|
|
102
|
+
|
|
103
|
+
// NEW (recommended)
|
|
104
|
+
const renderer = await GaussianSplatRenderer.create(container, path, options);
|
|
105
|
+
// ... use renderer ...
|
|
106
|
+
renderer.dispose(); // Don't forget!
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Key Changes:**
|
|
110
|
+
- Each `create()` call returns a **new independent instance** (no longer a singleton)
|
|
111
|
+
- You can now have **multiple renderers** on the same page
|
|
112
|
+
- Each instance has its own canvas element
|
|
113
|
+
- **Must call `dispose()`** when finished to clean up resources
|
|
114
|
+
|
|
79
115
|
### Animation States
|
|
80
116
|
|
|
81
117
|
The renderer supports the following states via `getChatState`:
|
|
@@ -112,12 +148,36 @@ The avatar ZIP file should contain:
|
|
|
112
148
|
```
|
|
113
149
|
avatar.zip
|
|
114
150
|
├── avatar/
|
|
115
|
-
│ ├── offset.ply
|
|
116
|
-
│ ├── animation.glb
|
|
117
|
-
│ ├── skin.glb
|
|
118
|
-
│
|
|
151
|
+
│ ├── offset.ply # Gaussian splats point cloud (required)
|
|
152
|
+
│ ├── animation.glb # Animation clips (required)
|
|
153
|
+
│ ├── skin.glb # Skinning/skeleton data (required)
|
|
154
|
+
│ ├── vertex_order.json # Vertex ordering data (required)
|
|
155
|
+
│ └── iris_occlusion.json # Iris occlusion ranges (optional)
|
|
119
156
|
```
|
|
120
157
|
|
|
158
|
+
### Optional: Iris Occlusion
|
|
159
|
+
|
|
160
|
+
To enable iris fade during eye blinks if the iris is still visible, include `iris_occlusion.json` in your avatar folder to apply a fix.
|
|
161
|
+
|
|
162
|
+
An example of `iris_occlusion.json` :
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"right_iris": [
|
|
167
|
+
[4000, 4100],
|
|
168
|
+
[3930, 3970]
|
|
169
|
+
],
|
|
170
|
+
"left_iris": [
|
|
171
|
+
[4470, 4605],
|
|
172
|
+
[18370, 18799]
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Each array `[start, end]` defines a range of Gaussian splat indices that belong to the iris. When eye blink blendshapes (eyeBlinkLeft, eyeBlinkRight) increase, these splats will smoothly fade out to prevent visual artifacts during eye closure.
|
|
178
|
+
|
|
179
|
+
If `iris_occlusion.json` is not present, the renderer will work normally without iris occlusion.
|
|
180
|
+
|
|
121
181
|
---
|
|
122
182
|
|
|
123
183
|
## Architecture Overview
|
|
@@ -145,6 +205,7 @@ The library supports hybrid rendering where Gaussian Splat positions are deforme
|
|
|
145
205
|
- **52 blendshapes**: Full ARKit compatibility for face tracking
|
|
146
206
|
- **LBS Skinning**: Splat positions transformed via bone matrices and blend weights
|
|
147
207
|
- **GPU-based**: All deformation computed in vertex shader via texture lookups
|
|
208
|
+
- **Iris Occlusion**: Optional dynamic iris fade during eye blinks (configured per-avatar via JSON)
|
|
148
209
|
|
|
149
210
|
---
|
|
150
211
|
|
|
@@ -156,50 +217,87 @@ The library supports hybrid rendering where Gaussian Splat positions are deforme
|
|
|
156
217
|
| `src/buffers/` | 5 | GPU buffer management (SplatBuffer, partitioning) |
|
|
157
218
|
| `src/core/` | 6 | Rendering engine (Viewer, SplatMesh, SplatTree) |
|
|
158
219
|
| `src/enums/` | 8 | Constants and enumerations |
|
|
220
|
+
| `src/errors/` | 1 | Custom error classes (ValidationError, NetworkError, ParseError, etc.) |
|
|
159
221
|
| `src/flame/` | 5 | FLAME model integration (FlameAnimator, textures) |
|
|
160
222
|
| `src/loaders/` | 6 | PLY format loader (INRIA v1) |
|
|
161
|
-
| `src/materials/` | 4 | WebGL shaders (SplatMaterial2D/3D) |
|
|
223
|
+
| `src/materials/` | 4 | WebGL shaders (SplatMaterial2D/3D, conditional iris occlusion) |
|
|
162
224
|
| `src/raycaster/` | 4 | Intersection testing |
|
|
163
225
|
| `src/renderer/` | 4 | Application layer (GaussianSplatRenderer, AnimationManager) |
|
|
164
|
-
| `src/utils/` |
|
|
226
|
+
| `src/utils/` | 8 | Shared utilities (validation, logging, object pooling, blob management) |
|
|
165
227
|
| `src/worker/` | 2 | WebAssembly sorting worker |
|
|
166
228
|
|
|
167
229
|
### Key Components
|
|
168
230
|
|
|
169
231
|
| Component | Purpose |
|
|
170
232
|
|-----------|---------|
|
|
171
|
-
| **GaussianSplatRenderer** | Main entry point, ZIP loading, render loop |
|
|
233
|
+
| **GaussianSplatRenderer** | Main entry point, ZIP loading, render loop, asset management |
|
|
172
234
|
| **Viewer** | Scene management, camera, render pipeline |
|
|
173
|
-
| **SplatMesh** | GPU textures, instanced geometry |
|
|
235
|
+
| **SplatMesh** | GPU textures, instanced geometry, iris config forwarding |
|
|
236
|
+
| **SplatMaterial3D** | WebGL shader generation, conditional iris occlusion code |
|
|
174
237
|
| **FlameAnimator** | Bone rotations, blendshape weights |
|
|
175
238
|
| **FlameTextureManager** | GPU texture uploads for FLAME data |
|
|
176
239
|
| **AnimationManager** | State machine (Idle, Listen, Think, Speak) |
|
|
177
|
-
| **PlyLoader** | Loading PLY files from ZIP |
|
|
240
|
+
| **PlyLoader** | Loading PLY files from ZIP with validation |
|
|
178
241
|
| **SortWorker** | WebAssembly depth sorting |
|
|
242
|
+
| **ValidationUtils** | Input validation (URLs, paths, ranges, types) |
|
|
243
|
+
| **Logger** | Structured logging system |
|
|
244
|
+
| **ObjectPool** | Object pooling for performance (Vector3, Quaternion) |
|
|
245
|
+
| **BlobUrlManager** | Blob URL lifecycle management |
|
|
179
246
|
|
|
180
247
|
---
|
|
181
248
|
|
|
182
249
|
## Build Output
|
|
183
250
|
|
|
184
|
-
Rollup produces ESM and CommonJS bundles in `dist/`:
|
|
251
|
+
Rollup produces optimized ESM and CommonJS bundles in `dist/`:
|
|
185
252
|
|
|
186
|
-
| File | Format |
|
|
187
|
-
|
|
188
|
-
| `gsplat-flame-avatar-renderer.esm.js
|
|
189
|
-
| `gsplat-flame-avatar-renderer.cjs.js
|
|
253
|
+
| File | Size | Format | Source Maps |
|
|
254
|
+
|------|------|--------|-------------|
|
|
255
|
+
| `gsplat-flame-avatar-renderer.esm.min.js`| 244 KB | ES Module (production, minified) | External (.map) |
|
|
256
|
+
| `gsplat-flame-avatar-renderer.cjs.min.js`| 246 KB | CommonJS (production, minified) | External (.map) |
|
|
257
|
+
| `gsplat-flame-avatar-renderer.esm.js` | 2.1 MB | ES Module (development, unminified) | Inline |
|
|
258
|
+
| `gsplat-flame-avatar-renderer.cjs.js` | 2.1 MB | CommonJS (development, unminified) | Inline |
|
|
190
259
|
|
|
191
|
-
|
|
260
|
+
** The minified builds are used by default** when importing the package. Development builds are automatically selected when `NODE_ENV=development`.
|
|
192
261
|
|
|
262
|
+
Type declarations are available at `dist/index.d.ts`, and the package publishes the `src/` folder for source inspection.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Browser Compatibility
|
|
267
|
+
|
|
268
|
+
### Desktop
|
|
269
|
+
| Browser | Version | WebGL 2 | SharedArrayBuffer | Status |
|
|
270
|
+
|---------|---------|---------|-------------------|--------|
|
|
271
|
+
| Chrome | 80+ | ✓ | ✓ (with headers) | Fully Supported |
|
|
272
|
+
| Firefox | 75+ | ✓ | ✓ (with headers) | Fully Supported |
|
|
273
|
+
| Safari | 14+ | ✓ | ✓ (macOS 11.3+) | Fully Supported |
|
|
274
|
+
| Edge | 80+ | ✓ | ✓ (with headers) | Fully Supported |
|
|
275
|
+
|
|
276
|
+
### Mobile
|
|
277
|
+
| Browser | Version | Performance | Notes |
|
|
278
|
+
|---------|---------|-------------|-------|
|
|
279
|
+
| Safari iOS | 14.5+ | Good | Enable WebGL 2 in Settings |
|
|
280
|
+
| Chrome Android | 80+ | Good | May require reduced splat count |
|
|
281
|
+
| Samsung Internet | 13+ | Fair | Limited SharedArrayBuffer support |
|
|
282
|
+
|
|
283
|
+
**Known Limitations:**
|
|
284
|
+
- iOS Safari: WebGL context may be lost during backgrounding
|
|
285
|
+
- Android: Performance varies significantly by device
|
|
286
|
+
- Firefox Android: SharedArrayBuffer requires site isolation
|
|
193
287
|
---
|
|
194
288
|
|
|
195
|
-
##
|
|
289
|
+
## Deployment Requirements
|
|
290
|
+
|
|
291
|
+
### SharedArrayBuffer Configuration
|
|
196
292
|
|
|
197
|
-
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
-
|
|
293
|
+
This library uses WebAssembly with SharedArrayBuffer for high-performance splat sorting. To deploy in production, your server **must** send the following HTTP headers:
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
Cross-Origin-Embedder-Policy: require-corp
|
|
297
|
+
Cross-Origin-Opener-Policy: same-origin
|
|
298
|
+
```
|
|
201
299
|
|
|
202
|
-
|
|
300
|
+
Without these headers, SharedArrayBuffer will be disabled by the browser and the renderer will fail to initialize.
|
|
203
301
|
|
|
204
302
|
---
|
|
205
303
|
|