I want to make a sphere randomly bouncing INSIDE a box. I’m using physijs but I can’t make it work.
The problem is that I don’t really know what the right way to approach this problem is.
At the beginning I have used a BoxMesh and I tried positioning the sphere inside it but it always went out of the box. It looks like there is no way to keep a sphere inside a box.
So I have built 6 walls. They are basically 6 BoxMesh with size (50, 1, 50) and I positioned them so that they create a cube. Then I tried to keep the sphere inside these walls in the following ways:
I tried to detect collisions and change the sphere’s position in the render function, but it turned out to be too complicated.
Then I tried “applyCentralImpulse” but it was still too complicated because I had to manage the positions.
I know there are “constraints” in physijs, but I am not sure which one I should use.
Is there something in physijs that automatically handles such a scenario?