Models & Meshes

Model loading, mesh generation, material setup, skeletal animation, billboards, bounding boxes.

Model reference

Model loading, mesh generation, material setup, skeletal animation, billboards, bounding boxes. Every raylib rmodels.c binding (46 total).

Model lifecycle

Model.load(file_name: String) -> Model

Category: Lifecycle · raylib: LoadModel

Load .obj / .gltf / .glb / .iqm / .vox / .m3d. Check with Model.is_valid; pair with unload.

val model = Model.load("tests/assets/models/cube.obj")

raylib cheatsheet · Iron source · Test usage

Model.from_mesh(mesh: Mesh) -> Model

Category: Lifecycle · raylib: LoadModelFromMesh

Wrap a procedurally generated Mesh in a Model. Useful as a fallback when Model.load fails.

val fallback = Model.from_mesh(Mesh.cube(Float32(2.0), Float32(2.0), Float32(2.0)))

raylib cheatsheet · Iron source · Test usage

Model.is_valid(model) -> Bool / Model.unload(model)

Category: Lifecycle · raylib: IsModelValid / UnloadModel

Validity guard + release meshes + materials.

if Model.is_valid(model) { Model.unload(model) }

raylib cheatsheet · Iron source · Test usage

Model query

Model.bounding_box(model: Model) -> BoundingBox

Category: Query · raylib: GetModelBoundingBox

Axis-aligned bounding box covering all meshes.

val bbox = Model.bounding_box(model)
Draw.bounding_box(bbox, GREEN)

raylib cheatsheet · Iron source · Test usage

Model draw

Model.draw(model, position, scale, tint) / draw_ex(model, position, rotation_axis, rotation_angle, scale: Vector3, tint)

Category: Draw · raylib: DrawModel / DrawModelEx

Render filled model. _ex takes axis-angle rotation + per-axis scale.

Model.draw(model, origin, Float32(1.0), WHITE)

raylib cheatsheet · Iron source · Test usage

Model.draw_wires / draw_wires_ex

Category: Draw · raylib: DrawModelWires / DrawModelWiresEx

Wireframe renders with matching _ex rotation/scale variants.

Model.draw_wires(model, origin, Float32(1.0), BLACK)

raylib cheatsheet · Iron source · Test usage

Mesh operations

Mesh.upload(mesh, dynamic: Bool) -> Mesh / update_buffer(mesh, index, data: [UInt8], offset, size)

Category: Operations · raylib: UploadMesh / UpdateMeshBuffer

Create GPU VBO/VAO; update buffer contents (dynamic meshes).

var m = Mesh.upload(mesh, false)

raylib cheatsheet · Iron source · Test usage

Mesh.unload(mesh) / export(mesh, file_name) -> Bool / export_as_code(mesh, file_name) -> Bool

Category: Operations · raylib: UnloadMesh / ExportMesh / ExportMeshAsCode

Release + write mesh to .obj or embed as C source.

Mesh.export(cube, "cube.obj")

raylib cheatsheet · Iron source · Test usage

Mesh.bounding_box(mesh) -> BoundingBox / gen_tangents(mesh) -> Mesh

Category: Operations · raylib: GetMeshBoundingBox / GenMeshTangents

Compute AABB; generate tangent vectors (required for normal-mapped materials).

var m = Mesh.gen_tangents(mesh)

raylib cheatsheet · Iron source · Test usage

Mesh draw

Mesh.draw(mesh, material, transform: Matrix)

Category: Mesh draw · raylib: DrawMesh

Draw a single mesh with explicit material + world transform. Low-level alternative to Model.draw.

Mesh.draw(cube_mesh, mat, Matrix.identity())

raylib cheatsheet · Iron source · Test usage

Mesh.draw_instanced(mesh, material, transforms: [Matrix], instances: Int32)

Category: Mesh draw · raylib: DrawMeshInstanced

Instanced draw — one mesh, many transforms per drawcall.

Mesh.draw_instanced(mesh, mat, transforms, Int32(transforms.length))

raylib cheatsheet · Iron source · Test usage

Mesh generation

Mesh.poly(sides: Int32, radius: Float32) / plane(width, length, res_x, res_z) / sphere(radius, rings, slices) / hemi_sphere(...)

Category: Generation · raylib: GenMeshPoly / Plane / Sphere / HemiSphere

Flat polygons, planes, full + half spheres.

val sphere = Mesh.sphere(Float32(1.0), Int32(16), Int32(32))

