Search code examples
androidsceneform

Where to place .glb file and how get path to it in android?


I'm trying to set up ARCore scene with Sceneform. There are this piece of code:

(supportFragmentManager.findFragmentById(R.id.single_player_ar_fragment) as ArFragment)
            .setOnTapPlaneGlbModel(link)

It loads 3d-model with .glb extension by link, which is String. I can't understand where to put .glb file and how get a path to it. I tried to put it in assets or res folders, but in 2 hours i couldn't find how to get String path to it.

I know that these folders have open() methods, which returns InputStream, but setOnTapPlaneGlbModel() needs String with a path as an argument.


Solution

  • I had assumed that the files are in the same location as the sample: https://github.com/SceneView/sceneform-android/tree/master/samples/3d-model-viewer/src/main/assets/models

    Based on comment thread:

    setOnTapPlaneGlbModel(Uri.parse(link).toString()) seems to resolve to the correct asset location and fix the issue.

    References: https://github.com/SceneView/sceneform-android/blob/master/samples/3d-model-viewer/src/main/java/com/google/ar/sceneform/samples/sceneviewbackground/MainActivity.java