I\'m looking for a way to render a transparent object in JavaFX 3D. So far, nothing. I found issue https://bugs.openjdk.java.net/browse/JDK-8090548. Is there a workaround
Here's a partial solution. To add transparency to a sphere with the image of the earth texture mapped to it, set both a diffuseMap and a diffuseColor:
private void makeEarth() {
PhongMaterial earthMaterial = new PhongMaterial();
Image earthImage = new Image("file:imgs/earth.jpg");
earthMaterial.setDiffuseMap(earthImage);
earthMaterial.setDiffuseColor(new Color(1,1,1,0.6)); // Note alpha of 0.6
earthMaterial.diffuseMapProperty();
earth=createSphere(0,0,0,300,earthMaterial);
earthMaterial.setSpecularColor(Color.INDIANRED);
earth.setRotationAxis(Rotate.Y_AXIS);
world.getChildren().add(earth);
}
This works only to allow the background image of the scene (set by scene.setFill(starFieldImagePattern);) to show through. It doesn't yet work for allowing other shapes to show through.
Apparently, the reason this works is that the diffuse color is multiplied by the diffuseMap color when calculating the color of the pixels. See https://docs.oracle.com/javase/8/javafx/api/javafx/scene/paint/PhongMaterial.html .