|
@@ -89523,6 +89523,10 @@ var BABYLON;
|
|
|
*/
|
|
|
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)
|
|
|
*/
|
|
|
this.useObjectOrienationForDragging = true;
|
|
@@ -89580,6 +89584,10 @@ var BABYLON;
|
|
|
PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
|
|
|
PointerDragBehavior._planeScene.detachControl();
|
|
|
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);
|
|
@@ -89591,6 +89599,7 @@ var BABYLON;
|
|
|
var pickPredicate = function (m) {
|
|
|
return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
|
|
|
};
|
|
|
+ var attachedElement = null;
|
|
|
this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
|
|
|
if (!_this.enabled) {
|
|
|
return;
|
|
@@ -89605,12 +89614,26 @@ var BABYLON;
|
|
|
_this.lastDragPosition.copyFrom(pickedPoint);
|
|
|
_this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: _this.currentDraggingPointerID });
|
|
|
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) {
|
|
|
if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
|
|
|
_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) {
|
|
@@ -89876,6 +89899,10 @@ var BABYLON;
|
|
|
* The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
|
|
|
*/
|
|
|
this.currentDraggingPointerID = -1;
|
|
|
+ /**
|
|
|
+ * If camera controls should be detached during the drag
|
|
|
+ */
|
|
|
+ this.detachCameraControls = true;
|
|
|
}
|
|
|
Object.defineProperty(SixDofDragBehavior.prototype, "name", {
|
|
|
/**
|
|
@@ -89913,6 +89940,7 @@ var BABYLON;
|
|
|
var pickPredicate = function (m) {
|
|
|
return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
|
|
|
};
|
|
|
+ var attachedElement = null;
|
|
|
this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
|
|
|
if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
|
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.dragging = true;
|
|
|
_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) {
|
|
@@ -89948,6 +89986,10 @@ var BABYLON;
|
|
|
_this.currentDraggingPointerID = -1;
|
|
|
pickedMesh = null;
|
|
|
_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) {
|