3D Drawing
3D camera, screen↔world conversion, 21 3D primitives.
DRAW3D-01..04 reference
3D camera mode, 5 camera update helpers, 4 screen↔world conversions, 21 3D primitives (cube, sphere, cylinder, capsule, plane, ray, grid, ...).
3D mode (DRAW3D-01)
Draw.begin_mode_3d(camera: Camera3D) / Draw.end_mode_3d()
Category: 3D mode · raylib: BeginMode3D / EndMode3D
Nest inside Draw.begin / end. Subsequent Draw.* primitives render in 3D using camera's view/projection matrices.
Draw.begin()
Draw.clear(SKYBLUE)
Draw.begin_mode_3d(cam)
-- 3D primitives
Draw.end_mode_3d()
Draw.end()
raylib cheatsheet ·
Iron source ·
Test usage
Camera (DRAW3D-02)
Camera3D.update(camera: Camera3D, mode: CameraMode) -> Camera3D
Category: Camera · raylib: UpdateCamera
Auto-update camera based on mode + current mouse/keyboard. Orbital, free, first-person, third-person. Returns the updated camera; bind it back with var.
cam = Camera3D.update(cam, CameraMode.ORBITAL)
raylib cheatsheet ·
Iron source ·
Test usage
Camera3D.update_pro(camera, movement: Vector3, rotation: Vector3, zoom: Float32) -> Camera3D
Category: Camera · raylib: UpdateCameraPro
Explicit movement/rotation/zoom inputs (no auto-sampling from input). Use for custom control schemes.
cam = Camera3D.update_pro(cam, move, Vector3.zero(), Float32(0.0))
raylib cheatsheet ·
Iron source ·
Test usage
Camera3D.matrix(camera: Camera3D) -> Matrix
Category: Camera · raylib: GetCameraMatrix
Extract current view matrix for custom projection math.
val view = Camera3D.matrix(cam)
raylib cheatsheet ·
Iron source ·
Test usage
Screen ↔ world (DRAW3D-03)
Camera3D.screen_to_world_ray(camera, position: Vector2) -> Ray
Category: Screen ↔ World · raylib: GetScreenToWorldRay
Build a 3D world-space ray from a 2D screen pixel (mouse picking).
val ray = Camera3D.screen_to_world_ray(cam, Mouse.get_position())
raylib cheatsheet ·
Iron source ·
Test usage
Camera3D.screen_to_world_ray_ex(camera, position, width, height: Int32) -> Ray
Category: Screen ↔ World · raylib: GetScreenToWorldRayEx
As above but with explicit viewport dimensions (for split-screen etc).
val ray = Camera3D.screen_to_world_ray_ex(cam, pos, Int32(400), Int32(300))
raylib cheatsheet ·
Iron source ·
Test usage
Camera3D.world_to_screen(camera, position: Vector3) -> Vector2 / world_to_screen_ex(camera, position, width, height)
Category: Screen ↔ World · raylib: GetWorldToScreen / GetWorldToScreenEx
Project 3D world point to 2D screen pixel (for HUD overlays).
val screen_pos = Camera3D.world_to_screen(cam, enemy_pos)
raylib cheatsheet ·
Iron source ·
Test usage
3D primitives (DRAW3D-04)
Draw.line_3d(start, end: Vector3, color)
Category: Primitives · raylib: DrawLine3D
3D line between two world points.
Draw.line_3d(Vector3.zero(), Vector3.of(1.0, 0.0, 0.0), RED)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.point_3d(position: Vector3, color)
Category: Primitives · raylib: DrawPoint3D
Single world-space point.
Draw.point_3d(origin, YELLOW)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.circle_3d(center, radius, rotation_axis, rotation_angle, color)
Category: Primitives · raylib: DrawCircle3D
Circle in 3D space with arbitrary rotation axis.
Draw.circle_3d(center, Float32(1.0), axis, angle, GREEN)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.triangle_3d(v1, v2, v3: Vector3, color) / triangle_strip_3d(points: [Vector3], count, color)
Category: Primitives · raylib: DrawTriangle3D / DrawTriangleStrip3D
Single 3D triangle or strip-batched 3D triangles.
Draw.triangle_3d(a, b, c, RED)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.cube(position: Vector3, width, height, length: Float32, color: Color)
Category: Primitives · raylib: DrawCube
Filled 3D box with independent dimensions.
Draw.cube(origin, Float32(2.0), Float32(2.0), Float32(2.0), RED)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.cube_v / cube_wires / cube_wires_v
Category: Primitives · raylib: DrawCubeV / Wires / WiresV
Vector3 size (_v); wireframe-only (_wires); combo (_wires_v).
Draw.cube_wires(origin, Float32(2.0), Float32(2.0), Float32(2.0), BLACK)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.sphere(center, radius, color) / sphere_ex(center, radius, rings, slices, color) / sphere_wires(...)
Category: Primitives · raylib: DrawSphere / Ex / Wires
Filled or wireframe sphere with configurable tesselation.
Draw.sphere(origin, Float32(1.0), BLUE)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.cylinder(position, radius_top, radius_bottom, height, slices: Int32, color)
Category: Primitives · raylib: DrawCylinder
Cylinder (frustum if top/bottom radii differ).
Draw.cylinder(origin, Float32(0.5), Float32(0.5), Float32(2.0), Int32(16), MAROON)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.cylinder_ex / cylinder_wires / cylinder_wires_ex
Category: Primitives · raylib: DrawCylinderEx / Wires / WiresEx
Start-end Vector3 endpoints (_ex); wireframe variants.
Draw.cylinder_ex(start, finish, Float32(0.5), Float32(0.5), Int32(16), RED)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.capsule(start, end: Vector3, radius, slices, rings: Int32, color) / capsule_wires(...)
Category: Primitives · raylib: DrawCapsule / CapsuleWires
Cylinder with hemispherical caps. Common character-collision volume.
Draw.capsule(start, finish, Float32(0.5), Int32(16), Int32(8), PURPLE)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.plane(center: Vector3, size: Vector2, color)
Category: Primitives · raylib: DrawPlane
XZ-aligned ground plane.
Draw.plane(origin, Vector2.of(10.0, 10.0), LIME)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.ray(ray: Ray, color)
Category: Primitives · raylib: DrawRay
Visualize a Ray. Useful for debug-rendering picking rays.
Draw.ray(mouse_ray, YELLOW)
raylib cheatsheet ·
Iron source ·
Test usage
Draw.grid(slices: Int32, spacing: Float32)
Category: Primitives · raylib: DrawGrid
XZ ground grid — no color parameter, raylib renders in a fixed gray.
Draw.grid(Int32(10), Float32(1.0))
raylib cheatsheet ·
Iron source ·
Test usage
See also