raylib cheatsheet · Iron source · Test usage

Mesh.cylinder(radius, height, slices) / cone(...) / torus(radius, size, rad_seg, sides) / knot(...)

Category: Generation · raylib: GenMeshCylinder / Cone / Torus / Knot

Tube, conic, torus, trefoil knot generators.

val torus = Mesh.torus(Float32(1.0), Float32(0.3), Int32(16), Int32(32))

raylib cheatsheet · Iron source · Test usage

Mesh.heightmap(heightmap: Image, size: Vector3) / cubicmap(cubicmap: Image, cube_size: Vector3)

Category: Generation · raylib: GenMeshHeightmap / Cubicmap

Height-field terrain from a grayscale image; Minecraft-style voxel map from a color image.

val terrain = Mesh.heightmap(heightmap_img, Vector3.of(16.0, 4.0, 16.0))

raylib cheatsheet · Iron source · Test usage

Material

Material.load(file_name: String) -> [Material]

Category: Material · raylib: LoadMaterials

Load materials from .mtl. Returns a list (.obj can reference multiple).

val mats = Material.load("scene.mtl")

raylib cheatsheet · Iron source · Test usage

Material.default() -> Material / is_valid(material) / unload(material)

Category: Material · raylib: LoadMaterialDefault / IsMaterialValid / UnloadMaterial

Default passthrough material + validity + release.

val mat = Material.default()

raylib cheatsheet · Iron source · Test usage

Material.set_texture(material, map_type: MaterialMapIndex, texture: Texture) -> Material

Category: Material · raylib: SetMaterialTexture

Assign texture to a material channel (albedo, normal, roughness, ...).

var mat = Material.set_texture(mat, MaterialMapIndex.ALBEDO, tex)

raylib cheatsheet · Iron source · Test usage

Model.set_mesh_material(model, mesh_id, material_id: Int32) -> Model

Category: Material · raylib: SetModelMeshMaterial

Associate a loaded material with one of the model's meshes.

var m = Model.set_mesh_material(model, Int32(0), Int32(0))

raylib cheatsheet · Iron source · Test usage

Animation

ModelAnimation.load(file_name: String) -> [ModelAnimation]

Category: Animation · raylib: LoadModelAnimations

Load skeletal animation clips from .iqm / .gltf / .m3d.

val anims = ModelAnimation.load("character.iqm")

raylib cheatsheet · Iron source · Test usage

Model.animation_valid(model, anim) -> Bool

Category: Animation · raylib: IsModelAnimationValid

Check that animation's bone structure is compatible with this model.

if Model.animation_valid(model, anims[0]) { }

raylib cheatsheet · Iron source · Test usage

Model.update_animation(model, anim, frame: Float32) / update_animation_ex(model, anim_a, frame_a, anim_b, frame_b, blend)

Category: Animation · raylib: UpdateModelAnimation / UpdateModelAnimationEx

Apply a single animation at a fractional frame or blend two animations directly using the raylib 6 extended update path.

Model.update_animation(model, anim, Float32(frame))

raylib cheatsheet · Iron source · Test usage

ModelAnimation.unload(anim) / unload_all(anims: [ModelAnimation])

Category: Animation · raylib: UnloadModelAnimation / UnloadModelAnimations

Release single anim or full list.

ModelAnimation.unload_all(anims)

raylib cheatsheet · Iron source · Test usage

Billboards

Draw.billboard(camera, texture, position: Vector3, size: Float32, tint: Color)

Category: Billboards · raylib: DrawBillboard

Screen-facing textured quad. Classic particle / tree-imposter primitive.

Draw.billboard(cam, tex, pos, Float32(2.0), WHITE)

raylib cheatsheet · Iron source · Test usage

Draw.billboard_rec(camera, texture, source: Rectangle, position, size, tint) / billboard_pro(...)

Category: Billboards · raylib: DrawBillboardRec / DrawBillboardPro

Source-rect crop (_rec); explicit up/origin/rotation (_pro) for oriented-particle effects.

Draw.billboard_rec(cam, tex, src, pos, size, WHITE)

raylib cheatsheet · Iron source · Test usage

Bounding box draw

Draw.bounding_box(box: BoundingBox, color: Color)

Category: Bounding box · raylib: DrawBoundingBox

Wireframe box draw. Pair with Model.bounding_box / Mesh.bounding_box.

Draw.bounding_box(Model.bounding_box(model), GREEN)

raylib cheatsheet · Iron source · Test usage

See also