I have created a for loop that randomly spawns trees

[java]

treeModel = (Spatial) assetManager.loadModel(“Models/Trees/Tree.j3o”);

material = assetManager.loadMaterial(“Models/Trees/Tree.j3m”);

```
treeModel2 = (Spatial) assetManager.loadModel("Models/Trees/Tree2.j3o");
material2 = assetManager.loadMaterial("Models/Trees/Tree2.j3m");
treeModel3 = (Spatial) assetManager.loadModel("Models/Trees/Tree3.j3o");
material3 = assetManager.loadMaterial("Models/Trees/Tree3.j3m");
tree = new Node();
trees = new Spatial[51];
trees2 = new Spatial[51];
trees3 = new Spatial[51];
/*
* Randomly spawn spatials (in this case trees)
*/
for (amountOfTrees = 0; amountOfTrees < 5; amountOfTrees++) {
trees3[amountOfTrees] = treeModel3.clone();
trees3[amountOfTrees].setMaterial(material3);
trees2[amountOfTrees] = treeModel2.clone();
trees2[amountOfTrees].setMaterial(material2);
trees[amountOfTrees] = treeModel.clone();
trees[amountOfTrees].setMaterial(material);
CollisionShape treeShape =
CollisionShapeFactory.createMeshShape((Node) tree);
treePhysics = new RigidBodyControl(treeShape, 0);
trees3[amountOfTrees].addControl(treePhysics);
trees2[amountOfTrees].addControl(treePhysics);
trees[amountOfTrees].addControl(treePhysics);
trees[amountOfTrees].setLocalTranslation(random.nextInt(500) - random.nextInt(1000), -2f, random.nextInt(500) - random.nextInt(1000));
trees2[amountOfTrees].setLocalTranslation(random.nextInt(500) - random.nextInt(1000), -2f, random.nextInt(500) - random.nextInt(1000));
trees3[amountOfTrees].setLocalTranslation(random.nextInt(500) - random.nextInt(1000), -2f, random.nextInt(500) - random.nextInt(1000));
trees[amountOfTrees].setLocalScale(10f, 6f, 13f);
trees2[amountOfTrees].setLocalScale(10f, 6f, 13f);
trees3[amountOfTrees].setLocalScale(10f, 6f, 13f);
tree.attachChild(trees[amountOfTrees]);
tree.attachChild(trees2[amountOfTrees]);
tree.attachChild(trees3[amountOfTrees]);
this.app.getRootNode()
.attachChild(tree.clone());
this.bulletAppState.getPhysicsSpace()
.add(treePhysics);
GeometryBatchFactory.optimize(tree);
}
```

[/java]

For whatever number i put in the for loop for amountOfTrees its multiplied by 3 cause their are 3 spatials. Right its 5 so it spawns 15 trees.

I use GeometryBatchFactory.optimize.

Each tree is <2000 vertices. Its fine fps wise but once i go over about 120 its gets a bit laggy <40 fps. Is there any other solutions to optimize this?