Setting up a Three.js scene for Physijs is very simple and only takes a couple of steps. The first thing we need to do is include the correct JavaScript file, which you can get from the GitHub repository at http://chandlerprall.github.io/Physijs/. Add the Physijs library to your HTML page like this:
<script type="text/javascript" src="../libs/physi.js"></script>
We've also included the necessary libraries in the sources of this book. Note that there is a bug in the Physijs code, which causes issues when using the point constraint. The Physijs library provided with the book contains a patch to make the code work correctly even with this specific constraint.
Simulating a scene is rather processor-intensive. If we run all the simulation computations on the render thread (since JavaScript...