小编Mar*_*nov的帖子

RealityKit – 从 Web URL 资源加载 ModelEntity

我想知道是否有人知道是否可以加载 AR 对象(例如,从 Web url 加载 .usdz 并将其放置在 AR 视图中)。我尝试过这个:

let fileUrl = NSURL(string: "https://developer.apple.com/augmented-reality/quick-look/models/drummertoy/toy_drummer.usdz")
cancellable = Entity.loadModelAsync(contentsOf: fileUrl! as URL)
                .sink(receiveCompletion: { completion in
                    self.cancellable?.cancel()
                }, receiveValue: { [self] (model: Entity) in
                    if let model = model as? ModelEntity {
                        let anchorEntity = AnchorEntity(anchor: anchor)
                        anchorEntity.addChild(model)

                        arView.scene.addAnchor(anchorEntity)
                        loadingView.isHidden = true
                    }
                })
Run Code Online (Sandbox Code Playgroud)

但它不起作用并抛出错误Failed to open scene 'https://developer.apple.com/augmented-reality/quick-look/models/drummertoy/toy_drummer.usdz'.

如果可能的话你会吗?

quicklook augmented-reality swift usdz realitykit

5
推荐指数
1
解决办法
1574
查看次数

标签 统计

augmented-reality ×1

quicklook ×1

realitykit ×1

swift ×1

usdz ×1