render-delta-time — Claude Code rule: what it does, how to install
render-delta-time instructs agents to use delta time in animation loops so motion remains consistent across all display refresh rates.
MIT ★ 4,719 updated 2026-10-24
.claude/rules/render-delta-time.mdWhat render-delta-time does
Static animation increments depend directly on frame frequency. A fixed step yields roughly 0.6 rad/sec at 60 fps, but reaches around 1.44 rad/sec on a 144 Hz monitor. This causes erratic motion on different screens.
The rule enforces tracking frame duration with THREE.Clock and clock.getDelta(). It includes standard patterns for linear movement, sinusoidal oscillation via clock.getElapsedTime(), and frame-rate-independent lerp calculations.
What it helps with
- normalize animation speed across 30 fps, 60 fps, and 144 Hz displays
- apply delta-based lerp factors for smooth camera following
- implement time-based periodic movement using
THREE.Clock
Example prompts for the agent
- Update the render loop to use delta time for all object rotations
- Smooth out the camera position lerp using frame delta
How to install render-delta-time
Manually: put the files in place
.claude/rules/render-delta-time.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/render-delta-time.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/render-delta-time.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/render-delta-time.mdManually: put the files in place
.clinerules/render-delta-time.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about render-delta-time
How do I install render-delta-time in Claude Code?
Save the rule content into .claude/rules/render-delta-time.md in your project repository.
What does the render-delta-time rule do?
It guides coding agents to scale animation transforms by elapsed frame time rather than adding constant values per tick.
How does it handle lerp smoothing?
The rule suggests calculating the interpolation factor as 1 - Math.pow(0.001, delta) before passing it to lerp.
Source text
render-delta-time.md · MIT
# render-delta-time
**Use delta time for frame-rate independent animation.**
## Why It Matters
Without delta time, animations run faster on high refresh rate displays (144Hz) and slower on low frame rate devices. Delta time ensures consistent animation speed regardless of frame rate.
## Bad Example
```javascript
// BAD - Animation speed varies with frame rate
function animate() {
requestAnimationFrame(animate);
object.rotation.y += 0.01; // Fast on 144hz, slow on 30hz
renderer.render(scene, camera);
}
```
At 60fps: rotates ~0.6 rad/sec
At 144fps: rotates ~1.44 rad/sec
At 30fps: rotates ~0.3 rad/sec
## Good Example
```javascript
// GOOD - Consistent speed regardless of frame rate
const clock = new THREE.Clock();
function animate() {
const delta = clock.getDelta(); // Time since last frame in seconds
object.rotation.y += 1.0 * delta; // 1 radian per second, always
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
```
Now the rotation is always 1 radian per second, regardless of frame rate.
## Common Patterns
### Movement
```javascript
const speed = 5; // units per second
function animate() {
const delta = clock.getDelta();
object.position.x += speed * delta;
}
```
### Lerp with Delta
```javascript
function animate() {
const delta = clock.getDelta();
const lerpFactor = 1 - Math.pow(0.001, delta); // Smooth, frame-rate independent
camera.position.lerp(targetPosition, lerpFactor);
}
```
### Time-based Effects
```javascript
function animate() {
const elapsed = clock.getElapsedTime(); // Total time since start
object.position.y = Math.sin(elapsed * 2) * 2; // Oscillate at 2 Hz
}
```
## References
- [Three.js Clock](https://threejs.org/docs/#api/en/core/Clock)
© zebbern · MIT · zebbern/claude-code-guide