part
Import from bear/engine/part.
Interfaces
BomDef
Defined in: bear/engine/part.ts:19
BOM metadata — how this material aggregates in a bill of materials.
Properties
| Property | Type | Description |
|---|---|---|
excludeKeys? | string[] | Column keys to EXCLUDE from BOM consolidation key. Dimension-specific columns (length, shape, dimensions) that should not split BOM lines. All other columns form the BOM identity. |
unit | BomUnit | Unit for BOM quantity reporting. Default: "ea". |
PartColumn
Defined in: bear/engine/part.ts:50
A column definition for the parts list display. Materials define these to specify what identifies them and how to display it. The values are used for consolidation (grouping identical parts) and display.
Properties
| Property | Type | Description |
|---|---|---|
key | string | Property key (used for consolidation key) |
label? | string | Human-readable column header |
value | PartColumnValue | The value — UI detects type and renders appropriately |
PartDefInput
Defined in: bear/engine/part.ts:64
The definition object passed to part(): a PartSpec plus the kind.
Extends
PartSpec<P,Roles,Refs>
Type Parameters
| Type Parameter | Default type |
|---|---|
P extends object | Record<string, unknown> |
Roles extends string | string |
Refs extends string | string |
Properties
| Property | Type | Description | Inherited from |
|---|---|---|---|
bom? | BomDef | BOM aggregation metadata. If omitted, defaults to { unit: "ea" }. | PartSpec.bom |
check? | (roles, node) => readonly string[] | Physical fit against the resolved roles, read in the same frame place gets. Each returned string becomes a warning on the node, so a connector that does not suit its members says so instead of rendering a plausible lie. Runs whether or not place did. | PartSpec.check |
columns? | (node, geometry) => PartColumn[] | Generate specification columns for the parts list. | PartSpec.columns |
connects? | Record<Roles, ConnectRole> | Connection roles: each key is a prop accepting a relation target, lowered through the role's registered relation spelling. Role props stay on the node (unlike global relation props), so Ref targets resolve when the node is collected. See ConnectRole in relations.ts. | PartSpec.connects |
division | string | CSI MasterFormat division code (e.g. "06 16 00"). | PartSpec.division |
drawing? | (node) => DrawingHints | Provide drawing hints for 2D representation in architectural drawings. | PartSpec.drawing |
extents? | (props, resolved) => Box | The part's bounding box in its local frame, from its props alone (resolved holds the Surfaces its Ref props name). | PartSpec.extents |
geometry? | (props, resolved, loaded?) => Geometry | The part's solid and material, from its props and what load fetched. Defaults to the extents box, unshaded. Synchronous: the materialize that calls it owns every handle it makes. | PartSpec.geometry |
hosted? | Hosted<P> | A part that sits in a host: the faces it reads and the planes that pose it (mate.ts). | PartSpec.hosted |
kind? | NodeKind | "geometry" (default) for leaf parts that produce manifold; "assembly" for branch parts. | - |
load? | (props) => Promise<Manifold | undefined> | Fetch the solid this part is made from (a cached mesh). Awaited for the converged tree before any geometry is built, so geometry can stay synchronous; resolves to a handle the caller owns. | PartSpec.load |
loadKey? | (props) => string | What load reads from the props. Props with the same key are one shape: loaded once, shared between instances and kept across builds (shapes.ts). Without it every instance loads its own solid. | PartSpec.loadKey |
panelSize? | (props) => readonly [number, number] | Stock face dimensions in project units (U, V), before clipping to a placement. | PartSpec.panelSize |
place? | (roles, node) => TransformMatrix | Derive the part's pose in its parent frame from its resolved connection roles (given in that same frame). Runs when the part is collected and nothing authored a transform; a throw becomes a diagnostic. | PartSpec.place |
planes? | (props, resolved) => Readonly<Record<Refs, Surface>> | The named reference planes a geometry part publishes, in its local frame, keyed by the names in refs (a hanger's seat, a tee's ports). The six box faces need no entry. | PartSpec.planes |
refs? | readonly Refs[] | Named refs this part publishes (e.g. ["top"], ["ext", "int"]). | PartSpec.refs |
Type Aliases
BomUnit
type BomUnit = "ea" | "lf" | "sf" | "cf" | "cy";Defined in: bear/engine/part.ts:16
Unit of measure for BOM aggregation.
CrossSectionData
type CrossSectionData = number[][];Defined in: bear/engine/part.ts:38
Serialized polygon data for crossSection shapes in parts list. Array of [x, y] coordinate pairs defining the polygon vertices.
PartColumnValue
type PartColumnValue = string | number | boolean | CrossSectionData;Defined in: bear/engine/part.ts:43
Value type for part columns — can be primitive or shape data.
Functions
part()
function part<P, Roles, Refs>(name, def): PartDef<P, Roles, Refs>;Defined in: bear/engine/part.ts:84
Creates a tagged part definition.
Type Parameters
| Type Parameter | Default type |
|---|---|
P extends object | Record<string, unknown> |
Roles extends string | string |
Refs extends string | string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | — Human-readable type name (e.g. "Lumber", "OSB"). Sets the function's .name property, used as the default FQN segment and as the material kind in the parts list. |
def | PartDefInput<P, Roles, Refs> | Part definition: division, bom, extents, geometry, columns. Roles and Refs state the part's interface contract; naming them makes connects, place, check and planes typecheck against it. |
Returns
PartDef<P, Roles, Refs>