@Override
        public void run() {
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    int quadIdx = i * 4 + j;
                    final Vector3f quadCell = location.add(quadIndex[quadIdx]);
                    TerrainQuad q = cache.get(quadCell);
                    if (q == null) {
                        if (gridTileLoader != null) {
                            q = gridTileLoader.getTerrainQuadAt(quadCell);
                            // only clone the material to the quad if it doesn't have a material of its own
                            if(q.getMaterial()==null) q.setMaterial(material.clone());
                            log.log(Level.FINE, "Loaded TerrainQuad {0} from TerrainQuadGrid", q.getName());
                        }
                    }
                    cache.put(quadCell, q);

                    
                    final int quadrant = getQuadrant(quadIdx);
                    final TerrainQuad newQuad = q;
                    
                    if (isCenter(quadIdx)) {
                        // if it should be attached as a child right now, attach it
                        getControl(UpdateControl.class).enqueue(new Callable<Object>() {
                            // back on the OpenGL thread:
                            @Override
                            public Object call() throws Exception {
                                if (newQuad.getParent() != null) {
                                    attachQuadAt(newQuad, quadrant, quadCell, true);
                                }
                                else {
                                    attachQuadAt(newQuad, quadrant, quadCell, false);
                                }
                                return null;
                            }
                        });
                    } else {
                        getControl(UpdateControl.class).enqueue(new Callable<Object>() {
                            @Override
                            public Object call() throws Exception {
                                removeQuad(newQuad);
                                return null;
                            }
                        });
                    }
                }
            }

            getControl(UpdateControl.class).enqueue(new Callable<Object>() {
                    // back on the OpenGL thread:
                    @Override
                    public Object call() throws Exception {
                        for (Spatial s : getChildren()) {
                            if (s instanceof TerrainQuad) {
                                TerrainQuad tq = (TerrainQuad)s;
                                tq.resetCachedNeighbours();
                            }
                        }
                        System.out.println("fixed normals "+location.clone().mult(size));
                        setNeedToRecalculateNormals();
                        return null;
                    }
            });
        }
This is executed if the camera has moved into a new CameraCell and will load in
the new TerrainQuad tiles to be children of this TerrainGrid parent.
It will first check the LRU cache to see if the terrain tile is already there,
if it is not there, it will load it in and then cache that tile.
The terrain tiles get added to the quad tree back on the OGL thread using the
attachQuadAt() method. It also resets any cached values in TerrainQuad (such as
neighbours).
jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainGrid.java