UNPKG

aframe-extras

Version:

Add-ons and examples for A-Frame VR.

2 lines 93.8 kB
/*! For license information please see aframe-extras.loaders.min.js.LICENSE.txt */ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("THREE"));else if("function"==typeof define&&define.amd)define(["THREE"],t);else{var n="object"==typeof exports?t(require("THREE")):t(e.THREE);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,e=>(()=>{var t={144:()=>{AFRAME.registerComponent("object-model",{schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){let e;const t=this.data;t.src&&(this.remove(),e=new THREE.ObjectLoader,t.crossorigin&&e.setCrossOrigin(t.crossorigin),e.load(t.src,e=>{e.traverse(e=>{e instanceof THREE.SkinnedMesh&&e.material&&(e.material.skinning=!!(e.geometry&&e.geometry.bones||[]).length)}),this.load(e)}))},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"json",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}})},417:()=>{const e={once:THREE.LoopOnce,repeat:THREE.LoopRepeat,pingpong:THREE.LoopPingPong};function t(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}AFRAME.registerComponent("animation-mixer",{schema:{clip:{default:"*"},useRegExp:{default:!1},duration:{default:0},clampWhenFinished:{default:!1,type:"boolean"},crossFadeDuration:{default:0},loop:{default:"repeat",oneOf:Object.keys(e)},repetitions:{default:1/0,min:0},timeScale:{default:1},startAt:{default:0}},init:function(){this.model=null,this.mixer=null,this.activeActions=[];const e=this.el.getObject3D("mesh");e?this.load(e):this.el.addEventListener("model-loaded",e=>{this.load(e.detail.model)})},load:function(e){const t=this.el;this.model=e,this.mixer=new THREE.AnimationMixer(e),this.mixer.addEventListener("loop",e=>{t.emit("animation-loop",{action:e.action,loopDelta:e.loopDelta})}),this.mixer.addEventListener("finished",e=>{t.emit("animation-finished",{action:e.action,direction:e.direction})}),this.data.clip&&this.update({})},remove:function(){this.mixer&&this.mixer.stopAllAction()},update:function(t){if(!t)return;const n=this.data,r=AFRAME.utils.diff(n,t);if("clip"in r)return this.stopAction(),void(n.clip&&this.playAction());this.activeActions.forEach(t=>{"duration"in r&&n.duration&&t.setDuration(n.duration),"clampWhenFinished"in r&&(t.clampWhenFinished=n.clampWhenFinished),("loop"in r||"repetitions"in r)&&t.setLoop(e[n.loop],n.repetitions),"timeScale"in r&&t.setEffectiveTimeScale(n.timeScale)})},stopAction:function(){const e=this.data;for(let t=0;t<this.activeActions.length;t++)e.crossFadeDuration?this.activeActions[t].fadeOut(e.crossFadeDuration):this.activeActions[t].stop();this.activeActions.length=0},playAction:function(){if(!this.mixer)return;const n=this.model,r=this.data,o=n.animations||(n.geometry||{}).animations||[];if(!o.length)return;const a=r.useRegExp?r.clip:(s=r.clip,new RegExp("^"+s.split(/\*+/).map(t).join(".*")+"$"));var s;for(let t,s=0;t=o[s];s++)if(t.name.match(a)){const o=this.mixer.clipAction(t,n);o.enabled=!0,o.clampWhenFinished=r.clampWhenFinished,r.duration&&o.setDuration(r.duration),1!==r.timeScale&&o.setEffectiveTimeScale(r.timeScale),o.startAt(this.mixer.time-r.startAt/1e3),o.setLoop(e[r.loop],r.repetitions).fadeIn(r.crossFadeDuration).play(),this.activeActions.push(o)}},tick:function(e,t){this.mixer&&!isNaN(t)&&this.mixer.update(t/1e3)}})},612:t=>{"use strict";t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}return(()=>{"use strict";r(417);var e=r(612);class t extends e.DataTextureLoader{constructor(e){super(e)}parse(t){if(t.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let n=0;const r=new Uint8Array(t),o={id_length:r[n++],colormap_type:r[n++],image_type:r[n++],colormap_index:r[n++]|r[n++]<<8,colormap_length:r[n++]|r[n++]<<8,colormap_size:r[n++],origin:[r[n++]|r[n++]<<8,r[n++]|r[n++]<<8],width:r[n++]|r[n++]<<8,height:r[n++]|r[n++]<<8,pixel_size:r[n++],flags:r[n++]};if(function(e){switch(e.image_type){case 1:case 9:if(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case 2:case 3:case 10:case 11:if(e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case 0:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+e.image_type)}if(e.width<=0||e.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size)throw new Error("THREE.TGALoader: Invalid pixel size "+e.pixel_size)}(o),o.id_length+n>t.length)throw new Error("THREE.TGALoader: No data.");n+=o.id_length;let a=!1,s=!1,i=!1;switch(o.image_type){case 9:a=!0,s=!0;break;case 1:s=!0;break;case 10:a=!0;break;case 2:break;case 11:a=!0,i=!0;break;case 3:i=!0}const c=new Uint8Array(o.width*o.height*4),l=function(e,t,n,r,o){let a,s;const i=n.pixel_size>>3,c=n.width*n.height*i;if(t&&(s=o.subarray(r,r+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;a=new Uint8Array(c);let s=0;const l=new Uint8Array(i);for(;s<c;)if(e=o[r++],t=1+(127&e),128&e){for(n=0;n<i;++n)l[n]=o[r++];for(n=0;n<t;++n)a.set(l,s+n*i);s+=i*t}else{for(t*=i,n=0;n<t;++n)a[s+n]=o[r++];s+=t}}else a=o.subarray(r,r+=t?n.width*n.height:c);return{pixel_data:a,palettes:s}}(a,s,o,n,r);return function(e,t,n,r,a){let s,c,l,u,d,p;switch((48&o.flags)>>4){default:case 2:s=0,l=1,d=t,c=0,u=1,p=n;break;case 0:s=0,l=1,d=t,c=n-1,u=-1,p=-1;break;case 3:s=t-1,l=-1,d=-1,c=0,u=1,p=n;break;case 1:s=t-1,l=-1,d=-1,c=n-1,u=-1,p=-1}if(i)switch(o.pixel_size){case 8:!function(e,t,n,r,a,s,i,c){let l,u,d,p=0;const h=o.width;for(d=t;d!==r;d+=n)for(u=a;u!==i;u+=s,p++)l=c[p],e[4*(u+h*d)+0]=l,e[4*(u+h*d)+1]=l,e[4*(u+h*d)+2]=l,e[4*(u+h*d)+3]=255}(e,c,u,p,s,l,d,r);break;case 16:!function(e,t,n,r,a,s,i,c){let l,u,d=0;const p=o.width;for(u=t;u!==r;u+=n)for(l=a;l!==i;l+=s,d+=2)e[4*(l+p*u)+0]=c[d+0],e[4*(l+p*u)+1]=c[d+0],e[4*(l+p*u)+2]=c[d+0],e[4*(l+p*u)+3]=c[d+1]}(e,c,u,p,s,l,d,r);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(o.pixel_size){case 8:!function(e,t,n,r,a,s,i,c,l){const u=l;let d,p,h,f=0;const m=o.width;for(h=t;h!==r;h+=n)for(p=a;p!==i;p+=s,f++)d=c[f],e[4*(p+m*h)+3]=255,e[4*(p+m*h)+2]=u[3*d+0],e[4*(p+m*h)+1]=u[3*d+1],e[4*(p+m*h)+0]=u[3*d+2]}(e,c,u,p,s,l,d,r,a);break;case 16:!function(e,t,n,r,a,s,i,c){let l,u,d,p=0;const h=o.width;for(d=t;d!==r;d+=n)for(u=a;u!==i;u+=s,p+=2)l=c[p+0]+(c[p+1]<<8),e[4*(u+h*d)+0]=(31744&l)>>7,e[4*(u+h*d)+1]=(992&l)>>2,e[4*(u+h*d)+2]=(31&l)<<3,e[4*(u+h*d)+3]=32768&l?0:255}(e,c,u,p,s,l,d,r);break;case 24:!function(e,t,n,r,a,s,i,c){let l,u,d=0;const p=o.width;for(u=t;u!==r;u+=n)for(l=a;l!==i;l+=s,d+=3)e[4*(l+p*u)+3]=255,e[4*(l+p*u)+2]=c[d+0],e[4*(l+p*u)+1]=c[d+1],e[4*(l+p*u)+0]=c[d+2]}(e,c,u,p,s,l,d,r);break;case 32:!function(e,t,n,r,a,s,i,c){let l,u,d=0;const p=o.width;for(u=t;u!==r;u+=n)for(l=a;l!==i;l+=s,d+=4)e[4*(l+p*u)+2]=c[d+0],e[4*(l+p*u)+1]=c[d+1],e[4*(l+p*u)+0]=c[d+2],e[4*(l+p*u)+3]=c[d+3]}(e,c,u,p,s,l,d,r);break;default:throw new Error("THREE.TGALoader: Format not supported.")}}(c,o.width,o.height,l.pixel_data,l.palettes),{data:c,width:o.width,height:o.height,flipY:!0,generateMipmaps:!0,minFilter:e.LinearMipmapLinearFilter}}}class n extends e.Loader{load(t,n,r,o){const a=this,s=""===a.path?e.LoaderUtils.extractUrlBase(t):a.path,i=new e.FileLoader(a.manager);i.setPath(a.path),i.setRequestHeader(a.requestHeader),i.setWithCredentials(a.withCredentials),i.load(t,function(e){try{n(a.parse(e,s))}catch(e){o?o(e):console.error(e),a.manager.itemError(t)}},r,o)}parse(n,r){function o(e,t){const n=[],r=e.childNodes;for(let e=0,o=r.length;e<o;e++){const o=r[e];o.nodeName===t&&n.push(o)}return n}function a(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=t[e];return n}function s(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=parseFloat(t[e]);return n}function i(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=parseInt(t[e]);return n}function c(e){return e.substring(1)}function l(){return"three_default_"+et++}function u(e){return 0===Object.keys(e).length}function d(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}function p(e){return void 0!==e?e.textContent:"Y_UP"}function h(e,t,n,r){const a=o(e,t)[0];if(void 0!==a){const e=o(a,n);for(let t=0;t<e.length;t++)r(e[t])}}function f(e,t){for(const n in e)e[n].build=t(e[n])}function m(e,t){return void 0!==e.build||(e.build=t(e)),e.build}function g(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"input"===r.nodeName){const e=c(r.getAttribute("source")),n=r.getAttribute("semantic");t.inputs[n]=e}}return t}function y(e){const t={};let n=e.getAttribute("target").split("/");const r=n.shift();let o=n.shift();const a=-1!==o.indexOf("("),s=-1!==o.indexOf(".");if(s)n=o.split("."),o=n.shift(),t.member=n.shift();else if(a){const e=o.split("(");o=e.shift();for(let t=0;t<e.length;t++)e[t]=parseInt(e[t].replace(/\)/,""));t.indices=e}return t.id=r,t.sid=o,t.arraySyntax=a,t.memberSyntax=s,t.sampler=c(e.getAttribute("source")),t}function v(e){const t=[],n=e.channels,r=e.samplers,o=e.sources;for(const e in n)if(n.hasOwnProperty(e)){const a=n[e],s=r[a.sampler],i=s.inputs.INPUT,c=s.inputs.OUTPUT;A(w(a,o[i],o[c]),t)}return t}function b(e){return m(tt.animations[e],v)}function w(e,t,n){const r=tt.nodes[e.id],o=je(r.id),a=r.transforms[e.sid],s=r.matrix.clone().transpose();let i,c,l,u,d,p;const h={};switch(a){case"matrix":for(l=0,u=t.array.length;l<u;l++)if(i=t.array[l],c=l*n.stride,void 0===h[i]&&(h[i]={}),!0===e.arraySyntax){const t=n.array[c],r=e.indices[0]+4*e.indices[1];h[i][r]=t}else for(d=0,p=n.stride;d<p;d++)h[i][d]=n.array[c+d];break;case"translate":case"rotate":case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',a)}const f=function(e,t){const n=[];for(const t in e)n.push({time:parseFloat(t),value:e[t]});n.sort(function(e,t){return e.time-t.time});for(let e=0;e<16;e++)E(n,e,t.elements[e]);return n}(h,s);return{name:o.uuid,keyframes:f}}const x=new e.Vector3,T=new e.Vector3,N=new e.Quaternion;function A(t,n){const r=t.keyframes,o=t.name,a=[],s=[],i=[],c=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],n=t.time,o=t.value;Me.fromArray(o).transpose(),Me.decompose(x,N,T),a.push(n),s.push(x.x,x.y,x.z),i.push(N.x,N.y,N.z,N.w),c.push(T.x,T.y,T.z)}return s.length>0&&n.push(new e.VectorKeyframeTrack(o+".position",a,s)),i.length>0&&n.push(new e.QuaternionKeyframeTrack(o+".quaternion",a,i)),c.length>0&&n.push(new e.VectorKeyframeTrack(o+".scale",a,c)),n}function E(e,t,n){let r,o,a,s=!0;for(o=0,a=e.length;o<a;o++)r=e[o],void 0===r.value[t]?r.value[t]=null:s=!1;if(!0===s)for(o=0,a=e.length;o<a;o++)r=e[o],r.value[t]=n;else!function(e,t){let n,r;for(let o=0,a=e.length;o<a;o++){const a=e[o];if(null===a.value[t]){if(n=k(e,o,t),r=I(e,o,t),null===n){a.value[t]=r.value[t];continue}if(null===r){a.value[t]=n.value[t];continue}C(a,n,r,t)}}}(e,t)}function k(e,t,n){for(;t>=0;){const r=e[t];if(null!==r.value[n])return r;t--}return null}function I(e,t,n){for(;t<e.length;){const r=e[t];if(null!==r.value[n])return r;t++}return null}function C(e,t,n,r){n.time-t.time!==0?e.value[r]=(e.time-t.time)*(n.value[r]-t.value[r])/(n.time-t.time)+t.value[r]:e.value[r]=t.value[r]}function M(t){const n=[],r=t.name,o=t.end-t.start||-1,a=t.animations;for(let e=0,t=a.length;e<t;e++){const t=b(a[e]);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}return new e.AnimationClip(r,o,n)}function L(e){return m(tt.clips[e],M)}function R(e){const t={sources:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=s(r.textContent);break;case"source":const e=r.getAttribute("id");t.sources[e]=le(r);break;case"joints":t.joints=S(r);break;case"vertex_weights":t.vertexWeights=D(r)}}return t}function S(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"input"===r.nodeName){const e=r.getAttribute("semantic"),n=c(r.getAttribute("source"));t.inputs[e]=n}}return t}function D(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"input":const e=r.getAttribute("semantic"),n=c(r.getAttribute("source")),o=parseInt(r.getAttribute("offset"));t.inputs[e]={id:n,offset:o};break;case"vcount":t.vcount=i(r.textContent);break;case"v":t.v=i(r.textContent)}}return t}function F(t){const n={id:t.id},r=tt.geometries[n.id];return void 0!==t.skin&&(n.skin=function(t){const n={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},r=t.sources,o=t.vertexWeights,a=o.vcount,s=o.v,i=o.inputs.JOINT.offset,c=o.inputs.WEIGHT.offset,l=t.sources[t.joints.inputs.JOINT],u=t.sources[t.joints.inputs.INV_BIND_MATRIX],d=r[o.inputs.WEIGHT.id].array;let p,h,f,m=0;for(p=0,f=a.length;p<f;p++){const e=a[p],t=[];for(h=0;h<e;h++){const e=s[m+i],n=d[s[m+c]];t.push({index:e,weight:n}),m+=2}for(t.sort(g),h=0;h<4;h++){const e=t[h];void 0!==e?(n.indices.array.push(e.index),n.weights.array.push(e.weight)):(n.indices.array.push(0),n.weights.array.push(0))}}for(t.bindShapeMatrix?n.bindMatrix=(new e.Matrix4).fromArray(t.bindShapeMatrix).transpose():n.bindMatrix=(new e.Matrix4).identity(),p=0,f=l.array.length;p<f;p++){const t=l.array[p],r=(new e.Matrix4).fromArray(u.array,p*u.stride).transpose();n.joints.push({name:t,boneInverse:r})}return n;function g(e,t){return t.weight-e.weight}}(t.skin),r.sources.skinIndices=n.skin.indices,r.sources.skinWeights=n.skin.weights),n}function O(e){return m(tt.controllers[e],F)}function P(e){return void 0!==e.build?e.build:e.init_from}function _(e){const t=tt.images[e];return void 0!==t?m(t,P):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",e),null)}function B(e){const t={surfaces:{},samplers:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"newparam":U(r,t);break;case"technique":t.technique=G(r);break;case"extra":t.extra=K(r)}}return t}function U(e,t){const n=e.getAttribute("sid");for(let r=0,o=e.childNodes.length;r<o;r++){const o=e.childNodes[r];if(1===o.nodeType)switch(o.nodeName){case"surface":t.surfaces[n]=j(o);break;case"sampler2D":t.samplers[n]=V(o)}}}function j(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"init_from"===r.nodeName&&(t.init_from=r.textContent)}return t}function V(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"source"===r.nodeName&&(t.source=r.textContent)}return t}function G(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=r.nodeName,t.parameters=H(r);break;case"extra":t.extra=K(r)}}return t}function H(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":t[r.nodeName]=z(r);break;case"transparent":t[r.nodeName]={opaque:r.hasAttribute("opaque")?r.getAttribute("opaque"):"A_ONE",data:z(r)}}}return t}function z(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"color":t[r.nodeName]=s(r.textContent);break;case"float":t[r.nodeName]=parseFloat(r.textContent);break;case"texture":t[r.nodeName]={id:r.getAttribute("texture"),extra:W(r)}}}return t}function W(e){const t={technique:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"extra"===r.nodeName&&X(r,t)}return t}function X(e,t){for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"technique"===r.nodeName&&q(r,t)}}function q(e,t){for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[r.nodeName]=parseFloat(r.textContent);break;case"wrapU":case"wrapV":"TRUE"===r.textContent.toUpperCase()?t.technique[r.nodeName]=1:"FALSE"===r.textContent.toUpperCase()?t.technique[r.nodeName]=0:t.technique[r.nodeName]=parseInt(r.textContent);break;case"bump":t[r.nodeName]=J(r)}}}function K(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"technique"===r.nodeName&&(t.technique=Y(r))}return t}function Y(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"double_sided":t[r.nodeName]=parseInt(r.textContent);break;case"bump":t[r.nodeName]=J(r)}}return t}function J(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"texture"===r.nodeName&&(t[r.nodeName]={id:r.getAttribute("texture"),texcoord:r.getAttribute("texcoord"),extra:W(r)})}return t}function Q(e){return e}function Z(t){const n=(r=t.url,m(tt.effects[r],Q));var r;const o=n.profile.technique;let a;switch(o.type){case"phong":case"blinn":a=new e.MeshPhongMaterial;break;case"lambert":a=new e.MeshLambertMaterial;break;default:a=new e.MeshBasicMaterial}function s(t,r=null){const o=n.profile.samplers[t.id];let a=null;if(void 0!==o?a=_(n.profile.surfaces[o.source].init_from):(console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),a=_(t.id)),null!==a){const n=function(e){let t,n=e.slice((e.lastIndexOf(".")-1>>>0)+2);return n=n.toLowerCase(),t="tga"===n?Je:Ye,t}(a);if(void 0!==n){const o=n.load(a),s=t.extra;if(void 0!==s&&void 0!==s.technique&&!1===u(s.technique)){const t=s.technique;o.wrapS=t.wrapU?e.RepeatWrapping:e.ClampToEdgeWrapping,o.wrapT=t.wrapV?e.RepeatWrapping:e.ClampToEdgeWrapping,o.offset.set(t.offsetU||0,t.offsetV||0),o.repeat.set(t.repeatU||1,t.repeatV||1)}else o.wrapS=e.RepeatWrapping,o.wrapT=e.RepeatWrapping;return null!==r&&(o.colorSpace=r),o}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",a),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",t.id),null}a.name=t.name||"";const i=o.parameters;for(const t in i){const n=i[t];switch(t){case"diffuse":n.color&&a.color.fromArray(n.color),n.texture&&(a.map=s(n.texture,e.SRGBColorSpace));break;case"specular":n.color&&a.specular&&a.specular.fromArray(n.color),n.texture&&(a.specularMap=s(n.texture));break;case"bump":n.texture&&(a.normalMap=s(n.texture));break;case"ambient":n.texture&&(a.lightMap=s(n.texture,e.SRGBColorSpace));break;case"shininess":n.float&&a.shininess&&(a.shininess=n.float);break;case"emission":n.color&&a.emissive&&a.emissive.fromArray(n.color),n.texture&&(a.emissiveMap=s(n.texture,e.SRGBColorSpace))}}a.color.convertSRGBToLinear(),a.specular&&a.specular.convertSRGBToLinear(),a.emissive&&a.emissive.convertSRGBToLinear();let c=i.transparent,l=i.transparency;if(void 0===l&&c&&(l={float:1}),void 0===c&&l&&(c={opaque:"A_ONE",data:{color:[1,1,1,1]}}),c&&l)if(c.data.texture)a.transparent=!0;else{const e=c.data.color;switch(c.opaque){case"A_ONE":a.opacity=e[3]*l.float;break;case"RGB_ZERO":a.opacity=1-e[0]*l.float;break;case"A_ZERO":a.opacity=1-e[3]*l.float;break;case"RGB_ONE":a.opacity=e[0]*l.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',c.opaque)}a.opacity<1&&(a.transparent=!0)}if(void 0!==o.extra&&void 0!==o.extra.technique){const t=o.extra.technique;for(const n in t){const r=t[n];switch(n){case"double_sided":a.side=1===r?e.DoubleSide:e.FrontSide;break;case"bump":a.normalMap=s(r.texture),a.normalScale=new e.Vector2(1,1)}}}return a}function $(e){return m(tt.materials[e],Z)}function ee(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if("technique_common"===n.nodeName)return te(n)}return{}}function te(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"perspective":case"orthographic":t.technique=r.nodeName,t.parameters=ne(r)}}return t}function ne(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[r.nodeName]=parseFloat(r.textContent)}}return t}function re(t){let n;switch(t.optics.technique){case"perspective":n=new e.PerspectiveCamera(t.optics.parameters.yfov,t.optics.parameters.aspect_ratio,t.optics.parameters.znear,t.optics.parameters.zfar);break;case"orthographic":let r=t.optics.parameters.ymag,o=t.optics.parameters.xmag;const a=t.optics.parameters.aspect_ratio;o=void 0===o?r*a:o,r=void 0===r?o/a:r,o*=.5,r*=.5,n=new e.OrthographicCamera(-o,o,r,-r,t.optics.parameters.znear,t.optics.parameters.zfar);break;default:n=new e.PerspectiveCamera}return n.name=t.name||"",n}function oe(e){const t=tt.cameras[e];return void 0!==t?m(t,re):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function ae(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=r.nodeName,t.parameters=se(r)}}return t}function se(t){const n={};for(let r=0,o=t.childNodes.length;r<o;r++){const o=t.childNodes[r];if(1===o.nodeType)switch(o.nodeName){case"color":const t=s(o.textContent);n.color=(new e.Color).fromArray(t).convertSRGBToLinear();break;case"falloff_angle":n.falloffAngle=parseFloat(o.textContent);break;case"quadratic_attenuation":const r=parseFloat(o.textContent);n.distance=r?Math.sqrt(1/r):0}}return n}function ie(t){let n;switch(t.technique){case"directional":n=new e.DirectionalLight;break;case"point":n=new e.PointLight;break;case"spot":n=new e.SpotLight;break;case"ambient":n=new e.AmbientLight}return t.parameters.color&&n.color.copy(t.parameters.color),t.parameters.distance&&(n.distance=t.parameters.distance),n}function ce(e){const t=tt.lights[e];return void 0!==t?m(t,ie):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",e),null)}function le(e){const t={array:[],stride:3};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"float_array":t.array=s(r.textContent);break;case"Name_array":t.array=a(r.textContent);break;case"technique_common":const e=o(r,"accessor")[0];void 0!==e&&(t.stride=parseInt(e.getAttribute("stride")))}}return t}function ue(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];1===r.nodeType&&(t[r.getAttribute("semantic")]=c(r.getAttribute("source")))}return t}function de(e){const t={type:e.nodeName,material:e.getAttribute("material"),count:parseInt(e.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"input":const e=c(r.getAttribute("source")),n=r.getAttribute("semantic"),o=parseInt(r.getAttribute("offset")),a=parseInt(r.getAttribute("set")),s=a>0?n+a:n;t.inputs[s]={id:e,offset:o},t.stride=Math.max(t.stride,o+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=i(r.textContent);break;case"p":t.p=i(r.textContent)}}return t}function pe(e){let t=0;for(let n=0,r=e.length;n<r;n++)!0===e[n].hasUV&&t++;t>0&&t<e.length&&(e.uvsNeedsFix=!0)}function he(e){const t={},n=e.sources,r=e.vertices,o=e.primitives;if(0===o.length)return{};const a=function(e){const t={};for(let n=0;n<e.length;n++){const r=e[n];void 0===t[r.type]&&(t[r.type]=[]),t[r.type].push(r)}return t}(o);for(const e in a){const o=a[e];pe(o),t[e]=fe(o,n,r)}return t}function fe(t,n,r){const o={},a={array:[],stride:0},s={array:[],stride:0},i={array:[],stride:0},c={array:[],stride:0},l={array:[],stride:0},u=[],d=[],p=new e.BufferGeometry,h=[];let f=0;for(let e=0;e<t.length;e++){const o=t[e],m=o.inputs;let g=0;switch(o.type){case"lines":case"linestrips":g=2*o.count;break;case"triangles":g=3*o.count;break;case"polylist":for(let e=0;e<o.count;e++){const t=o.vcount[e];switch(t){case 3:g+=3;break;case 4:g+=6;break;default:g+=3*(t-2)}}break;default:console.warn("THREE.ColladaLoader: Unknow primitive type:",o.type)}p.addGroup(f,g,e),f+=g,o.material&&h.push(o.material);for(const e in m){const p=m[e];switch(e){case"VERTEX":for(const e in r){const h=r[e];switch(e){case"POSITION":const r=a.array.length;if(me(o,n[h],p.offset,a.array),a.stride=n[h].stride,n.skinWeights&&n.skinIndices&&(me(o,n.skinIndices,p.offset,u),me(o,n.skinWeights,p.offset,d)),!1===o.hasUV&&!0===t.uvsNeedsFix){const e=(a.array.length-r)/a.stride;for(let t=0;t<e;t++)i.array.push(0,0)}break;case"NORMAL":me(o,n[h],p.offset,s.array),s.stride=n[h].stride;break;case"COLOR":me(o,n[h],p.offset,l.array),l.stride=n[h].stride;break;case"TEXCOORD":me(o,n[h],p.offset,i.array),i.stride=n[h].stride;break;case"TEXCOORD1":me(o,n[h],p.offset,c.array),i.stride=n[h].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',e)}}break;case"NORMAL":me(o,n[p.id],p.offset,s.array),s.stride=n[p.id].stride;break;case"COLOR":me(o,n[p.id],p.offset,l.array,!0),l.stride=n[p.id].stride;break;case"TEXCOORD":me(o,n[p.id],p.offset,i.array),i.stride=n[p.id].stride;break;case"TEXCOORD1":me(o,n[p.id],p.offset,c.array),c.stride=n[p.id].stride}}}return a.array.length>0&&p.setAttribute("position",new e.Float32BufferAttribute(a.array,a.stride)),s.array.length>0&&p.setAttribute("normal",new e.Float32BufferAttribute(s.array,s.stride)),l.array.length>0&&p.setAttribute("color",new e.Float32BufferAttribute(l.array,l.stride)),i.array.length>0&&p.setAttribute("uv",new e.Float32BufferAttribute(i.array,i.stride)),c.array.length>0&&p.setAttribute("uv1",new e.Float32BufferAttribute(c.array,c.stride)),u.length>0&&p.setAttribute("skinIndex",new e.Float32BufferAttribute(u,4)),d.length>0&&p.setAttribute("skinWeight",new e.Float32BufferAttribute(d,4)),o.data=p,o.type=t[0].type,o.materialKeys=h,o}function me(e,t,n,r,o=!1){const a=e.p,s=e.stride,i=e.vcount;function c(e){let t=a[e+n]*u;const s=t+u;for(;t<s;t++)r.push(l[t]);if(o){const e=r.length-u-1;Qe.setRGB(r[e+0],r[e+1],r[e+2]).convertSRGBToLinear(),r[e+0]=Qe.r,r[e+1]=Qe.g,r[e+2]=Qe.b}}const l=t.array,u=t.stride;if(void 0!==e.vcount){let e=0;for(let t=0,n=i.length;t<n;t++){const n=i[t];if(4===n){const t=e+1*s,n=e+2*s,r=e+3*s;c(e+0*s),c(t),c(r),c(t),c(n),c(r)}else if(3===n){const t=e+1*s,n=e+2*s;c(e+0*s),c(t),c(n)}else if(n>4)for(let t=1,r=n-2;t<=r;t++){const n=e+s*t,r=e+s*(t+1);c(e+0*s),c(n),c(r)}e+=s*n}}else for(let e=0,t=a.length;e<t;e+=s)c(e)}function ge(e){return m(tt.geometries[e],he)}function ye(e){return void 0!==e.build?e.build:e}function ve(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"joint":t.joints[r.getAttribute("sid")]=be(r);break;case"link":t.links.push(xe(r))}}}function be(e){let t;for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"prismatic":case"revolute":t=we(r)}}return t}function we(t){const n={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",axis:new e.Vector3,limits:{min:0,max:0},type:t.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let e=0;e<t.childNodes.length;e++){const r=t.childNodes[e];if(1===r.nodeType)switch(r.nodeName){case"axis":const e=s(r.textContent);n.axis.fromArray(e);break;case"limits":const t=r.getElementsByTagName("max")[0],o=r.getElementsByTagName("min")[0];n.limits.max=parseFloat(t.textContent),n.limits.min=parseFloat(o.textContent)}}return n.limits.min>=n.limits.max&&(n.static=!0),n.middlePosition=(n.limits.min+n.limits.max)/2,n}function xe(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"attachment_full":t.attachments.push(Te(r));break;case"matrix":case"translate":case"rotate":t.transforms.push(Ne(r))}}return t}function Te(e){const t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"link":t.links.push(xe(r));break;case"matrix":case"translate":case"rotate":t.transforms.push(Ne(r))}}return t}function Ne(t){const n={type:t.nodeName},r=s(t.textContent);switch(n.type){case"matrix":n.obj=new e.Matrix4,n.obj.fromArray(r).transpose();break;case"translate":n.obj=new e.Vector3,n.obj.fromArray(r);break;case"rotate":n.obj=new e.Vector3,n.obj.fromArray(r),n.angle=e.MathUtils.degToRad(r[3])}return n}function Ae(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];1===r.nodeType&&"technique_common"===r.nodeName&&Ee(r,t)}}function Ee(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"inertia":t.inertia=s(r.textContent);break;case"mass":t.mass=s(r.textContent)[0]}}}function ke(e){const t={target:e.getAttribute("target").split("/").pop()};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"axis"===r.nodeName){const e=r.getElementsByTagName("param")[0];t.axis=e.textContent;const n=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=n.substring(0,n.length-1)}}return t}function Ie(e){return void 0!==e.build?e.build:e}function Ce(t){const n=[],r=We.querySelector('[id="'+t.id+'"]');for(let t=0;t<r.childNodes.length;t++){const o=r.childNodes[t];if(1!==o.nodeType)continue;let a,i;switch(o.nodeName){case"matrix":a=s(o.textContent);const t=(new e.Matrix4).fromArray(a).transpose();n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:t});break;case"translate":case"scale":a=s(o.textContent),i=(new e.Vector3).fromArray(a),n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:i});break;case"rotate":a=s(o.textContent),i=(new e.Vector3).fromArray(a);const r=e.MathUtils.degToRad(a[3]);n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:i,angle:r})}}return n}const Me=new e.Matrix4,Le=new e.Vector3;function Re(t){const n={name:t.getAttribute("name")||"",type:t.getAttribute("type"),id:t.getAttribute("id"),sid:t.getAttribute("sid"),matrix:new e.Matrix4,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let r=0;r<t.childNodes.length;r++){const o=t.childNodes[r];if(1!==o.nodeType)continue;let a;switch(o.nodeName){case"node":n.nodes.push(o.getAttribute("id")),Re(o);break;case"instance_camera":n.instanceCameras.push(c(o.getAttribute("url")));break;case"instance_controller":n.instanceControllers.push(Se(o));break;case"instance_light":n.instanceLights.push(c(o.getAttribute("url")));break;case"instance_geometry":n.instanceGeometries.push(Se(o));break;case"instance_node":n.instanceNodes.push(c(o.getAttribute("url")));break;case"matrix":a=s(o.textContent),n.matrix.multiply(Me.fromArray(a).transpose()),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"translate":a=s(o.textContent),Le.fromArray(a),n.matrix.multiply(Me.makeTranslation(Le.x,Le.y,Le.z)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"rotate":a=s(o.textContent);const t=e.MathUtils.degToRad(a[3]);n.matrix.multiply(Me.makeRotationAxis(Le.fromArray(a),t)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"scale":a=s(o.textContent),n.matrix.scale(Le.fromArray(a)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"extra":break;default:console.log(o)}}return Ue(n.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",n.id):tt.nodes[n.id]=n,n}function Se(e){const t={id:c(e.getAttribute("url")),materials:{},skeletons:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"bind_material":const e=r.getElementsByTagName("instance_material");for(let n=0;n<e.length;n++){const r=e[n],o=r.getAttribute("symbol"),a=r.getAttribute("target");t.materials[o]=c(a)}break;case"skeleton":t.skeletons.push(c(r.textContent))}}return t}function De(t,n){const r=[],o=[];let a,s,i;for(a=0;a<t.length;a++){const e=t[a];let o;if(Ue(e))o=je(e),Fe(o,n,r);else if(Ge(e)){const t=tt.visualScenes[e].children;for(let e=0;e<t.length;e++){const o=t[e];"JOINT"===o.type&&Fe(je(o.id),n,r)}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",e)}for(a=0;a<n.length;a++)for(s=0;s<r.length;s++)if(i=r[s],i.bone.name===n[a].name){o[a]=i,i.processed=!0;break}for(a=0;a<r.length;a++)i=r[a],!1===i.processed&&(o.push(i),i.processed=!0);const c=[],l=[];for(a=0;a<o.length;a++)i=o[a],c.push(i.bone),l.push(i.boneInverse);return new e.Skeleton(c,l)}function Fe(t,n,r){t.traverse(function(t){if(!0===t.isBone){let o;for(let e=0;e<n.length;e++){const r=n[e];if(r.name===t.name){o=r.boneInverse;break}}void 0===o&&(o=new e.Matrix4),r.push({bone:t,boneInverse:o,processed:!1})}})}function Oe(t){const n=[],r=t.matrix,o=t.nodes,a=t.type,s=t.instanceCameras,i=t.instanceControllers,c=t.instanceLights,l=t.instanceGeometries,u=t.instanceNodes;for(let e=0,t=o.length;e<t;e++)n.push(je(o[e]));for(let e=0,t=s.length;e<t;e++){const t=oe(s[e]);null!==t&&n.push(t.clone())}for(let e=0,t=i.length;e<t;e++){const t=i[e],r=O(t.id),o=Be(ge(r.id),t.materials),a=De(t.skeletons,r.skin.joints);for(let e=0,t=o.length;e<t;e++){const t=o[e];t.isSkinnedMesh&&(t.bind(a,r.skin.bindMatrix),t.normalizeSkinWeights()),n.push(t)}}for(let e=0,t=c.length;e<t;e++){const t=ce(c[e]);null!==t&&n.push(t.clone())}for(let e=0,t=l.length;e<t;e++){const t=l[e],r=Be(ge(t.id),t.materials);for(let e=0,t=r.length;e<t;e++)n.push(r[e])}for(let e=0,t=u.length;e<t;e++)n.push(je(u[e]).clone());let d;if(0===o.length&&1===n.length)d=n[0];else{d="JOINT"===a?new e.Bone:new e.Group;for(let e=0;e<n.length;e++)d.add(n[e])}return d.name="JOINT"===a?t.sid:t.name,d.matrix.copy(r),d.matrix.decompose(d.position,d.quaternion,d.scale),d}const Pe=new e.MeshBasicMaterial({name:e.Loader.DEFAULT_MATERIAL_NAME,color:16711935});function _e(e,t){const n=[];for(let r=0,o=e.length;r<o;r++){const o=t[e[r]];void 0===o?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",e[r]),n.push(Pe)):n.push($(o))}return n}function Be(t,n){const r=[];for(const o in t){const a=t[o],s=_e(a.materialKeys,n);if(0===s.length&&("lines"===o||"linestrips"===o?s.push(new e.LineBasicMaterial):s.push(new e.MeshPhongMaterial)),"lines"===o||"linestrips"===o)for(let t=0,n=s.length;t<n;t++){const n=s[t];if(!0===n.isMeshPhongMaterial||!0===n.isMeshLambertMaterial){const r=new e.LineBasicMaterial;r.color.copy(n.color),r.opacity=n.opacity,r.transparent=n.transparent,s[t]=r}}const i=void 0!==a.data.attributes.skinIndex,c=1===s.length?s[0]:s;let l;switch(o){case"lines":l=new e.LineSegments(a.data,c);break;case"linestrips":l=new e.Line(a.data,c);break;case"triangles":case"polylist":l=i?new e.SkinnedMesh(a.data,c):new e.Mesh(a.data,c)}r.push(l)}return r}function Ue(e){return void 0!==tt.nodes[e]}function je(e){return m(tt.nodes[e],Oe)}function Ve(t){const n=new e.Group;n.name=t.name;const r=t.children;for(let e=0;e<r.length;e++){const t=r[e];n.add(je(t.id))}return n}function Ge(e){return void 0!==tt.visualScenes[e]}function He(e){return m(tt.visualScenes[e],Ve)}if(0===n.length)return{scene:new e.Scene};const ze=(new DOMParser).parseFromString(n,"application/xml"),We=o(ze,"COLLADA")[0],Xe=ze.getElementsByTagName("parsererror")[0];if(void 0!==Xe){const e=o(Xe,"div")[0];let t;return t=e?e.textContent:function(e){let t="";const n=[e];for(;n.length;){const e=n.shift();e.nodeType===Node.TEXT_NODE?t+=e.textContent:(t+="\n",n.push.apply(n,e.childNodes))}return t.trim()}(Xe),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",t),null}const qe=We.getAttribute("version");console.debug("THREE.ColladaLoader: File version",qe);const Ke=function(e){return{unit:d(o(e,"unit")[0]),upAxis:p(o(e,"up_axis")[0])}}(o(We,"asset")[0]),Ye=new e.TextureLoader(this.manager);let Je;Ye.setPath(this.resourcePath||r).setCrossOrigin(this.crossOrigin),t&&(Je=new t(this.manager),Je.setPath(this.resourcePath||r));const Qe=new e.Color,Ze=[];let $e={},et=0;const tt={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};h(We,"library_animations","animation",function t(n){const r={sources:{},samplers:{},channels:{}};let o=!1;for(let e=0,a=n.childNodes.length;e<a;e++){const a=n.childNodes[e];if(1!==a.nodeType)continue;let s;switch(a.nodeName){case"source":s=a.getAttribute("id"),r.sources[s]=le(a);break;case"sampler":s=a.getAttribute("id"),r.samplers[s]=g(a);break;case"channel":s=a.getAttribute("target"),r.channels[s]=y(a);break;case"animation":t(a),o=!0;break;default:console.log(a)}}!1===o&&(tt.animations[n.getAttribute("id")||e.MathUtils.generateUUID()]=r)}),h(We,"library_animation_clips","animation_clip",function(e){const t={name:e.getAttribute("id")||"default",start:parseFloat(e.getAttribute("start")||0),end:parseFloat(e.getAttribute("end")||0),animations:[]};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"instance_animation"===r.nodeName&&t.animations.push(c(r.getAttribute("url")))}tt.clips[e.getAttribute("id")]=t}),h(We,"library_controllers","controller",function(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"skin":t.id=c(r.getAttribute("source")),t.skin=R(r);break;case"morph":t.id=c(r.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}tt.controllers[e.getAttribute("id")]=t}),h(We,"library_images","image",function(e){const t={init_from:o(e,"init_from")[0].textContent};tt.images[e.getAttribute("id")]=t}),h(We,"library_effects","effect",function(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"profile_COMMON"===r.nodeName&&(t.profile=B(r))}tt.effects[e.getAttribute("id")]=t}),h(We,"library_materials","material",function(e){const t={name:e.getAttribute("name")};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"instance_effect"===r.nodeName&&(t.url=c(r.getAttribute("url")))}tt.materials[e.getAttribute("id")]=t}),h(We,"library_cameras","camera",function(e){const t={name:e.getAttribute("name")};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"optics"===r.nodeName&&(t.optics=ee(r))}tt.cameras[e.getAttribute("id")]=t}),h(We,"library_lights","light",function(e){let t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"technique_common"===r.nodeName&&(t=ae(r))}tt.lights[e.getAttribute("id")]=t}),h(We,"library_geometries","geometry",function(e){const t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},n=o(e,"mesh")[0];if(void 0!==n){for(let e=0;e<n.childNodes.length;e++){const r=n.childNodes[e];if(1!==r.nodeType)continue;const o=r.getAttribute("id");switch(r.nodeName){case"source":t.sources[o]=le(r);break;case"vertices":t.vertices=ue(r);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",r.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(de(r));break;default:console.log(r)}}tt.geometries[e.getAttribute("id")]=t}}),h(We,"library_nodes","node",Re),h(We,"library_visual_scenes","visual_scene",function(e){const t={name:e.getAttribute("name"),children:[]};!function(e){const t=e.getElementsByTagName("node");for(let e=0;e<t.length;e++){const n=t[e];!1===n.hasAttribute("id")&&n.setAttribute("id",l())}}(e);const n=o(e,"node");for(let e=0;e<n.length;e++)t.children.push(Re(n[e]));tt.visualScenes[e.getAttribute("id")]=t}),h(We,"library_kinematics_models","kinematics_model",function(e){const t={name:e.getAttribute("name")||"",joints:{},links:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];1===r.nodeType&&"technique_common"===r.nodeName&&ve(r,t)}tt.kinematicsModels[e.getAttribute("id")]=t}),h(We,"library_physics_models","physics_model",function(e){const t={name:e.getAttribute("name")||"",rigidBodies:{}};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];1===r.nodeType&&"rigid_body"===r.nodeName&&(t.rigidBodies[r.getAttribute("name")]={},Ae(r,t.rigidBodies[r.getAttribute("name")]))}tt.physicsModels[e.getAttribute("id")]=t}),h(We,"scene","instance_kinematics_scene",function(e){const t={bindJointAxis:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];1===r.nodeType&&"bind_joint_axis"===r.nodeName&&t.bindJointAxis.push(ke(r))}tt.kinematicsScenes[c(e.getAttribute("url"))]=t}),f(tt.animations,v),f(tt.clips,M),f(tt.controllers,F),f(tt.images,P),f(tt.effects,Q),f(tt.materials,Z),f(tt.cameras,re),f(tt.lights,ie),f(tt.geometries,he),f(tt.visualScenes,Ve),function(){const t=tt.clips;if(!0===u(t)){if(!1===u(tt.animations)){const t=[];for(const e in tt.animations){const n=b(e);for(let e=0,r=n.length;e<r;e++)t.push(n[e])}Ze.push(new e.AnimationClip("default",-1,t))}}else for(const e in t)Ze.push(L(e))}(),function(){const t=Object.keys(tt.kinematicsModels)[0],n=Object.keys(tt.kinematicsScenes)[0],r=Object.keys(tt.visualScenes)[0];if(void 0===t||void 0===n)return;const o=(a=t,m(tt.kinematicsModels[a],ye));var a;const s=function(e){return m(tt.kinematicsScenes[e],Ie)}(n),i=He(r),c=s.bindJointAxis,l={};for(let e=0,t=c.length;e<t;e++){const t=c[e],n=We.querySelector('[sid="'+t.target+'"]');if(n){const e=n.parentElement;u(t.jointIndex,e)}}function u(e,t){const n=t.getAttribute("name"),r=o.joints[e];i.traverse(function(o){o.name===n&&(l[e]={object:o,transforms:Ce(t),joint:r,position:r.zeroPosition})})}const d=new e.Matrix4;$e={joints:o&&o.joints,getJointValue:function(e){const t=l[e];if(t)return t.position;console.warn("THREE.ColladaLoader: Joint "+e+" doesn't exist.")},setJointValue:function(t,n){const r=l[t];if(r){const o=r.joint;if(n>o.limits.max||n<o.limits.min)console.warn("THREE.ColladaLoader: Joint "+t+" value "+n+" outside of limits (min: "+o.limits.min+", max: "+o.limits.max+").");else if(o.static)console.warn("THREE.ColladaLoader: Joint "+t+" is static.");else{const a=r.object,s=o.axis,i=r.transforms;Me.identity();for(let r=0;r<i.length;r++){const a=i[r];if(a.sid&&-1!==a.sid.indexOf(t))switch(o.type){case"revolute":Me.multiply(d.makeRotationAxis(s,e.MathUtils.degToRad(n)));break;case"prismatic":Me.multiply(d.makeTranslation(s.x*n,s.y*n,s.z*n));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+o.type)}else switch(a.type){case"matrix":Me.multiply(a.obj);break;case"translate":Me.multiply(d.makeTranslation(a.obj.x,a.obj.y,a.obj.z));break;case"scale":Me.scale(a.obj);break;case"rotate":Me.multiply(d.makeRotationAxis(a.obj,a.angle))}}a.matrix.copy(Me),a.matrix.decompose(a.position,a.quaternion,a.scale),l[t].position=n}}else console.log("THREE.ColladaLoader: "+t+" does not exist.")}}}();const nt=function(e){return He(c(o(e,"instance_visual_scene")[0].getAttribute("url")))}(o(We,"scene")[0]);return nt.animations=Ze,"Z_UP"===Ke.upAxis&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),nt.rotation.set(-Math.PI/2,0,0)),nt.scale.multiplyScalar(Ke.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Ze},kinematics:$e,library:tt,scene:nt}}}THREE.ColladaLoader=n,AFRAME.registerComponent("collada-model-legacy",{schema:{type:"asset"},init:function(){this.model=null,this.loader=new THREE.ColladaLoader},update:function(){var e=this,t=this.el,n=this.data,r=this.el.sceneEl.systems.renderer;n&&(this.remove(),this.loader.load(n,function(n){e.model=n.scene,e.model.traverse(function(e){if(e.isMesh){var t=e.material;t.color&&r.applyColorCorrection(t.color),t.map&&r.applyColorCorrection(t.map),t.emissive&&r.applyColorCorrection(t.emissive),t.emissiveMap&&r.applyColorCorrection(t.emissiveMap)}}),t.setObject3D("mesh",e.model),t.emit("model-loaded",{format:"collada",model:e.model})}))},remove:function(){this.model&&this.el.removeObject3D("mesh")}});var o=Uint8Array,a=Uint16Array,s=Int32Array,i=new o([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),c=new o([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),l=new o([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=function(e,t){for(var n=new a(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new s(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return{b:n,r:o}},d=u(i,2),p=d.b,h=d.r;p[28]=258,h[258]=28;for(var f=u(c,0),m=f.b,g=(f.r,new a(32768)),y=0;y<32768;++y){var v=(43690&y)>>1|(21845&y)<<1;v=(61680&(v=(52428&v)>>2|(13107&v)<<2))>>4|(3855&v)<<4,g[y]=((65280&v)>>8|(255&v)<<8)>>1}var b=function(e,t,n){for(var r=e.length,o=0,s=new a(t);o<r;++o)e[o]&&++s[e[o]-1];var i,c=new a(t);for(o=1;o<t;++o)c[o]=c[o-1]+s[o-1]<<1;if(n){i=new a(1<<t);var l=15-t;for(o=0;o<r;++o)if(e[o])for(var u=o<<4|e[o],d=t-e[o],p=c[e[o]-1]++<<d,h=p|(1<<d)-1;p<=h;++p)i[g[p]>>l]=u}else for(i=new a(r),o=0;o<r;++o)e[o]&&(i[o]=g[c[e[o]-1]++]>>15-e[o]);return i},w=new o(288);for(y=0;y<144;++y)w[y]=8;for(y=144;y<256;++y)w[y]=9;for(y=256;y<280;++y)w[y]=7;for(y=280;y<288;++y)w[y]=8;var x=new o(32);for(y=0;y<32;++y)x[y]=5;var T=b(w,9,1),N=b(x,5,1),A=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},E=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},k=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},I=function(e){return(e+7)/8|0},C=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],M=function(e,t,n){var r=new Error(t||C[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,M),!n)throw r;return r},L=function(e,t,n,r){var a=e.length,s=r?r.length:0;if(!a||t.f&&!t.l)return n||new o(0);var u=!n,d=u||2!=t.i,h=t.i;u&&(n=new o(3*a));var f=function(e){var t=n.length;if(e>t){var r=new o(Math.max(2*t,e));r.set(n),n=r}},g=t.f||0,y=t.p||0,v=t.b||0,w=t.l,x=t.d,C=t.m,L=t.n,R=8*a;do{if(!w){g=E(e,y,1);var S=E(e,y+1,3);if(y+=3,!S){var D=e[(z=I(y)+4)-4]|e[z-3]<<8,F=z+D;if(F>a){h&&M(0);break}d&&f(v+D),n.set(e.subarray(z,F),v),t.b=v+=D,t.p=y=8*F,t.f=g;continue}if(1==S)w=T,x=N,C=9,L=5;else if(2==S){var O=E(e,y,31)+257,P=E(e,y+10,15)+4,_=O+E(e,y+5,31)+1;y+=14;for(var B=new o(_),U=new o(19),j=0;j<P;++j)U[l[j]]=E(e,y+3*j,7);y+=3*P;var V=A(U),G=(1<<V)-1,H=b(U,V,1);for(j=0;j<_;){var z,W=H[E(e,y,G)];if(y+=15&W,(z=W>>4)<16)B[j++]=z;else{var X=0,q=0;for(16==z?(q=3+E(e,y,3),y+=2,X=B[j-1]):17==z?(q=3+E(e,y,7),y+=3):18==z&&(q=11+E(e,y,127),y+=7);q--;)B[j++]=X}}var K=B.subarray(0,O),Y=B.subarray(O);C=A(K),L=A(Y),w=b(K,C,1),x=b(Y,L,1)}else M(1);if(y>R){h&&M(0);break}}d&&f(v+131072);for(var J=(1<<C)-1,Q=(1<<L)-1,Z=y;;Z=y){var $=(X=w[k(e,y)&J])>>4;if((y+=15&X)>R){h&&M(0);break}if(X||M(2),$<256)n[v++]=$;else{if(256==$){Z=y,w=null;break}var ee=$-254;if($>264){var te=i[j=$-257];ee=E(e,y,(1<<te)-1)+p[j],y+=te}var ne=x[k(e,y)&Q],re=ne>>4;if(ne||M(3),y+=15&ne,Y=m[re],re>3&&(te=c[re],Y+=k(e,y)&(1<<te)-1,y+=te),y>R){h&&M(0);break}d&&f(v+131072);var oe=v+ee;if(v<Y){var ae=s-Y,se=Math.min(Y,oe);for(ae+v<0&&M(3);v<se;++v)n[v]=r[ae+v]}for(;v<oe;++v)n[v]=n[v-Y]}}t.l=w,t.p=Z,t.b=v,t.f=g,w&&(g=1,t.m=C,t.d=x,t.n=L)}while(!g);return v!=n.length&&u?function(e,t,n){return(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length),new o(e.subarray(t,n))}(n,0,v):n.subarray(0,v)},R=new o(0);function S(e,t){return L(e.subarray((n=e,r=t&&t.dictionary,(8!=(15&n[0])||n[0]>>4>7||(n[0]<<8|n[1])%31)&&M(6,"invalid zlib data"),(n[1]>>5&1)==+!r&&M(6,"invalid zlib data: "+(32&n[1]?"need":"unexpected")+" dictionary"),2+(n[1]>>3&4)),-4),{i:2},t&&t.out,t&&t.dictionary);var n,r}var D="undefined"!=typeof TextDecoder&&new TextDecoder;try{D.decode(R,{stream:!0})}catch(e){}function F(e,t,n){const r=n.length-e-1;if(t>=n[r])return r-1;if(t<=n[e])return e;let o=e,a=r,s=Math.floor((o+a)/2);for(;t<n[s]||t>=n[s+1];)t<n[s]?a=s:o=s,s=Math.floor((o+a)/2);return s}function O(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let r=1;for(let e=2;e<=t;++e)r*=e;for(let n=2;n<=e-t;++n)r*=n;return n/r}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;class P extends e.Curve{constructor(t,n,r,o,a){super(),this.degree=t,this.knots=n,this.controlPoints=[],this.startKnot=o||0,this.endKnot=a||this.knots.length-1;for(let t=0;t<r.length;++t){const n=r[t];this.controlPoints[t]=new e.Vector4(n.x,n.y,n.z,n.w)}}getPoint(t,n=new e.Vector3){const r=n,o=this.knots[this.startKnot]+t*(this.knots[this.endKnot]-this.knots[this.startKnot]),a=function(t,n,r,o){const a=F(t,o,n),s=function(e,t,n,r){const o=[],a=[],s=[];o[0]=1;for(let i=1;i<=n;++i){a[i]=t-r[e+1-i],s[i]=r[e+i]-t;let n=0;for(let e=0;e<i;++e){const t=s[e+1],r=a[i-e],c=o[e]/(t+r);o[e]=n+t*c,n=r*c}o[i]=n}return o}(a,o,t,n),i=new e.Vector4(0,0,0,0);for(let e=0;e<=t;++e){const n=r[a-t+e],o=s[e],c=n.w*o;i.x+=n.x*c,i.y+=n.y*c,i.z+=n.z*c,i.w+=n.w*o}return i}(this.degree,this.knots,this.controlPoints,o);return 1!==a.w&&a.divideScalar(a.w),r.set(a.x,a.y,a.z)}getTangent(t,n=new e.Vector3){const r=n,o=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),a=function(t,n,r,o,a){const s=function(t,n,r,o,a){const s=a<t?a:t,i=[],c=F(t,o,n),l=function(e,t,n,r,o){const a=[];for(let e=0;e<=n;++e)a[e]=0;const s=[];for(let e=0;e<=r;++e)s[e]=a.slice(0);const i=[];for(let e=0;e<=n;++e)i[e]=a.slice(0);i[0][0]=1;con