diff --git a/viewer/packages/camera-manager/src/Flexible/FlexibleCameraManager.ts b/viewer/packages/camera-manager/src/Flexible/FlexibleCameraManager.ts index b84a5e6ab25..063d7490641 100644 --- a/viewer/packages/camera-manager/src/Flexible/FlexibleCameraManager.ts +++ b/viewer/packages/camera-manager/src/Flexible/FlexibleCameraManager.ts @@ -62,8 +62,8 @@ export class FlexibleCameraManager implements IFlexibleCameraManager { private readonly _markers?: undefined | FlexibleCameraMarkers; private readonly _currentBoundingBox: Box3 = new Box3(); private _isDisposed = false; + private _isEnableClickAndDoubleClick = true; private _nearAndFarNeedsUpdate = false; - private _isEnabled = true; // For the wheel event private _prevTime = 0; @@ -286,7 +286,11 @@ export class FlexibleCameraManager implements IFlexibleCameraManager { } public get isEnabled(): boolean { - return this._isEnabled; + return this.controls.isEnabled; + } + + public get isEnableClickAndDoubleClick(): boolean { + return this._isEnableClickAndDoubleClick; } public get isDisposed(): boolean { @@ -294,8 +298,11 @@ export class FlexibleCameraManager implements IFlexibleCameraManager { } private set isEnabled(value: boolean) { - this._isEnabled = value; - this.controls.isEnabled = true; + this.controls.isEnabled = value; + } + + public set isEnableClickAndDoubleClick(value: boolean) { + this._isEnableClickAndDoubleClick = value; } private getPosition(): Vector3 { @@ -412,14 +419,14 @@ export class FlexibleCameraManager implements IFlexibleCameraManager { }; private readonly onClick = async (event: PointerEventData) => { - if (!this.isEnabled) return; + if (!this.isEnabled || !this.isEnableClickAndDoubleClick) return; if (this.options.mouseClickType !== FlexibleMouseActionType.None) { await this.mouseAction(event, this.options.mouseClickType); } }; private readonly onDoubleClick = async (event: PointerEventData) => { - if (!this.isEnabled) return; + if (!this.isEnabled || !this.isEnableClickAndDoubleClick) return; if (this.options.mouseDoubleClickType !== FlexibleMouseActionType.None) { await this.mouseAction(event, this.options.mouseDoubleClickType); } diff --git a/viewer/packages/camera-manager/src/Flexible/FlexibleControls.ts b/viewer/packages/camera-manager/src/Flexible/FlexibleControls.ts index 6b4682c45df..c3a678083d9 100644 --- a/viewer/packages/camera-manager/src/Flexible/FlexibleControls.ts +++ b/viewer/packages/camera-manager/src/Flexible/FlexibleControls.ts @@ -629,14 +629,14 @@ export class FlexibleControls extends EventDispatcher { }; const dispose = () => { - document.removeEventListener('pointerdown', onTouchStart); + this._domElement.removeEventListener('pointerdown', onTouchStart); + this._domElement.removeEventListener('pointerup', onTouchEnd); document.removeEventListener('pointermove', onTouchMove); - document.removeEventListener('pointerup', onTouchEnd); }; - document.addEventListener('pointerdown', onTouchStart); + this._domElement.addEventListener('pointerdown', onTouchStart); + this._domElement.addEventListener('pointerup', onTouchEnd, { passive: false }); document.addEventListener('pointermove', onTouchMove, { passive: false }); - document.addEventListener('pointerup', onTouchEnd, { passive: false }); } private rotate(delta: Vector2) { diff --git a/viewer/packages/tools/src/Measurement/MeasurementTool.ts b/viewer/packages/tools/src/Measurement/MeasurementTool.ts index 10afabe2afc..59fc24fd149 100644 --- a/viewer/packages/tools/src/Measurement/MeasurementTool.ts +++ b/viewer/packages/tools/src/Measurement/MeasurementTool.ts @@ -18,6 +18,7 @@ import { MeasurementLabels } from './MeasurementLabels'; import { HtmlOverlayTool, HtmlOverlayToolOptions } from '../HtmlOverlay/HtmlOverlayTool'; import rulerSvg from '!!raw-loader!./styles/ruler.svg'; import { MetricsLogger } from '@reveal/metrics'; +import { FlexibleCameraManager } from '@reveal/camera-manager'; type MeasurementEvents = 'added' | 'started' | 'ended' | 'disposed'; @@ -242,6 +243,10 @@ export class MeasurementTool extends Cognite3DViewerToolBase { this._events.measurementStarted.fire(); this._measurementMode = true; this._showMeasurements = true; + + if (this._viewer.cameraManager instanceof FlexibleCameraManager) { + this._viewer.cameraManager.isEnableClickAndDoubleClick = false; + } } /** @@ -256,6 +261,9 @@ export class MeasurementTool extends Cognite3DViewerToolBase { this._viewer.off('beforeSceneRendered', this._handleClippingPlanes); this._events.measurementEnded.fire(); this._measurementMode = false; + if (this._viewer.cameraManager instanceof FlexibleCameraManager) { + this._viewer.cameraManager.isEnableClickAndDoubleClick = true; + } } /**