BabylonJS / Editor

Community managed visual editor for Babylon.js
http://editor.babylonjs.com/
813 stars 232 forks source link

Modifications events #48

Closed Speuta closed 6 years ago

Speuta commented 6 years ago

Hi,

Is there a way we can listen for all modifications ? Something like:

BABYLON.Editor.on("change", (object, attribute, value) => { //DO STUFF HERE });

Where "object" can be the mesh or the material edited, "attribute" can be "diffuseColor", and "value" the hexa of the diffuse for example ?

Regards,

julien-moreau commented 6 years ago

Sure I can add! :) Are you using the V1 or the V2 of the Babylon.js Editor?

julien-moreau commented 6 years ago

The preview of the V2 is available here: http://editor.babylonjs.com/v2

Speuta commented 6 years ago

I don't have any constraints about versions, V2 is ok for me ;)

Many thanks !!

julien-moreau commented 6 years ago

Hey, just added in the V2 here: https://github.com/BabylonJS/Editor/commit/bded1b722c8c4504c30473f66bc2dbb0de9058e1

I do not close the issue right now because I don't notify you for EVERY changes, will add more changes notifications in future :)

You can now type:

editor.core.onGlobalPropertyChange.add((result) => {
        console.log(result.object); // The modified object
        console.log(result.property); // The proeprty changed (as string)
        console.log(result.value); // New value after change
        console.log(result.initialValue); // Value before change
});
julien-moreau commented 6 years ago

@devAxeon fixed, all modifications are plugged to undo-redo :) Closing the issue

Speuta commented 6 years ago

Great !! Thank you a lot !!