0

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.

Yonshoku
  • 115
  • 1
  • 7
  • Does this answer your question? [Android read text raw resource file](https://stackoverflow.com/questions/4087674/android-read-text-raw-resource-file) – Morrison Chang Jun 05 '22 at 21:16
  • Or have you seen: https://github.com/SceneView/sceneform-android/blob/master/samples/3d-model-viewer/src/main/java/com/google/ar/sceneform/samples/sceneviewbackground/MainActivity.java – Morrison Chang Jun 05 '22 at 21:20
  • @MorrisonChang I saw the similar one. I know that i can open file from assets or res folders, but this ```setOnTapPlaneGlbMode``` needs a path which is ```String```. – Yonshoku Jun 05 '22 at 23:47
  • @MorrisonChang yes, I have seen their sample. There is a path to .glb file, but i don't know where they did place it, so I could access it like they did – Yonshoku Jun 05 '22 at 23:48
  • So putting the files under `assets/model` https://github.com/SceneView/sceneform-android/tree/master/samples/3d-model-viewer/src/main/assets/models like the same didn't work? – Morrison Chang Jun 06 '22 at 00:13
  • @MorrisonChang Yeah, I tried before... It worked now, when I put it in ```Uri.parse()``` and called ```toString()```, which I didn't try before... Thank you :) – Yonshoku Jun 06 '22 at 00:42
  • @MorrisonChang I think you could add it as answer so I would accept this – Yonshoku Jun 06 '22 at 00:42

1 Answers1

1

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

Morrison Chang
  • 11,691
  • 3
  • 41
  • 77