Before you start
- Complete the quickstart in a browser app on
localhost. - Your app supplies the AI model, parses its response as JSON, and treats the result as
unknown. - Give the agent the building model contract and the requested dimensions, in metres.
Ask for building data
For the room in the quickstart, give your agent a request such as:Return validation feedback
Validate the parsed result. Send the returned issues to your agent if the document is invalid.path, a code, and a message. For example, an opening that extends past its wall is rejected. Ask the agent to correct the reported fields and validate again. Limit retries in your app and show unresolved errors to the person.
Do not accept a TypeScript cast as validation. Do not invent missing IDs, change units, or remove an invalid element silently to make the document pass.
Open the proposed project
After initialization, this function checks unknown input and creates a project with a plan of its first storey:openCandidate and keep the previous project open until the new one succeeds. A BmBuildError includes a path and a code; other build failures can be ordinary errors.
Add manager.root to your Three.js scene. For a plan that people can edit, call await manager.mountPlanEditor(container, 'agent-plan'). The container needs a width and height. See Add a plan editor.
Apply a small edit proposal
Keep the current manager when the user asks to move a door. Your app chooses the door target from the current model or selection. The agent proposes only the new offset:manager.revision before you send the request to the agent. Pass that number back when the response arrives. The host checks it before applying the edit:
building, ground, outer-walls, and front-door. The offset is measured in metres along that wall from its first point. Floorkit checks that the door fits between the joints of the wall and does not overlap another opening. A refused move has an opening-does-not-fit issue with the offsets where the door fits. If a door of the opened model does not fit at its saved offset, manager.session.currentBuild.warnings has an opening-does-not-fit warning with the same numbers. Give the agent its openingFit.nearestOffset; do not compute the fit in your app.
The revision comparison above belongs to your host application: ProjectManager.apply takes one command, not an expected revision argument. There is no await between the comparison and the edit. If you use BuildingSession directly, its apply takes the originating session revision. See Editing and history.
An accepted proposal is one step in the manager’s history. Use manager.undo() and manager.redo() for that same history. A rejected command leaves the saved model unchanged. Use the error’s path and code when available; do not replace the whole project to hide a rejected edit.
Save and reopen
Save on a user action or a timer, rather than after every frame:manager.dispose().
To produce drawings, compose a sheet and export a PDF. A GLB or PDF does not preserve the editable building document; keep the project file too.