On vision os we can go to Visualizations > Occlusion Mesh
To show something like the below:
I would like to be able to toggle that in the code, like a function I can toggle, or just add it. I was checking Visualizing and Interacting with a Reconstructed Scene from apple. The example they using is using
@IBOutlet var arView: ARView!
Then
func toggleMeshButtonPressed(_ button: UIButton) {
let isShowingMesh = arView.debugOptions.contains(.showSceneUnderstanding)
if isShowingMesh {
arView.debugOptions.remove(.showSceneUnderstanding)
button.setTitle("Show Mesh", for: [])
} else {
arView.debugOptions.insert(.showSceneUnderstanding)
button.setTitle("Hide Mesh", for: [])
}
}
When I try that in visionOS it gives me an error : 'ARView' is unavailable in visionOS
I am able to reconstruct the scene using :
import ARKit
import RealityKit
import RealityKitContent
import SwiftData
import SwiftUI
@Observable
class EntityModel {
let session = ARKitSession()
let sceneReconstruction = SceneReconstructionProvider()
var contentEntity = Entity()
This is also a copy paste from some of the apples code
How can I add/toggle the Occlusion Mesh on the visionOS properly?