Hello everyone!
is it possible to get somehow model orientation from the .glb file? I need to know where the north is. Or maybe there is some information in the scene about it?
Well, where is north? Do we say that (0,0,1) is north?
Then you can get the mesh rotation and see how it compares
Alright, I’ll check this tomorrow. I need it to calculate azymuth
Basically what I need to do is to calculate alfa angle.
Observer(black dot) is a mesh and orange dot is also a mesh in my case.
I think what @Deltakosh ment is, there is no predefined correct rotation or n/s/e/w.
everything is relative north is where ever you choose it is compared to the rest of your scene.
Totally. Basically in your case you can do the dot vector of (0,0,1) and the vector from a to b(you need to normalize it)
It will give you the cos of the azimuth so Math.acos will give you your angle
@Deltakosh, your comment was very helpful, I think I’m really close to the solution. What’s more, I found that (0, 0, -1) vector is the north in my model. But I came across two problems I couldn’t solve.
https://playground.babylonjs.com/#HZXM1I#5
- I think azimuth shouldn’t be changing when dragging Y axis.
- Your calculations are very good but it doesn’t work for the 0-360° range but for 0-180°. What I mean is when we put the red spheres(alfa = beta in this case) like in the image below they gonna have the same azimuth but it shouldn’t be the same…
should be something like this:
sorry for my bad drawings
I think the sign of the dot should give you the quadrant (0,0,1).(0,0,-1) will return -1
I managed to fix previously mentioned two issues Maybe not exactly in the mathematical way but I guess it gonna work well.
here’s the playground if someone ever needs it:
https://playground.babylonjs.com/#HZXM1I#7