1 |
- !function(u,A,J){"use strict";var i="ht",K=u[i],z=null,o=Math,E=o.abs,x=o.max,_=Number.MAX_VALUE,f=K.Default,Y=f.getInternal(),H=f.clone,p=Y.vec3TransformMat4,v=Y.appendArray,t=function(){var V=/v( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/,Z=/vt( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/,y=/vn( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/,S=/f( +\d+)( +\d+)( +\d+)( +\d+)?/,r=/f( +(\d+)\/(\d+))( +(\d+)\/(\d+))( +(\d+)\/(\d+))( +(\d+)\/(\d+))?/,e=/f( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))?/,Q=/f( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))?/,n=function(j,J){return J=parseInt(J),J>=0?j[J-1]:j[J+j.length]},j=function(M,B,z,s,R,u){if(M.vs){var G=n(B,s),T=n(B,R),t=n(B,u),J=z.matrix,C=M.vs;if(z.flipFace){var i=T;T=t,t=i}J?(v(C,p(H(G),J)),v(C,p(H(T),J)),v(C,p(H(t),J))):(v(C,G),v(C,T),v(C,t))}},$=function(V,s,k,R,K,j){if(V.vs){var l=n(s,R),X=n(s,K),F=n(s,j),G=k.flipY;if(k.flipFace){var B=X;X=F,F=B}V.uv.push(l[0],G?1-l[1]:l[1],X[0],G?1-X[1]:X[1],F[0],G?1-F[1]:F[1])}},o=function(E,$,t,i,T,x){if(E.vs){var C=n($,i),k=n($,T),B=n($,x),h=t.normalMatrix,b=E.ns;if(t.flipFace){var P=k;k=B,B=P}h?(v(b,p(H(C),h)),v(b,p(H(k),h)),v(b,p(H(B),h))):(v(b,C),v(b,k),v(b,B))}},I=function(E,O,q,z,Y,Q,r,g){var w=z&&z.length&&g;Q[3]===J?(j(E,O,Y,Q[0],Q[1],Q[2]),r&&$(E,q,Y,r[0],r[1],r[2]),w&&o(E,z,Y,g[0],g[1],g[2])):(j(E,O,Y,Q[0],Q[1],Q[3]),j(E,O,Y,Q[1],Q[2],Q[3]),r&&($(E,q,Y,r[0],r[1],r[3]),$(E,q,Y,r[1],r[2],r[3])),w&&(o(E,z,Y,g[0],g[1],g[3]),o(E,z,Y,g[1],g[2],g[3])))},B=function(U,n,Y,s){var W,o,a,L,P,b,A,p=_,g=_,I=_,H=-_,V=-_,t=-_;for(W in U)for(b=U[W].vs,A=b.length,o=0;A>o;o+=3)a=b[o+0],L=b[o+1],P=b[o+2],p>a&&(p=a),g>L&&(g=L),I>P&&(I=P),a>H&&(H=a),L>V&&(V=L),P>t&&(t=P);if(Y){var j=p+(H-p)/2,M=g+(V-g)/2,J=I+(t-I)/2;for(W in U)for(b=U[W].vs,A=b.length,o=0;A>o;o+=3)b[o+0]-=j,b[o+1]-=M,b[o+2]-=J}var K,R,S;Y?(K=H-p,R=V-g,S=t-I):(K=2*x(E(p),E(H)),R=2*x(E(g),E(V)),S=2*x(E(I),E(t))),s.rawS3=[K,R,S];for(W in U){if(b=U[W].vs,n)for(A=b.length,o=0;A>o;o+=3)K&&(b[o+0]/=K),R&&(b[o+1]/=R),S&&(b[o+2]/=S);U[W].rawS3=s.rawS3}};return function(m,X,j){if(!m)return z;Y.isString(X)&&(X=b(X)),j||(j={}),j.flipY==z&&(j.flipY=!0),(j.s3||j.r3||j.t3||j.mat)&&(j.matrix=Y.createWorldMatrix(j.mat,j.s3,j.r3,j.rotationMode,j.t3));var T,A,$,a,g,N,W=[],p=[],O=j.ignoreNormal?z:[],c=j.reverseFlipMtls,q={vs:[],uv:[],ns:O?[]:z},s={htdefault:q},M=m.split("\n"),l=0;for(O&&j.matrix&&(j.normalMatrix=Y.createNormalMatrix(j.matrix));l<M.length;l++)if(A=M[l].trim(),0!==A.length&&"#"!==A.charAt(0))if($=V.exec(A))W.push([parseFloat($[1]),parseFloat($[2]),parseFloat($[3])]);else if($=Z.exec(A))p.push([parseFloat($[1]),parseFloat($[2])]);else if(O&&($=y.exec(A)))j.flipFace?O.push([parseFloat(-$[1]),parseFloat(-$[2]),parseFloat(-$[3])]):O.push([parseFloat($[1]),parseFloat($[2]),parseFloat($[3])]);else if($=S.exec(A))I(q,W,p,O,j,[$[1],$[2],$[3],$[4]]);else if($=r.exec(A))I(q,W,p,O,j,[$[2],$[5],$[8],$[11]],[$[3],$[6],$[9],$[12]]);else if($=e.exec(A))I(q,W,p,O,j,[$[2],$[6],$[10],$[14]],[$[3],$[7],$[11],$[15]],[$[4],$[8],$[12],$[16]]);else if($=Q.exec(A))I(q,W,p,O,j,[$[2],$[5],$[8],$[11]],z,[$[3],$[6],$[9],$[12]]);else if(/^usemtl /.test(A)&&(a=A.substring(7).trim(),!(q=s[a]))){if(q={name:a,vs:[],uv:[],ns:O?[]:z},j.ignoreMtls&&j.ignoreMtls.indexOf(a)>=0&&delete q.vs,(j.reverseFlip||"*"===c||c&&c.indexOf(a)>=0)&&(q.reverseFlip=!0),X&&(g=X[a],g&&(j.ignoreColor||(q.color=g.kd),!j.ignoreTransparent&&g.d>0&&g.d<1&&(q.transparent=!0,q.opacity=g.d),!j.ignoreImage&&(N=g.map_kd)))){for(N=N.split(" "),T=0;T<N.length;T++)"-o"===N[T]?(q.uvOffset=[parseFloat(N[T+1]),parseFloat(N[T+2])],T+=2):"-s"===N[T]&&(q.uvScale=[parseFloat(N[T+1]),parseFloat(N[T+2])],T+=2);q.image=(j.prefix||"")+N[N.length-1]}s[a]=q}var J=[];for(var h in s){var d=s[h].vs;d&&0!==d.length||J.push(h)}J.forEach(function(B){delete s[B]}),B(s,j.cube,j.center,j);var w=j.shape3d;if(w){var L=[];for(var a in s){var q=s[a];L.rawS3=q.rawS3,L.push(q)}f.setShape3dModel(w,L)}return s}}(),b=function(e){var l={};if(e)for(var s,_,T,I,B,u,p=e.split("\n"),j=/\s+/,t=0;t<p.length;t++)_=p[t].trim(),0!==_.length&&"#"!==_.charAt(0)&&(T=_.indexOf(" "),I=(T?_.substring(0,T):_).toLowerCase(),B=(T?_.substring(T+1):"").trim(),"newmtl"===I?l[B]=s={name:B}:s&&("ka"===I||"kd"===I||"ks"===I?(u=B.split(j,3),s[I]=[parseFloat(u[0]),parseFloat(u[1]),parseFloat(u[2]),1]):s[I]="ns"===I||"d"===I?parseFloat(B):B));return l};Y.addMethod(f,{loadObj:function(h,s,O){O=O||{},f.xhrLoad(s?[h,s]:[h],function(p){var j,v=O.finishFunc,M=O.shape3d,S=p?t(p[0],p[1],O):null;if(S){if(M)j=f.getShape3dModel(M);else{j=[];for(var Y in S){var z=S[Y];j.rawS3=z.rawS3,j.push(z)}}v&&v(S,j,j.rawS3)}else v&&v(null)},O)},parseObj:function(l,L,A){return t(l,L,A)}})}("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:this,Object);
|