Commands come in two groups. Standalone commands, optimize, inspect and placeholder, take a model file. Chain commands each do one step, on a chain or from file to file: import, normals, weld, dedup, simplify, uv, ktx, avif, compress and export.
Each command has a page of its own: what it does, its options, what it reports, and how it works. This page has what they all share.
A command takes its input, and its output when it writes one, as positional arguments, as cp does: meshtinker weld in.glb out.gltf. No command picks an output name of its own.
| Kind | Commands | File mode | Chain mode |
|---|---|---|---|
| Transforms | normals, weld, dedup, simplify, uv, ktx, avif, compress |
cmd in.glb out.gltf |
cmd work/ adds a stage |
| Creating a chain | import |
import in.glb out.gltf |
import in.glb work/ |
| Reading | inspect |
inspect in.glb |
inspect work/ reads the last stage |
| Leaving a chain | export |
export work/ out.glb |
|
| Files only | optimize, placeholder |
optimize in.glb out.glb, placeholder in.glb out.gltf |
- The input is a
.gltfor.glbfile, or a chain: a directory holdingchain.json. A model is read in memory as ifimporthad normalized it (normalized profile). - The output is a
.gltffile, written with its.binand images beside it, in the normalized profile.optimizeandexportalso write.glb, by the output's extension. In chain mode a transform takes no output: giving one is a command-line error (2). - Outputs are never overwritten, and the output's directory must already exist (4 otherwise). Files appear only once the command succeeds: a failed or interrupted command removes what it wrote, and leaves nothing behind.
- A model may only reference files inside its own folder. A buffer or image
urimust lead to a regular file there:..is allowed while the path stays inside, but absolute paths, URLs and symlinks leading out are refused, unless--trustedis given.
- Stdout carries only data: the report, in text or, with
--json, as one JSON object. Everything else goes to stderr: progress, warnings, errors. - With
--json, stdout holds a JSON object even when the command fails. It then has anerror, with a stablecode, theexitCodeand amessage, and the warnings gathered so far. Every command's JSON starts withformat, the version of the object's shape, andtool, the command's name and version. - Warnings are counted: one line per kind of problem, with up to three examples, rather than one line per object. Each has a stable
code, and goes into the JSON'sdiagnosticstoo. Messages are in English; a program that shows them to users can map the codes. --log-leveland--log-formatset what goes to stderr: the least severe level printed, and text or one JSON object per line (logs.md).- Text shows sizes in decimal units (
12.3 MB) and times as1 min 23 s; JSON keeps bytes and seconds.
Commands that need more working memory than a fixed budget put the rest in files, in a temporary workspace (files and memory). It goes in the chain, or beside the output (beside the input for inspect), rather than in the system's temporary directory, which is often in memory. Put it on a real disk with --tmp-dir. --keep-tmp keeps it, for debugging.
Commands don't limit their own memory, and refuse no input for its size. Limits are the caller's to set (a container, a cgroup, ulimit): a command that runs out of memory exits with 3.
Every command takes these, besides its own.
| Option | |
|---|---|
-h, --help |
Print the command's help and exit. meshtinker help <command> does the same. |
--version |
Print the version and exit. |
--json |
Print the result as one JSON object on stdout, even on failure. |
--trusted |
Let the model reference files outside its folder: absolute paths, .. leading out, symlinks. Not export, which reads a chain. |
--tmp-dir DIR |
Where to create the workspace. Default: the chain, else the output's directory (the input's for inspect). Not dedup, ktx, avif and export, which need none. |
--keep-tmp |
Keep the workspace and print its path, for debugging. Not dedup, ktx, avif and export. |
--log-level LEVEL |
The least severe messages printed on stderr: trace, debug, info, warn or error. Default: info. |
--log-format FORMAT |
text, or json for one JSON object per line, with level, message and, for warnings and errors, their code. Default: text. |
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | The input was rejected |
| 2 | The command line is wrong |
| 3 | A resource limit was reached: disk full, quota or file-size limit, out of memory |
| 4 | Another problem with the machine: permissions, missing output directory, existing output |
| 70 | Internal error: a bug in meshtinker |