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 : ISpatialAnchor, ISpatialAnchor2public sealed class SpatialAnchor : ISpatialAnchor, ISpatialAnchor2Public NotInheritable Class SpatialAnchor Implements ISpatialAnchor, ISpatialAnchor2// You can use this class in JavaScript.
- Attributes
| 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.
Properties
CoordinateSystem CoordinateSystem CoordinateSystem CoordinateSystem
Gets the coordinate system of the anchor, with easing adjustments applied.
public : SpatialCoordinateSystem CoordinateSystem { get; }public SpatialCoordinateSystem CoordinateSystem { get; }Public ReadOnly Property CoordinateSystem As SpatialCoordinateSystem// You can use this property in JavaScript.
- Value
- SpatialCoordinateSystem SpatialCoordinateSystem SpatialCoordinateSystem SpatialCoordinateSystem
The eased coordinate system.
Remarks
This coordinate system lets you precisely place holograms near the anchor, with easing applied when the device adjusts the anchor's precise location.
RawCoordinateSystem RawCoordinateSystem RawCoordinateSystem RawCoordinateSystem
Gets the coordinate system of the anchor, without easing applied.
public : SpatialCoordinateSystem RawCoordinateSystem { get; }public SpatialCoordinateSystem RawCoordinateSystem { get; }Public ReadOnly Property RawCoordinateSystem As SpatialCoordinateSystem// You can use this property in JavaScript.
- Value
- SpatialCoordinateSystem SpatialCoordinateSystem SpatialCoordinateSystem SpatialCoordinateSystem
The raw coordinate system.
Remarks
This coordinate system lets you precisely place holograms near the anchor, with immediate updates when the device adjusts the anchor's precise location.
Use the corresponding RawCoordinateSystemAdjusted event to react when anchor adjustments occur.
RemovedByUser RemovedByUser RemovedByUser RemovedByUser
Gets a value indicating whether the persisted anchor was removed by the user.
public : PlatForm::Boolean RemovedByUser { get; }public bool RemovedByUser { get; }Public ReadOnly Property RemovedByUser As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True, if the anchor was removed; otherwise, false.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
The app should discard any other saved state that corresponds with this anchor.
Methods
TryCreateRelativeTo(SpatialCoordinateSystem) TryCreateRelativeTo(SpatialCoordinateSystem) TryCreateRelativeTo(SpatialCoordinateSystem) TryCreateRelativeTo(SpatialCoordinateSystem)
Creates an anchor at the origin of the specified coordinate system.
public : static SpatialAnchor TryCreateRelativeTo(SpatialCoordinateSystem coordinateSystem)public static SpatialAnchor TryCreateRelativeTo(SpatialCoordinateSystem coordinateSystem)Public Static Function TryCreateRelativeTo(coordinateSystem As SpatialCoordinateSystem) As SpatialAnchor// You can use this method in JavaScript.
- coordinateSystem
- SpatialCoordinateSystem SpatialCoordinateSystem SpatialCoordinateSystem SpatialCoordinateSystem
The reference SpatialCoordinateSystem object.
The new anchor, if the creation attempt is successful; otherwise, null.
Remarks
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) TryCreateRelativeTo(SpatialCoordinateSystem, Vector3) TryCreateRelativeTo(SpatialCoordinateSystem, Vector3) TryCreateRelativeTo(SpatialCoordinateSystem, Vector3)
Creates an anchor at a specific position within the specified coordinate system.
public : static SpatialAnchor TryCreateRelativeTo(SpatialCoordinateSystem coordinateSystem, Vector3 position)public static SpatialAnchor TryCreateRelativeTo(SpatialCoordinateSystem coordinateSystem, Vector3 position)Public Static Function TryCreateRelativeTo(coordinateSystem As SpatialCoordinateSystem, position As Vector3) As SpatialAnchor// You can use this method in JavaScript.
- coordinateSystem
- SpatialCoordinateSystem SpatialCoordinateSystem SpatialCoordinateSystem SpatialCoordinateSystem
The reference SpatialCoordinateSystem object.
- position
- Vector3 Vector3 Vector3 Vector3
A point specified relative to the coordinate system of the source SpatialCoordinateSystem object.
The new anchor, if the creation attempt is successful; otherwise, null.
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.
public : static SpatialAnchor TryCreateRelativeTo(SpatialCoordinateSystem coordinateSystem, Vector3 position, Quaternion orientation)public static SpatialAnchor TryCreateRelativeTo(SpatialCoordinateSystem coordinateSystem, Vector3 position, Quaternion orientation)Public Static Function TryCreateRelativeTo(coordinateSystem As SpatialCoordinateSystem, position As Vector3, orientation As Quaternion) As SpatialAnchor// You can use this method in JavaScript.
- coordinateSystem
- SpatialCoordinateSystem SpatialCoordinateSystem SpatialCoordinateSystem SpatialCoordinateSystem
The reference SpatialCoordinateSystem object.
- position
- Vector3 Vector3 Vector3 Vector3
A point specified relative to the coordinate system of the source SpatialCoordinateSystem object.
- orientation
- Quaternion Quaternion Quaternion Quaternion
A rotation specified relative to the coordinate system of the source SpatialCoordinateSystem object. The orientation of the created anchor's coordinate system is offset by this rotation relative to the source coordinate system.
The new anchor, if the creation attempt is successful; otherwise, null.
Events
RawCoordinateSystemAdjusted RawCoordinateSystemAdjusted RawCoordinateSystemAdjusted RawCoordinateSystemAdjusted
Occurs when the device adjusts the anchor's precise location, which updates the RawCoordinateSystem.
public : event TypedEventHandler RawCoordinateSystemAdjusted<SpatialAnchor, SpatialAnchorRawCoordinateSystemAdjustedEventArgs>public event TypedEventHandler RawCoordinateSystemAdjusted<SpatialAnchor, SpatialAnchorRawCoordinateSystemAdjustedEventArgs>Public Event RawCoordinateSystemAdjusted<SpatialAnchor, SpatialAnchorRawCoordinateSystemAdjustedEventArgs>// You can use this event in JavaScript.
Remarks
The event arguments contain a transform representing the adjustment that was made.