/** * @license * Cesium - https://github.com/CesiumGS/cesium * Version 1.109.1 * * 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. */ import{a as _t}from"./chunk-V24F56N4.js";import{a as D}from"./chunk-3FJ6KZYW.js";import{a as K}from"./chunk-7CAA5V4E.js";import{a as nt}from"./chunk-7GLIBSMD.js";import{a as yt}from"./chunk-DB2DGJAQ.js";import"./chunk-YRDOGW7W.js";import"./chunk-SMROTTNJ.js";import{a as mt}from"./chunk-IAIDZHSR.js";import{a as at}from"./chunk-DFHMTLCD.js";import{a as z}from"./chunk-JEAHRXD5.js";import{a as ct}from"./chunk-GTVOTRDF.js";import"./chunk-UGOEDKTL.js";import{a as ft,b as tt}from"./chunk-ZODPEIAS.js";import"./chunk-5CQT33QV.js";import"./chunk-YPLRJVJ5.js";import"./chunk-XZQSRYDQ.js";import"./chunk-MPWN7KNI.js";import{a as st}from"./chunk-BBX2BII7.js";import"./chunk-BZJ4WRF6.js";import{c as ut,d as q}from"./chunk-ESC6A27A.js";import{d as dt,f as rt}from"./chunk-FCJU2DRX.js";import"./chunk-JDODZPYM.js";import{c as ht,d as X}from"./chunk-Y3I2OBKV.js";import{a as Q}from"./chunk-KUWODMWG.js";import{a as u,b as $,c as V,d as k}from"./chunk-WADCMYQO.js";import{a as B}from"./chunk-2LQD2HPA.js";import"./chunk-YWFM6JRF.js";import"./chunk-P2U2ARL5.js";import{a as w}from"./chunk-3B6S2GOO.js";import{a as it,b as Y}from"./chunk-EYEHMX6X.js";import{e as A}from"./chunk-BWKFPVR5.js";var Ht=new $,Pt=new $;function Et(t,e,o,r){let i=r.cartesianToCartographic(t,Ht).height,n=r.cartesianToCartographic(e,Pt);n.height=i,r.cartographicToCartesian(n,e);let a=r.cartesianToCartographic(o,Pt);a.height=i-100,r.cartographicToCartesian(a,o)}var Ot=new _t,xt=new u,Ct=new u,Rt=new u,Nt=new u,vt=new u,Dt=new u,lt=new u,j=new u,et=new u,Ft=new X,It=new X,Lt=new u,bt=new rt,St=new k,Bt=new k;function pt(t){let e=t.vertexFormat,o=t.geometry,r=t.shadowVolume,i=o.attributes.position.values,n=A(o.attributes.st)?o.attributes.st.values:void 0,a=i.length,s=t.wall,l=t.top||s,c=t.bottom||s;if(e.st||e.normal||e.tangent||e.bitangent||r){let p=t.boundingRectangle,h=t.tangentPlane,m=t.ellipsoid,g=t.stRotation,y=t.perPositionHeight,d=Ft;d.x=p.x,d.y=p.y;let f,w=e.st?new Float32Array(a/3*2):void 0;e.normal&&(f=y&&l&&!s?o.attributes.normal.values:new Float32Array(a));let _=e.tangent?new Float32Array(a):void 0,b=e.bitangent?new Float32Array(a):void 0,T=r?new Float32Array(a):void 0,I=0,v=0,P=Ct,D=Rt,x=Nt,O=!0,E=St,H=Bt;if(0!==g){let t=rt.fromAxisAngle(h._plane.normal,g,bt);E=k.fromQuaternion(t,E),t=rt.fromAxisAngle(h._plane.normal,-g,bt),H=k.fromQuaternion(t,H)}else E=k.clone(k.IDENTITY,E),H=k.clone(k.IDENTITY,H);let N=0,R=0;l&&c&&(N=a/2,R=a/3,a/=2);for(let o=0;o<a;o+=3){let g=u.fromArray(i,o,Lt);if(e.st&&!A(n)){let t=k.multiplyByVector(E,g,xt);t=m.scaleToGeodeticSurface(t,t);let e=h.projectPointOntoPlane(t,It);X.subtract(e,d,e);let o=B.clamp(e.x/p.width,0,1),r=B.clamp(e.y/p.height,0,1);c&&(w[I+R]=o,w[I+1+R]=r),l&&(w[I]=o,w[I+1]=r),I+=2}if(e.normal||e.tangent||e.bitangent||r){let n=v+1,p=v+2;if(s){if(o+3<a){let t=u.fromArray(i,o+3,vt);if(O){let e=u.fromArray(i,o+a,Dt);y&&Et(g,t,e,m),u.subtract(t,g,t),u.subtract(e,g,e),P=u.normalize(u.cross(e,t,P),P),O=!1}u.equalsEpsilon(t,g,B.EPSILON10)&&(O=!0)}(e.tangent||e.bitangent)&&(x=m.geodeticSurfaceNormal(g,x),e.tangent&&(D=u.normalize(u.cross(x,P,D),D)))}else P=m.geodeticSurfaceNormal(g,P),(e.tangent||e.bitangent)&&(y&&(lt=u.fromArray(f,v,lt),j=u.cross(u.UNIT_Z,lt,j),j=u.normalize(k.multiplyByVector(H,j,j),j),e.bitangent&&(et=u.normalize(u.cross(lt,j,et),et))),D=u.cross(u.UNIT_Z,P,D),D=u.normalize(k.multiplyByVector(H,D,D),D),e.bitangent&&(x=u.normalize(u.cross(P,D,x),x)));e.normal&&(t.wall?(f[v+N]=P.x,f[n+N]=P.y,f[p+N]=P.z):c&&(f[v+N]=-P.x,f[n+N]=-P.y,f[p+N]=-P.z),(l&&!y||s)&&(f[v]=P.x,f[n]=P.y,f[p]=P.z)),r&&(s&&(P=m.geodeticSurfaceNormal(g,P)),T[v+N]=-P.x,T[n+N]=-P.y,T[p+N]=-P.z),e.tangent&&(t.wall?(_[v+N]=D.x,_[n+N]=D.y,_[p+N]=D.z):c&&(_[v+N]=-D.x,_[n+N]=-D.y,_[p+N]=-D.z),l&&(y?(_[v]=j.x,_[n]=j.y,_[p]=j.z):(_[v]=D.x,_[n]=D.y,_[p]=D.z))),e.bitangent&&(c&&(b[v+N]=x.x,b[n+N]=x.y,b[p+N]=x.z),l&&(y?(b[v]=et.x,b[n]=et.y,b[p]=et.z):(b[v]=x.x,b[n]=x.y,b[p]=x.z))),v+=3}}e.st&&!A(n)&&(o.attributes.st=new q({componentDatatype:Q.FLOAT,componentsPerAttribute:2,values:w})),e.normal&&(o.attributes.normal=new q({componentDatatype:Q.FLOAT,componentsPerAttribute:3,values:f})),e.tangent&&(o.attributes.tangent=new q({componentDatatype:Q.FLOAT,componentsPerAttribute:3,values:_})),e.bitangent&&(o.attributes.bitangent=new q({componentDatatype:Q.FLOAT,componentsPerAttribute:3,values:b})),r&&(o.attributes.extrudeDirection=new q({componentDatatype:Q.FLOAT,componentsPerAttribute:3,values:T}))}if(t.extrude&&A(t.offsetAttribute)){let e=i.length/3,r=new Uint8Array(e);if(t.offsetAttribute===at.TOP)l&&c||s?r=r.fill(1,0,e/2):l&&(r=r.fill(1));else{let e=t.offsetAttribute===at.NONE?0:1;r=r.fill(e)}o.attributes.applyOffset=new q({componentDatatype:Q.UNSIGNED_BYTE,componentsPerAttribute:1,values:r})}return o}var Vt=new $,kt=new $,Z={westOverIDL:0,eastOverIDL:0},ot=new mt;function At(t,e,o,r,i){if(i=w(i,new ht),!A(t)||t.length<3)return i.west=0,i.north=0,i.south=0,i.east=0,i;if(o===K.RHUMB)return ht.fromCartesianArray(t,e,i);ot.ellipsoid.equals(e)||(ot=new mt(void 0,void 0,e)),i.west=Number.POSITIVE_INFINITY,i.east=Number.NEGATIVE_INFINITY,i.south=Number.POSITIVE_INFINITY,i.north=Number.NEGATIVE_INFINITY,Z.westOverIDL=Number.POSITIVE_INFINITY,Z.eastOverIDL=Number.NEGATIVE_INFINITY;let n,a=1/B.chordLength(r,e.maximumRadius),s=t.length,l=e.cartesianToCartographic(t[0],kt),u=Vt;for(let c=1;c<s;c++)n=u,u=l,l=e.cartesianToCartographic(t[c],n),ot.setEndPoints(u,l),wt(ot,a,i,Z);return n=u,u=l,l=e.cartesianToCartographic(t[0],n),ot.setEndPoints(u,l),wt(ot,a,i,Z),i.east-i.west>Z.eastOverIDL-Z.westOverIDL&&(i.west=Z.westOverIDL,i.east=Z.eastOverIDL,i.east>B.PI&&(i.east=i.east-B.TWO_PI),i.west>B.PI&&(i.west=i.west-B.TWO_PI)),i}var Mt=new $;function wt(t,e,o,r){let i=t.surfaceDistance,n=Math.ceil(i*e),a=n>0?i/(n-1):Number.POSITIVE_INFINITY,s=0;for(let l=0;l<n;l++){let e=t.interpolateUsingSurfaceDistance(s,Mt);s+=a;let i=e.longitude,n=e.latitude;o.west=Math.min(o.west,i),o.east=Math.max(o.east,i),o.south=Math.min(o.south,n),o.north=Math.max(o.north,n);let l=i>=0?i:i+B.TWO_PI;r.westOverIDL=Math.min(r.westOverIDL,l),r.eastOverIDL=Math.max(r.eastOverIDL,l)}}var Tt=[];function zt(t,e,o,r,i,n,a,s,l,u){let c,p={walls:[]};if(a||s){let i,h,m=D.createGeometryFromPositions(t,e,o,r,n,l,u),g=m.attributes.position.values,y=m.indices;if(a&&s){let t=g.concat(g);i=t.length/3,h=st.createTypedArray(i,2*y.length),h.set(y);let e=y.length,r=i/2;for(c=0;c<e;c+=3){let t=h[c]+r,o=h[c+1]+r,i=h[c+2]+r;h[c+e]=i,h[c+1+e]=o,h[c+2+e]=t}if(m.attributes.position.values=t,n&&l.normal){let e=m.attributes.normal.values;m.attributes.normal.values=new Float32Array(t.length),m.attributes.normal.values.set(e)}if(l.st&&A(o)){let t=m.attributes.st.values;m.attributes.st.values=new Float32Array(2*i),m.attributes.st.values=t.concat(t)}m.indices=h}else if(s){for(i=g.length/3,h=st.createTypedArray(i,y.length),c=0;c<y.length;c+=3)h[c]=y[c+2],h[c+1]=y[c+1],h[c+2]=y[c];m.indices=h}p.topAndBottom=new nt({geometry:m})}let h=i.outerRing,m=ct.fromPoints(h,t),g=m.projectPointsOntoPlane(h,Tt),y=tt.computeWindingOrder2D(g);y===ft.CLOCKWISE&&(h=h.slice().reverse());let d=D.computeWallGeometry(h,o,t,r,n,u);p.walls.push(new nt({geometry:d}));let f=i.holes;for(c=0;c<f.length;c++){let e=f[c];m=ct.fromPoints(e,t),g=m.projectPointsOntoPlane(e,Tt),y=tt.computeWindingOrder2D(g),y===ft.COUNTER_CLOCKWISE&&(e=e.slice().reverse()),d=D.computeWallGeometry(e,o,t,r,n,u),p.walls.push(new nt({geometry:d}))}return p}function G(t){if(Y.typeOf.object("options",t),Y.typeOf.object("options.polygonHierarchy",t.polygonHierarchy),A(t.perPositionHeight)&&t.perPositionHeight&&A(t.height))throw new it("Cannot use both options.perPositionHeight and options.height");if(A(t.arcType)&&t.arcType!==K.GEODESIC&&t.arcType!==K.RHUMB)throw new it("Invalid arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB.");let e=t.polygonHierarchy,o=w(t.vertexFormat,z.DEFAULT),r=w(t.ellipsoid,V.WGS84),i=w(t.granularity,B.RADIANS_PER_DEGREE),n=w(t.stRotation,0),a=t.textureCoordinates,s=w(t.perPositionHeight,!1),l=s&&A(t.extrudedHeight),c=w(t.height,0),p=w(t.extrudedHeight,c);if(!l){let t=Math.max(c,p);p=Math.min(c,p),c=t}this._vertexFormat=z.clone(o),this._ellipsoid=V.clone(r),this._granularity=i,this._stRotation=n,this._height=c,this._extrudedHeight=p,this._closeTop=w(t.closeTop,!0),this._closeBottom=w(t.closeBottom,!0),this._polygonHierarchy=e,this._perPositionHeight=s,this._perPositionHeightExtrude=l,this._shadowVolume=w(t.shadowVolume,!1),this._workerName="createPolygonGeometry",this._offsetAttribute=t.offsetAttribute,this._arcType=w(t.arcType,K.GEODESIC),this._rectangle=void 0,this._textureCoordinateRotationPoints=void 0,this._textureCoordinates=a,this.packedLength=D.computeHierarchyPackedLength(e,u)+V.packedLength+z.packedLength+(a?D.computeHierarchyPackedLength(a,X):1)+12}G.fromPositions=function(t){t=w(t,w.EMPTY_OBJECT),Y.defined("options.positions",t.positions);let e={polygonHierarchy:{positions:t.positions},height:t.height,extrudedHeight:t.extrudedHeight,vertexFormat:t.vertexFormat,stRotation:t.stRotation,ellipsoid:t.ellipsoid,granularity:t.granularity,perPositionHeight:t.perPositionHeight,closeTop:t.closeTop,closeBottom:t.closeBottom,offsetAttribute:t.offsetAttribute,arcType:t.arcType,textureCoordinates:t.textureCoordinates};return new G(e)},G.pack=function(t,e,o){return Y.typeOf.object("value",t),Y.defined("array",e),o=w(o,0),o=D.packPolygonHierarchy(t._polygonHierarchy,e,o,u),V.pack(t._ellipsoid,e,o),o+=V.packedLength,z.pack(t._vertexFormat,e,o),o+=z.packedLength,e[o++]=t._height,e[o++]=t._extrudedHeight,e[o++]=t._granularity,e[o++]=t._stRotation,e[o++]=t._perPositionHeightExtrude?1:0,e[o++]=t._perPositionHeight?1:0,e[o++]=t._closeTop?1:0,e[o++]=t._closeBottom?1:0,e[o++]=t._shadowVolume?1:0,e[o++]=w(t._offsetAttribute,-1),e[o++]=t._arcType,A(t._textureCoordinates)?o=D.packPolygonHierarchy(t._textureCoordinates,e,o,X):e[o++]=-1,e[o++]=t.packedLength,e};var Gt=V.clone(V.UNIT_SPHERE),Ut=new z,jt={polygonHierarchy:{}};function Yt(t){let e=-t._stRotation;if(0===e)return[0,0,0,1,1,0];let o=t._ellipsoid,r=t._polygonHierarchy.positions,i=t.rectangle;return ut._textureCoordinateRotationPoints(r,e,o,i)}G.unpack=function(t,e,o){Y.defined("array",t),e=w(e,0);let r=D.unpackPolygonHierarchy(t,e,u);e=r.startingIndex,delete r.startingIndex;let i=V.unpack(t,e,Gt);e+=V.packedLength;let n=z.unpack(t,e,Ut);e+=z.packedLength;let a=t[e++],s=t[e++],l=t[e++],c=t[e++],p=1===t[e++],h=1===t[e++],m=1===t[e++],g=1===t[e++],y=1===t[e++],d=t[e++],f=t[e++],_=-1===t[e]?void 0:D.unpackPolygonHierarchy(t,e,X);A(_)?(e=_.startingIndex,delete _.startingIndex):e++;let b=t[e++];return A(o)||(o=new G(jt)),o._polygonHierarchy=r,o._ellipsoid=V.clone(i,o._ellipsoid),o._vertexFormat=z.clone(n,o._vertexFormat),o._height=a,o._extrudedHeight=s,o._granularity=l,o._stRotation=c,o._perPositionHeightExtrude=p,o._perPositionHeight=h,o._closeTop=m,o._closeBottom=g,o._shadowVolume=y,o._offsetAttribute=-1===d?void 0:d,o._arcType=f,o._textureCoordinates=_,o.packedLength=b,o},G.computeRectangle=function(t,e){Y.typeOf.object("options",t),Y.typeOf.object("options.polygonHierarchy",t.polygonHierarchy);let o=w(t.granularity,B.RADIANS_PER_DEGREE),r=w(t.arcType,K.GEODESIC);if(r!==K.GEODESIC&&r!==K.RHUMB)throw new it("Invalid arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB.");let i=t.polygonHierarchy,n=w(t.ellipsoid,V.WGS84);return At(i.positions,n,r,o,e)},G.createGeometry=function(t){let e=t._vertexFormat,o=t._ellipsoid,r=t._granularity,i=t._stRotation,n=t._polygonHierarchy,a=t._perPositionHeight,s=t._closeTop,l=t._closeBottom,u=t._arcType,c=t._textureCoordinates,p=A(c),h=n.positions;if(h.length<3)return;let m=ct.fromPoints(h,o),g=D.polygonsFromHierarchy(n,p,m.projectPointsOntoPlane.bind(m),!a,o),y=g.hierarchy,d=g.polygons,f=function(t){return t},w=p?D.polygonsFromHierarchy(c,!0,f,!1).polygons:void 0;if(0===y.length)return;h=y[0].outerRing;let _,b=D.computeBoundingRectangle(m.plane.normal,m.projectPointOntoPlane.bind(m),h,i,Ot),T=[],I=t._height,v=t._extrudedHeight,P=t._perPositionHeightExtrude||!B.equalsEpsilon(I,v,0,B.EPSILON2),x={perPositionHeight:a,vertexFormat:e,geometry:void 0,tangentPlane:m,boundingRectangle:b,ellipsoid:o,stRotation:i,textureCoordinates:void 0,bottom:!1,top:!0,wall:!1,extrude:!1,arcType:u};if(P)for(x.extrude=!0,x.top=s,x.bottom=l,x.shadowVolume=t._shadowVolume,x.offsetAttribute=t._offsetAttribute,_=0;_<d.length;_++){let t,i=zt(o,d[_],p?w[_]:void 0,r,y[_],a,s,l,e,u);s&&l?(t=i.topAndBottom,x.geometry=D.scaleToGeodeticHeightExtruded(t.geometry,I,v,o,a)):s?(t=i.topAndBottom,t.geometry.attributes.position.values=tt.scaleToGeodeticHeight(t.geometry.attributes.position.values,I,o,!a),x.geometry=t.geometry):l&&(t=i.topAndBottom,t.geometry.attributes.position.values=tt.scaleToGeodeticHeight(t.geometry.attributes.position.values,v,o,!0),x.geometry=t.geometry),(s||l)&&(x.wall=!1,t.geometry=pt(x),T.push(t));let n=i.walls;x.wall=!0;for(let e=0;e<n.length;e++){let t=n[e];x.geometry=D.scaleToGeodeticHeightExtruded(t.geometry,I,v,o,a),t.geometry=pt(x),T.push(t)}}else for(_=0;_<d.length;_++){let i=new nt({geometry:D.createGeometryFromPositions(o,d[_],p?w[_]:void 0,r,a,e,u)});if(i.geometry.attributes.position.values=tt.scaleToGeodeticHeight(i.geometry.attributes.position.values,I,o,!a),x.geometry=i.geometry,i.geometry=pt(x),A(t._offsetAttribute)){let e=i.geometry.attributes.position.values.length,o=t._offsetAttribute===at.NONE?0:1,r=new Uint8Array(e/3).fill(o);i.geometry.attributes.applyOffset=new q({componentDatatype:Q.UNSIGNED_BYTE,componentsPerAttribute:1,values:r})}T.push(i)}let O=yt.combineInstances(T)[0];O.attributes.position.values=new Float64Array(O.attributes.position.values),O.indices=st.createTypedArray(O.attributes.position.values.length/3,O.indices);let E=O.attributes,k=dt.fromVertices(E.position.values);return e.position||delete E.position,new ut({attributes:E,indices:O.indices,primitiveType:O.primitiveType,boundingSphere:k,offsetAttribute:t._offsetAttribute})},G.createShadowVolume=function(t,e,o){let r=t._granularity,i=t._ellipsoid,n=e(r,i),a=o(r,i);return new G({polygonHierarchy:t._polygonHierarchy,ellipsoid:i,stRotation:t._stRotation,granularity:r,perPositionHeight:!1,extrudedHeight:n,height:a,vertexFormat:z.POSITION_ONLY,shadowVolume:!0,arcType:t._arcType})},Object.defineProperties(G.prototype,{rectangle:{get:function(){if(!A(this._rectangle)){let t=this._polygonHierarchy.positions;this._rectangle=At(t,this._ellipsoid,this._arcType,this._granularity)}return this._rectangle}},textureCoordinateRotationPoints:{get:function(){return A(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=Yt(this)),this._textureCoordinateRotationPoints}}});var gt=G;function Wt(t,e){return A(e)&&(t=gt.unpack(t,e)),t._ellipsoid=V.clone(t._ellipsoid),gt.createGeometry(t)}var Ee=Wt;export{Ee as default};