getDistanceFromAnchor method
Returns the distance in meters between @anchor and device's camera.
Implementation
Future<double?> getDistanceFromAnchor(ARAnchor anchor) async {
Matrix4? cameraPose = await getCameraPose();
Matrix4? anchorPose = await getPose(anchor);
Vector3? cameraTranslation = cameraPose?.getTranslation();
Vector3? anchorTranslation = anchorPose?.getTranslation();
if (anchorTranslation != null && cameraTranslation != null) {
return getDistanceBetweenVectors(anchorTranslation, cameraTranslation);
} else {
return null;
}
}