2 min read

RoomTrackingProvider

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


Create enhanced spatial computing experiences with ARKit - WWDC24 - Videos - Apple Developer
Learn how to create captivating immersive experiences with ARKit’s latest features. Explore ways to use room tracking and object tracking…
RoomTrackingProvider | Apple Developer Documentation
A source of real-time information about the room that a person is currently in.
Building local experiences with room tracking | Apple Developer Documentation
Use room tracking in visionOS to provide custom interactions with physical spaces.