libassimp
0.1.0

Use in the browser

Load one artifact, resolve remote sidecars asynchronously, and move CPU work to a worker.

Open Markdown

Convert picked bytes

import { convert } from 'libassimp';const toGlb = async (file: File): Promise<Uint8Array> => {  const bytes = new Uint8Array(await file.arrayBuffer());  const { files } = await convert({ name: file.name, bytes }, { to: 'glb' });  return files[0].bytes;};

Input

objcube.obj136 B

Output

Preparing artifact…

Convert
Output
Files
WASM load

One artifact, automatic async route

Each package entry ships one Wasm artifact. During instantiation, libassimp checks for both WebAssembly.Suspending and WebAssembly.promising. A capable host uses JSPI to suspend Assimp parsing around an async resolver; every other supported host uses promise-cache replay. There is no user-agent test, alternate URL, or public mode option.

import { createAssimp } from 'libassimp';

using assimp = await createAssimp({
  wasmUrl: new URL('/assets/libassimp.wasm', location.href),
});

const bytes = new Uint8Array();
const { files } = await assimp.convert(
  { name: 'scene.gltf', bytes },
  {
    to: 'glb',
    resolve: async (name) => {
      const response = await fetch(`/models/${name}`);
      return response.ok ? new Uint8Array(await response.arrayBuffer()) : undefined;
    },
  },
);

console.log(files[0].name);

Serve Wasm with application/wasm, content-hashed immutable caching, and compression. Streaming compilation falls back to buffered compilation when MIME or host behavior requires it.

Use a worker

A conversion is CPU-heavy even when resolution suspends. Import libassimp inside a module worker and transfer input/output buffers. The artifact has no pthreads, so no cross-origin isolation headers are required.

const worker = new Worker(new URL('./convert-worker.js', import.meta.url), { type: 'module' });
worker.postMessage({ name: 'model.fbx', bytes: new Uint8Array() });

Download output

const download = (name: string, bytes: Uint8Array<ArrayBuffer>): void => {
  const url = URL.createObjectURL(new Blob([bytes]));
  const anchor = Object.assign(document.createElement('a'), { download: name, href: url });
  anchor.click();
  URL.revokeObjectURL(url);
};

The canonical compatibility matrix records browser floors and which current hosts accelerate through JSPI.

On this page