AR Core Flutter - An arcore flutter plugin on which i add some contribution based on my personal requirements and updated the code

Overview

arcore_flutter_plugin

Awesome Flutter

Thanks to Oleksandr Leuschenko for inspiration and his precious code: arkit_flutter_plugin

Usage

I wrote 2 articles for setup you project and start with ARCore Flutter Plugin:

ARCore Flutter Plugin: configurations.

ARCore Flutter Plugin: add object on the plane.

Configure your app

To use this plugin, add arcore_flutter_plugin as a dependency in your pubspec.yaml file.

  1. Follow official guide to enable ArCore

  2. Add the Sceneform library to your app's build.gradle file:

android {
    // Sceneform libraries use language constructs from Java 8.
    // Add these compile options if targeting minSdkVersion < 26.
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

dependencies {
    …

    // Provides ArFragment, and other UX resources.
    implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.8.0'

    // Alternatively, use ArSceneView without the UX dependency.
    implementation 'com.google.ar.sceneform:core:1.8.0'
}
  1. Import the Sceneform plugin into your project (OPTIONAL)

Example

The simplest code example:

import 'package:arcore_flutter_plugin/arcore_flutter_plugin.dart';
import 'package:flutter/material.dart';
import 'package:vector_math/vector_math_64.dart' as vector;

class HelloWorld extends StatefulWidget {
  @override
  _HelloWorldState createState() => _HelloWorldState();
}

class _HelloWorldState extends State<HelloWorld> {
  ArCoreController arCoreController;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Hello World'),
        ),
        body: ArCoreView(
          onArCoreViewCreated: _onArCoreViewCreated,
        ),
      ),
    );
  }

  void _onArCoreViewCreated(ArCoreController controller) {
    arCoreController = controller;

    _addSphere(arCoreController);
    _addCylindre(arCoreController);
    _addCube(arCoreController);
  }

  void _addSphere(ArCoreController controller) {
    final material = ArCoreMaterial(
        color: Color.fromARGB(120, 66, 134, 244));
    final sphere = ArCoreSphere(
      materials: [material],
      radius: 0.1,
    );
    final node = ArCoreNode(
      shape: sphere,
      position: vector.Vector3(0, 0, -1.5),
    );
    controller.addArCoreNode(node);
  }

  void _addCylindre(ArCoreController controller) {
    final material = ArCoreMaterial(
      color: Colors.red,
      reflectance: 1.0,
    );
    final cylindre = ArCoreCylinder(
      materials: [material],
      radius: 0.5,
      height: 0.3,
    );
    final node = ArCoreNode(
      shape: cylindre,
      position: vector.Vector3(0.0, -0.5, -2.0),
    );
    controller.addArCoreNode(node);
  }

  void _addCube(ArCoreController controller) {
    final material = ArCoreMaterial(
      color: Color.fromARGB(120, 66, 134, 244),
      metallic: 1.0,
    );
    final cube = ArCoreCube(
      materials: [material],
      size: vector.Vector3(0.5, 0.5, 0.5),
    );
    final node = ArCoreNode(
      shape: cube,
      position: vector.Vector3(-0.5, 0.5, -3.5),
    );
    controller.addArCoreNode(node);
  }

  @override
  void dispose() {
    arCoreController.dispose();
    super.dispose();
  }
}

See the example directory for a complete sample app.

3D Objects Credits

Anonymous


Documentation

Classes provided by the plugin

There are a total of 13 classes provided by this plugin until May 2020.

  • ArCoreView
  • ArCoreController
  • ArCoreFaceView
  • ArCoreFaceContrller
  • ArCoreSphere
  • ArCoreCylinder
  • ArCoreCube
  • ArCoreNode
  • ArCoeMaterial
  • ArCoreHitTestResult
  • ArCoreRotatingNode
  • ArCorePlane
  • ArCoreReferenceNode

ArCoreView

This class returns the view type. There are two types of views in it.

AUGMENTEDFACE STANDARDVIEW

There are 4 properties in it:

  • onArCoreViewCreated
  • enableTapRecoginzer
  • enableUpdateListener
  • type

onArCoreViewCreated

This property takes a ArCoreController.


enableTapRecoginzer

Initially, set to false. It is used as an argument by the MethodChannel.


enableUpdateListener

Initially, set to false. It is used as an argument by the MethodChannel.


type

It is a view type, it is either AUGMENTEDFACE, STANDARDVIEW*. It is set to STANDARDVIEW by default.


ArCoreController

This controller used to add a ArNode using addArCoreNode function, add a ArCoreNode with ancher using a addArCoreNodeWithAncher function and also remove node using removeNode function.


ArCoreFaceView

It is a stateful widget that returns a ArCoreAndroidView. It has two properties enableAugmentedFaces, onArCoreViewCreated.

Initially, enableAugmentedFaces is set to false. onArCoreViewCreated takes a function with ArCoreController argument.


ArCoreFaceController

It used dispose and loadMesh method to control the FaceView.


ArCoreSphere

It is ArCoreShape, takes a radius & ArCoreMaterial.


ArCoreCylender

It is ArCoreShape, takes a radius, height, & ArCoreMaterial.


ArCoreCube

It is ArCoreShape, takes a size i.e. Vector3 & ArCoreMaterial.


ArCoreNode

This widget is used to provide the position, shape, scale, rotation, name.


