David Catuhe 7 年之前
父節點
當前提交
0bf161b4b9

File diff suppressed because it is too large
+ 7278 - 7270
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 7 - 7
dist/preview release/babylon.js


+ 42 - 0
dist/preview release/babylon.max.js

@@ -89523,6 +89523,10 @@ var BABYLON;
              */
              */
             this.enabled = true;
             this.enabled = true;
             /**
             /**
+             * If camera controls should be detached during the drag
+             */
+            this.detachCameraControls = true;
+            /**
              * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
              * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
              */
              */
             this.useObjectOrienationForDragging = true;
             this.useObjectOrienationForDragging = true;
@@ -89580,6 +89584,10 @@ var BABYLON;
                     PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
                     PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
                     PointerDragBehavior._planeScene.detachControl();
                     PointerDragBehavior._planeScene.detachControl();
                     this._scene.getEngine().scenes.pop();
                     this._scene.getEngine().scenes.pop();
+                    this._scene.onDisposeObservable.addOnce(function () {
+                        PointerDragBehavior._planeScene.dispose();
+                        PointerDragBehavior._planeScene = null;
+                    });
                 }
                 }
             }
             }
             this._dragPlane = BABYLON.Mesh.CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, BABYLON.Mesh.DOUBLESIDE);
             this._dragPlane = BABYLON.Mesh.CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, BABYLON.Mesh.DOUBLESIDE);
@@ -89591,6 +89599,7 @@ var BABYLON;
             var pickPredicate = function (m) {
             var pickPredicate = function (m) {
                 return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
                 return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
             };
             };
+            var attachedElement = null;
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
                 if (!_this.enabled) {
                 if (!_this.enabled) {
                     return;
                     return;
@@ -89605,12 +89614,26 @@ var BABYLON;
                             _this.lastDragPosition.copyFrom(pickedPoint);
                             _this.lastDragPosition.copyFrom(pickedPoint);
                             _this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: _this.currentDraggingPointerID });
                             _this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: _this.currentDraggingPointerID });
                             targetPosition.copyFrom(_this._attachedNode.absolutePosition);
                             targetPosition.copyFrom(_this._attachedNode.absolutePosition);
+                            // Detatch camera controls
+                            if (_this.detachCameraControls && _this._scene.activeCamera) {
+                                if (_this._scene.activeCamera.inputs.attachedElement) {
+                                    attachedElement = _this._scene.activeCamera.inputs.attachedElement;
+                                    _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
+                                }
+                                else {
+                                    attachedElement = null;
+                                }
+                            }
                         }
                         }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
                         _this.releaseDrag();
                         _this.releaseDrag();
+                        // Reattach camera controls
+                        if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera) {
+                            _this._scene.activeCamera.attachControl(attachedElement, true);
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
@@ -89876,6 +89899,10 @@ var BABYLON;
              * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
              * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
              */
              */
             this.currentDraggingPointerID = -1;
             this.currentDraggingPointerID = -1;
+            /**
+             * If camera controls should be detached during the drag
+             */
+            this.detachCameraControls = true;
         }
         }
         Object.defineProperty(SixDofDragBehavior.prototype, "name", {
         Object.defineProperty(SixDofDragBehavior.prototype, "name", {
             /**
             /**
@@ -89913,6 +89940,7 @@ var BABYLON;
             var pickPredicate = function (m) {
             var pickPredicate = function (m) {
                 return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
                 return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
             };
             };
+            var attachedElement = null;
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
@@ -89939,6 +89967,16 @@ var BABYLON;
                         _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
                         _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
                         _this.dragging = true;
                         _this.dragging = true;
                         _this.currentDraggingPointerID = pointerInfo.event.pointerId;
                         _this.currentDraggingPointerID = pointerInfo.event.pointerId;
+                        // Detatch camera controls
+                        if (_this.detachCameraControls && _this._scene.activeCamera) {
+                            if (_this._scene.activeCamera.inputs.attachedElement) {
+                                attachedElement = _this._scene.activeCamera.inputs.attachedElement;
+                                _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
+                            }
+                            else {
+                                attachedElement = null;
+                            }
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
@@ -89948,6 +89986,10 @@ var BABYLON;
                         _this.currentDraggingPointerID = -1;
                         _this.currentDraggingPointerID = -1;
                         pickedMesh = null;
                         pickedMesh = null;
                         _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
                         _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
+                        // Reattach camera controls
+                        if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera) {
+                            _this._scene.activeCamera.attachControl(attachedElement, true);
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {

+ 42 - 0
dist/preview release/babylon.no-module.max.js

@@ -89490,6 +89490,10 @@ var BABYLON;
              */
              */
             this.enabled = true;
             this.enabled = true;
             /**
             /**
+             * If camera controls should be detached during the drag
+             */
+            this.detachCameraControls = true;
+            /**
              * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
              * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
              */
              */
             this.useObjectOrienationForDragging = true;
             this.useObjectOrienationForDragging = true;
@@ -89547,6 +89551,10 @@ var BABYLON;
                     PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
                     PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
                     PointerDragBehavior._planeScene.detachControl();
                     PointerDragBehavior._planeScene.detachControl();
                     this._scene.getEngine().scenes.pop();
                     this._scene.getEngine().scenes.pop();
+                    this._scene.onDisposeObservable.addOnce(function () {
+                        PointerDragBehavior._planeScene.dispose();
+                        PointerDragBehavior._planeScene = null;
+                    });
                 }
                 }
             }
             }
             this._dragPlane = BABYLON.Mesh.CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, BABYLON.Mesh.DOUBLESIDE);
             this._dragPlane = BABYLON.Mesh.CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, BABYLON.Mesh.DOUBLESIDE);
