Hierarchybounding vectors min & max along an axis

I have a GLTF scene mesh which has one or more tables that are touching a wall. The wall can be arbitrarily placed anywhere in the scene. The normal of the wall is known.

Now, I’d like to place items on the table from left to right. In order to do that i need to know the 2 points that represent the imaginary line on which objects can be placed. i.e. the horizontal line starting from middle of left edge of the table to the right edge.

I think I can get the 2 points by getting somevariation of the HierachyBounding vector of the table; For example this works if the wall normal is pointing towards -Z in which case the table’s left and right edges can be derived by looking at the min and max

const min = shelf.getHierarchyBoundingVectors().min;
const max = shelf.getHierarchyBoundingVectors().max;
const extendSize = shelf.getBoundingInfo().boundingBox.extendSize;
let left = new Vector3(max.x - extendSize.x/2, max.y, max.z - extendSize.z/2);
let right = ...something simlar
..then generate points between left and right to place items

but that wont work if the wall normal is pointing in any other direction.

What I’d like to get is not the world min, max but the min, max when looking at it from a particular direction. Any ideas on this can be achieved?

I’m not sure this is an easy task…

It might be more tractable if:

  • you make sure the table is in the X-Z plane, so it is a 2D problem (the Y coordinate does not matter and the top of the table is at boundingBox.maximumWorld.y)
  • the table is aligned with the X-Z axis in its local space. The rotation of the table is done by table.rotation.y

With these assumptions, I think this is doable with a little work.