Big models in JME3 cause too much lag when attached to the root node

I am developing an FPS game in the latest version on jMonkey. The map is a 3ds file the I converted to a j3o (obviously). However, this model is so big (in file and physical size) that when I attach it to the root node (basically load it) it causes so much lag that I can’t play the game as there is 0 Frames.
I have looked on other forums and topics, and they say things like “split it up into chunks” and “attach it outside of the main loop”. I am fairley new to jMonkey so I am nt sure how to do this. Any help would be appretiated.
My scource code:

package com.jacob.FPS;

import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;

public class model extends SimpleApplication {

public static void main(String[] args) {
    model app = new model();
    //app.setDisplayFps(false); //yes we do want it

public void simpleInitApp() {
    viewPort.setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f));

    Spatial model = assetManager.loadModel("Models/CODMapShipment/Map.j3o");

public void simpleUpdate(float tpf) {
    //TODO: add update code

public void simpleRender(RenderManager rm) {
    //TODO: add render code


At some point the mesh and textures have to be uploaded to the GPU. That happens when the model is actually rendered and happens in the update loop. You can load the model into the CPU memory outside the update loop (simply on another thread, read up on java threading) but as soon as the model has to be rendered (i.e. its in the frustum) the data gets uploaded to the GPU and you’ll get this “lag” (which is technically the wrong word for this).

One way to circumvent this is simply attaching the model at the beginning of the game and set its cullhint to never, then let one frame be rendered. After that you can detach the model and attach it later without interruptions.

1 Like

Thanks for your reply @normen I will test this now.
EDIT: I have looked a cullhints, would cullhint.dynamic make a difference?

The point of setting the cullhint to never in my example is to force the GPU to render the object no matter if its visible (i.e. in the frustum) or not. Only do that for that first frame, then set it back to inherit.

Thanks again the cullhint.never worked for me. If only I knew it was that simple.

…out of curiosity…how big is that 3ds file?? I mean, how big can be if 3ds file format is limited to 65,536 vertices and faces, which is something JME can easy handle without hickups…

I have another problem now, when I get close to the model, the corners are cut off (not rendered) so you can only really see it from far away.

The file is 7,500 KBs

I found a solution its using setFrustum();

Looks like your whole size relations are a bit whacked, shouldn’t really be necessary to change the frustum.

This is the reason I used frustum because the model was clipping (right word?) when I got near it.
is there an other way to achieve this?
I used this method:
However everything appears to be really thin.

EDIT: I suppose I should start a new topic for this…

Get your size relations in order? It sounds like your model is representing something huge but is tiny in terms of world units.

How would I go about finding the realationship between them?
Also how to change the ratio to make it more similar

Idk, look in blender how many units the object is? Put a 1x1x1 box next to it? Just scale it up?

OK, but is that going to help me with the “clipping” issue?

Think about it. Imagine you are wearing glasses. The position of your glasses is where stuff clips (near frustum). Now you have a 1x1x1 cm model of a house and want to put it so close to your eyes that it looks like a real house - you’ll end up bumping into your glasses with the model. Now you have a real house - will it bump into the glasses when it looks like its real size?

1 Like

So what your saying is that I basically need to make my model scale closer to the world units scale. so the ratio is the same. Thanks (I hope that doesnt sound sarcastic)