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=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=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=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;_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{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=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;a0&&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;h0){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;u1){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{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{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)){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)=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){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};