bmh_cesium/public/lib/cesiumjs/CesiumUnminified/Workers/EllipseGeometry-195afe88.js
2025-03-10 07:23:50 +08:00

2 lines
16 KiB
JavaScript

/* 2020-9-22 15:23:24 | 版权所有 军懋国兴 */
define(["exports","./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./Cartesian2-43e3a3be","./Transforms-2d1ac5ec","./ComponentDatatype-607c9a0c","./GeometryAttribute-2303bbfb","./GeometryAttributes-90846c5f","./GeometryPipeline-1ea64cde","./IndexDatatype-79bb407c","./GeometryOffsetAttribute-9c676324","./VertexFormat-fe64931e","./EllipseGeometryLibrary-304b788d","./GeometryInstance-6264cc0f"],function(e,U,h,p,Q,W,q,J,Z,_,C,K,f,B,v){"use strict";var X=new Q.Cartesian3,$=new Q.Cartesian3,ee=new Q.Cartesian3,te=new Q.Cartesian3,re=new Q.Cartesian2,ae=new W.Matrix3,Y=new W.Matrix3,ie=new W.Quaternion,ne=new Q.Cartesian3,oe=new Q.Cartesian3,se=new Q.Cartesian3,ue=new Q.Cartographic,le=new Q.Cartesian3,me=new Q.Cartesian2,ce=new Q.Cartesian2;function w(e,t,r){var a=t.vertexFormat,i=t.center,n=t.semiMajorAxis,o=t.semiMinorAxis,s=t.ellipsoid,u=t.stRotation,l=r?e.length/3*2:e.length/3,m=t.shadowVolume,c=a.st?new Float32Array(2*l):void 0,p=a.normal?new Float32Array(3*l):void 0,y=a.tangent?new Float32Array(3*l):void 0,d=a.bitangent?new Float32Array(3*l):void 0,h=m?new Float32Array(3*l):void 0,f=0,A=ne,x=oe,g=se,b=new W.GeographicProjection(s),_=b.project(s.cartesianToCartographic(i,ue),le),C=s.scaleToGeodeticSurface(i,X);s.geodeticSurfaceNormal(C,C);var v,w=ae,M=Y;M=0!==u?(v=W.Quaternion.fromAxisAngle(C,u,ie),w=W.Matrix3.fromQuaternion(v,w),v=W.Quaternion.fromAxisAngle(C,-u,ie),W.Matrix3.fromQuaternion(v,M)):(w=W.Matrix3.clone(W.Matrix3.IDENTITY,w),W.Matrix3.clone(W.Matrix3.IDENTITY,M));for(var E=Q.Cartesian2.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,me),I=Q.Cartesian2.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,ce),T=e.length,G=r?T:0,N=G/3*2,P=0;P<T;P+=3){var F,D,V=P+1,O=P+2,S=Q.Cartesian3.fromArray(e,P,X);a.st&&(F=W.Matrix3.multiplyByVector(w,S,$),D=b.project(s.cartesianToCartographic(F,ue),ee),Q.Cartesian3.subtract(D,_,D),re.x=(D.x+n)/(2*n),re.y=(D.y+o)/(2*o),E.x=Math.min(re.x,E.x),E.y=Math.min(re.y,E.y),I.x=Math.max(re.x,I.x),I.y=Math.max(re.y,I.y),r&&(c[f+N]=re.x,c[f+1+N]=re.y),c[f++]=re.x,c[f++]=re.y),(a.normal||a.tangent||a.bitangent||m)&&(A=s.geodeticSurfaceNormal(S,A),m&&(h[P+G]=-A.x,h[V+G]=-A.y,h[O+G]=-A.z),(a.normal||a.tangent||a.bitangent)&&((a.tangent||a.bitangent)&&(x=Q.Cartesian3.normalize(Q.Cartesian3.cross(Q.Cartesian3.UNIT_Z,A,x),x),W.Matrix3.multiplyByVector(M,x,x)),a.normal&&(p[P]=A.x,p[V]=A.y,p[O]=A.z,r&&(p[P+G]=-A.x,p[V+G]=-A.y,p[O+G]=-A.z)),a.tangent&&(y[P]=x.x,y[V]=x.y,y[O]=x.z,r&&(y[P+G]=-x.x,y[V+G]=-x.y,y[O+G]=-x.z)),a.bitangent&&(g=Q.Cartesian3.normalize(Q.Cartesian3.cross(A,x,g),g),d[P]=g.x,d[V]=g.y,d[O]=g.z,r&&(d[P+G]=g.x,d[V+G]=g.y,d[O+G]=g.z))))}if(a.st){T=c.length;for(var L=0;L<T;L+=2)c[L]=(c[L]-E.x)/(I.x-E.x),c[L+1]=(c[L+1]-E.y)/(I.y-E.y)}var R,j,k,z=new Z.GeometryAttributes;return a.position&&(R=B.EllipseGeometryLibrary.raisePositionsToHeight(e,t,r),z.position=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:R})),a.st&&(z.st=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:c})),a.normal&&(z.normal=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:p})),a.tangent&&(z.tangent=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:y})),a.bitangent&&(z.bitangent=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:d})),m&&(z.extrudeDirection=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:h})),r&&U.defined(t.offsetAttribute)&&(k=new Uint8Array(l),k=t.offsetAttribute===K.GeometryOffsetAttribute.TOP?K.arrayFill(k,1,0,l/2):(j=t.offsetAttribute===K.GeometryOffsetAttribute.NONE?0:1,K.arrayFill(k,j)),z.applyOffset=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:k})),z}function M(e){for(var t,r,a=new Array(e*(e+1)*12-6),i=0,n=0,o=1,s=0;s<3;s++)a[i++]=o++,a[i++]=n,a[i++]=o;for(s=2;s<e+1;++s){for(o=s*(s+1)-1,n=(s-1)*s-1,a[i++]=o++,a[i++]=n,a[i++]=o,t=2*s,r=0;r<t-1;++r)a[i++]=o,a[i++]=n++,a[i++]=n,a[i++]=o++,a[i++]=n,a[i++]=o;a[i++]=o++,a[i++]=n,a[i++]=o}for(t=2*e,++o,++n,s=0;s<t-1;++s)a[i++]=o,a[i++]=n++,a[i++]=n,a[i++]=o++,a[i++]=n,a[i++]=o;for(a[i++]=o,a[i++]=n++,a[i++]=n,a[i++]=o++,a[i++]=n++,a[i++]=n,++n,s=e-1;1<s;--s){for(a[i++]=n++,a[i++]=n,a[i++]=o,t=2*s,r=0;r<t-1;++r)a[i++]=o,a[i++]=n++,a[i++]=n,a[i++]=o++,a[i++]=n,a[i++]=o;a[i++]=n++,a[i++]=n++,a[i++]=o++}for(s=0;s<3;s++)a[i++]=n++,a[i++]=n,a[i++]=o;return a}var l=new Q.Cartesian3;var E=new W.BoundingSphere,I=new W.BoundingSphere;function m(e){var t=e.center,r=e.ellipsoid,a=e.semiMajorAxis,i=Q.Cartesian3.multiplyByScalar(r.geodeticSurfaceNormal(t,X),e.height,X);E.center=Q.Cartesian3.add(t,i,E.center),E.radius=a,i=Q.Cartesian3.multiplyByScalar(r.geodeticSurfaceNormal(t,i),e.extrudedHeight,i),I.center=Q.Cartesian3.add(t,i,I.center),I.radius=a;var n=B.EllipseGeometryLibrary.computeEllipsePositions(e,!0,!0),o=n.positions,s=n.numPts,u=n.outerPositions,l=W.BoundingSphere.union(E,I),m=w(o,e,!0),c=(A=M(s)).length;A.length=2*c;for(var p=o.length/3,y=0;y<c;y+=3)A[y+c]=A[y+2]+p,A[y+1+c]=A[y+1]+p,A[y+2+c]=A[y]+p;var d=C.IndexDatatype.createTypedArray(2*p/3,A),h=new J.Geometry({attributes:m,indices:d,primitiveType:J.PrimitiveType.TRIANGLES}),f=function(e,t){var r=t.vertexFormat,a=t.center,i=t.semiMajorAxis,n=t.semiMinorAxis,o=t.ellipsoid,s=t.height,u=t.extrudedHeight,l=t.stRotation,m=e.length/3*2,c=new Float64Array(3*m),p=r.st?new Float32Array(2*m):void 0,y=r.normal?new Float32Array(3*m):void 0,d=r.tangent?new Float32Array(3*m):void 0,h=r.bitangent?new Float32Array(3*m):void 0,f=t.shadowVolume,A=f?new Float32Array(3*m):void 0,x=0,g=ne,b=oe,_=se,C=new W.GeographicProjection(o),v=C.project(o.cartesianToCartographic(a,ue),le),w=o.scaleToGeodeticSurface(a,X);o.geodeticSurfaceNormal(w,w);for(var M=W.Quaternion.fromAxisAngle(w,l,ie),E=W.Matrix3.fromQuaternion(M,ae),I=Q.Cartesian2.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,me),T=Q.Cartesian2.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,ce),G=e.length,N=G/3*2,P=0;P<G;P+=3){var F,D,V=P+1,O=P+2,S=Q.Cartesian3.fromArray(e,P,X);r.st&&(F=W.Matrix3.multiplyByVector(E,S,$),D=C.project(o.cartesianToCartographic(F,ue),ee),Q.Cartesian3.subtract(D,v,D),re.x=(D.x+i)/(2*i),re.y=(D.y+n)/(2*n),I.x=Math.min(re.x,I.x),I.y=Math.min(re.y,I.y),T.x=Math.max(re.x,T.x),T.y=Math.max(re.y,T.y),p[x+N]=re.x,p[x+1+N]=re.y,p[x++]=re.x,p[x++]=re.y),S=o.scaleToGeodeticSurface(S,S),k=Q.Cartesian3.clone(S,$),g=o.geodeticSurfaceNormal(S,g),f&&(A[P+G]=-g.x,A[V+G]=-g.y,A[O+G]=-g.z);var L,R,j=Q.Cartesian3.multiplyByScalar(g,s,te),S=Q.Cartesian3.add(S,j,S),j=Q.Cartesian3.multiplyByScalar(g,u,j),k=Q.Cartesian3.add(k,j,k);r.position&&(c[P+G]=k.x,c[V+G]=k.y,c[O+G]=k.z,c[P]=S.x,c[V]=S.y,c[O]=S.z),(r.normal||r.tangent||r.bitangent)&&(_=Q.Cartesian3.clone(g,_),L=Q.Cartesian3.fromArray(e,(P+3)%G,te),Q.Cartesian3.subtract(L,S,L),R=Q.Cartesian3.subtract(k,S,ee),g=Q.Cartesian3.normalize(Q.Cartesian3.cross(R,L,g),g),r.normal&&(y[P]=g.x,y[V]=g.y,y[O]=g.z,y[P+G]=g.x,y[V+G]=g.y,y[O+G]=g.z),r.tangent&&(b=Q.Cartesian3.normalize(Q.Cartesian3.cross(_,g,b),b),d[P]=b.x,d[V]=b.y,d[O]=b.z,d[P+G]=b.x,d[P+1+G]=b.y,d[P+2+G]=b.z),r.bitangent&&(h[P]=_.x,h[V]=_.y,h[O]=_.z,h[P+G]=_.x,h[V+G]=_.y,h[O+G]=_.z))}if(r.st){G=p.length;for(var z=0;z<G;z+=2)p[z]=(p[z]-I.x)/(T.x-I.x),p[z+1]=(p[z+1]-I.y)/(T.y-I.y)}var B,Y,H=new Z.GeometryAttributes;return r.position&&(H.position=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:c})),r.st&&(H.st=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:p})),r.normal&&(H.normal=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:y})),r.tangent&&(H.tangent=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:d})),r.bitangent&&(H.bitangent=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:h})),f&&(H.extrudeDirection=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:A})),U.defined(t.offsetAttribute)&&(Y=new Uint8Array(m),Y=t.offsetAttribute===K.GeometryOffsetAttribute.TOP?K.arrayFill(Y,1,0,m/2):(B=t.offsetAttribute===K.GeometryOffsetAttribute.NONE?0:1,K.arrayFill(Y,B)),H.applyOffset=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:Y})),H}(u,e),A=function(e){for(var t=e.length/3,r=C.IndexDatatype.createTypedArray(t,6*t),a=0,i=0;i<t;i++){var n=i+t,o=(i+1)%t,s=o+t;r[a++]=i,r[a++]=n,r[a++]=o,r[a++]=o,r[a++]=n,r[a++]=s}return r}(u),x=C.IndexDatatype.createTypedArray(2*u.length/3,A),g=new J.Geometry({attributes:f,indices:x,primitiveType:J.PrimitiveType.TRIANGLES}),b=_.GeometryPipeline.combineInstances([new v.GeometryInstance({geometry:h}),new v.GeometryInstance({geometry:g})]);return{boundingSphere:l,attributes:b[0].attributes,indices:b[0].indices}}function u(e,t,r,a,i,n,o){for(var s=B.EllipseGeometryLibrary.computeEllipsePositions({center:e,semiMajorAxis:t,semiMinorAxis:r,rotation:a,granularity:i},!1,!0).outerPositions,u=s.length/3,l=new Array(u),m=0;m<u;++m)l[m]=Q.Cartesian3.fromArray(s,3*m);var c=Q.Rectangle.fromCartesianArray(l,n,o);return c.width>p.CesiumMath.PI&&(c.north=0<c.north?p.CesiumMath.PI_OVER_TWO-p.CesiumMath.EPSILON7:c.north,c.south=c.south<0?p.CesiumMath.EPSILON7-p.CesiumMath.PI_OVER_TWO:c.south,c.east=p.CesiumMath.PI,c.west=-p.CesiumMath.PI),c}function A(e){var t=(e=U.defaultValue(e,U.defaultValue.EMPTY_OBJECT)).center,r=U.defaultValue(e.ellipsoid,Q.Ellipsoid.WGS84),a=e.semiMajorAxis,i=e.semiMinorAxis,n=U.defaultValue(e.granularity,p.CesiumMath.RADIANS_PER_DEGREE),o=U.defaultValue(e.vertexFormat,f.VertexFormat.DEFAULT);if(h.Check.defined("options.center",t),h.Check.typeOf.number("options.semiMajorAxis",a),h.Check.typeOf.number("options.semiMinorAxis",i),a<i)throw new h.DeveloperError("semiMajorAxis must be greater than or equal to the semiMinorAxis.");if(n<=0)throw new h.DeveloperError("granularity must be greater than zero.");var s=U.defaultValue(e.height,0),u=U.defaultValue(e.extrudedHeight,s);this._center=Q.Cartesian3.clone(t),this._semiMajorAxis=a,this._semiMinorAxis=i,this._ellipsoid=Q.Ellipsoid.clone(r),this._rotation=U.defaultValue(e.rotation,0),this._stRotation=U.defaultValue(e.stRotation,0),this._height=Math.max(u,s),this._granularity=n,this._vertexFormat=f.VertexFormat.clone(o),this._extrudedHeight=Math.min(u,s),this._shadowVolume=U.defaultValue(e.shadowVolume,!1),this._workerName="createEllipseGeometry",this._offsetAttribute=e.offsetAttribute,this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0}A.packedLength=Q.Cartesian3.packedLength+Q.Ellipsoid.packedLength+f.VertexFormat.packedLength+9,A.pack=function(e,t,r){return h.Check.defined("value",e),h.Check.defined("array",t),r=U.defaultValue(r,0),Q.Cartesian3.pack(e._center,t,r),r+=Q.Cartesian3.packedLength,Q.Ellipsoid.pack(e._ellipsoid,t,r),r+=Q.Ellipsoid.packedLength,f.VertexFormat.pack(e._vertexFormat,t,r),r+=f.VertexFormat.packedLength,t[r++]=e._semiMajorAxis,t[r++]=e._semiMinorAxis,t[r++]=e._rotation,t[r++]=e._stRotation,t[r++]=e._height,t[r++]=e._granularity,t[r++]=e._extrudedHeight,t[r++]=e._shadowVolume?1:0,t[r]=U.defaultValue(e._offsetAttribute,-1),t};var x=new Q.Cartesian3,g=new Q.Ellipsoid,b=new f.VertexFormat,T={center:x,ellipsoid:g,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};A.unpack=function(e,t,r){h.Check.defined("array",e),t=U.defaultValue(t,0);var a=Q.Cartesian3.unpack(e,t,x);t+=Q.Cartesian3.packedLength;var i=Q.Ellipsoid.unpack(e,t,g);t+=Q.Ellipsoid.packedLength;var n=f.VertexFormat.unpack(e,t,b);t+=f.VertexFormat.packedLength;var o=e[t++],s=e[t++],u=e[t++],l=e[t++],m=e[t++],c=e[t++],p=e[t++],y=1===e[t++],d=e[t];return U.defined(r)?(r._center=Q.Cartesian3.clone(a,r._center),r._ellipsoid=Q.Ellipsoid.clone(i,r._ellipsoid),r._vertexFormat=f.VertexFormat.clone(n,r._vertexFormat),r._semiMajorAxis=o,r._semiMinorAxis=s,r._rotation=u,r._stRotation=l,r._height=m,r._granularity=c,r._extrudedHeight=p,r._shadowVolume=y,r._offsetAttribute=-1===d?void 0:d,r):(T.height=m,T.extrudedHeight=p,T.granularity=c,T.stRotation=l,T.rotation=u,T.semiMajorAxis=o,T.semiMinorAxis=s,T.shadowVolume=y,T.offsetAttribute=-1===d?void 0:d,new A(T))},A.computeRectangle=function(e,t){var r=(e=U.defaultValue(e,U.defaultValue.EMPTY_OBJECT)).center,a=U.defaultValue(e.ellipsoid,Q.Ellipsoid.WGS84),i=e.semiMajorAxis,n=e.semiMinorAxis,o=U.defaultValue(e.granularity,p.CesiumMath.RADIANS_PER_DEGREE),s=U.defaultValue(e.rotation,0);if(h.Check.defined("options.center",r),h.Check.typeOf.number("options.semiMajorAxis",i),h.Check.typeOf.number("options.semiMinorAxis",n),i<n)throw new h.DeveloperError("semiMajorAxis must be greater than or equal to the semiMinorAxis.");if(o<=0)throw new h.DeveloperError("granularity must be greater than zero.");return u(r,i,n,s,o,a,t)},A.createGeometry=function(e){if(!(e._semiMajorAxis<=0||e._semiMinorAxis<=0)){var t=e._height,r=e._extrudedHeight,a=!p.CesiumMath.equalsEpsilon(t,r,0,p.CesiumMath.EPSILON2);e._center=e._ellipsoid.scaleToGeodeticSurface(e._center,e._center);var i,n,o,s,u={center:e._center,semiMajorAxis:e._semiMajorAxis,semiMinorAxis:e._semiMinorAxis,ellipsoid:e._ellipsoid,rotation:e._rotation,height:t,granularity:e._granularity,vertexFormat:e._vertexFormat,stRotation:e._stRotation};return a?(u.extrudedHeight=r,u.shadowVolume=e._shadowVolume,u.offsetAttribute=e._offsetAttribute,s=m(u)):(s=function(e){var t=e.center;l=Q.Cartesian3.multiplyByScalar(e.ellipsoid.geodeticSurfaceNormal(t,l),e.height,l),l=Q.Cartesian3.add(t,l,l);var r=new W.BoundingSphere(l,e.semiMajorAxis),a=B.EllipseGeometryLibrary.computeEllipsePositions(e,!0,!1),i=a.positions,n=a.numPts,o=w(i,e,!1),s=M(n);return{boundingSphere:r,attributes:o,indices:s=C.IndexDatatype.createTypedArray(i.length/3,s)}}(u),U.defined(e._offsetAttribute)&&(i=s.attributes.position.values.length,n=new Uint8Array(i/3),o=e._offsetAttribute===K.GeometryOffsetAttribute.NONE?0:1,K.arrayFill(n,o),s.attributes.applyOffset=new J.GeometryAttribute({componentDatatype:q.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:n}))),new J.Geometry({attributes:s.attributes,indices:s.indices,primitiveType:J.PrimitiveType.TRIANGLES,boundingSphere:s.boundingSphere,offsetAttribute:e._offsetAttribute})}},A.createShadowVolume=function(e,t,r){var a=e._granularity,i=e._ellipsoid,n=t(a,i),o=r(a,i);return new A({center:e._center,semiMajorAxis:e._semiMajorAxis,semiMinorAxis:e._semiMinorAxis,ellipsoid:i,rotation:e._rotation,stRotation:e._stRotation,granularity:a,extrudedHeight:n,height:o,vertexFormat:f.VertexFormat.POSITION_ONLY,shadowVolume:!0})},Object.defineProperties(A.prototype,{rectangle:{get:function(){return U.defined(this._rectangle)||(this._rectangle=u(this._center,this._semiMajorAxis,this._semiMinorAxis,this._rotation,this._granularity,this._ellipsoid)),this._rectangle}},textureCoordinateRotationPoints:{get:function(){return U.defined(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=function(e){var t=-e._stRotation;if(0==t)return[0,0,0,1,1,0];for(var r=B.EllipseGeometryLibrary.computeEllipsePositions({center:e._center,semiMajorAxis:e._semiMajorAxis,semiMinorAxis:e._semiMinorAxis,rotation:e._rotation,granularity:e._granularity},!1,!0).outerPositions,a=r.length/3,i=new Array(a),n=0;n<a;++n)i[n]=Q.Cartesian3.fromArray(r,3*n);var o=e._ellipsoid,s=e.rectangle;return J.Geometry._textureCoordinateRotationPoints(i,t,o,s)}(this)),this._textureCoordinateRotationPoints}}}),e.EllipseGeometry=A});