/*! For license information please see aframe-extras.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 o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(self,e=>(()=>{var t={95:()=>{AFRAME.registerComponent("checkpoint",{schema:{offset:{default:{x:0,y:0,z:0},type:"vec3"}},init:function(){this.active=!1,this.targetEl=null,this.fire=this.fire.bind(this),this.offset=new THREE.Vector3},update:function(){this.offset.copy(this.data.offset)},play:function(){this.el.addEventListener("click",this.fire)},pause:function(){this.el.removeEventListener("click",this.fire)},remove:function(){this.pause()},fire:function(){const e=this.el.sceneEl.querySelector("[checkpoint-controls]");if(!e)throw new Error("No `checkpoint-controls` component found.");e.components["checkpoint-controls"].setCheckpoint(this.el)},getOffset:function(){return this.offset.copy(this.data.offset)}})},109:()=>{AFRAME.registerComponent("sphere-collider",{schema:{enabled:{default:!0},interval:{default:80},objects:{default:""},state:{default:"collided"},radius:{default:.05},watch:{default:!0}},init:function(){this.observer=null,this.els=[],this.collisions=[],this.prevCheckTime=void 0,this.eventDetail={},this.handleHit=this.handleHit.bind(this),this.handleHitEnd=this.handleHitEnd.bind(this)},play:function(){const e=this.el.sceneEl;this.data.watch&&(this.observer=new MutationObserver(this.update.bind(this,null)),this.observer.observe(e,{childList:!0,subtree:!0}))},pause:function(){this.observer&&(this.observer.disconnect(),this.observer=null)},update:function(){const e=this.data;let t;t=e.objects?this.el.sceneEl.querySelectorAll(e.objects):this.el.sceneEl.children,this.els=Array.prototype.slice.call(t)},tick:function(){const e=new THREE.Vector3,t=new THREE.Vector3,n=new THREE.Vector3,o=new THREE.Vector3,i=new THREE.Box3,s=[],r=new Map;return function(a){if(!this.data.enabled)return;const c=this.prevCheckTime;if(c&&a-cr.get(e)>r.get(t)?1:-1).forEach(this.handleHit),this.collisions.filter(e=>!r.has(e)).forEach(this.handleHitEnd),function(e,t){e.length=0;for(let n=0;n{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")}})},267:()=>{AFRAME.registerComponent("touch-controls",{schema:{enabled:{default:!0},reverseEnabled:{default:!0}},init:function(){this.dVelocity=new THREE.Vector3,this.bindMethods(),this.direction=0},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){const e=this.el.sceneEl,t=e.canvas;if(!t)return void e.addEventListener("render-target-loaded",this.addEventListeners.bind(this));t.addEventListener("touchstart",this.onTouchStart,{passive:!0}),t.addEventListener("touchend",this.onTouchEnd,{passive:!0});const n=e.getAttribute("vr-mode-ui");n&&n.cardboardModeEnabled&&e.addEventListener("enter-vr",this.onEnterVR)},removeEventListeners:function(){const e=this.el.sceneEl&&this.el.sceneEl.canvas;e&&(e.removeEventListener("touchstart",this.onTouchStart),e.removeEventListener("touchend",this.onTouchEnd),this.el.sceneEl.removeEventListener("enter-vr",this.onEnterVR))},isVelocityActive:function(){return this.data.enabled&&!!this.direction},getVelocityDelta:function(){return this.dVelocity.z=this.direction,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onEnterVR=this.onEnterVR.bind(this)},onTouchStart:function(e){this.direction=-1,this.data.reverseEnabled&&e.touches&&2===e.touches.length&&(this.direction=1),e.preventDefault()},onTouchEnd:function(e){this.direction=0,e.preventDefault()},onEnterVR:function(){const e=this.el.sceneEl.xrSession;e&&(e.addEventListener("selectstart",this.onTouchStart),e.addEventListener("selectend",this.onTouchEnd))}})},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,o=AFRAME.utils.diff(n,t);if("clip"in o)return this.stopAction(),void(n.clip&&this.playAction());this.activeActions.forEach(t=>{"duration"in o&&n.duration&&t.setDuration(n.duration),"clampWhenFinished"in o&&(t.clampWhenFinished=n.clampWhenFinished),("loop"in o||"repetitions"in o)&&t.setLoop(e[n.loop],n.repetitions),"timeScale"in o&&t.setEffectiveTimeScale(n.timeScale)})},stopAction:function(){const e=this.data;for(let t=0;t{"use strict";n(866),n(982);var o=n(612);class i{static roundNumber(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}static sample(e){return e[Math.floor(Math.random()*e.length)]}static distanceToSquared(e,t){var n=e.x-t.x,o=e.y-t.y,i=e.z-t.z;return n*n+o*o+i*i}static isPointInPoly(e,t){for(var n=!1,o=-1,i=e.length,s=i-1;++o{o=Math.min(n[e].y,o),i=Math.max(n[e].y,i),s.push(n[e])}),!!(e.yo-.5&&this.isPointInPoly(s,e))}static triarea2(e,t,n){return(n.x-e.x)*(t.z-e.z)-(t.x-e.x)*(n.z-e.z)}static vequal(e,t){return this.distanceToSquared(e,t)<1e-5}static mergeVertices(e,t=1e-4){t=Math.max(t,Number.EPSILON);for(var n={},i=e.getIndex(),s=e.getAttribute("position"),r=i?i.count:s.count,a=0,c=[],l=[],d=Math.log10(1/t),h=Math.pow(10,d),u=0;u0&&(this.content[0]=t,this.bubbleUp(0)),e}remove(e){const t=this.content.indexOf(e),n=this.content.pop();t!==this.content.length-1&&(this.content[t]=n,this.scoreFunction(n)0;){const n=(e+1>>1)-1,o=this.content[n];if(!(this.scoreFunction(t)0)){t.push(o),n=o,r=a,o=n,s=n,a=r,c=r,l=r;continue}s=h,c=l}if(i.triarea2(n,o,d)>=0){if(!(i.vequal(n,o)||i.triarea2(n,s,d)<0)){t.push(s),n=s,r=c,o=n,s=n,a=r,c=r,l=r;continue}o=d,a=l}}return 0!==t.length&&i.vequal(t[t.length-1],e[e.length-1].left)||t.push(e[e.length-1].left),this.path=t,t}}class a{constructor(){this.zones={}}static createZone(e,t=1e-4){return class{static buildZone(e,t){const n=this._buildNavigationMesh(e,t),s={};n.vertices.forEach(e=>{e.x=i.roundNumber(e.x,2),e.y=i.roundNumber(e.y,2),e.z=i.roundNumber(e.z,2)}),s.vertices=n.vertices;const r=this._buildPolygonGroups(n);return s.groups=new Array(r.length),r.forEach((e,t)=>{const n=new Map;e.forEach((e,t)=>{n.set(e,t)});const r=new Array(e.length);e.forEach((e,t)=>{const a=[];e.neighbours.forEach(e=>a.push(n.get(e)));const c=[];e.neighbours.forEach(t=>c.push(this._getSharedVerticesInOrder(e,t)));const l=new o.Vector3(0,0,0);l.add(s.vertices[e.vertexIds[0]]),l.add(s.vertices[e.vertexIds[1]]),l.add(s.vertices[e.vertexIds[2]]),l.divideScalar(3),l.x=i.roundNumber(l.x,2),l.y=i.roundNumber(l.y,2),l.z=i.roundNumber(l.z,2),r[t]={id:t,neighbours:a,vertexIds:e.vertexIds,centroid:l,portals:c}}),s.groups[t]=r}),s}static _buildNavigationMesh(e,t){return e=i.mergeVertices(e,t),this._buildPolygonsFromGeometry(e)}static _spreadGroupId(e){let t=new Set([e]);for(;t.size>0;){const n=t;t=new Set,n.forEach(n=>{n.group=e.group,n.neighbours.forEach(e=>{void 0===e.group&&t.add(e)})})}}static _buildPolygonGroups(e){const t=[];return e.polygons.forEach(e=>{void 0!==e.group?t[e.group].push(e):(e.group=t.length,this._spreadGroupId(e),t.push([e]))}),t}static _buildPolygonNeighbours(e,t){const n=new Set,o=t[e.vertexIds[1]],i=t[e.vertexIds[2]];return t[e.vertexIds[0]].forEach(t=>{t!==e&&(o.includes(t)||i.includes(t))&&n.add(t)}),o.forEach(t=>{t!==e&&i.includes(t)&&n.add(t)}),n}static _buildPolygonsFromGeometry(e){const t=[],n=[],i=e.attributes.position,s=e.index,r=[];for(let e=0;e{e.neighbours=this._buildPolygonNeighbours(e,r)}),{polygons:t,vertices:n}}static _getSharedVerticesInOrder(e,t){const n=e.vertexIds,o=n[0],i=n[1],s=n[2],r=t.vertexIds,a=r.includes(o),c=r.includes(i),l=r.includes(s);return a&&c&&l?Array.from(n):a&&c?[o,i]:c&&l?[i,s]:a&&l?[s,o]:(console.warn("Error processing navigation mesh neighbors; neighbors with <2 shared vertices found."),[])}}.buildZone(e,t)}setZoneData(e,t){this.zones[e]=t}getRandomNode(e,t,n,s){if(!this.zones[e])return new o.Vector3;n=n||null,s=s||0;const r=[];return this.zones[e].groups[t].forEach(e=>{n&&s?i.distanceToSquared(n,e.centroid){const n=i.distanceToSquared(t.centroid,e);n0;){const t=o.pop();if(t===n){let e=t;const n=[];for(;e.parent;)n.push(e),e=e.parent;return this.cleanUp(n),n.reverse()}t.closed=!0;const i=this.neighbours(e,t);for(let e=0,s=i.length;enew o.Vector3(e.x,e.y,e.z));return m.shift(),m}}a.prototype.getGroup=function(){const e=new o.Plane;return function(t,n,o=!1){if(!this.zones[t])return null;let s=null,r=Math.pow(50,2);const a=this.zones[t];for(let t=0;t2))for(let e=0;ee.updateNavLocation())},getNavMesh:function(){return this.navMesh},addAgent:function(e){this.agents.add(e)},removeAgent:function(e){this.agents.delete(e)},getPath:function(e,t,n){return this.navMesh?c.findPath(e,t,l,n):null},getGroup:function(e){return this.navMesh?c.getGroup(l,e):null},getNode:function(e,t){return this.navMesh?c.getClosestNode(e,l,t,!0):null},clampStep:function(e,t,n,o,i){return this.navMesh?o?c.clampStep(e,t,o,l,n,i):(i.copy(t),this.getNode(t,n)):(i.copy(t),null)}})},451:(e,t,n)=>{"use strict";n(417);var o=n(612);class i extends o.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),i={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)}(i),i.id_length+t>e.length)throw new Error("THREE.TGALoader: No data.");t+=i.id_length;let s=!1,r=!1,a=!1;switch(i.image_type){case 9:s=!0,r=!0;break;case 1:r=!0;break;case 10:s=!0;break;case 2:break;case 11:s=!0,a=!0;break;case 3:a=!0}const c=new Uint8Array(i.width*i.height*4),l=function(e,t,n,o,i){let s,r;const a=n.pixel_size>>3,c=n.width*n.height*a;if(t&&(r=i.subarray(o,o+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;s=new Uint8Array(c);let r=0;const l=new Uint8Array(a);for(;r>4){default:case 2:r=0,l=1,h=t,c=0,d=1,u=n;break;case 0:r=0,l=1,h=t,c=n-1,d=-1,u=-1;break;case 3:r=t-1,l=-1,h=-1,c=0,d=1,u=n;break;case 1:r=t-1,l=-1,h=-1,c=n-1,d=-1,u=-1}if(a)switch(i.pixel_size){case 8:!function(e,t,n,o,s,r,a,c){let l,d,h,u=0;const p=i.width;for(h=t;h!==o;h+=n)for(d=s;d!==a;d+=r,u++)l=c[u],e[4*(d+p*h)+0]=l,e[4*(d+p*h)+1]=l,e[4*(d+p*h)+2]=l,e[4*(d+p*h)+3]=255}(e,c,d,u,r,l,h,o);break;case 16:!function(e,t,n,o,s,r,a,c){let l,d,h=0;const u=i.width;for(d=t;d!==o;d+=n)for(l=s;l!==a;l+=r,h+=2)e[4*(l+u*d)+0]=c[h+0],e[4*(l+u*d)+1]=c[h+0],e[4*(l+u*d)+2]=c[h+0],e[4*(l+u*d)+3]=c[h+1]}(e,c,d,u,r,l,h,o);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(i.pixel_size){case 8:!function(e,t,n,o,s,r,a,c,l){const d=l;let h,u,p,f=0;const m=i.width;for(p=t;p!==o;p+=n)for(u=s;u!==a;u+=r,f++)h=c[f],e[4*(u+m*p)+3]=255,e[4*(u+m*p)+2]=d[3*h+0],e[4*(u+m*p)+1]=d[3*h+1],e[4*(u+m*p)+0]=d[3*h+2]}(e,c,d,u,r,l,h,o,s);break;case 16:!function(e,t,n,o,s,r,a,c){let l,d,h,u=0;const p=i.width;for(h=t;h!==o;h+=n)for(d=s;d!==a;d+=r,u+=2)l=c[u+0]+(c[u+1]<<8),e[4*(d+p*h)+0]=(31744&l)>>7,e[4*(d+p*h)+1]=(992&l)>>2,e[4*(d+p*h)+2]=(31&l)<<3,e[4*(d+p*h)+3]=32768&l?0:255}(e,c,d,u,r,l,h,o);break;case 24:!function(e,t,n,o,s,r,a,c){let l,d,h=0;const u=i.width;for(d=t;d!==o;d+=n)for(l=s;l!==a;l+=r,h+=3)e[4*(l+u*d)+3]=255,e[4*(l+u*d)+2]=c[h+0],e[4*(l+u*d)+1]=c[h+1],e[4*(l+u*d)+0]=c[h+2]}(e,c,d,u,r,l,h,o);break;case 32:!function(e,t,n,o,s,r,a,c){let l,d,h=0;const u=i.width;for(d=t;d!==o;d+=n)for(l=s;l!==a;l+=r,h+=4)e[4*(l+u*d)+2]=c[h+0],e[4*(l+u*d)+1]=c[h+1],e[4*(l+u*d)+0]=c[h+2],e[4*(l+u*d)+3]=c[h+3]}(e,c,d,u,r,l,h,o);break;default:throw new Error("THREE.TGALoader: Format not supported.")}}(c,i.width,i.height,l.pixel_data,l.palettes),{data:c,width:i.width,height:i.height,flipY:!0,generateMipmaps:!0,minFilter:o.LinearMipmapLinearFilter}}}class s extends o.Loader{load(e,t,n,i){const s=this,r=""===s.path?o.LoaderUtils.extractUrlBase(e):s.path,a=new o.FileLoader(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(n){try{t(s.parse(n,r))}catch(t){i?i(t):console.error(t),s.manager.itemError(e)}},n,i)}parse(e,t){function n(e,t){const n=[],o=e.childNodes;for(let e=0,i=o.length;e0&&t.push(new o.VectorKeyframeTrack(i+".position",s,r)),a.length>0&&t.push(new o.QuaternionKeyframeTrack(i+".quaternion",s,a)),c.length>0&&t.push(new o.VectorKeyframeTrack(i+".scale",s,c)),t}function T(e,t,n){let o,i,s,r=!0;for(i=0,s=e.length;i=0;){const o=e[t];if(null!==o.value[n])return o;t--}return null}function M(e,t,n){for(;t>>0)+2);return n=n.toLowerCase(),t="tga"===n?Ze:Je,t}(s);if(void 0!==t){const i=t.load(s),r=e.extra;if(void 0!==r&&void 0!==r.technique&&!1===d(r.technique)){const e=r.technique;i.wrapS=e.wrapU?o.RepeatWrapping:o.ClampToEdgeWrapping,i.wrapT=e.wrapV?o.RepeatWrapping:o.ClampToEdgeWrapping,i.offset.set(e.offsetU||0,e.offsetV||0),i.repeat.set(e.repeatU||1,e.repeatV||1)}else i.wrapS=o.RepeatWrapping,i.wrapT=o.RepeatWrapping;return null!==n&&(i.colorSpace=n),i}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 a=i.parameters;for(const e in a){const t=a[e];switch(e){case"diffuse":t.color&&s.color.fromArray(t.color),t.texture&&(s.map=r(t.texture,o.SRGBColorSpace));break;case"specular":t.color&&s.specular&&s.specular.fromArray(t.color),t.texture&&(s.specularMap=r(t.texture));break;case"bump":t.texture&&(s.normalMap=r(t.texture));break;case"ambient":t.texture&&(s.lightMap=r(t.texture,o.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=r(t.texture,o.SRGBColorSpace))}}s.color.convertSRGBToLinear(),s.specular&&s.specular.convertSRGBToLinear(),s.emissive&&s.emissive.convertSRGBToLinear();let c=a.transparent,l=a.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)s.transparent=!0;else{const e=c.data.color;switch(c.opaque){case"A_ONE":s.opacity=e[3]*l.float;break;case"RGB_ZERO":s.opacity=1-e[0]*l.float;break;case"A_ZERO":s.opacity=1-e[3]*l.float;break;case"RGB_ONE":s.opacity=e[0]*l.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!==i.extra&&void 0!==i.extra.technique){const e=i.extra.technique;for(const t in e){const n=e[t];switch(t){case"double_sided":s.side=1===n?o.DoubleSide:o.FrontSide;break;case"bump":s.normalMap=r(n.texture),s.normalScale=new o.Vector2(1,1)}}}return s}function $(e){return m(tt.materials[e],Q)}function ee(e){for(let t=0;t0?n+s:n;t.inputs[r]={id:e,offset:i},t.stride=Math.max(t.stride,i+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=a(o.textContent);break;case"p":t.p=a(o.textContent)}}return t}function ue(e){let t=0;for(let n=0,o=e.length;n0&&t0&&u.setAttribute("position",new o.Float32BufferAttribute(s.array,s.stride)),r.array.length>0&&u.setAttribute("normal",new o.Float32BufferAttribute(r.array,r.stride)),l.array.length>0&&u.setAttribute("color",new o.Float32BufferAttribute(l.array,l.stride)),a.array.length>0&&u.setAttribute("uv",new o.Float32BufferAttribute(a.array,a.stride)),c.array.length>0&&u.setAttribute("uv1",new o.Float32BufferAttribute(c.array,c.stride)),d.length>0&&u.setAttribute("skinIndex",new o.Float32BufferAttribute(d,4)),h.length>0&&u.setAttribute("skinWeight",new o.Float32BufferAttribute(h,4)),i.data=u,i.type=e[0].type,i.materialKeys=p,i}function me(e,t,n,o,i=!1){const s=e.p,r=e.stride,a=e.vcount;function c(e){let t=s[e+n]*d;const r=t+d;for(;t4)for(let t=1,o=n-2;t<=o;t++){const n=e+r*t,o=e+r*(t+1);c(e+0*r),c(n),c(o)}e+=r*n}}else for(let e=0,t=s.length;e=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function xe(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;ni.limits.max||t>1|(21845&b)<<1;w=(61680&(w=(52428&w)>>2|(13107&w)<<2))>>4|(3855&w)<<4,v[b]=((65280&w)>>8|(255&w)<<8)>>1}var x=function(e,t,n){for(var o=e.length,i=0,s=new a(t);i>l]=d}else for(r=new a(o),i=0;i>15-e[i]);return r},k=new r(288);for(b=0;b<144;++b)k[b]=8;for(b=144;b<256;++b)k[b]=9;for(b=256;b<280;++b)k[b]=7;for(b=280;b<288;++b)k[b]=8;var E=new r(32);for(b=0;b<32;++b)E[b]=5;var A=x(k,9,1),T=x(E,5,1),N=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},M=function(e,t,n){var o=t/8|0;return(e[o]|e[o+1]<<8)>>(7&t)&n},C=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},D=function(e){return(e+7)/8|0},L=["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"],O=function(e,t,n){var o=new Error(t||L[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,O),!n)throw o;return o},R=function(e,t,n,o){var i=e.length,s=o?o.length:0;if(!i||t.f&&!t.l)return n||new r(0);var a=!n,c=a||2!=t.i,u=t.i;a&&(n=new r(3*i));var p=function(e){var t=n.length;if(e>t){var o=new r(Math.max(2*t,e));o.set(n),n=o}},m=t.f||0,y=t.p||0,v=t.b||0,b=t.l,w=t.d,k=t.m,E=t.n,L=8*i;do{if(!b){m=M(e,y,1);var R=M(e,y+1,3);if(y+=3,!R){var I=e[(H=D(y)+4)-4]|e[H-3]<<8,S=H+I;if(S>i){u&&O(0);break}c&&p(v+I),n.set(e.subarray(H,S),v),t.b=v+=I,t.p=y=8*S,t.f=m;continue}if(1==R)b=A,w=T,k=9,E=5;else if(2==R){var P=M(e,y,31)+257,_=M(e,y+10,15)+4,F=P+M(e,y+5,31)+1;y+=14;for(var V=new r(F),j=new r(19),B=0;B<_;++B)j[h[B]]=M(e,y+3*B,7);y+=3*_;var K=N(j),z=(1<>4)<16)V[B++]=H;else{var q=0,X=0;for(16==H?(X=3+M(e,y,3),y+=2,q=V[B-1]):17==H?(X=3+M(e,y,7),y+=3):18==H&&(X=11+M(e,y,127),y+=7);X--;)V[B++]=q}}var W=V.subarray(0,P),J=V.subarray(P);k=N(W),E=N(J),b=x(W,k,1),w=x(J,E,1)}else O(1);if(y>L){u&&O(0);break}}c&&p(v+131072);for(var Z=(1<>4;if((y+=15&q)>L){u&&O(0);break}if(q||O(2),$<256)n[v++]=$;else{if(256==$){Q=y,b=null;break}var ee=$-254;if($>264){var te=l[B=$-257];ee=M(e,y,(1<>4;if(ne||O(3),y+=15&ne,J=g[oe],oe>3&&(te=d[oe],J+=C(e,y)&(1<L){u&&O(0);break}c&&p(v+131072);var ie=v+ee;if(ve.length)&&(n=e.length),new r(e.subarray(t,n))}(n,0,v):n.subarray(0,v)},I=new r(0);function S(e,t){return R(e.subarray((n=e,o=t&&t.dictionary,(8!=(15&n[0])||n[0]>>4>7||(n[0]<<8|n[1])%31)&&O(6,"invalid zlib data"),(n[1]>>5&1)==+!o&&O(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,o}var P="undefined"!=typeof TextDecoder&&new TextDecoder;try{P.decode(I,{stream:!0})}catch(e){}function _(e,t,n){const o=n.length-e-1;if(t>=n[o])return o-1;if(t<=n[e])return e;let i=e,s=o,r=Math.floor((i+s)/2);for(;t=n[r+1];)t=s&&(c[i][0]=c[t][0]/a[d+1][l],o=c[i][0]*a[l][d]);const h=e-1<=d?s-1:n-e;for(let e=l>=-1?1:-l;e<=h;++e)c[i][e]=(c[t][e]-c[t][e-1])/a[d+1][l+e],o+=c[i][e]*a[l+e][d];e<=d&&(c[i][s]=-c[t][s-1]/a[d+1][e],o+=c[i][s]*a[e][d]),r[s][e]=o;const u=t;t=i,i=u}}let d=n;for(let e=1;e<=o;++e){for(let t=0;t<=n;++t)r[e][t]*=d;d*=n-e}return r}(c,i,e,r,t),d=[];for(let e=0;e=21&&t===se(e,0,21)}(e))j=(new X).parse(e);else{const t=se(e);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 o(t){const o=e[t-1];return e=e.slice(n+t),n++,o}for(let e=0;e0,s="string"==typeof i.Content&&""!==i.Content;if(e||s){const e=this.parseImage(n[o]);t[i.RelativeFilename||i.Filename]=e}}}}for(const n in e){const o=e[n];void 0!==t[o]?e[n]=t[o]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,o=n.slice(n.lastIndexOf(".")+1).toLowerCase();let i;switch(o){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),i="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+o+'" is not supported.')}if("string"==typeof t)return"data:"+i+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:i}))}}parseTextures(e){const t=new Map;if("Texture"in j.Objects){const n=j.Objects.Texture;for(const o in n){const i=this.parseTexture(n[o],e);t.set(parseInt(o),i)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,r=void 0!==i?i.value:0,a=void 0!==s?s.value:0;if(n.wrapS=0===r?o.RepeatWrapping:o.ClampToEdgeWrapping,n.wrapT=0===a?o.RepeatWrapping:o.ClampToEdgeWrapping,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if("Translation"in e){const t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){let n;const i=this.textureLoader.path,s=B.get(e.id).children;let r;void 0!==s&&s.length>0&&void 0!==t[s[0].ID]&&(n=t[s[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const a=e.FileName.slice(-3).toLowerCase();if("tga"===a){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),r=new o.Texture):(t.setPath(this.textureLoader.path),r=t.load(n))}else if("dds"===a){const t=this.manager.getHandler(".dds");null===t?(console.warn("FBXLoader: DDS loader not found, creating placeholder texture for",e.RelativeFilename),r=new o.Texture):(t.setPath(this.textureLoader.path),r=t.load(n))}else"psd"===a?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),r=new o.Texture):r=this.textureLoader.load(n);return this.textureLoader.setPath(i),r}parseMaterials(e){const t=new Map;if("Material"in j.Objects){const n=j.Objects.Material;for(const o in n){const i=this.parseMaterial(n[o],e);null!==i&&t.set(parseInt(o),i)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let s=e.ShadingModel;if("object"==typeof s&&(s=s.value),!B.has(n))return null;const r=this.parseParameters(e,t,n);let a;switch(s.toLowerCase()){case"phong":a=new o.MeshPhongMaterial;break;case"lambert":a=new o.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new o.MeshPhongMaterial}return a.setValues(r),a.name=i,a}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new o.Color).fromArray(e.Diffuse.value).convertSRGBToLinear():!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(i.color=(new o.Color).fromArray(e.DiffuseColor.value).convertSRGBToLinear()),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new o.Color).fromArray(e.Emissive.value).convertSRGBToLinear():!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(i.emissive=(new o.Color).fromArray(e.EmissiveColor.value).convertSRGBToLinear()),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new o.Color).fromArray(e.Specular.value).convertSRGBToLinear():e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new o.Color).fromArray(e.SpecularColor.value).convertSRGBToLinear());const s=this;return B.get(n).children.forEach(function(e){const n=e.relationship;switch(n){case"Bump":i.bumpMap=s.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,e.ID),void 0!==i.map&&(i.map.colorSpace=o.SRGBColorSpace);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,e.ID),void 0!==i.emissiveMap&&(i.emissiveMap.colorSpace=o.SRGBColorSpace);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,e.ID),void 0!==i.envMap&&(i.envMap.mapping=o.EquirectangularReflectionMapping,i.envMap.colorSpace=o.SRGBColorSpace);break;case"SpecularColor":i.specularMap=s.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.colorSpace=o.SRGBColorSpace);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,e.ID),i.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}}),i}getTexture(e,t){return"LayeredTexture"in j.Objects&&t in j.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 j.Objects){const n=j.Objects.Deformer;for(const o in n){const i=n[o],s=B.get(parseInt(o));if("Skin"===i.attrType){const t=this.parseSkeleton(s,n);t.ID=o,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=s.parents[0].ID,e[o]=t}else if("BlendShape"===i.attrType){const e={id:o};e.rawTargets=this.parseMorphTargets(s,n),e.id=o,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[o]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(e){const i=t[e.ID];if("Cluster"!==i.attrType)return;const s={ID:e.ID,indices:[],weights:[],transformLink:(new o.Matrix4).fromArray(i.TransformLink.a)};"Indexes"in i&&(s.indices=i.Indexes.a,s.weights=i.Weights.a),n.push(s)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let o=0;o1?r=a:a.length>0?r=a[0]:(r=new o.MeshPhongMaterial({name:o.Loader.DEFAULT_MATERIAL_NAME,color:13421772}),a.push(r)),"color"in s.attributes&&a.forEach(function(e){e.vertexColors=!0}),s.FBX_Deformer?(i=new o.SkinnedMesh(s,r),i.normalizeSkinWeights()):i=new o.Mesh(s,r),i}createCurve(e,t){const n=e.children.reduce(function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e},null),i=new o.LineBasicMaterial({name:o.Loader.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new o.Line(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?oe(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(e,t){"LookAtProperty"in t&&B.get(e.ID).children.forEach(function(t){if("LookAtProperty"===t.relationship){const n=j.Objects.Model[t.ID];if("Lcl_Translation"in n){const t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),K.add(e.target)):e.lookAt((new o.Vector3).fromArray(t))}}})}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const s in e){const r=e[s];B.get(parseInt(r.ID)).parents.forEach(function(e){if(t.has(e.ID)){const t=e.ID;B.get(t).parents.forEach(function(e){n.has(e.ID)&&n.get(e.ID).bind(new o.Skeleton(r.bones),i[e.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in j.Objects){const t=j.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(t){e[t.Node]=(new o.Matrix4).fromArray(t.Matrix.a)}):e[i.Node]=(new o.Matrix4).fromArray(i.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in j){if("AmbientColor"in j.GlobalSettings){const e=j.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(0!==t||0!==n||0!==i){const e=new o.Color(t,n,i).convertSRGBToLinear();K.add(new o.AmbientLight(e,1))}}"UnitScaleFactor"in j.GlobalSettings&&(K.userData.unitScaleFactor=j.GlobalSettings.UnitScaleFactor.value)}}}class H{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in j.Objects){const n=j.Objects.Geometry;for(const o in n){const i=B.get(parseInt(o)),s=this.parseGeometry(i,n[o],e);t.set(parseInt(o),s)}}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 o=n.skeletons,i=[],s=e.parents.map(function(e){return j.Objects.Model[e.ID]});if(0===s.length)return;const r=e.children.reduce(function(e,t){return void 0!==o[t.ID]&&(e=o[t.ID]),e},null);e.children.forEach(function(e){void 0!==n.morphTargets[e.ID]&&i.push(n.morphTargets[e.ID])});const a=s[0],c={};"RotationOrder"in a&&(c.eulerOrder=oe(a.RotationOrder.value)),"InheritType"in a&&(c.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(c.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(c.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(c.scale=a.GeometricScaling.value);const l=ne(c);return this.genGeometry(t,r,i,l)}genGeometry(e,t,n,i){const s=new o.BufferGeometry;e.attrName&&(s.name=e.attrName);const r=this.parseGeoNode(e,t),a=this.genBuffers(r),c=new o.Float32BufferAttribute(a.vertex,3);if(c.applyMatrix4(i),s.setAttribute("position",c),a.colors.length>0&&s.setAttribute("color",new o.Float32BufferAttribute(a.colors,3)),t&&(s.setAttribute("skinIndex",new o.Uint16BufferAttribute(a.weightsIndices,4)),s.setAttribute("skinWeight",new o.Float32BufferAttribute(a.vertexWeights,4)),s.FBX_Deformer=t),a.normal.length>0){const e=(new o.Matrix3).getNormalMatrix(i),t=new o.Float32BufferAttribute(a.normal,3);t.applyNormalMatrix(e),s.setAttribute("normal",t)}if(a.uvs.forEach(function(e,t){const n=0===t?"uv":`uv${t}`;s.setAttribute(n,new o.Float32BufferAttribute(a.uvs[t],2))}),r.material&&"AllSame"!==r.material.mappingType){let e=a.materialIndex[0],t=0;if(a.materialIndex.forEach(function(n,o){n!==e&&(s.addGroup(t,o-t,e),e=n,t=o)}),s.groups.length>0){const t=s.groups[s.groups.length-1],n=t.start+t.count;n!==a.materialIndex.length&&s.addGroup(n,a.materialIndex.length-n,e)}0===s.groups.length&&s.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(s,e,n,i),s}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(o,i){void 0===n.weightTable[o]&&(n.weightTable[o]=[]),n.weightTable[o].push({id:t,weight:e.weights[i]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,o=0,i=!1,s=[],r=[],a=[],c=[],l=[],d=[];const h=this;return e.vertexIndices.forEach(function(u,p){let f,m=!1;u<0&&(u^=-1,m=!0);let y=[],g=[];if(s.push(3*u,3*u+1,3*u+2),e.color){const t=$(p,n,u,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[u]&&e.weightTable[u].forEach(function(e){g.push(e.weight),y.push(e.id)}),g.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const e=[0,0,0,0],t=[0,0,0,0];g.forEach(function(n,o){let i=n,s=y[o];t.forEach(function(t,n,o){if(i>t){o[n]=i,i=t;const r=e[n];e[n]=s,s=r}})}),y=e,g=t}for(;g.length<4;)g.push(0),y.push(0);for(let e=0;e<4;++e)l.push(g[e]),d.push(y[e])}if(e.normal){const t=$(p,n,u,e.normal);r.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=$(p,n,u,e.material)[0],f<0&&(h.negativeMaterialIndices=!0,f=0)),e.uv&&e.uv.forEach(function(e,t){const o=$(p,n,u,e);void 0===c[t]&&(c[t]=[]),c[t].push(o[0]),c[t].push(o[1])}),o++,m&&(h.genFace(t,e,s,f,r,a,c,l,d,o),n++,o=0,s=[],r=[],a=[],c=[],l=[],d=[])}),t}getNormalNewell(e){const t=new o.Vector3(0,0,0);for(let n=0;n.5?new o.Vector3(0,1,0):new o.Vector3(0,0,1)).cross(t).normalize(),i=t.clone().cross(n).normalize();return{normal:t,tangent:n,bitangent:i}}flattenVertex(e,t,n){return new o.Vector2(e.dot(t),e.dot(n))}genFace(e,t,n,i,s,r,a,c,l,d){let h;if(d>3){const e=[];for(let i=0;i1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=e.get(i[0].ID);n[o]={name:t[o].attrName,layer:s}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(e){t=t.concat(n.generateTracks(e))}),new o.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new o.Vector3,i=new o.Vector3;if(e.transform&&e.transform.decompose(n,new o.Quaternion,i),n=n.toArray(),i=i.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const o=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==o&&t.push(o)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const n=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){const n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,i){const s=this.getTimesForAllAxes(t),r=this.getKeyframeTrackValues(s,t,n);return new o.VectorKeyframeTrack(e+"."+i,s,r)}generateRotationTrack(e,t,n,i,s){let r,a;if(void 0!==t.x&&void 0!==t.y&&void 0!==t.z){const e=this.interpolateRotations(t.x,t.y,t.z,s);r=e[0],a=e[1]}void 0!==n&&((n=n.map(o.MathUtils.degToRad)).push(s),n=(new o.Euler).fromArray(n),n=(new o.Quaternion).setFromEuler(n)),void 0!==i&&((i=i.map(o.MathUtils.degToRad)).push(s),i=(new o.Euler).fromArray(i),i=(new o.Quaternion).setFromEuler(i).invert());const c=new o.Quaternion,l=new o.Euler,d=[];if(!a||!r)return new o.QuaternionKeyframeTrack(e+".quaternion",[0],[0]);for(let e=0;e2&&(new o.Quaternion).fromArray(d,(e-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w),c.toArray(d,e/3*4);return new o.QuaternionKeyframeTrack(e+".quaternion",r,d)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(e){return e/100}),i=K.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new o.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}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 o=1;o=180||p[1]>=180||p[2]>=180){const t=Math.max(...p)/180,n=new o.Euler(...l,i),c=new o.Euler(...h,i),d=(new o.Quaternion).setFromEuler(n),u=(new o.Quaternion).setFromEuler(c);d.dot(u)&&u.set(-u.x,-u.y,-u.z,-u.w);const f=e.times[a-1],m=e.times[a]-f,y=new o.Quaternion,g=new o.Euler;for(let e=0;e<1;e+=1/t)y.copy(d.clone().slerp(u.clone(),e)),s.push(f+e*m),g.setFromQuaternion(y,i),r.push(g.x),r.push(g.y),r.push(g.z)}else s.push(e.times[a]),r.push(o.MathUtils.degToRad(e.values[a])),r.push(o.MathUtils.degToRad(t.values[a])),r.push(o.MathUtils.degToRad(n.values[a]))}return[s,r]}}class q{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 J,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(e,o){const i=e.match(/^[\s\t]*;/),s=e.match(/^[\s\t]*$/);if(i||s)return;const r=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),c=e.match("^\\t{"+(t.currentIndent-1)+"}}");r?t.parseNodeBegin(e,r):a?t.parseNodeProperty(e,a,n[++o]):c?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),o=t[2].split(",").map(function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")}),i={name:n},s=this.parseNodeAttr(o),r=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,i):n in r?("PoseNode"===n?r.PoseNode.push(i):void 0!==r[n].id&&(r[n]={},r[n][r[n].id]=r[n]),""!==s.id&&(r[n][s.id]=i)):"number"==typeof s.id?(r[n]={},r[n][s.id]=i):"Properties70"!==n&&(r[n]="PoseNode"===n?[i]:i),"number"==typeof s.id&&(i.id=s.id),""!==s.name&&(i.attrName=s.name),""!==s.type&&(i.attrType=s.type),this.pushStack(i)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",o="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),o=e[2]),{id:t,name:n,type:o}}parseNodeProperty(e,t,n){let o=t[1].replace(/^"/,"").replace(/"$/,"").trim(),i=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===o&&","===i&&(i=n.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===o){const e=i.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let r=i.split(",").slice(3);r=r.map(function(e){return e.trim().replace(/^"/,"")}),o="connections",i=[t,n],function(e,t){for(let n=0,o=e.length,i=t.length;n=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},o=t>=7500?e.getUint64():e.getUint32(),i=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const s=e.getUint8(),r=e.getString(s);if(0===o)return null;const a=[];for(let t=0;t0?a[0]:"",l=a.length>1?a[1]:"",d=a.length>2?a[2]:"";for(n.singleProperty=1===i&&e.getOffset()===o;o>e.getOffset();){const o=this.parseNode(e,t);null!==o&&this.parseSubNode(r,n,o)}return n.propertyList=a,"number"==typeof c&&(n.id=c),""!==l&&(n.attrName=l),""!==d&&(n.attrType=d),""!==r&&(n.name=r),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],o=n.propertyList[1];const i=n.propertyList[2],s=n.propertyList[3];let r;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===o.indexOf("Lcl ")&&(o=o.replace("Lcl ","Lcl_")),r="Color"===o||"ColorRGB"===o||"Vector"===o||"Vector3D"===o||0===o.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:o,type2:i,flag:s,value:r}}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 o=e.getUint32(),i=e.getUint32(),s=e.getUint32();if(0===i)switch(t){case"b":case"c":return e.getBooleanArray(o);case"d":return e.getFloat64Array(o);case"f":return e.getFloat32Array(o);case"i":return e.getInt32Array(o);case"l":return e.getInt64Array(o)}const r=S(new Uint8Array(e.getArrayBuffer(s))),a=new W(r.buffer);switch(t){case"b":case"c":return a.getBooleanArray(o);case"d":return a.getFloat64Array(o);case"f":return a.getFloat32Array(o);case"i":return a.getInt32Array(o);case"l":return a.getInt64Array(o)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class W{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,o)),this._textDecoder.decode(n)}}class J{add(e,t){this[e]=t}}function Z(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 Q=[];function $(e,t,n,o){let i;switch(o.mappingType){case"ByPolygonVertex":i=e;break;case"ByPolygon":i=t;break;case"ByVertice":i=n;break;case"AllSame":i=o.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+o.mappingType)}"IndexToDirect"===o.referenceType&&(i=o.indices[i]);const s=i*o.dataSize,r=s+o.dataSize;return function(e,t,n,o){for(let i=n,s=0;i{window,e.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var o,i=function(e,t){var n=t.x-e.x,o=t.y-e.y;return Math.sqrt(n*n+o*o)},s=function(e){return e*(Math.PI/180)},r=new Map,a=function(e){r.has(e)&&clearTimeout(r.get(e)),r.set(e,setTimeout(e,100))},c=function(e,t,n){for(var o,i=t.split(/[ ,]+/g),s=0;s=0&&this._handlers_[e].splice(this._handlers_[e].indexOf(t),1),this},k.prototype.trigger=function(e,t){var n,o=this,i=e.split(/[ ,]+/g);o._handlers_=o._handlers_||{};for(var s=0;ss&&i<3*s&&!e.lockX?t="up":i>-s&&i<=s&&!e.lockY?t="left":i>3*-s&&i<=-s&&!e.lockX?t="down":e.lockY||(t="right"),e.lockY||(n=i>-r&&i0?"up":"down"),e.force>this.options.threshold){var a,c={};for(a in this.direction)this.direction.hasOwnProperty(a)&&(c[a]=this.direction[a]);var l={};for(a in this.direction={x:n,y:o,angle:t},e.direction=this.direction,c)c[a]===this.direction[a]&&(l[a]=!0);if(l.x&&l.y&&l.angle)return e;l.x&&l.y||this.trigger("plain",e),l.x||this.trigger("plain:"+n,e),l.y||this.trigger("plain:"+o,e),l.angle||this.trigger("dir dir:"+t,e)}else this.resetDirection();return e};var T=A;function N(e,t){this.nipples=[],this.idles=[],this.actives=[],this.ids=[],this.pressureIntervals={},this.manager=e,this.id=N.id,N.id+=1,this.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},this.config(t),"static"!==this.options.mode&&"semi"!==this.options.mode||(this.options.multitouch=!1),this.options.multitouch||(this.options.maxNumberOfNipples=1);var n=getComputedStyle(this.options.zone.parentElement);return n&&"flex"===n.display&&(this.parentIsFlex=!0),this.updateBox(),this.prepareNipples(),this.bindings(),this.begin(),this.nipples}N.prototype=new E,N.constructor=N,N.id=0,N.prototype.prepareNipples=function(){var e=this.nipples;e.on=this.on.bind(this),e.off=this.off.bind(this),e.options=this.options,e.destroy=this.destroy.bind(this),e.ids=this.ids,e.id=this.id,e.processOnMove=this.processOnMove.bind(this),e.processOnEnd=this.processOnEnd.bind(this),e.get=function(t){if(void 0===t)return e[0];for(var n=0,o=e.length;n