fix(viewer): eliminate 3D model rotation jitter at 345 degrees

This commit is contained in:
yiling
2026-10-11 11:21:04 +08:00
parent 22c518d70c
commit d08f7ee973
4 changed files with 55 additions and 13 deletions
@@ -3,11 +3,17 @@ export const FPS = 6
export const FRAME_DURATION = 1 / FPS
/**
* Calculates the presentation time at the center of a frame.
* Seeking to the frame center avoids PTS boundary inaccuracies in browser video decoders.
* Calculates the presentation time within a frame.
* Seeking near the frame center avoids PTS boundary inaccuracies in browser video decoders.
* For the final frame (TOTAL_FRAMES - 1), we use a safe offset inside the frame
* to avoid grazing the EOF boundary (video duration) which can cause browser decoders
* to trigger end-of-stream or loop behavior.
*/
export function calculateFrameCenterTime(frameIndex: number): number {
const normalizedFrame = ((frameIndex % TOTAL_FRAMES) + TOTAL_FRAMES) % TOTAL_FRAMES
if (normalizedFrame === TOTAL_FRAMES - 1) {
return normalizedFrame * FRAME_DURATION + FRAME_DURATION * 0.25
}
return (normalizedFrame + 0.5) * FRAME_DURATION
}