Hello, I have a problem with the camera behavior of a device orientation camera and universal camera.
My application should run in browser and on a smartphone device. The app on the smartphone runs only in landscape mode. On the browser the camera looks in the right direction and behaves like expected, but on the smartphone it looks in different one (90 degrees rotated).
Now I find out that the behavior depends on if I start in landscape or portrait mode. You can use this playground for testing: https://playground.babylonjs.com/#12WBC#492
When I load the playground in a browser on a pc, it looks at the red quad. When I started it on a smartphone in portrait mode it looks also to the red quad, but when I load the playgound in landscape mode it looks to the blue quad.
Do you have a fix or workaround for this behavior?
Starting in portrait or landscape mode , chrome on Android, It always looks at the blue square
When using a device orientation camera it takes the rotation as defined by the device you are using and use that to render the scene. We have no control over what the OS itself is delivering, but we do provide it straight to the camera on each frame.
Try loading the scene when looking up, you will not see any of the boxes. turn to the left and reload the page - a different box will appear.
Does it make sense? I might be missing something, maybe a screencast can help
Thanks for the quick response. I hope the screencast makes it a bit clearer what I mean.
Description on what I’m doing:
- I load the playground site above in portrait mode and get a red quad.
- I turn to landscape mode, doesn’t change the direction of the handy and load the site again. The result is a blue quad.
- Then I turn back to portrait mode, doesn’t change the direction, load the site again and get the red quad again.
When I load the playground on my pc I get the red quad.
I got this behavior an my handy in chrome and firefox. firefox caches the site so I have to go out and return to firefox app to get the behavior.
My chrome version on my android handy is 87.04280.66.
Is there any update on this matter? I also get inconsistent results with
.setTarget on device orientation camera:
I tested the playground on: Android 10 Pixel XL
Firefox version 83.1.0
portrait: blue (consistent)
landscape: yellow (little inconsistent)
landscape: yellow (little inconsistent)
I did the test a couple of times, with different horizontal start angles of my phone. With some angles I get the expected red square as result. But it is like 1 out of 36 times.
Is there maybe a proper workaround for now? Or any best practice with the device orientation camera to get a consistent result? Thanks in advance!
I tested the playground scene with another handy and got the same result as Cedrics - seeing always the blue quad independently from portrait or landscape mode.
It also seems, that it makes no different what values a used for the setTarget function, I get every time the red or blue quad, but for some milliseconds the right quad is shown. When I load the playground on my PC every thing works as expected.
I also tried a the UniversalCamera where I am adding the device orientation to the inputs. This has the same result as descripted above, but without adding the device orientation to the inputs of the UniversalCamera it behaves as aspected.
For me it seems that the setTarget() function in combination with device orientation would set the values right, but than the orientation camera snaps back to some init value, but that’s just a assumption.
I hope this is helpful, to come closer to strange behavior.
my workaround for this bug is to check if I am on a mobile or PC and than rotate all assets instead of rotating the camera. If someone has a better solution let me know
This works for me because the applications runs only in landscape mode. If someone needs both landscape and portrait mode on a mobile, then he has to face the different behaviors as descripted above.
It’s maybe not the best solution, but it works. I hope this helps out others with the same problem.