Backsolving a Matrix4() transformation, from before and after positions

Three makes it easy to apply Matrix4 transforms to a geometry, to get a new geometry with new position attributes. Given position BufferAttributes before and after an affine transformation, is there an obvious way to reverse engineer the transformation matrix?

(Context, if you’re curious: I’m rendering many buildings as rectangular prisms, which can all be represented as transforms of a canonical cube. If i can determine the transform matrix for each building, i can render them all as InstanceMeshes of the cube).