@rulecad/model-link

A model in a link: compressed into the URL fragment, never uploaded; STL and Bambu-ready 3MF made in the browser.

npm 0.3.3sourceMITNode >=20runs in this page
npm install @rulecad/model-link

Try it

A model made in this page, packed into a link. The model rides in the link's #fragment, which browsers never send, so nothing is uploaded.

Open in the model page
Drag to turn, scroll to zoom

Reference

Share a printable model as a link. The model is compressed into the URL's #fragment, which browsers never send to the server, so a public web page can open a private design and nothing is uploaded. It also writes STL files, and 3MF files in Bambu Studio's project layout with each part on its own filament (AMS) slot. No dependencies: it uses the browser's own CompressionStream, which Node 20+ has too.

import { fromParts, encode, decode, stl, threemf } from '@rulecad/model-link';

const model = {
  title: 'Soap tray', version: '1.0.0',
  ...fromParts([
    { name: 'tray', triangles },                                  // [[[x, y, z] ×3], …], mm, Z up
    { name: 'logo', triangles: logoTriangles, slot: 2 },          // printed in the AMS's second filament
  ]),
};
const link = `https://your-viewer.example/#m=${await encode(model)}`;

const back = await decode(link.split('#m=')[1]);
const stlBytes = stl(back);              // Uint8Array, binary STL
const zip = await threemf(back);         // Uint8Array, a .3mf (one object, two parts on slots 1 and 2)