1
Surpriseplus
2022-09-16 a7e5110ef3f5fe3c9205f7d1a526b9fbbb55d826
1
define(["./when-77f4e3be","./Check-d71f548f","./Math-b81aa1f1","./Cartesian2-69a87134","./Transforms-03dbcaf7","./RuntimeError-34dd6124","./WebGLConstants-3e40d443","./ComponentDatatype-af4852df","./GeometryAttribute-d15db730","./GeometryAttributes-0175f743","./AttributeCompression-b43e055a","./GeometryPipeline-8501d77d","./EncodedCartesian3-ab4754c9","./IndexDatatype-41885adf","./IntersectionTests-ad3a0195","./Plane-a18bfa39","./GeometryOffsetAttribute-1d161b37","./VertexFormat-bbe2af43","./GeometryInstance-0fd1b866","./arrayRemoveDuplicates-64383b1a","./BoundingRectangle-ea4a050c","./EllipsoidTangentPlane-5dd5582e","./ArcType-861b5442","./EllipsoidRhumbLine-28fc0dda","./PolygonPipeline-9a882b7c","./PolygonGeometryLibrary-0c0d3129","./EllipsoidGeodesic-be0f0da9"],function(Q,e,q,K,Z,t,r,J,X,a,o,D,i,L,n,s,$,v,N,l,u,H,c,p,R,M,m){"use strict";var y=new K.Cartographic,g=new K.Cartographic;function ee(e,t,r,a){var o=a.cartesianToCartographic(e,y).height,i=a.cartesianToCartographic(t,g);i.height=o,a.cartographicToCartesian(i,t);var n=a.cartesianToCartographic(r,g);n.height=o-100,a.cartographicToCartesian(n,r)}var S=new u.BoundingRectangle,te=new K.Cartesian3,re=new K.Cartesian3,ae=new K.Cartesian3,oe=new K.Cartesian3,ie=new K.Cartesian3,ne=new K.Cartesian3,se=new K.Cartesian3,le=new K.Cartesian3,ue=new K.Cartesian3,pe=new K.Cartesian2,ce=new K.Cartesian2,me=new K.Cartesian3,ye=new Z.Quaternion,ge=new Z.Matrix3,de=new Z.Matrix3;function B(e){var t=e.vertexFormat,r=e.geometry,a=e.shadowVolume,o=r.attributes.position.values,i=o.length,n=e.wall,s=e.top||n,l=e.bottom||n;if(t.st||t.normal||t.tangent||t.bitangent||a){var u=e.boundingRectangle,p=e.tangentPlane,c=e.ellipsoid,m=e.stRotation,y=e.perPositionHeight,g=pe;g.x=u.x,g.y=u.y;var d,h=t.st?new Float32Array(i/3*2):void 0,f=new Float32Array(i/3),v=0;t.normal&&(d=y&&s&&!n?r.attributes.normal.values:new Float32Array(i));var b=t.tangent?new Float32Array(i):void 0,_=t.bitangent?new Float32Array(i):void 0,P=a?new Float32Array(i):void 0,C=0,w=0,T=re,x=ae,A=oe,I=!0,E=ge,G=de;if(0!==m){var O=Z.Quaternion.fromAxisAngle(p._plane.normal,m,ye);E=Z.Matrix3.fromQuaternion(O,E),O=Z.Quaternion.fromAxisAngle(p._plane.normal,-m,ye),G=Z.Matrix3.fromQuaternion(O,G)}else E=Z.Matrix3.clone(Z.Matrix3.IDENTITY,E),G=Z.Matrix3.clone(Z.Matrix3.IDENTITY,G);var F=0,V=0;s&&l&&(F=i/2,V=i/3,i/=2);for(var D=0;D<i;D+=3){var L=K.Cartesian3.fromArray(o,D,me);if(t.st){var N=Z.Matrix3.multiplyByVector(E,L,te);N=c.scaleToGeodeticSurface(N,N);var H=p.projectPointOntoPlane(N,ce);K.Cartesian2.subtract(H,g,H);var R=q.CesiumMath.clamp(H.x/u.width,0,1),M=q.CesiumMath.clamp(H.y/u.height,0,1);l&&(h[C+V]=R,h[C+1+V]=M),s&&(h[C]=R,h[C+1]=M);var S=K.Cartographic.fromCartesian(L);f[v++]=Math.floor(S.height+1e-5),C+=2}if(t.normal||t.tangent||t.bitangent||a){var B=w+1,k=w+2;if(n){if(D+3<i){var z=K.Cartesian3.fromArray(o,D+3,ie);if(I){var W=K.Cartesian3.fromArray(o,D+i,ne);y&&ee(L,z,W,c),K.Cartesian3.subtract(z,L,z),K.Cartesian3.subtract(W,L,W),T=K.Cartesian3.normalize(K.Cartesian3.cross(W,z,T),T),I=!1}K.Cartesian3.equalsEpsilon(z,L,q.CesiumMath.EPSILON10)&&(I=!0)}(t.tangent||t.bitangent)&&(A=c.geodeticSurfaceNormal(L,A),t.tangent&&(x=K.Cartesian3.normalize(K.Cartesian3.cross(A,T,x),x)))}else T=c.geodeticSurfaceNormal(L,T),(t.tangent||t.bitangent)&&(y&&(se=K.Cartesian3.fromArray(d,w,se),le=K.Cartesian3.cross(K.Cartesian3.UNIT_Z,se,le),le=K.Cartesian3.normalize(Z.Matrix3.multiplyByVector(G,le,le),le),t.bitangent&&(ue=K.Cartesian3.normalize(K.Cartesian3.cross(se,le,ue),ue))),x=K.Cartesian3.cross(K.Cartesian3.UNIT_Z,T,x),x=K.Cartesian3.normalize(Z.Matrix3.multiplyByVector(G,x,x),x),t.bitangent&&(A=K.Cartesian3.normalize(K.Cartesian3.cross(T,x,A),A)));t.normal&&(e.wall?(d[w+F]=T.x,d[B+F]=T.y,d[k+F]=T.z):l&&(d[w+F]=-T.x,d[B+F]=-T.y,d[k+F]=-T.z),(s&&!y||n)&&(d[w]=T.x,d[B]=T.y,d[k]=T.z)),a&&(n&&(T=c.geodeticSurfaceNormal(L,T)),P[w+F]=-T.x,P[B+F]=-T.y,P[k+F]=-T.z),t.tangent&&(e.wall?(b[w+F]=x.x,b[B+F]=x.y,b[k+F]=x.z):l&&(b[w+F]=-x.x,b[B+F]=-x.y,b[k+F]=-x.z),s&&(y?(b[w]=le.x,b[B]=le.y,b[k]=le.z):(b[w]=x.x,b[B]=x.y,b[k]=x.z))),t.bitangent&&(l&&(_[w+F]=A.x,_[B+F]=A.y,_[k+F]=A.z),s&&(y?(_[w]=ue.x,_[B]=ue.y,_[k]=ue.z):(_[w]=A.x,_[B]=A.y,_[k]=A.z))),w+=3}}t.st&&(r.attributes.st=new X.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:h}),r.attributes.height=new X.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:1,values:f})),t.normal&&(r.attributes.normal=new X.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:d})),t.tangent&&(r.attributes.tangent=new X.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:b})),t.bitangent&&(r.attributes.bitangent=new X.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:_})),a&&(r.attributes.extrudeDirection=new X.GeometryAttribute({componentDatatype:J.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:P}))}if(e.extrude&&Q.defined(e.offsetAttribute)){var Y=o.length/3,U=new Uint8Array(Y);if(e.offsetAttribute===$.GeometryOffsetAttribute.TOP)s&&l||n?U=$.arrayFill(U,1,0,Y/2):s&&(U=$.arrayFill(U,1));else{var j=e.offsetAttribute===$.GeometryOffsetAttribute.NONE?0:1;U=$.arrayFill(U,j)}r.attributes.applyOffset=new X.GeometryAttribute({componentDatatype:J.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:U})}return r}var d=new K.Cartographic,h=new K.Cartographic,f={westOverIDL:0,eastOverIDL:0},b=new m.EllipsoidGeodesic;function _(e,t,r,a,o){if(o=Q.defaultValue(o,new K.Rectangle),!Q.defined(e)||e.length<3)return o.west=0,o.north=0,o.south=0,o.east=0,o;if(r===c.ArcType.RHUMB)return K.Rectangle.fromCartesianArray(e,t,o);b.ellipsoid.equals(t)||(b=new m.EllipsoidGeodesic(void 0,void 0,t)),o.west=Number.POSITIVE_INFINITY,o.east=Number.NEGATIVE_INFINITY,o.south=Number.POSITIVE_INFINITY,o.north=Number.NEGATIVE_INFINITY,f.westOverIDL=Number.POSITIVE_INFINITY,f.eastOverIDL=Number.NEGATIVE_INFINITY;for(var i,n=1/q.CesiumMath.chordLength(a,t.maximumRadius),s=e.length,l=t.cartesianToCartographic(e[0],h),u=d,p=1;p<s;p++)i=u,u=l,l=t.cartesianToCartographic(e[p],i),b.setEndPoints(u,l),C(b,n,o,f);return i=u,u=l,l=t.cartesianToCartographic(e[0],i),b.setEndPoints(u,l),C(b,n,o,f),o.east-o.west>f.eastOverIDL-f.westOverIDL&&(o.west=f.westOverIDL,o.east=f.eastOverIDL,o.east>q.CesiumMath.PI&&(o.east=o.east-q.CesiumMath.TWO_PI),o.west>q.CesiumMath.PI&&(o.west=o.west-q.CesiumMath.TWO_PI)),o}var P=new K.Cartographic;function C(e,t,r,a){for(var o=e.surfaceDistance,i=Math.ceil(o*t),n=0<i?o/(i-1):Number.POSITIVE_INFINITY,s=0,l=0;l<i;l++){var u=e.interpolateUsingSurfaceDistance(s,P);s+=n;var p=u.longitude,c=u.latitude;r.west=Math.min(r.west,p),r.east=Math.max(r.east,p),r.south=Math.min(r.south,c),r.north=Math.max(r.north,c);var m=0<=p?p:p+q.CesiumMath.TWO_PI;a.westOverIDL=Math.min(a.westOverIDL,m),a.eastOverIDL=Math.max(a.eastOverIDL,m)}}var O=[];function k(e,t,r,a,o,i,n,s,l){var u,p={walls:[]};if(i||n){var c,m,y=M.PolygonGeometryLibrary.createGeometryFromPositions(e,t,r,o,s,l),g=y.attributes.position.values,d=y.indices;if(i&&n){var h=g.concat(g);c=h.length/3,(m=L.IndexDatatype.createTypedArray(c,2*d.length)).set(d);var f=d.length,v=c/2;for(u=0;u<f;u+=3){var b=m[u]+v,_=m[u+1]+v,P=m[u+2]+v;m[u+f]=P,m[u+1+f]=_,m[u+2+f]=b}if(y.attributes.position.values=h,o&&s.normal){var C=y.attributes.normal.values;y.attributes.normal.values=new Float32Array(h.length),y.attributes.normal.values.set(C)}y.indices=m}else if(n){for(c=g.length/3,m=L.IndexDatatype.createTypedArray(c,d.length),u=0;u<d.length;u+=3)m[u]=d[u+2],m[u+1]=d[u+1],m[u+2]=d[u];y.indices=m}p.topAndBottom=new N.GeometryInstance({geometry:y})}var w=a.outerRing,T=H.EllipsoidTangentPlane.fromPoints(w,e),x=T.projectPointsOntoPlane(w,O),A=R.PolygonPipeline.computeWindingOrder2D(x);A===R.WindingOrder.CLOCKWISE&&(w=w.slice().reverse());var I=M.PolygonGeometryLibrary.computeWallGeometry(w,e,r,o,l);p.walls.push(new N.GeometryInstance({geometry:I}));var E=a.holes;for(u=0;u<E.length;u++){var G=E[u];x=(T=H.EllipsoidTangentPlane.fromPoints(G,e)).projectPointsOntoPlane(G,O),(A=R.PolygonPipeline.computeWindingOrder2D(x))===R.WindingOrder.COUNTER_CLOCKWISE&&(G=G.slice().reverse()),I=M.PolygonGeometryLibrary.computeWallGeometry(G,e,r,o,l),p.walls.push(new N.GeometryInstance({geometry:I}))}return p}function w(e){var t=e.polygonHierarchy,r=Q.defaultValue(e.vertexFormat,v.VertexFormat.DEFAULT),a=Q.defaultValue(e.ellipsoid,K.Ellipsoid.WGS84),o=Q.defaultValue(e.granularity,q.CesiumMath.RADIANS_PER_DEGREE),i=Q.defaultValue(e.stRotation,0),n=Q.defaultValue(e.perPositionHeight,!1),s=n&&Q.defined(e.extrudedHeight),l=Q.defaultValue(e.height,0),u=Q.defaultValue(e.extrudedHeight,l);if(!s){var p=Math.max(l,u);u=Math.min(l,u),l=p}this._vertexFormat=v.VertexFormat.clone(r),this._ellipsoid=K.Ellipsoid.clone(a),this._granularity=o,this._stRotation=i,this._height=l,this._extrudedHeight=u,this._closeTop=Q.defaultValue(e.closeTop,!0),this._closeBottom=Q.defaultValue(e.closeBottom,!0),this._polygonHierarchy=t,this._perPositionHeight=n,this._perPositionHeightExtrude=s,this._shadowVolume=Q.defaultValue(e.shadowVolume,!1),this._workerName="createPolygonGeometry",this._offsetAttribute=e.offsetAttribute,this._arcType=Q.defaultValue(e.arcType,c.ArcType.GEODESIC),this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0,this.packedLength=M.PolygonGeometryLibrary.computeHierarchyPackedLength(t)+K.Ellipsoid.packedLength+v.VertexFormat.packedLength+12}w.fromPositions=function(e){return new w({polygonHierarchy:{positions:(e=Q.defaultValue(e,Q.defaultValue.EMPTY_OBJECT)).positions},height:e.height,extrudedHeight:e.extrudedHeight,vertexFormat:e.vertexFormat,stRotation:e.stRotation,ellipsoid:e.ellipsoid,granularity:e.granularity,perPositionHeight:e.perPositionHeight,closeTop:e.closeTop,closeBottom:e.closeBottom,offsetAttribute:e.offsetAttribute,arcType:e.arcType})},w.pack=function(e,t,r){return r=Q.defaultValue(r,0),r=M.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,r),K.Ellipsoid.pack(e._ellipsoid,t,r),r+=K.Ellipsoid.packedLength,v.VertexFormat.pack(e._vertexFormat,t,r),r+=v.VertexFormat.packedLength,t[r++]=e._height,t[r++]=e._extrudedHeight,t[r++]=e._granularity,t[r++]=e._stRotation,t[r++]=e._perPositionHeightExtrude?1:0,t[r++]=e._perPositionHeight?1:0,t[r++]=e._closeTop?1:0,t[r++]=e._closeBottom?1:0,t[r++]=e._shadowVolume?1:0,t[r++]=Q.defaultValue(e._offsetAttribute,-1),t[r++]=e._arcType,t[r]=e.packedLength,t};var T=K.Ellipsoid.clone(K.Ellipsoid.UNIT_SPHERE),x=new v.VertexFormat,A={polygonHierarchy:{}};return w.unpack=function(e,t,r){t=Q.defaultValue(t,0);var a=M.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=a.startingIndex,delete a.startingIndex;var o=K.Ellipsoid.unpack(e,t,T);t+=K.Ellipsoid.packedLength;var i=v.VertexFormat.unpack(e,t,x);t+=v.VertexFormat.packedLength;var n=e[t++],s=e[t++],l=e[t++],u=e[t++],p=1===e[t++],c=1===e[t++],m=1===e[t++],y=1===e[t++],g=1===e[t++],d=e[t++],h=e[t++],f=e[t];return Q.defined(r)||(r=new w(A)),r._polygonHierarchy=a,r._ellipsoid=K.Ellipsoid.clone(o,r._ellipsoid),r._vertexFormat=v.VertexFormat.clone(i,r._vertexFormat),r._height=n,r._extrudedHeight=s,r._granularity=l,r._stRotation=u,r._perPositionHeightExtrude=p,r._perPositionHeight=c,r._closeTop=m,r._closeBottom=y,r._shadowVolume=g,r._offsetAttribute=-1===d?void 0:d,r._arcType=h,r.packedLength=f,r},w.computeRectangle=function(e,t){var r=Q.defaultValue(e.granularity,q.CesiumMath.RADIANS_PER_DEGREE),a=Q.defaultValue(e.arcType,c.ArcType.GEODESIC),o=e.polygonHierarchy,i=Q.defaultValue(e.ellipsoid,K.Ellipsoid.WGS84);return _(o.positions,i,a,r,t)},w.createGeometry=function(e){var t=e._vertexFormat,r=e._ellipsoid,a=e._granularity,o=e._stRotation,i=e._polygonHierarchy,n=e._perPositionHeight,s=e._closeTop,l=e._closeBottom,u=e._arcType,p=i.positions;if(!(p.length<3)){var c=H.EllipsoidTangentPlane.fromPoints(p,r),m=M.PolygonGeometryLibrary.polygonsFromHierarchy(i,c.projectPointsOntoPlane.bind(c),!n,r),y=m.hierarchy,g=m.polygons;if(0!==y.length){p=y[0].outerRing;var d,h=M.PolygonGeometryLibrary.computeBoundingRectangle(c.plane.normal,c.projectPointOntoPlane.bind(c),p,o,S),f=[],v=e._height,b=e._extrudedHeight,_={perPositionHeight:n,vertexFormat:t,geometry:void 0,tangentPlane:c,boundingRectangle:h,ellipsoid:r,stRotation:o,bottom:!1,top:!0,wall:!1,extrude:!1,arcType:u};if(e._perPositionHeightExtrude||!q.CesiumMath.equalsEpsilon(v,b,0,q.CesiumMath.EPSILON2))for(_.extrude=!0,_.top=s,_.bottom=l,_.shadowVolume=e._shadowVolume,_.offsetAttribute=e._offsetAttribute,d=0;d<g.length;d++){var P,C=k(r,g[d],a,y[d],n,s,l,t,u);s&&l?(P=C.topAndBottom,_.geometry=M.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(P.geometry,v,b,r,n)):s?((P=C.topAndBottom).geometry.attributes.position.values=R.PolygonPipeline.scaleToGeodeticHeight(P.geometry.attributes.position.values,v,r,!n),_.geometry=P.geometry):l&&((P=C.topAndBottom).geometry.attributes.position.values=R.PolygonPipeline.scaleToGeodeticHeight(P.geometry.attributes.position.values,b,r,!0),_.geometry=P.geometry),(s||l)&&(_.wall=!1,P.geometry=B(_),f.push(P));var w=C.walls;_.wall=!0;for(var T=0;T<w.length;T++){var x=w[T];_.geometry=M.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(x.geometry,v,b,r,n),x.geometry=B(_),f.push(x)}}else for(d=0;d<g.length;d++){var A=new N.GeometryInstance({geometry:M.PolygonGeometryLibrary.createGeometryFromPositions(r,g[d],a,n,t,u)});if(A.geometry.attributes.position.values=R.PolygonPipeline.scaleToGeodeticHeight(A.geometry.attributes.position.values,v,r,!n),_.geometry=A.geometry,A.geometry=B(_),Q.defined(e._offsetAttribute)){var I=A.geometry.attributes.position.values.length,E=new Uint8Array(I/3),G=e._offsetAttribute===$.GeometryOffsetAttribute.NONE?0:1;$.arrayFill(E,G),A.geometry.attributes.applyOffset=new X.GeometryAttribute({componentDatatype:J.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:E})}f.push(A)}var O=D.GeometryPipeline.combineInstances(f)[0];O.attributes.position.values=new Float64Array(O.attributes.position.values),O.indices=L.IndexDatatype.createTypedArray(O.attributes.position.values.length/3,O.indices);var F=O.attributes,V=Z.BoundingSphere.fromVertices(F.position.values);return t.position||delete F.position,new X.Geometry({attributes:F,indices:O.indices,primitiveType:O.primitiveType,boundingSphere:V,offsetAttribute:e._offsetAttribute})}}},w.createShadowVolume=function(e,t,r){var a=e._granularity,o=e._ellipsoid,i=t(a,o),n=r(a,o);return new w({polygonHierarchy:e._polygonHierarchy,ellipsoid:o,stRotation:e._stRotation,granularity:a,perPositionHeight:!1,extrudedHeight:i,height:n,vertexFormat:v.VertexFormat.POSITION_ONLY,shadowVolume:!0,arcType:e._arcType})},Object.defineProperties(w.prototype,{rectangle:{get:function(){if(!Q.defined(this._rectangle)){var e=this._polygonHierarchy.positions;this._rectangle=_(e,this._ellipsoid,this._arcType,this._granularity)}return this._rectangle}},textureCoordinateRotationPoints:{get:function(){return Q.defined(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=function(e){var t=-e._stRotation;if(0==t)return[0,0,0,1,1,0];var r=e._ellipsoid,a=e._polygonHierarchy.positions,o=e.rectangle;return X.Geometry._textureCoordinateRotationPoints(a,t,r,o)}(this)),this._textureCoordinateRotationPoints}}}),function(e,t){return Q.defined(t)&&(e=w.unpack(e,t)),e._ellipsoid=K.Ellipsoid.clone(e._ellipsoid),w.createGeometry(e)}});