!function e(t,r,n){function i(a,s){if(!r[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(o)return o(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[a]={exports:{}};t[a][0].call(u.exports,function(e){var r=t[a][1][e];return i(r||e)},u,u.exports,e,t,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a0&&r.has(l[0].ID))i=r.get(l[0].ID);else if(void 0!==c&&"/"!==c[0]&&null===c.match(/^[a-zA-Z]:/))i=c;else{var u=s.split(/[\\\/]/);i=u.length>0?u[u.length-1]:s}var f=t.path;0!==i.indexOf("blob:")&&0!==i.indexOf("data:")||t.setPath(void 0);var h=t.load(i);h.name=a,h.FBX_ID=o;var p=e.properties.WrapModeU,d=e.properties.WrapModeV,m=void 0!==p?p.value:0,v=void 0!==d?d.value:0;return h.wrapS=0===m?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,h.wrapT=0===v?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,t.setPath(f),h}function a(e,t,r){var n=new Map;if("Material"in e.Objects.subNodes){var i=e.Objects.subNodes.Material;for(var o in i){var a=s(i[o],t,r);null!==a&&n.set(parseInt(o),a)}}return n}function s(e,t,r){var n=e.id,i=e.attrName,o=e.properties.ShadingModel;if("object"==typeof o&&(o=o.value),!r.has(n))return null;var a,s=r.get(n).children,l=c(e.properties,t,s);switch(o.toLowerCase()){case"phong":a=new THREE.MeshPhongMaterial;break;case"lambert":a=new THREE.MeshLambertMaterial;break;default:console.warn("THREE.FBXLoader: No implementation given for material type %s in FBXLoader.js. Defaulting to standard material.",o),a=new THREE.MeshStandardMaterial({color:3342591})}return a.setValues(l),a.name=i,a}function c(e,t,r){var n={};e.Diffuse&&(n.color=Z(e.Diffuse)),e.Specular&&(n.specular=Z(e.Specular)),e.Shininess&&(n.shininess=e.Shininess.value),e.Emissive&&(n.emissive=Z(e.Emissive)),e.EmissiveFactor&&(n.emissiveIntensity=e.EmissiveFactor.value),e.Opacity&&(n.opacity=e.Opacity.value),n.opacity<1&&(n.transparent=!0);for(var i=0,o=r.length;i4){x||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),x=!0);var O=[0,0,0,0],j=[0,0,0,0];B.forEach(function(e,t){var r=e,n=L[t];j.forEach(function(e,t,i){if(r>e){i[t]=r,r=e;var o=O[t];O[t]=n,n=o}})}),L=O,B=j}for(Z=B.length;Z<4;++Z)B[Z]=0,L[Z]=0;H.skinWeights.fromArray(B),H.skinIndices.fromArray(L)}if(a&&H.normal.fromArray(E(_,R,N,a)),s&&H.uv.fromArray(E(_,R,N,s)),c&&H.color.fromArray(E(_,R,N,c)),I.push(H),A){var M=new S;if(M.genTrianglesFromVertices(I),void 0!==l){var P=E(_,R,N,l);M.materialIndex=P[0]}else M.materialIndex=0;r.faces.push(M),I=[],R++,A=!1}}var U=r.flattenToBuffers(),X=new THREE.BufferGeometry;X.name=e.name,X.addAttribute("position",new THREE.Float32BufferAttribute(U.vertexBuffer,3)),U.normalBuffer.length>0&&X.addAttribute("normal",new THREE.Float32BufferAttribute(U.normalBuffer,3)),U.uvBuffer.length>0&&X.addAttribute("uv",new THREE.Float32BufferAttribute(U.uvBuffer,2)),n.LayerElementColor&&X.addAttribute("color",new THREE.Float32BufferAttribute(U.colorBuffer,3)),t&&(X.addAttribute("skinIndex",new THREE.Float32BufferAttribute(U.skinIndexBuffer,4)),X.addAttribute("skinWeight",new THREE.Float32BufferAttribute(U.skinWeightBuffer,4)),X.FBX_Deformer=t);for(var z=U.materialIndexBuffer,V=z[0],Y=0,Z=0;Z1?y=E:E.length>0?y=E[0]:(y=new THREE.MeshStandardMaterial({color:3342591}),E.push(y)),"color"in g.attributes)for(var I=0,R=E.length;I-1){s[S].add(p);break}}null===p.parent&&o.add(p)}o.updateMatrixWorld(!0);var k=e.Objects.subNodes.Pose;for(var l in k)if("BindPose"===k[l].attrType){k=k[l];break}if(k)for(var O=k.subNodes.PoseNode,j=new Map,M=0,P=O.length;MA.min&&(s.stacks[l]={name:a[l].attrName,layers:N,length:A.max-A.min,frames:30*(A.max-A.min)})}return s}function I(e,t,r,n){var i=e.Objects.subNodes.Model,o={id:t.id,attr:t.attrName,internalID:t.id,attrX:!1,attrY:!1,attrZ:!1,containerBoneID:-1,containerID:-1,curves:{x:null,y:null,z:null},preRotations:null};if(!o.attr.match(/S|R|T/))return null;for(var a in t.properties)a.match(/X/)&&(o.attrX=!0),a.match(/Y/)&&(o.attrY=!0),a.match(/Z/)&&(o.attrZ=!0);for(var s=r.get(o.id).parents,c=s.length-1;c>=0;--c){var l=Q(n.skeleton.bones,function(e){return e.FBX_ID===s[c].ID});if(l>-1){o.containerBoneID=l,o.containerID=s[c].ID;var u=i[o.containerID.toString()];"PreRotation"in u.properties&&(o.preRotations=Y(u.properties.PreRotation).multiplyScalar(Math.PI/180));break}}return o}function R(e){return{version:null,id:e.id,internalID:e.id,times:G(e.subNodes.KeyTime.properties.a).map(V),values:G(e.subNodes.KeyValueFloat.properties.a),attrFlag:W(e.subNodes.KeyAttrFlags.properties.a),attrData:G(e.subNodes.KeyAttrDataFloat.properties.a)}}function x(e,t){e.R&&_(e.R.curves,t),e.S&&_(e.S.curves,t),e.T&&_(e.T.curves,t)}function _(e,t){e.x&&N(e.x,t),e.y&&N(e.y,t),e.z&&N(e.z,t)}function N(e,t){t.max=e.times[e.times.length-1]>t.max?e.times[e.times.length-1]:t.max,t.min=e.times[0]=t.length&&t===q(e,0,t.length)}function X(e){for(var t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],r=0,n=0;n1&&(r=e[1].replace(/^(\w+)::/,""),n=e[2]),{id:t,name:r,type:n}},parseNodeProperty:function(e,t,r){var n=this.getCurrentNode(),i=n.name;if(void 0!==i&&i.match(/Properties(\d)+/))this.parseNodeSpecialProperty(e,t,r);else{if("C"===t){var o=r.split(",").slice(1),a=parseInt(o[0]),s=parseInt(o[1]),c=r.split(",").slice(3);t="connections",J(r=[a,s],c),void 0===n.properties[t]&&(n.properties[t]=[])}if("Node"===t){var l=parseInt(r);n.properties.id=l,n.id=l}t in n.properties?Array.isArray(n.properties[t])?n.properties[t].push(r):n.properties[t]+=r:Array.isArray(n.properties[t])?n.properties[t].push(r):n.properties[t]=r,this.setCurrentProp(n.properties,t)}},parseNodePropertyContinued:function(e){this.currentProp[this.currentPropName]+=e},parseNodeSpecialProperty:function(e,t,r){for(var n=r.split('",'),i=0,o=n.length;i=e.size():e.getOffset()+160+16>=e.size()},parseNode:function(e,t){var r=t>=7500?e.getUint64():e.getUint32(),n=t>=7500?e.getUint64():e.getUint32(),i=(t>=7500?e.getUint64():e.getUint32(),e.getUint8()),o=e.getString(i);if(0===r)return null;for(var a=[],s=0;s0?a[0]:"",l=a.length>1?a[1]:"",u=a.length>2?a[2]:"",f={},h={},p=!1;for(1===n&&e.getOffset()===r&&(p=!0);r>e.getOffset();){var d=this.parseNode(e,t);if(null!==d)if(!0!==d.singleProperty)if("Connections"!==o||"C"!==d.name)if(d.name.match(/^Properties\d+$/))for(var m=Object.keys(d.properties),s=0,v=m.length;s0;){var r=this.getUint8();if(e--,0===r)break;t+=String.fromCharCode(r)}return this.skip(e),t}}),Object.assign(P.prototype,{add:function(e,t){this[e]=t},searchConnectionParent:function(e){if(void 0===this.__cache_search_connection_parent&&(this.__cache_search_connection_parent=[]),void 0!==this.__cache_search_connection_parent[e])return this.__cache_search_connection_parent[e];this.__cache_search_connection_parent[e]=[];for(var t=this.Connections.properties.connections,r=[],n=0;n0?(J(this.__cache_search_connection_parent[e],r),r):(this.__cache_search_connection_parent[e]=[-1],[-1])},searchConnectionChildren:function(e){if(void 0===this.__cache_search_connection_children&&(this.__cache_search_connection_children=[]),void 0!==this.__cache_search_connection_children[e])return this.__cache_search_connection_children[e];this.__cache_search_connection_children[e]=[];for(var t=this.Connections.properties.connections,r=[],n=0;n0?(J(this.__cache_search_connection_children[e],r),r):(this.__cache_search_connection_children[e]=[],[])},searchConnectionType:function(e,t){var r=e+","+t;if(void 0===this.__cache_search_connection_type&&(this.__cache_search_connection_type={}),void 0!==this.__cache_search_connection_type[r])return this.__cache_search_connection_type[r];this.__cache_search_connection_type[r]="";for(var n=this.Connections.properties.connections,i=0;i=n.elements[a].count&&(a++,s=0);var u=this.parseASCIIElement(n.elements[a].properties,l);this.handleElement(r,n.elements[a].name,u),s++}}return this.postProcess(r)},postProcess:function(e){if(e.useColor){for(var t=0;t