Skip to main content

@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​

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​

NameDescription
ClientsStart 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).
ModelingBuerliCadFacade connects a drawing, runs the ClassCAD API on it (api.v1.*) and turns the model into three.js geometry.
Engine KeysThe 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 SharingShares 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.

NameDescription
ConnectionThe 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.