Some custom rendering questions

I’m new to Cesium and I’m trying to add a custom 3d object (basically a compass that will stay on the corner of the screen).
I think I got the part of building the actual geometry and rendering it, based on the Cesium primitives code (using Geometry class etc).

My questions are:

1 - Is there a simple way to get a heading angle relative to a Cartographic point (or the North pole, to be more specific). I need this to properly orient the compass geometry.

2 - I need to render the compass with an orthographic projection matrix, to get a pixel perfect orientation, instead of being slightly distorted when put at the corner of the screen. I searched for a way to provide custom matrices for primitives, GeometryInstance does allow to pass a custom model matrix, but not a projection matrix. And this make sense, since Cesium calculates the projection for the globe, etc.

One idea that I had was to use a custom material with a shader that can receive a custom projection matrix as a uniform, instead of using the one passed by Cesium. But I read about Cesium materials and they don’t seem to allow a custom shader.
So I might need to bypass the whole primitive system and draw it separately at the end of the scene rendering, since it is just a widget sitting on top of the world (it is fuly 3D though, so it needs to be draw with Cesium renderer, instead of just overlaying a picture in the webpage)

There was some work on this a while back: https://groups.google.com/forum/#!searchin/cesium-dev/compass/cesium-dev/fsOZRZ4zOHQ/iJCf1FIwBjsJ

Patrick

Thanks Patrick, I have read the code, that kind of helps with the question number 1, now I know how to get the compassing heading.
However it does not help with question 2.
That navigation widgets is fully 2d and from what I’ve gathered is based on html instead of webgl.
I want to render a 3d compass, that instead of belonging to the globe/scene, is a separate entity/widget, that would be rendered in orthographic mode.
Any tips about this?