schteppe / cannon.js

A lightweight 3D physics engine written in JavaScript.
http://schteppe.github.com/cannon.js
MIT License
4.69k stars 712 forks source link

How to change a body that collides, to one that falls without collisions? #415

Open MillerMark opened 5 years ago

MillerMark commented 5 years ago

New to cannon.js. Trying to get a rigid body that rolls across the table to suddenly fall through the table and head toward the gravity center. I tried setting collisionResponse = 0; on the body, which works for 1-2 seconds and then throws this exception (I believe around the time the body hits the gravity center):

cannon.js:11048 Uncaught RangeError: Maximum call stack size exceeded at Narrowphase.createContactEquation (cannon.js:11048) at Narrowphase.(anonymous function).Narrowphase.planeConvex (http://localhost:44303/lib/dice/node_modules/cannon/build/cannon.js:12209:26) at Narrowphase.getContacts (cannon.js:11256) at World.internalStep (cannon.js:13359) at World.step (cannon.js:13197) at World.check (dice.js:79) at World.dispatchEvent (cannon.js:10576) at World.internalStep (cannon.js:13649) at World.step (cannon.js:13197) at World.check (dice.js:79)

Any suggestions? Is this the right way to do this?

MillerMark commented 5 years ago

As a work-around, I tried setting mass to 0 and animating the body's scale while spinning it to give the illusion that the body was falling through a hole. While this provides the look I want, unfortunately this too results in an exception after a few seconds:

Uncaught RangeError: Maximum call stack size exceeded at Function.ConvexPolyhedron.project (cannon.js:8701) at ConvexPolyhedron.testSepAxis (cannon.js:8212) at ConvexPolyhedron.findSeparatingAxis (cannon.js:8092) at Narrowphase.(anonymous function).Narrowphase.convexConvex (http://localhost:44303/lib/dice/node_modules/cannon/build/cannon.js:12263:11) at Narrowphase.(anonymous function).Narrowphase.boxConvex (http://localhost:44303/lib/dice/node_modules/cannon/build/cannon.js:11290:10) at Narrowphase.getContacts (cannon.js:11256) at World.internalStep (cannon.js:13359) at World.step (cannon.js:13197) at World.check (dice.js:79) at World.dispatchEvent (cannon.js:10576)