@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,41 +0,0 @@
1
- /**
2
- * SplatBufferGenerator
3
- *
4
- * Derived from @mkkellogg/gaussian-splats-3d (MIT License)
5
- * https://github.com/mkkellogg/GaussianSplats3D
6
- *
7
- * This file is functionally identical to the original.
8
- * Import paths adjusted for gsplat-flame-avatar package structure.
9
- */
10
-
11
- import { Vector3 } from 'three';
12
- import { SplatBuffer } from './SplatBuffer.js';
13
- import { SplatPartitioner } from './SplatPartitioner.js';
14
-
15
- export class SplatBufferGenerator {
16
-
17
- constructor(splatPartitioner, alphaRemovalThreshold, compressionLevel, sectionSize, sceneCenter, blockSize, bucketSize) {
18
- this.splatPartitioner = splatPartitioner;
19
- this.alphaRemovalThreshold = alphaRemovalThreshold;
20
- this.compressionLevel = compressionLevel;
21
- this.sectionSize = sectionSize;
22
- this.sceneCenter = sceneCenter ? new Vector3().copy(sceneCenter) : undefined;
23
- this.blockSize = blockSize;
24
- this.bucketSize = bucketSize;
25
- }
26
-
27
- generateFromUncompressedSplatArray(splatArray) {
28
- const partitionResults = this.splatPartitioner.partitionUncompressedSplatArray(splatArray);
29
- return SplatBuffer.generateFromUncompressedSplatArrays(partitionResults.splatArrays,
30
- this.alphaRemovalThreshold, this.compressionLevel,
31
- this.sceneCenter, this.blockSize, this.bucketSize,
32
- partitionResults.parameters);
33
- }
34
-
35
- static getStandardGenerator(alphaRemovalThreshold = 1, compressionLevel = 1, sectionSize = 0, sceneCenter = new Vector3(),
36
- blockSize = SplatBuffer.BucketBlockSize, bucketSize = SplatBuffer.BucketSize) {
37
- const splatPartitioner = SplatPartitioner.getStandardPartitioner(sectionSize, sceneCenter, blockSize, bucketSize);
38
- return new SplatBufferGenerator(splatPartitioner, alphaRemovalThreshold, compressionLevel,
39
- sectionSize, sceneCenter, blockSize, bucketSize);
40
- }
41
- }
@@ -1,110 +0,0 @@
1
- /**
2
- * SplatPartitioner
3
- *
4
- * Derived from @mkkellogg/gaussian-splats-3d (MIT License)
5
- * https://github.com/mkkellogg/GaussianSplats3D
6
- *
7
- * This file is functionally identical to the original.
8
- * Import paths adjusted for gsplat-flame-avatar package structure.
9
- */
10
-
11
- import { Vector3 } from 'three';
12
- import { SplatBuffer } from './SplatBuffer.js';
13
- import { UncompressedSplatArray } from './UncompressedSplatArray.js';
14
-
15
- export class SplatPartitioner {
16
-
17
- constructor(sectionCount, sectionFilters, groupingParameters, partitionGenerator) {
18
- this.sectionCount = sectionCount;
19
- this.sectionFilters = sectionFilters;
20
- this.groupingParameters = groupingParameters;
21
- this.partitionGenerator = partitionGenerator;
22
- }
23
-
24
- partitionUncompressedSplatArray(splatArray) {
25
- let groupingParameters;
26
- let sectionCount;
27
- let sectionFilters;
28
- if (this.partitionGenerator) {
29
- const results = this.partitionGenerator(splatArray);
30
- groupingParameters = results.groupingParameters;
31
- sectionCount = results.sectionCount;
32
- sectionFilters = results.sectionFilters;
33
- } else {
34
- groupingParameters = this.groupingParameters;
35
- sectionCount = this.sectionCount;
36
- sectionFilters = this.sectionFilters;
37
- }
38
-
39
- const newArrays = [];
40
- for (let s = 0; s < sectionCount; s++) {
41
- const sectionSplats = new UncompressedSplatArray(splatArray.sphericalHarmonicsDegree);
42
- const sectionFilter = sectionFilters[s];
43
- for (let i = 0; i < splatArray.splatCount; i++) {
44
- if (sectionFilter(i)) {
45
- sectionSplats.addSplat(splatArray.splats[i]);
46
- }
47
- }
48
- newArrays.push(sectionSplats);
49
- }
50
- return {
51
- splatArrays: newArrays,
52
- parameters: groupingParameters
53
- };
54
- }
55
-
56
- static getStandardPartitioner(partitionSize = 0, sceneCenter = new Vector3(),
57
- blockSize = SplatBuffer.BucketBlockSize, bucketSize = SplatBuffer.BucketSize) {
58
-
59
- const partitionGenerator = (splatArray) => {
60
-
61
- const OFFSET_X = UncompressedSplatArray.OFFSET.X;
62
- const OFFSET_Y = UncompressedSplatArray.OFFSET.Y;
63
- const OFFSET_Z = UncompressedSplatArray.OFFSET.Z;
64
-
65
- if (partitionSize <= 0) partitionSize = splatArray.splatCount;
66
-
67
- const center = new Vector3();
68
- const clampDistance = 0.5;
69
- const clampPoint = (point) => {
70
- point.x = Math.floor(point.x / clampDistance) * clampDistance;
71
- point.y = Math.floor(point.y / clampDistance) * clampDistance;
72
- point.z = Math.floor(point.z / clampDistance) * clampDistance;
73
- };
74
- splatArray.splats.forEach((splat) => {
75
- center.set(splat[OFFSET_X], splat[OFFSET_Y], splat[OFFSET_Z]).sub(sceneCenter);
76
- clampPoint(center);
77
- splat.centerDist = center.lengthSq();
78
- });
79
- splatArray.splats.sort((a, b) => {
80
- let centerADist = a.centerDist;
81
- let centerBDist = b.centerDist;
82
- if (centerADist > centerBDist) return 1;
83
- else return -1;
84
- });
85
-
86
- const sectionFilters = [];
87
- const groupingParameters = [];
88
- partitionSize = Math.min(splatArray.splatCount, partitionSize);
89
- const patitionCount = Math.ceil(splatArray.splatCount / partitionSize);
90
- let currentStartSplat = 0;
91
- for (let i = 0; i < patitionCount; i ++) {
92
- let startSplat = currentStartSplat;
93
- sectionFilters.push((splatIndex) => {
94
- return splatIndex >= startSplat && splatIndex < startSplat + partitionSize;
95
- });
96
- groupingParameters.push({
97
- 'blocksSize': blockSize,
98
- 'bucketSize': bucketSize,
99
- });
100
- currentStartSplat += partitionSize;
101
- }
102
- return {
103
- 'sectionCount': sectionFilters.length,
104
- sectionFilters,
105
- groupingParameters
106
- };
107
- };
108
- return new SplatPartitioner(undefined, undefined, undefined, partitionGenerator);
109
- }
110
- }
@@ -1,106 +0,0 @@
1
- /**
2
- * UncompressedSplatArray
3
- *
4
- * Derived from @mkkellogg/gaussian-splats-3d (MIT License)
5
- * https://github.com/mkkellogg/GaussianSplats3D
6
- *
7
- * This file is functionally identical to the original.
8
- * Import paths adjusted for gsplat-flame-avatar package structure.
9
- */
10
-
11
- import { getSphericalHarmonicsComponentCountForDegree } from '../utils/Util.js';
12
-
13
- const BASE_COMPONENT_COUNT = 14;
14
-
15
- export class UncompressedSplatArray {
16
-
17
- static OFFSET = {
18
- X: 0,
19
- Y: 1,
20
- Z: 2,
21
- SCALE0: 3,
22
- SCALE1: 4,
23
- SCALE2: 5,
24
- ROTATION0: 6,
25
- ROTATION1: 7,
26
- ROTATION2: 8,
27
- ROTATION3: 9,
28
- FDC0: 10,
29
- FDC1: 11,
30
- FDC2: 12,
31
- OPACITY: 13,
32
- FRC0: 14,
33
- FRC1: 15,
34
- FRC2: 16,
35
- FRC3: 17,
36
- FRC4: 18,
37
- FRC5: 19,
38
- FRC6: 20,
39
- FRC7: 21,
40
- FRC8: 22,
41
- FRC9: 23,
42
- FRC10: 24,
43
- FRC11: 25,
44
- FRC12: 26,
45
- FRC13: 27,
46
- FRC14: 28,
47
- FRC15: 29,
48
- FRC16: 30,
49
- FRC17: 31,
50
- FRC18: 32,
51
- FRC19: 33,
52
- FRC20: 34,
53
- FRC21: 35,
54
- FRC22: 36,
55
- FRC23: 37
56
- };
57
-
58
- constructor(sphericalHarmonicsDegree = 0) {
59
- this.sphericalHarmonicsDegree = sphericalHarmonicsDegree;
60
- this.sphericalHarmonicsCount = getSphericalHarmonicsComponentCountForDegree(this.sphericalHarmonicsDegree);
61
- this.componentCount = this.sphericalHarmonicsCount + BASE_COMPONENT_COUNT;
62
- this.defaultSphericalHarmonics = new Array(this.sphericalHarmonicsCount).fill(0);
63
- this.splats = [];
64
- this.splatCount = 0;
65
- }
66
-
67
- static createSplat(sphericalHarmonicsDegree = 0) {
68
- const baseSplat = [0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0];
69
- let shEntries = getSphericalHarmonicsComponentCountForDegree(sphericalHarmonicsDegree);
70
- for (let i = 0; i < shEntries; i++) baseSplat.push(0);
71
- return baseSplat;
72
- }
73
-
74
- addSplat(splat) {
75
- this.splats.push(splat);
76
- this.splatCount++;
77
- }
78
-
79
- getSplat(index) {
80
- return this.splats[index];
81
- }
82
-
83
- addDefaultSplat() {
84
- const newSplat = UncompressedSplatArray.createSplat(this.sphericalHarmonicsDegree);
85
- this.addSplat(newSplat);
86
- return newSplat;
87
- }
88
-
89
- addSplatFromComonents(x, y, z, scale0, scale1, scale2, rot0, rot1, rot2, rot3, r, g, b, opacity, ...rest) {
90
- const newSplat = [x, y, z, scale0, scale1, scale2, rot0, rot1, rot2, rot3, r, g, b, opacity, ...this.defaultSphericalHarmonics];
91
- for (let i = 0; i < rest.length && i < this.sphericalHarmonicsCount; i++) {
92
- newSplat[i] = rest[i];
93
- }
94
- this.addSplat(newSplat);
95
- return newSplat;
96
- }
97
-
98
- addSplatFromArray(src, srcIndex) {
99
- const srcSplat = src.splats[srcIndex];
100
- const newSplat = UncompressedSplatArray.createSplat(this.sphericalHarmonicsDegree);
101
- for (let i = 0; i < this.componentCount && i < srcSplat.length; i++) {
102
- newSplat[i] = srcSplat[i];
103
- }
104
- this.addSplat(newSplat);
105
- }
106
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * gsplat-flame-avatar - Buffers Module
3
- * GPU buffer management for Gaussian Splat data.
4
- *
5
- * Derived from @mkkellogg/gaussian-splats-3d (MIT License)
6
- */
7
-
8
- export { SplatBuffer } from './SplatBuffer.js';
9
- export { SplatBufferGenerator } from './SplatBufferGenerator.js';
10
- export { SplatPartitioner } from './SplatPartitioner.js';
11
- export { UncompressedSplatArray } from './UncompressedSplatArray.js';
@@ -1,48 +0,0 @@
1
- /**
2
- * SplatGeometry
3
- *
4
- * Derived from @mkkellogg/gaussian-splats-3d (MIT License)
5
- * https://github.com/mkkellogg/GaussianSplats3D
6
- *
7
- * This file is functionally identical to the original.
8
- */
9
-
10
- import { BufferAttribute, BufferGeometry, DynamicDrawUsage, InstancedBufferAttribute, InstancedBufferGeometry } from 'three';
11
-
12
- export class SplatGeometry {
13
-
14
- /**
15
- * Build the Three.js geometry that will be used to render the splats. The geometry is instanced and is made up of
16
- * vertices for a single quad as well as an attribute buffer for the splat indexes.
17
- * @param {number} maxSplatCount The maximum number of splats that the geometry will need to accomodate
18
- * @return {THREE.InstancedBufferGeometry}
19
- */
20
- static build(maxSplatCount) {
21
-
22
- const baseGeometry = new BufferGeometry();
23
- baseGeometry.setIndex([0, 1, 2, 0, 2, 3]);
24
-
25
- // Vertices for the instanced quad
26
- const positionsArray = new Float32Array(4 * 3);
27
- const positions = new BufferAttribute(positionsArray, 3);
28
- baseGeometry.setAttribute('position', positions);
29
- positions.setXYZ(0, -1.0, -1.0, 0.0);
30
- positions.setXYZ(1, -1.0, 1.0, 0.0);
31
- positions.setXYZ(2, 1.0, 1.0, 0.0);
32
- positions.setXYZ(3, 1.0, -1.0, 0.0);
33
- positions.needsUpdate = true;
34
-
35
- const geometry = new InstancedBufferGeometry().copy(baseGeometry);
36
-
37
- // Splat index buffer
38
- const splatIndexArray = new Uint32Array(maxSplatCount);
39
-
40
- const splatIndexes = new InstancedBufferAttribute(splatIndexArray, 1, false);
41
- splatIndexes.setUsage(DynamicDrawUsage);
42
- geometry.setAttribute('splatIndex', splatIndexes);
43
-
44
- geometry.instanceCount = 0;
45
-
46
- return geometry;
47
- }
48
- }