2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
define(["./defaultValue-81eec7ed","./Cartesian2-bd414876","./Rectangle-cf3e0e3e","./GeometryOffsetAttribute-ed56ff58","./BoundingSphere-9a3b5656","./Cartesian3-e0307675","./Check-741c5f3c","./ComponentDatatype-aaeec80f","./GeometryAttribute-2b42a913","./GeometryAttributes-32b29525","./GeometryInstance-1b39c9e8","./GeometryPipeline-e7083fea","./IndexDatatype-3f3c99e8","./Math-e73894ab","./Matrix2-dc0c61cc","./Matrix4-4c545f70","./PolygonPipeline-04baeb41","./Transforms-5b829630","./RectangleGeometryLibrary-5373dad7","./VertexFormat-d50a69ba","./GeographicProjection-c931c7fb","./WebGLConstants-508b9636","./AttributeCompression-8f752c03","./EncodedCartesian3-aafcc30f","./IntersectionTests-80510c7b","./Plane-bc8b6777","./RuntimeError-26acdd3b","./EllipsoidRhumbLine-592e8885","./when-422ea0ae","./Resource-8ae1a924","./combine-3c023bda"],(function(t,e,n,a,o,r,i,s,l,c,u,m,p,d,g,y,f,h,b,_,A,x,w,C,v,R,E,F,G,P,V){"use strict";const L=new r.Cartesian3,D=new r.Cartesian3,M=new r.Cartesian3,T=new r.Cartesian3,O=new n.Rectangle,N=new e.Cartesian2,S=new o.BoundingSphere,I=new o.BoundingSphere;function k(t,e){const n=new l.Geometry({attributes:new c.GeometryAttributes,primitiveType:l.PrimitiveType.TRIANGLES});return n.attributes.position=new l.GeometryAttribute({componentDatatype:s.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e.positions}),t.normal&&(n.attributes.normal=new l.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.normals})),t.tangent&&(n.attributes.tangent=new l.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.tangents})),t.bitangent&&(n.attributes.bitangent=new l.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.bitangents})),n}const H=new r.Cartesian3,z=new r.Cartesian3;function B(t,e){const n=t._vertexFormat,a=t._ellipsoid,o=e.height,i=e.width,c=e.northCap,u=e.southCap;let m=0,d=o,g=o,f=0;c&&(m=1,g-=1,f+=1),u&&(d-=1,g-=1,f+=1),f+=i*g;const h=n.position?new Float64Array(3*f):void 0,_=n.st?new Float32Array(2*f):void 0;let A=0,x=0;const w=L,C=N;let v=Number.MAX_VALUE,R=Number.MAX_VALUE,E=-Number.MAX_VALUE,F=-Number.MAX_VALUE;for(let t=m;t<d;++t)for(let o=0;o<i;++o)b.RectangleGeometryLibrary.computePosition(e,a,n.st,t,o,w,C),h[A++]=w.x,h[A++]=w.y,h[A++]=w.z,n.st&&(_[x++]=C.x,_[x++]=C.y,v=Math.min(v,C.x),R=Math.min(R,C.y),E=Math.max(E,C.x),F=Math.max(F,C.y));if(c&&(b.RectangleGeometryLibrary.computePosition(e,a,n.st,0,0,w,C),h[A++]=w.x,h[A++]=w.y,h[A++]=w.z,n.st&&(_[x++]=C.x,_[x++]=C.y,v=C.x,R=C.y,E=C.x,F=C.y)),u&&(b.RectangleGeometryLibrary.computePosition(e,a,n.st,o-1,0,w,C),h[A++]=w.x,h[A++]=w.y,h[A]=w.z,n.st&&(_[x++]=C.x,_[x]=C.y,v=Math.min(v,C.x),R=Math.min(R,C.y),E=Math.max(E,C.x),F=Math.max(F,C.y))),n.st&&(v<0||R<0||E>1||F>1))for(let t=0;t<_.length;t+=2)_[t]=(_[t]-v)/(E-v),_[t+1]=(_[t+1]-R)/(F-R);const G=function(t,e,n,a){const o=t.length,i=e.normal?new Float32Array(o):void 0,s=e.tangent?new Float32Array(o):void 0,l=e.bitangent?new Float32Array(o):void 0;let c=0;const u=T,m=M;let p=D;if(e.normal||e.tangent||e.bitangent)for(let d=0;d<o;d+=3){const o=r.Cartesian3.fromArray(t,d,L),g=c+1,f=c+2;p=n.geodeticSurfaceNormal(o,p),(e.tangent||e.bitangent)&&(r.Cartesian3.cross(r.Cartesian3.UNIT_Z,p,m),y.Matrix3.multiplyByVector(a,m,m),r.Cartesian3.normalize(m,m),e.bitangent&&r.Cartesian3.normalize(r.Cartesian3.cross(p,m,u),u)),e.normal&&(i[c]=p.x,i[g]=p.y,i[f]=p.z),e.tangent&&(s[c]=m.x,s[g]=m.y,s[f]=m.z),e.bitangent&&(l[c]=u.x,l[g]=u.y,l[f]=u.z),c+=3}return k(e,{positions:t,normals:i,tangents:s,bitangents:l})}(h,n,a,e.tangentRotationMatrix);let P=6*(i-1)*(g-1);c&&(P+=3*(i-1)),u&&(P+=3*(i-1));const V=p.IndexDatatype.createTypedArray(f,P);let O,S=0,I=0;for(O=0;O<g-1;++O){for(let t=0;t<i-1;++t){const t=S,e=t+i,n=e+1,a=t+1;V[I++]=t,V[I++]=e,V[I++]=a,V[I++]=a,V[I++]=e,V[I++]=n,++S}++S}if(c||u){let t=f-1;const e=f-1;let n,a;if(c&&u&&(t=f-2),S=0,c)for(O=0;O<i-1;O++)n=S,a=n+1,V[I++]=t,V[I++]=n,V[I++]=a,++S;if(u)for(S=(g-1)*i,O=0;O<i-1;O++)n=S,a=n+1,V[I++]=n,V[I++]=e,V[I++]=a,++S}return G.indices=V,n.st&&(G.attributes.st=new l.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:_})),G}function U(t,e,n,a,o){return t[e++]=a[n],t[e++]=a[n+1],t[e++]=a[n+2],t[e++]=o[n],t[e++]=o[n+1],t[e]=o[n+2],t}function Y(t,e,n,a){return t[e++]=a[n],t[e++]=a[n+1],t[e++]=a[n],t[e]=a[n+1],t}const q=new _.VertexFormat;function X(e,n){const o=e._shadowVolume,i=e._offsetAttribute,c=e._vertexFormat,g=e._extrudedHeight,y=e._surfaceHeight,h=e._ellipsoid,b=n.height,A=n.width;let x;if(o){const t=_.VertexFormat.clone(c,q);t.normal=!0,e._vertexFormat=t}const w=B(e,n);o&&(e._vertexFormat=c);let C=f.PolygonPipeline.scaleToGeodeticHeight(w.attributes.position.values,y,h,!1);C=new Float64Array(C);let v=C.length;const R=2*v,E=new Float64Array(R);E.set(C);const F=f.PolygonPipeline.scaleToGeodeticHeight(w.attributes.position.values,g,h);E.set(F,v),w.attributes.position.values=E;const G=c.normal?new Float32Array(R):void 0,P=c.tangent?new Float32Array(R):void 0,V=c.bitangent?new Float32Array(R):void 0,O=c.st?new Float32Array(R/3*2):void 0;let N,S,I;if(c.normal){for(S=w.attributes.normal.values,G.set(S),x=0;x<v;x++)S[x]=-S[x];G.set(S,v),w.attributes.normal.values=G}if(o){S=w.attributes.normal.values,c.normal||(w.attributes.normal=void 0);const t=new Float32Array(R);for(x=0;x<v;x++)S[x]=-S[x];t.set(S,v),w.attributes.extrudeDirection=new l.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:t})}const X=t.defined(i);if(X){const t=v/3*2;let e=new Uint8Array(t);i===a.GeometryOffsetAttribute.TOP?e=a.arrayFill(e,1,0,t/2):(I=i===a.GeometryOffsetAttribute.NONE?0:1,e=a.arrayFill(e,I)),w.attributes.applyOffset=new l.GeometryAttribute({componentDatatype:s.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:e})}if(c.tangent){const t=w.attributes.tangent.values;for(P.set(t),x=0;x<v;x++)t[x]=-t[x];P.set(t,v),w.attributes.tangent.values=P}if(c.bitangent){const t=w.attributes.bitangent.values;V.set(t),V.set(t,v),w.attributes.bitangent.values=V}c.st&&(N=w.attributes.st.values,O.set(N),O.set(N,v/3*2),w.attributes.st.values=O);const Q=w.indices,W=Q.length,j=v/3,J=p.IndexDatatype.createTypedArray(R/3,2*W);for(J.set(Q),x=0;x<W;x+=3)J[x+W]=Q[x+2]+j,J[x+1+W]=Q[x+1]+j,J[x+2+W]=Q[x]+j;w.indices=J;const Z=n.northCap,K=n.southCap;let $=b,tt=2,et=0,nt=4,at=4;Z&&(tt-=1,$-=1,et+=1,nt-=2,at-=1),K&&(tt-=1,$-=1,et+=1,nt-=2,at-=1),et+=tt*A+2*$-nt;const ot=2*(et+at);let rt=new Float64Array(3*ot);const it=o?new Float32Array(3*ot):void 0;let st=X?new Uint8Array(ot):void 0,lt=c.st?new Float32Array(2*ot):void 0;const ct=i===a.GeometryOffsetAttribute.TOP;X&&!ct&&(I=i===a.GeometryOffsetAttribute.ALL?1:0,st=a.arrayFill(st,I));let ut=0,mt=0,pt=0,dt=0;const gt=A*$;let yt;for(x=0;x<gt;x+=A)yt=3*x,rt=U(rt,ut,yt,C,F),ut+=6,c.st&&(lt=Y(lt,mt,2*x,N),mt+=4),o&&(pt+=3,it[pt++]=S[yt],it[pt++]=S[yt+1],it[pt++]=S[yt+2]),ct&&(st[dt++]=1,dt+=1);if(K){const t=Z?gt+1:gt;for(yt=3*t,x=0;x<2;x++)rt=U(rt,ut,yt,C,F),ut+=6,c.st&&(lt=Y(lt,mt,2*t,N),mt+=4),o&&(pt+=3,it[pt++]=S[yt],it[pt++]=S[yt+1],it[pt++]=S[yt+2]),ct&&(st[dt++]=1,dt+=1)}else for(x=gt-A;x<gt;x++)yt=3*x,rt=U(rt,ut,yt,C,F),ut+=6,c.st&&(lt=Y(lt,mt,2*x,N),mt+=4),o&&(pt+=3,it[pt++]=S[yt],it[pt++]=S[yt+1],it[pt++]=S[yt+2]),ct&&(st[dt++]=1,dt+=1);for(x=gt-1;x>0;x-=A)yt=3*x,rt=U(rt,ut,yt,C,F),ut+=6,c.st&&(lt=Y(lt,mt,2*x,N),mt+=4),o&&(pt+=3,it[pt++]=S[yt],it[pt++]=S[yt+1],it[pt++]=S[yt+2]),ct&&(st[dt++]=1,dt+=1);if(Z){const t=gt;for(yt=3*t,x=0;x<2;x++)rt=U(rt,ut,yt,C,F),ut+=6,c.st&&(lt=Y(lt,mt,2*t,N),mt+=4),o&&(pt+=3,it[pt++]=S[yt],it[pt++]=S[yt+1],it[pt++]=S[yt+2]),ct&&(st[dt++]=1,dt+=1)}else for(x=A-1;x>=0;x--)yt=3*x,rt=U(rt,ut,yt,C,F),ut+=6,c.st&&(lt=Y(lt,mt,2*x,N),mt+=4),o&&(pt+=3,it[pt++]=S[yt],it[pt++]=S[yt+1],it[pt++]=S[yt+2]),ct&&(st[dt++]=1,dt+=1);let ft=function(t,e,n){const a=t.length,o=e.normal?new Float32Array(a):void 0,i=e.tangent?new Float32Array(a):void 0,s=e.bitangent?new Float32Array(a):void 0;let l=0,c=0,u=0,m=!0,p=T,g=M,y=D;if(e.normal||e.tangent||e.bitangent)for(let f=0;f<a;f+=6){const h=r.Cartesian3.fromArray(t,f,L),b=r.Cartesian3.fromArray(t,(f+6)%a,H);if(m){const e=r.Cartesian3.fromArray(t,(f+3)%a,z);r.Cartesian3.subtract(b,h,b),r.Cartesian3.subtract(e,h,e),y=r.Cartesian3.normalize(r.Cartesian3.cross(e,b,y),y),m=!1}r.Cartesian3.equalsEpsilon(b,h,d.CesiumMath.EPSILON10)&&(m=!0),(e.tangent||e.bitangent)&&(p=n.geodeticSurfaceNormal(h,p),e.tangent&&(g=r.Cartesian3.normalize(r.Cartesian3.cross(p,y,g),g))),e.normal&&(o[l++]=y.x,o[l++]=y.y,o[l++]=y.z,o[l++]=y.x,o[l++]=y.y,o[l++]=y.z),e.tangent&&(i[c++]=g.x,i[c++]=g.y,i[c++]=g.z,i[c++]=g.x,i[c++]=g.y,i[c++]=g.z),e.bitangent&&(s[u++]=p.x,s[u++]=p.y,s[u++]=p.z,s[u++]=p.x,s[u++]=p.y,s[u++]=p.z)}return k(e,{positions:t,normals:o,tangents:i,bitangents:s})}(rt,c,h);c.st&&(ft.attributes.st=new l.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:lt})),o&&(ft.attributes.extrudeDirection=new l.GeometryAttribute({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:it})),X&&(ft.attributes.applyOffset=new l.GeometryAttribute({componentDatatype:s.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:st}));const ht=p.IndexDatatype.createTypedArray(ot,6*et);let bt,_t,At,xt;v=rt.length/3;let wt=0;for(x=0;x<v-1;x+=2){bt=x,xt=(bt+2)%v;const t=r.Cartesian3.fromArray(rt,3*bt,H),e=r.Cartesian3.fromArray(rt,3*xt,z);r.Cartesian3.equalsEpsilon(t,e,d.CesiumMath.EPSILON10)||(_t=(bt+1)%v,At=(_t+2)%v,ht[wt++]=bt,ht[wt++]=_t,ht[wt++]=xt,ht[wt++]=xt,ht[wt++]=_t,ht[wt++]=At)}return ft.indices=ht,ft=m.GeometryPipeline.combineInstances([new u.GeometryInstance({geometry:w}),new u.GeometryInstance({geometry:ft})]),ft[0]}const Q=[new r.Cartesian3,new r.Cartesian3,new r.Cartesian3,new r.Cartesian3],W=new e.Cartographic,j=new e.Cartographic;function J(t,e,a,o,r){if(0===a)return n.Rectangle.clone(t,r);const i=b.RectangleGeometryLibrary.computeOptions(t,e,a,0,O,W),s=i.height,l=i.width,c=Q;return b.RectangleGeometryLibrary.computePosition(i,o,!1,0,0,c[0]),b.RectangleGeometryLibrary.computePosition(i,o,!1,0,l-1,c[1]),b.RectangleGeometryLibrary.computePosition(i,o,!1,s-1,0,c[2]),b.RectangleGeometryLibrary.computePosition(i,o,!1,s-1,l-1,c[3]),n.Rectangle.fromCartesianArray(c,o,r)}function Z(a){const o=(a=t.defaultValue(a,t.defaultValue.EMPTY_OBJECT)).rectangle,r=t.defaultValue(a.height,0),i=t.defaultValue(a.extrudedHeight,r);this._rectangle=n.Rectangle.clone(o),this._granularity=t.defaultValue(a.granularity,d.CesiumMath.RADIANS_PER_DEGREE),this._ellipsoid=e.Ellipsoid.clone(t.defaultValue(a.ellipsoid,e.Ellipsoid.WGS84)),this._surfaceHeight=Math.max(r,i),this._rotation=t.defaultValue(a.rotation,0),this._stRotation=t.defaultValue(a.stRotation,0),this._vertexFormat=_.VertexFormat.clone(t.defaultValue(a.vertexFormat,_.VertexFormat.DEFAULT)),this._extrudedHeight=Math.min(r,i),this._shadowVolume=t.defaultValue(a.shadowVolume,!1),this._workerName="createRectangleGeometry",this._offsetAttribute=a.offsetAttribute,this._rotatedRectangle=void 0,this._textureCoordinateRotationPoints=void 0}Z.packedLength=n.Rectangle.packedLength+e.Ellipsoid.packedLength+_.VertexFormat.packedLength+7,Z.pack=function(a,o,r){return r=t.defaultValue(r,0),n.Rectangle.pack(a._rectangle,o,r),r+=n.Rectangle.packedLength,e.Ellipsoid.pack(a._ellipsoid,o,r),r+=e.Ellipsoid.packedLength,_.VertexFormat.pack(a._vertexFormat,o,r),r+=_.VertexFormat.packedLength,o[r++]=a._granularity,o[r++]=a._surfaceHeight,o[r++]=a._rotation,o[r++]=a._stRotation,o[r++]=a._extrudedHeight,o[r++]=a._shadowVolume?1:0,o[r]=t.defaultValue(a._offsetAttribute,-1),o};const K=new n.Rectangle,$=e.Ellipsoid.clone(e.Ellipsoid.UNIT_SPHERE),tt={rectangle:K,ellipsoid:$,vertexFormat:q,granularity:void 0,height:void 0,rotation:void 0,stRotation:void 0,extrudedHeight:void 0,shadowVolume:void 0,offsetAttribute:void 0};Z.unpack=function(a,o,r){o=t.defaultValue(o,0);const i=n.Rectangle.unpack(a,o,K);o+=n.Rectangle.packedLength;const s=e.Ellipsoid.unpack(a,o,$);o+=e.Ellipsoid.packedLength;const l=_.VertexFormat.unpack(a,o,q);o+=_.VertexFormat.packedLength;const c=a[o++],u=a[o++],m=a[o++],p=a[o++],d=a[o++],g=1===a[o++],y=a[o];return t.defined(r)?(r._rectangle=n.Rectangle.clone(i,r._rectangle),r._ellipsoid=e.Ellipsoid.clone(s,r._ellipsoid),r._vertexFormat=_.VertexFormat.clone(l,r._vertexFormat),r._granularity=c,r._surfaceHeight=u,r._rotation=m,r._stRotation=p,r._extrudedHeight=d,r._shadowVolume=g,r._offsetAttribute=-1===y?void 0:y,r):(tt.granularity=c,tt.height=u,tt.rotation=m,tt.stRotation=p,tt.extrudedHeight=d,tt.shadowVolume=g,tt.offsetAttribute=-1===y?void 0:y,new Z(tt))},Z.computeRectangle=function(n,a){const o=(n=t.defaultValue(n,t.defaultValue.EMPTY_OBJECT)).rectangle,r=t.defaultValue(n.granularity,d.CesiumMath.RADIANS_PER_DEGREE),i=t.defaultValue(n.ellipsoid,e.Ellipsoid.WGS84);return J(o,r,t.defaultValue(n.rotation,0),i,a)};const et=new y.Matrix3,nt=new h.Quaternion,at=new e.Cartographic;Z.createGeometry=function(e){if(d.CesiumMath.equalsEpsilon(e._rectangle.north,e._rectangle.south,d.CesiumMath.EPSILON10)||d.CesiumMath.equalsEpsilon(e._rectangle.east,e._rectangle.west,d.CesiumMath.EPSILON10))return;let r=e._rectangle;const i=e._ellipsoid,c=e._rotation,u=e._stRotation,m=e._vertexFormat,p=b.RectangleGeometryLibrary.computeOptions(r,e._granularity,c,u,O,W,j),g=et;if(0!==u||0!==c){const t=n.Rectangle.center(r,at),e=i.geodeticSurfaceNormalCartographic(t,H);h.Quaternion.fromAxisAngle(e,-u,nt),y.Matrix3.fromQuaternion(nt,g)}else y.Matrix3.clone(y.Matrix3.IDENTITY,g);const _=e._surfaceHeight,A=e._extrudedHeight,x=!d.CesiumMath.equalsEpsilon(_,A,0,d.CesiumMath.EPSILON2);let w,C;if(p.lonScalar=1/e._rectangle.width,p.latScalar=1/e._rectangle.height,p.tangentRotationMatrix=g,r=e._rectangle,x){w=X(e,p);const t=o.BoundingSphere.fromRectangle3D(r,i,_,I),n=o.BoundingSphere.fromRectangle3D(r,i,A,S);C=o.BoundingSphere.union(t,n)}else{if(w=B(e,p),w.attributes.position.values=f.PolygonPipeline.scaleToGeodeticHeight(w.attributes.position.values,_,i,!1),t.defined(e._offsetAttribute)){const t=w.attributes.position.values.length,n=new Uint8Array(t/3),o=e._offsetAttribute===a.GeometryOffsetAttribute.NONE?0:1;a.arrayFill(n,o),w.attributes.applyOffset=new l.GeometryAttribute({componentDatatype:s.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:n})}C=o.BoundingSphere.fromRectangle3D(r,i,_)}return m.position||delete w.attributes.position,new l.Geometry({attributes:w.attributes,indices:w.indices,primitiveType:w.primitiveType,boundingSphere:C,offsetAttribute:e._offsetAttribute})},Z.createShadowVolume=function(t,e,n){const a=t._granularity,o=t._ellipsoid,r=e(a,o),i=n(a,o);return new Z({rectangle:t._rectangle,rotation:t._rotation,ellipsoid:o,stRotation:t._stRotation,granularity:a,extrudedHeight:i,height:r,vertexFormat:_.VertexFormat.POSITION_ONLY,shadowVolume:!0})};const ot=new n.Rectangle,rt=[new e.Cartesian2,new e.Cartesian2,new e.Cartesian2],it=new g.Matrix2,st=new e.Cartographic;return Object.defineProperties(Z.prototype,{rectangle:{get:function(){return t.defined(this._rotatedRectangle)||(this._rotatedRectangle=J(this._rectangle,this._granularity,this._rotation,this._ellipsoid)),this._rotatedRectangle}},textureCoordinateRotationPoints:{get:function(){return t.defined(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=function(t){if(0===t._stRotation)return[0,0,0,1,1,0];const a=n.Rectangle.clone(t._rectangle,ot),o=t._granularity,r=t._ellipsoid,i=J(a,o,t._rotation-t._stRotation,r,ot),s=rt;s[0].x=i.west,s[0].y=i.south,s[1].x=i.west,s[1].y=i.north,s[2].x=i.east,s[2].y=i.south;const l=t.rectangle,c=g.Matrix2.fromRotation(t._stRotation,it),u=n.Rectangle.center(l,st);for(let t=0;t<3;++t){const e=s[t];e.x-=u.longitude,e.y-=u.latitude,g.Matrix2.multiplyByVector(c,e,e),e.x+=u.longitude,e.y+=u.latitude,e.x=(e.x-l.west)/l.width,e.y=(e.y-l.south)/l.height}const m=s[0],p=s[1],d=s[2],y=new Array(6);return e.Cartesian2.pack(m,y),e.Cartesian2.pack(p,y,2),e.Cartesian2.pack(d,y,4),y}(this)),this._textureCoordinateRotationPoints}}}),function(a,o){return t.defined(o)&&(a=Z.unpack(a,o)),a._ellipsoid=e.Ellipsoid.clone(a._ellipsoid),a._rectangle=n.Rectangle.clone(a._rectangle),Z.createGeometry(a)}}));
|