-
Notifications
You must be signed in to change notification settings - Fork 20
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
fix(react-components): Fixes bug where ground plane scale is stored as xz instead of xy #4743
Merged
anders-hopland
merged 3 commits into
master
from
amh/react-components-fix-bug-with-wrong-scene-ground-plane-scale
Sep 6, 2024
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,13 +77,24 @@ export const useGroundPlaneFromScene = (sceneExternalId: string, sceneSpaceId: s | |
} | ||
const groundMeshes: CustomObject[] = []; | ||
|
||
// New scale format was introduced as a bug in the Scenebuilder | ||
// on August 1st, 2024. This is a temporary fix to handle both formats. | ||
// This should be removed when we upgrade the Scene Data Model to a new version | ||
const groundPlaneUsesNewScaleFormat = groundPlaneUseNewScaleFormat( | ||
scene.sceneConfiguration.updatedAt | ||
); | ||
|
||
scene.groundPlanes.forEach((groundPlane, index) => { | ||
if (groundPlaneTextures?.[index] === undefined) { | ||
return; | ||
} | ||
const texture = groundPlaneTextures[index]; | ||
const material = new MeshBasicMaterial({ map: texture, side: DoubleSide }); | ||
const geometry = new PlaneGeometry(10000 * groundPlane.scaleX, 10000 * groundPlane.scaleY); | ||
|
||
const scaleX = groundPlane.scaleX; | ||
const scaleY = groundPlaneUsesNewScaleFormat ? groundPlane.scaleZ : groundPlane.scaleY; | ||
|
||
const geometry = new PlaneGeometry(10000 * scaleX, 10000 * scaleY); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still a bit weird to have this random scaling factor here 😅 Should it be in a variable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, fixed in 60db811 |
||
|
||
geometry.name = `CogniteGroundPlane`; | ||
|
||
|
@@ -121,4 +132,16 @@ export const useGroundPlaneFromScene = (sceneExternalId: string, sceneSpaceId: s | |
clear(groundMeshes); | ||
}; | ||
}, [groundPlaneTextures]); | ||
|
||
function groundPlaneUseNewScaleFormat(lastUpdatedAt: string | undefined): boolean { | ||
if (lastUpdatedAt === undefined) { | ||
return false; | ||
} | ||
|
||
const dateModified = new Date(lastUpdatedAt); | ||
|
||
const groundPlaneScaleFormatChangedDate = new Date('2024-08-01T10:44:00.000Z'); | ||
|
||
return dateModified > groundPlaneScaleFormatChangedDate; | ||
} | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to write this down in your document, so that we remember to actually remove this 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!