Physijs - ConvexMesh wall collision detection issue

1k views Asked by At

I'm using Three.js and Physijs. I have a wall that should act as a boundary, but objects (especially boxes) often pass through it, if the force is sufficient. The collision is detected, as they do not do so cleanly, but they start spinning or bounce in some direction. Is there a way to increase the maximum force with which the wall can act on the colliding object?

All four of the wall's points are on the same plane, forming a rectangle. The mesh consists of two large triangular faces. I'm using a ConvexMesh.

Breaking the two triangles into many smaller ones does not alleviate the problem.

I can confirm the normals are fine, as the wall is shaded correctly.

How can I solve this without converting the wall into a BoxMesh?

I'll also appreciate an explanation of why this happens. I'm guessing that the engine limits the maximum force that collisions can apply.

1

There are 1 answers

0
Boris Angelis On

I think it's Motion Clamping

https://github.com/chandlerprall/Physijs/wiki/Collisions

When an object has a high velocity, collisions can be missed if it moves through and past other objects between simulation steps. To fix this, enable CCD motion clamping. For a cube of size 1 try:

// Enable CCD if the object moves more than 1 meter in one simulation frame mesh.setCcdMotionThreshold(1);

// Set the radius of the embedded sphere such that it is smaller than the object mesh.setCcdSweptSphereRadius(0.2);

Hope this works ima try it now