import{a as N}from"./chunk-7635WVJB.js";import{d as Z}from"./chunk-CLGTNV2A.js";import{b as d,h as U}from"./chunk-RQCJJCAO.js";import{a as D}from"./chunk-7J4RJR4J.js";import{b as a,c as j,d as x,e as b}from"./chunk-UMC5CP2H.js";import{a as E}from"./chunk-72V3KRTJ.js";import{a as R,b as T}from"./chunk-VJ26MOOM.js";import{e as h}from"./chunk-E3YQ3WWZ.js";function z(o,t){T.typeOf.object("ellipsoid",o),this._ellipsoid=o,this._cameraPosition=new a,this._cameraPositionInScaledSpace=new a,this._distanceToLimbInScaledSpaceSquared=0,h(t)&&(this.cameraPosition=t)}Object.defineProperties(z.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},cameraPosition:{get:function(){return this._cameraPosition},set:function(o){let e=this._ellipsoid.transformPositionToScaledSpace(o,this._cameraPositionInScaledSpace),n=a.magnitudeSquared(e)-1;a.clone(o,this._cameraPosition),this._cameraPositionInScaledSpace=e,this._distanceToLimbInScaledSpaceSquared=n}}});var Q=new a;z.prototype.isPointVisible=function(o){let e=this._ellipsoid.transformPositionToScaledSpace(o,Q);return F(e,this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)};z.prototype.isScaledSpacePointVisible=function(o){return F(o,this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)};var nt=new a;z.prototype.isScaledSpacePointVisiblePossiblyUnderEllipsoid=function(o,t){let e=this._ellipsoid,n,i;return h(t)&&t<0&&e.minimumRadius>-t?(i=nt,i.x=this._cameraPosition.x/(e.radii.x+t),i.y=this._cameraPosition.y/(e.radii.y+t),i.z=this._cameraPosition.z/(e.radii.z+t),n=i.x*i.x+i.y*i.y+i.z*i.z-1):(i=this._cameraPositionInScaledSpace,n=this._distanceToLimbInScaledSpaceSquared),F(o,i,n)};z.prototype.computeHorizonCullingPoint=function(o,t,e){return K(this._ellipsoid,o,t,e)};var v=b.clone(b.UNIT_SPHERE);z.prototype.computeHorizonCullingPointPossiblyUnderEllipsoid=function(o,t,e,n){let i=J(this._ellipsoid,e,v);return K(i,o,t,n)};z.prototype.computeHorizonCullingPointFromVertices=function(o,t,e,n,i){return X(this._ellipsoid,o,t,e,n,i)};z.prototype.computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid=function(o,t,e,n,i,c){let s=J(this._ellipsoid,i,v);return X(s,o,t,e,n,c)};var st=[];z.prototype.computeHorizonCullingPointFromRectangle=function(o,t,e){T.typeOf.object("rectangle",o);let n=U.subsample(o,t,0,st),i=Z.fromPoints(n);if(!(a.magnitude(i.center)<.1*t.minimumRadius))return this.computeHorizonCullingPoint(i.center,n,e)};var at=new a;function J(o,t,e){if(h(t)&&t<0&&o.minimumRadius>-t){let n=a.fromElements(o.radii.x+t,o.radii.y+t,o.radii.z+t,at);o=b.fromCartesian3(n,e)}return o}function K(o,t,e,n){T.typeOf.object("directionToPoint",t),T.defined("positions",e),h(n)||(n=new a);let i=B(o,t),c=0;for(let s=0,r=e.length;s<r;++s){let m=e[s],p=Y(o,m,i);if(p<0)return;c=Math.max(c,p)}return $(i,c,n)}var O=new a;function X(o,t,e,n,i,c){T.typeOf.object("directionToPoint",t),T.defined("vertices",e),T.typeOf.number("stride",n),h(c)||(c=new a),n=n??3,i=i??a.ZERO;let s=B(o,t),r=0;for(let m=0,p=e.length;m<p;m+=n){O.x=e[m]+i.x,O.y=e[m+1]+i.y,O.z=e[m+2]+i.z;let u=Y(o,O,s);if(u<0)return;r=Math.max(r,u)}return $(s,r,c)}function F(o,t,e){let n=t,i=e,c=a.subtract(o,n,Q),s=-a.dot(c,n);return!(i<0?s>0:s>i&&s*s/a.magnitudeSquared(c)>i)}var ct=new a,rt=new a;function Y(o,t,e){let n=o.transformPositionToScaledSpace(t,ct),i=a.magnitudeSquared(n),c=Math.sqrt(i),s=a.divideByScalar(n,c,rt);i=Math.max(1,i),c=Math.max(1,c);let r=a.dot(s,e),m=a.magnitude(a.cross(s,e,s)),p=1/c,u=Math.sqrt(i-1)*p;return 1/(r*p-m*u)}function $(o,t,e){if(!(t<=0||t===1/0||t!==t))return a.multiplyByScalar(o,t,e)}var k=new a;function B(o,t){return a.equals(t,a.ZERO)?t:(o.transformPositionToScaledSpace(t,k),a.normalize(k,k))}var xt=z;var G={};G.getHeight=function(o,t,e){if(!Number.isFinite(t))throw new R("scale must be a finite number.");if(!Number.isFinite(e))throw new R("relativeHeight must be a finite number.");return(o-e)*t+e};var mt=new j;G.getPosition=function(o,t,e,n,i){let c=t.cartesianToCartographic(o,mt);if(!h(c))return a.clone(o,i);let s=G.getHeight(c.height,e,n);return a.fromRadians(c.longitude,c.latitude,s,t,i)};var tt=G;var dt={NONE:0,BITS12:1},S=Object.freeze(dt);var _=new a,ht=new a,f=new x,H=new d,lt=new d,pt=Math.pow(2,12);function l(o,t,e,n,i,c,s,r,m,p){let u=S.NONE,y,g;if(h(t)&&h(e)&&h(n)&&h(i)){let C=t.minimum,V=t.maximum,P=a.subtract(V,C,ht),I=n-e;Math.max(a.maximumComponent(P),I)<pt-1?u=S.BITS12:u=S.NONE,y=d.inverseTransformation(i,new d);let A=a.negate(C,_);d.multiply(d.fromTranslation(A,H),y,y);let M=_;M.x=1/P.x,M.y=1/P.y,M.z=1/P.z,d.multiply(d.fromScale(M,H),y,y),g=d.clone(i),d.setTranslation(g,a.ZERO,g),i=d.clone(i,new d);let et=d.fromTranslation(C,H),it=d.fromScale(P,lt),L=d.multiply(et,it,H);d.multiply(i,L,i),d.multiply(g,L,g)}this.quantization=u,this.minimumHeight=e,this.maximumHeight=n,this.center=a.clone(o),this.toScaledENU=y,this.fromScaledENU=i,this.matrix=g,this.hasVertexNormals=c,this.hasWebMercatorT=s??!1,this.hasGeodeticSurfaceNormals=r??!1,this.exaggeration=m??1,this.exaggerationRelativeHeight=p??0,this.stride=0,this._offsetGeodeticSurfaceNormal=0,this._offsetVertexNormal=0,this._calculateStrideAndOffsets()}l.prototype.encode=function(o,t,e,n,i,c,s,r,m,p,u){let y=n.x,g=n.y;if(this.quantization===S.BITS12){e=d.multiplyByPoint(this.toScaledENU,e,_),e.x=E.clamp(e.x,0,1),e.y=E.clamp(e.y,0,1),e.z=E.clamp(e.z,0,1);let C=this.maximumHeight-this.minimumHeight,V=E.clamp((i-this.minimumHeight)/C,0,1);x.fromElements(e.x,e.y,f);let P=N.compressTextureCoordinates(f);x.fromElements(e.z,V,f);let I=N.compressTextureCoordinates(f);x.fromElements(y,g,f);let W=N.compressTextureCoordinates(f);if(o[t++]=P,o[t++]=I,o[t++]=W,this.hasWebMercatorT){x.fromElements(s,0,f);let A=N.compressTextureCoordinates(f);o[t++]=A}}else a.subtract(e,this.center,_),o[t++]=_.x,o[t++]=_.y,o[t++]=_.z,o[t++]=i,o[t++]=y,o[t++]=g,this.hasWebMercatorT&&(o[t++]=s);return this.hasVertexNormals&&(m?o[t++]=c:(p&&(c.x=123.456,c.y=123.456),o[t++]=N.octPackFloat(c))),this.hasGeodeticSurfaceNormals&&(o[t++]=r.x,o[t++]=r.y,o[t++]=r.z),o[t++]=u,t};var ut=new a,ot=new a;l.prototype.addGeodeticSurfaceNormals=function(o,t,e){if(this.hasGeodeticSurfaceNormals)return;let n=this.stride,i=o.length/n;this.hasGeodeticSurfaceNormals=!0,this._calculateStrideAndOffsets();let c=this.stride;for(let s=0;s<i;s++){for(let u=0;u<n;u++){let y=s*n+u,g=s*c+u;t[g]=o[y]}let r=this.decodePosition(t,s,ut),m=e.geodeticSurfaceNormal(r,ot),p=s*c+this._offsetGeodeticSurfaceNormal;t[p]=m.x,t[p+1]=m.y,t[p+2]=m.z}};l.prototype.removeGeodeticSurfaceNormals=function(o,t){if(!this.hasGeodeticSurfaceNormals)return;let e=this.stride,n=o.length/e;this.hasGeodeticSurfaceNormals=!1,this._calculateStrideAndOffsets();let i=this.stride;for(let c=0;c<n;c++)for(let s=0;s<i;s++){let r=c*e+s,m=c*i+s;t[m]=o[r]}};l.prototype.decodePosition=function(o,t,e){if(h(e)||(e=new a),t*=this.stride,this.quantization===S.BITS12){let n=N.decompressTextureCoordinates(o[t],f);e.x=n.x,e.y=n.y;let i=N.decompressTextureCoordinates(o[t+1],f);return e.z=i.x,d.multiplyByPoint(this.fromScaledENU,e,e)}return e.x=o[t],e.y=o[t+1],e.z=o[t+2],a.add(e,this.center,e)};l.prototype.getExaggeratedPosition=function(o,t,e){e=this.decodePosition(o,t,e);let n=this.exaggeration,i=this.exaggerationRelativeHeight;if(n!==1&&this.hasGeodeticSurfaceNormals){let s=this.decodeGeodeticSurfaceNormal(o,t,ot),r=this.decodeHeight(o,t),m=tt.getHeight(r,n,i)-r;e.x+=s.x*m,e.y+=s.y*m,e.z+=s.z*m}return e};l.prototype.decodeTextureCoordinates=function(o,t,e){return h(e)||(e=new x),t*=this.stride,this.quantization===S.BITS12?N.decompressTextureCoordinates(o[t+2],e):x.fromElements(o[t+4],o[t+5],e)};l.prototype.decodeHeight=function(o,t){return t*=this.stride,this.quantization===S.BITS12?N.decompressTextureCoordinates(o[t+1],f).y*(this.maximumHeight-this.minimumHeight)+this.minimumHeight:o[t+3]};l.prototype.decodeWebMercatorT=function(o,t){return t*=this.stride,this.quantization===S.BITS12?N.decompressTextureCoordinates(o[t+3],f).x:o[t+6]};l.prototype.getOctEncodedNormal=function(o,t,e){t=t*this.stride+this._offsetVertexNormal;let n=o[t]/256,i=Math.floor(n),c=(n-i)*256;return x.fromElements(i,c,e)};l.prototype.decodeGeodeticSurfaceNormal=function(o,t,e){return t=t*this.stride+this._offsetGeodeticSurfaceNormal,e.x=o[t],e.y=o[t+1],e.z=o[t+2],e};l.prototype._calculateStrideAndOffsets=function(){let o=0;switch(this.quantization){case S.BITS12:o+=3;break;default:o+=6}this.hasWebMercatorT&&(o+=1),this.hasVertexNormals&&(this._offsetVertexNormal=o,o+=1),this.hasGeodeticSurfaceNormals&&(this._offsetGeodeticSurfaceNormal=o,o+=3),o+=1,this.stride=o};var w={position3DAndHeight:0,textureCoordAndEncodedNormals:1,geodeticSurfaceNormal:2,skirt:3},q={compressed0:0,compressed1:1,geodeticSurfaceNormal:2,skirt:3};l.prototype.getAttributes=function(o){let t=D.FLOAT,e=D.getSizeInBytes(t),n=this.stride*e,i=0,c=[];function s(r,m){c.push({index:r,vertexBuffer:o,componentDatatype:t,componentsPerAttribute:m,offsetInBytes:i,strideInBytes:n}),i+=m*e}if(this.quantization===S.NONE){s(w.position3DAndHeight,4);let r=2;r+=this.hasWebMercatorT?1:0,r+=this.hasVertexNormals?1:0,s(w.textureCoordAndEncodedNormals,r),this.hasGeodeticSurfaceNormals&&s(w.geodeticSurfaceNormal,3),s(w.skirt,1)}else{let r=this.hasWebMercatorT||this.hasVertexNormals,m=this.hasWebMercatorT&&this.hasVertexNormals;s(q.compressed0,r?4:3),m&&s(q.compressed1,1),this.hasGeodeticSurfaceNormals&&s(q.geodeticSurfaceNormal,3),s(q.skirt,1)}return c};l.prototype.getAttributeLocations=function(){return this.quantization===S.NONE?w:q};l.clone=function(o,t){if(h(o))return h(t)||(t=new l),t.quantization=o.quantization,t.minimumHeight=o.minimumHeight,t.maximumHeight=o.maximumHeight,t.center=a.clone(o.center),t.toScaledENU=d.clone(o.toScaledENU),t.fromScaledENU=d.clone(o.fromScaledENU),t.matrix=d.clone(o.matrix),t.hasVertexNormals=o.hasVertexNormals,t.hasWebMercatorT=o.hasWebMercatorT,t.hasGeodeticSurfaceNormals=o.hasGeodeticSurfaceNormals,t.exaggeration=o.exaggeration,t.exaggerationRelativeHeight=o.exaggerationRelativeHeight,t._calculateStrideAndOffsets(),t};var Dt=l;export{xt as a,Dt as b};
|