スキル一覧に戻る
verekia

smooth-interpolation

by verekia

⚛️ React Three Fiber Game Dev Recipes

17🍴 0📅 2026年1月22日
GitHubで見るManusで実行

SKILL.md


name: smooth-interpolation description: Animate values smoothly using exponential decay instead of linear interpolation.

Smooth Interpolation

Animate values smoothly using exponential decay instead of linear interpolation.

Technique

Use exponential smoothing formulas to interpolate between current and target values. This creates a natural easing effect that's frame-rate independent.

Key Concepts

  • Exponential smoothing: (target - current) * (1 - Math.exp(-speed * dt))
  • Exponential decay: target + (current - target) * Math.exp(-decay * dt)
  • Both formulas produce the same result with different parameters
  • Speed/decay values from 1-25 work well
  • Frame-rate independent due to delta time usage

Usage

const addSmoothExp = (current: number, target: number, speed: number, dt: number) =>
  (target - current) * (1 - Math.exp(-speed * dt))

const expDecay = (current: number, target: number, decay: number, dt: number) =>
  target + (current - target) * Math.exp(-decay * dt)

useFrame((_, delta) => {
  mesh.position.x += addSmoothExp(mesh.position.x, targetX, 3, delta)
  // or
  mesh.position.x = expDecay(mesh.position.x, targetX, 3, delta)
})

References


This skill is part of verekia's r3f-gamedev.

スコア

総合スコア

65/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

レビュー

💬

レビュー機能は近日公開予定です