Expand description
3D preview of CAD files – pure Rust, no browser plug-ins or downloads.
The server converts a file once into the compact mesh of crate::mesh
and caches it next to the vault (previews/ab/<sha256>.v<N>.tcm); the
browser (shared/js/viewer.js) and the desktop app only draw it. Meshes,
point clouds, STEP B-reps (tessellated with the truck kernel) and
simulation results (VTK, VTU/VTP, CalculiX FRD with result fields, see
crate::simmesh) are supported, see PreviewFormat.
The conversion never blocks the web server: it runs in a separate
teamcraft preview-mesh process with a time limit (in tests, where there is
no such binary, on a blocking thread), at most MAX_PARALLEL at a time,
and concurrent requests for the same file share one conversion. Failures
are cached as well, so a broken file is not converted again and again.
Structs§
- Preview
Limits - Size and memory limits of the preview (
TEAMCRAFT_PREVIEW_MAX_*). - Previews
- Cached, isolated conversions (one per server, part of
AppState).
Enums§
- Cache
Entry - What a file in the preview cache (
previews/ab/…) is, by its name. - Preview
Format - 3D formats the preview understands.
Constants§
- CACHED_
MESH --formatofteamcraft preview-meshfor an already converted preview mesh (only its shape signature is computed).- CACHE_
VERSION - Bump to invalidate every cached preview (reader fixes, new format).
Bump
shape::VERSIONwith it: the shape signatures stored in the database are computed from these meshes. 3: Inventor files with Zstandard segments (#271), cached as failed before. 4: Creo parts in millimetres (inch parts were 25.4 times too small), turned Creo parts. - MAX_
PARALLEL - Conversions that run at the same time.
- MAX_
RENDERS - Thumbnails drawn and assembly previews composed at the same time
(
Previews::render): each keeps one CPU busy and holds its meshes in memory.
Functions§
- cache_
entry - Classifies a file name of the preview cache: the meshes and failures of
this module (
<sha256>.v<N>.tcm|err), their shape signatures (<sha256>.v<N>.s<M>.json) and the thumbnails ofcrate::thumbnail(<sha256>.thumb.v<N>.png|bmp|jpg|none); every temporary name ends in.tmp. - convert
- Reads the file at
inputas a preview mesh. - convert_
file - Converts the file at
input(tests and tools). - convert_
within - Like
convert; a file abovemax_bytesis refused before it is opened. - limit_
memory - Limits the address space of this process (the preview child), so a file that needs more memory fails cleanly instead of taking the server host down. Linux and macOS; elsewhere (Windows) the limit is not enforced. Returns whether a limit is in force.
- run_job
- One job of the preview process (
teamcraft preview-mesh): convertsinputinto the preview mesh atoutputand/or writes the shape signature (ashape::Outcomeas JSON) tosignature. WithCACHED_MESHas format,inputis a cached preview mesh. A failed signature does not fail the conversion – the outcome records why. The mass properties (amassprops::Outcomeas JSON) go tomassthe same way. Returns the mesh (the CLI prints its size). - worker_
exe - The
teamcraftbinary that runs isolated jobs (preview-mesh,text-extract);Nonein tests and other binaries, which run them in-process. The desktop downloads with local server ship the same binary asteamcraft-server(crate::localserver::SIDECAR_NAME): next to the app’s ownTeamCraftexecutable,teamcraftwould be the same file name on Windows and macOS.