|
@@ -103657,6 +103657,10 @@ var BABYLON;
|
|
*/
|
|
*/
|
|
this.zDragFactor = 3;
|
|
this.zDragFactor = 3;
|
|
/**
|
|
/**
|
|
|
|
+ * If the object should rotate to face the drag origin
|
|
|
|
+ */
|
|
|
|
+ this.rotateDraggedObject = true;
|
|
|
|
+ /**
|
|
* If the behavior is currently in a dragging state
|
|
* If the behavior is currently in a dragging state
|
|
*/
|
|
*/
|
|
this.dragging = false;
|
|
this.dragging = false;
|
|
@@ -103723,7 +103727,7 @@ var BABYLON;
|
|
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)) {
|
|
if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
|
|
if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
|
|
- pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.position);
|
|
|
|
|
|
+ pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
|
|
}
|
|
}
|
|
pickedMesh = _this._ownerNode;
|
|
pickedMesh = _this._ownerNode;
|
|
BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
|
|
BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
|
|
@@ -103779,7 +103783,7 @@ var BABYLON;
|
|
if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
|
|
if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
|
|
var zDragFactor = _this.zDragFactor;
|
|
var zDragFactor = _this.zDragFactor;
|
|
if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
|
|
if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
|
|
- pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.position);
|
|
|
|
|
|
+ pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
|
|
zDragFactor = 0;
|
|
zDragFactor = 0;
|
|
}
|
|
}
|
|
// Calculate controller drag distance in controller space
|
|
// Calculate controller drag distance in controller space
|
|
@@ -103815,21 +103819,23 @@ var BABYLON;
|
|
BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
|
|
BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
|
|
// Slowly move mesh to avoid jitter
|
|
// Slowly move mesh to avoid jitter
|
|
pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
|
|
pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
|
|
- // Get change in rotation
|
|
|
|
- tmpQuaternion.copyFrom(_this._startingOrientation);
|
|
|
|
- tmpQuaternion.x = -tmpQuaternion.x;
|
|
|
|
- tmpQuaternion.y = -tmpQuaternion.y;
|
|
|
|
- tmpQuaternion.z = -tmpQuaternion.z;
|
|
|
|
- _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
|
|
|
|
- // Convert change in rotation to only y axis rotation
|
|
|
|
- BABYLON.Quaternion.RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
|
|
|
|
- tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
|
|
|
|
- // Slowly move mesh to avoid jitter
|
|
|
|
- var oldParent = pickedMesh.parent;
|
|
|
|
- pickedMesh.setParent(null);
|
|
|
|
- BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
|
|
|
|
- pickedMesh.setParent(oldParent);
|
|
|
|
- BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
|
|
|
|
|
|
+ if (_this.rotateDraggedObject) {
|
|
|
|
+ // Get change in rotation
|
|
|
|
+ tmpQuaternion.copyFrom(_this._startingOrientation);
|
|
|
|
+ tmpQuaternion.x = -tmpQuaternion.x;
|
|
|
|
+ tmpQuaternion.y = -tmpQuaternion.y;
|
|
|
|
+ tmpQuaternion.z = -tmpQuaternion.z;
|
|
|
|
+ _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
|
|
|
|
+ // Convert change in rotation to only y axis rotation
|
|
|
|
+ BABYLON.Quaternion.RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
|
|
|
|
+ tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
|
|
|
|
+ // Slowly move mesh to avoid jitter
|
|
|
|
+ var oldParent = pickedMesh.parent;
|
|
|
|
+ pickedMesh.setParent(null);
|
|
|
|
+ BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
|
|
|
|
+ pickedMesh.setParent(oldParent);
|
|
|
|
+ BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
};
|
|
};
|