SpatialAnchor SpatialAnchor SpatialAnchor SpatialAnchor SpatialAnchor Class

Definition

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

public : sealed class SpatialAnchor
struct winrt::Windows::Perception::Spatial::SpatialAnchor
public sealed class SpatialAnchor
Public NotInheritable Class SpatialAnchor
// This class does not provide a public constructor.
Attributes

Windows 10 requirements

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

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 CoordinateSystem CoordinateSystem CoordinateSystem CoordinateSystem

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

RawCoordinateSystem RawCoordinateSystem RawCoordinateSystem RawCoordinateSystem RawCoordinateSystem

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

RemovedByUser RemovedByUser RemovedByUser RemovedByUser RemovedByUser

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

Methods

TryCreateRelativeTo(SpatialCoordinateSystem) TryCreateRelativeTo(SpatialCoordinateSystem) TryCreateRelativeTo(SpatialCoordinateSystem) TryCreateRelativeTo(SpatialCoordinateSystem) TryCreateRelativeTo(SpatialCoordinateSystem)

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

TryCreateRelativeTo(SpatialCoordinateSystem, Vector3) TryCreateRelativeTo(SpatialCoordinateSystem, Vector3) TryCreateRelativeTo(SpatialCoordinateSystem, Vector3) TryCreateRelativeTo(SpatialCoordinateSystem, Vector3) TryCreateRelativeTo(SpatialCoordinateSystem, Vector3)

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

TryCreateRelativeTo(SpatialCoordinateSystem, Vector3, Quaternion) TryCreateRelativeTo(SpatialCoordinateSystem, Vector3, Quaternion) TryCreateRelativeTo(SpatialCoordinateSystem, Vector3, Quaternion) TryCreateRelativeTo(SpatialCoordinateSystem, Vector3, Quaternion) 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.

Events

RawCoordinateSystemAdjusted RawCoordinateSystemAdjusted RawCoordinateSystemAdjusted RawCoordinateSystemAdjusted RawCoordinateSystemAdjusted

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