logo

Babylon.js Market

PokerHUD

tabletop-casino · poker

PokerHUD

1
Unlock

Install with the CLI:

bjs download PokerHUD

PokerHUD

The opponents and the pot have to live somewhere the player can read at a glance. PokerHUD paints them as a row of glass pills over the canvas — one per seat, one for the pot — and lights the seat whose turn it is.

What it does

PokerHUD is the opponent-and-pot overlay, drawn as plain positioned DOM over the game canvas — readable pixel-sized text, not 3D-scaled labels. It owns no game state: it reduces the poker event stream into a per-seat HUD model (PokerHUD.core) and writes each seat's name, stack-and-bet, last action, and state into its pill.

On pokerTable.strategies it creates one NPC pill per seat and adopts each name and color; the player pill always exists. From there it is a pure consumer. It follows the PACED poker.display.turn and poker.display.action — the TurnPacer's staggered playback, not the raw poker.currentTurn / poker.actionTaken burst — so the turn glow and last-action label track the opponents as they visibly act. poker.chips updates every stack, bet, and the pot pill. pokerTable.handStarted clears each seat's action / fold / winner / turn state; pokerTable.handEnded marks the winners green; pokerTable.gameOver dims everyone but the last seat standing.

The seat model and the pure functions that compute each pill's text and state class (statusLine, chipsLine, pillClassName, potText) live in PokerHUD.core — no bus, no DOM. The System owns the overlay elements, touches document only behind a typeof document guard (the same precedent as PokerInput touching window), and tears the overlay down on shutdown. It never reaches this.world.renderer — this is plain DOM chrome, and it is game UI, not the viz/debug panel.

State drives the styling, by precedence: the active seat gets a blue glow border, a winner tints green, a folded seat tints faint red, and an eliminated seat dims. Turn beats fold so the live prompt always reads as the live seat.

Use it in a scene

PokerHUD is a singleton per table. Seat it on a presentation entity alongside the other display systems; the director's events do the rest.

A scene is just data — a list of entities, each with its components. At startup the SceneLoader turns this JSON into a live world; edit the file and reload to rebuild it.

Build it from scratch with the bjs CLI:

  1. 1Scaffold a project
    npm create @babylonjsmarket/arcade@latest my-game

    World, renderer, and dev server — ready to run.

  2. 2Install dependencies
    cd my-game && npm install
  3. 3Add PokerHUD
    bjs download PokerHUD

    Copies its source into src/ so the scene resolves.

    First time? Run bjs login once.

  4. 4Paste the scene into src/scenes/arcade-room.ts and run
    npm run dev

    SceneLoader builds the world from the JSON; reload to rebuild.

JSON
{
  "Presentation": {
    "components": {
      "TurnPacer": {},
      "PokerHUD": { "fontSize": 18 },
      "PokerTableCards": { "selectedBack": 1, "basePath": "/poker" }
    }
  }
}

The HUD needs no wiring of its own — PokerTableDirector + PokerBetting + TurnPacer already emit everything it reads. Drop it in and the pills appear.

Props

PropTypeDefaultMeaning
fontSizenumber18Base body font size (px) for a pill; name and chips rows scale off it.

Events

PokerHUD emits nothing — it is a pure consumer (PokerHUDInputEvents):

EventPayloadWhen
pokerTable.strategiesRecord<seatId, { name, initial, color }>Create the NPC pills + adopt their identities.
poker.display.turn{ playerId | null }Move the paced turn glow (null clears it).
poker.display.action{ playerId, action }Record a seat's paced last action (fold marks it folded).
poker.chips{ players: Record<id, { stack, bet }>, pot }Update every stack, bet, and the pot pill.
pokerTable.handStarted{}Clear per-seat action / fold / winner / turn state.
pokerTable.handEnded{ winnerIds, stacks? }Mark the winning seats.
pokerTable.gameOver{ winnerId }Eliminate (dim) everyone else.

Notes

  • The seat models and pill nodes live on the System, never on the Component — so serialize() round-trips to just { fontSize }.
  • Pills pin to fixed screen anchors that match the top-down seats: player bottom-center, npc0 left, npc1 top, npc2 right, pot near center-top. An extra seat id falls back near the top rather than stacking at the origin.
  • It consumes the poker.display.* paced variants on purpose. Wire it to the raw poker.currentTurn and the glow flashes through instantly — you would never see the opponents act.
  • Headless (no document), the seat model still tracks every event; only the pill creation is skipped, so the same System runs safely in a test or on the server.

More like this

PokerBetting
PokerTableDirector
TurnPacer
CardFan
DeckDealer
HealthBar
PokerAI
PokerAIBill
PokerAICali
PokerAIRandy
PokerAIShark
PokerAISurge
PokerAITilt
PokerHandEval
PokerInput
PokerMultiplayer
PokerSeating
PokerTableCards
Score
Scoreboard
SpaceShooterScore
Waypoint

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search