@myned-ai/gsplat-flame-avatar-renderer 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Myned AI
4
+ Copyright (c) 2024 Xiaodan Ye
5
+ Copyright (c) 2023 Mark Kellogg
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,268 @@
1
+ # gsplat-flame-avatar-renderer
2
+
3
+ [![npm version](https://img.shields.io/npm/v/gsplat-flame-avatar-renderer.svg)](https://www.npmjs.com/package/gsplat-flame-avatar-renderer)
4
+
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
+
7
+ ## Features
8
+
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
17
+
18
+ ---
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install gsplat-flame-avatar-renderer three jszip
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Quick Start
29
+
30
+ ```javascript
31
+ import { GaussianSplatRenderer } from 'gsplat-flame-avatar-renderer';
32
+
33
+ const container = document.getElementById('avatar-container');
34
+
35
+ const renderer = await GaussianSplatRenderer.getInstance(
36
+ container,
37
+ './path/to/avatar.zip',
38
+ {
39
+ backgroundColor: '0x000000',
40
+ getChatState: () => 'Idle',
41
+ getExpressionData: () => ({
42
+ jawOpen: 0.5,
43
+ mouthSmileLeft: 0.3,
44
+ mouthSmileRight: 0.3,
45
+ // ... other ARKit blendshapes
46
+ })
47
+ }
48
+ );
49
+ ```
50
+
51
+ ---
52
+
53
+ ## API Reference
54
+
55
+ ### GaussianSplatRenderer
56
+
57
+ The main class for rendering Gaussian splat avatars.
58
+
59
+ #### `GaussianSplatRenderer.getInstance(container, assetPath, options)`
60
+
61
+ Creates or returns a singleton renderer instance.
62
+
63
+ | Parameter | Type | Description |
64
+ |-----------|------|-------------|
65
+ | `container` | `HTMLDivElement` | Container element for the canvas |
66
+ | `assetPath` | `string` | Path to the ZIP file containing avatar assets |
67
+ | `options` | `object` | Configuration options |
68
+
69
+ **Options:**
70
+
71
+ | Option | Type | Description |
72
+ |--------|------|-------------|
73
+ | `backgroundColor` | `string` | Hex color string (e.g., '0x000000') |
74
+ | `getChatState` | `() => string` | Callback returning current animation state |
75
+ | `getExpressionData` | `() => object` | Callback returning blendshape weights |
76
+ | `loadProgress` | `(progress: number) => void` | Loading progress callback |
77
+ | `downloadProgress` | `(progress: number) => void` | Download progress callback |
78
+
79
+ ### Animation States
80
+
81
+ The renderer supports the following states via `getChatState`:
82
+
83
+ | State | Description |
84
+ |-------|-------------|
85
+ | `'Idle'` | Default idle animation |
86
+ | `'Listening'` | Listening state animation |
87
+ | `'Thinking'` | Processing/thinking animation |
88
+ | `'Responding'` | Speaking/responding animation |
89
+
90
+ ### ARKit Blendshapes (52)
91
+
92
+ ```
93
+ browDownLeft, browDownRight, browInnerUp, browOuterUpLeft, browOuterUpRight,
94
+ cheekPuff, cheekSquintLeft, cheekSquintRight, eyeBlinkLeft, eyeBlinkRight,
95
+ eyeLookDownLeft, eyeLookDownRight, eyeLookInLeft, eyeLookInRight, eyeLookOutLeft,
96
+ eyeLookOutRight, eyeLookUpLeft, eyeLookUpRight, eyeSquintLeft, eyeSquintRight,
97
+ eyeWideLeft, eyeWideRight, jawForward, jawLeft, jawOpen, jawRight,
98
+ mouthClose, mouthDimpleLeft, mouthDimpleRight, mouthFrownLeft, mouthFrownRight,
99
+ mouthFunnel, mouthLeft, mouthLowerDownLeft, mouthLowerDownRight, mouthPressLeft,
100
+ mouthPressRight, mouthPucker, mouthRight, mouthRollLower, mouthRollUpper,
101
+ mouthShrugLower, mouthShrugUpper, mouthSmileLeft, mouthSmileRight, mouthStretchLeft,
102
+ mouthStretchRight, mouthUpperUpLeft, mouthUpperUpRight, noseSneerLeft, noseSneerRight,
103
+ tongueOut
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Asset Format
109
+
110
+ The avatar ZIP file should contain:
111
+
112
+ ```
113
+ avatar.zip
114
+ ├── 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
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Architecture Overview
124
+
125
+ ### Rendering Pipeline
126
+
127
+ ```mermaid
128
+ flowchart LR
129
+ A[Loading<br/>PLY] --> B[Initialization<br/>Viewer]
130
+ B --> C[Scene Setup<br/>SplatMesh]
131
+ C --> D[Animation<br/>FLAME]
132
+ D --> E[Transform<br/>Update]
133
+ E --> F[Sorting<br/>WebAssembly]
134
+ F --> G[Drawing<br/>WebGL]
135
+ ```
136
+
137
+ 1. **Loading**: Assets fetched from ZIP, PLY parsed via INRIAV1PlyParser
138
+ 2. **Initialization**: Viewer creates WebGL context, materials, sort worker
139
+ 3. **Scene Setup**: SplatMesh uploads data to GPU textures
140
+ 4. **Animation**: FlameAnimator updates bone matrices, AnimationManager handles state transitions
141
+ 5. **Transform Update**: Scene transforms applied, camera matrices computed
142
+ 6. **Sorting**: WebAssembly radix sort produces depth-sorted indices
143
+ 7. **Drawing**: Instanced rendering of sorted splats with alpha blending
144
+
145
+ ### FLAME Integration
146
+
147
+ The library supports hybrid rendering where Gaussian Splat positions are deformed by FLAME's skeleton:
148
+
149
+ - **5 bones**: Root, Neck, Jaw, Left Eye, Right Eye
150
+ - **52 blendshapes**: Full ARKit compatibility for face tracking
151
+ - **LBS Skinning**: Splat positions transformed via bone matrices and blend weights
152
+ - **GPU-based**: All deformation computed in vertex shader via texture lookups
153
+
154
+ ---
155
+
156
+ ## Directory Structure
157
+
158
+ | Module | Files | Description |
159
+ |--------|-------|-------------|
160
+ | `src/api/` | 1 | Public API layer |
161
+ | `src/buffers/` | 5 | GPU buffer management (SplatBuffer, partitioning) |
162
+ | `src/core/` | 6 | Rendering engine (Viewer, SplatMesh, SplatTree) |
163
+ | `src/enums/` | 8 | Constants and enumerations |
164
+ | `src/flame/` | 5 | FLAME model integration (FlameAnimator, textures) |
165
+ | `src/loaders/` | 6 | PLY format loader (INRIA v1) |
166
+ | `src/materials/` | 4 | WebGL shaders (SplatMaterial2D/3D) |
167
+ | `src/raycaster/` | 4 | Intersection testing |
168
+ | `src/renderer/` | 4 | Application layer (GaussianSplatRenderer, AnimationManager) |
169
+ | `src/utils/` | 3 | Shared utilities |
170
+ | `src/worker/` | 2 | WebAssembly sorting worker |
171
+
172
+ ### Key Components
173
+
174
+ | Component | Purpose |
175
+ |-----------|---------|
176
+ | **GaussianSplatRenderer** | Main entry point, ZIP loading, render loop |
177
+ | **Viewer** | Scene management, camera, render pipeline |
178
+ | **SplatMesh** | GPU textures, instanced geometry |
179
+ | **FlameAnimator** | Bone rotations, blendshape weights |
180
+ | **FlameTextureManager** | GPU texture uploads for FLAME data |
181
+ | **AnimationManager** | State machine (Idle, Listen, Think, Speak) |
182
+ | **PlyLoader** | Loading PLY files from ZIP |
183
+ | **SortWorker** | WebAssembly depth sorting |
184
+
185
+ ---
186
+
187
+ ## Build Output
188
+
189
+ Rollup produces 4 bundles in `dist/`:
190
+
191
+ | File | Format |
192
+ |------|--------|
193
+ | `gsplat-flame-avatar.esm.js` | ES Module |
194
+ | `gsplat-flame-avatar.esm.min.js` | ES Module (minified) |
195
+ | `gsplat-flame-avatar.umd.js` | UMD |
196
+ | `gsplat-flame-avatar.umd.min.js` | UMD (minified) |
197
+
198
+ ---
199
+
200
+ ## Browser Support
201
+
202
+ - Chrome 80+
203
+ - Firefox 75+
204
+ - Safari 14+
205
+ - Edge 80+
206
+
207
+ **Requires WebGL 2.0 support.**
208
+
209
+ ---
210
+
211
+ ## Development
212
+
213
+ ```bash
214
+ # Clone the repo
215
+ git clone https://github.com/AntonisMakworimedia/gsplat-flame-avatar-renderer.git
216
+ cd gsplat-flame-avatar-renderer
217
+
218
+ # Install dependencies
219
+ npm install
220
+
221
+ # Start dev mode (watch for changes)
222
+ npm run dev
223
+
224
+ # Lint code
225
+ npm run lint
226
+
227
+ # Build for production
228
+ npm run build
229
+ ```
230
+
231
+ ### Publishing
232
+
233
+ ```bash
234
+ # Bump version and push tag (triggers CI publish)
235
+ npm version patch # or minor, major
236
+ git push --follow-tags
237
+ ```
238
+
239
+ ---
240
+
241
+ ## Credits & Attribution
242
+
243
+ This library is built upon the work of several open-source projects:
244
+
245
+ ### Three.js
246
+ **The foundation for all 3D rendering.**
247
+ - Website: https://threejs.org/
248
+ - License: MIT
249
+ - Used for: WebGL rendering, scene graph, cameras, materials, geometry, animation mixer
250
+
251
+ ### @mkkellogg/gaussian-splats-3d
252
+ **Base Gaussian Splat rendering engine.**
253
+ - Repository: https://github.com/mkkellogg/GaussianSplats3D
254
+ - Author: Mark Kellogg
255
+ - License: MIT
256
+ - Used for: Core splat rendering, buffers, loaders, raycaster, sorting worker, utilities
257
+
258
+ ### gaussian-splat-renderer-for-lam
259
+ **FLAME avatar extensions and high-level API.**
260
+ - npm package: https://www.npmjs.com/package/gaussian-splat-renderer-for-lam
261
+ - License: MIT
262
+ - Used for: FLAME model integration, animation state machine, FlameAnimator, FlameTextureManager, GPU skinning shaders
263
+
264
+ ### FLAME Model
265
+ **Parametric head model for facial animation.**
266
+ - Website: https://flame.is.tue.mpg.de/
267
+ - Institution: Max Planck Institute for Intelligent Systems
268
+ - Used for: 5-bone skeleton, 52 ARKit blendshapes, LBS skinning weights