sceneform-android-sdk
sceneform-android-sdk copied to clipboard
Build Scene - No visualization
Hello everyone.
I'm trying to use the SceneView feature, without ARCore in a ARFragment.
Here is my java activity code:
public class TestActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sceneview);
ModelRenderable.builder()
.setSource(this, R.raw.andy)
.build()
.thenAccept(renderable -> {
SceneView sceneView = findViewById(R.id.scene_view);
sceneView.setBackgroundColor(Color.LTGRAY);
Scene scene = sceneView.getScene();
Node node = new Node();
node.setParent(scene);
node.setName("Andy");
node.setRenderable(renderable);
})
.exceptionally(
throwable -> {
Toast toast =
Toast.makeText(this, "Unable to load andy renderable", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return null;
});
}
}
And here is my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TestActivity">
<com.google.ar.sceneform.SceneView
android:id="@+id/scene_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
With this sample codes I'm just got black screen on my device, even changing the BG to Color.LTGRAY.
Am I doing something wrong?
Try calling sceneView.pause() and sceneView.resume() in the Activity's onPause and onResume respectively.
Also, instead of scaling the node to (50, 50, 50), try setting the position of the node to (0, 0, -1).
@dsternfeld7 Thanks, it's works fine. Regards.