-
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
feat(react-components): Add ground plane rotation 0.52.0 #4638
Conversation
|
||
mesh.position.applyMatrix4(CDF_TO_VIEWER_TRANSFORMATION); | ||
const matrix4 = transformation3dToMatrix4(groundPlane).multiply(CDF_TO_VIEWER_TRANSFORMATION); |
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.
Cant we just convert Euler rotation to quaternion and apply to the mesh?
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.
We should also apply the scale. Isn't this what I'm doing? I am open to changing the syntax — do you have a concrete suggestion?
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.
// Apply position from groundPlane
mesh.position.set(groundPlane.position.x, groundPlane.position.y, groundPlane.position.z);
// Convert Euler rotation to quaternion and apply to the mesh
const euler = new Euler(groundPlane.rotation.x, groundPlane.rotation.y, groundPlane.rotation.z, groundPlane.rotation.order ?? 'XYZ');
mesh.quaternion.setFromEuler(euler);
// Apply scaling from groundPlane
mesh.scale.set(groundPlane.scaleX, groundPlane.scaleY, groundPlane.scaleZ);
I feel this is much simpler, unless it causes an issue
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.
I think below is much better than above suggestion
// Apply position, rotation, and scale using matrix
const matrix = new Matrix4();
const position = new Vector3(groundPlane.position.x, groundPlane.position.y, groundPlane.position.z);
const rotation = new Euler(groundPlane.rotation.x, groundPlane.rotation.y, groundPlane.rotation.z, groundPlane.rotation.order ?? 'XYZ');
const scale = new Vector3(groundPlane.scaleX, groundPlane.scaleY, groundPlane.scaleZ);
matrix.compose(position, new Quaternion().setFromEuler(rotation), scale);
mesh.matrix.copy(matrix);
matrix.decompose(mesh.position, mesh.quaternion, mesh.scale);
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.
After chatting with @haakonflatval-cognite, I think maybe the simplest way of doing this is what I updated it to now:
mesh.matrix.copy(matrix4);
mesh.matrixAutoUpdate = false;
Do you agree?
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.
👍
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.
LGTM 👍
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.
LGTM
…)" This reverts commit 5d0d7b9.
Type of change
Jira ticket 📘
No JIRA ticket.
Description 📝
This PR makes the ground plane load the Euler rotation and scale from DM. Before it only loaded the position.
How has this been tested? 🔍
This has been tested by
yalc
-ing with fusion.Test instructions ℹ️
Currently, I don't think there is any other easy way of testing than
yalc
-ing this into fusion and see that the rotation is the same as in SceneBuilder.Checklist ☑️