cadkit-scene
GPU-independent scene data for CAD application viewers and editors, part of the
cadkit CAD engine. It depends on cadkit-geom and is
WASM-compatible; it does not create a GPU device or open a window.
Plan2d: a persistent store of 2D lines, polylines, arcs and circles (cadkit-geomcurves) split into fixed-size chunks. Each chunk is encoded once into compact GPU instances in f32 coordinates relative to its center; every frame checks the f32 representation error against a screen-space budget and returns chunks that exceed it, curves the GPU does not represent and objects without bounds to the caller's CPU path. Selection and preview overlays are cut out of the GPU ranges.Mesh3d/MeshScene: triangle meshes in f64 world coordinates, withrelative_positionsfor an error-checked f64 to f32 conversion against a scene origin.
The crate decides how to draw, not what the geometry means: the caller maps its objects to
ObjectIds, chooses colors and stroke widths, tracks changes and calls upsert / remove.
cadkit-gpu draws the result with wgpu.
use ;
use ;
use BTreeSet;
let mut plan = new;
let wall = Line;
plan.upsert;
let view = new;
plan.prepare;
let frame = plan.frame;
assert_eq!;
From a drawing document
Enable the optional document feature for cadkit_scene::document::plan_document and
DocumentPlanOptions. This bridge adds cadkit-core and turns one document model into
plan items: it expands blocks and arrays, projects onto XY, resolves colors/lineweights
and groups items by layer. Curves that do not stay circular are flattened to polylines.
Inspect DocumentPlanReport: it counts flattened curves, dashes drawn solid, skipped
entity kinds and traversal truncation. Text, hatches/fills, points, images and viewports
are not drawn by this bridge. It does not produce a 3D mesh from a drawing document.
A frame's CPU handoff must be drawn by the host. PlanItem::force_cpu explicitly keeps an
item on that path; selection/preview cut-outs and precision failures also need host handling.
The render_png example
shows the document bridge with cadkit-gpu.
Licensed under MIT or Apache-2.0, at your option.