bmh_cesium/public/lib/cesiumjs/CesiumUnminified/Workers/createWallOutlineGeometry.js
2025-03-10 07:23:50 +08:00

2 lines
4.4 KiB
JavaScript

/* 2020-9-22 15:23:24 | 版权所有 军懋国兴 */
define(["./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./Cartesian2-43e3a3be","./Transforms-2d1ac5ec","./RuntimeError-f4c64df1","./WebGLConstants-95ceb4e9","./ComponentDatatype-607c9a0c","./GeometryAttribute-2303bbfb","./GeometryAttributes-90846c5f","./IndexDatatype-79bb407c","./IntersectionTests-459f6f08","./Plane-46b5436f","./arrayRemoveDuplicates-d96adeb6","./EllipsoidRhumbLine-357c11e7","./EllipsoidGeodesic-007422da","./PolylinePipeline-be169602","./WallGeometryLibrary-ebaee328"],function(D,m,x,G,L,e,i,P,T,V,I,t,r,n,a,o,s,R){"use strict";var S=new G.Cartesian3,q=new G.Cartesian3;function u(e){var i=(e=D.defaultValue(e,D.defaultValue.EMPTY_OBJECT)).positions,t=e.maximumHeights,r=e.minimumHeights;if(!D.defined(i))throw new m.DeveloperError("options.positions is required.");if(D.defined(t)&&t.length!==i.length)throw new m.DeveloperError("options.positions and options.maximumHeights must have the same length.");if(D.defined(r)&&r.length!==i.length)throw new m.DeveloperError("options.positions and options.minimumHeights must have the same length.");var n=D.defaultValue(e.granularity,x.CesiumMath.RADIANS_PER_DEGREE),a=D.defaultValue(e.ellipsoid,G.Ellipsoid.WGS84);this._positions=i,this._minimumHeights=r,this._maximumHeights=t,this._granularity=n,this._ellipsoid=G.Ellipsoid.clone(a),this._workerName="createWallOutlineGeometry";var o=1+i.length*G.Cartesian3.packedLength+2;D.defined(r)&&(o+=r.length),D.defined(t)&&(o+=t.length),this.packedLength=o+G.Ellipsoid.packedLength+1}u.pack=function(e,i,t){if(!D.defined(e))throw new m.DeveloperError("value is required");if(!D.defined(i))throw new m.DeveloperError("array is required");var r;t=D.defaultValue(t,0);var n=e._positions,a=n.length;for(i[t++]=a,r=0;r<a;++r,t+=G.Cartesian3.packedLength)G.Cartesian3.pack(n[r],i,t);var o=e._minimumHeights,a=D.defined(o)?o.length:0;if(i[t++]=a,D.defined(o))for(r=0;r<a;++r)i[t++]=o[r];var s=e._maximumHeights;if(a=D.defined(s)?s.length:0,i[t++]=a,D.defined(s))for(r=0;r<a;++r)i[t++]=s[r];return G.Ellipsoid.pack(e._ellipsoid,i,t),i[t+=G.Ellipsoid.packedLength]=e._granularity,i};var p=G.Ellipsoid.clone(G.Ellipsoid.UNIT_SPHERE),f={positions:void 0,minimumHeights:void 0,maximumHeights:void 0,ellipsoid:p,granularity:void 0};return u.unpack=function(e,i,t){if(!D.defined(e))throw new m.DeveloperError("array is required");i=D.defaultValue(i,0);for(var r,n,a=e[i++],o=new Array(a),s=0;s<a;++s,i+=G.Cartesian3.packedLength)o[s]=G.Cartesian3.unpack(e,i);if(0<(a=e[i++]))for(r=new Array(a),s=0;s<a;++s)r[s]=e[i++];if(0<(a=e[i++]))for(n=new Array(a),s=0;s<a;++s)n[s]=e[i++];var l=G.Ellipsoid.unpack(e,i,p),d=e[i+=G.Ellipsoid.packedLength];return D.defined(t)?(t._positions=o,t._minimumHeights=r,t._maximumHeights=n,t._ellipsoid=G.Ellipsoid.clone(l,t._ellipsoid),t._granularity=d,t):(f.positions=o,f.minimumHeights=r,f.maximumHeights=n,f.granularity=d,new u(f))},u.fromConstantHeights=function(e){var i=(e=D.defaultValue(e,D.defaultValue.EMPTY_OBJECT)).positions;if(!D.defined(i))throw new m.DeveloperError("options.positions is required.");var t=e.minimumHeight,r=e.maximumHeight,n=D.defined(t),a=D.defined(r);if(n||a)for(var o=i.length,s=n?new Array(o):void 0,l=a?new Array(o):void 0,d=0;d<o;++d)n&&(s[d]=t),a&&(l[d]=r);return new u({positions:i,maximumHeights:l,minimumHeights:s,ellipsoid:e.ellipsoid})},u.createGeometry=function(e){var i=e._positions,t=e._minimumHeights,r=e._maximumHeights,n=e._granularity,a=e._ellipsoid,o=R.WallGeometryLibrary.computePositions(a,i,r,t,n,!1);if(D.defined(o)){var s=o.bottomPositions,l=o.topPositions,d=l.length,m=2*d,u=new Float64Array(m),p=0;for(d/=3,w=0;w<d;++w){var f=3*w,h=G.Cartesian3.fromArray(l,f,S),g=G.Cartesian3.fromArray(s,f,q);u[p++]=g.x,u[p++]=g.y,u[p++]=g.z,u[p++]=h.x,u[p++]=h.y,u[p++]=h.z}for(var c=new V.GeometryAttributes({position:new T.GeometryAttribute({componentDatatype:P.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:u})}),y=m/3,m=2*y-4+y,v=I.IndexDatatype.createTypedArray(y,m),E=0,w=0;w<y-2;w+=2){var _,b,C=w,H=w+2,A=G.Cartesian3.fromArray(u,3*C,S),k=G.Cartesian3.fromArray(u,3*H,q);G.Cartesian3.equalsEpsilon(A,k,x.CesiumMath.EPSILON10)||(_=w+1,b=w+3,v[E++]=_,v[E++]=C,v[E++]=_,v[E++]=b,v[E++]=C,v[E++]=H)}return v[E++]=y-2,v[E++]=y-1,new T.Geometry({attributes:c,indices:v,primitiveType:T.PrimitiveType.LINES,boundingSphere:new L.BoundingSphere.fromVertices(u)})}},function(e,i){return D.defined(i)&&(e=u.unpack(e,i)),e._ellipsoid=G.Ellipsoid.clone(e._ellipsoid),u.createGeometry(e)}});