mylingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
21 lines • 910 B
JavaScript
import { TextureLoader, RepeatWrapping } from "three";
import { forceGet } from "@lincode/utils";
import { handleProgress } from "./bytesLoaded";
import { RGBELoader } from "three/examples/jsm/loaders/RGBELoader.js";
import Events from "@lincode/events";
const cache = new Map();
const textureLoader = new TextureLoader();
const rgbeLoader = new RGBELoader();
const loaded = new Events();
export default (url, onLoad) => {
onLoad && loaded.once(url, () => queueMicrotask(onLoad));
return forceGet(cache, url, () => {
const hdr = url.toLowerCase().endsWith(".hdr");
const loader = hdr ? rgbeLoader : textureLoader;
return loader.load(url, (texture) => {
texture.wrapS = texture.wrapT = RepeatWrapping;
loaded.setState(url);
}, handleProgress(url), () => loaded.setState(url));
});
};
//# sourceMappingURL=loadTexture.js.map