Rendering large numbers of identical objects efficients (SharedMesh?)

I’m trying to render a large number of identical objects which may move/be removed/added. However I’m experiencing very poor performance with large numbers of objects. My simplest code is below (obviously I don’t actually want to create one massive box out of many smaller ones, this is just an example).

From what I have read I need to change to using a sharedmesh, but I’ve not been able to find any example code using it. Additionally its import seems to have changed between jme2 and jme3, import com.jme3.scene.SharedMesh; doesn’t seem to work. Has SharedMesh been replaced by something else?



import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.material.Material;

import com.jme3.scene.*;

import com.jme3.scene.shape.Box;

public class Simplest extends SimpleApplication{

public static void main(String[] args) {

Simplest app = new Simplest();



public void simpleInitApp() {

viewPort.setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f));

cam.setLocation(new Vector3f(0f,0,50f));



private void setUpBlocks(){

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

mat.setColor(“Color”, ColorRGBA.Blue);

Box b = new Box(Vector3f.ZERO, 1, 1, 1);

for(int i=0;i<30;i++){

for(int j=0;j<30;j++){

for(int k=0;k<30;k++){

Geometry geometry = new Geometry(“blue cube”, b);


Node translationNode=new Node();









Thanks for any help you can offer

The object count is what is driving down the fps, not the meshes. use the GeometryBatchFactory or BatchNode depending on your needs. And please read the documentation, it contains lots of information like this.

Thanks for your very quick (and useful) reply. I had previously read the documentation on GeometryBatchFactory ( but had discounted it because it was stated that GeometryBatchFactory is only appropriate for static Geometry. However BatchNode sounds like exactly what I need and I will now try to incorperate that.

The fact that your making a lot of boxes, and then want to add/remove some of them, suggests to me that your trying to make some sort of “minecraft” clone (box world), if so search for voxels

And if you hover over “box world” above… you see the appropriate advice: “Box worlds are not made of boxes.”

Making a minecraft “clone” might be a bit beyond me at this point, but this voxel approach is certainly very interesting.

For anyone finding this on google this is an interesting page on voxels in jMonkey: