在统一中,我们可以用环境深度实现遮挡。它在场景后面使用ARKit。如何在iOS ARkit中实现相同的行为。
我知道我们可以配置框架语义的深度,但我怀疑它是否真的等同于统一环境的深度遮挡?
// Build the set of required frame semantics.
let semantics: ARConfiguration.FrameSemantics = [.sceneDepth]
configuration.frameSemantics = semantics
session.run(configuration)发布于 2021-12-24 13:15:39
在ARKit中实现sceneReconstruction选项,在RealityKit中打开.occlusion。
唯一的缺点是丑陋的面具周围有柔软膨胀的边缘.
import RealityKit
import SwiftUI
import ARKit
struct ContentView: View {
var body: some View {
return ARContainer().ignoresSafeArea()
}
}
struct ARContainer: UIViewRepresentable {
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
arView.cameraMode = .ar
arView.automaticallyConfigureSession = false
let config = ARWorldTrackingConfiguration()
config.sceneReconstruction = .mesh
arView.session.run(config)
arView.environment.sceneUnderstanding.options = .occlusion
let box: MeshResource = .generateBox(size: 0.5)
let material = SimpleMaterial(color: .green, isMetallic: true)
let entity = ModelEntity(mesh: box, materials: [material])
let anchor = AnchorEntity(world: [0,0,-1.5])
anchor.addChild(entity)
arView.scene.anchors.append(anchor)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) { }
}https://stackoverflow.com/questions/70458954
复制相似问题