Skip to content

Commit

Permalink
Move ui code to DispatchQueue.main queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Sega-Zero committed Apr 29, 2018
1 parent 797bb18 commit 552aa3b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Source/CTPanoramaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,17 @@ import ImageIO
let rm = motionData.attitude.rotationMatrix
var userHeading = .pi - atan2(rm.m32, rm.m31)
userHeading += .pi/2

if panoramaView.panoramaType == .cylindrical {
panoramaView.cameraNode.eulerAngles = SCNVector3Make(0, Float(-userHeading), 0) // Prevent vertical movement in a cylindrical panorama
}
else {
// Use quaternions when in spherical mode to prevent gimbal lock
panoramaView.cameraNode.orientation = motionData.orientation()

DispatchQueue.main.async {
if panoramaView.panoramaType == .cylindrical {
panoramaView.cameraNode.eulerAngles = SCNVector3Make(0, Float(-userHeading), 0) // Prevent vertical movement in a cylindrical panorama
}
else {
// Use quaternions when in spherical mode to prevent gimbal lock
panoramaView.cameraNode.orientation = motionData.orientation()
}
panoramaView.reportMovement(CGFloat(userHeading), panoramaView.xFov.toRadians())
}
panoramaView.reportMovement(CGFloat(userHeading), panoramaView.xFov.toRadians())
})
}
}
Expand Down

0 comments on commit 552aa3b

Please sign in to comment.