public final void setMaxNumInstances(int maxNumInstances) {
        if (maxNumInstances < 1) {
            throw new IllegalArgumentException("maxNumInstances must be 1 or higher");
        }

        Geometry[] originalGeometries = geometries;
        this.geometries = new Geometry[maxNumInstances];

        if (originalGeometries != null) {
            System.arraycopy(originalGeometries, 0, geometries, 0, originalGeometries.length);
        }

        // Resize instance data.
        if (transformInstanceData != null) {
            BufferUtils.destroyDirectBuffer(transformInstanceData.getData());
            transformInstanceData.updateData(BufferUtils.createFloatBuffer(geometries.length * INSTANCE_SIZE));
        } else if (transformInstanceData == null) {
            transformInstanceData = new VertexBuffer(Type.InstanceData);
            transformInstanceData.setInstanced(true);
            transformInstanceData.setupData(Usage.Stream,
                    INSTANCE_SIZE,
                    Format.Float,
                    BufferUtils.createFloatBuffer(geometries.length * INSTANCE_SIZE));
            updateAllInstanceData();
        }
    }
Set the maximum amount of instances that can be rendered by this
instanced geometry when mode is set to auto.

This re-allocates internal structures and therefore should be called
only when necessary.

@param maxNumInstances The maximum number of instances that can be
rendered.

@throws IllegalStateException If mode is set to manual.
@throws IllegalArgumentException If maxNumInstances is zero or negative
jme3-core/src/main/java/com/jme3/scene/instancing/InstancedGeometry.java