UNPKG

threepipe

Version:

A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.

21 lines (17 loc) 636 B
import {FileLoader, LoadingManager} from 'three' import {blobToDataURL} from 'ts-browser-helpers' export class DataUrlLoader extends FileLoader { constructor(manager: LoadingManager) { super(manager) this.responseType = 'blob' } load(url: string, onLoad?: (response: (any)) => void, onProgress?: (request: ProgressEvent) => void, onError?: (event: unknown) => void): any { return super.load(url, (res)=>{ try { onLoad?.(blobToDataURL(res as any as Blob)) } catch (e: any) { onError?.(e) } }, onProgress, onError) } }