extensions / sd-3dmodel-loader /javascript /3d-model-loader-import.js
toto10's picture
5abb6291403b19368a3b842ea4f13b1f23694d90948b2da0ae23e85acf2bb1e9
fb54f6e
raw
history blame
1.38 kB
(function () {
if (!globalThis.threeDModelLoader) globalThis.threeDModelLoader = {};
const threeDModelLoader = globalThis.threeDModelLoader;
function load(cont) {
const scripts = cont.textContent.trim().split('\n');
const base_path = `/file=${scripts.shift()}/js`;
cont.textContent = '';
const df = document.createDocumentFragment();
for (let src of scripts) {
const script = document.createElement('script');
script.async = true;
script.type = 'module';
script.src = `file=${src}`;
df.appendChild(script);
}
globalThis.threeDModelLoader.import = async () => {
const threeDModelLoader = await import(`${base_path}/3d-model-loader.bundle.js`);
return {threeDModelLoader};
};
if (!globalThis.threeDModelLoader.imports) {
globalThis.threeDModelLoader.imports = {};
}
if (!globalThis.threeDModelLoader.imports.threeDModelLoader) {
globalThis.threeDModelLoader.imports.threeDModelLoader = async () => await import(`${base_path}/3d-model-loader.bundle.js`);
}
cont.appendChild(df);
}
onUiLoaded(function () {
webGLOutputDiv3DModel = gradioApp().querySelector('#WebGL-output-3dmodel-import');
load(webGLOutputDiv3DModel);
})
})();