2 lines
7.4 KiB
JavaScript
2 lines
7.4 KiB
JavaScript
/* 2020-9-22 15:23:25 | 版权所有 军懋国兴 */
|
|
define(["exports","./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./Cartesian2-43e3a3be","./Transforms-2d1ac5ec","./ComponentDatatype-607c9a0c","./GeometryAttribute-2303bbfb","./GeometryAttributes-90846c5f","./IndexDatatype-79bb407c","./GeometryOffsetAttribute-9c676324","./VertexFormat-fe64931e"],function(e,ue,d,le,ce,fe,de,pe,Ce,ye,he,p){"use strict";var _e=new ce.Cartesian3,ve=new ce.Cartesian3,Ae=new ce.Cartesian3,be=new ce.Cartesian3,xe=new ce.Cartesian3,l=new ce.Cartesian3(1,1,1),we=Math.cos,ke=Math.sin;function C(e){e=ue.defaultValue(e,ue.defaultValue.EMPTY_OBJECT);var t=ue.defaultValue(e.radii,l),a=ue.defaultValue(e.innerRadii,t),r=ue.defaultValue(e.minimumClock,0),i=ue.defaultValue(e.maximumClock,le.CesiumMath.TWO_PI),n=ue.defaultValue(e.minimumCone,0),o=ue.defaultValue(e.maximumCone,le.CesiumMath.PI),m=Math.round(ue.defaultValue(e.stackPartitions,64)),s=Math.round(ue.defaultValue(e.slicePartitions,64)),u=ue.defaultValue(e.vertexFormat,p.VertexFormat.DEFAULT);if(s<3)throw new d.DeveloperError("options.slicePartitions cannot be less than three.");if(m<3)throw new d.DeveloperError("options.stackPartitions cannot be less than three.");this._radii=ce.Cartesian3.clone(t),this._innerRadii=ce.Cartesian3.clone(a),this._minimumClock=r,this._maximumClock=i,this._minimumCone=n,this._maximumCone=o,this._stackPartitions=m,this._slicePartitions=s,this._vertexFormat=p.VertexFormat.clone(u),this._offsetAttribute=e.offsetAttribute,this._workerName="createEllipsoidGeometry"}C.packedLength=2*ce.Cartesian3.packedLength+p.VertexFormat.packedLength+7,C.pack=function(e,t,a){if(!ue.defined(e))throw new d.DeveloperError("value is required");if(!ue.defined(t))throw new d.DeveloperError("array is required");return a=ue.defaultValue(a,0),ce.Cartesian3.pack(e._radii,t,a),a+=ce.Cartesian3.packedLength,ce.Cartesian3.pack(e._innerRadii,t,a),a+=ce.Cartesian3.packedLength,p.VertexFormat.pack(e._vertexFormat,t,a),a+=p.VertexFormat.packedLength,t[a++]=e._minimumClock,t[a++]=e._maximumClock,t[a++]=e._minimumCone,t[a++]=e._maximumCone,t[a++]=e._stackPartitions,t[a++]=e._slicePartitions,t[a]=ue.defaultValue(e._offsetAttribute,-1),t};var t,y=new ce.Cartesian3,h=new ce.Cartesian3,_=new p.VertexFormat,v={radii:y,innerRadii:h,vertexFormat:_,minimumClock:void 0,maximumClock:void 0,minimumCone:void 0,maximumCone:void 0,stackPartitions:void 0,slicePartitions:void 0,offsetAttribute:void 0};C.unpack=function(e,t,a){if(!ue.defined(e))throw new d.DeveloperError("array is required");t=ue.defaultValue(t,0);var r=ce.Cartesian3.unpack(e,t,y);t+=ce.Cartesian3.packedLength;var i=ce.Cartesian3.unpack(e,t,h);t+=ce.Cartesian3.packedLength;var n=p.VertexFormat.unpack(e,t,_);t+=p.VertexFormat.packedLength;var o=e[t++],m=e[t++],s=e[t++],u=e[t++],l=e[t++],c=e[t++],f=e[t];return ue.defined(a)?(a._radii=ce.Cartesian3.clone(r,a._radii),a._innerRadii=ce.Cartesian3.clone(i,a._innerRadii),a._vertexFormat=p.VertexFormat.clone(n,a._vertexFormat),a._minimumClock=o,a._maximumClock=m,a._minimumCone=s,a._maximumCone=u,a._stackPartitions=l,a._slicePartitions=c,a._offsetAttribute=-1===f?void 0:f,a):(v.minimumClock=o,v.maximumClock=m,v.minimumCone=s,v.maximumCone=u,v.stackPartitions=l,v.slicePartitions=c,v.offsetAttribute=-1===f?void 0:f,new C(v))},C.createGeometry=function(e){var t=e._radii;if(!(t.x<=0||t.y<=0||t.z<=0)){var a=e._innerRadii;if(!(a.x<=0||a.y<=0||a.z<=0)){var r=e._minimumClock,i=e._maximumClock,n=e._minimumCone,o=e._maximumCone,m=e._vertexFormat,s=e._slicePartitions+1,u=e._stackPartitions+1;(s=Math.round(s*Math.abs(i-r)/le.CesiumMath.TWO_PI))<2&&(s=2),(u=Math.round(u*Math.abs(o-n)/le.CesiumMath.PI))<2&&(u=2);var l=0,c=[n],f=[r];for(W=0;W<u;W++)c.push(n+W*(o-n)/(u-1));for(c.push(o),I=0;I<s;I++)f.push(r+I*(i-r)/(s-1));f.push(i);var d=c.length,p=f.length,C=0,y=1,h=a.x!==t.x||a.y!==t.y||a.z!==t.z,_=!1,v=!1,A=!1;h&&(y=2,0<n&&(_=!0,C+=s-1),o<Math.PI&&(v=!0,C+=s-1),(i-r)%le.CesiumMath.TWO_PI?(A=!0,C+=2*(u-1)+1):C+=1);var b=p*d*y,x=new Float64Array(3*b),w=he.arrayFill(new Array(b),!1),k=he.arrayFill(new Array(b),!1),P=s*u*y,F=6*(P+C+1-(s+u)*y),g=ye.IndexDatatype.createTypedArray(P,F),V=m.normal?new Float32Array(3*b):void 0,D=m.tangent?new Float32Array(3*b):void 0,M=m.bitangent?new Float32Array(3*b):void 0,T=m.st?new Float32Array(2*b):void 0,E=new Array(d),G=new Array(d);for(W=0;W<d;W++)E[W]=ke(c[W]),G[W]=we(c[W]);for(var L=new Array(p),O=new Array(p),I=0;I<p;I++)O[I]=we(f[I]),L[I]=ke(f[I]);for(W=0;W<d;W++)for(I=0;I<p;I++)x[l++]=t.x*E[W]*O[I],x[l++]=t.y*E[W]*L[I],x[l++]=t.z*G[W];var z,N,R,U,S=b/2;if(h)for(W=0;W<d;W++)for(I=0;I<p;I++)x[l++]=a.x*E[W]*O[I],x[l++]=a.y*E[W]*L[I],x[l++]=a.z*G[W],w[S]=!0,0<W&&W!==d-1&&0!==I&&I!==p-1&&(k[S]=!0),S++;for(l=0,W=1;W<d-2;W++)for(z=W*p,N=(W+1)*p,I=1;I<p-2;I++)g[l++]=N+I,g[l++]=N+I+1,g[l++]=z+I+1,g[l++]=N+I,g[l++]=z+I+1,g[l++]=z+I;if(h)for(var B=d*p,W=1;W<d-2;W++)for(z=B+W*p,N=B+(W+1)*p,I=1;I<p-2;I++)g[l++]=N+I,g[l++]=z+I,g[l++]=z+I+1,g[l++]=N+I,g[l++]=z+I+1,g[l++]=N+I+1;if(h){if(_)for(U=d*p,W=1;W<p-2;W++)g[l++]=W,g[l++]=W+1,g[l++]=U+W+1,g[l++]=W,g[l++]=U+W+1,g[l++]=U+W;if(v)for(R=d*p-p,U=d*p*y-p,W=1;W<p-2;W++)g[l++]=R+W+1,g[l++]=R+W,g[l++]=U+W,g[l++]=R+W+1,g[l++]=U+W,g[l++]=U+W+1}if(A){for(W=1;W<d-2;W++)U=p*d+p*W,R=p*W,g[l++]=U,g[l++]=R+p,g[l++]=R,g[l++]=U,g[l++]=U+p,g[l++]=R+p;for(W=1;W<d-2;W++)U=p*d+p*(W+1)-1,R=p*(W+1)-1,g[l++]=R+p,g[l++]=U,g[l++]=R,g[l++]=R+p,g[l++]=U+p,g[l++]=U}var q=new Ce.GeometryAttributes;m.position&&(q.position=new pe.GeometryAttribute({componentDatatype:de.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:x}));var Y,J,X,Z,j=0,H=0,K=0,Q=0,$=b/2,ee=ce.Ellipsoid.fromCartesian3(t),te=ce.Ellipsoid.fromCartesian3(a);if(m.st||m.normal||m.tangent||m.bitangent){for(W=0;W<b;W++){Y=w[W]?te:ee;var ae,re,ie,ne,oe,me=ce.Cartesian3.fromArray(x,3*W,_e),se=Y.geodeticSurfaceNormal(me,ve);k[W]&&ce.Cartesian3.negate(se,se),m.st&&(ae=ce.Cartesian2.negate(se,xe),T[j++]=Math.atan2(ae.y,ae.x)/le.CesiumMath.TWO_PI+.5,T[j++]=Math.asin(se.z)/Math.PI+.5),m.normal&&(V[H++]=se.x,V[H++]=se.y,V[H++]=se.z),(m.tangent||m.bitangent)&&(re=Ae,ie=0,w[W]&&(ie=$),ne=!_&&ie<=W&&W<ie+2*p?ce.Cartesian3.UNIT_X:ce.Cartesian3.UNIT_Z,ce.Cartesian3.cross(ne,se,re),ce.Cartesian3.normalize(re,re),m.tangent&&(D[K++]=re.x,D[K++]=re.y,D[K++]=re.z),m.bitangent&&(oe=ce.Cartesian3.cross(se,re,be),ce.Cartesian3.normalize(oe,oe),M[Q++]=oe.x,M[Q++]=oe.y,M[Q++]=oe.z))}m.st&&(q.st=new pe.GeometryAttribute({componentDatatype:de.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:T})),m.normal&&(q.normal=new pe.GeometryAttribute({componentDatatype:de.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:V})),m.tangent&&(q.tangent=new pe.GeometryAttribute({componentDatatype:de.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:D})),m.bitangent&&(q.bitangent=new pe.GeometryAttribute({componentDatatype:de.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:M}))}return ue.defined(e._offsetAttribute)&&(J=x.length,X=new Uint8Array(J/3),Z=e._offsetAttribute===he.GeometryOffsetAttribute.NONE?0:1,he.arrayFill(X,Z),q.applyOffset=new pe.GeometryAttribute({componentDatatype:de.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:X})),new pe.Geometry({attributes:q,indices:g,primitiveType:pe.PrimitiveType.TRIANGLES,boundingSphere:fe.BoundingSphere.fromEllipsoid(ee),offsetAttribute:e._offsetAttribute})}}},C.getUnitEllipsoid=function(){return ue.defined(t)||(t=C.createGeometry(new C({radii:new ce.Cartesian3(1,1,1),vertexFormat:p.VertexFormat.POSITION_ONLY}))),t},e.EllipsoidGeometry=C}); |