fix(scene): cut the opening crane to the chase framing on any interaction

This commit is contained in:
2026-10-10 20:50:47 +03:00
parent d9cdbbbde2
commit 8044ad88e3

View File

@@ -187,7 +187,6 @@ export async function createProceduralSceneGeneration(
// Opening shot: a crane down from the sun to the chase position. It plays
// once, only when the visit starts at the top, and a scroll hurries it.
let introProgress: number | null = null;
let introHurried = false;
let introFrames = 0;
let introSlowFrames = 0;
@@ -521,20 +520,21 @@ export async function createProceduralSceneGeneration(
if (introProgress === 0) renderer.compile(scene, camera);
}
if (introProgress < 1) {
// The shot belongs to a visitor who waits at the top. Once they scroll
// or navigate it lands within INTRO_LANDING_SECONDS of wall time: a sign
// latches its placement after its 300 ms anticipation, so the chase
// framing must be back before then.
if (snapshot.scrollY > 40 || snapshot.activeSectionId !== 'start') introHurried = true;
// A crane that stutters is worse than none: on a device that cannot
// hold the shot smoothly, land it straight away.
// The first frames carry shader compilation and a lone hitch (a late
// texture upload) is forgiven; three slow frames end the shot.
// The shot belongs to a visitor who waits at the top. Scrolling,
// navigating or a sign on its way cuts straight to the chase framing:
// signs latch their placement against that camera.
if (
snapshot.scrollY > 40
|| snapshot.activeSectionId !== 'start'
|| snapshot.sign !== null
) introProgress = 1;
// A crane that stutters is worse than none. The first frames carry
// shader compilation and a lone hitch is forgiven; three slow frames
// end the shot.
introFrames += 1;
if (introFrames > 3 && wallSeconds > 0.1) introSlowFrames += 1;
if (introSlowFrames >= 3) introHurried = true;
const step = introHurried ? Math.min(0.5, wallSeconds) / INTRO_LANDING_SECONDS : deltaSeconds / INTRO_SECONDS;
introProgress = Math.min(1, introProgress + step);
if (introSlowFrames >= 3) introProgress = 1;
introProgress = Math.min(1, introProgress + deltaSeconds / INTRO_SECONDS);
}
const crane = easeInOutCubic(
THREE.MathUtils.clamp((introProgress - 0.06) / 0.94, 0, 1),
@@ -619,7 +619,6 @@ export async function createProceduralSceneGeneration(
};
}
const INTRO_LANDING_SECONDS = 0.18;
const INTRO_SECONDS = 4.2;
function easeInOutCubic(t: number): number {