UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

33 lines (30 loc) 776 B
import { http } from '../../platform/net/http.js'; import { ResourceHandler } from './handler.js'; class HtmlHandler extends ResourceHandler { load(url, callback) { if (typeof url === 'string') { url = { load: url, original: url }; } http.get(url.load, { retry: this.maxRetries > 0, maxRetries: this.maxRetries }, (err, response)=>{ if (!err) { callback(null, response); } else { callback(`Error loading html resource: ${url.original} [${err}]`); } }); } openBinary(data) { this.decoder ?? (this.decoder = new TextDecoder('utf-8')); return this.decoder.decode(data); } constructor(app){ super(app, 'html'), this.decoder = null; } } export { HtmlHandler };