Share via


SpatialAnchor Class

Definition

Represents a coordinate system that is strongly anchored to a point in the user's surroundings.

public ref class SpatialAnchor sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 131072)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class SpatialAnchor final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 131072)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class SpatialAnchor
Public NotInheritable Class SpatialAnchor
Inheritance
Object Platform::Object IInspectable SpatialAnchor
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10586.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced in v2.0)

Remarks

You can create a SpatialAnchor at any position and orientation within the SpatialCoordinateSystem of your choosing. The device must be able to locate that coordinate system at the moment, and the system must not have reached its limit of spatial anchors.

Once defined, the coordinate system of a SpatialAnchor adjusts continually to retain the precise position and orientation of its initial location. You can then use this SpatialAnchor to render holograms that will appear fixed in the user's surroundings at that exact location.

The effects of the adjustments that keep the anchor in place are magnified as distance from the anchor increases. You should avoid rendering content relative to an anchor that is more than 3 meters from that anchor's origin.

You can persist a SpatialAnchor using the SpatialAnchorStore class and then get it back in a future app session.

The CoordinateSystem property gets a coordinate system that lets you place content relative to the anchor, with easing applied when the device adjusts the anchor's precise location.

Use the RawCoordinateSystem property and the corresponding RawCoordinateSystemAdjusted event to manage these adjustments yourself.

The coordinate system is right-handed, with +y up, +x to the right, and -z forward.

Version history

Windows version SDK version Value added
1607 14393 RemovedByUser

Properties

CoordinateSystem

Gets the coordinate system of the anchor, with easing adjustments applied.

RawCoordinateSystem

Gets the coordinate system of the anchor, without easing applied.

RemovedByUser

Gets a value indicating whether the persisted anchor was removed by the user.

Methods

TryCreateRelativeTo(SpatialCoordinateSystem, Vector3, Quaternion)

Creates an anchor at a specific position and orientation within the specified coordinate system.

This can return null if the system has reached its limit on spatial anchors. It may also return null if the specified coordinate system cannot be located this frame.

TryCreateRelativeTo(SpatialCoordinateSystem, Vector3)

Creates an anchor at a specific position within the specified coordinate system.

TryCreateRelativeTo(SpatialCoordinateSystem)

Creates an anchor at the origin of the specified coordinate system.

Events

RawCoordinateSystemAdjusted

Occurs when the device adjusts the anchor's precise location, which updates the RawCoordinateSystem.

Applies to