This commit is contained in:
Ole
2026-05-31 20:25:41 +00:00
commit 0a07ab8593
275 changed files with 52660 additions and 0 deletions
@@ -0,0 +1,30 @@
import type { DMInstanceRef } from '@cognite/reveal';
import { useMemo } from 'react';
import {
useInstancesWithBoundingBoxes,
type InstancesWithBoxesAndOriginalInstance,
} from './useInstancesWithBoundingBoxes';
import { useFindRelated3dInstances } from './useFindRelated3dInstances';
export const useInstancesWithBounds = (
inputInstances: DMInstanceRef[],
originalInstance: DMInstanceRef
): InstancesWithBoxesAndOriginalInstance | undefined => {
const instancesWithBounds = useInstancesWithBoundingBoxes(inputInstances);
return useMemo<InstancesWithBoxesAndOriginalInstance | undefined>(() => {
if (inputInstances.length === 0 || instancesWithBounds.length === 0) {
return undefined;
}
return { instancesWithBoxes: [...instancesWithBounds], originalInstance };
}, [instancesWithBounds, inputInstances.length, originalInstance]);
};
export function use3dDataForSelectedInstance(
instance: DMInstanceRef
): InstancesWithBoxesAndOriginalInstance | undefined {
const threeDRelatedSelection = useFindRelated3dInstances(instance);
const selectedInstancesWithBoundsAndCorrespondingInstance =
useInstancesWithBounds(threeDRelatedSelection, instance);
return selectedInstancesWithBoundsAndCorrespondingInstance;
}