mylingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
22 lines (19 loc) • 615 B
text/typescript
import { SVGLoader, SVGResult } from "three/examples/jsm/loaders/SVGLoader"
import { forceGet } from "@lincode/utils"
import { handleProgress } from "./bytesLoaded"
const cache = new Map<string, Promise<SVGResult>>()
const loader = new SVGLoader()
export default (url: string) =>
forceGet(
cache,
url,
() =>
new Promise<SVGResult>((resolve, reject) => {
loader.load(
url,
(svg) => resolve(Object.freeze(svg)),
handleProgress(url),
reject
)
})
)