Extract Reality Composer scene for ARQuickLook

↘锁芯ラ 提交于 2020-07-08 20:43:26

问题


I have a Reality Composer scene and I want to extract it as usdz file or any files that can be used in ARQuickLook? is it possible?


回答1:


From Apple's Creating 3D Content with Reality Composer document:

You can also save your composition to a .reality file for use as a lightweight AR Quick Look experience in your app or on the web. This allows users to place and preview content in the real world to get a quick sense of what it’s like.

To create a Reality file, choose File > Export > Export Project in the Reality Composer menu, and provide a name for the file. You use the Reality file that gets stored to disk just like you would use a USDZ file, as described in Previewing a Model with AR Quick Look.




回答2:


At build time, Xcode compiles your .rcproject into a .reality file, and AR Quick Look accepts preview items of type .reality. Here's an example that uses AR Quick Look to preview the Experience.rcproject taken from Apple's SwiftStrike TableTop sample code:

import UIKit
import QuickLook
import ARKit


class ViewController: UIViewController, QLPreviewControllerDataSource {

    override func viewDidAppear(_ animated: Bool) {
        let previewController = QLPreviewController()
        previewController.dataSource = self
        present(previewController, animated: true, completion: nil)
    }

    func numberOfPreviewItems(in controller: QLPreviewController) -> Int { return 1 }

    func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
        guard let path = Bundle.main.path(forResource: "Experience", ofType: "reality") else { fatalError("couldn't find the rcproject file.") }
        let url = URL(fileURLWithPath: path)
        let item = ARQuickLookPreviewItem(fileAt: url)
        return item
    }    
}


来源:https://stackoverflow.com/questions/56539227/extract-reality-composer-scene-for-arquicklook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!