Creating a basic Three.js scene with physics

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. ...

Get Learn Three.js - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.