ArCoreMaterial

It is used to describe the outlook of the virtual object created by the user.

It has color,textureBytes, metallic, roughness, reflection.


ArCoreRotatingNode

It is an ArCoreNode with a degreesPerSecond property which is a double value.


ArCorePlane

It takes the x, y coordinate of the plane, ArCorePose & ArCorePlaneType.

There are three types of plane:

  • HORIZONTAL_UPWARD_FACING
  • HORIZONTAL_DOWNWARD_FACING
  • VERTICAL

ArCoreReferenceNode

It is ArCoreNode, it has all the properties that the ArCoreNode has also it has objectUrl and object3DFileName.


objectUrl

URL of glft object for remote rendering.


object3DFileName

Filename of sfb object in assets folder.

You might also like...
A mobile application developed for *Android* devices, aimed at 11th grade students in which they can take some basic training tests for presentation of external tests.

ApliKTest11 Application with Kit of questions and Knowledge Test for the preparation of the Saber Test. Description A mobile application developed for

Arc Layout is a view group with which you can add a arc-shaped container in your layout.
Arc Layout is a view group with which you can add a arc-shaped container in your layout.

ArcLayout Arc Layout is a view group with which you can add a arc-shaped container in your layout. Two main variables are the direction and the curvat

💡🚀⭐️ A generalized adapter for RecyclerView on Android which makes it easy to add heterogeneous items to a list
💡🚀⭐️ A generalized adapter for RecyclerView on Android which makes it easy to add heterogeneous items to a list

Mystique is a Kotlin library for Android’s RecyclerView which allows you to create homogeneous and heterogeneous lists effortlessly using an universal

A Flutter implementation of Salesforce Marketing Cloud for iOS and Android

sfmc_flutter A Flutter implementation of Salesforce Marketing Cloud for iOS and Android. Features Setup Marketing Cloud (iOS and Android) Support for

Klutter: Flutter + Kotlin Multiplatform

Klutter Klutter is a framework and tool set which uses Flutter to create the frontend and Kotlin Multiplatform for the backend. The connective layer i

1aingenieriaygas native base android - Project base for the migration of the Flutter App of 1A Ingenieria y Gas
1aingenieriaygas native base android - Project base for the migration of the Flutter App of 1A Ingenieria y Gas

1A Ingenieria y Gas App Versión Wordpress Backend Este proyecto se encuentra sol

Provides Kotlin libs and some features for building Kotlin plugins
Provides Kotlin libs and some features for building Kotlin plugins

Kotlin Plugin Provides Kotlin libs and some features for building awesome Kotlin plugins. Can be used instead of CreeperFace's KotlinLib (don't use to

This is a sample app to use [Molecule library] and solve some scoping problems in Android development.
This is a sample app to use [Molecule library] and solve some scoping problems in Android development.

Android sample app Problem It's started when P.Y. in Twitter shared this tweet and his post, which is a correct complain about introducing a new set o

The KPy gradle plugin allows you to write Kotlin/Native code and use it from python.

The KPy gradle plugin allows you to write Kotlin/Native code and use it from python.

Owner
Muhammad Bilal
Hello i am Bilal idrees a Flutter developer and working in this field for the past 3 years. I have also been an Android Native Developer.
Muhammad Bilal
Esp touch flutter plugin - Client-side (mobile) Android Flutter implementation for ESP-Touch protocol

esp_touch_flutter_plugin Client-side (mobile) Android Flutter implementation for

huangyanxiong 0 Jan 21, 2022
Open as default - A flutter plugin that allows setting up your flutter app to open files as default

open_as_default A flutter plugin that allows setting up your flutter app to open

LuisDeLaValier 3 Nov 15, 2022
Removes account requirements and telemetry from Oculus Quest devices

Removes account requirements and telemetry from Oculus Quest devices

Bastian 1.6k Dec 29, 2022
kotlin-core

kotlin-core This package is not Android-specific, and can be used across platforms. However, for a good example of use in Android, take a look at kotl

Lightning Kite 36 Oct 3, 2022
OPEX core for Opex exchange, Open Source Cryptocurrency Exchange.

Opex Core OPEX Core is a Kotlin based cryptocurrency exchange and matching engine from the OPEX project. This extendable and microservice architecture

OPEX 16 Dec 26, 2022
A personal project made using Jetpack Compose, Clean-MVVM architecture and other jetpack libraries

A basic CRUD for recording your personal credit and debit transactions. Made using Jetpack Compose, Clean-MVVM and other Jetpack libraries, incorporated with Unit Tests.

Shoaib Ahmed 3 Dec 6, 2022
🚀 CLI-like personal webpage built with Kotlin/JS

kotlin-cv.js Personal terminal-like simple webpage template built with Kotlin/JS. The template features CLI commands help, cat, ls, their completion a

Viktor 9 Sep 10, 2022
Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders

Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders.

Vehement 8 Nov 26, 2022
A flutter plugin to scan stripe readers and connect to the them and get the payment methods.

stripe_terminal A flutter plugin to scan stripe readers and connect to the them and get the payment methods. Installation Android No Configuration nee

Aawaz Gyawali 8 Dec 29, 2022
use kmm to write a flutter plugin

use KMM to write a flutter plugin The reference plugin_codelab example plugin that accompanies the How to write a Flutter plugin codelab. I changed pl

libill 8 Nov 9, 2022