Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group 'io.carius.lars.ar_flutter_plugin'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.5.20'
repositories {
google()
jcenter()
Expand Down
50 changes: 23 additions & 27 deletions example/lib/examples/cloudanchorexample.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:convert';

import 'package:ar_flutter_plugin/managers/ar_location_manager.dart';
import 'package:ar_flutter_plugin/managers/ar_session_manager.dart';
import 'package:ar_flutter_plugin/managers/ar_object_manager.dart';
Expand Down Expand Up @@ -236,33 +234,31 @@ class _CloudAnchorWidgetState extends State<CloudAnchorWidget> {
List<ARHitTestResult> hitTestResults) async {
var singleHitTestResult = hitTestResults.firstWhere(
(hitTestResult) => hitTestResult.type == ARHitTestResultType.plane);
if (singleHitTestResult != null) {
var newAnchor = ARPlaneAnchor(
transformation: singleHitTestResult.worldTransform, ttl: 2);
bool? didAddAnchor = await this.arAnchorManager!.addAnchor(newAnchor);
if (didAddAnchor ?? false) {
this.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),
data: {"onTapText": "Ouch, that hurt!"});
bool? didAddNodeToAnchor =
await this.arObjectManager!.addNode(newNode, planeAnchor: newAnchor);
if (didAddNodeToAnchor ?? false) {
this.nodes.add(newNode);
setState(() {
readyToUpload = true;
});
} else {
this.arSessionManager!.onError("Adding Node to Anchor failed");
}
var newAnchor = ARPlaneAnchor(
transformation: singleHitTestResult.worldTransform, ttl: 2);
bool? didAddAnchor = await this.arAnchorManager!.addAnchor(newAnchor);
if (didAddAnchor ?? false) {
this.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),
data: {"onTapText": "Ouch, that hurt!"});
bool? didAddNodeToAnchor =
await this.arObjectManager!.addNode(newNode, planeAnchor: newAnchor);
if (didAddNodeToAnchor ?? false) {
this.nodes.add(newNode);
setState(() {
readyToUpload = true;
});
} else {
this.arSessionManager!.onError("Adding Anchor failed");
this.arSessionManager!.onError("Adding Node to Anchor failed");
}
} else {
this.arSessionManager!.onError("Adding Anchor failed");
}
}

Expand Down
50 changes: 23 additions & 27 deletions example/lib/examples/externalmodelmanagementexample.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:convert';