@@ -89558,6 +89566,7 @@ var BABYLON;
             var pickPredicate = function (m) {
             var pickPredicate = function (m) {
                 return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
                 return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
             };
             };
+            var attachedElement = null;
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
                 if (!_this.enabled) {
                 if (!_this.enabled) {
                     return;
                     return;
@@ -89572,12 +89581,26 @@ var BABYLON;
                             _this.lastDragPosition.copyFrom(pickedPoint);
                             _this.lastDragPosition.copyFrom(pickedPoint);
                             _this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: _this.currentDraggingPointerID });
                             _this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: _this.currentDraggingPointerID });
                             targetPosition.copyFrom(_this._attachedNode.absolutePosition);
                             targetPosition.copyFrom(_this._attachedNode.absolutePosition);
+                            // Detatch camera controls
+                            if (_this.detachCameraControls && _this._scene.activeCamera) {
+                                if (_this._scene.activeCamera.inputs.attachedElement) {
+                                    attachedElement = _this._scene.activeCamera.inputs.attachedElement;
+                                    _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
+                                }
+                                else {
+                                    attachedElement = null;
+                                }
+                            }
                         }
                         }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
                         _this.releaseDrag();
                         _this.releaseDrag();
+                        // Reattach camera controls
+                        if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera) {
+                            _this._scene.activeCamera.attachControl(attachedElement, true);
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
@@ -89843,6 +89866,10 @@ var BABYLON;
              * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
              * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
              */
              */
             this.currentDraggingPointerID = -1;
             this.currentDraggingPointerID = -1;
+            /**
+             * If camera controls should be detached during the drag
+             */
+            this.detachCameraControls = true;
         }
         }
         Object.defineProperty(SixDofDragBehavior.prototype, "name", {
         Object.defineProperty(SixDofDragBehavior.prototype, "name", {
             /**
             /**
@@ -89880,6 +89907,7 @@ var BABYLON;
             var pickPredicate = function (m) {
             var pickPredicate = function (m) {
                 return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
                 return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
             };
             };
+            var attachedElement = null;
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
@@ -89906,6 +89934,16 @@ var BABYLON;
                         _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
                         _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
                         _this.dragging = true;
                         _this.dragging = true;
                         _this.currentDraggingPointerID = pointerInfo.event.pointerId;
                         _this.currentDraggingPointerID = pointerInfo.event.pointerId;
+                        // Detatch camera controls
+                        if (_this.detachCameraControls && _this._scene.activeCamera) {
+                            if (_this._scene.activeCamera.inputs.attachedElement) {
+                                attachedElement = _this._scene.activeCamera.inputs.attachedElement;
+                                _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
+                            }
+                            else {
+                                attachedElement = null;
+                            }
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
@@ -89915,6 +89953,10 @@ var BABYLON;
                         _this.currentDraggingPointerID = -1;
                         _this.currentDraggingPointerID = -1;
                         pickedMesh = null;
                         pickedMesh = null;
                         _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
                         _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
+                        // Reattach camera controls
+                        if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera) {
+                            _this._scene.activeCamera.attachControl(attachedElement, true);
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {

File diff suppressed because it is too large
+ 7 - 7
dist/preview release/babylon.worker.js


+ 42 - 0
dist/preview release/es6.js

@@ -89490,6 +89490,10 @@ var BABYLON;
              */
              */
             this.enabled = true;
             this.enabled = true;
             /**
             /**
+             * If camera controls should be detached during the drag
+             */
+            this.detachCameraControls = true;
+            /**
              * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
              * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
              */
              */
             this.useObjectOrienationForDragging = true;
             this.useObjectOrienationForDragging = true;
@@ -89547,6 +89551,10 @@ var BABYLON;
                     PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
                     PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
                     PointerDragBehavior._planeScene.detachControl();
                     PointerDragBehavior._planeScene.detachControl();
                     this._scene.getEngine().scenes.pop();
                     this._scene.getEngine().scenes.pop();
+                    this._scene.onDisposeObservable.addOnce(function () {
+                        PointerDragBehavior._planeScene.dispose();
+                        PointerDragBehavior._planeScene = null;
+                    });
                 }
                 }
             }
             }
             this._dragPlane = BABYLON.Mesh.CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, BABYLON.Mesh.DOUBLESIDE);
             this._dragPlane = BABYLON.Mesh.CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, BABYLON.Mesh.DOUBLESIDE);
