Skip to content

Commit 13d9d6b

Browse files
authored
Merge pull request #147 from mkkellogg/progressive_loading_updates
Progressive loading updates
2 parents 06f08e6 + 81c63d9 commit 13d9d6b

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
return splatBufferGenerator.generateFromUncompressedSplatArray(splatArray);
263263
}
264264

265-
function convertStandardSplatToSplatBuffer(bufferData, compressionLevel, alphaRemovalThreshold, sectionSize, blockSize, bucketSize){
265+
function convertStandardSplatToSplatBuffer(bufferData, compressionLevel, alphaRemovalThreshold, sectionSize, sceneCenter, blockSize, bucketSize){
266266
const splatArray = GaussianSplats3D.SplatParser.parseStandardSplatToUncompressedSplatArray(bufferData);
267267
const splatBufferGenerator = GaussianSplats3D.SplatBufferGenerator.getStandardGenerator(alphaRemovalThreshold, compressionLevel, sectionSize, sceneCenter, blockSize, bucketSize);
268268
return splatBufferGenerator.generateFromUncompressedSplatArray(splatArray);

src/SplatMesh.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,13 @@ export class SplatMesh extends THREE.Mesh {
452452
const position = new THREE.Vector3().fromArray(positionArray);
453453
const rotation = new THREE.Quaternion().fromArray(rotationArray);
454454
const scale = new THREE.Vector3().fromArray(scaleArray);
455-
scenes[i] = SplatMesh.createScene(splatBuffer, position, rotation, scale);
455+
scenes[i] = SplatMesh.createScene(splatBuffer, position, rotation, scale, options.splatAlphaRemovalThreshold || 1);
456456
}
457457
return scenes;
458458
}
459459

460-
static createScene(splatBuffer, position, rotation, scale) {
461-
return new SplatScene(splatBuffer, position, rotation, scale);
460+
static createScene(splatBuffer, position, rotation, scale, minimumAlpha) {
461+
return new SplatScene(splatBuffer, position, rotation, scale, minimumAlpha);
462462
}
463463

464464
/**
@@ -1516,7 +1516,7 @@ export class SplatMesh extends THREE.Mesh {
15161516
srcFrom, srcTo, localDestFrom, this.halfPrecisionCovariancesOnGPU ? 1 : 0);
15171517
}
15181518
if (centers) splatBuffer.fillSplatCenterArray(centers, sceneTransform, srcFrom, srcTo, localDestFrom);
1519-
if (colors) splatBuffer.fillSplatColorArray(colors, sceneTransform, srcFrom, srcTo, localDestFrom);
1519+
if (colors) splatBuffer.fillSplatColorArray(colors, scene.minimumAlpha, sceneTransform, srcFrom, srcTo, localDestFrom);
15201520
destfrom += splatBuffer.getSplatCount();
15211521
}
15221522
}

src/SplatScene.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import * as THREE from 'three';
55
*/
66
export class SplatScene {
77

8-
constructor(splatBuffer, position = new THREE.Vector3(), quaternion = new THREE.Quaternion(), scale = new THREE.Vector3(1, 1, 1)) {
8+
constructor(splatBuffer, position = new THREE.Vector3(), quaternion = new THREE.Quaternion(),
9+
scale = new THREE.Vector3(1, 1, 1), minimumAlpha = 1) {
910
this.splatBuffer = splatBuffer;
1011
this.position = position.clone();
1112
this.quaternion = quaternion.clone();
1213
this.scale = scale.clone();
1314
this.transform = new THREE.Matrix4();
15+
this.minimumAlpha = minimumAlpha;
1416
this.updateTransform();
1517
}
1618

src/Viewer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,11 @@ export class Viewer {
475475

476476
let downloadDone = false;
477477

478-
let loadedPercent = 0;
478+
let downloadedPercentage = 0;
479479
const onProgress = (percent, percentLabel, loaderStatus) => {
480-
loadedPercent = percent;
481480
if (showLoadingUI) {
482481
if (loaderStatus === LoaderStatus.Downloading) {
482+
downloadedPercentage = percent;
483483
if (percent == 100) {
484484
this.loadingSpinner.setMessageForTask(loadingTaskId, 'Download complete!');
485485
} else {
@@ -516,7 +516,7 @@ export class Viewer {
516516
downloadDone = true;
517517
this.loadingProgressBar.hide();
518518
} else {
519-
this.loadingProgressBar.setProgress(loadedPercent);
519+
this.loadingProgressBar.setProgress(downloadedPercentage);
520520
}
521521
}
522522
}

src/loaders/SplatBuffer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export class SplatBuffer {
279279
}
280280
}
281281

282-
fillSplatColorArray(outColorArray, transform, srcFrom, srcTo, destFrom) {
282+
fillSplatColorArray(outColorArray, minimumAlpha, transform, srcFrom, srcTo, destFrom) {
283283
const splatCount = this.splatCount;
284284

285285
srcFrom = srcFrom || 0;
@@ -296,10 +296,13 @@ export class SplatBuffer {
296296
const colorSrcBase = this.bytesPerSplat * localSplatIndex + splatColorOffset;
297297
const colorDestBase = (i - srcFrom + destFrom) * SplatBuffer.ColorComponentCount;
298298

299+
let alpha = section.dataArrayUint8[colorSrcBase + 3];
300+
alpha = (alpha >= minimumAlpha) ? alpha : 0;
301+
299302
outColorArray[colorDestBase] = section.dataArrayUint8[colorSrcBase];
300303
outColorArray[colorDestBase + 1] = section.dataArrayUint8[colorSrcBase + 1];
301304
outColorArray[colorDestBase + 2] = section.dataArrayUint8[colorSrcBase + 2];
302-
outColorArray[colorDestBase + 3] = section.dataArrayUint8[colorSrcBase + 3];
305+
outColorArray[colorDestBase + 3] = alpha;
303306

304307
// TODO: implement application of transform for spherical harmonics
305308
}

0 commit comments

Comments
 (0)