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