顯示用戶能夠移動(dòng)裆操、縮放并與他人共享的模型或場景怒详。
概覽
借助 AR 快速查看炉媒,用戶能夠在 ARKit 從現(xiàn)實(shí)環(huán)境中找到的任何表面上放置您提供的虛擬內(nèi)容。用戶可以通過以下方式與您的虛擬內(nèi)容進(jìn)行互動(dòng):使用觸控手勢來移動(dòng)和縮放虛擬內(nèi)容昆烁,或者通過 iOS 共享列表來與他人共享吊骤。
選取輸入格式
您可以采用 .usdz 或 .reality 格式提供增強(qiáng)現(xiàn)實(shí)體驗(yàn)的內(nèi)容:
(1) 要瀏覽 .usdz
文件資料庫,請參閱“AR 快速查看圖庫”静尼。
(2) 要瀏覽 .reality
素材資源資料庫白粉,請使用 Reality Composer。
如果您在 App 的“拷貝文件”構(gòu)建階段附加了 Reality Composer 文件 (.rcproject)鼠渺,那么 Xcode 會(huì)在構(gòu)建時(shí)自動(dòng)將轉(zhuǎn)換后的 .reality 文件輸出至您的 App 包鸭巴。
在您的 App 中呈現(xiàn)增強(qiáng)現(xiàn)實(shí)體驗(yàn)
在您的 App 中,您可以通過向 QLPreviewController 提供受支持的輸入文件來啟用 AR 快速查看系冗。下列代碼演示了如何從 App 套裝預(yù)覽名為 myScene 的場景
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: "myScene", ofType: "reality") else { fatalError("Couldn't find the supported input file.") }
let url = URL(fileURLWithPath: path)
return url as QLPreviewItem
}
}
為了防止用戶縮放您的虛擬內(nèi)容或自定默認(rèn)的分享列表行為奕扣,請使用 ARQuickLookPreviewItem 而非 QLPreviewItem 薪鹦。
在您的網(wǎng)頁中呈現(xiàn)增強(qiáng)現(xiàn)實(shí)體驗(yàn)
在您的網(wǎng)頁中掌敬,您可以通過鏈接受支持的輸入文件來啟用 AR 快速查看。
<div>
<a rel="ar" href="/assets/models/my-model.usdz">
<img src="/assets/models/my-model-thumbnail.jpg">
</a>
</div>
當(dāng)用戶在 Safari 瀏覽器中或者您的 App 所顯示的網(wǎng)頁視圖中點(diǎn)按鏈接時(shí)池磁,iOS 會(huì)替您在 AR 快速查看視圖中呈現(xiàn)您的場景奔害。有關(guān)更多信息,請參閱“在 iOS 版 Safari 瀏覽器中查看增強(qiáng)現(xiàn)實(shí)素材資源 (英文)”地熄。