addPoint method
Implementation
Future<void> addPoint() async {
final Color pointColor = widget.pointColor ?? Theme.of(context).colorScheme.onPrimary;
final UArHitResult? hit = controller.value.frame.centerHit ?? (await controller.hitTestCenter()).firstOrNull;
if (hit == null) return;
final UArVector3 point = hit.pose.position;
final int index = points.length;
points.add(point);
unawaited(HapticFeedback.selectionClick());
await controller.addNode(
UArNode.sphere(
id: "p$index",
radius: 0.006,
position: point,
material: UArMaterial(color: pointColor, unlit: true),
),
);
if (index > 0) await _segment(index - 1, index);
await _updateClosing();
_notify();
}