I want to create a dice throw animation that ends in a specific number, pulled from random.org then pass it to the code that will generate the animation.

I thought about pre-baking multiple animations for each dice face. But there are multiple types of die and I think it would be necessary perhaps hundreds of animations for this to not look pre-baked.

Then I thought about creating "loaded dice" using the physics engine so that the throw is very biased. It doesn't need to be exactly the number pulled from random.org, since it's random anyway.

I'll use a js physics engine like cannon, but any example will help me wrap my head around this.

1

There are 1 best solutions below

0
On

You don't need to use random.org (in fact, I would recommend not using it based on its Automated API requirements).

The nature of using physics-based dice is enough. You just have to create a system to track which face is up.

Creating loaded dice on the other hand would require a little more work. You can try to implement one of the tried-and-true methods (that come with free prison sentences, too!) or just impart a tiny bit of force when the desired side is guaranteed not to come up.