Determining internal objects

I wondering the best approach to determine which meshes are internal to another. For example, if I had a model of a PC, I would want to easily find all the internals (motherboard, power supply etc).

The only way I can think of doing this is to raycast from points around a sphere and see what parts get hit. If an object is never intersected then it must be internal(?). The more ray casts/points on the sphere that I do the tighter the tolerance.

This could lead to doing a lot of ray casts which seem inefficient, is there a better approach?

Maybe better to use Box3s to determine, if a an object is inside of another one, calling, for example, the .containsBox() method :thinking:

1 Like

to add to this… if a box3 ever partially falls outside the bounds of the containing box3 due to object orientation / AABB mismaches the box3 class also has a “containsPoint” method which can check if all points of a mesh are absolutely contained in the containing box3

2 Likes

I guess this method assumes I know the containing part(s)? Otherwise, you would have the check every box3 against every other box3.

What if it could be any complex model that is inserted in the scene e.g. a Car, where there are mulitple parts (bonnet, boot, doors, etc) that make up the external and then multiple interior parts (engine, steering wheel, seats etc) would the box3 method still be suitable?

You’d want to use extended libraries for detecting if complex shapes such as a car contains all points / bounding tree of another mesh for instance… shape intersection as part of the three-mesh-bvh library, whereby you can rapidly check if a box3 / all points of / all parts of a mesh are contained within a bounding volume hierarchy.

2 Likes

If you have control over the creation of the models, you can put inner objects as children of their outer objects. Thus, a small change in the input data will simplify the calculations.

This will also help you answer the question: is the rice inside the bowl, if it rises above the rim of the bowl?

istockphoto-860931464-612x612

3 Likes

I don’t have control over the creation of the model. For your rice example, in my use case, I would not treat that as internal. I’m looking to find parts that cannot be seen and hence can be discarded. Sounds like @Lawrence3DPK suggestion of three-mesh-bvh may be the best option

Just curious to know if you have decided on an approach and whether it has yielded the intended results. I have need for something - not exactly the same - but on similar lines.

Thanks much

OLDMAN

Unfortunately not yet, so if you get anywhere let me know!

I have an idea: a combination of ray-casting and something I call “face chasing”. Will need to try this out at some point and will keep you posted. But the idea is sort of opposite your problem statement:

  • find external objects
  • all those that are not external are internal
1 Like