2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
/* 2020-9-22 15:23:25 | 版权所有 军懋国兴 */
|
|
define(["./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./Cartesian2-43e3a3be","./Transforms-2d1ac5ec","./RuntimeError-f4c64df1","./WebGLConstants-95ceb4e9","./ComponentDatatype-607c9a0c","./GeometryAttribute-2303bbfb","./GeometryAttributes-90846c5f","./AttributeCompression-ea810287","./GeometryPipeline-1ea64cde","./EncodedCartesian3-29a09d7b","./IndexDatatype-79bb407c","./IntersectionTests-459f6f08","./Plane-46b5436f","./GeometryOffsetAttribute-9c676324","./VertexFormat-fe64931e","./GeometryInstance-6264cc0f","./arrayRemoveDuplicates-d96adeb6","./BoundingRectangle-943d30f6","./EllipsoidTangentPlane-b5927ee3","./ArcType-2b58731c","./EllipsoidRhumbLine-357c11e7","./PolygonPipeline-2ee85025","./PolygonGeometryLibrary-bcb33f68","./EllipsoidGeodesic-007422da"],function(W,b,Y,j,Q,e,t,q,K,r,o,V,a,F,i,n,Z,v,L,s,l,N,c,u,R,M,y){"use strict";var J=new j.Cartographic,X=new j.Cartographic;var S=new l.BoundingRectangle,$=new j.Cartesian3,ee=new j.Cartesian3,te=new j.Cartesian3,re=new j.Cartesian3,oe=new j.Cartesian3,ae=new j.Cartesian3,ie=new j.Cartesian3,ne=new j.Cartesian3,se=new j.Cartesian3,le=new j.Cartesian2,ue=new j.Cartesian2,pe=new j.Cartesian3,ce=new Q.Quaternion,ye=new Q.Matrix3,de=new Q.Matrix3;function k(e){var t,r,o,a=e.vertexFormat,i=e.geometry,n=e.shadowVolume,s=i.attributes.position.values,l=s.length,u=e.wall,p=e.top||u,c=e.bottom||u;if(a.st||a.normal||a.tangent||a.bitangent||n){var y=e.boundingRectangle,d=e.tangentPlane,g=e.ellipsoid,m=e.stRotation,h=e.perPositionHeight,f=le;f.x=y.x,f.y=y.y;var b,v=a.st?new Float32Array(l/3*2):void 0;a.normal&&(b=h&&p&&!u?i.attributes.normal.values:new Float32Array(l));var _,P=a.tangent?new Float32Array(l):void 0,C=a.bitangent?new Float32Array(l):void 0,T=n?new Float32Array(l):void 0,w=0,I=0,A=ee,x=te,E=re,G=!0,O=ye,H=de;H=0!==m?(_=Q.Quaternion.fromAxisAngle(d._plane.normal,m,ce),O=Q.Matrix3.fromQuaternion(_,O),_=Q.Quaternion.fromAxisAngle(d._plane.normal,-m,ce),Q.Matrix3.fromQuaternion(_,H)):(O=Q.Matrix3.clone(Q.Matrix3.IDENTITY,O),Q.Matrix3.clone(Q.Matrix3.IDENTITY,H));var D=0,V=0;p&&c&&(D=l/2,V=l/3,l/=2);for(var F=0;F<l;F+=3){var L,N,R,M,S,k,B,z,U=j.Cartesian3.fromArray(s,F,pe);a.st&&(L=Q.Matrix3.multiplyByVector(O,U,$),L=g.scaleToGeodeticSurface(L,L),N=d.projectPointOntoPlane(L,ue),j.Cartesian2.subtract(N,f,N),R=Y.CesiumMath.clamp(N.x/y.width,0,1),M=Y.CesiumMath.clamp(N.y/y.height,0,1),c&&(v[w+V]=R,v[w+1+V]=M),p&&(v[w]=R,v[w+1]=M),w+=2),(a.normal||a.tangent||a.bitangent||n)&&(S=I+1,k=I+2,u?(F+3<l&&(B=j.Cartesian3.fromArray(s,F+3,oe),G&&(z=j.Cartesian3.fromArray(s,F+l,ae),h&&function(e,t,r,o){var a=o.cartesianToCartographic(e,J).height,i=o.cartesianToCartographic(t,X);i.height=a,o.cartographicToCartesian(i,t);var n=o.cartesianToCartographic(r,X);n.height=a-100,o.cartographicToCartesian(n,r)}(U,B,z,g),j.Cartesian3.subtract(B,U,B),j.Cartesian3.subtract(z,U,z),A=j.Cartesian3.normalize(j.Cartesian3.cross(z,B,A),A),G=!1),j.Cartesian3.equalsEpsilon(B,U,Y.CesiumMath.EPSILON10)&&(G=!0)),(a.tangent||a.bitangent)&&(E=g.geodeticSurfaceNormal(U,E),a.tangent&&(x=j.Cartesian3.normalize(j.Cartesian3.cross(E,A,x),x)))):(A=g.geodeticSurfaceNormal(U,A),(a.tangent||a.bitangent)&&(h&&(ie=j.Cartesian3.fromArray(b,I,ie),ne=j.Cartesian3.cross(j.Cartesian3.UNIT_Z,ie,ne),ne=j.Cartesian3.normalize(Q.Matrix3.multiplyByVector(H,ne,ne),ne),a.bitangent&&(se=j.Cartesian3.normalize(j.Cartesian3.cross(ie,ne,se),se))),x=j.Cartesian3.cross(j.Cartesian3.UNIT_Z,A,x),x=j.Cartesian3.normalize(Q.Matrix3.multiplyByVector(H,x,x),x),a.bitangent&&(E=j.Cartesian3.normalize(j.Cartesian3.cross(A,x,E),E)))),a.normal&&(e.wall?(b[I+D]=A.x,b[S+D]=A.y,b[k+D]=A.z):c&&(b[I+D]=-A.x,b[S+D]=-A.y,b[k+D]=-A.z),(p&&!h||u)&&(b[I]=A.x,b[S]=A.y,b[k]=A.z)),n&&(u&&(A=g.geodeticSurfaceNormal(U,A)),T[I+D]=-A.x,T[S+D]=-A.y,T[k+D]=-A.z),a.tangent&&(e.wall?(P[I+D]=x.x,P[S+D]=x.y,P[k+D]=x.z):c&&(P[I+D]=-x.x,P[S+D]=-x.y,P[k+D]=-x.z),p&&(h?(P[I]=ne.x,P[S]=ne.y,P[k]=ne.z):(P[I]=x.x,P[S]=x.y,P[k]=x.z))),a.bitangent&&(c&&(C[I+D]=E.x,C[S+D]=E.y,C[k+D]=E.z),p&&(h?(C[I]=se.x,C[S]=se.y,C[k]=se.z):(C[I]=E.x,C[S]=E.y,C[k]=E.z))),I+=3)}a.st&&(i.attributes.st=new K.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:v})),a.normal&&(i.attributes.normal=new K.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:b})),a.tangent&&(i.attributes.tangent=new K.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:P})),a.bitangent&&(i.attributes.bitangent=new K.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:C})),n&&(i.attributes.extrudeDirection=new K.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:T}))}return e.extrude&&W.defined(e.offsetAttribute)&&(t=s.length/3,o=new Uint8Array(t),e.offsetAttribute===Z.GeometryOffsetAttribute.TOP?p&&c||u?o=Z.arrayFill(o,1,0,t/2):p&&(o=Z.arrayFill(o,1)):(r=e.offsetAttribute===Z.GeometryOffsetAttribute.NONE?0:1,o=Z.arrayFill(o,r)),i.attributes.applyOffset=new K.GeometryAttribute({componentDatatype:q.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:o})),i}var d=new j.Cartographic,g=new j.Cartographic,m={westOverIDL:0,eastOverIDL:0},h=new y.EllipsoidGeodesic;function p(e,t,r,o,a){if(a=W.defaultValue(a,new j.Rectangle),!W.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 j.Rectangle.fromCartesianArray(e,t,a);h.ellipsoid.equals(t)||(h=new y.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,m.westOverIDL=Number.POSITIVE_INFINITY,m.eastOverIDL=Number.NEGATIVE_INFINITY;for(var i,n=1/Y.CesiumMath.chordLength(o,t.maximumRadius),s=e.length,l=t.cartesianToCartographic(e[0],g),u=d,p=1;p<s;p++)i=u,u=l,l=t.cartesianToCartographic(e[p],i),h.setEndPoints(u,l),_(h,n,a,m);return i=u,u=l,l=t.cartesianToCartographic(e[0],i),h.setEndPoints(u,l),_(h,n,a,m),a.east-a.west>m.eastOverIDL-m.westOverIDL&&(a.west=m.westOverIDL,a.east=m.eastOverIDL,a.east>Y.CesiumMath.PI&&(a.east=a.east-Y.CesiumMath.TWO_PI),a.west>Y.CesiumMath.PI&&(a.west=a.west-Y.CesiumMath.TWO_PI)),a}var f=new j.Cartographic;function _(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,f);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 y=0<=p?p:p+Y.CesiumMath.TWO_PI;o.westOverIDL=Math.min(o.westOverIDL,y),o.eastOverIDL=Math.max(o.eastOverIDL,y)}}var B=[];function P(e){if(b.Check.typeOf.object("options",e),b.Check.typeOf.object("options.polygonHierarchy",e.polygonHierarchy),W.defined(e.perPositionHeight)&&e.perPositionHeight&&W.defined(e.height))throw new b.DeveloperError("Cannot use both options.perPositionHeight and options.height");if(W.defined(e.arcType)&&e.arcType!==c.ArcType.GEODESIC&&e.arcType!==c.ArcType.RHUMB)throw new b.DeveloperError("Invalid arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB.");var t,r=e.polygonHierarchy,o=W.defaultValue(e.vertexFormat,v.VertexFormat.DEFAULT),a=W.defaultValue(e.ellipsoid,j.Ellipsoid.WGS84),i=W.defaultValue(e.granularity,Y.CesiumMath.RADIANS_PER_DEGREE),n=W.defaultValue(e.stRotation,0),s=W.defaultValue(e.perPositionHeight,!1),l=s&&W.defined(e.extrudedHeight),u=W.defaultValue(e.height,0),p=W.defaultValue(e.extrudedHeight,u);l||(t=Math.max(u,p),p=Math.min(u,p),u=t),this._vertexFormat=v.VertexFormat.clone(o),this._ellipsoid=j.Ellipsoid.clone(a),this._granularity=i,this._stRotation=n,this._height=u,this._extrudedHeight=p,this._closeTop=W.defaultValue(e.closeTop,!0),this._closeBottom=W.defaultValue(e.closeBottom,!0),this._polygonHierarchy=r,this._perPositionHeight=s,this._perPositionHeightExtrude=l,this._shadowVolume=W.defaultValue(e.shadowVolume,!1),this._workerName="createPolygonGeometry",this._offsetAttribute=e.offsetAttribute,this._arcType=W.defaultValue(e.arcType,c.ArcType.GEODESIC),this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0,this.packedLength=M.PolygonGeometryLibrary.computeHierarchyPackedLength(r)+j.Ellipsoid.packedLength+v.VertexFormat.packedLength+12}P.fromPositions=function(e){return e=W.defaultValue(e,W.defaultValue.EMPTY_OBJECT),b.Check.defined("options.positions",e.positions),new P({polygonHierarchy:{positions:e.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})},P.pack=function(e,t,r){return b.Check.typeOf.object("value",e),b.Check.defined("array",t),r=W.defaultValue(r,0),r=M.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,r),j.Ellipsoid.pack(e._ellipsoid,t,r),r+=j.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++]=W.defaultValue(e._offsetAttribute,-1),t[r++]=e._arcType,t[r]=e.packedLength,t};var C=j.Ellipsoid.clone(j.Ellipsoid.UNIT_SPHERE),T=new v.VertexFormat,w={polygonHierarchy:{}};return P.unpack=function(e,t,r){b.Check.defined("array",e),t=W.defaultValue(t,0);var o=M.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=o.startingIndex,delete o.startingIndex;var a=j.Ellipsoid.unpack(e,t,C);t+=j.Ellipsoid.packedLength;var i=v.VertexFormat.unpack(e,t,T);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++],y=1===e[t++],d=1===e[t++],g=1===e[t++],m=e[t++],h=e[t++],f=e[t];return W.defined(r)||(r=new P(w)),r._polygonHierarchy=o,r._ellipsoid=j.Ellipsoid.clone(a,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=y,r._closeBottom=d,r._shadowVolume=g,r._offsetAttribute=-1===m?void 0:m,r._arcType=h,r.packedLength=f,r},P.computeRectangle=function(e,t){b.Check.typeOf.object("options",e),b.Check.typeOf.object("options.polygonHierarchy",e.polygonHierarchy);var r=W.defaultValue(e.granularity,Y.CesiumMath.RADIANS_PER_DEGREE),o=W.defaultValue(e.arcType,c.ArcType.GEODESIC);if(o!==c.ArcType.GEODESIC&&o!==c.ArcType.RHUMB)throw new b.DeveloperError("Invalid arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB.");var a=e.polygonHierarchy,i=W.defaultValue(e.ellipsoid,j.Ellipsoid.WGS84);return p(a.positions,i,o,r,t)},P.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,p=i.positions;if(!(p.length<3)){var c=N.EllipsoidTangentPlane.fromPoints(p,r),y=M.PolygonGeometryLibrary.polygonsFromHierarchy(i,c.projectPointsOntoPlane.bind(c),!n,r),d=y.hierarchy,g=y.polygons;if(0!==d.length){p=d[0].outerRing;var m,h=M.PolygonGeometryLibrary.computeBoundingRectangle(c.plane.normal,c.projectPointOntoPlane.bind(c),p,a,S),f=[],b=e._height,v=e._extrudedHeight,_={perPositionHeight:n,vertexFormat:t,geometry:void 0,tangentPlane:c,boundingRectangle:h,ellipsoid:r,stRotation:a,bottom:!1,top:!0,wall:!1,extrude:!1,arcType:u};if(e._perPositionHeightExtrude||!Y.CesiumMath.equalsEpsilon(b,v,0,Y.CesiumMath.EPSILON2))for(_.extrude=!0,_.top=s,_.bottom=l,_.shadowVolume=e._shadowVolume,_.offsetAttribute=e._offsetAttribute,m=0;m<g.length;m++){var P,C=function(e,t,r,o,a,i,n,s,l){var u={walls:[]};if(i||n){var p=M.PolygonGeometryLibrary.createGeometryFromPositions(e,t,r,a,s,l),c=p.attributes.position.values,y=p.indices;if(i&&n){var d,g=c.concat(c),m=g.length/3;(d=F.IndexDatatype.createTypedArray(m,2*y.length)).set(y);for(var h,f=y.length,b=m/2,v=0;v<f;v+=3){var _=d[v]+b,P=d[v+1]+b,C=d[v+2]+b;d[v+f]=C,d[v+1+f]=P,d[v+2+f]=_}p.attributes.position.values=g,a&&s.normal&&(h=p.attributes.normal.values,p.attributes.normal.values=new Float32Array(g.length),p.attributes.normal.values.set(h)),p.indices=d}else if(n){for(m=c.length/3,d=F.IndexDatatype.createTypedArray(m,y.length),v=0;v<y.length;v+=3)d[v]=y[v+2],d[v+1]=y[v+1],d[v+2]=y[v];p.indices=d}u.topAndBottom=new L.GeometryInstance({geometry:p})}var T=o.outerRing,w=N.EllipsoidTangentPlane.fromPoints(T,e).projectPointsOntoPlane(T,B);R.PolygonPipeline.computeWindingOrder2D(w)===R.WindingOrder.CLOCKWISE&&(T=T.slice().reverse());var I=M.PolygonGeometryLibrary.computeWallGeometry(T,e,r,a,l);u.walls.push(new L.GeometryInstance({geometry:I}));var A=o.holes;for(v=0;v<A.length;v++){var x=A[v],w=N.EllipsoidTangentPlane.fromPoints(x,e).projectPointsOntoPlane(x,B);R.PolygonPipeline.computeWindingOrder2D(w)===R.WindingOrder.COUNTER_CLOCKWISE&&(x=x.slice().reverse()),I=M.PolygonGeometryLibrary.computeWallGeometry(x,e,r,a,l),u.walls.push(new L.GeometryInstance({geometry:I}))}return u}(r,g[m],o,d[m],n,s,l,t,u);s&&l?(P=C.topAndBottom,_.geometry=M.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(P.geometry,b,v,r,n)):s?((P=C.topAndBottom).geometry.attributes.position.values=R.PolygonPipeline.scaleToGeodeticHeight(P.geometry.attributes.position.values,b,r,!n),_.geometry=P.geometry):l&&((P=C.topAndBottom).geometry.attributes.position.values=R.PolygonPipeline.scaleToGeodeticHeight(P.geometry.attributes.position.values,v,r,!0),_.geometry=P.geometry),(s||l)&&(_.wall=!1,P.geometry=k(_),f.push(P));var T=C.walls;_.wall=!0;for(var w=0;w<T.length;w++){var I=T[w];_.geometry=M.PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(I.geometry,b,v,r,n),I.geometry=k(_),f.push(I)}}else for(m=0;m<g.length;m++){var A,x,E,G=new L.GeometryInstance({geometry:M.PolygonGeometryLibrary.createGeometryFromPositions(r,g[m],o,n,t,u)});G.geometry.attributes.position.values=R.PolygonPipeline.scaleToGeodeticHeight(G.geometry.attributes.position.values,b,r,!n),_.geometry=G.geometry,G.geometry=k(_),W.defined(e._offsetAttribute)&&(A=G.geometry.attributes.position.values.length,x=new Uint8Array(A/3),E=e._offsetAttribute===Z.GeometryOffsetAttribute.NONE?0:1,Z.arrayFill(x,E),G.geometry.attributes.applyOffset=new K.GeometryAttribute({componentDatatype:q.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:x})),f.push(G)}var O=V.GeometryPipeline.combineInstances(f)[0];O.attributes.position.values=new Float64Array(O.attributes.position.values),O.indices=F.IndexDatatype.createTypedArray(O.attributes.position.values.length/3,O.indices);var H=O.attributes,D=Q.BoundingSphere.fromVertices(H.position.values);return t.position||delete H.position,new K.Geometry({attributes:H,indices:O.indices,primitiveType:O.primitiveType,boundingSphere:D,offsetAttribute:e._offsetAttribute})}}},P.createShadowVolume=function(e,t,r){var o=e._granularity,a=e._ellipsoid,i=t(o,a),n=r(o,a);return new P({polygonHierarchy:e._polygonHierarchy,ellipsoid:a,stRotation:e._stRotation,granularity:o,perPositionHeight:!1,extrudedHeight:i,height:n,vertexFormat:v.VertexFormat.POSITION_ONLY,shadowVolume:!0,arcType:e._arcType})},Object.defineProperties(P.prototype,{rectangle:{get:function(){var e;return W.defined(this._rectangle)||(e=this._polygonHierarchy.positions,this._rectangle=p(e,this._ellipsoid,this._arcType,this._granularity)),this._rectangle}},textureCoordinateRotationPoints:{get:function(){return W.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,a=e.rectangle;return K.Geometry._textureCoordinateRotationPoints(o,t,r,a)}(this)),this._textureCoordinateRotationPoints}}}),function(e,t){return W.defined(t)&&(e=P.unpack(e,t)),e._ellipsoid=j.Ellipsoid.clone(e._ellipsoid),P.createGeometry(e)}}); |