@Test
    public void testSpotFiltering() {
        SpotLight sl = new SpotLight(Vector3f.ZERO, Vector3f.UNIT_Z);
        sl.setSpotRange(0);
        geom.addLight(sl);
        checkFilteredLights(1); // Infinite spot lights are only filtered
                                // if the geometry is outside the infinite cone.
        
        TempVars vars = TempVars.get();
        try {
            // The spot is not touching the near plane of the camera yet, 
            // should still be culled.
            sl.setSpotRange(1f - FastMath.ZERO_TOLERANCE);
            assert !sl.intersectsFrustum(cam, vars);
            // should be culled from the geometry's PoV
            checkFilteredLights(0);
            
            // Now it touches the near plane.
            sl.setSpotRange(1f);
            // still culled from the geometry's PoV
            checkFilteredLights(0);
            assert sl.intersectsFrustum(cam, vars);
        } finally {
            vars.release();
        }
        
        // make it barely reach the geometry
        sl.setSpotRange(9f);
        checkFilteredLights(0);
        
        // make it reach the geometry (touching its bound)
        sl.setSpotRange(9f + FastMath.ZERO_TOLERANCE);
        checkFilteredLights(1);
        
        // rotate the cone a bit so it no longer faces the geom
        sl.setDirection(new Vector3f(0.316f, 0, 0.948f).normalizeLocal());
        checkFilteredLights(0);
        
        // extent the range much farther
        sl.setSpotRange(20);
        checkFilteredLights(0);
        
        // Create box of size X=10 (double the extent)
        // now, the spot will touch the box.
        geom.setMesh(new Box(5, 1, 1));
        checkFilteredLights(1);
        
        // ==================================
        // Tests for bounding sphere, with a radius of 1f (in the box geom)
        sl.setPosition(Vector3f.ZERO);
        sl.setDirection(Vector3f.UNIT_Z);
        geom.setLocalTranslation(Vector3f.ZERO);
        geom.setModelBound(new BoundingSphere(1f, Vector3f.ZERO));
       
        // Infinite spot lights are only filtered
        // if the geometry is outside the infinite cone.
        sl.setSpotRange(0);
        checkFilteredLights(1);
       
        //the geometry is outside the infinite cone (cone direction going away from the geom)
        sl.setPosition(Vector3f.UNIT_Z.mult(1+FastMath.ZERO_TOLERANCE));
        checkFilteredLights(0);
       
        //place the spot light in the corner of the box geom, (in order to test bounding sphere)
        sl.setDirection(new Vector3f(1, 1, 0).normalizeLocal());
        geom.setLocalTranslation(0, 0, 10);
        sl.setPosition(sl.getDirection().mult(-2f).add(geom.getLocalTranslation()));

        // make it barely reach the sphere, incorrect with a box
        sl.setSpotRange(1f - FastMath.ZERO_TOLERANCE);
        checkFilteredLights(0);
       
        // make it reach the sphere
        sl.setSpotRange(1f + FastMath.ZERO_TOLERANCE);
        checkFilteredLights(1);
       
        // extend the range
        sl.setPosition(Vector3f.ZERO);
        sl.setDirection(Vector3f.UNIT_Z);
        sl.setSpotRange(20);
        checkFilteredLights(1);
               
        // rotate the cone a bit so it no longer faces the geom
        sl.setDirection(new Vector3f(0, 0.3f, 0.7f).normalizeLocal());
        checkFilteredLights(0);
       
        // Create sphere of size X=10 (double the radius)
        // now, the spot will touch the sphere.
        geom.setModelBound(new BoundingSphere(5f, Vector3f.ZERO));
        checkFilteredLights(1);
    }
Test light filtering for various light types.

@author Kirill Vainer
jme3-core/src/test/java/com/jme3/light/LightFilterTest.java