Skip to main content
You send it edit commands. It checks each command, builds the geometry again and keeps undo and redo.

Import

Example

Notes

  • Add session.root to your scene one time. It stays valid after each edit.
  • Read session.revision when an edit starts, and pass it to apply. If a different edit came first, apply throws stale-revision.
  • The session of a ProjectManager has the revision of the manager. It also goes up after each step of the views, sheets and markers, and a step of them makes an older revision stale.
  • An edit that fails changes nothing.
  • Pass onProgress to see the cost of each element of a build: the session calls it for each element of the first build and of each edit, and last for the flush, with done, total and elapsedMs.
  • A -0 in a command is saved as 0, because JSON has no -0. lastEditCommand has the 0. NaN and Infinity are rejected as invalid-command.
  • A new edit clears the redo list. undo and redo return null when there is nothing to do.
  • snapshot() returns a copy of the building model. Save this copy.
  • After an edit, get the elements again from currentBuild by their ids. A changed element can be a new object, and Floorkit then disposes the old object. A changed wall, and a door, a window or a hole on a wall, can also stay the same object with new geometry.
  • add-element, replace-element and remove-element change one slab, roof, room, stair, column, beam, railing or instance. An add rejects an id that the list has. A replace or a remove rejects an id that the list does not have, and the new element of a replace must have the same id.
  • add-asset, replace-asset and remove-asset change one asset of the model. remove-asset rejects an asset that an instance uses.
  • add-wall-type, replace-wall-type and remove-wall-type change one wall type of the model, each as one undo step. remove-wall-type rejects a type that walls use, with one wall-type-in-use issue that names the walls. add-wall-type and remove-wall-type build nothing again. replace-wall-type builds again only the walls of the storeys that hold a wall of the type; only the walls whose thickness or join changes get new bodies, so the work does not grow with the size of the building. The session refuses new layers that make a door or window of a wall stop fitting, with the fit numbers, and then nothing changes.
  • replace-wall-settings with typeRef gives a wall the thickness of its type. The location line stays in place and the openings keep their stations; the session refuses the step when a door or window stops fitting, with the fit numbers, as for a new thickness.
  • add-storey, remove-storey and replace-storey-settings change the storeys of a building. add-storey rejects a storey id that the building has, and remove-storey rejects the last storey.
  • replace-mass sets the mass of a building and the settings of all its storeys in one step. storeys is the new storey list, in its order. A storey id that stays keeps its walls and elements, a new id adds an empty storey, and a storey that is left out is removed. It rejects the removal of a storey that holds an element. Without mass, the building has no mass. massSegmentHeightCommand(model, buildingId, segmentId, height) gives this command for a new height of one segment, snapped to whole storeys.
  • add-building adds a whole building, last in the list: its storeys, their elements and its optional mass. Each id in it must be new in the whole model. The smallest valid building has one storey, and for a massing study a mass with one segment whose storeyIds names that storey and whose height is the height of the storey. remove-building removes a building and all it holds; it rejects the last building of the model.
  • replace-site replaces the site whole: boundary, lotLines, elevation, geoAnchor, trueNorthDeg and the zoning rules. Without site, the model has no site any more. The model check refuses a self-intersecting boundary and a lotLines list that does not have one class per boundary edge. Run evaluateZoning again after the step; the command does not run it. The session builds again only the storeys and the mass of the added or removed building, or only the site.
  • A batch applies several commands as one step: one revision, one build and one undo step. If one command fails, nothing changes, and the message of the error starts with the place of the command, such as command 2 of 3:. After a batch, lastEditCommand is the batch.
  • A session does not know the saved views of a project. Thus a remove-storey, a replace-mass or a remove-building that removes a storey that a plan view names passes in a session. ProjectManager.apply rejects it.
  • The history is not saved in the project file.

Constructor

