SpatialEntity.TryGetPlaneAlign
bool TryGetPlaneAlign(PlaneAlign& alignment)
The general orientation of a detected plane, like horizontal or vertical. Plane tracking always provides this, so it’s a reliable fallback on devices that don’t provide labels.
| PlaneAlign& alignment | The plane’s general orientation, None if unavailable. |
| RETURNS: bool | False if this entity has no plane alignment component. |
Examples
Finding a table to put things on
Not every device labels its planes, so this falls back to any surface that faces upward.
static bool FindTable(out Pose surface)
{
foreach (SpatialEntity plane in SpatialEntity.With(SpatialComponent.Bounds2D))
{
bool isTable = plane.TryGetLabel(out SpatialLabel label)
? label == SpatialLabel.Table
: plane.TryGetPlaneAlign(out PlaneAlign align) && align == PlaneAlign.HorizontalUp;
if (isTable && plane.TryGetBounds2D(out surface, out _))
return true;
}
surface = Pose.Identity;
return false;
}
Found an issue with these docs, or have some additional questions? Create an Issue on Github!