diff --git a/react-components/src/hooks/useCalculateModelsStyling.tsx b/react-components/src/hooks/useCalculateModelsStyling.tsx index 4332326d519..094526e238c 100644 --- a/react-components/src/hooks/useCalculateModelsStyling.tsx +++ b/react-components/src/hooks/useCalculateModelsStyling.tsx @@ -179,8 +179,8 @@ function getModelMappings( (mapping) => mapping.modelId === model.modelId && mapping.revisionId === model.revisionId ) .reduce( + // reduce is added to avoid duplication of a models that span several pages. (acc, mapping) => { - // reduce is added to avoid duplicate models from several pages. mergeMaps(acc.mappings, mapping.mappings); return acc; }, diff --git a/react-components/src/hooks/useMappedEquipmentBy3DModelsList.tsx b/react-components/src/hooks/useMappedEquipmentBy3DModelsList.tsx index 2920cc209be..1b3239a652e 100644 --- a/react-components/src/hooks/useMappedEquipmentBy3DModelsList.tsx +++ b/react-components/src/hooks/useMappedEquipmentBy3DModelsList.tsx @@ -46,9 +46,9 @@ function groupToModelRevision( const edgesForModel = map.get(modelRevisionIdKey); if (edgesForModel === undefined) { map.set(modelRevisionIdKey, [edge]); - return map; + } else { + edgesForModel.push(edge); } - edgesForModel.push(edge); return map; }, new Map>>()); diff --git a/react-components/src/utilities/FdmSDK.ts b/react-components/src/utilities/FdmSDK.ts index caa18f9bcb5..155acd17264 100644 --- a/react-components/src/utilities/FdmSDK.ts +++ b/react-components/src/utilities/FdmSDK.ts @@ -132,7 +132,17 @@ export class FdmSDK { const edgeResult = result.data.items as Array>>; - if (source !== undefined) { + hoistEdgeProperties(); + + return { + edges: result.data.items as Array>, + nextCursor: result.data.nextCursor + }; + + function hoistEdgeProperties(): void { + if (source === undefined) { + return; + } const propertyKey = `${source.externalId}/${source.version}`; edgeResult.forEach((edge) => { if (edge.properties[source.space][propertyKey] !== undefined) { @@ -140,11 +150,6 @@ export class FdmSDK { } }); } - - return { - edges: result.data.items as Array>, - nextCursor: result.data.nextCursor - }; } public async filterAllInstances>( diff --git a/react-components/stories/Reveal3DResources.stories.tsx b/react-components/stories/Reveal3DResources.stories.tsx index d17ed192f0c..2be4378968a 100644 --- a/react-components/stories/Reveal3DResources.stories.tsx +++ b/react-components/stories/Reveal3DResources.stories.tsx @@ -3,10 +3,9 @@ */ import type { Meta, StoryObj } from '@storybook/react'; import { Reveal3DResources, RevealContainer } from '../src'; -import { Color } from 'three'; +import { Color, Matrix4 } from 'three'; import { CameraController } from '../src/'; import { createSdkByUrlToken } from './utilities/createSdkByUrlToken'; -import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; const meta = { title: 'Example/Reveal3DResources', @@ -23,16 +22,21 @@ export const Main: Story = { args: { resources: [ { - modelId: 2231774635735416, - revisionId: 912809199849811, - styling: { - default: { - color: new Color('#efefef') - }, - mapped: { - color: new Color('#c5cbff') - } - } + modelId: 1791160622840317, + revisionId: 498427137020189, + transform: new Matrix4().makeTranslation(40, 0, 0) + }, + { + modelId: 1791160622840317, + revisionId: 498427137020189, + transform: new Matrix4().makeTranslation(40, 10, 0) + }, + { + siteId: 'c_RC_2' + }, + { + modelId: 3865289545346058, + revisionId: 4160448151596909 } ] }, @@ -47,28 +51,7 @@ export const Main: Story = { placement: 'topRight' } }}> - - +