搜尋分類、套件與程式碼儲存庫

套件詳情v0.1.0

arcore_flutter_plugin

用於 ARCore SDK 的 Flutter 插件,Android 平台,用於建立新的擴增實境體驗

Android
近 30 天下載
700
喜歡數
337
Pub 分數
120

安裝套件

flutter pub add arcore_flutter_plugin

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

arcore_flutter_plugin 是一個 Flutter 套件,讓開發者能夠在 Android 裝置上使用 Google 的 ARCore SDK 建立增強實境(AR)體驗。它在 Flutter 和 ARCore 之間提供橋接,允許在 Flutter 應用程式中整合 3D 內容、運動追蹤與環境理解功能。專為 Android 設計,該套件支援平面偵測、光線估計與物件錨定等功能。開發者可利用此工具建立用於遊戲、教育、零售等領域的沉浸式 AR 應用。此套件為開源並由社群積極維護。

適用情境

  • 構建AR遊戲
  • 建立互動式產品視覺化
  • 開發教育類AR工具
  • 提升零售購物體驗
  • 實施AR導航輔助

主要特色

  • ARCore SDK 集成
  • 平面和表面檢測
  • 運動追蹤
  • 光線估算
  • 3D對象錨定

適合對象

  • 僅限 Android 的 AR 開發者
  • Flutter 開發者探索 AR
  • 教育類應用程式創作者
  • 零售和電子商務平台

使用建議

  • 僅限 Android 平台
  • 需要相容的硬體
  • 可能需要額外設定以獲得最佳效能
  • 取決於設備上的 ARCore 可用性

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

I'm working to a new sceneview_flutter plugin to implement all features available in sceneview. SceneView is a Sceneform Maintained replacement in Kotlin.

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.

所屬分類

依賴

依賴清單 3 項

原始碼儲存庫

使用此套件的專案