Files
fad_oa/ruoyi-ui/public/file-viewer/assets/FBXLoader-Bj34Z_uf.js

1 line
44 KiB
JavaScript

import{$ as e,Bt as t,C as n,Ct as r,Dt as i,E as a,Et as o,Ft as s,Ht as c,K as l,Mt as u,Ot as d,Pt as f,Q as p,R as m,Rt as h,S as g,Vt as _,Z as v,_ as y,bt as b,dt as x,et as S,f as C,ht as w,m as T,n as E,nt as D,o as O,p as k,pt as A,q as ee,r as j,rt as M,u as N,ut as te,vt as P,w as F,wt as I,x as ne,yt as L,z as re,zt as ie}from"./three.module-BFsVh7r1.js";import{n as ae}from"./fflate.module-BIQmJeC9.js";function R(e,t,n){let r=n.length-e-1;if(t>=n[r])return r-1;if(t<=n[e])return e;let i=e,a=r,o=Math.floor((i+a)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?a=o:i=o,o=Math.floor((i+a)/2);return o}function oe(e,t,n,r){let i=[],a=[],o=[];i[0]=1;for(let s=1;s<=n;++s){a[s]=t-r[e+1-s],o[s]=r[e+s]-t;let n=0;for(let e=0;e<s;++e){let t=o[e+1],r=a[s-e],c=i[e]/(t+r);i[e]=n+t*c,n=r*c}i[s]=n}return i}function se(e,t,n,r){let i=R(e,r,t),a=oe(i,r,e,t),o=new _(0,0,0,0);for(let t=0;t<=e;++t){let r=n[i-e+t],s=a[t],c=r.w*s;o.x+=r.x*c,o.y+=r.y*c,o.z+=r.z*c,o.w+=r.w*s}return o}function ce(e,t,n,r,i){let a=[];for(let e=0;e<=n;++e)a[e]=0;let o=[];for(let e=0;e<=r;++e)o[e]=a.slice(0);let s=[];for(let e=0;e<=n;++e)s[e]=a.slice(0);s[0][0]=1;let c=a.slice(0),l=a.slice(0);for(let r=1;r<=n;++r){c[r]=t-i[e+1-r],l[r]=i[e+r]-t;let n=0;for(let e=0;e<r;++e){let t=l[e+1],i=c[r-e];s[r][e]=t+i;let a=s[e][r-1]/s[r][e];s[e][r]=n+t*a,n=i*a}s[r][r]=n}for(let e=0;e<=n;++e)o[0][e]=s[e][n];for(let e=0;e<=n;++e){let t=0,i=1,c=[];for(let e=0;e<=n;++e)c[e]=a.slice(0);c[0][0]=1;for(let a=1;a<=r;++a){let r=0,l=e-a,u=n-a;e>=a&&(c[i][0]=c[t][0]/s[u+1][l],r=c[i][0]*s[l][u]);let d=l>=-1?1:-l,f=e-1<=u?a-1:n-e;for(let e=d;e<=f;++e)c[i][e]=(c[t][e]-c[t][e-1])/s[u+1][l+e],r+=c[i][e]*s[l+e][u];e<=u&&(c[i][a]=-c[t][a-1]/s[u+1][e],r+=c[i][a]*s[e][u]),o[a][e]=r;let p=t;t=i,i=p}}let u=n;for(let e=1;e<=r;++e){for(let t=0;t<=n;++t)o[e][t]*=u;u*=n-e}return o}function le(e,t,n,r,i){let a=i<e?i:e,o=[],s=R(e,r,t),c=ce(s,r,e,a,t),l=[];for(let e=0;e<n.length;++e){let t=n[e].clone(),r=t.w;t.x*=r,t.y*=r,t.z*=r,l[e]=t}for(let t=0;t<=a;++t){let n=l[s-e].clone().multiplyScalar(c[t][0]);for(let r=1;r<=e;++r)n.add(l[s-e+r].clone().multiplyScalar(c[t][r]));o[t]=n}for(let e=a+1;e<=i+1;++e)o[e]=new _(0,0,0);return o}function ue(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let r=1;for(let e=2;e<=t;++e)r*=e;for(let n=2;n<=e-t;++n)r*=n;return n/r}function de(e){let n=e.length,r=[],i=[];for(let a=0;a<n;++a){let n=e[a];r[a]=new t(n.x,n.y,n.z),i[a]=n.w}let a=[];for(let e=0;e<n;++e){let t=r[e].clone();for(let n=1;n<=e;++n)t.sub(a[e-n].clone().multiplyScalar(ue(e,n)*i[n]));a[e]=t.divideScalar(i[0])}return a}function z(e,t,n,r,i){return de(le(e,t,n,r,i))}var B=class extends y{constructor(e,t,n,r,i){super();let a=t?t.length-1:0,o=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=i||a;for(let e=0;e<o;++e){let t=n[e];this.controlPoints[e]=new _(t.x,t.y,t.z,t.w)}}getPoint(e,n=new t){let r=n,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),a=se(this.degree,this.knots,this.controlPoints,i);return a.w!==1&&a.divideScalar(a.w),r.set(a.x,a.y,a.z)}getTangent(e,n=new t){let r=n,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),a=z(this.degree,this.knots,this.controlPoints,i,1);return r.copy(a[1]).normalize(),r}toJSON(){let e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(e=>e.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(e=>new _(e[0],e[1],e[2],e[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}},V,H,U,fe=class extends l{constructor(e){super(e)}load(e,t,r,i){let a=this,o=a.path===``?ee.extractUrlBase(e):a.path,s=new n(this.manager);s.setPath(a.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(a.requestHeader),s.setWithCredentials(a.withCredentials),s.load(e,function(n){try{t(a.parse(n,o))}catch(t){i?i(t):console.error(t),a.manager.itemError(e)}},r,i)}parse(e,t){if(ve(e))V=new _e().parse(e);else{let t=$(e);if(!ye(t))throw Error(`THREE.FBXLoader: Unknown format.`);if(K(t)<7e3)throw Error(`THREE.FBXLoader: FBX version not supported, FileVersion: `+K(t));V=new ge().parse(t)}return new pe(new s(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),this.manager).parse(V)}},pe=class{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){H=this.parseConnections();let e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),i=new me().parse(r);return this.parseScene(r,i,n),U}parseConnections(){let e=new Map;return`Connections`in V&&V.Connections.connections.forEach(function(t){let n=t[0],r=t[1],i=t[2];e.has(n)||e.set(n,{parents:[],children:[]});let a={ID:r,relationship:i};e.get(n).parents.push(a),e.has(r)||e.set(r,{parents:[],children:[]});let o={ID:n,relationship:i};e.get(r).children.push(o)}),e}parseImages(){let e={},t={};if(`Video`in V.Objects){let n=V.Objects.Video;for(let r in n){let i=n[r],a=parseInt(r);if(e[a]=i.RelativeFilename||i.Filename,`Content`in i){let e=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,a=typeof i.Content==`string`&&i.Content!==``;if(e||a){let e=this.parseImage(n[r]);t[i.RelativeFilename||i.Filename]=e}}}}for(let n in e){let r=e[n];t[r]===void 0?e[n]=e[n].split(`\\`).pop():e[n]=t[r]}return e}parseImage(e){let t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(`.`)+1).toLowerCase(),i;switch(r){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`:this.manager.getHandler(`.tga`)===null&&console.warn(`FBXLoader: TGA loader not found, skipping `,n),i=`image/tga`;break;case`webp`:i=`image/webp`;break;default:console.warn(`FBXLoader: Image type "`+r+`" is not supported.`);return}if(typeof t==`string`)return`data:`+i+`;base64,`+t;{let e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:i}))}}parseTextures(e){let t=new Map;if(`Texture`in V.Objects){let n=V.Objects.Texture;for(let r in n){let i=this.parseTexture(n[r],e);t.set(parseInt(r),i)}}return t}parseTexture(e,t){let n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;let i=e.WrapModeU,a=e.WrapModeV,o=i===void 0?0:i.value,s=a===void 0?0:a.value;if(n.wrapS=o===0?r:C,n.wrapT=s===0?r:C,`Scaling`in e){let t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if(`Translation`in e){let t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){let n=e.FileName.split(`.`).pop().toLowerCase(),r=this.manager.getHandler(`.${n}`);r===null&&(r=this.textureLoader);let i=r.path;i||r.setPath(this.textureLoader.path);let a=H.get(e.id).children,o;if(a!==void 0&&a.length>0&&t[a[0].ID]!==void 0&&(o=t[a[0].ID],(o.indexOf(`blob:`)===0||o.indexOf(`data:`)===0)&&r.setPath(void 0)),o===void 0)return console.warn(`FBXLoader: Undefined filename, creating placeholder texture.`),new f;let s=r.load(o);return r.setPath(i),s}parseMaterials(e){let t=new Map;if(`Material`in V.Objects){let n=V.Objects.Material;for(let r in n){let i=this.parseMaterial(n[r],e);i!==null&&t.set(parseInt(r),i)}}return t}parseMaterial(e,t){let n=e.id,r=e.attrName,i=e.ShadingModel;if(typeof i==`object`&&(i=i.value),!H.has(n))return null;let a=this.parseParameters(e,t,n),o;switch(i.toLowerCase()){case`phong`:o=new M;break;case`lambert`:o=new D;break;default:console.warn(`THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.`,i),o=new M;break}return o.setValues(a),o.name=r,o}parseParameters(e,t,n){let r={};e.BumpFactor&&(r.bumpScale=e.BumpFactor.value),e.Diffuse?r.color=T.colorSpaceToWorking(new k().fromArray(e.Diffuse.value),I):e.DiffuseColor&&(e.DiffuseColor.type===`Color`||e.DiffuseColor.type===`ColorRGB`)&&(r.color=T.colorSpaceToWorking(new k().fromArray(e.DiffuseColor.value),I)),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=T.colorSpaceToWorking(new k().fromArray(e.Emissive.value),I):e.EmissiveColor&&(e.EmissiveColor.type===`Color`||e.EmissiveColor.type===`ColorRGB`)&&(r.emissive=T.colorSpaceToWorking(new k().fromArray(e.EmissiveColor.value),I)),e.EmissiveFactor&&(r.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),r.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),(r.opacity===1||r.opacity===0)&&(r.opacity=e.Opacity?parseFloat(e.Opacity.value):null,r.opacity===null&&(r.opacity=1)),r.opacity<1&&(r.transparent=!0),e.ReflectionFactor&&(r.reflectivity=e.ReflectionFactor.value),e.Shininess&&(r.shininess=e.Shininess.value),e.Specular?r.specular=T.colorSpaceToWorking(new k().fromArray(e.Specular.value),I):e.SpecularColor&&e.SpecularColor.type===`Color`&&(r.specular=T.colorSpaceToWorking(new k().fromArray(e.SpecularColor.value),I));let i=this;return H.get(n).children.forEach(function(e){let n=e.relationship;switch(n){case`Bump`:r.bumpMap=i.getTexture(t,e.ID);break;case`Maya|TEX_ao_map`:r.aoMap=i.getTexture(t,e.ID);break;case`DiffuseColor`:case`Maya|TEX_color_map`:r.map=i.getTexture(t,e.ID),r.map!==void 0&&(r.map.colorSpace=I);break;case`DisplacementColor`:r.displacementMap=i.getTexture(t,e.ID);break;case`EmissiveColor`:r.emissiveMap=i.getTexture(t,e.ID),r.emissiveMap!==void 0&&(r.emissiveMap.colorSpace=I);break;case`NormalMap`:case`Maya|TEX_normal_map`:r.normalMap=i.getTexture(t,e.ID);break;case`ReflectionColor`:r.envMap=i.getTexture(t,e.ID),r.envMap!==void 0&&(r.envMap.mapping=303,r.envMap.colorSpace=I);break;case`SpecularColor`:r.specularMap=i.getTexture(t,e.ID),r.specularMap!==void 0&&(r.specularMap.colorSpace=I);break;case`TransparentColor`:case`TransparencyFactor`:r.alphaMap=i.getTexture(t,e.ID),r.transparent=!0;break;default:console.warn(`THREE.FBXLoader: %s map is not supported in three.js, skipping texture.`,n);break}}),r}getTexture(e,t){return`LayeredTexture`in V.Objects&&t in V.Objects.LayeredTexture&&(console.warn(`THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer.`),t=H.get(t).children[0].ID),e.get(t)}parseDeformers(){let e={},t={};if(`Deformer`in V.Objects){let n=V.Objects.Deformer;for(let r in n){let i=n[r],a=H.get(parseInt(r));if(i.attrType===`Skin`){let t=this.parseSkeleton(a,n);t.ID=r,a.parents.length>1&&console.warn(`THREE.FBXLoader: skeleton attached to more than one geometry is not supported.`),t.geometryID=a.parents[0].ID,e[r]=t}else if(i.attrType===`BlendShape`){let e={id:r};e.rawTargets=this.parseMorphTargets(a,n),e.id=r,a.parents.length>1&&console.warn(`THREE.FBXLoader: morph target attached to more than one geometry is not supported.`),t[r]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(t,n){let r=[];return t.children.forEach(function(t){let i=n[t.ID];if(i.attrType!==`Cluster`)return;let a={ID:t.ID,indices:[],weights:[],transformLink:new e().fromArray(i.TransformLink.a)};`Indexes`in i&&(a.indices=i.Indexes.a,a.weights=i.Weights.a),r.push(a)}),{rawBones:r,bones:[]}}parseMorphTargets(e,t){let n=[];for(let r=0;r<e.children.length;r++){let i=e.children[r],a=t[i.ID],o={name:a.attrName,initialWeight:a.DeformPercent,id:a.id,fullWeights:a.FullWeights.a};if(a.attrType!==`BlendShapeChannel`)return;o.geoID=H.get(parseInt(i.ID)).children.filter(function(e){return e.relationship===void 0})[0].ID,n.push(o)}return n}parseScene(t,n,r){U=new a;let i=this.parseModels(t.skeletons,n,r),o=V.Objects.Model,s=this;i.forEach(function(e){let t=o[e.ID];s.setLookAtProperties(e,t),H.get(e.ID).parents.forEach(function(t){let n=i.get(t.ID);n!==void 0&&n.add(e)}),e.parent===null&&U.add(e)}),this.addGlobalSceneSettings(),U.traverse(function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);let t=X(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}});let c=this.parsePoseNodes(),l=new Set;for(let e in t.skeletons)t.skeletons[e].rawBones.forEach(function(n,r){let i=t.skeletons[e].bones[r];i&&l.add(i.ID)});let u=new e;U.traverse(function(e){if(e.isBone&&e.ID!==void 0&&!l.has(e.ID)){let t=c[e.ID];t!==void 0&&(e.parent?(u.copy(e.parent.matrixWorld).invert(),u.multiply(t)):u.copy(t),u.decompose(e.position,e.quaternion,e.scale),e.updateMatrix(),e.matrixWorld.copy(t))}}),this.bindSkeleton(t.skeletons,n,i);let d=new he().parse();U.children.length===1&&U.children[0].isGroup&&(U.children[0].animations=d,U=U.children[0]),U.animations=d,`GlobalSettings`in V&&`UpAxis`in V.GlobalSettings&&V.GlobalSettings.UpAxis.value===2&&(console.warn(`THREE.FBXLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted.`),U.rotation.set(-Math.PI/2,0,0))}parseModels(e,t,n){let r=new Map,i=V.Objects.Model;for(let o in i){let s=parseInt(o),c=i[o],l=H.get(s),u=this.buildSkeleton(l,e,s,c.attrName);if(!u){switch(c.attrType){case`Camera`:u=this.createCamera(l);break;case`Light`:u=this.createLight(l);break;case`Mesh`:u=this.createMesh(l,t,n);break;case`NurbsCurve`:u=this.createCurve(l,t);break;case`LimbNode`:case`Root`:u=new O;break;default:u=new a;break}u.name=c.attrName?P.sanitizeNodeName(c.attrName):``,u.userData.originalName=c.attrName,u.ID=s}this.getTransformData(u,c),r.set(s,u)}return r}buildSkeleton(e,t,n,r){let i=null;return e.parents.forEach(function(e){for(let a in t){let o=t[a];o.rawBones.forEach(function(t,a){if(t.ID===e.ID){let e=i;i=new O,i.matrixWorld.copy(t.transformLink),i.name=r?P.sanitizeNodeName(r):``,i.userData.originalName=r,i.ID=n,o.bones[a]=i,e!==null&&i.add(e)}})}}),i}createCamera(e){let t,n;if(e.children.forEach(function(e){let t=V.Objects.NodeAttribute[e.ID];t!==void 0&&(n=t)}),n===void 0)t=new x;else{let e=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(e=1);let r=1;n.NearPlane!==void 0&&(r=n.NearPlane.value/1e3);let i=1e3;n.FarPlane!==void 0&&(i=n.FarPlane.value/1e3);let a=window.innerWidth,o=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(a=n.AspectWidth.value,o=n.AspectHeight.value);let s=a/o,c=45;n.FieldOfView!==void 0&&(c=n.FieldOfView.value);let l=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new A(c,s,r,i),l!==null&&t.setFocalLength(l);break;case 1:console.warn(`THREE.FBXLoader: Orthographic cameras not supported yet.`),t=new x;break;default:console.warn(`THREE.FBXLoader: Unknown camera type `+e+`.`),t=new x;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(e){let t=V.Objects.NodeAttribute[e.ID];t!==void 0&&(n=t)}),n===void 0)t=new x;else{let e;e=n.LightType===void 0?0:n.LightType.value;let r=16777215;n.Color!==void 0&&(r=T.colorSpaceToWorking(new k().fromArray(n.Color.value),I));let i=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(i=0);let a=0;switch(n.FarAttenuationEnd!==void 0&&(a=n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?0:n.FarAttenuationEnd.value),e){case 0:t=new w(r,i,a,1);break;case 1:t=new ne(r,i);break;case 2:let e=Math.PI/3,o=0;n.OuterAngle===void 0?n.InnerAngle!==void 0&&(e=v.degToRad(n.InnerAngle.value)):(e=v.degToRad(n.OuterAngle.value),n.InnerAngle!==void 0&&(o=1-n.InnerAngle.value/n.OuterAngle.value,o=Math.max(0,o))),t=new u(r,i,a,e,o,1);break;default:console.warn(`THREE.FBXLoader: Unknown light type `+n.LightType.value+`, defaulting to a PointLight.`),t=new w(r,i);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let r,i=null,a=null,o=[];if(e.children.forEach(function(e){t.has(e.ID)&&(i=t.get(e.ID)),n.has(e.ID)&&o.push(n.get(e.ID))}),o.length>1?a=o:o.length>0?a=o[0]:(a=new M({name:l.DEFAULT_MATERIAL_NAME,color:13421772}),o.push(a)),`color`in i.attributes&&o.forEach(function(e){e.vertexColors=!0}),i.groups.length>0){let e=!1;for(let t=0,n=i.groups.length;t<n;t++){let n=i.groups[t];(n.materialIndex<0||n.materialIndex>=o.length)&&(n.materialIndex=o.length,e=!0)}if(e){let e=new M;o.push(e)}}return i.FBX_Deformer?(r=new d(i,a),r.normalizeSkinWeights()):r=new S(i,a),r}createCurve(e,t){return new m(e.children.reduce(function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e},null),new re({name:l.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1}))}getTransformData(e,t){let n={};`InheritType`in t&&(n.inheritType=parseInt(t.InheritType.value)),`RotationOrder`in t?n.eulerOrder=Z(t.RotationOrder.value):n.eulerOrder=Z(0),`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,n){`LookAtProperty`in n&&H.get(e.ID).children.forEach(function(n){if(n.relationship===`LookAtProperty`){let r=V.Objects.Model[n.ID];if(`Lcl_Translation`in r){let n=r.Lcl_Translation.value;e.target===void 0?e.lookAt(new t().fromArray(n)):(e.target.position.fromArray(n),U.add(e.target))}}})}bindSkeleton(t,n,r){for(let a in t){let o=t[a],s=[];for(let t=0,n=o.bones.length;t<n;t++){let n=new e;o.bones[t]&&o.rawBones[t]&&n.copy(o.rawBones[t].transformLink).invert(),s.push(n)}H.get(parseInt(o.ID)).parents.forEach(function(e){if(n.has(e.ID)){let t=e.ID;H.get(t).parents.forEach(function(e){if(r.has(e.ID)){let t=r.get(e.ID);t.updateMatrixWorld(!0),t.bind(new i(o.bones,s),t.matrixWorld)}})}})}}parsePoseNodes(){let t={};if(`Pose`in V.Objects){let n=V.Objects.Pose;for(let r in n)if(n[r].attrType===`BindPose`&&n[r].NbPoseNodes>0){let i=n[r].PoseNode;Array.isArray(i)?i.forEach(function(n){t[n.Node]=new e().fromArray(n.Matrix.a)}):t[i.Node]=new e().fromArray(i.Matrix.a)}}return t}addGlobalSceneSettings(){if(`GlobalSettings`in V){if(`AmbientColor`in V.GlobalSettings){let e=V.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],r=e[2];if(t!==0||n!==0||r!==0){let e=new k().setRGB(t,n,r,I);U.add(new E(e,1))}}`UnitScaleFactor`in V.GlobalSettings&&(U.userData.unitScaleFactor=V.GlobalSettings.UnitScaleFactor.value)}}},me=class{constructor(){this.negativeMaterialIndices=!1}parse(e){let t=new Map;if(`Geometry`in V.Objects){let n=V.Objects.Geometry;for(let r in n){let i=H.get(parseInt(r)),a=this.parseGeometry(i,n[r],e);t.set(parseInt(r),a)}}return this.negativeMaterialIndices===!0&&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){let r=n.skeletons,i=[],a=e.parents.map(function(e){return V.Objects.Model[e.ID]});if(a.length===0)return;let o=e.children.reduce(function(e,t){return r[t.ID]!==void 0&&(e=r[t.ID]),e},null);e.children.forEach(function(e){n.morphTargets[e.ID]!==void 0&&i.push(n.morphTargets[e.ID])});let s=a[0],c={};`RotationOrder`in s&&(c.eulerOrder=Z(s.RotationOrder.value)),`InheritType`in s&&(c.inheritType=parseInt(s.InheritType.value)),`GeometricTranslation`in s&&(c.translation=s.GeometricTranslation.value),`GeometricRotation`in s&&(c.rotation=s.GeometricRotation.value),`GeometricScaling`in s&&(c.scale=s.GeometricScaling.value);let l=X(c);return this.genGeometry(t,o,i,l)}genGeometry(e,t,n,r){let i=new N;e.attrName&&(i.name=e.attrName);let a=this.parseGeoNode(e,t),o=this.genBuffers(a),s=new F(o.vertex,3);if(s.applyMatrix4(r),i.setAttribute(`position`,s),o.colors.length>0&&i.setAttribute(`color`,new F(o.colors,3)),t&&(i.setAttribute(`skinIndex`,new h(o.weightsIndices,4)),i.setAttribute(`skinWeight`,new F(o.vertexWeights,4)),i.FBX_Deformer=t),o.normal.length>0){let e=new p().getNormalMatrix(r),t=new F(o.normal,3);t.applyNormalMatrix(e),i.setAttribute(`normal`,t)}if(o.uvs.forEach(function(e,t){let n=t===0?`uv`:`uv${t}`;i.setAttribute(n,new F(o.uvs[t],2))}),a.material&&a.material.mappingType!==`AllSame`){let e=o.materialIndex[0],t=0;if(o.materialIndex.forEach(function(n,r){n!==e&&(i.addGroup(t,r-t,e),e=n,t=r)}),i.groups.length>0){let t=i.groups[i.groups.length-1],n=t.start+t.count;n!==o.materialIndex.length&&i.addGroup(n,o.materialIndex.length-n,e)}i.groups.length===0&&i.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(i,e,n,r),i}parseGeoNode(e,t){let n={};if(n.vertexPositions=e.Vertices===void 0?[]:e.Vertices.a,n.vertexIndices=e.PolygonVertexIndex===void 0?[]:e.PolygonVertexIndex.a,e.LayerElementColor&&e.LayerElementColor[0].Colors&&(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={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(r,i){n.weightTable[r]===void 0&&(n.weightTable[r]=[]),n.weightTable[r].push({id:t,weight:e.weights[i]})})})),n}genBuffers(e){let t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},n=0,r=0,i=!1,a=[],o=[],s=[],c=[],l=[],u=[],d=this;return e.vertexIndices.forEach(function(f,p){let m,h=!1;f<0&&(f^=-1,h=!0);let g=[],_=[];if(a.push(f*3,f*3+1,f*3+2),e.color){let t=q(p,n,f,e.color);s.push(t[0],t[1],t[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(e){_.push(e.weight),g.push(e.id)}),_.length>4){i||=(console.warn(`THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights.`),!0);let e=[0,0,0,0],t=[0,0,0,0];_.forEach(function(n,r){let i=n,a=g[r];t.forEach(function(t,n,r){if(i>t){r[n]=i,i=t;let o=e[n];e[n]=a,a=o}})}),g=e,_=t}for(;_.length<4;)_.push(0),g.push(0);for(let e=0;e<4;++e)l.push(_[e]),u.push(g[e])}if(e.normal){let t=q(p,n,f,e.normal);o.push(t[0],t[1],t[2])}e.material&&e.material.mappingType!==`AllSame`&&(m=q(p,n,f,e.material)[0],m<0&&(d.negativeMaterialIndices=!0,m=0)),e.uv&&e.uv.forEach(function(e,t){let r=q(p,n,f,e);c[t]===void 0&&(c[t]=[]),c[t].push(r[0]),c[t].push(r[1])}),r++,h&&(d.genFace(t,e,a,m,o,s,c,l,u,r),n++,r=0,a=[],o=[],s=[],c=[],l=[],u=[])}),t}getNormalNewell(e){let n=new t(0,0,0);for(let t=0;t<e.length;t++){let r=e[t],i=e[(t+1)%e.length];n.x+=(r.y-i.y)*(r.z+i.z),n.y+=(r.z-i.z)*(r.x+i.x),n.z+=(r.x-i.x)*(r.y+i.y)}return n.normalize(),n}getNormalTangentAndBitangent(e){let n=this.getNormalNewell(e),r=(Math.abs(n.z)>.5?new t(0,1,0):new t(0,0,1)).cross(n).normalize();return{normal:n,tangent:r,bitangent:n.clone().cross(r).normalize()}}flattenVertex(e,t,n){return new ie(e.dot(t),e.dot(n))}genFace(e,n,r,i,a,s,c,l,u,d){let f;if(d>3){let e=[],i=n.baseVertexPositions||n.vertexPositions;for(let n=0;n<r.length;n+=3)e.push(new t(i[r[n]],i[r[n+1]],i[r[n+2]]));let{tangent:a,bitangent:s}=this.getNormalTangentAndBitangent(e),c=[];for(let t of e)c.push(this.flattenVertex(t,a,s));f=o.triangulateShape(c,[])}else f=[[0,1,2]];for(let[t,o,d]of f)e.vertex.push(n.vertexPositions[r[t*3]]),e.vertex.push(n.vertexPositions[r[t*3+1]]),e.vertex.push(n.vertexPositions[r[t*3+2]]),e.vertex.push(n.vertexPositions[r[o*3]]),e.vertex.push(n.vertexPositions[r[o*3+1]]),e.vertex.push(n.vertexPositions[r[o*3+2]]),e.vertex.push(n.vertexPositions[r[d*3]]),e.vertex.push(n.vertexPositions[r[d*3+1]]),e.vertex.push(n.vertexPositions[r[d*3+2]]),n.skeleton&&(e.vertexWeights.push(l[t*4]),e.vertexWeights.push(l[t*4+1]),e.vertexWeights.push(l[t*4+2]),e.vertexWeights.push(l[t*4+3]),e.vertexWeights.push(l[o*4]),e.vertexWeights.push(l[o*4+1]),e.vertexWeights.push(l[o*4+2]),e.vertexWeights.push(l[o*4+3]),e.vertexWeights.push(l[d*4]),e.vertexWeights.push(l[d*4+1]),e.vertexWeights.push(l[d*4+2]),e.vertexWeights.push(l[d*4+3]),e.weightsIndices.push(u[t*4]),e.weightsIndices.push(u[t*4+1]),e.weightsIndices.push(u[t*4+2]),e.weightsIndices.push(u[t*4+3]),e.weightsIndices.push(u[o*4]),e.weightsIndices.push(u[o*4+1]),e.weightsIndices.push(u[o*4+2]),e.weightsIndices.push(u[o*4+3]),e.weightsIndices.push(u[d*4]),e.weightsIndices.push(u[d*4+1]),e.weightsIndices.push(u[d*4+2]),e.weightsIndices.push(u[d*4+3])),n.color&&(e.colors.push(s[t*3]),e.colors.push(s[t*3+1]),e.colors.push(s[t*3+2]),e.colors.push(s[o*3]),e.colors.push(s[o*3+1]),e.colors.push(s[o*3+2]),e.colors.push(s[d*3]),e.colors.push(s[d*3+1]),e.colors.push(s[d*3+2])),n.material&&n.material.mappingType!==`AllSame`&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),n.normal&&(e.normal.push(a[t*3]),e.normal.push(a[t*3+1]),e.normal.push(a[t*3+2]),e.normal.push(a[o*3]),e.normal.push(a[o*3+1]),e.normal.push(a[o*3+2]),e.normal.push(a[d*3]),e.normal.push(a[d*3+1]),e.normal.push(a[d*3+2])),n.uv&&n.uv.forEach(function(n,r){e.uvs[r]===void 0&&(e.uvs[r]=[]),e.uvs[r].push(c[r][t*2]),e.uvs[r].push(c[r][t*2+1]),e.uvs[r].push(c[r][o*2]),e.uvs[r].push(c[r][o*2+1]),e.uvs[r].push(c[r][d*2]),e.uvs[r].push(c[r][d*2+1])})}addMorphTargets(e,t,n,r){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];let i=r.clone().setPosition(0,0,0),a=this;n.forEach(function(n){n.rawTargets.forEach(function(n){let r=V.Objects.Geometry[n.geoID];r!==void 0&&a.genMorphGeometry(e,t,r,i,n.name)})})}genMorphGeometry(e,t,n,r,i){let a=t.Vertices===void 0?[]:t.Vertices.a,o=t.PolygonVertexIndex===void 0?[]:t.PolygonVertexIndex.a,s=n.Vertices===void 0?[]:n.Vertices.a,c=n.Indexes===void 0?[]:n.Indexes.a,l=e.attributes.position.count*3,u=new Float32Array(l);for(let e=0;e<c.length;e++){let t=c[e]*3;u[t]=s[e*3],u[t+1]=s[e*3+1],u[t+2]=s[e*3+2]}let d={vertexIndices:o,vertexPositions:u,baseVertexPositions:a},f=new F(this.genBuffers(d).vertex,3);f.name=i||n.attrName,f.applyMatrix4(r),e.morphAttributes.position.push(f)}parseNormals(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a,i=[];return n===`IndexToDirect`&&(`NormalIndex`in e?i=e.NormalIndex.a:`NormalsIndex`in e&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:i,mappingType:t,referenceType:n}}parseUVs(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a,i=[];return n===`IndexToDirect`&&(i=e.UVIndex.a),{dataSize:2,buffer:r,indices:i,mappingType:t,referenceType:n}}parseVertexColors(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a,i=[];n===`IndexToDirect`&&(i=e.ColorIndex.a);for(let e=0,t=new k;e<r.length;e+=4)t.fromArray(r,e),T.colorSpaceToWorking(t,I),t.toArray(r,e);return{dataSize:4,buffer:r,indices:i,mappingType:t,referenceType:n}}parseMaterialIndices(e){let t=e.MappingInformationType,n=e.ReferenceInformationType;if(t===`NoMappingInformation`)return{dataSize:1,buffer:[0],indices:[0],mappingType:`AllSame`,referenceType:n};let r=e.Materials.a,i=[];for(let e=0;e<r.length;++e)i.push(e);return{dataSize:1,buffer:r,indices:i,mappingType:t,referenceType:n}}parseNurbsGeometry(e){let t=parseInt(e.Order);if(isNaN(t))return console.error(`THREE.FBXLoader: Invalid Order %s given for geometry ID: %s`,e.Order,e.id),new N;let n=t-1,r=e.KnotVector.a,i=[],a=e.Points.a;for(let e=0,t=a.length;e<t;e+=4)i.push(new _().fromArray(a,e));let o,s;if(e.Form===`Closed`)i.push(i[0]);else if(e.Form===`Periodic`){o=n,s=r.length-1-o;for(let e=0;e<n;++e)i.push(i[e])}let c=new B(n,r,i,o,s).getPoints(i.length*12);return new N().setFromPoints(c)}},he=class{parse(){let e=[],t=this.parseClips();if(t!==void 0)for(let n in t){let r=t[n],i=this.addClip(r);e.push(i)}return e}parseClips(){if(V.Objects.AnimationCurve===void 0)return;let e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);let t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){let e=V.Objects.AnimationCurveNode,t=new Map;for(let n in e){let r=e[n];if(r.attrName.match(/S|R|T|DeformPercent/)!==null){let e={id:r.id,attr:r.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){let t=V.Objects.AnimationCurve;for(let n in t){let r={id:t[n].id,times:t[n].KeyTime.a.map(be),values:t[n].KeyValueFloat.a},i=H.get(r.id);if(i!==void 0){let t=i.parents[0].ID,n=i.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=r:n.match(/Y/)?e.get(t).curves.y=r:n.match(/Z/)?e.get(t).curves.z=r:n.match(/DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=r)}}}parseAnimationLayers(t){let n=V.Objects.AnimationLayer,r=new Map;for(let i in n){let n=[],a=H.get(parseInt(i));a!==void 0&&(a.children.forEach(function(r,i){if(t.has(r.ID)){let a=t.get(r.ID);if(a.curves.x!==void 0||a.curves.y!==void 0||a.curves.z!==void 0){if(n[i]===void 0){let t=H.get(r.ID).parents.filter(function(e){return e.relationship!==void 0});if(t.length===0)return;let a=t[0].ID;if(a!==void 0){let t=V.Objects.Model[a.toString()];if(t===void 0){console.warn(`THREE.FBXLoader: Encountered a unused curve.`,r);return}let o={modelName:t.attrName?P.sanitizeNodeName(t.attrName):``,ID:t.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};U.traverse(function(e){e.ID===t.id&&(o.transform=e.matrix,e.userData.transformData&&(o.eulerOrder=e.userData.transformData.eulerOrder,e.userData.transformData.rotation&&(o.initialRotation=e.userData.transformData.rotation)))}),o.transform||=new e,`PreRotation`in t&&(o.preRotation=t.PreRotation.value),`PostRotation`in t&&(o.postRotation=t.PostRotation.value),n[i]=o}}n[i]&&(n[i][a.attr]=a)}else if(a.curves.morph!==void 0){if(n[i]===void 0){let e=H.get(r.ID).parents.filter(function(e){return e.relationship!==void 0});if(e.length===0)return;let t=e[0].ID,a=H.get(t).parents[0].ID,o=H.get(a).parents[0].ID,s=H.get(o).parents[0].ID,c=V.Objects.Model[s];n[i]={modelName:c.attrName?P.sanitizeNodeName(c.attrName):``,morphName:V.Objects.Deformer[t].attrName}}n[i][a.attr]=a}}}),r.set(parseInt(i),n))}return r}parseAnimStacks(e){let t=V.Objects.AnimationStack,n={};for(let r in t){let i=H.get(parseInt(r)).children;i.length>1&&console.warn(`THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.`);let a=e.get(i[0].ID);n[r]={name:t[r].attrName,layer:a}}return n}addClip(e){let t=[],n=this;return e.layer.forEach(function(e){t=t.concat(n.generateTracks(e))}),new j(e.name,-1,t)}generateTracks(e){let n=[],r=new t,i=new t;if(e.transform&&e.transform.decompose(r,new L,i),r=r.toArray(),i=i.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){let t=this.generateVectorTrack(e.modelName,e.T.curves,r,`position`);t!==void 0&&n.push(t)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){let t=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder,e.initialRotation);t!==void 0&&n.push(t)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){let t=this.generateVectorTrack(e.modelName,e.S.curves,i,`scale`);t!==void 0&&n.push(t)}if(e.DeformPercent!==void 0){let t=this.generateMorphTrack(e);t!==void 0&&n.push(t)}return n}generateVectorTrack(e,t,n,r){let i=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(i,t,n);return new c(e+`.`+r,i,a)}generateRotationTrack(e,t,n,r,i,a){let o,s;if(t.x!==void 0||t.y!==void 0||t.z!==void 0){let e=this.getTimesForAllAxes(t);if(e.length>0){let n=a||[0,0,0],r=this.synchronizeCurve(t.x,e,n[0]),c=this.synchronizeCurve(t.y,e,n[1]),l=this.synchronizeCurve(t.z,e,n[2]),u=this.interpolateRotations(r,c,l,i);o=u[0],s=u[1]}}let c=Z(0);n!==void 0&&(n=n.map(v.degToRad),n.push(c),n=new g().fromArray(n),n=new L().setFromEuler(n)),r!==void 0&&(r=r.map(v.degToRad),r.push(c),r=new g().fromArray(r),r=new L().setFromEuler(r).invert());let l=new L,u=new g,d=[];if(!(!s||!o)){for(let e=0;e<s.length;e+=3)u.set(s[e],s[e+1],s[e+2],i),l.setFromEuler(u),n!==void 0&&l.premultiply(n),r!==void 0&&l.multiply(r),e>2&&new L().fromArray(d,(e-3)/3*4).dot(l)<0&&l.set(-l.x,-l.y,-l.z,-l.w),l.toArray(d,e/3*4);return new b(e+`.quaternion`,o,d)}}generateMorphTrack(e){let t=e.DeformPercent.curves.morph,n=t.values.map(function(e){return e/100}),r=U.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new te(e.modelName+`.morphTargetInfluences[`+r+`]`,t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(e,t){return e-t}),t.length>1){let e=1,n=t[0];for(let r=1;r<t.length;r++){let i=t[r];i!==n&&(t[e]=i,n=i,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){let r=n,i=[],a=-1,o=-1,s=-1;return e.forEach(function(e){if(t.x&&(a=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(s=t.z.times.indexOf(e)),a!==-1){let e=t.x.values[a];i.push(e),r[0]=e}else i.push(r[0]);if(o!==-1){let e=t.y.values[o];i.push(e),r[1]=e}else i.push(r[1]);if(s!==-1){let e=t.z.values[s];i.push(e),r[2]=e}else i.push(r[2])}),i}synchronizeCurve(e,t,n){if(e===void 0)return{times:t,values:t.map(()=>n)};if(e.times.length===t.length)return e;let r=[];for(let i=0;i<t.length;i++)r.push(this.sampleCurveValue(e,t[i],n));return{times:t,values:r}}sampleCurveValue(e,t,n){let r=e.times,i=e.values;if(t<=r[0])return i[0];if(t>=r[r.length-1])return i[i.length-1];for(let e=0;e<r.length-1;e++)if(t>=r[e]&&t<=r[e+1]){if(r[e]===t)return i[e];let n=(t-r[e])/(r[e+1]-r[e]);return i[e]*(1-n)+i[e+1]*n}return n}interpolateRotations(e,t,n,r){let i=[],a=[];i.push(e.times[0]),a.push(v.degToRad(e.values[0])),a.push(v.degToRad(t.values[0])),a.push(v.degToRad(n.values[0]));for(let o=1;o<e.values.length;o++){let s=[e.values[o-1],t.values[o-1],n.values[o-1]];if(isNaN(s[0])||isNaN(s[1])||isNaN(s[2]))continue;let c=s.map(v.degToRad),l=[e.values[o],t.values[o],n.values[o]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;let u=l.map(v.degToRad),d=[l[0]-s[0],l[1]-s[1],l[2]-s[2]],f=[Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2])];if(f[0]>=180||f[1]>=180||f[2]>=180){let t=Math.max(...f)/180,n=new g(...c,r),s=new g(...u,r),l=new L().setFromEuler(n),d=new L().setFromEuler(s);l.dot(d)<0&&d.set(-d.x,-d.y,-d.z,-d.w);let p=e.times[o-1],m=e.times[o]-p,h=new L,_=new g;for(let e=0;e<1;e+=1/t)h.copy(l.clone().slerp(d.clone(),e)),i.push(p+e*m),_.setFromQuaternion(h,r),a.push(_.x),a.push(_.y),a.push(_.z)}else i.push(e.times[o]),a.push(v.degToRad(e.values[o])),a.push(v.degToRad(t.values[o])),a.push(v.degToRad(n.values[o]))}return[i,a]}},ge=class{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}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new G,this.nodeStack=[],this.currentProp=[],this.currentPropName=``;let t=this,n=e.split(/[\r\n]+/);return n.forEach(function(e,r){let i=e.match(/^[\s\t]*;/),a=e.match(/^[\s\t]*$/);if(i||a)return;let o=e.match(`^\\t{`+t.currentIndent+`}(\\w+):(.*){`,``),s=e.match(`^\\t{`+t.currentIndent+`}(\\w+):[\\s\\t\\r\\n](.*)`),c=e.match(`^\\t{`+(t.currentIndent-1)+`}}`);o?t.parseNodeBegin(e,o):s?t.parseNodeProperty(e,s,n[++r]):c?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}),this.allNodes}parseNodeBegin(e,t){let n=t[1].trim().replace(/^"/,``).replace(/"$/,``),r=t[2].split(`,`).map(function(e){return e.trim().replace(/^"/,``).replace(/"$/,``)}),i={name:n},a=this.parseNodeAttr(r),o=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,i):n in o?(n===`PoseNode`?o.PoseNode.push(i):o[n].id!==void 0&&(o[n]={},o[n][o[n].id]=o[n]),a.id!==``&&(o[n][a.id]=i)):typeof a.id==`number`?(o[n]={},o[n][a.id]=i):n!==`Properties70`&&(n===`PoseNode`?o[n]=[i]:o[n]=i),typeof a.id==`number`&&(i.id=a.id),a.name!==``&&(i.attrName=a.name),a.type!==``&&(i.attrType=a.type),this.pushStack(i)}parseNodeAttr(e){let t=e[0];e[0]!==``&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n=``,r=``;return e.length>1&&(n=e[1].replace(/^(\w+)::/,``),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,``).replace(/"$/,``).trim(),i=t[2].replace(/^"/,``).replace(/"$/,``).trim();r===`Content`&&i===`,`&&(i=n.replace(/"/g,``).replace(/,$/,``).trim());let a=this.getCurrentNode();if(a.name===`Properties70`){this.parseNodeSpecialProperty(e,r,i);return}if(r===`C`){let e=i.split(`,`).slice(1),t=parseInt(e[0]),n=parseInt(e[1]),o=i.split(`,`).slice(3);o=o.map(function(e){return e.trim().replace(/^"/,``)}),r=`connections`,i=[t,n],Se(i,o),a[r]===void 0&&(a[r]=[])}r===`Node`&&(a.id=i),r in a&&Array.isArray(a[r])?a[r].push(i):r===`a`?a.a=i:a[r]=i,this.setCurrentProp(a,r),r===`a`&&i.slice(-1)!==`,`&&(a.a=Q(i))}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,e.slice(-1)!==`,`&&(t.a=Q(t.a))}parseNodeSpecialProperty(e,t,n){let r=n.split(`",`).map(function(e){return e.trim().replace(/^\"/,``).replace(/\s/,`_`)}),i=r[0],a=r[1],o=r[2],s=r[3],c=r[4];switch(a){case`int`:case`enum`:case`bool`:case`ULongLong`:case`double`:case`Number`:case`FieldOfView`:c=parseFloat(c);break;case`Color`:case`ColorRGB`:case`Vector3D`:case`Lcl_Translation`:case`Lcl_Rotation`:case`Lcl_Scaling`:c=Q(c);break}this.getPrevNode()[i]={type:a,type2:o,flag:s,value:c},this.setCurrentProp(this.getPrevNode(),i)}},_e=class{parse(e){let t=new W(e);t.skip(23);let n=t.getUint32();if(n<6400)throw Error(`THREE.FBXLoader: FBX version not supported, FileVersion: `+n);let r=new G;for(;!this.endOfContent(t);){let e=this.parseNode(t,n);e!==null&&r.add(e.name,e)}return r}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){let n={},r=t>=7500?e.getUint64():e.getUint32(),i=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();let a=e.getUint8(),o=e.getString(a);if(r===0)return null;let s=[];for(let t=0;t<i;t++)s.push(this.parseProperty(e));let c=s.length>0?s[0]:``,l=s.length>1?s[1]:``,u=s.length>2?s[2]:``;for(n.singleProperty=i===1&&e.getOffset()===r;r>e.getOffset();){let r=this.parseNode(e,t);r!==null&&this.parseSubNode(o,n,r)}return n.propertyList=s,typeof c==`number`&&(n.id=c),l!==``&&(n.attrName=l),u!==``&&(n.attrType=u),o!==``&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){let e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if(e===`Connections`&&n.name===`C`){let e=[];n.propertyList.forEach(function(t,n){n!==0&&e.push(t)}),t.connections===void 0&&(t.connections=[]),t.connections.push(e)}else if(n.name===`Properties70`)Object.keys(n).forEach(function(e){t[e]=n[e]});else if(e===`Properties70`&&n.name===`P`){let e=n.propertyList[0],r=n.propertyList[1],i=n.propertyList[2],a=n.propertyList[3],o;e.indexOf(`Lcl `)===0&&(e=e.replace(`Lcl `,`Lcl_`)),r.indexOf(`Lcl `)===0&&(r=r.replace(`Lcl `,`Lcl_`)),o=r===`Color`||r===`ColorRGB`||r===`Vector`||r===`Vector3D`||r.indexOf(`Lcl_`)===0?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:r,type2:i,flag:a,value:o}}else t[n.name]===void 0?typeof n.id==`number`?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name===`PoseNode`?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){let t=e.getString(1),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`:let r=e.getUint32(),i=e.getUint32(),a=e.getUint32();if(i===0)switch(t){case`b`:case`c`:return e.getBooleanArray(r);case`d`:return e.getFloat64Array(r);case`f`:return e.getFloat32Array(r);case`i`:return e.getInt32Array(r);case`l`:return e.getInt64Array(r)}let o=new W(ae(new Uint8Array(e.getArrayBuffer(a))).buffer);switch(t){case`b`:case`c`:return o.getBooleanArray(r);case`d`:return o.getFloat64Array(r);case`f`:return o.getFloat32Array(r);case`i`:return o.getInt32Array(r);case`l`:return o.getInt64Array(r)}break;default:throw Error(`THREE.FBXLoader: Unknown property type `+t)}}},W=class{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t===void 0?!0:t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)==1}getBooleanArray(e){let t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){let e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){let e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){let e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){let e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){let e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){let e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){let t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=this.offset,n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);let r=n.indexOf(0);return r>=0&&(n=new Uint8Array(this.dv.buffer,t,r)),this._textDecoder.decode(n)}},G=class{add(e,t){this[e]=t}};function ve(e){return e.byteLength>=21&&$(e,0,21)===`Kaydara FBX Binary \0`}function ye(e){let t=[`K`,`a`,`y`,`d`,`a`,`r`,`a`,`\\`,`F`,`B`,`X`,`\\`,`B`,`i`,`n`,`a`,`r`,`y`,`\\`,`\\`],n=0;function r(t){let r=e[t-1];return e=e.slice(n+t),n++,r}for(let e=0;e<t.length;++e)if(r(1)===t[e])return!1;return!0}function K(e){let t=e.match(/FBXVersion: (\d+)/);if(t)return parseInt(t[1]);throw Error(`THREE.FBXLoader: Cannot find the version number for the file given.`)}function be(e){return e/46186158e3}var xe=[];function q(e,t,n,r){let i;switch(r.mappingType){case`ByPolygonVertex`:i=e;break;case`ByPolygon`:i=t;break;case`ByVertice`:i=n;break;case`AllSame`:i=r.indices[0];break;default:console.warn(`THREE.FBXLoader: unknown attribute mapping type `+r.mappingType)}r.referenceType===`IndexToDirect`&&(i=r.indices[i]);let a=i*r.dataSize,o=a+r.dataSize;return Ce(xe,r.buffer,a,o)}var J=new g,Y=new t;function X(n){let r=new e,i=new e,a=new e,o=new e,s=new e,c=new e,l=new e,u=new e,d=new e,f=new e,p=new e,m=new e,h=n.inheritType?n.inheritType:0;n.translation&&r.setPosition(Y.fromArray(n.translation));let g=Z(0);if(n.preRotation){let e=n.preRotation.map(v.degToRad);e.push(g),i.makeRotationFromEuler(J.fromArray(e))}if(n.rotation){let e=n.rotation.map(v.degToRad);e.push(n.eulerOrder||g),a.makeRotationFromEuler(J.fromArray(e))}if(n.postRotation){let e=n.postRotation.map(v.degToRad);e.push(g),o.makeRotationFromEuler(J.fromArray(e)),o.invert()}n.scale&&s.scale(Y.fromArray(n.scale)),n.scalingOffset&&l.setPosition(Y.fromArray(n.scalingOffset)),n.scalingPivot&&c.setPosition(Y.fromArray(n.scalingPivot)),n.rotationOffset&&u.setPosition(Y.fromArray(n.rotationOffset)),n.rotationPivot&&d.setPosition(Y.fromArray(n.rotationPivot)),n.parentMatrixWorld&&(p.copy(n.parentMatrix),f.copy(n.parentMatrixWorld));let _=i.clone().multiply(a).multiply(o),y=new e;y.extractRotation(f);let b=new e;b.copyPosition(f);let x=b.clone().invert().multiply(f),S=y.clone().invert().multiply(x),C=s,w=new e;if(h===0)w.copy(y).multiply(_).multiply(S).multiply(C);else if(h===1)w.copy(y).multiply(S).multiply(_).multiply(C);else{let n=new e().scale(new t().setFromMatrixScale(p)).clone().invert(),r=S.clone().multiply(n);w.copy(y).multiply(_).multiply(r).multiply(C)}let T=d.clone().invert(),E=c.clone().invert(),D=r.clone().multiply(u).multiply(d).multiply(i).multiply(a).multiply(o).multiply(T).multiply(l).multiply(c).multiply(s).multiply(E),O=new e().copyPosition(D),k=f.clone().multiply(O);return m.copyPosition(k),D=m.clone().multiply(w),D.premultiply(f.invert()),D}function Z(e){e||=0;let t=[`ZYX`,`YZX`,`XZY`,`ZXY`,`YXZ`,`XYZ`];return e===6?(console.warn(`THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect.`),t[0]):t[e]}function Q(e){return e.split(`,`).map(function(e){return parseFloat(e)})}function $(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=e.byteLength),new TextDecoder().decode(new Uint8Array(e,t,n))}function Se(e,t){for(let n=0,r=e.length,i=t.length;n<i;n++,r++)e[r]=t[n]}function Ce(e,t,n,r){for(let i=n,a=0;i<r;i++,a++)e[a]=t[i];return e}export{fe as FBXLoader};