3DRoll: physics-based 3D dice in the browser, 18 materials, links that set the dice and material

3DRoll is a free web dice roller rendered with three.js (r186). Every roll starts from a random spin and force, the physics simulation takes over, and whatever face ends up on top is the result.

The part I’d like to share is the materials:

  • Crystal, amethyst, sapphire, emerald and rose quartz use MeshPhysicalMaterial with transmission, IOR, dispersion and attenuation color, plus a clearcoat layer.
  • Holographic uses iridescence (thin-film interference) with some metalness.
  • Marble, walnut, jade and terrazzo are textures with clearcoat.
  • Each material has its own collision sound set: glass, metal, resin, stone and wood.

Latest update: a tray above the Roll button to switch materials and dice in one tap, plus a Random material button. URLs can also carry state, e.g. ?dice=d20x2&mat=crystal opens two crystal D20s. That state only applies to that visit and doesn’t overwrite the visitor’s own settings.

Two crystal D20s: Online 3D Dice Roller – Free Physics Dice Simulator | 3DRoll
Holographic D20: 3D D20 Roller – Roll a 20-Sided Die Online Free | 3DRoll

Works on phone and desktop, no sign-up. Feedback welcome, especially on transmission performance on mobile and how the dispersion looks.

1 Like

Letting the URL carry the dice and material for one visit without touching the visitor’s saved settings is a really considerate detail.

On transmission performance on phones, two things from the WebGLRenderer source that might help. There’s a renderer.transmissionResolutionScale property (default 1.0) that shrinks the transmission render target, and its doc comment says lowering it can give significant performance improvements; at dice size, 0.5 on mobile might be hard to spot. Also, any transmissive material set to DoubleSide gets its back faces drawn into that target in an extra pass, so if the crystal dice look fine with FrontSide, that’s one less draw per die.

Have you compared frame times with the gem materials against marble on a mid-range phone? I’d be curious how big the gap is.

Thanks for noticing that detail! Keeping shared links from overwriting someone’s own saved setup was exactly the goal. Both tips are really useful. I haven’t properly compared frame times for gem vs. marble materials on a mid-range phone yet, so I’ll try lowering transmissionResolutionScale and switching the gems to FrontSide, then come back with numbers. Any other suggestions are welcome; I’ll keep improving it.

Glad they help! Curious to see what the numbers look like once you’ve tried them. Nice work on the materials either way, the gems look great.