48 lines
1.6 KiB
Swift
48 lines
1.6 KiB
Swift
//
|
|
// SessionConfigurationFactory.swift
|
|
// GasTankAR
|
|
//
|
|
// Created by Dennis Nemec on 26.08.26.
|
|
//
|
|
|
|
import ARKit
|
|
|
|
/// Baut die `ARWorldTrackingConfiguration` für den AR-Modus.
|
|
/// Kapselt die LiDAR-/People-Occlusion-/Image-Detection-Logik an einem Ort.
|
|
struct SessionConfigurationFactory {
|
|
let useLiDAR: Bool
|
|
let referenceImages: Set<ARReferenceImage>
|
|
|
|
func make(withImages: Bool, initialWorldMap: ARWorldMap?) -> ARWorldTrackingConfiguration {
|
|
let config = ARWorldTrackingConfiguration()
|
|
config.planeDetection = [.horizontal]
|
|
|
|
if useLiDAR {
|
|
if ARWorldTrackingConfiguration.supportsSceneReconstruction(.mesh) {
|
|
config.sceneReconstruction = .mesh
|
|
}
|
|
if ARWorldTrackingConfiguration.supportsFrameSemantics(.sceneDepth) {
|
|
config.frameSemantics.insert(.sceneDepth)
|
|
}
|
|
} else {
|
|
config.sceneReconstruction = []
|
|
config.frameSemantics = []
|
|
}
|
|
|
|
// People Occlusion funktioniert auch ohne LiDAR (A12+): Personen zwischen Kamera
|
|
// und Tank verdecken das Objekt korrekt. (Beliebige Objekte wie Stühle brauchen LiDAR.)
|
|
if ARWorldTrackingConfiguration.supportsFrameSemantics(.personSegmentationWithDepth) {
|
|
config.frameSemantics.insert(.personSegmentationWithDepth)
|
|
}
|
|
|
|
if let initialWorldMap {
|
|
config.initialWorldMap = initialWorldMap
|
|
}
|
|
if withImages {
|
|
config.detectionImages = referenceImages
|
|
config.maximumNumberOfTrackedImages = 1
|
|
}
|
|
return config
|
|
}
|
|
}
|