Jelajahi Sumber

notify when gizmo manager attached

Trevor Baron 6 tahun lalu
induk
melakukan
85079440ce
1 mengubah file dengan 5 tambahan dan 0 penghapusan
  1. 5 0
      src/Gizmos/babylon.gizmoManager.ts

+ 5 - 0
src/Gizmos/babylon.gizmoManager.ts

@@ -7,7 +7,10 @@ module BABYLON {
          * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
          */
         public gizmos: {positionGizmo: Nullable<PositionGizmo>, rotationGizmo: Nullable<RotationGizmo>, scaleGizmo: Nullable<ScaleGizmo>, boundingBoxGizmo: Nullable<BoundingBoxGizmo>};
+        /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
         public clearGizmoOnEmptyPointerEvent = false;
+        /** Fires an event when the manager is attached to a mesh */
+        public onAttachedToMeshObservable = new Observable<Nullable<AbstractMesh>>();
         private _gizmosEnabled = {positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false};
         private _pointerObserver: Nullable<Observer<PointerInfo>> = null;
         private _attachedMesh: Nullable<AbstractMesh> = null;
@@ -100,6 +103,7 @@ module BABYLON {
             if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
                 this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
             }
+            this.onAttachedToMeshObservable.notifyObservers(mesh);
         }
 
         /**
@@ -185,6 +189,7 @@ module BABYLON {
             this._defaultKeepDepthUtilityLayer.dispose();
             this._defaultUtilityLayer.dispose();
             this.boundingBoxDragBehavior.detach();
+            this.onAttachedToMeshObservable.clear();
         }
     }
 }