Skip to content

Commit

Permalink
fix(react-components): don't select objects when clicking in measurem…
Browse files Browse the repository at this point in the history
…ent (#4544)

* fix(react-components): don't select objects when clicking in measurement

* chore: add utility methods to ToolController

* chore: remove unused import
  • Loading branch information
haakonflatval-cognite authored May 28, 2024
1 parent 2856f3a commit 0842ac7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export class ToolControllers extends PointerEvents {
return this._activeTool;
}

public get defaultTool(): BaseTool | undefined {
return this._defaultTool;
}

public get isDefaultToolActive(): boolean {
return this.activeTool === this.defaultTool;
}

// ================================================
// OVERRIDES of PointerEvents
// ================================================
Expand Down
5 changes: 3 additions & 2 deletions react-components/src/hooks/useClickedNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { usePointCloudAnnotationMappingForAssetId } from '../components/CachePro
import { type PointCloudAnnotationMappedAssetData } from './types';
import { MOUSE, Vector2 } from 'three';
import { type DmsUniqueIdentifier, type Source } from '../utilities/FdmSDK';
import { useReveal } from '../components/RevealCanvas/ViewerContext';
import { useRenderTarget, useReveal } from '../components/RevealCanvas/ViewerContext';

export type AssetMappingDataResult = {
cadNode: Node3D;
Expand All @@ -39,6 +39,7 @@ export type ClickedNodeData = {

export const useClickedNodeData = (): ClickedNodeData | undefined => {
const viewer = useReveal();
const renderTarget = useRenderTarget();

const [intersection, setIntersection] = useState<AnyIntersection | undefined>(undefined);

Expand All @@ -49,7 +50,7 @@ export const useClickedNodeData = (): ClickedNodeData | undefined => {
useEffect(() => {
const callback = (event: PointerEventData): void => {
void (async () => {
if (event.button !== MOUSE.LEFT) {
if (event.button !== MOUSE.LEFT || !renderTarget.toolController.isDefaultToolActive) {
return;
}

Expand Down

0 comments on commit 0842ac7

Please sign in to comment.