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
}
}
Post
Replies
Boosts
Views
Activity
Here is the updated answer:
var node: SCNNode
let geometry = SCNSphere(radius: 0.04)
geometry.firstMaterial?.diffuse.contents = UIColor.black
for device in self.devices{
node = SCNNode(geometry: geometry)
node.castsShadow = true
node.simdPosition = device.getLocation()
node.name = "Device: \(device.getTag())"
scene?.rootNode.addChildNode(node)
}
Figured it out, this works:
for sensor in self.sensors{
node = SCNNode(geometry: SCNSphere(radius: 0.04))
node.geometry?.firstMaterial?.diffuse.contents = UIColor.black
node.castsShadow = true
node.simdPosition = sensor.getLocation()
node.name = "Sensor: \(sensor.getTag())"
scene?.rootNode.addChildNode(node)
}
Sensor is a data class that I wrote, it could be replaced with any other method of assigning a name or position.
Figured it out: in the Build Rules section of the .xcodeproj file there was a null script being created for some reason. Once I removed it, the error went away.