public static ByteBuffer ensureLargeEnough(ByteBuffer buffer, int required) {
        if (buffer != null) {
            buffer.limit(buffer.capacity());
        }
        if (buffer == null || (buffer.remaining() < required)) {
            int position = (buffer != null ? buffer.position() : 0);
            ByteBuffer newVerts = createByteBuffer(position + required);
            if (buffer != null) {
                buffer.flip();
                newVerts.put(buffer);
                newVerts.position(position);
            }
            buffer = newVerts;
        }
        return buffer;
    }
Ensures there is at least the <code>required</code> number of entries
left after the current position of the buffer. If the buffer is too small
a larger one is created and the old one copied to the new buffer.

@param buffer
           buffer that should be checked/copied (may be null)
@param required
           minimum number of elements that should be remaining in the
           returned buffer
@return a buffer large enough to receive at least the
        <code>required</code> number of entries, same position as the
        input buffer, not null
jme3-core/src/main/java/com/jme3/util/BufferUtils.java