augmented-realityarcoresceneform

How do I put custom image on 3D Sphere in ARCore


The following is my code for building a 3D Earth and showing it:

com.google.ar.sceneform.rendering.Texture.Builder builder= com.google.ar.sceneform.rendering.Texture.builder();
builder.setSource(context,R.drawable.earth);
builder.build().thenAccept(texture ->
        MaterialFactory.makeOpaqueWithTexture(context, texture).
                thenAccept(material -> {
                  earthSphereRenderable =
                          ShapeFactory.makeSphere(0.1f, new Vector3(0.0f, 0.0f, 0.0f), material);
                  Toast.makeText(context,"All done",Toast.LENGTH_SHORT).show();})
);

The Toast message is coming but I am not able to see any object. Please note that R.drawable.earth is the Earth.jpg file that I put in there, which I want to show in AR.

Here is where I am rendering it

cornerNode = new Node();
    cornerNode.setParent(this);
    cornerNode.setLocalPosition(localPosition);
    cornerNode.setRenderable(earthSphereRenderable);

Moreover, if I replace makeOpaqueWithTexture with makeOpaqueWithColor and but color as Red then the whole thing is working fine (i.e. I can see the sphere)

What must I change here in order to be able to see the sphere with Earth's texture on it?


Solution

  • Ok, I got the answer to this. It does not accept jpg files but it accepts png files. Weird stuff!