【问题标题】:How to generate a Sceneform asset at runtime in flutter如何在 Flutter 中运行时生成 Sceneform 资源
【发布时间】:2021-08-02 02:19:37
【问题描述】:

我是 Flutter 新手,目前正在开发基于 AR 的应用程序。我想在 RUNTIME 创建可渲染的 3d Sceneform 资产。我知道如何在 build.gradle 文件中定义 Sceneform 资产,但这不是动态的。

编译中制作3d场景资源的方式(app级build.gradle):

sceneform.asset('sampledata/earth.obj',
        'default',
        'sampledata/earth.sfa',
        'src/main/assets/earth_model')

但我想在运行时创建一个场景形式资产。我正在使用arcore_flutter_plugin 和 Google 的 AR 核心与场景形式。我无法找到任何帮助/示例来在运行时从 Flutter 中的 firebase 存储渲染 3d 场景形式资产。所有可用的文档都适用于 java 和 kotlin。在运行时渲染场景资源的目的是从firebase storage加载一个.sfb文件并在应用中渲染,以保持应用的轻量级。

【问题讨论】:

    标签: android flutter arcore sceneform 3d-model


    【解决方案1】:

    如果您深入研究文档文档,您会发现带有参数 objectUrl 的类 ArCoreReferenceNode https://pub.dev/documentation/arcore_flutter_plugin/latest/arcore_flutter_plugin/ArCoreReferenceNode/objectUrl.html.

    我将取自example app code

    final toucanNode = ArCoreReferenceNode(
        name: "Toucano",
        objectUrl:
                "https://github.com/KhronosGroup/glTF-Sample-Models/raw/master/2.0/Duck/glTF/Duck.gltf",
        position: plane.pose.translation,
        rotation: plane.pose.rotation,
    );
    
    arCoreController.addArCoreNodeWithAnchor(toucanNode);
    

    【讨论】:

    • 兄弟,谢谢它的工作,现在有什么服务可以用来托管 .gltf 文件。最初的思考过程是从 firebase 存储中下载 .obj,但您的回答让它变得更容易了。
    • 这取决于您对存储和带宽的需求。但是 netlify.com 对我来说已经足够好了。它可以直接从你的 git 部署 :) 有时我将它部署在 github gh 页面上
    • 顺便说一句,有没有办法可以在 arcore 中扫描和渲染?看看这个视频就明白了,youtube.com/watch?v=SWzurBQ81CM你也是android ville的兄弟吗?
    • 以前不要尝试,也许有一天。顺便说一句,我也不是来自 android ville
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 1970-01-01
    • 1970-01-01
    • 2020-01-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多