Skip to content

Error in ConvexPolyherdron.clipAgainstHull on collision check #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
leroy opened this issue Aug 2, 2015 · 3 comments
Closed

Error in ConvexPolyherdron.clipAgainstHull on collision check #217

leroy opened this issue Aug 2, 2015 · 3 comments

Comments

@leroy
Copy link

leroy commented Aug 2, 2015

Hi,

I set up a world using this code:

    @physicsWorld = new CANNON.World()
    @physicsWorld.broadphase = new CANNON.NaiveBroadphase()
    @physicsWorld.gravity.set(0, 0, 0)

    @physicsWorld.solver.iterations = 10

    @physicsWorld.defaultContactMaterial.contactEquationStiffness = 1e6;
    @physicsWorld.defaultContactMaterial.contactEquationRelaxation = 10;

And two bodies:

     @debugCubeBody = new CANNON.Body({
        mass: 1,
        shape: new CANNON.Box(new CANNON.Vec3(1, 1, 1)),
        position: new CANNON.Vec3(20, 0, 0),
        quaternion: new CANNON.Vec3(0, 0, 0),
        velocity: new CANNON.Vec3(1, 0, 0)
    })
    @physicsWorld.addBody(@debugCubeBody)

    geom = new THREE.BoxGeometry(2, 2, 2)
    mat = new THREE.MeshBasicMaterial({
        color: 0x00FF00,
        wireframe: true
    })
    @object = new THREE.Mesh(geom, mat)
    @scene.add(@object)

    dimensions = new THREE.Box3().setFromObject(@object).size()

    @body = new CANNON.Body({
        position: new CANNON.Vec3(0, 0, 0),
        shape: new CANNON.Box(new CANNON.Vec3(dimensions.x, dimensions.y, dimensions.z)),
        quaternion: new CANNON.Vec3().copy(@object.quaternion),
        mass: 1
    })
    @world.addBody(@body)

However, when one of the bodies comes near the other, an error occures.
polyB is undefined, because closestFace never gets set. At this point i'm out of options.
I hope i have provided you with enough information.

  • The code is written in coffeescript, but this should be understandable from a javascript's perspective.
@leroy
Copy link
Author

leroy commented Aug 3, 2015

Any chance i could get some help with this matter?

@schteppe
Copy link
Owner

schteppe commented Aug 3, 2015

Maybe it's because you set the quaternion to a Vec3 instead of a Quaternion?

@leroy
Copy link
Author

leroy commented Aug 3, 2015

Sigh.. this solved the error. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants