EllipseGeometry-47042820.js 14 KB

1
  1. define(["exports","./arrayFill-0358accf","./buildModuleUrl-3d15f25c","./Cartesian2-6033fa5d","./Cartographic-67e73ef9","./Check-52a7d806","./ComponentDatatype-81047f82","./when-92c6cf3c","./EllipseGeometryLibrary-f97eafbd","./Rectangle-bab7abf0","./Intersect-b97e930a","./GeometryAttribute-ef657318","./GeometryAttributes-7f66ea53","./GeometryInstance-da5e91bc","./GeometryOffsetAttribute-b4d599f5","./GeometryPipeline-f4eddf07","./IndexDatatype-4c0e98b8","./Math-92c3b5f7","./PrimitiveType-cdfe443e","./VertexFormat-f496a3f1"],(function(t,e,o,r,n,i,a,s,u,m,l,c,p,y,d,f,h,A,x,g){"use strict";var _=new n.t,v=new n.t,b=new n.t,w=new n.t,I=new r.o,T=new x.p,N=new x.p,M=new c.n,E=new n.t,P=new n.t,D=new n.t,F=new n.t$1,O=new n.t,S=new r.o,C=new r.o;function R(t,o,i){var m=o.vertexFormat,y=o.center,f=o.semiMajorAxis,h=o.semiMinorAxis,A=o.ellipsoid,g=o.stRotation,w=i?t.length/3*2:t.length/3,R=o.shadowVolume,L=m.st?new Float32Array(2*w):void 0,j=m.normal?new Float32Array(3*w):void 0,z=m.tangent?new Float32Array(3*w):void 0,G=m.bitangent?new Float32Array(3*w):void 0,V=R?new Float32Array(3*w):void 0,k=0,Y=E,B=P,H=D,U=new l.n(A),W=U.project(A.cartesianToCartographic(y,F),O),q=A.scaleToGeodeticSurface(y,_);A.geodeticSurfaceNormal(q,q);var Q=T,J=N;if(0!==g){var Z=c.n.fromAxisAngle(q,g,M);Q=x.p.fromQuaternion(Z,Q),Z=c.n.fromAxisAngle(q,-g,M),J=x.p.fromQuaternion(Z,J)}else Q=x.p.clone(x.p.IDENTITY,Q),J=x.p.clone(x.p.IDENTITY,J);for(var $=r.o.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,S),K=r.o.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,C),X=t.length,tt=i?X:0,et=tt/3*2,ot=0;ot<X;ot+=3){var rt=ot+1,nt=ot+2,it=n.t.fromArray(t,ot,_);if(m.st){var at=x.p.multiplyByVector(Q,it,v),st=U.project(A.cartesianToCartographic(at,F),b);n.t.subtract(st,W,st),I.x=(st.x+f)/(2*f),I.y=(st.y+h)/(2*h),$.x=Math.min(I.x,$.x),$.y=Math.min(I.y,$.y),K.x=Math.max(I.x,K.x),K.y=Math.max(I.y,K.y),i&&(L[k+et]=I.x,L[k+1+et]=I.y),L[k++]=I.x,L[k++]=I.y}(m.normal||m.tangent||m.bitangent||R)&&(Y=A.geodeticSurfaceNormal(it,Y),R&&(V[ot+tt]=-Y.x,V[rt+tt]=-Y.y,V[nt+tt]=-Y.z),(m.normal||m.tangent||m.bitangent)&&((m.tangent||m.bitangent)&&(B=n.t.normalize(n.t.cross(n.t.UNIT_Z,Y,B),B),x.p.multiplyByVector(J,B,B)),m.normal&&(j[ot]=Y.x,j[rt]=Y.y,j[nt]=Y.z,i&&(j[ot+tt]=-Y.x,j[rt+tt]=-Y.y,j[nt+tt]=-Y.z)),m.tangent&&(z[ot]=B.x,z[rt]=B.y,z[nt]=B.z,i&&(z[ot+tt]=-B.x,z[rt+tt]=-B.y,z[nt+tt]=-B.z)),m.bitangent&&(H=n.t.normalize(n.t.cross(Y,B,H),H),G[ot]=H.x,G[rt]=H.y,G[nt]=H.z,i&&(G[ot+tt]=H.x,G[rt+tt]=H.y,G[nt+tt]=H.z))))}if(m.st){X=L.length;for(var ut=0;ut<X;ut+=2)L[ut]=(L[ut]-$.x)/(K.x-$.x),L[ut+1]=(L[ut+1]-$.y)/(K.y-$.y)}var mt=new p.a;if(m.position){var lt=u.C.raisePositionsToHeight(t,o,i);mt.position=new c.o({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:lt})}if(m.st&&(mt.st=new c.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:L})),m.normal&&(mt.normal=new c.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:j})),m.tangent&&(mt.tangent=new c.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:z})),m.bitangent&&(mt.bitangent=new c.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:G})),R&&(mt.extrudeDirection=new c.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:V})),i&&s.e(o.offsetAttribute)){var ct=new Uint8Array(w);if(o.offsetAttribute===d.z.TOP)ct=e.d(ct,1,0,w/2);else{var pt=o.offsetAttribute===d.z.NONE?0:1;ct=e.d(ct,pt)}mt.applyOffset=new c.o({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:ct})}return mt}function L(t){var e,o,r,n,i,a=new Array(t*(t+1)*12-6),s=0;for(e=0,r=1,n=0;n<3;n++)a[s++]=r++,a[s++]=e,a[s++]=r;for(n=2;n<t+1;++n){for(r=n*(n+1)-1,e=(n-1)*n-1,a[s++]=r++,a[s++]=e,a[s++]=r,o=2*n,i=0;i<o-1;++i)a[s++]=r,a[s++]=e++,a[s++]=e,a[s++]=r++,a[s++]=e,a[s++]=r;a[s++]=r++,a[s++]=e,a[s++]=r}for(o=2*t,++r,++e,n=0;n<o-1;++n)a[s++]=r,a[s++]=e++,a[s++]=e,a[s++]=r++,a[s++]=e,a[s++]=r;for(a[s++]=r,a[s++]=e++,a[s++]=e,a[s++]=r++,a[s++]=e++,a[s++]=e,++e,n=t-1;n>1;--n){for(a[s++]=e++,a[s++]=e,a[s++]=r,o=2*n,i=0;i<o-1;++i)a[s++]=r,a[s++]=e++,a[s++]=e,a[s++]=r++,a[s++]=e,a[s++]=r;a[s++]=e++,a[s++]=e++,a[s++]=r++}for(n=0;n<3;n++)a[s++]=e++,a[s++]=e,a[s++]=r;return a}var j=new n.t;var z=new o.i,G=new o.i;function V(t){var i=t.center,m=t.ellipsoid,A=t.semiMajorAxis,g=n.t.multiplyByScalar(m.geodeticSurfaceNormal(i,_),t.height,_);z.center=n.t.add(i,g,z.center),z.radius=A,g=n.t.multiplyByScalar(m.geodeticSurfaceNormal(i,g),t.extrudedHeight,g),G.center=n.t.add(i,g,G.center),G.radius=A;var N=u.C.computeEllipsePositions(t,!0,!0),j=N.positions,V=N.numPts,k=N.outerPositions,Y=o.i.union(z,G),B=R(j,t,!0),H=L(V),U=H.length;H.length=2*U;for(var W=j.length/3,q=0;q<U;q+=3)H[q+U]=H[q+2]+W,H[q+1+U]=H[q+1]+W,H[q+2+U]=H[q]+W;var Q=h.IndexDatatype.createTypedArray(2*W/3,H),J=new c.I({attributes:B,indices:Q,primitiveType:x._0x29ba75.TRIANGLES}),Z=function(t,o){var i=o.vertexFormat,u=o.center,m=o.semiMajorAxis,y=o.semiMinorAxis,f=o.ellipsoid,h=o.height,A=o.extrudedHeight,g=o.stRotation,N=t.length/3*2,R=new Float64Array(3*N),L=i.st?new Float32Array(2*N):void 0,j=i.normal?new Float32Array(3*N):void 0,z=i.tangent?new Float32Array(3*N):void 0,G=i.bitangent?new Float32Array(3*N):void 0,V=o.shadowVolume,k=V?new Float32Array(3*N):void 0,Y=0,B=E,H=P,U=D,W=new l.n(f),q=W.project(f.cartesianToCartographic(u,F),O),Q=f.scaleToGeodeticSurface(u,_);f.geodeticSurfaceNormal(Q,Q);for(var J=c.n.fromAxisAngle(Q,g,M),Z=x.p.fromQuaternion(J,T),$=r.o.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,S),K=r.o.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,C),X=t.length,tt=X/3*2,et=0;et<X;et+=3){var ot,rt=et+1,nt=et+2,it=n.t.fromArray(t,et,_);if(i.st){var at=x.p.multiplyByVector(Z,it,v),st=W.project(f.cartesianToCartographic(at,F),b);n.t.subtract(st,q,st),I.x=(st.x+m)/(2*m),I.y=(st.y+y)/(2*y),$.x=Math.min(I.x,$.x),$.y=Math.min(I.y,$.y),K.x=Math.max(I.x,K.x),K.y=Math.max(I.y,K.y),L[Y+tt]=I.x,L[Y+1+tt]=I.y,L[Y++]=I.x,L[Y++]=I.y}it=f.scaleToGeodeticSurface(it,it),ot=n.t.clone(it,v),B=f.geodeticSurfaceNormal(it,B),V&&(k[et+X]=-B.x,k[rt+X]=-B.y,k[nt+X]=-B.z);var ut=n.t.multiplyByScalar(B,h,w);if(it=n.t.add(it,ut,it),ut=n.t.multiplyByScalar(B,A,ut),ot=n.t.add(ot,ut,ot),i.position&&(R[et+X]=ot.x,R[rt+X]=ot.y,R[nt+X]=ot.z,R[et]=it.x,R[rt]=it.y,R[nt]=it.z),i.normal||i.tangent||i.bitangent){U=n.t.clone(B,U);var mt=n.t.fromArray(t,(et+3)%X,w);n.t.subtract(mt,it,mt);var lt=n.t.subtract(ot,it,b);B=n.t.normalize(n.t.cross(lt,mt,B),B),i.normal&&(j[et]=B.x,j[rt]=B.y,j[nt]=B.z,j[et+X]=B.x,j[rt+X]=B.y,j[nt+X]=B.z),i.tangent&&(H=n.t.normalize(n.t.cross(U,B,H),H),z[et]=H.x,z[rt]=H.y,z[nt]=H.z,z[et+X]=H.x,z[et+1+X]=H.y,z[et+2+X]=H.z),i.bitangent&&(G[et]=U.x,G[rt]=U.y,G[nt]=U.z,G[et+X]=U.x,G[rt+X]=U.y,G[nt+X]=U.z)}}if(i.st){X=L.length;for(var ct=0;ct<X;ct+=2)L[ct]=(L[ct]-$.x)/(K.x-$.x),L[ct+1]=(L[ct+1]-$.y)/(K.y-$.y)}var pt=new p.a;if(i.position&&(pt.position=new c.o({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:R})),i.st&&(pt.st=new c.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:L})),i.normal&&(pt.normal=new c.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:j})),i.tangent&&(pt.tangent=new c.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:z})),i.bitangent&&(pt.bitangent=new c.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:G})),V&&(pt.extrudeDirection=new c.o({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:k})),s.e(o.offsetAttribute)){var yt=new Uint8Array(N);if(o.offsetAttribute===d.z.TOP)yt=e.d(yt,1,0,N/2);else{var dt=o.offsetAttribute===d.z.NONE?0:1;yt=e.d(yt,dt)}pt.applyOffset=new c.o({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:yt})}return pt}(k,t);H=function(t){for(var e=t.length/3,o=h.IndexDatatype.createTypedArray(e,6*e),r=0,n=0;n<e;n++){var i=n,a=n+e,s=(i+1)%e,u=s+e;o[r++]=i,o[r++]=a,o[r++]=s,o[r++]=s,o[r++]=a,o[r++]=u}return o}(k);var $=h.IndexDatatype.createTypedArray(2*k.length/3,H),K=new c.I({attributes:Z,indices:$,primitiveType:x._0x29ba75.TRIANGLES}),X=f.k.combineInstances([new y.d({geometry:J}),new y.d({geometry:K})]);return{boundingSphere:Y,attributes:X[0].attributes,indices:X[0].indices}}function k(t,e,o,r,i,a,s){for(var l=u.C.computeEllipsePositions({center:t,semiMajorAxis:e,semiMinorAxis:o,rotation:r,granularity:i},!1,!0).outerPositions,c=l.length/3,p=new Array(c),y=0;y<c;++y)p[y]=n.t.fromArray(l,3*y);var d=m.h.fromCartesianArray(p,a,s);return d.width>A.e.PI&&(d.north=d.north>0?A.e.PI_OVER_TWO-A.e.EPSILON7:d.north,d.south=d.south<0?A.e.EPSILON7-A.e.PI_OVER_TWO:d.south,d.east=A.e.PI,d.west=-A.e.PI),d}function Y(t){var e=(t=s.u(t,s.u.EMPTY_OBJECT)).center,o=s.u(t.ellipsoid,m.t.WGS84),r=t.semiMajorAxis,a=t.semiMinorAxis,u=s.u(t.granularity,A.e.RADIANS_PER_DEGREE),l=s.u(t.vertexFormat,g.n.DEFAULT);if(i.o.defined("options.center",e),i.o.typeOf.number("options.semiMajorAxis",r),i.o.typeOf.number("options.semiMinorAxis",a),r<a)throw new i.t("semiMajorAxis must be greater than or equal to the semiMinorAxis.");if(u<=0)throw new i.t("granularity must be greater than zero.");var c=s.u(t.height,0),p=s.u(t.extrudedHeight,c);this._center=n.t.clone(e),this._semiMajorAxis=r,this._semiMinorAxis=a,this._ellipsoid=m.t.clone(o),this._rotation=s.u(t.rotation,0),this._stRotation=s.u(t.stRotation,0),this._height=Math.max(p,c),this._granularity=u,this._vertexFormat=g.n.clone(l),this._extrudedHeight=Math.min(p,c),this._shadowVolume=s.u(t.shadowVolume,!1),this._workerName="createEllipseGeometry",this._offsetAttribute=t.offsetAttribute,this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0}Y.packedLength=n.t.packedLength+m.t.packedLength+g.n.packedLength+9,Y.pack=function(t,e,o){return i.o.defined("value",t),i.o.defined("array",e),o=s.u(o,0),n.t.pack(t._center,e,o),o+=n.t.packedLength,m.t.pack(t._ellipsoid,e,o),o+=m.t.packedLength,g.n.pack(t._vertexFormat,e,o),o+=g.n.packedLength,e[o++]=t._semiMajorAxis,e[o++]=t._semiMinorAxis,e[o++]=t._rotation,e[o++]=t._stRotation,e[o++]=t._height,e[o++]=t._granularity,e[o++]=t._extrudedHeight,e[o++]=t._shadowVolume?1:0,e[o]=s.u(t._offsetAttribute,-1),e};var B=new n.t,H=new m.t,U=new g.n,W={center:B,ellipsoid:H,vertexFormat:U,semiMajorAxis:void 0,semiMinorAxis:void 0,rotation:void 0,stRotation:void 0,height:void 0,granularity:void 0,extrudedHeight:void 0,shadowVolume:void 0,offsetAttribute:void 0};Y.unpack=function(t,e,o){i.o.defined("array",t),e=s.u(e,0);var r=n.t.unpack(t,e,B);e+=n.t.packedLength;var a=m.t.unpack(t,e,H);e+=m.t.packedLength;var u=g.n.unpack(t,e,U);e+=g.n.packedLength;var l=t[e++],c=t[e++],p=t[e++],y=t[e++],d=t[e++],f=t[e++],h=t[e++],A=1===t[e++],x=t[e];return s.e(o)?(o._center=n.t.clone(r,o._center),o._ellipsoid=m.t.clone(a,o._ellipsoid),o._vertexFormat=g.n.clone(u,o._vertexFormat),o._semiMajorAxis=l,o._semiMinorAxis=c,o._rotation=p,o._stRotation=y,o._height=d,o._granularity=f,o._extrudedHeight=h,o._shadowVolume=A,o._offsetAttribute=-1===x?void 0:x,o):(W.height=d,W.extrudedHeight=h,W.granularity=f,W.stRotation=y,W.rotation=p,W.semiMajorAxis=l,W.semiMinorAxis=c,W.shadowVolume=A,W.offsetAttribute=-1===x?void 0:x,new Y(W))},Y.computeRectangle=function(t,e){var o=(t=s.u(t,s.u.EMPTY_OBJECT)).center,r=s.u(t.ellipsoid,m.t.WGS84),n=t.semiMajorAxis,a=t.semiMinorAxis,u=s.u(t.granularity,A.e.RADIANS_PER_DEGREE),l=s.u(t.rotation,0);if(i.o.defined("options.center",o),i.o.typeOf.number("options.semiMajorAxis",n),i.o.typeOf.number("options.semiMinorAxis",a),n<a)throw new i.t("semiMajorAxis must be greater than or equal to the semiMinorAxis.");if(u<=0)throw new i.t("granularity must be greater than zero.");return k(o,n,a,l,u,r,e)},Y.createGeometry=function(t){if(!(t._semiMajorAxis<=0||t._semiMinorAxis<=0)){var r=t._height,i=t._extrudedHeight,m=!A.e.equalsEpsilon(r,i,0,A.e.EPSILON2);t._center=t._ellipsoid.scaleToGeodeticSurface(t._center,t._center);var l,p={center:t._center,semiMajorAxis:t._semiMajorAxis,semiMinorAxis:t._semiMinorAxis,ellipsoid:t._ellipsoid,rotation:t._rotation,height:r,granularity:t._granularity,vertexFormat:t._vertexFormat,stRotation:t._stRotation};if(m)p.extrudedHeight=i,p.shadowVolume=t._shadowVolume,p.offsetAttribute=t._offsetAttribute,l=V(p);else if(l=function(t){var e=t.center;j=n.t.multiplyByScalar(t.ellipsoid.geodeticSurfaceNormal(e,j),t.height,j),j=n.t.add(e,j,j);var r=new o.i(j,t.semiMajorAxis),i=u.C.computeEllipsePositions(t,!0,!1),a=i.positions,s=i.numPts,m=R(a,t,!1),l=L(s);return{boundingSphere:r,attributes:m,indices:l=h.IndexDatatype.createTypedArray(a.length/3,l)}}(p),s.e(t._offsetAttribute)){var y=l.attributes.position.values.length,f=new Uint8Array(y/3),g=t._offsetAttribute===d.z.NONE?0:1;e.d(f,g),l.attributes.applyOffset=new c.o({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:f})}return new c.I({attributes:l.attributes,indices:l.indices,primitiveType:x._0x29ba75.TRIANGLES,boundingSphere:l.boundingSphere,offsetAttribute:t._offsetAttribute})}},Y.createShadowVolume=function(t,e,o){var r=t._granularity,n=t._ellipsoid,i=e(r,n),a=o(r,n);return new Y({center:t._center,semiMajorAxis:t._semiMajorAxis,semiMinorAxis:t._semiMinorAxis,ellipsoid:n,rotation:t._rotation,stRotation:t._stRotation,granularity:r,extrudedHeight:i,height:a,vertexFormat:g.n.POSITION_ONLY,shadowVolume:!0})},Object.defineProperties(Y.prototype,{rectangle:{get:function(){return s.e(this._rectangle)||(this._rectangle=k(this._center,this._semiMajorAxis,this._semiMinorAxis,this._rotation,this._granularity,this._ellipsoid)),this._rectangle}},textureCoordinateRotationPoints:{get:function(){return s.e(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=function(t){var e=-t._stRotation;if(0===e)return[0,0,0,1,1,0];for(var o=u.C.computeEllipsePositions({center:t._center,semiMajorAxis:t._semiMajorAxis,semiMinorAxis:t._semiMinorAxis,rotation:t._rotation,granularity:t._granularity},!1,!0).outerPositions,r=o.length/3,i=new Array(r),a=0;a<r;++a)i[a]=n.t.fromArray(o,3*a);var s=t._ellipsoid,m=t.rectangle;return c.I._textureCoordinateRotationPoints(i,e,s,m)}(this)),this._textureCoordinateRotationPoints}}}),t.Y=Y}));