From daed1215629c7cb7ff0444682757468f08ccf21a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Flatval?= Date: Fri, 4 Aug 2023 14:59:25 +0200 Subject: [PATCH 1/2] fix: make FDM config non-required in 3DResources To facilitate CDF-only usage too --- .../components/Reveal3DResources/Reveal3DResources.tsx | 2 +- .../src/components/Reveal3DResources/queryMappedData.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx b/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx index abaa0a21a5c..d0662e09f31 100644 --- a/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx +++ b/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx @@ -41,7 +41,7 @@ export type Reveal3DResourcesStyling = { export type Reveal3DResourcesProps = { resources: AddResourceOptions[]; - fdmAssetMappingConfig: FdmAssetMappingsConfig; + fdmAssetMappingConfig?: FdmAssetMappingsConfig; styling?: Reveal3DResourcesStyling; onNodeClick?: (node: NodeDataResult | undefined) => void; }; diff --git a/react-components/src/components/Reveal3DResources/queryMappedData.ts b/react-components/src/components/Reveal3DResources/queryMappedData.ts index c92f8ecd387..6ec5b38e977 100644 --- a/react-components/src/components/Reveal3DResources/queryMappedData.ts +++ b/react-components/src/components/Reveal3DResources/queryMappedData.ts @@ -20,9 +20,13 @@ export async function queryMappedData( viewer: Cognite3DViewer, cdfClient: CogniteClient, fdmClient: FdmSDK, - fdmConfig: FdmAssetMappingsConfig, - clickEvent: PointerEventData + clickEvent: PointerEventData, + fdmConfig?: FdmAssetMappingsConfig ): Promise | undefined> { + if (fdmConfig === undefined) { + throw Error('Must supply fdmConfig when using FDM queries'); + } + const intersection = await viewer.getIntersectionFromPixel( clickEvent.offsetX, clickEvent.offsetY From 59e23ced00f949f8551ed16cdb2568f658117b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Flatval?= Date: Fri, 4 Aug 2023 15:06:04 +0200 Subject: [PATCH 2/2] fix: correct argument order --- .../src/components/Reveal3DResources/Reveal3DResources.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx b/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx index d0662e09f31..07075f01797 100644 --- a/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx +++ b/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx @@ -81,8 +81,8 @@ export const Reveal3DResources = ({ viewer, client, fdmSdk, - fdmAssetMappingConfig, - event + event, + fdmAssetMappingConfig ); onNodeClick(data);