createCorridorGeometry.js 15 KB

1
  1. define(["./arrayFill-0358accf","./arrayRemoveDuplicates-f7eaafa2","./buildModuleUrl-3d15f25c","./Cartographic-67e73ef9","./Check-52a7d806","./ComponentDatatype-81047f82","./PolylineVolumeGeometryLibrary-9a645937","./CorridorGeometryLibrary-db429299","./when-92c6cf3c","./Rectangle-bab7abf0","./GeometryAttribute-ef657318","./GeometryAttributes-7f66ea53","./GeometryOffsetAttribute-b4d599f5","./IndexDatatype-4c0e98b8","./Math-92c3b5f7","./PolygonPipeline-b86e8785","./PrimitiveType-cdfe443e","./VertexFormat-f496a3f1","./Intersect-b97e930a","./Event-3390cd7d","./RuntimeError-c6a62a80","./WebGLConstants-71f10989","./Cartesian2-6033fa5d","./Cartesian4-ad128b5d","./EllipsoidTangentPlane-53184efd","./IntersectionTests-a42760d9","./Plane-f8d22530","./PolylinePipeline-c0932bf7","./EllipsoidGeodesic-04ac0e77","./EllipsoidRhumbLine-8847d1a1","./FeatureDetection-067cb23c","./WindingOrder-1b9c8a87"],(function(t,e,r,a,o,n,i,s,l,d,u,c,f,m,h,p,g,b,v,y,A,_,w,T,E,N,D,P,I,x,F,O){"use strict";var M=new a.t,S=new a.t,L=new a.t,C=new a.t,V=new a.t,G=new a.t,k=new a.t,R=new a.t;function z(t,e){for(var r=0;r<t.length;r++)t[r]=e.scaleToGeodeticSurface(t[r],t[r]);return t}function H(t,e,r,o,n,i){var l=t.normals,d=t.tangents,u=t.bitangents,c=a.t.normalize(a.t.cross(r,e,k),k);i.normal&&s.b.addAttribute(l,e,o,n),i.tangent&&s.b.addAttribute(d,c,o,n),i.bitangent&&s.b.addAttribute(u,r,o,n)}function U(t,e,r){var o,i,d,f=t.positions,p=t.corners,g=t.endPositions,b=t.lefts,v=t.normals,y=new c.a,A=0,_=0,w=0;for(i=0;i<f.length;i+=2)A+=d=f[i].length-3,w+=2*d,_+=f[i+1].length-3;for(A+=3,_+=3,i=0;i<p.length;i++){o=p[i];var T=p[i].leftPositions;l.e(T)?(A+=d=T.length,w+=d):(_+=d=p[i].rightPositions.length,w+=d)}var E,N=l.e(g);N&&(A+=E=g[0].length-3,_+=E,w+=6*(E/=3));var D,P,I,x,F,O,V=A+_,z=new Float64Array(V),U={normals:e.normal?new Float32Array(V):void 0,tangents:e.tangent?new Float32Array(V):void 0,bitangents:e.bitangent?new Float32Array(V):void 0},Y=0,B=V-1,W=M,q=S,$=E/2,J=m.IndexDatatype.createTypedArray(V/3,w),j=0;if(N){O=L,F=C;var K=g[0];for(W=a.t.fromArray(v,0,W),q=a.t.fromArray(b,0,q),i=0;i<$;i++)O=a.t.fromArray(K,3*($-1-i),O),F=a.t.fromArray(K,3*($+i),F),s.b.addAttribute(z,F,Y),s.b.addAttribute(z,O,void 0,B),H(U,W,q,Y,B,e),x=(P=Y/3)+1,I=(D=(B-2)/3)-1,J[j++]=D,J[j++]=P,J[j++]=I,J[j++]=I,J[j++]=P,J[j++]=x,Y+=3,B-=3}var Q,X,Z=0,tt=0,et=f[Z++],rt=f[Z++];for(z.set(et,Y),z.set(rt,B-rt.length+1),q=a.t.fromArray(b,tt,q),d=rt.length-3,i=0;i<d;i+=3)Q=r.geodeticSurfaceNormal(a.t.fromArray(et,i,k),k),X=r.geodeticSurfaceNormal(a.t.fromArray(rt,d-i,R),R),H(U,W=a.t.normalize(a.t.add(Q,X,W),W),q,Y,B,e),x=(P=Y/3)+1,I=(D=(B-2)/3)-1,J[j++]=D,J[j++]=P,J[j++]=I,J[j++]=I,J[j++]=P,J[j++]=x,Y+=3,B-=3;for(Q=r.geodeticSurfaceNormal(a.t.fromArray(et,d,k),k),X=r.geodeticSurfaceNormal(a.t.fromArray(rt,d,R),R),W=a.t.normalize(a.t.add(Q,X,W),W),tt+=3,i=0;i<p.length;i++){var at,ot,nt,it=(o=p[i]).leftPositions,st=o.rightPositions,lt=G,dt=L,ut=C;if(W=a.t.fromArray(v,tt,W),l.e(it)){for(H(U,W,q,void 0,B,e),B-=3,ot=x,nt=I,at=0;at<it.length/3;at++)lt=a.t.fromArray(it,3*at,lt),J[j++]=ot,J[j++]=nt-at-1,J[j++]=nt-at,s.b.addAttribute(z,lt,void 0,B),dt=a.t.fromArray(z,3*(nt-at-1),dt),ut=a.t.fromArray(z,3*ot,ut),H(U,W,q=a.t.normalize(a.t.subtract(dt,ut,q),q),void 0,B,e),B-=3;lt=a.t.fromArray(z,3*ot,lt),dt=a.t.subtract(a.t.fromArray(z,3*nt,dt),lt,dt),ut=a.t.subtract(a.t.fromArray(z,3*(nt-at),ut),lt,ut),H(U,W,q=a.t.normalize(a.t.add(dt,ut,q),q),Y,void 0,e),Y+=3}else{for(H(U,W,q,Y,void 0,e),Y+=3,ot=I,nt=x,at=0;at<st.length/3;at++)lt=a.t.fromArray(st,3*at,lt),J[j++]=ot,J[j++]=nt+at,J[j++]=nt+at+1,s.b.addAttribute(z,lt,Y),dt=a.t.fromArray(z,3*ot,dt),ut=a.t.fromArray(z,3*(nt+at),ut),H(U,W,q=a.t.normalize(a.t.subtract(dt,ut,q),q),Y,void 0,e),Y+=3;lt=a.t.fromArray(z,3*ot,lt),dt=a.t.subtract(a.t.fromArray(z,3*(nt+at),dt),lt,dt),ut=a.t.subtract(a.t.fromArray(z,3*nt,ut),lt,ut),H(U,W,q=a.t.normalize(a.t.negate(a.t.add(ut,dt,q),q),q),void 0,B,e),B-=3}for(et=f[Z++],rt=f[Z++],et.splice(0,3),rt.splice(rt.length-3,3),z.set(et,Y),z.set(rt,B-rt.length+1),d=rt.length-3,tt+=3,q=a.t.fromArray(b,tt,q),at=0;at<rt.length;at+=3)Q=r.geodeticSurfaceNormal(a.t.fromArray(et,at,k),k),X=r.geodeticSurfaceNormal(a.t.fromArray(rt,d-at,R),R),H(U,W=a.t.normalize(a.t.add(Q,X,W),W),q,Y,B,e),P=(x=Y/3)-1,D=(I=(B-2)/3)+1,J[j++]=D,J[j++]=P,J[j++]=I,J[j++]=I,J[j++]=P,J[j++]=x,Y+=3,B-=3;Y-=3,B+=3}if(H(U,W=a.t.fromArray(v,v.length-3,W),q,Y,B,e),N){Y+=3,B-=3,O=L,F=C;var ct=g[1];for(i=0;i<$;i++)O=a.t.fromArray(ct,3*(E-i-1),O),F=a.t.fromArray(ct,3*i,F),s.b.addAttribute(z,O,void 0,B),s.b.addAttribute(z,F,Y),H(U,W,q,Y,B,e),P=(x=Y/3)-1,D=(I=(B-2)/3)+1,J[j++]=D,J[j++]=P,J[j++]=I,J[j++]=I,J[j++]=P,J[j++]=x,Y+=3,B-=3}if(y.position=new u.o({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:z}),e.st){var ft,mt,ht=new Float32Array(V/3*2),pt=0;if(N){A/=3,_/=3;var gt=Math.PI/(E+1);mt=1/(A-E+1),ft=1/(_-E+1);var bt,vt=E/2;for(i=vt+1;i<E+1;i++)bt=h.e.PI_OVER_TWO+gt*i,ht[pt++]=ft*(1+Math.cos(bt)),ht[pt++]=.5*(1+Math.sin(bt));for(i=1;i<_-E+1;i++)ht[pt++]=i*ft,ht[pt++]=0;for(i=E;i>vt;i--)bt=h.e.PI_OVER_TWO-i*gt,ht[pt++]=1-ft*(1+Math.cos(bt)),ht[pt++]=.5*(1+Math.sin(bt));for(i=vt;i>0;i--)bt=h.e.PI_OVER_TWO-gt*i,ht[pt++]=1-mt*(1+Math.cos(bt)),ht[pt++]=.5*(1+Math.sin(bt));for(i=A-E;i>0;i--)ht[pt++]=i*mt,ht[pt++]=1;for(i=1;i<vt+1;i++)bt=h.e.PI_OVER_TWO+gt*i,ht[pt++]=mt*(1+Math.cos(bt)),ht[pt++]=.5*(1+Math.sin(bt))}else{for(mt=1/((A/=3)-1),ft=1/((_/=3)-1),i=0;i<_;i++)ht[pt++]=i*ft,ht[pt++]=0;for(i=A;i>0;i--)ht[pt++]=(i-1)*mt,ht[pt++]=1}y.st=new u.o({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:ht})}return e.normal&&(y.normal=new u.o({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:U.normals})),e.tangent&&(y.tangent=new u.o({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:U.tangents})),e.bitangent&&(y.bitangent=new u.o({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:U.bitangents})),{attributes:y,indices:J}}function Y(t,e,r){r[e++]=t[0],r[e++]=t[1],r[e++]=t[2];for(var a=3;a<t.length;a+=3){var o=t[a],n=t[a+1],i=t[a+2];r[e++]=o,r[e++]=n,r[e++]=i,r[e++]=o,r[e++]=n,r[e++]=i}return r[e++]=t[0],r[e++]=t[1],r[e++]=t[2],r}function B(e,r){var o=new b.n({position:r.position,normal:r.normal||r.bitangent||e.shadowVolume,tangent:r.tangent,bitangent:r.normal||r.bitangent,st:r.st}),i=e.ellipsoid,d=U(s.b.computePositions(e),o,i),c=e.height,h=e.extrudedHeight,g=d.attributes,v=d.indices,y=g.position.values,A=y.length,_=new Float64Array(6*A),w=new Float64Array(A);w.set(y);var T=new Float64Array(4*A);T=Y(y=p.A.scaleToGeodeticHeight(y,c,i),0,T),T=Y(w=p.A.scaleToGeodeticHeight(w,h,i),2*A,T),_.set(y),_.set(w,A),_.set(T,2*A),g.position.values=_,g=function(t,e){if(!(e.normal||e.tangent||e.bitangent||e.st))return t;var r,o,n=t.position.values;(e.normal||e.bitangent)&&(r=t.normal.values,o=t.bitangent.values);var i,l=t.position.values.length/18,d=3*l,u=2*l,c=2*d;if(e.normal||e.bitangent||e.tangent){var f=e.normal?new Float32Array(6*d):void 0,m=e.tangent?new Float32Array(6*d):void 0,h=e.bitangent?new Float32Array(6*d):void 0,p=M,g=S,b=L,v=C,y=V,A=G,_=c;for(i=0;i<d;i+=3){var w=_+c;p=a.t.fromArray(n,i,p),g=a.t.fromArray(n,i+d,g),b=a.t.fromArray(n,(i+3)%d,b),g=a.t.subtract(g,p,g),b=a.t.subtract(b,p,b),v=a.t.normalize(a.t.cross(g,b,v),v),e.normal&&(s.b.addAttribute(f,v,w),s.b.addAttribute(f,v,w+3),s.b.addAttribute(f,v,_),s.b.addAttribute(f,v,_+3)),(e.tangent||e.bitangent)&&(A=a.t.fromArray(r,i,A),e.bitangent&&(s.b.addAttribute(h,A,w),s.b.addAttribute(h,A,w+3),s.b.addAttribute(h,A,_),s.b.addAttribute(h,A,_+3)),e.tangent&&(y=a.t.normalize(a.t.cross(A,v,y),y),s.b.addAttribute(m,y,w),s.b.addAttribute(m,y,w+3),s.b.addAttribute(m,y,_),s.b.addAttribute(m,y,_+3))),_+=6}if(e.normal){for(f.set(r),i=0;i<d;i+=3)f[i+d]=-r[i],f[i+d+1]=-r[i+1],f[i+d+2]=-r[i+2];t.normal.values=f}else t.normal=void 0;if(e.bitangent?(h.set(o),h.set(o,d),t.bitangent.values=h):t.bitangent=void 0,e.tangent){var T=t.tangent.values;m.set(T),m.set(T,d),t.tangent.values=m}}if(e.st){var E=t.st.values,N=new Float32Array(6*u);N.set(E),N.set(E,u);for(var D=2*u,P=0;P<2;P++){for(N[D++]=E[0],N[D++]=E[1],i=2;i<u;i+=2){var I=E[i],x=E[i+1];N[D++]=I,N[D++]=x,N[D++]=I,N[D++]=x}N[D++]=E[0],N[D++]=E[1]}t.st.values=N}return t}(g,r);var E,N=A/3;if(e.shadowVolume){var D=g.normal.values;A=D.length;var P=new Float32Array(6*A);for(E=0;E<A;E++)D[E]=-D[E];P.set(D,A),P=Y(D,4*A,P),g.extrudeDirection=new u.o({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:P}),r.normal||(g.normal=void 0)}if(l.e(e.offsetAttribute)){var I=new Uint8Array(6*N);if(e.offsetAttribute===f.z.TOP)I=t.d(I,1,0,N),I=t.d(I,1,2*N,4*N);else{var x=e.offsetAttribute===f.z.NONE?0:1;I=t.d(I,x)}g.applyOffset=new u.o({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:I})}var F=v.length,O=N+N,k=m.IndexDatatype.createTypedArray(_.length/3,2*F+3*O);k.set(v);var R,z,H,B,W=F;for(E=0;E<F;E+=3){var q=v[E],$=v[E+1],J=v[E+2];k[W++]=J+N,k[W++]=$+N,k[W++]=q+N}for(E=0;E<O;E+=2)H=(R=E+O)+1,B=(z=R+O)+1,k[W++]=R,k[W++]=z,k[W++]=H,k[W++]=H,k[W++]=z,k[W++]=B;return{attributes:g,indices:k}}var W=new a.t,q=new a.t,$=new a.t$1;function J(t,e,r,o,n,i){var s=a.t.subtract(e,t,W);a.t.normalize(s,s);var l=r.geodeticSurfaceNormal(t,q),d=a.t.cross(s,l,W);a.t.multiplyByScalar(d,o,d);var u=n.latitude,c=n.longitude,f=i.latitude,m=i.longitude;a.t.add(t,d,q),r.cartesianToCartographic(q,$);var h=$.latitude,p=$.longitude;u=Math.min(u,h),c=Math.min(c,p),f=Math.max(f,h),m=Math.max(m,p),a.t.subtract(t,d,q),r.cartesianToCartographic(q,$),h=$.latitude,p=$.longitude,u=Math.min(u,h),c=Math.min(c,p),f=Math.max(f,h),m=Math.max(m,p),n.latitude=u,n.longitude=c,i.latitude=f,i.longitude=m}var j=new a.t,K=new a.t,Q=new a.t$1,X=new a.t$1;function Z(t,r,o,n,s){t=z(t,r);var u=e.D(t,a.t.equalsEpsilon),c=u.length;if(c<2||o<=0)return new d.h;var f,m,h=.5*o;if(Q.latitude=Number.POSITIVE_INFINITY,Q.longitude=Number.POSITIVE_INFINITY,X.latitude=Number.NEGATIVE_INFINITY,X.longitude=Number.NEGATIVE_INFINITY,n===i.S.ROUNDED){var p=u[0];a.t.subtract(p,u[1],j),a.t.normalize(j,j),a.t.multiplyByScalar(j,h,j),a.t.add(p,j,K),r.cartesianToCartographic(K,$),f=$.latitude,m=$.longitude,Q.latitude=Math.min(Q.latitude,f),Q.longitude=Math.min(Q.longitude,m),X.latitude=Math.max(X.latitude,f),X.longitude=Math.max(X.longitude,m)}for(var g=0;g<c-1;++g)J(u[g],u[g+1],r,h,Q,X);var b=u[c-1];a.t.subtract(b,u[c-2],j),a.t.normalize(j,j),a.t.multiplyByScalar(j,h,j),a.t.add(b,j,K),J(b,K,r,h,Q,X),n===i.S.ROUNDED&&(r.cartesianToCartographic(K,$),f=$.latitude,m=$.longitude,Q.latitude=Math.min(Q.latitude,f),Q.longitude=Math.min(Q.longitude,m),X.latitude=Math.max(X.latitude,f),X.longitude=Math.max(X.longitude,m));var v=l.e(s)?s:new d.h;return v.north=X.latitude,v.south=Q.latitude,v.east=X.longitude,v.west=Q.longitude,v}function tt(t){var e=(t=l.u(t,l.u.EMPTY_OBJECT)).positions,r=t.width;o.o.defined("options.positions",e),o.o.defined("options.width",r);var n=l.u(t.height,0),s=l.u(t.extrudedHeight,n);this._positions=e,this._ellipsoid=d.t.clone(l.u(t.ellipsoid,d.t.WGS84)),this._vertexFormat=b.n.clone(l.u(t.vertexFormat,b.n.DEFAULT)),this._width=r,this._height=Math.max(n,s),this._extrudedHeight=Math.min(n,s),this._cornerType=l.u(t.cornerType,i.S.ROUNDED),this._granularity=l.u(t.granularity,h.e.RADIANS_PER_DEGREE),this._shadowVolume=l.u(t.shadowVolume,!1),this._workerName="createCorridorGeometry",this._offsetAttribute=t.offsetAttribute,this._rectangle=void 0,this.packedLength=1+e.length*a.t.packedLength+d.t.packedLength+b.n.packedLength+7}tt.pack=function(t,e,r){o.o.defined("value",t),o.o.defined("array",e),r=l.u(r,0);var n=t._positions,i=n.length;e[r++]=i;for(var s=0;s<i;++s,r+=a.t.packedLength)a.t.pack(n[s],e,r);return d.t.pack(t._ellipsoid,e,r),r+=d.t.packedLength,b.n.pack(t._vertexFormat,e,r),r+=b.n.packedLength,e[r++]=t._width,e[r++]=t._height,e[r++]=t._extrudedHeight,e[r++]=t._cornerType,e[r++]=t._granularity,e[r++]=t._shadowVolume?1:0,e[r]=l.u(t._offsetAttribute,-1),e};var et=d.t.clone(d.t.UNIT_SPHERE),rt=new b.n,at={positions:void 0,ellipsoid:et,vertexFormat:rt,width:void 0,height:void 0,extrudedHeight:void 0,cornerType:void 0,granularity:void 0,shadowVolume:void 0,offsetAttribute:void 0};return tt.unpack=function(t,e,r){o.o.defined("array",t),e=l.u(e,0);for(var n=t[e++],i=new Array(n),s=0;s<n;++s,e+=a.t.packedLength)i[s]=a.t.unpack(t,e);var u=d.t.unpack(t,e,et);e+=d.t.packedLength;var c=b.n.unpack(t,e,rt);e+=b.n.packedLength;var f=t[e++],m=t[e++],h=t[e++],p=t[e++],g=t[e++],v=1===t[e++],y=t[e];return l.e(r)?(r._positions=i,r._ellipsoid=d.t.clone(u,r._ellipsoid),r._vertexFormat=b.n.clone(c,r._vertexFormat),r._width=f,r._height=m,r._extrudedHeight=h,r._cornerType=p,r._granularity=g,r._shadowVolume=v,r._offsetAttribute=-1===y?void 0:y,r):(at.positions=i,at.width=f,at.height=m,at.extrudedHeight=h,at.cornerType=p,at.granularity=g,at.shadowVolume=v,at.offsetAttribute=-1===y?void 0:y,new tt(at))},tt.computeRectangle=function(t,e){var r=(t=l.u(t,l.u.EMPTY_OBJECT)).positions,a=t.width;return o.o.defined("options.positions",r),o.o.defined("options.width",a),Z(r,l.u(t.ellipsoid,d.t.WGS84),a,l.u(t.cornerType,i.S.ROUNDED),e)},tt.createGeometry=function(o){var i=o._positions,d=o._width,c=o._ellipsoid;i=z(i,c);var m=e.D(i,a.t.equalsEpsilon);if(!(m.length<2||d<=0)){var b,v=o._height,y=o._extrudedHeight,A=!h.e.equalsEpsilon(v,y,0,h.e.EPSILON2),_=o._vertexFormat,w={ellipsoid:c,positions:m,width:d,cornerType:o._cornerType,granularity:o._granularity,saveAttributes:!0};if(A)w.height=v,w.extrudedHeight=y,w.shadowVolume=o._shadowVolume,w.offsetAttribute=o._offsetAttribute,b=B(w,_);else if((b=U(s.b.computePositions(w),_,c)).attributes.position.values=p.A.scaleToGeodeticHeight(b.attributes.position.values,v,c),l.e(o._offsetAttribute)){var T=o._offsetAttribute===f.z.NONE?0:1,E=b.attributes.position.values.length,N=new Uint8Array(E/3);t.d(N,T),b.attributes.applyOffset=new u.o({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:N})}var D=b.attributes,P=r.i.fromVertices(D.position.values,void 0,3);return _.position||(b.attributes.position.values=void 0),new u.I({attributes:D,indices:b.indices,primitiveType:g._0x29ba75.TRIANGLES,boundingSphere:P,offsetAttribute:o._offsetAttribute})}},tt.createShadowVolume=function(t,e,r){var a=t._granularity,o=t._ellipsoid,n=e(a,o),i=r(a,o);return new tt({positions:t._positions,width:t._width,cornerType:t._cornerType,ellipsoid:o,granularity:a,extrudedHeight:n,height:i,vertexFormat:b.n.POSITION_ONLY,shadowVolume:!0})},Object.defineProperties(tt.prototype,{rectangle:{get:function(){return l.e(this._rectangle)||(this._rectangle=Z(this._positions,this._ellipsoid,this._width,this._cornerType)),this._rectangle}},textureCoordinateRotationPoints:{get:function(){return[0,0,0,1,1,0]}}}),function(t,e){return l.e(e)&&(t=tt.unpack(t,e)),t._ellipsoid=d.t.clone(t._ellipsoid),tt.createGeometry(t)}}));