From 2fd7fed93b3c825e49cea0a22913a32b0dcf2808 Mon Sep 17 00:00:00 2001 From: Lars Carius Date: Mon, 21 Jun 2021 17:49:16 +0200 Subject: [PATCH] updates documentation and deletes unneccesary files --- CHANGELOG.md | 5 +++++ lib/datatypes/hittest_result_types.dart | 1 + lib/managers/ar_anchor_manager.dart | 4 +++- lib/managers/ar_model_manager.dart | 0 lib/managers/ar_object_manager.dart | 4 +++- lib/managers/ar_user_manager.dart | 0 lib/models/ar_anchor.dart | 6 +++++- lib/models/ar_hittest_result.dart | 9 ++++++++- lib/models/ar_node.dart | 3 +-- lib/widgets/ar_view.dart | 1 + 10 files changed, 27 insertions(+), 6 deletions(-) delete mode 100644 lib/managers/ar_model_manager.dart delete mode 100644 lib/managers/ar_user_manager.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index dadf6ddb..f23fd4ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.4.2 + +* Updates documentation +* Deletes unnecessary files + ## 0.4.1 * Adds External Model Management Example: A firebase database is used to store a list of 3D models (name, preview image, URI of the file location in a github repo). These models can be scrolled through and selected from in the example and can then be placed into the scene, uploaded through the Google Cloud Anchor API and downloaded on any other device with the app installed. The downloading user does not need to have the model "pre-installed", it is downloaded on the first occasion. diff --git a/lib/datatypes/hittest_result_types.dart b/lib/datatypes/hittest_result_types.dart index 81e21d92..bc46be0b 100644 --- a/lib/datatypes/hittest_result_types.dart +++ b/lib/datatypes/hittest_result_types.dart @@ -1,3 +1,4 @@ +/// Determines which types of hit results the plugin supports enum ARHitTestResultType { undefined, plane, diff --git a/lib/managers/ar_anchor_manager.dart b/lib/managers/ar_anchor_manager.dart index b8fe0322..817bc27e 100644 --- a/lib/managers/ar_anchor_manager.dart +++ b/lib/managers/ar_anchor_manager.dart @@ -7,7 +7,7 @@ typedef AnchorUploadedHandler = void Function(ARAnchor arAnchor); typedef AnchorDownloadedHandler = ARAnchor Function( Map serializedAnchor); -/// Manages the session configuration, parameters and events of an [ARView] +/// Handles all anchor-related functionality of an [ARView], including configuration and usage of collaborative sessions class ARAnchorManager { /// Platform channel used for communication from and to [ARAnchorManager] late MethodChannel _channel; @@ -32,6 +32,7 @@ class ARAnchorManager { } } + /// Activates collaborative AR mode (using Google Cloud Anchors) initGoogleCloudAnchorMode() async { _channel.invokeMethod('initGoogleCloudAnchorMode', {}); } @@ -107,6 +108,7 @@ class ARAnchorManager { } } + /// Try to download anchor with the given ID from the Google Cloud Anchor API and add it to the scene Future downloadAnchor(String cloudanchorid) async { print("TRYING TO DOWNLOAD ANCHOR WITH ID " + cloudanchorid); _channel diff --git a/lib/managers/ar_model_manager.dart b/lib/managers/ar_model_manager.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/managers/ar_object_manager.dart b/lib/managers/ar_object_manager.dart index a1bfce5a..49f5cbef 100644 --- a/lib/managers/ar_object_manager.dart +++ b/lib/managers/ar_object_manager.dart @@ -5,7 +5,7 @@ import 'package:flutter/services.dart'; // Type definitions to enforce a consistent use of the API typedef NodeTapResultHandler = void Function(List nodes); -/// Manages the all actions related to 3D objects (=Nodes) of an [ARView] +/// Manages the all node-related actions of an [ARView] class ARObjectManager { /// Platform channel used for communication from and to [ARObjectManager] late MethodChannel _channel; @@ -13,6 +13,7 @@ class ARObjectManager { /// Debugging status flag. If true, all platform calls are printed. Defaults to false. final bool debug; + /// Callback function that is invoked when the platform detects a tap on a node NodeTapResultHandler? onNodeTap; ARObjectManager(int id, {this.debug = false}) { @@ -51,6 +52,7 @@ class ARObjectManager { return Future.value(); } + /// Sets up the AR Object Manager onInitialize() { _channel.invokeMethod('init', {}); } diff --git a/lib/managers/ar_user_manager.dart b/lib/managers/ar_user_manager.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/models/ar_anchor.dart b/lib/models/ar_anchor.dart index f94c9297..4ab87e84 100644 --- a/lib/models/ar_anchor.dart +++ b/lib/models/ar_anchor.dart @@ -4,7 +4,7 @@ import 'package:ar_flutter_plugin/utils/json_converters.dart'; import 'package:vector_math/vector_math_64.dart'; import 'package:flutter/widgets.dart'; -/// Object specifying a position and rotation in the AR environment +/// Object attached to a tracked physical entity of the AR environment (can be initialized with a world transformation) abstract class ARAnchor { ARAnchor({ required this.type, @@ -19,6 +19,7 @@ abstract class ARAnchor { /// Will be autogenerated if not defined. final String name; + /// Constructs an [ARAnchor] from a serialized anchor object factory ARAnchor.fromJson(Map arguments) { final type = arguments['type']; switch (type) { @@ -31,6 +32,7 @@ abstract class ARAnchor { /// Defines the anchor’s rotation, translation and scale in world coordinates. final Matrix4 transformation; + /// Serializes an [ARAnchor] Map toJson(); } @@ -64,6 +66,7 @@ class ARPlaneAnchor extends ARAnchor { Map toJson() => aRPlaneAnchorToJson(this); } +/// Constructs an [ARPlaneAnchor] from a serialized PlaneAnchor object ARPlaneAnchor aRPlaneAnchorFromJson(Map json) { return ARPlaneAnchor( transformation: @@ -78,6 +81,7 @@ ARPlaneAnchor aRPlaneAnchorFromJson(Map json) { ); } +/// Serializes an [ARPlaneAnchor] Map aRPlaneAnchorToJson(ARPlaneAnchor instance) { return { 'type': instance.type.index, diff --git a/lib/models/ar_hittest_result.dart b/lib/models/ar_hittest_result.dart index 0b8cd71a..6a95c944 100644 --- a/lib/models/ar_hittest_result.dart +++ b/lib/models/ar_hittest_result.dart @@ -5,7 +5,7 @@ import 'package:ar_flutter_plugin/utils/json_converters.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:vector_math/vector_math_64.dart'; -/// A result of an intersection found during a hit-test. +/// A result (type, distance from the camera, world transformation) of an intersection found during a hit-test. class ARHitTestResult { ARHitTestResult( this.type, @@ -23,12 +23,15 @@ class ARHitTestResult { /// relative to the world. final Matrix4 worldTransform; + /// Instantiates am [ARHitTestResult] from a serialized ARHitTestResult static ARHitTestResult fromJson(Map json) => _$ARHitTestResultFromJson(json); + /// Serializes the [ARHitTestResult] Map toJson() => _$ARHitTestResultToJson(this); } +/// Instantiates am [ARHitTestResult] from a serialized ARHitTestResult ARHitTestResult _$ARHitTestResultFromJson(Map json) { return ARHitTestResult( const ARHitTestResultTypeConverter().fromJson(json['type'] as int), @@ -37,6 +40,7 @@ ARHitTestResult _$ARHitTestResultFromJson(Map json) { ); } +/// Serializes the [ARHitTestResult] Map _$ARHitTestResultToJson(ARHitTestResult instance) { final val = {}; @@ -54,10 +58,12 @@ Map _$ARHitTestResultToJson(ARHitTestResult instance) { return val; } +/// Helper class to convert the type of an [ARHitTestResult] from its integer representation to the [ARHitTestResultType] and vice versa class ARHitTestResultTypeConverter implements JsonConverter { const ARHitTestResultTypeConverter(); + /// Converts the type of an [ARHitTestResult] from its integer representation to the [ARHitTestResultType] @override ARHitTestResultType fromJson(int json) { switch (json) { @@ -70,6 +76,7 @@ class ARHitTestResultTypeConverter } } + /// Converts the type of an [ARHitTestResult] from its [ARHitTestResultType] to an integer representation @override int toJson(ARHitTestResultType object) { switch (object) { diff --git a/lib/models/ar_node.dart b/lib/models/ar_node.dart index 9966bca6..e0a7e0a3 100644 --- a/lib/models/ar_node.dart +++ b/lib/models/ar_node.dart @@ -111,8 +111,7 @@ class ARNode { } } -// Helper functions - +/// Helper function to create a Matrix4 from either a given matrix or from position, scale and rotation relative to the origin Matrix4 createTransformMatrix(Matrix4? origin, Vector3? position, Vector3? scale, Vector4? rotation, Vector3? eulerAngles) { final transform = origin ?? Matrix4.identity(); diff --git a/lib/widgets/ar_view.dart b/lib/widgets/ar_view.dart index f77d77a5..8a8844db 100644 --- a/lib/widgets/ar_view.dart +++ b/lib/widgets/ar_view.dart @@ -32,6 +32,7 @@ abstract class PlatformARView { @required ARViewCreatedCallback arViewCreatedCallback, @required PlaneDetectionConfig planeDetectionConfig}); + /// Callback function that is executed once the view is established void onPlatformViewCreated(int id); }