0

When using QLPreviewController to display a .usdz 3D Object.

There are 2 viewing modes: AR and Object

By default, AR is selected. I'd like the default selected to be "Object" and would like to also disable the Switch so that they can't view it in AR mode. Is this possible?

enter image description here enter image description here

Here is my subclassed QLPreviewController:

import UIKit
import ARKit
import QuickLook


class ARQLViewController: QLPreviewController, 
QLPreviewControllerDataSource {
var fileURL: URL!

override func viewDidLoad() {
    super.viewDidLoad()
    dataSource = self
}

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

func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
    let item = ARQuickLookPreviewItem(fileAt: fileURL)
    item.canonicalWebPageURL = nil
    return item
}

}
grantespo
  • 2,233
  • 2
  • 24
  • 62
  • What if you change the extension to `usd` or `usda`? – EmilioPelaez May 19 '21 at 17:42
  • I don't think the MIME makes a difference. I think it comes down to the limitations of `QLPreviewController` regardless of MIME. e.g.: others are also having trouble hiding that share button in top right. So, it may be that is is impossible or extremely difficult to modify that customized navbar – grantespo May 19 '21 at 17:44
  • Yes, the QLPreviewController is famously uncustomizable. Maybe changing the extension is not enough, but you could read the file, export as obj or another 3D supported format, and pass that to the preview controller. – EmilioPelaez May 19 '21 at 18:19
  • Since QLPreviewController has an awful forced UX. I resorted to viewing using .obj files with Scenekit – grantespo May 19 '21 at 19:12

1 Answers1

0

As EmilioPelaez mentioned, QLPreviewController is uncustomizable.

to view a 3d Object, I am no longer using .usdz files, but using obj files + SceneKit

grantespo
  • 2,233
  • 2
  • 24
  • 62