How to dynamically adjust timeScale while maintaining animation continuity? (Real-time speed control for playing animations)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.1k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
Background
I'm using Tween.js with Three.js to implement camera roaming animations, where I smoothly transition the camera's position and target via . The animation consists of multiple segments, each with fixed target positions, targets, and durations.OrbitControls
Problem
I need to implement real-time speed control (e.g., dynamically adjusting to 0.5x, 1x, 2x, etc.) so that playing animations can continue at the new speed, while maintaining correct time progress after pausing/resuming. However, I’m facing the following issues:
- Directly modifying the animation’s causes incorrect remaining time calculations for the current segment (e.g., sudden jumps when speeding up).
// This will affect the animation that is in play.
setTimeScale(scale) {
const duration = this.currentTween.getDuration();
this.currentTween.duration(duration / scale);
}
The desired behavior is similar to video player speed control: animations should transition smoothly after speed changes, remaining time should scale proportionally with the new speed, and playback should resume from the correct position after pausing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the currentTween duration, pause, resume, and progress behavior described in the issue and the setTimeScale example. Compare behavior before and after changing speed while a segment is playing or paused. Done means speed changes preserve animation continuity, scale the remaining time proportionally, and resume from the correct position.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, three.js, typescript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100