|
@@ -22,7 +22,7 @@ export class SixDofDragBehavior implements Behavior<Mesh> {
|
|
|
private _pointerObserver: Nullable<Observer<PointerInfo>>;
|
|
|
private _moving = false;
|
|
|
private _startingOrientation = new Quaternion();
|
|
|
- private _attachedElement: Nullable<HTMLElement> = null;
|
|
|
+ private _attachedToElement: boolean = false;
|
|
|
|
|
|
/**
|
|
|
* How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
|
|
@@ -144,12 +144,13 @@ export class SixDofDragBehavior implements Behavior<Mesh> {
|
|
|
this.dragging = true;
|
|
|
this.currentDraggingPointerID = (<PointerEvent>pointerInfo.event).pointerId;
|
|
|
|
|
|
- // Detatch camera controls
|
|
|
+ // Detach camera controls
|
|
|
if (this.detachCameraControls && this._pointerCamera && !this._pointerCamera.leftCamera) {
|
|
|
if (this._pointerCamera.inputs.attachedToElement) {
|
|
|
this._pointerCamera.detachControl();
|
|
|
+ this._attachedToElement = true;
|
|
|
} else {
|
|
|
- this._attachedElement = null;
|
|
|
+ this._attachedToElement = false;
|
|
|
}
|
|
|
}
|
|
|
PivotTools._RestorePivotPoint(pickedMesh);
|
|
@@ -164,8 +165,9 @@ export class SixDofDragBehavior implements Behavior<Mesh> {
|
|
|
this._virtualOriginMesh.removeChild(this._virtualDragMesh);
|
|
|
|
|
|
// Reattach camera controls
|
|
|
- if (this.detachCameraControls && this._attachedElement && this._pointerCamera && !this._pointerCamera.leftCamera) {
|
|
|
+ if (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera) {
|
|
|
this._pointerCamera.attachControl(true);
|
|
|
+ this._attachedToElement = false;
|
|
|
}
|
|
|
this.onDragEndObservable.notifyObservers({});
|
|
|
}
|
|
@@ -245,8 +247,9 @@ export class SixDofDragBehavior implements Behavior<Mesh> {
|
|
|
*/
|
|
|
public detach(): void {
|
|
|
if (this._scene) {
|
|
|
- if (this.detachCameraControls && this._attachedElement && this._pointerCamera && !this._pointerCamera.leftCamera) {
|
|
|
+ if (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera) {
|
|
|
this._pointerCamera.attachControl(true);
|
|
|
+ this._attachedToElement = false;
|
|
|
}
|
|
|
this._scene.onPointerObservable.remove(this._pointerObserver);
|
|
|
}
|