How to generate a Sceneform asset at runtime in flutter

Viewed 940

I am new to flutter and am currently developing a AR based application. I want to create renderable 3d Sceneform assets at RUNTIME. I know how to define a Sceneform asset in the build.gradle file but that isn't dynamic.

The way to make a 3d sceneform asset in the compilation(app level build.gradle):

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

But I want to create a sceneform asset during runtime. I am using arcore_flutter_plugin and Google's AR core with sceneform. I am unable to find any assistance/examples to render a 3d sceneform asset at runtime from firebase storage in flutter. All of the documentations available are for java and kotlin. The purpose of rendering sceneform assets at runtime is to load a .sfb file from firebase storage and render it in the app to keep the app lightweight.

1 Answers

If you dig deep into the documentation docs, you will find class ArCoreReferenceNode with parameter objectUrl https://pub.dev/documentation/arcore_flutter_plugin/latest/arcore_flutter_plugin/ArCoreReferenceNode/objectUrl.html.

I will take from the 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);
Related