@myned-ai/gsplat-flame-avatar-renderer 1.0.6 → 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 (64) hide show
  1. package/README.md +30 -0
  2. package/dist/gsplat-flame-avatar-renderer.cjs.js +38 -33
  3. package/dist/gsplat-flame-avatar-renderer.cjs.min.js +1 -1
  4. package/dist/gsplat-flame-avatar-renderer.cjs.min.js.map +1 -1
  5. package/dist/gsplat-flame-avatar-renderer.esm.js +38 -33
  6. package/dist/gsplat-flame-avatar-renderer.esm.min.js +1 -1
  7. package/dist/gsplat-flame-avatar-renderer.esm.min.js.map +1 -1
  8. package/package.json +5 -2
  9. package/src/api/index.js +0 -7
  10. package/src/buffers/SplatBuffer.js +0 -1394
  11. package/src/buffers/SplatBufferGenerator.js +0 -41
  12. package/src/buffers/SplatPartitioner.js +0 -110
  13. package/src/buffers/UncompressedSplatArray.js +0 -106
  14. package/src/buffers/index.js +0 -11
  15. package/src/core/SplatGeometry.js +0 -48
  16. package/src/core/SplatMesh.js +0 -2627
  17. package/src/core/SplatScene.js +0 -43
  18. package/src/core/SplatTree.js +0 -200
  19. package/src/core/Viewer.js +0 -2746
  20. package/src/core/index.js +0 -13
  21. package/src/enums/EngineConstants.js +0 -58
  22. package/src/enums/LogLevel.js +0 -13
  23. package/src/enums/RenderMode.js +0 -11
  24. package/src/enums/SceneFormat.js +0 -21
  25. package/src/enums/SceneRevealMode.js +0 -11
  26. package/src/enums/SplatRenderMode.js +0 -10
  27. package/src/enums/index.js +0 -13
  28. package/src/errors/ApplicationError.js +0 -185
  29. package/src/errors/index.js +0 -17
  30. package/src/flame/FlameAnimator.js +0 -496
  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 -519
  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 -1068
  43. package/src/materials/SplatMaterial2D.js +0 -358
  44. package/src/materials/SplatMaterial3D.js +0 -323
  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 -577
  51. package/src/renderer/AppConstants.js +0 -101
  52. package/src/renderer/GaussianSplatRenderer.js +0 -1146
  53. package/src/renderer/index.js +0 -24
  54. package/src/utils/BlobUrlManager.js +0 -294
  55. package/src/utils/EventEmitter.js +0 -349
  56. package/src/utils/LoaderUtils.js +0 -66
  57. package/src/utils/Logger.js +0 -171
  58. package/src/utils/ObjectPool.js +0 -248
  59. package/src/utils/RenderLoop.js +0 -306
  60. package/src/utils/Util.js +0 -416
  61. package/src/utils/ValidationUtils.js +0 -331
  62. package/src/utils/index.js +0 -18
  63. package/src/worker/SortWorker.js +0 -284
  64. package/src/worker/index.js +0 -8
