Java Reference
In-Depth Information
insert group into exampleGroup.content;;
In this example, a rectangle is created called rect1 , which then has a PointLight applied to it. The
PointLight has its location bound to the variables x, y, and z . Note that where the y location of the
PointLight is set, there's a line of commented-out code above it. At the time of this writing, there is a bug
in JavaFX 1.2 that causes PointLight and SpotLight to show up in a weird location.
The rectangle and a circle called dot are included in a group . The dot's coordinates are also bound to
the values x and y ; the dot's scale is bound to the z value. In this way, as the animation moves the light
around, the dot will move with it to indicate its location. The dot will also grow in size as the z value
increases, as if it is getting closer to the viewer.
The animation simply starts by setting the x , y, and z values to 0.0, which is the upper left corner of
the rectangle. The animation then moves the PointLight to the center of the rectangle where it increases
the z value of the PointLight . As the z value increases, the amount of the rectangle that is illuminated
Platform Issue
There is a bug in JavaFX that can cause the light to appear in the wrong location. This may be more of an
issue for OS X users. Please see JavaFX bug RT-5579.
Spot Light Example
A spot light is much like a point light when its location and target are on the same z axis, but when a
SpotLight is aimed at a point that is not directly under it, the cone of light emitted becomes obvious as it
is projected across a surface.
Search WWH ::

Custom Search