Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

arcore_flutter_plugin

flutter plugin for arcore sdk, android platform to build new augmented reality experiences

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.


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.