import 'package:ar_flutter_plugin/managers/ar_location_manager.dart';
import 'package:ar_flutter_plugin/managers/ar_session_manager.dart';
import 'package:ar_flutter_plugin/managers/ar_object_manager.dart';
Expand Down Expand Up @@ -266,33 +264,31 @@ class _ExternalModelManagementWidgetState
List<ARHitTestResult> hitTestResults) async {
var singleHitTestResult = hitTestResults.firstWhere(
(hitTestResult) => hitTestResult.type == ARHitTestResultType.plane);
if (singleHitTestResult != null) {
var newAnchor = ARPlaneAnchor(
transformation: singleHitTestResult.worldTransform, ttl: 2);
bool? didAddAnchor = await this.arAnchorManager!.addAnchor(newAnchor);
if (didAddAnchor!) {
this.anchors.add(newAnchor);
// Add note to anchor
var newNode = ARNode(
type: NodeType.webGLB,
uri: this.selectedModel.uri,
scale: VectorMath.Vector3(0.2, 0.2, 0.2),
position: VectorMath.Vector3(0.0, 0.0, 0.0),
rotation: VectorMath.Vector4(1.0, 0.0, 0.0, 0.0),
data: {"onTapText": "I am a " + this.selectedModel.name});
bool? didAddNodeToAnchor =
await this.arObjectManager!.addNode(newNode, planeAnchor: newAnchor);
if (didAddNodeToAnchor!) {
this.nodes.add(newNode);
setState(() {
readyToUpload = true;
});
} else {
this.arSessionManager!.onError("Adding Node to Anchor failed");
}
var newAnchor = ARPlaneAnchor(
transformation: singleHitTestResult.worldTransform, ttl: 2);
bool? didAddAnchor = await this.arAnchorManager!.addAnchor(newAnchor);
if (didAddAnchor!) {
this.anchors.add(newAnchor);
// Add note to anchor
var newNode = ARNode(
type: NodeType.webGLB,
uri: this.selectedModel.uri,
scale: VectorMath.Vector3(0.2, 0.2, 0.2),
position: VectorMath.Vector3(0.0, 0.0, 0.0),
rotation: VectorMath.Vector4(1.0, 0.0, 0.0, 0.0),
data: {"onTapText": "I am a " + this.selectedModel.name});
bool? didAddNodeToAnchor =
await this.arObjectManager!.addNode(newNode, planeAnchor: newAnchor);
if (didAddNodeToAnchor!) {
this.nodes.add(newNode);
setState(() {
readyToUpload = true;
});
} else {
this.arSessionManager!.onError("Adding Anchor failed");
this.arSessionManager!.onError("Adding Node to Anchor failed");
}
} else {
this.arSessionManager!.onError("Adding Anchor failed");
}
}

Expand Down
44 changes: 20 additions & 24 deletions example/lib/examples/objectgesturesexample.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import 'package:ar_flutter_plugin/datatypes/node_types.dart';
import 'package:ar_flutter_plugin/datatypes/hittest_result_types.dart';
import 'package:ar_flutter_plugin/models/ar_node.dart';
import 'package:ar_flutter_plugin/models/ar_hittest_result.dart';
import 'package:flutter/services.dart';
import 'package:vector_math/vector_math_64.dart';
import 'dart:math';

class ObjectGesturesWidget extends StatefulWidget {
ObjectGesturesWidget({Key? key}) : super(key: key);
Expand Down Expand Up @@ -101,30 +99,28 @@ class _ObjectGesturesWidgetState extends State<ObjectGesturesWidget> {
List<ARHitTestResult> hitTestResults) async {
var singleHitTestResult = hitTestResults.firstWhere(
(hitTestResult) => hitTestResult.type == ARHitTestResultType.plane);
if (singleHitTestResult != null) {
var newAnchor =
ARPlaneAnchor(transformation: singleHitTestResult.worldTransform);
bool? didAddAnchor = await this.arAnchorManager!.addAnchor(newAnchor);
if (didAddAnchor!) {
this.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 this.arObjectManager!.addNode(newNode, planeAnchor: newAnchor);
if (didAddNodeToAnchor!) {
this.nodes.add(newNode);
} else {
this.arSessionManager!.onError("Adding Node to Anchor failed");
}
var newAnchor =
ARPlaneAnchor(transformation: singleHitTestResult.worldTransform);
bool? didAddAnchor = await this.arAnchorManager!.addAnchor(newAnchor);
if (didAddAnchor!) {
this.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 this.arObjectManager!.addNode(newNode, planeAnchor: newAnchor);
if (didAddNodeToAnchor!) {
this.nodes.add(newNode);
} else {
this.arSessionManager!.onError("Adding Anchor failed");
this.arSessionManager!.onError("Adding Node to Anchor failed");
}
} else {
this.arSessionManager!.onError("Adding Anchor failed");
}
}

Expand Down
53 changes: 19 additions & 34 deletions example/lib/examples/objectsonplanesexample.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import 'package:ar_flutter_plugin/datatypes/node_types.dart';
import 'package:ar_flutter_plugin/datatypes/hittest_result_types.dart';
import 'package:ar_flutter_plugin/models/ar_node.dart';
import 'package:ar_flutter_plugin/models/ar_hittest_result.dart';
import 'package:flutter/services.dart';
import 'package:vector_math/vector_math_64.dart';
import 'dart:math';

class ObjectsOnPlanesWidget extends StatefulWidget {
ObjectsOnPlanesWidget({Key? key}) : super(key: key);
Expand Down Expand Up @@ -99,41 +97,28 @@ class _ObjectsOnPlanesWidgetState extends State<ObjectsOnPlanesWidget> {
List<ARHitTestResult> hitTestResults) async {
var singleHitTestResult = hitTestResults.firstWhere(
(hitTestResult) => hitTestResult.type == ARHitTestResultType.plane);
if (singleHitTestResult != null) {
var newAnchor =
ARPlaneAnchor(transformation: singleHitTestResult.worldTransform);
bool? didAddAnchor = await this.arAnchorManager!.addAnchor(newAnchor);
if (didAddAnchor!) {
this.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 this.arObjectManager!.addNode(newNode, planeAnchor: newAnchor);
if (didAddNodeToAnchor!) {
this.nodes.add(newNode);
} else {
this.arSessionManager!.onError("Adding Node to Anchor failed");
}
} else {
this.arSessionManager!.onError("Adding Anchor failed");
}
/*
// To add a node to the tapped position without creating an anchor, use the following code (Please mind: the function onRemoveEverything has to be adapted accordingly!):
var newAnchor =
ARPlaneAnchor(transformation: singleHitTestResult.worldTransform);
bool? didAddAnchor = await this.arAnchorManager!.addAnchor(newAnchor);
if (didAddAnchor!) {
this.anchors.add(newAnchor);
// Add note to anchor
var newNode = ARNode(
type: NodeType.localGLTF2,
uri: "Models/Chicken_01/Chicken_01.gltf",
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),
transformation: singleHitTestResult.worldTransform);
bool didAddWebNode = await this.arObjectManager.addNode(newNode);
if (didAddWebNode) {
position: Vector3(0.0, 0.0, 0.0),
rotation: Vector4(1.0, 0.0, 0.0, 0.0));
bool? didAddNodeToAnchor =
await this.arObjectManager!.addNode(newNode, planeAnchor: newAnchor);
if (didAddNodeToAnchor!) {
this.nodes.add(newNode);
}*/
} else {
this.arSessionManager!.onError("Adding Node to Anchor failed");
}
} else {
this.arSessionManager!.onError("Adding Anchor failed");
}
}
}
55 changes: 21 additions & 34 deletions example/lib/examples/screenshotexample.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,42 +116,29 @@ class _ScreenshotWidgetState extends State<ScreenshotWidget> {
List<ARHitTestResult> hitTestResults) async {
var singleHitTestResult = hitTestResults.firstWhere(
(hitTestResult) => hitTestResult.type == ARHitTestResultType.plane);
if (singleHitTestResult != null) {
var newAnchor =
ARPlaneAnchor(transformation: singleHitTestResult.worldTransform);
bool? didAddAnchor = await arAnchorManager!.addAnchor(newAnchor);
if (didAddAnchor != null && 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 != null && didAddNodeToAnchor) {
nodes.add(newNode);
} else {
arSessionManager!.onError("Adding Node to Anchor failed");
}
} else {
arSessionManager!.onError("Adding Anchor failed");
}
/*
// To add a node to the tapped position without creating an anchor, use the following code (Please mind: the function onRemoveEverything has to be adapted accordingly!):
var newAnchor =
ARPlaneAnchor(transformation: singleHitTestResult.worldTransform);
bool? didAddAnchor = await arAnchorManager!.addAnchor(newAnchor);
if (didAddAnchor != null && didAddAnchor) {
anchors.add(newAnchor);
// Add note to anchor
var newNode = ARNode(
type: NodeType.localGLTF2,
uri: "Models/Chicken_01/Chicken_01.gltf",
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),
transformation: singleHitTestResult.worldTransform);
bool didAddWebNode = await this.arObjectManager.addNode(newNode);
if (didAddWebNode) {
this.nodes.add(newNode);
}*/
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 != null && didAddNodeToAnchor) {
nodes.add(newNode);
} else {
arSessionManager!.onError("Adding Node to Anchor failed");
}
} else {
arSessionManager!.onError("Adding Anchor failed");
}
}
}