RoomTrackingProvider

Tom mentioned it, so here's a little test of the sample code for the new visionOS 2.0 room tracking capability. The project demonstrates how to construct an ARKit session with a RoomTrackingProvider, which allows to check if any point in space is contained to the current room. The frequency of updates is great and improves over time (due to the refinement of the captured room). This creates many possibilities for navigation on space features, as well as optional triggers upon entering or exiting a location.
While remaining on the door arch that connects the living room and the hallway, I placed the spheres provided by the example code and observed how their colors shifted depending on whether I was entering or exiting. The update frequency was basically immediate.
private func isSphereInCurrentRoom(sphere: WorldAnchor) -> Bool {
guard let currentRoom = roomTracking.currentRoomAnchor else {
return false
}
let spherePosition = sphere.originFromAnchorTransform.columns.3.xyz
return currentRoom.contains(spherePosition)
}
Once the setup is complete, the elegance of the subscription is something worth noticing


