/*! 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{"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>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;e0&&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=0;){const r=e[t];if(null!==r.value[n])return r;t--}return null}function I(e,t,n){for(;t>>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;t0?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;n0&&t0&&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(;t4)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=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;no.limits.max||n>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>l]=u}else for(i=new a(r),o=0;o>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;nt&&(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>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<>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<>4;if(ne||M(3),y+=15&ne,Y=m[re],re>3&&(te=c[re],Y+=k(e,y)&(1<R){h&&M(0);break}d&&f(v+131072);var oe=v+ee;if(ve.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+1];)t=a&&(c[o][0]=c[t][0]/i[u+1][l],r=c[o][0]*i[l][u]);const d=e-1<=u?a-1:n-e;for(let e=l>=-1?1:-l;e<=d;++e)c[o][e]=(c[t][e]-c[t][e-1])/i[u+1][l+e],r+=c[o][e]*i[l+e][u];e<=u&&(c[o][a]=-c[t][a-1]/i[u+1][e],r+=c[o][a]*i[e][u]),s[a][e]=r;const p=t;t=o,o=p}}let u=n;for(let e=1;e<=r;++e){for(let t=0;t<=n;++t)s[e][t]*=u;u*=n-e}return s}(c,o,t,s,n),u=[];for(let e=0;e=21&&t===re(e,0,21)}(t))_=(new W).parse(t);else{const e=re(t);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(t){const r=e[t-1];return e=e.slice(n+t),n++,r}for(let e=0;e0,a="string"==typeof o.Content&&""!==o.Content;if(e||a){const e=this.parseImage(n[r]);t[o.RelativeFilename||o.Filename]=e}}}}for(const n in e){const r=e[n];void 0!==t[r]?e[n]=t[r]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let o;switch(r){case"bmp":o="image/bmp";break;case"jpg":case"jpeg":o="image/jpeg";break;case"png":o="image/png";break;case"tif":o="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),o="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof t)return"data:"+o+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:o}))}}parseTextures(e){const t=new Map;if("Texture"in _.Objects){const n=_.Objects.Texture;for(const r in n){const o=this.parseTexture(n[r],e);t.set(parseInt(r),o)}}return t}parseTexture(t,n){const r=this.loadTexture(t,n);r.ID=t.id,r.name=t.attrName;const o=t.WrapModeU,a=t.WrapModeV,s=void 0!==o?o.value:0,i=void 0!==a?a.value:0;if(r.wrapS=0===s?e.RepeatWrapping:e.ClampToEdgeWrapping,r.wrapT=0===i?e.RepeatWrapping:e.ClampToEdgeWrapping,"Scaling"in t){const e=t.Scaling.value;r.repeat.x=e[0],r.repeat.y=e[1]}if("Translation"in t){const e=t.Translation.value;r.offset.x=e[0],r.offset.y=e[1]}return r}loadTexture(t,n){let r;const o=this.textureLoader.path,a=B.get(t.id).children;let s;void 0!==a&&a.length>0&&void 0!==n[a[0].ID]&&(r=n[a[0].ID],0!==r.indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0));const i=t.FileName.slice(-3).toLowerCase();if("tga"===i){const n=this.manager.getHandler(".tga");null===n?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),s=new e.Texture):(n.setPath(this.textureLoader.path),s=n.load(r))}else if("dds"===i){const n=this.manager.getHandler(".dds");null===n?(console.warn("FBXLoader: DDS loader not found, creating placeholder texture for",t.RelativeFilename),s=new e.Texture):(n.setPath(this.textureLoader.path),s=n.load(r))}else"psd"===i?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),s=new e.Texture):s=this.textureLoader.load(r);return this.textureLoader.setPath(o),s}parseMaterials(e){const t=new Map;if("Material"in _.Objects){const n=_.Objects.Material;for(const r in n){const o=this.parseMaterial(n[r],e);null!==o&&t.set(parseInt(r),o)}}return t}parseMaterial(t,n){const r=t.id,o=t.attrName;let a=t.ShadingModel;if("object"==typeof a&&(a=a.value),!B.has(r))return null;const s=this.parseParameters(t,n,r);let i;switch(a.toLowerCase()){case"phong":i=new e.MeshPhongMaterial;break;case"lambert":i=new e.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',a),i=new e.MeshPhongMaterial}return i.setValues(s),i.name=o,i}parseParameters(t,n,r){const o={};t.BumpFactor&&(o.bumpScale=t.BumpFactor.value),t.Diffuse?o.color=(new e.Color).fromArray(t.Diffuse.value).convertSRGBToLinear():!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(o.color=(new e.Color).fromArray(t.DiffuseColor.value).convertSRGBToLinear()),t.DisplacementFactor&&(o.displacementScale=t.DisplacementFactor.value),t.Emissive?o.emissive=(new e.Color).fromArray(t.Emissive.value).convertSRGBToLinear():!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(o.emissive=(new e.Color).fromArray(t.EmissiveColor.value).convertSRGBToLinear()),t.EmissiveFactor&&(o.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(o.opacity=parseFloat(t.Opacity.value)),o.opacity<1&&(o.transparent=!0),t.ReflectionFactor&&(o.reflectivity=t.ReflectionFactor.value),t.Shininess&&(o.shininess=t.Shininess.value),t.Specular?o.specular=(new e.Color).fromArray(t.Specular.value).convertSRGBToLinear():t.SpecularColor&&"Color"===t.SpecularColor.type&&(o.specular=(new e.Color).fromArray(t.SpecularColor.value).convertSRGBToLinear());const a=this;return B.get(r).children.forEach(function(t){const r=t.relationship;switch(r){case"Bump":o.bumpMap=a.getTexture(n,t.ID);break;case"Maya|TEX_ao_map":o.aoMap=a.getTexture(n,t.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":o.map=a.getTexture(n,t.ID),void 0!==o.map&&(o.map.colorSpace=e.SRGBColorSpace);break;case"DisplacementColor":o.displacementMap=a.getTexture(n,t.ID);break;case"EmissiveColor":o.emissiveMap=a.getTexture(n,t.ID),void 0!==o.emissiveMap&&(o.emissiveMap.colorSpace=e.SRGBColorSpace);break;case"NormalMap":case"Maya|TEX_normal_map":o.normalMap=a.getTexture(n,t.ID);break;case"ReflectionColor":o.envMap=a.getTexture(n,t.ID),void 0!==o.envMap&&(o.envMap.mapping=e.EquirectangularReflectionMapping,o.envMap.colorSpace=e.SRGBColorSpace);break;case"SpecularColor":o.specularMap=a.getTexture(n,t.ID),void 0!==o.specularMap&&(o.specularMap.colorSpace=e.SRGBColorSpace);break;case"TransparentColor":case"TransparencyFactor":o.alphaMap=a.getTexture(n,t.ID),o.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r)}}),o}getTexture(e,t){return"LayeredTexture"in _.Objects&&t in _.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=B.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in _.Objects){const n=_.Objects.Deformer;for(const r in n){const o=n[r],a=B.get(parseInt(r));if("Skin"===o.attrType){const t=this.parseSkeleton(a,n);t.ID=r,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=a.parents[0].ID,e[r]=t}else if("BlendShape"===o.attrType){const e={id:r};e.rawTargets=this.parseMorphTargets(a,n),e.id=r,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[r]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(t,n){const r=[];return t.children.forEach(function(t){const o=n[t.ID];if("Cluster"!==o.attrType)return;const a={ID:t.ID,indices:[],weights:[],transformLink:(new e.Matrix4).fromArray(o.TransformLink.a)};"Indexes"in o&&(a.indices=o.Indexes.a,a.weights=o.Weights.a),r.push(a)}),{rawBones:r,bones:[]}}parseMorphTargets(e,t){const n=[];for(let r=0;r1?s=i:i.length>0?s=i[0]:(s=new e.MeshPhongMaterial({name:e.Loader.DEFAULT_MATERIAL_NAME,color:13421772}),i.push(s)),"color"in a.attributes&&i.forEach(function(e){e.vertexColors=!0}),a.FBX_Deformer?(o=new e.SkinnedMesh(a,s),o.normalizeSkinWeights()):o=new e.Mesh(a,s),o}createCurve(t,n){const r=t.children.reduce(function(e,t){return n.has(t.ID)&&(e=n.get(t.ID)),e},null),o=new e.LineBasicMaterial({name:e.Loader.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new e.Line(r,o)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?te(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(t,n){"LookAtProperty"in n&&B.get(t.ID).children.forEach(function(n){if("LookAtProperty"===n.relationship){const r=_.Objects.Model[n.ID];if("Lcl_Translation"in r){const n=r.Lcl_Translation.value;void 0!==t.target?(t.target.position.fromArray(n),U.add(t.target)):t.lookAt((new e.Vector3).fromArray(n))}}})}bindSkeleton(t,n,r){const o=this.parsePoseNodes();for(const a in t){const s=t[a];B.get(parseInt(s.ID)).parents.forEach(function(t){if(n.has(t.ID)){const n=t.ID;B.get(n).parents.forEach(function(t){r.has(t.ID)&&r.get(t.ID).bind(new e.Skeleton(s.bones),o[t.ID])})}})}}parsePoseNodes(){const t={};if("Pose"in _.Objects){const n=_.Objects.Pose;for(const r in n)if("BindPose"===n[r].attrType&&n[r].NbPoseNodes>0){const o=n[r].PoseNode;Array.isArray(o)?o.forEach(function(n){t[n.Node]=(new e.Matrix4).fromArray(n.Matrix.a)}):t[o.Node]=(new e.Matrix4).fromArray(o.Matrix.a)}}return t}addGlobalSceneSettings(){if("GlobalSettings"in _){if("AmbientColor"in _.GlobalSettings){const t=_.GlobalSettings.AmbientColor.value,n=t[0],r=t[1],o=t[2];if(0!==n||0!==r||0!==o){const t=new e.Color(n,r,o).convertSRGBToLinear();U.add(new e.AmbientLight(t,1))}}"UnitScaleFactor"in _.GlobalSettings&&(U.userData.unitScaleFactor=_.GlobalSettings.UnitScaleFactor.value)}}}class G{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in _.Objects){const n=_.Objects.Geometry;for(const r in n){const o=B.get(parseInt(r)),a=this.parseGeometry(o,n[r],e);t.set(parseInt(r),a)}}return!0===this.negativeMaterialIndices&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const r=n.skeletons,o=[],a=e.parents.map(function(e){return _.Objects.Model[e.ID]});if(0===a.length)return;const s=e.children.reduce(function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e},null);e.children.forEach(function(e){void 0!==n.morphTargets[e.ID]&&o.push(n.morphTargets[e.ID])});const i=a[0],c={};"RotationOrder"in i&&(c.eulerOrder=te(i.RotationOrder.value)),"InheritType"in i&&(c.inheritType=parseInt(i.InheritType.value)),"GeometricTranslation"in i&&(c.translation=i.GeometricTranslation.value),"GeometricRotation"in i&&(c.rotation=i.GeometricRotation.value),"GeometricScaling"in i&&(c.scale=i.GeometricScaling.value);const l=ee(c);return this.genGeometry(t,s,o,l)}genGeometry(t,n,r,o){const a=new e.BufferGeometry;t.attrName&&(a.name=t.attrName);const s=this.parseGeoNode(t,n),i=this.genBuffers(s),c=new e.Float32BufferAttribute(i.vertex,3);if(c.applyMatrix4(o),a.setAttribute("position",c),i.colors.length>0&&a.setAttribute("color",new e.Float32BufferAttribute(i.colors,3)),n&&(a.setAttribute("skinIndex",new e.Uint16BufferAttribute(i.weightsIndices,4)),a.setAttribute("skinWeight",new e.Float32BufferAttribute(i.vertexWeights,4)),a.FBX_Deformer=n),i.normal.length>0){const t=(new e.Matrix3).getNormalMatrix(o),n=new e.Float32BufferAttribute(i.normal,3);n.applyNormalMatrix(t),a.setAttribute("normal",n)}if(i.uvs.forEach(function(t,n){const r=0===n?"uv":`uv${n}`;a.setAttribute(r,new e.Float32BufferAttribute(i.uvs[n],2))}),s.material&&"AllSame"!==s.material.mappingType){let e=i.materialIndex[0],t=0;if(i.materialIndex.forEach(function(n,r){n!==e&&(a.addGroup(t,r-t,e),e=n,t=r)}),a.groups.length>0){const t=a.groups[a.groups.length-1],n=t.start+t.count;n!==i.materialIndex.length&&a.addGroup(n,i.materialIndex.length-n,e)}0===a.groups.length&&a.addGroup(0,i.materialIndex.length,i.materialIndex[0])}return this.addMorphTargets(a,t,r,o),a}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(r,o){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:t,weight:e.weights[o]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,o=!1,a=[],s=[],i=[],c=[],l=[],u=[];const d=this;return e.vertexIndices.forEach(function(p,h){let f,m=!1;p<0&&(p^=-1,m=!0);let g=[],y=[];if(a.push(3*p,3*p+1,3*p+2),e.color){const t=Q(h,n,p,e.color);i.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[p]&&e.weightTable[p].forEach(function(e){y.push(e.weight),g.push(e.id)}),y.length>4){o||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),o=!0);const e=[0,0,0,0],t=[0,0,0,0];y.forEach(function(n,r){let o=n,a=g[r];t.forEach(function(t,n,r){if(o>t){r[n]=o,o=t;const s=e[n];e[n]=a,a=s}})}),g=e,y=t}for(;y.length<4;)y.push(0),g.push(0);for(let e=0;e<4;++e)l.push(y[e]),u.push(g[e])}if(e.normal){const t=Q(h,n,p,e.normal);s.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=Q(h,n,p,e.material)[0],f<0&&(d.negativeMaterialIndices=!0,f=0)),e.uv&&e.uv.forEach(function(e,t){const r=Q(h,n,p,e);void 0===c[t]&&(c[t]=[]),c[t].push(r[0]),c[t].push(r[1])}),r++,m&&(d.genFace(t,e,a,f,s,i,c,l,u,r),n++,r=0,a=[],s=[],i=[],c=[],l=[],u=[])}),t}getNormalNewell(t){const n=new e.Vector3(0,0,0);for(let e=0;e.5?new e.Vector3(0,1,0):new e.Vector3(0,0,1)).cross(n).normalize(),o=n.clone().cross(r).normalize();return{normal:n,tangent:r,bitangent:o}}flattenVertex(t,n,r){return new e.Vector2(t.dot(n),t.dot(r))}genFace(t,n,r,o,a,s,i,c,l,u){let d;if(u>3){const t=[];for(let o=0;o1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const a=e.get(o[0].ID);n[r]={name:t[r].attrName,layer:a}}return n}addClip(t){let n=[];const r=this;return t.layer.forEach(function(e){n=n.concat(r.generateTracks(e))}),new e.AnimationClip(t.name,-1,n)}generateTracks(t){const n=[];let r=new e.Vector3,o=new e.Vector3;if(t.transform&&t.transform.decompose(r,new e.Quaternion,o),r=r.toArray(),o=o.toArray(),void 0!==t.T&&Object.keys(t.T.curves).length>0){const e=this.generateVectorTrack(t.modelName,t.T.curves,r,"position");void 0!==e&&n.push(e)}if(void 0!==t.R&&Object.keys(t.R.curves).length>0){const e=this.generateRotationTrack(t.modelName,t.R.curves,t.preRotation,t.postRotation,t.eulerOrder);void 0!==e&&n.push(e)}if(void 0!==t.S&&Object.keys(t.S.curves).length>0){const e=this.generateVectorTrack(t.modelName,t.S.curves,o,"scale");void 0!==e&&n.push(e)}if(void 0!==t.DeformPercent){const e=this.generateMorphTrack(t);void 0!==e&&n.push(e)}return n}generateVectorTrack(t,n,r,o){const a=this.getTimesForAllAxes(n),s=this.getKeyframeTrackValues(a,n,r);return new e.VectorKeyframeTrack(t+"."+o,a,s)}generateRotationTrack(t,n,r,o,a){let s,i;if(void 0!==n.x&&void 0!==n.y&&void 0!==n.z){const e=this.interpolateRotations(n.x,n.y,n.z,a);s=e[0],i=e[1]}void 0!==r&&((r=r.map(e.MathUtils.degToRad)).push(a),r=(new e.Euler).fromArray(r),r=(new e.Quaternion).setFromEuler(r)),void 0!==o&&((o=o.map(e.MathUtils.degToRad)).push(a),o=(new e.Euler).fromArray(o),o=(new e.Quaternion).setFromEuler(o).invert());const c=new e.Quaternion,l=new e.Euler,u=[];if(!i||!s)return new e.QuaternionKeyframeTrack(t+".quaternion",[0],[0]);for(let t=0;t2&&(new e.Quaternion).fromArray(u,(t-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w),c.toArray(u,t/3*4);return new e.QuaternionKeyframeTrack(t+".quaternion",s,u)}generateMorphTrack(t){const n=t.DeformPercent.curves.morph,r=n.values.map(function(e){return e/100}),o=U.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new e.NumberKeyframeTrack(t.modelName+".morphTargetInfluences["+o+"]",n.times,r)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort(function(e,t){return e-t}),t.length>1){let e=1,n=t[0];for(let r=1;r=180||h[1]>=180||h[2]>=180){const n=Math.max(...h)/180,r=new e.Euler(...l,o),c=new e.Euler(...d,o),u=(new e.Quaternion).setFromEuler(r),p=(new e.Quaternion).setFromEuler(c);u.dot(p)&&p.set(-p.x,-p.y,-p.z,-p.w);const f=t.times[i-1],m=t.times[i]-f,g=new e.Quaternion,y=new e.Euler;for(let e=0;e<1;e+=1/n)g.copy(u.clone().slerp(p.clone(),e)),a.push(f+e*m),y.setFromQuaternion(g,o),s.push(y.x),s.push(y.y),s.push(y.z)}else a.push(t.times[i]),s.push(e.MathUtils.degToRad(t.values[i])),s.push(e.MathUtils.degToRad(n.values[i])),s.push(e.MathUtils.degToRad(r.values[i]))}return[a,s]}}class z{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new q,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(e,r){const o=e.match(/^[\s\t]*;/),a=e.match(/^[\s\t]*$/);if(o||a)return;const s=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),i=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),c=e.match("^\\t{"+(t.currentIndent-1)+"}}");s?t.parseNodeBegin(e,s):i?t.parseNodeProperty(e,i,n[++r]):c?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),r=t[2].split(",").map(function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")}),o={name:n},a=this.parseNodeAttr(r),s=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,o):n in s?("PoseNode"===n?s.PoseNode.push(o):void 0!==s[n].id&&(s[n]={},s[n][s[n].id]=s[n]),""!==a.id&&(s[n][a.id]=o)):"number"==typeof a.id?(s[n]={},s[n][a.id]=o):"Properties70"!==n&&(s[n]="PoseNode"===n?[o]:o),"number"==typeof a.id&&(o.id=a.id),""!==a.name&&(o.attrName=a.name),""!==a.type&&(o.attrType=a.type),this.pushStack(o)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",r="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,"").replace(/"$/,"").trim(),o=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===o&&(o=n.replace(/"/g,"").replace(/,$/,"").trim());const a=this.getCurrentNode();if("Properties70"!==a.name){if("C"===r){const e=o.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let s=o.split(",").slice(3);s=s.map(function(e){return e.trim().replace(/^"/,"")}),r="connections",o=[t,n],function(e,t){for(let n=0,r=e.length,o=t.length;n=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},r=t>=7500?e.getUint64():e.getUint32(),o=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const a=e.getUint8(),s=e.getString(a);if(0===r)return null;const i=[];for(let t=0;t0?i[0]:"",l=i.length>1?i[1]:"",u=i.length>2?i[2]:"";for(n.singleProperty=1===o&&e.getOffset()===r;r>e.getOffset();){const r=this.parseNode(e,t);null!==r&&this.parseSubNode(s,n,r)}return n.propertyList=i,"number"==typeof c&&(n.id=c),""!==l&&(n.attrName=l),""!==u&&(n.attrType=u),""!==s&&(n.name=s),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach(function(t,n){0!==n&&e.push(t)}),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name)Object.keys(n).forEach(function(e){t[e]=n[e]});else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],r=n.propertyList[1];const o=n.propertyList[2],a=n.propertyList[3];let s;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),s="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:r,type2:o,flag:a,value:s}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=e.getUint32(),o=e.getUint32(),a=e.getUint32();if(0===o)switch(t){case"b":case"c":return e.getBooleanArray(r);case"d":return e.getFloat64Array(r);case"f":return e.getFloat32Array(r);case"i":return e.getInt32Array(r);case"l":return e.getInt64Array(r)}const s=S(new Uint8Array(e.getArrayBuffer(a))),i=new X(s.buffer);switch(t){case"b":case"c":return i.getBooleanArray(r);case"d":return i.getFloat64Array(r);case"f":return i.getFloat32Array(r);case"i":return i.getInt32Array(r);case"l":return i.getInt64Array(r)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class X{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return!(1&~this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n=0&&(n=new Uint8Array(this.dv.buffer,t,r)),this._textDecoder.decode(n)}}class q{add(e,t){this[e]=t}}function K(e){const t=e.match(/FBXVersion: (\d+)/);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Y(e){return e/46186158e3}const J=[];function Q(e,t,n,r){let o;switch(r.mappingType){case"ByPolygonVertex":o=e;break;case"ByPolygon":o=t;break;case"ByVertice":o=n;break;case"AllSame":o=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}"IndexToDirect"===r.referenceType&&(o=r.indices[o]);const a=o*r.dataSize,s=a+r.dataSize;return function(e,t,n,r){for(let o=n,a=0;o