lmmagnum
lmmagnum is a native lmcode host that builds a 3D scene from Magnum primitives, renders it with a built-in software rasterizer and exports PNG, PPM, STL, OBJ or PLY. It is one static executable with no GPU, window system or shared library requirement, and lmscript installs it automatically.
This page is the quick reference. The latest release checked here is lmmagnum 0.2.15; it ships the 206-signature lmcode_std_v3 standard library next to its 60 host signatures.
Install and run
npm install -g @lmctl-ai/lmctl
lmscript scene.lms # downloads the lmmagnum release on first use
lmscript --check scene.lms # compile the _lmcode_ block against the host schema
The install attribute github:lmctl-ai/lmmagnum@latest on the block makes lmscript download and cache the release binary. The current release lane publishes Linux x64 and arm64 binaries. Run a repository example straight from its URL (it writes images/primitives.png):
lmctl autorun https://raw.githubusercontent.com/lmctl-ai/lmmagnum/main/examples/primitives.lms
Minimal runnable example
prog = _lmcode_ cli="lmmagnum" install="github:lmctl-ai/lmmagnum@latest";
scene.background(0.08, 0.09, 0.12);
let m = material().color(0.85, 0.45, 0.2).specular(0.4);
scene.cube(1.0, m).translate(-1.5, 0.0, 0.0).rotate(20.0, 30.0, 0.0);
scene.sphere(0.6, m).translate(1.5, 0.0, 0.0);
scene.camera(40.0, 0.0, 1.5, 9.0, 0.0, -0.5, 0.0);
scene.directional_light(-0.5, -1.0, -0.4, 0.9);
scene.render_png("scene.png", 800, 400);
scene.export_obj("scene.obj");
lmcode_return_put("shapes", scene.shape_count());
lmcode_return_put("triangles", scene.triangle_count());
lmcode_return_put("magnum", magnum_version());
end _lmcode_
r = run_lmcode(prog);
println(json_stringify(r));
require(r.ok, "render failed");
Saved as scene.lms and run with lmscript scene.lms, the program writes scene.png and scene.obj and prints:
lmscript scene.lms
{"ok":true,"result":{"shapes":2,"triangles":2220,"magnum":"369e9620ab22"}}
Host CLI and protocol
| Invocation | Effect | Exit |
|---|---|---|
| lmmagnum --version | Print lmmagnum and its version, for example lmmagnum 0.2.15 | 0 |
| lmmagnum --lmcode-schema --json | Print the embedded schema JSON (dsl.schema 2, name lmmagnum) that lmscript compiles against | 0 |
| lmmagnum --lmcode-signatures | Print one line per context, function and method signature: 267 lines in 0.2.15 | 0 |
| lmmagnum --lmcode FILE [FILE ...] | Run compiled bytecode files; the result frame is printed between LMCODE_RETURN_BEGIN and LMCODE_RETURN_END | 0 or 3 |
| Anything else | Usage text and a failure frame with phase cli and code CLI_USAGE | 2 |
| Item | Value |
|---|---|
| Block header | cli="lmmagnum" install="github:lmctl-ai/lmmagnum@latest" |
| Outer call | r = run_lmcode(prog) returns a map with ok and result; on failure ok is false and phase, code and message are set |
| Result value | Set inside the block with lmcode_return_set(value) or lmcode_return_put(name, value) |
| Exit codes | 0 success, 2 CLI usage, 3 load or run error |
| Bytecode limit | Each --lmcode input must be a readable file no larger than 16 MiB |
| Standard library | lmcode_std_v3, 206 signatures in release 0.2.15 (the current catalog has 226; see the reference) |
Host API quick reference
The single context object is scene, of type Scene. Builder methods return their receiver so calls chain. Argument descriptions follow the usage in the repository examples.
| Call | Returns | Purpose |
|---|---|---|
| material() | Material | New material; chain color(r, g, b), specular(v), shininess(v), roughness(v), texture(tex) |
| magnum_version() | string | Identifier of the embedded Magnum build |
| scene.background(r, g, b), scene.ambient(v), scene.shadows(on) | Scene | Background colour, ambient light level, shadow map switch |
| scene.cube(size, m), scene.box(x, y, z, m), scene.sphere(radius, m), scene.icosphere(radius, subdivisions, m) | Shape | Solid primitives |
| scene.cylinder(radius, length, m), scene.cone(radius, length, m), scene.capsule(radius, length, m) | Shape | Round primitives taking two floats and a material |
| scene.plane(size, m), scene.ring(float, float, m), scene.text(string, size, m) | Shape | Flat quad, ring, voxel text from a 5x7 font |
| scene.tube_between(x1, y1, z1, x2, y2, z2, radius, m) | Shape | Tube between two points (bonds, struts, streamlines) |
| scene.triangle(nine floats, m) | Shape | One triangle from three points |
| shape.translate(x, y, z), rotate(x, y, z), scale(x, y, z) | Shape | Transform; rotation arguments are degrees in the examples |
| shape.color(r, g, b), texture(tex), name(string), visible(bool), parent(group) | Shape | Per-shape overrides, naming, visibility and scene graph parent |
| scene.group() | Group | Scene graph node with translate, rotate, scale and parent(group) |
| scene.camera(seven floats) | Camera | Camera; camera.look_at(six floats) re-aims it |
| scene.directional_light(x, y, z, intensity) | Light | Directional light; light.intensity(v) changes it |
| scene.texture(w, h), texture_checker(w, h, six floats), texture_file(path) | Texture | Blank, checker or file-backed texture (PNG, JPEG, BMP, TGA) |
| texture.pixel(x, y, r, g, b), filter(mode), wrap(mode), repeat(u, v), save_png(path), width(), height() | Texture, void or int | Paint, sampling modes (linear, nearest; repeat, clamp, mirror), save |
| scene.render_png(path, w, h), scene.render_ppm(path, w, h) | void | Render the scene to an image file |
| scene.accumulate(int, int), reset_accumulation(), save_accumulated_png(path) | void | Frame accumulation, used by the motion blur example |
| scene.export_obj(path), export_stl(path), export_ply(path) | void | Mesh export |
| scene.shape_count(), scene.triangle_count(), shape.triangle_count() | int | Counts for verification |
Detail pages
- Skill: install, commands, safety rules, worked examples, errors and verification for agents.
- Guide: concepts, architecture, workflow, domain model and limits.
- Reference: every type, method, function, flag, exit code and the standard library tables.
- GitHub repository lmctl-ai/lmmagnum: README gallery, examples and releases.