health-bars

Render health bars above 3D characters using Drei Html and scaleX.

31|Updated Jan 19, 2026
One-click install
npx skills add https://github.com/verekia/r3f-gamedev --skill health-bars
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: health-bars
Source: https://github.com/verekia/r3f-gamedev/tree/main/skills/health-bars
Command: npx skills add https://github.com/verekia/r3f-gamedev --skill health-bars

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Health bars provide at-a-glance visibility of character survivability in 3D scenes; this skill demonstrates a simple pattern to render and animate health indicators above entities using React Three Fiber and Drei's Html component.

Core Features & Use Cases

  • Use Drei's Html component to render health bars in 3D space above entities.
  • Drive the bar width with a DOM element's scaleX via a ref inside useFrame for smooth, performant updates.
  • Style the bars with CSS (gradients, borders, and color transitions) to clearly convey health status.
  • Use-cases include player health, enemy HP indicators, or ally status overlays directly in the scene.

Quick Start

Place an Html container above the character and attach a ref to the inner bar that scales horizontally according to the health percentage.

Frequently Asked Questions about health-bars

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I display health bars above characters in a React Three Fiber 3D scene?

To display health bars above characters in a React Three Fiber 3D scene, use Drei's Html component to render a DOM element in 3D space and scale its width via transform: scaleX() inside useFrame for smooth updates.

Can I use Drei Html to render UI elements like health bars in three.js?

Yes, you can use Drei Html to render UI elements like health bars in three.js by placing an Html container above the character and attaching a ref to an inner DOM element that scales horizontally according to the health percentage.

What's the best way to animate health bar updates smoothly in React Three Fiber?

The best way to animate health bar updates smoothly in React Three Fiber is to update a DOM element's transform: scaleX() property through a ref inside the useFrame loop, ensuring performant per-frame rendering.

Do I need React and @react-three/drei to show 3D health indicators above entities?

Yes, you need React, three.js, and @react-three/drei to show 3D health indicators above entities, as this pattern relies on Drei's Html component and React Three Fiber's useFrame hook for rendering and updating.

How to style health bars with CSS to convey health status in a 3D UI?

To style health bars with CSS to convey health status in a 3D UI, apply gradients, borders, and color transitions to the DOM element rendered by Drei Html, allowing clear visual feedback for player, enemy, and ally units.