26 lines
6.6 KiB
JavaScript
26 lines
6.6 KiB
JavaScript
/**
|
|
* @license
|
|
* Cesium - https://github.com/CesiumGS/cesium
|
|
* Version 1.98
|
|
*
|
|
* Copyright 2011-2022 Cesium Contributors
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* Columbus View (Pat. Pend.)
|
|
*
|
|
* Portions licensed separately.
|
|
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
|
|
*/
|
|
define(["./defaultValue-50f7432c","./Matrix2-cf4c6e69","./Transforms-c9e418cb","./ComponentDatatype-9b23164a","./GeometryAttribute-b84ffce6","./GeometryAttributes-8bab1b25","./GeometryOffsetAttribute-490bc2c9","./IndexDatatype-ceed713e","./PolygonPipeline-13f0bfa4","./RectangleGeometryLibrary-9f12e096","./RuntimeError-48e1f06d","./combine-8462e002","./WebGLConstants-58abc51a","./EllipsoidRhumbLine-0cc30625"],(function(e,t,i,n,o,a,r,l,s,u,c,p,f,d){"use strict";const g=new i.BoundingSphere,h=new i.BoundingSphere,y=new t.Cartesian3,b=new t.Rectangle;function m(e,t){const i=e._ellipsoid,r=t.height,s=t.width,c=t.northCap,p=t.southCap;let f=r,d=2,g=0,h=4;c&&(d-=1,f-=1,g+=1,h-=2),p&&(d-=1,f-=1,g+=1,h-=2),g+=d*s+2*f-h;const b=new Float64Array(3*g);let m,_=0,E=0;const A=y;if(c)u.RectangleGeometryLibrary.computePosition(t,i,!1,E,0,A),b[_++]=A.x,b[_++]=A.y,b[_++]=A.z;else for(m=0;m<s;m++)u.RectangleGeometryLibrary.computePosition(t,i,!1,E,m,A),b[_++]=A.x,b[_++]=A.y,b[_++]=A.z;for(m=s-1,E=1;E<r;E++)u.RectangleGeometryLibrary.computePosition(t,i,!1,E,m,A),b[_++]=A.x,b[_++]=A.y,b[_++]=A.z;if(E=r-1,!p)for(m=s-2;m>=0;m--)u.RectangleGeometryLibrary.computePosition(t,i,!1,E,m,A),b[_++]=A.x,b[_++]=A.y,b[_++]=A.z;for(m=0,E=r-2;E>0;E--)u.RectangleGeometryLibrary.computePosition(t,i,!1,E,m,A),b[_++]=A.x,b[_++]=A.y,b[_++]=A.z;const G=b.length/3*2,R=l.IndexDatatype.createTypedArray(b.length/3,G);let P=0;for(let e=0;e<b.length/3-1;e++)R[P++]=e,R[P++]=e+1;R[P++]=b.length/3-1,R[P++]=0;const L=new o.Geometry({attributes:new a.GeometryAttributes,primitiveType:o.PrimitiveType.LINES});return L.attributes.position=new o.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:b}),L.indices=R,L}function _(i){const o=(i=e.defaultValue(i,e.defaultValue.EMPTY_OBJECT)).rectangle,a=e.defaultValue(i.granularity,n.CesiumMath.RADIANS_PER_DEGREE),r=e.defaultValue(i.ellipsoid,t.Ellipsoid.WGS84),l=e.defaultValue(i.rotation,0),s=e.defaultValue(i.height,0),u=e.defaultValue(i.extrudedHeight,s);this._rectangle=t.Rectangle.clone(o),this._granularity=a,this._ellipsoid=r,this._surfaceHeight=Math.max(s,u),this._rotation=l,this._extrudedHeight=Math.min(s,u),this._offsetAttribute=i.offsetAttribute,this._workerName="createRectangleOutlineGeometry"}_.packedLength=t.Rectangle.packedLength+t.Ellipsoid.packedLength+5,_.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 E=new t.Rectangle,A=t.Ellipsoid.clone(t.Ellipsoid.UNIT_SPHERE),G={rectangle:E,ellipsoid:A,granularity:void 0,height:void 0,rotation:void 0,extrudedHeight:void 0,offsetAttribute:void 0};_.unpack=function(i,n,o){n=e.defaultValue(n,0);const a=t.Rectangle.unpack(i,n,E);n+=t.Rectangle.packedLength;const r=t.Ellipsoid.unpack(i,n,A);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):(G.granularity=l,G.height=s,G.rotation=u,G.extrudedHeight=c,G.offsetAttribute=-1===p?void 0:p,new _(G))};const R=new t.Cartographic;return _.createGeometry=function(t){const a=t._rectangle,c=t._ellipsoid,p=u.RectangleGeometryLibrary.computeOptions(a,t._granularity,t._rotation,0,b,R);let f,d;if(n.CesiumMath.equalsEpsilon(a.north,a.south,n.CesiumMath.EPSILON10)||n.CesiumMath.equalsEpsilon(a.east,a.west,n.CesiumMath.EPSILON10))return;const y=t._surfaceHeight,_=t._extrudedHeight;let E;if(!n.CesiumMath.equalsEpsilon(y,_,0,n.CesiumMath.EPSILON2)){if(f=function(e,t){const i=e._surfaceHeight,n=e._extrudedHeight,o=e._ellipsoid,a=n,r=i,u=m(e,t),c=t.height,p=t.width,f=s.PolygonPipeline.scaleToGeodeticHeight(u.attributes.position.values,r,o,!1);let d=f.length;const g=new Float64Array(2*d);g.set(f);const h=s.PolygonPipeline.scaleToGeodeticHeight(u.attributes.position.values,a,o);g.set(h,d),u.attributes.position.values=g;const y=t.northCap,b=t.southCap;let _=4;y&&(_-=1),b&&(_-=1);const E=2*(g.length/3+_),A=l.IndexDatatype.createTypedArray(g.length/3,E);d=g.length/6;let G,R=0;for(let e=0;e<d-1;e++)A[R++]=e,A[R++]=e+1,A[R++]=e+d,A[R++]=e+d+1;if(A[R++]=d-1,A[R++]=0,A[R++]=d+d-1,A[R++]=d,A[R++]=0,A[R++]=d,y)G=c-1;else{const e=p-1;A[R++]=e,A[R++]=e+d,G=p+c-2}if(A[R++]=G,A[R++]=G+d,!b){const e=p+G-1;A[R++]=e,A[R]=e+d}return u.indices=A,u}(t,p),e.defined(t._offsetAttribute)){const e=f.attributes.position.values.length/3;let i=new Uint8Array(e);t._offsetAttribute===r.GeometryOffsetAttribute.TOP?i=i.fill(1,0,e/2):(E=t._offsetAttribute===r.GeometryOffsetAttribute.NONE?0:1,i=i.fill(E)),f.attributes.applyOffset=new o.GeometryAttribute({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:i})}const u=i.BoundingSphere.fromRectangle3D(a,c,y,h),b=i.BoundingSphere.fromRectangle3D(a,c,_,g);d=i.BoundingSphere.union(u,b)}else{if(f=m(t,p),f.attributes.position.values=s.PolygonPipeline.scaleToGeodeticHeight(f.attributes.position.values,y,c,!1),e.defined(t._offsetAttribute)){const e=f.attributes.position.values.length;E=t._offsetAttribute===r.GeometryOffsetAttribute.NONE?0:1;const i=new Uint8Array(e/3).fill(E);f.attributes.applyOffset=new o.GeometryAttribute({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:i})}d=i.BoundingSphere.fromRectangle3D(a,c,y)}return new o.Geometry({attributes:f.attributes,indices:f.indices,primitiveType:o.PrimitiveType.LINES,boundingSphere:d,offsetAttribute:t._offsetAttribute})},function(i,n){return e.defined(n)&&(i=_.unpack(i,n)),i._ellipsoid=t.Ellipsoid.clone(i._ellipsoid),i._rectangle=t.Rectangle.clone(i._rectangle),_.createGeometry(i)}}));
|