// => ignore the JTree selection of the whole shape in this example
if (!(parameter instanceof PickResult)) return;
PickResult result = (PickResult)parameter;
result.setFirstIntersectOnly(true);
PickIntersection pi = result.getIntersection(0);
// indices of the picked triangle
// should always be triangle at this point
// Indices are set to vertex indices, as this is not an Index Geometry object
int[] idx = pi.getPrimitiveColorIndices();
FloatBuffer colors = (FloatBuffer)(pi.getGeometryArray()).getColorRefBuffer().getBuffer();
float[] color = new float[3];
// The index returned by this method is relative the the array returned above,
// not the shape geometry array!
int closest = pi.getClosestVertexIndex();
// This method is called both when highlighting the shape and when de-selecting it
// => handles both, so as to restore the original colors
// Tip : try to hold CTRL while picking elements, for multiple selection
// => this method is called exactly once for each element state change