The drawings module turns a Scene's 3D content into a
technical-drawing-style 2D view. Output is a new SceneModel
whose hierarchy mirrors the source one-to-one (one SceneObject
per source SceneObject, one SceneMesh per source mesh),
so picks on the drawing can be mapped back to the source model.
buildDrawing accepts DrawingProjectionParams and writes
into the caller's target SceneModel. Internally it uses three stages,
each exposed as a submodule:
hle — CPU-side orthographic depth-buffer
rasterisation and edge-visibility testing.
fills — per-source-object filled silhouette
extraction. Shares the HLE depth buffer for pixel-aligned boundaries.
The caller creates the target SceneModel
and passes it in; buildDrawing populates it. Six face presets
resolve to axis-aligned views of the source AABB: "top",
"bottom", "front", "back", "left", "right".
if (!result.ok) { console.error(result.error); targetModel.destroy(); // partial state may exist }
The target SceneModel renders alongside the source in the same
View and picks back to source SceneObjects
by stripping "__" + targetModel.id from the picked object's id.
Source and target may also live in different Scenes. buildDrawing
reads world orientation and collision data from sourceModel.scene
and writes only to targetModel.
3) Project along an arbitrary ray
Pass a DrawingProjectionRay for oblique, diagonal, or isometric
views. forward is the camera-look direction; up (optional) selects
which world direction reads as "up" on the image.
awaitbuildDrawing({ sourceModel:scene.models["myModel"], targetModel, direction: { forward: [1, -1, 1], // looking down-and-forward up: [0, 1, 0] // world Y reads as "up" on the image } });
4) Hidden-line elimination
Pass hideHidden: true to drop edges occluded by other source meshes
along the projection direction. Pass an HLEOptions to
tune resolution, per-edge sample count, and depth bias.
Pass fill: true to emit a TrianglesPrimitive silhouette per source
SceneObject alongside the wireframe. Fill and wireframe derive from the
same depth buffer, so silhouette boundaries are pixel-aligned with the
line work. Pass a FillSpec to customise.
For drawings of large source models, pass progressive: true so the
function yields between batches of createObject calls and the
target model can update during a long build. Pass a
ProgressiveSpec for batch size and yield control.
Pass layerId to assign every emitted SceneObject to a named
ViewLayer. The host can then hide, show, or
style the drawing without touching the source model.
Point clouds, line-only models, and surface meshes without
edgeIndices produce empty drawings. canBuildDrawing reports
whether the source has geometry the projector can emit, so
callers can skip the call instead of letting it fail with a
"no projectable edges or fills" error.
The caller owns the target SceneModel, so teardown is just
targetModel.destroy(). clearDrawing is a convenience
wrapper that no-ops if the target is null or already destroyed.
Drawings
The
drawingsmodule turns a Scene's 3D content into a technical-drawing-style 2D view. Output is a new SceneModel whose hierarchy mirrors the source one-to-one (one SceneObject per source SceneObject, one SceneMesh per source mesh), so picks on the drawing can be mapped back to the source model.Pipeline
buildDrawing accepts DrawingProjectionParams and writes into the caller's target SceneModel. Internally it uses three stages, each exposed as a submodule:
Behavior
LinesPrimitivemeshes, with optional hidden-line elimination.{forward, up}rays for diagonal and isometric views.Usage
These snippets assume a Scene with a source SceneModel already loaded (via any of the SDK importers, for example
DotBIMLoaderorGLTFLoader).1) Import the entry points
2) Project onto an AABB face
The caller creates the target SceneModel and passes it in;
buildDrawingpopulates it. Six face presets resolve to axis-aligned views of the source AABB:"top","bottom","front","back","left","right".The target SceneModel renders alongside the source in the same View and picks back to source SceneObjects by stripping
"__" + targetModel.idfrom the picked object's id.Source and target may also live in different Scenes.
buildDrawingreads world orientation and collision data fromsourceModel.sceneand writes only totargetModel.3) Project along an arbitrary ray
Pass a DrawingProjectionRay for oblique, diagonal, or isometric views.
forwardis the camera-look direction;up(optional) selects which world direction reads as "up" on the image.4) Hidden-line elimination
Pass
hideHidden: trueto drop edges occluded by other source meshes along the projection direction. Pass an HLEOptions to tune resolution, per-edge sample count, and depth bias.5) Solid fills
Pass
fill: trueto emit aTrianglesPrimitivesilhouette per source SceneObject alongside the wireframe. Fill and wireframe derive from the same depth buffer, so silhouette boundaries are pixel-aligned with the line work. Pass a FillSpec to customise.To emit fills without wireframe lines, also set
lines: false.6) Section cut-away
Pass
clipto render a sliced cross-section. Two shapes:{depth}— plane perpendicular to the projection direction, at the given basis-space depth. The side closer to the camera is discarded.{point, normal}— arbitrary world-space plane. The sidenormalpoints toward is kept.7) Frame, panel, and title block
The frame is a rectangle around the projected geometry; the panel is a backing quad; the title block is placed in the bottom-right corner.
8) Progressive emission
For drawings of large source models, pass
progressive: trueso the function yields between batches ofcreateObjectcalls and the target model can update during a long build. Pass a ProgressiveSpec for batch size and yield control.9) Park drawings on their own ViewLayer
Pass
layerIdto assign every emitted SceneObject to a named ViewLayer. The host can then hide, show, or style the drawing without touching the source model.10) Guard against unprojectable sources
Point clouds, line-only models, and surface meshes without
edgeIndicesproduce empty drawings. canBuildDrawing reports whether the source has geometry the projector can emit, so callers can skip the call instead of letting it fail with a "no projectable edges or fills" error.11) Tearing down
The caller owns the target SceneModel, so teardown is just
targetModel.destroy(). clearDrawing is a convenience wrapper that no-ops if the target is null or already destroyed.