1
Surpriseplus
2022-09-16 a7e5110ef3f5fe3c9205f7d1a526b9fbbb55d826
1
define(["./when-e3a49219","./Matrix2-ae0e0b05","./ArcType-5c308c35","./GeometryOffsetAttribute-9dbaeacc","./BoundingRectangle-61e59108","./Transforms-a6362ad2","./RuntimeError-ffc802eb","./ComponentDatatype-64cf6611","./EllipsoidGeodesic-524df442","./EllipsoidTangentPlane-e3af9e65","./GeometryAttribute-50aef525","./GeometryInstance-81c02fd9","./GeometryPipeline-50591033","./IndexDatatype-e12e2493","./PolygonGeometryLibrary-e16e0c71","./PolygonPipeline-2bbe6eb1","./VertexFormat-9bafa8ef","./PixelFormat-83d70a69","./WebGLConstants-1c8239cc","./combine-c7a1ec8a","./AxisAlignedBoundingBox-699685f5","./IntersectionTests-8be403d7","./Plane-2bf1bb80","./AttributeCompression-8cb78525","./EncodedCartesian3-f1386330","./arrayRemoveDuplicates-328bac4c","./EllipsoidRhumbLine-b6518e5c","./GeometryAttributes-3db3f2c9"],(function(e,t,r,a,o,i,n,s,l,u,c,p,m,y,g,d,h,f,v,b,_,P,x,w,C,T,I,A){"use strict";var E=new t.Cartographic,G=new t.Cartographic;function O(e,t,r,a){var o=a.cartesianToCartographic(e,E).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 V=new o.BoundingRectangle,F=new t.Cartesian3,D=new t.Cartesian3,L=new t.Cartesian3,N=new t.Cartesian3,H=new t.Cartesian3,R=new t.Cartesian3,M=new t.Cartesian3,S=new t.Cartesian3,B=new t.Cartesian3,k=new t.Cartesian2,z=new t.Cartesian2,W=new t.Cartesian3,Y=new i.Quaternion,U=new t.Matrix3,j=new t.Matrix3;function Q(r){var o=r.vertexFormat,n=r.geometry,l=r.shadowVolume,u=n.attributes.position.values,p=u.length,m=r.wall,y=r.top||m,g=r.bottom||m;if(o.st||o.normal||o.tangent||o.bitangent||l){var d=r.boundingRectangle,h=r.tangentPlane,f=r.ellipsoid,v=r.stRotation,b=r.perPositionHeight,_=k;_.x=d.x,_.y=d.y;var P,x=o.st?new Float32Array(p/3*2):void 0;o.normal&&(P=b&&y&&!m?n.attributes.normal.values:new Float32Array(p));var w=o.tangent?new Float32Array(p):void 0,C=o.bitangent?new Float32Array(p):void 0,T=l?new Float32Array(p):void 0,I=0,A=0,E=D,G=L,V=N,Q=!0,q=U,K=j;if(0!==v){var Z=i.Quaternion.fromAxisAngle(h._plane.normal,v,Y);q=t.Matrix3.fromQuaternion(Z,q),Z=i.Quaternion.fromAxisAngle(h._plane.normal,-v,Y),K=t.Matrix3.fromQuaternion(Z,K)}else q=t.Matrix3.clone(t.Matrix3.IDENTITY,q),K=t.Matrix3.clone(t.Matrix3.IDENTITY,K);var J=0,X=0;y&&g&&(J=p/2,X=p/3,p/=2);for(var $=0;$<p;$+=3){var ee=t.Cartesian3.fromArray(u,$,W);if(o.st){var te=t.Matrix3.multiplyByVector(q,ee,F);te=f.scaleToGeodeticSurface(te,te);var re=h.projectPointOntoPlane(te,z);t.Cartesian2.subtract(re,_,re);var ae=s.CesiumMath.clamp(re.x/d.width,0,1),oe=s.CesiumMath.clamp(re.y/d.height,0,1);g&&(x[I+X]=ae,x[I+1+X]=oe),y&&(x[I]=ae,x[I+1]=oe),I+=2}if(o.normal||o.tangent||o.bitangent||l){var ie=A+1,ne=A+2;if(m){if($+3<p){var se=t.Cartesian3.fromArray(u,$+3,H);if(Q){var le=t.Cartesian3.fromArray(u,$+p,R);b&&O(ee,se,le,f),t.Cartesian3.subtract(se,ee,se),t.Cartesian3.subtract(le,ee,le),E=t.Cartesian3.normalize(t.Cartesian3.cross(le,se,E),E),Q=!1}t.Cartesian3.equalsEpsilon(se,ee,s.CesiumMath.EPSILON10)&&(Q=!0)}(o.tangent||o.bitangent)&&(V=f.geodeticSurfaceNormal(ee,V),o.tangent&&(G=t.Cartesian3.normalize(t.Cartesian3.cross(V,E,G),G)))}else E=f.geodeticSurfaceNormal(ee,E),(o.tangent||o.bitangent)&&(b&&(M=t.Cartesian3.fromArray(P,A,M),S=t.Cartesian3.cross(t.Cartesian3.UNIT_Z,M,S),S=t.Cartesian3.normalize(t.Matrix3.multiplyByVector(K,S,S),S),o.bitangent&&(B=t.Cartesian3.normalize(t.Cartesian3.cross(M,S,B),B))),G=t.Cartesian3.cross(t.Cartesian3.UNIT_Z,E,G),G=t.Cartesian3.normalize(t.Matrix3.multiplyByVector(K,G,G),G),o.bitangent&&(V=t.Cartesian3.normalize(t.Cartesian3.cross(E,G,V),V)));o.normal&&(r.wall?(P[A+J]=E.x,P[ie+J]=E.y,P[ne+J]=E.z):g&&(P[A+J]=-E.x,P[ie+J]=-E.y,P[ne+J]=-E.z),(y&&!b||m)&&(P[A]=E.x,P[ie]=E.y,P[ne]=E.z)),l&&(m&&(E=f.geodeticSurfaceNormal(ee,E)),T[A+J]=-E.x,T[ie+J]=-E.y,T[ne+J]=-E.z),o.tangent&&(r.wall?(w[A+J]=G.x,w[ie+J]=G.y,w[ne+J]=G.z):g&&(w[A+J]=-G.x,w[ie+J]=-G.y,w[ne+J]=-G.z),y&&(b?(w[A]=S.x,w[ie]=S.y,w[ne]=S.z):(w[A]=G.x,w[ie]=G.y,w[ne]=G.z))),o.bitangent&&(g&&(C[A+J]=V.x,C[ie+J]=V.y,C[ne+J]=V.z),y&&(b?(C[A]=B.x,C[ie]=B.y,C[ne]=B.z):(C[A]=V.x,C[ie]=V.y,C[ne]=V.z))),A+=3}}o.st&&(n.attributes.st=new c.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:x})),o.normal&&(n.attributes.normal=new c.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:P})),o.tangent&&(n.attributes.tangent=new c.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:w})),o.bitangent&&(n.attributes.bitangent=new c.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:C})),l&&(n.attributes.extrudeDirection=new c.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:T}))}if(r.extrude&&e.defined(r.offsetAttribute)){var ue=u.length/3,ce=new Uint8Array(ue);if(r.offsetAttribute===a.GeometryOffsetAttribute.TOP)y&&g||m?ce=a.arrayFill(ce,1,0,ue/2):y&&(ce=a.arrayFill(ce,1));else{var pe=r.offsetAttribute===a.GeometryOffsetAttribute.NONE?0:1;ce=a.arrayFill(ce,pe)}n.attributes.applyOffset=new c.GeometryAttribute({componentDatatype:s.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:ce})}return n}var q=new t.Cartographic,K=new t.Cartographic,Z={westOverIDL:0,eastOverIDL:0},J=new l.EllipsoidGeodesic;function X(a,o,i,n,u){if(u=e.defaultValue(u,new t.Rectangle),!e.defined(a)||a.length<3)return u.west=0,u.north=0,u.south=0,u.east=0,u;if(i===r.ArcType.RHUMB)return t.Rectangle.fromCartesianArray(a,o,u);J.ellipsoid.equals(o)||(J=new l.EllipsoidGeodesic(void 0,void 0,o)),u.west=Number.POSITIVE_INFINITY,u.east=Number.NEGATIVE_INFINITY,u.south=Number.POSITIVE_INFINITY,u.north=Number.NEGATIVE_INFINITY,Z.westOverIDL=Number.POSITIVE_INFINITY,Z.eastOverIDL=Number.NEGATIVE_INFINITY;for(var c,p=1/s.CesiumMath.chordLength(n,o.maximumRadius),m=a.length,y=o.cartesianToCartographic(a[0],K),g=q,d=1;d<m;d++)c=g,g=y,y=o.cartesianToCartographic(a[d],c),J.setEndPoints(g,y),ee(J,p,u,Z);return c=g,g=y,y=o.cartesianToCartographic(a[0],c),J.setEndPoints(g,y),ee(J,p,u,Z),u.east-u.west>Z.eastOverIDL-Z.westOverIDL&&(u.west=Z.westOverIDL,u.east=Z.eastOverIDL,u.east>s.CesiumMath.PI&&(u.east=u.east-s.CesiumMath.TWO_PI),u.west>s.CesiumMath.PI&&(u.west=u.west-s.CesiumMath.TWO_PI)),u}var $=new t.Cartographic;function ee(e,t,r,a){for(var o=e.surfaceDistance,i=Math.ceil(o*t),n=i>0?o/(i-1):Number.POSITIVE_INFINITY,l=0,u=0;u<i;u++){var c=e.interpolateUsingSurfaceDistance(l,$);l+=n;var p=c.longitude,m=c.latitude;r.west=Math.min(r.west,p),r.east=Math.max(r.east,p),r.south=Math.min(r.south,m),r.north=Math.max(r.north,m);var y=p>=0?p:p+s.CesiumMath.TWO_PI;a.westOverIDL=Math.min(a.westOverIDL,y),a.eastOverIDL=Math.max(a.eastOverIDL,y)}}var te=[];function re(e,t,r,a,o,i,n,s,l){var c,m={walls:[]};if(i||n){var h,f,v=g.PolygonGeometryLibrary.createGeometryFromPositions(e,t,r,o,s,l),b=v.attributes.position.values,_=v.indices;if(i&&n){var P=b.concat(b);h=P.length/3,(f=y.IndexDatatype.createTypedArray(h,2*_.length)).set(_);var x=_.length,w=h/2;for(c=0;c<x;c+=3){var C=f[c]+w,T=f[c+1]+w,I=f[c+2]+w;f[c+x]=I,f[c+1+x]=T,f[c+2+x]=C}if(v.attributes.position.values=P,o&&s.normal){var A=v.attributes.normal.values;v.attributes.normal.values=new Float32Array(P.length),v.attributes.normal.values.set(A)}v.indices=f}else if(n){for(h=b.length/3,f=y.IndexDatatype.createTypedArray(h,_.length),c=0;c<_.length;c+=3)f[c]=_[c+2],f[c+1]=_[c+1],f[c+2]=_[c];v.indices=f}m.topAndBottom=new p.GeometryInstance({geometry:v})}var E=a.outerRing,G=u.EllipsoidTangentPlane.fromPoints(E,e),O=G.projectPointsOntoPlane(E,te),V=d.PolygonPipeline.computeWindingOrder2D(O);V===d.WindingOrder.CLOCKWISE&&(E=E.slice().reverse());var F=g.PolygonGeometryLibrary.computeWallGeometry(E,e,r,o,l);m.walls.push(new p.GeometryInstance({geometry:F}));var D=a.holes;for(c=0;c<D.length;c++){var L=D[c];O=(G=u.EllipsoidTangentPlane.fromPoints(L,e)).projectPointsOntoPlane(L,te),(V=d.PolygonPipeline.computeWindingOrder2D(O))===d.WindingOrder.COUNTER_CLOCKWISE&&(L=L.slice().reverse()),F=g.PolygonGeometryLibrary.computeWallGeometry(L,e,r,o,l),m.walls.push(new p.GeometryInstance({geometry:F}))}return m}function ae(a){var o=a.polygonHierarchy,i=e.defaultValue(a.vertexFormat,h.VertexFormat.DEFAULT),n=e.defaultValue(a.ellipsoid,t.Ellipsoid.WGS84),l=e.defaultValue(a.granularity,s.CesiumMath.RADIANS_PER_DEGREE),u=e.defaultValue(a.stRotation,0),c=e.defaultValue(a.perPositionHeight,!1),p=c&&e.defined(a.extrudedHeight),m=e.defaultValue(a.height,0),y=e.defaultValue(a.extrudedHeight,m);if(!p){var d=Math.max(m,y);y=Math.min(m,y),m=d}this._vertexFormat=h.VertexFormat.clone(i),this._ellipsoid=t.Ellipsoid.clone(n),this._granularity=l,this._stRotation=u,this._height=m,this._extrudedHeight=y,this._closeTop=e.defaultValue(a.closeTop,!0),this._closeBottom=e.defaultValue(a.closeBottom,!0),this._polygonHierarchy=o,this._perPositionHeight=c,this._perPositionHeightExtrude=p,this._shadowVolume=e.defaultValue(a.shadowVolume,!1),this._workerName="createPolygonGeometry",this._offsetAttribute=a.offsetAttribute,this._arcType=e.defaultValue(a.arcType,r.ArcType.GEODESIC),this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0,this.packedLength=g.PolygonGeometryLibrary.computeHierarchyPackedLength(o)+t.Ellipsoid.packedLength+h.VertexFormat.packedLength+12}ae.fromPositions=function(t){return new ae({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})},ae.pack=function(r,a,o){return o=e.defaultValue(o,0),o=g.PolygonGeometryLibrary.packPolygonHierarchy(r._polygonHierarchy,a,o),t.Ellipsoid.pack(r._ellipsoid,a,o),o+=t.Ellipsoid.packedLength,h.VertexFormat.pack(r._vertexFormat,a,o),o+=h.VertexFormat.packedLength,a[o++]=r._height,a[o++]=r._extrudedHeight,a[o++]=r._granularity,a[o++]=r._stRotation,a[o++]=r._perPositionHeightExtrude?1:0,a[o++]=r._perPositionHeight?1:0,a[o++]=r._closeTop?1:0,a[o++]=r._closeBottom?1:0,a[o++]=r._shadowVolume?1:0,a[o++]=e.defaultValue(r._offsetAttribute,-1),a[o++]=r._arcType,a[o]=r.packedLength,a};var oe=t.Ellipsoid.clone(t.Ellipsoid.UNIT_SPHERE),ie=new h.VertexFormat,ne={polygonHierarchy:{}};return ae.unpack=function(r,a,o){a=e.defaultValue(a,0);var i=g.PolygonGeometryLibrary.unpackPolygonHierarchy(r,a);a=i.startingIndex,delete i.startingIndex;var n=t.Ellipsoid.unpack(r,a,oe);a+=t.Ellipsoid.packedLength;var s=h.VertexFormat.unpack(r,a,ie);a+=h.VertexFormat.packedLength;var l=r[a++],u=r[a++],c=r[a++],p=r[a++],m=1===r[a++],y=1===r[a++],d=1===r[a++],f=1===r[a++],v=1===r[a++],b=r[a++],_=r[a++],P=r[a];return e.defined(o)||(o=new ae(ne)),o._polygonHierarchy=i,o._ellipsoid=t.Ellipsoid.clone(n,o._ellipsoid),o._vertexFormat=h.VertexFormat.clone(s,o._vertexFormat),o._height=l,o._extrudedHeight=u,o._granularity=c,o._stRotation=p,o._perPositionHeightExtrude=m,o._perPositionHeight=y,o._closeTop=d,o._closeBottom=f,o._shadowVolume=v,o._offsetAttribute=-1===b?void 0:b,o._arcType=_,o.packedLength=P,o},ae.computeRectangle=function(a,o){var i=e.defaultValue(a.granularity,s.CesiumMath.RADIANS_PER_DEGREE),n=e.defaultValue(a.arcType,r.ArcType.GEODESIC),l=a.polygonHierarchy,u=e.defaultValue(a.ellipsoid,t.Ellipsoid.WGS84);return X(l.positions,u,n,i,o)},ae.createGeometry=function(t){var r=t._vertexFormat,o=t._ellipsoid,n=t._granularity,l=t._stRotation,h=t._polygonHierarchy,f=t._perPositionHeight,v=t._closeTop,b=t._closeBottom,_=t._arcType,P=h.positions;if(!(P.length<3)){var x=u.EllipsoidTangentPlane.fromPoints(P,o),w=g.PolygonGeometryLibrary.polygonsFromHierarchy(h,x.projectPointsOntoPlane.bind(x),!f,o),C=w.hierarchy,T=w.polygons;if(0!==C.length){P=C[0].outerRing;var I,A=g.PolygonGeometryLibrary.computeBoundingRectangle(x.plane.normal,x.projectPointOntoPlane.bind(x),P,l,V),E=[],G=t._height,O=t._extrudedHeight,F={perPositionHeight:f,vertexFormat:r,geometry:void 0,tangentPlane:x,boundingRectangle:A,ellipsoid:o,stRotation:l,bottom:!1,top:!0,wall:!1,extrude:!1,arcType:_};if(t._perPositionHeightExtrude||!s.CesiumMath.equalsEpsilon(G,O,0,s.CesiumMath.EPSILON2))for(F.extrude=!0,F.top=v,F.bottom=b,F.shadowVolume=t._shadowVolume,F.offsetAttribute=t._offsetAttribute,I=0;I<T.length;I++){var D,L=re(o,T[I],n,C[I],f,v,b,r,_);v&&b?(D=L.topAndBottom,F.geometry=g.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(D.geometry,G,O,o,f)):v?((D=L.topAndBottom).geometry.attributes.position.values=d.PolygonPipeline.scaleToGeodeticHeight(D.geometry.attributes.position.values,G,o,!f),F.geometry=D.geometry):b&&((D=L.topAndBottom).geometry.attributes.position.values=d.PolygonPipeline.scaleToGeodeticHeight(D.geometry.attributes.position.values,O,o,!0),F.geometry=D.geometry),(v||b)&&(F.wall=!1,D.geometry=Q(F),E.push(D));var N=L.walls;F.wall=!0;for(var H=0;H<N.length;H++){var R=N[H];F.geometry=g.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(R.geometry,G,O,o,f),R.geometry=Q(F),E.push(R)}}else for(I=0;I<T.length;I++){var M=new p.GeometryInstance({geometry:g.PolygonGeometryLibrary.createGeometryFromPositions(o,T[I],n,f,r,_)});if(M.geometry.attributes.position.values=d.PolygonPipeline.scaleToGeodeticHeight(M.geometry.attributes.position.values,G,o,!f),F.geometry=M.geometry,M.geometry=Q(F),e.defined(t._offsetAttribute)){var S=M.geometry.attributes.position.values.length,B=new Uint8Array(S/3),k=t._offsetAttribute===a.GeometryOffsetAttribute.NONE?0:1;a.arrayFill(B,k),M.geometry.attributes.applyOffset=new c.GeometryAttribute({componentDatatype:s.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:B})}E.push(M)}var z=m.GeometryPipeline.combineInstances(E)[0];z.attributes.position.values=new Float64Array(z.attributes.position.values),z.indices=y.IndexDatatype.createTypedArray(z.attributes.position.values.length/3,z.indices);var W=z.attributes,Y=i.BoundingSphere.fromVertices(W.position.values);return r.position||delete W.position,new c.Geometry({attributes:W,indices:z.indices,primitiveType:z.primitiveType,boundingSphere:Y,offsetAttribute:t._offsetAttribute})}}},ae.createShadowVolume=function(e,t,r){var a=e._granularity,o=e._ellipsoid,i=t(a,o),n=r(a,o);return new ae({polygonHierarchy:e._polygonHierarchy,ellipsoid:o,stRotation:e._stRotation,granularity:a,perPositionHeight:!1,extrudedHeight:i,height:n,vertexFormat:h.VertexFormat.POSITION_ONLY,shadowVolume:!0,arcType:e._arcType})},Object.defineProperties(ae.prototype,{rectangle:{get:function(){if(!e.defined(this._rectangle)){var t=this._polygonHierarchy.positions;this._rectangle=X(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 r=e._ellipsoid,a=e._polygonHierarchy.positions,o=e.rectangle;return c.Geometry._textureCoordinateRotationPoints(a,t,r,o)}(this)),this._textureCoordinateRotationPoints}}}),function(r,a){return e.defined(a)&&(r=ae.unpack(r,a)),r._ellipsoid=t.Ellipsoid.clone(r._ellipsoid),ae.createGeometry(r)}}));