| 1 |
- define(["./when-b60132fc","./Cartesian2-47311507","./ArcType-29cf2197","./arrayFill-4513d7ad","./BoundingRectangle-c09cdb4c","./buildModuleUrl-57a32107","./Cartographic-3309dd0d","./Check-7b2a090c","./ComponentDatatype-c140a87d","./EllipsoidGeodesic-0f19ac62","./EllipsoidTangentPlane-ceab6aaa","./GeometryAttribute-c42d25b7","./GeometryInstance-dbc9f4c4","./GeometryOffsetAttribute-fbeb6f1a","./GeometryPipeline-6d9322f0","./IndexDatatype-8a5eead4","./Math-119be1a3","./Matrix4-cde86d0e","./PolygonGeometryLibrary-20c09e27","./PolygonPipeline-805ba13c","./VertexFormat-6446fca0","./WebGLConstants-4ae0db90","./RuntimeError-4a5c8994","./Cartesian4-3ca25aab","./IntersectionTests-5e35c2ab","./Plane-ca0357f4","./FeatureDetection-c3b71206","./AttributeCompression-90851096","./EncodedCartesian3-f1396b05","./arrayRemoveDuplicates-d2f048c5","./EllipsoidRhumbLine-ed1a6bf4","./GeometryAttributes-252e9929","./earcut-2.2.1-20c8012f"],(function(e,t,a,r,o,i,n,s,l,u,c,p,y,d,g,m,h,f,b,v,_,P,x,C,w,T,A,E,I,G,V,F,N){"use strict";var H=new n.Cartographic,O=new n.Cartographic;function R(e,t,a,r){var o=r.cartesianToCartographic(e,H).height,i=r.cartesianToCartographic(t,O);i.height=o,r.cartographicToCartesian(i,t);var n=r.cartesianToCartographic(a,O);n.height=o-100,r.cartographicToCartesian(n,a)}var D=new o.BoundingRectangle,L=new n.Cartesian3,M=new n.Cartesian3,S=new n.Cartesian3,B=new n.Cartesian3,k=new n.Cartesian3,z=new n.Cartesian3,Y=new n.Cartesian3,U=new n.Cartesian3,W=new n.Cartesian3,j=new t.Cartesian2,Q=new t.Cartesian2,q=new n.Cartesian3,K=new p.Quaternion,Z=new f.Matrix3,J=new f.Matrix3;function X(a){var o=a.vertexFormat,i=a.geometry,s=a.shadowVolume,u=i.attributes.position.values,c=u.length,y=a.wall,g=a.top||y,m=a.bottom||y;if(o.st||o.normal||o.tangent||o.bitangent||s){var b=a.boundingRectangle,v=a.tangentPlane,_=a.ellipsoid,P=a.stRotation,x=a.perPositionHeight,C=j;C.x=b.x,C.y=b.y;var w,T=o.st?new Float32Array(c/3*2):void 0;o.normal&&(w=x&&g&&!y?i.attributes.normal.values:new Float32Array(c));var A=o.tangent?new Float32Array(c):void 0,E=o.bitangent?new Float32Array(c):void 0,I=s?new Float32Array(c):void 0,G=0,V=0,F=M,N=S,H=B,O=!0,D=Z,X=J;if(0!==P){var $=p.Quaternion.fromAxisAngle(v._plane.normal,P,K);D=f.Matrix3.fromQuaternion($,D),$=p.Quaternion.fromAxisAngle(v._plane.normal,-P,K),X=f.Matrix3.fromQuaternion($,X)}else D=f.Matrix3.clone(f.Matrix3.IDENTITY,D),X=f.Matrix3.clone(f.Matrix3.IDENTITY,X);var ee=0,te=0;g&&m&&(ee=c/2,te=c/3,c/=2);for(var ae=0;ae<c;ae+=3){var re=n.Cartesian3.fromArray(u,ae,q);if(o.st){var oe=f.Matrix3.multiplyByVector(D,re,L);oe=_.scaleToGeodeticSurface(oe,oe);var ie=v.projectPointOntoPlane(oe,Q);t.Cartesian2.subtract(ie,C,ie);var ne=h.CesiumMath.clamp(ie.x/b.width,0,1),se=h.CesiumMath.clamp(ie.y/b.height,0,1);m&&(T[G+te]=ne,T[G+1+te]=se),g&&(T[G]=ne,T[G+1]=se),G+=2}if(o.normal||o.tangent||o.bitangent||s){var le=V+1,ue=V+2;if(y){if(ae+3<c){var ce=n.Cartesian3.fromArray(u,ae+3,k);if(O){var pe=n.Cartesian3.fromArray(u,ae+c,z);x&&R(re,ce,pe,_),n.Cartesian3.subtract(ce,re,ce),n.Cartesian3.subtract(pe,re,pe),F=n.Cartesian3.normalize(n.Cartesian3.cross(pe,ce,F),F),O=!1}n.Cartesian3.equalsEpsilon(ce,re,h.CesiumMath.EPSILON10)&&(O=!0)}(o.tangent||o.bitangent)&&(H=_.geodeticSurfaceNormal(re,H),o.tangent&&(N=n.Cartesian3.normalize(n.Cartesian3.cross(H,F,N),N)))}else F=_.geodeticSurfaceNormal(re,F),(o.tangent||o.bitangent)&&(x&&(Y=n.Cartesian3.fromArray(w,V,Y),U=n.Cartesian3.cross(n.Cartesian3.UNIT_Z,Y,U),U=n.Cartesian3.normalize(f.Matrix3.multiplyByVector(X,U,U),U),o.bitangent&&(W=n.Cartesian3.normalize(n.Cartesian3.cross(Y,U,W),W))),N=n.Cartesian3.cross(n.Cartesian3.UNIT_Z,F,N),N=n.Cartesian3.normalize(f.Matrix3.multiplyByVector(X,N,N),N),o.bitangent&&(H=n.Cartesian3.normalize(n.Cartesian3.cross(F,N,H),H)));o.normal&&(a.wall?(w[V+ee]=F.x,w[le+ee]=F.y,w[ue+ee]=F.z):m&&(w[V+ee]=-F.x,w[le+ee]=-F.y,w[ue+ee]=-F.z),(g&&!x||y)&&(w[V]=F.x,w[le]=F.y,w[ue]=F.z)),s&&(y&&(F=_.geodeticSurfaceNormal(re,F)),I[V+ee]=-F.x,I[le+ee]=-F.y,I[ue+ee]=-F.z),o.tangent&&(a.wall?(A[V+ee]=N.x,A[le+ee]=N.y,A[ue+ee]=N.z):m&&(A[V+ee]=-N.x,A[le+ee]=-N.y,A[ue+ee]=-N.z),g&&(x?(A[V]=U.x,A[le]=U.y,A[ue]=U.z):(A[V]=N.x,A[le]=N.y,A[ue]=N.z))),o.bitangent&&(m&&(E[V+ee]=H.x,E[le+ee]=H.y,E[ue+ee]=H.z),g&&(x?(E[V]=W.x,E[le]=W.y,E[ue]=W.z):(E[V]=H.x,E[le]=H.y,E[ue]=H.z))),V+=3}}o.st&&(i.attributes.st=new p.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:T})),o.normal&&(i.attributes.normal=new p.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:w})),o.tangent&&(i.attributes.tangent=new p.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:A})),o.bitangent&&(i.attributes.bitangent=new p.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:E})),s&&(i.attributes.extrudeDirection=new p.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:I}))}if(a.extrude&&e.defined(a.offsetAttribute)){var ye=u.length/3,de=new Uint8Array(ye);if(a.offsetAttribute===d.GeometryOffsetAttribute.TOP)g&&m||y?de=r.arrayFill(de,1,0,ye/2):g&&(de=r.arrayFill(de,1));else{var ge=a.offsetAttribute===d.GeometryOffsetAttribute.NONE?0:1;de=r.arrayFill(de,ge)}i.attributes.applyOffset=new p.GeometryAttribute({componentDatatype:l.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:de})}return i}var $=new n.Cartographic,ee=new n.Cartographic,te={west:0,east:0},ae=new u.EllipsoidGeodesic;function re(r,o,i,n,s){if(s=e.defaultValue(s,new t.Rectangle),!e.defined(r)||r.length<3)return s.west=0,s.north=0,s.south=0,s.east=0,s;if(i===a.ArcType.RHUMB)return t.Rectangle.fromCartesianArray(r,o,s);ae.ellipsoid.equals(o)||(ae=new u.EllipsoidGeodesic(void 0,void 0,o)),s.west=Number.POSITIVE_INFINITY,s.east=Number.NEGATIVE_INFINITY,s.south=Number.POSITIVE_INFINITY,s.north=Number.NEGATIVE_INFINITY,te.west=Number.POSITIVE_INFINITY,te.east=Number.NEGATIVE_INFINITY;for(var l,c=1/h.CesiumMath.chordLength(n,o.maximumRadius),p=r.length,y=o.cartesianToCartographic(r[0],ee),d=$,g=1;g<p;g++)l=d,d=y,y=o.cartesianToCartographic(r[g],l),ae.setEndPoints(d,y),ie(ae,c,s,te);return l=d,d=y,y=o.cartesianToCartographic(r[0],l),ae.setEndPoints(d,y),ie(ae,c,s,te),s.east-s.west>te.west-te.east&&(s.east=te.east,s.west=te.west),s}var oe=new n.Cartographic;function ie(e,t,a,r){for(var o=e.surfaceDistance,i=Math.ceil(o*t),n=i>0?o/(i-1):Number.POSITIVE_INFINITY,s=0,l=0;l<i;l++){var u=e.interpolateUsingSurfaceDistance(s,oe);s+=n;var c=u.longitude,p=u.latitude;a.west=Math.min(a.west,c),a.east=Math.max(a.east,c),a.south=Math.min(a.south,p),a.north=Math.max(a.north,p),r.west=c>0?Math.min(c,r.west):r.west,r.east=c<0?Math.max(c,r.east):r.east}}var ne=[];function se(e,t,a,r,o,i,n,s,l,u){var p,d={walls:[]};if(i||n){var g,h,f=b.PolygonGeometryLibrary.createGeometryFromPositions(e,t,a,o,s,l),_=f.attributes.position.values,P=f.indices;if(i&&n){var x=_.concat(_);g=x.length/3,(h=m.IndexDatatype.createTypedArray(g,2*P.length)).set(P);var C=P.length,w=g/2;for(p=0;p<C;p+=3){var T=h[p]+w,A=h[p+1]+w,E=h[p+2]+w;h[p+C]=E,h[p+1+C]=A,h[p+2+C]=T}if(f.attributes.position.values=x,o&&s.normal){var I=f.attributes.normal.values;f.attributes.normal.values=new Float32Array(x.length),f.attributes.normal.values.set(I)}f.indices=h}else if(n){for(g=_.length/3,h=m.IndexDatatype.createTypedArray(g,P.length),p=0;p<P.length;p+=3)h[p]=P[p+2],h[p+1]=P[p+1],h[p+2]=P[p];f.indices=h}d.topAndBottom=new y.GeometryInstance({geometry:f})}var G,V=r.outerRing,F=c.EllipsoidTangentPlane.fromPoints(V,e),N=F.projectPointsOntoPlane(V,ne),H=v.PolygonPipeline.computeWindingOrder2D(N);H===v.WindingOrder.CLOCKWISE&&(V=V.slice().reverse()),u&&(G=b.PolygonGeometryLibrary.computeWallGeometry(V,e,a,o,l),d.walls.push(new y.GeometryInstance({geometry:G})));var O=r.holes;for(p=0;p<O.length;p++){var R=O[p];N=(F=c.EllipsoidTangentPlane.fromPoints(R,e)).projectPointsOntoPlane(R,ne),(H=v.PolygonPipeline.computeWindingOrder2D(N))===v.WindingOrder.COUNTER_CLOCKWISE&&(R=R.slice().reverse()),G=b.PolygonGeometryLibrary.computeWallGeometry(R,e,a,o,l),d.walls.push(new y.GeometryInstance({geometry:G}))}return d}function le(r){var o=r.polygonHierarchy,i=e.defaultValue(r.vertexFormat,_.VertexFormat.DEFAULT),n=e.defaultValue(r.ellipsoid,t.Ellipsoid.WGS84),s=e.defaultValue(r.granularity,h.CesiumMath.RADIANS_PER_DEGREE),l=e.defaultValue(r.stRotation,0),u=e.defaultValue(r.perPositionHeight,!1),c=u&&e.defined(r.extrudedHeight),p=e.defaultValue(r.height,0),y=e.defaultValue(r.extrudedHeight,p);if(!c){var d=Math.max(p,y);y=Math.min(p,y),p=d}this._vertexFormat=_.VertexFormat.clone(i),this._ellipsoid=t.Ellipsoid.clone(n),this._granularity=s,this._stRotation=l,this._height=p,this._extrudedHeight=y,this._closeTop=e.defaultValue(r.closeTop,!0),this._closeBottom=e.defaultValue(r.closeBottom,!0),this._extrudeOutering=e.defaultValue(r.extrudeOutering,!0),this._polygonHierarchy=o,this._perPositionHeight=u,this._perPositionHeightExtrude=c,this._shadowVolume=e.defaultValue(r.shadowVolume,!1),this._workerName="createPolygonGeometry",this._offsetAttribute=r.offsetAttribute,this._arcType=e.defaultValue(r.arcType,a.ArcType.GEODESIC),this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0,this.packedLength=b.PolygonGeometryLibrary.computeHierarchyPackedLength(o)+t.Ellipsoid.packedLength+_.VertexFormat.packedLength+12}le.fromPositions=function(t){return new le({polygonHierarchy:{positions:(t=e.defaultValue(t,e.defaultValue.EMPTY_OBJECT)).positions},height:t.height,extrudedHeight:t.extrudedHeight,vertexFormat:t.vertexFormat,stRotation:t.stRotation,ellipsoid:t.ellipsoid,granularity:t.granularity,perPositionHeight:t.perPositionHeight,closeTop:t.closeTop,closeBottom:t.closeBottom,offsetAttribute:t.offsetAttribute,arcType:t.arcType})},le.pack=function(a,r,o){return o=e.defaultValue(o,0),o=b.PolygonGeometryLibrary.packPolygonHierarchy(a._polygonHierarchy,r,o),t.Ellipsoid.pack(a._ellipsoid,r,o),o+=t.Ellipsoid.packedLength,_.VertexFormat.pack(a._vertexFormat,r,o),o+=_.VertexFormat.packedLength,r[o++]=a._height,r[o++]=a._extrudedHeight,r[o++]=a._granularity,r[o++]=a._stRotation,r[o++]=a._perPositionHeightExtrude?1:0,r[o++]=a._perPositionHeight?1:0,r[o++]=a._closeTop?1:0,r[o++]=a._closeBottom?1:0,r[o++]=a._shadowVolume?1:0,r[o++]=e.defaultValue(a._offsetAttribute,-1),r[o++]=a._arcType,r[o]=a.packedLength,r};var ue=t.Ellipsoid.clone(t.Ellipsoid.UNIT_SPHERE),ce=new _.VertexFormat,pe={polygonHierarchy:{}};return le.unpack=function(a,r,o){r=e.defaultValue(r,0);var i=b.PolygonGeometryLibrary.unpackPolygonHierarchy(a,r);r=i.startingIndex,delete i.startingIndex;var n=t.Ellipsoid.unpack(a,r,ue);r+=t.Ellipsoid.packedLength;var s=_.VertexFormat.unpack(a,r,ce);r+=_.VertexFormat.packedLength;var l=a[r++],u=a[r++],c=a[r++],p=a[r++],y=1===a[r++],d=1===a[r++],g=1===a[r++],m=1===a[r++],h=1===a[r++],f=a[r++],v=a[r++],P=a[r];return e.defined(o)||(o=new le(pe)),o._polygonHierarchy=i,o._ellipsoid=t.Ellipsoid.clone(n,o._ellipsoid),o._vertexFormat=_.VertexFormat.clone(s,o._vertexFormat),o._height=l,o._extrudedHeight=u,o._granularity=c,o._stRotation=p,o._perPositionHeightExtrude=y,o._perPositionHeight=d,o._closeTop=g,o._closeBottom=m,o._shadowVolume=h,o._offsetAttribute=-1===f?void 0:f,o._arcType=v,o.packedLength=P,o},le.computeRectangle=function(r,o){var i=e.defaultValue(r.granularity,h.CesiumMath.RADIANS_PER_DEGREE),n=e.defaultValue(r.arcType,a.ArcType.GEODESIC),s=r.polygonHierarchy,l=e.defaultValue(r.ellipsoid,t.Ellipsoid.WGS84);return re(s.positions,l,n,i,o)},le.createGeometry=function(t){var a=t._vertexFormat,o=t._ellipsoid,n=t._granularity,s=t._stRotation,u=t._polygonHierarchy,f=t._perPositionHeight,_=t._closeTop,P=t._closeBottom,x=t._arcType,C=u.positions;if(!(C.length<3)){var w=c.EllipsoidTangentPlane.fromPoints(C,o),T=b.PolygonGeometryLibrary.polygonsFromHierarchy(u,w.projectPointsOntoPlane.bind(w),!f,o),A=T.hierarchy,E=T.polygons;if(0!==A.length){C=A[0].outerRing;var I,G=b.PolygonGeometryLibrary.computeBoundingRectangle(w.plane.normal,w.projectPointOntoPlane.bind(w),C,s,D),V=[],F=t._height,N=t._extrudedHeight,H={perPositionHeight:f,vertexFormat:a,geometry:void 0,tangentPlane:w,boundingRectangle:G,ellipsoid:o,stRotation:s,bottom:!1,top:!0,wall:!1,extrude:!1,arcType:x};if(t._perPositionHeightExtrude||!h.CesiumMath.equalsEpsilon(F,N,0,h.CesiumMath.EPSILON2))for(H.extrude=!0,H.top=_,H.bottom=P,H.shadowVolume=t._shadowVolume,H.offsetAttribute=t._offsetAttribute,I=0;I<E.length;I++){var O,R=se(o,E[I],n,A[I],f,_,P,a,x,t._extrudeOutering);_&&P?(O=R.topAndBottom,H.geometry=b.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(O.geometry,F,N,o,f)):_?((O=R.topAndBottom).geometry.attributes.position.values=v.PolygonPipeline.scaleToGeodeticHeight(O.geometry.attributes.position.values,F,o,!f),H.geometry=O.geometry):P&&((O=R.topAndBottom).geometry.attributes.position.values=v.PolygonPipeline.scaleToGeodeticHeight(O.geometry.attributes.position.values,N,o,!0),H.geometry=O.geometry),(_||P)&&(H.wall=!1,O.geometry=X(H),V.push(O));var L=R.walls;H.wall=!0;for(var M=0;M<L.length;M++){var S=L[M];H.geometry=b.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(S.geometry,F,N,o,f),S.geometry=X(H),V.push(S)}}else for(I=0;I<E.length;I++){var B=new y.GeometryInstance({geometry:b.PolygonGeometryLibrary.createGeometryFromPositions(o,E[I],n,f,a,x)});if(B.geometry.attributes.position.values=v.PolygonPipeline.scaleToGeodeticHeight(B.geometry.attributes.position.values,F,o,!f),H.geometry=B.geometry,B.geometry=X(H),e.defined(t._offsetAttribute)){var k=B.geometry.attributes.position.values.length,z=new Uint8Array(k/3),Y=t._offsetAttribute===d.GeometryOffsetAttribute.NONE?0:1;r.arrayFill(z,Y),B.geometry.attributes.applyOffset=new p.GeometryAttribute({componentDatatype:l.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:z})}V.push(B)}var U=g.GeometryPipeline.combineInstances(V)[0];U.attributes.position.values=new Float64Array(U.attributes.position.values),U.indices=m.IndexDatatype.createTypedArray(U.attributes.position.values.length/3,U.indices);var W=U.attributes,j=i.BoundingSphere.fromVertices(W.position.values);return a.position||delete W.position,new p.Geometry({attributes:W,indices:U.indices,primitiveType:U.primitiveType,boundingSphere:j,offsetAttribute:t._offsetAttribute})}}},le.createShadowVolume=function(e,t,a){var r=e._granularity,o=e._ellipsoid,i=t(r,o),n=a(r,o);return new le({polygonHierarchy:e._polygonHierarchy,ellipsoid:o,stRotation:e._stRotation,granularity:r,perPositionHeight:!1,extrudedHeight:i,height:n,vertexFormat:_.VertexFormat.POSITION_ONLY,shadowVolume:!0,arcType:e._arcType})},Object.defineProperties(le.prototype,{rectangle:{get:function(){if(!e.defined(this._rectangle)){var t=this._polygonHierarchy.positions;this._rectangle=re(t,this._ellipsoid,this._arcType,this._granularity)}return this._rectangle}},textureCoordinateRotationPoints:{get:function(){return e.defined(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=function(e){var t=-e._stRotation;if(0===t)return[0,0,0,1,1,0];var a=e._ellipsoid,r=e._polygonHierarchy.positions,o=e.rectangle;return p.Geometry._textureCoordinateRotationPoints(r,t,a,o)}(this)),this._textureCoordinateRotationPoints}}}),function(a,r){return e.defined(r)&&(a=le.unpack(a,r)),a._ellipsoid=t.Ellipsoid.clone(a._ellipsoid),le.createGeometry(a)}}));
|