import javafx.animation.Interpolator; import javafx.animation.RotateTransition; import javafx.animation.Timeline; import javafx.application.Application; import javafx.event.EventHandler; import javafx.geometry.Point3D; import javafx.scene.AmbientLight; import javafx.scene.Group; import javafx.scene.PerspectiveCamera; import javafx.scene.PointLight; import javafx.scene.Scene; import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.Sphere; import javafx.stage.Stage; import javafx.util.Duration; public class Bug extends Application { @Override public void start(Stage primaryStage) throws Exception { Color diffuseColor = Color.ORANGE; Color specularLight = Color.rgb(55, 55, 55); PhongMaterial material = new PhongMaterial(diffuseColor, null, null, null, null); material.setSpecularColor(specularLight); Sphere sphere = new Sphere(200); sphere.setMaterial(material); sphere.setLayoutX(300); sphere.setLayoutY(300); AmbientLight ambientLight = new AmbientLight(); ambientLight.setColor(Color.rgb(255, 255, 255, 0.15)); PointLight pointLight = new PointLight(); pointLight.setColor(Color.WHITE); pointLight.setLayoutX(200); pointLight.setLayoutY(-100); pointLight.setTranslateZ(-1100); pointLight.getScope().add(sphere); Group content = new Group(); content.getChildren().addAll(sphere, pointLight, ambientLight); Scene scene = new Scene(content, 600, 600); scene.setFill(Color.BLACK); PerspectiveCamera camera = new PerspectiveCamera(false); scene.setCamera(camera); scene.setOnMousePressed(new EventHandler() { @Override public void handle(MouseEvent event) { System.err.println(event.getPickResult().getIntersectedTexCoord()); } }); primaryStage.setTitle("3D World"); primaryStage.setScene(scene); primaryStage.show(); RotateTransition rotateTransition = new RotateTransition(); rotateTransition.setAxis(new Point3D(0, 1, 0)); rotateTransition.setDuration(Duration.seconds(10)); rotateTransition.setByAngle(360); rotateTransition.setCycleCount(Timeline.INDEFINITE); rotateTransition.setInterpolator(Interpolator.LINEAR); rotateTransition.setNode(sphere); rotateTransition.play(); primaryStage.show(); } public static void main(String[] args) { // System.setProperty("prism.dirtyopts", "false"); launch(args); } }