I place a virtual model on the wall 10m away with RealityKit. I can not see the virtual model, though I can see the wall clearly. And when I enable debugoption.showSceneUnderstanding
in RealityKit, the virtual model shows up. Or when I come closer to the wall, the virtual model can also show up. The configuration of ARView is as follows. Debug options are controlled by showMesh
.
func makeUIView(context: Context) -> ARView {
let config = ARWorldTrackingConfiguration()
// Plane Detection
config.planeDetection = [.horizontal, .vertical]
// Environment Texturing
if #available(iOS 12, *) {
config.environmentTexturing = .automatic
}
// Person segmantantion
if (ARWorldTrackingConfiguration.supportsFrameSemantics(.personSegmentationWithDepth)) {
config.frameSemantics.insert(.personSegmentationWithDepth)
config.frameSemantics.insert(.sceneDepth)
print("[Debug] People occlusion on")
} else {
print("[Debug] People occlusion not available on this devices")
}
// Use LiDAR to promote the scan ablity
if(ARWorldTrackingConfiguration.supportsSceneReconstruction(.mesh)){
config.sceneReconstruction = .mesh
print("[Debug] Scene reconstruction on")
} else {
print("[Debug] The device does not support LiDAR")
}
// Scene Understanding
arViewModel.arView.environment.sceneUnderstanding.options.insert(.occlusion)
arViewModel.arView.environment.sceneUnderstanding.options.insert(.receivesLighting)
// ARCoachingOverlay
arViewModel.arView.addCoaching()
// Debug
if showMesh {
arViewModel.arView.debugOptions.insert(.showAnchorOrigins)
arViewModel.arView.debugOptions.insert(.showSceneUnderstanding)
}
arViewModel.arView.session.run(config)
placementSetting.sceneObserver = arViewModel.arView.scene.subscribe(to: SceneEvents.Update.self, { (event) in
updateScene(for: arViewModel.arView)
})
return arViewModel.arView
}
Do I miss some configurations? Does ARKit support the visualization of objects at distance?
Here is the video telling what I met.
P.S.
The AR object disappears at 23 seconds and `debug option is enabled when the meshes of the scene appears at 40 seconds.
Update!: I find the problem is caused by:
arViewModel.arView.environment.sceneUnderstanding.options.insert(.occlusion)
When I disable the occulusion by removing the above sentence, the AR objects can be seen at distance but can not be occluded by real objects. Moreover, I find the problem may be irrelevant to lidar because I tried lidar+occlusion(disappear), lidar(work well without occlusion), occlusion(disappear), none(work well without occlusion).
Lidar is enabled by:
config.sceneReconstruction = .mesh