1
Surpriseplus
2022-09-16 8d1a91c23df335b090e38b2edd15203aa3b03da9
1
define(["./when-cbf8cd21","./Check-35e1a91d","./Math-e66fad2a","./Rectangle-53325d53","./WebGLConstants-95ceb4e9","./PixelFormat-d198afce","./Transforms-00c25a19","./RuntimeError-f4c64df1","./ComponentDatatype-7ee14e67","./GeometryAttribute-0b3418e6","./GeometryAttributes-90846c5f","./AttributeCompression-fd688b33","./GeometryPipeline-eeba9dc9","./EncodedCartesian3-35776b5f","./IndexDatatype-66caba23","./IntersectionTests-fdc68d04","./Plane-353c5ea0","./GeometryOffsetAttribute-84f7eff3","./VertexFormat-cc24f342","./GeometryInstance-5e3224ad","./EllipsoidRhumbLine-59f604d0","./PolygonPipeline-ae1ebf63","./RectangleGeometryLibrary-f20ce921"],function(mt,t,dt,pt,e,a,k,r,gt,yt,n,o,ft,i,ht,s,l,vt,bt,_t,u,At,H){"use strict";var xt=new pt.Cartesian3,wt=new pt.Cartesian3,Ct=new pt.Cartesian3,Rt=new pt.Cartesian3,_=new pt.Rectangle,z=new pt.Cartesian2,A=new k.BoundingSphere,x=new k.BoundingSphere;function Et(t,e){var a=new yt.Geometry({attributes:new n.GeometryAttributes,primitiveType:yt.PrimitiveType.TRIANGLES});return a.attributes.position=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e.positions}),t.normal&&(a.attributes.normal=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.normals})),t.tangent&&(a.attributes.tangent=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.tangents})),t.bitangent&&(a.attributes.bitangent=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.bitangents})),a}var Ft=new pt.Cartesian3,Gt=new pt.Cartesian3;function Pt(t,e){var a=t._vertexFormat,r=t._ellipsoid,n=e.height,o=e.width,i=e.northCap,s=e.southCap,l=0,u=n,c=n,m=0;i&&(--c,m+=l=1),s&&(--u,--c,m+=1),m+=o*c;for(var d=a.position?new Float64Array(3*m):void 0,p=a.st?new Float32Array(2*m):void 0,g=0,y=0,f=xt,h=z,v=Number.MAX_VALUE,b=Number.MAX_VALUE,_=-Number.MAX_VALUE,A=-Number.MAX_VALUE,x=l;x<u;++x)for(var w=0;w<o;++w)H.RectangleGeometryLibrary.computePosition(e,r,a.st,x,w,f,h),d[g++]=f.x,d[g++]=f.y,d[g++]=f.z,a.st&&(p[y++]=h.x,p[y++]=h.y,v=Math.min(v,h.x),b=Math.min(b,h.y),_=Math.max(_,h.x),A=Math.max(A,h.y));if(i&&(H.RectangleGeometryLibrary.computePosition(e,r,a.st,0,0,f,h),d[g++]=f.x,d[g++]=f.y,d[g++]=f.z,a.st&&(p[y++]=h.x,p[y++]=h.y,v=h.x,b=h.y,_=h.x,A=h.y)),s&&(H.RectangleGeometryLibrary.computePosition(e,r,a.st,n-1,0,f,h),d[g++]=f.x,d[g++]=f.y,d[g]=f.z,a.st&&(p[y++]=h.x,p[y]=h.y,v=Math.min(v,h.x),b=Math.min(b,h.y),_=Math.max(_,h.x),A=Math.max(A,h.y))),a.st&&(v<0||b<0||1<_||1<A))for(var C=0;C<p.length;C+=2)p[C]=(p[C]-v)/(_-v),p[C+1]=(p[C+1]-b)/(A-b);var R=function(t,e,a,r){var n=t.length,o=e.normal?new Float32Array(n):void 0,i=e.tangent?new Float32Array(n):void 0,s=e.bitangent?new Float32Array(n):void 0,l=0,u=Rt,c=Ct,m=wt;if(e.normal||e.tangent||e.bitangent)for(var d=0;d<n;d+=3){var p=pt.Cartesian3.fromArray(t,d,xt),g=l+1,y=l+2,m=a.geodeticSurfaceNormal(p,m);(e.tangent||e.bitangent)&&(pt.Cartesian3.cross(pt.Cartesian3.UNIT_Z,m,c),k.Matrix3.multiplyByVector(r,c,c),pt.Cartesian3.normalize(c,c),e.bitangent&&pt.Cartesian3.normalize(pt.Cartesian3.cross(m,c,u),u)),e.normal&&(o[l]=m.x,o[g]=m.y,o[y]=m.z),e.tangent&&(i[l]=c.x,i[g]=c.y,i[y]=c.z),e.bitangent&&(s[l]=u.x,s[g]=u.y,s[y]=u.z),l+=3}return Et(e,{positions:t,normals:o,tangents:i,bitangents:s})}(d,a,r,e.tangentRotationMatrix),E=6*(o-1)*(c-1);i&&(E+=3*(o-1)),s&&(E+=3*(o-1));for(var F=ht.IndexDatatype.createTypedArray(m,E),G=0,P=0,V=0;V<c-1;++V){for(var L=0;L<o-1;++L){var D=G+o,M=D+1,T=G+1;F[P++]=G,F[P++]=D,F[P++]=T,F[P++]=T,F[P++]=D,F[P++]=M,++G}++G}if(i||s){var O,N,S=m-1,I=m-1;if(i&&s&&(S=m-2),G=0,i)for(V=0;V<o-1;V++)N=(O=G)+1,F[P++]=S,F[P++]=O,F[P++]=N,++G;if(s)for(G=(c-1)*o,V=0;V<o-1;V++)N=(O=G)+1,F[P++]=O,F[P++]=I,F[P++]=N,++G}return R.indices=F,a.st&&(R.attributes.st=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:p})),R}function Vt(t,e,a,r,n){return t[e++]=r[a],t[e++]=r[a+1],t[e++]=r[a+2],t[e++]=n[a],t[e++]=n[a+1],t[e]=n[a+2],t}function Lt(t,e,a,r){return t[e++]=r[a],t[e++]=r[a+1],t[e++]=r[a],t[e]=r[a+1],t}var Dt=new bt.VertexFormat;function w(t,e){var a,r=t._shadowVolume,n=t._offsetAttribute,o=t._vertexFormat,i=t._extrudedHeight,s=t._surfaceHeight,l=t._ellipsoid,u=e.height,c=e.width;r&&((a=bt.VertexFormat.clone(o,Dt)).normal=!0,t._vertexFormat=a);var m=Pt(t,e);r&&(t._vertexFormat=o);var d=At.PolygonPipeline.scaleToGeodeticHeight(m.attributes.position.values,s,l,!1),p=2*(st=(d=new Float64Array(d)).length),g=new Float64Array(p);g.set(d);var y=At.PolygonPipeline.scaleToGeodeticHeight(m.attributes.position.values,i,l);g.set(y,st),m.attributes.position.values=g;var f,h,v,b=o.normal?new Float32Array(p):void 0,_=o.tangent?new Float32Array(p):void 0,A=o.bitangent?new Float32Array(p):void 0,x=o.st?new Float32Array(p/3*2):void 0;if(o.normal){for(h=m.attributes.normal.values,b.set(h),C=0;C<st;C++)h[C]=-h[C];b.set(h,st),m.attributes.normal.values=b}if(r){h=m.attributes.normal.values,o.normal||(m.attributes.normal=void 0);for(var w=new Float32Array(p),C=0;C<st;C++)h[C]=-h[C];w.set(h,st),m.attributes.extrudeDirection=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:w})}var R,E,F,G=mt.defined(n);if(G&&(R=st/3*2,E=new Uint8Array(R),E=n===vt.GeometryOffsetAttribute.TOP?vt.arrayFill(E,1,0,R/2):(v=n===vt.GeometryOffsetAttribute.NONE?0:1,vt.arrayFill(E,v)),m.attributes.applyOffset=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:E})),o.tangent){var P=m.attributes.tangent.values;for(_.set(P),C=0;C<st;C++)P[C]=-P[C];_.set(P,st),m.attributes.tangent.values=_}o.bitangent&&(F=m.attributes.bitangent.values,A.set(F),A.set(F,st),m.attributes.bitangent.values=A),o.st&&(f=m.attributes.st.values,x.set(f),x.set(f,st/3*2),m.attributes.st.values=x);var V=m.indices,L=V.length,D=st/3,M=ht.IndexDatatype.createTypedArray(p/3,2*L);for(M.set(V),C=0;C<L;C+=3)M[C+L]=V[C+2]+D,M[C+1+L]=V[C+1]+D,M[C+2+L]=V[C]+D;m.indices=M;var T=e.northCap,O=e.southCap,N=u,S=2,I=0,k=4,H=4;T&&(--S,--N,I+=1,k-=2,--H),O&&(--S,--N,I+=1,k-=2,--H);var z=2*((I+=S*c+2*N-k)+H),B=new Float64Array(3*z),U=r?new Float32Array(3*z):void 0,Y=G?new Uint8Array(z):void 0,q=o.st?new Float32Array(2*z):void 0,X=n===vt.GeometryOffsetAttribute.TOP;G&&!X&&(v=n===vt.GeometryOffsetAttribute.ALL?1:0,Y=vt.arrayFill(Y,v));var Q=0,W=0,J=0,j=0,Z=c*N;for(C=0;C<Z;C+=c)B=Vt(B,Q,$=3*C,d,y),Q+=6,o.st&&(q=Lt(q,W,2*C,f),W+=4),r&&(J+=3,U[J++]=h[$],U[J++]=h[$+1],U[J++]=h[$+2]),X&&(Y[j++]=1,j+=1);if(O){var K=T?1+Z:Z,$=3*K;for(C=0;C<2;C++)B=Vt(B,Q,$,d,y),Q+=6,o.st&&(q=Lt(q,W,2*K,f),W+=4),r&&(J+=3,U[J++]=h[$],U[J++]=h[$+1],U[J++]=h[$+2]),X&&(Y[j++]=1,j+=1)}else for(C=Z-c;C<Z;C++)B=Vt(B,Q,$=3*C,d,y),Q+=6,o.st&&(q=Lt(q,W,2*C,f),W+=4),r&&(J+=3,U[J++]=h[$],U[J++]=h[$+1],U[J++]=h[$+2]),X&&(Y[j++]=1,j+=1);for(C=Z-1;0<C;C-=c)B=Vt(B,Q,$=3*C,d,y),Q+=6,o.st&&(q=Lt(q,W,2*C,f),W+=4),r&&(J+=3,U[J++]=h[$],U[J++]=h[$+1],U[J++]=h[$+2]),X&&(Y[j++]=1,j+=1);if(T){var tt=Z;for($=3*tt,C=0;C<2;C++)B=Vt(B,Q,$,d,y),Q+=6,o.st&&(q=Lt(q,W,2*tt,f),W+=4),r&&(J+=3,U[J++]=h[$],U[J++]=h[$+1],U[J++]=h[$+2]),X&&(Y[j++]=1,j+=1)}else for(C=c-1;0<=C;C--)B=Vt(B,Q,$=3*C,d,y),Q+=6,o.st&&(q=Lt(q,W,2*C,f),W+=4),r&&(J+=3,U[J++]=h[$],U[J++]=h[$+1],U[J++]=h[$+2]),X&&(Y[j++]=1,j+=1);var et=function(t,e,a){var r=t.length,n=e.normal?new Float32Array(r):void 0,o=e.tangent?new Float32Array(r):void 0,i=e.bitangent?new Float32Array(r):void 0,s=0,l=0,u=0,c=!0,m=Rt,d=Ct,p=wt;if(e.normal||e.tangent||e.bitangent)for(var g=0;g<r;g+=6){var y,f=pt.Cartesian3.fromArray(t,g,xt),h=pt.Cartesian3.fromArray(t,(g+6)%r,Ft);c&&(y=pt.Cartesian3.fromArray(t,(g+3)%r,Gt),pt.Cartesian3.subtract(h,f,h),pt.Cartesian3.subtract(y,f,y),p=pt.Cartesian3.normalize(pt.Cartesian3.cross(y,h,p),p),c=!1),pt.Cartesian3.equalsEpsilon(h,f,dt.CesiumMath.EPSILON10)&&(c=!0),(e.tangent||e.bitangent)&&(m=a.geodeticSurfaceNormal(f,m),e.tangent&&(d=pt.Cartesian3.normalize(pt.Cartesian3.cross(m,p,d),d))),e.normal&&(n[s++]=p.x,n[s++]=p.y,n[s++]=p.z,n[s++]=p.x,n[s++]=p.y,n[s++]=p.z),e.tangent&&(o[l++]=d.x,o[l++]=d.y,o[l++]=d.z,o[l++]=d.x,o[l++]=d.y,o[l++]=d.z),e.bitangent&&(i[u++]=m.x,i[u++]=m.y,i[u++]=m.z,i[u++]=m.x,i[u++]=m.y,i[u++]=m.z)}return Et(e,{positions:t,normals:n,tangents:o,bitangents:i})}(B,o,l);o.st&&(et.attributes.st=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:q})),r&&(et.attributes.extrudeDirection=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:U})),G&&(et.attributes.applyOffset=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:Y}));var at,rt,nt,ot,it=ht.IndexDatatype.createTypedArray(z,6*I),st=B.length/3,lt=0;for(C=0;C<st-1;C+=2){ot=((at=C)+2)%st;var ut=pt.Cartesian3.fromArray(B,3*at,Ft),ct=pt.Cartesian3.fromArray(B,3*ot,Gt);pt.Cartesian3.equalsEpsilon(ut,ct,dt.CesiumMath.EPSILON10)||(nt=(2+(rt=(at+1)%st))%st,it[lt++]=at,it[lt++]=rt,it[lt++]=ot,it[lt++]=ot,it[lt++]=rt,it[lt++]=nt)}return et.indices=it,(et=ft.GeometryPipeline.combineInstances([new _t.GeometryInstance({geometry:m}),new _t.GeometryInstance({geometry:et})]))[0]}var c=[new pt.Cartesian3,new pt.Cartesian3,new pt.Cartesian3,new pt.Cartesian3],C=new pt.Cartographic,R=new pt.Cartographic;function y(t,e,a,r,n){if(0===a)return pt.Rectangle.clone(t,n);var o=H.RectangleGeometryLibrary.computeOptions(t,e,a,0,_,C),i=o.height,s=o.width,l=c;return H.RectangleGeometryLibrary.computePosition(o,r,!1,0,0,l[0]),H.RectangleGeometryLibrary.computePosition(o,r,!1,0,s-1,l[1]),H.RectangleGeometryLibrary.computePosition(o,r,!1,i-1,0,l[2]),H.RectangleGeometryLibrary.computePosition(o,r,!1,i-1,s-1,l[3]),pt.Rectangle.fromCartesianArray(l,r,n)}function p(t){var e=(t=mt.defaultValue(t,mt.defaultValue.EMPTY_OBJECT)).rectangle,a=mt.defaultValue(t.height,0),r=mt.defaultValue(t.extrudedHeight,a);this._rectangle=pt.Rectangle.clone(e),this._granularity=mt.defaultValue(t.granularity,dt.CesiumMath.RADIANS_PER_DEGREE),this._ellipsoid=pt.Ellipsoid.clone(mt.defaultValue(t.ellipsoid,pt.Ellipsoid.WGS84)),this._surfaceHeight=Math.max(a,r),this._rotation=mt.defaultValue(t.rotation,0),this._stRotation=mt.defaultValue(t.stRotation,0),this._vertexFormat=bt.VertexFormat.clone(mt.defaultValue(t.vertexFormat,bt.VertexFormat.DEFAULT)),this._extrudedHeight=Math.min(a,r),this._shadowVolume=mt.defaultValue(t.shadowVolume,!1),this._workerName="createRectangleGeometry",this._offsetAttribute=t.offsetAttribute,this._rotatedRectangle=void 0,this._textureCoordinateRotationPoints=void 0}p.packedLength=pt.Rectangle.packedLength+pt.Ellipsoid.packedLength+bt.VertexFormat.packedLength+7,p.pack=function(t,e,a){return a=mt.defaultValue(a,0),pt.Rectangle.pack(t._rectangle,e,a),a+=pt.Rectangle.packedLength,pt.Ellipsoid.pack(t._ellipsoid,e,a),a+=pt.Ellipsoid.packedLength,bt.VertexFormat.pack(t._vertexFormat,e,a),a+=bt.VertexFormat.packedLength,e[a++]=t._granularity,e[a++]=t._surfaceHeight,e[a++]=t._rotation,e[a++]=t._stRotation,e[a++]=t._extrudedHeight,e[a++]=t._shadowVolume?1:0,e[a]=mt.defaultValue(t._offsetAttribute,-1),e};var g=new pt.Rectangle,f=pt.Ellipsoid.clone(pt.Ellipsoid.UNIT_SPHERE),h={rectangle:g,ellipsoid:f,vertexFormat:Dt,granularity:void 0,height:void 0,rotation:void 0,stRotation:void 0,extrudedHeight:void 0,shadowVolume:void 0,offsetAttribute:void 0};p.unpack=function(t,e,a){e=mt.defaultValue(e,0);var r=pt.Rectangle.unpack(t,e,g);e+=pt.Rectangle.packedLength;var n=pt.Ellipsoid.unpack(t,e,f);e+=pt.Ellipsoid.packedLength;var o=bt.VertexFormat.unpack(t,e,Dt);e+=bt.VertexFormat.packedLength;var i=t[e++],s=t[e++],l=t[e++],u=t[e++],c=t[e++],m=1===t[e++],d=t[e];return mt.defined(a)?(a._rectangle=pt.Rectangle.clone(r,a._rectangle),a._ellipsoid=pt.Ellipsoid.clone(n,a._ellipsoid),a._vertexFormat=bt.VertexFormat.clone(o,a._vertexFormat),a._granularity=i,a._surfaceHeight=s,a._rotation=l,a._stRotation=u,a._extrudedHeight=c,a._shadowVolume=m,a._offsetAttribute=-1===d?void 0:d,a):(h.granularity=i,h.height=s,h.rotation=l,h.stRotation=u,h.extrudedHeight=c,h.shadowVolume=m,h.offsetAttribute=-1===d?void 0:d,new p(h))},p.computeRectangle=function(t,e){var a=(t=mt.defaultValue(t,mt.defaultValue.EMPTY_OBJECT)).rectangle,r=mt.defaultValue(t.granularity,dt.CesiumMath.RADIANS_PER_DEGREE),n=mt.defaultValue(t.ellipsoid,pt.Ellipsoid.WGS84);return y(a,r,mt.defaultValue(t.rotation,0),n,e)};var E=new k.Matrix3,F=new k.Quaternion,G=new pt.Cartographic;p.createGeometry=function(t){if(!dt.CesiumMath.equalsEpsilon(t._rectangle.north,t._rectangle.south,dt.CesiumMath.EPSILON10)&&!dt.CesiumMath.equalsEpsilon(t._rectangle.east,t._rectangle.west,dt.CesiumMath.EPSILON10)){var e,a,r=t._rectangle,n=t._ellipsoid,o=t._rotation,i=t._stRotation,s=t._vertexFormat,l=H.RectangleGeometryLibrary.computeOptions(r,t._granularity,o,i,_,C,R),u=E;0!==i||0!==o?(e=pt.Rectangle.center(r,G),a=n.geodeticSurfaceNormalCartographic(e,Ft),k.Quaternion.fromAxisAngle(a,-i,F),k.Matrix3.fromQuaternion(F,u)):k.Matrix3.clone(k.Matrix3.IDENTITY,u);var c,m,d,p,g,y,f,h=t._surfaceHeight,v=t._extrudedHeight,b=!dt.CesiumMath.equalsEpsilon(h,v,0,dt.CesiumMath.EPSILON2);return l.lonScalar=1/t._rectangle.width,l.latScalar=1/t._rectangle.height,l.tangentRotationMatrix=u,r=t._rectangle,d=b?(f=w(t,l),c=k.BoundingSphere.fromRectangle3D(r,n,h,x),m=k.BoundingSphere.fromRectangle3D(r,n,v,A),k.BoundingSphere.union(c,m)):((f=Pt(t,l)).attributes.position.values=At.PolygonPipeline.scaleToGeodeticHeight(f.attributes.position.values,h,n,!1),mt.defined(t._offsetAttribute)&&(p=f.attributes.position.values.length,g=new Uint8Array(p/3),y=t._offsetAttribute===vt.GeometryOffsetAttribute.NONE?0:1,vt.arrayFill(g,y),f.attributes.applyOffset=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:g})),k.BoundingSphere.fromRectangle3D(r,n,h)),s.position||delete f.attributes.position,new yt.Geometry({attributes:f.attributes,indices:f.indices,primitiveType:f.primitiveType,boundingSphere:d,offsetAttribute:t._offsetAttribute})}},p.createShadowVolume=function(t,e,a){var r=t._granularity,n=t._ellipsoid,o=e(r,n),i=a(r,n);return new p({rectangle:t._rectangle,rotation:t._rotation,ellipsoid:n,stRotation:t._stRotation,granularity:r,extrudedHeight:i,height:o,vertexFormat:bt.VertexFormat.POSITION_ONLY,shadowVolume:!0})};var v=new pt.Rectangle,b=[new pt.Cartesian2,new pt.Cartesian2,new pt.Cartesian2],P=new yt.Matrix2,V=new pt.Cartographic;return Object.defineProperties(p.prototype,{rectangle:{get:function(){return mt.defined(this._rotatedRectangle)||(this._rotatedRectangle=y(this._rectangle,this._granularity,this._rotation,this._ellipsoid)),this._rotatedRectangle}},textureCoordinateRotationPoints:{get:function(){return mt.defined(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=function(t){if(0===t._stRotation)return[0,0,0,1,1,0];var e=pt.Rectangle.clone(t._rectangle,v),a=t._granularity,r=t._ellipsoid,n=y(e,a,t._rotation-t._stRotation,r,v),o=b;o[0].x=n.west,o[0].y=n.south,o[1].x=n.west,o[1].y=n.north,o[2].x=n.east,o[2].y=n.south;for(var i=t.rectangle,s=yt.Matrix2.fromRotation(t._stRotation,P),l=pt.Rectangle.center(i,V),u=0;u<3;++u){var c=o[u];c.x-=l.longitude,c.y-=l.latitude,yt.Matrix2.multiplyByVector(s,c,c),c.x+=l.longitude,c.y+=l.latitude,c.x=(c.x-i.west)/i.width,c.y=(c.y-i.south)/i.height}var m=o[0],d=o[1],p=o[2],g=new Array(6);return pt.Cartesian2.pack(m,g),pt.Cartesian2.pack(d,g,2),pt.Cartesian2.pack(p,g,4),g}(this)),this._textureCoordinateRotationPoints}}}),function(t,e){return mt.defined(e)&&(t=p.unpack(t,e)),t._ellipsoid=pt.Ellipsoid.clone(t._ellipsoid),t._rectangle=pt.Rectangle.clone(t._rectangle),p.createGeometry(t)}});