UNPKG

lingo3d

Version:

Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor

21 lines 895 B
import { assert, forceGet } from "@lincode/utils"; import { FileLoader } from "three"; import { decreaseLoadingAssetsCount, increaseLoadingAssetsCount } from "../../../states/useLoadingAssetsCount"; import { handleProgress } from "./utils/bytesLoaded"; import { assetsPathPtr } from "../../../pointers/assetsPathPointers"; const cache = new Map(); const loader = new FileLoader(); export default (url) => forceGet(cache, url, () => new Promise((resolve, reject) => { const isAssets = url.startsWith(assetsPathPtr[0]); isAssets && increaseLoadingAssetsCount(); loader.load(url, (data) => { try { assert(typeof data === "string"); const parsed = JSON.parse(data); isAssets && decreaseLoadingAssetsCount(); resolve(parsed); } catch { } }, handleProgress(url), reject); })); //# sourceMappingURL=loadJSON.js.map