BREP_render — the wgpu render/pick engine
Part of the next.BREP.io Rust B-rep kernel: cargo add BREP_render · licence summary
The windowing-agnostic rendering, picking, and viewer-state engine for the
BREP kernel (publishes on crates.io as BREP_render, lib brep_render).
It runs a kernel feature history in-process, populates a renderer-agnostic
scene store from the resident solids, and draws it with a wgpu 29 core — the
same code backing a headless artifact binary, a native winit window, and a
browser canvas.
Layering
From src/lib.rs, bottom up:
scene— the renderer-agnostic scene store (RenderScene): display objects keyed by the same kernel names the feature pipeline mints (per-face triangle ranges + names, edge polylines + names, vertices) with typed metadata. No GPU, no window.pipeline— history-request JSON → the kernel's nativeexecute_history(same process, same thread) → scene population from the resident solid handles via the kernel's display accessors. No serialization boundary between kernel and renderer. A failed feature still displays what the history did build, with diagnostics.runner— the submit/poll boundary around that pipeline.EngineStatedefaults to the synchronousInlineRunner; native hosts can install the persistentThreadRunner, and the browser app supplies its worker-backed implementation. The same channel also runs STL, OBJ and 3MF mesh reconstruction throughBREP_reconstruction(MeshImportFormat).history—History, the engine-owned editable feature history plus its rollback index.engine_state— [EngineState], the viewer brain every shell wraps: scene + camera + arcball controls + render settings, selection and hover emphasis with a selection filter, picking, the editable feature history (rollback, undo/redo — the single source of truth; UIs keep no copy), sketch mode (in-viewer 2D sketch editing: input, solving, dimensions, inference), widget overlays (transform gizmo, ViewCube, datums, feature dimensions viaBREP_gizmos), expressions, and model I/O. It also owns assembly solving/BOM/interference, exploded views, PMI views and overlays, drawing sheets, CAM operations, manufacturing instructions, motion-study playback (BREP_simulation), wire-harness routing, the 3D sketch editor (sketch3d), plugins, and the spline anchor editor. No GPU, no canvas — it is fully unit-testable on native, and everything crosses its boundary as plain JSON and scalars.render— the wgpu core.RenderCore::render_to_viewdraws a scene into anywgpu::TextureView(4x MSAA): shaded faces with per-face selection/hover emphasis, screen-constant-width edges with occluded portions dimmed rather than dropped, selected-face boundary outlines, vertex point sprites, overlays.render_to_pngadds render-to-texture → readback for headless use. Per-solid GPU buffers are retained while a solid's scene revision is unchanged, so history reruns don't re-upload unchanged solids; the same scene + camera + size + styles produce identical PNG bytes on the same device. The WGSL lives insrc/shaders.wgsl(shipped in the package).pick— CPU ray/screen-space picking over the scene's display buffers, returning kernel names with VERTEX > EDGE > FACE priority, CSS-pixel thresholds, and a ranked candidate list. Exact, deterministic, and identical on native and wasm.camera/controls/view— pure-math cameras (artifact framing, orbit/arcball, ortho/perspective).sheets— drawing sheets: the document'ssheetsblock, projection of placed PMI views onto paper with an analytic hidden-line pass, and SVG and PDF writers (a sheet PDF can embed a U3D 3D model).thumbnail— part thumbnails from a small CPU rasterizer over the scene's display meshes, so they render without a GPU device.widgets— the engine-side registry that hosts theBREP_gizmosgizmos;feature_dimensionsandconstraint_overlaysbuild draggable feature-parameter annotations and assembly-constraint overlays, andcam_simdraws the CAM simulation player's overlays.features,metadata,style,visibility— feature schemas mapped to form fields, the per-entity metadata/measurement store, render settings and emphasis state, and visibility masks.
The crate re-exports its kernel dependency as brep_render::brep_kernel,
so downstream shells can name the run-boundary types (HistoryRequest, …)
without taking their own kernel dependency and re-mirroring this crate's
kernel feature split.
Presentation shells
The render core never owns a window or canvas; the shells are thin:
- Headless:
brep-render-artifact(always built) —brep-render-artifact <history-request.json> <out.png> [width height]runs the whole history natively and writes one framed PNG. History errors are reported on stderr but still produce a frame. - Desktop (feature
desktop):brep-render-desktop <history-request.json>wraps a winit window + wgpu surface around the sameEngineState+RenderCore— orbit/pan/zoom, standard views, the ViewCube, and picking all flow through the shared state. Frames are drawn on demand (only when the state is dirty). Off by default so the headless binary builds without windowing dependencies. - Web (
wasm32only): theenginemodule is the wasm-bindgen canvas shell — attach/resize/event/camera/pick/scene-feed/settings API over a WebGPU or WebGL2 device (wgpu'swebglfeature is enabled). Every dependency on the shared path is wasm32-clean.
The interactive application host is the BREP_app crate, which embeds this
engine in an egui frame; dependency chain: BREP_app → BREP_render →
{ BREP_kernel, BREP_gizmos, BREP_reconstruction, BREP_cam,
BREP_instructions, BREP_simulation, BREP_plugins, BREP_ecad_core }.
Build and test
The crate is standalone (not a workspace member) on purpose: the kernel's own
Cargo.toml carries wasm-specific profile settings that a workspace root
would override. Native builds link the kernel with its parallel
tessellation feature; the wasm build deliberately does not.
Licence
In plain words: the crates are free to use as they are, including in a commercial project. If you fix or change something in the kernel, send the change back as a pull request to github.com/mmiscool/next.BREP.io_RUST_BREP_KERNEL. If you do not want to share your changes, buy a commercial licence from Autodrop3d LLC; with it you never have to share your code back.
The exact terms are in LICENSE.md, shipped in the crate (license-file in the manifest) and at
LICENSE.md; if this summary and the file ever differ, the file wins.
Links
- Version: 0.27.0.