define(["exports","./when-cbf8cd21","./Check-35e1a91d","./Math-e66fad2a","./Rectangle-062e2e03","./Transforms-abe53271","./ComponentDatatype-7ee14e67","./GeometryAttribute-36360b52","./GeometryAttributes-90846c5f","./GeometryPipeline-6fb5201d","./IndexDatatype-66caba23","./GeometryOffsetAttribute-84f7eff3","./VertexFormat-cc24f342","./EllipseGeometryLibrary-1156f0ca","./GeometryInstance-1963f019"],function(e,U,t,y,Q,W,J,q,Z,b,C,K,f,B,v){"use strict";var X=new Q.Cartesian3,$=new Q.Cartesian3,ee=new Q.Cartesian3,te=new Q.Cartesian3,re=new Q.Cartesian2,ae=new W.Matrix3,Y=new W.Matrix3,ie=new W.Quaternion,ne=new Q.Cartesian3,oe=new Q.Cartesian3,se=new Q.Cartesian3,ue=new Q.Cartographic,le=new Q.Cartesian3,me=new Q.Cartesian2,pe=new Q.Cartesian2;function w(e,t,r){var a=t.vertexFormat,i=t.center,n=t.semiMajorAxis,o=t.semiMinorAxis,s=t.ellipsoid,u=t.stRotation,l=r?e.length/3*2:e.length/3,m=t.shadowVolume,p=a.st?new Float32Array(2*l):void 0,y=a.normal?new Float32Array(3*l):void 0,c=a.tangent?new Float32Array(3*l):void 0,d=a.bitangent?new Float32Array(3*l):void 0,f=m?new Float32Array(3*l):void 0,A=0,h=ne,x=oe,g=se,_=new W.GeographicProjection(s),b=_.project(s.cartesianToCartographic(i,ue),le),C=s.scaleToGeodeticSurface(i,X);s.geodeticSurfaceNormal(C,C);var v,w=ae,M=Y;M=0!==u?(v=W.Quaternion.fromAxisAngle(C,u,ie),w=W.Matrix3.fromQuaternion(v,w),v=W.Quaternion.fromAxisAngle(C,-u,ie),W.Matrix3.fromQuaternion(v,M)):(w=W.Matrix3.clone(W.Matrix3.IDENTITY,w),W.Matrix3.clone(W.Matrix3.IDENTITY,M));for(var E=Q.Cartesian2.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,me),I=Q.Cartesian2.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,pe),T=e.length,G=r?T:0,N=G/3*2,P=0;P<T;P+=3){var F,V,D=P+1,O=P+2,S=Q.Cartesian3.fromArray(e,P,X);a.st&&(F=W.Matrix3.multiplyByVector(w,S,$),V=_.project(s.cartesianToCartographic(F,ue),ee),Q.Cartesian3.subtract(V,b,V),re.x=(V.x+n)/(2*n),re.y=(V.y+o)/(2*o),E.x=Math.min(re.x,E.x),E.y=Math.min(re.y,E.y),I.x=Math.max(re.x,I.x),I.y=Math.max(re.y,I.y),r&&(p[A+N]=re.x,p[A+1+N]=re.y),p[A++]=re.x,p[A++]=re.y),(a.normal||a.tangent||a.bitangent||m)&&(h=s.geodeticSurfaceNormal(S,h),m&&(f[P+G]=-h.x,f[D+G]=-h.y,f[O+G]=-h.z),(a.normal||a.tangent||a.bitangent)&&((a.tangent||a.bitangent)&&(x=Q.Cartesian3.normalize(Q.Cartesian3.cross(Q.Cartesian3.UNIT_Z,h,x),x),W.Matrix3.multiplyByVector(M,x,x)),a.normal&&(y[P]=h.x,y[D]=h.y,y[O]=h.z,r&&(y[P+G]=-h.x,y[D+G]=-h.y,y[O+G]=-h.z)),a.tangent&&(c[P]=x.x,c[D]=x.y,c[O]=x.z,r&&(c[P+G]=-x.x,c[D+G]=-x.y,c[O+G]=-x.z)),a.bitangent&&(g=Q.Cartesian3.normalize(Q.Cartesian3.cross(h,x,g),g),d[P]=g.x,d[D]=g.y,d[O]=g.z,r&&(d[P+G]=g.x,d[D+G]=g.y,d[O+G]=g.z))))}if(a.st){T=p.length;for(var L=0;L<T;L+=2)p[L]=(p[L]-E.x)/(I.x-E.x),p[L+1]=(p[L+1]-E.y)/(I.y-E.y)}var R,j,k,z=new Z.GeometryAttributes;return a.position&&(R=B.EllipseGeometryLibrary.raisePositionsToHeight(e,t,r),z.position=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:R})),a.st&&(z.st=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:p})),a.normal&&(z.normal=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:y})),a.tangent&&(z.tangent=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:c})),a.bitangent&&(z.bitangent=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:d})),m&&(z.extrudeDirection=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:f})),r&&U.defined(t.offsetAttribute)&&(k=new Uint8Array(l),k=t.offsetAttribute===K.GeometryOffsetAttribute.TOP?K.arrayFill(k,1,0,l/2):(j=t.offsetAttribute===K.GeometryOffsetAttribute.NONE?0:1,K.arrayFill(k,j)),z.applyOffset=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:k})),z}function M(e){for(var t,r,a=new Array(e*(e+1)*12-6),i=0,n=0,o=1,s=0;s<3;s++)a[i++]=o++,a[i++]=n,a[i++]=o;for(s=2;s<e+1;++s){for(o=s*(s+1)-1,n=(s-1)*s-1,a[i++]=o++,a[i++]=n,a[i++]=o,t=2*s,r=0;r<t-1;++r)a[i++]=o,a[i++]=n++,a[i++]=n,a[i++]=o++,a[i++]=n,a[i++]=o;a[i++]=o++,a[i++]=n,a[i++]=o}for(t=2*e,++o,++n,s=0;s<t-1;++s)a[i++]=o,a[i++]=n++,a[i++]=n,a[i++]=o++,a[i++]=n,a[i++]=o;for(a[i++]=o,a[i++]=n++,a[i++]=n,a[i++]=o++,a[i++]=n++,a[i++]=n,++n,s=e-1;1<s;--s){for(a[i++]=n++,a[i++]=n,a[i++]=o,t=2*s,r=0;r<t-1;++r)a[i++]=o,a[i++]=n++,a[i++]=n,a[i++]=o++,a[i++]=n,a[i++]=o;a[i++]=n++,a[i++]=n++,a[i++]=o++}for(s=0;s<3;s++)a[i++]=n++,a[i++]=n,a[i++]=o;return a}var l=new Q.Cartesian3;var E=new W.BoundingSphere,I=new W.BoundingSphere;function m(e){var t=e.center,r=e.ellipsoid,a=e.semiMajorAxis,i=Q.Cartesian3.multiplyByScalar(r.geodeticSurfaceNormal(t,X),e.height,X);E.center=Q.Cartesian3.add(t,i,E.center),E.radius=a,i=Q.Cartesian3.multiplyByScalar(r.geodeticSurfaceNormal(t,i),e.extrudedHeight,i),I.center=Q.Cartesian3.add(t,i,I.center),I.radius=a;var n=B.EllipseGeometryLibrary.computeEllipsePositions(e,!0,!0),o=n.positions,s=n.numPts,u=n.outerPositions,l=W.BoundingSphere.union(E,I),m=w(o,e,!0),p=(h=M(s)).length;h.length=2*p;for(var y=o.length/3,c=0;c<p;c+=3)h[c+p]=h[c+2]+y,h[c+1+p]=h[c+1]+y,h[c+2+p]=h[c]+y;var d=C.IndexDatatype.createTypedArray(2*y/3,h),f=new q.Geometry({attributes:m,indices:d,primitiveType:q.PrimitiveType.TRIANGLES}),A=function(e,t){var r=t.vertexFormat,a=t.center,i=t.semiMajorAxis,n=t.semiMinorAxis,o=t.ellipsoid,s=t.height,u=t.extrudedHeight,l=t.stRotation,m=e.length/3*2,p=new Float64Array(3*m),y=r.st?new Float32Array(2*m):void 0,c=r.normal?new Float32Array(3*m):void 0,d=r.tangent?new Float32Array(3*m):void 0,f=r.bitangent?new Float32Array(3*m):void 0,A=t.shadowVolume,h=A?new Float32Array(3*m):void 0,x=0,g=ne,_=oe,b=se,C=new W.GeographicProjection(o),v=C.project(o.cartesianToCartographic(a,ue),le),w=o.scaleToGeodeticSurface(a,X);o.geodeticSurfaceNormal(w,w);for(var M=W.Quaternion.fromAxisAngle(w,l,ie),E=W.Matrix3.fromQuaternion(M,ae),I=Q.Cartesian2.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,me),T=Q.Cartesian2.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,pe),G=e.length,N=G/3*2,P=0;P<G;P+=3){var F,V,D=P+1,O=P+2,S=Q.Cartesian3.fromArray(e,P,X);r.st&&(F=W.Matrix3.multiplyByVector(E,S,$),V=C.project(o.cartesianToCartographic(F,ue),ee),Q.Cartesian3.subtract(V,v,V),re.x=(V.x+i)/(2*i),re.y=(V.y+n)/(2*n),I.x=Math.min(re.x,I.x),I.y=Math.min(re.y,I.y),T.x=Math.max(re.x,T.x),T.y=Math.max(re.y,T.y),y[x+N]=re.x,y[x+1+N]=re.y,y[x++]=re.x,y[x++]=re.y),S=o.scaleToGeodeticSurface(S,S),k=Q.Cartesian3.clone(S,$),g=o.geodeticSurfaceNormal(S,g),A&&(h[P+G]=-g.x,h[D+G]=-g.y,h[O+G]=-g.z);var L,R,j=Q.Cartesian3.multiplyByScalar(g,s,te),S=Q.Cartesian3.add(S,j,S),j=Q.Cartesian3.multiplyByScalar(g,u,j),k=Q.Cartesian3.add(k,j,k);r.position&&(p[P+G]=k.x,p[D+G]=k.y,p[O+G]=k.z,p[P]=S.x,p[D]=S.y,p[O]=S.z),(r.normal||r.tangent||r.bitangent)&&(b=Q.Cartesian3.clone(g,b),L=Q.Cartesian3.fromArray(e,(P+3)%G,te),Q.Cartesian3.subtract(L,S,L),R=Q.Cartesian3.subtract(k,S,ee),g=Q.Cartesian3.normalize(Q.Cartesian3.cross(R,L,g),g),r.normal&&(c[P]=g.x,c[D]=g.y,c[O]=g.z,c[P+G]=g.x,c[D+G]=g.y,c[O+G]=g.z),r.tangent&&(_=Q.Cartesian3.normalize(Q.Cartesian3.cross(b,g,_),_),d[P]=_.x,d[D]=_.y,d[O]=_.z,d[P+G]=_.x,d[P+1+G]=_.y,d[P+2+G]=_.z),r.bitangent&&(f[P]=b.x,f[D]=b.y,f[O]=b.z,f[P+G]=b.x,f[D+G]=b.y,f[O+G]=b.z))}if(r.st){G=y.length;for(var z=0;z<G;z+=2)y[z]=(y[z]-I.x)/(T.x-I.x),y[z+1]=(y[z+1]-I.y)/(T.y-I.y)}var B,Y,H=new Z.GeometryAttributes;return r.position&&(H.position=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:p})),r.st&&(H.st=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:y})),r.normal&&(H.normal=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:c})),r.tangent&&(H.tangent=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:d})),r.bitangent&&(H.bitangent=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:f})),A&&(H.extrudeDirection=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:h})),U.defined(t.offsetAttribute)&&(Y=new Uint8Array(m),Y=t.offsetAttribute===K.GeometryOffsetAttribute.TOP?K.arrayFill(Y,1,0,m/2):(B=t.offsetAttribute===K.GeometryOffsetAttribute.NONE?0:1,K.arrayFill(Y,B)),H.applyOffset=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:Y})),H}(u,e),h=function(e){for(var t=e.length/3,r=C.IndexDatatype.createTypedArray(t,6*t),a=0,i=0;i<t;i++){var n=i+t,o=(i+1)%t,s=o+t;r[a++]=i,r[a++]=n,r[a++]=o,r[a++]=o,r[a++]=n,r[a++]=s}return r}(u),x=C.IndexDatatype.createTypedArray(2*u.length/3,h),g=new q.Geometry({attributes:A,indices:x,primitiveType:q.PrimitiveType.TRIANGLES}),_=b.GeometryPipeline.combineInstances([new v.GeometryInstance({geometry:f}),new v.GeometryInstance({geometry:g})]);return{boundingSphere:l,attributes:_[0].attributes,indices:_[0].indices}}function s(e,t,r,a,i,n,o){for(var s=B.EllipseGeometryLibrary.computeEllipsePositions({center:e,semiMajorAxis:t,semiMinorAxis:r,rotation:a,granularity:i},!1,!0).outerPositions,u=s.length/3,l=new Array(u),m=0;m<u;++m)l[m]=Q.Cartesian3.fromArray(s,3*m);var p=Q.Rectangle.fromCartesianArray(l,n,o);return p.width>y.CesiumMath.PI&&(p.north=0<p.north?y.CesiumMath.PI_OVER_TWO-y.CesiumMath.EPSILON7:p.north,p.south=p.south<0?y.CesiumMath.EPSILON7-y.CesiumMath.PI_OVER_TWO:p.south,p.east=y.CesiumMath.PI,p.west=-y.CesiumMath.PI),p}function A(e){var t=(e=U.defaultValue(e,U.defaultValue.EMPTY_OBJECT)).center,r=U.defaultValue(e.ellipsoid,Q.Ellipsoid.WGS84),a=e.semiMajorAxis,i=e.semiMinorAxis,n=U.defaultValue(e.granularity,y.CesiumMath.RADIANS_PER_DEGREE),o=U.defaultValue(e.vertexFormat,f.VertexFormat.DEFAULT),s=U.defaultValue(e.height,0),u=U.defaultValue(e.extrudedHeight,s);this._center=Q.Cartesian3.clone(t),this._semiMajorAxis=a,this._semiMinorAxis=i,this._ellipsoid=Q.Ellipsoid.clone(r),this._rotation=U.defaultValue(e.rotation,0),this._stRotation=U.defaultValue(e.stRotation,0),this._height=Math.max(u,s),this._granularity=n,this._vertexFormat=f.VertexFormat.clone(o),this._extrudedHeight=Math.min(u,s),this._shadowVolume=U.defaultValue(e.shadowVolume,!1),this._workerName="createEllipseGeometry",this._offsetAttribute=e.offsetAttribute,this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0}A.packedLength=Q.Cartesian3.packedLength+Q.Ellipsoid.packedLength+f.VertexFormat.packedLength+9,A.pack=function(e,t,r){return r=U.defaultValue(r,0),Q.Cartesian3.pack(e._center,t,r),r+=Q.Cartesian3.packedLength,Q.Ellipsoid.pack(e._ellipsoid,t,r),r+=Q.Ellipsoid.packedLength,f.VertexFormat.pack(e._vertexFormat,t,r),r+=f.VertexFormat.packedLength,t[r++]=e._semiMajorAxis,t[r++]=e._semiMinorAxis,t[r++]=e._rotation,t[r++]=e._stRotation,t[r++]=e._height,t[r++]=e._granularity,t[r++]=e._extrudedHeight,t[r++]=e._shadowVolume?1:0,t[r]=U.defaultValue(e._offsetAttribute,-1),t};var h=new Q.Cartesian3,x=new Q.Ellipsoid,g=new f.VertexFormat,_={center:h,ellipsoid:x,vertexFormat:g,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};A.unpack=function(e,t,r){t=U.defaultValue(t,0);var a=Q.Cartesian3.unpack(e,t,h);t+=Q.Cartesian3.packedLength;var i=Q.Ellipsoid.unpack(e,t,x);t+=Q.Ellipsoid.packedLength;var n=f.VertexFormat.unpack(e,t,g);t+=f.VertexFormat.packedLength;var o=e[t++],s=e[t++],u=e[t++],l=e[t++],m=e[t++],p=e[t++],y=e[t++],c=1===e[t++],d=e[t];return U.defined(r)?(r._center=Q.Cartesian3.clone(a,r._center),r._ellipsoid=Q.Ellipsoid.clone(i,r._ellipsoid),r._vertexFormat=f.VertexFormat.clone(n,r._vertexFormat),r._semiMajorAxis=o,r._semiMinorAxis=s,r._rotation=u,r._stRotation=l,r._height=m,r._granularity=p,r._extrudedHeight=y,r._shadowVolume=c,r._offsetAttribute=-1===d?void 0:d,r):(_.height=m,_.extrudedHeight=y,_.granularity=p,_.stRotation=l,_.rotation=u,_.semiMajorAxis=o,_.semiMinorAxis=s,_.shadowVolume=c,_.offsetAttribute=-1===d?void 0:d,new A(_))},A.computeRectangle=function(e,t){var r=(e=U.defaultValue(e,U.defaultValue.EMPTY_OBJECT)).center,a=U.defaultValue(e.ellipsoid,Q.Ellipsoid.WGS84),i=e.semiMajorAxis,n=e.semiMinorAxis,o=U.defaultValue(e.granularity,y.CesiumMath.RADIANS_PER_DEGREE);return s(r,i,n,U.defaultValue(e.rotation,0),o,a,t)},A.createGeometry=function(e){if(!(e._semiMajorAxis<=0||e._semiMinorAxis<=0)){var t=e._height,r=e._extrudedHeight,a=!y.CesiumMath.equalsEpsilon(t,r,0,y.CesiumMath.EPSILON2);e._center=e._ellipsoid.scaleToGeodeticSurface(e._center,e._center);var i,n,o,s,u={center:e._center,semiMajorAxis:e._semiMajorAxis,semiMinorAxis:e._semiMinorAxis,ellipsoid:e._ellipsoid,rotation:e._rotation,height:t,granularity:e._granularity,vertexFormat:e._vertexFormat,stRotation:e._stRotation};return a?(u.extrudedHeight=r,u.shadowVolume=e._shadowVolume,u.offsetAttribute=e._offsetAttribute,s=m(u)):(s=function(e){var t=e.center;l=Q.Cartesian3.multiplyByScalar(e.ellipsoid.geodeticSurfaceNormal(t,l),e.height,l),l=Q.Cartesian3.add(t,l,l);var r=new W.BoundingSphere(l,e.semiMajorAxis),a=B.EllipseGeometryLibrary.computeEllipsePositions(e,!0,!1),i=a.positions,n=a.numPts,o=w(i,e,!1),s=M(n);return{boundingSphere:r,attributes:o,indices:s=C.IndexDatatype.createTypedArray(i.length/3,s)}}(u),U.defined(e._offsetAttribute)&&(i=s.attributes.position.values.length,n=new Uint8Array(i/3),o=e._offsetAttribute===K.GeometryOffsetAttribute.NONE?0:1,K.arrayFill(n,o),s.attributes.applyOffset=new q.GeometryAttribute({componentDatatype:J.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:n}))),new q.Geometry({attributes:s.attributes,indices:s.indices,primitiveType:q.PrimitiveType.TRIANGLES,boundingSphere:s.boundingSphere,offsetAttribute:e._offsetAttribute})}},A.createShadowVolume=function(e,t,r){var a=e._granularity,i=e._ellipsoid,n=t(a,i),o=r(a,i);return new A({center:e._center,semiMajorAxis:e._semiMajorAxis,semiMinorAxis:e._semiMinorAxis,ellipsoid:i,rotation:e._rotation,stRotation:e._stRotation,granularity:a,extrudedHeight:n,height:o,vertexFormat:f.VertexFormat.POSITION_ONLY,shadowVolume:!0})},Object.defineProperties(A.prototype,{rectangle:{get:function(){return U.defined(this._rectangle)||(this._rectangle=s(this._center,this._semiMajorAxis,this._semiMinorAxis,this._rotation,this._granularity,this._ellipsoid)),this._rectangle}},textureCoordinateRotationPoints:{get:function(){return U.defined(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=function(e){var t=-e._stRotation;if(0==t)return[0,0,0,1,1,0];for(var r=B.EllipseGeometryLibrary.computeEllipsePositions({center:e._center,semiMajorAxis:e._semiMajorAxis,semiMinorAxis:e._semiMinorAxis,rotation:e._rotation,granularity:e._granularity},!1,!0).outerPositions,a=r.length/3,i=new Array(a),n=0;n<a;++n)i[n]=Q.Cartesian3.fromArray(r,3*n);var o=e._ellipsoid,s=e.rectangle;return q.Geometry._textureCoordinateRotationPoints(i,t,o,s)}(this)),this._textureCoordinateRotationPoints}}}),e.EllipseGeometry=A});
|