Skip to main content

WebAssembly

The engine, compiled to WebAssembly, runs in a Web Worker inside your page. There is no server to run: each page has its own engine.

Install​

npm install @buerli.io/classcad

Token​

Make a public access token under Access tokens on your account. It belongs in your page's code: it only works on localhost and on the domains registered on your account.

Connect​

import { init, WASMClient, BuerliCadFacade } from '@buerli.io/classcad'

init(id => new WASMClient(id, { token: 'ccpk_…' }))

const facade = new BuerliCadFacade()
await facade.connect()
const api = facade.api

const part = await api.v1.part.create({ name: 'Flange' })

connect() loads the engine from ClassCAD's CDN, fetches a key with the token and opens a drawing. The key is renewed before it expires.

To show the model, facade.createBufferGeometry(part) returns three.js geometry. buerli.io has React components for it.

Domains​

  • localhost works on every plan.
  • Your own domains: register them under Domains on your account. Pro allows one domain per seat, Business any number, wildcards included.

On any other domain the token gets no key, and the engine does not start.

Your own sign-in​

An app with its own sign-in can pass getKey instead of token: a function that returns a key. Your server gets the keys with a secret access token, which never goes into a page.

Hosting the engine yourself​

With Business, the engine's files are under Downloads on your account (WebAssembly). Serve them yourself and point the client at them:

init(id => new WASMClient(id, { token: 'ccpk_…', url: 'https://example.com/classcad/' }))