Determine whether a plane is landscape or portrait

Is it possible to determine whether a plane is landscape or portrait?

Given that there are many random planes, is there a way to know whether one plane is landscape or portrait on click?

Here is a sample playground https://playground.babylonjs.com/#KHRZG3#3
(In this example, you can see that if you click on a plane that portrait plane, it looks zoomed in but if you click a portrait plane it still looks a bit zoomed out.)

I hope you can help me with this :slight_smile:

You could transform the bounding box of the clicked plane with its world transform matrix than use the x/y/z extents to compute the camera radius. It’s basically the existing code the computes mx but using the transformed bounding box instead of the bounding box itself.

Sorry I am a bit new to 3D concepts, when you mention to update it you mean to say the bx to the value of the world matrix using TransformCoordinates (local position being the mesh and matrix coming from mesh.computeWorldMatrix)?

Not quite sure if this is it what your’e saying but I am currently trying this:Introduction To Coordinate Transformation | Babylon.js Documentation but I am not quite sure whether this is the right approach or not.

The coordinates would be the x/y/z extents you get from the bounding box (bx.minimum, bx.maximum) and you would transform them with bx.getWorldMatrix(). To compute the distance, you should use the max difference in the x/y/z dimensions, something like:

1 Like

I see! A quick out of the topic of this original question but ideally would this also work to get the rotation of the bounding box? If so how would you do it (currently alpha and beta uses plane’s rotation but in my current implementation I’m using rotation quaternion)?

You can get the rotation from a matrix by using matrix.decompose(...), so calling this method with bx.getWorldMatrix() will get the rotation quaternion. Now, you would need to convert it to polar coordinates as it is what the arc rotate camera is expecting…

And polar coordinates is not equivalent to euler angles. That is what I tried to do ( rotation quaternion to euler) but it ended up being not what I wanted :frowning: