/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package test; import javafx.application.Application; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.PerspectiveCamera; import javafx.scene.PointLight; import javafx.scene.Scene; import javafx.scene.input.KeyEvent; import javafx.scene.paint.Color; import javafx.scene.shape.Shape3D; import javafx.scene.shape.Sphere; import javafx.stage.Stage; /** * * @author Andrew Glushchenko */ public class LightAddTestApp extends Application { private static int WIDTH = 500; private static int HEIGHT = 500; private Group root; @Override public void start(Stage stage){ root = new Group(buildSingle(new Sphere(50))); root.setTranslateX(WIDTH / 2); root.setTranslateY(HEIGHT / 2); Scene scene = new Scene(root, WIDTH, HEIGHT,true); scene.setCamera(new PerspectiveCamera()); scene.setOnKeyPressed(new EventHandler() { @Override public void handle(KeyEvent t) { switch (t.getText()) { case "+": PointLight pl = new PointLight(Color.RED); pl.setTranslateX(200); root.getChildren().add(pl); break; } } }); stage.setScene(scene); stage.show(); } private Group buildSingle(Shape3D shape) { Group grp = new Group(shape); return grp; } public static void main(String[] args) { launch(args); } }