Javafx 3D Transparency not working zero alpha

103 Views Asked by At

If I use the following material, I get some transparency which is fine:

PhongMaterial material = new PhongMaterial(new Color(0.5, 0, 0, 0.5));

But I can never get fully transparent mesh. For example, I expect the material below to be fully invisible but it's still visible:

PhongMaterial material = new PhongMaterial(new Color(0.5, 0, 0, 0));

Is this a bug?

enter image description here

Code:

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Box;
import javafx.stage.Stage;

public class Hello extends Application {
    public void start(Stage stage) throws Exception {
        PhongMaterial material = new PhongMaterial(new Color(0.5, 0, 0, 0));
        Box box = new Box(1, 1, 1);
        box.setMaterial(material);
        box.setTranslateZ(10);

        Scene scene = new Scene(new Group(box), 100, 100);
        scene.setFill(Color.BLACK);
        scene.setCamera(new PerspectiveCamera(true));

        stage.setScene(scene);
        stage.show();
    }
}
0

There are 0 best solutions below