So in the WWDC23 video on the Roomplan enhancement, it says that it is now possible to set a custom ARSession for the RoomCaptureSession. But how do you actually set the config for the custom ARSession?
init() {
let arConfig = ARWorldTrackingConfiguration()
arConfig.worldAlignment = .gravityAndHeading
arSession = ARSession()
roomCaptureView = RoomCaptureView(frame: CGRect(x: 0, y: 0, width: 42, height: 42), arSession: arSession)
sessionConfig = RoomCaptureSession.Configuration()
roomCaptureView.captureSession.delegate = self
roomCaptureView.delegate = self
}
However, I keep getting an issue that self is being used in the property access before being initialised. What can I do to fix it?
Had to move some code around to get it to work. I think the main issue was declaring arSession as a class variable instead of within the initialiser.
class RoomCaptureController: RoomCaptureViewDelegate, RoomCaptureSessionDelegate, ObservableObject
{
var roomCaptureView: RoomCaptureView
var sessionConfig: RoomCaptureSession.Configuration
init() {
roomCaptureView = RoomCaptureView(frame: CGRect(x: 0, y: 0, width: 42, height: 42))//, arSession: arSession)
sessionConfig = RoomCaptureSession.Configuration()
let arConfig = ARWorldTrackingConfiguration()
arConfig.worldAlignment = .gravityAndHeading
roomCaptureView.captureSession.arSession.run(arConfig)
roomCaptureView.captureSession.delegate = self
roomCaptureView.delegate = self
}
}