EllipsoidGeometry-6c2860c7.js 6.5 KB

1
  1. define(["exports","./arrayFill-0358accf","./buildModuleUrl-3d15f25c","./Cartesian2-6033fa5d","./Cartographic-67e73ef9","./ComponentDatatype-81047f82","./when-92c6cf3c","./Check-52a7d806","./Rectangle-bab7abf0","./GeometryAttribute-ef657318","./GeometryAttributes-7f66ea53","./GeometryOffsetAttribute-b4d599f5","./IndexDatatype-4c0e98b8","./Math-92c3b5f7","./PrimitiveType-cdfe443e","./VertexFormat-f496a3f1"],(function(t,e,n,i,a,r,o,m,s,u,c,f,p,l,d,_){"use strict";var h=new a.t,v=new a.t,y=new a.t,w=new a.t,k=new a.t(1,1,1),C=Math.cos,b=Math.sin;function A(t){t=o.u(t,o.u.EMPTY_OBJECT);var e=o.u(t.radii,k),n=o.u(t.innerRadii,e),i=o.u(t.minimumClock,0),r=o.u(t.maximumClock,l.e.TWO_PI),s=o.u(t.minimumCone,0),u=o.u(t.maximumCone,l.e.PI),c=Math.round(o.u(t.stackPartitions,64)),f=Math.round(o.u(t.slicePartitions,64)),p=o.u(t.vertexFormat,_.n.DEFAULT);if(f<3)throw new m.t("options.slicePartitions cannot be less than three.");if(c<3)throw new m.t("options.stackPartitions cannot be less than three.");this._radii=a.t.clone(e),this._innerRadii=a.t.clone(n),this._minimumClock=i,this._maximumClock=r,this._minimumCone=s,this._maximumCone=u,this._stackPartitions=c,this._slicePartitions=f,this._vertexFormat=_.n.clone(p),this._offsetAttribute=t.offsetAttribute,this._workerName="createEllipsoidGeometry"}A.packedLength=2*a.t.packedLength+_.n.packedLength+7,A.pack=function(t,e,n){if(!o.e(t))throw new m.t("value is required");if(!o.e(e))throw new m.t("array is required");return n=o.u(n,0),a.t.pack(t._radii,e,n),n+=a.t.packedLength,a.t.pack(t._innerRadii,e,n),n+=a.t.packedLength,_.n.pack(t._vertexFormat,e,n),n+=_.n.packedLength,e[n++]=t._minimumClock,e[n++]=t._maximumClock,e[n++]=t._minimumCone,e[n++]=t._maximumCone,e[n++]=t._stackPartitions,e[n++]=t._slicePartitions,e[n]=o.u(t._offsetAttribute,-1),e};var x,P=new a.t,g=new a.t,F=new _.n,T={radii:P,innerRadii:g,vertexFormat:F,minimumClock:void 0,maximumClock:void 0,minimumCone:void 0,maximumCone:void 0,stackPartitions:void 0,slicePartitions:void 0,offsetAttribute:void 0};A.unpack=function(t,e,n){if(!o.e(t))throw new m.t("array is required");e=o.u(e,0);var i=a.t.unpack(t,e,P);e+=a.t.packedLength;var r=a.t.unpack(t,e,g);e+=a.t.packedLength;var s=_.n.unpack(t,e,F);e+=_.n.packedLength;var u=t[e++],c=t[e++],f=t[e++],p=t[e++],l=t[e++],d=t[e++],h=t[e];return o.e(n)?(n._radii=a.t.clone(i,n._radii),n._innerRadii=a.t.clone(r,n._innerRadii),n._vertexFormat=_.n.clone(s,n._vertexFormat),n._minimumClock=u,n._maximumClock=c,n._minimumCone=f,n._maximumCone=p,n._stackPartitions=l,n._slicePartitions=d,n._offsetAttribute=-1===h?void 0:h,n):(T.minimumClock=u,T.maximumClock=c,T.minimumCone=f,T.maximumCone=p,T.stackPartitions=l,T.slicePartitions=d,T.offsetAttribute=-1===h?void 0:h,new A(T))},A.createGeometry=function(t){var i=t._radii;if(!(i.x<=0||i.y<=0||i.z<=0)){var m=t._innerRadii;if(!(m.x<=0||m.y<=0||m.z<=0)){var _=t._minimumClock,k=t._maximumClock,A=t._minimumCone,x=t._maximumCone,P=t._vertexFormat,g=t._slicePartitions+1,F=t._stackPartitions+1;(g=Math.round(g*Math.abs(k-_)/l.e.TWO_PI))<2&&(g=2),(F=Math.round(F*Math.abs(x-A)/l.e.PI))<2&&(F=2);var T,D,I=0,L=[A],O=[_];for(T=0;T<F;T++)L.push(A+T*(x-A)/(F-1));for(L.push(x),D=0;D<g;D++)O.push(_+D*(k-_)/(g-1));O.push(k);var M=L.length,z=O.length,E=0,N=1,R=m.x!==i.x||m.y!==i.y||m.z!==i.z,G=!1,U=!1,S=!1;R&&(N=2,A>0&&(G=!0,E+=g-1),x<Math.PI&&(U=!0,E+=g-1),(k-_)%l.e.TWO_PI?(S=!0,E+=2*(F-1)+1):E+=1);var W=z*M*N,q=new Float64Array(3*W),B=e.d(new Array(W),!1),Y=e.d(new Array(W),!1),J=g*F*N,V=6*(J+E+1-(g+F)*N),X=p.IndexDatatype.createTypedArray(J,V),Z=P.normal?new Float32Array(3*W):void 0,j=P.tangent?new Float32Array(3*W):void 0,H=P.bitangent?new Float32Array(3*W):void 0,K=P.st?new Float32Array(2*W):void 0,Q=new Array(M),$=new Array(M);for(T=0;T<M;T++)Q[T]=b(L[T]),$[T]=C(L[T]);var tt=new Array(z),et=new Array(z);for(D=0;D<z;D++)et[D]=C(O[D]),tt[D]=b(O[D]);for(T=0;T<M;T++)for(D=0;D<z;D++)q[I++]=i.x*Q[T]*et[D],q[I++]=i.y*Q[T]*tt[D],q[I++]=i.z*$[T];var nt,it,at,rt,ot=W/2;if(R)for(T=0;T<M;T++)for(D=0;D<z;D++)q[I++]=m.x*Q[T]*et[D],q[I++]=m.y*Q[T]*tt[D],q[I++]=m.z*$[T],B[ot]=!0,T>0&&T!==M-1&&0!==D&&D!==z-1&&(Y[ot]=!0),ot++;for(I=0,T=1;T<M-2;T++)for(nt=T*z,it=(T+1)*z,D=1;D<z-2;D++)X[I++]=it+D,X[I++]=it+D+1,X[I++]=nt+D+1,X[I++]=it+D,X[I++]=nt+D+1,X[I++]=nt+D;if(R){var mt=M*z;for(T=1;T<M-2;T++)for(nt=mt+T*z,it=mt+(T+1)*z,D=1;D<z-2;D++)X[I++]=it+D,X[I++]=nt+D,X[I++]=nt+D+1,X[I++]=it+D,X[I++]=nt+D+1,X[I++]=it+D+1}if(R){if(G)for(rt=M*z,T=1;T<z-2;T++)X[I++]=T,X[I++]=T+1,X[I++]=rt+T+1,X[I++]=T,X[I++]=rt+T+1,X[I++]=rt+T;if(U)for(at=M*z-z,rt=M*z*N-z,T=1;T<z-2;T++)X[I++]=at+T+1,X[I++]=at+T,X[I++]=rt+T,X[I++]=at+T+1,X[I++]=rt+T,X[I++]=rt+T+1}if(S){for(T=1;T<M-2;T++)rt=z*M+z*T,at=z*T,X[I++]=rt,X[I++]=at+z,X[I++]=at,X[I++]=rt,X[I++]=rt+z,X[I++]=at+z;for(T=1;T<M-2;T++)rt=z*M+z*(T+1)-1,at=z*(T+1)-1,X[I++]=at+z,X[I++]=rt,X[I++]=at,X[I++]=at+z,X[I++]=rt+z,X[I++]=rt}var st=new c.a;P.position&&(st.position=new u.o({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:q}));var ut,ct=0,ft=0,pt=0,lt=0,dt=W/2,_t=s.t.fromCartesian3(i),ht=s.t.fromCartesian3(m);if(P.st||P.normal||P.tangent||P.bitangent){for(T=0;T<W;T++){ut=B[T]?ht:_t;var vt=a.t.fromArray(q,3*T,h),yt=ut.geodeticSurfaceNormal(vt,v);if(P.st){var wt=Math.atan2(yt.y,yt.x);wt<0&&(wt+=l.e.TWO_PI),K[ct++]=wt/l.e.TWO_PI,K[ct++]=Math.asin(yt.z)/Math.PI+.5}if(P.normal&&(Y[T]&&a.t.negate(yt,yt),Z[ft++]=yt.x,Z[ft++]=yt.y,Z[ft++]=yt.z),P.tangent||P.bitangent){var kt,Ct=y,bt=0;if(B[T]&&(bt=dt),kt=!G&&T>=bt&&T<bt+2*z?a.t.UNIT_X:a.t.UNIT_Z,a.t.cross(kt,yt,Ct),a.t.normalize(Ct,Ct),P.tangent&&(j[pt++]=Ct.x,j[pt++]=Ct.y,j[pt++]=Ct.z),P.bitangent){var At=a.t.cross(yt,Ct,w);a.t.normalize(At,At),H[lt++]=At.x,H[lt++]=At.y,H[lt++]=At.z}}}P.st&&(st.st=new u.o({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:K})),P.normal&&(st.normal=new u.o({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:Z})),P.tangent&&(st.tangent=new u.o({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:j})),P.bitangent&&(st.bitangent=new u.o({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:H}))}if(o.e(t._offsetAttribute)){var xt=q.length,Pt=new Uint8Array(xt/3),gt=t._offsetAttribute===f.z.NONE?0:1;e.d(Pt,gt),st.applyOffset=new u.o({componentDatatype:r.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:Pt})}return new u.I({attributes:st,indices:X,primitiveType:d._0x29ba75.TRIANGLES,boundingSphere:n.i.fromEllipsoid(_t),offsetAttribute:t._offsetAttribute})}}},A.getUnitEllipsoid=function(){return o.e(x)||(x=A.createGeometry(new A({radii:new a.t(1,1,1),vertexFormat:_.n.POSITION_ONLY}))),x},t.b=A}));