Skydome going black

Hi, I have 2 objects in my scene, skydome and a sphere, I’ve noticed whenever sphere is not in my camera view skydome dissapears and whole scene goes black until I manage to go back and look at the sphere, any ideas how to fix it and what is causing it?

Here is the code:

[java]public class Main extends SimpleApplication {

float angle = 0;

Geometry geom;

public static void main(String[] args) {

Main app = new Main();

app.showSettings = false;

AppSettings settings = new AppSettings(true);

settings.setBitsPerPixel(24);

settings.setResolution(1024, 768);

app.setSettings(settings);

app.start();

}

private void buildSkyBox()

{

}

@Override

public void simpleInitApp() {

Spatial sky;

FilterPostProcessor fpp = new FilterPostProcessor(assetManager);

FogFilter fog = new FogFilter();

fog.setFogColor(new ColorRGBA(1.0f,1.0f,1.0f,1.0f));

fog.setFogDistance(155);

fog.setFogDensity(0.0f);

fpp.addFilter(fog);

viewPort.addProcessor(fpp);

Sphere b = new Sphere(160,160,20);

geom = new Geometry(“Sphere”, b);

Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

Texture tex_ml = assetManager.loadTexture(“earth.jpg”);

mat.setTexture(“ColorMap”, tex_ml);

geom.setMaterial(mat);

geom.rotate(280FastMath.DEG_TO_RAD, 0, 0);

sky = SkyFactory.createSky(assetManager, “outputCube.dds”,true);

rootNode.attachChild(sky);

rootNode.attachChild(geom);

}

@Override

public void simpleUpdate(float tpf) {

//TODO: add update code

geom.rotate(0,0,0.001f
FastMath.DEG_TO_RAD);

}

@Override

public void simpleRender(RenderManager rm) {

//TODO: add render code

}

}

[/java]

It happens because the root node bounding box is found to not be in the camera frustum, so everything under it is culled.



One solution to this is to attach the sky to the viewport, instead of the root node:

[java]Spatial sky = SkyFactory.createSky( … );

sky.updateGeometricState();

viewPort.attachScene(sky);

[/java]