mapbox-maps-ios icon indicating copy to clipboard operation
mapbox-maps-ios copied to clipboard

Camera and Model Position Misalignment at High Pitch Angles

Open programmer443 opened this issue 1 year ago • 0 comments

Environment

  • Xcode version: 15.3
  • iOS version: 17.4
  • Devices affected:
  • Maps SDK Version: 11.1.0

Observed behavior and steps to reproduce

I am experiencing an issue with the camera and model position alignment in my project. Specifically, when the pitch angle of the camera exceeds 100 degrees, the camera and model positions become misaligned. At a pitch of 0 degrees, the camera is facing the ground directly and both the camera and model positions are aligned correctly. However, as the pitch increases beyond 100 degrees, this alignment breaks down. I attached the pictures one at 0 pitch and other at 110 pitch for reference.

func cameraPositionInViewR(alt: Double, lat: Double, lng: Double, deviceHeading: Double, pitch: Double = 40) {
    let freeCam = self.mapProxy?.map?.freeCameraOptions
    
    // Convert altitude from hundreds of feet to meters
    freeCam?.altitude = alt + 200 // View from 100 meters above
    freeCam?.location = CLLocationCoordinate2D(latitude: lat, longitude: lng)

    freeCam?.setPitchBearingForPitch(pitch, bearing: -285) // Default look straight
    mapProxy?.map?.freeCameraOptions = freeCam!
}

Expected behavior

The camera and model positions should remain aligned regardless of the pitch angle.

I suspect this issue might be related to how pitch angles are being handled or interpreted within the freeCameraOptions. Any guidance or suggestions on how to resolve this misalignment issue would be greatly appreciated.

Additional links and references

image image

programmer443 avatar May 25 '24 12:05 programmer443