1 |
- define(["exports","./GeometryOffsetAttribute-ed56ff58","./Transforms-98ffa11d","./Matrix2-e3fb4559","./Cartesian3-7e9cc2ff","./Check-741c5f3c","./ComponentDatatype-aaeec80f","./defaultValue-81eec7ed","./EllipseGeometryLibrary-77f59e46","./GeometryAttribute-b025f9a8","./GeometryAttributes-32b29525","./GeometryInstance-ce434bcb","./GeometryPipeline-4b426993","./IndexDatatype-f1e3f799","./Math-5f585871","./Matrix4-d34187af","./VertexFormat-d50a69ba"],(function(t,e,i,r,n,o,a,s,l,u,m,c,p,y,d,f,A){"use strict";const x=new n.Cartesian3,h=new n.Cartesian3,g=new n.Cartesian3,_=new n.Cartesian3,b=new r.Cartesian2,C=new f.Matrix3,w=new f.Matrix3,M=new i.Quaternion,E=new n.Cartesian3,I=new n.Cartesian3,T=new n.Cartesian3,G=new r.Cartographic,N=new n.Cartesian3,P=new r.Cartesian2,F=new r.Cartesian2;function v(t,o,c){const p=o.vertexFormat,y=o.center,d=o.semiMajorAxis,A=o.semiMinorAxis,_=o.ellipsoid,v=o.stRotation,V=c?t.length/3*2:t.length/3,D=o.shadowVolume,O=p.st?new Float32Array(2*V):void 0,S=p.normal?new Float32Array(3*V):void 0,L=p.tangent?new Float32Array(3*V):void 0,R=p.bitangent?new Float32Array(3*V):void 0,j=D?new Float32Array(3*V):void 0;let k=0,z=E,B=I,Y=T;const H=new i.GeographicProjection(_),U=H.project(_.cartesianToCartographic(y,G),N),Q=_.scaleToGeodeticSurface(y,x);_.geodeticSurfaceNormal(Q,Q);let W=C,J=w;if(0!==v){let t=i.Quaternion.fromAxisAngle(Q,v,M);W=f.Matrix3.fromQuaternion(t,W),t=i.Quaternion.fromAxisAngle(Q,-v,M),J=f.Matrix3.fromQuaternion(t,J)}else W=f.Matrix3.clone(f.Matrix3.IDENTITY,W),J=f.Matrix3.clone(f.Matrix3.IDENTITY,J);const q=r.Cartesian2.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,P),Z=r.Cartesian2.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,F);let K=t.length;const X=c?K:0,$=X/3*2;for(let e=0;e<K;e+=3){const i=e+1,r=e+2,o=n.Cartesian3.fromArray(t,e,x);if(p.st){const t=f.Matrix3.multiplyByVector(W,o,h),e=H.project(_.cartesianToCartographic(t,G),g);n.Cartesian3.subtract(e,U,e),b.x=(e.x+d)/(2*d),b.y=(e.y+A)/(2*A),q.x=Math.min(b.x,q.x),q.y=Math.min(b.y,q.y),Z.x=Math.max(b.x,Z.x),Z.y=Math.max(b.y,Z.y),c&&(O[k+$]=b.x,O[k+1+$]=b.y),O[k++]=b.x,O[k++]=b.y}(p.normal||p.tangent||p.bitangent||D)&&(z=_.geodeticSurfaceNormal(o,z),D&&(j[e+X]=-z.x,j[i+X]=-z.y,j[r+X]=-z.z),(p.normal||p.tangent||p.bitangent)&&((p.tangent||p.bitangent)&&(B=n.Cartesian3.normalize(n.Cartesian3.cross(n.Cartesian3.UNIT_Z,z,B),B),f.Matrix3.multiplyByVector(J,B,B)),p.normal&&(S[e]=z.x,S[i]=z.y,S[r]=z.z,c&&(S[e+X]=-z.x,S[i+X]=-z.y,S[r+X]=-z.z)),p.tangent&&(L[e]=B.x,L[i]=B.y,L[r]=B.z,c&&(L[e+X]=-B.x,L[i+X]=-B.y,L[r+X]=-B.z)),p.bitangent&&(Y=n.Cartesian3.normalize(n.Cartesian3.cross(z,B,Y),Y),R[e]=Y.x,R[i]=Y.y,R[r]=Y.z,c&&(R[e+X]=Y.x,R[i+X]=Y.y,R[r+X]=Y.z))))}if(p.st){K=O.length;for(let t=0;t<K;t+=2)O[t]=(O[t]-q.x)/(Z.x-q.x),O[t+1]=(O[t+1]-q.y)/(Z.y-q.y)}const tt=new m.GeometryAttributes;if(p.position){const e=l.EllipseGeometryLibrary.raisePositionsToHeight(t,o,c);tt.position=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e})}if(p.st&&(tt.st=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:O})),p.normal&&(tt.normal=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:S})),p.tangent&&(tt.tangent=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:L})),p.bitangent&&(tt.bitangent=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:R})),D&&(tt.extrudeDirection=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:j})),c&&s.defined(o.offsetAttribute)){let t=new Uint8Array(V);if(o.offsetAttribute===e.GeometryOffsetAttribute.TOP)t=e.arrayFill(t,1,0,V/2);else{const i=o.offsetAttribute===e.GeometryOffsetAttribute.NONE?0:1;t=e.arrayFill(t,i)}tt.applyOffset=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:t})}return tt}function V(t){const e=new Array(t*(t+1)*12-6);let i,r,n,o,a,s=0;for(i=0,n=1,o=0;o<3;o++)e[s++]=n++,e[s++]=i,e[s++]=n;for(o=2;o<t+1;++o){for(n=o*(o+1)-1,i=(o-1)*o-1,e[s++]=n++,e[s++]=i,e[s++]=n,r=2*o,a=0;a<r-1;++a)e[s++]=n,e[s++]=i++,e[s++]=i,e[s++]=n++,e[s++]=i,e[s++]=n;e[s++]=n++,e[s++]=i,e[s++]=n}for(r=2*t,++n,++i,o=0;o<r-1;++o)e[s++]=n,e[s++]=i++,e[s++]=i,e[s++]=n++,e[s++]=i,e[s++]=n;for(e[s++]=n,e[s++]=i++,e[s++]=i,e[s++]=n++,e[s++]=i++,e[s++]=i,++i,o=t-1;o>1;--o){for(e[s++]=i++,e[s++]=i,e[s++]=n,r=2*o,a=0;a<r-1;++a)e[s++]=n,e[s++]=i++,e[s++]=i,e[s++]=n++,e[s++]=i,e[s++]=n;e[s++]=i++,e[s++]=i++,e[s++]=n++}for(o=0;o<3;o++)e[s++]=i++,e[s++]=i,e[s++]=n;return e}let D=new n.Cartesian3;const O=new i.BoundingSphere,S=new i.BoundingSphere;function L(t){const o=t.center,d=t.ellipsoid,A=t.semiMajorAxis;let w=n.Cartesian3.multiplyByScalar(d.geodeticSurfaceNormal(o,x),t.height,x);O.center=n.Cartesian3.add(o,w,O.center),O.radius=A,w=n.Cartesian3.multiplyByScalar(d.geodeticSurfaceNormal(o,w),t.extrudedHeight,w),S.center=n.Cartesian3.add(o,w,S.center),S.radius=A;const D=l.EllipseGeometryLibrary.computeEllipsePositions(t,!0,!0),L=D.positions,R=D.numPts,j=D.outerPositions,k=i.BoundingSphere.union(O,S),z=v(L,t,!0);let B=V(R);const Y=B.length;B.length=2*Y;const H=L.length/3;for(let t=0;t<Y;t+=3)B[t+Y]=B[t+2]+H,B[t+1+Y]=B[t+1]+H,B[t+2+Y]=B[t]+H;const U=y.IndexDatatype.createTypedArray(2*H/3,B),Q=new u.Geometry({attributes:z,indices:U,primitiveType:u.PrimitiveType.TRIANGLES}),W=function(t,o){const l=o.vertexFormat,c=o.center,p=o.semiMajorAxis,y=o.semiMinorAxis,d=o.ellipsoid,A=o.height,w=o.extrudedHeight,v=o.stRotation,V=t.length/3*2,D=new Float64Array(3*V),O=l.st?new Float32Array(2*V):void 0,S=l.normal?new Float32Array(3*V):void 0,L=l.tangent?new Float32Array(3*V):void 0,R=l.bitangent?new Float32Array(3*V):void 0,j=o.shadowVolume,k=j?new Float32Array(3*V):void 0;let z=0,B=E,Y=I,H=T;const U=new i.GeographicProjection(d),Q=U.project(d.cartesianToCartographic(c,G),N),W=d.scaleToGeodeticSurface(c,x);d.geodeticSurfaceNormal(W,W);const J=i.Quaternion.fromAxisAngle(W,v,M),q=f.Matrix3.fromQuaternion(J,C),Z=r.Cartesian2.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,P),K=r.Cartesian2.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,F);let X=t.length;const $=X/3*2;for(let e=0;e<X;e+=3){const i=e+1,r=e+2;let o,a=n.Cartesian3.fromArray(t,e,x);if(l.st){const t=f.Matrix3.multiplyByVector(q,a,h),e=U.project(d.cartesianToCartographic(t,G),g);n.Cartesian3.subtract(e,Q,e),b.x=(e.x+p)/(2*p),b.y=(e.y+y)/(2*y),Z.x=Math.min(b.x,Z.x),Z.y=Math.min(b.y,Z.y),K.x=Math.max(b.x,K.x),K.y=Math.max(b.y,K.y),O[z+$]=b.x,O[z+1+$]=b.y,O[z++]=b.x,O[z++]=b.y}a=d.scaleToGeodeticSurface(a,a),o=n.Cartesian3.clone(a,h),B=d.geodeticSurfaceNormal(a,B),j&&(k[e+X]=-B.x,k[i+X]=-B.y,k[r+X]=-B.z);let s=n.Cartesian3.multiplyByScalar(B,A,_);if(a=n.Cartesian3.add(a,s,a),s=n.Cartesian3.multiplyByScalar(B,w,s),o=n.Cartesian3.add(o,s,o),l.position&&(D[e+X]=o.x,D[i+X]=o.y,D[r+X]=o.z,D[e]=a.x,D[i]=a.y,D[r]=a.z),l.normal||l.tangent||l.bitangent){H=n.Cartesian3.clone(B,H);const s=n.Cartesian3.fromArray(t,(e+3)%X,_);n.Cartesian3.subtract(s,a,s);const u=n.Cartesian3.subtract(o,a,g);B=n.Cartesian3.normalize(n.Cartesian3.cross(u,s,B),B),l.normal&&(S[e]=B.x,S[i]=B.y,S[r]=B.z,S[e+X]=B.x,S[i+X]=B.y,S[r+X]=B.z),l.tangent&&(Y=n.Cartesian3.normalize(n.Cartesian3.cross(H,B,Y),Y),L[e]=Y.x,L[i]=Y.y,L[r]=Y.z,L[e+X]=Y.x,L[e+1+X]=Y.y,L[e+2+X]=Y.z),l.bitangent&&(R[e]=H.x,R[i]=H.y,R[r]=H.z,R[e+X]=H.x,R[i+X]=H.y,R[r+X]=H.z)}}if(l.st){X=O.length;for(let t=0;t<X;t+=2)O[t]=(O[t]-Z.x)/(K.x-Z.x),O[t+1]=(O[t+1]-Z.y)/(K.y-Z.y)}const tt=new m.GeometryAttributes;if(l.position&&(tt.position=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:D})),l.st&&(tt.st=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:O})),l.normal&&(tt.normal=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:S})),l.tangent&&(tt.tangent=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:L})),l.bitangent&&(tt.bitangent=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:R})),j&&(tt.extrudeDirection=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:k})),s.defined(o.offsetAttribute)){let t=new Uint8Array(V);if(o.offsetAttribute===e.GeometryOffsetAttribute.TOP)t=e.arrayFill(t,1,0,V/2);else{const i=o.offsetAttribute===e.GeometryOffsetAttribute.NONE?0:1;t=e.arrayFill(t,i)}tt.applyOffset=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:t})}return tt}(j,t);B=function(t){const e=t.length/3,i=y.IndexDatatype.createTypedArray(e,6*e);let r=0;for(let t=0;t<e;t++){const n=t,o=t+e,a=(n+1)%e,s=a+e;i[r++]=n,i[r++]=o,i[r++]=a,i[r++]=a,i[r++]=o,i[r++]=s}return i}(j);const J=y.IndexDatatype.createTypedArray(2*j.length/3,B),q=new u.Geometry({attributes:W,indices:J,primitiveType:u.PrimitiveType.TRIANGLES}),Z=p.GeometryPipeline.combineInstances([new c.GeometryInstance({geometry:Q}),new c.GeometryInstance({geometry:q})]);return{boundingSphere:k,attributes:Z[0].attributes,indices:Z[0].indices}}function R(t,e,i,o,a,s,u){const m=l.EllipseGeometryLibrary.computeEllipsePositions({center:t,semiMajorAxis:e,semiMinorAxis:i,rotation:o,granularity:a},!1,!0).outerPositions,c=m.length/3,p=new Array(c);for(let t=0;t<c;++t)p[t]=n.Cartesian3.fromArray(m,3*t);const y=r.Rectangle.fromCartesianArray(p,s,u);return y.width>d.CesiumMath.PI&&(y.north=y.north>0?d.CesiumMath.PI_OVER_TWO-d.CesiumMath.EPSILON7:y.north,y.south=y.south<0?d.CesiumMath.EPSILON7-d.CesiumMath.PI_OVER_TWO:y.south,y.east=d.CesiumMath.PI,y.west=-d.CesiumMath.PI),y}function j(t){const e=(t=s.defaultValue(t,s.defaultValue.EMPTY_OBJECT)).center,i=s.defaultValue(t.ellipsoid,r.Ellipsoid.WGS84),o=t.semiMajorAxis,a=t.semiMinorAxis,l=s.defaultValue(t.granularity,d.CesiumMath.RADIANS_PER_DEGREE),u=s.defaultValue(t.vertexFormat,A.VertexFormat.DEFAULT),m=s.defaultValue(t.height,0),c=s.defaultValue(t.extrudedHeight,m);this._center=n.Cartesian3.clone(e),this._semiMajorAxis=o,this._semiMinorAxis=a,this._ellipsoid=r.Ellipsoid.clone(i),this._rotation=s.defaultValue(t.rotation,0),this._stRotation=s.defaultValue(t.stRotation,0),this._height=Math.max(c,m),this._granularity=l,this._vertexFormat=A.VertexFormat.clone(u),this._extrudedHeight=Math.min(c,m),this._shadowVolume=s.defaultValue(t.shadowVolume,!1),this._workerName="createEllipseGeometry",this._offsetAttribute=t.offsetAttribute,this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0}j.packedLength=n.Cartesian3.packedLength+r.Ellipsoid.packedLength+A.VertexFormat.packedLength+9,j.pack=function(t,e,i){return i=s.defaultValue(i,0),n.Cartesian3.pack(t._center,e,i),i+=n.Cartesian3.packedLength,r.Ellipsoid.pack(t._ellipsoid,e,i),i+=r.Ellipsoid.packedLength,A.VertexFormat.pack(t._vertexFormat,e,i),i+=A.VertexFormat.packedLength,e[i++]=t._semiMajorAxis,e[i++]=t._semiMinorAxis,e[i++]=t._rotation,e[i++]=t._stRotation,e[i++]=t._height,e[i++]=t._granularity,e[i++]=t._extrudedHeight,e[i++]=t._shadowVolume?1:0,e[i]=s.defaultValue(t._offsetAttribute,-1),e};const k=new n.Cartesian3,z=new r.Ellipsoid,B=new A.VertexFormat,Y={center:k,ellipsoid:z,vertexFormat:B,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};j.unpack=function(t,e,i){e=s.defaultValue(e,0);const o=n.Cartesian3.unpack(t,e,k);e+=n.Cartesian3.packedLength;const a=r.Ellipsoid.unpack(t,e,z);e+=r.Ellipsoid.packedLength;const l=A.VertexFormat.unpack(t,e,B);e+=A.VertexFormat.packedLength;const u=t[e++],m=t[e++],c=t[e++],p=t[e++],y=t[e++],d=t[e++],f=t[e++],x=1===t[e++],h=t[e];return s.defined(i)?(i._center=n.Cartesian3.clone(o,i._center),i._ellipsoid=r.Ellipsoid.clone(a,i._ellipsoid),i._vertexFormat=A.VertexFormat.clone(l,i._vertexFormat),i._semiMajorAxis=u,i._semiMinorAxis=m,i._rotation=c,i._stRotation=p,i._height=y,i._granularity=d,i._extrudedHeight=f,i._shadowVolume=x,i._offsetAttribute=-1===h?void 0:h,i):(Y.height=y,Y.extrudedHeight=f,Y.granularity=d,Y.stRotation=p,Y.rotation=c,Y.semiMajorAxis=u,Y.semiMinorAxis=m,Y.shadowVolume=x,Y.offsetAttribute=-1===h?void 0:h,new j(Y))},j.computeRectangle=function(t,e){const i=(t=s.defaultValue(t,s.defaultValue.EMPTY_OBJECT)).center,n=s.defaultValue(t.ellipsoid,r.Ellipsoid.WGS84),o=t.semiMajorAxis,a=t.semiMinorAxis,l=s.defaultValue(t.granularity,d.CesiumMath.RADIANS_PER_DEGREE);return R(i,o,a,s.defaultValue(t.rotation,0),l,n,e)},j.createGeometry=function(t){if(t._semiMajorAxis<=0||t._semiMinorAxis<=0)return;const r=t._height,o=t._extrudedHeight,m=!d.CesiumMath.equalsEpsilon(r,o,0,d.CesiumMath.EPSILON2);t._center=t._ellipsoid.scaleToGeodeticSurface(t._center,t._center);const c={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};let p;if(m)c.extrudedHeight=o,c.shadowVolume=t._shadowVolume,c.offsetAttribute=t._offsetAttribute,p=L(c);else if(p=function(t){const e=t.center;D=n.Cartesian3.multiplyByScalar(t.ellipsoid.geodeticSurfaceNormal(e,D),t.height,D),D=n.Cartesian3.add(e,D,D);const r=new i.BoundingSphere(D,t.semiMajorAxis),o=l.EllipseGeometryLibrary.computeEllipsePositions(t,!0,!1),a=o.positions,s=o.numPts,u=v(a,t,!1);let m=V(s);return m=y.IndexDatatype.createTypedArray(a.length/3,m),{boundingSphere:r,attributes:u,indices:m}}(c),s.defined(t._offsetAttribute)){const i=p.attributes.position.values.length,r=new Uint8Array(i/3),n=t._offsetAttribute===e.GeometryOffsetAttribute.NONE?0:1;e.arrayFill(r,n),p.attributes.applyOffset=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:r})}return new u.Geometry({attributes:p.attributes,indices:p.indices,primitiveType:u.PrimitiveType.TRIANGLES,boundingSphere:p.boundingSphere,offsetAttribute:t._offsetAttribute})},j.createShadowVolume=function(t,e,i){const r=t._granularity,n=t._ellipsoid,o=e(r,n),a=i(r,n);return new j({center:t._center,semiMajorAxis:t._semiMajorAxis,semiMinorAxis:t._semiMinorAxis,ellipsoid:n,rotation:t._rotation,stRotation:t._stRotation,granularity:r,extrudedHeight:o,height:a,vertexFormat:A.VertexFormat.POSITION_ONLY,shadowVolume:!0})},Object.defineProperties(j.prototype,{rectangle:{get:function(){return s.defined(this._rectangle)||(this._rectangle=R(this._center,this._semiMajorAxis,this._semiMinorAxis,this._rotation,this._granularity,this._ellipsoid)),this._rectangle}},textureCoordinateRotationPoints:{get:function(){return s.defined(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=function(t){const e=-t._stRotation;if(0===e)return[0,0,0,1,1,0];const i=l.EllipseGeometryLibrary.computeEllipsePositions({center:t._center,semiMajorAxis:t._semiMajorAxis,semiMinorAxis:t._semiMinorAxis,rotation:t._rotation,granularity:t._granularity},!1,!0).outerPositions,r=i.length/3,o=new Array(r);for(let t=0;t<r;++t)o[t]=n.Cartesian3.fromArray(i,3*t);const a=t._ellipsoid,s=t.rectangle;return u.Geometry._textureCoordinateRotationPoints(o,e,a,s)}(this)),this._textureCoordinateRotationPoints}}}),t.EllipseGeometry=j}));
|