Babylon.js icon indicating copy to clipboard operation
Babylon.js copied to clipboard

[Tooling] Support undo/redo

Open carolhmj opened this issue 2 years ago • 9 comments

This would improve user experience on NME, GUI Editor, etc... And a generic solution can be used in future tools.

carolhmj avatar Jul 11 '23 19:07 carolhmj

Some forum requests for this: https://forum.babylonjs.com/t/add-shortcuts-to-undo-and-redo-in-the-gui-editor/42326 https://forum.babylonjs.com/t/nme-improvements/35266 https://forum.babylonjs.com/t/gui-editor-improvements-suggestion-feedback-parts-1-to-6/32704 https://forum.babylonjs.com/t/nodematerial-add-undo/30672/2

carolhmj avatar Jul 11 '23 19:07 carolhmj

I have a generic script for "Commands" that you could wrap all the existing functionality in pretty easy.

https://github.com/Pryme8/Doomish/blob/main/src/Editor/Commands/Command.ts

Not sure if this would do it for you, but it has worked in every project that I have made that needs undo redo.

You can see how its used by the editor here: https://github.com/Pryme8/Doomish/blob/main/src/Editor/Editor.ts#L295

and then a simple example command would be like this: https://github.com/Pryme8/Doomish/blob/main/src/Editor/Commands/Common/DeleteRoomCommand.ts Normally you just define them inline and not on a separate file like this, here is an example of that: https://github.com/Pryme8/Doomish/blob/main/src/Editor/Gizmos/Gizmos.ts#L91

This can also be tied into a notification system that stacks little popups to the user notifying them when they have ran/undone a command etc.

If you are interested let me know, if not no worries!

Pryme8 avatar Jul 18 '23 22:07 Pryme8

Hi, I'm curious if there are any updates on this feature? It would really improve the ux of the editor :)

borismoyosa avatar Oct 18 '23 09:10 borismoyosa

This is still on our agenda. It is simply not that trivial with our current architecture. If we want to deliver something, we want to deliver it the best we can. We have no timeline on this, sadly.

RaananW avatar Oct 18 '23 11:10 RaananW

I understand, thanks for the reply!

borismoyosa avatar Oct 18 '23 14:10 borismoyosa

https://github.com/Pryme8/Doomish/blob/main/src/Editor/Commands/Command.ts

The link you provided cannot be opened, I would like to refer to it

Jeggery avatar Mar 21 '24 14:03 Jeggery

Since NME etc. are mainly based on JSON it might be very simple to use immer and Json patches? Immer can generate changes and inverseChanges

Immer however produces immutable data structures. And every change on the json would need to be wrapped by immer then. But it is pretty convenient.

dennemark avatar Apr 10 '24 09:04 dennemark

This issue has been automatically staled because it has been inactive for more than 14 days. Please update to "unstale".

github-actions[bot] avatar May 09 '24 00:05 github-actions[bot]