aframe-extras
Version:
Add-ons and examples for A-Frame VR.
1 lines • 95.4 kB
JavaScript
!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={37:e=>{function t(e){const t=document.getElementById(e),n=t.parentNode;try{n&&n.removeChild(t)}catch(e){}}e.exports=function(e){return e=e||{},function(n,r){return function(e,n,r){return new r((function(r,o){const s=n.timeout||5e3,a="script_"+Date.now()+"_"+Math.ceil(1e5*Math.random()),i=function(e,t){var n=document.createElement("script");return n.type="text/javascript",n.async=!0,n.id=t,n.src=e,n}(e,a),c=setTimeout((function(){o(new Error("Script request to "+e+" timed out")),t(a)}),s),l=function(e){clearTimeout(e)};i.addEventListener("load",(function(e){r({ok:!0}),l(c),t(a)})),i.addEventListener("error",(function(n){o(new Error("Script request to "+e+" failed "+n)),l(c),t(a)})),function(e){const t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}(i)}))}(n,r=r||{},e.Promise||Promise)}}},417:e=>{const t={once:THREE.LoopOnce,repeat:THREE.LoopRepeat,pingpong:THREE.LoopPingPong};function n(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}e.exports=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(t)},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(e){if(!e)return;const n=this.data,r=AFRAME.utils.diff(n,e);if("clip"in r)return this.stopAction(),void(n.clip&&this.playAction());this.activeActions.forEach((e=>{"duration"in r&&n.duration&&e.setDuration(n.duration),"clampWhenFinished"in r&&(e.clampWhenFinished=n.clampWhenFinished),("loop"in r||"repetitions"in r)&&e.setLoop(t[n.loop],n.repetitions),"timeScale"in r&&e.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 e=this.model,r=this.data,o=e.animations||(e.geometry||{}).animations||[];if(!o.length)return;const s=r.useRegExp?r.clip:(a=r.clip,new RegExp("^"+a.split(/\*+/).map(n).join(".*")+"$"));var a;for(let n,a=0;n=o[a];a++)if(n.name.match(s)){const o=this.mixer.clipAction(n,e);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(t[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)}})},299:(e,t,n)=>{"use strict";var r=n(612);class o extends r.DataTextureLoader{constructor(e){super(e)}parse(e){if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let t=0;const n=new Uint8Array(e),o={id_length:n[t++],colormap_type:n[t++],image_type:n[t++],colormap_index:n[t++]|n[t++]<<8,colormap_length:n[t++]|n[t++]<<8,colormap_size:n[t++],origin:[n[t++]|n[t++]<<8,n[t++]|n[t++]<<8],width:n[t++]|n[t++]<<8,height:n[t++]|n[t++]<<8,pixel_size:n[t++],flags:n[t++]};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+t>e.length)throw new Error("THREE.TGALoader: No data.");t+=o.id_length;let s=!1,a=!1,i=!1;switch(o.image_type){case 9:s=!0,a=!0;break;case 1:a=!0;break;case 10:s=!0;break;case 2:break;case 11:s=!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 s,a;const i=n.pixel_size>>3,c=n.width*n.height*i;if(t&&(a=o.subarray(r,r+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;s=new Uint8Array(c);let a=0;const l=new Uint8Array(i);for(;a<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)s.set(l,a+n*i);a+=i*t}else{for(t*=i,n=0;n<t;++n)s[a+n]=o[r++];a+=t}}else s=o.subarray(r,r+=t?n.width*n.height:c);return{pixel_data:s,palettes:a}}(s,a,o,t,n);return function(e,t,n,r,s){let a,c,l,u,d,p;switch((48&o.flags)>>4){default:case 2:a=0,l=1,d=t,c=0,u=1,p=n;break;case 0:a=0,l=1,d=t,c=n-1,u=-1,p=-1;break;case 3:a=t-1,l=-1,d=-1,c=0,u=1,p=n;break;case 1:a=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,s,a,i,c){let l,u,d,p=0;const h=o.width;for(d=t;d!==r;d+=n)for(u=s;u!==i;u+=a,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,a,l,d,r);break;case 16:!function(e,t,n,r,s,a,i,c){let l,u,d=0;const p=o.width;for(u=t;u!==r;u+=n)for(l=s;l!==i;l+=a,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,a,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,s,a,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=s;p!==i;p+=a,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,a,l,d,r,s);break;case 16:!function(e,t,n,r,s,a,i,c){let l,u,d,p=0;const h=o.width;for(d=t;d!==r;d+=n)for(u=s;u!==i;u+=a,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,a,l,d,r);break;case 24:!function(e,t,n,r,s,a,i,c){let l,u,d=0;const p=o.width;for(u=t;u!==r;u+=n)for(l=s;l!==i;l+=a,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,a,l,d,r);break;case 32:!function(e,t,n,r,s,a,i,c){let l,u,d=0;const p=o.width;for(u=t;u!==r;u+=n)for(l=s;l!==i;l+=a,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,a,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:r.LinearMipmapLinearFilter}}}class s extends r.Loader{load(e,t,n,o){const s=this,a=""===s.path?r.LoaderUtils.extractUrlBase(e):s.path,i=new r.FileLoader(s.manager);i.setPath(s.path),i.setRequestHeader(s.requestHeader),i.setWithCredentials(s.withCredentials),i.load(e,(function(n){try{t(s.parse(n,a))}catch(t){o?o(t):console.error(t),s.manager.itemError(e)}}),n,o)}parse(e,t){function n(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 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]=t[e];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]=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(e){return 0===Object.keys(e).length}function u(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}function d(e){return void 0!==e?e.textContent:"Y_UP"}function p(e,t,r,o){const s=n(e,t)[0];if(void 0!==s){const e=n(s,r);for(let t=0;t<e.length;t++)o(e[t])}}function h(e,t){for(const n in e)e[n].build=t(e[n])}function f(e,t){return void 0!==e.build||(e.build=t(e)),e.build}function m(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 g(e){const t={};let n=e.getAttribute("target").split("/");const r=n.shift();let o=n.shift();const s=-1!==o.indexOf("("),a=-1!==o.indexOf(".");if(a)n=o.split("."),o=n.shift(),t.member=n.shift();else if(s){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=s,t.memberSyntax=a,t.sampler=c(e.getAttribute("source")),t}function y(e){const t=[],n=e.channels,r=e.samplers,o=e.sources;for(const e in n)if(n.hasOwnProperty(e)){const s=n[e],a=r[s.sampler],i=a.inputs.INPUT,c=a.inputs.OUTPUT;N(b(s,o[i],o[c]),t)}return t}function v(e){return f(Ze.animations[e],y)}function b(e,t,n){const r=Ze.nodes[e.id],o=_e(r.id),s=r.transforms[e.sid],a=r.matrix.clone().transpose();let i,c,l,u,d,p;const h={};switch(s){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.',s)}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++)A(n,e,t.elements[e]);return n}(h,a);return{name:o.uuid,keyframes:f}}const w=new r.Vector3,x=new r.Vector3,T=new r.Quaternion;function N(e,t){const n=e.keyframes,o=e.name,s=[],a=[],i=[],c=[];for(let e=0,t=n.length;e<t;e++){const t=n[e],r=t.time,o=t.value;Ie.fromArray(o).transpose(),Ie.decompose(w,T,x),s.push(r),a.push(w.x,w.y,w.z),i.push(T.x,T.y,T.z,T.w),c.push(x.x,x.y,x.z)}return a.length>0&&t.push(new r.VectorKeyframeTrack(o+".position",s,a)),i.length>0&&t.push(new r.QuaternionKeyframeTrack(o+".quaternion",s,i)),c.length>0&&t.push(new r.VectorKeyframeTrack(o+".scale",s,c)),t}function A(e,t,n){let r,o,s,a=!0;for(o=0,s=e.length;o<s;o++)r=e[o],void 0===r.value[t]?r.value[t]=null:a=!1;if(!0===a)for(o=0,s=e.length;o<s;o++)r=e[o],r.value[t]=n;else!function(e,t){let n,r;for(let o=0,s=e.length;o<s;o++){const s=e[o];if(null===s.value[t]){if(n=E(e,o,t),r=k(e,o,t),null===n){s.value[t]=r.value[t];continue}if(null===r){s.value[t]=n.value[t];continue}I(s,n,r,t)}}}(e,t)}function E(e,t,n){for(;t>=0;){const r=e[t];if(null!==r.value[n])return r;t--}return null}function k(e,t,n){for(;t<e.length;){const r=e[t];if(null!==r.value[n])return r;t++}return null}function I(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 C(e){const t=[],n=e.name,o=e.end-e.start||-1,s=e.animations;for(let e=0,n=s.length;e<n;e++){const n=v(s[e]);for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return new r.AnimationClip(n,o,t)}function M(e){return f(Ze.clips[e],C)}function L(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=a(r.textContent);break;case"source":const e=r.getAttribute("id");t.sources[e]=ie(r);break;case"joints":t.joints=R(r);break;case"vertex_weights":t.vertexWeights=S(r)}}return t}function R(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 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)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 D(e){const t={id:e.id},n=Ze.geometries[t.id];return void 0!==e.skin&&(t.skin=function(e){const t={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},n=e.sources,o=e.vertexWeights,s=o.vcount,a=o.v,i=o.inputs.JOINT.offset,c=o.inputs.WEIGHT.offset,l=e.sources[e.joints.inputs.JOINT],u=e.sources[e.joints.inputs.INV_BIND_MATRIX],d=n[o.inputs.WEIGHT.id].array;let p,h,f,m=0;for(p=0,f=s.length;p<f;p++){const e=s[p],n=[];for(h=0;h<e;h++){const e=a[m+i],t=d[a[m+c]];n.push({index:e,weight:t}),m+=2}for(n.sort(g),h=0;h<4;h++){const e=n[h];void 0!==e?(t.indices.array.push(e.index),t.weights.array.push(e.weight)):(t.indices.array.push(0),t.weights.array.push(0))}}for(e.bindShapeMatrix?t.bindMatrix=(new r.Matrix4).fromArray(e.bindShapeMatrix).transpose():t.bindMatrix=(new r.Matrix4).identity(),p=0,f=l.array.length;p<f;p++){const e=l.array[p],n=(new r.Matrix4).fromArray(u.array,p*u.stride).transpose();t.joints.push({name:e,boneInverse:n})}return t;function g(e,t){return t.weight-e.weight}}(e.skin),n.sources.skinIndices=t.skin.indices,n.sources.skinWeights=t.skin.weights),t}function F(e){return void 0!==e.build?e.build:e.init_from}function P(e){const t=Ze.images[e];return void 0!==t?f(t,F):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",e),null)}function O(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":B(r,t);break;case"technique":t.technique=j(r);break;case"extra":t.extra=X(r)}}return t}function B(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]=_(o);break;case"sampler2D":t.samplers[n]=U(o)}}}function _(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 U(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 j(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=G(r);break;case"extra":t.extra=X(r)}}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"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":t[r.nodeName]=V(r);break;case"transparent":t[r.nodeName]={opaque:r.hasAttribute("opaque")?r.getAttribute("opaque"):"A_ONE",data:V(r)}}}return t}function V(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]=a(r.textContent);break;case"float":t[r.nodeName]=parseFloat(r.textContent);break;case"texture":t[r.nodeName]={id:r.getAttribute("texture"),extra:H(r)}}}return t}function H(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&&z(r,t)}return t}function z(e,t){for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];1===r.nodeType&&"technique"===r.nodeName&&W(r,t)}}function W(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]=K(r)}}}function X(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=q(r))}return t}function q(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]=K(r)}}return t}function K(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:H(r)})}return t}function Y(e){return e}function J(e){const t=(n=e.url,f(Ze.effects[n],Y));var n;const o=t.profile.technique;let s;switch(o.type){case"phong":case"blinn":s=new r.MeshPhongMaterial;break;case"lambert":s=new r.MeshLambertMaterial;break;default:s=new r.MeshBasicMaterial}function a(e,n=null){const o=t.profile.samplers[e.id];let s=null;if(void 0!==o?s=P(t.profile.surfaces[o.source].init_from):(console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),s=P(e.id)),null!==s){const t=function(e){let t,n=e.slice(2+(e.lastIndexOf(".")-1>>>0));return n=n.toLowerCase(),t="tga"===n?qe:Xe,t}(s);if(void 0!==t){const o=t.load(s),a=e.extra;if(void 0!==a&&void 0!==a.technique&&!1===l(a.technique)){const e=a.technique;o.wrapS=e.wrapU?r.RepeatWrapping:r.ClampToEdgeWrapping,o.wrapT=e.wrapV?r.RepeatWrapping:r.ClampToEdgeWrapping,o.offset.set(e.offsetU||0,e.offsetV||0),o.repeat.set(e.repeatU||1,e.repeatV||1)}else o.wrapS=r.RepeatWrapping,o.wrapT=r.RepeatWrapping;return null!==n&&(o.colorSpace=n),o}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",s),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}s.name=e.name||"";const i=o.parameters;for(const e in i){const t=i[e];switch(e){case"diffuse":t.color&&s.color.fromArray(t.color),t.texture&&(s.map=a(t.texture,r.SRGBColorSpace));break;case"specular":t.color&&s.specular&&s.specular.fromArray(t.color),t.texture&&(s.specularMap=a(t.texture));break;case"bump":t.texture&&(s.normalMap=a(t.texture));break;case"ambient":t.texture&&(s.lightMap=a(t.texture,r.SRGBColorSpace));break;case"shininess":t.float&&s.shininess&&(s.shininess=t.float);break;case"emission":t.color&&s.emissive&&s.emissive.fromArray(t.color),t.texture&&(s.emissiveMap=a(t.texture,r.SRGBColorSpace))}}s.color.convertSRGBToLinear(),s.specular&&s.specular.convertSRGBToLinear(),s.emissive&&s.emissive.convertSRGBToLinear();let c=i.transparent,u=i.transparency;if(void 0===u&&c&&(u={float:1}),void 0===c&&u&&(c={opaque:"A_ONE",data:{color:[1,1,1,1]}}),c&&u)if(c.data.texture)s.transparent=!0;else{const e=c.data.color;switch(c.opaque){case"A_ONE":s.opacity=e[3]*u.float;break;case"RGB_ZERO":s.opacity=1-e[0]*u.float;break;case"A_ZERO":s.opacity=1-e[3]*u.float;break;case"RGB_ONE":s.opacity=e[0]*u.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',c.opaque)}s.opacity<1&&(s.transparent=!0)}if(void 0!==o.extra&&void 0!==o.extra.technique){const e=o.extra.technique;for(const t in e){const n=e[t];switch(t){case"double_sided":s.side=1===n?r.DoubleSide:r.FrontSide;break;case"bump":s.normalMap=a(n.texture),s.normalScale=new r.Vector2(1,1)}}}return s}function Q(e){return f(Ze.materials[e],J)}function Z(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if("technique_common"===n.nodeName)return $(n)}return{}}function $(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=ee(r)}}return t}function ee(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 te(e){let t;switch(e.optics.technique){case"perspective":t=new r.PerspectiveCamera(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,o=e.optics.parameters.xmag;const s=e.optics.parameters.aspect_ratio;o=void 0===o?n*s:o,n=void 0===n?o/s:n,o*=.5,n*=.5,t=new r.OrthographicCamera(-o,o,n,-n,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new r.PerspectiveCamera}return t.name=e.name||"",t}function ne(e){const t=Ze.cameras[e];return void 0!==t?f(t,te):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function re(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=oe(r)}}return t}function oe(e){const t={};for(let n=0,o=e.childNodes.length;n<o;n++){const o=e.childNodes[n];if(1===o.nodeType)switch(o.nodeName){case"color":const e=a(o.textContent);t.color=(new r.Color).fromArray(e).convertSRGBToLinear();break;case"falloff_angle":t.falloffAngle=parseFloat(o.textContent);break;case"quadratic_attenuation":const n=parseFloat(o.textContent);t.distance=n?Math.sqrt(1/n):0}}return t}function se(e){let t;switch(e.technique){case"directional":t=new r.DirectionalLight;break;case"point":t=new r.PointLight;break;case"spot":t=new r.SpotLight;break;case"ambient":t=new r.AmbientLight}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),t}function ae(e){const t=Ze.lights[e];return void 0!==t?f(t,se):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",e),null)}function ie(e){const t={array:[],stride:3};for(let r=0;r<e.childNodes.length;r++){const o=e.childNodes[r];if(1===o.nodeType)switch(o.nodeName){case"float_array":t.array=a(o.textContent);break;case"Name_array":t.array=s(o.textContent);break;case"technique_common":const e=n(o,"accessor")[0];void 0!==e&&(t.stride=parseInt(e.getAttribute("stride")))}}return t}function ce(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 le(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")),s=parseInt(r.getAttribute("set")),a=s>0?n+s:n;t.inputs[a]={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 ue(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 de(e){const t={},n=e.sources,r=e.vertices,o=e.primitives;if(0===o.length)return{};const s=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 s){const o=s[e];ue(o),t[e]=pe(o,n,r)}return t}function pe(e,t,n){const o={},s={array:[],stride:0},a={array:[],stride:0},i={array:[],stride:0},c={array:[],stride:0},l={array:[],stride:0},u=[],d=[],p=new r.BufferGeometry,h=[];let f=0;for(let r=0;r<e.length;r++){const o=e[r],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,r),f+=g,o.material&&h.push(o.material);for(const r in m){const p=m[r];switch(r){case"VERTEX":for(const r in n){const h=n[r];switch(r){case"POSITION":const n=s.array.length;if(he(o,t[h],p.offset,s.array),s.stride=t[h].stride,t.skinWeights&&t.skinIndices&&(he(o,t.skinIndices,p.offset,u),he(o,t.skinWeights,p.offset,d)),!1===o.hasUV&&!0===e.uvsNeedsFix){const e=(s.array.length-n)/s.stride;for(let t=0;t<e;t++)i.array.push(0,0)}break;case"NORMAL":he(o,t[h],p.offset,a.array),a.stride=t[h].stride;break;case"COLOR":he(o,t[h],p.offset,l.array),l.stride=t[h].stride;break;case"TEXCOORD":he(o,t[h],p.offset,i.array),i.stride=t[h].stride;break;case"TEXCOORD1":he(o,t[h],p.offset,c.array),i.stride=t[h].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',r)}}break;case"NORMAL":he(o,t[p.id],p.offset,a.array),a.stride=t[p.id].stride;break;case"COLOR":he(o,t[p.id],p.offset,l.array,!0),l.stride=t[p.id].stride;break;case"TEXCOORD":he(o,t[p.id],p.offset,i.array),i.stride=t[p.id].stride;break;case"TEXCOORD1":he(o,t[p.id],p.offset,c.array),c.stride=t[p.id].stride}}}return s.array.length>0&&p.setAttribute("position",new r.Float32BufferAttribute(s.array,s.stride)),a.array.length>0&&p.setAttribute("normal",new r.Float32BufferAttribute(a.array,a.stride)),l.array.length>0&&p.setAttribute("color",new r.Float32BufferAttribute(l.array,l.stride)),i.array.length>0&&p.setAttribute("uv",new r.Float32BufferAttribute(i.array,i.stride)),c.array.length>0&&p.setAttribute("uv1",new r.Float32BufferAttribute(c.array,c.stride)),u.length>0&&p.setAttribute("skinIndex",new r.Float32BufferAttribute(u,4)),d.length>0&&p.setAttribute("skinWeight",new r.Float32BufferAttribute(d,4)),o.data=p,o.type=e[0].type,o.materialKeys=h,o}function he(e,t,n,r,o=!1){const s=e.p,a=e.stride,i=e.vcount;function c(e){let t=s[e+n]*u;const a=t+u;for(;t<a;t++)r.push(l[t]);if(o){const e=r.length-u-1;Ke.setRGB(r[e+0],r[e+1],r[e+2]).convertSRGBToLinear(),r[e+0]=Ke.r,r[e+1]=Ke.g,r[e+2]=Ke.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*a,n=e+2*a,r=e+3*a;c(e+0*a),c(t),c(r),c(t),c(n),c(r)}else if(3===n){const t=e+1*a,n=e+2*a;c(e+0*a),c(t),c(n)}else if(n>4)for(let t=1,r=n-2;t<=r;t++){const n=e+a*t,r=e+a*(t+1);c(e+0*a),c(n),c(r)}e+=a*n}}else for(let e=0,t=s.length;e<t;e+=a)c(e)}function fe(e){return f(Ze.geometries[e],de)}function me(e){return void 0!==e.build?e.build:e}function ge(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")]=ye(r);break;case"link":t.links.push(be(r))}}}function ye(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=ve(r)}}return t}function ve(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",axis:new r.Vector3,limits:{min:0,max:0},type:e.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"axis":const e=a(r.textContent);t.axis.fromArray(e);break;case"limits":const n=r.getElementsByTagName("max")[0],o=r.getElementsByTagName("min")[0];t.limits.max=parseFloat(n.textContent),t.limits.min=parseFloat(o.textContent)}}return t.limits.min>=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function be(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(we(r));break;case"matrix":case"translate":case"rotate":t.transforms.push(xe(r))}}return t}function we(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(be(r));break;case"matrix":case"translate":case"rotate":t.transforms.push(xe(r))}}return t}function xe(e){const t={type:e.nodeName},n=a(e.textContent);switch(t.type){case"matrix":t.obj=new r.Matrix4,t.obj.fromArray(n).transpose();break;case"translate":t.obj=new r.Vector3,t.obj.fromArray(n);break;case"rotate":t.obj=new r.Vector3,t.obj.fromArray(n),t.angle=r.MathUtils.degToRad(n[3])}return t}function Te(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];1===r.nodeType&&"technique_common"===r.nodeName&&Ne(r,t)}}function Ne(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=a(r.textContent);break;case"mass":t.mass=a(r.textContent)[0]}}}function Ae(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 Ee(e){return void 0!==e.build?e.build:e}function ke(e){const t=[],n=Ve.querySelector('[id="'+e.id+'"]');for(let e=0;e<n.childNodes.length;e++){const o=n.childNodes[e];if(1!==o.nodeType)continue;let s,i;switch(o.nodeName){case"matrix":s=a(o.textContent);const e=(new r.Matrix4).fromArray(s).transpose();t.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:e});break;case"translate":case"scale":s=a(o.textContent),i=(new r.Vector3).fromArray(s),t.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:i});break;case"rotate":s=a(o.textContent),i=(new r.Vector3).fromArray(s);const n=r.MathUtils.degToRad(s[3]);t.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:i,angle:n})}}return t}const Ie=new r.Matrix4,Ce=new r.Vector3;function Me(e){const t={name:e.getAttribute("name")||"",type:e.getAttribute("type"),id:e.getAttribute("id"),sid:e.getAttribute("sid"),matrix:new r.Matrix4,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let n=0;n<e.childNodes.length;n++){const o=e.childNodes[n];if(1!==o.nodeType)continue;let s;switch(o.nodeName){case"node":t.nodes.push(o.getAttribute("id")),Me(o);break;case"instance_camera":t.instanceCameras.push(c(o.getAttribute("url")));break;case"instance_controller":t.instanceControllers.push(Le(o));break;case"instance_light":t.instanceLights.push(c(o.getAttribute("url")));break;case"instance_geometry":t.instanceGeometries.push(Le(o));break;case"instance_node":t.instanceNodes.push(c(o.getAttribute("url")));break;case"matrix":s=a(o.textContent),t.matrix.multiply(Ie.fromArray(s).transpose()),t.transforms[o.getAttribute("sid")]=o.nodeName;break;case"translate":s=a(o.textContent),Ce.fromArray(s),t.matrix.multiply(Ie.makeTranslation(Ce.x,Ce.y,Ce.z)),t.transforms[o.getAttribute("sid")]=o.nodeName;break;case"rotate":s=a(o.textContent);const e=r.MathUtils.degToRad(s[3]);t.matrix.multiply(Ie.makeRotationAxis(Ce.fromArray(s),e)),t.transforms[o.getAttribute("sid")]=o.nodeName;break;case"scale":s=a(o.textContent),t.matrix.scale(Ce.fromArray(s)),t.transforms[o.getAttribute("sid")]=o.nodeName;break;case"extra":break;default:console.log(o)}}return Be(t.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",t.id):Ze.nodes[t.id]=t,t}function Le(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"),s=r.getAttribute("target");t.materials[o]=c(s)}break;case"skeleton":t.skeletons.push(c(r.textContent))}}return t}function Re(e,t){const n=[],o=[];let s,a,i;for(s=0;s<e.length;s++){const r=e[s];let o;if(Be(r))o=_e(r),Se(o,t,n);else if(c=r,void 0!==Ze.visualScenes[c]){const e=Ze.visualScenes[r].children;for(let r=0;r<e.length;r++){const o=e[r];"JOINT"===o.type&&Se(_e(o.id),t,n)}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",r)}var c;for(s=0;s<t.length;s++)for(a=0;a<n.length;a++)if(i=n[a],i.bone.name===t[s].name){o[s]=i,i.processed=!0;break}for(s=0;s<n.length;s++)i=n[s],!1===i.processed&&(o.push(i),i.processed=!0);const l=[],u=[];for(s=0;s<o.length;s++)i=o[s],l.push(i.bone),u.push(i.boneInverse);return new r.Skeleton(l,u)}function Se(e,t,n){e.traverse((function(e){if(!0===e.isBone){let o;for(let n=0;n<t.length;n++){const r=t[n];if(r.name===e.name){o=r.boneInverse;break}}void 0===o&&(o=new r.Matrix4),n.push({bone:e,boneInverse:o,processed:!1})}}))}function De(e){const t=[],n=e.matrix,o=e.nodes,s=e.type,a=e.instanceCameras,i=e.instanceControllers,c=e.instanceLights,l=e.instanceGeometries,u=e.instanceNodes;for(let e=0,n=o.length;e<n;e++)t.push(_e(o[e]));for(let e=0,n=a.length;e<n;e++){const n=ne(a[e]);null!==n&&t.push(n.clone())}for(let e=0,n=i.length;e<n;e++){const n=i[e],r=(d=n.id,f(Ze.controllers[d],D)),o=Oe(fe(r.id),n.materials),s=Re(n.skeletons,r.skin.joints);for(let e=0,n=o.length;e<n;e++){const n=o[e];n.isSkinnedMesh&&(n.bind(s,r.skin.bindMatrix),n.normalizeSkinWeights()),t.push(n)}}var d;for(let e=0,n=c.length;e<n;e++){const n=ae(c[e]);null!==n&&t.push(n.clone())}for(let e=0,n=l.length;e<n;e++){const n=l[e],r=Oe(fe(n.id),n.materials);for(let e=0,n=r.length;e<n;e++)t.push(r[e])}for(let e=0,n=u.length;e<n;e++)t.push(_e(u[e]).clone());let p;if(0===o.length&&1===t.length)p=t[0];else{p="JOINT"===s?new r.Bone:new r.Group;for(let e=0;e<t.length;e++)p.add(t[e])}return p.name="JOINT"===s?e.sid:e.name,p.matrix.copy(n),p.matrix.decompose(p.position,p.quaternion,p.scale),p}const Fe=new r.MeshBasicMaterial({name:r.Loader.DEFAULT_MATERIAL_NAME,color:16711935});function Pe(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(Fe)):n.push(Q(o))}return n}function Oe(e,t){const n=[];for(const o in e){const s=e[o],a=Pe(s.materialKeys,t);if(0===a.length&&("lines"===o||"linestrips"===o?a.push(new r.LineBasicMaterial):a.push(new r.MeshPhongMaterial)),"lines"===o||"linestrips"===o)for(let e=0,t=a.length;e<t;e++){const t=a[e];if(!0===t.isMeshPhongMaterial||!0===t.isMeshLambertMaterial){const n=new r.LineBasicMaterial;n.color.copy(t.color),n.opacity=t.opacity,n.transparent=t.transparent,a[e]=n}}const i=void 0!==s.data.attributes.skinIndex,c=1===a.length?a[0]:a;let l;switch(o){case"lines":l=new r.LineSegments(s.data,c);break;case"linestrips":l=new r.Line(s.data,c);break;case"triangles":case"polylist":l=i?new r.SkinnedMesh(s.data,c):new r.Mesh(s.data,c)}n.push(l)}return n}function Be(e){return void 0!==Ze.nodes[e]}function _e(e){return f(Ze.nodes[e],De)}function Ue(e){const t=new r.Group;t.name=e.name;const n=e.children;for(let e=0;e<n.length;e++){const r=n[e];t.add(_e(r.id))}return t}function je(e){return f(Ze.visualScenes[e],Ue)}if(0===e.length)return{scene:new r.Scene};const Ge=(new DOMParser).parseFromString(e,"application/xml"),Ve=n(Ge,"COLLADA")[0],He=Ge.getElementsByTagName("parsererror")[0];if(void 0!==He){const e=n(He,"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()}(He),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",t),null}const ze=Ve.getAttribute("version");console.debug("THREE.ColladaLoader: File version",ze);const We=function(e){return{unit:u(n(e,"unit")[0]),upAxis:d(n(e,"up_axis")[0])}}(n(Ve,"asset")[0]),Xe=new r.TextureLoader(this.manager);let qe;Xe.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),o&&(qe=new o(this.manager),qe.setPath(this.resourcePath||t));const Ke=new r.Color,Ye=[];let Je={},Qe=0;const Ze={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};p(Ve,"library_animations","animation",(function e(t){const n={sources:{},samplers:{},channels:{}};let o=!1;for(let r=0,s=t.childNodes.length;r<s;r++){const s=t.childNodes[r];if(1!==s.nodeType)continue;let a;switch(s.nodeName){case"source":a=s.getAttribute("id"),n.sources[a]=ie(s);break;case"sampler":a=s.getAttribute("id"),n.samplers[a]=m(s);break;case"channel":a=s.getAttribute("target"),n.channels[a]=g(s);break;case"animation":e(s),o=!0;break;default:console.log(s)}}!1===o&&(Ze.animations[t.getAttribute("id")||r.MathUtils.generateUUID()]=n)})),p(Ve,"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")))}Ze.clips[e.getAttribute("id")]=t})),p(Ve,"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=L(r);break;case"morph":t.id=c(r.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}Ze.controllers[e.getAttribute("id")]=t})),p(Ve,"library_images","image",(function(e){const t={init_from:n(e,"init_from")[0].textContent};Ze.images[e.getAttribute("id")]=t})),p(Ve,"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=O(r))}Ze.effects[e.getAttribute("id")]=t})),p(Ve,"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")))}Ze.materials[e.getAttribute("id")]=t})),p(Ve,"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=Z(r))}Ze.cameras[e.getAttribute("id")]=t})),p(Ve,"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=re(r))}Ze.lights[e.getAttribute("id")]=t})),p(Ve,"library_geometries","geometry",(function(e){const t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},r=n(e,"mesh")[0];if(void 0!==r){for(let e=0;e<r.childNodes.length;e++){const n=r.childNodes[e];if(1!==n.nodeType)continue;const o=n.getAttribute("id");switch(n.nodeName){case"source":t.sources[o]=ie(n);break;case"vertices":t.vertices=ce(n);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",n.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(le(n));break;default:console.log(n)}}Ze.geometries[e.getAttribute("id")]=t}})),p(Ve,"library_nodes","node",Me),p(Ve,"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","three_default_"+Qe++)}}(e);const r=n(e,"node");for(let e=0;e<r.length;e++)t.children.push(Me(r[e]));Ze.visualScenes[e.getAttribute("id")]=t})),p(Ve,"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&&ge(r,t)}Ze.kinematicsModels[e.getAttribute("id")]=t})),p(Ve,"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")]={},Te(r,t.rigidBodies[r.getAttribute("name")]))}Ze.physicsModels[e.getAttribute("id")]=t})),p(Ve,"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(Ae(r))}Ze.kinematicsScenes[c(e.getAttribute("url"))]=t})),h(Ze.animations,y),h(Ze.clips,C),h(Ze.controllers,D),h(Ze.images,F),h(Ze.effects,Y),h(Ze.materials,J),h(Ze.cameras,te),h(Ze.lights,se),h(Ze.geometries,de),h(Ze.visualScenes,Ue),function(){const e=Ze.clips;if(!0===l(e)){if(!1===l(Ze.animations)){const e=[];for(const t in Ze.animations){const n=v(t);for(let t=0,r=n.length;t<r;t++)e.push(n[t])}Ye.push(new r.AnimationClip("default",-1,e))}}else for(const t in e)Ye.push(M(t))}(),function(){const e=Object.keys(Ze.kinematicsModels)[0],t=Object.keys(Ze.kinematicsScenes)[0],n=Object.keys(Ze.visualScenes)[0];if(void 0===e||void 0===t)return;const o=(s=e,f(Ze.kinematicsModels[s],me));var s;const a=function(e){return f(Ze.kinematicsScenes[e],Ee)}(t),i=je(n),c=a.bindJointAxis,l={};for(let e=0,t=c.length;e<t;e++){const t=c[e],n=Ve.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:ke(t),joint:r,position:r.zeroPosition})}))}const d=new r.Matrix4;Je={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(e,t){const n=l[e];if(n){const o=n.joint;if(t>o.limits.max||t<o.limits.min)console.warn("THREE.ColladaLoader: Joint "+e+" value "+t+" outside of limits (min: "+o.limits.min+", max: "+o.limits.max+").");else if(o.static)console.warn("THREE.ColladaLoader: Joint "+e+" is static.");else{const s=n.object,a=o.axis,i=n.transforms;Ie.identity();for(let n=0;n<i.length;n++){const s=i[n];if(s.sid&&-1!==s.sid.indexOf(e))switch(o.type){case"revolute":Ie.multiply(d.makeRotationAxis(a,r.MathUtils.degToRad(t)));break;case"prismatic":Ie.multiply(d.makeTranslation(a.x*t,a.y*t,a.z*t));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+o.type)}else switch(s.type){case"matrix":Ie.multiply(s.obj);break;case"translate":Ie.multiply(d.makeTranslation(s.obj.x,s.obj.y,s.obj.z));break;case"scale":Ie.scale(s.obj);break;case"rotate":Ie.multiply(d.makeRotationAxis(s.obj,s.angle))}}s.matrix.copy(Ie),s.matrix.decompose(s.position,s.quaternion,s.scale),l[e].position=t}}else console.log("THREE.ColladaLoader: "+e+" does not exist.")}}}();const $e=function(e){return je(c(n(e,"instance_visual_scene")[0].getAttribute("url")))}(n(Ve,"scene")[0]);return $e.animations=Ye,"Z_UP"===We.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."),$e.rotation.set(-Math.PI/2,0,0)),$e.scale.multiplyScalar(We.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Ye},kinematics:Je,library:Ze,scene:$e}}}THREE.ColladaLoader=s,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")}})},724:(e,t,n)=>{"use strict";var r=n(612),o=Uint8Array,s=Uint16Array,a=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 s(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new a(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 s(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,a=new s(t);o<r;++o)e[o]&&++a[e[o]-1];var i,c=new s(t);for(o=1;o<t;++o)c[o]=c[o-1]+a[o-1]<<1;if(n){i=new s(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 s(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=["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"],C=function(e,t,n){var r=new Error(t||I[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,C),!n)throw r;return r},M=function(e,t,n,r){var s=e.length,a=r?r.length:0;if(!s||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*s));var f,g=function(e){var t=n.length;if(e>t){var r=new o(Math.max(2*t,e));r.set(n),n=r}},y=t.f||0,v=t.p||0,w=t.b||0,x=t.l,I=t.d,M=t.m,L=t.n,R=8*s;do{if(!x){y=E(e,v,1);var S=E(e,v+1,3);if(v+=3,!S){var D=e[(f=v,(z=4+((f+7)/8|0))-4)]|e[z-3]<<8,F=z+D;if(F>s){h&&C(0);break}d&&g(w+D),n.set(e.subarray(z,F),w),t.b=w+=D,t.p=v=8*F,t.f=y;continue}if(1==S)x=T,I=N,M=9,L=5;else if(2==S){var P=E(e,v,31)+257,O=E(e,v+10,15)+4,B=P+E(e,v+5,31)+1;v+=14;for(var _=new o(B),U=new o(19),j=0;j<O;++j)U[l[j]]=E(e,v+3*j,7);v+=3*O;var G=A(U),V=(1<<G)-1,H=b(U,G,1);for(j=0;j<B;){var z,W=H[E(e,v,V)];if(v+=15&W,(z=W>>4)<16)_[j++]=z;else{var X=0,q=0;for(16==z?(q=3+E(e,v,3),v+=2,X=_[j-1]):17==z?(q=3+E(e,v,7),v+=3):18==z&&(q=11+E(e,v,127),v+=7);q--;)_[j++]=X}}var K=_.subarray(0,P),Y=_.subarray(P);M=A(K),L=A(Y),x=b(K,M,1),I=b(Y,L,1)}else C(1);if(v>R){h&&C(0);break}}d&&g(w+131072);for(var J=(1<<M)-1,Q=(1<<L)-1,Z=v;;Z=v){var $=(X=x[k(e,v)&J])>>4;if((v+=15&X)>R){h&&C(0);break}if(X||C(2),$<256)n[w++]=$;else{if(256==$){Z=v,x=null;break}var ee=$-254;if($>264){var te=i[j=$-257];ee=E(e,v,(1<<te)-1)+p[j],v+=te}var ne=I[k(e,v)&Q],re=ne>>4;if(ne||C(3),v+=15&ne,Y=m[re],re>3&&(te=c[re],Y+=k(e,v)&(1<<te)-1,v+=te),v>R){h&&C(0);break}d&&g(w+131072);var oe=w+ee;if(w<Y){var se=a-Y,ae=Math.min(Y,oe);for(se+w<0&&C(3);w<ae;++w)n[w]=r[se+w]}for(;w<oe;++w)n[w]=n[w-Y]}}t.l=x,t.p=Z,t.b=w,t.f=y,x&&(y=1,t.m=M,t.d=I,t.n=L)}while(!y);return w!=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,w):n.subarray(0,w)},L=new o(0);function R(e,t){return M(e.subarray((n=e,r=t&&t.dictionary,(8!=(15&n[0])||n[0]>>4>7||(n[0]<<8|n[1])%31)&&C(6,"invalid zlib data"),(n[1]>>5&1)==+!r&&C(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 S="undefined"!=typeof TextDecoder&&new TextDecoder;try{S.decode(L,{stream:!0})}catch(e){}function D(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,s=r,a=Math.floor((o+s)/2);for(;t<n[a]||t>=n[a+1];)t<n[a]?s=a:o=a,a=Math.floor((o+s)/2);return a}function F(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 r.Curve{constructor(e,t,n,o,s){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=o||0,this.endKnot=s||this.knots.length-1;for(let e=0;e<n.length;++e){const t=n[e];this.controlPoints[e]=new r.Vector4(t.x,t.y,t.z,t.w)}}getPoint(e,t=new r.Vector3){const n=t,o=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=function(e,t,n,o){const s=D(e,o,t),a=function(e,t,n,r){const o=[],s=[],a=[];o[0]=1;for(let i=1;i<=n;++i){s[i]=t-r[e+1-i],a[i]=r[e+i]-t;let n=0;for(let e=0;e<i;++e){const t=a[e+1],r=s[i-e],c=o[e]/(t+r);o[e]=n+t*c,n=r*c}o[i]=n}return o}(s,o,e,t),i=new r.Vector4(0,0,0,0);for(let t=0;t<=e;++t){const r=n[s-e+t],o=a[t],c=r.w*o;i.x+=r.x*c,i.y+=r.y*c,i.z+=r.z*c,i.w+=r.w*o}return i}(this.degree,this.knots,this.controlPoints,o);return 1!==s.w&&s.divideScalar(s.w),n.set(s.x,s.y,s.z)}getTangent(e,t=new r.Vector3){const n=t,o=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=function(e,t,n,o,s){const a=function(e,t,n,o,s){const a=s<e?s:e,i=[],c=D(e,o,t),l=function(e,t,n,r,o){const s=[];for(let e=0;e<=n;++e)s[e]=0;const a=[];for(let e=0;e<=r;++e)a[e]=s.slice(0);const i=[];for(let e=0;e<=n;++e)i[e]=s.slice(0);i[0][0]=1;const c=s.slice(0)