@ridp/threejs 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ "use strict";const l=require("three"),H=require("vue"),Y=require("./modelSerialize-BJf_M0Ys.cjs"),Oe=require("dexie");function fe(f,e){if(e===l.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(e===l.TriangleFanDrawMode||e===l.TriangleStripDrawMode){let t=f.getIndex();if(t===null){const i=[],a=f.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)i.push(o);f.setIndex(i),t=f.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),f}const r=t.count-2,n=[];if(e===l.TriangleFanDrawMode)for(let i=1;i<=r;i++)n.push(t.getX(0)),n.push(t.getX(i)),n.push(t.getX(i+1));else for(let i=0;i<r;i++)i%2===0?(n.push(t.getX(i)),n.push(t.getX(i+1)),n.push(t.getX(i+2))):(n.push(t.getX(i+2)),n.push(t.getX(i+1)),n.push(t.getX(i)));n.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=f.clone();return s.setIndex(n),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),f}const se=new WeakMap;class Ne extends l.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,r,n){const s=new l.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,i=>{this.parse(i,t,n)},r,n)}parse(e,t,r=()=>{}){this.decodeDracoFile(e,t,null,null,l.SRGBColorSpace,r).catch(r)}decodeDracoFile(e,t,r,n,s=l.LinearSRGBColorSpace,i=()=>{}){const a={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(i)}decodeGeometry(e,t){const r=JSON.stringify(t);if(se.has(e)){const o=se.get(e);if(o.key===r)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const s=this.workerNextTaskID++,i=e.byteLength,a=this._getWorker(s,i).then(o=>(n=o,new Promise((c,d)=>{n._callbacks[s]={resolve:c,reject:d},n.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{n&&s&&this._releaseTask(n,s)}),se.set(e,{key:r,promise:a}),a}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.BufferAttribute(e.index.array,1));for(let r=0;r<e.attributes.length;r++){const n=e.attributes[r],s=n.name,i=n.array,a=n.itemSize,o=new l.BufferAttribute(i,a);s==="color"&&(this._assignVertexColorSpace(o,n.vertexColorSpace),o.normalized=!(i instanceof Float32Array)),t.setAttribute(s,o)}return t}_assignVertexColorSpace(e,t){if(t!==l.SRGBColorSpace)return;const r=new l.Color;for(let n=0,s=e.count;n<s;n++)r.fromBufferAttribute(e,n),l.ColorManagement.colorSpaceToWorking(r,l.SRGBColorSpace),e.setXYZ(n,r.r,r.g,r.b)}_loadLibrary(e,t){const r=new l.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise((n,s)=>{r.load(e,n,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(r=>{const n=r[0];e||(this.decoderConfig.wasmBinary=r[1]);const s=Pe.toString(),i=["/* draco decoder */",n,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
2
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(s){const i=s.data;switch(i.type){case"decode":n._callbacks[i.id].resolve(i);break;case"error":n._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,s){return n._taskLoad>s._taskLoad?-1:1});const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Pe(){let f,e;onmessage=function(i){const a=i.data;switch(a.type){case"init":f=a.decoderConfig,e=new Promise(function(d){f.onModuleLoaded=function(u){d({draco:u})},DracoDecoderModule(f)});break;case"decode":const o=a.buffer,c=a.taskConfig;e.then(d=>{const u=d.draco,h=new u.Decoder;try{const p=t(u,h,new Int8Array(o),c),m=p.attributes.map(y=>y.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{u.destroy(h)}});break}};function t(i,a,o,c){const d=c.attributeIDs,u=c.attributeTypes;let h,p;const m=a.GetEncodedGeometryType(o);if(m===i.TRIANGULAR_MESH)h=new i.Mesh,p=a.DecodeArrayToMesh(o,o.byteLength,h);else if(m===i.POINT_CLOUD)h=new i.PointCloud,p=a.DecodeArrayToPointCloud(o,o.byteLength,h);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||h.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const y={index:null,attributes:[]};for(const g in d){const T=self[u[g]];let S,L;if(c.useUniqueIDs)L=d[g],S=a.GetAttributeByUniqueId(h,L);else{if(L=a.GetAttributeId(h,i[d[g]]),L===-1)continue;S=a.GetAttribute(h,L)}const R=n(i,a,h,g,T,S);g==="color"&&(R.vertexColorSpace=c.vertexColorSpace),y.attributes.push(R)}return m===i.TRIANGULAR_MESH&&(y.index=r(i,a,h)),i.destroy(h),y}function r(i,a,o){const d=o.num_faces()*3,u=d*4,h=i._malloc(u);a.GetTrianglesUInt32Array(o,u,h);const p=new Uint32Array(i.HEAPF32.buffer,h,d).slice();return i._free(h),{array:p,itemSize:1}}function n(i,a,o,c,d,u){const h=u.num_components(),m=o.num_points()*h,y=m*d.BYTES_PER_ELEMENT,g=s(i,d),T=i._malloc(y);a.GetAttributeDataArrayForAllPoints(o,u,g,y,T);const S=new d(i.HEAPF32.buffer,T,m).slice();return i._free(T),{name:c,array:S,itemSize:h}}function s(i,a){switch(a){case Float32Array:return i.DT_FLOAT32;case Int8Array:return i.DT_INT8;case Int16Array:return i.DT_INT16;case Int32Array:return i.DT_INT32;case Uint8Array:return i.DT_UINT8;case Uint16Array:return i.DT_UINT16;case Uint32Array:return i.DT_UINT32}}}class De extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Be(t)}),this.register(function(t){return new Ge(t)}),this.register(function(t){return new Ye(t)}),this.register(function(t){return new Je(t)}),this.register(function(t){return new Qe(t)}),this.register(function(t){return new je(t)}),this.register(function(t){return new ze(t)}),this.register(function(t){return new Ve(t)}),this.register(function(t){return new Ke(t)}),this.register(function(t){return new Ue(t)}),this.register(function(t){return new Xe(t)}),this.register(function(t){return new He(t)}),this.register(function(t){return new We(t)}),this.register(function(t){return new qe(t)}),this.register(function(t){return new Fe(t)}),this.register(function(t){return new Ze(t)}),this.register(function(t){return new $e(t)})}load(e,t,r,n){const s=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const c=l.LoaderUtils.extractUrlBase(e);i=l.LoaderUtils.resolveURL(c,this.path)}else i=l.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){n?n(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},o=new l.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{s.parse(c,i,function(d){t(d),s.manager.itemEnd(e)},a)}catch(d){a(d)}},r,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,n){let s;const i={},a={},o=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===Me){try{i[b.KHR_BINARY_GLTF]=new et(e)}catch(u){n&&n(u);return}s=JSON.parse(i[b.KHR_BINARY_GLTF].content)}else s=JSON.parse(o.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new ft(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const u=this.pluginCallbacks[d](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,i[u.name]=!0}if(s.extensionsUsed)for(let d=0;d<s.extensionsUsed.length;++d){const u=s.extensionsUsed[d],h=s.extensionsRequired||[];switch(u){case b.KHR_MATERIALS_UNLIT:i[u]=new ve;break;case b.KHR_DRACO_MESH_COMPRESSION:i[u]=new tt(s,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:i[u]=new nt;break;case b.KHR_MESH_QUANTIZATION:i[u]=new st;break;default:h.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(i),c.setPlugins(a),c.parse(r,n)}parseAsync(e,t){const r=this;return new Promise(function(n,s){r.parse(e,t,n,s)})}}function ke(){let f={};return{get:function(e){return f[e]},add:function(e,t){f[e]=t},remove:function(e){delete f[e]},removeAll:function(){f={}}}}const b={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Fe{constructor(e){this.parser=e,this.name=b.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,n=t.length;r<n;r++){const s=t[r];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let n=t.cache.get(r);if(n)return n;const s=t.json,o=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let c;const d=new l.Color(16777215);o.color!==void 0&&d.setRGB(o.color[0],o.color[1],o.color[2],l.LinearSRGBColorSpace);const u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new l.DirectionalLight(d),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new l.PointLight(d),c.distance=u;break;case"spot":c=new l.SpotLight(d),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),v(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=t.createUniqueName(o.name||"light_"+e),n=Promise.resolve(c),t.cache.add(r,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,r=this.parser,s=r.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return r._getNodeRef(t.cache,a,o)})}}class ve{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,r){const n=[];e.color=new l.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const i=s.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],l.LinearSRGBColorSpace),e.opacity=i[3]}s.baseColorTexture!==void 0&&n.push(r.assignTexture(e,"map",s.baseColorTexture,l.SRGBColorSpace))}return Promise.all(n)}}class Ue{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class Be{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(s.push(r.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const a=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new l.Vector2(a,a)}return Promise.all(s)}}class Ge{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_DISPERSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class He{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(s)}}class je{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=n.extensions[this.name];if(i.sheenColorFactor!==void 0){const a=i.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],l.LinearSRGBColorSpace)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&s.push(r.assignTexture(t,"sheenColorMap",i.sheenColorTexture,l.SRGBColorSpace)),i.sheenRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}}class ze{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&s.push(r.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(s)}}class Ve{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&s.push(r.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const a=i.attenuationColor||[1,1,1];return t.attenuationColor=new l.Color().setRGB(a[0],a[1],a[2],l.LinearSRGBColorSpace),Promise.all(s)}}class Ke{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class Xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&s.push(r.assignTexture(t,"specularIntensityMap",i.specularTexture));const a=i.specularColorFactor||[1,1,1];return t.specularColor=new l.Color().setRGB(a[0],a[1],a[2],l.LinearSRGBColorSpace),i.specularColorTexture!==void 0&&s.push(r.assignTexture(t,"specularColorMap",i.specularColorTexture,l.SRGBColorSpace)),Promise.all(s)}}class qe{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&s.push(r.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(s)}}class We{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&s.push(r.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(s)}}class Ye{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,n=r.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const s=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,i)}}class Je{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,r=this.parser,n=r.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],a=n.images[i.source];let o=r.textureLoader;if(a.uri){const c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return r.loadTextureImage(e,i.source,o)}}class Qe{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,r=this.parser,n=r.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],a=n.images[i.source];let o=r.textureLoader;if(a.uri){const c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return r.loadTextureImage(e,i.source,o)}}class Ze{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const n=r.extensions[this.name],s=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const o=n.byteOffset||0,c=n.byteLength||0,d=n.count,u=n.byteStride,h=new Uint8Array(a,o,c);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(d,u,h,n.mode,n.filter).then(function(p){return p.buffer}):i.ready.then(function(){const p=new ArrayBuffer(d*u);return i.decodeGltfBuffer(new Uint8Array(p),d,u,h,n.mode,n.filter),p})})}else return null}}class $e{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const n=t.meshes[r.mesh];for(const c of n.primitives)if(c.mode!==N.TRIANGLES&&c.mode!==N.TRIANGLE_STRIP&&c.mode!==N.TRIANGLE_FAN&&c.mode!==void 0)return null;const i=r.extensions[this.name].attributes,a=[],o={};for(const c in i)a.push(this.parser.getDependency("accessor",i[c]).then(d=>(o[c]=d,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const d=c.pop(),u=d.isGroup?d.children:[d],h=c[0].count,p=[];for(const m of u){const y=new l.Matrix4,g=new l.Vector3,T=new l.Quaternion,S=new l.Vector3(1,1,1),L=new l.InstancedMesh(m.geometry,m.material,h);for(let R=0;R<h;R++)o.TRANSLATION&&g.fromBufferAttribute(o.TRANSLATION,R),o.ROTATION&&T.fromBufferAttribute(o.ROTATION,R),o.SCALE&&S.fromBufferAttribute(o.SCALE,R),L.setMatrixAt(R,y.compose(g,T,S));for(const R in o)if(R==="_COLOR_0"){const C=o[R];L.instanceColor=new l.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else R!=="TRANSLATION"&&R!=="ROTATION"&&R!=="SCALE"&&m.geometry.setAttribute(R,o[R]);l.Object3D.prototype.copy.call(L,m),this.parser.assignFinalMaterial(L),p.push(L)}return d.isGroup?(d.clear(),d.add(...p),d):p[0]}))}}const Me="glTF",$=12,pe={JSON:1313821514,BIN:5130562};class et{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,$),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Me)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-$,s=new DataView(e,$);let i=0;for(;i<n;){const a=s.getUint32(i,!0);i+=4;const o=s.getUint32(i,!0);if(i+=4,o===pe.JSON){const c=new Uint8Array(e,$+i,a);this.content=r.decode(c)}else if(o===pe.BIN){const c=$+i;this.body=e.slice(c,c+a)}i+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class tt{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=b.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const r=this.json,n=this.dracoLoader,s=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},o={},c={};for(const d in i){const u=ae[d]||d.toLowerCase();a[u]=i[d]}for(const d in e.attributes){const u=ae[d]||d.toLowerCase();if(i[d]!==void 0){const h=r.accessors[e.attributes[d]],p=J[h.componentType];c[u]=p.name,o[u]=h.normalized===!0}}return t.getDependency("bufferView",s).then(function(d){return new Promise(function(u,h){n.decodeDracoFile(d,function(p){for(const m in p.attributes){const y=p.attributes[m],g=o[m];g!==void 0&&(y.normalized=g)}u(p)},a,c,l.LinearSRGBColorSpace,h)})})}}class nt{constructor(){this.name=b.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class st{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class Ae extends l.Interpolant{constructor(e,t,r,n){super(e,t,r,n)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,s=e*n*3+n;for(let i=0;i!==n;i++)t[i]=r[s+i];return t}interpolate_(e,t,r,n){const s=this.resultBuffer,i=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,d=n-t,u=(r-t)/d,h=u*u,p=h*u,m=e*c,y=m-c,g=-2*p+3*h,T=p-h,S=1-g,L=T-h+u;for(let R=0;R!==a;R++){const C=i[y+R+a],D=i[y+R+o]*d,I=i[m+R+a],U=i[m+R]*d;s[R]=S*C+L*D+g*I+T*U}return s}}const rt=new l.Quaternion;class it extends Ae{interpolate_(e,t,r,n){const s=super.interpolate_(e,t,r,n);return rt.fromArray(s).normalize().toArray(s),s}}const N={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},J={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},me={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},ge={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},re={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ae={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},j={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ot={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},ie={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function at(f){return f.DefaultMaterial===void 0&&(f.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),f.DefaultMaterial}function V(f,e,t){for(const r in t.extensions)f[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=t.extensions[r])}function v(f,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(f.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ct(f,e,t){let r=!1,n=!1,s=!1;for(let c=0,d=e.length;c<d;c++){const u=e[c];if(u.POSITION!==void 0&&(r=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(s=!0),r&&n&&s)break}if(!r&&!n&&!s)return Promise.resolve(f);const i=[],a=[],o=[];for(let c=0,d=e.length;c<d;c++){const u=e[c];if(r){const h=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):f.attributes.position;i.push(h)}if(n){const h=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):f.attributes.normal;a.push(h)}if(s){const h=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):f.attributes.color;o.push(h)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o)]).then(function(c){const d=c[0],u=c[1],h=c[2];return r&&(f.morphAttributes.position=d),n&&(f.morphAttributes.normal=u),s&&(f.morphAttributes.color=h),f.morphTargetsRelative=!0,f})}function lt(f,e){if(f.updateMorphTargets(),e.weights!==void 0)for(let t=0,r=e.weights.length;t<r;t++)f.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(f.morphTargetInfluences.length===t.length){f.morphTargetDictionary={};for(let r=0,n=t.length;r<n;r++)f.morphTargetDictionary[t[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ut(f){let e;const t=f.extensions&&f.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+oe(t.attributes):e=f.indices+":"+oe(f.attributes)+":"+f.mode,f.targets!==void 0)for(let r=0,n=f.targets.length;r<n;r++)e+=":"+oe(f.targets[r]);return e}function oe(f){let e="";const t=Object.keys(f).sort();for(let r=0,n=t.length;r<n;r++)e+=t[r]+":"+f[t[r]]+";";return e}function ce(f){switch(f){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function dt(f){return f.search(/\.jpe?g($|\?)/i)>0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const ht=new l.Matrix4;class ft{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ke,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,n=-1,s=!1,i=-1;if(typeof navigator<"u"){const a=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=r&&o?parseInt(o[1],10):-1,s=a.indexOf("Firefox")>-1,i=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&n<17||s&&i<98?this.textureLoader=new l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const r=this,n=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(i){const a={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:r,userData:{}};return V(s,a,n),v(a,n),Promise.all(r._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let n=0,s=t.length;n<s;n++){const i=t[n].joints;for(let a=0,o=i.length;a<o;a++)e[i[a]].isBone=!0}for(let n=0,s=e.length;n<s;n++){const i=e[n];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(r[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;const n=r.clone(),s=(i,a)=>{const o=this.associations.get(i);o!=null&&this.associations.set(a,o);for(const[c,d]of i.children.entries())s(d,a.children[c])};return s(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const n=e(t[r]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let n=0;n<t.length;n++){const s=e(t[n]);s&&r.push(s)}return r}getDependency(e,t){const r=e+":"+t;let n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":n=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(r,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(s,i){return r.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(s,i){r.load(l.LoaderUtils.resolveURL(t.uri,n.path),s,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(r){const n=t.byteLength||0,s=t.byteOffset||0;return r.slice(s,s+n)})}loadAccessor(e){const t=this,r=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const i=re[n.type],a=J[n.componentType],o=n.normalized===!0,c=new a(n.count*i);return Promise.resolve(new l.BufferAttribute(c,i,o))}const s=[];return n.bufferView!==void 0?s.push(this.getDependency("bufferView",n.bufferView)):s.push(null),n.sparse!==void 0&&(s.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(s).then(function(i){const a=i[0],o=re[n.type],c=J[n.componentType],d=c.BYTES_PER_ELEMENT,u=d*o,h=n.byteOffset||0,p=n.bufferView!==void 0?r.bufferViews[n.bufferView].byteStride:void 0,m=n.normalized===!0;let y,g;if(p&&p!==u){const T=Math.floor(h/p),S="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+T+":"+n.count;let L=t.cache.get(S);L||(y=new c(a,T*p,n.count*p/d),L=new l.InterleavedBuffer(y,p/d),t.cache.add(S,L)),g=new l.InterleavedBufferAttribute(L,o,h%p/d,m)}else a===null?y=new c(n.count*o):y=new c(a,h,n.count*o),g=new l.BufferAttribute(y,o,m);if(n.sparse!==void 0){const T=re.SCALAR,S=J[n.sparse.indices.componentType],L=n.sparse.indices.byteOffset||0,R=n.sparse.values.byteOffset||0,C=new S(i[1],L,n.sparse.count*T),D=new c(i[2],R,n.sparse.count*o);a!==null&&(g=new l.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let I=0,U=C.length;I<U;I++){const k=C[I];if(g.setX(k,D[I*o]),o>=2&&g.setY(k,D[I*o+1]),o>=3&&g.setZ(k,D[I*o+2]),o>=4&&g.setW(k,D[I*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(e){const t=this.json,r=this.options,s=t.textures[e].source,i=t.images[s];let a=this.textureLoader;if(i.uri){const o=r.manager.getHandler(i.uri);o!==null&&(a=o)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,r){const n=this,s=this.json,i=s.textures[e],a=s.images[t],o=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(t,r).then(function(d){d.flipY=!1,d.name=i.name||a.name||"",d.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(d.name=a.uri);const h=(s.samplers||{})[i.sampler]||{};return d.magFilter=me[h.magFilter]||l.LinearFilter,d.minFilter=me[h.minFilter]||l.LinearMipmapLinearFilter,d.wrapS=ge[h.wrapS]||l.RepeatWrapping,d.wrapT=ge[h.wrapT]||l.RepeatWrapping,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==l.NearestFilter&&d.minFilter!==l.LinearFilter,n.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(e,t){const r=this,n=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const i=n.images[e],a=self.URL||self.webkitURL;let o=i.uri||"",c=!1;if(i.bufferView!==void 0)o=r.getDependency("bufferView",i.bufferView).then(function(u){c=!0;const h=new Blob([u],{type:i.mimeType});return o=a.createObjectURL(h),o});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then(function(u){return new Promise(function(h,p){let m=h;t.isImageBitmapLoader===!0&&(m=function(y){const g=new l.Texture(y);g.needsUpdate=!0,h(g)}),t.load(l.LoaderUtils.resolveURL(u,s.path),m,void 0,p)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),v(u,i),u.userData.mimeType=i.mimeType||dt(i.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[e]=d,d}assignTexture(e,t,r,n){const s=this;return this.getDependency("texture",r.index).then(function(i){if(!i)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(i=i.clone(),i.channel=r.texCoord),s.extensions[b.KHR_TEXTURE_TRANSFORM]){const a=r.extensions!==void 0?r.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=s.associations.get(i);i=s.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),s.associations.set(i,o)}}return n!==void 0&&(i.colorSpace=n),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const n=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+r.uuid;let o=this.cache.get(a);o||(o=new l.PointsMaterial,l.Material.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,o.sizeAttenuation=!1,this.cache.add(a,o)),r=o}else if(e.isLine){const a="LineBasicMaterial:"+r.uuid;let o=this.cache.get(a);o||(o=new l.LineBasicMaterial,l.Material.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,this.cache.add(a,o)),r=o}if(n||s||i){let a="ClonedMaterial:"+r.uuid+":";n&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=r.clone(),s&&(o.vertexColors=!0),i&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(r))),r=o}e.material=r}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,r=this.json,n=this.extensions,s=r.materials[e];let i;const a={},o=s.extensions||{},c=[];if(o[b.KHR_MATERIALS_UNLIT]){const u=n[b.KHR_MATERIALS_UNLIT];i=u.getMaterialType(),c.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new l.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const h=u.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],l.LinearSRGBColorSpace),a.opacity=h[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,l.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),i=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=l.DoubleSide);const d=s.alphaMode||ie.OPAQUE;if(d===ie.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,d===ie.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&i!==l.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new l.Vector2(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&i!==l.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&i!==l.MeshBasicMaterial){const u=s.emissiveFactor;a.emissive=new l.Color().setRGB(u[0],u[1],u[2],l.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&i!==l.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,l.SRGBColorSpace)),Promise.all(c).then(function(){const u=new i(a);return s.name&&(u.name=s.name),v(u,s),t.associations.set(u,{materials:e}),s.extensions&&V(n,u,s),u})}createUniqueName(e){const t=l.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,r=this.extensions,n=this.primitiveCache;function s(a){return r[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(o){return Te(o,a,t)})}const i=[];for(let a=0,o=e.length;a<o;a++){const c=e[a],d=ut(c),u=n[d];if(u)i.push(u.promise);else{let h;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?h=s(c):h=Te(new l.BufferGeometry,c,t),n[d]={primitive:c,promise:h},i.push(h)}}return Promise.all(i)}loadMesh(e){const t=this,r=this.json,n=this.extensions,s=r.meshes[e],i=s.primitives,a=[];for(let o=0,c=i.length;o<c;o++){const d=i[o].material===void 0?at(this.cache):this.getDependency("material",i[o].material);a.push(d)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),d=o[o.length-1],u=[];for(let p=0,m=d.length;p<m;p++){const y=d[p],g=i[p];let T;const S=c[p];if(g.mode===N.TRIANGLES||g.mode===N.TRIANGLE_STRIP||g.mode===N.TRIANGLE_FAN||g.mode===void 0)T=s.isSkinnedMesh===!0?new l.SkinnedMesh(y,S):new l.Mesh(y,S),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),g.mode===N.TRIANGLE_STRIP?T.geometry=fe(T.geometry,l.TriangleStripDrawMode):g.mode===N.TRIANGLE_FAN&&(T.geometry=fe(T.geometry,l.TriangleFanDrawMode));else if(g.mode===N.LINES)T=new l.LineSegments(y,S);else if(g.mode===N.LINE_STRIP)T=new l.Line(y,S);else if(g.mode===N.LINE_LOOP)T=new l.LineLoop(y,S);else if(g.mode===N.POINTS)T=new l.Points(y,S);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(T.geometry.morphAttributes).length>0&&lt(T,s),T.name=t.createUniqueName(s.name||"mesh_"+e),v(T,s),g.extensions&&V(n,T,g),t.assignFinalMaterial(T),u.push(T)}for(let p=0,m=u.length;p<m;p++)t.associations.set(u[p],{meshes:e,primitives:p});if(u.length===1)return s.extensions&&V(n,u[0],s),u[0];const h=new l.Group;s.extensions&&V(n,h,s),t.associations.set(h,{meshes:e});for(let p=0,m=u.length;p<m;p++)h.add(u[p]);return h})}loadCamera(e){let t;const r=this.json.cameras[e],n=r[r.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?t=new l.PerspectiveCamera(l.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):r.type==="orthographic"&&(t=new l.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),v(t,r),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],r=[];for(let n=0,s=t.joints.length;n<s;n++)r.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(n){const s=n.pop(),i=n,a=[],o=[];for(let c=0,d=i.length;c<d;c++){const u=i[c];if(u){a.push(u);const h=new l.Matrix4;s!==null&&h.fromArray(s.array,c*16),o.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new l.Skeleton(a,o)})}loadAnimation(e){const t=this.json,r=this,n=t.animations[e],s=n.name?n.name:"animation_"+e,i=[],a=[],o=[],c=[],d=[];for(let u=0,h=n.channels.length;u<h;u++){const p=n.channels[u],m=n.samplers[p.sampler],y=p.target,g=y.node,T=n.parameters!==void 0?n.parameters[m.input]:m.input,S=n.parameters!==void 0?n.parameters[m.output]:m.output;y.node!==void 0&&(i.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",T)),o.push(this.getDependency("accessor",S)),c.push(m),d.push(y))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(d)]).then(function(u){const h=u[0],p=u[1],m=u[2],y=u[3],g=u[4],T=[];for(let S=0,L=h.length;S<L;S++){const R=h[S],C=p[S],D=m[S],I=y[S],U=g[S];if(R===void 0)continue;R.updateMatrix&&R.updateMatrix();const k=r._createAnimationTracks(R,C,D,I,U);if(k)for(let Q=0;Q<k.length;Q++)T.push(k[Q])}return new l.AnimationClip(s,void 0,T)})}createNodeMesh(e){const t=this.json,r=this,n=t.nodes[e];return n.mesh===void 0?null:r.getDependency("mesh",n.mesh).then(function(s){const i=r._getNodeRef(r.meshCache,n.mesh,s);return n.weights!==void 0&&i.traverse(function(a){if(a.isMesh)for(let o=0,c=n.weights.length;o<c;o++)a.morphTargetInfluences[o]=n.weights[o]}),i})}loadNode(e){const t=this.json,r=this,n=t.nodes[e],s=r._loadNodeShallow(e),i=[],a=n.children||[];for(let c=0,d=a.length;c<d;c++)i.push(r.getDependency("node",a[c]));const o=n.skin===void 0?Promise.resolve(null):r.getDependency("skin",n.skin);return Promise.all([s,Promise.all(i),o]).then(function(c){const d=c[0],u=c[1],h=c[2];h!==null&&d.traverse(function(p){p.isSkinnedMesh&&p.bind(h,ht)});for(let p=0,m=u.length;p<m;p++)d.add(u[p]);return d})}_loadNodeShallow(e){const t=this.json,r=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],i=s.name?n.createUniqueName(s.name):"",a=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return o&&a.push(o),s.camera!==void 0&&a.push(n.getDependency("camera",s.camera).then(function(c){return n._getNodeRef(n.cameraCache,s.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let d;if(s.isBone===!0?d=new l.Bone:c.length>1?d=new l.Group:c.length===1?d=c[0]:d=new l.Object3D,d!==c[0])for(let u=0,h=c.length;u<h;u++)d.add(c[u]);if(s.name&&(d.userData.name=s.name,d.name=i),v(d,s),s.extensions&&V(r,d,s),s.matrix!==void 0){const u=new l.Matrix4;u.fromArray(s.matrix),d.applyMatrix4(u)}else s.translation!==void 0&&d.position.fromArray(s.translation),s.rotation!==void 0&&d.quaternion.fromArray(s.rotation),s.scale!==void 0&&d.scale.fromArray(s.scale);if(!n.associations.has(d))n.associations.set(d,{});else if(s.mesh!==void 0&&n.meshCache.refs[s.mesh]>1){const u=n.associations.get(d);n.associations.set(d,{...u})}return n.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,r=this.json.scenes[e],n=this,s=new l.Group;r.name&&(s.name=n.createUniqueName(r.name)),v(s,r),r.extensions&&V(t,s,r);const i=r.nodes||[],a=[];for(let o=0,c=i.length;o<c;o++)a.push(n.getDependency("node",i[o]));return Promise.all(a).then(function(o){for(let d=0,u=o.length;d<u;d++)s.add(o[d]);const c=d=>{const u=new Map;for(const[h,p]of n.associations)(h instanceof l.Material||h instanceof l.Texture)&&u.set(h,p);return d.traverse(h=>{const p=n.associations.get(h);p!=null&&u.set(h,p)}),u};return n.associations=c(s),s})}_createAnimationTracks(e,t,r,n,s){const i=[],a=e.name?e.name:e.uuid,o=[];j[s.path]===j.weights?e.traverse(function(h){h.morphTargetInfluences&&o.push(h.name?h.name:h.uuid)}):o.push(a);let c;switch(j[s.path]){case j.weights:c=l.NumberKeyframeTrack;break;case j.rotation:c=l.QuaternionKeyframeTrack;break;case j.translation:case j.scale:c=l.VectorKeyframeTrack;break;default:switch(r.itemSize){case 1:c=l.NumberKeyframeTrack;break;case 2:case 3:default:c=l.VectorKeyframeTrack;break}break}const d=n.interpolation!==void 0?ot[n.interpolation]:l.InterpolateLinear,u=this._getArrayFromAccessor(r);for(let h=0,p=o.length;h<p;h++){const m=new c(o[h]+"."+j[s.path],t.array,u,d);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),i.push(m)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const r=ce(t.constructor),n=new Float32Array(t.length);for(let s=0,i=t.length;s<i;s++)n[s]=t[s]*r;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(r){const n=this instanceof l.QuaternionKeyframeTrack?it:Ae;return new n(this.times,this.values,this.getValueSize()/3,r)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function pt(f,e,t){const r=e.attributes,n=new l.Box3;if(r.POSITION!==void 0){const a=t.json.accessors[r.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(n.set(new l.Vector3(o[0],o[1],o[2]),new l.Vector3(c[0],c[1],c[2])),a.normalized){const d=ce(J[a.componentType]);n.min.multiplyScalar(d),n.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new l.Vector3,o=new l.Vector3;for(let c=0,d=s.length;c<d;c++){const u=s[c];if(u.POSITION!==void 0){const h=t.json.accessors[u.POSITION],p=h.min,m=h.max;if(p!==void 0&&m!==void 0){if(o.setX(Math.max(Math.abs(p[0]),Math.abs(m[0]))),o.setY(Math.max(Math.abs(p[1]),Math.abs(m[1]))),o.setZ(Math.max(Math.abs(p[2]),Math.abs(m[2]))),h.normalized){const y=ce(J[h.componentType]);o.multiplyScalar(y)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}f.boundingBox=n;const i=new l.Sphere;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,f.boundingSphere=i}function Te(f,e,t){const r=e.attributes,n=[];function s(i,a){return t.getDependency("accessor",i).then(function(o){f.setAttribute(a,o)})}for(const i in r){const a=ae[i]||i.toLowerCase();a in f.attributes||n.push(s(r[i],a))}if(e.indices!==void 0&&!f.index){const i=t.getDependency("accessor",e.indices).then(function(a){f.setIndex(a)});n.push(i)}return l.ColorManagement.workingColorSpace!==l.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${l.ColorManagement.workingColorSpace}" not supported.`),v(f,e),pt(f,e,t),Promise.all(n).then(function(){return e.targets!==void 0?ct(f,e.targets,t):f})}const M={c:null,u:[new l.Vector3,new l.Vector3,new l.Vector3],e:[]},A={c:null,u:[new l.Vector3,new l.Vector3,new l.Vector3],e:[]},E=[[],[],[]],x=[[],[],[]],w=[],K=new l.Vector3,X=new l.Vector3,q=new l.Vector3,_=new l.Vector3,ye=new l.Vector3,xe=new l.Vector3,P=new l.Matrix3,Re=new l.Box3,ee=new l.Matrix4,be=new l.Matrix4,Se=new l.Ray;class le{constructor(e=new l.Vector3,t=new l.Vector3,r=new l.Matrix3){this.center=e,this.halfSize=t,this.rotation=r}set(e,t,r){return this.center=e,this.halfSize=t,this.rotation=r,this}copy(e){return this.center.copy(e.center),this.halfSize.copy(e.halfSize),this.rotation.copy(e.rotation),this}clone(){return new this.constructor().copy(this)}getSize(e){return e.copy(this.halfSize).multiplyScalar(2)}clampPoint(e,t){const r=this.halfSize;_.subVectors(e,this.center),this.rotation.extractBasis(K,X,q),t.copy(this.center);const n=l.MathUtils.clamp(_.dot(K),-r.x,r.x);t.add(K.multiplyScalar(n));const s=l.MathUtils.clamp(_.dot(X),-r.y,r.y);t.add(X.multiplyScalar(s));const i=l.MathUtils.clamp(_.dot(q),-r.z,r.z);return t.add(q.multiplyScalar(i)),t}containsPoint(e){return _.subVectors(e,this.center),this.rotation.extractBasis(K,X,q),Math.abs(_.dot(K))<=this.halfSize.x&&Math.abs(_.dot(X))<=this.halfSize.y&&Math.abs(_.dot(q))<=this.halfSize.z}intersectsBox3(e){return this.intersectsOBB(mt.fromBox3(e))}intersectsSphere(e){return this.clampPoint(e.center,xe),xe.distanceToSquared(e.center)<=e.radius*e.radius}intersectsOBB(e,t=Number.EPSILON){M.c=this.center,M.e[0]=this.halfSize.x,M.e[1]=this.halfSize.y,M.e[2]=this.halfSize.z,this.rotation.extractBasis(M.u[0],M.u[1],M.u[2]),A.c=e.center,A.e[0]=e.halfSize.x,A.e[1]=e.halfSize.y,A.e[2]=e.halfSize.z,e.rotation.extractBasis(A.u[0],A.u[1],A.u[2]);for(let s=0;s<3;s++)for(let i=0;i<3;i++)E[s][i]=M.u[s].dot(A.u[i]);_.subVectors(A.c,M.c),w[0]=_.dot(M.u[0]),w[1]=_.dot(M.u[1]),w[2]=_.dot(M.u[2]);for(let s=0;s<3;s++)for(let i=0;i<3;i++)x[s][i]=Math.abs(E[s][i])+t;let r,n;for(let s=0;s<3;s++)if(r=M.e[s],n=A.e[0]*x[s][0]+A.e[1]*x[s][1]+A.e[2]*x[s][2],Math.abs(w[s])>r+n)return!1;for(let s=0;s<3;s++)if(r=M.e[0]*x[0][s]+M.e[1]*x[1][s]+M.e[2]*x[2][s],n=A.e[s],Math.abs(w[0]*E[0][s]+w[1]*E[1][s]+w[2]*E[2][s])>r+n)return!1;return r=M.e[1]*x[2][0]+M.e[2]*x[1][0],n=A.e[1]*x[0][2]+A.e[2]*x[0][1],!(Math.abs(w[2]*E[1][0]-w[1]*E[2][0])>r+n||(r=M.e[1]*x[2][1]+M.e[2]*x[1][1],n=A.e[0]*x[0][2]+A.e[2]*x[0][0],Math.abs(w[2]*E[1][1]-w[1]*E[2][1])>r+n)||(r=M.e[1]*x[2][2]+M.e[2]*x[1][2],n=A.e[0]*x[0][1]+A.e[1]*x[0][0],Math.abs(w[2]*E[1][2]-w[1]*E[2][2])>r+n)||(r=M.e[0]*x[2][0]+M.e[2]*x[0][0],n=A.e[1]*x[1][2]+A.e[2]*x[1][1],Math.abs(w[0]*E[2][0]-w[2]*E[0][0])>r+n)||(r=M.e[0]*x[2][1]+M.e[2]*x[0][1],n=A.e[0]*x[1][2]+A.e[2]*x[1][0],Math.abs(w[0]*E[2][1]-w[2]*E[0][1])>r+n)||(r=M.e[0]*x[2][2]+M.e[2]*x[0][2],n=A.e[0]*x[1][1]+A.e[1]*x[1][0],Math.abs(w[0]*E[2][2]-w[2]*E[0][2])>r+n)||(r=M.e[0]*x[1][0]+M.e[1]*x[0][0],n=A.e[1]*x[2][2]+A.e[2]*x[2][1],Math.abs(w[1]*E[0][0]-w[0]*E[1][0])>r+n)||(r=M.e[0]*x[1][1]+M.e[1]*x[0][1],n=A.e[0]*x[2][2]+A.e[2]*x[2][0],Math.abs(w[1]*E[0][1]-w[0]*E[1][1])>r+n)||(r=M.e[0]*x[1][2]+M.e[1]*x[0][2],n=A.e[0]*x[2][1]+A.e[1]*x[2][0],Math.abs(w[1]*E[0][2]-w[0]*E[1][2])>r+n))}intersectsPlane(e){this.rotation.extractBasis(K,X,q);const t=this.halfSize.x*Math.abs(e.normal.dot(K))+this.halfSize.y*Math.abs(e.normal.dot(X))+this.halfSize.z*Math.abs(e.normal.dot(q)),r=e.normal.dot(this.center)-e.constant;return Math.abs(r)<=t}intersectRay(e,t){return this.getSize(ye),Re.setFromCenterAndSize(_.set(0,0,0),ye),ee.setFromMatrix3(this.rotation),ee.setPosition(this.center),be.copy(ee).invert(),Se.copy(e).applyMatrix4(be),Se.intersectBox(Re,t)?t.applyMatrix4(ee):null}intersectsRay(e){return this.intersectRay(e,_)!==null}fromBox3(e){return e.getCenter(this.center),e.getSize(this.halfSize).multiplyScalar(.5),this.rotation.identity(),this}equals(e){return e.center.equals(this.center)&&e.halfSize.equals(this.halfSize)&&e.rotation.equals(this.rotation)}applyMatrix4(e){const t=e.elements;let r=_.set(t[0],t[1],t[2]).length();const n=_.set(t[4],t[5],t[6]).length(),s=_.set(t[8],t[9],t[10]).length();e.determinant()<0&&(r=-r),P.setFromMatrix4(e);const a=1/r,o=1/n,c=1/s;return P.elements[0]*=a,P.elements[1]*=a,P.elements[2]*=a,P.elements[3]*=o,P.elements[4]*=o,P.elements[5]*=o,P.elements[6]*=c,P.elements[7]*=c,P.elements[8]*=c,this.rotation.multiply(P),this.halfSize.x*=r,this.halfSize.y*=n,this.halfSize.z*=s,_.setFromMatrixPosition(e),this.center.add(_),this}}const mt=new le,gt={enableDamping:!0,dampingFactor:.25,screenSpacePanning:!1,minDistance:.1,maxDistance:1e3,maxPolarAngle:l.MathUtils.degToRad(60)};function Tt(f,e){const t=Object.assign({css3d:!1,stats:!1,renderType:"change",control:{init:!0,options:{}}},e||{});let r,n,s,i=[];const a=H.ref(!1),o=H.shallowRef(),c=H.ref(0),d=H.ref(0),u=new l.WebGLRenderer({antialias:!0,alpha:!0,precision:"mediump",logarithmicDepthBuffer:!0}),h=new l.Scene({}),p=new l.PerspectiveCamera(50,1,.1,2e3),m=Math.tan(Math.PI/180*p.fov/2);let y=!1;u.setPixelRatio(window.devicePixelRatio);function g(){a.value=!1;const O=U();c.value=O[0],d.value=O[1],p.aspect=c.value/d.value,p.position.set(47,39,100),p.fov=360/Math.PI*Math.atan(m*(d.value/c.value)),p.lookAt(0,0,0),p.updateProjectionMatrix(),u.setSize(c.value,d.value),r.appendChild(u.domElement),t.stats&&k(),t.css3d&&Le();let B;if(t.control&&t.control.init){B=Y.createOrbitControl(p,u.domElement);const G=Object.assign(gt,t.control.options||{});Object.keys(G).forEach(Z=>{B[Z]=G[Z]})}return H.nextTick(()=>a.value=!0),B}function T(O){O.preventDefault(),cancelAnimationFrame(R)}function S(O){O.preventDefault(),g(),R()}function L(O){i.push(O)}function R(O){i&&i.length&&i.forEach(B=>{typeof B=="function"&&B()}),t.renderType==="loop"&&C(),requestAnimationFrame(R)}function C(){y=!1,n&&n.update(),o.value&&o.value.update(),u.render(h,p),s&&s.render(h,p)}function D(){y||(y=!0,requestAnimationFrame(C))}function I(){H.nextTick(()=>{const O=U();c.value=O[0],d.value=O[1],p.aspect=c.value/d.value,p.fov=360/Math.PI*Math.atan(m*(d.value/c.value)),p.updateProjectionMatrix(),p.lookAt(h.position),u.setSize(c.value,d.value),s&&s.setSize(c.value,d.value),C()})}function U(){return r=document.querySelector(f),r?[r.clientWidth,r.clientHeight]:[0,0]}function k(){n=new Y.Stats,n.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r.appendChild(n.dom)}function Q(O,B,G,Z,ue){const de=new l.Box3().setFromObject(O),he=de.getSize(new l.Vector3).length(),z=de.getCenter(new l.Vector3);ue&&z.add(ue);const _e=he*B*.5,Ce=l.MathUtils.degToRad(G.fov*.5),Ie=_e/Math.tan(Ce),ne=new l.Vector3().subVectors(G.position,z).multiply(new l.Vector3(1,1,1)).normalize().multiplyScalar(Ie).add(z),W={x:ne.x,y:ne.y,z:ne.z,lookAt_x:z.x,lookAt_y:z.y,lookAt_z:z.z};return G.position.set(W.x,W.y,W.z),G.lookAt(W.lookAt_x,W.lookAt_y,W.lookAt_z),G.updateProjectionMatrix(),Z.target.copy(z),Z.update(),he}function Le(){s=new Y.CSS3DRenderer,s.setSize(c.value,d.value),s.domElement.style.position="absolute",s.domElement.style.top=0,s.domElement.style.left=0,s.domElement.style.pointerEvents="none",r.appendChild(s.domElement)}function Ee(){Y.disposeThreeObject(h)}return H.onMounted(()=>{o.value=g(),window.addEventListener("resize",I,!1),u.domElement.addEventListener("webglcontextlost",T,!1),u.domElement.addEventListener("webglcontextrestored",S,!1),t.renderType==="loop"?requestAnimationFrame(R):t.renderType==="change"&&o.value&&o.value.addEventListener("change",D)}),H.onUnmounted(()=>{cancelAnimationFrame(R),u.domElement.removeEventListener("resize",I,!1),u.domElement.removeEventListener("webglcontextlost",T,!1),u.domElement.removeEventListener("webglcontextrestored",S,!1),Ee()}),{addAnimate:L,frameArea:Q,onRender:C,css3dRenderer:s,scene:h,camera:p,control:o,renderer:u,domWidth:c,domHeight:d,isReady:a}}const yt=(f="app")=>{const e=new l.Raycaster;e.params.Line.threshold=8;const t=new l.Vector2,r=document.getElementById(f);function n(a,o){const{scaleX:c,scaleY:d}=i(r),{clientWidth:u,clientHeight:h}=o,p=o.getBoundingClientRect(),m=u*c,y=h*d,g=a.clientX-p.left,T=a.clientY-p.top;return t.x=(a.clientX-p.left)/m*2-1,t.y=-((a.clientY-p.top)/y)*2+1,{pointer:t,x:g,y:T}}function s(a,o,c,d){const{pointer:u,x:h,y:p}=n(a,o);return e.setFromCamera(u,c),{intersects:e.intersectObjects(d),pointer:u,x:h,y:p}}function i(a){const o=window.getComputedStyle(a),c=o.transform||o.webkitTransform||o.mozTransform;if(c&&c!=="none"){const d=c.match(/^matrix\((.+)\)$/);if(d){const u=d[1].split(", "),h=parseFloat(u[0]),p=parseFloat(u[3]);return{scaleX:h,scaleY:p}}}return{scaleX:1,scaleY:1}}return{raycaster:e,pointer:t,getPointer:n,getScale:i,getIntersects:s}},F=[],xt=new l.Color(16711680),Rt=()=>{const f=()=>{F.splice(0)},e=(a,o)=>{o.traverse(c=>{c&&t(a,c)})},t=(a,o)=>{if(o.userData.needCheck&&(o.autoUpdateMatrix=!1,o.updateMatrix(),o.updateMatrixWorld(),o.isMesh)){const c=new l.Box3(new l.Vector3).setFromObject(o);o.geometry.userData.obb=new le,o.geometry.userData.obb.halfSize.copy(c.getSize(new l.Vector3)).multiplyScalar(.5).multiplyScalar(.88),o.userData.obb=new le,o.userData.originColor=o.material.color.clone(),o.userData.parentUid=a,F.push({object:o,parentUid:a})}};return{resetObbs:f,initObb:e,getObbObjectByParentUid:a=>F.filter(o=>o.parentUid===a),addObbFromArray:(a,o)=>{for(let c=0,d=o.length;c<d;c++)t(a,o[c])},removeObbFromArray:a=>{const o=F.filter(c=>!a.includes(c.object));F.splice(0,F.length,...o)},removeUidObb:a=>{for(let o=F.length-1;o>=0;o--)F[o].parentUid===a&&F.splice(o,1)}}};class we{constructor(e="threeJsIDBCache",t=3){this.version=t,this.dbName=e,this.dbInit()}dbInit(){this.db=new Oe(this.dbName),this.materialMap={},this.db.version(this.version).stores({models:"&path, version, data"})}getDatabase(){return this.db}async cacheModel(e,t,r){console.log("[ ] ====> path, modelData, version",e,t,r);try{this.db.table("models").put({version:r,path:e,data:t}).then(()=>{console.log(`Model "${e}" cached successfully in table models`)})}catch{console.log(" 缓存模型失败 =====> ")}return t}async loadCachedModel(e,t){let r=null;try{if(r=await this.db.table("models").get(e),!r)return console.warn(`Model "${t}" not found in table models`),null;if(r.version!==t)return console.log(" =====> 模型版本不一致, 清除当前记录"),await this.db.table("models").delete(e),null}catch{return console.log(" =====> 查询表中模型失败"),this.db.delete().then(()=>{this.init()}),null}return r.data}}let te;const bt=()=>{const f=new De,e=new Ne;e.setDecoderPath("/draco/"),f.setDRACOLoader(e);function t(s,i,a,o){return f.load(s,i,a,o)}function r(s,i){return new Promise((a,o)=>{f.load(s,a,i,o)})}async function n(s,i,a=!0,o){te||(te=new we);const c=await te.loadCachedModel(s,i);return c?a?Y.dataToObject3D(c):c:new Promise((d,u)=>{f.load(s,d,o,u)}).then(async d=>{const u=Y.object3DToData(d.scene);return te.cacheModel(s,u,i),a?d.scene:u})}return{load:t,asyncLoad:r,asyncCacheLoad:n}};exports.IDBCache=we;exports.intersectColor=xt;exports.obbObjects=F;exports.useGLTFLoader=bt;exports.useObb=Rt;exports.useRaycaster=yt;exports.useThreeJs=Tt;
package/dist/utils.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./modelSerialize-Ds_2KBaA.cjs"),r=require("./common-C1rNPPkt.cjs");exports.ImageLoader=e.ImageLoader;exports.createArrowHelper=e.createArrowHelper;exports.createAxesHelper=e.createAxesHelper;exports.createBox3Helper=e.createBox3Helper;exports.createCameraHelper=e.createCameraHelper;exports.createGridHelper=e.createGridHelper;exports.createMapControls=e.createMapControls;exports.createOrbitControl=e.createOrbitControl;exports.createRaycaster=e.createRaycaster;exports.createStats=e.createStats;exports.dataToObject3D=e.dataToObject3D;exports.disposeThreeObject=e.disposeThreeObject;exports.initEnvImage=e.initEnvImage;exports.object3DToData=e.object3DToData;exports.createInfoPlane=r.createInfoPlane;exports.createTagPlane=r.createTagPlane;exports.getCommonParent=r.getCommonParent;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./modelSerialize-BJf_M0Ys.cjs"),a=require("./common-lRDriwln.cjs");exports.ImageLoader=e.ImageLoader;exports.createArrowHelper=e.createArrowHelper;exports.createAxesHelper=e.createAxesHelper;exports.createBox3Helper=e.createBox3Helper;exports.createCameraHelper=e.createCameraHelper;exports.createGridHelper=e.createGridHelper;exports.createMapControls=e.createMapControls;exports.createOrbitControl=e.createOrbitControl;exports.createRaycaster=e.createRaycaster;exports.createStats=e.createStats;exports.dataToObject3D=e.dataToObject3D;exports.dataToObject3DSync=e.dataToObject3DSync;exports.disposeThreeObject=e.disposeThreeObject;exports.initEnvImage=e.initEnvImage;exports.object3DToData=e.object3DToData;exports.object3DToDataSync=e.object3DToDataSync;exports.createInfoPlane=a.createInfoPlane;exports.createTagPlane=a.createTagPlane;exports.getCommonParent=a.getCommonParent;
package/dist/utils.js CHANGED
@@ -1,21 +1,23 @@
1
- import { I as r, h as t, g as s, b as o, c, a as l, e as n, d as p, f as m, i as g, l as i, j as b, k as d, o as H } from "./modelSerialize-5oJb1ka7.js";
2
- import { c as j, a as x, g as C } from "./common-D1_IztgM.js";
1
+ import { I as r, h as t, g as s, b as o, c, a as n, e as l, d as p, f as m, i as b, m as d, n as g, j as i, k as j, o as D, l as T } from "./modelSerialize-BybDeWER.js";
2
+ import { c as f, a as x, g as C } from "./common-C8KE_lHC.js";
3
3
  export {
4
4
  r as ImageLoader,
5
5
  t as createArrowHelper,
6
6
  s as createAxesHelper,
7
7
  o as createBox3Helper,
8
8
  c as createCameraHelper,
9
- l as createGridHelper,
10
- j as createInfoPlane,
11
- n as createMapControls,
9
+ n as createGridHelper,
10
+ f as createInfoPlane,
11
+ l as createMapControls,
12
12
  p as createOrbitControl,
13
13
  m as createRaycaster,
14
- g as createStats,
14
+ b as createStats,
15
15
  x as createTagPlane,
16
- i as dataToObject3D,
17
- b as disposeThreeObject,
16
+ d as dataToObject3D,
17
+ g as dataToObject3DSync,
18
+ i as disposeThreeObject,
18
19
  C as getCommonParent,
19
- d as initEnvImage,
20
- H as object3DToData
20
+ j as initEnvImage,
21
+ D as object3DToData,
22
+ T as object3DToDataSync
21
23
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ridp/threejs",
3
3
  "private": false,
4
- "version": "1.3.0",
4
+ "version": "1.3.2",
5
5
  "type": "module",
6
6
  "main": "dist/threejs.js",
7
7
  "exports": {
package/readme.md CHANGED
@@ -1,7 +1,27 @@
1
1
  # @ridp/threejs
2
2
 
3
- ## Hooks
4
3
 
4
+ ## 安装
5
+
6
+ 本库依赖以下 peer dependencies:
7
+
8
+ ```json
9
+ "peerDependencies": {
10
+ "dexie": ">=4.0.0 <5.0.0",
11
+ "vue": ">=3.0.0 <4.0.0",
12
+ "three": ">=0.178.0 <1.0.0"
13
+ }
14
+ ```
15
+
16
+ 请一并安装
17
+
18
+ ```bash
19
+
20
+ npm install @ridp/threejs dexie@^4 vue@^3 three@^0.178
21
+
22
+ ```
23
+
24
+ ## Hooks
5
25
  - useThreeJs
6
26
  声明:
7
27
 
@@ -1,5 +0,0 @@
1
- "use strict";const o=require("three");function ct(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:()=>e[i]})}}return t.default=e,Object.freeze(t)}const Y=ct(o);var G=function(){var e=0,t=document.createElement("div");t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",function(_){_.preventDefault(),n(++e%t.children.length)},!1);function i(_){return t.appendChild(_.dom),_}function n(_){for(var l=0;l<t.children.length;l++)t.children[l].style.display=l===_?"block":"none";e=_}var h=(performance||Date).now(),p=h,r=0,y=i(new G.Panel("FPS","#0ff","#002")),P=i(new G.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var w=i(new G.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:t,addPanel:i,showPanel:n,begin:function(){h=(performance||Date).now()},end:function(){r++;var _=(performance||Date).now();if(P.update(_-h,200),_>=p+1e3&&(y.update(r*1e3/(_-p),100),p=_,r=0,w)){var l=performance.memory;w.update(l.usedJSHeapSize/1048576,l.jsHeapSizeLimit/1048576)}return _},update:function(){h=this.end()},domElement:t,setMode:n}};G.Panel=function(e,t,i){var n=1/0,h=0,p=Math.round,r=p(window.devicePixelRatio||1),y=80*r,P=48*r,w=3*r,_=2*r,l=3*r,A=15*r,L=74*r,C=30*r,v=document.createElement("canvas");v.width=y,v.height=P,v.style.cssText="width:80px;height:48px";var a=v.getContext("2d");return a.font="bold "+9*r+"px Helvetica,Arial,sans-serif",a.textBaseline="top",a.fillStyle=i,a.fillRect(0,0,y,P),a.fillStyle=t,a.fillText(e,w,_),a.fillRect(l,A,L,C),a.fillStyle=i,a.globalAlpha=.9,a.fillRect(l,A,L,C),{dom:v,update:function(s,M){n=Math.min(n,s),h=Math.max(h,s),a.fillStyle=i,a.globalAlpha=1,a.fillRect(0,0,y,A),a.fillStyle=t,a.fillText(p(s)+" "+e+" ("+p(n)+"-"+p(h)+")",w,_),a.drawImage(v,l+r,A,L-r,C,l,A,L-r,C),a.fillRect(l+L-r,A,r,C),a.fillStyle=i,a.globalAlpha=.9,a.fillRect(l+L-r,A,r,p((1-s/M)*C))}}};const Q=new o.Vector3,pt=new o.Quaternion,J=new o.Vector3;class dt extends o.Object3D{constructor(t=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=t,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.addEventListener("removed",function(){this.traverse(function(i){i.element instanceof i.element.ownerDocument.defaultView.Element&&i.element.parentNode!==null&&i.element.remove()})})}copy(t,i){return super.copy(t,i),this.element=t.element.cloneNode(!0),this}}class ut extends dt{constructor(t){super(t),this.isCSS3DSprite=!0,this.rotation2D=0}copy(t,i){return super.copy(t,i),this.rotation2D=t.rotation2D,this}}const I=new o.Matrix4,mt=new o.Matrix4;class _t{constructor(t={}){const i=this;let n,h,p,r;const y={camera:{style:""},objects:new WeakMap},P=t.element!==void 0?t.element:document.createElement("div");P.style.overflow="hidden",this.domElement=P;const w=document.createElement("div");w.style.transformOrigin="0 0",w.style.pointerEvents="none",P.appendChild(w);const _=document.createElement("div");_.style.transformStyle="preserve-3d",w.appendChild(_),this.getSize=function(){return{width:n,height:h}},this.render=function(a,s){const M=s.projectionMatrix.elements[5]*r;s.view&&s.view.enabled?(w.style.transform=`translate( ${-s.view.offsetX*(n/s.view.width)}px, ${-s.view.offsetY*(h/s.view.height)}px )`,w.style.transform+=`scale( ${s.view.fullWidth/s.view.width}, ${s.view.fullHeight/s.view.height} )`):w.style.transform="",a.matrixWorldAutoUpdate===!0&&a.updateMatrixWorld(),s.parent===null&&s.matrixWorldAutoUpdate===!0&&s.updateMatrixWorld();let z,R;s.isOrthographicCamera&&(z=-(s.right+s.left)/2,R=(s.top+s.bottom)/2);const O=s.view&&s.view.enabled?s.view.height/s.view.fullHeight:1,H=s.isOrthographicCamera?`scale( ${O} )scale(`+M+")translate("+l(z)+"px,"+l(R)+"px)"+A(s.matrixWorldInverse):`scale( ${O} )translateZ(`+M+"px)"+A(s.matrixWorldInverse),c=(s.isPerspectiveCamera?"perspective("+M+"px) ":"")+H+"translate("+p+"px,"+r+"px)";y.camera.style!==c&&(_.style.transform=c,y.camera.style=c),v(a,a,s)},this.setSize=function(a,s){n=a,h=s,p=n/2,r=h/2,P.style.width=a+"px",P.style.height=s+"px",w.style.width=a+"px",w.style.height=s+"px",_.style.width=a+"px",_.style.height=s+"px"};function l(a){return Math.abs(a)<1e-10?0:a}function A(a){const s=a.elements;return"matrix3d("+l(s[0])+","+l(-s[1])+","+l(s[2])+","+l(s[3])+","+l(s[4])+","+l(-s[5])+","+l(s[6])+","+l(s[7])+","+l(s[8])+","+l(-s[9])+","+l(s[10])+","+l(s[11])+","+l(s[12])+","+l(-s[13])+","+l(s[14])+","+l(s[15])+")"}function L(a){const s=a.elements;return"translate(-50%,-50%)"+("matrix3d("+l(s[0])+","+l(s[1])+","+l(s[2])+","+l(s[3])+","+l(-s[4])+","+l(-s[5])+","+l(-s[6])+","+l(-s[7])+","+l(s[8])+","+l(s[9])+","+l(s[10])+","+l(s[11])+","+l(s[12])+","+l(s[13])+","+l(s[14])+","+l(s[15])+")")}function C(a){a.isCSS3DObject&&(a.element.style.display="none");for(let s=0,M=a.children.length;s<M;s++)C(a.children[s])}function v(a,s,M,z){if(a.visible===!1){C(a);return}if(a.isCSS3DObject){const R=a.layers.test(M.layers)===!0,O=a.element;if(O.style.display=R===!0?"":"none",R===!0){a.onBeforeRender(i,s,M);let H;a.isCSS3DSprite?(I.copy(M.matrixWorldInverse),I.transpose(),a.rotation2D!==0&&I.multiply(mt.makeRotationZ(a.rotation2D)),a.matrixWorld.decompose(Q,pt,J),I.setPosition(Q),I.scale(J),I.elements[3]=0,I.elements[7]=0,I.elements[11]=0,I.elements[15]=1,H=L(I)):H=L(a.matrixWorld);const k=y.objects.get(a);if(k===void 0||k.style!==H){O.style.transform=H;const c={style:H};y.objects.set(a,c)}O.parentNode!==_&&_.appendChild(O),a.onAfterRender(i,s,M)}}for(let R=0,O=a.children.length;R<O;R++)v(a.children[R],s,M)}}}const tt={type:"change"},X={type:"start"},st={type:"end"},B=new o.Ray,et=new o.Plane,ft=Math.cos(70*o.MathUtils.DEG2RAD),T=new o.Vector3,x=2*Math.PI,u={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Z=1e-6;class ot extends o.Controls{constructor(t,i=null){super(t,i),this.state=u.NONE,this.target=new o.Vector3,this.cursor=new o.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:o.MOUSE.ROTATE,MIDDLE:o.MOUSE.DOLLY,RIGHT:o.MOUSE.PAN},this.touches={ONE:o.TOUCH.ROTATE,TWO:o.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new o.Vector3,this._lastQuaternion=new o.Quaternion,this._lastTargetPosition=new o.Vector3,this._quat=new o.Quaternion().setFromUnitVectors(t.up,new o.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new o.Spherical,this._sphericalDelta=new o.Spherical,this._scale=1,this._panOffset=new o.Vector3,this._rotateStart=new o.Vector2,this._rotateEnd=new o.Vector2,this._rotateDelta=new o.Vector2,this._panStart=new o.Vector2,this._panEnd=new o.Vector2,this._panDelta=new o.Vector2,this._dollyStart=new o.Vector2,this._dollyEnd=new o.Vector2,this._dollyDelta=new o.Vector2,this._dollyDirection=new o.Vector3,this._mouse=new o.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=gt.bind(this),this._onPointerDown=yt.bind(this),this._onPointerUp=Et.bind(this),this._onContextMenu=Mt.bind(this),this._onMouseWheel=St.bind(this),this._onKeyDown=Dt.bind(this),this._onTouchStart=Tt.bind(this),this._onTouchMove=Pt.bind(this),this._onMouseDown=bt.bind(this),this._onMouseMove=wt.bind(this),this._interceptControlDown=Rt.bind(this),this._interceptControlUp=xt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(tt),this.update(),this.state=u.NONE}update(t=null){const i=this.object.position;T.copy(i).sub(this.target),T.applyQuaternion(this._quat),this._spherical.setFromVector3(T),this.autoRotate&&this.state===u.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,h=this.maxAzimuthAngle;isFinite(n)&&isFinite(h)&&(n<-Math.PI?n+=x:n>Math.PI&&(n-=x),h<-Math.PI?h+=x:h>Math.PI&&(h-=x),n<=h?this._spherical.theta=Math.max(n,Math.min(h,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+h)/2?Math.max(n,this._spherical.theta):Math.min(h,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let p=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),p=r!=this._spherical.radius}if(T.setFromSpherical(this._spherical),T.applyQuaternion(this._quatInverse),i.copy(this.target).add(T),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let r=null;if(this.object.isPerspectiveCamera){const y=T.length();r=this._clampDistance(y*this._scale);const P=y-r;this.object.position.addScaledVector(this._dollyDirection,P),this.object.updateMatrixWorld(),p=!!P}else if(this.object.isOrthographicCamera){const y=new o.Vector3(this._mouse.x,this._mouse.y,0);y.unproject(this.object);const P=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),p=P!==this.object.zoom;const w=new o.Vector3(this._mouse.x,this._mouse.y,0);w.unproject(this.object),this.object.position.sub(w).add(y),this.object.updateMatrixWorld(),r=T.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(B.origin.copy(this.object.position),B.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(B.direction))<ft?this.object.lookAt(this.target):(et.setFromNormalAndCoplanarPoint(this.object.up,this.target),B.intersectPlane(et,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),p=!0)}return this._scale=1,this._performCursorZoom=!1,p||this._lastPosition.distanceToSquared(this.object.position)>Z||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Z||this._lastTargetPosition.distanceToSquared(this.target)>Z?(this.dispatchEvent(tt),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?x/60*this.autoRotateSpeed*t:x/60/60*this.autoRotateSpeed}_getZoomScale(t){const i=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*i)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,i){T.setFromMatrixColumn(i,0),T.multiplyScalar(-t),this._panOffset.add(T)}_panUp(t,i){this.screenSpacePanning===!0?T.setFromMatrixColumn(i,1):(T.setFromMatrixColumn(i,0),T.crossVectors(this.object.up,T)),T.multiplyScalar(t),this._panOffset.add(T)}_pan(t,i){const n=this.domElement;if(this.object.isPerspectiveCamera){const h=this.object.position;T.copy(h).sub(this.target);let p=T.length();p*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*p/n.clientHeight,this.object.matrix),this._panUp(2*i*p/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(i*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,i){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),h=t-n.left,p=i-n.top,r=n.width,y=n.height;this._mouse.x=h/r*2-1,this._mouse.y=-(p/y)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const i=this.domElement;this._rotateLeft(x*this._rotateDelta.x/i.clientHeight),this._rotateUp(x*this._rotateDelta.y/i.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let i=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(x*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),i=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-x*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),i=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(x*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),i=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-x*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),i=!0;break}i&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const i=this._getSecondPointerPosition(t),n=.5*(t.pageX+i.x),h=.5*(t.pageY+i.y);this._rotateStart.set(n,h)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const i=this._getSecondPointerPosition(t),n=.5*(t.pageX+i.x),h=.5*(t.pageY+i.y);this._panStart.set(n,h)}}_handleTouchStartDolly(t){const i=this._getSecondPointerPosition(t),n=t.pageX-i.x,h=t.pageY-i.y,p=Math.sqrt(n*n+h*h);this._dollyStart.set(0,p)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),h=.5*(t.pageX+n.x),p=.5*(t.pageY+n.y);this._rotateEnd.set(h,p)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const i=this.domElement;this._rotateLeft(x*this._rotateDelta.x/i.clientHeight),this._rotateUp(x*this._rotateDelta.y/i.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const i=this._getSecondPointerPosition(t),n=.5*(t.pageX+i.x),h=.5*(t.pageY+i.y);this._panEnd.set(n,h)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const i=this._getSecondPointerPosition(t),n=t.pageX-i.x,h=t.pageY-i.y,p=Math.sqrt(n*n+h*h);this._dollyEnd.set(0,p),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const r=(t.pageX+i.x)*.5,y=(t.pageY+i.y)*.5;this._updateZoomParameters(r,y)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let i=0;i<this._pointers.length;i++)if(this._pointers[i]==t.pointerId){this._pointers.splice(i,1);return}}_isTrackingPointer(t){for(let i=0;i<this._pointers.length;i++)if(this._pointers[i]==t.pointerId)return!0;return!1}_trackPointer(t){let i=this._pointerPositions[t.pointerId];i===void 0&&(i=new o.Vector2,this._pointerPositions[t.pointerId]=i),i.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const i=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[i]}_customWheelEvent(t){const i=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(i){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function yt(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(e)&&(this._addPointer(e),e.pointerType==="touch"?this._onTouchStart(e):this._onMouseDown(e)))}function gt(e){this.enabled!==!1&&(e.pointerType==="touch"?this._onTouchMove(e):this._onMouseMove(e))}function Et(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(st),this.state=u.NONE;break;case 1:const t=this._pointers[0],i=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:i.x,pageY:i.y});break}}function bt(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case o.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=u.DOLLY;break;case o.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=u.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=u.ROTATE}break;case o.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=u.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=u.PAN}break;default:this.state=u.NONE}this.state!==u.NONE&&this.dispatchEvent(X)}function wt(e){switch(this.state){case u.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case u.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case u.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function St(e){this.enabled===!1||this.enableZoom===!1||this.state!==u.NONE||(e.preventDefault(),this.dispatchEvent(X),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(st))}function Dt(e){this.enabled!==!1&&this._handleKeyDown(e)}function Tt(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case o.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=u.TOUCH_ROTATE;break;case o.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=u.TOUCH_PAN;break;default:this.state=u.NONE}break;case 2:switch(this.touches.TWO){case o.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=u.TOUCH_DOLLY_PAN;break;case o.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=u.TOUCH_DOLLY_ROTATE;break;default:this.state=u.NONE}break;default:this.state=u.NONE}this.state!==u.NONE&&this.dispatchEvent(X)}function Pt(e){switch(this._trackPointer(e),this.state){case u.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case u.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case u.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case u.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=u.NONE}}function Mt(e){this.enabled!==!1&&e.preventDefault()}function Rt(e){e.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function xt(e){e.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Ot extends ot{constructor(t,i){super(t,i),this.screenSpacePanning=!1,this.mouseButtons={LEFT:o.MOUSE.PAN,MIDDLE:o.MOUSE.DOLLY,RIGHT:o.MOUSE.ROTATE},this.touches={ONE:o.TOUCH.PAN,TWO:o.TOUCH.DOLLY_ROTATE}}}function At(e){return new o.CameraHelper(e)}function Lt(e=150,...t){return new o.GridHelper(e,e/10,...t)}function Ct(e){return new o.BoxHelper(e,16776960)}function vt(e,t){return new ot(e,t)}function Ht(e,t){return new Ot(e,t)}function kt(){const e=new o.Raycaster,t=new o.Vector2(0,0);return{raycaster:e,pointer:t}}function It(e=10){return new o.AxesHelper(e)}function Nt(e=new o.Vector3(1,1,1),t=new o.Vector3(10,10,10),i=5,n=16776960){return e.normalize(),new o.ArrowHelper(e,t,i,n)}function Ut(){const e=new G;return e.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e}class jt extends o.DataTextureLoader{constructor(t){super(t),this.type=o.HalfFloatType}parse(t){const r=function(c,m){switch(c){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(m||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(m||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(m||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(m||""))}},_=`
2
- `,l=function(c,m,g){m=m||1024;let S=c.pos,b=-1,d=0,D="",f=String.fromCharCode.apply(null,new Uint16Array(c.subarray(S,S+128)));for(;0>(b=f.indexOf(_))&&d<m&&S<c.byteLength;)D+=f,d+=f.length,S+=128,f+=String.fromCharCode.apply(null,new Uint16Array(c.subarray(S,S+128)));return-1<b?(c.pos+=d+b+1,D+f.slice(0,b)):!1},A=function(c){const m=/^#\?(\S+)/,g=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,E=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,S=/^\s*FORMAT=(\S+)\s*$/,b=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,d={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let D,f;for((c.pos>=c.byteLength||!(D=l(c)))&&r(1,"no header found"),(f=D.match(m))||r(3,"bad initial token"),d.valid|=1,d.programtype=f[1],d.string+=D+`
3
- `;D=l(c),D!==!1;){if(d.string+=D+`
4
- `,D.charAt(0)==="#"){d.comments+=D+`
5
- `;continue}if((f=D.match(g))&&(d.gamma=parseFloat(f[1])),(f=D.match(E))&&(d.exposure=parseFloat(f[1])),(f=D.match(S))&&(d.valid|=2,d.format=f[1]),(f=D.match(b))&&(d.valid|=4,d.height=parseInt(f[1],10),d.width=parseInt(f[2],10)),d.valid&2&&d.valid&4)break}return d.valid&2||r(3,"missing format specifier"),d.valid&4||r(3,"missing image size specifier"),d},L=function(c,m,g){const E=m;if(E<8||E>32767||c[0]!==2||c[1]!==2||c[2]&128)return new Uint8Array(c);E!==(c[2]<<8|c[3])&&r(3,"wrong scanline width");const S=new Uint8Array(4*m*g);S.length||r(4,"unable to allocate buffer space");let b=0,d=0;const D=4*E,f=new Uint8Array(4),F=new Uint8Array(D);let q=g;for(;q>0&&d<c.byteLength;){d+4>c.byteLength&&r(1),f[0]=c[d++],f[1]=c[d++],f[2]=c[d++],f[3]=c[d++],(f[0]!=2||f[1]!=2||(f[2]<<8|f[3])!=E)&&r(3,"bad rgbe scanline format");let V=0,N;for(;V<D&&d<c.byteLength;){N=c[d++];const U=N>128;if(U&&(N-=128),(N===0||V+N>D)&&r(3,"bad scanline data"),U){const j=c[d++];for(let $=0;$<N;$++)F[V++]=j}else F.set(c.subarray(d,d+N),V),V+=N,d+=N}const lt=E;for(let U=0;U<lt;U++){let j=0;S[b]=F[U+j],j+=E,S[b+1]=F[U+j],j+=E,S[b+2]=F[U+j],j+=E,S[b+3]=F[U+j],b+=4}q--}return S},C=function(c,m,g,E){const S=c[m+3],b=Math.pow(2,S-128)/255;g[E+0]=c[m+0]*b,g[E+1]=c[m+1]*b,g[E+2]=c[m+2]*b,g[E+3]=1},v=function(c,m,g,E){const S=c[m+3],b=Math.pow(2,S-128)/255;g[E+0]=o.DataUtils.toHalfFloat(Math.min(c[m+0]*b,65504)),g[E+1]=o.DataUtils.toHalfFloat(Math.min(c[m+1]*b,65504)),g[E+2]=o.DataUtils.toHalfFloat(Math.min(c[m+2]*b,65504)),g[E+3]=o.DataUtils.toHalfFloat(1)},a=new Uint8Array(t);a.pos=0;const s=A(a),M=s.width,z=s.height,R=L(a.subarray(a.pos),M,z);let O,H,k;switch(this.type){case o.FloatType:k=R.length/4;const c=new Float32Array(k*4);for(let g=0;g<k;g++)C(R,g*4,c,g*4);O=c,H=o.FloatType;break;case o.HalfFloatType:k=R.length/4;const m=new Uint16Array(k*4);for(let g=0;g<k;g++)v(R,g*4,m,g*4);O=m,H=o.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:M,height:z,data:O,header:s.string,gamma:s.gamma,exposure:s.exposure,type:H}}setDataType(t){return this.type=t,this}load(t,i,n,h){function p(r,y){switch(r.type){case o.FloatType:case o.HalfFloatType:r.colorSpace=o.LinearSRGBColorSpace,r.minFilter=o.LinearFilter,r.magFilter=o.LinearFilter,r.generateMipmaps=!1,r.flipY=!0;break}i&&i(r,y)}return super.load(t,p,n,h)}}const nt=e=>{e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>{it(t)}):it(e.material)),e.children&&e.children.forEach(t=>nt(t))};function it(e){for(const t in e)e[t]&&e[t].isTexture&&e[t].dispose();e.dispose()}const W={},at=new jt;async function Yt(e,t){if(t){if(W[t]){const i=W[t];e.environment=i;return}return new Promise((i,n)=>{at.load(t,i,void 0,n)}).then(i=>{i.mapping=o.EquirectangularReflectionMapping,e.environment=i,W[t]=i}).catch(i=>{console.log(" =====> e:",i)})}}async function zt(e){return new Promise((t,i)=>{at.load(e,t,void 0,i)})}const K={};function rt(e){const t={type:e.type,name:e.name,position:e.position.toArray(),rotation:e.rotation.toArray(),scale:e.scale.toArray(),visible:e.visible,children:[],geometry:null,material:null,userData:e.userData};e.isMesh&&(t.geometry=Ft(e.geometry),t.material=Vt(e.material));for(const i of e.children)t.children.push(rt(i));return t}function ht(e){let t;switch(e.type){case"Mesh":const i=Gt(e.geometry),n=Bt(e.material);t=new Y.Mesh(i,n);break;case"Group":t=new Y.Group;break;case"Object3D":t=new Y.Object3D;break;default:return console.warn(`Unsupported object type: ${e.type}`),null}t.name=e.name,t.position.fromArray(e.position),t.rotation.fromArray(e.rotation),t.scale.fromArray(e.scale),t.visible=e.visible,t.userData=e.userData;for(const i of e.children){const n=ht(i);n&&t.add(n)}return t}function Ft(e){const t=[],{attributes:i,index:n,type:h}=e;i.position&&(t.position={type:"Float32Array",array:Array.from(i.position.array),itemSize:3}),i.normal&&(t.normal={type:"Float32Array",array:Array.from(i.normal.array),itemSize:3}),i.uv&&(t.uv={type:"Float32Array",array:Array.from(i.uv.array),itemSize:2});const p={type:h,attributes:t};return n&&n.array&&(p.index={type:"Uint32Array",array:Array.from(n.array),itemSize:1}),p}function Gt(e){const{type:t,attributes:i,index:n}=e,h=new Y.BufferGeometry;return Object.keys(i).forEach(p=>{const{type:r,array:y,itemSize:P}=i[p];h.setAttribute(p,new Y.BufferAttribute(new Float32Array(y),P))}),n&&h.setIndex(n.array),h}function Vt(e){return{type:e.type,color:e.color.getHex(),map:e.map?e.map.image.src:null,opacity:e.opacity,name:e.name,depthTest:e.depthTest,depthWrite:e.depthWrite,transparent:e.transparent,side:e.side,roughness:e.roughness,metalness:e.metalness,emissive:e.emissive.getHex()}}function Bt(e){if(K[e.name])return K[e.name];const{type:t,...i}=e,n=t||"MeshStandardMaterial",h=new Y[n]({...i});if(e.map){const p=new Y.TextureLoader().load(e.map);h.map=p}return h.needsUpdate=!0,K[e.name]=h,h}exports.CSS3DRenderer=_t;exports.CSS3DSprite=ut;exports.ImageLoader=zt;exports.Stats=G;exports.createArrowHelper=Nt;exports.createAxesHelper=It;exports.createBox3Helper=Ct;exports.createCameraHelper=At;exports.createGridHelper=Lt;exports.createMapControls=Ht;exports.createOrbitControl=vt;exports.createRaycaster=kt;exports.createStats=Ut;exports.dataToObject3D=ht;exports.disposeThreeObject=nt;exports.initEnvImage=Yt;exports.object3DToData=rt;