THREE.FBXLoader=function(){var e,t,r;function a(e){THREE.Loader.call(this,e)}function n(e,t){this.textureLoader=e,this.manager=t,this.imageNum=0,this.loadTextureCount=0,this.onLoad=null}function i(){}function o(){}function s(){}function u(){}function l(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}function c(){}function p(e){var 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 h(e){return e/46186158e3}a.prototype=Object.assign(Object.create(THREE.Loader.prototype),{constructor:a,load:function(e,t,r,a){var n=this,i=""===n.path?THREE.LoaderUtils.extractUrlBase(e):n.path,o=new THREE.FileLoader(this.manager);o.setPath(n.path),o.setResponseType("arraybuffer"),o.setRequestHeader(n.requestHeader),o.setWithCredentials(n.withCredentials),o.load(e,(function(r){try{n.parse(r,i,t)}catch(t){a?a(t):console.error(t),n.manager.itemError(e)}}),r,a)},parse:function(t,r,a){if(l="Kaydara FBX Binary \0",(o=t).byteLength>=l.length&&l===T(o,0,l.length))e=(new u).parse(t);else{var i=T(t);if(!function(e){var t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],r=0;function a(t){var a=e[t-1];return e=e.slice(r+t),r++,a}for(var n=0;n=this.imageNum){var e=this.parseMaterials(this.textures),t=this.parseDeformers(),a=(new i).parse(t);this.parseScene(t,a,e),this.onLoad&&this.onLoad(r)}},parseConnections:function(){var t=new Map;"Connections"in e&&e.Connections.connections.forEach((function(e){var r=e[0],a=e[1],n=e[2];t.has(r)||t.set(r,{parents:[],children:[]});var i={ID:a,relationship:n};t.get(r).parents.push(i),t.has(a)||t.set(a,{parents:[],children:[]});var o={ID:r,relationship:n};t.get(a).children.push(o)}));return t},parseImages:function(){var t={},r={};if(this.imageNum=0,"Video"in e.Objects){var a=e.Objects.Video;for(var n in a){var i=a[n];if(t[l=parseInt(n)]=i.RelativeFilename||i.Filename,this.imageNum++,"Content"in i){var o=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,s="string"==typeof i.Content&&""!==i.Content;if(o||s){var u=this.parseImage(a[n]);r[i.RelativeFilename||i.Filename]=u}}}}for(var l in t){var c=t[l];void 0!==r[c]?t[l]=r[c]:t[l]=t[l].split("\\").pop()}return t},parseImage:function(e){var t,r=e.Content,a=e.RelativeFilename||e.Filename,n=a.slice(a.lastIndexOf(".")+1).toLowerCase();switch(n){case"bmp":t="image/bmp";break;case"jpg":case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"tif":t="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",a),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+n+'" is not supported.')}if("string"==typeof r)return"data:"+t+";base64,"+r;var i=new Uint8Array(r);return window.URL.createObjectURL(new Blob([i],{type:t}))},parseTextures:function(t){if(this.textures=new Map,"Texture"in e.Objects){var r=e.Objects.Texture;for(var a in r){var n=this.parseTexture(r[a],t);this.textures.set(parseInt(a),n)}}return this.textures},parseTexture:function(e,t){var r=this.loadTexture(e,t);r.ID=e.id,r.name=e.attrName;var a=e.WrapModeU,n=e.WrapModeV,i=void 0!==a?a.value:0,o=void 0!==n?n.value:0;if(r.wrapS=0===i?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,r.wrapT=0===o?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,"Scaling"in e){var s=e.Scaling.value;r.repeat.x=s[0],r.repeat.y=s[1]}return r},loadTexture:function(e,r){var a,n,i=this.textureLoader.path,o=this,s=t.get(e.id).children;void 0!==s&&s.length>0&&void 0!==r[s[0].ID]&&(0!==(a=r[s[0].ID]).indexOf("blob:")&&0!==a.indexOf("data:")||this.textureLoader.setPath(void 0));var u=e.FileName.slice(-3).toLowerCase();if("tga"===u){var l=this.manager.getHandler(".tga");null===l?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),n=null,o.onLoadTexture()):n=l.load(a,(function(){o.onLoadTexture()}),void 0,(function(){o.textures.set(e.id,null),o.onLoadTexture()}))}else"psd"===u?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),n=null,o.onLoadTexture()):n=this.textureLoader.load(a,(function(){o.onLoadTexture()}),void 0,(function(){o.textures.set(e.id,null),o.onLoadTexture()}));return this.textureLoader.setPath(i),n},parseMaterials:function(t){var r=new Map;if("Material"in e.Objects){var a=e.Objects.Material;for(var n in a){var i=this.parseMaterial(a[n],t);null!==i&&r.set(parseInt(n),i)}}return r},parseMaterial:function(e,r){var a=e.id,n=e.attrName,i=e.ShadingModel;if("object"==typeof i&&(i=i.value),!t.has(a))return null;var o,s=this.parseParameters(e,r,a);switch(i.toLowerCase()){case"phong":o=new THREE.MeshPhongMaterial;break;case"lambert":o=new THREE.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),o=new THREE.MeshPhongMaterial}return o.setValues(s),o.name=n,o},parseParameters:function(e,r,a){var n={};e.BumpFactor&&(n.bumpScale=e.BumpFactor.value),e.Diffuse?n.color=(new THREE.Color).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(n.color=(new THREE.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=(new THREE.Color).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(n.emissive=(new THREE.Color).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(n.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(n.opacity=parseFloat(e.Opacity.value)),n.opacity<1&&(n.transparent=!0),e.ReflectionFactor&&(n.reflectivity=e.ReflectionFactor.value),e.Shininess&&(n.shininess=e.Shininess.value),e.Specular?n.specular=(new THREE.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(n.specular=(new THREE.Color).fromArray(e.SpecularColor.value));var i=this;return t.get(a).children.forEach((function(e){var t=e.relationship;switch(t){case"Bump":n.bumpMap=i.getTexture(r,e.ID);break;case"Maya|TEX_ao_map":n.aoMap=i.getTexture(r,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":n.map=i.getTexture(r,e.ID),n.map&&(n.map.encoding=THREE.sRGBEncoding);break;case"DisplacementColor":n.displacementMap=i.getTexture(r,e.ID);break;case"EmissiveColor":n.emissiveMap=i.getTexture(r,e.ID),n.emissiveMap&&(n.emissiveMap.encoding=THREE.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":n.normalMap=i.getTexture(r,e.ID);break;case"ReflectionColor":n.envMap=i.getTexture(r,e.ID),n.envMap&&(n.envMap.mapping=THREE.EquirectangularReflectionMapping,n.envMap.encoding=THREE.sRGBEncoding);break;case"SpecularColor":n.specularMap=i.getTexture(r,e.ID),n.specularMap&&(n.specularMap.encoding=THREE.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":n.alphaMap=i.getTexture(r,e.ID),n.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",t)}})),n},getTexture:function(r,a){return r?("LayeredTexture"in e.Objects&&a in e.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),a=t.get(a).children[0].ID),r.get(a)):null},parseDeformers:function(){var r={},a={};if("Deformer"in e.Objects){var n=e.Objects.Deformer;for(var i in n){var o=n[i],s=t.get(parseInt(i));if("Skin"===o.attrType){var u=this.parseSkeleton(s,n);u.ID=i,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),u.geometryID=s.parents[0].ID,r[i]=u}else if("BlendShape"===o.attrType){var l={id:i};l.rawTargets=this.parseMorphTargets(s,n),l.id=i,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),a[i]=l}}}return{skeletons:r,morphTargets:a}},parseSkeleton:function(e,t){var r=[];return e.children.forEach((function(e){var a=t[e.ID];if("Cluster"===a.attrType){var n={ID:e.ID,indices:[],weights:[],transformLink:(new THREE.Matrix4).fromArray(a.TransformLink.a)};"Indexes"in a&&(n.indices=a.Indexes.a,n.weights=a.Weights.a),r.push(n)}})),{rawBones:r,bones:[]}},parseMorphTargets:function(e,r){for(var a=[],n=0;n1?i=o:o.length>0?i=o[0]:(i=new THREE.MeshPhongMaterial({color:13421772}),o.push(i)),"color"in n.attributes&&o.forEach((function(e){e.vertexColors=!0})),n.FBX_Deformer?(o.forEach((function(e){e.skinning=!0})),(a=new THREE.SkinnedMesh(n,i)).normalizeSkinWeights()):a=new THREE.Mesh(n,i),a},createCurve:function(e,t){var r=e.children.reduce((function(e,r){return t.has(r.ID)&&(e=t.get(r.ID)),e}),null),a=new THREE.LineBasicMaterial({color:3342591,linewidth:1});return new THREE.Line(r,a)},getTransformData:function(e,t){var r={};"InheritType"in t&&(r.inheritType=parseInt(t.InheritType.value)),r.eulerOrder="RotationOrder"in t?E(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(r.translation=t.Lcl_Translation.value),"PreRotation"in t&&(r.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(r.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(r.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(r.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(r.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(r.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(r.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(r.rotationPivot=t.RotationPivot.value),e.userData.transformData=r},setLookAtProperties:function(a,n){"LookAtProperty"in n&&t.get(a.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){var n=e.Objects.Model[t.ID];if("Lcl_Translation"in n){var i=n.Lcl_Translation.value;void 0!==a.target?(a.target.position.fromArray(i),r.add(a.target)):a.lookAt((new THREE.Vector3).fromArray(i))}}}))},bindSkeleton:function(e,r,a){var n=this.parsePoseNodes();for(var i in e){var o=e[i];t.get(parseInt(o.ID)).parents.forEach((function(e){if(r.has(e.ID)){var i=e.ID;t.get(i).parents.forEach((function(e){a.has(e.ID)&&a.get(e.ID).bind(new THREE.Skeleton(o.bones),n[e.ID])}))}}))}},parsePoseNodes:function(){var t={};if("Pose"in e.Objects){var r=e.Objects.Pose;for(var a in r)if("BindPose"===r[a].attrType){var n=r[a].PoseNode;Array.isArray(n)?n.forEach((function(e){t[e.Node]=(new THREE.Matrix4).fromArray(e.Matrix.a)})):t[n.Node]=(new THREE.Matrix4).fromArray(n.Matrix.a)}}return t},createAmbientLight:function(){if("GlobalSettings"in e&&"AmbientColor"in e.GlobalSettings){var t=e.GlobalSettings.AmbientColor.value,a=t[0],n=t[1],i=t[2];if(0!==a||0!==n||0!==i){var o=new THREE.Color(a,n,i);r.add(new THREE.AmbientLight(o,1))}}},setupMorphMaterials:function(){var e=this;r.traverse((function(t){t.isMesh&&t.geometry.morphAttributes.position&&t.geometry.morphAttributes.position.length&&(Array.isArray(t.material)?t.material.forEach((function(r,a){e.setupMorphMaterial(t,r,a)})):e.setupMorphMaterial(t,t.material))}))},setupMorphMaterial:function(e,t,a){var n=e.uuid,i=t.uuid,o=!1;if(r.traverse((function(e){e.isMesh&&(Array.isArray(e.material)?e.material.forEach((function(t){t.uuid===i&&e.uuid!==n&&(o=!0)})):e.material.uuid===i&&e.uuid!==n&&(o=!0))})),!0===o){var s=t.clone();s.morphTargets=!0,void 0===a?e.material=s:e.material[a]=s}else t.morphTargets=!0}},i.prototype={constructor:i,parse:function(r){var a=new Map;if("Geometry"in e.Objects){var n=e.Objects.Geometry;for(var i in n){var o=t.get(parseInt(i)),s=this.parseGeometry(o,n[i],r);a.set(parseInt(i),s)}}return a},parseGeometry:function(e,t,r){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,r);case"NurbsCurve":return this.parseNurbsGeometry(t)}},parseMeshGeometry:function(t,r,a){var n=a.skeletons,i=[],o=t.parents.map((function(t){return e.Objects.Model[t.ID]}));if(0!==o.length){var s=t.children.reduce((function(e,t){return void 0!==n[t.ID]&&(e=n[t.ID]),e}),null);t.children.forEach((function(e){void 0!==a.morphTargets[e.ID]&&i.push(a.morphTargets[e.ID])}));var u=o[0],l={};"RotationOrder"in u&&(l.eulerOrder=E(u.RotationOrder.value)),"InheritType"in u&&(l.inheritType=parseInt(u.InheritType.value)),"GeometricTranslation"in u&&(l.translation=u.GeometricTranslation.value),"GeometricRotation"in u&&(l.rotation=u.GeometricRotation.value),"GeometricScaling"in u&&(l.scale=u.GeometricScaling.value);var c=g(l);return this.genGeometry(r,s,i,c)}},genGeometry:function(e,t,r,a){var n=new THREE.BufferGeometry;e.attrName&&(n.name=e.attrName);var i=this.parseGeoNode(e,t),o=this.genBuffers(i),s=new THREE.Float32BufferAttribute(o.vertex,3);if(s.applyMatrix4(a),n.setAttribute("position",s),o.colors.length>0&&n.setAttribute("color",new THREE.Float32BufferAttribute(o.colors,3)),t&&(n.setAttribute("skinIndex",new THREE.Uint16BufferAttribute(o.weightsIndices,4)),n.setAttribute("skinWeight",new THREE.Float32BufferAttribute(o.vertexWeights,4)),n.FBX_Deformer=t),o.normal.length>0){var u=(new THREE.Matrix3).getNormalMatrix(a),l=new THREE.Float32BufferAttribute(o.normal,3);l.applyNormalMatrix(u),n.setAttribute("normal",l)}if(o.uvs.forEach((function(e,t){var r="uv"+(t+1).toString();0===t&&(r="uv"),n.setAttribute(r,new THREE.Float32BufferAttribute(o.uvs[t],2))})),i.material&&"AllSame"!==i.material.mappingType){var c=o.materialIndex[0],p=0;if(o.materialIndex.forEach((function(e,t){e!==c&&(n.addGroup(p,t-p,c),c=e,p=t)})),n.groups.length>0){var h=n.groups[n.groups.length-1],f=h.start+h.count;f!==o.materialIndex.length&&n.addGroup(f,o.materialIndex.length-f,c)}0===n.groups.length&&n.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(n,e,r,a),n},parseGeoNode:function(e,t){var r={};if(r.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],r.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(r.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(r.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(r.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){r.uv=[];for(var a=0;e.LayerElementUV[a];)e.LayerElementUV[a].UV&&r.uv.push(this.parseUVs(e.LayerElementUV[a])),a++}return r.weightTable={},null!==t&&(r.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(a,n){void 0===r.weightTable[a]&&(r.weightTable[a]=[]),r.weightTable[a].push({id:t,weight:e.weights[n]})}))}))),r},genBuffers:function(e){var t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},r=0,a=0,n=!1,i=[],o=[],s=[],u=[],l=[],c=[],p=this;return e.vertexIndices.forEach((function(h,f){var v=!1;h<0&&(h^=-1,v=!0);var m=[],g=[];if(i.push(3*h,3*h+1,3*h+2),e.color){var E=d(f,r,h,e.color);s.push(E[0],E[1],E[2])}if(e.skeleton){if(void 0!==e.weightTable[h]&&e.weightTable[h].forEach((function(e){g.push(e.weight),m.push(e.id)})),g.length>4){n||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),n=!0);var y=[0,0,0,0],T=[0,0,0,0];g.forEach((function(e,t){var r=e,a=m[t];T.forEach((function(e,t,n){if(r>e){n[t]=r,r=e;var i=y[t];y[t]=a,a=i}}))})),m=y,g=T}for(;g.length<4;)g.push(0),m.push(0);for(var R=0;R<4;++R)l.push(g[R]),c.push(m[R])}if(e.normal){E=d(f,r,h,e.normal);o.push(E[0],E[1],E[2])}if(e.material&&"AllSame"!==e.material.mappingType)var w=d(f,r,h,e.material)[0];e.uv&&e.uv.forEach((function(e,t){var a=d(f,r,h,e);void 0===u[t]&&(u[t]=[]),u[t].push(a[0]),u[t].push(a[1])})),a++,v&&(p.genFace(t,e,i,w,o,s,u,l,c,a),r++,a=0,i=[],o=[],s=[],u=[],l=[],c=[])})),t},genFace:function(e,t,r,a,n,i,o,s,u,l){for(var c=2;c1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");var s=r.get(o[0].ID);n[i]={name:a[i].attrName,layer:s}}return n},addClip:function(e){var t=[],r=this;return e.layer.forEach((function(e){t=t.concat(r.generateTracks(e))})),new THREE.AnimationClip(e.name,-1,t)},generateTracks:function(e){var t=[],r=new THREE.Vector3,a=new THREE.Quaternion,n=new THREE.Vector3;if(e.transform&&e.transform.decompose(r,a,n),r=r.toArray(),a=(new THREE.Euler).setFromQuaternion(a,e.eulerOrder).toArray(),n=n.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){var i=this.generateVectorTrack(e.modelName,e.T.curves,r,"position");void 0!==i&&t.push(i)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){var o=this.generateRotationTrack(e.modelName,e.R.curves,a,e.preRotation,e.postRotation,e.eulerOrder);void 0!==o&&t.push(o)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){var s=this.generateVectorTrack(e.modelName,e.S.curves,n,"scale");void 0!==s&&t.push(s)}if(void 0!==e.DeformPercent){var u=this.generateMorphTrack(e);void 0!==u&&t.push(u)}return t},generateVectorTrack:function(e,t,r,a){var n=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(n,t,r);return new THREE.VectorKeyframeTrack(e+"."+a,n,i)},generateRotationTrack:function(e,t,r,a,n,i){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(THREE.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(THREE.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(THREE.MathUtils.degToRad));var o=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(o,t,r);void 0!==a&&((a=a.map(THREE.MathUtils.degToRad)).push(i),a=(new THREE.Euler).fromArray(a),a=(new THREE.Quaternion).setFromEuler(a)),void 0!==n&&((n=n.map(THREE.MathUtils.degToRad)).push(i),n=(new THREE.Euler).fromArray(n),n=(new THREE.Quaternion).setFromEuler(n).invert());for(var u=new THREE.Quaternion,l=new THREE.Euler,c=[],p=0;p1){for(var r=1,a=t[0],n=1;n=180){for(var i=n/180,o=a/i,s=r+o,u=e.times[t-1],l=(e.times[t]-u)/i,c=u+l,p=[],h=[];c1&&(r=e[1].replace(/^(\w+)::/,""),a=e[2]),{id:t,name:r,type:a}},parseNodeProperty:function(e,t,r){var a=t[1].replace(/^"/,"").replace(/"$/,"").trim(),n=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===a&&","===n&&(n=r.replace(/"/g,"").replace(/,$/,"").trim());var i=this.getCurrentNode();if("Properties70"!==i.name){if("C"===a){var o=n.split(",").slice(1),s=parseInt(o[0]),u=parseInt(o[1]),l=n.split(",").slice(3);a="connections",function(e,t){for(var r=0,a=e.length,n=t.length;r=e.size():e.getOffset()+160+16>=e.size()},parseNode:function(e,t){var r={},a=t>=7500?e.getUint64():e.getUint32(),n=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();var i=e.getUint8(),o=e.getString(i);if(0===a)return null;for(var s=[],u=0;u0?s[0]:"",c=s.length>1?s[1]:"",p=s.length>2?s[2]:"";for(r.singleProperty=1===n&&e.getOffset()===a;a>e.getOffset();){var h=this.parseNode(e,t);null!==h&&this.parseSubNode(o,r,h)}return r.propertyList=s,"number"==typeof l&&(r.id=l),""!==c&&(r.attrName=c),""!==p&&(r.attrType=p),""!==o&&(r.name=o),r},parseSubNode:function(e,t,r){if(!0===r.singleProperty){var a=r.propertyList[0];Array.isArray(a)?(t[r.name]=r,r.a=a):t[r.name]=a}else if("Connections"===e&&"C"===r.name){var n=[];r.propertyList.forEach((function(e,t){0!==t&&n.push(e)})),void 0===t.connections&&(t.connections=[]),t.connections.push(n)}else if("Properties70"===r.name){Object.keys(r).forEach((function(e){t[e]=r[e]}))}else if("Properties70"===e&&"P"===r.name){var i,o=r.propertyList[0],s=r.propertyList[1],u=r.propertyList[2],l=r.propertyList[3];0===o.indexOf("Lcl ")&&(o=o.replace("Lcl ","Lcl_")),0===s.indexOf("Lcl ")&&(s=s.replace("Lcl ","Lcl_")),i="Color"===s||"ColorRGB"===s||"Vector"===s||"Vector3D"===s||0===s.indexOf("Lcl_")?[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:r.propertyList[4],t[o]={type:s,type2:u,flag:l,value:i}}else void 0===t[r.name]?"number"==typeof r.id?(t[r.name]={},t[r.name][r.id]=r):t[r.name]=r:"PoseNode"===r.name?(Array.isArray(t[r.name])||(t[r.name]=[t[r.name]]),t[r.name].push(r)):void 0===t[r.name][r.id]&&(t[r.name][r.id]=r)},parseProperty:function(e){var t=e.getString(1);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":var r=e.getUint32();return e.getArrayBuffer(r);case"S":r=e.getUint32();return e.getString(r);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var a=e.getUint32(),n=e.getUint32(),i=e.getUint32();if(0===n)switch(t){case"b":case"c":return e.getBooleanArray(a);case"d":return e.getFloat64Array(a);case"f":return e.getFloat32Array(a);case"i":return e.getInt32Array(a);case"l":return e.getInt64Array(a)}"undefined"==typeof fflate&&console.error("THREE.FBXLoader: External library fflate.min.js required.");var o=new l(fflate.unzlibSync(new Uint8Array(e.getArrayBuffer(i))).buffer);switch(t){case"b":case"c":return o.getBooleanArray(a);case"d":return o.getFloat64Array(a);case"f":return o.getFloat32Array(a);case"i":return o.getInt32Array(a);case"l":return o.getInt64Array(a)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}},l.prototype={constructor:l,getOffset:function(){return this.offset},size:function(){return this.dv.buffer.byteLength},skip:function(e){this.offset+=e},getBoolean:function(){return 1==(1&this.getUint8())},getBooleanArray:function(e){for(var t=[],r=0;r=0&&(t=t.slice(0,a)),THREE.LoaderUtils.decodeText(new Uint8Array(t))}},c.prototype={constructor:c,add:function(e,t){this[e]=t}};var f=[];function d(e,t,r,a){var n;switch(a.mappingType){case"ByPolygonVertex":n=e;break;case"ByPolygon":n=t;break;case"ByVertice":n=r;break;case"AllSame":n=a.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+a.mappingType)}"IndexToDirect"===a.referenceType&&(n=a.indices[n]);var i=n*a.dataSize,o=i+a.dataSize;return function(e,t,r,a){for(var n=r,i=0;n