static class Spatial
Spatial is where you choose which kinds of scene
understanding the device should run, like plane tracking, QR codes,
or anchors, and how they’re configured. Each of these is a
SpatialCapability, and the things they discover show up as
SpatialEntity objects.
Check Capabilities to see what the current device supports, then
Request what you need. Capabilities start up asynchronously, and
may need a permission first, so Running tells you which ones have
actually started. Marker settings like SetMarkerSize and
ArucoDictionary are best set before requesting, since changing
them restarts that capability’s tracking.
Static Fields and Properties
| AprilTagDict AprilTagDictionary | Which family of AprilTag markers SpatialCapability.AprilTag looks for. Markers from other dictionaries aren’t detected, so this must match the markers you printed! Default lets StereoKit pick. Changing it while AprilTags are being tracked restarts that tracking. |
| ArucoDict ArucoDictionary | Which family of ArUco markers SpatialCapability.Aruco looks for. Markers from other dictionaries aren’t detected, so this must match the markers you printed! Default lets StereoKit pick. Changing it while ArUco markers are being tracked restarts that tracking. |
| SpatialCapability Capabilities | The spatial capabilities the current device supports! This is None until an XR session with spatial entity support has initialized. |
| SpatialCapability Requested | The capabilities that have been requested, via Request or by StereoKit systems like Anchor, minus any you’ve turned off with Disable. |
| SpatialCapability Running | The capabilities that have started up and are providing entities. This is a subset of Requested, since capabilities take a little time to start after being requested. |
Static Methods
| ComponentsFor | The components the device can provide on entities discovered by the given capability. |
| Disable | Stop tracking these capabilities. Their entities leave the entity list, and any SpatialEntity identifiers you still hold stop resolving. Persisted entities are the exception, they wait with Status Pending, and come back if the capability is requested again. This also overrides StereoKit’s own use of a capability. The Anchor system turns on SpatialCapability.Anchor the first time you use it, and calling this before SK.Initialize keeps Anchor from using spatial entities at all. |
| GetMarkerSize | The physical marker size set via SetMarkerSize, 0 if unknown. |
| GetMarkerStationary | Whether this marker type was marked as stationary via SetMarkerStationary. |
| IsRequested | Have all of these capabilities been requested, and not turned off with Disable? This doesn’t mean they’ve started yet, see IsRunning for that. |
| IsRunning | Have all of these capabilities started up, and are they providing entities? Capabilities take a little time to start after being requested, and may wait on a permission first. |
| IsSupported | Does the current device support all of these capabilities? This is false until an XR session with spatial entity support has initialized. |
| Request | Request tracking for these capabilities, additively! This takes effect asynchronously, and entities will appear in the entity list as the system starts up and discovers them. Requesting or disabling one capability never disturbs entities belonging to another. If a capability needs a permission, this requests it automatically as a fallback, but requesting it yourself in advance via Permission.Request gives you control over when the user is asked, and lets you handle a denial. You can call this before SK.Initialize, and it takes effect once StereoKit starts. |
| SetMarkerSize | Tell the system how big your printed markers of this type are. This matters most for ArUco and AprilTags, where a known size can help a runtime judge marker distance, but it’s only a hint, and runtimes may ignore it. Changing this while that marker type is being tracked restarts its tracking, so set it before Request when you can. |
| SetMarkerStationary | Tell the system whether markers of this type stay put, like a code taped to a wall, rather than being carried around. Stationary markers can have their pose refined over time instead of re-detected every frame. Changing this while that marker type is being tracked restarts its tracking, so set it before Request when you can. Not all devices use this, treat it as a hint. |
Examples
Drawing detected planes
Request plane tracking once, and the device’s walls, floors and tables show up in the entity list as it finds them.
public void StartPlanes()
{
Spatial.Request(SpatialCapability.PlaneTracking);
}
public void StopPlanes()
{
Spatial.Disable(SpatialCapability.PlaneTracking);
}
public void DrawPlanes()
{
foreach (SpatialEntity plane in SpatialEntity.With(SpatialComponent.Bounds2D))
{
// Quads face Forward, same as the plane's center pose
plane.TryGetBounds2D(out Pose center, out Vec2 size);
Mesh.Quad.Draw(Material.Default, center.ToMatrix(new Vec3(size.x, size.y, 1)));
}
}
Found an issue with these docs, or have some additional questions? Create an Issue on Github!