Przeglądaj źródła

Optional predicate for pointerDragBehavior attach

Michael Smith 6 lat temu
rodzic
commit
8e1c58ab52
1 zmienionych plików z 2 dodań i 2 usunięć
  1. 2 2
      src/Behaviors/Meshes/pointerDragBehavior.ts

+ 2 - 2
src/Behaviors/Meshes/pointerDragBehavior.ts

@@ -143,7 +143,7 @@ export class PointerDragBehavior implements Behavior<AbstractMesh> {
      * Attaches the drag behavior the passed in mesh
      * @param ownerNode The mesh that will be dragged around once attached
      */
-    public attach(ownerNode: AbstractMesh): void {
+    public attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void {
         this._scene = ownerNode.getScene();
         this.attachedNode = ownerNode;
 
@@ -165,7 +165,7 @@ export class PointerDragBehavior implements Behavior<AbstractMesh> {
         // State of the drag
         this.lastDragPosition = new Vector3(0, 0, 0);
 
-        var pickPredicate = (m: AbstractMesh) => {
+        var pickPredicate = !!predicate ? predicate : (m: AbstractMesh) => {
             return this.attachedNode == m || m.isDescendantOf(this.attachedNode);
         };