import javafx.animation.Interpolator; import javafx.animation.RotateTransition; import javafx.animation.Timeline; import javafx.application.Application; import javafx.geometry.Point3D; import javafx.scene.AmbientLight; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.Box; import javafx.stage.Stage; import javafx.util.Duration; public class Bug3D extends Application { public static final float D = 200; @Override public void start(Stage primaryStage) throws Exception { PhongMaterial material = new PhongMaterial(Color.RED); Box box = new Box(0, D, 0); box.setMaterial(material); // box.setCullFace(CullFace.NONE); box.setTranslateX(200); box.setTranslateY(200); box.setTranslateZ(150); RotateTransition rotTrans = new RotateTransition(Duration.seconds(35), box); rotTrans.setAutoReverse(true); rotTrans.setAxis(new Point3D(2, 1, 0).normalize()); rotTrans.setInterpolator(Interpolator.EASE_BOTH); rotTrans.setCycleCount(Timeline.INDEFINITE); rotTrans.setByAngle(360); // rotTrans.play(); AmbientLight ambientLight = new AmbientLight(Color.YELLOW); Group root = new Group(); root.getChildren().add(box); root.getChildren().add(ambientLight); Scene scene = new Scene(root, 800, 1000); primaryStage.setScene(scene); primaryStage.show(); } /** * Java main for when running without JavaFX launcher */ public static void main(String[] args) { System.setProperty("prism.dirtyopts", "false"); launch(args); } }