I have the following fiddle, where you can move a cube using the arrow keys: Three.js base - JSFiddle - Code Playground
The goal is that you can move the cube on the grey plane but when you move it outside is should drop off. To do this I need to add some physics and I choose for Physijs. I already have added the call for it in the fiddle.
To implement this correctly I need to add and change some code and here the problems start. I also need ammo.js and a worker so in the javascript part of the fiddle I add:
// Physics
Physijs.scripts.ammo = ‘http://gamingJS.com/ammo.js’;
Physijs.scripts.worker = ‘http://gamingJS.com/physijs_worker.js’;
If you do this and press Run in the fiddle, the render will disappear. Okay perhaps this is because I need to do some more code changes, but at the moment the renderer is broken.
So I also added/changed:
scene = new Physijs.Scene();
scene.setGravity(new THREE.Vector3( 0, -50, 0 ));
Added to: function animate() {
scene.simulate(); // run physics
Changed for the cube and plane:
new Physijs.BoxMesh
As far as I can see these are the things I needed to change, but the renderer is still not showing anything. See this fiddle: Three.js base - JSFiddle - Code Playground
What am I missing here?