WidgetViewport Camera Frustum

I have a SimpleGame that loads a large dimensioned terrain & skydome. To get the terrain & sky dome to be visible I had to set the camera frustum as follows:

_cam.setFrustum(1000.0f,4000000.0f,-500.0f, 500.0f, 500.0f, -500.0f);

I am now trying to get this same terrain & skydome into a WidgetViewport, but all I see is the black background. Setting the camera frustum does not seem to have any effect. I can get them to show up by scaling them way down:

Model terrain = new MilkshapeASCIIModel("Terrain");

terrain.load("…/models/terrain.txt", "…/textures");


Model dome = new MilkshapeASCIIModel("SkyDome");

dome.load("…/models/dome.txt", "…/textures");


Here is how my camera controller is being set up for the WidgetViewport Scene:

protected WidgetViewportCameraController initNewCameraController() {

Camera camera = DisplaySystem.getDisplaySystem().getRenderer().getCamera(1, 1);

//camera.setFrustum(1.0f,1000.0f,-0.55f, 0.55f, 04125f, -0.4125f);

camera.setFrustum(1000.0f,4000000.0f,-500.0f, 500.0f, 500.0f, -500.0f);

Vector3f loc = new Vector3f(0.0f, 0.0f, 20000f);

Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);

Vector3f up = new Vector3f(0.0f, 0.0f, -1.0f);

Vector3f dir = new Vector3f(0.0f, 1.0f, 0.0f);

camera.setFrame(loc, left, up, dir);

WidgetViewportCameraController cameraController =

new WidgetViewportCameraController(camera, null);

return cameraController;


Any ideas as to why my WidgetViewport camera frustum is not behaving as in the simple case?


(I hate to hijack this topic, but just a small note: we recommend that you use VariableTimestepGame instead of SimpleGame. Instead of requiring you to keep track of the delta time for each update, it is instead passed to the update(float) method as the deltaTime parameter.

Depending on your situation, the other game templates in the com.jme.app package might be more useful - check out the JavaDocs/source for more information.)

As for your actual question, I really can’t say. WidgetViewportCameraController is not much more than a wrapper binding a Camera and an AbstractInputHandler. Gregg will be able to say more.


If you can send me your code I’ll take a look at it. I’m not a camera expert so I can’t really tell without experimenting with the code.



The quickest way would be to create a class that extends WidgetViewport and override the setCameraFrustum method.

However, it appears that I need to come up with a more flexible approach for handling this.


You have to set the frustum at the end of your initialization and don’t call updateChildrenViewports() after that.

It’s so easy to lose your own settings (one of many “features” in the GUI library :wink: ).