Skip to content

Commit

Permalink
fix(react-components): cad & point cloud models getting added multipl…
Browse files Browse the repository at this point in the history
…e time due to incorrect transforms (#4957)

* fixed cad & point cloud models getting added multiple time due model transforms is inccorect and also added important css properties for SlicerButton

* lint fix

* forcing RangeSlider css property to fix Search issue
  • Loading branch information
pramod-cog authored Jan 13, 2025
1 parent dcbd7fd commit 16ed4b2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion react-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cognite/reveal-react-components",
"version": "0.73.12",
"version": "0.73.13",
"exports": {
".": {
"import": "./dist/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ export function CadModelContainer({
return cadModel;

async function getOrAddModel(): Promise<CogniteCadModel> {
const viewerModel = viewer.models.find(
(model) =>
isSameModel(model, addModelOptions) &&
const viewerModel = viewer.models.find((model) => {
const cadModel = { ...model, transform: model.getModelTransformation() };
return (
isSameModel(cadModel, addModelOptions) &&
isSameGeometryFilter(geometryFilter, initializingModelsGeometryFilter.current)
);
);
});

if (viewerModel !== undefined) {
return await Promise.resolve(viewerModel as CogniteCadModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,13 @@ export function PointCloudContainer({
return pointCloudModel;

async function getOrAddModel(): Promise<CognitePointCloudModel<DataSourceType>> {
const viewerModel = viewer.models.find((pointCloudModel) =>
isSameModel(pointCloudModel, addModelOptions)
);
const viewerModel = viewer.models.find((pointCloudModel) => {
const pointCloudModelClone = {
...pointCloudModel,
transform: pointCloudModel.getModelTransformation()
};
return isSameModel(pointCloudModelClone, addModelOptions);
});

if (viewerModel !== undefined) {
return await Promise.resolve(viewerModel as CognitePointCloudModel<DataSourceType>);
Expand Down
25 changes: 17 additions & 8 deletions react-components/src/components/RevealToolbar/SlicerButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,31 @@ const StyledMenu = styled(Menu)`
max-width: 32px !important;
min-width: 32px !important;
padding: 12px 8px 12px 8px !important;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
overflow: hidden !important;
display: flex !important;
flex-direction: column !important;
justify-content: center !important;
align-items: center !important;
.cogs-v10.cogs-slider .rc-slider-rail {
height: 100% !important;
width: 4px !important;
}
.cogs-v10.cogs-slider .rc-slider-track {
left: auto !important;
}
.cogs-v10.cogs-slider .rc-slider-handle {
margin-left: 0.75px !important;
}
`;

const StyledRangeSlider = styled(RangeSlider)`
height: 100% !important;
width: 4px !important;
display: flex;
flex-direction: row;
justify-content: center;
display: flex !important;
flex-direction: row !important;
justify-content: center !important;
}
`;

0 comments on commit 16ed4b2

Please sign in to comment.