/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{estimateNumberArrayMemory as t}from"../../../../core/memoryEstimations.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{splatPageSizeInU32 as e}from"./GaussianSplatAtlasPages.js";class i{constructor(i,r,o,n,a,b,h,u){this.handle=i,this.obb=r,this.gaussianAtlasIndices=o,this.pageIds=n,this.positions=a,this.squaredScales=b,this.maxScale=h,this.elevationRange=u,this.isVisible=!1,this.fadeDirection=0,this.opacityModifier=0,this.usedMemory=t(this.gaussianAtlasIndices,this.positions,this.squaredScales)+this.pageIds.length*e*4;const c=s();r?.getCenter(c),this._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const d=r?.radius??-1;this._obbRadius=d;const l=d<0?-1:d*d;this._obbRadiusSquared=l;const f=r?.halfSize;this._obbShortestHalfsize=f?Math.min(f[0],f[1],f[2]):0}boundingVolumeIntersectsRay(t,s){if(!this.obb)return!0;const{_obbCenterX:e,_obbCenterY:i,_obbCenterZ:r}=this,o=e-t[0],n=i-t[1],a=r-t[2],b=o*s[0]+n*s[1]+a*s[2],h=o*o+n*n+a*a-b*b;return(this._obbRadiusSquared<0||h<=this._obbRadiusSquared)&&this.obb.intersectRay(t,s)}boundingVolumeIntersectsSphere(t){const s=this._obbRadius;if(s<0)return!0;const e=t.center,i=t.radius,r=s+i,o=this._obbCenterX-e[0];if(o>r)return!1;const n=this._obbCenterY-e[1];if(n>r)return!1;const a=this._obbCenterZ-e[2];if(a>r)return!1;const b=o*o+n*n+a*a;if(b>r*r)return!1;if(b<=(this._obbShortestHalfsize+i)**2)return!0;return Math.sqrt(b)+s<=i||(this.obb?.intersectSphere(t)??!0)}}export{i as GaussianTile};
