qa-prevention-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/PolygonGeometry-95e6b579.js

2 lines
15 KiB
JavaScript

define(["exports","./ArcType-fc72c06c","./GeometryOffsetAttribute-ed56ff58","./BoundingRectangle-0e36efc3","./BoundingSphere-9a3b5656","./Cartesian2-bd414876","./Cartesian3-e0307675","./Check-741c5f3c","./ComponentDatatype-aaeec80f","./defaultValue-81eec7ed","./EllipsoidGeodesic-e7a5ca44","./EllipsoidTangentPlane-4d138901","./GeometryAttribute-2b42a913","./GeometryInstance-1b39c9e8","./GeometryPipeline-e7083fea","./IndexDatatype-3f3c99e8","./Math-e73894ab","./Matrix4-4c545f70","./PolygonGeometryLibrary-231711c2","./PolygonPipeline-04baeb41","./Transforms-5b829630","./Rectangle-cf3e0e3e","./VertexFormat-d50a69ba"],(function(e,t,o,r,n,a,i,s,l,c,u,p,y,g,m,d,h,f,b,_,P,x,C){"use strict";const w=new a.Cartographic,T=new a.Cartographic;function I(e,t,o,r){const n=r.cartesianToCartographic(e,w).height,a=r.cartesianToCartographic(t,T);a.height=n,r.cartographicToCartesian(a,t);const i=r.cartesianToCartographic(o,T);i.height=n-100,r.cartographicToCartesian(i,o)}const A=new r.BoundingRectangle,E=new i.Cartesian3,v=new i.Cartesian3,G=new i.Cartesian3,O=new i.Cartesian3,V=new i.Cartesian3,F=new i.Cartesian3;let N=new i.Cartesian3,D=new i.Cartesian3,H=new i.Cartesian3;const L=new a.Cartesian2,R=new a.Cartesian2,M=new i.Cartesian3,S=new P.Quaternion,B=new f.Matrix3,k=new f.Matrix3;function z(e){const t=e.vertexFormat,r=e.geometry,n=e.shadowVolume,s=r.attributes.position.values;let u=s.length;const p=e.wall,g=e.top||p,m=e.bottom||p;if(t.st||t.normal||t.tangent||t.bitangent||n){const o=e.boundingRectangle,c=e.tangentPlane,d=e.ellipsoid,b=e.stRotation,_=e.perPositionHeight,x=L;x.x=o.x,x.y=o.y;const C=t.st?new Float32Array(u/3*2):void 0;let w;t.normal&&(w=_&&g&&!p?r.attributes.normal.values:new Float32Array(u));const T=t.tangent?new Float32Array(u):void 0,A=t.bitangent?new Float32Array(u):void 0,z=n?new Float32Array(u):void 0;let W=0,Y=0,U=v,j=G,Q=O,q=!0,K=B,Z=k;if(0!==b){let e=P.Quaternion.fromAxisAngle(c._plane.normal,b,S);K=f.Matrix3.fromQuaternion(e,K),e=P.Quaternion.fromAxisAngle(c._plane.normal,-b,S),Z=f.Matrix3.fromQuaternion(e,Z)}else K=f.Matrix3.clone(f.Matrix3.IDENTITY,K),Z=f.Matrix3.clone(f.Matrix3.IDENTITY,Z);let J=0,X=0;g&&m&&(J=u/2,X=u/3,u/=2);for(let r=0;r<u;r+=3){const l=i.Cartesian3.fromArray(s,r,M);if(t.st){let e=f.Matrix3.multiplyByVector(K,l,E);e=d.scaleToGeodeticSurface(e,e);const t=c.projectPointOntoPlane(e,R);a.Cartesian2.subtract(t,x,t);const r=h.CesiumMath.clamp(t.x/o.width,0,1),n=h.CesiumMath.clamp(t.y/o.height,0,1);m&&(C[W+X]=r,C[W+1+X]=n),g&&(C[W]=r,C[W+1]=n),W+=2}if(t.normal||t.tangent||t.bitangent||n){const o=Y+1,a=Y+2;if(p){if(r+3<u){const e=i.Cartesian3.fromArray(s,r+3,V);if(q){const t=i.Cartesian3.fromArray(s,r+u,F);_&&I(l,e,t,d),i.Cartesian3.subtract(e,l,e),i.Cartesian3.subtract(t,l,t),U=i.Cartesian3.normalize(i.Cartesian3.cross(t,e,U),U),q=!1}i.Cartesian3.equalsEpsilon(e,l,h.CesiumMath.EPSILON10)&&(q=!0)}(t.tangent||t.bitangent)&&(Q=d.geodeticSurfaceNormal(l,Q),t.tangent&&(j=i.Cartesian3.normalize(i.Cartesian3.cross(Q,U,j),j)))}else U=d.geodeticSurfaceNormal(l,U),(t.tangent||t.bitangent)&&(_&&(N=i.Cartesian3.fromArray(w,Y,N),D=i.Cartesian3.cross(i.Cartesian3.UNIT_Z,N,D),D=i.Cartesian3.normalize(f.Matrix3.multiplyByVector(Z,D,D),D),t.bitangent&&(H=i.Cartesian3.normalize(i.Cartesian3.cross(N,D,H),H))),j=i.Cartesian3.cross(i.Cartesian3.UNIT_Z,U,j),j=i.Cartesian3.normalize(f.Matrix3.multiplyByVector(Z,j,j),j),t.bitangent&&(Q=i.Cartesian3.normalize(i.Cartesian3.cross(U,j,Q),Q)));t.normal&&(e.wall?(w[Y+J]=U.x,w[o+J]=U.y,w[a+J]=U.z):m&&(w[Y+J]=-U.x,w[o+J]=-U.y,w[a+J]=-U.z),(g&&!_||p)&&(w[Y]=U.x,w[o]=U.y,w[a]=U.z)),n&&(p&&(U=d.geodeticSurfaceNormal(l,U)),z[Y+J]=-U.x,z[o+J]=-U.y,z[a+J]=-U.z),t.tangent&&(e.wall?(T[Y+J]=j.x,T[o+J]=j.y,T[a+J]=j.z):m&&(T[Y+J]=-j.x,T[o+J]=-j.y,T[a+J]=-j.z),g&&(_?(T[Y]=D.x,T[o]=D.y,T[a]=D.z):(T[Y]=j.x,T[o]=j.y,T[a]=j.z))),t.bitangent&&(m&&(A[Y+J]=Q.x,A[o+J]=Q.y,A[a+J]=Q.z),g&&(_?(A[Y]=H.x,A[o]=H.y,A[a]=H.z):(A[Y]=Q.x,A[o]=Q.y,A[a]=Q.z))),Y+=3}}t.st&&(r.attributes.st=new y.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:C})),t.normal&&(r.attributes.normal=new y.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:w})),t.tangent&&(r.attributes.tangent=new y.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:T})),t.bitangent&&(r.attributes.bitangent=new y.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:A})),n&&(r.attributes.extrudeDirection=new y.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:z}))}if(e.extrude&&c.defined(e.offsetAttribute)){const t=s.length/3;let n=new Uint8Array(t);if(e.offsetAttribute===o.GeometryOffsetAttribute.TOP)g&&m||p?n=o.arrayFill(n,1,0,t/2):g&&(n=o.arrayFill(n,1));else{const t=e.offsetAttribute===o.GeometryOffsetAttribute.NONE?0:1;n=o.arrayFill(n,t)}r.attributes.applyOffset=new y.GeometryAttribute({componentDatatype:l.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:n})}return r}const W=new a.Cartographic,Y=new a.Cartographic,U={westOverIDL:0,eastOverIDL:0};let j=new u.EllipsoidGeodesic;function Q(e,o,r,n,a){if(a=c.defaultValue(a,new x.Rectangle),!c.defined(e)||e.length<3)return a.west=0,a.north=0,a.south=0,a.east=0,a;if(r===t.ArcType.RHUMB)return x.Rectangle.fromCartesianArray(e,o,a);j.ellipsoid.equals(o)||(j=new u.EllipsoidGeodesic(void 0,void 0,o)),a.west=Number.POSITIVE_INFINITY,a.east=Number.NEGATIVE_INFINITY,a.south=Number.POSITIVE_INFINITY,a.north=Number.NEGATIVE_INFINITY,U.westOverIDL=Number.POSITIVE_INFINITY,U.eastOverIDL=Number.NEGATIVE_INFINITY;const i=1/h.CesiumMath.chordLength(n,o.maximumRadius),s=e.length;let l,p=o.cartesianToCartographic(e[0],Y),y=W;for(let t=1;t<s;t++)l=y,y=p,p=o.cartesianToCartographic(e[t],l),j.setEndPoints(y,p),K(j,i,a,U);return l=y,y=p,p=o.cartesianToCartographic(e[0],l),j.setEndPoints(y,p),K(j,i,a,U),a.east-a.west>U.eastOverIDL-U.westOverIDL&&(a.west=U.westOverIDL,a.east=U.eastOverIDL,a.east>h.CesiumMath.PI&&(a.east=a.east-h.CesiumMath.TWO_PI),a.west>h.CesiumMath.PI&&(a.west=a.west-h.CesiumMath.TWO_PI)),a}const q=new a.Cartographic;function K(e,t,o,r){const n=e.surfaceDistance,a=Math.ceil(n*t),i=a>0?n/(a-1):Number.POSITIVE_INFINITY;let s=0;for(let t=0;t<a;t++){const t=e.interpolateUsingSurfaceDistance(s,q);s+=i;const n=t.longitude,a=t.latitude;o.west=Math.min(o.west,n),o.east=Math.max(o.east,n),o.south=Math.min(o.south,a),o.north=Math.max(o.north,a);const l=n>=0?n:n+h.CesiumMath.TWO_PI;r.westOverIDL=Math.min(r.westOverIDL,l),r.eastOverIDL=Math.max(r.eastOverIDL,l)}}const Z=[];function J(e,t,o,r,n,a,i,s,l){const c={walls:[]};let u;if(a||i){const r=b.PolygonGeometryLibrary.createGeometryFromPositions(e,t,o,n,s,l),p=r.attributes.position.values,y=r.indices;let m,h;if(a&&i){const e=p.concat(p);m=e.length/3,h=d.IndexDatatype.createTypedArray(m,2*y.length),h.set(y);const t=y.length,o=m/2;for(u=0;u<t;u+=3){const e=h[u]+o,r=h[u+1]+o,n=h[u+2]+o;h[u+t]=n,h[u+1+t]=r,h[u+2+t]=e}if(r.attributes.position.values=e,n&&s.normal){const t=r.attributes.normal.values;r.attributes.normal.values=new Float32Array(e.length),r.attributes.normal.values.set(t)}r.indices=h}else if(i){for(m=p.length/3,h=d.IndexDatatype.createTypedArray(m,y.length),u=0;u<y.length;u+=3)h[u]=y[u+2],h[u+1]=y[u+1],h[u+2]=y[u];r.indices=h}c.topAndBottom=new g.GeometryInstance({geometry:r})}let y=r.outerRing,m=p.EllipsoidTangentPlane.fromPoints(y,e),h=m.projectPointsOntoPlane(y,Z),f=_.PolygonPipeline.computeWindingOrder2D(h);f===_.WindingOrder.CLOCKWISE&&(y=y.slice().reverse());let P=b.PolygonGeometryLibrary.computeWallGeometry(y,e,o,n,l);c.walls.push(new g.GeometryInstance({geometry:P}));const x=r.holes;for(u=0;u<x.length;u++){let t=x[u];m=p.EllipsoidTangentPlane.fromPoints(t,e),h=m.projectPointsOntoPlane(t,Z),f=_.PolygonPipeline.computeWindingOrder2D(h),f===_.WindingOrder.COUNTER_CLOCKWISE&&(t=t.slice().reverse()),P=b.PolygonGeometryLibrary.computeWallGeometry(t,e,o,n,l),c.walls.push(new g.GeometryInstance({geometry:P}))}return c}function X(e){const o=e.polygonHierarchy,r=c.defaultValue(e.vertexFormat,C.VertexFormat.DEFAULT),n=c.defaultValue(e.ellipsoid,a.Ellipsoid.WGS84),i=c.defaultValue(e.granularity,h.CesiumMath.RADIANS_PER_DEGREE),s=c.defaultValue(e.stRotation,0),l=c.defaultValue(e.perPositionHeight,!1),u=l&&c.defined(e.extrudedHeight);let p=c.defaultValue(e.height,0),y=c.defaultValue(e.extrudedHeight,p);if(!u){const e=Math.max(p,y);y=Math.min(p,y),p=e}this._vertexFormat=C.VertexFormat.clone(r),this._ellipsoid=a.Ellipsoid.clone(n),this._granularity=i,this._stRotation=s,this._height=p,this._extrudedHeight=y,this._closeTop=c.defaultValue(e.closeTop,!0),this._closeBottom=c.defaultValue(e.closeBottom,!0),this._polygonHierarchy=o,this._perPositionHeight=l,this._perPositionHeightExtrude=u,this._shadowVolume=c.defaultValue(e.shadowVolume,!1),this._workerName="createPolygonGeometry",this._offsetAttribute=e.offsetAttribute,this._arcType=c.defaultValue(e.arcType,t.ArcType.GEODESIC),this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0,this.packedLength=b.PolygonGeometryLibrary.computeHierarchyPackedLength(o)+a.Ellipsoid.packedLength+C.VertexFormat.packedLength+12}X.fromPositions=function(e){return new X({polygonHierarchy:{positions:(e=c.defaultValue(e,c.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,o){return o=c.defaultValue(o,0),o=b.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,o),a.Ellipsoid.pack(e._ellipsoid,t,o),o+=a.Ellipsoid.packedLength,C.VertexFormat.pack(e._vertexFormat,t,o),o+=C.VertexFormat.packedLength,t[o++]=e._height,t[o++]=e._extrudedHeight,t[o++]=e._granularity,t[o++]=e._stRotation,t[o++]=e._perPositionHeightExtrude?1:0,t[o++]=e._perPositionHeight?1:0,t[o++]=e._closeTop?1:0,t[o++]=e._closeBottom?1:0,t[o++]=e._shadowVolume?1:0,t[o++]=c.defaultValue(e._offsetAttribute,-1),t[o++]=e._arcType,t[o]=e.packedLength,t};const $=a.Ellipsoid.clone(a.Ellipsoid.UNIT_SPHERE),ee=new C.VertexFormat,te={polygonHierarchy:{}};X.unpack=function(e,t,o){t=c.defaultValue(t,0);const r=b.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=r.startingIndex,delete r.startingIndex;const n=a.Ellipsoid.unpack(e,t,$);t+=a.Ellipsoid.packedLength;const i=C.VertexFormat.unpack(e,t,ee);t+=C.VertexFormat.packedLength;const s=e[t++],l=e[t++],u=e[t++],p=e[t++],y=1===e[t++],g=1===e[t++],m=1===e[t++],d=1===e[t++],h=1===e[t++],f=e[t++],_=e[t++],P=e[t];return c.defined(o)||(o=new X(te)),o._polygonHierarchy=r,o._ellipsoid=a.Ellipsoid.clone(n,o._ellipsoid),o._vertexFormat=C.VertexFormat.clone(i,o._vertexFormat),o._height=s,o._extrudedHeight=l,o._granularity=u,o._stRotation=p,o._perPositionHeightExtrude=y,o._perPositionHeight=g,o._closeTop=m,o._closeBottom=d,o._shadowVolume=h,o._offsetAttribute=-1===f?void 0:f,o._arcType=_,o.packedLength=P,o},X.computeRectangle=function(e,o){const r=c.defaultValue(e.granularity,h.CesiumMath.RADIANS_PER_DEGREE),n=c.defaultValue(e.arcType,t.ArcType.GEODESIC),i=e.polygonHierarchy,s=c.defaultValue(e.ellipsoid,a.Ellipsoid.WGS84);return Q(i.positions,s,n,r,o)},X.createGeometry=function(e){const t=e._vertexFormat,r=e._ellipsoid,a=e._granularity,i=e._stRotation,s=e._polygonHierarchy,u=e._perPositionHeight,f=e._closeTop,P=e._closeBottom,x=e._arcType;let C=s.positions;if(C.length<3)return;const w=p.EllipsoidTangentPlane.fromPoints(C,r),T=b.PolygonGeometryLibrary.polygonsFromHierarchy(s,w.projectPointsOntoPlane.bind(w),!u,r),I=T.hierarchy,E=T.polygons;if(0===I.length)return;C=I[0].outerRing;const v=b.PolygonGeometryLibrary.computeBoundingRectangle(w.plane.normal,w.projectPointOntoPlane.bind(w),C,i,A),G=[],O=e._height,V=e._extrudedHeight,F={perPositionHeight:u,vertexFormat:t,geometry:void 0,tangentPlane:w,boundingRectangle:v,ellipsoid:r,stRotation:i,bottom:!1,top:!0,wall:!1,extrude:!1,arcType:x};let N;if(e._perPositionHeightExtrude||!h.CesiumMath.equalsEpsilon(O,V,0,h.CesiumMath.EPSILON2))for(F.extrude=!0,F.top=f,F.bottom=P,F.shadowVolume=e._shadowVolume,F.offsetAttribute=e._offsetAttribute,N=0;N<E.length;N++){const e=J(r,E[N],a,I[N],u,f,P,t,x);let o;f&&P?(o=e.topAndBottom,F.geometry=b.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(o.geometry,O,V,r,u)):f?(o=e.topAndBottom,o.geometry.attributes.position.values=_.PolygonPipeline.scaleToGeodeticHeight(o.geometry.attributes.position.values,O,r,!u),F.geometry=o.geometry):P&&(o=e.topAndBottom,o.geometry.attributes.position.values=_.PolygonPipeline.scaleToGeodeticHeight(o.geometry.attributes.position.values,V,r,!0),F.geometry=o.geometry),(f||P)&&(F.wall=!1,o.geometry=z(F),G.push(o));const n=e.walls;F.wall=!0;for(let e=0;e<n.length;e++){const t=n[e];F.geometry=b.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(t.geometry,O,V,r,u),t.geometry=z(F),G.push(t)}}else for(N=0;N<E.length;N++){const n=new g.GeometryInstance({geometry:b.PolygonGeometryLibrary.createGeometryFromPositions(r,E[N],a,u,t,x)});if(n.geometry.attributes.position.values=_.PolygonPipeline.scaleToGeodeticHeight(n.geometry.attributes.position.values,O,r,!u),F.geometry=n.geometry,n.geometry=z(F),c.defined(e._offsetAttribute)){const t=n.geometry.attributes.position.values.length,r=new Uint8Array(t/3),a=e._offsetAttribute===o.GeometryOffsetAttribute.NONE?0:1;o.arrayFill(r,a),n.geometry.attributes.applyOffset=new y.GeometryAttribute({componentDatatype:l.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:r})}G.push(n)}const D=m.GeometryPipeline.combineInstances(G)[0];D.attributes.position.values=new Float64Array(D.attributes.position.values),D.indices=d.IndexDatatype.createTypedArray(D.attributes.position.values.length/3,D.indices);const H=D.attributes,L=n.BoundingSphere.fromVertices(H.position.values);return t.position||delete H.position,new y.Geometry({attributes:H,indices:D.indices,primitiveType:D.primitiveType,boundingSphere:L,offsetAttribute:e._offsetAttribute})},X.createShadowVolume=function(e,t,o){const r=e._granularity,n=e._ellipsoid,a=t(r,n),i=o(r,n);return new X({polygonHierarchy:e._polygonHierarchy,ellipsoid:n,stRotation:e._stRotation,granularity:r,perPositionHeight:!1,extrudedHeight:a,height:i,vertexFormat:C.VertexFormat.POSITION_ONLY,shadowVolume:!0,arcType:e._arcType})},Object.defineProperties(X.prototype,{rectangle:{get:function(){if(!c.defined(this._rectangle)){const e=this._polygonHierarchy.positions;this._rectangle=Q(e,this._ellipsoid,this._arcType,this._granularity)}return this._rectangle}},textureCoordinateRotationPoints:{get:function(){return c.defined(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=function(e){const t=-e._stRotation;if(0===t)return[0,0,0,1,1,0];const o=e._ellipsoid,r=e._polygonHierarchy.positions,n=e.rectangle;return y.Geometry._textureCoordinateRotationPoints(r,t,o,n)}(this)),this._textureCoordinateRotationPoints}}}),e.PolygonGeometry=X}));