搜索分类、插件与代码仓

插件详情v0.7.3

ar_flutter_plugin

用于创建(协作式)增强现实体验的 Flutter 插件 - 支持 iOS 的 ARKit 和 Android 设备的 ARCore。

AndroidiOS
近 30 天下载
343
喜欢数
364
Pub 分数
120

安装插件

flutter pub add ar_flutter_plugin

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

ar_flutter_plugin 允许开发者在 Flutter 应用中构建增强现实体验,支持 iOS 上的 ARKit 和 Android 上的 ARCore。该插件通过允许多个用户实时交互同一虚拟内容,实现协作式 AR。该插件可无缝集成到 Flutter 项目中,并通过统一的 API 提供对设备特定 AR 功能的访问。非常适合用于互动教育工具、游戏和沉浸式产品可视化。

适合场景

  • 互动AR游戏
  • 虚拟产品预览
  • 教育类AR应用
  • 协作式AR体验
  • 基于AR的导航

主要特点

  • 支持 ARKit (iOS) 和 ARCore (Android)
  • 启用多用户AR协作
  • 与 Flutter 的简单集成
  • 实时3D物体放置
  • 跨平台AR开发

适合对象

  • 使用 Flutter 的 AR 开发人员
  • 教育类应用程序创作者
  • 产品可视化应用
  • 游戏应用
  • 互动叙事平台

使用建议

  • 需要支持AR的兼容设备
  • 在较旧或不受支持的硬件上功能受限
  • 可能需要额外设置才能获得最佳性能
  • 依赖于平台特定的AR框架
  • 不适用于非AR使用场景

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

ar_flutter_plugin

pub package

Flutter Plugin for (collaborative) Augmented Reality - Supports ARKit for iOS and ARCore for Android devices.

Many thanks to Oleksandr Leuschenko for the arkit_flutter_plugin and to Gian Marco Di Francesco for the arcore_flutter_plugin which both served as a great basis and starting point for this project.

Getting Started

Installing

Add the Flutter package to your project by running:

flutter pub add ar_flutter_plugin

Or manually add this to your pubspec.yaml file (and run flutter pub get):

ar_flutter_plugin package extension

dependencies:
  ar_flutter_plugin: ^0.7.3
Importing

Add this to your code:

import 'package:ar_flutter_plugin/ar_flutter_plugin.dart';

If you have problems with permissions on iOS (e.g. with the camera view not showing up even though camera access is allowed), add this to the podfile of your app's ios directory:

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      flutter_additional_ios_build_settings(target)
      target.build_configurations.each do |config|
        # Additional configuration options could already be set here

        # BEGINNING OF WHAT YOU SHOULD ADD
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
          '$(inherited)',

          ## dart: PermissionGroup.camera
          'PERMISSION_CAMERA=1',

          ## dart: PermissionGroup.photos
          'PERMISSION_PHOTOS=1',

          ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
          'PERMISSION_LOCATION=1',

          ## dart: PermissionGroup.sensors
          'PERMISSION_SENSORS=1',

          ## dart: PermissionGroup.bluetooth
          'PERMISSION_BLUETOOTH=1',

          # add additional permission groups if required
        ]
        # END OF WHAT YOU SHOULD ADD
      end
    end
  end
Example Applications

To try out the plugin, it is best to have a look at one of the following examples implemented in the Example app:

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
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
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
Object Transformation Gestures Same as Objects & Anchors on Planes example, but objects can be panned and rotated using gestures after being placed Objects & Anchors on Planes Code
Screenshots Same as Objects & Anchors on Planes Example, but the snapshot function is used to take screenshots of the AR Scene Screenshots Code
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 Cloud Anchors Code
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. 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

Contributing

Contributions to this plugin are very welcome. To contribute code and discuss ideas, create a pull request, open an issue, or start a discussion.

Plugin Architecture

This is a rough sketch of the architecture the plugin implements:

ar_plugin_architecture

所属分类

依赖

依赖清单 4 项

源码仓库

使用此插件的项目