@@ -313,6 +313,8 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
313
313
if ( this . miraType === MiraType . ROBOT || ! cameraControls . focusProvider ) {
314
314
cameraControls . focusProvider = this
315
315
}
316
+
317
+ MirabufObjectChangeEvent . dispatch ( this )
316
318
}
317
319
318
320
// Centered in xz plane, bottom surface of object
@@ -431,6 +433,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
431
433
if ( this . _brain && this . _brain instanceof SynthesisBrain ) {
432
434
this . _brain . clearControls ( )
433
435
}
436
+ MirabufObjectChangeEvent . dispatch ( null )
434
437
}
435
438
436
439
public eject ( ) {
@@ -986,3 +989,29 @@ export class RigidNodeAssociate extends BodyAssociate {
986
989
}
987
990
988
991
export 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