スキル一覧に戻る
verekia

ui-useframe

by verekia

⚛️ React Three Fiber Game Dev Recipes

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

SKILL.md


name: ui-useframe description: Sync UI elements outside the Canvas with the render loop using R3F v10's external useFrame.

UI useFrame

Sync UI elements outside the Canvas with the render loop using R3F v10's external useFrame.

Technique

Since React Three Fiber v10, useFrame can be used outside of the Canvas component. This allows updating DOM elements in sync with the 3D scene without using Drei's Html component.

Key Concepts

  • useFrame works outside <Canvas> in R3F v10+
  • Use refs to manipulate DOM elements directly for performance
  • Throttle with { fps: N } option since DOM manipulation is expensive
  • Useful for HUDs, debug info, and UI that doesn't need to be in 3D space

Usage

const Ui = () => {
  const ref = useRef<HTMLDivElement>(null)

  useFrame(() => {
    ref.current.innerText = `${position.x.toFixed(2)}, ${position.y.toFixed(2)}`
  }, { fps: 10 })

  return <div ref={ref} className="fixed top-4 right-4" />
}

// Place outside Canvas
<Canvas>
  <Scene />
</Canvas>
<Ui />

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ヶ月以内に更新

+5
フォーク

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

0/5
Issue管理

オープンIssueが50未満

+5
言語

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

+5
タグ

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

+5

レビュー

💬

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