Newer
Older
smartwell_front_dz / smartwell / mars3d-cesium / Workers / PolygonPipeline-ec925640.js
wangxitong on 11 Sep 2023 14 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","./Matrix2-4706dd70","./RuntimeError-a977b8e0","./ComponentDatatype-438cad2a","./defaultValue-028a8a27","./EllipsoidRhumbLine-248c8a1e","./GeometryAttribute-2cdece80","./WebGLConstants-0ff1ce58"],(function(e,t,n,r,a,i,s,u){"use strict";var o=p,x=p;function p(e,t,n){n=n||2;var r,a,i,s,u,o,x,p=t&&t.length,y=p?t[0]*n:e.length,c=l(e,0,y,n,!0),f=[];if(!c||c.next===c.prev)return f;if(p&&(c=C(e,t,c,n)),e.length>80*n){r=i=e[0],a=s=e[1];for(var d=n;d<y;d+=n)u=e[d],o=e[d+1],u<r&&(r=u),o<a&&(a=o),u>i&&(i=u),o>s&&(s=o);x=Math.max(i-r,s-a),x=0!==x?1/x:0}return h(c,f,n,r,a,x),f}function l(e,t,n,r,a){var i,s;if(a===q(e,t,n,r)>0)for(i=t;i<n;i+=r)s=P(i,e[i],e[i+1],s);else for(i=n-r;i>=t;i-=r)s=P(i,e[i],e[i+1],s);return s&&L(s,s.next)&&($(s),s=s.next),s}function y(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!L(r,r.next)&&0!==z(r.prev,r,r.next))r=r.next;else{if($(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function h(e,t,n,r,a,i,s){if(e){!s&&i&&A(e,r,a,i);for(var u,o,x=e;e.prev!==e.next;)if(u=e.prev,o=e.next,i?f(e,r,a,i):c(e))t.push(u.i/n),t.push(e.i/n),t.push(o.i/n),$(e),e=o.next,x=o.next;else if(e=o,e===x){s?1===s?(e=d(y(e),t,n),h(e,t,n,r,a,i,2)):2===s&&v(e,t,n,r,a,i):h(y(e),t,n,r,a,i,1);break}}}function c(e){var t=e.prev,n=e,r=e.next;if(z(t,n,r)>=0)return!1;for(var a=e.next.next;a!==e.prev;){if(O(t.x,t.y,n.x,n.y,r.x,r.y,a.x,a.y)&&z(a.prev,a,a.next)>=0)return!1;a=a.next}return!0}function f(e,t,n,r){var a=e.prev,i=e,s=e.next;if(z(a,i,s)>=0)return!1;for(var u=a.x<i.x?a.x<s.x?a.x:s.x:i.x<s.x?i.x:s.x,o=a.y<i.y?a.y<s.y?a.y:s.y:i.y<s.y?i.y:s.y,x=a.x>i.x?a.x>s.x?a.x:s.x:i.x>s.x?i.x:s.x,p=a.y>i.y?a.y>s.y?a.y:s.y:i.y>s.y?i.y:s.y,l=S(u,o,t,n,r),y=S(x,p,t,n,r),h=e.prevZ,c=e.nextZ;h&&h.z>=l&&c&&c.z<=y;){if(h!==e.prev&&h!==e.next&&O(a.x,a.y,i.x,i.y,s.x,s.y,h.x,h.y)&&z(h.prev,h,h.next)>=0||(h=h.prevZ,c!==e.prev&&c!==e.next&&O(a.x,a.y,i.x,i.y,s.x,s.y,c.x,c.y)&&z(c.prev,c,c.next)>=0))return!1;c=c.nextZ}for(;h&&h.z>=l;){if(h!==e.prev&&h!==e.next&&O(a.x,a.y,i.x,i.y,s.x,s.y,h.x,h.y)&&z(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;c&&c.z<=y;){if(c!==e.prev&&c!==e.next&&O(a.x,a.y,i.x,i.y,s.x,s.y,c.x,c.y)&&z(c.prev,c,c.next)>=0)return!1;c=c.nextZ}return!0}function d(e,t,n){var r=e;do{var a=r.prev,i=r.next.next;!L(a,i)&&R(a,r,r.next,i)&&G(a,i)&&G(i,a)&&(t.push(a.i/n),t.push(r.i/n),t.push(i.i/n),$(r),$(r.next),r=e=i),r=r.next}while(r!==e);return y(r)}function v(e,t,n,r,a,i){var s=e;do{for(var u=s.next.next;u!==s.prev;){if(s.i!==u.i&&Z(s,u)){var o=W(s,u);return s=y(s,s.next),o=y(o,o.next),h(s,t,n,r,a,i),void h(o,t,n,r,a,i)}u=u.next}s=s.next}while(s!==e)}function C(e,t,n,r){var a,i,s,u,o,x=[];for(a=0,i=t.length;a<i;a++)s=t[a]*r,u=a<i-1?t[a+1]*r:e.length,o=l(e,s,u,r,!1),o===o.next&&(o.steiner=!0),x.push(M(o));for(x.sort(m),a=0;a<x.length;a++)n=g(x[a],n),n=y(n,n.next);return n}function m(e,t){return e.x-t.x}function g(e,t){var n=b(e,t);if(!n)return t;var r=W(n,e),a=y(n,n.next);return y(r,r.next),t===n?a:t}function b(e,t){var n,r=t,a=e.x,i=e.y,s=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){var u=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(u<=a&&u>s){if(s=u,u===a){if(i===r.y)return r;if(i===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(a===s)return n;var o,x=n,p=n.x,l=n.y,y=1/0;r=n;do{a>=r.x&&r.x>=p&&a!==r.x&&O(i<l?a:s,i,p,l,i<l?s:a,i,r.x,r.y)&&(o=Math.abs(i-r.y)/(a-r.x),G(r,e)&&(o<y||o===y&&(r.x>n.x||r.x===n.x&&w(n,r)))&&(n=r,y=o)),r=r.next}while(r!==x);return n}function w(e,t){return z(e.prev,e,t.prev)<0&&z(t.next,e,e.next)<0}function A(e,t,n,r){var a=e;do{null===a.z&&(a.z=S(a.x,a.y,t,n,r)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next}while(a!==e);a.prevZ.nextZ=null,a.prevZ=null,E(a)}function E(e){var t,n,r,a,i,s,u,o,x=1;do{for(n=e,e=null,i=null,s=0;n;){for(s++,r=n,u=0,t=0;t<x&&(u++,r=r.nextZ,r);t++);for(o=x;u>0||o>0&&r;)0!==u&&(0===o||!r||n.z<=r.z)?(a=n,n=n.nextZ,u--):(a=r,r=r.nextZ,o--),i?i.nextZ=a:e=a,a.prevZ=i,i=a;n=r}i.nextZ=null,x*=2}while(s>1);return e}function S(e,t,n,r,a){return e=32767*(e-n)*a,t=32767*(t-r)*a,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function M(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function O(e,t,n,r,a,i,s,u){return(a-s)*(t-u)-(e-s)*(i-u)>=0&&(e-s)*(r-u)-(n-s)*(t-u)>=0&&(n-s)*(i-u)-(a-s)*(r-u)>=0}function Z(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!k(e,t)&&(G(e,t)&&G(t,e)&&B(e,t)&&(z(e.prev,e,t.prev)||z(e,t.prev,t))||L(e,t)&&z(e.prev,e,e.next)>0&&z(t.prev,t,t.next)>0)}function z(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function L(e,t){return e.x===t.x&&e.y===t.y}function R(e,t,n,r){var a=T(z(e,t,n)),i=T(z(e,t,r)),s=T(z(n,r,e)),u=T(z(n,r,t));return!!(a!==i&&s!==u||0===a&&D(e,n,t)||0===i&&D(e,r,t)||0===s&&D(n,e,r)||0===u&&D(n,t,r))}function D(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function T(e){return e>0?1:e<0?-1:0}function k(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&R(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function G(e,t){return z(e.prev,e,e.next)<0?z(e,t,e.next)>=0&&z(e,e.prev,t)>=0:z(e,t,e.prev)<0||z(e,e.next,t)<0}function B(e,t){var n=e,r=!1,a=(e.x+t.x)/2,i=(e.y+t.y)/2;do{n.y>i!=n.next.y>i&&n.next.y!==n.y&&a<(n.next.x-n.x)*(i-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}function W(e,t){var n=new I(e.i,e.x,e.y),r=new I(t.i,t.x,t.y),a=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=a,a.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function P(e,t,n,r){var a=new I(e,t,n);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function $(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function I(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function q(e,t,n,r){for(var a=0,i=t,s=n-r;i<n;i+=r)a+=(e[s]-e[i])*(e[i+1]+e[s+1]),s=i;return a}p.deviation=function(e,t,n,r){var a=t&&t.length,i=a?t[0]*n:e.length,s=Math.abs(q(e,0,i,n));if(a)for(var u=0,o=t.length;u<o;u++){var x=t[u]*n,p=u<o-1?t[u+1]*n:e.length;s-=Math.abs(q(e,x,p,n))}var l=0;for(u=0;u<r.length;u+=3){var y=r[u]*n,h=r[u+1]*n,c=r[u+2]*n;l+=Math.abs((e[y]-e[c])*(e[h+1]-e[y+1])-(e[y]-e[h])*(e[c+1]-e[y+1]))}return 0===s&&0===l?0:Math.abs((l-s)/s)},p.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,a=0;a<e.length;a++){for(var i=0;i<e[a].length;i++)for(var s=0;s<t;s++)n.vertices.push(e[a][i][s]);a>0&&(r+=e[a-1].length,n.holes.push(r))}return n},o.default=x;const N={CLOCKWISE:u.WebGLConstants.CW,COUNTER_CLOCKWISE:u.WebGLConstants.CCW,validate:function(e){return e===N.CLOCKWISE||e===N.COUNTER_CLOCKWISE}};var U=Object.freeze(N);const _=new t.Cartesian3,K=new t.Cartesian3,V={computeArea2D:function(e){n.Check.defined("positions",e),n.Check.typeOf.number.greaterThanOrEquals("positions.length",e.length,3);const t=e.length;let r=0;for(let n=t-1,a=0;a<t;n=a++){const t=e[n],i=e[a];r+=t.x*i.y-i.x*t.y}return.5*r},computeWindingOrder2D:function(e){return V.computeArea2D(e)>0?U.COUNTER_CLOCKWISE:U.CLOCKWISE},triangulate:function(e,r){n.Check.defined("positions",e);const a=t.Cartesian2.packArray(e);return o(a,r,2)}},F=new t.Cartesian3,j=new t.Cartesian3,H=new t.Cartesian3,J=new t.Cartesian3,Q=new t.Cartesian3,X=new t.Cartesian3,Y=new t.Cartesian3,ee=new t.Cartesian2,te=new t.Cartesian2,ne=new t.Cartesian2,re=new t.Cartesian2;V.computeSubdivision=function(e,i,u,o,x){x=a.defaultValue(x,r.CesiumMath.RADIANS_PER_DEGREE);const p=a.defined(o);n.Check.typeOf.object("ellipsoid",e),n.Check.defined("positions",i),n.Check.defined("indices",u),n.Check.typeOf.number.greaterThanOrEquals("indices.length",u.length,3),n.Check.typeOf.number.equals("indices.length % 3","0",u.length%3,0),n.Check.typeOf.number.greaterThan("granularity",x,0);const l=u.slice(0);let y;const h=i.length,c=new Array(3*h),f=new Array(2*h);let d=0,v=0;for(y=0;y<h;y++){const e=i[y];if(c[d++]=e.x,c[d++]=e.y,c[d++]=e.z,p){const e=o[y];f[v++]=e.x,f[v++]=e.y}}const C=[],m={},g=e.maximumRadius,b=r.CesiumMath.chordLength(x,g),w=b*b;for(;l.length>0;){const e=l.pop(),n=l.pop(),r=l.pop(),i=t.Cartesian3.fromArray(c,3*r,F),s=t.Cartesian3.fromArray(c,3*n,j),u=t.Cartesian3.fromArray(c,3*e,H);let o,x,h;p&&(o=t.Cartesian2.fromArray(f,2*r,ee),x=t.Cartesian2.fromArray(f,2*n,te),h=t.Cartesian2.fromArray(f,2*e,ne));const d=t.Cartesian3.multiplyByScalar(t.Cartesian3.normalize(i,J),g,J),v=t.Cartesian3.multiplyByScalar(t.Cartesian3.normalize(s,Q),g,Q),b=t.Cartesian3.multiplyByScalar(t.Cartesian3.normalize(u,X),g,X),A=t.Cartesian3.magnitudeSquared(t.Cartesian3.subtract(d,v,Y)),E=t.Cartesian3.magnitudeSquared(t.Cartesian3.subtract(v,b,Y)),S=t.Cartesian3.magnitudeSquared(t.Cartesian3.subtract(b,d,Y)),M=Math.max(A,E,S);let O,Z,z;M>w?A===M?(O=`${Math.min(r,n)} ${Math.max(r,n)}`,y=m[O],a.defined(y)||(Z=t.Cartesian3.add(i,s,Y),t.Cartesian3.multiplyByScalar(Z,.5,Z),c.push(Z.x,Z.y,Z.z),y=c.length/3-1,m[O]=y,p&&(z=t.Cartesian2.add(o,x,re),t.Cartesian2.multiplyByScalar(z,.5,z),f.push(z.x,z.y))),l.push(r,y,e),l.push(y,n,e)):E===M?(O=`${Math.min(n,e)} ${Math.max(n,e)}`,y=m[O],a.defined(y)||(Z=t.Cartesian3.add(s,u,Y),t.Cartesian3.multiplyByScalar(Z,.5,Z),c.push(Z.x,Z.y,Z.z),y=c.length/3-1,m[O]=y,p&&(z=t.Cartesian2.add(x,h,re),t.Cartesian2.multiplyByScalar(z,.5,z),f.push(z.x,z.y))),l.push(n,y,r),l.push(y,e,r)):S===M&&(O=`${Math.min(e,r)} ${Math.max(e,r)}`,y=m[O],a.defined(y)||(Z=t.Cartesian3.add(u,i,Y),t.Cartesian3.multiplyByScalar(Z,.5,Z),c.push(Z.x,Z.y,Z.z),y=c.length/3-1,m[O]=y,p&&(z=t.Cartesian2.add(h,o,re),t.Cartesian2.multiplyByScalar(z,.5,z),f.push(z.x,z.y))),l.push(e,y,n),l.push(y,r,n)):(C.push(r),C.push(n),C.push(e))}const A={attributes:{position:new s.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:c})},indices:C,primitiveType:s.PrimitiveType.TRIANGLES};return p&&(A.attributes.st=new s.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:f})),new s.Geometry(A)};const ae=new t.Cartographic,ie=new t.Cartographic,se=new t.Cartographic,ue=new t.Cartographic;V.computeRhumbLineSubdivision=function(e,u,o,x,p){p=a.defaultValue(p,r.CesiumMath.RADIANS_PER_DEGREE);const l=a.defined(x);n.Check.typeOf.object("ellipsoid",e),n.Check.defined("positions",u),n.Check.defined("indices",o),n.Check.typeOf.number.greaterThanOrEquals("indices.length",o.length,3),n.Check.typeOf.number.equals("indices.length % 3","0",o.length%3,0),n.Check.typeOf.number.greaterThan("granularity",p,0);const y=o.slice(0);let h;const c=u.length,f=new Array(3*c),d=new Array(2*c);let v=0,C=0;for(h=0;h<c;h++){const e=u[h];if(f[v++]=e.x,f[v++]=e.y,f[v++]=e.z,l){const e=x[h];d[C++]=e.x,d[C++]=e.y}}const m=[],g={},b=e.maximumRadius,w=r.CesiumMath.chordLength(p,b),A=new i.EllipsoidRhumbLine(void 0,void 0,e),E=new i.EllipsoidRhumbLine(void 0,void 0,e),S=new i.EllipsoidRhumbLine(void 0,void 0,e);for(;y.length>0;){const n=y.pop(),r=y.pop(),i=y.pop(),s=t.Cartesian3.fromArray(f,3*i,F),u=t.Cartesian3.fromArray(f,3*r,j),o=t.Cartesian3.fromArray(f,3*n,H);let x,p,c;l&&(x=t.Cartesian2.fromArray(d,2*i,ee),p=t.Cartesian2.fromArray(d,2*r,te),c=t.Cartesian2.fromArray(d,2*n,ne));const v=e.cartesianToCartographic(s,ae),C=e.cartesianToCartographic(u,ie),b=e.cartesianToCartographic(o,se);A.setEndPoints(v,C);const M=A.surfaceDistance;E.setEndPoints(C,b);const O=E.surfaceDistance;S.setEndPoints(b,v);const Z=S.surfaceDistance,z=Math.max(M,O,Z);let L,R,D,T,k;z>w?M===z?(L=`${Math.min(i,r)} ${Math.max(i,r)}`,h=g[L],a.defined(h)||(R=A.interpolateUsingFraction(.5,ue),D=.5*(v.height+C.height),T=t.Cartesian3.fromRadians(R.longitude,R.latitude,D,e,Y),f.push(T.x,T.y,T.z),h=f.length/3-1,g[L]=h,l&&(k=t.Cartesian2.add(x,p,re),t.Cartesian2.multiplyByScalar(k,.5,k),d.push(k.x,k.y))),y.push(i,h,n),y.push(h,r,n)):O===z?(L=`${Math.min(r,n)} ${Math.max(r,n)}`,h=g[L],a.defined(h)||(R=E.interpolateUsingFraction(.5,ue),D=.5*(C.height+b.height),T=t.Cartesian3.fromRadians(R.longitude,R.latitude,D,e,Y),f.push(T.x,T.y,T.z),h=f.length/3-1,g[L]=h,l&&(k=t.Cartesian2.add(p,c,re),t.Cartesian2.multiplyByScalar(k,.5,k),d.push(k.x,k.y))),y.push(r,h,i),y.push(h,n,i)):Z===z&&(L=`${Math.min(n,i)} ${Math.max(n,i)}`,h=g[L],a.defined(h)||(R=S.interpolateUsingFraction(.5,ue),D=.5*(b.height+v.height),T=t.Cartesian3.fromRadians(R.longitude,R.latitude,D,e,Y),f.push(T.x,T.y,T.z),h=f.length/3-1,g[L]=h,l&&(k=t.Cartesian2.add(c,x,re),t.Cartesian2.multiplyByScalar(k,.5,k),d.push(k.x,k.y))),y.push(n,h,r),y.push(h,i,r)):(m.push(i),m.push(r),m.push(n))}const M={attributes:{position:new s.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:f})},indices:m,primitiveType:s.PrimitiveType.TRIANGLES};return l&&(M.attributes.st=new s.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:d})),new s.Geometry(M)},V.scaleToGeodeticHeight=function(e,n,r,i){r=a.defaultValue(r,t.Ellipsoid.WGS84);let s=_,u=K;if(n=a.defaultValue(n,0),i=a.defaultValue(i,!0),a.defined(e)){const a=e.length;for(let o=0;o<a;o+=3)t.Cartesian3.fromArray(e,o,u),i&&(u=r.scaleToGeodeticSurface(u,u)),0!==n&&(s=r.geodeticSurfaceNormal(u,s),t.Cartesian3.multiplyByScalar(s,n,s),t.Cartesian3.add(u,s,u)),e[o]=u.x,e[o+1]=u.y,e[o+2]=u.z}return e},e.PolygonPipeline=V,e.WindingOrder=U}));