问题描述
这是Apple文档:
1。Loading Reality Composer Files Manually Without Generated Code
并且我使用了“从URL异步加载场景”代码:
func loadRealityComposerSceneAsync (filename: String,fileExtension: String,sceneName: String,completion: @escaping (Swift.Result<(Entity & HasAnchoring)?,Swift.Error>) -> Void) {
guard let realityFileSceneURL = createRealityURL(filename: filename,fileExtension: fileExtension,sceneName: sceneName) else {
print("Error: Unable to find specified file in application bundle")
return
}
let loadRequest = Entity.loadAnchorAsync(contentsOf: realityFileSceneURL)
let cancellable = loadRequest.sink(receiveCompletion: { (loadCompletion) in
if case let .failure(error) = loadCompletion {
completion(.failure(error))
}
},receiveValue: { (entity) in
// entity -> AnchorEntity
completion(.success(entity))
})
cancellable.store(in: &streams)
}
在viewDidLoad中:
loadRealityComposerSceneAsync(filename: "TestScene",fileExtension: "reality",sceneName: "space") { result in
switch result {
case .success(let anchor):
print("space is \(anchor)\n")
// anchor -> (Entity & HasAnchoring)?
// How to show the TestScene file on the self.arView.scene
break
case .failure(let error):
print(error.localizedDescription)
break
}
}
打印空间为:
Optional(▿ '' : AnchorEntity,children: 1
⟐ SynchronizationComponent
⟐ Transform
⟐ AnchoringComponent
▿ '' : Entity,children: 3
⟐ SynchronizationComponent
⟐ Transform
▿ 'boxs' : Entity,children: 1
⟐ SynchronizationComponent
⟐ Transform
▿ 'simpBld_root' : ModelEntity
⟐ ModelComponent
⟐ SynchronizationComponent
⟐ Transform
⟐ CollisionComponent
▿ '8C519DF7-2575-4AEE-A729-57F7CE0EFB41' : Entity,children: 1
⟐ SynchronizationComponent
⟐ Transform
▿ 'simpBld_root' : ModelEntity
⟐ ModelComponent
⟐ SynchronizationComponent
⟐ Transform
▿ 'star' : Entity,children: 1
⟐ SynchronizationComponent
⟐ Transform
▿ 'simpBld_root' : ModelEntity
⟐ ModelComponent
⟐ SynchronizationComponent
⟐ Transform
)
所以我的问题是:如何在self.arView.scene上显示我的TestScene.reality文件。 谢谢!!!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)