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.

19 lines (16 loc) 597 B
import {FileLoader} from 'three' export class SimpleJSONLoader extends FileLoader { load(url: string, onLoad?: (response: (any)) => void, onProgress?: (request: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): any { return super.load(url, (res)=>{ try { if (typeof res === 'string') { onLoad?.(JSON.parse(res)) } else { throw new Error('Invalid JSON') } } catch (e: any) { onError?.(e) } }, onProgress, onError) } }