@Override
    public void setSpatial(Spatial spatial) {
        if (spatial != null && !(spatial instanceof Geometry)) {
            throw new IllegalArgumentException("LodControl can only be attached to Geometry!");
        }

        super.setSpatial(spatial);
        
        if(spatial != null) {
            Geometry geom = (Geometry) spatial;
            Mesh mesh = geom.getMesh();
            numLevels = mesh.getNumLodLevels();
            numTris = new int[numLevels];
            for (int i = numLevels - 1; i >= 0; i--) {
                numTris[i] = mesh.getTriangleCount(i);
            }
        } else {
            numLevels = 0;
            numTris = null;
        }
    }
Sets the triangles per pixel value. The
<code>LodControl</code> will use this value as an error metric to
determine which LOD level to use based on the geometry's area on the
screen.

@param trisPerPixel triangles per pixel
jme3-core/src/main/java/com/jme3/scene/control/LodControl.java