GeometryBatchFactory not work correctly with GuiNode

Hello everybody.
Can someone explain to me why the use GeometryBatchFactory on GuiNode disappears BitmapText.

package mygame;

import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Node;
import com.jme3.texture.Texture2D;
import com.jme3.ui.Picture;
import jme3tools.optimize.GeometryBatchFactory;

public class Main extends SimpleApplication {

public Node node_1;

public static void main(String[] args) {
    Main app = new Main();

public void simpleInitApp() {

node_1 = new Node();
BitmapFont font = assetManager.loadFont("Interface/Fonts/Default.fnt");


Picture logo = new Picture("logo");
Texture2D logo_t = (Texture2D) assetManager.loadTexture("Common/MatDefs/SSAO/Textures/random.png");
float w_temp = logo_t.getImage().getWidth();
float h_temp = logo_t.getImage().getHeight();

logo.setTexture(assetManager, logo_t, true);

logo.setLocalTranslation(100, 100, 0);



for (int z = 0; z < 9; z++) {

BitmapText helloText = new BitmapText(font);
helloText.setText("Hello World " + z);
helloText.setLocalTranslation(300, 100+helloText.getLineHeight()*z*1.1f, 0);



// If uncomment - text not show !!!
// GeometryBatchFactory.optimize(node_1);


inputManager.addMapping("batch", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(new ActionListener() {

public void onAction(String name, boolean isPressed, float tpf) {

if (isPressed && name.equals("batch")) {


}, "batch");




When optimizing unit by pressing the space bar - it works. Why ???

You are only adding a few objects to the guinode, as such, batching is unlikely to give you any noticable, if even actual, performance gains. Therefore, I recommend just removing the GeometryBatchFactory. Also, I think that when you are triggering it via the input there is a good chance that it is actually doing nothing for some reason or another – it wasn’t designed to be used on spatials already attacked to the scenegraph.

Also, you should only really use GeometryBatchFactory if you have a very large number of geometries with the same material that don’t change position. I can’t think of any scenarios where it makes sense to use it in the gui node.

I think batch optimizing the gui makes sense depending on the gui. This being said, it’s important to not batch the parts that move or change, which is why I made a batch optimize that discriminates between what needs to be optimized and what doesn’t.

This being said, I wouldn’t focus on that early on.

Before the BitmapText is rendered the first time, I don’t think it actually has a mesh. So when you batch it before rendering it then it batches nothing.

Batching BitmapText is kind of a strange thing to do anyway as it’s usually not that static. And given that it doesn’t actually update its mesh until the end of the update loop, it’s hard to batch it consistently anyway.


Thank you for your response. In fact, I have two units , each of which has about 50 facilities. The first node optimized properly , and the second all the objects disappeared . So I wanted to write an example where I would have understood how the GeometryBatchFactory for GuiNode.