For a while, I’ve had 2D elements overlayed on top of the 3D world in Might is Right, and it looked pretty good to me.
But lately I’ve been wondering, what if I could apply rotation of these 2d elements based on camera transform. So I spent a bit of time and added support for that into the engine. Here’s what that looks like:
Honestly, I’m pretty happy.
Right now I compute rotation by taking 2 points in the world and transforming them both into view space, then taking the delta and using good old Math.atan2.
const angle = Math.atan2(up_ndcY - ndcY, up_ndcX - ndcX);
I keep thinking that there must be a better way to do that, to avoid all that extra math, plus the second point seems a bit wonky, I’m just taking the original world point + Vector(0,1,0).
Anyone got ideas?