Where do I need to add one of these lines of code in order to enable people occlusion in my scene?
config.frameSemantics.insert(.personSegmentationWithDepth)
static var personSegmentationWithDepth: ARConfiguration.FrameSemantics { get }
Here is the code:
import UIKit
import RealityKit
import ARKit
class ViewControllerBarock: UIViewController, ARSessionDelegate {
@IBOutlet var arView: ARView!
let qubeAnchor = try! Barock.loadQube()
var imageAnchorToEntity: [ARImageAnchor: AnchorEntity] = [:]
override func viewDidLoad() {
super.viewDidLoad()
arView.scene.addAnchor(qubeAnchor)
arView.session.delegate = self
}
func session(_ session: ARSession, didAdd anchors: [ARAnchor]){
anchors.compactMap { $0 as? ARImageAnchor }.forEach {
let anchorEntity = AnchorEntity()
let modelEntity = qubeAnchor.stehgreifWurfel!
anchorEntity.addChild(modelEntity)
arView.scene.addAnchor(anchorEntity)
anchorEntity.transform.matrix = $0.transform
imageAnchorToEntity[$0] = anchorEntity
}
}
func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
anchors.compactMap { $0 as? ARImageAnchor }.forEach {
let anchorEntity = imageAnchorToEntity[$0]
anchorEntity?.transform.matrix = $0.transform
}
}
}