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
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,19 @@ Therefore, it is necessary to publish your project with github and make the modi
</table>


### Example Applications
### Example Application

A complete, runnable demo app lives in [`example/`](example/) — run it on a physical ARCore/ARKit device with `cd example && flutter run`. Each feature has its own screen under [`example/lib/demos/`](example/lib/demos/). The Cloud Anchors and External Model Management demos additionally require a Firebase project (see [cloudAnchorSetup.md](cloudAnchorSetup.md)).

| Example Name | Description | Link to Code |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------|
| Debug Options | Simple AR scene with toggles to visualize the world origin, feature points and tracked planes | [Debug Options Code](https://github.com/hlefe/ar_flutter_plugin_2/blob/main/examples/debug_options.dart) |
| Local & Online Objects | AR scene with buttons to place GLTF objects from the flutter asset folders, GLB objects from the internet, or a GLB object from the app's Documents directory at a given position, rotation and scale. Additional buttons allow to modify scale, position and orientation with regard to the world origin after objects have been placed. | [Local & Online Objects Code](https://github.com/hlefe/ar_flutter_plugin_2/blob/main/examples/local_and_web_objects.dart) |
| Objects & Anchors on Planes | AR Scene in which tapping on a plane creates an anchor with a 3D model attached to it | [Objects & Anchors on Planes Code](https://github.com/hlefe/ar_flutter_plugin_2/blob/main/examples/objects_on_planes.dart) |
| Object Transformation Gestures | Same as Objects & Anchors on Planes example, but objects can be panned and rotated using gestures after being placed | [Objects Gestures](https://github.com/hlefe/ar_flutter_plugin_2/blob/main/examples/object_gestures.dart) |
| Screenshots | Same as Objects & Anchors on Planes Example, but the snapshot function is used to take screenshots of the AR Scene | [Screenshots Code](https://github.com/hlefe/ar_flutter_plugin_2/blob/main/examples/screenshot.dart) |
| Cloud Anchors | AR Scene in which objects can be placed, uploaded and downloaded, thus creating an interactive AR experience that can be shared between multiple devices. Currently, the example allows to upload the last placed object along with its anchor and download all anchors within a radius of 100m along with all the attached objects (independent of which device originally placed the objects). As sharing the objects is done by using the Google Cloud Anchor Service and Firebase, this requires some additional setup, please read [Getting Started with cloud anchors](cloudAnchorSetup.md) | [Cloud Anchors Code](https://github.com/hlefe/ar_flutter_plugin_2/blob/main/examples/cloud_anchor.dart) |
| External Object Management | Similar to the Cloud Anchors example, but contains UI to choose between different models. Rather than being hard-coded, an external database (Firestore) is used to manage the available models. As sharing the objects is done by using the Google Cloud Anchor Service and Firebase, this requires some additional setup, please read [Getting Started with cloud anchors](cloudAnchorSetup.md). Also make sure that in your Firestore database, the collection "models" contains some entries with the fields "name", "image", and "uri", where "uri" points to the raw file of a model in GLB format | [External Model Management Code](https://github.com/hlefe/ar_flutter_plugin_2/blob/main/examples/external_model_management.dart) |
| Debug Options | Simple AR scene with toggles to visualize the world origin, feature points and tracked planes | [Debug Options Code](example/lib/demos/debug_options_demo.dart) |
| Local & Online Objects | AR scene with buttons to place GLTF objects from the flutter asset folders, GLB objects from the internet, or a GLB object from the app's Documents directory at a given position, rotation and scale. Additional buttons allow to modify scale, position and orientation with regard to the world origin after objects have been placed. | [Local & Online Objects Code](example/lib/demos/local_and_web_objects_demo.dart) |
| Objects & Anchors on Planes | AR Scene in which tapping on a plane creates an anchor with a 3D model attached to it | [Objects & Anchors on Planes Code](example/lib/demos/objects_on_planes_demo.dart) |
| Object Transformation Gestures | Same as Objects & Anchors on Planes example, but objects can be panned and rotated using gestures after being placed | [Objects Gestures](example/lib/demos/object_gestures_demo.dart) |
| Screenshots | Same as Objects & Anchors on Planes Example, but the snapshot function is used to take screenshots of the AR Scene | [Screenshots Code](example/lib/demos/screenshot_demo.dart) |
| Cloud Anchors | AR Scene in which objects can be placed, uploaded and downloaded, thus creating an interactive AR experience that can be shared between multiple devices. Currently, the example allows to upload the last placed object along with its anchor and download all anchors within a radius of 100m along with all the attached objects (independent of which device originally placed the objects). As sharing the objects is done by using the Google Cloud Anchor Service and Firebase, this requires some additional setup, please read [Getting Started with cloud anchors](cloudAnchorSetup.md) | [Cloud Anchors Code](example/lib/demos/cloud_anchor_demo.dart) |
| External Object Management | Similar to the Cloud Anchors example, but contains UI to choose between different models. Rather than being hard-coded, an external database (Firestore) is used to manage the available models. As sharing the objects is done by using the Google Cloud Anchor Service and Firebase, this requires some additional setup, please read [Getting Started with cloud anchors](cloudAnchorSetup.md). Also make sure that in your Firestore database, the collection "models" contains some entries with the fields "name", "image", and "uri", where "uri" points to the raw file of a model in GLB format | [External Model Management Code](example/lib/demos/external_model_demo.dart) |


## Plugin Architecture
Expand Down
45 changes: 45 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/
/coverage/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
33 changes: 33 additions & 0 deletions example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "f94f4fc76b4d74543ed9b085bbd75341ef65de22"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f94f4fc76b4d74543ed9b085bbd75341ef65de22
base_revision: f94f4fc76b4d74543ed9b085bbd75341ef65de22
- platform: android
create_revision: f94f4fc76b4d74543ed9b085bbd75341ef65de22
base_revision: f94f4fc76b4d74543ed9b085bbd75341ef65de22
- platform: ios
create_revision: f94f4fc76b4d74543ed9b085bbd75341ef65de22
base_revision: f94f4fc76b4d74543ed9b085bbd75341ef65de22

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
51 changes: 51 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# ar_flutter_plugin_2 example

A runnable demo app for the `ar_flutter_plugin_2` plugin (referenced via a
path dependency on `../`).

## Requirements

AR runs only on a **physical device** — ARCore on Android, ARKit on iOS. It
will not render in an emulator or simulator. Camera permission is requested at
runtime.

- Android: `minSdk 28` (set in `android/app/build.gradle.kts`); the device must
support [ARCore](https://developers.google.com/ar/devices).
- iOS: an ARKit-capable device; `NSCameraUsageDescription` is set in
`ios/Runner/Info.plist`.

## Run

```bash
cd example
flutter pub get
flutter run # on a connected AR-capable device
```

## Demos

| Screen | Feature exercised | Source |
| --- | --- | --- |
| Objects on planes | Plane detection, `addAnchor`, `addNode` on a plane anchor, `onNodeTap` | `lib/demos/objects_on_planes_demo.dart` |
| Object gestures | `handlePans`/`handleRotation`, `onPanEnd`/`onRotationEnd`, syncing `ARNode.transform` | `lib/demos/object_gestures_demo.dart` |
| Web object + updateNode | `addNode`/`removeNode` at the world origin and `updateNode` (programmatic rotate/scale) | `lib/demos/web_object_demo.dart` |
| Local & web objects | `localGLTF2` (bundled asset), `webGLB`, `fileSystemAppFolderGLB`, transform shuffle | `lib/demos/local_and_web_objects_demo.dart` |
| Screenshots | `ARSessionManager.snapshot()` | `lib/demos/screenshot_demo.dart` |
| Debug options | Live-toggling `showFeaturePoints` / `showPlanes` / `showWorldOrigin` | `lib/demos/debug_options_demo.dart` |
| Cloud anchors | `initGoogleCloudAnchorMode`, `uploadAnchor`/`downloadAnchor` + Firestore | `lib/demos/cloud_anchor_demo.dart` |
| External model management | Firestore-managed model list + cloud anchors | `lib/demos/external_model_demo.dart` |

Most models load as `NodeType.webGLB` from a public Khronos sample URL. Bundled
assets are `assets/images/triangle.png` (plane texture for
`customPlaneTexturePath`) and a self-contained `assets/models/Duck.gltf` (for
the local-asset demo).

### Cloud anchor demos (Firebase)

The **Cloud anchors** and **External model management** screens need a
configured Firebase project and the Google Cloud Anchor service — see
[`cloudAnchorSetup.md`](../cloudAnchorSetup.md). Without a Firebase
configuration they show a "Firebase initialization failed" screen rather than
crashing, so the rest of the app still runs. These two demos are simplified
from the original snippets: they drop the discontinued `geoflutterfire2`
geo-radius query and download the most recently uploaded anchor instead.
28 changes: 28 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
14 changes: 14 additions & 0 deletions example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
.cxx/

# Remember to never publicly share your keystore.
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
46 changes: 46 additions & 0 deletions example/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
plugins {
id("com.android.application")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}

android {
namespace = "com.example.ar_flutter_plugin_2_example"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.ar_flutter_plugin_2_example"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
// ar_flutter_plugin_2 requires a minimum SDK of 28.
minSdk = 28
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
}
}
}

kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}

flutter {
source = "../.."
}
Loading