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