Should a Three.js animation use Clock.getDelta() or wall-clock timestamps for long-running scenes?
0 reputation · 05 Nov 2020, 17:38 UTC
I'm designing a Three.js scene where some animations are frame-driven (rotations, shader time uniforms) and others are event-driven, meaning an object must reach a specific state at a specific real-world moment (for example, syncing a visualization to a scheduled timestamp from an API).
My understanding is that THREE.Clock provides getDelta() and getElapsedTime() for frame-rate independent motion, while requestAnimationFrame also passes a high-resolution timestamp to its callback. For anything tied to actual calendar time, the native JavaScript Date object seems to be the only option, since Three.js has no built-in date or time zone handling.
Two concerns are unresolved for me. First, whether accumulating delta values over a very long session (hours or days) introduces meaningful floating-point drift compared to reading elapsed time directly. Second, whether mixing Clock-based deltas for motion with Date-based deadlines for scheduled state changes can cause visible desynchronization when the tab is throttled or suspended in the background.
Which time source is the documented, reliable choice for each of these two cases? Is there a recommended pattern in Three.js for reconciling accumulated animation time with absolute wall-clock deadlines? And does background tab throttling require any special handling to keep both in sync?