mesh
Real 3D meshes: textured, lit by the world, depth-tested, optionally GPU-skinned. Create once, draw inside on_draw_3d.
Functions
mesh.create
mesh.create(desc) -> Mesh| Name | Type | Description |
|---|---|---|
| desc.positions | number[] | string | 3 per vertex. Required. |
| desc.normalsoptional | number[] | string | 3 per vertex; computed from the triangles when missing. |
| desc.uvsoptional | number[] | string | 2 per vertex. |
| desc.indicesoptional | number[] | string | 3 per triangle, 0-based; missing = every 3 vertices. |
| desc.bonesoptional | number[] | string | 1 to 4 bone indices (0 to 127) per vertex. |
| desc.weightsoptional | number[] | string | Same count as bones; normalized. |
| desc.index_bitsoptional | integer | 16 or 32 for an indices string. Default 32. |
Uploads a mesh.
- Binary strings (string.pack or a file) are much faster than tables: float32 for positions / normals / uvs / weights, uint8 bones, uint16 / uint32 indices.
- Errors on bad input. Limits: 262144 vertices, 1572864 indices per mesh, 64 MB per script, 256 MB total.
mesh.stats
mesh.stats() -> table{meshes, bytes, draws, triangles}; draws and triangles from the last frame.
mesh.supported
mesh.supported() -> boolean | nilfalse if the GPU lacks shaders; nil before the first draw.