Setting world matrix for implementing undo redo feature

I have created a dummy playground with only one cube with the capability of translation and rotation. Moreover I have added the two GUI Buttons for undo and redo.

I wantto implement the basic undo redo feature when the mesh is translated and/or rotated.

I understand that when dragEndObservable is called I get the new world Transformation matrix corresponding to the mesh, which I need to store in the undo stack.
I can get this using event.pointerInfo.pickInfo.pickedMesh._worldMatrix

I am able to store it. When undo operation is being performed , I am popping the world transformation matrix from the stack. However I am not been to find an API for setting the world Matrix directly into the mesh of interest(without baking the transformation into the mesh).

Babylon community, I Need help to sort this out.

You can use decomposeToTransformNode of Matrix to set world matrix of mesh:

PG Example:

1 Like

event.pointerInfo.pickInfo.pickedMesh._worldMatrix: you should probably use event.pointerInfo.pickInfo.pickedMesh.getWorldMatrix() instead, as _worldMatrix is a private variable.

1 Like