1 |
- define(["./when-4bbc8319","./Matrix2-ccd5b911","./ArcType-98ec98bf","./GeometryOffsetAttribute-1772960d","./BoundingRectangle-2b0e1a9b","./Transforms-d5c6ad6e","./RuntimeError-346a3079","./ComponentDatatype-93750d1a","./EllipsoidGeodesic-19ea7553","./EllipsoidTangentPlane-e000bae1","./GeometryAttribute-c30799b8","./GeometryInstance-5f4fe82b","./GeometryPipeline-548e76d2","./IndexDatatype-b7d979a6","./PolygonGeometryLibrary-d35c292d","./PolygonPipeline-83fb62b0","./VertexFormat-71718faa","./combine-83860057","./WebGLConstants-1c8239cc","./AxisAlignedBoundingBox-883f9c89","./IntersectionTests-4d6f5c54","./Plane-18bb00f8","./AttributeCompression-1f045b73","./EncodedCartesian3-08b8d980","./arrayRemoveDuplicates-18786327","./EllipsoidRhumbLine-aa9e6266","./GeometryAttributes-7827a6c2"],function(z,W,c,Y,e,U,t,j,m,A,Q,E,G,O,V,F,f,r,o,a,i,n,s,l,u,p,y){"use strict";var q=new W.Cartographic,K=new W.Cartographic;var D=new e.BoundingRectangle,Z=new W.Cartesian3,J=new W.Cartesian3,X=new W.Cartesian3,$=new W.Cartesian3,ee=new W.Cartesian3,te=new W.Cartesian3,re=new W.Cartesian3,oe=new W.Cartesian3,ae=new W.Cartesian3,ie=new W.Cartesian2,ne=new W.Cartesian2,se=new W.Cartesian3,le=new U.Quaternion,ue=new W.Matrix3,pe=new W.Matrix3;function L(e){var t,r=e.vertexFormat,o=e.geometry,a=e.shadowVolume,i=o.attributes.position.values,n=i.length,s=e.wall,l=e.top||s,u=e.bottom||s;if(r.st||r.normal||r.tangent||r.bitangent||a){var p=e.boundingRectangle,c=e.tangentPlane,m=e.ellipsoid,y=e.stRotation,g=e.perPositionHeight,d=ie;d.x=p.x,d.y=p.y;var h,f=r.st?new Float32Array(n/3*2):void 0;r.normal&&(h=g&&l&&!s?o.attributes.normal.values:new Float32Array(n));var b,_=r.tangent?new Float32Array(n):void 0,v=r.bitangent?new Float32Array(n):void 0,P=a?new Float32Array(n):void 0,x=0,w=0,C=J,T=X,I=$,A=!0,E=ue,G=pe;G=0!==y?(b=U.Quaternion.fromAxisAngle(c._plane.normal,y,le),E=W.Matrix3.fromQuaternion(b,E),b=U.Quaternion.fromAxisAngle(c._plane.normal,-y,le),W.Matrix3.fromQuaternion(b,G)):(E=W.Matrix3.clone(W.Matrix3.IDENTITY,E),W.Matrix3.clone(W.Matrix3.IDENTITY,G));var O=0,V=0;l&&u&&(O=n/2,V=n/3,n/=2);for(var F=0;F<n;F+=3){var D,L,N,H,R,M,S,B,k=W.Cartesian3.fromArray(i,F,se);r.st&&(D=W.Matrix3.multiplyByVector(E,k,Z),D=m.scaleToGeodeticSurface(D,D),L=c.projectPointOntoPlane(D,ne),W.Cartesian2.subtract(L,d,L),N=j.CesiumMath.clamp(L.x/p.width,0,1),H=j.CesiumMath.clamp(L.y/p.height,0,1),u&&(f[x+V]=N,f[x+1+V]=H),l&&(f[x]=N,f[x+1]=H),x+=2),(r.normal||r.tangent||r.bitangent||a)&&(R=w+1,M=w+2,s?(F+3<n&&(S=W.Cartesian3.fromArray(i,F+3,ee),A&&(B=W.Cartesian3.fromArray(i,F+n,te),g&&(t=k,D=S,L=B,N=void 0,N=(H=m).cartesianToCartographic(t,q).height,(t=H.cartesianToCartographic(D,K)).height=N,H.cartographicToCartesian(t,D),(D=H.cartesianToCartographic(L,K)).height=N-100,H.cartographicToCartesian(D,L)),W.Cartesian3.subtract(S,k,S),W.Cartesian3.subtract(B,k,B),C=W.Cartesian3.normalize(W.Cartesian3.cross(B,S,C),C),A=!1),W.Cartesian3.equalsEpsilon(S,k,j.CesiumMath.EPSILON10)&&(A=!0)),(r.tangent||r.bitangent)&&(I=m.geodeticSurfaceNormal(k,I),r.tangent&&(T=W.Cartesian3.normalize(W.Cartesian3.cross(I,C,T),T)))):(C=m.geodeticSurfaceNormal(k,C),(r.tangent||r.bitangent)&&(g&&(re=W.Cartesian3.fromArray(h,w,re),oe=W.Cartesian3.cross(W.Cartesian3.UNIT_Z,re,oe),oe=W.Cartesian3.normalize(W.Matrix3.multiplyByVector(G,oe,oe),oe),r.bitangent&&(ae=W.Cartesian3.normalize(W.Cartesian3.cross(re,oe,ae),ae))),T=W.Cartesian3.cross(W.Cartesian3.UNIT_Z,C,T),T=W.Cartesian3.normalize(W.Matrix3.multiplyByVector(G,T,T),T),r.bitangent&&(I=W.Cartesian3.normalize(W.Cartesian3.cross(C,T,I),I)))),r.normal&&(e.wall?(h[w+O]=C.x,h[R+O]=C.y,h[M+O]=C.z):u&&(h[w+O]=-C.x,h[R+O]=-C.y,h[M+O]=-C.z),(l&&!g||s)&&(h[w]=C.x,h[R]=C.y,h[M]=C.z)),a&&(s&&(C=m.geodeticSurfaceNormal(k,C)),P[w+O]=-C.x,P[R+O]=-C.y,P[M+O]=-C.z),r.tangent&&(e.wall?(_[w+O]=T.x,_[R+O]=T.y,_[M+O]=T.z):u&&(_[w+O]=-T.x,_[R+O]=-T.y,_[M+O]=-T.z),l&&(g?(_[w]=oe.x,_[R]=oe.y,_[M]=oe.z):(_[w]=T.x,_[R]=T.y,_[M]=T.z))),r.bitangent&&(u&&(v[w+O]=I.x,v[R+O]=I.y,v[M+O]=I.z),l&&(g?(v[w]=ae.x,v[R]=ae.y,v[M]=ae.z):(v[w]=I.x,v[R]=I.y,v[M]=I.z))),w+=3)}r.st&&(o.attributes.st=new Q.GeometryAttribute({componentDatatype:j.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:f})),r.normal&&(o.attributes.normal=new Q.GeometryAttribute({componentDatatype:j.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:h})),r.tangent&&(o.attributes.tangent=new Q.GeometryAttribute({componentDatatype:j.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:_})),r.bitangent&&(o.attributes.bitangent=new Q.GeometryAttribute({componentDatatype:j.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:v})),a&&(o.attributes.extrudeDirection=new Q.GeometryAttribute({componentDatatype:j.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:P}))}return e.extrude&&z.defined(e.offsetAttribute)&&(y=i.length/3,b=new Uint8Array(y),e.offsetAttribute===Y.GeometryOffsetAttribute.TOP?l&&u||s?b=Y.arrayFill(b,1,0,y/2):l&&(b=Y.arrayFill(b,1)):(y=e.offsetAttribute===Y.GeometryOffsetAttribute.NONE?0:1,b=Y.arrayFill(b,y)),o.attributes.applyOffset=new Q.GeometryAttribute({componentDatatype:j.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:b})),o}var g=new W.Cartographic,d=new W.Cartographic,h={westOverIDL:0,eastOverIDL:0},b=new m.EllipsoidGeodesic;function _(e,t,r,o,a){if(a=z.defaultValue(a,new W.Rectangle),!z.defined(e)||e.length<3)return a.west=0,a.north=0,a.south=0,a.east=0,a;if(r===c.ArcType.RHUMB)return W.Rectangle.fromCartesianArray(e,t,a);b.ellipsoid.equals(t)||(b=new m.EllipsoidGeodesic(void 0,void 0,t)),a.west=Number.POSITIVE_INFINITY,a.east=Number.NEGATIVE_INFINITY,a.south=Number.POSITIVE_INFINITY,a.north=Number.NEGATIVE_INFINITY,h.westOverIDL=Number.POSITIVE_INFINITY,h.eastOverIDL=Number.NEGATIVE_INFINITY;for(var i,n=1/j.CesiumMath.chordLength(o,t.maximumRadius),s=e.length,l=t.cartesianToCartographic(e[0],d),u=g,p=1;p<s;p++)i=u,u=l,l=t.cartesianToCartographic(e[p],i),b.setEndPoints(u,l),P(b,n,a,h);return i=u,u=l,l=t.cartesianToCartographic(e[0],i),b.setEndPoints(u,l),P(b,n,a,h),a.east-a.west>h.eastOverIDL-h.westOverIDL&&(a.west=h.westOverIDL,a.east=h.eastOverIDL,a.east>j.CesiumMath.PI&&(a.east=a.east-j.CesiumMath.TWO_PI),a.west>j.CesiumMath.PI&&(a.west=a.west-j.CesiumMath.TWO_PI)),a}var v=new W.Cartographic;function P(e,t,r,o){for(var a=e.surfaceDistance,i=Math.ceil(a*t),n=0<i?a/(i-1):Number.POSITIVE_INFINITY,s=0,l=0;l<i;l++){var u=e.interpolateUsingSurfaceDistance(s,v);s+=n;var p=u.longitude,u=u.latitude;r.west=Math.min(r.west,p),r.east=Math.max(r.east,p),r.south=Math.min(r.south,u),r.north=Math.max(r.north,u);p=0<=p?p:p+j.CesiumMath.TWO_PI;o.westOverIDL=Math.min(o.westOverIDL,p),o.eastOverIDL=Math.max(o.eastOverIDL,p)}}var N=[];function x(e){var t,r=e.polygonHierarchy,o=z.defaultValue(e.vertexFormat,f.VertexFormat.DEFAULT),a=z.defaultValue(e.ellipsoid,W.Ellipsoid.WGS84),i=z.defaultValue(e.granularity,j.CesiumMath.RADIANS_PER_DEGREE),n=z.defaultValue(e.stRotation,0),s=z.defaultValue(e.perPositionHeight,!1),l=s&&z.defined(e.extrudedHeight),u=z.defaultValue(e.height,0),p=z.defaultValue(e.extrudedHeight,u);l||(t=Math.max(u,p),p=Math.min(u,p),u=t),this._vertexFormat=f.VertexFormat.clone(o),this._ellipsoid=W.Ellipsoid.clone(a),this._granularity=i,this._stRotation=n,this._height=u,this._extrudedHeight=p,this._closeTop=z.defaultValue(e.closeTop,!0),this._closeBottom=z.defaultValue(e.closeBottom,!0),this._polygonHierarchy=r,this._perPositionHeight=s,this._perPositionHeightExtrude=l,this._shadowVolume=z.defaultValue(e.shadowVolume,!1),this._workerName="createPolygonGeometry",this._offsetAttribute=e.offsetAttribute,this._arcType=z.defaultValue(e.arcType,c.ArcType.GEODESIC),this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0,this.packedLength=V.PolygonGeometryLibrary.computeHierarchyPackedLength(r)+W.Ellipsoid.packedLength+f.VertexFormat.packedLength+12}x.fromPositions=function(e){return new x({polygonHierarchy:{positions:(e=z.defaultValue(e,z.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})},x.pack=function(e,t,r){return r=z.defaultValue(r,0),r=V.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,r),W.Ellipsoid.pack(e._ellipsoid,t,r),r+=W.Ellipsoid.packedLength,f.VertexFormat.pack(e._vertexFormat,t,r),r+=f.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++]=z.defaultValue(e._offsetAttribute,-1),t[r++]=e._arcType,t[r]=e.packedLength,t};var w=W.Ellipsoid.clone(W.Ellipsoid.UNIT_SPHERE),C=new f.VertexFormat,T={polygonHierarchy:{}};return x.unpack=function(e,t,r){t=z.defaultValue(t,0);var o=V.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=o.startingIndex,delete o.startingIndex;var a=W.Ellipsoid.unpack(e,t,w);t+=W.Ellipsoid.packedLength;var i=f.VertexFormat.unpack(e,t,C);t+=f.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++],t=e[t];return(r=!z.defined(r)?new x(T):r)._polygonHierarchy=o,r._ellipsoid=W.Ellipsoid.clone(a,r._ellipsoid),r._vertexFormat=f.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=t,r},x.computeRectangle=function(e,t){var r=z.defaultValue(e.granularity,j.CesiumMath.RADIANS_PER_DEGREE),o=z.defaultValue(e.arcType,c.ArcType.GEODESIC),a=e.polygonHierarchy,e=z.defaultValue(e.ellipsoid,W.Ellipsoid.WGS84);return _(a.positions,e,o,r,t)},x.createGeometry=function(e){var t=e._vertexFormat,r=e._ellipsoid,o=e._granularity,a=e._stRotation,i=e._polygonHierarchy,n=e._perPositionHeight,s=e._closeTop,l=e._closeBottom,u=e._arcType;if(!((g=i.positions).length<3)){var p=A.EllipsoidTangentPlane.fromPoints(g,r),i=V.PolygonGeometryLibrary.polygonsFromHierarchy(i,p.projectPointsOntoPlane.bind(p),!n,r),c=i.hierarchy,m=i.polygons;if(0!==c.length){var y,g=c[0].outerRing,g=V.PolygonGeometryLibrary.computeBoundingRectangle(p.plane.normal,p.projectPointOntoPlane.bind(p),g,a,D),d=[],h=e._height,f=e._extrudedHeight,b={perPositionHeight:n,vertexFormat:t,geometry:void 0,tangentPlane:p,boundingRectangle:g,ellipsoid:r,stRotation:a,bottom:!1,top:!0,wall:!1,extrude:!1,arcType:u};if(e._perPositionHeightExtrude||!j.CesiumMath.equalsEpsilon(h,f,0,j.CesiumMath.EPSILON2))for(b.extrude=!0,b.top=s,b.bottom=l,b.shadowVolume=e._shadowVolume,b.offsetAttribute=e._offsetAttribute,y=0;y<m.length;y++){var _,v=function(e,t,r,o,a,i,n,s,l){var u={walls:[]};if(i||n){var p=V.PolygonGeometryLibrary.createGeometryFromPositions(e,t,r,a,s,l),t=p.attributes.position.values,c=p.indices;if(i&&n){var m,i=t.concat(t),y=i.length/3;(m=O.IndexDatatype.createTypedArray(y,2*c.length)).set(c);for(var g=c.length,d=y/2,h=0;h<g;h+=3){var f=m[h]+d,b=m[h+1]+d,_=m[h+2]+d;m[h+g]=_,m[h+1+g]=b,m[h+2+g]=f}p.attributes.position.values=i,a&&s.normal&&(s=p.attributes.normal.values,p.attributes.normal.values=new Float32Array(i.length),p.attributes.normal.values.set(s)),p.indices=m}else if(n){for(y=t.length/3,m=O.IndexDatatype.createTypedArray(y,c.length),h=0;h<c.length;h+=3)m[h]=c[h+2],m[h+1]=c[h+1],m[h+2]=c[h];p.indices=m}u.topAndBottom=new E.GeometryInstance({geometry:p})}var p=o.outerRing,v=A.EllipsoidTangentPlane.fromPoints(p,e).projectPointsOntoPlane(p,N);F.PolygonPipeline.computeWindingOrder2D(v)===F.WindingOrder.CLOCKWISE&&(p=p.slice().reverse());var P=V.PolygonGeometryLibrary.computeWallGeometry(p,e,r,a,l);u.walls.push(new E.GeometryInstance({geometry:P}));var x=o.holes;for(h=0;h<x.length;h++){var w=x[h],v=A.EllipsoidTangentPlane.fromPoints(w,e).projectPointsOntoPlane(w,N);F.PolygonPipeline.computeWindingOrder2D(v)===F.WindingOrder.COUNTER_CLOCKWISE&&(w=w.slice().reverse()),P=V.PolygonGeometryLibrary.computeWallGeometry(w,e,r,a,l),u.walls.push(new E.GeometryInstance({geometry:P}))}return u}(r,m[y],o,c[y],n,s,l,t,u);s&&l?(_=v.topAndBottom,b.geometry=V.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(_.geometry,h,f,r,n)):s?((_=v.topAndBottom).geometry.attributes.position.values=F.PolygonPipeline.scaleToGeodeticHeight(_.geometry.attributes.position.values,h,r,!n),b.geometry=_.geometry):l&&((_=v.topAndBottom).geometry.attributes.position.values=F.PolygonPipeline.scaleToGeodeticHeight(_.geometry.attributes.position.values,f,r,!0),b.geometry=_.geometry),(s||l)&&(b.wall=!1,_.geometry=L(b),d.push(_));var P=v.walls;b.wall=!0;for(var x=0;x<P.length;x++){var w=P[x];b.geometry=V.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(w.geometry,h,f,r,n),w.geometry=L(b),d.push(w)}}else for(y=0;y<m.length;y++){var C,T,I=new E.GeometryInstance({geometry:V.PolygonGeometryLibrary.createGeometryFromPositions(r,m[y],o,n,t,u)});I.geometry.attributes.position.values=F.PolygonPipeline.scaleToGeodeticHeight(I.geometry.attributes.position.values,h,r,!n),b.geometry=I.geometry,I.geometry=L(b),z.defined(e._offsetAttribute)&&(T=I.geometry.attributes.position.values.length,C=new Uint8Array(T/3),T=e._offsetAttribute===Y.GeometryOffsetAttribute.NONE?0:1,Y.arrayFill(C,T),I.geometry.attributes.applyOffset=new Q.GeometryAttribute({componentDatatype:j.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:C})),d.push(I)}p=G.GeometryPipeline.combineInstances(d)[0];p.attributes.position.values=new Float64Array(p.attributes.position.values),p.indices=O.IndexDatatype.createTypedArray(p.attributes.position.values.length/3,p.indices);g=p.attributes,a=U.BoundingSphere.fromVertices(g.position.values);return t.position||delete g.position,new Q.Geometry({attributes:g,indices:p.indices,primitiveType:p.primitiveType,boundingSphere:a,offsetAttribute:e._offsetAttribute})}}},x.createShadowVolume=function(e,t,r){var o=e._granularity,a=e._ellipsoid,t=t(o,a),r=r(o,a);return new x({polygonHierarchy:e._polygonHierarchy,ellipsoid:a,stRotation:e._stRotation,granularity:o,perPositionHeight:!1,extrudedHeight:t,height:r,vertexFormat:f.VertexFormat.POSITION_ONLY,shadowVolume:!0,arcType:e._arcType})},Object.defineProperties(x.prototype,{rectangle:{get:function(){var e;return z.defined(this._rectangle)||(e=this._polygonHierarchy.positions,this._rectangle=_(e,this._ellipsoid,this._arcType,this._granularity)),this._rectangle}},textureCoordinateRotationPoints:{get:function(){return z.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,o=e._polygonHierarchy.positions,e=e.rectangle;return Q.Geometry._textureCoordinateRotationPoints(o,t,r,e)}(this)),this._textureCoordinateRotationPoints}}}),function(e,t){return(e=z.defined(t)?x.unpack(e,t):e)._ellipsoid=W.Ellipsoid.clone(e._ellipsoid),x.createGeometry(e)}});
|