import javafx.application.Application; import javafx.application.Launcher; import javafx.scene.Group; import javafx.scene.PerspectiveCamera; import javafx.scene.Scene; import javafx.scene.effect.DropShadow; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.scene.transform.Rotate; import javafx.scene.transform.Translate; import javafx.stage.Stage; /** * @author cyang */ public class EffectOnGroup extends Application { @Override public void start(Stage stage) { stage.setTitle("Effect On Group with Z-Buffer On"); Scene scene = new Scene(new Group(), 500, 500); scene.setFill(Color.GRAY); scene.setCamera(new PerspectiveCamera()); System.out.println("Draw order (back to front): RED, GREEN, BLUE"); System.out.println("Z order (back to front): BLUE, RED, GREEN"); DropShadow dropshadow = new DropShadow(); dropshadow.setOffsetY(1.0); Rectangle red = new Rectangle(10, 10, 100, 100); red.setFill(Color.RED); red.setTranslateZ(2); Rectangle green = new Rectangle(50, 20, 100, 100); green.setFill(Color.GREEN); green.setTranslateZ(1); Rectangle blue = new Rectangle(20, 50, 100, 100); blue.setFill(Color.BLUE); blue.setTranslateZ(3); Group group = new Group(); group.getChildren().addAll(red, green, blue); group.setEffect(dropshadow); // To reproduce the bug comment out the 2 lines below: // group.setRotationAxis(Rotate.Y_AXIS); // group.setRotate(-20); ((Group)scene.getRoot()).getChildren().addAll(group); stage.setScene(scene); stage.setVisible(true); } public static void main(String[] args) { Launcher.launch(EffectOnGroup.class, args); } static { // TODO: temp until Z-buffer API is available System.setProperty("prism.depthtest", "true"); } }