scihant / CTPanoramaView

A library that displays spherical or cylindrical panoramas with touch or motion based controls.
MIT License
1.04k stars 88 forks source link

compass rotation angle bug #63

Closed IhorKram closed 2 years ago

IhorKram commented 2 years ago

to rotate compass we use eulerAngles: -cameraNode.eulerAngles.y But it works not in a proper way. The compass always jumps in different directions during rotation.

IhorKram commented 2 years ago

I've found the solution. Instead of -cameraNode.eulerAngles.y

use rotation:

let v1 = SCNVector3(0, 0, 1)
let v2 = cameraNode.presentation.convertPosition(v1, to: nil)
let rotation = atan2(v2.z, v2.x) - (.pi / 2)
xavierchia commented 1 year ago

Had the same problem. Good fix. This fix should be merged into the latest version.