Skip to content

Commit

Permalink
Add parameter to control scene reveal speed
Browse files Browse the repository at this point in the history
  • Loading branch information
mkkellogg committed Sep 9, 2024
1 parent 093ca0b commit d52d428
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ Advanced `Viewer` parameters
| `plyInMemoryCompressionLevel` | Level to compress `.ply` files when loading them for direct rendering (not exporting to `.ksplat`). Valid values are the same as `.ksplat` compression levels (0, 1, or 2). Default is 2.
| `freeIntermediateSplatData` | When true, the intermediate splat data that is the result of decompressing splat bufffer(s) and used to populate data textures will be freed. This will reduces memory usage, but if that data needs to be modified it will need to be re-populated from the splat buffer(s). Defaults to `false`.
| `splatRenderMode` | Determine which splat rendering mode to enable. Valid values are defined in the `SplatRenderMode` enum: `ThreeD` and `TwoD`. `ThreeD` is the original/traditional mode and `TwoD` is the new mode described here: https://surfsplatting.github.io/
| `sceneFadeInRateMultiplier` | Customize the speed at which the scene is revealed. Default is 1.0.
<br>

### Creating KSPLAT files
Expand Down
5 changes: 4 additions & 1 deletion src/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ export class Viewer {
}
this.splatRenderMode = options.splatRenderMode;

// Customize the speed at which the scene is revealed
this.sceneFadeInRateMultiplier = options.sceneFadeInRateMultiplier || 1.0;

this.onSplatMeshChangedCallback = null;
this.createSplatMesh();

Expand Down Expand Up @@ -265,7 +268,7 @@ export class Viewer {
this.splatMesh = new SplatMesh(this.splatRenderMode, this.dynamicScene, this.enableOptionalEffects,
this.halfPrecisionCovariancesOnGPU, this.devicePixelRatio, this.gpuAcceleratedSort,
this.integerBasedSort, this.antialiased, this.maxScreenSpaceSplatSize, this.logLevel,
this.sphericalHarmonicsDegree);
this.sphericalHarmonicsDegree, this.sceneFadeInRateMultiplier);
this.splatMesh.frustumCulled = false;
if (this.onSplatMeshChangedCallback) this.onSplatMeshChangedCallback();
}
Expand Down
8 changes: 5 additions & 3 deletions src/splatmesh/SplatMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class SplatMesh extends THREE.Mesh {
constructor(splatRenderMode = SplatRenderMode.ThreeD, dynamicMode = false, enableOptionalEffects = false,
halfPrecisionCovariancesOnGPU = false, devicePixelRatio = 1, enableDistancesComputationOnGPU = true,
integerBasedDistancesComputation = false, antialiased = false, maxScreenSpaceSplatSize = 1024, logLevel = LogLevel.None,
sphericalHarmonicsDegree = 0) {
sphericalHarmonicsDegree = 0, sceneFadeInRateMultiplier = 1.0) {
super(dummyGeometry, dummyMaterial);

// Reference to a Three.js renderer
Expand Down Expand Up @@ -98,6 +98,8 @@ export class SplatMesh extends THREE.Mesh {
this.sphericalHarmonicsDegree = sphericalHarmonicsDegree;
this.minSphericalHarmonicsDegree = 0;

this.sceneFadeInRateMultiplier = sceneFadeInRateMultiplier;

// The individual splat scenes stored in this splat mesh, each containing their own transform
this.scenes = [];

Expand Down Expand Up @@ -1193,8 +1195,8 @@ export class SplatMesh extends THREE.Mesh {
}

updateVisibleRegionFadeDistance(sceneRevealMode = SceneRevealMode.Default) {
const fastFadeRate = SCENE_FADEIN_RATE_FAST;
const gradualFadeRate = SCENE_FADEIN_RATE_GRADUAL;
const fastFadeRate = SCENE_FADEIN_RATE_FAST * this.sceneFadeInRateMultiplier;
const gradualFadeRate = SCENE_FADEIN_RATE_GRADUAL * this.sceneFadeInRateMultiplier;
const defaultFadeInRate = this.finalBuild ? fastFadeRate : gradualFadeRate;
const fadeInRate = sceneRevealMode === SceneRevealMode.Default ? defaultFadeInRate : gradualFadeRate;
this.visibleRegionFadeStartRadius = (this.visibleRegionRadius - this.visibleRegionFadeStartRadius) *
Expand Down

0 comments on commit d52d428

Please sign in to comment.