import{$ as e,Bt as t,C as n,Ct as r,Dt as i,E as a,Et as o,F as s,Ft as c,Ht as l,I as u,K as d,Lt as f,Mt as p,Ot as m,R as h,Tt as g,U as _,V as v,Z as y,b,bt as x,et as S,f as C,ft as w,ht as T,m as E,n as D,nt as O,o as k,p as A,pt as j,q as M,r as N,rt as P,tt as F,u as I,w as L,wt as R,x as z,yt as B,z as V,zt as H}from"./three.module-BFsVh7r1.js";var U=class extends b{constructor(e){super(e)}parse(e){function t(e){switch(e.image_type){case d:case m:if(e.colormap_length>256||e.colormap_size!==24||e.colormap_type!==1)throw Error(`THREE.TGALoader: Invalid type colormap data for indexed type.`);break;case f:case p:case h:case g:if(e.colormap_type)throw Error(`THREE.TGALoader: Invalid type colormap data for colormap type.`);break;case u:throw Error(`THREE.TGALoader: No data.`);default:throw Error(`THREE.TGALoader: Invalid type `+e.image_type)}if(e.width<=0||e.height<=0)throw Error(`THREE.TGALoader: Invalid image size.`);if(e.pixel_size!==8&&e.pixel_size!==16&&e.pixel_size!==24&&e.pixel_size!==32)throw Error(`THREE.TGALoader: Invalid pixel size `+e.pixel_size)}function n(e,t,n,r,i){let a,o,s=n.pixel_size>>3,c=n.width*n.height*s;if(t&&(o=i.subarray(r,r+=n.colormap_length*(n.colormap_size>>3))),e){a=new Uint8Array(c);let e,t,n,o=0,l=new Uint8Array(s);for(;o>7,e[(u+f*d)*4+1]=(c&992)>>2,e[(u+f*d)*4+2]=(c&31)<<3,e[(u+f*d)*4+3]=c&32768?0:255;return e}function a(e,t,n,r,i,a,o,s){let c=0,l,u,d=E.width;for(u=t;u!==r;u+=n)for(l=i;l!==o;l+=a,c+=3)e[(l+d*u)*4+3]=255,e[(l+d*u)*4+2]=s[c+0],e[(l+d*u)*4+1]=s[c+1],e[(l+d*u)*4+0]=s[c+2];return e}function o(e,t,n,r,i,a,o,s){let c=0,l,u,d=E.width;for(u=t;u!==r;u+=n)for(l=i;l!==o;l+=a,c+=4)e[(l+d*u)*4+2]=s[c+0],e[(l+d*u)*4+1]=s[c+1],e[(l+d*u)*4+0]=s[c+2],e[(l+d*u)*4+3]=s[c+3];return e}function s(e,t,n,r,i,a,o,s){let c,l=0,u,d,f=E.width;for(d=t;d!==r;d+=n)for(u=i;u!==o;u+=a,l++)c=s[l],e[(u+f*d)*4+0]=c,e[(u+f*d)*4+1]=c,e[(u+f*d)*4+2]=c,e[(u+f*d)*4+3]=255;return e}function c(e,t,n,r,i,a,o,s){let c=0,l,u,d=E.width;for(u=t;u!==r;u+=n)for(l=i;l!==o;l+=a,c+=2)e[(l+d*u)*4+0]=s[c+0],e[(l+d*u)*4+1]=s[c+0],e[(l+d*u)*4+2]=s[c+0],e[(l+d*u)*4+3]=s[c+1];return e}function l(e,t,n,l,u){let d,f,p,m,h,g;switch((E.flags&v)>>y){default:case S:d=0,p=1,h=t,f=0,m=1,g=n;break;case b:d=0,p=1,h=t,f=n-1,m=-1,g=-1;break;case C:d=t-1,p=-1,h=-1,f=0,m=1,g=n;break;case x:d=t-1,p=-1,h=-1,f=n-1,m=-1,g=-1;break}if(k)switch(E.pixel_size){case 8:s(e,f,m,g,d,p,h,l);break;case 16:c(e,f,m,g,d,p,h,l);break;default:throw Error(`THREE.TGALoader: Format not supported.`)}else switch(E.pixel_size){case 8:r(e,f,m,g,d,p,h,l,u);break;case 16:i(e,f,m,g,d,p,h,l);break;case 24:a(e,f,m,g,d,p,h,l);break;case 32:o(e,f,m,g,d,p,h,l);break;default:throw Error(`THREE.TGALoader: Format not supported.`)}return e}let u=0,d=1,f=2,p=3,m=9,h=10,g=11,v=48,y=4,b=0,x=1,S=2,C=3;if(e.length<19)throw Error(`THREE.TGALoader: Not enough data to contain header.`);let w=0,T=new Uint8Array(e),E={id_length:T[w++],colormap_type:T[w++],image_type:T[w++],colormap_index:T[w++]|T[w++]<<8,colormap_length:T[w++]|T[w++]<<8,colormap_size:T[w++],origin:[T[w++]|T[w++]<<8,T[w++]|T[w++]<<8],width:T[w++]|T[w++]<<8,height:T[w++]|T[w++]<<8,pixel_size:T[w++],flags:T[w++]};if(t(E),E.id_length+w>e.length)throw Error(`THREE.TGALoader: No data.`);w+=E.id_length;let D=!1,O=!1,k=!1;switch(E.image_type){case 9:D=!0,O=!0;break;case 1:O=!0;break;case 10:D=!0;break;case 2:break;case 11:D=!0,k=!0;break;case 3:k=!0;break}let A=new Uint8Array(E.width*E.height*4),j=n(D,O,E,w,T);return l(A,E.width,E.height,j.pixel_data,j.palettes),{data:A,width:E.width,height:E.height,flipY:!0,generateMipmaps:!0,minFilter:_}}};function W(e,t){let n=[],r=e.childNodes;for(let e=0,i=r.length;eparseInt(e))}function J(e){return e.substring(1)}var Y=class{constructor(){this.count=0}generateId(){return`three_default_`+ this.count++}parse(e){if(e.length===0)return null;let t=new DOMParser().parseFromString(e,`application/xml`),n=W(t,`COLLADA`)[0],r=t.getElementsByTagName(`parsererror`)[0];if(r!==void 0){let e=W(r,`div`)[0],t;return t=e?e.textContent:this.parserErrorToText(r),console.error(`THREE.ColladaLoader: Failed to parse collada file. `,t),null}let i=n.getAttribute(`version`);console.debug(`THREE.ColladaLoader: File version`,i);let a=this.parseAsset(W(n,`asset`)[0]),o={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{},joints:{}};return this.library=o,this.collada=n,this.parseLibrary(n,`library_animations`,`animation`,this.parseAnimation.bind(this)),this.parseLibrary(n,`library_animation_clips`,`animation_clip`,this.parseAnimationClip.bind(this)),this.parseLibrary(n,`library_controllers`,`controller`,this.parseController.bind(this)),this.parseLibrary(n,`library_images`,`image`,this.parseImage.bind(this)),this.parseLibrary(n,`library_effects`,`effect`,this.parseEffect.bind(this)),this.parseLibrary(n,`library_materials`,`material`,this.parseMaterial.bind(this)),this.parseLibrary(n,`library_cameras`,`camera`,this.parseCamera.bind(this)),this.parseLibrary(n,`library_lights`,`light`,this.parseLight.bind(this)),this.parseLibrary(n,`library_geometries`,`geometry`,this.parseGeometry.bind(this)),this.parseLibrary(n,`library_nodes`,`node`,this.parseNode.bind(this)),this.parseLibrary(n,`library_visual_scenes`,`visual_scene`,this.parseVisualScene.bind(this)),this.parseLibrary(n,`library_joints`,`joint`,this.parseLibraryJoint.bind(this)),this.parseLibrary(n,`library_kinematics_models`,`kinematics_model`,this.parseKinematicsModel.bind(this)),this.parseLibrary(n,`library_physics_models`,`physics_model`,this.parsePhysicsModel.bind(this)),this.parseLibrary(n,`scene`,`instance_kinematics_scene`,this.parseKinematicsScene.bind(this)),{library:o,asset:a,collada:n}}parserErrorToText(e){let t=[],n=[e];for(;n.length;){let e=n.shift();e.nodeType===Node.TEXT_NODE?t.push(e.textContent):(t.push(` `),n.push(...e.childNodes))}return t.join(``).trim()}parseAsset(e){return{unit:this.parseAssetUnit(W(e,`unit`)[0]),upAxis:this.parseAssetUpAxis(W(e,`up_axis`)[0])}}parseAssetUnit(e){return e!==void 0&&e.hasAttribute(`meter`)===!0?parseFloat(e.getAttribute(`meter`)):1}parseAssetUpAxis(e){return e===void 0?`Y_UP`:e.textContent}parseLibrary(e,t,n,r){let i=W(e,t)[0];if(i!==void 0){let e=W(i,n);for(let t=0;t0?n+a:n;t.inputs[o]={id:e,offset:i},t.stride=Math.max(t.stride,i+1),n===`TEXCOORD`&&(t.hasUV=!0);break;case`vcount`:t.vcount=q(r.textContent);break;case`p`:t.p=q(r.textContent);break}}return t.type===`polygons`&&(t.vcount=[t.p.length/t.stride]),t}parseLibraryJoint(e){this.library.joints[e.getAttribute(`id`)]=this.parseKinematicsJoint(e)}parseKinematicsModel(e){let t={name:e.getAttribute(`name`)||``,joints:{},links:[]};for(let n=0;n=n.limits.max&&(n.static=!0),n.middlePosition=(n.limits.min+n.limits.max)/2,n}parseKinematicsLink(e){let t={sid:e.getAttribute(`sid`),name:e.getAttribute(`name`)||``,attachments:[],transforms:[]};for(let n=0;n0&&d.dot(u)<0&&(u.x=-u.x,u.y=-u.y,u.z=-u.z,u.w=-u.w),d.copy(u),p.push(u.x,u.y,u.z,u.w)}let h=new x(e.uuid+`.quaternion`,c,p);this.applyInterpolation(h,m),o.push(h)}buildScaleTrack(e,t,n,r){if(t.default&&t.default.stride===3){let n=t.default,i=Array.from(n.times),a=Array.from(n.values),o=new l(e.uuid+`.scale`,i,a),s=this.getInterpolationInfo(t);this.applyInterpolation(o,s,t),r.push(o);return}let i=this.getTimesForAllAxes(t);if(i.length===0)return;let a=[],o=this.getInterpolationInfo(t);for(let e=0;ee-t),t}getValueAtTime(e,t,n){if(!e)return n;let r=e.times,i=e.values,a=e.interpolation;for(let n=0;nt){if(n===0)return i[0];let o=n-1,s=n,c=r[o],l=r[s],u=i[o],d=i[s],f=a?a[o]:`LINEAR`;return f===`STEP`?u:f===`BEZIER`&&e.inTangent&&e.outTangent?this.evaluateBezierComponent(e,o,s,c,l,t):u+(t-c)/(l-c)*(d-u)}}return i[i.length-1]}evaluateBezierComponent(e,t,n,r,i,a){let o=e.values,s=e.inTangent,c=e.outTangent,l=e.inTangentStride||1,u=o[t],d=o[n],f,p,m,h;l===2?(f=c[t*2],p=c[t*2+1],m=s[n*2],h=s[n*2+1]):(f=r+(i-r)/3,p=c[t],m=i-(i-r)/3,h=s[n]);let g=(a-r)/(i-r);for(let e=0;e<8;e++){let e=g*g,t=e*g,n=1-g,o=n*n,s=o*n*r+3*o*g*f+3*n*e*m+t*i,c=3*o*(f-r)+6*n*g*(m-f)+3*e*(i-m);if(Math.abs(c)<1e-10)break;let l=s-a;if(Math.abs(l)<1e-10)break;g-=l/c,g=Math.max(0,Math.min(1,g))}let _=g*g,v=_*g,y=1-g,b=y*y;return b*y*u+3*b*g*p+3*y*_*h+v*d}getInterpolationInfo(e){let t=[`X`,`Y`,`Z`,`ANGLE`,`default`],n=null,r=!0;for(let i of t){let t=e[i];if(!t||!t.interpolation)continue;let a=t.interpolation;for(let e=0;ee.time-t.time);for(let e=0;e<16;e++)this.transformAnimationData(n,e,t.elements[e]);return n}createKeyframeTracks(e,t){let n=e.keyframes,r=e.name,i=[],a=[],o=[],s=[],c=this.position,u=this.quaternion,d=this.scale,f=this.matrix;for(let e=0,t=n.length;e0&&t.push(new l(r+`.position`,i,a)),o.length>0&&t.push(new x(r+`.quaternion`,i,o)),s.length>0&&t.push(new l(r+`.scale`,i,s)),t}transformAnimationData(e,t,n){let r,i=!0,a,o;for(a=0,o=e.length;a=0;){let r=e[t];if(r.value[n]!==null)return r;t--}return null}getNext(e,t,n){for(;t>>0)+2);switch(n=n.toLowerCase(),n){case`tga`:t=this.tgaLoader;break;default:t=this.textureLoader}return t}buildMaterial(e){let t=this.getEffect(e.url),n=t.profile.technique,i;switch(n.type){case`phong`:case`blinn`:i=new P;break;case`lambert`:i=new O;break;default:i=new F;break}i.name=e.name||``;let a=this;function o(e,n=null){let i=t.profile.samplers[e.id],o=null;if(i!==void 0){let e=t.profile.surfaces[i.source];o=a.getImage(e.init_from)}else console.warn(`THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530).`),o=a.getImage(e.id);if(o!==null){let t=a.getTextureLoader(o);if(t!==void 0){let i=t.load(o),s=e.extra;if(s!==void 0&&s.technique!==void 0&&a.isEmpty(s.technique)===!1){let e=s.technique;i.wrapS=e.wrapU?r:C,i.wrapT=e.wrapV?r:C,i.offset.set(e.offsetU||0,e.offsetV||0),i.repeat.set(e.repeatU||1,e.repeatV||1)}else i.wrapS=r,i.wrapT=r;return n!==null&&(i.colorSpace=n),i}else return console.warn(`THREE.ColladaLoader: Loader for texture %s not found.`,o),null}else return console.warn(`THREE.ColladaLoader: Couldn't create texture with ID:`,e.id),null}let s=n.parameters;for(let e in s){let t=s[e];switch(e){case`diffuse`:t.color&&i.color.fromArray(t.color),t.texture&&(i.map=o(t.texture,R));break;case`specular`:t.color&&i.specular&&i.specular.fromArray(t.color),t.texture&&(i.specularMap=o(t.texture));break;case`bump`:t.texture&&(i.normalMap=o(t.texture));break;case`ambient`:t.texture&&(i.lightMap=o(t.texture,R));break;case`shininess`:t.float&&i.shininess&&(i.shininess=t.float);break;case`emission`:t.color&&i.emissive&&i.emissive.fromArray(t.color),t.texture&&(i.emissiveMap=o(t.texture,R));break}}E.colorSpaceToWorking(i.color,R),i.specular&&E.colorSpaceToWorking(i.specular,R),i.emissive&&E.colorSpaceToWorking(i.emissive,R);let c=s.transparent,l=s.transparency;if(l===void 0&&c&&(l={float:1}),c===void 0&&l&&(c={opaque:`A_ONE`,data:{color:[1,1,1,1]}}),c&&l)if(c.data.texture)i.transparent=!0;else{let e=c.data.color;switch(c.opaque){case`A_ONE`:i.opacity=e[3]*l.float;break;case`RGB_ZERO`:i.opacity=1-e[0]*l.float;break;case`A_ZERO`:i.opacity=1-e[3]*l.float;break;case`RGB_ONE`:i.opacity=e[0]*l.float;break;default:console.warn(`THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.`,c.opaque)}i.opacity<1&&(i.transparent=!0)}if(n.extra!==void 0&&n.extra.technique!==void 0){let e=n.extra.technique;for(let t in e){let n=e[t];switch(t){case`double_sided`:i.side=n===1?2:0;break;case`bump`:i.normalMap=o(n.texture),i.normalScale=new H(1,1);break}}}return i}getMaterial(e){return this.getBuild(this.library.materials[e],this.buildMaterial.bind(this))}buildCamera(e){let t;switch(e.optics.technique){case`perspective`:t=new j(e.optics.parameters.yfov,e.optics.parameters.aspect_ratio,e.optics.parameters.znear,e.optics.parameters.zfar);break;case`orthographic`:let n=e.optics.parameters.ymag,r=e.optics.parameters.xmag,i=e.optics.parameters.aspect_ratio;r=r===void 0?n*i:r,n=n===void 0?r/i:n,r*=.5,n*=.5,t=new w(-r,r,n,-n,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new j;break}return t.name=e.name||``,t}getCamera(e){let t=this.library.cameras[e];return t===void 0?(console.warn(`THREE.ColladaLoader: Couldn't find camera with ID:`,e),null):this.getBuild(t,this.buildCamera.bind(this))}buildLight(e){let t;switch(e.technique){case`directional`:t=new z;break;case`point`:t=new T;break;case`spot`:t=new p;break;case`ambient`:t=new D;break}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),e.parameters.falloffAngle&&(t.angle=y.degToRad(e.parameters.falloffAngle)),t}getLight(e){let t=this.library.lights[e];return t===void 0?(console.warn(`THREE.ColladaLoader: Couldn't find light with ID:`,e),null):this.getBuild(t,this.buildLight.bind(this))}groupPrimitives(e){let t={};for(let n=0;n0&&t0&&d.setAttribute(`position`,new L(i.array,i.stride)),a.array.length>0&&d.setAttribute(`normal`,new L(a.array,a.stride)),c.array.length>0&&d.setAttribute(`color`,new L(c.array,c.stride)),o.array.length>0&&d.setAttribute(`uv`,new L(o.array,o.stride)),s.array.length>0&&d.setAttribute(`uv1`,new L(s.array,s.stride)),l.array.length>0&&d.setAttribute(`skinIndex`,new L(l.array,l.stride)),u.array.length>0&&d.setAttribute(`skinWeight`,new L(u.array,u.stride)),r.data=d,r.type=e[0].type,r.materialKeys=f,r}buildGeometryData(e,n,r,i,a=!1){let s=e.p,c=e.stride,l=e.vcount,u=this.tempColor;function d(e){let t=s[e+r]*m,n=t+m;for(;t4){let n=[];for(let i=0;iMath.abs(i.y)&&Math.abs(i.x)>Math.abs(i.z))for(let e=0;eMath.abs(i.z))for(let e=0;er.limits.max||t0&&l.dot(c)<0&&(c.x=-c.x,c.y=-c.y,c.z=-c.z,c.w=-c.w),l.copy(c),u.push(c.x,c.y,c.z,c.w)}let f=new x(e.uuid+`.quaternion`,o,u);this.applyInterpolation(f,d),i.push(f)}buildHierarchyScaleTrack(e,t,n,r){if(t.default&&t.default.stride===3){let n=t.default,i=new l(e.uuid+`.scale`,Array.from(n.times),Array.from(n.values)),a=this.getInterpolationInfo(t);this.applyInterpolation(i,a,t),r.push(i);return}let i=this.getTimesForAllAxes(t);if(i.length===0)return;let a=[],o=this.getInterpolationInfo(t);for(let e=0;e