var gdjs;(function(t){const s=new t.Logger("Model3DManager"),i=["model3D"];class n{constructor(r){this._loadedThreeModels=new t.ResourceCache;this._downloadedArrayBuffers=new t.ResourceCache;this._loader=null;this._dracoLoader=null;if(this._resourceLoader=r,typeof THREE!="undefined"){this._loader=new THREE_ADDONS.GLTFLoader,this._dracoLoader=new THREE_ADDONS.DRACOLoader,this._dracoLoader.setDecoderPath("./pixi-renderers/draco/gltf/"),this._loader.setDRACOLoader(this._dracoLoader);const e=new THREE.Group;e.add(new THREE.Mesh(new THREE.BoxGeometry(1,1,1),new THREE.MeshBasicMaterial({color:"#ff00ff"}))),this._invalidModel={scene:e,animations:[],cameras:[],scenes:[],asset:{},userData:{},parser:null}}}getResourceKinds(){return i}async processResource(r){const e=this._resourceLoader.getResource(r);if(!e){s.warn('Unable to find texture for resource "'+r+'".');return}const a=this._loader;if(!a)return;const d=this._downloadedArrayBuffers.get(e);if(!!d){this._downloadedArrayBuffers.delete(e);try{const o=await a.parseAsync(d,"");this._loadedThreeModels.set(e,o)}catch(o){s.error("Can't fetch the 3D model file "+e.file+", error: "+o)}}}async loadResource(r){const e=this._resourceLoader.getResource(r);if(!e){s.warn('Unable to find texture for resource "'+r+'".');return}if(!this._loader||this._loadedThreeModels.get(e))return;const d=this._resourceLoader.getFullUrl(e.file);try{const o=await fetch(d,{credentials:this._resourceLoader.checkIfCredentialsRequired(d)?"include":"omit"});if(!o.ok)throw new Error("Network response was not ok");const l=await o.arrayBuffer();this._downloadedArrayBuffers.set(e,l)}catch(o){throw s.error("Can't fetch the 3D model file "+e.file+", error: "+o),o}}getModel(r){return this._loadedThreeModels.getFromName(r)||this._invalidModel}dispose(){this._loadedThreeModels.clear(),this._downloadedArrayBuffers.clear(),this._loader=null,this._dracoLoader=null,this._invalidModel&&(this._invalidModel.cameras=[],this._invalidModel.animations=[],this._invalidModel.scenes=[],this._invalidModel.userData={},this._invalidModel.asset={},this._invalidModel.scene.clear())}unloadResource(r){const e=this._loadedThreeModels.getFromName(r.name);e&&(e.scene.clear(),this._loadedThreeModels.delete(r)),this._downloadedArrayBuffers.getFromName(r.name)&&this._downloadedArrayBuffers.delete(r)}}t.Model3DManager=n})(gdjs||(gdjs={}));
//# sourceMappingURL=Model3DManager.js.map
