lmfilament reference
Every signature on this page was read from the output of lmfilament --lmcode-signatures and --lmcode-schema --json of the released lmfilament 0.3.21, which embeds Filament 1.78.1. Notes describe only what the repository README and examples state.
Context objects
| Name | Type | Role |
|---|---|---|
| fil | Filament | The only context object: factory for materials, meshes, textures and scenes |
Host types
| Type | Methods | Created by |
|---|---|---|
| Filament | 19 | The fil context object |
| Material | 7 | fil.material, fil.material_file |
| Mesh | 6 | fil.box, sphere, icosphere, cylinder, cone, capsule, plane, ring, triangle, text, tube_between, mesh_obj |
| Texture | 7 | fil.texture, texture_checker, texture_file |
| Scene | 14 | fil.scene |
| Part | 5 | Scene.add_part |
| Node | 4 | Scene.node |
| Total | 62 | The schema declares no host functions; everything is a method |
Filament methods
| Method | Signature | Notes |
|---|---|---|
| box | (float, float, float) -> Mesh | Procedural box mesh |
| capsule | (float, float, int) -> Mesh | Procedural capsule mesh |
| cone | (float, float, int) -> Mesh | Procedural cone mesh |
| cylinder | (float, float, int) -> Mesh | Procedural cylinder mesh |
| icosphere | (float, int) -> Mesh | Procedural icosphere mesh |
| material | (string, string) -> Material | Compile Filament material source given as a string; the examples pass a name and the source text |
| material_file | (string) -> Material | Compile a Filament material source file |
| mesh_obj | (string) -> Mesh | Import an OBJ file; vt is flipped so v = 0 is the top image row |
| plane | (float, float) -> Mesh | Procedural plane mesh |
| ring | (float, float, int) -> Mesh | Procedural ring mesh |
| scene | () -> Scene | Create a scene on the Filament engine (noop backend) |
| sphere | (float, int) -> Mesh | Procedural sphere mesh; examples pass radius and segment count |
| text | (string, float) -> Mesh | Voxel text mesh from a 5x7 font |
| texture | (int, int) -> Texture | Create an image of the given width and height |
| texture_checker | (int, int, float, float, float, float, float, float) -> Texture | Create a generated checker image |
| texture_file | (string) -> Texture | Load a PNG, JPEG, BMP or TGA image |
| triangle | () -> Mesh | The vertex-colored triangle of the upstream hellotriangle sample |
| tube_between | (float, float, float, float, float, float, float) -> Mesh | Tube mesh between two points; examples pass start x y z, end x y z and a radius |
| version | () -> string | Embedded Filament version string; 1.78.1 in lmfilament 0.3.21 |
Material methods
| Method | Signature | Notes |
|---|---|---|
| name | () -> string | Material name |
| package_size | () -> int | Size of the compiled filamat package in bytes |
| save | (string) -> void | Write the compiled package to a file |
| set_float | (string, float) -> Material | Set a float parameter by name; returns the material |
| set_float3 | (string, float, float, float) -> Material | Set a float3 parameter such as baseColor |
| set_float4 | (string, float, float, float, float) -> Material | Set a float4 parameter |
| set_texture | (string, Texture) -> Material | Bind a texture to a sampler2d parameter such as albedo |
Mesh methods
| Method | Signature | Notes |
|---|---|---|
| compute_tangents | () -> Mesh | Compute tangent frames; returns the mesh |
| has_colors | () -> bool | Whether the mesh has vertex colors |
| has_tangents | () -> bool | Whether the mesh has tangent frames |
| save_obj | (string) -> void | Export the mesh as an OBJ file |
| triangle_count | () -> int | Number of triangles |
| vertex_count | () -> int | Number of vertices |
Texture methods
| Method | Signature | Notes |
|---|---|---|
| filter | (string) -> Texture | Sampling filter; the examples use linear and nearest |
| height | () -> int | Height in pixels |
| pixel | (int, int, float, float, float) -> Texture | Set one pixel: x, y and a color of three floats |
| repeat | (float, float) -> Texture | UV repeat factors |
| save_png | (string) -> void | Write the image as PNG |
| width | () -> int | Width in pixels |
| wrap | (string) -> Texture | Wrap mode; the examples use repeat, clamp and mirror |
Scene methods
| Method | Signature | Notes |
|---|---|---|
| add | (Mesh, Material) -> Scene | Add a renderable from a mesh and a material; returns the scene |
| add_at | (Mesh, Material, float, float, float) -> Scene | Add a renderable at a position x y z |
| add_part | (Mesh, Material) -> Part | Add a renderable and return a Part that can be transformed, parented and hidden |
| camera | (float, float, float, float, float, float, float) -> Scene | Set the camera; the examples pass a field of view, an eye position and a target position |
| directional_light | (float, float, float, float, float, float, float) -> Scene | Add a directional light; the examples pass color r g b, intensity 110000.0 and a direction x y z |
| light_count | () -> int | Number of lights in the scene |
| node | () -> Node | Create a scene-graph node (Filament TransformManager) |
| point_light | (float, float, float, float, float) -> Scene | Add a point light |
| render_frames | (int) -> int | Drive the Filament render loop for the given number of frames; no pixels are produced |
| render_png | (string, int, int) -> void | Write a CPU preview picture: path, width, height |
| renderable_count | () -> int | Number of renderables in the scene |
| shadows | (bool) -> Scene | Turn the preview shadow map on or off |
| skybox | (float, float, float) -> Scene | Solid skybox color r g b |
| sun | (float) -> Scene | Add a sun light |
Part methods
| Method | Signature | Notes |
|---|---|---|
| parent | (Node) -> Part | Parent the part to a node |
| rotate | (float, float, float) -> Part | Rotate the part; three floats |
| scale | (float, float, float) -> Part | Scale the part |
| translate | (float, float, float) -> Part | Move the part; returns the part |
| visible | (bool) -> Part | Show or hide the part |
Node methods
| Method | Signature | Notes |
|---|---|---|
| parent | (Node) -> Node | Parent the node to another node |
| rotate | (float, float, float) -> Node | Rotate the node; three floats |
| scale | (float, float, float) -> Node | Scale the node |
| translate | (float, float, float) -> Node | Move the node; returns the node |
Enumerated string values
| Parameter | Values used in the repository examples |
|---|---|
| Texture.filter | linear, nearest |
| Texture.wrap | repeat, clamp, mirror |
| Material.set_texture sampler name used by the preview | albedo, baseColor, color or emissive, else the first sampler |
| fil.texture_file formats | PNG, JPEG, BMP, TGA |
CLI flags
usage: lmfilament --version | --lmcode-schema [--json] | --lmcode-signatures | --lmcode FILE [FILE ...]
| Flag | Behavior |
|---|---|
| --version | Print lmfilament and the version |
| --lmcode-schema | Print all signatures as text |
| --lmcode-schema --json | Print the embedded schema JSON with the keys dsl.schema (2), name, types, functions and context |
| --lmcode-signatures | Print all signatures as text: 1 context line, 206 standard signatures and 62 host methods |
| --lmcode FILE [FILE ...] | Run the compiled programs; this is the protocol that run_lmcode drives |
Exit codes and result frame
| Exit | Phase | Meaning |
|---|---|---|
| 0 | none | Success, also for --version and the schema flags |
| 2 | cli | Usage error; code CLI_USAGE |
| 3 | load | A program file could not be read; code LOAD_BAD_BYTECODE |
Only the exit codes observed with lmfilament 0.3.21 are listed. A failed invocation ends with one result frame on stdout:
lmfilament
usage: lmfilament --version | --lmcode-schema [--json] | --lmcode-signatures | --lmcode FILE [FILE ...]
LMCODE_RETURN_BEGIN
{"ok":false,"phase":"cli","code":"CLI_USAGE","message":"expected --lmcode FILE [FILE ...]"}
LMCODE_RETURN_END
lmfilament --lmcode missing.dslb
LMCODE_RETURN_BEGIN
{"ok":false,"phase":"load","code":"LOAD_BAD_BYTECODE","message":"cannot read missing.dslb"}
LMCODE_RETURN_END
Standard library (lmcode_std_v3)
lmfilament 0.3.21 ships 206 standard signatures: 83 function signatures and 123 method signatures on 16 standard types. They need no import and are callable in any lmfilament block next to the fil context. The result sink functions fill the result field of the run_lmcode envelope.
Function groups
| Group | Signatures | Purpose |
|---|---|---|
| String | 17 | Byte-string search, slicing, case, split, replace, numeric parsing and glob match |
| Encoding | 4 | Base64 and hexadecimal encode and decode |
| Math | 16 | Integer and float overloads of abs, ceil, floor, max, min, pow, round and sqrt |
| File | 5 | Whole-file read, write, append, existence test and line split |
| Collection constructors | 15 | Create empty lists, maps, queues, stacks and priority queues of int, float and string |
| JSON and templates | 2 | Parse JSON text into a Json value; render a text template from a Json value |
| Result sink | 24 | Set the value that run_lmcode returns as result: one value, or named fields |
| Collection and Json methods | 123 | Methods of the 16 standard types listed below |
| Total | 206 | 83 function signatures plus 123 method signatures |
Standard functions
| Function | Signature |
|---|---|
| file_append | (string, string) -> void |
| file_exists | (string) -> bool |
| file_lines | (string) -> StrList |
| file_read | (string) -> string |
| file_write | (string, string) -> void |
| float_list | () -> FloatList |
| float_map | () -> FloatMap |
| float_pq | () -> FloatPQ |
| float_queue | () -> FloatQueue |
| float_stack | () -> FloatStack |
| int_list | () -> IntList |
| int_map | () -> IntMap |
| int_pq | () -> IntPQ |
| int_queue | () -> IntQueue |
| int_stack | () -> IntStack |
| json_parse | (string) -> Json |
| lmcode_return_null | () -> void |
| lmcode_return_put | (string, FloatList) -> void |
| lmcode_return_put | (string, FloatMap) -> void |
| lmcode_return_put | (string, IntList) -> void |
| lmcode_return_put | (string, IntMap) -> void |
| lmcode_return_put | (string, Json) -> void |
| lmcode_return_put | (string, StrList) -> void |
| lmcode_return_put | (string, StrMap) -> void |
| lmcode_return_put | (string, bool) -> void |
| lmcode_return_put | (string, float) -> void |
| lmcode_return_put | (string, int) -> void |
| lmcode_return_put | (string, string) -> void |
| lmcode_return_put_null | (string) -> void |
| lmcode_return_set | (FloatList) -> void |
| lmcode_return_set | (FloatMap) -> void |
| lmcode_return_set | (IntList) -> void |
| lmcode_return_set | (IntMap) -> void |
| lmcode_return_set | (Json) -> void |
| lmcode_return_set | (StrList) -> void |
| lmcode_return_set | (StrMap) -> void |
| lmcode_return_set | (bool) -> void |
| lmcode_return_set | (float) -> void |
| lmcode_return_set | (int) -> void |
| lmcode_return_set | (string) -> void |
| math_abs | (float) -> float |
| math_abs | (int) -> int |
| math_ceil | (float) -> float |
| math_ceil | (int) -> int |
| math_floor | (float) -> float |
| math_floor | (int) -> int |
| math_max | (float, float) -> float |
| math_max | (int, int) -> int |
| math_min | (float, float) -> float |
| math_min | (int, int) -> int |
| math_pow | (float, float) -> float |
| math_pow | (int, int) -> int |
| math_round | (float) -> float |
| math_round | (int) -> int |
| math_sqrt | (float) -> float |
| math_sqrt | (int) -> int |
| str_base64_decode | (string) -> string |
| str_base64_encode | (string) -> string |
| str_contains | (string, string) -> bool |
| str_ends_with | (string, string) -> bool |
| str_find | (string, string) -> int |
| str_hex_decode | (string) -> string |
| str_hex_encode | (string) -> string |
| str_is_float | (string) -> bool |
| str_is_int | (string) -> bool |
| str_len | (string) -> int |
| str_list | () -> StrList |
| str_lower | (string) -> string |
| str_map | () -> StrMap |
| str_match | (string, string) -> bool |
| str_pq | () -> StrPQ |
| str_queue | () -> StrQueue |
| str_repeat | (string, int) -> string |
| str_replace | (string, string, string) -> string |
| str_split | (string, string) -> StrList |
| str_stack | () -> StrStack |
| str_starts_with | (string, string) -> bool |
| str_substr | (string, int, int) -> string |
| str_to_float | (string) -> float |
| str_to_int | (string) -> int |
| str_trim | (string) -> string |
| str_upper | (string) -> string |
| template_render | (string, Json) -> string |
Standard types and methods
FloatList
| Method | Signature |
|---|---|
| add | (float) -> FloatList |
| at | (int) -> float |
| clear | () -> FloatList |
| contains | (float) -> bool |
| index_of | (float) -> int |
| len | () -> int |
| set | (int, float) -> FloatList |
FloatMap
| Method | Signature |
|---|---|
| clear | () -> FloatMap |
| get | (string) -> float |
| get_or | (string, float) -> float |
| has | (string) -> bool |
| key_at | (int) -> string |
| keys | () -> StrList |
| len | () -> int |
| remove | (string) -> bool |
| set | (string, float) -> FloatMap |
| values | () -> FloatList |
FloatPQ
| Method | Signature |
|---|---|
| clear | () -> FloatPQ |
| empty | () -> bool |
| len | () -> int |
| peek | () -> float |
| pop | () -> float |
| push | (float, float) -> FloatPQ |
FloatQueue
| Method | Signature |
|---|---|
| at | (int) -> float |
| clear | () -> FloatQueue |
| empty | () -> bool |
| len | () -> int |
| peek | () -> float |
| pop | () -> float |
| push | (float) -> FloatQueue |
FloatStack
| Method | Signature |
|---|---|
| at | (int) -> float |
| clear | () -> FloatStack |
| empty | () -> bool |
| len | () -> int |
| peek | () -> float |
| pop | () -> float |
| push | (float) -> FloatStack |
IntList
| Method | Signature |
|---|---|
| add | (int) -> IntList |
| at | (int) -> int |
| clear | () -> IntList |
| contains | (int) -> bool |
| index_of | (int) -> int |
| len | () -> int |
| set | (int, int) -> IntList |
IntMap
| Method | Signature |
|---|---|
| clear | () -> IntMap |
| get | (string) -> int |
| get_or | (string, int) -> int |
| has | (string) -> bool |
| key_at | (int) -> string |
| keys | () -> StrList |
| len | () -> int |
| remove | (string) -> bool |
| set | (string, int) -> IntMap |
| values | () -> IntList |
IntPQ
| Method | Signature |
|---|---|
| clear | () -> IntPQ |
| empty | () -> bool |
| len | () -> int |
| peek | () -> int |
| pop | () -> int |
| push | (int, float) -> IntPQ |
IntQueue
| Method | Signature |
|---|---|
| at | (int) -> int |
| clear | () -> IntQueue |
| empty | () -> bool |
| len | () -> int |
| peek | () -> int |
| pop | () -> int |
| push | (int) -> IntQueue |
IntStack
| Method | Signature |
|---|---|
| at | (int) -> int |
| clear | () -> IntStack |
| empty | () -> bool |
| len | () -> int |
| peek | () -> int |
| pop | () -> int |
| push | (int) -> IntStack |
Json
| Method | Signature |
|---|---|
| as_bool | () -> bool |
| as_float | () -> float |
| as_int | () -> int |
| as_string | () -> string |
| at | (int) -> Json |
| get | (string) -> Json |
| has | (string) -> bool |
| keys | () -> StrList |
| kind | () -> string |
| len | () -> int |
| to_json | () -> string |
StrList
| Method | Signature |
|---|---|
| add | (string) -> StrList |
| at | (int) -> string |
| clear | () -> StrList |
| contains | (string) -> bool |
| index_of | (string) -> int |
| join | (string) -> string |
| len | () -> int |
| set | (int, string) -> StrList |
StrMap
| Method | Signature |
|---|---|
| clear | () -> StrMap |
| get | (string) -> string |
| get_or | (string, string) -> string |
| has | (string) -> bool |
| key_at | (int) -> string |
| keys | () -> StrList |
| len | () -> int |
| remove | (string) -> bool |
| set | (string, string) -> StrMap |
| values | () -> StrList |
StrPQ
| Method | Signature |
|---|---|
| clear | () -> StrPQ |
| empty | () -> bool |
| len | () -> int |
| peek | () -> string |
| pop | () -> string |
| push | (string, float) -> StrPQ |
StrQueue
| Method | Signature |
|---|---|
| at | (int) -> string |
| clear | () -> StrQueue |
| empty | () -> bool |
| len | () -> int |
| peek | () -> string |
| pop | () -> string |
| push | (string) -> StrQueue |
StrStack
| Method | Signature |
|---|---|
| at | (int) -> string |
| clear | () -> StrStack |
| empty | () -> bool |
| len | () -> int |
| peek | () -> string |
| pop | () -> string |
| push | (string) -> StrStack |
Standard REST and CLI interfaces (current catalog, not yet in this host)
The current lmcode_std_v3 catalog in lmcode-cpp has 226 canonical signatures. The 20 signatures beyond the 206 that lmfilament vendors are the former lmcode_std_rest_v1 module: 5 functions and 15 RestExchange methods, together with 10 standard interfaces. lmfilament does not ship them yet; it picks them up when it syncs its lmcode-cpp SDK and publishes a release. Until then a lmfilament program that calls rest_route or declares a RestGet handler does not compile against the lmfilament schema.
| Interface | Signature | Role |
|---|---|---|
| RestGet | (RestExchange exchange) -> void | Handler for GET routes |
| RestPost | (RestExchange exchange) -> void | Handler for POST routes |
| RestPut | (RestExchange exchange) -> void | Handler for PUT routes |
| RestDelete | (RestExchange exchange) -> void | Handler for DELETE routes |
| RestPatch | (RestExchange exchange) -> void | Handler for PATCH routes |
| RestHead | (RestExchange exchange) -> void | Handler for HEAD routes |
| RestOptions | (RestExchange exchange) -> void | Handler for OPTIONS routes |
| RestHandler | (RestExchange exchange) -> void | Generic handler bound by rest_route to an annotation name |
| CliCommand | (RestExchange exchange) -> void | Handler for a command dispatched by rest_cli |
| CliOption | (RestExchange exchange) -> void | Handler for an option dispatched by rest_cli |
| Function | Signature | Behavior |
|---|---|---|
| rest_config | (string, string) -> void | Store a configuration key and value; the keys prefix and base_path set the route prefix and max_body_bytes sets the request body limit |
| rest_route | (string, string, string) -> void | Register method, path template and handler annotation; templates accept {param} and {rest...} or :param and :rest... placeholders |
| rest_serve | () -> void | Request serving after the program body; routes are frozen from this call on |
| rest_stop | () -> void | Stop serving |
| rest_cli | (StrList) -> string | Stateless CLI mode: dispatch an argument vector to options, commands and REST routes and return the response text |
| RestExchange method | Signature | Behavior |
|---|---|---|
| method | () -> string | Request method |
| path | () -> string | Request path |
| query | (string) -> string | Query parameter value, empty when absent |
| has_query | (string) -> bool | Whether a query parameter is present |
| param | (string) -> string | Route template parameter value, empty when absent |
| header | (string) -> string | Request header value; repeated headers are joined with a comma and a space |
| has_header | (string) -> bool | Whether a request header is present |
| body | () -> string | Request body bytes |
| status | (int) -> void | Set the response status; values outside 200..599 are a host error |
| set_header | (string, string) -> void | Set a response header; Content-Length, Connection and Transfer-Encoding are managed by the server |
| send | (string) -> void | Set the response body |
| json | (string) -> void | Set the response body and the Content-Type application/json |
| get | (string) -> string | Read a shared state value, empty when absent |
| set | (string, string) -> void | Write a shared state value |
| increment | (string) -> int | Increment a shared named counter and return it |