I am representing a plane with box geometry (BoxGeometry(width, height, planeThickness)) where plane thickness is much smaller than width and height.

I am aligning the box with a plane created from three points by applying a matrix to the mesh. I want to accomplish this my applying a single matrix to the mesh, rather that to the mesh and to the geometry, because I need to use the same calculation in other functions.

And the function below successfully places the box representation of the plane through the three points. But the rotation about the plane normal and the position along the plane does not represent the location of the three points. I want to rotate and offset the box along the plane to align it with the two remaining points. But I have not been able to figure out how to do that.

You can simply apply to your mesh a quaternion which represents rotation from up vector (0, 1, 0) and plain normal, which is a Ńross product of vectors from point1 to point2 and point3

mesh.applyQuaternion(new THREE.Quaternion().setFromUnitVectors(
new THREE.Vector3(0,1,0),
point2.clone().sub(point1).cross(point3.clone().sub(point1)).normalize()
))

You donât need multiple matrices, you can apply rotation to your existing matrice:

matrix.makeRotationFromQuaternion(
new Quaternion().setFromUnitVectors(
new Vector3(0, 1, 0),
point2.clone().sub(point1).cross(point3.clone().sub(point1)).normalize(),
)
).setPosition(center)

I get a box that is not through the three points. Using the previous method, the box was aligned with the three points on the plane they created, just not within the plane.

Assuming the box (blue rectangle) is in the plane of the three points (black), and boxâs center is one of the points, then what does âalignâ mean? The next illustration is most likely not-aligned. How would it look like when the box is aligned?

Thanks @PavelBoytchev. Good question. I guess technically it would be the smallest rectangle by area that would go through all three points. But it is not critical. It just has to go through all the points and not have too much overhang. For example. In the first image below, I could just make the rectangle larger until it extended through each point, but that would be too large. That box is the correct size, but it needs to be rotated and translated to go through all three points. The second image is more like what I want.

Could you tell me the coordinates of the three points from the snapshot. I made some Q-n-D code that may produce plausible results (not guaranteed to be minimal area). I want to try it with your data. Here is what I get with random points: