@buerli.io/classcad
Connects an app to ClassCAD, the CAD engine, and runs the ClassCAD API on its drawings: the package every buerli app starts with. The engine runs in the browser as WebAssembly, or natively behind a server; a session can be shared with other apps and with AI agents.
What it exposes
- init: sets buerli up with a factory that makes the client of each drawing.
- WASMClient: runs the engine in the browser, with a public access token (
ccpk_…). - WSClient: connects to a native engine's own WebSocket server (
classcad-cli worker). - SocketIOClient: connects to the ClassCAD server (
classcad-socketio). - onClient: prepares each client a host makes, before it connects.
- BuerliCadFacade: connects a drawing, holds its ClassCAD API (
api.v1.*) and makes three.js geometry of the model. - resolveEngineKey: an engine key from an access token, for engines an app starts itself.
- Session sharing: createInvite on a client, buildShareUrl and getShareTokenFromUrl, getSessionShareState, syncSelection, and the participants' ClientIdentity.
Example
import * as THREE from 'three'
import { init, BuerliCadFacade, WASMClient } from '@buerli.io/classcad'
// The engine in the browser; a public access token from classcad.ch/account
init(drawingId => new WASMClient(drawingId, { token: 'ccpk_…' }))
const facade = new BuerliCadFacade()
await facade.connect()
const part = (await facade.api.v1.part.create({ name: 'Part' }))!
await facade.api.v1.part.box({ id: part, length: 100, width: 60, height: 20 })
await facade.api.v1.part.cylinder({ id: part, diameter: 30, height: 50 })
// The model as three.js geometry
const geometries = await facade.createBufferGeometry(part)
const meshes = geometries?.map(geometry => new THREE.Mesh(geometry, new THREE.MeshStandardMaterial()))
API
| Name | Description |
|---|---|
| Clients | Start here: init takes a factory that makes the client of each drawing, which connects it to ClassCAD: the engine in the page (WASMClient), a native engine (WSClient) or the ClassCAD server (SocketIOClient). |
| Modeling | BuerliCadFacade connects a drawing, runs the ClassCAD API on it (api.v1.*) and turns the model into three.js geometry. |
| Engine Keys | The key an engine starts with. A public access token on the WASMClient is all most apps need; the rest is for apps with a sign-in of their own, and for servers. |
| Session Sharing | Shares a drawing's session with other apps and AI agents: invites and share links, who is in the session, what they publish, and what they have selected. |
Advanced
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on buerli itself.
| Name | Description |
|---|---|
| Connection | The protocol between a client and its engine: requests, replies, and what the engine sends back after a command (EmissionConfig). For apps that talk to the engine directly. |