I want pick GLB file from phone sdcard then with file address or uri, show 3D model in my app. I tried sceneform-android java code as said this link:
https://github.com/SceneView/sceneform-android/blob/master/samples/3d-model-viewer/src/main/java/com/google/ar/sceneform/samples/sceneviewbackground/MainActivity.java
So I tried this code in mainactivity:
public void loadModels(Uri uri) {
CompletableFuture<ModelRenderable> dragon = ModelRenderable
.builder()
.setSource(this
,Uri.parse("https://storage.googleapis.com/ar-answers-in-search-models/static/Tiger/model.glb"))
.setIsFilamentGltf(true)
.setAsyncLoadEnabled(true)
.build();
CompletableFuture.allOf(dragon, backdrop)
.handle((ok, ex) -> {
try {
Node modelNode1 = new Node();
modelNode1.setRenderable(dragon.get());
modelNode1.setLocalScale(new Vector3(0.3f, 0.3f, 0.3f));
modelNode1.setLocalRotation(Quaternion.multiply(
Quaternion.axisAngle(new Vector3(1f, 0f, 0f), 45),
Quaternion.axisAngle(new Vector3(0f, 1f, 0f), 75)));
modelNode1.setLocalPosition(new Vector3(0f, 0f, -1.0f));
backgroundSceneView.getScene().addChild(modelNode1);
Node modelNode3 = new Node();
modelNode3.setRenderable(dragon.get());
modelNode3.setLocalScale(new Vector3(0.3f, 0.3f, 0.3f));
modelNode3.setLocalRotation(Quaternion.axisAngle(new Vector3(0f, 1f, 0f), 35));
modelNode3.setLocalPosition(new Vector3(0f, 0f, -1.0f));
transparentSceneView.getScene().addChild(modelNode3);
} catch (InterruptedException | ExecutionException ignore) {
Toast.makeText(this, "ERROR!!!!!!!!!!", Toast.LENGTH_SHORT).show();
}
return null;
});
}
and in layout file:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="550dp"
android:orientation="vertical">
<com.google.ar.sceneform.SceneView
android:id="@+id/backgroundSceneView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_weight="1"
android:background="#FF0000FF" />
<com.google.ar.sceneform.SceneView
android:id="@+id/transparentSceneView"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_weight="1"
android:background="@android:color/transparent"/>
</LinearLayout>
I faced to any error but noting displayed. Please help!. What is the problem?