Applying lighting effects

Lighting is a complex effect dedicated to giving an object pseudo-3D depth by imitating a light source. An algorithm finds node boundaries and graphically elevates them by shading those further from the imaginary light and lighting the closer ones:

To achieve this effect, you'll have to set the location and type of an imaginary light, which shines on the scene and is implemented as shown in the following code snippet:

// chapter8/light/LightingDemo.javapublic void start(Stage primaryStage) {    Light.Distant light = new Light.Distant();    light.setAzimuth(-135);    Lighting lighting = new Lighting(); lighting.setLight(light); ...

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.