⚠ Preview docs — built from the develop branch and may be unstable. Go to the stable docs.

SpatialEntity.TryGetBounds2D

bool TryGetBounds2D(Pose& center, Vec2& size)

The 2D rectangular bounds of this entity, such as the extents of a detected plane, or the shape of a marker. The pose faces out of the surface, so its Forward is the surface normal, the same way quads and text face in StereoKit. A floor’s pose faces up, and a wall’s pose faces into the room. The center is usually the same as Pose, but can differ on entities with several pose components, like a table with both a top and a volume.

   
Pose& center The pose at the center of the rectangle.
Vec2& size The rectangle’s total size in meters, along the center pose’s X and Y axes.
RETURNS: bool False if this entity has no bounds2d component.

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!