threejs-editor

Calculating plane dimensions on THREEJS


I have a 2D plane in a 3D world. The plane can have any arbitrary orientation, so just getting boundboxmax and min, and do x2-x1 for width and y2-y1 for height won't work. How should I solve this?. I was thinking about calculating the angles and rotate the plane so it's normal faces the positive y axis, this way I could calculate differences in x and z coords. But how do I do that?


Solution

  • If you have a quad of any orientation and can get any three points of the quad (say (x1,y1,z1), (x2, y2, z2), (x3, y3, z3)) you can construct a Line3 with points 1 and 2 and with 2 and 3, then use Line3.distance() to get each of the sides.