@@ -89558,6 +89566,7 @@ var BABYLON;
             var pickPredicate = function (m) {
             var pickPredicate = function (m) {
                 return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
                 return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
             };
             };
+            var attachedElement = null;
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
                 if (!_this.enabled) {
                 if (!_this.enabled) {
                     return;
                     return;
@@ -89572,12 +89581,26 @@ var BABYLON;
                             _this.lastDragPosition.copyFrom(pickedPoint);
                             _this.lastDragPosition.copyFrom(pickedPoint);
                             _this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: _this.currentDraggingPointerID });
                             _this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: _this.currentDraggingPointerID });
                             targetPosition.copyFrom(_this._attachedNode.absolutePosition);
                             targetPosition.copyFrom(_this._attachedNode.absolutePosition);
+                            // Detatch camera controls
+                            if (_this.detachCameraControls && _this._scene.activeCamera) {
+                                if (_this._scene.activeCamera.inputs.attachedElement) {
+                                    attachedElement = _this._scene.activeCamera.inputs.attachedElement;
+                                    _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
+                                }
+                                else {
+                                    attachedElement = null;
+                                }
+                            }
                         }
                         }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
                         _this.releaseDrag();
                         _this.releaseDrag();
+                        // Reattach camera controls
+                        if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera) {
+                            _this._scene.activeCamera.attachControl(attachedElement, true);
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
@@ -89843,6 +89866,10 @@ var BABYLON;
              * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
              * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
              */
              */
             this.currentDraggingPointerID = -1;
             this.currentDraggingPointerID = -1;
+            /**
+             * If camera controls should be detached during the drag
+             */
+            this.detachCameraControls = true;
         }
         }
         Object.defineProperty(SixDofDragBehavior.prototype, "name", {
         Object.defineProperty(SixDofDragBehavior.prototype, "name", {
             /**
             /**
@@ -89880,6 +89907,7 @@ var BABYLON;
             var pickPredicate = function (m) {
             var pickPredicate = function (m) {
                 return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
                 return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
             };
             };
+            var attachedElement = null;
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
@@ -89906,6 +89934,16 @@ var BABYLON;
                         _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
                         _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
                         _this.dragging = true;
                         _this.dragging = true;
                         _this.currentDraggingPointerID = pointerInfo.event.pointerId;
                         _this.currentDraggingPointerID = pointerInfo.event.pointerId;
+                        // Detatch camera controls
+                        if (_this.detachCameraControls && _this._scene.activeCamera) {
+                            if (_this._scene.activeCamera.inputs.attachedElement) {
+                                attachedElement = _this._scene.activeCamera.inputs.attachedElement;
+                                _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
+                            }
+                            else {
+                                attachedElement = null;
+                            }
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
@@ -89915,6 +89953,10 @@ var BABYLON;
                         _this.currentDraggingPointerID = -1;
                         _this.currentDraggingPointerID = -1;
                         pickedMesh = null;
                         pickedMesh = null;
                         _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
                         _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
+                        // Reattach camera controls
+                        if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera) {
+                            _this._scene.activeCamera.attachControl(attachedElement, true);
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {

File diff suppressed because it is too large
+ 22 - 22
dist/preview release/viewer/babylon.viewer.js


+ 42 - 0
dist/preview release/viewer/babylon.viewer.max.js

@@ -89611,6 +89611,10 @@ var BABYLON;
              */
              */
             this.enabled = true;
             this.enabled = true;
             /**
             /**
+             * If camera controls should be detached during the drag
+             */
+            this.detachCameraControls = true;
+            /**
              * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
              * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
              */
              */
             this.useObjectOrienationForDragging = true;
             this.useObjectOrienationForDragging = true;
@@ -89668,6 +89672,10 @@ var BABYLON;
                     PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
                     PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
                     PointerDragBehavior._planeScene.detachControl();
                     PointerDragBehavior._planeScene.detachControl();
                     this._scene.getEngine().scenes.pop();
                     this._scene.getEngine().scenes.pop();
+                    this._scene.onDisposeObservable.addOnce(function () {
+                        PointerDragBehavior._planeScene.dispose();
+                        PointerDragBehavior._planeScene = null;
+                    });
                 }
                 }
             }
             }
             this._dragPlane = BABYLON.Mesh.CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, BABYLON.Mesh.DOUBLESIDE);
             this._dragPlane = BABYLON.Mesh.CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, BABYLON.Mesh.DOUBLESIDE);
