Skip to content

Commit

Permalink
chore: rename a bit more for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonflatval-cognite committed May 31, 2024
1 parent f6e511b commit 3319bd4
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import {
import { type Matrix4 } from 'three';

type Image360CollectionContainerProps = {
addImageCollection360Options: AddImage360CollectionOptions;
addImage360CollectionOptions: AddImage360CollectionOptions;
styling?: ImageCollectionModelStyling;
onLoad?: (image360: Image360Collection) => void;
onLoadError?: (addOptions: AddImage360CollectionOptions, error: any) => void;
};

export function Image360CollectionContainer({
addImageCollection360Options,
addImage360CollectionOptions,
styling,
onLoad,
onLoadError
Expand All @@ -35,31 +35,31 @@ export function Image360CollectionContainer({

useEffect(() => {
if (
'siteId' in addImageCollection360Options &&
initializingSiteId.current === addImageCollection360Options
'siteId' in addImage360CollectionOptions &&
initializingSiteId.current === addImage360CollectionOptions
) {
return;
}

initializingSiteId.current = addImageCollection360Options;
initializingSiteId.current = addImage360CollectionOptions;

void add360Collection(addImageCollection360Options.transform);
void add360Collection(addImage360CollectionOptions.transform);
return remove360Collection;
}, [addImageCollection360Options]);
}, [addImage360CollectionOptions]);

useApply360AnnotationStyling(modelRef.current, styling);

useEffect(() => {
if (
modelRef.current === undefined ||
addImageCollection360Options.transform === undefined ||
addImage360CollectionOptions.transform === undefined ||
!viewer.get360ImageCollections().includes(modelRef.current)
) {
return;
}

modelRef.current.setModelTransformation(addImageCollection360Options.transform);
}, [modelRef, addImageCollection360Options.transform, viewer]);
modelRef.current.setModelTransformation(addImage360CollectionOptions.transform);
}, [modelRef, addImage360CollectionOptions.transform, viewer]);

return <></>;

Expand All @@ -75,30 +75,30 @@ export function Image360CollectionContainer({
})
.catch((error: any) => {
const errorReportFunction = onLoadError ?? defaultLoadErrorHandler;
errorReportFunction(addImageCollection360Options, error);
errorReportFunction(addImage360CollectionOptions, error);
});

async function getOrAdd360Collection(): Promise<Image360Collection> {
const collections = viewer.get360ImageCollections();
const siteId =
'siteId' in addImageCollection360Options
? addImageCollection360Options.siteId
: addImageCollection360Options.externalId;
'siteId' in addImage360CollectionOptions
? addImage360CollectionOptions.siteId
: addImage360CollectionOptions.externalId;
const collection = collections.find((collection) => collection.id === siteId);
if (collection !== undefined) {
return collection;
}

if ('siteId' in addImageCollection360Options) {
if ('siteId' in addImage360CollectionOptions) {
return await viewer.add360ImageSet(
'events',
{ site_id: siteId },
{ preMultipliedRotation: false }
);
} else {
return await viewer.add360ImageSet('datamodels', {
image360CollectionExternalId: addImageCollection360Options.externalId,
space: addImageCollection360Options.space
image360CollectionExternalId: addImage360CollectionOptions.externalId,
space: addImage360CollectionOptions.space
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const Reveal3DResources = ({
return (
<Image360CollectionContainer
key={key}
addImageCollection360Options={addModelOption}
addImage360CollectionOptions={addModelOption}
styling={image360Styling}
onLoad={onModelLoaded}
onLoadError={onModelLoadedError}
Expand Down
4 changes: 2 additions & 2 deletions react-components/src/components/Reveal3DResources/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type AddImage360CollectionDatamodelsOptions = {

export type FdmPropertyType<NodeType> = Record<string, Record<string, NodeType>>;

export type TaggedAddImageCollection360Options = {
export type TaggedAddImage360CollectionOptions = {
type: 'image360';
addOptions: AddImage360CollectionOptions;
};
Expand All @@ -40,7 +40,7 @@ export type TaggedAdd3DModelOptions = {
addOptions: AddReveal3DModelOptions;
};

export type TaggedAddResourceOptions = TaggedAdd3DModelOptions | TaggedAddImageCollection360Options;
export type TaggedAddResourceOptions = TaggedAdd3DModelOptions | TaggedAddImage360CollectionOptions;

export type AddResourceOptions = AddReveal3DModelOptions | AddImage360CollectionOptions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import { type AnnotationsAssetRef, type CogniteClient, type IdEither } from '@cognite/sdk/dist/src';
import { uniq } from 'lodash';
import { isDefined } from '../../utilities/isDefined';
import { type TaggedAddImageCollection360Options } from '../../components/Reveal3DResources/types';
import { type TaggedAddImage360CollectionOptions } from '../../components/Reveal3DResources/types';

export async function getImage360CollectionsForAsset(
assetId: number,
sdk: CogniteClient
): Promise<TaggedAddImageCollection360Options[]> {
): Promise<TaggedAddImage360CollectionOptions[]> {
const fileRefsResult = await sdk.annotations.reverseLookup({
filter: { annotatedResourceType: 'file', data: { assetRef: { id: assetId } } },
limit: 1000
Expand Down
2 changes: 1 addition & 1 deletion react-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export {
type Image360AssetStylingGroup,
type TaggedAddResourceOptions,
type TaggedAdd3DModelOptions,
type TaggedAddImageCollection360Options,
type TaggedAddImage360CollectionOptions,
type AddImage360CollectionEventsOptions,
type AddImage360CollectionDatamodelsOptions,
type AddImage360CollectionOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ type Story = StoryObj<typeof meta>;

export const Main: Story = {
args: {
addImageCollection360Options: { siteId: 'c_RC_2', transform: new Matrix4() }
addImage360CollectionOptions: { siteId: 'c_RC_2', transform: new Matrix4() }
},
render: ({ addImageCollection360Options, styling }) => (
render: ({ addImage360CollectionOptions, styling }) => (
<RevealStoryContainer color={new Color(0x4a4a4a)}>
<Image360CollectionContainerStoryContent
addImageCollection360Options={addImageCollection360Options}
addImageCollection360Options={addImage360CollectionOptions}
styling={styling}
/>
</RevealStoryContainer>
Expand Down Expand Up @@ -57,7 +57,7 @@ const Image360CollectionContainerStoryContent = ({
return (
<>
<Image360CollectionContainer
addImageCollection360Options={addImageCollection360Options}
addImage360CollectionOptions={addImageCollection360Options}
styling={styling}
onLoad={onLoad}
/>
Expand Down
2 changes: 1 addition & 1 deletion react-components/stories/Image360Details.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const Main: Story = {
<RevealContext sdk={sdk} color={new Color(0x4a4a4a)}>
<RevealCanvas>
<Image360CollectionContainer
addImageCollection360Options={{ siteId: 'c_RC_2' }}
addImage360CollectionOptions={{ siteId: 'c_RC_2' }}
onLoad={() => {
setLoading(false);
}}
Expand Down
2 changes: 1 addition & 1 deletion react-components/stories/LayersContainer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Main: Story = {
}}
transform={new Matrix4()}
/>
<Image360CollectionContainer addImageCollection360Options={{ siteId: 'Hibernia_RS2' }} />
<Image360CollectionContainer addImage360CollectionOptions={{ siteId: 'Hibernia_RS2' }} />
<RevealToolbar />
</RevealCanvas>
</RevealContext>
Expand Down

0 comments on commit 3319bd4

Please sign in to comment.