I'm tinkering with the Sceneform SDK's Augmented Image sample code after I completed the accompanying code lab. The completed sample adds two types of objects to the AR scene: one is modeled with a CAD software and loaded from an sfb
binary (that's the green maze) and the other one is a red ball which is constructed run-time using the MaterialFactory
and ShapeFactory
.
A simple experiment is to remove the green maze to only have the red ball (and remove the physics engine of course as well). In that case however the red ball does not appear on the AR scene.
The interesting thing is that the green maze does not have to appear on the scene - by that I mean I don't have to create the Node
, assign renderable, etc. https://github.com/CsabaConsulting/sceneform-android-sdk/blob/master/samples/augmentedimage/app/src/main/java/com/google/ar/sceneform/samples/augmentedimage/AugmentedImageNode.java#L139:
mazeNode = new Node();
mazeNode.setParent(this);
mazeNode.setRenderable(mazeRenderable.getNow(null));
But if I take out the loading code https://github.com/CsabaConsulting/sceneform-android-sdk/blob/master/samples/augmentedimage/app/src/main/java/com/google/ar/sceneform/samples/augmentedimage/AugmentedImageNode.java#L89
mazeRenderable =
ModelRenderable.builder()
.setSource(context, Uri.parse("GreenMaze.sfb"))
.build();
and most importantly the code in the setImage
which waits until the model is fully loaded and built https://github.com/CsabaConsulting/sceneform-android-sdk/blob/master/samples/augmentedimage/app/src/main/java/com/google/ar/sceneform/samples/augmentedimage/AugmentedImageNode.java#L125
if (!mazeRenderable.isDone()) {
CompletableFuture.allOf(mazeRenderable)
.thenAccept((Void aVoid) -> setImage(image))
.exceptionally(
throwable -> {
Log.e(TAG, "Exception loading", throwable);
return null;
});
return;
}
The ball won't appear. The ball (and any other run-time constructed objects I add) won't appear if I take out this .isDone()
section above. I haven't found any indicator in the AR Session
or anywhere else which would indicate that something is not ready to work yet. In my application I may only use run-time built 3D objects, do I need an sfb
only for the sake of those appearing?