viro
viro copied to clipboard
Method ViroARScene.getCameraOrientationAsync() returns strange values in rotation array
Environment
- Windows + Linux (WSL2)
- Device: Android 10. Xiaomi Mi 9
- ViroReact 2.20.2
Description
The ViroARScene.getCameraOrientationAsync()
returns unexpected values in rotation
array when I rotate the device over the y-axis, trying to keep the x
and z
axis fixed.
Specifically, when the y-axis reaches the -90º the x/z values change to +/180º and from this point the y-axis values are getting close to 0, for instance, instead of -135º the y-axis value is -45 with the x/z values in +/-180. In other words the y-axis values NEVER return an absolute value over 90.
So, there are some questions that I cannot find out a reasonable answer:
- Why the absolute value of y-axis is never greater than 90 ?
- Why the x/z values change to +/-180º when I reach some point (+/-90º in y-axis) if I'm just rotating the device over the y-axis.
Is this the expeted behavior ? If so, could anyone explain these values (please).
I've designed some mockups with the real rotation value got at each position and the "expected" value according to me (I know that there are an error margen of about 6 degrees):
Initial position. Expected values: [0,0,0]
Rotated -45º. Expected values: [0,-45,0]
Rotated -90º. Expected values: [0,-90,0]
Rotated -135º. Expected values: [0,-135,0]
Rotated +/-180º. Expected value: [0, +/-180, 0]
I suspect that the answer to this issue can help me with my other problem with the polyline rotation: #11
Reproducible Demo
To get the values I've been rotating the device in vertical position, when I reached the desired rotation I put my hand over the camera to force the event onTrackingUpdated
to be fired.
<ViroARScene onTrackingUpdated={this._onInitialized} anchorDetectionTypes={"PlanesVertical"}>
...
</ViroARScene>
_onInitialized(state, reason) {
if (state === ViroConstants.TRACKING_NORMAL && reason === ViroConstants.TRACKING_REASON_NONE) {
console.log('Tracking initiated NavScene');
this._scene.getCameraOrientationAsync().then(
(orientation) => {
console.log('Cam rot:', round(orientation.rotation));
});
}
}