2 lines
54 KiB
Java
2 lines
54 KiB
Java
var bt=Object.defineProperty,vt=Object.defineProperties;var It=Object.getOwnPropertyDescriptors;var ke=Object.getOwnPropertySymbols;var Nt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable;var Fe=(d,t,e)=>t in d?bt(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,$=(d,t)=>{for(var e in t||(t={}))Nt.call(t,e)&&Fe(d,e,t[e]);if(ke)for(var e of ke(t))Ct.call(t,e)&&Fe(d,e,t[e]);return d},ue=(d,t)=>vt(d,It(t));var ee=(d,t,e)=>new Promise((s,n)=>{var i=r=>{try{a(e.next(r))}catch(c){n(c)}},o=r=>{try{a(e.throw(r))}catch(c){n(c)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(i,o);a((e=e.apply(d,t)).next())});import{TrianglesDrawMode as Ot,TriangleFanDrawMode as ye,TriangleStripDrawMode as tt,Loader as Pt,LoaderUtils as oe,FileLoader as nt,MeshPhysicalMaterial as G,Vector2 as be,Color as X,LinearSRGBColorSpace as K,SRGBColorSpace as ae,SpotLight as Dt,PointLight as Ht,DirectionalLight as st,Matrix4 as he,InstancedMesh as kt,Vector3 as B,Quaternion as it,InstancedBufferAttribute as Ft,Object3D as ot,TextureLoader as Gt,ImageBitmapLoader as Ut,BufferAttribute as ge,InterleavedBuffer as Bt,LinearMipmapLinearFilter as rt,NearestMipmapLinearFilter as Kt,LinearMipmapNearestFilter as jt,NearestMipmapNearestFilter as Vt,LinearFilter as Ae,NearestFilter as at,RepeatWrapping as _e,MirroredRepeatWrapping as zt,ClampToEdgeWrapping as Xt,PointsMaterial as Wt,Material as Te,LineBasicMaterial as qt,MeshStandardMaterial as re,DoubleSide as Yt,MeshBasicMaterial as ie,PropertyBinding as Qt,BufferGeometry as Jt,SkinnedMesh as Zt,Mesh as fe,LineSegments as $t,Line as en,LineLoop as tn,Points as nn,Group as xe,PerspectiveCamera as ct,MathUtils as sn,OrthographicCamera as on,Skeleton as rn,AnimationClip as an,Bone as cn,InterpolateDiscrete as ln,InterpolateLinear as lt,InterleavedBufferAttribute as un,Texture as Ge,VectorKeyframeTrack as Ue,NumberKeyframeTrack as Be,QuaternionKeyframeTrack as Ke,ColorManagement as dn,FrontSide as fn,Interpolant as hn,Box3 as pn,Sphere as mn,Scene as gn,WebGLRenderer as Tn,MOUSE as Ee,AmbientLight as xn,PlaneGeometry as En,GridHelper as Rn,BoxGeometry as je,Raycaster as wn}from"./three.module-DDq6qIBS.js";import{O as Mn}from"./OrbitControls-BnVF_s4z.js";import{au as yn}from"./index-X7Y8jykP.js";import{o as An,r as j,x as _n,C as te,z as ne,Q as v,H as Ve,T as ze,G as U,J as Sn,E as q}from"./vue-vendor-DNhG1Cve.js";import"./emoji-mart-vue-fast-R0uJEDq-.js";function Xe(d,t){if(t===Ot)return d;if(t===ye||t===tt){let e=d.getIndex();if(e===null){const o=[],a=d.getAttribute("position");if(a!==void 0){for(let r=0;r<a.count;r++)o.push(r);d.setIndex(o),e=d.getIndex()}else return d}const s=e.count-2,n=[];if(t===ye)for(let o=1;o<=s;o++)n.push(e.getX(0)),n.push(e.getX(o)),n.push(e.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(e.getX(o)),n.push(e.getX(o+1)),n.push(e.getX(o+2))):(n.push(e.getX(o+2)),n.push(e.getX(o+1)),n.push(e.getX(o)));n.length/3;const i=d.clone();return i.setIndex(n),i.clearGroups(),i}else return d}function Ln(d){const t=new Map,e=new Map,s=d.clone();return ut(d,s,function(n,i){t.set(i,n),e.set(n,i)}),s.traverse(function(n){if(!n.isSkinnedMesh)return;const i=n,o=t.get(n),a=o.skeleton.bones;i.skeleton=o.skeleton.clone(),i.bindMatrix.copy(o.bindMatrix),i.skeleton.bones=a.map(function(r){return e.get(r)}),i.bind(i.skeleton,i.bindMatrix)}),s}function ut(d,t,e){e(d,t);for(let s=0;s<d.children.length;s++)ut(d.children[s],t.children[s],e)}class bn extends Pt{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new On(e)}),this.register(function(e){return new Pn(e)}),this.register(function(e){return new jn(e)}),this.register(function(e){return new Vn(e)}),this.register(function(e){return new zn(e)}),this.register(function(e){return new Hn(e)}),this.register(function(e){return new kn(e)}),this.register(function(e){return new Fn(e)}),this.register(function(e){return new Gn(e)}),this.register(function(e){return new Cn(e)}),this.register(function(e){return new Un(e)}),this.register(function(e){return new Dn(e)}),this.register(function(e){return new Kn(e)}),this.register(function(e){return new Bn(e)}),this.register(function(e){return new In(e)}),this.register(function(e){return new We(e,M.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new We(e,M.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new Xn(e)})}load(t,e,s,n){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=oe.extractUrlBase(t);o=oe.resolveURL(c,this.path)}else o=oe.extractUrlBase(t);this.manager.itemStart(t);const a=function(c){n&&n(c),i.manager.itemError(t),i.manager.itemEnd(t)},r=new nt(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(c){try{i.parse(c,o,function(l){e(l),i.manager.itemEnd(t)},a)}catch(l){a(l)}},s,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,s,n){let i;const o={},a={},r=new TextDecoder;if(typeof t=="string")i=JSON.parse(t);else if(t instanceof ArrayBuffer)if(r.decode(new Uint8Array(t,0,4))===dt){try{o[M.KHR_BINARY_GLTF]=new Wn(t)}catch(u){n&&n(u);return}i=JSON.parse(o[M.KHR_BINARY_GLTF].content)}else i=JSON.parse(r.decode(t));else i=t;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new rs(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){const u=this.pluginCallbacks[l](c);u.name,a[u.name]=u,o[u.name]=!0}if(i.extensionsUsed)for(let l=0;l<i.extensionsUsed.length;++l){const u=i.extensionsUsed[l],f=i.extensionsRequired||[];switch(u){case M.KHR_MATERIALS_UNLIT:o[u]=new Nn;break;case M.KHR_DRACO_MESH_COMPRESSION:o[u]=new qn(i,this.dracoLoader);break;case M.KHR_TEXTURE_TRANSFORM:o[u]=new Yn;break;case M.KHR_MESH_QUANTIZATION:o[u]=new Qn;break;default:f.indexOf(u)>=0&&a[u]}}c.setExtensions(o),c.setPlugins(a),c.parse(s,n)}parseAsync(t,e){const s=this;return new Promise(function(n,i){s.parse(t,e,n,i)})}}function vn(){let d={};return{get:function(t){return d[t]},add:function(t,e){d[t]=e},remove:function(t){delete d[t]},removeAll:function(){d={}}}}function N(d,t,e){const s=d.json.materials[t];return s.extensions&&s.extensions[e]?s.extensions[e]:null}const M={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",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class In{constructor(t){this.parser=t,this.name=M.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let s=0,n=e.length;s<n;s++){const i=e[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const e=this.parser,s="light:"+t;let n=e.cache.get(s);if(n)return n;const i=e.json,r=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let c;const l=new X(16777215);r.color!==void 0&&l.setRGB(r.color[0],r.color[1],r.color[2],K);const u=r.range!==void 0?r.range:0;switch(r.type){case"directional":c=new st(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Ht(l),c.distance=u;break;case"spot":c=new Dt(l),c.distance=u,r.spot=r.spot||{},r.spot.innerConeAngle=r.spot.innerConeAngle!==void 0?r.spot.innerConeAngle:0,r.spot.outerConeAngle=r.spot.outerConeAngle!==void 0?r.spot.outerConeAngle:Math.PI/4,c.angle=r.spot.outerConeAngle,c.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+r.type)}return c.position.set(0,0,0),F(c,r),r.intensity!==void 0&&(c.intensity=r.intensity),c.name=e.createUniqueName(r.name||"light_"+t),n=Promise.resolve(c),e.cache.add(s,n),n}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,s=this.parser,i=s.json.nodes[t],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(r){return s._getNodeRef(e.cache,a,r)})}}class Nn{constructor(){this.name=M.KHR_MATERIALS_UNLIT}getMaterialType(){return ie}extendParams(t,e,s){const n=[];t.color=new X(1,1,1),t.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;t.color.setRGB(o[0],o[1],o[2],K),t.opacity=o[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(t,"map",i.baseColorTexture,ae))}return Promise.all(n)}}class Cn{constructor(t){this.parser=t,this.name=M.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const s=N(this.parser,t,this.name);return s===null||s.emissiveStrength!==void 0&&(e.emissiveIntensity=s.emissiveStrength),Promise.resolve()}}class On{constructor(t){this.parser=t,this.name=M.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){return N(this.parser,t,this.name)!==null?G:null}extendMaterialParams(t,e){const s=N(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&n.push(this.parser.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(n.push(this.parser.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new be(i,i)}return Promise.all(n)}}class Pn{constructor(t){this.parser=t,this.name=M.KHR_MATERIALS_DISPERSION}getMaterialType(t){return N(this.parser,t,this.name)!==null?G:null}extendMaterialParams(t,e){const s=N(this.parser,t,this.name);return s===null||(e.dispersion=s.dispersion!==void 0?s.dispersion:0),Promise.resolve()}}class Dn{constructor(t){this.parser=t,this.name=M.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){return N(this.parser,t,this.name)!==null?G:null}extendMaterialParams(t,e){const s=N(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&n.push(this.parser.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&n.push(this.parser.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(n)}}class Hn{constructor(t){this.parser=t,this.name=M.KHR_MATERIALS_SHEEN}getMaterialType(t){return N(this.parser,t,this.name)!==null?G:null}extendMaterialParams(t,e){const s=N(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];if(e.sheenColor=new X(0,0,0),e.sheenRoughness=0,e.sheen=1,s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;e.sheenColor.setRGB(i[0],i[1],i[2],K)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&n.push(this.parser.assignTexture(e,"sheenColorMap",s.sheenColorTexture,ae)),s.sheenRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(n)}}class kn{constructor(t){this.parser=t,this.name=M.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){return N(this.parser,t,this.name)!==null?G:null}extendMaterialParams(t,e){const s=N(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&n.push(this.parser.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(n)}}class Fn{constructor(t){this.parser=t,this.name=M.KHR_MATERIALS_VOLUME}getMaterialType(t){return N(this.parser,t,this.name)!==null?G:null}extendMaterialParams(t,e){const s=N(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&n.push(this.parser.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return e.attenuationColor=new X().setRGB(i[0],i[1],i[2],K),Promise.all(n)}}class Gn{constructor(t){this.parser=t,this.name=M.KHR_MATERIALS_IOR}getMaterialType(t){return N(this.parser,t,this.name)!==null?G:null}extendMaterialParams(t,e){const s=N(this.parser,t,this.name);return s===null||(e.ior=s.ior!==void 0?s.ior:1.5,e.ior===0&&(e.ior=1e3)),Promise.resolve()}}class Un{constructor(t){this.parser=t,this.name=M.KHR_MATERIALS_SPECULAR}getMaterialType(t){return N(this.parser,t,this.name)!==null?G:null}extendMaterialParams(t,e){const s=N(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&n.push(this.parser.assignTexture(e,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return e.specularColor=new X().setRGB(i[0],i[1],i[2],K),s.specularColorTexture!==void 0&&n.push(this.parser.assignTexture(e,"specularColorMap",s.specularColorTexture,ae)),Promise.all(n)}}class Bn{constructor(t){this.parser=t,this.name=M.EXT_MATERIALS_BUMP}getMaterialType(t){return N(this.parser,t,this.name)!==null?G:null}extendMaterialParams(t,e){const s=N(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&n.push(this.parser.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(n)}}class Kn{constructor(t){this.parser=t,this.name=M.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){return N(this.parser,t,this.name)!==null?G:null}extendMaterialParams(t,e){const s=N(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&n.push(this.parser.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(n)}}class jn{constructor(t){this.parser=t,this.name=M.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,s=e.json,n=s.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],o=e.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,i.source,o)}}class Vn{constructor(t){this.parser=t,this.name=M.EXT_TEXTURE_WEBP}loadTexture(t){const e=this.name,s=this.parser,n=s.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const o=i.extensions[e],a=n.images[o.source];let r=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(r=c)}return s.loadTextureImage(t,o.source,r)}}class zn{constructor(t){this.parser=t,this.name=M.EXT_TEXTURE_AVIF}loadTexture(t){const e=this.name,s=this.parser,n=s.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const o=i.extensions[e],a=n.images[o.source];let r=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(r=c)}return s.loadTextureImage(t,o.source,r)}}class We{constructor(t,e){this.name=e,this.parser=t}loadBufferView(t){const e=this.parser.json,s=e.bufferViews[t];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const r=n.byteOffset||0,c=n.byteLength||0,l=n.count,u=n.byteStride,f=new Uint8Array(a,r,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(l,u,f,n.mode,n.filter).then(function(h){return h.buffer}):o.ready.then(function(){const h=new ArrayBuffer(l*u);return o.decodeGltfBuffer(new Uint8Array(h),l,u,f,n.mode,n.filter),h})})}else return null}}class Xn{constructor(t){this.name=M.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,s=e.nodes[t];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=e.meshes[s.mesh];for(const c of n.primitives)if(c.mode!==H.TRIANGLES&&c.mode!==H.TRIANGLE_STRIP&&c.mode!==H.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=s.extensions[this.name].attributes,a=[],r={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(l=>(r[c]=l,r[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,h=[];for(const g of u){const y=new he,T=new B,E=new it,L=new B(1,1,1),b=new kt(g.geometry,g.material,f);for(let _=0;_<f;_++)r.TRANSLATION&&T.fromBufferAttribute(r.TRANSLATION,_),r.ROTATION&&E.fromBufferAttribute(r.ROTATION,_),r.SCALE&&L.fromBufferAttribute(r.SCALE,_),b.setMatrixAt(_,y.compose(T,E,L));for(const _ in r)if(_==="_COLOR_0"){const I=r[_];b.instanceColor=new Ft(I.array,I.itemSize,I.normalized)}else _!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&g.geometry.setAttribute(_,r[_]);ot.prototype.copy.call(b,g),this.parser.assignFinalMaterial(b),h.push(b)}return l.isGroup?(l.clear(),l.add(...h),l):h[0]}))}}const dt="glTF",se=12,qe={JSON:1313821514,BIN:5130562};class Wn{constructor(t){this.name=M.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,se),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==dt)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-se,i=new DataView(t,se);let o=0;for(;o<n;){const a=i.getUint32(o,!0);o+=4;const r=i.getUint32(o,!0);if(o+=4,r===qe.JSON){const c=new Uint8Array(t,se+o,a);this.content=s.decode(c)}else if(r===qe.BIN){const c=se+o;this.body=t.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class qn{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=M.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const s=this.json,n=this.dracoLoader,i=t.extensions[this.name].bufferView,o=t.extensions[this.name].attributes,a={},r={},c={};for(const l in o){const u=Se[l]||l.toLowerCase();a[u]=o[l]}for(const l in t.attributes){const u=Se[l]||l.toLowerCase();if(o[l]!==void 0){const f=s.accessors[t.attributes[l]],h=Y[f.componentType];c[u]=h.name,r[u]=f.normalized===!0}}return e.getDependency("bufferView",i).then(function(l){return new Promise(function(u,f){n.decodeDracoFile(l,function(h){for(const g in h.attributes){const y=h.attributes[g],T=r[g];T!==void 0&&(y.normalized=T)}u(h)},a,c,K,f)})})}}class Yn{constructor(){this.name=M.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Qn{constructor(){this.name=M.KHR_MESH_QUANTIZATION}}class ft extends hn{constructor(t,e,s,n){super(t,e,s,n)}copySampleValue_(t){const e=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=t*n*3+n;for(let o=0;o!==n;o++)e[o]=s[i+o];return e}interpolate_(t,e,s,n){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,r=a*2,c=a*3,l=n-e,u=(s-e)/l,f=u*u,h=f*u,g=t*c,y=g-c,T=-2*h+3*f,E=h-f,L=1-T,b=E-f+u;for(let _=0;_!==a;_++){const I=o[y+_+a],P=o[y+_+r]*l,C=o[g+_+a],D=o[g+_]*l;i[_]=L*I+b*P+T*C+E*D}return i}}const Jn=new it;class Zn extends ft{interpolate_(t,e,s,n){const i=super.interpolate_(t,e,s,n);return Jn.fromArray(i).normalize().toArray(i),i}}const H={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Y={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ye={9728:at,9729:Ae,9984:Vt,9985:jt,9986:Kt,9987:rt},Qe={33071:Xt,33648:zt,10497:_e},Re={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Se={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"},V={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},$n={CUBICSPLINE:void 0,LINEAR:lt,STEP:ln},we={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function es(d){return d.DefaultMaterial===void 0&&(d.DefaultMaterial=new re({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:fn})),d.DefaultMaterial}function W(d,t,e){for(const s in e.extensions)d[s]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=e.extensions[s])}function F(d,t){t.extras!==void 0&&typeof t.extras=="object"&&Object.assign(d.userData,t.extras)}function ts(d,t,e){let s=!1,n=!1,i=!1;for(let c=0,l=t.length;c<l;c++){const u=t[c];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(d);const o=[],a=[],r=[];for(let c=0,l=t.length;c<l;c++){const u=t[c];if(s){const f=u.POSITION!==void 0?e.getDependency("accessor",u.POSITION):d.attributes.position;o.push(f)}if(n){const f=u.NORMAL!==void 0?e.getDependency("accessor",u.NORMAL):d.attributes.normal;a.push(f)}if(i){const f=u.COLOR_0!==void 0?e.getDependency("accessor",u.COLOR_0):d.attributes.color;r.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(r)]).then(function(c){const l=c[0],u=c[1],f=c[2];return s&&(d.morphAttributes.position=l),n&&(d.morphAttributes.normal=u),i&&(d.morphAttributes.color=f),d.morphTargetsRelative=!0,d})}function ns(d,t){if(d.updateMorphTargets(),t.weights!==void 0)for(let e=0,s=t.weights.length;e<s;e++)d.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(d.morphTargetInfluences.length===e.length){d.morphTargetDictionary={};for(let s=0,n=e.length;s<n;s++)d.morphTargetDictionary[e[s]]=s}}}function ss(d){let t;const e=d.extensions&&d.extensions[M.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+Me(e.attributes):t=d.indices+":"+Me(d.attributes)+":"+d.mode,d.targets!==void 0)for(let s=0,n=d.targets.length;s<n;s++)t+=":"+Me(d.targets[s]);return t}function Me(d){let t="";const e=Object.keys(d).sort();for(let s=0,n=e.length;s<n;s++)t+=e[s]+":"+d[e[s]]+";";return t}function Le(d){switch(d){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 is(d){return d.search(/\.jpe?g($|\?)/i)>0||d.search(/^data\:image\/jpeg/)===0?"image/jpeg":d.search(/\.webp($|\?)/i)>0||d.search(/^data\:image\/webp/)===0?"image/webp":d.search(/\.ktx2($|\?)/i)>0||d.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const os=new he;class rs{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new vn,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 s=!1,n=-1,i=!1,o=-1;if(typeof navigator!="undefined"&&typeof navigator.userAgent!="undefined"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const r=a.match(/Version\/(\d+)/);n=s&&r?parseInt(r[1],10):-1,i=a.indexOf("Firefox")>-1,o=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap=="undefined"||s&&n<17||i&&o<98?this.textureLoader=new Gt(this.options.manager):this.textureLoader=new Ut(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new nt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const a={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};return W(i,a,n),F(a,n),Promise.all(s._invokeAll(function(r){return r.afterRoot&&r.afterRoot(a)})).then(function(){for(const r of a.scenes)r.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const o=e[n].joints;for(let a=0,r=o.length;a<r;a++)t[o[a]].isBone=!0}for(let n=0,i=t.length;n<i;n++){const o=t[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,s){if(t.refs[e]<=1)return s;const n=s.clone(),i=(o,a)=>{const r=this.associations.get(o);r!=null&&this.associations.set(a,r);for(const[c,l]of o.children.entries())i(l,a.children[c])};return i(s,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const n=t(e[s]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let n=0;n<e.length;n++){const i=t(e[n]);i&&s.push(i)}return s}getDependency(t,e){const s=t+":"+e;let n=this.cache.get(s);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(e)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t);break}this.cache.add(s,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const s=this,n=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(n.map(function(i,o){return s.getDependency(t,o)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[M.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,o){s.load(oe.resolveURL(e.uri,n.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(s){const n=e.byteLength||0,i=e.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(t){const e=this,s=this.json,n=this.json.accessors[t];if(n.bufferView===void 0&&n.sparse===void 0){const o=Re[n.type],a=Y[n.componentType],r=n.normalized===!0,c=new a(n.count*o);return Promise.resolve(new ge(c,o,r))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(o){const a=o[0],r=Re[n.type],c=Y[n.componentType],l=c.BYTES_PER_ELEMENT,u=l*r,f=n.byteOffset||0,h=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,g=n.normalized===!0;let y,T;if(h&&h!==u){const E=Math.floor(f/h),L="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+E+":"+n.count;let b=e.cache.get(L);b||(y=new c(a,E*h,n.count*h/l),b=new Bt(y,h/l),e.cache.add(L,b)),T=new un(b,r,f%h/l,g)}else a===null?y=new c(n.count*r):y=new c(a,f,n.count*r),T=new ge(y,r,g);if(n.sparse!==void 0){const E=Re.SCALAR,L=Y[n.sparse.indices.componentType],b=n.sparse.indices.byteOffset||0,_=n.sparse.values.byteOffset||0,I=new L(o[1],b,n.sparse.count*E),P=new c(o[2],_,n.sparse.count*r);a!==null&&(T=new ge(T.array.slice(),T.itemSize,T.normalized)),T.normalized=!1;for(let C=0,D=I.length;C<D;C++){const S=I[C];if(T.setX(S,P[C*r]),r>=2&&T.setY(S,P[C*r+1]),r>=3&&T.setZ(S,P[C*r+2]),r>=4&&T.setW(S,P[C*r+3]),r>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}T.normalized=g}return T})}loadTexture(t){const e=this.json,s=this.options,i=e.textures[t].source,o=e.images[i];let a=this.textureLoader;if(o.uri){const r=s.manager.getHandler(o.uri);r!==null&&(a=r)}return this.loadTextureImage(t,i,a)}loadTextureImage(t,e,s){const n=this,i=this.json,o=i.textures[t],a=i.images[e],r=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[r])return this.textureCache[r];const c=this.loadImageSource(e,s).then(function(l){l.flipY=!1,l.name=o.name||a.name||"",l.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(l.name=a.uri);const f=(i.samplers||{})[o.sampler]||{};return l.magFilter=Ye[f.magFilter]||Ae,l.minFilter=Ye[f.minFilter]||rt,l.wrapS=Qe[f.wrapS]||_e,l.wrapT=Qe[f.wrapT]||_e,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==at&&l.minFilter!==Ae,n.associations.set(l,{textures:t}),l}).catch(function(){return null});return this.textureCache[r]=c,c}loadImageSource(t,e){const s=this,n=this.json,i=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(u=>u.clone());const o=n.images[t],a=self.URL||self.webkitURL;let r=o.uri||"",c=!1;if(o.bufferView!==void 0)r=s.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const f=new Blob([u],{type:o.mimeType});return r=a.createObjectURL(f),r});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(r).then(function(u){return new Promise(function(f,h){let g=f;e.isImageBitmapLoader===!0&&(g=function(y){const T=new Ge(y);T.needsUpdate=!0,f(T)}),e.load(oe.resolveURL(u,i.path),g,void 0,h)})}).then(function(u){return c===!0&&a.revokeObjectURL(r),F(u,o),u.userData.mimeType=o.mimeType||is(o.uri),u}).catch(function(u){throw u});return this.sourceCache[t]=l,l}assignTexture(t,e,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[M.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[M.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const r=i.associations.get(o);o=i.extensions[M.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),i.associations.set(o,r)}}return n!==void 0&&(o.colorSpace=n),t[e]=o,o})}assignFinalMaterial(t){const e=t.geometry;let s=t.material;const n=e.attributes.tangent===void 0,i=e.attributes.color!==void 0,o=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+s.uuid;let r=this.cache.get(a);r||(r=new Wt,Te.prototype.copy.call(r,s),r.color.copy(s.color),r.map=s.map,r.sizeAttenuation=!1,this.cache.add(a,r)),s=r}else if(t.isLine){const a="LineBasicMaterial:"+s.uuid;let r=this.cache.get(a);r||(r=new qt,Te.prototype.copy.call(r,s),r.color.copy(s.color),r.map=s.map,this.cache.add(a,r)),s=r}if(n||i||o){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let r=this.cache.get(a);r||(r=s.clone(),i&&(r.vertexColors=!0),o&&(r.flatShading=!0),n&&(r.normalScale&&(r.normalScale.y*=-1),r.clearcoatNormalScale&&(r.clearcoatNormalScale.y*=-1)),this.cache.add(a,r),this.associations.set(r,this.associations.get(s))),s=r}t.material=s}getMaterialType(){return re}loadMaterial(t){const e=this,s=this.json,n=this.extensions,i=s.materials[t];let o;const a={},r=i.extensions||{},c=[];if(r[M.KHR_MATERIALS_UNLIT]){const u=n[M.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,i,e))}else{const u=i.pbrMetallicRoughness||{};if(a.color=new X(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],K),a.opacity=f[3]}u.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",u.baseColorTexture,ae)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,a)})))}i.doubleSided===!0&&(a.side=Yt);const l=i.alphaMode||we.OPAQUE;if(l===we.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===we.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==ie&&(c.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new be(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;a.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&o!==ie&&(c.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==ie){const u=i.emissiveFactor;a.emissive=new X().setRGB(u[0],u[1],u[2],K)}return i.emissiveTexture!==void 0&&o!==ie&&c.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture,ae)),Promise.all(c).then(function(){const u=new o(a);return i.name&&(u.name=i.name),F(u,i),e.associations.set(u,{materials:t}),i.extensions&&W(n,u,i),u})}createUniqueName(t){const e=Qt.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,s=this.extensions,n=this.primitiveCache;function i(a){return s[M.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(r){return Je(r,a,e)})}const o=[];for(let a=0,r=t.length;a<r;a++){const c=t[a],l=ss(c),u=n[l];if(u)o.push(u.promise);else{let f;c.extensions&&c.extensions[M.KHR_DRACO_MESH_COMPRESSION]?f=i(c):f=Je(new Jt,c,e),n[l]={primitive:c,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(t){const e=this,s=this.json,n=this.extensions,i=s.meshes[t],o=i.primitives,a=[];for(let r=0,c=o.length;r<c;r++){const l=o[r].material===void 0?es(this.cache):this.getDependency("material",o[r].material);a.push(l)}return a.push(e.loadGeometries(o)),Promise.all(a).then(function(r){const c=r.slice(0,r.length-1),l=r[r.length-1],u=[];for(let h=0,g=l.length;h<g;h++){const y=l[h],T=o[h];let E;const L=c[h];if(T.mode===H.TRIANGLES||T.mode===H.TRIANGLE_STRIP||T.mode===H.TRIANGLE_FAN||T.mode===void 0)E=i.isSkinnedMesh===!0?new Zt(y,L):new fe(y,L),E.isSkinnedMesh===!0&&E.normalizeSkinWeights(),T.mode===H.TRIANGLE_STRIP?E.geometry=Xe(E.geometry,tt):T.mode===H.TRIANGLE_FAN&&(E.geometry=Xe(E.geometry,ye));else if(T.mode===H.LINES)E=new $t(y,L);else if(T.mode===H.LINE_STRIP)E=new en(y,L);else if(T.mode===H.LINE_LOOP)E=new tn(y,L);else if(T.mode===H.POINTS)E=new nn(y,L);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+T.mode);Object.keys(E.geometry.morphAttributes).length>0&&ns(E,i),E.name=e.createUniqueName(i.name||"mesh_"+t),F(E,i),T.extensions&&W(n,E,T),e.assignFinalMaterial(E),u.push(E)}for(let h=0,g=u.length;h<g;h++)e.associations.set(u[h],{meshes:t,primitives:h});if(u.length===1)return i.extensions&&W(n,u[0],i),u[0];const f=new xe;i.extensions&&W(n,f,i),e.associations.set(f,{meshes:t});for(let h=0,g=u.length;h<g;h++)f.add(u[h]);return f})}loadCamera(t){let e;const s=this.json.cameras[t],n=s[s.type];if(n)return s.type==="perspective"?e=new ct(sn.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(e=new on(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),F(e,s),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],s=[];for(let n=0,i=e.joints.length;n<i;n++)s.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),o=n,a=[],r=[];for(let c=0,l=o.length;c<l;c++){const u=o[c];if(u){a.push(u);const f=new he;i!==null&&f.fromArray(i.array,c*16),r.push(f)}}return new rn(a,r)})}loadAnimation(t){const e=this.json,s=this,n=e.animations[t],i=n.name?n.name:"animation_"+t,o=[],a=[],r=[],c=[],l=[];for(let u=0,f=n.channels.length;u<f;u++){const h=n.channels[u],g=n.samplers[h.sampler],y=h.target,T=y.node,E=n.parameters!==void 0?n.parameters[g.input]:g.input,L=n.parameters!==void 0?n.parameters[g.output]:g.output;y.node!==void 0&&(o.push(this.getDependency("node",T)),a.push(this.getDependency("accessor",E)),r.push(this.getDependency("accessor",L)),c.push(g),l.push(y))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(r),Promise.all(c),Promise.all(l)]).then(function(u){const f=u[0],h=u[1],g=u[2],y=u[3],T=u[4],E=[];for(let b=0,_=f.length;b<_;b++){const I=f[b],P=h[b],C=g[b],D=y[b],S=T[b];if(I===void 0)continue;I.updateMatrix&&I.updateMatrix();const Q=s._createAnimationTracks(I,P,C,D,S);if(Q)for(let J=0;J<Q.length;J++)E.push(Q[J])}const L=new an(i,void 0,E);return F(L,n),L})}createNodeMesh(t){const e=this.json,s=this,n=e.nodes[t];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const o=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let r=0,c=n.weights.length;r<c;r++)a.morphTargetInfluences[r]=n.weights[r]}),o})}loadNode(t){const e=this.json,s=this,n=e.nodes[t],i=s._loadNodeShallow(t),o=[],a=n.children||[];for(let c=0,l=a.length;c<l;c++)o.push(s.getDependency("node",a[c]));const r=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(o),r]).then(function(c){const l=c[0],u=c[1],f=c[2];f!==null&&l.traverse(function(h){h.isSkinnedMesh&&h.bind(f,os)});for(let h=0,g=u.length;h<g;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){const h=l.userData.pivot,g=u[0];l.pivot=new B().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],g.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(t){const e=this.json,s=this.extensions,n=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const i=e.nodes[t],o=i.name?n.createUniqueName(i.name):"",a=[],r=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(t)});return r&&a.push(r),i.camera!==void 0&&a.push(n.getDependency("camera",i.camera).then(function(c){return n._getNodeRef(n.cameraCache,i.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(t)}).forEach(function(c){a.push(c)}),this.nodeCache[t]=Promise.all(a).then(function(c){let l;if(i.isBone===!0?l=new cn:c.length>1?l=new xe:c.length===1?l=c[0]:l=new ot,l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(i.name&&(l.userData.name=i.name,l.name=o),F(l,i),i.extensions&&W(s,l,i),i.matrix!==void 0){const u=new he;u.fromArray(i.matrix),l.applyMatrix4(u)}else i.translation!==void 0&&l.position.fromArray(i.translation),i.rotation!==void 0&&l.quaternion.fromArray(i.rotation),i.scale!==void 0&&l.scale.fromArray(i.scale);if(!n.associations.has(l))n.associations.set(l,{});else if(i.mesh!==void 0&&n.meshCache.refs[i.mesh]>1){const u=n.associations.get(l);n.associations.set(l,$({},u))}return n.associations.get(l).nodes=t,l}),this.nodeCache[t]}loadScene(t){const e=this.extensions,s=this.json.scenes[t],n=this,i=new xe;s.name&&(i.name=n.createUniqueName(s.name)),F(i,s),s.extensions&&W(e,i,s);const o=s.nodes||[],a=[];for(let r=0,c=o.length;r<c;r++)a.push(n.getDependency("node",o[r]));return Promise.all(a).then(function(r){for(let l=0,u=r.length;l<u;l++){const f=r[l];f.parent!==null?i.add(Ln(f)):i.add(f)}const c=l=>{const u=new Map;for(const[f,h]of n.associations)(f instanceof Te||f instanceof Ge)&&u.set(f,h);return l.traverse(f=>{const h=n.associations.get(f);h!=null&&u.set(f,h)}),u};return n.associations=c(i),i})}_createAnimationTracks(t,e,s,n,i){const o=[],a=t.name?t.name:t.uuid,r=[];function c(h){h.morphTargetInfluences&&r.push(h.name?h.name:h.uuid)}V[i.path]===V.weights?(c(t),t.isGroup&&t.children.forEach(c)):r.push(a);let l;switch(V[i.path]){case V.weights:l=Be;break;case V.rotation:l=Ke;break;case V.translation:case V.scale:l=Ue;break;default:switch(s.itemSize){case 1:l=Be;break;case 2:case 3:default:l=Ue;break}break}const u=n.interpolation!==void 0?$n[n.interpolation]:lt,f=this._getArrayFromAccessor(s);for(let h=0,g=r.length;h<g;h++){const y=new l(r[h]+"."+V[i.path],e.array,f,u);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),o.push(y)}return o}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const s=Le(e.constructor),n=new Float32Array(e.length);for(let i=0,o=e.length;i<o;i++)n[i]=e[i]*s;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(s){const n=this instanceof Ke?Zn:ft;return new n(this.times,this.values,this.getValueSize()/3,s)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function as(d,t,e){const s=t.attributes,n=new pn;if(s.POSITION!==void 0){const a=e.json.accessors[s.POSITION],r=a.min,c=a.max;if(r!==void 0&&c!==void 0){if(n.set(new B(r[0],r[1],r[2]),new B(c[0],c[1],c[2])),a.normalized){const l=Le(Y[a.componentType]);n.min.multiplyScalar(l),n.max.multiplyScalar(l)}}else return}else return;const i=t.targets;if(i!==void 0){const a=new B,r=new B;for(let c=0,l=i.length;c<l;c++){const u=i[c];if(u.POSITION!==void 0){const f=e.json.accessors[u.POSITION],h=f.min,g=f.max;if(h!==void 0&&g!==void 0){if(r.setX(Math.max(Math.abs(h[0]),Math.abs(g[0]))),r.setY(Math.max(Math.abs(h[1]),Math.abs(g[1]))),r.setZ(Math.max(Math.abs(h[2]),Math.abs(g[2]))),f.normalized){const y=Le(Y[f.componentType]);r.multiplyScalar(y)}a.max(r)}}}n.expandByVector(a)}d.boundingBox=n;const o=new mn;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,d.boundingSphere=o}function Je(d,t,e){const s=t.attributes,n=[];function i(o,a){return e.getDependency("accessor",o).then(function(r){d.setAttribute(a,r)})}for(const o in s){const a=Se[o]||o.toLowerCase();a in d.attributes||n.push(i(s[o],a))}if(t.indices!==void 0&&!d.index){const o=e.getDependency("accessor",t.indices).then(function(a){d.setIndex(a)});n.push(o)}return dn.workingColorSpace!==K&&"COLOR_0"in s,F(d,t),as(d,t,e),Promise.all(n).then(function(){return t.targets!==void 0?ts(d,t.targets,e):d})}const cs={class:"workshop-container"},ls={class:"gesture-control-wrapper"},us={key:1,class:"gesture-info"},ds={key:1,class:"info-panel"},fs={class:"info-header"},hs={class:"info-content"},ps=50,de=.002,z=.6,Ze=2.5,$e=4,et=1500,ms=120,gs={__name:"index",setup(d){const t=j(null),e=j(null),s=j(null),n=j(null),i=j(!1),o=j("正在加载模型..."),a=j(!1),r=j({x:0,y:0});let c,l,u,f,h,g=[],y,T,E=null,L=null,b=null,_=null,I=null,P=!1,C=!1,D=null,S={x:0,y:0};const Q=[{id:"DEV-001",name:"加工中心A",status:"运行中",statusColor:"#52c41a",temperature:45,runtime:1234,color:1609983},{id:"DEV-002",name:"加工中心B",status:"待机",statusColor:"#faad14",temperature:28,runtime:2456,color:5424154},{id:"DEV-003",name:"装配机器人",status:"运行中",statusColor:"#52c41a",temperature:38,runtime:3678,color:16065069},{id:"DEV-004",name:"质检设备",status:"故障",statusColor:"#f5222d",temperature:65,runtime:890,color:16419862},{id:"DEV-005",name:"包装机",status:"运行中",statusColor:"#52c41a",temperature:42,runtime:5432,color:7483089}];An(()=>{J(),ht(),mt(),De(),window.addEventListener("resize",Ie)}),_n(()=>{cancelAnimationFrame(h),window.removeEventListener("resize",Ie),window.removeEventListener("click",ve),pe(),f.dispose(),u.dispose(),c.clear()});function J(){c=new gn,c.background=new X(15790837),l=new ct(75,t.value.clientWidth/t.value.clientHeight,.1,1e3),l.position.set(8,8,8),l.lookAt(0,0,0),u=new Tn({antialias:!0}),u.setSize(t.value.clientWidth,t.value.clientHeight),u.shadowMap.enabled=!0,t.value.appendChild(u.domElement),f=new Mn(l,u.domElement),f.enableDamping=!0,f.dampingFactor=.05,f.mouseButtons={LEFT:Ee.ROTATE,MIDDLE:Ee.PAN,RIGHT:Ee.PAN};const p=new xn(16777215,.6);c.add(p);const m=new st(16777215,.8);m.position.set(10,10,5),m.castShadow=!0,c.add(m);const R=new En(20,20),x=new re({color:13421772}),w=new fe(R,x);w.rotation.x=-Math.PI/2,w.receiveShadow=!0,c.add(w);const A=new Rn(20,20,8947848,14540253);c.add(A)}function ht(){const p=[{x:-4,y:1,z:-4},{x:4,y:1,z:-4},{x:0,y:1,z:0},{x:-4,y:1,z:4},{x:4,y:1,z:4}];Q.forEach((m,R)=>{if(R===2)pt(p[R],m);else{const x=new je(1.5,1.5,1.5),w=new re({color:m.color,metalness:.3,roughness:.4}),A=new fe(x,w);A.position.set(p[R].x,p[R].y,p[R].z),A.castShadow=!0,A.receiveShadow=!0,A.userData=ue($({},m),{position:p[R],originalColor:m.color}),c.add(A),g.push(A)}})}function pt(p,m){new bn().load("/models/robot.glb",x=>{E=x.scene,E.position.set(p.x,p.y,p.z),E.scale.set(2,2,2),E.traverse(w=>{w.isMesh&&(w.castShadow=!0,w.receiveShadow=!0)}),E.userData=ue($({},m),{position:p,originalColor:m.color,isModel:!0}),c.add(E),g.push(E)},x=>{},x=>{const w=new je(1.5,1.5,1.5),A=new re({color:m.color,metalness:.3,roughness:.4}),O=new fe(w,A);O.position.set(p.x,p.y,p.z),O.castShadow=!0,O.receiveShadow=!0,O.userData=ue($({},m),{position:p,originalColor:m.color}),c.add(O),g.push(O)})}function mt(){y=new wn,T=new be,window.addEventListener("click",ve)}function ve(p){const m=t.value.getBoundingClientRect();T.x=(p.clientX-m.left)/m.width*2-1,T.y=-((p.clientY-m.top)/m.height)*2+1,y.setFromCamera(T,l);const R=y.intersectObjects(g,!0);if(g.forEach(x=>{x.material?(x.material.color.setHex(x.userData.originalColor),x.material.emissive.setHex(0)):x.userData.isModel&&x.traverse(w=>{w.isMesh&&w.material&&w.material.emissive.setHex(0)})}),R.length>0){let w=R[0].object;for(;w.parent&&!g.includes(w);)w=w.parent;w.material?w.material.emissive.setHex(5592405):w.userData.isModel&&w.traverse(A=>{A.isMesh&&A.material&&A.material.emissive.setHex(5592405)}),e.value=w.userData}else e.value=null}function Ie(){l.aspect=t.value.clientWidth/t.value.clientHeight,l.updateProjectionMatrix(),u.setSize(t.value.clientWidth,t.value.clientHeight)}function Ne(){return ee(this,null,function*(){i.value?pe():yield Tt()})}function gt(){return ee(this,null,function*(){return new Promise((p,m)=>{if(window.tf&&window.handpose){p();return}const R=document.createElement("script");R.src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@3.11.0/dist/tf.min.js",R.onload=()=>{const x=document.createElement("script");x.src="https://cdn.jsdelivr.net/npm/@tensorflow-models/handpose@0.0.7/dist/handpose.min.js",x.onload=()=>p(),x.onerror=()=>m(new Error("HandPose 加载失败")),document.head.appendChild(x)},R.onerror=()=>m(new Error("TensorFlow.js 加载失败")),document.head.appendChild(R)})})}function Tt(){return ee(this,null,function*(){try{o.value="正在加载 TensorFlow.js...",yield gt(),o.value="正在加载手势识别模型...",_=yield window.handpose.load(),o.value="正在启动摄像头...",L=yield navigator.mediaDevices.getUserMedia({video:{width:640,height:480,facingMode:"user"}}),s.value.srcObject=L,i.value=!0,yield new Promise(p=>{s.value.onloadedmetadata=p}),n.value.width=s.value.videoWidth,n.value.height=s.value.videoHeight,o.value="手势控制已启用",Ce()}catch(p){o.value="启动失败: "+p.message,pe(),alert("手势控制启动失败: "+p.message)}})}function pe(){L&&(L.getTracks().forEach(p=>p.stop()),L=null),b&&(cancelAnimationFrame(b),b=null),i.value=!1,I=null,P=!1,C=!1,D=null,S={x:0,y:0}}function Ce(){return ee(this,null,function*(){if(!(!i.value||!_)){try{const p=yield _.estimateHands(s.value),m=n.value.getContext("2d");m.clearRect(0,0,n.value.width,n.value.height),m.drawImage(s.value,0,0,n.value.width,n.value.height),p.length>0?(p.forEach(R=>yt(m,R.landmarks)),p.length>=2?Et(p):Pe(p[0].landmarks)):(o.value="未检测到手部",Oe())}catch(p){}b=requestAnimationFrame(Ce)}})}function Oe(){I=null,P=!1,C=!1,D=null,S={x:0,y:0}}function me(p){const m=p[4],R=p[8];return Math.sqrt(Math.pow(m[0]-R[0],2)+Math.pow(m[1]-R[1],2))<ps}function xt(p){const m=p[0],R=[p[4],p[8],p[12],p[16],p[20]];let x=0;return R.forEach(A=>{const O=Math.sqrt(Math.pow(A[0]-m[0],2)+Math.pow(A[1]-m[1],2));x+=O}),x/R.length>ms}function Pe(p){const m=me(p),R=xt(p);if(m){const x=p[4],w=p[8],A=[(x[0]+w[0])/2,(x[1]+w[1])/2],O=A[0]/n.value.width*window.innerWidth,k=A[1]/n.value.height*window.innerHeight;if(r.value={x:O,y:k},a.value=!0,P&&I){let ce=(A[0]-I[0])/n.value.width,le=(A[1]-I[1])/n.value.height;S.x=S.x*(1-z)+ce*z,S.y=S.y*(1-z)+le*z,Math.abs(S.x)<de&&(S.x=0),Math.abs(S.y)<de&&(S.y=0),Rt(S.x,S.y),o.value="捏合旋转"}I=A,P=!0,D=null}else if(R){if(a.value=!1,D===null)D=Date.now();else{const x=Date.now()-D;x>=et?(Mt(),o.value="视角已重置",D=null):o.value=`保持手掌张开 ${((et-x)/1e3).toFixed(1)}s 重置视角`}P=!1,I=null}else a.value=!1,Oe(),o.value="等待手势..."}function Et(p){const m=p[0].landmarks,R=p[1].landmarks,x=me(m),w=me(R);if(x&&w){const A=m[4],O=m[8],k=R[4],ce=R[8],le=[(A[0]+O[0])/2,(A[1]+O[1])/2],He=[(k[0]+ce[0])/2,(k[1]+ce[1])/2],Z=[(le[0]+He[0])/2,(le[1]+He[1])/2],At=Z[0]/n.value.width*window.innerWidth,_t=Z[1]/n.value.height*window.innerHeight;if(r.value={x:At,y:_t},a.value=!0,C&&I){let St=(Z[0]-I[0])/n.value.width,Lt=(Z[1]-I[1])/n.value.height;S.x=S.x*(1-z)+St*z,S.y=S.y*(1-z)+Lt*z,Math.abs(S.x)<de&&(S.x=0),Math.abs(S.y)<de&&(S.y=0),wt(S.x,S.y),o.value="双手平移"}I=Z,C=!0,P=!1}else C=!1,Pe(p[0].landmarks)}function Rt(p,m){const R=-p*Math.PI*Ze,x=-m*Math.PI*Ze,w=l.position.clone().sub(f.target),A=w.length();let O=Math.atan2(w.x,w.z),k=Math.acos(Math.max(-1,Math.min(1,w.y/A)));O+=R,k+=x,k=Math.max(.1,Math.min(Math.PI-.1,k)),l.position.x=f.target.x+A*Math.sin(k)*Math.sin(O),l.position.y=f.target.y+A*Math.cos(k),l.position.z=f.target.z+A*Math.sin(k)*Math.cos(O),l.lookAt(f.target)}function wt(p,m){const R=new B,x=new B;R.setFromMatrixColumn(l.matrix,0),x.setFromMatrixColumn(l.matrix,1),f.target.add(R.multiplyScalar(-p*$e)),f.target.add(x.multiplyScalar(m*$e))}function Mt(){l.position.set(8,8,8),f.target.set(0,0,0),l.lookAt(f.target)}function yt(p,m){p.fillStyle="#00ff00",m.forEach(x=>{p.beginPath(),p.arc(x[0],x[1],5,0,2*Math.PI),p.fill()});const R=[[0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[0,9],[9,10],[10,11],[11,12],[0,13],[13,14],[14,15],[15,16],[0,17],[17,18],[18,19],[19,20],[5,9],[9,13],[13,17]];p.strokeStyle="#00ff00",p.lineWidth=2,R.forEach(([x,w])=>{p.beginPath(),p.moveTo(m[x][0],m[x][1]),p.lineTo(m[w][0],m[w][1]),p.stroke()})}function De(){h=requestAnimationFrame(De),g.forEach((p,m)=>{p.userData.isModel||(p.rotation.y+=.005*(m%2===0?1:-1))}),f.update(),u.render(c,l)}return(p,m)=>(ne(),te("div",cs,[v("div",{ref_key:"container",ref:t,class:"three-container"},null,512),a.value?(ne(),te("div",{key:0,class:"virtual-cursor",style:ze({left:r.value.x+"px",top:r.value.y+"px"})},[...m[1]||(m[1]=[v("div",{class:"cursor-dot"},null,-1),v("div",{class:"cursor-ring"},null,-1)])],4)):Ve("",!0),v("div",ls,[i.value?(ne(),te("div",us,[v("span",null,U(o.value),1),v("button",{onClick:Ne,class:"toggle-btn"},"关闭")])):(ne(),te("button",{key:0,onClick:Ne,class:"gesture-toggle-btn"}," 🎥 启用手势控制 "))]),v("div",{class:Sn(["camera-preview",{hidden:!i.value}])},[v("video",{ref_key:"videoElement",ref:s,autoplay:"",playsinline:""},null,512),v("canvas",{ref_key:"canvasElement",ref:n},null,512)],2),e.value?(ne(),te("div",ds,[v("div",fs,[m[2]||(m[2]=v("h3",null,"设备信息",-1)),v("button",{onClick:m[0]||(m[0]=R=>e.value=null),class:"close-btn"},"×")]),v("div",hs,[v("p",null,[m[3]||(m[3]=v("strong",null,"设备名称:",-1)),q(" "+U(e.value.name),1)]),v("p",null,[m[4]||(m[4]=v("strong",null,"设备ID:",-1)),q(" "+U(e.value.id),1)]),v("p",null,[m[5]||(m[5]=v("strong",null,"状态:",-1)),m[6]||(m[6]=q()),v("span",{style:ze({color:e.value.statusColor})},U(e.value.status),5)]),v("p",null,[m[7]||(m[7]=v("strong",null,"位置:",-1)),q(" X: "+U(e.value.position.x.toFixed(2))+", Y: "+U(e.value.position.y.toFixed(2))+", Z: "+U(e.value.position.z.toFixed(2)),1)]),v("p",null,[m[8]||(m[8]=v("strong",null,"温度:",-1)),q(" "+U(e.value.temperature)+"°C",1)]),v("p",null,[m[9]||(m[9]=v("strong",null,"运行时长:",-1)),q(" "+U(e.value.runtime)+"小时",1)])])])):Ve("",!0)]))}},ys=yn(gs,[["__scopeId","data-v-f14b8421"]]);export{ys as default};
|