From 5cce9d07057e5d2746e6da5981e964d3b4c389ab Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Mon, 16 Nov 2026 14:18:21 -0800 Subject: [PATCH] Nepal evidence: a seek in the hold places a camera-led shot's sequence For a shot whose path runs during the camera move, a seek in the hold showed its evidence sequence at the start and a resumed run jumped to its end. The sequence now stands where its own clock has it (after the clip and its exit), and a resumed run carries on from there. --- src/data/bhoteKoshiEvent.js | 84 +++++++++++++++++++------------ src/data/bhoteKoshiEvent.test.mjs | 64 ++++++++++++++++++++++- 2 files changed, 115 insertions(+), 33 deletions(-) diff --git a/src/data/bhoteKoshiEvent.js b/src/data/bhoteKoshiEvent.js index bbd6abe1d..86d17e710 100644 --- a/src/data/bhoteKoshiEvent.js +++ b/src/data/bhoteKoshiEvent.js @@ -1858,6 +1858,43 @@ export function createBhoteKoshiEventLayer({ return true; } + // The settled-camera reveal waits out the shot's clip and its exit + // (unless the path runs during the clip), then runs for its duration. + const mediaDurationSec = + _sceneControls.evidenceMediaAutoplay === true + ? Math.max( + SCENE_MEDIA_MIN_PLAYBACK_SECONDS, + Number(_sceneControls.mediaPlaybackHoldSec) || 0, + ) + : 0; + const exitDurationSec = + _sceneControls.evidenceMediaAutoplay === true + ? Math.max( + SCENE_MEDIA_EXIT_SECONDS, + Number(_sceneControls.mediaExitDurationSec) || 0, + ) + : 0; + const settledDurationSec = Math.max( + 0.25, + Number( + sceneUsesSourcePath() + ? _sceneControls.evidencePathDurationSec + : sceneEvidenceSequenceAnimates() + ? _sceneControls.evidenceSequenceDurationSec + : _sceneControls.evidenceRevealDurationSec, + ) || 0.9, + ); + const settledStartSec = Math.max( + 0, + Number(_sceneControls.evidencePathStartDelaySec) || 0, + _sceneControls.evidencePathDuringMedia === true + ? 0 + : mediaDurationSec + exitDurationSec, + ); + const settledLinear = clampUnit( + (holdElapsedSec - settledStartSec) / settledDurationSec, + ); + if (scenePathMovesDuringCamera()) { const authoredDurationSec = Number( _sceneControls.evidencePathTravelDurationSec, @@ -1883,41 +1920,24 @@ export function createBhoteKoshiEventLayer({ Number(_sceneControls.evidenceRevealDurationSec) || 0.9, ), ); + // In the hold, an animated evidence sequence runs on its own clock + // after the camera's path; it stands where that clock has it. + const sequenceWindow = + cameraProgress >= 1 && sceneEvidenceSequenceAnimates() + ? evidenceSequenceWindow(_sceneBeatId, _evidenceTimeline) + : null; + if (sequenceWindow) { + _sceneSeekRevealLinear = settledLinear; + _sceneRevealProgress = smoothstep(0, 1, settledLinear); + _progress = + sequenceWindow.startProgress + + (sequenceWindow.targetProgress - sequenceWindow.startProgress) * + _sceneRevealProgress; + } return true; } - const mediaDurationSec = - _sceneControls.evidenceMediaAutoplay === true - ? Math.max( - SCENE_MEDIA_MIN_PLAYBACK_SECONDS, - Number(_sceneControls.mediaPlaybackHoldSec) || 0, - ) - : 0; - const exitDurationSec = - _sceneControls.evidenceMediaAutoplay === true - ? Math.max( - SCENE_MEDIA_EXIT_SECONDS, - Number(_sceneControls.mediaExitDurationSec) || 0, - ) - : 0; - const pathDurationSec = Math.max( - 0.25, - Number( - sceneUsesSourcePath() - ? _sceneControls.evidencePathDurationSec - : sceneEvidenceSequenceAnimates() - ? _sceneControls.evidenceSequenceDurationSec - : _sceneControls.evidenceRevealDurationSec, - ) || 0.9, - ); - const pathStartSec = Math.max( - 0, - Number(_sceneControls.evidencePathStartDelaySec) || 0, - _sceneControls.evidencePathDuringMedia === true - ? 0 - : mediaDurationSec + exitDurationSec, - ); - const linear = clampUnit((holdElapsedSec - pathStartSec) / pathDurationSec); + const linear = settledLinear; _sceneSeekRevealLinear = linear; _sceneRevealProgress = smoothstep(0, 1, linear); _scenePathRevealProgress = diff --git a/src/data/bhoteKoshiEvent.test.mjs b/src/data/bhoteKoshiEvent.test.mjs index a33984d0f..87159fd18 100644 --- a/src/data/bhoteKoshiEvent.test.mjs +++ b/src/data/bhoteKoshiEvent.test.mjs @@ -34,7 +34,7 @@ import { usesProviderEmbeddedEvidence, visibleSegmentCount, } from './bhoteKoshiEvent.js'; -import { SCENE_RECIPES } from '../scenes/recipes.js'; +import { SCENE_RECIPES, getSceneAppendRecipeById } from '../scenes/recipes.js'; import { LayerLifecycle } from './lifecycle.js'; import { createBhoteKoshiEmbeddedMedia } from './bhoteKoshiEmbeddedMedia.js'; import { SceneDirector } from '../scenes/director.js'; @@ -467,6 +467,68 @@ test('scene media plays again when a run goes on from a seek inside its hold, un } finally { await layer.destroy(); Object.assign(globalThis, previous); } }); +test('a run going on from a seek in Timure’s hold resumes its evidence sequence from that point', async () => { + const keys = ['document', 'window', 'performance', 'requestAnimationFrame', 'cancelAnimationFrame']; + const previous = Object.fromEntries(keys.map((key) => [key, globalThis[key]])); + installEventDom(); + let now = 1000; + let nextFrame = 0; + const frames = new Map(); + globalThis.window = { setTimeout: () => 1, clearTimeout() {} }; + globalThis.performance = { now: () => now }; + globalThis.requestAnimationFrame = (callback) => { frames.set(++nextFrame, callback); return nextFrame; }; + globalThis.cancelAnimationFrame = (id) => frames.delete(id); + const frame = (ms) => { + now += ms; + const callback = frames.get(nextFrame); + frames.delete(nextFrame); + callback?.(now); + }; + const event = JSON.parse(await readFile(eventUrl, 'utf8')); + const layer = createBhoteKoshiEventLayer({ + eventLoader: async () => event, + imagerySpecFactory: async (url) => ({ url }), + terrainSampler: async () => null, + mediaLoader: async () => { throw Object.assign(new Error('fixture'), { name: 'AbortError' }); }, + overlayHost: { setEntries() {}, setVisible() {}, clearSource() {} }, + renderHost: { request() {}, hold() {}, release() {} }, + embeddedMediaFactory: () => ({ warm: () => true, show: () => true, play() {}, pause() {}, + getPlaybackState: () => ({ phase: 'completed' }), hide() {}, destroy() {} }), + }); + const recipe = getSceneAppendRecipeById('bhote-koshi-nepal-evidence-pack'); + const controls = { ...recipe.runtimeControlsByBeat['timure-cluster'], cameraSettled: true }; + assert.equal(controls.evidenceSequence, true); + assert.equal(controls.evidencePathDuringCamera, true); + const params = (sceneControls) => ({ presentation: 'scene-beat', sceneSurface: 'evidence-beat', + beatId: 'timure-cluster', sceneControls }); + // The sequence waits out the 6 s clip and its 0.65 s exit, then runs 12 s: + // 8 s into the hold it is 1.35 s along. + const seek = { ...controls, + timelineSeek: { cameraProgress: 1, holdElapsedSec: 8, holdDurationSec: 12, flightDurationSec: 2 } }; + const at = (holdElapsedSec) => { + layer.setParams(params({ ...seek, timelineSeek: { ...seek.timelineSeek, holdElapsedSec } }), + { origin: 'scene' }); + return layer.getPlaybackState().progress; + }; + try { + const viewer = eventViewer(); + await layer.init(viewer); + layer.setParams(params(seek), { origin: 'scene' }); + await layer.enable(viewer, { origin: 'scene' }); + // Where the sequence starts and ends, and where the seek puts it. + const start = at(0); + const end = at(30); + const atSeek = at(8); + assert.ok(start < atSeek && atSeek < end, `the seek shows the sequence partway (${start} < ${atSeek} < ${end})`); + // The run goes on: the sequence carries on from that point, not 0 or its end. + layer.setParams(params(controls), { origin: 'scene' }); + assert.ok(Math.abs(layer.getPlaybackState().progress - atSeek) < 1e-9, 'it starts where the seek stood'); + frame(1000); + const later = layer.getPlaybackState().progress; + assert.ok(atSeek < later && later < end, `and moves on from there (${atSeek} < ${later} < ${end})`); + } finally { await layer.destroy(); Object.assign(globalThis, previous); } +}); + test('Pinokio source-card fallback selects authored Director dwell, not an impossible player hold', async () => { const previous = { document: globalThis.document, window: globalThis.window }; installEventDom();