@@ -1,66 +0,0 @@
1
- /**
2
- * LoaderUtils
3
- *
4
- * Derived from @mkkellogg/gaussian-splats-3d (MIT License)
5
- * https://github.com/mkkellogg/GaussianSplats3D
6
- *
7
- * Loader utilities for decoding text and resolving URLs.
8
- */
9
-
10
- export class LoaderUtils {
11
-
12
- /**
13
- * @deprecated Use TextDecoder instead
14
- */
15
- static decodeText(array) {
16
- if (typeof TextDecoder !== 'undefined') {
17
- return new TextDecoder().decode(array);
18
- }
19
-
20
- // Fallback for environments without TextDecoder
21
- let s = '';
22
-
23
- for (let i = 0, il = array.length; i < il; i++) {
24
- // Implicitly assumes little-endian.
25
- s += String.fromCharCode(array[i]);
26
- }
27
-
28
- try {
29
- // merges multi-byte utf-8 characters.
30
- return decodeURIComponent(escape(s));
31
- } catch {
32
- // see #16358 - ignore decoding errors
33
- return s;
34
- }
35
- }
36
-
37
- static extractUrlBase(url) {
38
- const index = url.lastIndexOf('/');
39
-
40
- if (index === -1) return './';
41
-
42
- return url.slice(0, index + 1);
43
- }
44
-
45
- static resolveURL(url, path) {
46
- // Invalid URL
47
- if (typeof url !== 'string' || url === '') return '';
48
-
49
- // Host Relative URL
50
- if (/^https?:\/\//i.test(path) && /^\//.test(url)) {
51
- path = path.replace(/(^https?:\/\/[^/]+).*/i, '$1');
52
- }
53
-
54
- // Absolute URL http://,https://,//
55
- if (/^(https?:)?\/\//i.test(url)) return url;
56
-
57
- // Data URI
58
- if (/^data:.*,.*$/i.test(url)) return url;
59
-
60
- // Blob URL
61
- if (/^blob:.*$/i.test(url)) return url;
62
-
63
- // Relative URL
64
- return path + url;
65
- }
66
- }
@@ -1,171 +0,0 @@
1
- /**
2
- * Logger - Structured logging system
3
- *
4
- * Provides leveled logging with optional output suppression for production.
5
- * Replaces direct console.log calls for better control and debugging.
6
- */
7
-
8
- /**
9
- * Logger levels in order of severity
10
- * Note: Named LoggerLevel to avoid conflict with existing LogLevel enum
11
- */
12
- export const LoggerLevel = Object.freeze({
13
- DEBUG: 0,
14
- INFO: 1,
15
- WARN: 2,
16
- ERROR: 3,
17
- NONE: 4
18
- });
19
-
20
- /**
21
- * Logger class for structured application logging
22
- */
23
- export class Logger {
24
- /**
25
- * Create a Logger instance
26
- * @param {string} namespace - Logger namespace (e.g., 'Renderer', 'Loader')
27
- * @param {number} [minLevel=LoggerLevel.INFO] - Minimum log level to output
28
- */
29
- constructor(namespace, minLevel = LoggerLevel.INFO) {
30
- this.namespace = namespace;
31
- this.minLevel = minLevel;
32
- }
33
-
34
- /**
35
- * Set minimum log level
36
- * @param {number} level - Minimum level from LoggerLevel enum
37
- */
38
- setLevel(level) {
39
- this.minLevel = level;
40
- }
41
-
42
- /**
43
- * Format log message with namespace and timestamp
44
- * @private
45
- * @param {string} level - Log level name
46
- * @param {Array} args - Log arguments
47
- * @returns {Array} Formatted arguments
48
- */
49
- _format(level, args) {
50
- const timestamp = new Date().toISOString();
51
- const prefix = `[${timestamp}] [${level}] [${this.namespace}]`;
52
- return [prefix, ...args];
53
- }
54
-
55
- /**
56
- * Log debug message (most verbose)
57
- * @param {...*} args - Arguments to log
58
- */
59
- debug(...args) {
60
- if (this.minLevel <= LoggerLevel.DEBUG) {
61
- console.debug(...this._format('DEBUG', args));
62
- }
63
- }
64
-
65
- /**
66
- * Log info message
67
- * @param {...*} args - Arguments to log
68
- */
69
- info(...args) {
70
- if (this.minLevel <= LoggerLevel.INFO) {
71
- console.info(...this._format('INFO', args));
72
- }
73
- }
74
-
75
- /**
76
- * Log warning message
77
- * @param {...*} args - Arguments to log
78
- */
79
- warn(...args) {
80
- if (this.minLevel <= LoggerLevel.WARN) {
81
- console.warn(...this._format('WARN', args));
82
- }
83
- }
84
-
85
- /**
86
- * Log error message
87
- * @param {...*} args - Arguments to log
88
- */
89
- error(...args) {
90
- if (this.minLevel <= LoggerLevel.ERROR) {
91
- console.error(...this._format('ERROR', args));
92
- }
93
- }
94
-
95
- /**
96
- * Log error with stack trace
97
- * @param {Error} error - Error object
98
- * @param {string} [context] - Additional context
99
- */
100
- errorWithTrace(error, context = '') {
101
- if (this.minLevel <= LoggerLevel.ERROR) {
102
- const contextStr = context ? ` Context: ${context}` : '';
103
- console.error(...this._format('ERROR', [
104
- `${error.message}${contextStr}`,
105
- '\nStack:', error.stack
106
- ]));
107
- }
108
- }
109
-
110
- /**
111
- * Create a child logger with extended namespace
112
- * @param {string} childNamespace - Child namespace to append
113
- * @returns {Logger} New logger with combined namespace
114
- */
115
- child(childNamespace) {
116
- return new Logger(`${this.namespace}:${childNamespace}`, this.minLevel);
117
- }
118
- }
119
-
120
- /**
121
- * Global logger registry
122
- * @private
123
- */
124
- const loggers = new Map();
125
-
126
- /**
127
- * Global log level (affects all new loggers)
128
- * @private
129
- */
130
- let globalLogLevel = LoggerLevel.INFO;
131
-
132
- /**
133
- * Set global log level for all loggers
134
- * @param {number} level - Log level from LoggerLevel enum
135
- */
136
- export function setGlobalLogLevel(level) {
137
- globalLogLevel = level;
138
- // Update existing loggers
139
- for (const logger of loggers.values()) {
140
- logger.setLevel(level);
141
- }
142
- }
143
-
144
- /**
145
- * Get or create a logger for a namespace
146
- * @param {string} namespace - Logger namespace
147
- * @returns {Logger} Logger instance
148
- */
149
- export function getLogger(namespace) {
150
- if (!loggers.has(namespace)) {
151
- loggers.set(namespace, new Logger(namespace, globalLogLevel));
152
- }
153
- return loggers.get(namespace);
154
- }
155
-
156
- /**
157
- * Configure logging for production (suppress all logs)
158
- */
159
- export function configureForProduction() {
160
- setGlobalLogLevel(LoggerLevel.NONE);
161
- }
162
-
163
- /**
164
- * Configure logging for development (show all logs)
165
- */
166
- export function configureForDevelopment() {
167
- setGlobalLogLevel(LoggerLevel.DEBUG);
168
- }
169
-
170
- // Export default logger for convenience
171
- export default getLogger('App');
@@ -1,248 +0,0 @@
1
- /**
2
- * ObjectPool - Memory-efficient object pooling
3
- *
4
- * Reduces garbage collection pressure by reusing objects instead of
5
- * repeatedly allocating and deallocating them. Critical for real-time rendering.
6
- */
7
-
8
- import { Vector3, Matrix4, Quaternion, Euler } from 'three';
9
-
10
- /**
11
- * Generic object pool
12
- */
13
- export class ObjectPool {
14
- /**
15
- * Create an ObjectPool
16
- * @param {Function} factory - Function that creates new objects
17
- * @param {Function} reset - Function that resets an object to initial state
18
- * @param {number} [initialSize=10] - Number of objects to pre-allocate
19
- */
20
- constructor(factory, reset, initialSize = 10) {
21
- this._factory = factory;
22
- this._reset = reset;
23
- this._pool = [];
24
- this._allocated = 0;
25
- this._maxSize = initialSize * 10; // Prevent unbounded growth
26
-
27
- // Pre-allocate initial objects
28
- for (let i = 0; i < initialSize; i++) {
29
- this._pool.push(factory());
30
- }
31
- }
32
-
33
- /**
34
- * Acquire an object from the pool
35
- * @returns {*} Pooled object
36
- */
37
- acquire() {
38
- this._allocated++;
39
- if (this._pool.length > 0) {
40
- return this._pool.pop();
41
- }
42
- // Pool exhausted, create new object
43
- return this._factory();
44
- }
45
-
46
- /**
47
- * Release an object back to the pool
48
- * @param {*} obj - Object to return to pool
49
- */
50
- release(obj) {
51
- this._allocated--;
52
- if (this._pool.length < this._maxSize) {
53
- this._reset(obj);
54
- this._pool.push(obj);
55
- }
56
- // If pool is at max size, let object be garbage collected
57
- }
58
-
59
- /**
60
- * Release multiple objects
61
- * @param {Array} objects - Objects to return to pool
62
- */
63
- releaseAll(objects) {
64
- for (const obj of objects) {
65
- this.release(obj);
66
- }
67
- }
68
-
69
- /**
70
- * Get pool statistics
71
- * @returns {object} Pool stats
72
- */
73
- getStats() {
74
- return {
75
- available: this._pool.length,
76
- allocated: this._allocated,
77
- maxSize: this._maxSize
78
- };
79
- }
80
-
81
- /**
82
- * Clear the pool and release all objects
83
- */
84
- dispose() {
85
- this._pool.length = 0;
86
- this._allocated = 0;
87
- }
88
- }
89
-
90
- /**
91
- * Pre-configured pools for common Three.js objects
92
- */
93
-
94
- /**
95
- * Vector3 pool
96
- * @type {ObjectPool}
97
- */
98
- export const vector3Pool = new ObjectPool(
99
- () => new Vector3(),
100
- (v) => v.set(0, 0, 0),
101
- 50 // Pre-allocate 50 vectors
102
- );
103
-
104
- /**
105
- * Matrix4 pool
106
- * @type {ObjectPool}
107
- */
108
- export const matrix4Pool = new ObjectPool(
109
- () => new Matrix4(),
110
- (m) => m.identity(),
111
- 20 // Pre-allocate 20 matrices
112
- );
113
-
114
- /**
115
- * Quaternion pool
116
- * @type {ObjectPool}
117
- */
118
- export const quaternionPool = new ObjectPool(
119
- () => new Quaternion(),
120
- (q) => q.set(0, 0, 0, 1),
121
- 30 // Pre-allocate 30 quaternions
122
- );
123
-
124
- /**
125
- * Euler pool
126
- * @type {ObjectPool}
127
- */
128
- export const eulerPool = new ObjectPool(
129
- () => new Euler(),
130
- (e) => e.set(0, 0, 0),
131
- 30 // Pre-allocate 30 eulers
132
- );
133
-
134
- /**
135
- * Scoped pool allocation helper
136
- *
137
- * Automatically releases pooled objects when scope exits.
138
- * Use with try/finally to ensure cleanup.
139
- *
140
- * @example
141
- * const scope = new PoolScope();
142
- * try {
143
- * const v1 = scope.vector3();
144
- * const v2 = scope.vector3();
145
- * // Use vectors...
146
- * } finally {
147
- * scope.releaseAll();
148
- * }
149
- */
150
- export class PoolScope {
151
- constructor() {
152
- this._allocated = [];
153
- }
154
-
155
- /**
156
- * Acquire a Vector3 from pool
157
- * @returns {Vector3} Pooled vector
158
- */
159
- vector3() {
160
- const obj = vector3Pool.acquire();
161
- this._allocated.push({ pool: vector3Pool, obj });
162
- return obj;
163
- }
164
-
165
- /**
166
- * Acquire a Matrix4 from pool
167
- * @returns {Matrix4} Pooled matrix
168
- */
169
- matrix4() {
170
- const obj = matrix4Pool.acquire();
171
- this._allocated.push({ pool: matrix4Pool, obj });
172
- return obj;
173
- }
174
-
175
- /**
176
- * Acquire a Quaternion from pool
177
- * @returns {Quaternion} Pooled quaternion
178
- */
179
- quaternion() {
180
- const obj = quaternionPool.acquire();
181
- this._allocated.push({ pool: quaternionPool, obj });
182
- return obj;
183
- }
184
-
185
- /**
186
- * Acquire an Euler from pool
187
- * @returns {Euler} Pooled euler
188
- */
189
- euler() {
190
- const obj = eulerPool.acquire();
191
- this._allocated.push({ pool: eulerPool, obj });
192
- return obj;
193
- }
194
-
195
- /**
196
- * Release all objects allocated in this scope
197
- */
198
- releaseAll() {
199
- for (const { pool, obj } of this._allocated) {
200
- pool.release(obj);
201
- }
202
- this._allocated.length = 0;
203
- }
204
-
205
- /**
206
- * Get count of allocated objects in this scope
207
- * @returns {number} Number of allocated objects
208
- */
209
- getAllocatedCount() {
210
- return this._allocated.length;
211
- }
212
- }
213
-
214
- /**
215
- * Module-level temporary objects for hot-path reuse
216
- * IMPORTANT: These are NOT thread-safe. Only use in single-threaded contexts.
217
- * Reset these before use to avoid stale data.
218
- */
219
- export const tempVector3A = new Vector3();
220
- export const tempVector3B = new Vector3();
221
- export const tempVector3C = new Vector3();
222
- export const tempMatrix4A = new Matrix4();
223
- export const tempMatrix4B = new Matrix4();
224
- export const tempQuaternionA = new Quaternion();
225
- export const tempQuaternionB = new Quaternion();
226
-
227
- /**
228
- * Get pool statistics for all pre-configured pools
229
- * @returns {object} Statistics for all pools
230
- */
231
- export function getPoolStats() {
232
- return {
233
- vector3: vector3Pool.getStats(),
234
- matrix4: matrix4Pool.getStats(),
235
- quaternion: quaternionPool.getStats(),
236
- euler: eulerPool.getStats()
237
- };
238
- }
239
-
240
- /**
241
- * Dispose all pre-configured pools
242
- */
243
- export function disposeAllPools() {
244
- vector3Pool.dispose();
245
- matrix4Pool.dispose();
246
- quaternionPool.dispose();
247
- eulerPool.dispose();
248
- }