xhookLua
Game

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
NameTypeDescription
desc.positionsnumber[] | string3 per vertex. Required.
desc.normalsoptionalnumber[] | string3 per vertex; computed from the triangles when missing.
desc.uvsoptionalnumber[] | string2 per vertex.
desc.indicesoptionalnumber[] | string3 per triangle, 0-based; missing = every 3 vertices.
desc.bonesoptionalnumber[] | string1 to 4 bone indices (0 to 127) per vertex.
desc.weightsoptionalnumber[] | stringSame count as bones; normalized.
desc.index_bitsoptionalinteger16 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 | nil

false if the GPU lacks shaders; nil before the first draw.

mesh ยท Lua API ยท xhook