So basically I’ve started using CannonJS and got it working very well with ThreeJS on the client side. I wanted to now try to implement CannonJS on the server, but for some time now I have been met with a stack overflow error.
Whenever I try to add a body to the world, be it plane or cube, the server just overflows. I use NodeJS with Express, Socket.io for comms and trying to implement CannonJS. Below is picture of error:
If I make the function hasBinary return true by defualt, suddenly socket.io becomes the issue on the stack. Any idea what is going on?
function loadLevel(){
const cubeShape = new CANNON.Box(new CANNON.Vec3(.5, .5, .5))
var cubeBody = new CANNON.Body({ mass: 1 });
cubeBody.addShape(cubeShape)
cubeBody.position.x = 0
cubeBody.position.y = 20
cubeBody.position.z = 4
objects.push(cubeBody)
//FLOOR
//const planeShape = new CANNON.Plane()
const planeShape = new CANNON.Box(new CANNON.Vec3(15, 15, 0.1))
var planeBody = new CANNON.Body({ mass: 0, material: physicsMaterial })
planeBody.addShape(planeShape)
planeBody.position.set(0, 0, 0)
planeBody.quaternion.setFromAxisAngle(new CANNON.Vec3(1, 0, 0), -Math.PI / 2)
objects.push(planeBody)
/*
//THIS IS PROBLEM CODE
world.addBody(objects[0])
world.addBody(objects[1])
*/
}