/** * @license * Cesium - https://github.com/CesiumGS/cesium * Version 1.96.6 * * Copyright 2011-2022 Cesium Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Columbus View (Pat. Pend.) * * Portions licensed separately. * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details. */ define(["exports","./Transforms-66eda18c","./Matrix2-4706dd70","./RuntimeError-a977b8e0","./ComponentDatatype-438cad2a","./defaultValue-028a8a27","./EllipseGeometryLibrary-5f21f480","./GeometryAttribute-2cdece80","./GeometryAttributes-98e858da","./GeometryInstance-bbed0de0","./GeometryOffsetAttribute-116f8293","./GeometryPipeline-d062bcb6","./IndexDatatype-dfa09980","./VertexFormat-3518f543"],(function(t,e,r,i,n,o,a,s,l,u,m,c,p,y){"use strict";const d=new r.Cartesian3,f=new r.Cartesian3,h=new r.Cartesian3,A=new r.Cartesian3,x=new r.Cartesian2,g=new r.Matrix3,b=new r.Matrix3,_=new e.Quaternion,C=new r.Cartesian3,w=new r.Cartesian3,M=new r.Cartesian3,E=new r.Cartographic,I=new r.Cartesian3,T=new r.Cartesian2,G=new r.Cartesian2;function v(t,i,u){const c=i.vertexFormat,p=i.center,y=i.semiMajorAxis,A=i.semiMinorAxis,v=i.ellipsoid,N=i.stRotation,P=u?t.length/3*2:t.length/3,V=i.shadowVolume,D=c.st?new Float32Array(2*P):void 0,F=c.normal?new Float32Array(3*P):void 0,O=c.tangent?new Float32Array(3*P):void 0,S=c.bitangent?new Float32Array(3*P):void 0,L=V?new Float32Array(3*P):void 0;let R=0,j=C,k=w,z=M;const B=new e.GeographicProjection(v),Y=B.project(v.cartesianToCartographic(p,E),I),H=v.scaleToGeodeticSurface(p,d);v.geodeticSurfaceNormal(H,H);let U=g,Q=b;if(0!==N){let t=e.Quaternion.fromAxisAngle(H,N,_);U=r.Matrix3.fromQuaternion(t,U),t=e.Quaternion.fromAxisAngle(H,-N,_),Q=r.Matrix3.fromQuaternion(t,Q)}else U=r.Matrix3.clone(r.Matrix3.IDENTITY,U),Q=r.Matrix3.clone(r.Matrix3.IDENTITY,Q);const W=r.Cartesian2.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,T),q=r.Cartesian2.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,G);let J=t.length;const Z=u?J:0,K=Z/3*2;for(let e=0;e<J;e+=3){const i=e+1,n=e+2,o=r.Cartesian3.fromArray(t,e,d);if(c.st){const t=r.Matrix3.multiplyByVector(U,o,f),e=B.project(v.cartesianToCartographic(t,E),h);r.Cartesian3.subtract(e,Y,e),x.x=(e.x+y)/(2*y),x.y=(e.y+A)/(2*A),W.x=Math.min(x.x,W.x),W.y=Math.min(x.y,W.y),q.x=Math.max(x.x,q.x),q.y=Math.max(x.y,q.y),u&&(D[R+K]=x.x,D[R+1+K]=x.y),D[R++]=x.x,D[R++]=x.y}(c.normal||c.tangent||c.bitangent||V)&&(j=v.geodeticSurfaceNormal(o,j),V&&(L[e+Z]=-j.x,L[i+Z]=-j.y,L[n+Z]=-j.z),(c.normal||c.tangent||c.bitangent)&&((c.tangent||c.bitangent)&&(k=r.Cartesian3.normalize(r.Cartesian3.cross(r.Cartesian3.UNIT_Z,j,k),k),r.Matrix3.multiplyByVector(Q,k,k)),c.normal&&(F[e]=j.x,F[i]=j.y,F[n]=j.z,u&&(F[e+Z]=-j.x,F[i+Z]=-j.y,F[n+Z]=-j.z)),c.tangent&&(O[e]=k.x,O[i]=k.y,O[n]=k.z,u&&(O[e+Z]=-k.x,O[i+Z]=-k.y,O[n+Z]=-k.z)),c.bitangent&&(z=r.Cartesian3.normalize(r.Cartesian3.cross(j,k,z),z),S[e]=z.x,S[i]=z.y,S[n]=z.z,u&&(S[e+Z]=z.x,S[i+Z]=z.y,S[n+Z]=z.z))))}if(c.st){J=D.length;for(let t=0;t<J;t+=2)D[t]=(D[t]-W.x)/(q.x-W.x),D[t+1]=(D[t+1]-W.y)/(q.y-W.y)}const X=new l.GeometryAttributes;if(c.position){const e=a.EllipseGeometryLibrary.raisePositionsToHeight(t,i,u);X.position=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e})}if(c.st&&(X.st=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:D})),c.normal&&(X.normal=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:F})),c.tangent&&(X.tangent=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:O})),c.bitangent&&(X.bitangent=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:S})),V&&(X.extrudeDirection=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:L})),u&&o.defined(i.offsetAttribute)){let t=new Uint8Array(P);if(i.offsetAttribute===m.GeometryOffsetAttribute.TOP)t=t.fill(1,0,P/2);else{const e=i.offsetAttribute===m.GeometryOffsetAttribute.NONE?0:1;t=t.fill(e)}X.applyOffset=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:t})}return X}function N(t){const e=new Array(t*(t+1)*12-6);let r,i,n,o,a,s=0;for(r=0,n=1,o=0;o<3;o++)e[s++]=n++,e[s++]=r,e[s++]=n;for(o=2;o<t+1;++o){for(n=o*(o+1)-1,r=(o-1)*o-1,e[s++]=n++,e[s++]=r,e[s++]=n,i=2*o,a=0;a<i-1;++a)e[s++]=n,e[s++]=r++,e[s++]=r,e[s++]=n++,e[s++]=r,e[s++]=n;e[s++]=n++,e[s++]=r,e[s++]=n}for(i=2*t,++n,++r,o=0;o<i-1;++o)e[s++]=n,e[s++]=r++,e[s++]=r,e[s++]=n++,e[s++]=r,e[s++]=n;for(e[s++]=n,e[s++]=r++,e[s++]=r,e[s++]=n++,e[s++]=r++,e[s++]=r,++r,o=t-1;o>1;--o){for(e[s++]=r++,e[s++]=r,e[s++]=n,i=2*o,a=0;a<i-1;++a)e[s++]=n,e[s++]=r++,e[s++]=r,e[s++]=n++,e[s++]=r,e[s++]=n;e[s++]=r++,e[s++]=r++,e[s++]=n++}for(o=0;o<3;o++)e[s++]=r++,e[s++]=r,e[s++]=n;return e}let P=new r.Cartesian3;function V(t){const i=t.center;P=r.Cartesian3.multiplyByScalar(t.ellipsoid.geodeticSurfaceNormal(i,P),t.height,P),P=r.Cartesian3.add(i,P,P);const n=new e.BoundingSphere(P,t.semiMajorAxis),o=a.EllipseGeometryLibrary.computeEllipsePositions(t,!0,!1),s=o.positions,l=o.numPts,u=v(s,t,!1);let m=N(l);return m=p.IndexDatatype.createTypedArray(s.length/3,m),{boundingSphere:n,attributes:u,indices:m}}function D(t,i){const a=i.vertexFormat,u=i.center,c=i.semiMajorAxis,p=i.semiMinorAxis,y=i.ellipsoid,b=i.height,v=i.extrudedHeight,N=i.stRotation,P=t.length/3*2,V=new Float64Array(3*P),D=a.st?new Float32Array(2*P):void 0,F=a.normal?new Float32Array(3*P):void 0,O=a.tangent?new Float32Array(3*P):void 0,S=a.bitangent?new Float32Array(3*P):void 0,L=i.shadowVolume,R=L?new Float32Array(3*P):void 0;let j=0,k=C,z=w,B=M;const Y=new e.GeographicProjection(y),H=Y.project(y.cartesianToCartographic(u,E),I),U=y.scaleToGeodeticSurface(u,d);y.geodeticSurfaceNormal(U,U);const Q=e.Quaternion.fromAxisAngle(U,N,_),W=r.Matrix3.fromQuaternion(Q,g),q=r.Cartesian2.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,T),J=r.Cartesian2.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,G);let Z=t.length;const K=Z/3*2;for(let e=0;e<Z;e+=3){const i=e+1,n=e+2;let o,s=r.Cartesian3.fromArray(t,e,d);if(a.st){const t=r.Matrix3.multiplyByVector(W,s,f),e=Y.project(y.cartesianToCartographic(t,E),h);r.Cartesian3.subtract(e,H,e),x.x=(e.x+c)/(2*c),x.y=(e.y+p)/(2*p),q.x=Math.min(x.x,q.x),q.y=Math.min(x.y,q.y),J.x=Math.max(x.x,J.x),J.y=Math.max(x.y,J.y),D[j+K]=x.x,D[j+1+K]=x.y,D[j++]=x.x,D[j++]=x.y}s=y.scaleToGeodeticSurface(s,s),o=r.Cartesian3.clone(s,f),k=y.geodeticSurfaceNormal(s,k),L&&(R[e+Z]=-k.x,R[i+Z]=-k.y,R[n+Z]=-k.z);let l=r.Cartesian3.multiplyByScalar(k,b,A);if(s=r.Cartesian3.add(s,l,s),l=r.Cartesian3.multiplyByScalar(k,v,l),o=r.Cartesian3.add(o,l,o),a.position&&(V[e+Z]=o.x,V[i+Z]=o.y,V[n+Z]=o.z,V[e]=s.x,V[i]=s.y,V[n]=s.z),a.normal||a.tangent||a.bitangent){B=r.Cartesian3.clone(k,B);const l=r.Cartesian3.fromArray(t,(e+3)%Z,A);r.Cartesian3.subtract(l,s,l);const u=r.Cartesian3.subtract(o,s,h);k=r.Cartesian3.normalize(r.Cartesian3.cross(u,l,k),k),a.normal&&(F[e]=k.x,F[i]=k.y,F[n]=k.z,F[e+Z]=k.x,F[i+Z]=k.y,F[n+Z]=k.z),a.tangent&&(z=r.Cartesian3.normalize(r.Cartesian3.cross(B,k,z),z),O[e]=z.x,O[i]=z.y,O[n]=z.z,O[e+Z]=z.x,O[e+1+Z]=z.y,O[e+2+Z]=z.z),a.bitangent&&(S[e]=B.x,S[i]=B.y,S[n]=B.z,S[e+Z]=B.x,S[i+Z]=B.y,S[n+Z]=B.z)}}if(a.st){Z=D.length;for(let t=0;t<Z;t+=2)D[t]=(D[t]-q.x)/(J.x-q.x),D[t+1]=(D[t+1]-q.y)/(J.y-q.y)}const X=new l.GeometryAttributes;if(a.position&&(X.position=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:V})),a.st&&(X.st=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:D})),a.normal&&(X.normal=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:F})),a.tangent&&(X.tangent=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:O})),a.bitangent&&(X.bitangent=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:S})),L&&(X.extrudeDirection=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:R})),o.defined(i.offsetAttribute)){let t=new Uint8Array(P);if(i.offsetAttribute===m.GeometryOffsetAttribute.TOP)t=t.fill(1,0,P/2);else{const e=i.offsetAttribute===m.GeometryOffsetAttribute.NONE?0:1;t=t.fill(e)}X.applyOffset=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:t})}return X}function F(t){const e=t.length/3,r=p.IndexDatatype.createTypedArray(e,6*e);let i=0;for(let n=0;n<e;n++){const t=n,o=n+e,a=(t+1)%e,s=a+e;r[i++]=t,r[i++]=o,r[i++]=a,r[i++]=a,r[i++]=o,r[i++]=s}return r}const O=new e.BoundingSphere,S=new e.BoundingSphere;function L(t){const i=t.center,n=t.ellipsoid,o=t.semiMajorAxis;let l=r.Cartesian3.multiplyByScalar(n.geodeticSurfaceNormal(i,d),t.height,d);O.center=r.Cartesian3.add(i,l,O.center),O.radius=o,l=r.Cartesian3.multiplyByScalar(n.geodeticSurfaceNormal(i,l),t.extrudedHeight,l),S.center=r.Cartesian3.add(i,l,S.center),S.radius=o;const m=a.EllipseGeometryLibrary.computeEllipsePositions(t,!0,!0),y=m.positions,f=m.numPts,h=m.outerPositions,A=e.BoundingSphere.union(O,S),x=v(y,t,!0);let g=N(f);const b=g.length;g.length=2*b;const _=y.length/3;for(let e=0;e<b;e+=3)g[e+b]=g[e+2]+_,g[e+1+b]=g[e+1]+_,g[e+2+b]=g[e]+_;const C=p.IndexDatatype.createTypedArray(2*_/3,g),w=new s.Geometry({attributes:x,indices:C,primitiveType:s.PrimitiveType.TRIANGLES}),M=D(h,t);g=F(h);const E=p.IndexDatatype.createTypedArray(2*h.length/3,g),I=new s.Geometry({attributes:M,indices:E,primitiveType:s.PrimitiveType.TRIANGLES}),T=c.GeometryPipeline.combineInstances([new u.GeometryInstance({geometry:w}),new u.GeometryInstance({geometry:I})]);return{boundingSphere:A,attributes:T[0].attributes,indices:T[0].indices}}function R(t,e,i,o,s,l,u){const m=a.EllipseGeometryLibrary.computeEllipsePositions({center:t,semiMajorAxis:e,semiMinorAxis:i,rotation:o,granularity:s},!1,!0).outerPositions,c=m.length/3,p=new Array(c);for(let n=0;n<c;++n)p[n]=r.Cartesian3.fromArray(m,3*n);const y=r.Rectangle.fromCartesianArray(p,l,u);return y.width>n.CesiumMath.PI&&(y.north=y.north>0?n.CesiumMath.PI_OVER_TWO-n.CesiumMath.EPSILON7:y.north,y.south=y.south<0?n.CesiumMath.EPSILON7-n.CesiumMath.PI_OVER_TWO:y.south,y.east=n.CesiumMath.PI,y.west=-n.CesiumMath.PI),y}function j(t){t=o.defaultValue(t,o.defaultValue.EMPTY_OBJECT);const e=t.center,a=o.defaultValue(t.ellipsoid,r.Ellipsoid.WGS84),s=t.semiMajorAxis,l=t.semiMinorAxis,u=o.defaultValue(t.granularity,n.CesiumMath.RADIANS_PER_DEGREE),m=o.defaultValue(t.vertexFormat,y.VertexFormat.DEFAULT);if(i.Check.defined("options.center",e),i.Check.typeOf.number("options.semiMajorAxis",s),i.Check.typeOf.number("options.semiMinorAxis",l),s<l)throw new i.DeveloperError("semiMajorAxis must be greater than or equal to the semiMinorAxis.");if(u<=0)throw new i.DeveloperError("granularity must be greater than zero.");const c=o.defaultValue(t.height,0),p=o.defaultValue(t.extrudedHeight,c);this._center=r.Cartesian3.clone(e),this._semiMajorAxis=s,this._semiMinorAxis=l,this._ellipsoid=r.Ellipsoid.clone(a),this._rotation=o.defaultValue(t.rotation,0),this._stRotation=o.defaultValue(t.stRotation,0),this._height=Math.max(p,c),this._granularity=u,this._vertexFormat=y.VertexFormat.clone(m),this._extrudedHeight=Math.min(p,c),this._shadowVolume=o.defaultValue(t.shadowVolume,!1),this._workerName="createEllipseGeometry",this._offsetAttribute=t.offsetAttribute,this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0}j.packedLength=r.Cartesian3.packedLength+r.Ellipsoid.packedLength+y.VertexFormat.packedLength+9,j.pack=function(t,e,n){return i.Check.defined("value",t),i.Check.defined("array",e),n=o.defaultValue(n,0),r.Cartesian3.pack(t._center,e,n),n+=r.Cartesian3.packedLength,r.Ellipsoid.pack(t._ellipsoid,e,n),n+=r.Ellipsoid.packedLength,y.VertexFormat.pack(t._vertexFormat,e,n),n+=y.VertexFormat.packedLength,e[n++]=t._semiMajorAxis,e[n++]=t._semiMinorAxis,e[n++]=t._rotation,e[n++]=t._stRotation,e[n++]=t._height,e[n++]=t._granularity,e[n++]=t._extrudedHeight,e[n++]=t._shadowVolume?1:0,e[n]=o.defaultValue(t._offsetAttribute,-1),e};const k=new r.Cartesian3,z=new r.Ellipsoid,B=new y.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};function H(t){const e=-t._stRotation;if(0===e)return[0,0,0,1,1,0];const i=a.EllipseGeometryLibrary.computeEllipsePositions({center:t._center,semiMajorAxis:t._semiMajorAxis,semiMinorAxis:t._semiMinorAxis,rotation:t._rotation,granularity:t._granularity},!1,!0).outerPositions,n=i.length/3,o=new Array(n);for(let a=0;a<n;++a)o[a]=r.Cartesian3.fromArray(i,3*a);const l=t._ellipsoid,u=t.rectangle;return s.Geometry._textureCoordinateRotationPoints(o,e,l,u)}j.unpack=function(t,e,n){i.Check.defined("array",t),e=o.defaultValue(e,0);const a=r.Cartesian3.unpack(t,e,k);e+=r.Cartesian3.packedLength;const s=r.Ellipsoid.unpack(t,e,z);e+=r.Ellipsoid.packedLength;const l=y.VertexFormat.unpack(t,e,B);e+=y.VertexFormat.packedLength;const u=t[e++],m=t[e++],c=t[e++],p=t[e++],d=t[e++],f=t[e++],h=t[e++],A=1===t[e++],x=t[e];return o.defined(n)?(n._center=r.Cartesian3.clone(a,n._center),n._ellipsoid=r.Ellipsoid.clone(s,n._ellipsoid),n._vertexFormat=y.VertexFormat.clone(l,n._vertexFormat),n._semiMajorAxis=u,n._semiMinorAxis=m,n._rotation=c,n._stRotation=p,n._height=d,n._granularity=f,n._extrudedHeight=h,n._shadowVolume=A,n._offsetAttribute=-1===x?void 0:x,n):(Y.height=d,Y.extrudedHeight=h,Y.granularity=f,Y.stRotation=p,Y.rotation=c,Y.semiMajorAxis=u,Y.semiMinorAxis=m,Y.shadowVolume=A,Y.offsetAttribute=-1===x?void 0:x,new j(Y))},j.computeRectangle=function(t,e){t=o.defaultValue(t,o.defaultValue.EMPTY_OBJECT);const a=t.center,s=o.defaultValue(t.ellipsoid,r.Ellipsoid.WGS84),l=t.semiMajorAxis,u=t.semiMinorAxis,m=o.defaultValue(t.granularity,n.CesiumMath.RADIANS_PER_DEGREE),c=o.defaultValue(t.rotation,0);if(i.Check.defined("options.center",a),i.Check.typeOf.number("options.semiMajorAxis",l),i.Check.typeOf.number("options.semiMinorAxis",u),l<u)throw new i.DeveloperError("semiMajorAxis must be greater than or equal to the semiMinorAxis.");if(m<=0)throw new i.DeveloperError("granularity must be greater than zero.");return R(a,l,u,c,m,s,e)},j.createGeometry=function(t){if(t._semiMajorAxis<=0||t._semiMinorAxis<=0)return;const e=t._height,r=t._extrudedHeight,i=!n.CesiumMath.equalsEpsilon(e,r,0,n.CesiumMath.EPSILON2);t._center=t._ellipsoid.scaleToGeodeticSurface(t._center,t._center);const a={center:t._center,semiMajorAxis:t._semiMajorAxis,semiMinorAxis:t._semiMinorAxis,ellipsoid:t._ellipsoid,rotation:t._rotation,height:e,granularity:t._granularity,vertexFormat:t._vertexFormat,stRotation:t._stRotation};let l;if(i)a.extrudedHeight=r,a.shadowVolume=t._shadowVolume,a.offsetAttribute=t._offsetAttribute,l=L(a);else if(l=V(a),o.defined(t._offsetAttribute)){const e=l.attributes.position.values.length,r=t._offsetAttribute===m.GeometryOffsetAttribute.NONE?0:1,i=new Uint8Array(e/3).fill(r);l.attributes.applyOffset=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:i})}return new s.Geometry({attributes:l.attributes,indices:l.indices,primitiveType:s.PrimitiveType.TRIANGLES,boundingSphere:l.boundingSphere,offsetAttribute:t._offsetAttribute})},j.createShadowVolume=function(t,e,r){const i=t._granularity,n=t._ellipsoid,o=e(i,n),a=r(i,n);return new j({center:t._center,semiMajorAxis:t._semiMajorAxis,semiMinorAxis:t._semiMinorAxis,ellipsoid:n,rotation:t._rotation,stRotation:t._stRotation,granularity:i,extrudedHeight:o,height:a,vertexFormat:y.VertexFormat.POSITION_ONLY,shadowVolume:!0})},Object.defineProperties(j.prototype,{rectangle:{get:function(){return o.defined(this._rectangle)||(this._rectangle=R(this._center,this._semiMajorAxis,this._semiMinorAxis,this._rotation,this._granularity,this._ellipsoid)),this._rectangle}},textureCoordinateRotationPoints:{get:function(){return o.defined(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=H(this)),this._textureCoordinateRotationPoints}}}),t.EllipseGeometry=j}));