Scene changed event to track modification of the scene

I would like to implement a CTRL+Z feature, and I would like to use the SceneRecorder to do it. But how can I get an event where the scene has changed (mesh added, position of a mesh changed, and so on) in order to register the state of the scene in some way?

Thank you

Toni

There are plenty of observables you could hook into. The simplest is too look into the code for observable to have the full list.

Unfortunately for perf concerns there are things you will probably not be able to track so it all depends and what exactly you are trying to get.

What I was looking for was some event on the scene that is called when something significant changes, but looking on the documentation I just found events like “onAfterRenderObservable” that are too heavy called. The purpouse is to save the last “state” of the scene, do you think I am following the right path?

Thank you

Toni

You have all the on mesh added observable and so on that tou could rely on. But may I ask what is your use case exactly ? It might help finding the best strategy.

I want to implement a CTRL+Z command to undo the operation made on the scene. I was thinking about making a “snapshot” every time the scene changes, and so I can keep a “storyboard” of the changes and apply them on the reverse order.

The main thing is what is creating the changes ? cause you could serialize changes at this level instead of listening to the scene ?

Yes, I was trying to do the same in effect, but I was wondering if there’s a global event I can use intead of putting code everywhere in my lib. If you think it’s difficult to trap such a situation, I will stay with the original idea and insert the “snapshot” whenever I need. Just I was thinking, if I want to undo some changes just on the movement of an object or something like that?

Thank you again for your precious help

2 Likes