fix: tune granular splat reveal timing
This commit is contained in:
parent
5363a62e0e
commit
97f3bf2c20
@ -104,10 +104,10 @@ const SPLAT_LOADING_PROFILE: SparkRevealProfile = {
|
|||||||
const SPLAT_PARTICLE_PROFILE: SparkRevealProfile = {
|
const SPLAT_PARTICLE_PROFILE: SparkRevealProfile = {
|
||||||
blurAmount: 0.01,
|
blurAmount: 0.01,
|
||||||
preBlurAmount: 0,
|
preBlurAmount: 0,
|
||||||
minAlpha: 0.19,
|
minAlpha: 0.28,
|
||||||
maxStdDev: Math.sqrt(2.2),
|
maxStdDev: Math.sqrt(1.45),
|
||||||
focalAdjustment: 2.35,
|
focalAdjustment: 3.05,
|
||||||
falloff: 0.2,
|
falloff: 0.08,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -155,6 +155,8 @@ function lerpSparkRevealProfile(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SPLAT_REVEAL_DURATION_MS = 2600;
|
||||||
|
|
||||||
const KEY_TO_MOVEMENT: Partial<Record<string, MovementCommand>> = {
|
const KEY_TO_MOVEMENT: Partial<Record<string, MovementCommand>> = {
|
||||||
KeyW: "forward",
|
KeyW: "forward",
|
||||||
ArrowUp: "forward",
|
ArrowUp: "forward",
|
||||||
@ -582,23 +584,38 @@ function WorldSplatScene({
|
|||||||
const phase = revealPhaseRef.current;
|
const phase = revealPhaseRef.current;
|
||||||
const revealElapsed =
|
const revealElapsed =
|
||||||
phase === "revealing"
|
phase === "revealing"
|
||||||
? Math.min((performance.now() - revealStartedAtRef.current) / 1650, 1)
|
? Math.min((performance.now() - revealStartedAtRef.current) / SPLAT_REVEAL_DURATION_MS, 1)
|
||||||
: 0;
|
: 0;
|
||||||
const easedReveal = 1 - Math.pow(1 - revealElapsed, 3);
|
const easedReveal = THREE.MathUtils.smoothstep(revealElapsed, 0, 1);
|
||||||
|
|
||||||
if (phase === "loading") {
|
if (phase === "loading") {
|
||||||
applySparkRevealProfile(sparkRenderer, splatMesh, SPLAT_LOADING_PROFILE);
|
applySparkRevealProfile(sparkRenderer, splatMesh, SPLAT_LOADING_PROFILE);
|
||||||
} else if (phase === "revealing") {
|
} else if (phase === "revealing") {
|
||||||
const particleHold = 0.32;
|
const particleIntroEnd = 0.2;
|
||||||
const granularProgress =
|
const particleHoldEnd = 0.6;
|
||||||
easedReveal <= particleHold
|
let profile = SPLAT_PARTICLE_PROFILE;
|
||||||
? 0
|
|
||||||
: (easedReveal - particleHold) / (1 - particleHold);
|
if (easedReveal < particleIntroEnd) {
|
||||||
const profile = lerpSparkRevealProfile(
|
profile = lerpSparkRevealProfile(
|
||||||
SPLAT_PARTICLE_PROFILE,
|
SPLAT_LOADING_PROFILE,
|
||||||
SPLAT_NORMAL_PROFILE,
|
SPLAT_PARTICLE_PROFILE,
|
||||||
THREE.MathUtils.smoothstep(granularProgress, 0, 1)
|
THREE.MathUtils.smoothstep(easedReveal / particleIntroEnd, 0, 1)
|
||||||
);
|
);
|
||||||
|
} else if (easedReveal < particleHoldEnd) {
|
||||||
|
const pulse = Math.sin((performance.now() - revealStartedAtRef.current) * 0.008) * 0.02;
|
||||||
|
profile = {
|
||||||
|
...SPLAT_PARTICLE_PROFILE,
|
||||||
|
minAlpha: SPLAT_PARTICLE_PROFILE.minAlpha + pulse,
|
||||||
|
focalAdjustment: SPLAT_PARTICLE_PROFILE.focalAdjustment + pulse * 2.4,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const granularProgress = (easedReveal - particleHoldEnd) / (1 - particleHoldEnd);
|
||||||
|
profile = lerpSparkRevealProfile(
|
||||||
|
SPLAT_PARTICLE_PROFILE,
|
||||||
|
SPLAT_NORMAL_PROFILE,
|
||||||
|
THREE.MathUtils.smoothstep(granularProgress, 0, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
applySparkRevealProfile(sparkRenderer, splatMesh, profile);
|
applySparkRevealProfile(sparkRenderer, splatMesh, profile);
|
||||||
} else {
|
} else {
|
||||||
applySparkRevealProfile(sparkRenderer, splatMesh, SPLAT_NORMAL_PROFILE);
|
applySparkRevealProfile(sparkRenderer, splatMesh, SPLAT_NORMAL_PROFILE);
|
||||||
@ -757,7 +774,7 @@ function WorldSplatViewer({
|
|||||||
setOverlayPhase("revealing");
|
setOverlayPhase("revealing");
|
||||||
const timer = window.setTimeout(() => {
|
const timer = window.setTimeout(() => {
|
||||||
setOverlayPhase("hidden");
|
setOverlayPhase("hidden");
|
||||||
}, 1650);
|
}, SPLAT_REVEAL_DURATION_MS);
|
||||||
return () => window.clearTimeout(timer);
|
return () => window.clearTimeout(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user