Skip to main content

Crate brep_render

Crate brep_render 

Source
Expand description

brep-render — the Rust rendering engine that replaced the retired viewer.

Slice 1 (requirements doc §11 R40(1)/R41): engine core + solid/face/edge display fed by the kernel feature pipeline, with native headless artifact rendering for the test suite.

Layering (the dual-target requirement — web AND desktop from one codebase):

  • scene: the renderer-agnostic scene store (scene::RenderScene), keyed by kernel names. No GPU, no window, no renderer assumptions.
  • pipeline: history request JSON → execute_history (in-process kernel call) → scene population via the kernel’s native display accessors.
  • camera: pure-math cameras (orthographic artifact framing, orbit).
  • render: the wgpu core — SceneRenderer::render_to_view(scene, camera, view, size) draws into ANY wgpu::TextureView. It never owns a window or canvas; presentation shells are thin:
    • headless: render-to-texture → readback → PNG (render_to_png), used by the brep-render-artifact binary and the test suite;
    • desktop: brep-render-desktop (feature desktop) wraps a winit window
      • surface around the same core;
    • web (later slice): a wasm canvas surface around the same core.
  • color: the name-hashed stable solid colors (byte-compatible with the previous artifact renderer’s solidColor) + sRGB helpers.

Re-exports§

pub use brep_kernel;

Modules§

camera
Pure-math cameras: the artifact framing (a faithful port of the retired artifact page’s orthographic isometric camera) and a small orbit helper for the desktop shell. f64 math throughout; f32 only at the GPU boundary.
color
Stable per-solid display colors + color-space helpers.
controls
Arcball orbit/pan/zoom (R22) — the ArcballControls feel the user base has muscle memory for, as a pure state machine over ViewCamera:
engine_state
EngineState — the windowing-agnostic viewer state machine the host UI programs against (R3): scene + camera + controls + settings + emphasis, plus the whole event/command/query surface (run-history feed, pointer/wheel ingestion, camera commands, picking, world→screen, visibility). No GPU, no canvas — the wasm Engine and the winit desktop shell both wrap this; it is fully unit-testable on native.
feature_dimensions
Feature-dimension annotations (FD-1) — the engine-native port of the original FeatureDimensionAnnotationBuilder.
features
Feature-schema access + the feature-schema → FormField mapping.
history
History — the engine-owned, editable model recipe: the ordered feature history plus the rollback index (the feature the model is currently built up to). This is the SINGLE SOURCE OF TRUTH for the model — the UI keeps NO copy; it mutates and reads the history only through crate::engine_state::EngineState methods. That keeps one engine-owned history (UI-agnostic) and converges with the in-flight “whole history in Rust” pipeline migration — later this sinks into brep-kernel-rs proper without touching the UI.
metadata
The Properties-panel DATA layer (UI comes later): a name-keyed metadata store, per-entity measurements, and object provenance — all engine-native, all crossing the R3 boundary as plain JSON/scalars.
pick
Picking in Rust (R23/R24), replacing the retired raycaster + selectionMethods._pickAtEvent: returns KERNEL NAMES with the candidate priority order VERTEX > EDGE > FACE > … > SOLID, CSS-pixel thresholds for lines/points (the earlier picker’s worldPerPixel * 6 is exactly 6 CSS px), a double-sided face toggle, and a ranked candidate list feeding the host’s multi-candidate popup. Selection-filter filtering stays in the UI layer where the filter state lives — the engine reports everything under the cursor.
pipeline
History → scene: run a whole feature history through the kernel’s native execute_history (same process, same thread — the solid registry is thread-local) and populate a RenderScene from the resident handles via the kernel’s native display payload accessor. No JSON, no typed-array boundary — the R1 promise.
render
The wgpu render core — windowing-agnostic (the dual-target seam).
runner
The history-run seam — the async RUN machine behind a trait, mirroring the platform-seam shape of brep-app/src/store.rs’s ModelStore (a trait with impls behind it, async surfaced via a poll idiom).
scene
The renderer-agnostic scene store (requirements R8–R9): display objects keyed by the SAME kernel names the feature pipeline mints, with typed metadata — no userData grab-bag, no renderer objects. Rendering, picking and feature-reference display all resolve against this one map.
sketch
Engine-native sketch mode — S0 (data model + solver plumbing + read-only display). See docs/developer/sketch-mode-rust-plan.md.
style
Render settings (R14 — the CADmaterials semantics: per-kind material variants, hover color, flat-shading toggle, user-persisted overrides) and the selection/hover emphasis state (R17/R24 — name-keyed, fed by the host’s SelectionFilter). Plain data, shared by the engine core and the wgpu renderer; JSON in/out at the R3 boundary.
view
The interactive viewer camera (R21/R25): orthographic default + perspective toggle with state-preserving switch, zoom-to-fit, dynamic depth-range fit, world-per-pixel and world→screen queries. Pure f64 math — shared verbatim by the wasm canvas shell and the winit desktop shell (dual-target directive).
visibility
Per-entity + group visibility for a solid’s faces / edges / vertices.
widgets
In-scene overlay widgets: the engine-side registry that hosts the brep-gizmos gizmos natively. It owns the widget STATE (fed as plain JSON over the R3 boundary — datum planes/axes/frames, curve display, feature dimensions, the transform gizmo, the always-on ViewCube), constructs a GizmoCamera from the engine’s live ViewCamera each frame, and emits the brep-gizmos Overlay geometry the render core converts into overlay GPU buffers. It also answers pointer hit-tests (ViewCube snap target, datum pick, transform-gizmo hover/pick) and computes transform drag deltas.