Newer
Older
smartwell_front_dz / smartwell / mars3d-cesium / Workers / EllipseOutlineGeometry-bf79daa0.js
wangxitong on 11 Sep 2023 6 KB first commit
/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.96.6
 *
 * 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(["exports","./Transforms-66eda18c","./Matrix2-4706dd70","./ComponentDatatype-438cad2a","./defaultValue-028a8a27","./RuntimeError-a977b8e0","./EllipseGeometryLibrary-5f21f480","./GeometryAttribute-2cdece80","./GeometryAttributes-98e858da","./GeometryOffsetAttribute-116f8293","./IndexDatatype-dfa09980"],(function(e,t,i,r,n,o,a,s,l,u,d){"use strict";const f=new i.Cartesian3;let c=new i.Cartesian3;function p(e){const n=e.center;c=i.Cartesian3.multiplyByScalar(e.ellipsoid.geodeticSurfaceNormal(n,c),e.height,c),c=i.Cartesian3.add(n,c,c);const o=new t.BoundingSphere(c,e.semiMajorAxis),u=a.EllipseGeometryLibrary.computeEllipsePositions(e,!1,!0).outerPositions,f=new l.GeometryAttributes({position:new s.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:a.EllipseGeometryLibrary.raisePositionsToHeight(u,e,!1)})}),p=u.length/3,m=d.IndexDatatype.createTypedArray(p,2*p);let h=0;for(let t=0;t<p;++t)m[h++]=t,m[h++]=(t+1)%p;return{boundingSphere:o,attributes:f,indices:m}}const m=new t.BoundingSphere,h=new t.BoundingSphere;function y(e){const o=e.center,c=e.ellipsoid,p=e.semiMajorAxis;let y=i.Cartesian3.multiplyByScalar(c.geodeticSurfaceNormal(o,f),e.height,f);m.center=i.Cartesian3.add(o,y,m.center),m.radius=p,y=i.Cartesian3.multiplyByScalar(c.geodeticSurfaceNormal(o,y),e.extrudedHeight,y),h.center=i.Cartesian3.add(o,y,h.center),h.radius=p;let A=a.EllipseGeometryLibrary.computeEllipsePositions(e,!1,!0).outerPositions;const b=new l.GeometryAttributes({position:new s.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:a.EllipseGeometryLibrary.raisePositionsToHeight(A,e,!0)})});A=b.position.values;const _=t.BoundingSphere.union(m,h);let g=A.length/3;if(n.defined(e.offsetAttribute)){let t=new Uint8Array(g);if(e.offsetAttribute===u.GeometryOffsetAttribute.TOP)t=t.fill(1,0,g/2);else{const i=e.offsetAttribute===u.GeometryOffsetAttribute.NONE?0:1;t=t.fill(i)}b.applyOffset=new s.GeometryAttribute({componentDatatype:r.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:t})}let E=n.defaultValue(e.numberOfVerticalLines,16);E=r.CesiumMath.clamp(E,0,g/2);const x=d.IndexDatatype.createTypedArray(g,2*g+2*E);g/=2;let M,w,v=0;for(M=0;M<g;++M)x[v++]=M,x[v++]=(M+1)%g,x[v++]=M+g,x[v++]=(M+1)%g+g;if(E>0){const e=Math.min(E,g);w=Math.round(g/e);const t=Math.min(w*E,g);for(M=0;M<t;M+=w)x[v++]=M,x[v++]=M+g}return{boundingSphere:_,attributes:b,indices:x}}function A(e){e=n.defaultValue(e,n.defaultValue.EMPTY_OBJECT);const t=e.center,a=n.defaultValue(e.ellipsoid,i.Ellipsoid.WGS84),s=e.semiMajorAxis,l=e.semiMinorAxis,u=n.defaultValue(e.granularity,r.CesiumMath.RADIANS_PER_DEGREE);if(!n.defined(t))throw new o.DeveloperError("center is required.");if(!n.defined(s))throw new o.DeveloperError("semiMajorAxis is required.");if(!n.defined(l))throw new o.DeveloperError("semiMinorAxis is required.");if(s<l)throw new o.DeveloperError("semiMajorAxis must be greater than or equal to the semiMinorAxis.");if(u<=0)throw new o.DeveloperError("granularity must be greater than zero.");const d=n.defaultValue(e.height,0),f=n.defaultValue(e.extrudedHeight,d);this._center=i.Cartesian3.clone(t),this._semiMajorAxis=s,this._semiMinorAxis=l,this._ellipsoid=i.Ellipsoid.clone(a),this._rotation=n.defaultValue(e.rotation,0),this._height=Math.max(f,d),this._granularity=u,this._extrudedHeight=Math.min(f,d),this._numberOfVerticalLines=Math.max(n.defaultValue(e.numberOfVerticalLines,16),0),this._offsetAttribute=e.offsetAttribute,this._workerName="createEllipseOutlineGeometry"}A.packedLength=i.Cartesian3.packedLength+i.Ellipsoid.packedLength+8,A.pack=function(e,t,r){if(!n.defined(e))throw new o.DeveloperError("value is required");if(!n.defined(t))throw new o.DeveloperError("array is required");return r=n.defaultValue(r,0),i.Cartesian3.pack(e._center,t,r),r+=i.Cartesian3.packedLength,i.Ellipsoid.pack(e._ellipsoid,t,r),r+=i.Ellipsoid.packedLength,t[r++]=e._semiMajorAxis,t[r++]=e._semiMinorAxis,t[r++]=e._rotation,t[r++]=e._height,t[r++]=e._granularity,t[r++]=e._extrudedHeight,t[r++]=e._numberOfVerticalLines,t[r]=n.defaultValue(e._offsetAttribute,-1),t};const b=new i.Cartesian3,_=new i.Ellipsoid,g={center:b,ellipsoid:_,semiMajorAxis:void 0,semiMinorAxis:void 0,rotation:void 0,height:void 0,granularity:void 0,extrudedHeight:void 0,numberOfVerticalLines:void 0,offsetAttribute:void 0};A.unpack=function(e,t,r){if(!n.defined(e))throw new o.DeveloperError("array is required");t=n.defaultValue(t,0);const a=i.Cartesian3.unpack(e,t,b);t+=i.Cartesian3.packedLength;const s=i.Ellipsoid.unpack(e,t,_);t+=i.Ellipsoid.packedLength;const l=e[t++],u=e[t++],d=e[t++],f=e[t++],c=e[t++],p=e[t++],m=e[t++],h=e[t];return n.defined(r)?(r._center=i.Cartesian3.clone(a,r._center),r._ellipsoid=i.Ellipsoid.clone(s,r._ellipsoid),r._semiMajorAxis=l,r._semiMinorAxis=u,r._rotation=d,r._height=f,r._granularity=c,r._extrudedHeight=p,r._numberOfVerticalLines=m,r._offsetAttribute=-1===h?void 0:h,r):(g.height=f,g.extrudedHeight=p,g.granularity=c,g.rotation=d,g.semiMajorAxis=l,g.semiMinorAxis=u,g.numberOfVerticalLines=m,g.offsetAttribute=-1===h?void 0:h,new A(g))},A.createGeometry=function(e){if(e._semiMajorAxis<=0||e._semiMinorAxis<=0)return;const t=e._height,i=e._extrudedHeight,o=!r.CesiumMath.equalsEpsilon(t,i,0,r.CesiumMath.EPSILON2);e._center=e._ellipsoid.scaleToGeodeticSurface(e._center,e._center);const a={center:e._center,semiMajorAxis:e._semiMajorAxis,semiMinorAxis:e._semiMinorAxis,ellipsoid:e._ellipsoid,rotation:e._rotation,height:t,granularity:e._granularity,numberOfVerticalLines:e._numberOfVerticalLines};let l;if(o)a.extrudedHeight=i,a.offsetAttribute=e._offsetAttribute,l=y(a);else if(l=p(a),n.defined(e._offsetAttribute)){const t=l.attributes.position.values.length,i=e._offsetAttribute===u.GeometryOffsetAttribute.NONE?0:1,n=new Uint8Array(t/3).fill(i);l.attributes.applyOffset=new s.GeometryAttribute({componentDatatype:r.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:n})}return new s.Geometry({attributes:l.attributes,indices:l.indices,primitiveType:s.PrimitiveType.LINES,boundingSphere:l.boundingSphere,offsetAttribute:e._offsetAttribute})},e.EllipseOutlineGeometry=A}));