With my mouse pointer, I would like to move a Mesh around as in this Playground. I’ve modified the original to not move with collisions because I would instead like to have the Mesh move such that:
- The Mesh always moves to the picked point (as it is in the Playground)
- As I move the Mesh around, it should dynamically move its height so that it is above any other object that it would otherwise collide with.
So if I move the red cube around and it would collide with the purple cube, it will instead be just above the purple cube. If the purple cube is stacked on top of the blue cube and the red cube would be moved to collide with the blue cube, the red cube will move above both the blue and purple cubes.
What I’ve tried: As I move around a Mesh, I check to see if it’s intersecting any other Mesh in the scene. If it is, then move the position up a touch, check for intersection, then move it up again until finally there’s no intersection with any other Mesh. The problem with this is that if I have a Mesh that I am moving and it intersects with a second Mesh, then when I move its position up to a point where it should be clear,
intersectsMesh will always return
true unless I re-render the scene with a
Surely there’s a better way to do this and I imagine someone might have an example Playground where it’s already been done.