Skip to content
Shapemetry

Model - Views

API reference for src/lanes/views/views, src/schema/views, src/document/views, src/validate/views on @huukhanhnguyen/model, reachable from ..

See the Guide for the ModelJSON / evaluate pipeline.

API reference

Signatures are generated from the live package .d.ts - not hand-written.

annotationNaturalDirection

function

Natural direction for the single-view annotation kinds — sheets.ts uses this to assign each one to exactly ONE of a sheet's views. A radial mark points out along its own leader; a leader points from target to landing.

annotationNaturalDirection(entity: AnnotationEntity): Point$1 | null

ArchetypeCameraOptions

type

type ArchetypeCameraOptions
// = {
    /** Matches a perspective camera's own fov — purely to size the fit
     *  distance the same way a perspective camera would frame the box, so a
     *  freshly-seeded camera looks reasonable at authoring time; the STORED
     *  camera is orthographic regardless (`type` omitted, Camera's
     *  own default). Default 45. */
    fovDegrees?: number;
    /** Extra room around the bbox, as a fraction of its half-diagonal. Default 0.1 (10%). */
    margin?: number;
    /** Section archetype: also set `near` at the box center along the view
     *  direction (a section cut through the middle of the model). */
    section?: boolean;
}

deriveArchetypeCamera

function

Seed a NEW view's camera (position/target) by fitting an orthographic camera to bbox from direction — the archetype-creation menu (packages/ui's ViewsSection: Plan/Section/Elevation) is the one consumer; an EXISTING view's camera is already a complete stored pose and needs no derivation at all. Single source of truth — the box is a snapshot passed in by the caller (the host's live scene, or a doc's own tessellated bounds), nothing is cached.

deriveArchetypeCamera(direction: PrincipalView, bbox: BoundingBox, options?: ArchetypeCameraOptions): OrthographicCamera

directionFitsView

function

True when direction lies (near enough) in the view's plane.

directionFitsView(direction: Point$1, basis: { right: Point$1; up: Point$1; }): boolean

EntityFilterResult

type

type EntityFilterResult
// = {
    passes: boolean;
    override?: ViewFilterOverride;
}

filterEntity

function

AND-combine every rule (a rule with neither equals/notEquals is a no-op filter — see ViewFilterRule's doc); collect the override of every rule the entity's value SATISFIES (later rule wins on conflicting keys). Absorbs the pre-2026-07-22 View.layers allow-list as {key:"layer", equals:[...]} — same precedent the old allow-list set: an entity with NO layer bypasses every layer-keyed rule entirely (nothing to filter or override), unlike an arbitrary attributes key, where absence fails an equals rule.

filterEntity(rules: ViewFilterRule[] | undefined, layer: string | undefined, attributes: Record<string, unknown> | undefined): EntityFilterResult

isCameraJSON

function

A COMPLETE camera: a pose plus exactly one projection field. Both, or neither, is not a camera — see the Camera union.

isCameraJSON(value: unknown): value is Camera

isCameraPoseJSON

function

Where a camera stands and what it looks at — a fold produces exactly this (a drawing takes its frame from the sheet, so it claims none).

isCameraPoseJSON(value: unknown): value is CameraBase

isSavedViewJSON

function

isSavedViewJSON(value: unknown): value is SavedView

isViewFamily

function

Saved-view RUNTIME — the guards that narrow an unknown value to a view record, family tag, camera or filter override.

The records (SavedView / Camera / ViewFilterRule / ViewFilterOverride / ViewFamily) are declared in @huukhanhnguyen/types and re-exported from this package's barrel. VIEW_FAMILIES — the runtime array isViewFamily tests against — stays beside the entity guards in ./entities.ts.

isViewFamily(value: unknown): value is ViewFamily

isViewFilterOverride

function

isViewFilterOverride(value: unknown): value is ViewFilterOverride

projectionCameraOf

function

The pose a DRAWING projects through — the folded camera, whatever named it. Every drawing is a parallel projection, so a view3d's fov only ever meant "this pose came from an orbit"; the pose itself is what the basis is built from, and projecting down it yields an axonometric (see VIEW_PLACEABLE_METHODS). A frame (fov / height) has no drawing meaning and is simply never read — which is why this returns a POSE, not a full Camera. near/far are absent on a 3D bookmark, so consumers that test them (sheets.ts's hasCut) behave as before.

Was orthographicCameraOf, which returned undefined for a view3d — that dropped the pose and silently drew every placed 3D view from the "front" default.

projectionCameraOf(view: View | FoldedView): CameraBase | undefined

resolveView

function

Resolve one view chain against the scene. Config-folds the chain first (see viewChain.ts), then runs the projection/HLR path. See the module doc for the output contract (flat entities, paint order, attributes.drafting).

scene is the ORDINARY entity stream, already tessellated and already FLAT: a drawing projects world triangles, so every BlockEntity placement must be expanded before it gets here (nodeMethods/block.ts's expandAndTessellate — the one shared expand door; Model does this for its own views/sheets). A BlockEntity that reaches this function draws nothing: it has no geometry of its own to project.

resolveView(scene: Entity[], view: View, options?: ResolveViewOptionsEx): ResolvedView

ResolveViewOptions

type

type ResolveViewOptions
// = {
    /** Sheet-level cross-view annotation assignment (sheets.ts): an
     *  annotation failing this predicate is skipped IN ADDITION to the
     *  view's own geometric foreshortening tests. Absent = geometric only. */
    includeAnnotation?: (annotation: AnnotationEntity) => boolean;
    /** `viewDetail` head only: the flat 2D content of the components[] entry
     *  the head names (Model wires `_evaluateComponentGated`, which returns
     *  the declared flat nodes' output or — by inference — a flat body, and
     *  THROWS a named error for a 3D one). Absent hook (bare-engine
     *  consumer) = fail-soft empty, same law every other by-key lookup here
     *  follows. */
    resolveDetail?: (source: string) => Entity[];
}

ResolveViewOptionsEx

type

type ResolveViewOptionsEx
// = ResolveViewOptions & FoldViewOptions

viewBasis

function

Public helper for sheets.ts's singleViewAssigner: the view's own projection basis (front default for an absent camera — see projectionOf).

viewBasis(view: View | FoldedView): { right: Point$1; up: Point$1; }

viewDetailReferenceErrors

function

Soft diagnostics: a viewDetail head whose LITERAL source names no components[] entry. Literal-only (an expression is unknowable statically) and soft, same reasoning as styleReferenceErrors — resolveView already fail-softs, drawing the named error as a note instead of throwing.

viewDetailReferenceErrors(model: ModelJSON): RegistryError[]

viewErrors

function

Hard validation for the views[] chain lane.

viewErrors(model: ModelJSON): RegistryError[]

viewFamilyOf

function

View family from the head method map (VIEW_FAMILY_OF). Headless → "3d". Never inferred from camera fields.

viewFamilyOf(view: View | FoldedView): ViewFamily
Last updated: 📖 4 min readEdit on GitHub