!function(){if(void 0===THREE.SkinnedMeshEx){const e=new THREE.Vector3,t=new THREE.Vector4,r=new THREE.Vector4,n=new THREE.Vector3,o=(new THREE.Box3,new THREE.Matrix4);class s extends THREE.SkinnedMesh{constructor(e,t){super(e,t),this.isSkinnedMeshEx=!0,this.bindMatrixInverseReal=new THREE.Matrix4}computeBoundingBox(){const e=this.geometry;return null===this.boundingBox&&(this.boundingBox=new Box3),e.computeBoundingBox()}getBindMatrixInverse(){return this.bindMatrixInverseReal}copy(e){return super.copy(e),this.isSkinnedMeshEx=e.isSkinnedMeshEx,this.bindMatrixInverseReal.copy(e.bindMatrixInverseReal),this}bind(e,t){this.skeleton&&(this.skeleton.associatedSkinnedMesh=null),super.bind(e,t),this.bindMatrixInverseReal.copy(this.bindMatrix).invert(),this.skeleton.associatedSkinnedMesh=this}updateMatrixWorld(e){THREE.Mesh.prototype.updateMatrixWorld.call(this,e),"attached"===this.bindMode?(this.bindMatrixInverseReal.copy(this.matrixWorld).invert(),this.bindMatrixInverse.identity()):"detached"===this.bindMode?(this.bindMatrixInverse.copy(this.bindMatrix).invert(),this.bindMatrixInverseReal.copy(this.bindMatrix).invert()):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(s,a){const i=this.skeleton,l=this.geometry;t.fromBufferAttribute(l.attributes.skinIndex,s),r.fromBufferAttribute(l.attributes.skinWeight,s),e.fromBufferAttribute(l.attributes.position,s).applyMatrix4(this.bindMatrix),a.set(0,0,0);for(let s=0;s<4;s++){const l=r.getComponent(s);if(0!==l){const r=t.getComponent(s);o.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),a.addScaledVector(n.copy(e).applyMatrix4(o),l)}}return a.applyMatrix4(this.bindMatrixInverseReal)}}THREE.SkinnedMeshEx=s}if(void 0===THREE.SkeletonEx){const e=new THREE.Matrix4,t=new THREE.Matrix4;class r extends THREE.Skeleton{constructor(e=[],t=[]){super(e,t),this.associatedSkinnedMesh=null}clone(){return new r(this.bones,this.boneInverses)}getBindMatrixInverse(){return this.associatedSkinnedMesh?this.associatedSkinnedMesh.getBindMatrixInverse():void 0}update(){const r=this.bones,n=this.boneInverses,o=this.boneMatrices,s=this.boneTexture,a=this.getBindMatrixInverse();for(let s=0,i=r.length;s=r[n])return n-1;if(t<=r[e])return e;let o=e,s=n,a=Math.floor((o+s)/2);for(;t=r[a+1];)t=s&&(l[o][0]=l[t][0]/i[u+1][c],n=l[o][0]*i[c][u]);const p=e-1<=u?s-1:r-e;for(let e=c>=-1?1:-c;e<=p;++e)l[o][e]=(l[t][e]-l[t][e-1])/i[u+1][c+e],n+=l[o][e]*i[c+e][u];e<=u&&(l[o][s]=-l[t][s-1]/i[u+1][e],n+=l[o][s]*i[e][u]),a[s][e]=n;const h=t;t=o,o=h}}let u=r;for(let e=1;e<=n;++e){for(let t=0;t<=r;++t)a[e][t]*=u;u*=r-e}return a}(l,o,t,a,r),u=[];for(let e=0;e=t.length&&t===I(e,0,t.length)}(e))s=(new d).parse(e);else{const t=I(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let r=0;function n(t){const n=e[t-1];return e=e.slice(r+t),r++,n}for(let e=0;e=this.imageNum){const e=this.parseMaterials(this.textures),t=this.parseDeformers(),r=(new u).parse(t);this.parseScene(t,r,e),this.onLoad&&this.onLoad(i)}}parseConnections(){const e=new Map;if("Connections"in s){s.Connections.connections.forEach((function(t){const r=t[0],n=t[1],o=t[2];e.has(r)||e.set(r,{parents:[],children:[]});const s={ID:n,relationship:o};e.get(r).parents.push(s),e.has(n)||e.set(n,{parents:[],children:[]});const a={ID:r,relationship:o};e.get(n).children.push(a)}))}return e}parseImages(){const e={},t={};if(this.imageNum=0,"Video"in s.Objects){const r=s.Objects.Video;for(const n in r){const o=r[n];if(e[parseInt(n)]=o.RelativeFilename||o.Filename,"Content"in o){const e=o.Content instanceof ArrayBuffer&&o.Content.byteLength>0,s="string"==typeof o.Content&&""!==o.Content;if(e||s){const e=this.parseImage(r[n]);t[o.RelativeFilename||o.Filename]=e}}}}for(const r in e){const n=e[r];this.imageNum++,void 0!==t[n]?e[r]=t[n]:e[r]=e[r].split("\\").pop()}return e}parseImage(e){const t=e.Content,r=e.RelativeFilename||e.Filename,n=r.slice(r.lastIndexOf(".")+1).toLowerCase();let o;switch(n){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 ",r),o="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+n+'" 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){if(this.textures=new Map,"Texture"in s.Objects){const t=s.Objects.Texture;for(const r in t){const n=this.parseTexture(t[r],e);this.textures.set(parseInt(r),n)}}return this.textures}parseTexture(e,t){const r=this.loadTexture(e,t);if(!r)return r;r.ID=e.id,r.name=e.attrName;const n=e.WrapModeU,o=e.WrapModeV,s=void 0!==n?n.value:0,a=void 0!==o?o.value:0;if(r.wrapS=0===s?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,r.wrapT=0===a?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,"Scaling"in e){const t=e.Scaling.value;r.repeat.x=t[0],r.repeat.y=t[1]}if("Translation"in e){const t=e.Translation.value;r.offset.x=t[0],r.offset.y=t[1]}return r}loadTexture(e,t){let r;const n=this.textureLoader.path,o=a.get(e.id).children;let s;void 0!==o&&o.length>0&&void 0!==t[o[0].ID]&&(r=t[o[0].ID],0!==r.indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0));const i=e.FileName.slice(-3).toLowerCase();if("tga"===i){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),s=new THREE.Texture,s=null,this.onLoadTexture()):(t.setPath(this.textureLoader.path),s=t.load(r,(()=>{this.onLoadTexture()}),void 0,(()=>{this.textures.set(e.id,null),this.onLoadTexture()})))}else if("dds"===i){const t=this.manager.getHandler(".dds");null===t?(console.warn("FBXLoader: DDS loader not found, creating placeholder texture for",e.RelativeFilename),s=new THREE.Texture,s=null,this.onLoadTexture()):(t.setPath(this.textureLoader.path),s=t.load(r,(()=>{this.onLoadTexture()}),void 0,(()=>{this.textures.set(e.id,null),this.onLoadTexture()})))}else"psd"===i?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),s=new THREE.Texture,s=null,this.onLoadTexture()):s=this.textureLoader.load(r,(()=>{this.onLoadTexture()}),void 0,(()=>{this.textures.set(e.id,null),this.onLoadTexture()}));return this.textureLoader.setPath(n),s}parseMaterials(e){const t=new Map;if("Material"in s.Objects){const r=s.Objects.Material;for(const n in r){const o=this.parseMaterial(r[n],e);null!==o&&t.set(parseInt(n),o)}}return t}parseMaterial(e,t){const r=e.id,n=e.attrName;let o=e.ShadingModel;if("object"==typeof o&&(o=o.value),!a.has(r))return null;const s=this.parseParameters(e,t,r);let i;switch(o.toLowerCase()){case"phong":i=new THREE.MeshPhongMaterial;break;case"lambert":i=new THREE.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to THREE.MeshPhongMaterial.',o),i=new THREE.MeshPhongMaterial}return i.setValues(s),i.name=n,i}parseParameters(e,t,r){const n={};e.BumpFactor&&(n.bumpScale=e.BumpFactor.value),e.Diffuse?n.color=(new THREE.Color).fromArray(e.Diffuse.value).convertSRGBToLinear():!e.DiffuseColor||"THREE.Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(n.color=(new THREE.Color).fromArray(e.DiffuseColor.value).convertSRGBToLinear()),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=(new THREE.Color).fromArray(e.Emissive.value).convertSRGBToLinear():!e.EmissiveColor||"THREE.Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(n.emissive=(new THREE.Color).fromArray(e.EmissiveColor.value).convertSRGBToLinear()),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).convertSRGBToLinear():e.SpecularColor&&"THREE.Color"===e.SpecularColor.type&&(n.specular=(new THREE.Color).fromArray(e.SpecularColor.value).convertSRGBToLinear());const o=this;return a.get(r).children.forEach((function(e){const r=e.relationship;switch(r){case"Bump":n.bumpMap=o.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":n.aoMap=o.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":n.map=o.getTexture(t,e.ID),n.map&&(n.map.colorSpace=THREE.SRGBColorSpace);break;case"DisplacementColor":n.displacementMap=o.getTexture(t,e.ID);break;case"EmissiveColor":n.emissiveMap=o.getTexture(t,e.ID),n.emissiveMap&&(n.emissiveMap.colorSpace=THREE.SRGBColorSpace);break;case"NormalMap":case"Maya|TEX_normal_map":n.normalMap=o.getTexture(t,e.ID);break;case"ReflectionColor":n.envMap=o.getTexture(t,e.ID),n.envMap&&(n.envMap.mapping=THREE.EquirectangularReflectionMapping,n.envMap.colorSpace=THREE.SRGBColorSpace);break;case"SpecularColor":n.specularMap=o.getTexture(t,e.ID),n.specularMap&&(n.specularMap.colorSpace=THREE.SRGBColorSpace);break;case"TransparentColor":case"TransparencyFactor":n.alphaMap=o.getTexture(t,e.ID),n.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r)}})),n}getTexture(e,t){return"LayeredTexture"in s.Objects&&t in s.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=a.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in s.Objects){const r=s.Objects.Deformer;for(const n in r){const o=r[n],s=a.get(parseInt(n));if("Skin"===o.attrType){const t=this.parseSkeleton(s,r);t.ID=n,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[n]=t}else if("BlendShape"===o.attrType){const e={id:n};e.rawTargets=this.parseMorphTargets(s,r),e.id=n,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[n]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const r=[];return e.children.forEach((function(e){const n=t[e.ID];if("Cluster"!==n.attrType)return;const o={ID:e.ID,indices:[],weights:[],transformLink:(new THREE.Matrix4).fromArray(n.TransformLink.a)};"Indexes"in n&&(o.indices=n.Indexes.a,o.weights=n.Weights.a),r.push(o)})),{rawBones:r,bones:[]}}parseMorphTargets(e,t){const r=[];for(let n=0;n1?s=a:a.length>0?s=a[0]:(s=new THREE.MeshPhongMaterial({name:THREE.Loader.DEFAULT_MATERIAL_NAME,color:13421772}),a.push(s)),"color"in o.attributes&&a.forEach((function(e){e.vertexColors=!0})),o.FBX_Deformer?(n=new THREE.SkinnedMeshEx(o,s),n.normalizeSkinWeights()):n=new THREE.Mesh(o,s),n}createCurve(e,t){const r=e.children.reduce((function(e,r){return t.has(r.ID)&&(e=t.get(r.ID)),e}),null),n=new THREE.LineBasicMaterial({name:THREE.Loader.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new THREE.Line(r,n)}getTransformData(e,t){const r={};"InheritType"in t&&(r.inheritType=parseInt(t.InheritType.value)),r.eulerOrder="RotationOrder"in t?w(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(e,t){if("LookAtProperty"in t){a.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){const r=s.Objects.Model[t.ID];if("Lcl_Translation"in r){const t=r.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),i.add(e.target)):e.lookAt((new THREE.Vector3).fromArray(t))}}}))}}bindSkeleton(e,t,r){const n=this.parsePoseNodes();for(const o in e){const s=e[o];a.get(parseInt(s.ID)).parents.forEach((function(e){if(t.has(e.ID)){const t=e.ID;a.get(t).parents.forEach((function(e){if(r.has(e.ID)){r.get(e.ID).bind(new THREE.SkeletonEx(s.bones),n[e.ID])}}))}}))}}parsePoseNodes(){const e={};if("Pose"in s.Objects){const t=s.Objects.Pose;for(const r in t)if("BindPose"===t[r].attrType&&t[r].NbPoseNodes>0){const n=t[r].PoseNode;Array.isArray(n)?n.forEach((function(t){e[t.Node]=(new THREE.Matrix4).fromArray(t.Matrix.a)})):e[n.Node]=(new THREE.Matrix4).fromArray(n.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in s){if("AmbientColor"in s.GlobalSettings){const e=s.GlobalSettings.AmbientColor.value,t=e[0],r=e[1],n=e[2];if(0!==t||0!==r||0!==n){const e=new THREE.Color(t,r,n).convertSRGBToLinear();i.add(new THREE.AmbientLight(e,1))}}"UnitScaleFactor"in s.GlobalSettings&&(i.userData.unitScaleFactor=s.GlobalSettings.UnitScaleFactor.value)}}}class u{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in s.Objects){const r=s.Objects.Geometry;for(const n in r){const o=a.get(parseInt(n)),s=this.parseGeometry(o,r[n],e);t.set(parseInt(n),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,r){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,r);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,r){const n=r.skeletons,o=[],a=e.parents.map((function(e){return s.Objects.Model[e.ID]}));if(0===a.length)return;const i=e.children.reduce((function(e,t){return void 0!==n[t.ID]&&(e=n[t.ID]),e}),null);e.children.forEach((function(e){void 0!==r.morphTargets[e.ID]&&o.push(r.morphTargets[e.ID])}));const l=a[0],c={};"RotationOrder"in l&&(c.eulerOrder=w(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);const u=x(c);return this.genGeometry(t,i,o,u)}genGeometry(e,t,r,n){const o=new THREE.BufferGeometry;e.attrName&&(o.name=e.attrName);const s=this.parseGeoNode(e,t),a=this.genBuffers(s),i=new THREE.Float32BufferAttribute(a.vertex,3);if(i.applyMatrix4(n),o.setAttribute("position",i),a.colors.length>0&&o.setAttribute("color",new THREE.Float32BufferAttribute(a.colors,3)),t&&(o.setAttribute("skinIndex",new THREE.Uint16BufferAttribute(a.weightsIndices,4)),o.setAttribute("skinWeight",new THREE.Float32BufferAttribute(a.vertexWeights,4)),o.FBX_Deformer=t),a.normal.length>0){const e=(new THREE.Matrix3).getNormalMatrix(n),t=new THREE.Float32BufferAttribute(a.normal,3);t.applyNormalMatrix(e),o.setAttribute("normal",t)}if(a.uvs.forEach((function(e,t){const r=0===t?"uv":`uv${t}`;o.setAttribute(r,new THREE.Float32BufferAttribute(a.uvs[t],2))})),s.material&&"AllSame"!==s.material.mappingType){let e=a.materialIndex[0],t=0;if(a.materialIndex.forEach((function(r,n){r!==e&&(o.addGroup(t,n-t,e),e=r,t=n)})),o.groups.length>0){const t=o.groups[o.groups.length-1],r=t.start+t.count;r!==a.materialIndex.length&&o.addGroup(r,a.materialIndex.length-r,e)}0===o.groups.length&&o.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(o,e,r,n),o}parseGeoNode(e,t){const 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=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&r.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return r.weightTable={},null!==t&&(r.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(n,o){void 0===r.weightTable[n]&&(r.weightTable[n]=[]),r.weightTable[n].push({id:t,weight:e.weights[o]})}))}))),r}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let r=0,n=0,o=!1,s=[],a=[],i=[],l=[],c=[],u=[];const p=this;return e.vertexIndices.forEach((function(h,d){let f,m=!1;h<0&&(h^=-1,m=!0);let E=[],g=[];if(s.push(3*h,3*h+1,3*h+2),e.color){const t=v(d,r,h,e.color);i.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[h]&&e.weightTable[h].forEach((function(e){g.push(e.weight),E.push(e.id)})),g.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];g.forEach((function(r,n){let o=r,s=E[n];t.forEach((function(t,r,n){if(o>t){n[r]=o,o=t;const a=e[r];e[r]=s,s=a}}))})),E=e,g=t}for(;g.length<4;)g.push(0),E.push(0);for(let e=0;e<4;++e)c.push(g[e]),u.push(E[e])}if(e.normal){const t=v(d,r,h,e.normal);a.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=v(d,r,h,e.material)[0],f<0&&(p.negativeMaterialIndices=!0,f=0)),e.uv&&e.uv.forEach((function(e,t){const n=v(d,r,h,e);void 0===l[t]&&(l[t]=[]),l[t].push(n[0]),l[t].push(n[1])})),n++,m&&(p.genFace(t,e,s,f,a,i,l,c,u,n),r++,n=0,s=[],a=[],i=[],l=[],c=[],u=[])})),t}getNormalNewell(e){const t=new THREE.Vector3(0,0,0);for(let r=0;r.5?new THREE.Vector3(0,1,0):new THREE.Vector3(0,0,1)).cross(t).normalize(),n=t.clone().cross(r).normalize();return{normal:t,tangent:r,bitangent:n}}flattenVertex(e,t,r){return new THREE.Vector2(e.dot(t),e.dot(r))}genFace(e,t,r,n,o,s,a,i,l,c){let u;if(c>3){const e=[];for(let n=0;n1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=e.get(o[0].ID);r[n]={name:t[n].attrName,layer:s}}return r}addClip(e){let t=[];const r=this;return e.layer.forEach((function(e){t=t.concat(r.generateTracks(e))})),new THREE.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let r=new THREE.Vector3,n=new THREE.Quaternion,o=new THREE.Vector3;if(e.transform&&e.transform.decompose(r,new THREE.Quaternion,o),r=r.toArray(),n=(new THREE.Euler).setFromQuaternion(n,e.eulerOrder).toArray(),o=o.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.T.curves,r,"position");void 0!==n&&t.push(n)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const r=this.generateRotationTrack(e.modelName,e.R.curves,n,e.preRotation,e.postRotation,e.eulerOrder);void 0!==r&&t.push(r)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.S.curves,o,"scale");void 0!==r&&t.push(r)}if(void 0!==e.DeformPercent){const r=this.generateMorphTrack(e);void 0!==r&&t.push(r)}return t}generateVectorTrack(e,t,r,n){const o=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(o,t,r);return new THREE.VectorKeyframeTrack(e+"."+n,o,s)}generateRotationTrack(e,t,r,n,o,s){void 0!==t.x&&(this.interpolateRotations2(t.x),t.x.values=t.x.values.map(THREE.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations2(t.y),t.y.values=t.y.values.map(THREE.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations2(t.z),t.z.values=t.z.values.map(THREE.MathUtils.degToRad));const a=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(a,t,r);void 0!==n&&((n=n.map(THREE.MathUtils.degToRad)).push(s),n=(new THREE.Euler).fromArray(n),n=(new THREE.Quaternion).setFromEuler(n)),void 0!==o&&((o=o.map(THREE.MathUtils.degToRad)).push(s),o=(new THREE.Euler).fromArray(o),o=(new THREE.Quaternion).setFromEuler(o).invert());const l=new THREE.Quaternion,c=new THREE.Euler,u=[];for(let e=0;e1){let e=1,r=t[0];for(let n=1;n=180||h[1]>=180||h[2]>=180){const t=Math.max(...h)/180,r=new THREE.Euler(...l,n),i=new THREE.Euler(...u,n),c=(new THREE.Quaternion).setFromEuler(r),p=(new THREE.Quaternion).setFromEuler(i);c.dot(p)&&p.set(-p.x,-p.y,-p.z,-p.w);const d=e.times[a-1],f=e.times[a]-d,m=new THREE.Quaternion,E=new THREE.Euler;for(let e=0;e<1;e+=1/t)m.copy(c.clone().slerp(p.clone(),e)),o.push(d+e*f),E.setFromQuaternion(m,n),s.push(E.x),s.push(E.y),s.push(E.z)}else o.push(e.times[a]),s.push(THREE.MathUtils.degToRad(e.values[a])),s.push(THREE.MathUtils.degToRad(t.values[a])),s.push(THREE.MathUtils.degToRad(r.values[a]))}return[o,s]}interpolateRotations2(e){for(let t=1;t=180){const s=o/180,a=n/s;let i=r+a;const l=e.times[t-1],c=(e.times[t]-l)/s;let u=l+c;const p=[],h=[];for(;u1&&(r=e[1].replace(/^(\w+)::/,""),n=e[2]),{id:t,name:r,type:n}}parseNodeProperty(e,t,r){let n=t[1].replace(/^"/,"").replace(/"$/,"").trim(),o=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===n&&","===o&&(o=r.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===n){const e=o.split(",").slice(1),t=parseInt(e[0]),r=parseInt(e[1]);let a=o.split(",").slice(3);a=a.map((function(e){return e.trim().replace(/^"/,"")})),n="connections",o=[t,r],function(e,t){for(let r=0,n=e.length,o=t.length;r=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const r={},n=t>=7500?e.getUint64():e.getUint32(),o=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const s=e.getUint8(),a=e.getString(s);if(0===n)return null;const i=[];for(let t=0;t0?i[0]:"",c=i.length>1?i[1]:"",u=i.length>2?i[2]:"";for(r.singleProperty=1===o&&e.getOffset()===n;n>e.getOffset();){const n=this.parseNode(e,t);null!==n&&this.parseSubNode(a,r,n)}return r.propertyList=i,"number"==typeof l&&(r.id=l),""!==c&&(r.attrName=c),""!==u&&(r.attrType=u),""!==a&&(r.name=a),r}parseSubNode(e,t,r){if(!0===r.singleProperty){const e=r.propertyList[0];Array.isArray(e)?(t[r.name]=r,r.a=e):t[r.name]=e}else if("Connections"===e&&"C"===r.name){const e=[];r.propertyList.forEach((function(t,r){0!==r&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===r.name){Object.keys(r).forEach((function(e){t[e]=r[e]}))}else if("Properties70"===e&&"P"===r.name){let e=r.propertyList[0],n=r.propertyList[1];const o=r.propertyList[2],s=r.propertyList[3];let a;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===n.indexOf("Lcl ")&&(n=n.replace("Lcl ","Lcl_")),a="THREE.Color"===n||"ColorRGB"===n||"Vector"===n||"Vector3D"===n||0===n.indexOf("Lcl_")?[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:r.propertyList[4],t[e]={type:n,type2:o,flag:s,value:a}}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(e){const t=e.getString(1);let r;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 r=e.getUint32(),e.getArrayBuffer(r);case"S":return r=e.getUint32(),e.getString(r);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const n=e.getUint32(),o=e.getUint32(),s=e.getUint32();if(0===o)switch(t){case"b":case"c":return e.getBooleanArray(n);case"d":return e.getFloat64Array(n);case"f":return e.getFloat32Array(n);case"i":return e.getInt32Array(n);case"l":return e.getInt64Array(n)}const a=fflate.unzlibSync(new Uint8Array(e.getArrayBuffer(s))),i=new f(a.buffer);switch(t){case"b":case"c":return i.getBooleanArray(n);case"d":return i.getFloat64Array(n);case"f":return i.getFloat32Array(n);case"i":return i.getInt32Array(n);case"l":return i.getInt64Array(n)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class f{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==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let r=0;r=0&&(r=new Uint8Array(this.dv.buffer,t,n)),this._textDecoder.decode(r)}}class m{add(e,t){this[e]=t}}function E(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 g(e){return e/46186158e3}const T=[];function v(e,t,r,n){let o;switch(n.mappingType){case"ByPolygonVertex":o=e;break;case"ByPolygon":o=t;break;case"ByVertice":o=r;break;case"AllSame":o=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}"IndexToDirect"===n.referenceType&&(o=n.indices[o]);const s=o*n.dataSize,a=s+n.dataSize;return function(e,t,r,n){for(let o=r,s=0;o