@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.
- package/README.md +160 -32
- package/dist/gsplat-flame-avatar-renderer.cjs.js +3510 -749
- package/dist/gsplat-flame-avatar-renderer.cjs.min.js +2 -0
- package/dist/gsplat-flame-avatar-renderer.cjs.min.js.map +1 -0
- package/dist/gsplat-flame-avatar-renderer.esm.js +3471 -751
- package/dist/gsplat-flame-avatar-renderer.esm.min.js +2 -0
- package/dist/gsplat-flame-avatar-renderer.esm.min.js.map +1 -0
- package/package.json +14 -7
- package/dist/gsplat-flame-avatar-renderer.cjs.js.map +0 -1
- package/dist/gsplat-flame-avatar-renderer.esm.js.map +0 -1
- package/src/api/index.js +0 -7
- package/src/buffers/SplatBuffer.js +0 -1394
- package/src/buffers/SplatBufferGenerator.js +0 -41
- package/src/buffers/SplatPartitioner.js +0 -110
- package/src/buffers/UncompressedSplatArray.js +0 -106
- package/src/buffers/index.js +0 -11
- package/src/core/SplatGeometry.js +0 -48
- package/src/core/SplatMesh.js +0 -2620
- package/src/core/SplatScene.js +0 -43
- package/src/core/SplatTree.js +0 -200
- package/src/core/Viewer.js +0 -2895
- package/src/core/index.js +0 -13
- package/src/enums/EngineConstants.js +0 -58
- package/src/enums/LogLevel.js +0 -13
- package/src/enums/RenderMode.js +0 -11
- package/src/enums/SceneFormat.js +0 -21
- package/src/enums/SceneRevealMode.js +0 -11
- package/src/enums/SplatRenderMode.js +0 -10
- package/src/enums/index.js +0 -13
- package/src/flame/FlameAnimator.js +0 -271
- package/src/flame/FlameConstants.js +0 -21
- package/src/flame/FlameTextureManager.js +0 -293
- package/src/flame/index.js +0 -22
- package/src/flame/utils.js +0 -50
- package/src/index.js +0 -39
- package/src/loaders/DirectLoadError.js +0 -14
- package/src/loaders/INRIAV1PlyParser.js +0 -223
- package/src/loaders/PlyLoader.js +0 -261
- package/src/loaders/PlyParser.js +0 -19
- package/src/loaders/PlyParserUtils.js +0 -311
- package/src/loaders/index.js +0 -13
- package/src/materials/SplatMaterial.js +0 -1065
- package/src/materials/SplatMaterial2D.js +0 -358
- package/src/materials/SplatMaterial3D.js +0 -278
- package/src/materials/index.js +0 -11
- package/src/raycaster/Hit.js +0 -37
- package/src/raycaster/Ray.js +0 -123
- package/src/raycaster/Raycaster.js +0 -175
- package/src/raycaster/index.js +0 -10
- package/src/renderer/AnimationManager.js +0 -574
- package/src/renderer/AppConstants.js +0 -101
- package/src/renderer/GaussianSplatRenderer.js +0 -695
- package/src/renderer/index.js +0 -24
- package/src/utils/LoaderUtils.js +0 -65
- package/src/utils/Util.js +0 -375
- package/src/utils/index.js +0 -9
- package/src/worker/SortWorker.js +0 -284
- 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
|
-
}
|
package/src/buffers/index.js
DELETED
|
@@ -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
|
-
}
|