Closed jingxuan98 closed 3 years ago
As a part of ongoing efforts to maintain ARCore repositories, I’m closing this issue as stale. If this is still an issue, you can use the newly open-sourced Sceneform SDK sources to try to diagnose the problem, or find a community-reared fork in which the issue has been addressed.
Guys, I am working on an AR app which enables the user to upload tthe model they downloaded in their phone local storage and place it on AR with Android AR Core.
In order to render in runtime, I use .gItf.
I was planning let the user to upload the file in the first activity and pass the Uri to the second activity to render and put it in AR
However, there is a problem which i wasn't able to load the model by using its Uri. I been searching online for hours but seems no answer for it
Any solutions?
My ModelRendereable code
ModelRenderable.builder() .setSource(arFragment.getContext(), RenderableSource.builder().setSource( this, Uri.parse(GLTF_ASSET), RenderableSource.SourceType.GLTF2) .setScale(0.5f) // Scale the original model to 50%. .setRecenterMode(RenderableSource.RecenterMode.ROOT) .build() ) .setRegistryId(GLTF_ASSET) .build().thenAccept(renderable -> addNodeToScene(arFragment, anchor, renderable) ) .exceptionally( throwable -> { Toast.makeText(this,"Unable to load cat model", Toast.LENGTH_SHORT).show(); System.out.println(GLTF_ASSET); return null; } );
How I let the user select from internal storage ` @Override public void onClick(View v) {
`
` Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
`
How I pass the Uri to second activity
Intent intent = new Intent(MainActivity.this, Activity2.class); intent.putExtra("Uri",uriList.get(0).toString()); startActivity(intent);
How I get the Uri from the first activity
GLTF_ASSET = intent.getStringExtra("Uri");