@myned-ai/gsplat-flame-avatar-renderer 1.0.5 → 1.0.7

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.
Files changed (58) hide show
  1. package/README.md +160 -32
  2. package/dist/gsplat-flame-avatar-renderer.cjs.js +3510 -749
  3. package/dist/gsplat-flame-avatar-renderer.cjs.min.js +2 -0
  4. package/dist/gsplat-flame-avatar-renderer.cjs.min.js.map +1 -0
  5. package/dist/gsplat-flame-avatar-renderer.esm.js +3471 -751
  6. package/dist/gsplat-flame-avatar-renderer.esm.min.js +2 -0
  7. package/dist/gsplat-flame-avatar-renderer.esm.min.js.map +1 -0
  8. package/package.json +14 -7
  9. package/dist/gsplat-flame-avatar-renderer.cjs.js.map +0 -1
  10. package/dist/gsplat-flame-avatar-renderer.esm.js.map +0 -1
  11. package/src/api/index.js +0 -7
  12. package/src/buffers/SplatBuffer.js +0 -1394
  13. package/src/buffers/SplatBufferGenerator.js +0 -41
  14. package/src/buffers/SplatPartitioner.js +0 -110
  15. package/src/buffers/UncompressedSplatArray.js +0 -106
  16. package/src/buffers/index.js +0 -11
  17. package/src/core/SplatGeometry.js +0 -48
  18. package/src/core/SplatMesh.js +0 -2620
  19. package/src/core/SplatScene.js +0 -43
  20. package/src/core/SplatTree.js +0 -200
  21. package/src/core/Viewer.js +0 -2895
  22. package/src/core/index.js +0 -13
  23. package/src/enums/EngineConstants.js +0 -58
  24. package/src/enums/LogLevel.js +0 -13
  25. package/src/enums/RenderMode.js +0 -11
  26. package/src/enums/SceneFormat.js +0 -21
  27. package/src/enums/SceneRevealMode.js +0 -11
  28. package/src/enums/SplatRenderMode.js +0 -10
  29. package/src/enums/index.js +0 -13
  30. package/src/flame/FlameAnimator.js +0 -271
  31. package/src/flame/FlameConstants.js +0 -21
  32. package/src/flame/FlameTextureManager.js +0 -293
  33. package/src/flame/index.js +0 -22
  34. package/src/flame/utils.js +0 -50
  35. package/src/index.js +0 -39
  36. package/src/loaders/DirectLoadError.js +0 -14
  37. package/src/loaders/INRIAV1PlyParser.js +0 -223
  38. package/src/loaders/PlyLoader.js +0 -261
  39. package/src/loaders/PlyParser.js +0 -19
  40. package/src/loaders/PlyParserUtils.js +0 -311
  41. package/src/loaders/index.js +0 -13
  42. package/src/materials/SplatMaterial.js +0 -1065
  43. package/src/materials/SplatMaterial2D.js +0 -358
  44. package/src/materials/SplatMaterial3D.js +0 -278
  45. package/src/materials/index.js +0 -11
  46. package/src/raycaster/Hit.js +0 -37
  47. package/src/raycaster/Ray.js +0 -123
  48. package/src/raycaster/Raycaster.js +0 -175
  49. package/src/raycaster/index.js +0 -10
  50. package/src/renderer/AnimationManager.js +0 -574
  51. package/src/renderer/AppConstants.js +0 -101
  52. package/src/renderer/GaussianSplatRenderer.js +0 -695
  53. package/src/renderer/index.js +0 -24
  54. package/src/utils/LoaderUtils.js +0 -65
  55. package/src/utils/Util.js +0 -375
  56. package/src/utils/index.js +0 -9
  57. package/src/worker/SortWorker.js +0 -284
  58. package/src/worker/index.js +0 -8
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
- - 🎭 **52 ARKit Blendshapes** — Complete facial expression control
10
- - 🔥 **FLAME Model Support** — Full integration with FLAME parametric head model
11
- - 🎮 **Animation State Machine** — Built-in states (Idle, Listening, Thinking, Responding)
12
- - **GPU Optimized** — WebGL-based rendering with WebAssembly sorting
13
- - 🎯 **Three.js Integration** — Works seamlessly with Three.js r150+
14
- - 🧠 **LAM Head Avatars** — Support for Large Avatar Model based head avatars
15
- - 📦 **ZIP Asset Loading** — Load compressed avatar assets directly
16
- - 🔄 **Real-time Animation** — Smooth blendshape interpolation at 30fps
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
- const renderer = await GaussianSplatRenderer.getInstance(
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.getInstance(container, assetPath, options)`
66
+ #### `GaussianSplatRenderer.create(container, assetPath, options)`
60
67
 
61
- Creates or returns a singleton renderer instance.
68
+ Creates a new renderer instance with proper resource isolation.
62
69
 
63
70
  | Parameter | Type | Description |
64
71
  |-----------|------|-------------|
@@ -76,6 +83,65 @@ 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
+ **Advanced Options:**
87
+
88
+ Additional options for customizing avatar appearance and rendering:
89
+
90
+ **Scene Reveal & Fade-In**
91
+
92
+ | Option | Type | Default | Description |
93
+ |--------|------|---------|-------------|
94
+ | `sceneRevealMode` | `number` | `0` (Default) | Controls how avatar appears: `0` = Default (fast for final, slow for progressive), `1` = Gradual (slow fade-in), `2` = Instant (immediate) |
95
+ | `sceneFadeInRateMultiplier` | `number` | `1.0` | Speed multiplier for fade-in effect. Higher = faster appearance |
96
+
97
+ **Camera & View Settings**
98
+
99
+ | Option | Type | Default | Description |
100
+ |--------|------|---------|-------------|
101
+ | `initialCameraPosition` | `Array<number>` | `[0, 10, 15]` | Starting camera position [x, y, z] |
102
+ | `initialCameraRotation` | `Array<number>` | `[0, 0, 0]` | Starting camera rotation [x, y, z] in radians |
103
+ | `initialCameraLookAt` | `Array<number>` | `[0, 0, 0]` | Camera focal point [x, y, z] |
104
+ | `cameraUp` | `Array<number>` | `[0, 1, 0]` | Camera up vector [x, y, z] |
105
+
106
+ **Rendering Quality**
107
+
108
+ | Option | Type | Default | Description |
109
+ |--------|------|---------|-------------|
110
+ | `antialiased` | `boolean` | `false` | Enable anti-aliasing to reduce artifacts at different resolutions |
111
+ | `kernel2DSize` | `number` | `0.3` | Constant added to projected 2D splat scales (affects splat smoothness) |
112
+ | `maxScreenSpaceSplatSize` | `number` | `1024` | Maximum screen-space splat size in pixels |
113
+ | `halfPrecisionCovariancesOnGPU` | `boolean` | `false` | Use 16-bit float for GPU covariances (better performance, slight quality loss) |
114
+ | `ignoreDevicePixelRatio` | `boolean` | `false` | Force device pixel ratio to 1 for better performance on high-DPI displays |
115
+
116
+ #### `renderer.dispose()`
117
+
118
+ 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.
119
+
120
+ ```javascript
121
+ // Clean up when done
122
+ renderer.dispose();
123
+ ```
124
+
125
+ #### Migration from v1.0.5
126
+
127
+ If you're upgrading from v1.0.5 or earlier:
128
+
129
+ ```javascript
130
+ // OLD (still works but deprecated)
131
+ const renderer = await GaussianSplatRenderer.getInstance(container, path, options);
132
+
133
+ // NEW (recommended)
134
+ const renderer = await GaussianSplatRenderer.create(container, path, options);
135
+ // ... use renderer ...
136
+ renderer.dispose(); // Don't forget!
137
+ ```
138
+
139
+ **Key Changes:**
140
+ - Each `create()` call returns a **new independent instance** (no longer a singleton)
141
+ - You can now have **multiple renderers** on the same page
142
+ - Each instance has its own canvas element
143
+ - **Must call `dispose()`** when finished to clean up resources
144
+
79
145
  ### Animation States
80
146
 
81
147
  The renderer supports the following states via `getChatState`:
@@ -112,12 +178,36 @@ The avatar ZIP file should contain:
112
178
  ```
113
179
  avatar.zip
114
180
  ├── avatar/
115
- │ ├── offset.ply # Gaussian splat point cloud
116
- │ ├── animation.glb # Animation clips
117
- │ ├── skin.glb # Skinning/skeleton data
118
- └── vertex_order.json # Vertex ordering data
181
+ │ ├── offset.ply # Gaussian splats point cloud (required)
182
+ │ ├── animation.glb # Animation clips (required)
183
+ │ ├── skin.glb # Skinning/skeleton data (required)
184
+ ├── vertex_order.json # Vertex ordering data (required)
185
+ │ └── iris_occlusion.json # Iris occlusion ranges (optional)
186
+ ```
187
+
188
+ ### Optional: Iris Occlusion
189
+
190
+ 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.
191
+
192
+ An example of `iris_occlusion.json` :
193
+
194
+ ```json
195
+ {
196
+ "right_iris": [
197
+ [4000, 4100],
198
+ [3930, 3970]
199
+ ],
200
+ "left_iris": [
201
+ [4470, 4605],
202
+ [18370, 18799]
203
+ ]
204
+ }
119
205
  ```
120
206
 
207
+ 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.
208
+
209
+ If `iris_occlusion.json` is not present, the renderer will work normally without iris occlusion.
210
+
121
211
  ---
122
212
 
123
213
  ## Architecture Overview
@@ -145,6 +235,7 @@ The library supports hybrid rendering where Gaussian Splat positions are deforme
145
235
  - **52 blendshapes**: Full ARKit compatibility for face tracking
146
236
  - **LBS Skinning**: Splat positions transformed via bone matrices and blend weights
147
237
  - **GPU-based**: All deformation computed in vertex shader via texture lookups
238
+ - **Iris Occlusion**: Optional dynamic iris fade during eye blinks (configured per-avatar via JSON)
148
239
 
149
240
  ---
150
241
 
@@ -156,50 +247,87 @@ The library supports hybrid rendering where Gaussian Splat positions are deforme
156
247
  | `src/buffers/` | 5 | GPU buffer management (SplatBuffer, partitioning) |
157
248
  | `src/core/` | 6 | Rendering engine (Viewer, SplatMesh, SplatTree) |
158
249
  | `src/enums/` | 8 | Constants and enumerations |
250
+ | `src/errors/` | 1 | Custom error classes (ValidationError, NetworkError, ParseError, etc.) |
159
251
  | `src/flame/` | 5 | FLAME model integration (FlameAnimator, textures) |
160
252
  | `src/loaders/` | 6 | PLY format loader (INRIA v1) |
161
- | `src/materials/` | 4 | WebGL shaders (SplatMaterial2D/3D) |
253
+ | `src/materials/` | 4 | WebGL shaders (SplatMaterial2D/3D, conditional iris occlusion) |
162
254
  | `src/raycaster/` | 4 | Intersection testing |
163
255
  | `src/renderer/` | 4 | Application layer (GaussianSplatRenderer, AnimationManager) |
164
- | `src/utils/` | 3 | Shared utilities |
256
+ | `src/utils/` | 8 | Shared utilities (validation, logging, object pooling, blob management) |
165
257
  | `src/worker/` | 2 | WebAssembly sorting worker |
166
258
 
167
259
  ### Key Components
168
260
 
169
261
  | Component | Purpose |
170
262
  |-----------|---------|
171
- | **GaussianSplatRenderer** | Main entry point, ZIP loading, render loop |
263
+ | **GaussianSplatRenderer** | Main entry point, ZIP loading, render loop, asset management |
172
264
  | **Viewer** | Scene management, camera, render pipeline |
173
- | **SplatMesh** | GPU textures, instanced geometry |
265
+ | **SplatMesh** | GPU textures, instanced geometry, iris config forwarding |
266
+ | **SplatMaterial3D** | WebGL shader generation, conditional iris occlusion code |
174
267
  | **FlameAnimator** | Bone rotations, blendshape weights |
175
268
  | **FlameTextureManager** | GPU texture uploads for FLAME data |
176
269
  | **AnimationManager** | State machine (Idle, Listen, Think, Speak) |
177
- | **PlyLoader** | Loading PLY files from ZIP |
270
+ | **PlyLoader** | Loading PLY files from ZIP with validation |
178
271
  | **SortWorker** | WebAssembly depth sorting |
272
+ | **ValidationUtils** | Input validation (URLs, paths, ranges, types) |
273
+ | **Logger** | Structured logging system |
274
+ | **ObjectPool** | Object pooling for performance (Vector3, Quaternion) |
275
+ | **BlobUrlManager** | Blob URL lifecycle management |
179
276
 
180
277
  ---
181
278
 
182
279
  ## Build Output
183
280
 
184
- Rollup produces ESM and CommonJS bundles in `dist/`:
281
+ Rollup produces optimized ESM and CommonJS bundles in `dist/`:
282
+
283
+ | File | Size | Format | Source Maps |
284
+ |------|------|--------|-------------|
285
+ | `gsplat-flame-avatar-renderer.esm.min.js`| 244 KB | ES Module (production, minified) | External (.map) |
286
+ | `gsplat-flame-avatar-renderer.cjs.min.js`| 246 KB | CommonJS (production, minified) | External (.map) |
287
+ | `gsplat-flame-avatar-renderer.esm.js` | 2.1 MB | ES Module (development, unminified) | Inline |
288
+ | `gsplat-flame-avatar-renderer.cjs.js` | 2.1 MB | CommonJS (development, unminified) | Inline |
185
289
 
186
- | File | Format |
187
- |------|--------|
188
- | `gsplat-flame-avatar-renderer.esm.js` | ES Module (ESM) — for modern bundlers and browsers |
189
- | `gsplat-flame-avatar-renderer.cjs.js` | CommonJS (CJS) — for Node `require()` consumers |
290
+ ** The minified builds are used by default** when importing the package. Development builds are automatically selected when `NODE_ENV=development`.
190
291
 
191
- Builds include inline source maps. Type declarations are available at `dist/index.d.ts`, and the package publishes the `src/` folder for source inspection.
292
+ Type declarations are available at `dist/index.d.ts`, and the package publishes the `src/` folder for source inspection.
293
+
294
+ ---
192
295
 
296
+ ## Browser Compatibility
297
+
298
+ ### Desktop
299
+ | Browser | Version | WebGL 2 | SharedArrayBuffer | Status |
300
+ |---------|---------|---------|-------------------|--------|
301
+ | Chrome | 80+ | ✓ | ✓ (with headers) | Fully Supported |
302
+ | Firefox | 75+ | ✓ | ✓ (with headers) | Fully Supported |
303
+ | Safari | 14+ | ✓ | ✓ (macOS 11.3+) | Fully Supported |
304
+ | Edge | 80+ | ✓ | ✓ (with headers) | Fully Supported |
305
+
306
+ ### Mobile
307
+ | Browser | Version | Performance | Notes |
308
+ |---------|---------|-------------|-------|
309
+ | Safari iOS | 14.5+ | Good | Enable WebGL 2 in Settings |
310
+ | Chrome Android | 80+ | Good | May require reduced splat count |
311
+ | Samsung Internet | 13+ | Fair | Limited SharedArrayBuffer support |
312
+
313
+ **Known Limitations:**
314
+ - iOS Safari: WebGL context may be lost during backgrounding
315
+ - Android: Performance varies significantly by device
316
+ - Firefox Android: SharedArrayBuffer requires site isolation
193
317
  ---
194
318
 
195
- ## Browser Support
319
+ ## Deployment Requirements
196
320
 
197
- - Chrome 80+
198
- - Firefox 75+
199
- - Safari 14+
200
- - Edge 80+
321
+ ### SharedArrayBuffer Configuration
322
+
323
+ This library uses WebAssembly with SharedArrayBuffer for high-performance splat sorting. To deploy in production, your server **must** send the following HTTP headers:
324
+
325
+ ```
326
+ Cross-Origin-Embedder-Policy: require-corp
327
+ Cross-Origin-Opener-Policy: same-origin
328
+ ```
201
329
 
202
- **Requires WebGL 2.0 support.**
330
+ Without these headers, SharedArrayBuffer will be disabled by the browser and the renderer will fail to initialize.
203
331
 
204
332
  ---
205
333