vehicle-generator/scripts/glb-node.ts
CRT d8f3a6e3df Vehicle Generator 0.1.0 (alpha)
Procedural, game-ready vehicles for three.js: 13 body styles, blending, seeded
random vehicles, three LODs, colliders, 13 parametric mods, paint and livery,
a rig that drives, and GLB export that a game can load and drive. Ships with a
studio (browser or Tauri desktop app) and a Play mode.
2026-10-11 00:22:23 +00:00

23 lines
746 B
TypeScript

/**
* 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 {}