How is it possible to implement a vertical plane detection (i.e. for walls)?
let configuration = ARWorldTrackingSessionConfiguration()
configuration.planeDet
In ARKit 1.0 there was just
.horizontalenum's case for detecting horizontal surfaces like a table or a floor. In ARKit 1.5 and higher there are.horizontaland.verticaltype properties of aPlaneDetectionstruct that conforms toOptionSetprotocol.
To implement a vertical plane detection in ARKit 2.0 use the following code:
configuration.planeDetection = ARWorldTrackingConfiguration.PlaneDetection.vertical
Or you can use detection for both types of planes:
private func configureSceneView(_ sceneView: ARSCNView) {
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal, .vertical] //BOTH TYPES
configuration.isLightEstimationEnabled = true
sceneView.session.run(configuration)
}
Also you can add an extension to ARSceneManager to handle the delegate calls:
extension ARSceneManager: ARSCNViewDelegate {
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
guard let planeAnchor = anchor as? ARPlaneAnchor else {
return
}
print("Found plane: \(planeAnchor)")
}
}