diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 026f01b..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index bf6f69e..9837267 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,4 @@ repomix-output.txt *.log .env *.tmp - +.DS_Store diff --git a/android/.DS_Store b/android/.DS_Store deleted file mode 100644 index 6af815c..0000000 Binary files a/android/.DS_Store and /dev/null differ diff --git a/android/src/.DS_Store b/android/src/.DS_Store deleted file mode 100644 index 94b858a..0000000 Binary files a/android/src/.DS_Store and /dev/null differ diff --git a/android/src/main/.DS_Store b/android/src/main/.DS_Store deleted file mode 100644 index 6636fe1..0000000 Binary files a/android/src/main/.DS_Store and /dev/null differ diff --git a/android/src/main/assets/.DS_Store b/android/src/main/assets/.DS_Store deleted file mode 100644 index dcde3dd..0000000 Binary files a/android/src/main/assets/.DS_Store and /dev/null differ diff --git a/android/src/main/kotlin/.DS_Store b/android/src/main/kotlin/.DS_Store deleted file mode 100644 index 94d996b..0000000 Binary files a/android/src/main/kotlin/.DS_Store and /dev/null differ diff --git a/android/src/main/res/.DS_Store b/android/src/main/res/.DS_Store deleted file mode 100644 index baebba1..0000000 Binary files a/android/src/main/res/.DS_Store and /dev/null differ diff --git a/examples/.DS_Store b/examples/.DS_Store deleted file mode 100644 index 5d56837..0000000 Binary files a/examples/.DS_Store and /dev/null differ diff --git a/lib/.DS_Store b/lib/.DS_Store deleted file mode 100644 index 8d81c56..0000000 Binary files a/lib/.DS_Store and /dev/null differ diff --git a/lib/managers/ar_session_manager.dart b/lib/managers/ar_session_manager.dart index deee08b..6a73497 100644 --- a/lib/managers/ar_session_manager.dart +++ b/lib/managers/ar_session_manager.dart @@ -1,5 +1,6 @@ import 'dart:math' show sqrt; import 'dart:typed_data'; +import 'dart:io'; import 'package:ar_flutter_plugin_2/datatypes/config_planedetection.dart'; import 'package:ar_flutter_plugin_2/models/ar_anchor.dart'; @@ -49,9 +50,18 @@ class ARSessionManager { /// Returns the camera pose in Matrix4 format with respect to the world coordinate system of the [ARView] Future getCameraPose() async { try { - final serializedCameraPose = - await _channel.invokeMethod>('getCameraPose', {}); - return MatrixConverter().fromJson(serializedCameraPose!); + if (Platform.isAndroid) { + final serializedCameraPose = await _channel.invokeMethod>('getCameraPose', {}); + final position = serializedCameraPose!['position']; + final rotation = serializedCameraPose!['rotation']; + + final translation = Vector3(position!['x'], position!['y'], position!['z']); + final quaternion = Quaternion(rotation!['x'], rotation!['y'], rotation!['z'], rotation!['w']); + return Matrix4.compose(translation, quaternion, Vector3.all(1.0)); + } else { + final serializedCameraPose = await _channel.invokeMethod>('getCameraPose', {}); + return MatrixConverter().fromJson(serializedCameraPose!); + } } catch (e) { print('Error caught: ' + e.toString()); return null; @@ -122,7 +132,7 @@ class ARSessionManager { } //Show or hide planes - void showPlanes(bool showPlanes){ + void showPlanes(bool showPlanes) { _channel.invokeMethod('showPlanes', { "showPlanes": showPlanes, }); @@ -138,8 +148,7 @@ class ARSessionManager { if (onError != null) { onError!(call.arguments[0]); print(call.arguments); - } - else{ + } else { ScaffoldMessenger.of(buildContext).showSnackBar(SnackBar( content: Text(call.arguments[0]), action: SnackBarAction( @@ -207,7 +216,6 @@ class ARSessionManager { }); } - /// Dispose the AR view on the platforms to pause the scenes and disconnect the platform handlers. /// You should call this before removing the AR view to prevent out of memory erros dispose() async {