@@ -89679,6 +89687,7 @@ var BABYLON;
             var pickPredicate = function (m) {
             var pickPredicate = function (m) {
                 return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
                 return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
             };
             };
+            var attachedElement = null;
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
                 if (!_this.enabled) {
                 if (!_this.enabled) {
                     return;
                     return;
@@ -89693,12 +89702,26 @@ var BABYLON;
                             _this.lastDragPosition.copyFrom(pickedPoint);
                             _this.lastDragPosition.copyFrom(pickedPoint);
                             _this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: _this.currentDraggingPointerID });
                             _this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: _this.currentDraggingPointerID });
                             targetPosition.copyFrom(_this._attachedNode.absolutePosition);
                             targetPosition.copyFrom(_this._attachedNode.absolutePosition);
+                            // Detatch camera controls
+                            if (_this.detachCameraControls && _this._scene.activeCamera) {
+                                if (_this._scene.activeCamera.inputs.attachedElement) {
+                                    attachedElement = _this._scene.activeCamera.inputs.attachedElement;
+                                    _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
+                                }
+                                else {
+                                    attachedElement = null;
+                                }
+                            }
                         }
                         }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
                         _this.releaseDrag();
                         _this.releaseDrag();
+                        // Reattach camera controls
+                        if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera) {
+                            _this._scene.activeCamera.attachControl(attachedElement, true);
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
@@ -89964,6 +89987,10 @@ var BABYLON;
              * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
              * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
              */
              */
             this.currentDraggingPointerID = -1;
             this.currentDraggingPointerID = -1;
+            /**
+             * If camera controls should be detached during the drag
+             */
+            this.detachCameraControls = true;
         }
         }
         Object.defineProperty(SixDofDragBehavior.prototype, "name", {
         Object.defineProperty(SixDofDragBehavior.prototype, "name", {
             /**
             /**
@@ -90001,6 +90028,7 @@ var BABYLON;
             var pickPredicate = function (m) {
             var pickPredicate = function (m) {
                 return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
                 return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
             };
             };
+            var attachedElement = null;
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
             this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
@@ -90027,6 +90055,16 @@ var BABYLON;
                         _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
                         _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
                         _this.dragging = true;
                         _this.dragging = true;
                         _this.currentDraggingPointerID = pointerInfo.event.pointerId;
                         _this.currentDraggingPointerID = pointerInfo.event.pointerId;
+                        // Detatch camera controls
+                        if (_this.detachCameraControls && _this._scene.activeCamera) {
+                            if (_this._scene.activeCamera.inputs.attachedElement) {
+                                attachedElement = _this._scene.activeCamera.inputs.attachedElement;
+                                _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
+                            }
+                            else {
+                                attachedElement = null;
+                            }
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
@@ -90036,6 +90074,10 @@ var BABYLON;
                         _this.currentDraggingPointerID = -1;
                         _this.currentDraggingPointerID = -1;
                         pickedMesh = null;
                         pickedMesh = null;
                         _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
                         _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
+                        // Reattach camera controls
+                        if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera) {
+                            _this._scene.activeCamera.attachControl(attachedElement, true);
+                        }
                     }
                     }
                 }
                 }
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
                 else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {

+ 4 - 5
src/Behaviors/Mesh/babylon.pointerDragBehavior.ts

@@ -68,7 +68,7 @@ module BABYLON {
         /**
         /**
          * If camera controls should be detached during the drag
          * If camera controls should be detached during the drag
          */
          */
-        public detatchCameraControls = true;
+        public detachCameraControls = true;
         
         
         /**
         /**
          * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
          * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
@@ -126,10 +126,9 @@ module BABYLON {
                     PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
                     PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
                     PointerDragBehavior._planeScene.detachControl();
                     PointerDragBehavior._planeScene.detachControl();
                     this._scene.getEngine().scenes.pop();
                     this._scene.getEngine().scenes.pop();
-                    var sceneDisposeObserver = this._scene.onDisposeObservable.add(()=>{
+                    this._scene.onDisposeObservable.addOnce(()=>{
                         PointerDragBehavior._planeScene.dispose();
                         PointerDragBehavior._planeScene.dispose();
                         (<any>PointerDragBehavior._planeScene) = null;
                         (<any>PointerDragBehavior._planeScene) = null;
-                        this._scene.onDisposeObservable.remove(sceneDisposeObserver);
                     })
                     })
                 }
                 }
             }
             }
@@ -164,7 +163,7 @@ module BABYLON {
                             targetPosition.copyFrom((<Mesh>this._attachedNode).absolutePosition)
                             targetPosition.copyFrom((<Mesh>this._attachedNode).absolutePosition)
 
 
                             // Detatch camera controls
                             // Detatch camera controls
-                            if(this.detatchCameraControls && this._scene.activeCamera){
+                            if(this.detachCameraControls && this._scene.activeCamera){
                                 if(this._scene.activeCamera.inputs.attachedElement){
                                 if(this._scene.activeCamera.inputs.attachedElement){
                                     attachedElement = this._scene.activeCamera.inputs.attachedElement;
                                     attachedElement = this._scene.activeCamera.inputs.attachedElement;
                                     this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
                                     this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
@@ -179,7 +178,7 @@ module BABYLON {
                         this.releaseDrag();
                         this.releaseDrag();
 
 
                         // Reattach camera controls
                         // Reattach camera controls
-                        if(this.detatchCameraControls && attachedElement && this._scene.activeCamera){
+                        if(this.detachCameraControls && attachedElement && this._scene.activeCamera){
                             this._scene.activeCamera.attachControl(attachedElement, true);
                             this._scene.activeCamera.attachControl(attachedElement, true);
                         }
                         }
                     }
                     }

+ 3 - 3
src/Behaviors/Mesh/babylon.sixDofDragBehavior.ts

@@ -32,7 +32,7 @@ module BABYLON {
         /**
         /**
          * If camera controls should be detached during the drag
          * If camera controls should be detached during the drag
          */
          */
-        public detatchCameraControls = true;
+        public detachCameraControls = true;
 
 
 
 
         constructor(){
         constructor(){
@@ -107,7 +107,7 @@ module BABYLON {
                         this.currentDraggingPointerID = (<PointerEvent>pointerInfo.event).pointerId;
                         this.currentDraggingPointerID = (<PointerEvent>pointerInfo.event).pointerId;
 
 
                         // Detatch camera controls
                         // Detatch camera controls
-                        if(this.detatchCameraControls && this._scene.activeCamera){
+                        if(this.detachCameraControls && this._scene.activeCamera){
                             if(this._scene.activeCamera.inputs.attachedElement){
                             if(this._scene.activeCamera.inputs.attachedElement){
                                 attachedElement = this._scene.activeCamera.inputs.attachedElement;
                                 attachedElement = this._scene.activeCamera.inputs.attachedElement;
                                 this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
                                 this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
@@ -125,7 +125,7 @@ module BABYLON {
                         this._virtualOriginMesh.removeChild(this._virtualDragMesh);
                         this._virtualOriginMesh.removeChild(this._virtualDragMesh);
                         
                         
                         // Reattach camera controls
                         // Reattach camera controls
-                        if(this.detatchCameraControls && attachedElement && this._scene.activeCamera){
+                        if(this.detachCameraControls && attachedElement && this._scene.activeCamera){
                             this._scene.activeCamera.attachControl(attachedElement, true);
                             this._scene.activeCamera.attachControl(attachedElement, true);
                         }
                         }
                     }
                     }

+ 6 - 0
tests/validation/config.json

@@ -6,6 +6,12 @@
       "playgroundId": "#1VGT5D#2",
       "playgroundId": "#1VGT5D#2",
       "renderCount": 50,
       "renderCount": 50,
       "referenceImage": "particle_helper.png"
       "referenceImage": "particle_helper.png"
+    },        
+    {
+      "title": "Particle Helper",
+      "playgroundId": "#1VGT5D#2",
+      "renderCount": 50,
+      "referenceImage": "particle_helper.png"
     },     
     },     
     {
     {
       "title": "Chibi Rex",
       "title": "Chibi Rex",