Hi Nico, welcome to the new forum.
Let’s make a demo playground, eh?
IF… the blue sphere… is parented-to the outer containers, then you can check blue sphere parents. See lines 61/62, and JS console on that playground.
If NOT parented… much more work, perhaps. I have turned-ON showBoundingBox for all three mesh, and have output eachmesh.getBoundingInfo().boundingbox to console (lines 58-60). On each boundingbox object seen on console, there are many useful properties. Some are “world-space” measurements (like extendSizeWorld), and some are “local-space” measurements (like extendSize).
I don’t know your goal, but these are tools that COULD be useful. Physical containment of mesh… generally happens on a layer ABOVE BJS library (user-coded)… or possibly with the help of 3rd-party physics engines, which BJS has connectors-for. But, collision-testing on the inside of other mesh… can be challenging, possibly requiring the containment boxes to be assembled from 6 planes.
Ok, stay tuned for more comments. One question: Does the inner blue sphere need to “learn” IF/NOT it is contained? Or does it just need to “discover” its containers, and it WILL ALWAYS have one/some? Give more details about that, if possible. thx.