import {widget as Widget} from './../widget.js' import {inferSource} from './util.js' // extensions import {default as thumb} from './../widget/thumb.js' import {default as play} from './../widget/play.js' const widget = Widget() // init extensions thumb(widget) play(widget) // init xrforge extension widget.ext.xrforge = { } // in case of Manyfold backend, a thumbnail is passed (not gltf src e.g.) // so we will infer the source-url based on the thumbnail widget.on('init.thumb', async (thumb) => { let src = widget.src const img = /\.(png|jpg|webp)/ if( src.match(img) ){ thumb.src = src let inferredSrc = await inferSource(src) widget.src = inferredSrc.replace(img,".glb") } }) widget.on("play", async () => { // initialize a specialized build of THREE/AFRAME const AFRAME = await import('aframe') window.THREE.DRACOLoader = await import('three/examples/jsm/loaders/DRACOLoader.js') window.THREE.FBXLoader = await import('three/examples/jsm/loaders/FBXLoader.js') window.THREE.USDZLoader = await import('three/examples/jsm/loaders/USDZLoader.js') window.THREE.ColladaLoader = await import('three/examples/jsm/loaders/ColladaLoader.js') window.THREE.MTLLoader = await import('three/examples/jsm/loaders/MTLLoader.js') window.THREE.GLTFExporter = await import('three/examples/jsm/exporters/GLTFExporter.js') // optional utils window.zipjs = await import("@zip.js/zip.js") window.webdav = await import("webdav") window.rs = await import("remotestoragejs") window.trystero = await import("trystero") // include xrsh (remote for now, until the final integration is more clear) const script = document.createElement("script") script.src = "https://xrsh.isvery.ninja/xrsh.js" script.addEventListener("load", function(){ const ent = document.createElement("a-entity") ent.setAttribute("isoterminal","minimized:true") ent.setAttribute("position","0 1.6 -0.3") document.querySelector("a-scene").appendChild(ent) }) document.body.appendChild(script) }) await widget.emit("init") console.dir(widget)