Scenekit SCNRenderer snapshot orientation issue

Viewed 261

SCNRenderer.snapshot works good in portrait mode.

If the device is in landscape the ARSCNView is viewed correctly in device, but on taking snapshot there is a mismatch between camera preview and 3d model orientation.

renderer.snapshot in portrait

portrait

renderer.snapshot in landscape

landscape

Actual screenshot of device in landscape mode (expected result of renderer.snapshot in landscape)

screenshot

Video recording for better understanding the issue

Apple developer forum mentioning same issue link 1, link 2

To simulate issue in XCode File -> New -> Project -> Augmented Reality App and add the below code:

override func viewDidLoad() {
        super.viewDidLoad()
        .
        .
        .
        if let device = MTLCreateSystemDefaultDevice(){
        self.renderer = SCNRenderer(device: device, options: nil)
        renderer.scene = self.sceneView.scene
    }
}

@IBAction func captureButtonClicked(_ sender: UIButton) {
    let time = CACurrentMediaTime()
    let img = renderer.snapshot(atTime: time, with: CGSize(width: self.sceneView.frame.width, height: self.sceneView.frame.height), antialiasingMode: .none)
    UIImageWriteToSavedPhotosAlbum(img, self, #selector(imageSaved(_:didFinishSavingWithError:contextInfo:)), nil)
}
0 Answers
Related