Model - Entities
API reference for src/document/entities 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.
annotationPoints
function
Every point an annotation's own geometry carries, in a fixed order — the ONE place the per-type field layout is spelled out. Bounds, view windowing and hit-testing all read through this instead of reaching for a field that only one of the six types has (anchors, until 2026-08-16). For a radial mark the arc is sampled at centre + both axis tips, which is what bounds need and what mapAnnotationGeometry inverts.
annotationPoints(e: AnnotationEntity): Point[]draftingTextOf
function
The string a mark displays, when it carries one of its own. A dimension's measurement is NOT this: it is derived from the geometry at draw time and lives in the TextEntity inside entities; only an explicit text OVERRIDE answers here.
draftingTextOf(e: AnnotationEntity): string | undefinedentityTypeOf
function
Stream entity kind — ONE spelling with tessellation primitives: faceEntity ↔ tessellation type "faceEntity" (was "mesh"), curveEntity ↔ "curveEntity" (was "curve"), pointEntity ↔ "pointEntity". Annotation entities share AnnotationType via geometry.annotation.
entityTypeOf(e: unknown): "curveEntity" | "faceEntity" | "pointEntity" | "blockEntity" | "meshEntity" | "annotationEntity" | "sectionEntity" | "hatchEntity" | "lightEntity"isAngularDimension
function
isAngularDimension(e: unknown): e is AngularDimensionEntityisAnnotation
function
isAnnotation(e: unknown): e is AnnotationEntityisBlock
function
isBlock(e: unknown): e is BlockEntityisCurve
function
Curve-entity geometry is a PolyCurve and nothing else. A Wire (the branching B-Rep 1D graph) and a bare NurbsCurve are NOT stream geometry.
isCurve(e: unknown): e is CurveEntityisDimension
function
Any of the three MEASURED marks — what carries a style, a drawn form and the text/textPoint overrides.
isDimension(e: unknown): e is LinearDimensionEntity | RadialDimensionEntity | AngularDimensionEntityisHatch
function
Hatch sniff: geometry has cell (and typically face). Unique key.
isHatch(e: unknown): e is HatchEntityisImage
function
isImage(e: unknown): e is ImageEntityisLeader
function
isLeader(e: unknown): e is LeaderEntityisLight
function
Light sniff: geometry has lumens — the one field only an emitter has. A light is an ordinary entity kind (see LightEntity): its geometry IS the emitting shape, so nothing else in the stream needs a light-shaped flag.
isLight(e: unknown): e is LightEntityisLinearDimension
function
isLinearDimension(e: unknown): e is LinearDimensionEntityisMesh
function
isMesh(e: unknown): e is MeshEntityisPoint
function
isPoint(e: unknown): e is PointEntityisPolyCurve
function
Is this value a PolyCurve? Ordered chain of tagged segments.
isPolyCurve(value: unknown): value is PolyCurveisRadialDimension
function
isRadialDimension(e: unknown): e is RadialDimensionEntityisSection
function
isSection(e: unknown): e is SectionEntityisShell
function
isShell(e: unknown): e is ShellEntityisText
function
isText(e: unknown): e is TextEntitymapAnnotationGeometry
function
Apply a point map to an annotation geometry, rebuilding each type from its OWN fields — the counterpart of annotationPoints and the ONE place a transform or a view projection touches annotation geometry.
A radial mark cannot be point-mapped naively: its arc carries a frame, so the frame is REBUILT from the mapped centre and axis tips. That throws when the map is not a similarity in the arc's plane (a squash, or a projection seen edge-on), because the result would not be a circle and a silently wrong radius is exactly the believable-number bug the fail-loud law names.
mapAnnotationGeometry(e: AnnotationEntity, map: (p: Point) => Point): AnnotationEntity["geometry"]VIEW_FAMILIES
const
Entity-stream RUNTIME — the geometry-shape guards and the drafting helpers.
An entity is { geometry, …meta }: there is NO type discriminant tag, so an entity's kind is sniffed from the SHAPE of its geometry field. That sniffing is what this module is. Every TYPE it names — Entity and its per-kind members, BlockDefinition, Annotation — is declared in @huukhanhnguyen/types and re-exported from this package's barrel (src/index.ts); this file holds only what a declarations-only package cannot: values.
const VIEW_FAMILIES: readonly ["3d", "plan", "section", "elevation", "pattern", "detail"]