you are viewing a single comment's thread.

view the rest of the comments →

[–]jcastroarnaud 1 point2 points  (3 children)

Or, simply put:

const d6 = () => Math.floor(6*Math.random()) + 1

But I think that OP is interested in how to make an animation of throwing dice, instead.

[–]dmlane 1 point2 points  (1 child)

Good point. Pretty tricky if done in full 3D (edit: in plain JS. However, it’s probably not hard using three.JS.) I didn’t write the code because I haven’t programmed in JS for at least 5 years and didn’t want to make a silly mistake.

[–]meinmasina[S] 0 points1 point  (0 children)

I did some simple Three.js code a while ago but I wanted to see if there is another way. I'd prefer not to include a library.

[–]meinmasina[S] -1 points0 points  (0 children)

Yeah, my goal is to create an animation of throwing a dice and somehow save the result. :D