SpatialSurfaceObserver SpatialSurfaceObserver SpatialSurfaceObserver SpatialSurfaceObserver Class

Definition

Provides methods for observing surfaces in the user's surroundings.

public : sealed class SpatialSurfaceObserver : ISpatialSurfaceObserver
public sealed class SpatialSurfaceObserver : ISpatialSurfaceObserver
Public NotInheritable Class SpatialSurfaceObserver Implements ISpatialSurfaceObserver
var spatialSurfaceObserver = new spatialSurfaceObserver();
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)
Capabilities
spatialPerception

Remarks

Spatial mapping lets your app understand the shape and location of the surfaces in the user's surroundings.

Through the sensors on a device like HoloLens, Windows generates 3D triangle meshes of surfaces in large cube-shaped volumes. Over time, as Windows improves its understanding of your surroundings, new surface volumes are generated and existing volumes are updated with new mesh. Sometimes, surface volumes can be destroyed as well, when the system is running low on storage.

You access these surfaces by expressing interest in a volume of space, either a bounding box, bounding frustum, or bounding sphere. Windows updates you to let you know when the set of surfaces in that observed volume has changed, with each surface volume identified by an id and the time of its last update. By reasoning about changes to this set of observed surface metadata, you can detect new mesh, updated mesh, and removed mesh over time.

Constructors

SpatialSurfaceObserver() SpatialSurfaceObserver() SpatialSurfaceObserver() SpatialSurfaceObserver()

Initializes a new instance of the SpatialSurfaceObserver class.

public : SpatialSurfaceObserver()
public SpatialSurfaceObserver()
Public Sub New()
var spatialSurfaceObserver = new spatialSurfaceObserver();
Additional features and 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)
Capabilities
spatialPerception

Methods

GetObservedSurfaces() GetObservedSurfaces() GetObservedSurfaces() GetObservedSurfaces()

Gets metadata for the set of surfaces observed within the bounding volume at the moment.

public : IMapView<Platform::Guid, SpatialSurfaceInfo> GetObservedSurfaces()
public IReadOnlyDictionary<Guid, SpatialSurfaceInfo> GetObservedSurfaces()
Public Function GetObservedSurfaces() As IReadOnlyDictionary<Guid, SpatialSurfaceInfo>( Of Guid )( Of SpatialSurfaceInfo )
var iMapView = spatialSurfaceObserver.getObservedSurfaces();
Returns
IMapView<Platform::Guid, SpatialSurfaceInfo> IReadOnlyDictionary<Guid, SpatialSurfaceInfo> IReadOnlyDictionary<Guid, SpatialSurfaceInfo> IReadOnlyDictionary<Guid, SpatialSurfaceInfo>

The observed surfaces.

Additional features and 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)
Capabilities
spatialPerception

Remarks

Each SpatialSurfaceInfo snapshot is immutable, so you can compare their values later to see if a given surface has recently experienced a mesh update.

Correlating the Id and UpdateTime properties across multiple observations lets you identify new mesh, updated mesh and removed mesh:

  • If you see a SpatialSurfaceInfo with an Id you haven't seen before, treat it as new mesh.
  • If you see a SpatialSurfaceInfo with a known Id, but with a new UpdateTime, treat it as updated mesh.
  • If you no longer see a SpatialSurfaceInfo with a known Id, treat it as removed mesh.

IsSupported() IsSupported() IsSupported() IsSupported()

Gets whether spatial mapping is supported on the current system.

public : static Platform::Boolean IsSupported()
public static bool IsSupported()
Public Static Function IsSupported() As bool
var bool = Windows.Perception.Spatial.Surfaces.SpatialSurfaceObserver.isSupported();
Returns
Platform::Boolean bool bool bool

Whether spatial mapping is supported.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)
Capabilities
spatialPerception

Remarks

This returns true on HoloLens and false elsewhere.

RequestAccessAsync() RequestAccessAsync() RequestAccessAsync() RequestAccessAsync()

Requests access for an app to use spatial mapping. This requires the spatialPerception capability.

public : static IAsyncOperation<SpatialPerceptionAccessStatus> RequestAccessAsync()
public static IAsyncOperation<SpatialPerceptionAccessStatus> RequestAccessAsync()
Public Static Function RequestAccessAsync() As IAsyncOperation( Of SpatialPerceptionAccessStatus )
Windows.Perception.Spatial.Surfaces.SpatialSurfaceObserver.requestAccessAsync().done( /* Your success and error handlers */ );
Returns
Additional features and 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)
Capabilities
spatialPerception

SetBoundingVolume(SpatialBoundingVolume) SetBoundingVolume(SpatialBoundingVolume) SetBoundingVolume(SpatialBoundingVolume) SetBoundingVolume(SpatialBoundingVolume)

Sets the single bounding volume that this observer will track for new, updated or removed surfaces.

public : void SetBoundingVolume(SpatialBoundingVolume bounds)
public void SetBoundingVolume(SpatialBoundingVolume bounds)
Public Function SetBoundingVolume(bounds As SpatialBoundingVolume) As void
spatialSurfaceObserver.setBoundingVolume(bounds);
Parameters
bounds
SpatialBoundingVolume SpatialBoundingVolume SpatialBoundingVolume SpatialBoundingVolume

The new bounding volume for this observer to track for surface updates.

Additional features and 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)
Capabilities
spatialPerception

Remarks

When the set of surface metadata within this bounding volume changes, the ObservedSurfacesChanged event will fire.

SetBoundingVolumes(IIterable) SetBoundingVolumes(IIterable) SetBoundingVolumes(IIterable) SetBoundingVolumes(IIterable)

Sets the list of bounding volumes that this observer will track for new, updated or removed surfaces.

public : void SetBoundingVolumes(IIterable<SpatialBoundingVolume> bounds)
public void SetBoundingVolumes(IEnumerable<SpatialBoundingVolume> bounds)
Public Function SetBoundingVolumes(bounds As IEnumerable<SpatialBoundingVolume>) As void
spatialSurfaceObserver.setBoundingVolumes(bounds);
Parameters
bounds
IIterable<SpatialBoundingVolume> IEnumerable<SpatialBoundingVolume> IEnumerable<SpatialBoundingVolume> IEnumerable<SpatialBoundingVolume>

The bounding volumes.

Additional features and 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)
Capabilities
spatialPerception

Remarks

When the set of surface metadata within these bounding volumes changes, the ObservedSurfacesChanged event will fire.

Events

ObservedSurfacesChanged ObservedSurfacesChanged ObservedSurfacesChanged ObservedSurfacesChanged

Occurs when the set of surface metadata observed within the bounding volume has changed.

public : event TypedEventHandler ObservedSurfacesChanged<SpatialSurfaceObserver, object>
public event TypedEventHandler ObservedSurfacesChanged<SpatialSurfaceObserver, object>
Public Event TypedEventHandler ObservedSurfacesChanged( Of ( Of SpatialSurfaceObserver ), ( Of object ))
function onObservedSurfacesChanged(eventArgs){/* Your code */}


spatialSurfaceObserver.addEventListener("observedSurfacesChanged", onObservedSurfacesChanged);
spatialSurfaceObserver.removeEventListener("observedSurfacesChanged", onObservedSurfacesChanged);
Additional features and 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)
Capabilities
spatialPerception

Remarks

When this event fires, call GetObservedSurfaces to get the latest set of surface metadata.