lovr.graphics.newMesh
Creates a new Mesh. Meshes contain the data for an arbitrary set of vertices, and can be drawn. You must specify either the capacity for the Mesh or an initial set of vertex data. Optionally, a custom format table can be used to specify the set of vertex attributes the mesh will provide to the active shader. The draw mode and usage hint can also optionally be specified.
The default data type for an attribute is float
, and the default component count is 1.
mesh = lovr.graphics.newMesh(size, mode, usage, readable)
Arguments
Name | Type | Default | Description |
size | number | | The maximum number of vertices the Mesh can store.
|
mode | DrawMode | 'fan' | How the Mesh will connect its vertices into triangles.
|
usage | MeshUsage | 'dynamic' | An optimization hint indicating how often the data in the Mesh will be updated.
|
readable | boolean | false | Whether vertices from the Mesh can be read.
|
Returns
Name | Type | Description |
mesh | Mesh | The new Mesh.
|
mesh = lovr.graphics.newMesh(vertices, mode, usage, readable)
Arguments
Name | Type | Default | Description |
vertices | table | | A table of vertices. Each vertex is a table containing the vertex data.
|
mode | DrawMode | 'fan' | How the Mesh will connect its vertices into triangles.
|
usage | MeshUsage | 'dynamic' | An optimization hint indicating how often the data in the Mesh will be updated.
|
readable | boolean | false | Whether vertices from the Mesh can be read.
|
Returns
Name | Type | Description |
mesh | Mesh | The new Mesh.
|
mesh = lovr.graphics.newMesh(blob, mode, usage, readable)
Arguments
Name | Type | Default | Description |
blob | Blob | | A binary Blob containing vertex data.
|
mode | DrawMode | 'fan' | How the Mesh will connect its vertices into triangles.
|
usage | MeshUsage | 'dynamic' | An optimization hint indicating how often the data in the Mesh will be updated.
|
readable | boolean | false | Whether vertices from the Mesh can be read.
|
Returns
Name | Type | Description |
mesh | Mesh | The new Mesh.
|
These variants accept a custom vertex format. For more info, see the Mesh
page.
mesh = lovr.graphics.newMesh(format, size, mode, usage, readable)
Arguments
Name | Type | Default | Description |
format | table | | A table describing the attribute format for the vertices.
|
size | number | | The maximum number of vertices the Mesh can store.
|
mode | DrawMode | 'fan' | How the Mesh will connect its vertices into triangles.
|
usage | MeshUsage | 'dynamic' | An optimization hint indicating how often the data in the Mesh will be updated.
|
readable | boolean | false | Whether vertices from the Mesh can be read.
|
Returns
Name | Type | Description |
mesh | Mesh | The new Mesh.
|
mesh = lovr.graphics.newMesh(format, vertices, mode, usage, readable)
Arguments
Name | Type | Default | Description |
format | table | | A table describing the attribute format for the vertices.
|
vertices | table | | A table of vertices. Each vertex is a table containing the vertex data.
|
mode | DrawMode | 'fan' | How the Mesh will connect its vertices into triangles.
|
usage | MeshUsage | 'dynamic' | An optimization hint indicating how often the data in the Mesh will be updated.
|
readable | boolean | false | Whether vertices from the Mesh can be read.
|
Returns
Name | Type | Description |
mesh | Mesh | The new Mesh.
|
mesh = lovr.graphics.newMesh(format, blob, mode, usage, readable)
Arguments
Name | Type | Default | Description |
format | table | | A table describing the attribute format for the vertices.
|
blob | Blob | | A binary Blob containing vertex data.
|
mode | DrawMode | 'fan' | How the Mesh will connect its vertices into triangles.
|
usage | MeshUsage | 'dynamic' | An optimization hint indicating how often the data in the Mesh will be updated.
|
readable | boolean | false | Whether vertices from the Mesh can be read.
|
Returns
Name | Type | Description |
mesh | Mesh | The new Mesh.
|
Notes
Once created, the size and format of the Mesh cannot be changed.'
The default mesh format is:
{
{ 'lovrPosition', 'float', 3 },
{ 'lovrNormal', 'float', 3 },
{ 'lovrTexCoord', 'float', 2 }
}
See also