mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-01 21:44:27 +00:00
fix(viewer): eliminate 3D model rotation jitter at 345 degrees
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user