@Override
    public void simpleUpdate(float tpf) {
        /*
         * In Radians per second
         */
        final float ROT_SPEED = FastMath.PI / 2;
        /*
         * 360 degree rotation
         */
        final float FULL_ROT = FastMath.PI * 2;

        TempVars vars = TempVars.get();
        Vector3f lightDirection = vars.vect2, nodeDirection = vars.vect3;
        float length;

        angles[0] += rotAxis.x * ROT_SPEED * tpf;
        angles[1] += rotAxis.y * ROT_SPEED * tpf;
        angles[2] += rotAxis.z * ROT_SPEED * tpf;
        lightNode.setLocalRotation(new Quaternion().fromAngles(angles));
        super.simpleUpdate(tpf);

        /*
         * Make sure they are equal.
         */
        lightDirection.set(direction.getDirection());
        lightDirection.normalize();
        lightNode.getWorldRotation().mult(Vector3f.UNIT_Z, nodeDirection);
        nodeDirection.negateLocal().normalizeLocal();
        length = lightDirection.subtract(nodeDirection, vars.vect4).lengthSquared();
        length = FastMath.abs(length);
        if (length > .1F) {
            System.err.printf("Rotation not equal: is %s, needs to be %s (%f)\n", nodeDirection, lightDirection, length);
        }

        if (angles[0] >= FULL_ROT || angles[1] >= FULL_ROT || angles[2] >= FULL_ROT) {
            lightNode.setLocalRotation(Quaternion.DIRECTION_Z);
            angles[0] = 0;
            angles[1] = 0;
            angles[2] = 0;
            if (rotAxis.x > 0 && rotAxis.y == 0 && rotAxis.z == 0) {
                rotAxis.set(0, 1, 0);
            } else if (rotAxis.y > 0 && rotAxis.x == 0 && rotAxis.z == 0) {
                rotAxis.set(0, 0, 1);
            } else if (rotAxis.z > 0 && rotAxis.x == 0 && rotAxis.y == 0) {
                rotAxis.set(FastMath.nextRandomFloat() % 1, FastMath.nextRandomFloat() % 1, FastMath.nextRandomFloat() % 1);
            } else {
                rotAxis.set(1, 0, 0);
            }
        }

        vars.release();
    }
Creates a directional light controlled by rotating a node. The light will shine on a surrounding sphere.
The light will rotate on each axis, then on a random axis, then return to the X
axis.

@author Markil 3
jme3-examples/src/main/java/jme3test/light/TestLightControlDirectional.java