Skip to content

feat: add @3d-dice/dice-box as visual overlay on dice roll#207

Open
Copilot wants to merge 5 commits into
mainfrom
copilot/add-extra-3d-dice-visual
Open

feat: add @3d-dice/dice-box as visual overlay on dice roll#207
Copilot wants to merge 5 commits into
mainfrom
copilot/add-extra-3d-dice-visual

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 25, 2026

Adds a full-screen 3D dice roll animation that plays on top of the board whenever dice are rolled, using @3d-dice/dice-box. The 3D dice use the default dot/pip theme and play as a pure visual overlay — the game's existing rollDie() logic is unchanged and the 3D animation is triggered after the roll as eye candy.

The 2D board dice have also been updated to display dot/pip faces instead of digit numerals.

Changes

  • @3d-dice/dice-box added as a dependency; static assets (ammo wasm + default dot/pip theme textures) committed to public/assets/dice-box/
  • DiceBox3D.tsx — new component that initialises DiceBox once on mount and exposes a roll(values: number[]) method via useImperativeHandle; renders a position: fixed; pointer-events: none canvas overlay that fades in on roll and auto-dismisses 600ms after dice settle
  • vite-env.d.ts — TypeScript module declaration for the untyped package
  • index.tsx — renders <DiceBox3D ref={diceBox3DRef} /> and calls diceBox3DRef.current?.roll(dice) after the synchronous rollDie()-based roll as a visual overlay
  • digit-N-{black,white}.png — all 12 die face images replaced with dot/pip versions (rounded square background, white pips on dark for black dice, dark pips on light for white dice)

@ProLoser ProLoser marked this pull request as ready for review April 25, 2026 22:24
@ProLoser ProLoser self-requested a review as a code owner April 25, 2026 22:24
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 25, 2026

PR Preview Action v1.8.1

🚀 View preview at
https://ProLoser.github.io/PeaceInTheMiddleEast/preview/pr-207/

Built to branch gh-pages at 2026-04-26 01:56 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@ProLoser
Copy link
Copy Markdown
Owner

use the dots ui instead of numbers for the dice and the dice results should match

@ProLoser
Copy link
Copy Markdown
Owner

@copilot use the dots ui instead of numbers for the dice and the dice results should match

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 25, 2026

@copilot use the dots ui instead of numbers for the dice and the dice results should match

Done in fe4a68f. The 3D dice already use the default dot/pip theme from dice-box. The matching values issue is fixed by making the 3D roll the source of truth: rollDice now awaits diceBox3D.roll(2), gets the actual values from onRollComplete, and uses those as the game dice — so the 2D and 3D displays always show the same numbers.

Copilot AI requested a review from ProLoser April 25, 2026 22:36
@ProLoser
Copy link
Copy Markdown
Owner

@copilot no revert your last commit. That was the wrong direction. I want you to make the new library library role end up on the values that I calculated the previous way so don't change how the dice is rolled change how the library is called so that we are passing the new dice values to it whenever we roll it instead of having the library have a random result. Also try and simplify and remove as much as you can from the library. Config

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 26, 2026

@copilot no revert your last commit. That was the wrong direction. I want you to make the new library library role end up on the values that I calculated the previous way so don't change how the dice ...

Done in bd0511d. rollDice is back to the original synchronous rollDie() approach. The dice values are now passed TO dice-box by temporarily overriding window.crypto.getRandomValues with a pre-seeded queue before calling box.roll() — each die value maps to a precomputed Uint32 pair that produces exactly that face through dice-box's internal Zl.range formula. The override is restored in onRollComplete. Config is also simplified down to just assetPath, suspendSimulation: true, delay, and scale (all physics-tuning params removed).

@ProLoser
Copy link
Copy Markdown
Owner

ProLoser commented Apr 26, 2026 via email

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 26, 2026

@copilot now the rollDie animation is broken, go back to your first commit
and JUST change to using dots instead of numbers

...

Done in dd3a770. Reverted all changes after the first commit and replaced the 12 digit die images with dot/pip faces (rounded square, white pips on dark background for black dice, dark pips on light background for white dice):

dice dots preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants