一键导入
r3f-ui-useframe
Sync UI elements with the React Three Fiber render loop without causing unnecessary React re-renders.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Sync UI elements with the React Three Fiber render loop without causing unnecessary React re-renders.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use React Three Fiber camera shake when a player takes damage or on impacts for visual feedback.
Display React Three Fiber floating damage numbers that animate upward and fade out, with support for critical hits.
Display React Three Fiber health bars above characters using Drei Html and CSS styling.
Display a React Three Fiber pulsing red vignette overlay when the player's health is low.
Make React Three Fiber enemies flash white and rock back and forth when receiving damage.
Poll for React Three Fiber value changes and trigger React re-renders when needed.
| name | r3f-ui-useframe |
| description | Sync UI elements with the React Three Fiber render loop without causing unnecessary React re-renders. |
Sync UI elements with the render loop without causing unnecessary React re-renders.
In this project, React Three Fiber is currently on v8, so useFrame should run inside the Canvas tree. For DOM HUDs outside the Canvas, prefer normal React state from the simulation. When a DOM value truly needs render-loop cadence, put a tiny bridge component inside the Canvas that writes to refs or an external store.
useFrame belongs inside <Canvas>const UiBridge = ({
positionRef,
valueRef,
}: {
positionRef: React.RefObject<{ x: number; y: number }>
valueRef: React.RefObject<HTMLDivElement>
}) => {
const elapsedRef = useRef(0)
useFrame((_, delta) => {
elapsedRef.current += delta
if (elapsedRef.current < 1 / 10) return
elapsedRef.current = 0
if (positionRef.current && valueRef.current) {
valueRef.current.innerText =
`${positionRef.current.x.toFixed(2)}, ${positionRef.current.y.toFixed(2)}`
}
})
return null
}
const Ui = () => {
const ref = useRef<HTMLDivElement>(null)
const positionRef = useRef({ x: 0, y: 0 })
return (
<>
<Canvas>
<Scene />
<UiBridge positionRef={positionRef} valueRef={ref} />
</Canvas>
<div ref={ref} className="fixed top-4 right-4" />
</>
)
}
This skill is part of verekia's r3f-gamedev.