Constructor
new L3D.GLMesh()
Properties
The number of triangles to be drawn.
The number of points to be drawn.
Methods
static load(gl, buffers, options) → GLMesh
Static method to create a mesh from a list of common streams
gl |
GLContext | |
buffers |
Object | |
options |
Object |
addBuffer(name, buffer)
Add a buffer to be used by the mesh.
name |
String | |
buffer |
GLBuffer |
addBuffers(vertexBuffers, indexBuffers, usage)
Adds vertex and indices buffers to a mesh
vertexBuffers |
Object | |
indexBuffers |
Object | |
usage |
number | STATIC_DRAW, DYNAMIC_DRAW, STREAM_DRAW |
bindBuffers(shader)
Bind all vertex buffers to the shader by attribute name
shader |
GLShader |
clone(gl) → GLMesh
Creates a clone of the mesh, duplicating the data arrays.
gl |
GLContext |
cloneShared(gl) → GLMesh
Creates a clone of the mesh, but the data arrays are shared between both meshes.
gl |
GLContext |
createIndexBuffer(name, data, usage) → GLBuffer
Creates a new empty index buffer and attachs it to this mesh
name |
String | |
data |
* | |
usage |
number |
createVertexBuffer(name, data, attribute, itemSize, usage) → GLBuffer
Creates a new empty buffer and attachs it to this mesh
name |
String | Name of the buffer |
data |
ArrayBufferView | the data in typed array format [optional, if ommited it created an empty array of getNumVertices() * itemSize] |
attribute |
String | name of the stream in the shader "a_P","a_N",... [optional, if omitted is used the common_buffers] |
itemSize |
number | itemSize components per vertex [optional, if ommited is used the commonBuffers, if not found then uses 3] |
usage |
number | STATIC_DRAW (default), DYNAMIC_DRAW, STREAM_DRAW |
deleteBuffers()
Delete all buffers used by the mesh
freeData()
Remove all local memory from the streams (leaving it only in the VRAM) to save RAM
getBuffer(name) → GLBuffer
Returns a vertex buffer
name |
String |
getIndexBuffer(name) → GLBuffer
Returns an index buffer with the given name.
name |
String |
getVertexBuffer(name) → GLBuffer
Returns a vertex buffer with the given name.
name |
String |
removeIndexBuffer(name, free)
Removes an index buffer from the mesh
name |
String | The name of the buffer |
free |
bool | if you want to remove the data from the GPU |
removeVertexBuffer(name, free)
Removes a vertex buffer from the mesh
name |
String | Name of the buffer |
free |
bool | if you want to remove the data from the GPU |
totalMemory() → number
Returns the amount of memory used by this mesh in bytes (sum of all buffers)
- number
unbindBuffers(shader)
Unbind all vertex buffers from the shader
shader |
GLShader |
updateVertexBuffer(name, data, attribute, itemSize, usage)
Updates a vertex buffer
name |
String | |
data |
* | |
attribute |
String | |
itemSize |
number | |
usage |
number |
upload(usage)
Uploads data inside buffers to the GPU
usage |
number |