dice-core
2026-02-16
Initialize dice-core library with 3D physics simulation, React Three Fiber components, and secure throw system
114 files · 16,001+ · 6,971-
Core simulation engine
7 files changed
pre-simulate.tsDeterministic physics pre-simulation using Rapier with seeded RNG for reproducible dice rollsplayback.tsFrame-by-frame playback system that replays pre-simulated physics resultsspawn-configs.tsDice spawn position, rotation, and velocity configurationpre-simulate-async.tsAsync wrapper for pre-simulation with cancellation supportpre-simulate-worker.tsWeb worker for offloading pre-simulation to a background threadquat-math.tsQuaternion math utilities for orientation calculationsseeded-rng.tsSeeded random number generator for deterministic simulation
- Built a deterministic physics pre-simulation engine using Rapier that produces reproducible dice rolls via seeded RNG, with async and web worker execution options
instantiate
architectural
3 files
pre-simulate.tspre-simulate-async.tsseeded-rng.ts
React Three Fiber components
8 files changed
DiceArena.tsxMain arena component managing dice rolls, Rapier initialization, camera, and orchestrationDiceScene.tsxScene component handling simulation execution, settlement detection, and result reportingDiceRoller.tsxRoller component triggering dice throws with notation parsingDie.tsxIndividual die component for live physics interactionPlaybackDie.tsxDie component for frame-by-frame playback of pre-simulated resultsChamber.tsxInvisible physics boundaries containing dice within the arenaDiceLighting.tsxConfigurable lighting setup for the dice sceneErrorBoundary.tsxReact error boundary with WebGL context loss recovery
- Created a full React Three Fiber component hierarchy: DiceArena orchestrates DiceScene which manages Die/PlaybackDie instances within a Chamber with configurable DiceLighting
instantiate
architectural
3 files
DiceArena.tsxDiceScene.tsxDiceRoller.tsx
Dice geometry and face reading
6 files changed
geometry-data.tsGeometry definitions for all standard dice types (D4/D6/D8/D10/D12/D20/D100)face-reader.tsFace value determination from die orientation using normal vector alignmentnotation-parser.tsDice notation parser supporting standard formats like 2d6+3, 1d20, etc.custom-geometry.tsCustom geometry support for non-standard dicetextures.tsTexture generation for dice face numberingmodifiers.tsDice roll modifier application (bonuses, penalties, advantage)
- Implemented geometry data, face reading via normal alignment, notation parsing, and texture generation for all standard polyhedral dice types
instantiate
behavioral
3 files
geometry-data.tsface-reader.tsnotation-parser.ts
Configuration and types
4 files changed
defaults.tsDefault configuration values for physics, rendering, and arena settingsdice-configs.tsPer-die-type configuration (size, mass, restitution)config.tsTypeScript interfaces for all configuration optionsdice.tsDice type definitions and enums
- Defined comprehensive configuration defaults and TypeScript types for physics, rendering, arena, and per-die-type settings
instantiate
behavioral
2 files
defaults.tsconfig.ts
Visual system
4 files changed
die-meshes.tsThree.js mesh creation for dice with materials and textureschamber-meshes.tsArena boundary mesh generationface-data.tsFace positioning and UV data for all dice typesdie-visuals.tsxVisual component for rendering dice with glow and effects
- Built a vanilla Three.js visual layer with mesh factories, chamber boundaries, face data, and a die-visuals component with glow effects
instantiate
behavioral
3 files
die-meshes.tschamber-meshes.tsdie-visuals.tsx
Bug fixes across 8 iterations
1 file changed
rapier-init.tsRapier WASM initialization with retry logic
- Fixed number plane offset and depth clipping on D10/D12 dice, WebGL context loss crashes, D10 secure throw face value remapping, multi-dice spawn logic, pre-simulation arena containment, and die settling detection
harden
behavioral
4 files
DiceArena.tsxDiceScene.tsxDie.tsxPlaybackDie.tsx
Testing and CI
4 files changed
ci.ymlCI workflow for linting, testing, and buildingdice-roll.spec.tsE2E dice roll tests with Playwrightphysics-parity.spec.tsPhysics parity tests between simulation and playbackpublic-api.test.tsPublic API surface tests
- Added CI workflow, Playwright E2E tests for dice rolling and physics parity, and comprehensive unit tests for the public API, face reader, notation parser, and simulation engine
qualify
behavioral
3 files
ci.ymldice-roll.spec.tspublic-api.test.ts
Build and tooling
5 files changed
vite.config.tsVite build configuration for library outputeslint.config.jsESLint configuration.prettierrcPrettier formatting rulespre-commitPre-commit hook for lintingindex.htmlVanilla HTML example demonstrating dice-core usage