public static Buffer createBuffer(Format format, int components, int numElements) {
        if (components < 1 || components > 4) {
            throw new IllegalArgumentException("Num components must be between 1 and 4");
        }

        int total = numElements * components;

        switch (format) {
            case Byte:
            case UnsignedByte:
                return BufferUtils.createByteBuffer(total);
            case Half:
                return BufferUtils.createByteBuffer(total * 2);
            case Short:
            case UnsignedShort:
                return BufferUtils.createShortBuffer(total);
            case Int:
            case UnsignedInt:
                return BufferUtils.createIntBuffer(total);
            case Float:
                return BufferUtils.createFloatBuffer(total);
            case Double:
                return BufferUtils.createDoubleBuffer(total);
            default:
                throw new UnsupportedOperationException("Unrecognized buffer format: " + format);
        }
    }
Creates a {@link Buffer} that satisfies the given type and size requirements
of the parameters. The buffer will be of the type specified by
{@link Format format} and would be able to contain the given number
of elements with the given number of components in each element.

@param format the desired format of components, such as Float or Half
@param components the number of components per element (&ge;1, &le;4)
@param numElements the desired capacity (number of elements)
@return a new Buffer
jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java