Documentation menu

Advanced Features

The Scene System

A retained-mode layer over Mako3D's immediate-mode primitives. Instead of hand-writing a draw call per object per frame, spawn objects once and mutate them by handle.

New to coding?

Copy the examples exactly first. Run them. Then change one number or word and run them again. You are not expected to memorize the command lists.

1

Spawning objects

Try this code
h = Mako3D.spawn_cube(0, 1, 0,  2, 2, 2, Mako3D.RED);
Mako3D.spawn_sphere(5, 1, 0,  1.5, Mako3D.BLUE);
Mako3D.spawn_cylinder(-5, 0, 0,  0.8, 0.8, 2, Mako3D.GREEN);
Mako3D.spawn_plane(0, 0, 0,  20, 20, Mako3D.DARKGRAY);
2

Mutating by handle

Try this code
Mako3D.set_object_pos(h, x, y, z);
Mako3D.set_object_color(h, Mako3D.GOLD);
Mako3D.set_object_rotation(h, angle_deg);   // Y-axis, v1
Mako3D.set_object_name(h, "player");
Mako3D.remove_object(h);
3

Drawing everything at once

Try this code
while Mako3D.running() {
    Mako3D.begin_3d(cam);
    Mako3D.draw_scene();   // every spawned, visible object — one call
    Mako3D.end_3d();
}
4

Add a skybox

Use one 4×3 cross-layout image to surround the camera with a sky. Load it once, then draw it first inside the 3D pass.

Try this code
skybox = Mako3D.create_skybox("Images/Skybox.png");

Mako3D.begin_3d(cam);
Mako3D.draw_skybox(skybox);  # Draw the sky behind the world
Mako3D.draw_scene();
Mako3D.end_3d();

The path is resolved relative to the running script. Missing files use a fallback sky instead of crashing.

5

Reading state back

object_info() is the read side of every set_object_* call — the basis of a live inspector panel.

Try this code
info = Mako3D.object_info(h);
info["shape"]; info["x"]; info["color"]; info["name"];
6

Click-to-select (picking)

Casts a ray from the camera through the mouse and returns whatever it hits.

Try this code
if Inputs.mouse_pressed("left") {
    selected = Mako3D.pick_object(cam);
}
7

Mesh edit mode

A Blender-inspired step deeper than whole-object selection: inspect an object's actual vertices, edges, and faces.

Try this code
info = Mako3D.mesh_info(h);   // {vertex_count, edge_count, face_count}
Mako3D.draw_vertices(h, Mako3D.YELLOW, 0.06);
Mako3D.draw_edges(h, Mako3D.YELLOW);
vi = Mako3D.pick_vertex(cam, h);   // nearest vertex to the mouse
8

Save & load a scene

The whole spawned scene round-trips through JSON.

Try this code
Mako3D.save_scene("scene.json");
Mako3D.load_scene("scene.json");   // clears and respawns everything