NONGYESHUZIDIZUO/public/Cesium/Workers/EllipseGeometry-39620aaf.js

2 lines
14 KiB
JavaScript

define(["exports","./arrayFill-deb10550","./buildModuleUrl-d920237a","./Cartesian2-2b41fabe","./Cartographic-1d953166","./Check-2514d21d","./ComponentDatatype-07894a2b","./when-d186add7","./EllipseGeometryLibrary-39c9f059","./Rectangle-f841217d","./GeometryAttribute-95780fd1","./GeometryAttributes-9c67dd14","./GeometryInstance-2076821b","./GeometryOffsetAttribute-da5a1d35","./GeometryPipeline-6f0b08bc","./IndexDatatype-61ffec74","./Math-7f5f2992","./FeatureDetection-4281d393","./VertexFormat-769ac289"],(function(t,e,o,r,n,i,a,s,u,m,l,c,p,d,y,f,h,A,x){"use strict";var g=new n.t,_=new n.t,v=new n.t,b=new n.t,w=new r.o,I=new A.p,T=new A.p,N=new l.n,M=new n.t,E=new n.t,P=new n.t,D=new n.t$1,F=new n.t,O=new r.o,S=new r.o;function C(t,i,m){var p=i.vertexFormat,y=i.center,f=i.semiMajorAxis,h=i.semiMinorAxis,x=i.ellipsoid,b=i.stRotation,C=m?t.length/3*2:t.length/3,R=i.shadowVolume,L=p.st?new Float32Array(2*C):void 0,j=p.normal?new Float32Array(3*C):void 0,z=p.tangent?new Float32Array(3*C):void 0,G=p.bitangent?new Float32Array(3*C):void 0,V=R?new Float32Array(3*C):void 0,k=0,Y=M,B=E,H=P,U=new o.n(x),W=U.project(x.cartesianToCartographic(y,D),F),q=x.scaleToGeodeticSurface(y,g);x.geodeticSurfaceNormal(q,q);var Q=I,J=T;if(0!==b){var Z=l.n.fromAxisAngle(q,b,N);Q=A.p.fromQuaternion(Z,Q),Z=l.n.fromAxisAngle(q,-b,N),J=A.p.fromQuaternion(Z,J)}else Q=A.p.clone(A.p.IDENTITY,Q),J=A.p.clone(A.p.IDENTITY,J);for(var $=r.o.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,O),K=r.o.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,S),X=t.length,tt=m?X:0,et=tt/3*2,ot=0;ot<X;ot+=3){var rt=ot+1,nt=ot+2,it=n.t.fromArray(t,ot,g);if(p.st){var at=A.p.multiplyByVector(Q,it,_),st=U.project(x.cartesianToCartographic(at,D),v);n.t.subtract(st,W,st),w.x=(st.x+f)/(2*f),w.y=(st.y+h)/(2*h),$.x=Math.min(w.x,$.x),$.y=Math.min(w.y,$.y),K.x=Math.max(w.x,K.x),K.y=Math.max(w.y,K.y),m&&(L[k+et]=w.x,L[k+1+et]=w.y),L[k++]=w.x,L[k++]=w.y}(p.normal||p.tangent||p.bitangent||R)&&(Y=x.geodeticSurfaceNormal(it,Y),R&&(V[ot+tt]=-Y.x,V[rt+tt]=-Y.y,V[nt+tt]=-Y.z),(p.normal||p.tangent||p.bitangent)&&((p.tangent||p.bitangent)&&(B=n.t.normalize(n.t.cross(n.t.UNIT_Z,Y,B),B),A.p.multiplyByVector(J,B,B)),p.normal&&(j[ot]=Y.x,j[rt]=Y.y,j[nt]=Y.z,m&&(j[ot+tt]=-Y.x,j[rt+tt]=-Y.y,j[nt+tt]=-Y.z)),p.tangent&&(z[ot]=B.x,z[rt]=B.y,z[nt]=B.z,m&&(z[ot+tt]=-B.x,z[rt+tt]=-B.y,z[nt+tt]=-B.z)),p.bitangent&&(H=n.t.normalize(n.t.cross(Y,B,H),H),G[ot]=H.x,G[rt]=H.y,G[nt]=H.z,m&&(G[ot+tt]=H.x,G[rt+tt]=H.y,G[nt+tt]=H.z))))}if(p.st){X=L.length;for(var ut=0;ut<X;ut+=2)L[ut]=(L[ut]-$.x)/(K.x-$.x),L[ut+1]=(L[ut+1]-$.y)/(K.y-$.y)}var mt=new c.a;if(p.position){var lt=u.C.raisePositionsToHeight(t,i,m);mt.position=new l.o({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:lt})}if(p.st&&(mt.st=new l.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:L})),p.normal&&(mt.normal=new l.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:j})),p.tangent&&(mt.tangent=new l.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:z})),p.bitangent&&(mt.bitangent=new l.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:G})),R&&(mt.extrudeDirection=new l.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:V})),m&&s.e(i.offsetAttribute)){var ct=new Uint8Array(C);if(i.offsetAttribute===d.z.TOP)ct=e.d(ct,1,0,C/2);else{var pt=i.offsetAttribute===d.z.NONE?0:1;ct=e.d(ct,pt)}mt.applyOffset=new l.o({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:ct})}return mt}function R(t){var e,o,r,n,i,a=new Array(t*(t+1)*12-6),s=0;for(e=0,r=1,n=0;n<3;n++)a[s++]=r++,a[s++]=e,a[s++]=r;for(n=2;n<t+1;++n){for(r=n*(n+1)-1,e=(n-1)*n-1,a[s++]=r++,a[s++]=e,a[s++]=r,o=2*n,i=0;i<o-1;++i)a[s++]=r,a[s++]=e++,a[s++]=e,a[s++]=r++,a[s++]=e,a[s++]=r;a[s++]=r++,a[s++]=e,a[s++]=r}for(o=2*t,++r,++e,n=0;n<o-1;++n)a[s++]=r,a[s++]=e++,a[s++]=e,a[s++]=r++,a[s++]=e,a[s++]=r;for(a[s++]=r,a[s++]=e++,a[s++]=e,a[s++]=r++,a[s++]=e++,a[s++]=e,++e,n=t-1;n>1;--n){for(a[s++]=e++,a[s++]=e,a[s++]=r,o=2*n,i=0;i<o-1;++i)a[s++]=r,a[s++]=e++,a[s++]=e,a[s++]=r++,a[s++]=e,a[s++]=r;a[s++]=e++,a[s++]=e++,a[s++]=r++}for(n=0;n<3;n++)a[s++]=e++,a[s++]=e,a[s++]=r;return a}var L=new n.t;var j=new o.i,z=new o.i;function G(t){var i=t.center,m=t.ellipsoid,h=t.semiMajorAxis,x=n.t.multiplyByScalar(m.geodeticSurfaceNormal(i,g),t.height,g);j.center=n.t.add(i,x,j.center),j.radius=h,x=n.t.multiplyByScalar(m.geodeticSurfaceNormal(i,x),t.extrudedHeight,x),z.center=n.t.add(i,x,z.center),z.radius=h;var T=u.C.computeEllipsePositions(t,!0,!0),L=T.positions,G=T.numPts,V=T.outerPositions,k=o.i.union(j,z),Y=C(L,t,!0),B=R(G),H=B.length;B.length=2*H;for(var U=L.length/3,W=0;W<H;W+=3)B[W+H]=B[W+2]+U,B[W+1+H]=B[W+1]+U,B[W+2+H]=B[W]+U;var q=f.IndexDatatype.createTypedArray(2*U/3,B),Q=new l.I({attributes:Y,indices:q,primitiveType:A._0x12cc5d.TRIANGLES}),J=function(t,i){var u=i.vertexFormat,m=i.center,p=i.semiMajorAxis,y=i.semiMinorAxis,f=i.ellipsoid,h=i.height,x=i.extrudedHeight,T=i.stRotation,C=t.length/3*2,R=new Float64Array(3*C),L=u.st?new Float32Array(2*C):void 0,j=u.normal?new Float32Array(3*C):void 0,z=u.tangent?new Float32Array(3*C):void 0,G=u.bitangent?new Float32Array(3*C):void 0,V=i.shadowVolume,k=V?new Float32Array(3*C):void 0,Y=0,B=M,H=E,U=P,W=new o.n(f),q=W.project(f.cartesianToCartographic(m,D),F),Q=f.scaleToGeodeticSurface(m,g);f.geodeticSurfaceNormal(Q,Q);for(var J=l.n.fromAxisAngle(Q,T,N),Z=A.p.fromQuaternion(J,I),$=r.o.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,O),K=r.o.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,S),X=t.length,tt=X/3*2,et=0;et<X;et+=3){var ot,rt=et+1,nt=et+2,it=n.t.fromArray(t,et,g);if(u.st){var at=A.p.multiplyByVector(Z,it,_),st=W.project(f.cartesianToCartographic(at,D),v);n.t.subtract(st,q,st),w.x=(st.x+p)/(2*p),w.y=(st.y+y)/(2*y),$.x=Math.min(w.x,$.x),$.y=Math.min(w.y,$.y),K.x=Math.max(w.x,K.x),K.y=Math.max(w.y,K.y),L[Y+tt]=w.x,L[Y+1+tt]=w.y,L[Y++]=w.x,L[Y++]=w.y}it=f.scaleToGeodeticSurface(it,it),ot=n.t.clone(it,_),B=f.geodeticSurfaceNormal(it,B),V&&(k[et+X]=-B.x,k[rt+X]=-B.y,k[nt+X]=-B.z);var ut=n.t.multiplyByScalar(B,h,b);if(it=n.t.add(it,ut,it),ut=n.t.multiplyByScalar(B,x,ut),ot=n.t.add(ot,ut,ot),u.position&&(R[et+X]=ot.x,R[rt+X]=ot.y,R[nt+X]=ot.z,R[et]=it.x,R[rt]=it.y,R[nt]=it.z),u.normal||u.tangent||u.bitangent){U=n.t.clone(B,U);var mt=n.t.fromArray(t,(et+3)%X,b);n.t.subtract(mt,it,mt);var lt=n.t.subtract(ot,it,v);B=n.t.normalize(n.t.cross(lt,mt,B),B),u.normal&&(j[et]=B.x,j[rt]=B.y,j[nt]=B.z,j[et+X]=B.x,j[rt+X]=B.y,j[nt+X]=B.z),u.tangent&&(H=n.t.normalize(n.t.cross(U,B,H),H),z[et]=H.x,z[rt]=H.y,z[nt]=H.z,z[et+X]=H.x,z[et+1+X]=H.y,z[et+2+X]=H.z),u.bitangent&&(G[et]=U.x,G[rt]=U.y,G[nt]=U.z,G[et+X]=U.x,G[rt+X]=U.y,G[nt+X]=U.z)}}if(u.st){X=L.length;for(var ct=0;ct<X;ct+=2)L[ct]=(L[ct]-$.x)/(K.x-$.x),L[ct+1]=(L[ct+1]-$.y)/(K.y-$.y)}var pt=new c.a;if(u.position&&(pt.position=new l.o({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:R})),u.st&&(pt.st=new l.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:L})),u.normal&&(pt.normal=new l.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:j})),u.tangent&&(pt.tangent=new l.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:z})),u.bitangent&&(pt.bitangent=new l.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:G})),V&&(pt.extrudeDirection=new l.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:k})),s.e(i.offsetAttribute)){var dt=new Uint8Array(C);if(i.offsetAttribute===d.z.TOP)dt=e.d(dt,1,0,C/2);else{var yt=i.offsetAttribute===d.z.NONE?0:1;dt=e.d(dt,yt)}pt.applyOffset=new l.o({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:dt})}return pt}(V,t);B=function(t){for(var e=t.length/3,o=f.IndexDatatype.createTypedArray(e,6*e),r=0,n=0;n<e;n++){var i=n,a=n+e,s=(i+1)%e,u=s+e;o[r++]=i,o[r++]=a,o[r++]=s,o[r++]=s,o[r++]=a,o[r++]=u}return o}(V);var Z=f.IndexDatatype.createTypedArray(2*V.length/3,B),$=new l.I({attributes:J,indices:Z,primitiveType:A._0x12cc5d.TRIANGLES}),K=y.k.combineInstances([new p.d({geometry:Q}),new p.d({geometry:$})]);return{boundingSphere:k,attributes:K[0].attributes,indices:K[0].indices}}function V(t,e,o,r,i,a,s){for(var l=u.C.computeEllipsePositions({center:t,semiMajorAxis:e,semiMinorAxis:o,rotation:r,granularity:i},!1,!0).outerPositions,c=l.length/3,p=new Array(c),d=0;d<c;++d)p[d]=n.t.fromArray(l,3*d);var y=m.h.fromCartesianArray(p,a,s);return y.width>h.e.PI&&(y.north=y.north>0?h.e.PI_OVER_TWO-h.e.EPSILON7:y.north,y.south=y.south<0?h.e.EPSILON7-h.e.PI_OVER_TWO:y.south,y.east=h.e.PI,y.west=-h.e.PI),y}function k(t){var e=(t=s.u(t,s.u.EMPTY_OBJECT)).center,o=s.u(t.ellipsoid,m.t.WGS84),r=t.semiMajorAxis,a=t.semiMinorAxis,u=s.u(t.granularity,h.e.RADIANS_PER_DEGREE),l=s.u(t.vertexFormat,x.n.DEFAULT);if(i.o.defined("options.center",e),i.o.typeOf.number("options.semiMajorAxis",r),i.o.typeOf.number("options.semiMinorAxis",a),r<a)throw new i.t("semiMajorAxis must be greater than or equal to the semiMinorAxis.");if(u<=0)throw new i.t("granularity must be greater than zero.");var c=s.u(t.height,0),p=s.u(t.extrudedHeight,c);this._center=n.t.clone(e),this._semiMajorAxis=r,this._semiMinorAxis=a,this._ellipsoid=m.t.clone(o),this._rotation=s.u(t.rotation,0),this._stRotation=s.u(t.stRotation,0),this._height=Math.max(p,c),this._granularity=u,this._vertexFormat=x.n.clone(l),this._extrudedHeight=Math.min(p,c),this._shadowVolume=s.u(t.shadowVolume,!1),this._workerName="createEllipseGeometry",this._offsetAttribute=t.offsetAttribute,this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0}k.packedLength=n.t.packedLength+m.t.packedLength+x.n.packedLength+9,k.pack=function(t,e,o){return i.o.defined("value",t),i.o.defined("array",e),o=s.u(o,0),n.t.pack(t._center,e,o),o+=n.t.packedLength,m.t.pack(t._ellipsoid,e,o),o+=m.t.packedLength,x.n.pack(t._vertexFormat,e,o),o+=x.n.packedLength,e[o++]=t._semiMajorAxis,e[o++]=t._semiMinorAxis,e[o++]=t._rotation,e[o++]=t._stRotation,e[o++]=t._height,e[o++]=t._granularity,e[o++]=t._extrudedHeight,e[o++]=t._shadowVolume?1:0,e[o]=s.u(t._offsetAttribute,-1),e};var Y=new n.t,B=new m.t,H=new x.n,U={center:Y,ellipsoid:B,vertexFormat:H,semiMajorAxis:void 0,semiMinorAxis:void 0,rotation:void 0,stRotation:void 0,height:void 0,granularity:void 0,extrudedHeight:void 0,shadowVolume:void 0,offsetAttribute:void 0};k.unpack=function(t,e,o){i.o.defined("array",t),e=s.u(e,0);var r=n.t.unpack(t,e,Y);e+=n.t.packedLength;var a=m.t.unpack(t,e,B);e+=m.t.packedLength;var u=x.n.unpack(t,e,H);e+=x.n.packedLength;var l=t[e++],c=t[e++],p=t[e++],d=t[e++],y=t[e++],f=t[e++],h=t[e++],A=1===t[e++],g=t[e];return s.e(o)?(o._center=n.t.clone(r,o._center),o._ellipsoid=m.t.clone(a,o._ellipsoid),o._vertexFormat=x.n.clone(u,o._vertexFormat),o._semiMajorAxis=l,o._semiMinorAxis=c,o._rotation=p,o._stRotation=d,o._height=y,o._granularity=f,o._extrudedHeight=h,o._shadowVolume=A,o._offsetAttribute=-1===g?void 0:g,o):(U.height=y,U.extrudedHeight=h,U.granularity=f,U.stRotation=d,U.rotation=p,U.semiMajorAxis=l,U.semiMinorAxis=c,U.shadowVolume=A,U.offsetAttribute=-1===g?void 0:g,new k(U))},k.computeRectangle=function(t,e){var o=(t=s.u(t,s.u.EMPTY_OBJECT)).center,r=s.u(t.ellipsoid,m.t.WGS84),n=t.semiMajorAxis,a=t.semiMinorAxis,u=s.u(t.granularity,h.e.RADIANS_PER_DEGREE),l=s.u(t.rotation,0);if(i.o.defined("options.center",o),i.o.typeOf.number("options.semiMajorAxis",n),i.o.typeOf.number("options.semiMinorAxis",a),n<a)throw new i.t("semiMajorAxis must be greater than or equal to the semiMinorAxis.");if(u<=0)throw new i.t("granularity must be greater than zero.");return V(o,n,a,l,u,r,e)},k.createGeometry=function(t){if(!(t._semiMajorAxis<=0||t._semiMinorAxis<=0)){var r=t._height,i=t._extrudedHeight,m=!h.e.equalsEpsilon(r,i,0,h.e.EPSILON2);t._center=t._ellipsoid.scaleToGeodeticSurface(t._center,t._center);var c,p={center:t._center,semiMajorAxis:t._semiMajorAxis,semiMinorAxis:t._semiMinorAxis,ellipsoid:t._ellipsoid,rotation:t._rotation,height:r,granularity:t._granularity,vertexFormat:t._vertexFormat,stRotation:t._stRotation};if(m)p.extrudedHeight=i,p.shadowVolume=t._shadowVolume,p.offsetAttribute=t._offsetAttribute,c=G(p);else if(c=function(t){var e=t.center;L=n.t.multiplyByScalar(t.ellipsoid.geodeticSurfaceNormal(e,L),t.height,L),L=n.t.add(e,L,L);var r=new o.i(L,t.semiMajorAxis),i=u.C.computeEllipsePositions(t,!0,!1),a=i.positions,s=i.numPts,m=C(a,t,!1),l=R(s);return{boundingSphere:r,attributes:m,indices:l=f.IndexDatatype.createTypedArray(a.length/3,l)}}(p),s.e(t._offsetAttribute)){var y=c.attributes.position.values.length,x=new Uint8Array(y/3),g=t._offsetAttribute===d.z.NONE?0:1;e.d(x,g),c.attributes.applyOffset=new l.o({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:x})}return new l.I({attributes:c.attributes,indices:c.indices,primitiveType:A._0x12cc5d.TRIANGLES,boundingSphere:c.boundingSphere,offsetAttribute:t._offsetAttribute})}},k.createShadowVolume=function(t,e,o){var r=t._granularity,n=t._ellipsoid,i=e(r,n),a=o(r,n);return new k({center:t._center,semiMajorAxis:t._semiMajorAxis,semiMinorAxis:t._semiMinorAxis,ellipsoid:n,rotation:t._rotation,stRotation:t._stRotation,granularity:r,extrudedHeight:i,height:a,vertexFormat:x.n.POSITION_ONLY,shadowVolume:!0})},Object.defineProperties(k.prototype,{rectangle:{get:function(){return s.e(this._rectangle)||(this._rectangle=V(this._center,this._semiMajorAxis,this._semiMinorAxis,this._rotation,this._granularity,this._ellipsoid)),this._rectangle}},textureCoordinateRotationPoints:{get:function(){return s.e(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=function(t){var e=-t._stRotation;if(0===e)return[0,0,0,1,1,0];for(var o=u.C.computeEllipsePositions({center:t._center,semiMajorAxis:t._semiMajorAxis,semiMinorAxis:t._semiMinorAxis,rotation:t._rotation,granularity:t._granularity},!1,!0).outerPositions,r=o.length/3,i=new Array(r),a=0;a<r;++a)i[a]=n.t.fromArray(o,3*a);var s=t._ellipsoid,m=t.rectangle;return l.I._textureCoordinateRotationPoints(i,e,s,m)}(this)),this._textureCoordinateRotationPoints}}}),t.Y=k}));