createRectangleOutlineGeometry.js 5.9 KB

1
  1. define(["./defaultValue-81eec7ed","./Matrix2-e3fb4559","./GeometryOffsetAttribute-ed56ff58","./Transforms-98ffa11d","./Cartesian3-7e9cc2ff","./ComponentDatatype-aaeec80f","./Check-741c5f3c","./GeometryAttribute-b025f9a8","./GeometryAttributes-32b29525","./IndexDatatype-f1e3f799","./Math-5f585871","./PolygonPipeline-6f83d8b1","./RectangleGeometryLibrary-193b0cdb","./Matrix4-d34187af","./RuntimeError-26acdd3b","./_commonjsHelpers-3aae1032-26891ab7","./combine-3c023bda","./WebGLConstants-508b9636","./EllipsoidRhumbLine-9c6b32ea"],(function(e,t,i,n,o,a,r,l,s,u,c,p,d,f,g,h,y,b,m){"use strict";const _=new n.BoundingSphere,E=new n.BoundingSphere,A=new o.Cartesian3,G=new t.Rectangle;function R(e,t){const i=e._ellipsoid,n=t.height,o=t.width,r=t.northCap,c=t.southCap;let p=n,f=2,g=0,h=4;r&&(f-=1,p-=1,g+=1,h-=2),c&&(f-=1,p-=1,g+=1,h-=2),g+=f*o+2*p-h;const y=new Float64Array(3*g);let b,m=0,_=0;const E=A;if(r)d.RectangleGeometryLibrary.computePosition(t,i,!1,_,0,E),y[m++]=E.x,y[m++]=E.y,y[m++]=E.z;else for(b=0;b<o;b++)d.RectangleGeometryLibrary.computePosition(t,i,!1,_,b,E),y[m++]=E.x,y[m++]=E.y,y[m++]=E.z;for(b=o-1,_=1;_<n;_++)d.RectangleGeometryLibrary.computePosition(t,i,!1,_,b,E),y[m++]=E.x,y[m++]=E.y,y[m++]=E.z;if(_=n-1,!c)for(b=o-2;b>=0;b--)d.RectangleGeometryLibrary.computePosition(t,i,!1,_,b,E),y[m++]=E.x,y[m++]=E.y,y[m++]=E.z;for(b=0,_=n-2;_>0;_--)d.RectangleGeometryLibrary.computePosition(t,i,!1,_,b,E),y[m++]=E.x,y[m++]=E.y,y[m++]=E.z;const G=y.length/3*2,R=u.IndexDatatype.createTypedArray(y.length/3,G);let P=0;for(let e=0;e<y.length/3-1;e++)R[P++]=e,R[P++]=e+1;R[P++]=y.length/3-1,R[P++]=0;const L=new l.Geometry({attributes:new s.GeometryAttributes,primitiveType:l.PrimitiveType.LINES});return L.attributes.position=new l.GeometryAttribute({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:y}),L.indices=R,L}function P(i){const n=(i=e.defaultValue(i,e.defaultValue.EMPTY_OBJECT)).rectangle,o=e.defaultValue(i.granularity,c.CesiumMath.RADIANS_PER_DEGREE),a=e.defaultValue(i.ellipsoid,t.Ellipsoid.WGS84),r=e.defaultValue(i.rotation,0),l=e.defaultValue(i.height,0),s=e.defaultValue(i.extrudedHeight,l);this._rectangle=t.Rectangle.clone(n),this._granularity=o,this._ellipsoid=a,this._surfaceHeight=Math.max(l,s),this._rotation=r,this._extrudedHeight=Math.min(l,s),this._offsetAttribute=i.offsetAttribute,this._workerName="createRectangleOutlineGeometry"}P.packedLength=t.Rectangle.packedLength+t.Ellipsoid.packedLength+5,P.pack=function(i,n,o){return o=e.defaultValue(o,0),t.Rectangle.pack(i._rectangle,n,o),o+=t.Rectangle.packedLength,t.Ellipsoid.pack(i._ellipsoid,n,o),o+=t.Ellipsoid.packedLength,n[o++]=i._granularity,n[o++]=i._surfaceHeight,n[o++]=i._rotation,n[o++]=i._extrudedHeight,n[o]=e.defaultValue(i._offsetAttribute,-1),n};const L=new t.Rectangle,v=t.Ellipsoid.clone(t.Ellipsoid.UNIT_SPHERE),w={rectangle:L,ellipsoid:v,granularity:void 0,height:void 0,rotation:void 0,extrudedHeight:void 0,offsetAttribute:void 0};P.unpack=function(i,n,o){n=e.defaultValue(n,0);const a=t.Rectangle.unpack(i,n,L);n+=t.Rectangle.packedLength;const r=t.Ellipsoid.unpack(i,n,v);n+=t.Ellipsoid.packedLength;const l=i[n++],s=i[n++],u=i[n++],c=i[n++],p=i[n];return e.defined(o)?(o._rectangle=t.Rectangle.clone(a,o._rectangle),o._ellipsoid=t.Ellipsoid.clone(r,o._ellipsoid),o._surfaceHeight=s,o._rotation=u,o._extrudedHeight=c,o._offsetAttribute=-1===p?void 0:p,o):(w.granularity=l,w.height=s,w.rotation=u,w.extrudedHeight=c,w.offsetAttribute=-1===p?void 0:p,new P(w))};const C=new t.Cartographic;return P.createGeometry=function(t){const o=t._rectangle,r=t._ellipsoid,s=d.RectangleGeometryLibrary.computeOptions(o,t._granularity,t._rotation,0,G,C);let f,g;if(c.CesiumMath.equalsEpsilon(o.north,o.south,c.CesiumMath.EPSILON10)||c.CesiumMath.equalsEpsilon(o.east,o.west,c.CesiumMath.EPSILON10))return;const h=t._surfaceHeight,y=t._extrudedHeight;let b;if(!c.CesiumMath.equalsEpsilon(h,y,0,c.CesiumMath.EPSILON2)){if(f=function(e,t){const i=e._surfaceHeight,n=e._extrudedHeight,o=e._ellipsoid,a=n,r=i,l=R(e,t),s=t.height,c=t.width,d=p.PolygonPipeline.scaleToGeodeticHeight(l.attributes.position.values,r,o,!1);let f=d.length;const g=new Float64Array(2*f);g.set(d);const h=p.PolygonPipeline.scaleToGeodeticHeight(l.attributes.position.values,a,o);g.set(h,f),l.attributes.position.values=g;const y=t.northCap,b=t.southCap;let m=4;y&&(m-=1),b&&(m-=1);const _=2*(g.length/3+m),E=u.IndexDatatype.createTypedArray(g.length/3,_);f=g.length/6;let A,G=0;for(let e=0;e<f-1;e++)E[G++]=e,E[G++]=e+1,E[G++]=e+f,E[G++]=e+f+1;if(E[G++]=f-1,E[G++]=0,E[G++]=f+f-1,E[G++]=f,E[G++]=0,E[G++]=f,y)A=s-1;else{const e=c-1;E[G++]=e,E[G++]=e+f,A=c+s-2}if(E[G++]=A,E[G++]=A+f,!b){const e=c+A-1;E[G++]=e,E[G]=e+f}return l.indices=E,l}(t,s),e.defined(t._offsetAttribute)){const e=f.attributes.position.values.length/3;let n=new Uint8Array(e);t._offsetAttribute===i.GeometryOffsetAttribute.TOP?n=i.arrayFill(n,1,0,e/2):(b=t._offsetAttribute===i.GeometryOffsetAttribute.NONE?0:1,n=i.arrayFill(n,b)),f.attributes.applyOffset=new l.GeometryAttribute({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:n})}const c=n.BoundingSphere.fromRectangle3D(o,r,h,E),d=n.BoundingSphere.fromRectangle3D(o,r,y,_);g=n.BoundingSphere.union(c,d)}else{if(f=R(t,s),f.attributes.position.values=p.PolygonPipeline.scaleToGeodeticHeight(f.attributes.position.values,h,r,!1),e.defined(t._offsetAttribute)){const e=f.attributes.position.values.length,n=new Uint8Array(e/3);b=t._offsetAttribute===i.GeometryOffsetAttribute.NONE?0:1,i.arrayFill(n,b),f.attributes.applyOffset=new l.GeometryAttribute({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:n})}g=n.BoundingSphere.fromRectangle3D(o,r,h)}return new l.Geometry({attributes:f.attributes,indices:f.indices,primitiveType:l.PrimitiveType.LINES,boundingSphere:g,offsetAttribute:t._offsetAttribute})},function(i,n){return e.defined(n)&&(i=P.unpack(i,n)),i._ellipsoid=t.Ellipsoid.clone(i._ellipsoid),i._rectangle=t.Rectangle.clone(i._rectangle),P.createGeometry(i)}}));