GPU device
Interface of IPipeline
An array of vertex data. Note that this array should include the index
data. For example, if a render pipeline
has position
, normal
, and uv
, then this data
array should defined by
const data = [dat.positions, dat.normals, dat.uvs, dat.indices];
Of course, for this data array, you also need to define corresponding vertex buffer array in the render pipeline:
p.vertexBuffers = [positonBuffer, normalBuffer, uvBuffer, indexBuffer];
If the data is generated in such a way that the vertex data contains all attributes (position
, normal
, uv
) and it is
stored in a single buffer, we can specify the data
array using the code:
const data = [dat.vertices, dat.indices];
and corresponding vertex buffer array:
p.vertexBuffers = [vertexBuffer, indexBuffer];
The data length of the first element in the original data
array.
Generated using TypeDoc
This function updates the vertex buffers when the vertex data is changed by varying some parameters by the user. Let's take the UV sphere as an example. A UV sphere can have three parameters: radius, u-segments, and v-segments. Varying the radius parameter only changes the data values but not the buffer size, while warying the u- (or v-) segments parameter will change both the data values and buffer size. In the former case, we can write the new data directly into the original buffers; while in the latter case, we have to destroy the original buffers and recreate the new buffers with new buffer size, and then write the new data into the newly created buffers. Here, we check whether the buffer size is changed or not by comparing the length of the original data (called
origNumVertices
) with that of the new data.