Java Reference
In-Depth Information
private double normalize(double x) {
return min(abs(x) / SPHERE_RADIUS, 1);
}
}
}
When the program in Listing 10-10 is run, the Sphere with MouseEvents window in Figure
10-13
is displayed. You
can click on or drag the mouse over the sphere to see the sphere changing color.
Figure 10-13.
The SphereWithEvents program
The program in Listing 10-11 displays a user-defined
MeshView
of a cube and contains a control panel that allows
the user to control the
z
coordinate of the cube, change the drawing mode between
DrawMode.LINE
and
DrawMode.FILL
, and shows the face number of the intersected face.
Listing 10-11.
MeshCubePickDemo.java
import javafx.application.Application;
import javafx.beans.binding.When;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.geometry.Insets;
import javafx.scene.Group;
Search WWH ::
Custom Search