Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(reveal): Add support for CDM 360 images in reveal #4894

Merged
merged 9 commits into from
Nov 27, 2024

Conversation

anders-hopland
Copy link
Contributor

@anders-hopland anders-hopland commented Nov 25, 2024

Type of change

Feat

Jira ticket 📘

BND3D-4787

Description 📝

Add support for CDM 360 images in reveal

Checklist ☑️

  • I am proud of this feature.
  • I have performed a self-review of my own code.
  • I have added PR type (Feat, Bug, Chore, Test, Docs, Style, Refactor) to the PR title.
  • I have manually tested this for different scenarios (different models, formats, devices, browsers).
  • I have commented my code in hard-to-understand areas.
  • I have made corresponding changes to the public documentation.
  • I have added unit and visuals tests to prove that my feature works to the best of my ability.
  • I have refactored the code for readability to the best of my ability.
  • I have checked that my changes do not introduce regressions in the public documentation.
  • I have outlined any known defects / lacking capabilities in the contents of this PR.
  • I have listed any remaining work that should follow this PR in the description or jira/miro/etc.
  • I have added TSDoc to any public facing changes.
  • I have added "developer documentation" in any package README.md that is related / applicable to this PR.
  • I have noted down and am currently tracking any technical debt introduced in this PR.
  • I have thoroughly thought about the architecture of this implementation.
  • I have asked peers to test this feature.

@anders-hopland anders-hopland requested a review from a team as a code owner November 25, 2024 09:10
Copy link
Contributor

@haakonflatval-cognite haakonflatval-cognite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - although I only had a quick look. Just some nitpick

imageProp.bottom as DirectRelationReference
]);

const externalIdBatches = chunk(chunk(cubeMapFileIds, 1000), 15);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is 15 and can add it into Constant variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about why it's 15, but I would guess that it has something to do about the File API's concurrency limits. I asked Christopher who wrote the datamodeling provider I based this CDM implementation on, and he did not remember why 15 was chosen

Comment on lines +18 to +21
import chunk from 'lodash/chunk';
import zip from 'lodash/zip';
import groupBy from 'lodash/groupBy';
import partition from 'lodash/partition';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import chunk from 'lodash/chunk';
import zip from 'lodash/zip';
import groupBy from 'lodash/groupBy';
import partition from 'lodash/partition';
import { chunk, zip, groupBy, partition } from 'lodash';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eslint asks me to import the modules individually, so I'll thus keep it as is

Copy link
Contributor

@pramodcog pramodcog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, minor comments

@anders-hopland
Copy link
Contributor Author

React components is currently not building as I have not bumped reveal there. I'll remove the changes done in react components after the person(s) reviewing has tested this as it's easier to test it through react-components. I'll then create a new PR with the changes to react-components when this PR is merged

}
}

type CoreDmFileResponse = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the type at the top of the file

Copy link
Contributor

@pramodcog pramodcog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Minor comment

Copy link
Contributor

@haakonflatval-cognite haakonflatval-cognite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - but a few suggestions

Comment on lines +139 to +140
imageProp.front as DirectRelationReference,
imageProp.back as DirectRelationReference,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have to do this casting? Isn't the result object properly typed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is the viewer, I guess we don't have proper typing on DMS-queries here?

Comment on lines +238 to +245
const [x, y, z] = [revision.eulerRotationX, revision.eulerRotationY, revision.eulerRotationZ];
const eulerRotation = new Euler(x, z, -y, 'XYZ');
return new Matrix4().makeRotationFromEuler(eulerRotation);
}

function getTranslation(): Matrix4 {
const [x, y, z] = [revision.translationX, revision.translationY, revision.translationZ];
return new Matrix4().makeTranslation(x, z, -y);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiply by CDF_TO_VIEWER_TRANSFORM instead here

Comment on lines +190 to +221
return [
{
fileId: fileInfos[0].id,
face: 'front',
mimeType: fileInfos[0].mimeType!
},
{
fileId: fileInfos[1].id,
face: 'back',
mimeType: fileInfos[1].mimeType!
},
{
fileId: fileInfos[2].id,
face: 'left',
mimeType: fileInfos[2].mimeType!
},
{
fileId: fileInfos[3].id,
face: 'right',
mimeType: fileInfos[3].mimeType!
},
{
fileId: fileInfos[4].id,
face: 'top',
mimeType: fileInfos[5].mimeType!
},
{
fileId: fileInfos[5].id,
face: 'bottom',
mimeType: fileInfos[5].mimeType!
}
] as Image360FileDescriptor[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a bit nicer if you create a list with all the face names ('front', 'back' etc..) and then iterate through it to create all these objects.

Comment on lines +86 to +93
const ret = Object.values(groups)
.concat(imagesWithoutStation.map(p => [p]))
.map(imageWithFileDescriptors => {
return this.getHistorical360ImageSet(collectionId, collectionLabel, imageWithFileDescriptors);
});

return ret;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we return right away here?

this.getImageRevision(mainImagePropsArray[index], p.fileDescriptors)
),
label: '',
transform: this.getRevisionTransform(mainImagePropsArray[0] as any)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with the any? 🧐

private getImageRevision(imageProps: ImageResultProperties, fileInfos: FileInfo[]): Image360Descriptor {
return {
faceDescriptors: getFaceDescriptors(),
timestamp: imageProps.takenAt as string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't takenAt properly typed in imageProps?

Copy link
Contributor

@haakonflatval-cognite haakonflatval-cognite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks alright - but I'd like some code deduplication between CoreDM and the system model implementations when we have the time @anders-hopland

@pramodcog
Copy link
Contributor

Looks alright - but I'd like some code deduplication between CoreDM and the system model implementations when we have the time @anders-hopland

@anders-hopland I would also like to have the reveal examples supporting CoreDM 360 images. But we can note it in Jira ticket.

@anders-hopland
Copy link
Contributor Author

Looks alright - but I'd like some code deduplication between CoreDM and the system model implementations when we have the time @anders-hopland

@anders-hopland I would also like to have the reveal examples supporting CoreDM 360 images. But we can note it in Jira ticket.

I'll create a Jira ticket for it 👌

@anders-hopland anders-hopland changed the title feat(reveal): Add support for CDM 360 images in reveal and reveal react components feat(reveal): Add support for CDM 360 images in reveal Nov 27, 2024
@anders-hopland anders-hopland merged commit 1f9db64 into master Nov 27, 2024
14 checks passed
@anders-hopland anders-hopland deleted the amh/add-cdm-support-for-360-images branch November 27, 2024 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants