Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startAngle not working when controlMethod = motion #36

Open
ali991 opened this issue Mar 14, 2019 · 10 comments
Open

startAngle not working when controlMethod = motion #36

ali991 opened this issue Mar 14, 2019 · 10 comments

Comments

@ali991
Copy link

ali991 commented Mar 14, 2019

when setting controlMethod = motion , despite any value we put on our startAngle, our camera node keeps the same angle,

@ali991
Copy link
Author

ali991 commented Mar 14, 2019

If controlMethod = touch everything is correct

@nayooti
Copy link

nayooti commented Apr 29, 2021

related to #31

@PeHk
Copy link

PeHk commented Oct 1, 2021

Do we have any updates on this case? I need it too, I am not sure how to implement such a case ..

@nayooti
Copy link

nayooti commented Oct 1, 2021

Do we have any updates on this case? I need it too, I am not sure how to implement such a case ..

Here is what I did a while ago:

class PanoramaController: UIViewController {

       lazy var loctionManager: CLLocationManager = {
        let locationManager = CLLocationManager()
        locationManager.delegate = self
        return locationManager
    }()

    private lazy var panoramaView: CTPanoramaView = {
        let view = CTPanoramaView()
        view.compass = compassView // create CTPieSlideView somewhere in this ViewController if needed
        return view
    }()


    var northAngle: Float? {
        didSet {
            if let newValue = northAngle, oldValue == nil {
             	// this will only set once
               //  print("set start angle to: \(newValue)")
                panoramaView.startAngle = newValue // -.pi / 2
                panoramaView.controlMethod = .motion
            }
        }
    }
}

/* 
use location manager delegate to find and set north and calibrate panorama view 
*/

extension PanoramaController: CLLocationManagerDelegate {
    func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {

        // calculate + reset north
        let heading = newHeading.magneticHeading
        let normalisedHeading = Double((Int(heading) - 270 + 360) % 360)
        let radian = normalisedHeading * .pi / 180
        let radianPi = radian / .pi
        // center image (image is centered at -0.5 * pi)
        let imageCenter = 3.5 * .pi
        let centeredRadian = imageCenter - radian
        self.northAngle = Float(centeredRadian)  // Float(imageOffset)
        manager.stopUpdatingHeading()
    }
}

Hope I could help.

@PeHk
Copy link

PeHk commented Oct 1, 2021

lazy var loctionManager: CLLocationManager = {
        let locationManager = CLLocationManager()
        locationManager.delegate = self
        return locationManager
    }()

I've added your code to my app, I am able to get the print out of the new value (I must added a locationManager.startUpdatingHeading() in viewDidLoad()), but there is no change on the panorama view at all. Can you please check if you are not using the old version of the Pod? Basically, in the CTPanoramaView class, there is no such option to set offset to spherical panorama, it really does nothing at all. Even I've tried to rewrite the code, there is SCNVector4 and I am not really sure how to tell this vector to move a bit... It always mess up all the panorama stuff.

@nayooti
Copy link

nayooti commented Oct 1, 2021

I don't have much time.
If I recall correctly I took the CTPanoramaView from a PR that has been closed without being merged.
In my scenario I needed motion and touch support at the same time.
I think it is the PR mentioned here: #46.

@PeHk
Copy link

PeHk commented Oct 1, 2021

I don't have much time. If I recall correctly I took the CTPanoramaView from a PR that has been closed without being merged. In my scenario I needed motion and touch support at the same time. I think it is the PR mentioned here: #46.

Great, I was able to get both motion and touch support from the PR, but still, for spherical panorama, there is no chance of getting the offset based on device heading :(

@PeHk
Copy link

PeHk commented Oct 2, 2021

@nayooti sorry for bothering you again. Can you share the code from the CTPanoramaView as well? I think I've just missing some little stuff to be able to make it work. I am not sure how to add a offset to the X axis only... It will be very very helpful and kind. Thanks!

@nayooti
Copy link

nayooti commented Oct 7, 2021

@nayooti sorry for bothering you again. Can you share the code from the CTPanoramaView as well? I think I've just missing some little stuff to be able to make it work. I am not sure how to add a offset to the X axis only... It will be very very helpful and kind. Thanks!

You should have find an invitation for a project that includes sample code.

@PeHk
Copy link

PeHk commented Oct 10, 2021

@nayooti sorry for bothering you again. Can you share the code from the CTPanoramaView as well? I think I've just missing some little stuff to be able to make it work. I am not sure how to add a offset to the X axis only... It will be very very helpful and kind. Thanks!

You should have find an invitation for a project that includes sample code.

Yes thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants