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

sync quaternion instead of euler #368

Closed
wants to merge 2 commits into from
Closed

Conversation

vincentfretin
Copy link
Member

@vincentfretin vincentfretin commented Sep 17, 2022

Sync quaternion instead of the rotation euler to fix some rotation issues with the YXZ or XYZ euler order.
I didn't fix the tests yet.
@kylebakerio with that does it fix your rotation issues?

@kylebakerio
Copy link
Member

Yes! I compared it with master, and this branch does indeed fix it.
Here's the problem on master:
naf-rotation-problem.webm
Here's the issue fixed after this fix:
naf-controller-fixed.webm

@@ -411,6 +408,21 @@ AFRAME.registerComponent('networked', {
// Call networkUpdatePredicate first so that it can update any cached values in the event of a fullSync.
if (this.networkUpdatePredicates[i](syncedComponentData) || fullSync) {
componentsData = componentsData || {};
if (componentName === 'rotation') {
// We compared the rotation, but we are sending actually the quaternion.
Copy link
Member

Choose a reason for hiding this comment

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

"but we are sending actually" -> "but we actually send" or, "but we are actuallying sending"

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I changed to "but we actually send".

@vincentfretin
Copy link
Member Author

Out of curiosity, did you try before adding rotation component on the entities of left-hand-default-template and right-hand-default-template templates, as well on my-tracked-left-hand and my-tracked-right-hand entities so this set the YXZ order? Didn't this fix the issue too?
Even if it fixed the issue, putting an empty rotation component just to set the same rotation order as the hard coded YXZ in naf is counter-intuitive, I agree.

@kylebakerio
Copy link
Member

Out of curiosity, did you try before adding rotation component on the entities of left-hand-default-template and right-hand-default-template templates, as well on my-tracked-left-hand and my-tracked-right-hand entities so this set the YXZ order? Didn't this fix the issue too? Even if it fixed the issue, putting an empty rotation component just to set the same rotation order as the hard coded YXZ in naf is counter-intuitive, I agree.

I just hadn't gotten around to trying.

@vincentfretin
Copy link
Member Author

Just adding templateInner.setAttribute('rotation', '0 0 0'); // to set the YXZ order in addHandTemplate
fixes the issue as well.
The avatar has the look-controls component on it so it's setting the YXZ order because it has rotation component as dependency, but on the receiving side in avatar-template we have the default XYZ because we don't specify the rotation component on the template, but even if the order mismatch we don't seem to have the issue.
FYI Hubs has a set-yxz-order component they use on rig, camera, hands and media to fix this issue actually, see
https://github.com/mozilla/hubs/search?q=set-yxz-order
and in their new NetworkedTransform they are syncing the quaternion now.

@vincentfretin
Copy link
Member Author

I pushed 0d46822 on master to immediately fix the issue.
I'll work further on this PR, fixing the tests obviously, but also I want to try modifying the serialization to use an array instead of an object with x,y,z,w keys for position, rotation, scale and using on the receiving side Vector3/Quaternion.fromArray(data) instead of Vector3/Quaternion.copy(data)

@vincentfretin
Copy link
Member Author

I'm not sure if this is relevant to work on this change. We're adding an additional float to every rotation sync in the naf messages.
And we're discussing perf with binary protocol in #455

@vincentfretin
Copy link
Member Author

That would be a non issue in aframe 1.6.0.
aframe master now set object3D.rotation.order = 'YXZ'; even when the rotation component is not set.
aframevr/aframe#5513

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.

None yet

2 participants