Create a new VertexBuffer instance.
The graphics device used to manage this vertex buffer.
The vertex format of this vertex buffer.
The number of vertices that this vertex buffer will hold.
Optionaloptions: {Object for passing optional arguments.
Optionaldata?: ArrayBuffer | ArrayBufferView<ArrayBufferLike>Initial data. Can be an
ArrayBuffer or a typed array (for example a Float32Array). The data is
stored by reference and is not copied, so a typed array that is a view into a larger buffer
is kept as-is. If left unspecified, the vertex buffer will be initialized to zeros.
Optionalstorage?: booleanDefines if the vertex buffer can be used as a storage buffer by a compute shader. Defaults to false. Only supported on WebGPU.
Optionalusage?: numberThe usage type of the vertex buffer (see BUFFER_*). Defaults to BUFFER_STATIC.
Frees resources associated with this vertex buffer.
Returns the data format of the specified vertex buffer.
The data format of the specified vertex buffer.
Returns the number of vertices stored in the specified vertex buffer.
The number of vertices stored in the vertex buffer.
Returns the usage type of the specified vertex buffer. This indicates whether the buffer can be modified once and used many times BUFFER_STATIC, modified repeatedly and used many times BUFFER_DYNAMIC or modified once and used at most a few times BUFFER_STREAM.
The usage type of the vertex buffer (see BUFFER_*).
Returns a mapped memory block representing the content of the vertex buffer.
The memory that stores the buffer's vertices. This matches whatever was supplied as the initial data: an ArrayBuffer when none was provided, otherwise the ArrayBuffer or typed array that was passed in. Use ArrayBufferConstructor.isView to distinguish the two before accessing it.
Sets the data of the vertex buffer and uploads it to the GPU.
Optionaldata: ArrayBuffer | ArrayBufferView<ArrayBufferLike>
Source data. Can be an ArrayBuffer or a typed array. Stored by reference, not copied.
True if function finished successfully, false otherwise.
Uploads the client side copy of the vertex buffer to the GPU. When called without arguments, uploads the entire buffer. An explicit range uploads only those bytes at the same GPU offset. The first upload always initializes the entire GPU buffer, regardless of the requested range. A zero byte length does nothing, including before the first upload.
Partial uploads do not resize the buffer or change its CPU storage. The caller must upload every modified range before expecting those changes on the GPU. Context restoration uploads the entire CPU storage. Invalid ranges are ignored in all builds and report an assertion in debug builds.
OptionalbyteOffset: number
Offset in bytes from the start of the buffer's storage. Defaults to 0. Must be a non-negative integer and a multiple of 4 on all graphics backends.
OptionalbyteLength: number
Number of bytes to upload. Defaults to the remaining bytes after byteOffset. The length must be a non-negative integer and the range must fit within the buffer. Partial ranges require a length that is a multiple of 4. Full-buffer uploads support any byte length, whether the range is explicit or the arguments are omitted.
A vertex buffer is the mechanism via which the application specifies vertex data to the graphics hardware.