I am playing with three JS and want to determine if a mesh is fully inside another mesh. I wrote a little robot which should run into a home box navigated by the player. I know how to detect collision, but is there an easy way to detect if an object is inside another object?
I could calculate center Position of the homebox and compare to robot Position, but maybe there is something build in to threejs.
If you make a boundingBox (
THREE.Box3
) for both the 'robot' and the 'home' you can use thecontainsBox
method. So something like this:Where
home
androbot
are your objects. Now you can do:robotIsHome
will be true if therobotBB
is completely insidehomeBB
.