Spatial anchors: Difference between revisions
Appearance
Xinreality (talk | contribs) No edit summary |
Xinreality (talk | contribs) |
||
| Line 124: | Line 124: | ||
=== Apple ARKit === | === Apple ARKit === | ||
ARKit represents anchors with the `ARAnchor` class, which Apple defines as "a real-world position and orientation that can be used for placing objects in an AR scene."<ref name="ARKitAnchor"/> ARKit provides '''10+ specific anchor types''', all inheriting from the base ARAnchor class: '''ARAnchor''' (base class for position and orientation), '''ARPlaneAnchor''' (horizontal and vertical surfaces with semantic classification), '''ARImageAnchor''' (tracked images with scale estimation), '''ARObjectAnchor''' (real-world 3D objects), '''ARBodyAnchor''' (human body positions), '''ARFaceAnchor''' (facial tracking), '''ARGeoAnchor''' (geographic locations using GPS and visual positioning, ARKit 4.0+), '''ARMeshAnchor''' (polygonal mesh geometry using LiDAR, ARKit 3.5+), '''ARParticipantAnchor''' (multi-user AR experiences), '''AREnvironmentProbeAnchor''' (environmental lighting), and '''ARAppClipCodeAnchor''' (App Clip Code tracking, ARKit 4.0+).<ref name="ARKitDocs">[https://developer.apple.com/documentation/arkit/aranchor Apple Developer – ARAnchor Documentation]</ref> | [[ARKit]] represents anchors with the `ARAnchor` class, which Apple defines as "a real-world position and orientation that can be used for placing objects in an AR scene."<ref name="ARKitAnchor"/> ARKit provides '''10+ specific anchor types''', all inheriting from the base ARAnchor class: '''ARAnchor''' (base class for position and orientation), '''ARPlaneAnchor''' (horizontal and vertical surfaces with semantic classification), '''ARImageAnchor''' (tracked images with scale estimation), '''ARObjectAnchor''' (real-world 3D objects), '''ARBodyAnchor''' (human body positions), '''ARFaceAnchor''' (facial tracking), '''ARGeoAnchor''' (geographic locations using GPS and visual positioning, ARKit 4.0+), '''ARMeshAnchor''' (polygonal mesh geometry using LiDAR, ARKit 3.5+), '''ARParticipantAnchor''' (multi-user AR experiences), '''AREnvironmentProbeAnchor''' (environmental lighting), and '''ARAppClipCodeAnchor''' (App Clip Code tracking, ARKit 4.0+).<ref name="ARKitDocs">[https://developer.apple.com/documentation/arkit/aranchor Apple Developer – ARAnchor Documentation]</ref> | ||
ARKit automatically generates some anchors (for example, when planar surfaces or images are detected, it creates plane anchors or image anchors), and developers can add their own anchors at arbitrary positions. ARKit does not have a built-in cloud anchor service, but it allows multi-user sharing by merging AR sessions: an app can share a map (which contains anchors) with another device to synchronize their coordinate space. In ARKit 4, Apple introduced '''Location Anchors (ARGeoAnchor)''', which use high-resolution Apple Maps data in certain cities to anchor content to real-world coordinates (latitude, longitude, altitude)-enabling experiences where AR content is tied to specific landmarks or locations.<ref name="AppleLocation">[https://www.apple.com/newsroom/2020/06/ios-14-offers-new-features/ Apple Newsroom – ARKit 4 Location Anchors (2020)]</ref> | ARKit automatically generates some anchors (for example, when planar surfaces or images are detected, it creates plane anchors or image anchors), and developers can add their own anchors at arbitrary positions. ARKit does not have a built-in cloud anchor service, but it allows multi-user sharing by merging AR sessions: an app can share a map (which contains anchors) with another device to synchronize their coordinate space. In ARKit 4, Apple introduced '''Location Anchors (ARGeoAnchor)''', which use high-resolution Apple Maps data in certain cities to anchor content to real-world coordinates (latitude, longitude, altitude)-enabling experiences where AR content is tied to specific landmarks or locations.<ref name="AppleLocation">[https://www.apple.com/newsroom/2020/06/ios-14-offers-new-features/ Apple Newsroom – ARKit 4 Location Anchors (2020)]</ref> | ||
| Line 132: | Line 132: | ||
=== Google ARCore === | === Google ARCore === | ||
ARCore provides an `Anchor` class in its API for locking a virtual object's position. ARCore anchors are often created after a '''hit test''' (raycast) against the environment or attached to detected plane surfaces. ARCore provides four anchor types: '''Local Anchors''' (stored locally, valid for single app instance), '''Cloud Anchors''' (hosted in Google Cloud, shareable between devices/users), '''Persistent Cloud Anchors''' (ARCore 1.20+, configurable lifetime from 1 to 365 days), and '''Geospatial Anchors''' (based on GPS coordinates plus Visual Positioning System).<ref name="ARCoreAnchors">[https://developers.google.com/ar/develop/anchors Google ARCore – Working with Anchors]</ref> | [[ARCore]] provides an `Anchor` class in its API for locking a virtual object's position. ARCore anchors are often created after a '''hit test''' (raycast) against the environment or attached to detected plane surfaces. ARCore provides four anchor types: '''Local Anchors''' (stored locally, valid for single app instance), '''Cloud Anchors''' (hosted in Google Cloud, shareable between devices/users), '''Persistent Cloud Anchors''' (ARCore 1.20+, configurable lifetime from 1 to 365 days), and '''Geospatial Anchors''' (based on GPS coordinates plus Visual Positioning System).<ref name="ARCoreAnchors">[https://developers.google.com/ar/develop/anchors Google ARCore – Working with Anchors]</ref> | ||
In addition to local anchors, ARCore's Cloud Anchors (and persistent Cloud Anchors) enable saving and sharing anchors via Google's cloud. ARCore also offers geospatial anchors through the Geospatial API, using global VPS; developers can create a WGS84 anchor by specifying a latitude, longitude, and altitude, and ARCore will align it using localization from satellite imagery and Street View data.<ref name="ARCoreGeo"/> | In addition to local anchors, ARCore's Cloud Anchors (and persistent Cloud Anchors) enable saving and sharing anchors via Google's cloud. ARCore also offers geospatial anchors through the Geospatial API, using global VPS; developers can create a WGS84 anchor by specifying a latitude, longitude, and altitude, and ARCore will align it using localization from satellite imagery and Street View data.<ref name="ARCoreGeo"/> | ||
| Line 140: | Line 140: | ||
=== Microsoft Windows Mixed Reality === | === Microsoft Windows Mixed Reality === | ||
On HoloLens and other WMR devices, spatial anchors (sometimes called ''world anchors'') are used to keep holograms fixed in place. The device continuously refines the anchors using its spatial mapping and tracking system. Microsoft provided the '''Azure Spatial Anchors''' cloud service for cross-platform persistence: developers could create an anchor on a HoloLens (as a `CloudSpatialAnchor` in the SDK), upload it to Azure, then locate that same anchor on an iPhone or Android device, allowing a shared experience.<ref name="ASA"/> | On [[HoloLens]] and other WMR devices, spatial anchors (sometimes called ''world anchors'') are used to keep holograms fixed in place. The device continuously refines the anchors using its spatial mapping and tracking system. Microsoft provided the '''Azure Spatial Anchors''' cloud service for cross-platform persistence: developers could create an anchor on a HoloLens (as a `CloudSpatialAnchor` in the SDK), upload it to Azure, then locate that same anchor on an iPhone or Android device, allowing a shared experience.<ref name="ASA"/> | ||
Locally, HoloLens also allowed saving anchors to disk and exporting/importing them (via a WorldAnchorTransferBatch in Unity) to persist holograms between app runs.<ref name="MSLearn3"/> The HoloLens system has a limit on how far content can be from an anchor before stability decreases-Microsoft recommends keeping holograms within a few meters of their anchor for best accuracy, specifically noting that holograms greater than 3 meters from anchor origin experience noticeable positional errors.<ref name="MSLearn2"/> | Locally, HoloLens also allowed saving anchors to disk and exporting/importing them (via a WorldAnchorTransferBatch in Unity) to persist holograms between app runs.<ref name="MSLearn3"/> The HoloLens system has a limit on how far content can be from an anchor before stability decreases-Microsoft recommends keeping holograms within a few meters of their anchor for best accuracy, specifically noting that holograms greater than 3 meters from anchor origin experience noticeable positional errors.<ref name="MSLearn2"/> | ||
| Line 148: | Line 148: | ||
=== Meta (Oculus) Quest === | === Meta (Oculus) Quest === | ||
Meta's mixed reality SDK supports spatial anchors for its VR/AR headsets. Developers using the Meta Oculus SDK or OpenXR on Quest devices can create anchors (for example with the `OVRSpatialAnchor` in Unity) to persist virtual objects in a room. These anchors can be saved to the device's storage so that content remains in place across sessions (Quest headsets can store a certain number of anchors in their local memory).<ref name="MetaAnchors"/> | [[Meta]]'s mixed reality SDK supports spatial anchors for its VR/AR headsets. Developers using the Meta Oculus SDK or OpenXR on Quest devices can create anchors (for example with the `OVRSpatialAnchor` in Unity) to persist virtual objects in a room. These anchors can be saved to the device's storage so that content remains in place across sessions (Quest headsets can store a certain number of anchors in their local memory).<ref name="MetaAnchors"/> | ||
Meta provides a '''Shared Spatial Anchors''' feature that lets devices in proximity share anchor data with each other for co-located multiplayer experiences (two users in the same room see the same virtual object anchored on a table). In the Meta framework, an anchor is described as a "world-locked frame of reference" for content, underscoring that it maintains its position in the real world rather than moving with the user.<ref name="MetaAnchors"/> Meta supports two sharing models: an older user-based model that requires Oculus User IDs and a newer, recommended group-based model that uses a shared UUID to simplify the sharing process.<ref name="Meta_SharedAnchors"/> | Meta provides a '''[[Shared Spatial Anchors]]''' feature that lets devices in proximity share anchor data with each other for co-located multiplayer experiences (two users in the same room see the same virtual object anchored on a table). In the Meta framework, an anchor is described as a "world-locked frame of reference" for content, underscoring that it maintains its position in the real world rather than moving with the user.<ref name="MetaAnchors"/> Meta supports two sharing models: an older user-based model that requires Oculus User IDs and a newer, recommended group-based model that uses a shared UUID to simplify the sharing process.<ref name="Meta_SharedAnchors"/> | ||
The `OVRSpatialAnchor` component in Unity enables creating anchors at specific positions, saving anchors locally or to Meta servers, loading previously saved anchors, erasing anchors when no longer needed, and querying for nearby anchors. Configuration requires Anchor Support enabled, Shared Spatial Anchor Support set to Supported, and Enhanced Spatial Services enabled in device settings.<ref name="MetaAnchors"/> | The `OVRSpatialAnchor` component in Unity enables creating anchors at specific positions, saving anchors locally or to Meta servers, loading previously saved anchors, erasing anchors when no longer needed, and querying for nearby anchors. Configuration requires Anchor Support enabled, Shared Spatial Anchor Support set to Supported, and Enhanced Spatial Services enabled in device settings.<ref name="MetaAnchors"/> | ||
| Line 156: | Line 156: | ||
=== Magic Leap === | === Magic Leap === | ||
Magic Leap 1 and 2 devices use spatial anchors as part of their Space mapping. A Magic Leap user scans an environment to establish a Space (a map of the area); within that space, anchors can be placed to mark where virtual content should appear. Magic Leap 2 supports up to 5 local Spaces stored on the device, allowing a user to save multiple environments with their anchors.<ref name="MagicLeap"/> | [[Magic Leap]] 1 and 2 devices use spatial anchors as part of their Space mapping. A Magic Leap user scans an environment to establish a Space (a map of the area); within that space, anchors can be placed to mark where virtual content should appear. Magic Leap 2 supports up to 5 local Spaces stored on the device, allowing a user to save multiple environments with their anchors.<ref name="MagicLeap"/> | ||
When a user returns to a mapped Space, the device can localize itself and restore all anchors (and content) in that space. The platform uses a concept called "Spaces," which are persistent, scanned 3D maps of an environment. Within these Spaces, developers can create spatial anchors that can be stored either locally on the device or in the AR Cloud.<ref name="MagicLeapSpaces">[https://developer-docs.magicleap.cloud/docs/guides/features/spaces/spatial-anchors/ Magic Leap Developer Docs – Spaces and Spatial Anchors]</ref> While Magic Leap's earlier cloud service for sharing anchors (Cloud Anchor / AR Cloud) was phased out, developers can integrate third-party services (or use Magic Leap's local networking) for multi-user scenarios if needed. | When a user returns to a mapped Space, the device can localize itself and restore all anchors (and content) in that space. The platform uses a concept called "Spaces," which are persistent, scanned 3D maps of an environment. Within these Spaces, developers can create spatial anchors that can be stored either locally on the device or in the AR Cloud.<ref name="MagicLeapSpaces">[https://developer-docs.magicleap.cloud/docs/guides/features/spaces/spatial-anchors/ Magic Leap Developer Docs – Spaces and Spatial Anchors]</ref> While Magic Leap's earlier cloud service for sharing anchors (Cloud Anchor / AR Cloud) was phased out, developers can integrate third-party services (or use Magic Leap's local networking) for multi-user scenarios if needed. | ||
| Line 162: | Line 162: | ||
=== Unity AR Foundation === | === Unity AR Foundation === | ||
Unity AR Foundation provides a '''cross-platform abstraction''' for spatial anchors across ARKit (iOS), ARCore (Android), Magic Leap, Meta Quest, and HoloLens (via OpenXR). The `ARAnchor` component can be added via `AddComponent<ARAnchor>()` on any GameObject, with transforms automatically updated by AR Foundation.<ref name="UnityAnchor"/> Manual transform changes are not recommended as anchors enter a pending state before full tracking is established, queryable via the `ARAnchor.pending` property. | [[Unity AR Foundation]] provides a '''cross-platform abstraction''' for spatial anchors across ARKit (iOS), ARCore (Android), Magic Leap, Meta Quest, and HoloLens (via OpenXR). The `ARAnchor` component can be added via `AddComponent<ARAnchor>()` on any GameObject, with transforms automatically updated by AR Foundation.<ref name="UnityAnchor"/> Manual transform changes are not recommended as anchors enter a pending state before full tracking is established, queryable via the `ARAnchor.pending` property. | ||
The `ARAnchorManager` manages the lifecycle of all anchors in the scene, providing an `anchorsChanged` event reporting added, updated, and removed anchors. The `AttachAnchor(ARPlane plane, Pose pose)` method attaches anchors to detected planes. The system translates between Unity world space and AR session space, compensating for tracking loss and session reinitialization.<ref name="UnityAnchor"/> | The `ARAnchorManager` manages the lifecycle of all anchors in the scene, providing an `anchorsChanged` event reporting added, updated, and removed anchors. The `AttachAnchor(ARPlane plane, Pose pose)` method attaches anchors to detected planes. The system translates between Unity world space and AR session space, compensating for tracking loss and session reinitialization.<ref name="UnityAnchor"/> | ||