2 lines
8.5 KiB
JavaScript
2 lines
8.5 KiB
JavaScript
|
define(["exports","./ArcType-fc72c06c","./arrayRemoveDuplicates-cea3b206","./Cartesian2-bd414876","./Cartesian3-e0307675","./ComponentDatatype-aaeec80f","./defaultValue-81eec7ed","./EllipsoidRhumbLine-592e8885","./GeometryAttribute-2b42a913","./GeometryAttributes-32b29525","./GeometryPipeline-e7083fea","./IndexDatatype-3f3c99e8","./Math-e73894ab","./Matrix4-4c545f70","./PolygonPipeline-04baeb41","./Transforms-5b829630"],(function(e,t,n,i,o,r,a,s,c,l,u,h,f,p,d,y){"use strict";function g(){this._array=[],this._offset=0,this._length=0}Object.defineProperties(g.prototype,{length:{get:function(){return this._length}}}),g.prototype.enqueue=function(e){this._array.push(e),this._length++},g.prototype.dequeue=function(){if(0===this._length)return;const e=this._array;let t=this._offset;const n=e[t];return e[t]=void 0,t++,t>10&&2*t>e.length&&(this._array=e.slice(t),t=0),this._offset=t,this._length--,n},g.prototype.peek=function(){if(0!==this._length)return this._array[this._offset]},g.prototype.contains=function(e){return-1!==this._array.indexOf(e)},g.prototype.clear=function(){this._array.length=this._offset=this._length=0},g.prototype.sort=function(e){this._offset>0&&(this._array=this._array.slice(this._offset),this._offset=0),this._array.sort(e)};const m={computeHierarchyPackedLength:function(e){let t=0;const n=[e];for(;n.length>0;){const e=n.pop();if(!a.defined(e))continue;t+=2;const i=e.positions,r=e.holes;if(a.defined(i)&&(t+=i.length*o.Cartesian3.packedLength),a.defined(r)){const e=r.length;for(let t=0;t<e;++t)n.push(r[t])}}return t},packPolygonHierarchy:function(e,t,n){const i=[e];for(;i.length>0;){const e=i.pop();if(!a.defined(e))continue;const r=e.positions,s=e.holes;if(t[n++]=a.defined(r)?r.length:0,t[n++]=a.defined(s)?s.length:0,a.defined(r)){const e=r.length;for(let i=0;i<e;++i,n+=3)o.Cartesian3.pack(r[i],t,n)}if(a.defined(s)){const e=s.length;for(let t=0;t<e;++t)i.push(s[t])}}return n},unpackPolygonHierarchy:function(e,t){const n=e[t++],i=e[t++],r=new Array(n),a=i>0?new Array(i):void 0;for(let i=0;i<n;++i,t+=o.Cartesian3.packedLength)r[i]=o.Cartesian3.unpack(e,t);for(let n=0;n<i;++n)a[n]=m.unpackPolygonHierarchy(e,t),t=a[n].startingIndex,delete a[n].startingIndex;return{positions:r,holes:a,startingIndex:t}}},C=new o.Cartesian3;function b(e,t,n,i){return o.Cartesian3.subtract(t,e,C),o.Cartesian3.multiplyByScalar(C,n/i,C),o.Cartesian3.add(e,C,C),[C.x,C.y,C.z]}m.subdivideLineCount=function(e,t,n){const i=o.Cartesian3.distance(e,t)/n,r=Math.max(0,Math.ceil(f.CesiumMath.log2(i)));return Math.pow(2,r)};const T=new i.Cartographic,w=new i.Cartographic,I=new i.Cartographic,x=new o.Cartesian3;m.subdivideRhumbLineCount=function(e,t,n,i){const o=e.cartesianToCartographic(t,T),r=e.cartesianToCartographic(n,w),a=new s.EllipsoidRhumbLine(o,r,e).surfaceDistance/i,c=Math.max(0,Math.ceil(f.CesiumMath.log2(a)));return Math.pow(2,c)},m.subdivideLine=function(e,t,n,i){const r=m.subdivideLineCount(e,t,n),s=o.Cartesian3.distance(e,t),c=s/r;a.defined(i)||(i=[]);const l=i;l.length=3*r;let u=0;for(let n=0;n<r;n++){const i=b(e,t,n*c,s);l[u++]=i[0],l[u++]=i[1],l[u++]=i[2]}return l},m.subdivideRhumbLine=function(e,t,n,i,o){const r=e.cartesianToCartographic(t,T),c=e.cartesianToCartographic(n,w),l=new s.EllipsoidRhumbLine(r,c,e),u=l.surfaceDistance/i,h=Math.max(0,Math.ceil(f.CesiumMath.log2(u))),p=Math.pow(2,h),d=l.surfaceDistance/p;a.defined(o)||(o=[]);const y=o;y.length=3*p;let g=0;for(let t=0;t<p;t++){const n=l.interpolateUsingSurfaceDistance(t*d,I),i=e.cartographicToCartesian(n,x);y[g++]=i.x,y[g++]=i.y,y[g++]=i.z}return y};const v=new o.Cartesian3,E=new o.Cartesian3,A=new o.Cartesian3,P=new o.Cartesian3;m.scaleToGeodeticHeightExtruded=function(e,t,n,r,s){r=a.defaultValue(r,i.Ellipsoid.WGS84);const c=v;let l=E;const u=A;let h=P;if(a.defined(e)&&a.defined(e.attributes)&&a.defined(e.attributes.position)){const i=e.attributes.position.values,a=i.length/2;for(let e=0;e<a;e+=3)o.Cartesian3.fromArray(i,e,u),r.geodeticSurfaceNormal(u,c),h=r.scaleToGeodeticSurface(u,h),l=o.Cartesian3.multiplyByScalar(c,n,l),l=o.Cartesian3.add(h,l,l),i[e+a]=l.x,i[e+1+a]
|