CAGD 458 - Blog Post 2 - 4/12/2026
This sprint I finalized the compass getting it to track the devices orientation, it is not perfect, but it is very close to what a compass app would show you. In the demo, the compass rotates in real time as the device turns, and that movement is driven by a JavaScript bridge that listens to deviceorientation events in the browser. I handle multiple heading cases in the JavaScript, using alpha when absolute data is available, falling back to webkitCompassHeading on iOS, and converting values when needed to keep the heading consistent. That value is sent into my UpdateHeading method using SendMessage, where I parse it and store it as the current heading. I also added validation checks to make sure the value is not NaN or invalid before applying it, which helped prevent occasional glitches where the compass would jump or freeze. To make the compass feel stable, I focused heavily on filtering and smoothing the incoming data. I use Mathf.DeltaAngle to calculate the difference between the c...