/** * GLTFExporter collects its binary output through `FileReader`, a browser API * bun does not have. This covers the one method the exporter calls. Import it * before anything that loads the exporter. */ class BunFileReader { result: ArrayBuffer | string | null = null onloadend: (() => void) | null = null onerror: ((error: unknown) => void) | null = null readAsArrayBuffer(blob: Blob): void { // The exporter assigns `onloadend` after calling this, so resolve later. void blob.arrayBuffer().then( (buffer) => { this.result = buffer; this.onloadend?.() }, (error) => { this.onerror?.(error) }, ) } } const globals = globalThis as { FileReader?: unknown } globals.FileReader ??= BunFileReader export {}