I have been trying to find an answer to this for hours to no avail. Currently the mesh that shows scene reconstruction shows different colors based on how far the object is from the camera. I have tried all kinds of variations of the code below from many different sources (including from the Swift documentation), but no matter what I do, I cannot get the colors to be uniform or be colored based on classification. If anyone has any ideas on how to fix this, that would be greatly appreciated. Alternatively, I have heard that there is something similar to this in SceneKit, so if no one can figure this out, then I will also take suggestions on how to do it with SceneKit. Thanks in advance.
import UIKit
import RealityKit
import ARKit
extension ARMeshClassification {
var description: String {
switch self {
case .ceiling: return "Ceiling"
case .door: return "Door"
case .floor: return "Floor"
case .seat: return "Seat"
case .table: return "Table"
case .wall: return "Wall"
case .window: return "Window"
case .none: return "None"
@unknown default: return "Unknown"
}
}
var color: UIColor {
switch self {
case .ceiling: return .red
case .door: return .green
case .floor: return .blue
case .seat: return .cyan
case .table: return .magenta
case .wall: return .yellow
case .window: return .black
case .none: return .systemOrange
@unknown default: return .white
}
}
}
class ViewController: UIViewController {
@IBOutlet var arView: ARView!
override func viewDidLoad() {
super.viewDidLoad()
arView.automaticallyConfigureSession = false
let config = ARWorldTrackingConfiguration()
config.sceneReconstruction = .meshWithClassification
arView.debugOptions.insert(.showSceneUnderstanding)
}
}