Created
July 26, 2023 06:49
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<void> onPlaneOrPointTapped( | |
List<ARHitTestResult> hitTestResults) async { | |
var singleHitTestResult = hitTestResults.firstWhere( | |
(hitTestResult) => hitTestResult.type == ARHitTestResultType.plane); | |
var newAnchor = | |
ARPlaneAnchor(transformation: singleHitTestResult.worldTransform); | |
bool? didAddAnchor = await arAnchorManager!.addAnchor(newAnchor); | |
if (didAddAnchor!) { | |
anchors.add(newAnchor); | |
// Add note to anchor | |
var newNode = ARNode( | |
type: NodeType.webGLB, | |
uri: | |
"https://github.com/KhronosGroup/glTF-Sample-Models/raw/master/2.0/Duck/glTF-Binary/Duck.glb", | |
scale: Vector3(0.2, 0.2, 0.2), | |
position: Vector3(0.0, 0.0, 0.0), | |
rotation: Vector4(1.0, 0.0, 0.0, 0.0)); | |
bool? didAddNodeToAnchor = await arObjectManager! | |
.addNode(newNode, planeAnchor: newAnchor); | |
if (didAddNodeToAnchor!) { | |
nodes.add(newNode); | |
} else { | |
arSessionManager!.onError("Adding Node to Anchor failed"); | |
} | |
} else { | |
arSessionManager!.onError("Adding Anchor failed"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment