mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Stories: Play resumes at the exact paused or sought moment
startScene takes fromProgress and starts partway into a shot: the camera goes on along the rest of the flight, the hold waits only what is left and the scene clock carries on from the same point.
This commit is contained in:
1 parent
fec84dbf78
commit
8734f5e515
11 files changed
+341
-45
No files matched your search
@@ -19,7 +19,12 @@ export function createCameraMotion({
|
||||
disposed = true;
|
||||
cancel();
|
||||
},
|
||||
play(move, token) {
|
||||
/**
|
||||
* Play one move. `fromProgress` starts partway in, as if the move had
|
||||
* already run that share of its duration; `sample` replaces the authored
|
||||
* sampler (a resumed ordinary flight follows its own path).
|
||||
*/
|
||||
play(move, token, { fromProgress = 0, sample = sampleCameraMove } = {}) {
|
||||
cancel();
|
||||
if (disposed || token?.cancelled || token?.signal?.aborted)
|
||||
return Promise.resolve(false);
|
||||
@@ -27,7 +32,11 @@ export function createCameraMotion({
|
||||
throw new RangeError('Camera move duration must be positive');
|
||||
return new Promise((resolve, reject) => {
|
||||
const run = { handle: null, finish: null };
|
||||
const startedAt = now();
|
||||
const startOffset =
|
||||
Math.min(1, Math.max(0, Number(fromProgress) || 0)) *
|
||||
move.durationSec *
|
||||
1000;
|
||||
const startedAt = now() - startOffset;
|
||||
const onAbort = () => run.finish(false);
|
||||
run.finish = (completed, error) => {
|
||||
if (active !== run) return;
|
||||
@@ -51,7 +60,7 @@ export function createCameraMotion({
|
||||
1,
|
||||
Math.max(0, (now() - startedAt) / (move.durationSec * 1000)),
|
||||
);
|
||||
if (applyPose(sampleCameraMove(move, progress)) === false) {
|
||||
if (applyPose(sample(move, progress)) === false) {
|
||||
run.finish(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user