Skip to main content

Module thumbnail

Module thumbnail 

Source
Expand description

Part thumbnails: a small CPU rasterizer over the RenderScene’s display meshes, the one picture producer that runs the same on native, in the browser and in the headless bake worker (which has no GPU device at all).

The picture is the ViewCube’s ISO view (from +X+Y+Z, +Y up), orthographic, fit to what is drawn, square, on a transparent background: Lambert shading under a fixed light, a depth buffer, each body’s viewport colour (a face’s colour, else its solid’s, else the name-hashed colour), and the display edges drawn over it. It is supersampled [SUPERSAMPLE]× per axis and averaged down, so silhouettes are anti-aliased.

capture copies what the picture needs out of the scene (cheap, on the caller’s thread); render_png does the rest and is Send-safe, so a native host can run it on a thread of its own. The PNG carries no text or time chunks: the same scene gives the same bytes.

Structs§

Body
One body’s triangles, ready to draw.
Capture
What render_png draws: an owned copy of the visible scene.

Constants§

RENDERER
The renderer’s version, stored beside each thumbnail on the server. Bump it whenever the picture for the same document would change, so a server can tell a thumbnail made by an older renderer.
SIZE
The default thumbnail edge, in pixels.

Functions§

capture
Copy the visible bodies out of scene: every visible solid and committed sketch sheet, hidden faces left out, in the viewport’s colours.
embedded_png
Portable preview carried by native CAD JSON. The image has no external URL.
empty_embedded
Empty documents and edits still rebuilding have an honest empty preview.
render_png
Render capture as a size×size RGBA PNG. None when nothing is drawn (an empty document gets no thumbnail; consumers show their placeholder).
render_rgba
render_png’s pixels, before encoding: size² RGBA, row-major.