Swift 虚拟现实技术 尝试使用我的RealyTyKIT项目作为屏幕应用程序(VR)的基础,而不是投影到真实世界(AR)外的后置摄像头。
有人知道如何使用Swift 虚拟现实技术 尝试使用我的RealyTyKIT项目作为屏幕应用程序(VR)的基础,而不是投影到真实世界(AR)外的后置摄像头。,swift,virtual-reality,realitykit,reality-composer,Swift,Virtual Reality,Realitykit,Reality Composer,有人知道如何使用.nonAR摄像头选项异步加载RealityKit项目,从而使其在应用程序中投影,而不是利用后向摄像头吗 我是在Swift代码还是Reality Composer项目中创建位置信息?以下是如何借助RealityKit的.loadModelAsync()实例方法和Combine的anyCancelable类型异步加载.usdz虚拟现实模型 import UIKit import RealityKit import Combine class VRViewController: U
.nonAR
摄像头选项异步加载RealityKit项目,从而使其在应用程序中投影,而不是利用后向摄像头吗
我是在Swift代码还是Reality Composer项目中创建位置信息?以下是如何借助RealityKit的
.loadModelAsync()
实例方法和Combine的anyCancelable
类型异步加载.usdz
虚拟现实模型
import UIKit
import RealityKit
import Combine
class VRViewController: UIViewController {
@IBOutlet var arView: ARView!
var anyCancellable: AnyCancellable? = nil
let anchorEntity = AnchorEntity(world: [0, 0,-2])
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
arView.backgroundColor = .black
arView.cameraMode = .nonAR
anyCancellable = ModelEntity.loadModelAsync(named: "horse").sink(
receiveCompletion: { _ in
self.anyCancellable?.cancel()
},
receiveValue: { [self] (object: Entity) in
if let model = object as? ModelEntity {
self.anchorEntity.addChild(model)
self.arView.scene.anchors.append(self.anchorEntity)
} else {
print("Can't load a model due to some issues")
}
}
)
}
}
但是,如果要在三维环境中移动,请不要使用.nonAR
相机模式,而是使用:
arView.environment.background = .color(.black)