diff --git a/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx b/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx index abaa0a21a5c..35d9c0a7e6c 100644 --- a/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx +++ b/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx @@ -39,19 +39,19 @@ export type Reveal3DResourcesStyling = { groups?: FdmAssetStylingGroup[]; }; -export type Reveal3DResourcesProps = { +export type Reveal3DResourcesProps = { resources: AddResourceOptions[]; fdmAssetMappingConfig: FdmAssetMappingsConfig; styling?: Reveal3DResourcesStyling; - onNodeClick?: (node: NodeDataResult | undefined) => void; + onNodeClick?: (node: NodeDataResult | undefined) => void; }; -export const Reveal3DResources = ({ +export const Reveal3DResources = ({ resources, styling, fdmAssetMappingConfig, onNodeClick -}: Reveal3DResourcesProps): ReactElement => { +}: Reveal3DResourcesProps): ReactElement => { const [reveal3DModels, setReveal3DModels] = useState([]); const [reveal3DModelsStyling, setReveal3DModelsStyling] = useState< Array @@ -77,13 +77,7 @@ export const Reveal3DResources = ({ const callback = (event: PointerEventData): void => { void (async (event: PointerEventData): Promise => { if (onNodeClick === undefined) return; - const data = await queryMappedData( - viewer, - client, - fdmSdk, - fdmAssetMappingConfig, - event - ); + const data = await queryMappedData(viewer, client, fdmSdk, fdmAssetMappingConfig, event); onNodeClick(data); })(event); diff --git a/react-components/src/components/Reveal3DResources/queryMappedData.ts b/react-components/src/components/Reveal3DResources/queryMappedData.ts index c92f8ecd387..76469429d53 100644 --- a/react-components/src/components/Reveal3DResources/queryMappedData.ts +++ b/react-components/src/components/Reveal3DResources/queryMappedData.ts @@ -8,21 +8,19 @@ import { type EdgeItem, type InspectResultList, type FdmSDK, - type DmsUniqueIdentifier, - type Source, - type FdmNode + type DmsUniqueIdentifier } from '../../utilities/FdmSDK'; import { type FdmAssetMappingsConfig } from '../../hooks/types'; import { type NodeDataResult } from './types'; import assert from 'assert'; -export async function queryMappedData( +export async function queryMappedData( viewer: Cognite3DViewer, cdfClient: CogniteClient, fdmClient: FdmSDK, fdmConfig: FdmAssetMappingsConfig, clickEvent: PointerEventData -): Promise | undefined> { +): Promise { const intersection = await viewer.getIntersectionFromPixel( clickEvent.offsetX, clickEvent.offsetY @@ -63,14 +61,8 @@ export async function queryMappedData( const dataView = inspectionResult.items[0]?.inspectionResults.involvedViewsAndContainers?.views[0]; - const nodeData = await filterNodeData(fdmClient, dataNode, dataView); - - if (nodeData === undefined) { - return undefined; - } - return { - data: nodeData, + nodeExternalId: dataNode.externalId, view: dataView, cadNode: selectedNode, intersection: cadIntersection @@ -153,20 +145,3 @@ async function inspectNode( return inspectionResult; } - -async function filterNodeData( - fdmClient: FdmSDK, - dataNode: DmsUniqueIdentifier, - dataView: Source -): Promise | undefined> { - if (dataView === undefined) { - return undefined; - } - - const dataQueryResult = await fdmClient.getByExternalIds( - [{ instanceType: 'node', ...dataNode }], - dataView - ); - - return dataQueryResult.items[0]; -} diff --git a/react-components/src/components/Reveal3DResources/types.ts b/react-components/src/components/Reveal3DResources/types.ts index 63d4875a396..bb30b2a84ce 100644 --- a/react-components/src/components/Reveal3DResources/types.ts +++ b/react-components/src/components/Reveal3DResources/types.ts @@ -8,7 +8,7 @@ import { type CadIntersection } from '@cognite/reveal'; import { type Matrix4 } from 'three'; -import { type FdmNode, type Source } from '../../utilities/FdmSDK'; +import { type Source } from '../../utilities/FdmSDK'; import { type Node3D } from '@cognite/sdk/dist/src'; export type AddImageCollection360Options = { @@ -22,8 +22,8 @@ export type AddResourceOptions = AddReveal3DModelOptions | AddImageCollection360 export type AddReveal3DModelOptions = AddModelOptions & { transform?: Matrix4 }; export type TypedReveal3DModel = AddReveal3DModelOptions & { type: SupportedModelTypes | '' }; -export type NodeDataResult = { - data: FdmNode; +export type NodeDataResult = { + nodeExternalId: string; view: Source; cadNode: Node3D; intersection: CadIntersection; diff --git a/react-components/stories/HighlightNode.stories.tsx b/react-components/stories/HighlightNode.stories.tsx index cbfa8b459a4..e91f3a51d8d 100644 --- a/react-components/stories/HighlightNode.stories.tsx +++ b/react-components/stories/HighlightNode.stories.tsx @@ -60,9 +60,9 @@ const StoryContent = ({ const [highlightedId, setHighlightedId] = useState(undefined); - const callback = (nodeData: NodeDataResult | undefined): void => { - setNodeData(nodeData?.data); - setHighlightedId(nodeData?.data?.externalId); + const callback = (nodeData: NodeDataResult | undefined): void => { + setNodeData(nodeData); + setHighlightedId(nodeData?.nodeExternalId); if (nodeData === undefined) return;