Skip to Content
Bear documentation

Bear overview

This is a package that represents buildings using JSX / TSX.

This is a pretty complex domain to model so there are some concepts that are useful to know.

TSX Elements

TSX is the authoring and code-based UX for the representation of the building. However, the TSX is simply there to express how the building is assembled in an easy-to-read-and-write way. Bear uses its own JSX runtime, not React's renderer. materialize() turns the elements into a model that consumers can query, measure, and render.

Capabilities

Beyond simply piling building products together, models must know how the different elements relate and interact with each other so they can be properly constructed. For instance, if you have a Simpson tie and some lumber, you would fasten them together differently than if you had a mortise and tenon and some lumber, while still achieving a similar structural outcome.

Capabilities allow products and assemblies to describe how they can interact with the world. For instance, an assembled wall of studs can provide a "surface" for drywall and "anchors" for drywall screws. When solving for how to cut an lay out the drywall panels, we view the stud frame was a planar surface. When figuring out where to place all the screws, we view it as a series of rectangles that we can anchor fasteners to.

Coordinate Conventions

Bear uses a right-handed, Z-up coordinate system with project units (1 pu = 1/32 inch).

Transforms are local (parent-relative)

Each node's transform is relative to its parent's coordinate frame. Consumers compose transforms top-down to produce world positions: treeToScene nests Three.js Groups (automatic parent-child composition) and sectionView explicitly multiplies parentWorldMatrix * localMatrix. This matches IFC's IfcLocalPlacement model.

Levels are elevation-only

A Level supplies a horizontal datum with translate(0, 0, elevation) by default. Its children use the enclosing building's XY frame. An explicit Level transform composes with that elevation.

Elevation props are local offsets

A component's elevation prop is relative to its parent frame (usually a Level). Floor datums refer to the top of the finish surface; roofing uses its bearing or eave datum.

BlueprintElevation reference point
LevelThe datum plane itself
FloorTop of sheathing (finish surface)
SlabTop of slab (implied at z=0 in parent frame)
RoofBottom of rafters at the low edge

A stable insertion point

Dimension-defined blueprints center their nominal plan at (0, 0): X spans [-width/2, width/2] and Y spans [-depth/2, depth/2]. Their local origin is a stable insertion point, with Z on a construction datum. It is not the centroid of the generated geometry: changing finishes, pitch or framing spacing must not move it.

BlueprintLocal origin / insertion point
BuildingPlan center at grade; default grids are Left/Right = ±width/2, Front/Back = ±depth/2
FloorPlan center at the top of sheathing, or joists when sheathing is omitted
SlabFootprint bounding-box center at the top surface; a gradient pivots through this point
GableTrusses / ScissorTrussesPlan center at chord-axis eave elevation; ridge at X = 0
Roof / RafterFramingPlan center at the low-edge rafter-bottom elevation
StudFramingWall midpoint in plan, at the base
JoistFraming with a footprintFootprint bounding-box center at the joist base

These blueprints accept transform directly. It moves the entire subtree, including children and named reference surfaces. Rotation acts about the insertion point. Roof does not inspect its ancestors' grids to choose a position.

<ScissorTrusses
  footprint={["28ft", "28ft"]}
  pitch="6:12"
  ceilingPitch="3:12"
  transform={translate(centerX, centerY, eaveZ)}
/>

To put a dimension-defined assembly's front-left corner at (x, y), translate its center to (x + width/2, y + depth/2). To rotate about some other point, compose an explicit transform or use an enclosing Assembly. There is no per-blueprint center/corner mode.

Coordinates are placements, dimensions are sizes

An explicit path, polygon, point or grid contains placement information in the parent frame, not world coordinates. Preserve that information. Walls use their authored path; Floor, Slab and footprint-based JoistFraming use centerPolygon() to derive a local footprint and its insertion point from the bounding box. Their automatic placement translates back to that point, and an optional transform acts in the resulting local frame. A footprint from (10, 20) to (30, 40) therefore stays there, with a rotation pivot at (20, 30).

Explicit Building.gridReferences are used verbatim, including imported grids. They do not move dimension-defined children. Connection-defined elements (a joist run between supports, connectors on named faces, or panels on a face) derive their placement from those references. Moving their supports moves them; an independent transform is not a substitute for that connection.

Named reference surfaces are published in their owner's local frame. resolveRef() and resolved Ref props express them in the consuming parent's frame. Surface UV coordinates can still start at a corner for panel layout; those are separate from the blueprint's XYZ origin.

Migrating corner-based models

  • GableTrusses and ScissorTrusses now center themselves. Remove wrappers that translated them by (-width/2, -depth/2). To retain an old corner placement instead, give the trusses transform={translate(width/2, depth/2, 0)} (compose this after any existing placement transform).
  • Building's default grid is centered. For an existing model authored on [0, width] × [0, depth], pass the old grid explicitly: { x: { Left: 0, Right: width }, y: { Front: 0, Back: depth } }.
  • Floor's length/width form and Roof now center at zero. Existing corner-based callers need an explicit translation to the intended center. For a Roof that previously used an enclosing grid's center, use that center, which can differ from the roof's own half dimensions.
  • Explicit Floor and Slab polygons retain their placement. Floor children now use the finish datum at Z = 0; an existing child offset measured from the old framing base must subtract the floor's total thickness. Floor and Slab rotations about X/Y now pivot on the top surface.

Building a model

The model holds the element tree, relations, resolved dimensions, diagnostics, and geometry. materialize() builds it in three stages:

  1. Collect the JSX into a tree with sizes, reference planes, and placements.
  2. Compute relations and solve dimensions, repeating to a fixed point.
  3. Build geometry once for the converged tree.

The finished tree is sealed. Each node carries its model, so a query starting from a node can also find its relations. The full pipeline contract lives in engine/architecture.md.

Consumers

Consumers take the finished model: q(model) queries it, treeToScene(model) builds a Three.js scene, and diagnosticsOf(model) reports findings. Drawings, checks, quantities, and exports all use the same model.

On this page