Record<string, string | OpenElementDefinition>
.op sources for the document’s external-op assets, keyed by their uri, as either a raw buffer or an already-parsed definition. Fetching is the CALLER’s pre-step so this function stays synchronous — the same split .opbase uses (OPBaseOptions.assetSources). An embedded-op asset needs nothing here.
Readonly<Record<string, string>>
The colour of a mass part by its use, #rrggbb by use name, used for a part when neither it nor its mass has a color. Replaces MASS_COLORS_BY_USE whole; a use it does not list takes #a0b8c8. Pass it where the project is opened (ProjectManager build) so that the live build, the plan drawings and the sheets take the same colours.
boolean
Stamp storeyId/buildingId onto every element’s propertySet. Default true.
((progress: BuildProgress) => void)
Called after each element of the build and after the final flush, with its cost in elapsedMs. A build is synchronous: show the reports after it, or log them.

Properties

THREE.Group<THREE.Object3DEventMap>
Read-only. Stable scene node. The app may mount it once and retain it across edits.
number
Read-only. Goes up by one after each edit, undo or redo. The session of a ProjectManager shares the revision of the manager: it also goes up after each step of the views, sheets and markers.
boolean
Read-only.
boolean
Read-only.
boolean
Read-only.
BuildingEditCommand | undefined
Read-only. Caller-owned identity of the latest successfully published edit or history replay; after a batch it is the batch.
BuildResult
Read-only.

Methods

snapshot

A caller-owned copy; live preview edits never change this saved model.

apply

Return the new revision after one complete edit and compilation.

undo

Restore the preceding committed model; an empty history is a no-op.

redo

Reapply the next committed model; an empty redo history is a no-op.

refreshDisplay

Draw again the look that the host gave the bodies of the live objects of liveIds (of the whole build when omitted): their materials, shader hooks (onBeforeCompile, customProgramCacheKey) and shadow flags, also where a storey draws them through a batch, an instanced mesh or a merged fill.

setOutlineWidth

