由于某些原因,我无法让人物遮挡(people occlusion)起作用,尽管我看了Stackoverflow上的某人的问题。以下是我的代码:
//Load ARView
let arView = ARView(frame: .zero)
//Load people occlusion
let session = ARSession()
if let configuration = session.configuration as? ARWorldTrackingConfiguration {
configuration.frameSemantics.insert(.personSegmentationWithDepth)
session.run(configuration)
}
//Load custom model(not in use)
let model = try! Entity.loadModel(named: "Mug")
//Load Anchor + Entity
let anchor = AnchorEntity(plane: .horizontal)
let box = MeshResource.generateBox(size: 0.1)
let material = SimpleMaterial(color: .red, isMetallic: true)
let entity = ModelEntity(mesh: box, materials: [material])
arView.scene.anchors.append(anchor)
anchor.addChild(entity)
return arView
我错过了什么?
touchesBegan
吗?我不想等待用户输入才启用遮挡。我希望尽快启用它。 - user3064538renderer(...)
或session(...)
中使用let frame = arView.session.currentFrame
,然后使用guard frame?.estimatedDepthData != nil else { print("depth is being captured") return }
。 - Andy Jazz