hitTest method
Perform a hit test at screen coordinates (normalized 0-1).
Implementation
@override
Future<List<ArHitResult>> hitTest(double screenX, double screenY) async {
if (_controller == null) return [];
final results = await _controller!.performHitTest(
x: screenX,
y: screenY,
);
return results.map((r) {
ArHitType type;
switch (r.type) {
case ARKitHitTestResultType.existingPlaneUsingExtent:
case ARKitHitTestResultType.existingPlaneUsingGeometry:
type = ArHitType.existingPlane;
case ARKitHitTestResultType.estimatedHorizontalPlane:
type = ArHitType.estimatedPlane;
case ARKitHitTestResultType.featurePoint:
type = ArHitType.featurePoint;
default:
type = ArHitType.unknown;
}
return ArHitResult(
type: type,
distance: r.distance,
pose: ArPose.fromMatrix4(r.worldTransform),
anchorId: r.anchor?.identifier,
);
}).toList();
}