I’m trying to build a tool that helps user to “align” a 3d scanned object with the origin of the coordinate system, since I need that for some downstream processing. But when I bake the GizmoManager transform weird things happen. Does anyone know the magic incantation I need to perform on my transform Matrix to make it something that is correctly applicable to my glb vertices? And is this a bug?
Repo:
use the gizmo to move the model closer to the origin of the x,y,z axes, and rotate it to align with those axes.
then click the green “bake” button in the top left of the screen.
Actual: model jumps to random wrong location.
Expected: the model should not move when transform is baked.
You should put your pivot node as as child of the __root__ node that is created by the gltf loader to handle left/right handedness. Also, your meshes have an initial matrix which is not the identity (they have a rotation around the x axis), so baking using only the pivot matrix won’t produce the expected result as the x rotation will be applied afterward. So, you should:
bake the current transformation of the meshes just after loading time to reset their local matrix
Cool, thanks for your help, your solution is tantalizingly close, but sometimes, depending on order of operations, usually after translate/rotate combinations, the bake button doesn’t stick (meaning if you click the bake button multiple times without doing any gizmo manipulations the model moves by an increment each time)…
Repro steps:
Move model in + Z axis closer to the origin
Bake
Rotate around Y axis clockwise (green) to align with X axis
Bake
Rotate clockwise around Z axis (blue) to be horizontal with X axis
Bake
Bake
Bake
Bake
The model just keeps on rotating clockwise about Z axis like this: