UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

45 lines (44 loc) 1.11 kB
"use strict"; import { FileLoader, Loader } from "three"; import { isString } from "../../Type"; import { Font } from "./Font"; export class FontLoader extends Loader { constructor(manager) { super(manager); } load(url, onLoad, onProgress, onError) { const scope = this; const loader = new FileLoader(this.manager); loader.setPath(this.path); loader.setRequestHeader(this.requestHeader); loader.setWithCredentials(scope.withCredentials); loader.load( url, function(text) { if (!isString(text)) { return; } let json; try { json = JSON.parse(text); } catch (e) { console.warn( "THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead." ); json = JSON.parse(text.substring(65, text.length - 2)); } if (!json) { return; } const font = scope.parse(json); if (onLoad) onLoad(font); }, onProgress, onError ); } parse(json) { return new Font(json); } }