Skip to content

Commit

Permalink
updates documentation and deletes unneccesary files
Browse files Browse the repository at this point in the history
  • Loading branch information
CariusLars committed Jun 21, 2021
1 parent 8d21965 commit 2fd7fed
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions lib/datatypes/hittest_result_types.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// Determines which types of hit results the plugin supports
enum ARHitTestResultType {
undefined,
plane,
Expand Down
4 changes: 3 additions & 1 deletion lib/managers/ar_anchor_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ typedef AnchorUploadedHandler = void Function(ARAnchor arAnchor);
typedef AnchorDownloadedHandler = ARAnchor Function(
Map<String, dynamic> 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;
Expand All @@ -32,6 +32,7 @@ class ARAnchorManager {
}
}

/// Activates collaborative AR mode (using Google Cloud Anchors)
initGoogleCloudAnchorMode() async {
_channel.invokeMethod<bool>('initGoogleCloudAnchorMode', {});
}
Expand Down Expand Up @@ -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<bool?> downloadAnchor(String cloudanchorid) async {
print("TRYING TO DOWNLOAD ANCHOR WITH ID " + cloudanchorid);
_channel
Expand Down
Empty file removed lib/managers/ar_model_manager.dart
Empty file.
4 changes: 3 additions & 1 deletion lib/managers/ar_object_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import 'package:flutter/services.dart';
// Type definitions to enforce a consistent use of the API
typedef NodeTapResultHandler = void Function(List<String> 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;

/// 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}) {
Expand Down Expand Up @@ -51,6 +52,7 @@ class ARObjectManager {
return Future.value();
}

/// Sets up the AR Object Manager
onInitialize() {
_channel.invokeMethod<void>('init', {});
}
Expand Down
Empty file removed lib/managers/ar_user_manager.dart
Empty file.
6 changes: 5 additions & 1 deletion lib/models/ar_anchor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<String, dynamic> arguments) {
final type = arguments['type'];
switch (type) {
Expand All @@ -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<String, dynamic> toJson();
}

Expand Down Expand Up @@ -64,6 +66,7 @@ class ARPlaneAnchor extends ARAnchor {
Map<String, dynamic> toJson() => aRPlaneAnchorToJson(this);
}

/// Constructs an [ARPlaneAnchor] from a serialized PlaneAnchor object
ARPlaneAnchor aRPlaneAnchorFromJson(Map<String, dynamic> json) {
return ARPlaneAnchor(
transformation:
Expand All @@ -78,6 +81,7 @@ ARPlaneAnchor aRPlaneAnchorFromJson(Map<String, dynamic> json) {
);
}

/// Serializes an [ARPlaneAnchor]
Map<String, dynamic> aRPlaneAnchorToJson(ARPlaneAnchor instance) {
return <String, dynamic>{
'type': instance.type.index,
Expand Down
9 changes: 8 additions & 1 deletion lib/models/ar_hittest_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -23,12 +23,15 @@ class ARHitTestResult {
/// relative to the world.
final Matrix4 worldTransform;

/// Instantiates am [ARHitTestResult] from a serialized ARHitTestResult
static ARHitTestResult fromJson(Map<String, dynamic> json) =>
_$ARHitTestResultFromJson(json);

/// Serializes the [ARHitTestResult]
Map<String, dynamic> toJson() => _$ARHitTestResultToJson(this);
}

/// Instantiates am [ARHitTestResult] from a serialized ARHitTestResult
ARHitTestResult _$ARHitTestResultFromJson(Map<String, dynamic> json) {
return ARHitTestResult(
const ARHitTestResultTypeConverter().fromJson(json['type'] as int),
Expand All @@ -37,6 +40,7 @@ ARHitTestResult _$ARHitTestResultFromJson(Map<String, dynamic> json) {
);
}

/// Serializes the [ARHitTestResult]
Map<String, dynamic> _$ARHitTestResultToJson(ARHitTestResult instance) {
final val = <String, dynamic>{};

Expand All @@ -54,10 +58,12 @@ Map<String, dynamic> _$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<ARHitTestResultType, int> {
const ARHitTestResultTypeConverter();

/// Converts the type of an [ARHitTestResult] from its integer representation to the [ARHitTestResultType]
@override
ARHitTestResultType fromJson(int json) {
switch (json) {
Expand All @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions lib/models/ar_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/ar_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 2fd7fed

Please sign in to comment.