Skip to main content
rule CX Codex

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

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/render-delta-time.md
Open on GitHub

What 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.md

The paths frontmatter field limits the files

Step 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

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set86

The whole set →
server-auth-actions The server-auth-actions rule puts authentication and permission checks inside every Server Action. Use it to guard server mutations that callers can invoke directly. CX Codex +1 ★ 4,719repo stars setup-use-import-maps setup-use-import-maps — a rule that swaps the old Three.js CDN <script src> tag for an import map with ES modules and a pinned version. CX Codex +1 ★ 4,719repo stars memory-dispose-geometry memory-dispose-geometry is a Claude Code rule that tells the agent to release geometry when removing scene objects. It applies to Three.js resource cleanup. CX Codex +1 ★ 4,719repo stars root-cause-debugger The root-cause-debugger subagent for Claude Code and Codex reproduces failures and finds bug root causes before code changes. It helps diagnose bugs without editing code. CX Codex ★ 4,719repo stars code-reviewer code-reviewer is a Claude Code subagent that checks completed work for bugs and regressions. It runs after implementation or when an existing diff needs review. CX Codex ★ 4,719repo stars perf-visibility-toggle perf-visibility-toggle guides the AI to toggle the visible prop on Three.js components rather than conditionally unmounting them, avoiding GPU shader recompilation. CX Codex +1 ★ 4,719repo stars perf-r3f-perf The perf-r3f-perf rule teaches Claude Code about r3f-perf, a performance monitoring library for Three.js scenes in real time. Spot frame drops, memory leaks, and unnecessary matrix recalculations as they happen. CX Codex +1 ★ 4,719repo stars codebase-mapper codebase-mapper maps repository structure, call chains, and data flows before code changes without mutating any files. CX Codex ★ 4,719repo stars

Project sponsors

Companies that keep this analytics open