Draw the lines of the 3D build px CSS pixels wide: a wall’s outline, a body’s feature outline (setAppearance(&#123; outline &#125;)) with the silhouette of its curved faces, and the other plain lines of a storey, whether a storey merges or bakes them or an element draws them itself (a selected or hovered element). Throws: {RangeError} when px is not a finite number of at least 1.

subscribe

Notify after a committed transition; unsubscribe may be called repeatedly.

dispose

BuildingSessionError

Types

BuildingEditCommand

A single, serializable edit to an authored building model.

BuildingSessionChange

'apply' | 'undo' | 'redo' | 'restore'
required
What made the step. restore is no saved step: a step failed after it changed built objects, and the session built them again from the saved model.
number
required
The revision of the session after the step. A restore leaves the revision as it was.
readonly string[]
The live ids (keys of currentBuild.elementsById and modelObjectsById) that the step built again, added or removed, where a removed id is in the list and not in the build; absent when the whole building was built again. An element that was built again is a new object, or the same object with new geometry.

BuildingSessionErrorCode

BatchCommand

Several edits as one step, in order: all of them or none.

ReplaceBuildingModelCommand

Replace the complete strict building model as one compiled history step.

ModelObjectEditCommand

One complete saved object edit; replacement preserves authored identity and kind.

ElementListCommand

One saved edit of a storey list; a replacement keeps the element id and its list.

BuildingElementCommand

One saved edit of a building list, as the element commands edit a storey list.

AssetCommand

One saved edit of the block definitions of a model; an instance names its definition by id.

WallTypeCommand

The package does not export this type by name.

OpeningTypeCommand

Reserved edits of the model’s stamped opening-type library.

MaterialCommand

The package does not export this type by name.

SetPhaseCommand

Set or remove the phase of elements of one building, hosted openings included.
'set-phase'
required
string
required
string[]
required
BmPhase | null
required
null removes the field: the element is new again.

RoofJoinCommand

Trim one roof against another roof of its building, on any storey, or undo it: the part of roofId inside the mass of toRoofId goes, and the valley where they meet is a true edge.

StoreyCommand

One saved edit of the storeys of a building; the settings of a storey are replaced whole.

StoreyCopyCommand

Copy the elements of one storey onto one or more existing storeys of the same building, as one step; copy-storey instead makes a new storey on top of its source.
'copy-storey-to'
required
string
required
string
required
The storey that is copied.
readonly string[]
required
One storey or more of the same building: distinct, and none of them the source.
readonly StoreyCopyPart[]
The lists that are copied, each named once. Absent: every list.
boolean
true empties those lists of each target before the copy (walls also its saved joins and wall network state), so copying walls onto storeys that already hold the same walls gives no second wall. A working plane that this copy makes again ($&#123;planeId&#125;@$&#123;targetStoreyId&#125;) and that only the removed model objects used is replaced; any other plane stays, a plane made by hand included, even when nothing uses it any more. An element that stays may not refer to one that goes (invalid-command): replacing walls under a dimension that follows one needs annotations (which also replaces the target’s text and leader notes), stairs under a railing need railings, and slabs that a stair cuts need that stair replaced too. Absent or false: the copies are added.

BuildingMoveCommand

Move building buildingId by translation (world XZ metres), after turning it yawDeg degrees about origin when both are given, as one step: every storey’s walls with their doors, windows and voids, loose doors and windows, slabs, roofs with their rooflights and dormers, rooms, stairs, railings, ramps, columns, beams, chimneys, soil stacks, placed blocks, plan notes and room separators, and the building’s grid lines, working planes and mass. The package does not export this type by name.
'move-building'
required
string
required
PointXZ
required
PointXZ
The world XZ pivot of the turn, in metres. Given with yawDeg or not at all.
number
The turn in degrees, counter-clockwise seen from above (+X toward −Z), before the translation. Given with origin or not at all.

SiteRoadCommand

Add, replace or remove one road of the site (BmSite.roads), as one saved step.

SiteWaterCommand

Add, replace or remove one water of the site (BmSite.waters), as one saved step, exactly as SiteRoadCommand does a road.

ContextBuildingCommand

Add, replace or remove one context building of the site (BmSite.contextBuildings), as one saved step, exactly as SiteRoadCommand does a road.

SlabTransformCommand

One saved slab transform in world XZ coordinates, retaining its vertical placement.

SpaceTransformCommand

One saved space transform in world XZ coordinates, retaining its vertical placement.

RoofTransformCommand

One saved roof transform in world XZ coordinates, retaining its vertical placement.

StairTransformCommand

One saved stair transform in world XZ coordinates, retaining its vertical placement.

StairSlabHoleFitCommand

Fit the slab hole a stair links to (slabHole) to the stair’s plan outline, grown by margin metres, as a shaft opening is sized from its stair. The package does not export this type by name.
'fit-stair-slab-hole'
required
string
required
string
required
string
required
number
Metres, 0 or more; saved on the link as its margin.

ElementReshapeCommand

NetworkWallTranslateCommand

Translate one compiled segment by a world XZ delta through its storey’s WallNetwork: the walls joined at its ends follow.
'translate-network-wall'
required
string
required
string
required
string
required
number
required
PointXZ
required
ReshapeOpeningRule
Where the openings of a wall that follows go. keep-place (default): an opening stays where it is in the world while its segment keeps its line, and keeps its distance from the fixed end of a segment that turns. keep-station: it keeps its distance from the start of its segment. An opening that would leave its segment refuses the move and is named.

NetworkWallEndMoveCommand

Move one end of a compiled segment through its storey’s WallNetwork.
'move-network-wall-end'
required
string
required
string
required
string
required
number
required
WallEnd
required
PointXZ
required
ReshapeOpeningRule
Where the openings of the segments that change go. keep-place (default): an opening stays where it is in the world while its segment keeps its line, and keeps its distance from the fixed end of a segment that turns. keep-station: it keeps its distance from the start of its segment. An opening that would leave its segment refuses the move and is named.

WallCreateCommand

Append one complete authored wall run; openings require their own saved edit.

WallDeleteCommand

Remove the complete authored run, including every segment of a closed wall.
'delete-wall'
required
string
required
string
required
string
required
'detach' | 'delete'
What becomes of the wall’s doors and windows: 'detach' (the default) keeps them as loose openings where they are drawn; 'delete' deletes them with their host, as a person deleting a wall in the editor means. Undo brings them back either way.

WallSplitCommand

Cut wall wallId at station (metres along its centreline from its first point) into two walls with the same settings. The package does not export this type by name.

WallMergeCommand

Join wall otherWallId to wall wallId where their ends meet (within 1 mm) and remove otherWallId. The package does not export this type by name.

WallPointInsertCommand

Add a point to wall wallId at station (metres along its centreline from its first point), on a straight segment, which becomes two. The package does not export this type by name.

WallsTranslateCommand

Translate the walls wallIds of one storey by translation, as one step. The package does not export this type by name.
'translate-walls'
required
string
required
string
required
string[]
required
The walls that move whole: one or more, each once.
PointXZ
required
World XZ translation in metres.
ReshapeOpeningRule
Where the openings of a wall that follows go; see move-wall-point.

FilletWallsCommand

Round the corner where an end of wall wallIdA meets an end of wall wallIdB with a new curved wall newWallId of radius metres, in one step. The package does not export this type by name.

BendWallCommand

The package does not export this type by name.

HostedOpeningRemoveCommand

Remove one authored opening from its exact wall without changing its wall axis.

FreeOpeningRemoveCommand

Remove one exact storey-owned free door or window without changing any wall.

HostedOpeningCreateCommand

Add an authored door, window or void to its explicitly chosen wall.

FreeOpeningCreateCommand

Add one physical door or window at an explicit free pose in a storey.

FreeOpeningReplaceCommand

Replace one free door or window whole: its size, pose, type or label. The package does not export this type by name.

HostedOpeningDetachCommand

Explicitly remove a door/window from its host and place it in world XZ metres. The package does not export this type by name.

HostedOpeningRehostCommand

Move one door, window or void from its wall to a place on another wall of the same storey.
'rehost-hosted-opening'
required
string
required
string
required
string
required
string
required
string
required
number
required
Distance in metres along the saved centreline of the new wall.

ReshapeOpeningRule

Where a wall reshape puts the hosted openings of a segment that it changes. The package does not export this type by name.

ElementLists

The storey lists that the element commands edit, with the element type of each list.

BuildingElementLists

The building lists that the building element commands edit, with the element type of each.

StoreyCopyPart

A list of a storey that copy-storey-to can copy.

ProfileTransform

A rigid world XZ transform shared by authored polygon families. The package does not export this type by name.
PointXZ
required
World XZ pivot in metres.
PointXZ
required
World XZ translation in metres, applied after rotation.
number
required
Relative degrees. In a command, counter-clockwise seen from above: +X turns toward −Z. The transforms here take it turned the other way, +X toward +Z (oppositeYaw).

SlabReshapeCommand

Replace one slab’s outline and thickness.
'reshape-slab'
required
string
required
string
required
string
required
PolygonProfile
required
Outline and holes in world XZ metres.
number
required
BmSlab['arcs']
BmSlab['cornerRadii']

RoofReshapeCommand

Replace one roof’s outline and its eave height above the storey.
'reshape-roof'
required
string
required
string
required
string
required
PolygonProfile
required
Outline and holes in world XZ metres.
number
required
BmSlab['arcs']
BmSlab['cornerRadii']

SpaceReshapeCommand

Replace one room’s outline and, when given, its height.
'reshape-space'
required
string
required
string
required
string
required
PolygonProfile
required
Outline and holes in world XZ metres.
number
BmSpace['arcs']

StairReshapeCommand

Put one stair’s start point at a new place and height above the storey; a given size replaces its own.

OpeningCreateInput

The package does not export this type by name.

FramedOpening

The package does not export this type by name.
Last modified on December 1, 2026