@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 +23 -0
- package/README.md +268 -0
- package/dist/gsplat-flame-avatar-renderer.esm.js +12755 -0
- package/dist/gsplat-flame-avatar-renderer.esm.js.map +1 -0
- package/dist/gsplat-flame-avatar-renderer.esm.min.js +2 -0
- package/dist/gsplat-flame-avatar-renderer.esm.min.js.map +1 -0
- package/dist/gsplat-flame-avatar-renderer.umd.js +12876 -0
- package/dist/gsplat-flame-avatar-renderer.umd.js.map +1 -0
- package/dist/gsplat-flame-avatar-renderer.umd.min.js +2 -0
- package/dist/gsplat-flame-avatar-renderer.umd.min.js.map +1 -0
- package/dist/gsplat-flame-avatar.esm.js +12755 -0
- package/dist/gsplat-flame-avatar.esm.js.map +1 -0
- package/dist/gsplat-flame-avatar.esm.min.js +2 -0
- package/dist/gsplat-flame-avatar.esm.min.js.map +1 -0
- package/dist/gsplat-flame-avatar.umd.js +12876 -0
- package/dist/gsplat-flame-avatar.umd.js.map +1 -0
- package/dist/gsplat-flame-avatar.umd.min.js +2 -0
- package/dist/gsplat-flame-avatar.umd.min.js.map +1 -0
- package/dist/index.d.ts +349 -0
- package/package.json +66 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { Camera, Scene, WebGLRenderer, AnimationMixer, Clock, Vector3 } from 'three';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Voice chat state enum
|
|
5
|
+
*/
|
|
6
|
+
export enum TYVoiceChatState {
|
|
7
|
+
Idle = 'Idle',
|
|
8
|
+
Hello = 'Hello',
|
|
9
|
+
Listening = 'Listening',
|
|
10
|
+
Thinking = 'Thinking',
|
|
11
|
+
Responding = 'Responding'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Scene format enum
|
|
16
|
+
*/
|
|
17
|
+
export enum SceneFormat {
|
|
18
|
+
Ply = 0,
|
|
19
|
+
Splat = 1,
|
|
20
|
+
KSplat = 2
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Render mode enum
|
|
25
|
+
*/
|
|
26
|
+
export enum RenderMode {
|
|
27
|
+
Always = 0,
|
|
28
|
+
OnChange = 1,
|
|
29
|
+
Never = 2
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Log level enum
|
|
34
|
+
*/
|
|
35
|
+
export enum LogLevel {
|
|
36
|
+
None = 0,
|
|
37
|
+
Info = 1,
|
|
38
|
+
Warning = 2,
|
|
39
|
+
Error = 3,
|
|
40
|
+
Debug = 4
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Scene reveal mode enum
|
|
45
|
+
*/
|
|
46
|
+
export enum SceneRevealMode {
|
|
47
|
+
Default = 0,
|
|
48
|
+
Gradual = 1,
|
|
49
|
+
Instant = 2
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Splat render mode enum
|
|
54
|
+
*/
|
|
55
|
+
export enum SplatRenderMode {
|
|
56
|
+
Default = 0,
|
|
57
|
+
TwoD = 1
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* WebXR mode enum
|
|
62
|
+
*/
|
|
63
|
+
export enum WebXRMode {
|
|
64
|
+
None = 0,
|
|
65
|
+
VR = 1,
|
|
66
|
+
AR = 2
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Options for getInstance
|
|
71
|
+
*/
|
|
72
|
+
export interface GaussianSplatRendererOptions {
|
|
73
|
+
getChatState?: () => TYVoiceChatState | string;
|
|
74
|
+
getExpressionData?: () => Record<string, number>;
|
|
75
|
+
loadProgress?: (progress: number) => void;
|
|
76
|
+
downloadProgress?: (progress: number) => void;
|
|
77
|
+
backgroundColor?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Viewer options
|
|
82
|
+
*/
|
|
83
|
+
export interface ViewerOptions {
|
|
84
|
+
rootElement?: HTMLElement;
|
|
85
|
+
threejsCanvas?: HTMLCanvasElement;
|
|
86
|
+
cameraUp?: [number, number, number];
|
|
87
|
+
initialCameraPosition?: [number, number, number];
|
|
88
|
+
initialCameraRotation?: [number, number, number];
|
|
89
|
+
sphericalHarmonicsDegree?: number;
|
|
90
|
+
backgroundColor?: number;
|
|
91
|
+
selfDrivenMode?: boolean;
|
|
92
|
+
useBuiltInControls?: boolean;
|
|
93
|
+
ignoreDevicePixelRatio?: boolean;
|
|
94
|
+
halfPrecisionCovariancesOnGPU?: boolean;
|
|
95
|
+
antialiased?: boolean;
|
|
96
|
+
focalAdjustment?: number;
|
|
97
|
+
logLevel?: LogLevel;
|
|
98
|
+
webXRMode?: WebXRMode;
|
|
99
|
+
renderMode?: RenderMode;
|
|
100
|
+
sceneRevealMode?: SceneRevealMode;
|
|
101
|
+
splatRenderMode?: SplatRenderMode;
|
|
102
|
+
dynamicScene?: boolean;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Splat scene options
|
|
107
|
+
*/
|
|
108
|
+
export interface SplatSceneOptions {
|
|
109
|
+
progressiveLoad?: boolean;
|
|
110
|
+
sharedMemoryForWorkers?: boolean;
|
|
111
|
+
showLoadingUI?: boolean;
|
|
112
|
+
format?: SceneFormat;
|
|
113
|
+
splatAlphaRemovalThreshold?: number;
|
|
114
|
+
position?: [number, number, number];
|
|
115
|
+
rotation?: [number, number, number, number];
|
|
116
|
+
scale?: [number, number, number];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Main GaussianSplatRenderer class
|
|
121
|
+
*/
|
|
122
|
+
export class GaussianSplatRenderer {
|
|
123
|
+
static _canvas: HTMLCanvasElement;
|
|
124
|
+
static instance: GaussianSplatRenderer | undefined;
|
|
125
|
+
|
|
126
|
+
viewer: Viewer;
|
|
127
|
+
zipUrls: {
|
|
128
|
+
urls: Map<string, string>;
|
|
129
|
+
zip?: any;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Get or create a GaussianSplatRenderer instance
|
|
134
|
+
*/
|
|
135
|
+
static getInstance(
|
|
136
|
+
container: HTMLDivElement,
|
|
137
|
+
assetPath: string,
|
|
138
|
+
options?: GaussianSplatRendererOptions
|
|
139
|
+
): Promise<GaussianSplatRenderer>;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Dispose the renderer and release resources
|
|
143
|
+
*/
|
|
144
|
+
dispose(): void;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Dispose just the model
|
|
148
|
+
*/
|
|
149
|
+
disposeModel(): void;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get the camera
|
|
153
|
+
*/
|
|
154
|
+
getCamera(): Camera | undefined;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Start the render loop
|
|
158
|
+
*/
|
|
159
|
+
render(): void;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Set expression weights
|
|
163
|
+
*/
|
|
164
|
+
setExpression(): void;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Load a FLAME model
|
|
168
|
+
*/
|
|
169
|
+
loadFlameModel(fileName: string, motionConfig: any): Promise<void>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Load a non-FLAME model
|
|
173
|
+
*/
|
|
174
|
+
loadModel(fileName: string, animationConfig: any, motionConfig: any): Promise<void>;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Viewer class for rendering Gaussian splats
|
|
179
|
+
*/
|
|
180
|
+
export class Viewer {
|
|
181
|
+
camera: Camera;
|
|
182
|
+
renderer: WebGLRenderer;
|
|
183
|
+
scene: Scene;
|
|
184
|
+
splatMesh: SplatMesh;
|
|
185
|
+
selfDrivenMode: boolean;
|
|
186
|
+
selfDrivenModeRunning: boolean;
|
|
187
|
+
webXRMode: WebXRMode;
|
|
188
|
+
renderMode: RenderMode;
|
|
189
|
+
frame: number;
|
|
190
|
+
totalFrames: number;
|
|
191
|
+
useFlame: boolean;
|
|
192
|
+
avatarMesh: any;
|
|
193
|
+
splatRenderReady: boolean;
|
|
194
|
+
consecutiveRenderFrames: number;
|
|
195
|
+
renderNextFrame: boolean;
|
|
196
|
+
requestFrameId: number;
|
|
197
|
+
selfDrivenUpdateFunc: () => void;
|
|
198
|
+
|
|
199
|
+
constructor(options?: ViewerOptions);
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Add a splat scene to the viewer
|
|
203
|
+
*/
|
|
204
|
+
addSplatScene(
|
|
205
|
+
path: string,
|
|
206
|
+
options?: SplatSceneOptions
|
|
207
|
+
): Promise<void>;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Update the viewer
|
|
211
|
+
*/
|
|
212
|
+
update(renderer: WebGLRenderer, camera: Camera): void;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Check if should render
|
|
216
|
+
*/
|
|
217
|
+
shouldRender(): boolean;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Render the scene
|
|
221
|
+
*/
|
|
222
|
+
render(): void;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Dispose the viewer
|
|
226
|
+
*/
|
|
227
|
+
dispose(): void;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Start self-driven mode
|
|
231
|
+
*/
|
|
232
|
+
start(): void;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Stop self-driven mode
|
|
236
|
+
*/
|
|
237
|
+
stop(): void;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Force render next frame
|
|
241
|
+
*/
|
|
242
|
+
forceRenderNextFrame(): void;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* SplatMesh class
|
|
247
|
+
*/
|
|
248
|
+
export class SplatMesh {
|
|
249
|
+
bsWeight: Record<string, number> | number[];
|
|
250
|
+
visibleRegionChanging: boolean;
|
|
251
|
+
|
|
252
|
+
getMaxSplatCount(): number;
|
|
253
|
+
getSplatCount(): number;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Animation manager for state-based animations
|
|
258
|
+
*/
|
|
259
|
+
export class AnimationManager {
|
|
260
|
+
constructor(mixer: AnimationMixer, clips: any[]);
|
|
261
|
+
|
|
262
|
+
update(state: TYVoiceChatState | string): void;
|
|
263
|
+
dispose(): void;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Drop-in viewer for simple integration
|
|
268
|
+
*/
|
|
269
|
+
export class DropInViewer {
|
|
270
|
+
constructor(options?: ViewerOptions);
|
|
271
|
+
|
|
272
|
+
addSplatScene(path: string, options?: SplatSceneOptions): Promise<void>;
|
|
273
|
+
dispose(): void;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Orbit controls for camera manipulation
|
|
278
|
+
*/
|
|
279
|
+
export class OrbitControls {
|
|
280
|
+
constructor(camera: Camera, domElement: HTMLElement);
|
|
281
|
+
|
|
282
|
+
update(): void;
|
|
283
|
+
dispose(): void;
|
|
284
|
+
enabled: boolean;
|
|
285
|
+
enableDamping: boolean;
|
|
286
|
+
dampingFactor: number;
|
|
287
|
+
enableZoom: boolean;
|
|
288
|
+
enableRotate: boolean;
|
|
289
|
+
enablePan: boolean;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Splat buffer class
|
|
294
|
+
*/
|
|
295
|
+
export class SplatBuffer {
|
|
296
|
+
static CenterComponentCount: number;
|
|
297
|
+
static ScaleComponentCount: number;
|
|
298
|
+
static RotationComponentCount: number;
|
|
299
|
+
static ColorComponentCount: number;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Splat buffer generator
|
|
304
|
+
*/
|
|
305
|
+
export class SplatBufferGenerator {
|
|
306
|
+
static getStandardSections(compressionLevel: number): any;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Splat partitioner
|
|
311
|
+
*/
|
|
312
|
+
export class SplatPartitioner {
|
|
313
|
+
static partitionIntoSections(splats: any[], sectionCapacity: number): any[];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* PLY loader
|
|
318
|
+
*/
|
|
319
|
+
export class PlyLoader {
|
|
320
|
+
static loadFromURL(url: string, onProgress?: (progress: number) => void): Promise<ArrayBuffer>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* PLY parser
|
|
325
|
+
*/
|
|
326
|
+
export class PlyParser {
|
|
327
|
+
static parseToUncompressedSplatArray(data: ArrayBuffer): any;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* KSplat loader
|
|
332
|
+
*/
|
|
333
|
+
export class KSplatLoader {
|
|
334
|
+
static loadFromURL(url: string, onProgress?: (progress: number) => void): Promise<ArrayBuffer>;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Utility functions
|
|
339
|
+
*/
|
|
340
|
+
export const LoaderUtils: {
|
|
341
|
+
downloadFile(url: string, onProgress?: (progress: number) => void): Promise<ArrayBuffer>;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Abortable promise utility
|
|
346
|
+
*/
|
|
347
|
+
export class AbortablePromise<T> extends Promise<T> {
|
|
348
|
+
abort(): void;
|
|
349
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@myned-ai/gsplat-flame-avatar-renderer",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "FLAME-enabled Gaussian Splatting library for animated avatars with ARKit blendshape support",
|
|
5
|
+
"main": "dist/gsplat-flame-avatar-renderer.umd.js",
|
|
6
|
+
"module": "dist/gsplat-flame-avatar-renderer.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/gsplat-flame-avatar-renderer.esm.js",
|
|
12
|
+
"require": "./dist/gsplat-flame-avatar-renderer.umd.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "rollup -c",
|
|
18
|
+
"dev": "rollup -c -w",
|
|
19
|
+
"lint": "eslint src/",
|
|
20
|
+
"prepublishOnly": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"gaussian-splatting",
|
|
24
|
+
"3d-gaussian-splatting",
|
|
25
|
+
"flame",
|
|
26
|
+
"avatar",
|
|
27
|
+
"animation",
|
|
28
|
+
"webgl",
|
|
29
|
+
"threejs",
|
|
30
|
+
"arkit",
|
|
31
|
+
"blendshapes",
|
|
32
|
+
"facial-animation",
|
|
33
|
+
"3d-avatar"
|
|
34
|
+
],
|
|
35
|
+
"author": "Myned AI",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"jszip": "^3.10.1"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"three": ">=0.150.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@eslint/js": "^9.39.2",
|
|
45
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
46
|
+
"eslint": "^9.39.2",
|
|
47
|
+
"rollup": "^4.0.0"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist/",
|
|
51
|
+
"README.md",
|
|
52
|
+
"LICENSE"
|
|
53
|
+
],
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "git+https://github.com/myned-ai/gsplat-flame-avatar.git"
|
|
57
|
+
},
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/myned-ai/gsplat-flame-avatar/issues"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/myned-ai/gsplat-flame-avatar#readme",
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=16.0.0"
|
|
64
|
+
},
|
|
65
|
+
"sideEffects": false
|
|
66
|
+
}
|