@@ -313,6 +313,8 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
313313 if ( this . miraType === MiraType . ROBOT || ! cameraControls . focusProvider ) {
314314 cameraControls . focusProvider = this
315315 }
316+
317+ MirabufObjectChangeEvent . dispatch ( this )
316318 }
317319
318320 // Centered in xz plane, bottom surface of object
@@ -431,6 +433,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
431433 if ( this . _brain && this . _brain instanceof SynthesisBrain ) {
432434 this . _brain . clearControls ( )
433435 }
436+ MirabufObjectChangeEvent . dispatch ( null )
434437 }
435438
436439 public eject ( ) {
@@ -986,3 +989,29 @@ export class RigidNodeAssociate extends BodyAssociate {
986989}
987990
988991export default MirabufSceneObject
992+
993+ export class MirabufObjectChangeEvent extends Event {
994+ private static _eventKey = "MirabufObjectChange"
995+ private _obj : MirabufSceneObject | null
996+
997+ private constructor ( obj : MirabufSceneObject | null ) {
998+ super ( MirabufObjectChangeEvent . _eventKey )
999+ this . _obj = obj
1000+ }
1001+
1002+ public static addEventListener ( cb : ( object : MirabufSceneObject | null ) => void ) : ( ) => void {
1003+ const listener = ( event : Event ) => {
1004+ if ( event instanceof MirabufObjectChangeEvent ) {
1005+ cb ( event . _obj )
1006+ } else {
1007+ cb ( null )
1008+ }
1009+ }
1010+ window . addEventListener ( this . _eventKey , listener )
1011+ return ( ) => window . removeEventListener ( this . _eventKey , listener )
1012+ }
1013+
1014+ public static dispatch ( obj : MirabufSceneObject | null ) {
1015+ window . dispatchEvent ( new MirabufObjectChangeEvent ( obj ) )
1016+ }
1017+ }
0 commit comments