Improvement of DeviceOrientationCamera: Recover the real orientation North / South

Hi @Deltakosh,

I go back to you to know if you can improve DeviceOrientationCamera for allowing to recover the real orientation North / South.

That would be great, and useful for many applications.

I have already demonstrated a proof of concept to allow our students to be oriented on campus by scanning QR codes. But to have a correct orientation, students must remain facing the QRCodes until the program is initialized.

In the state, I, unfortunately, can’t go beyond that :frowning:

Thank you in advance for your feedback, which I hope will be positive.

The question is how could I do that? :slight_smile:
How can I get the real north?

Indeed, I searched the net, it is not something that seems easy :pensive: or even impossible :cry:
But I found this, maybe a lead to do that :smiley::
JavaScript Geolocation based Speedometer and Compass

Hi @Cstfan and @Deltakosh

I am trying to use this feature too! And I already mount some code to it, PG Sample but I do not know how to set the Device Orientation camera with the heading/North result from device compass!

If you guys end up finding a way I’ll gladly add a new “pointToNorth” function :slight_smile:

@Deltakosh and @Cstfan

Ok, I will try to evolute here!



Before I chekout source code of device orientaiton camera can someone tell me what web api it uses: device orientation & device motion events or sensor api’s orientation interface (virtual fusion sensors: absolute and relative orientation sensors).

If one day it becomes possible to have a “pointToNorth” function, it will open up great possibilities. :smiley:
I hope we can find a source that will allow us to do that.

Actually you can do that. The info Babylonjs device orientation specifc camera is fed by may have the absolute orientation, ie. the orientation wrt the North, if your device is capable of determining it. For example, If it has a magnetometer it can.

BJS uses the deviceorientationevent for this, and it has an absolute property.

@NRA your PG may use that property alongside the webkitCompassHeading you employ. It may have a wider support range. You can know how many angles your alpha angle is away from the North if the absolute is true at any time, so you can iplement your own pointToNorth function.