define(["exports","./BoundingSphere-9a3b5656","./Cartesian3-e0307675","./Check-741c5f3c","./defaultValue-81eec7ed","./Cartesian2-bd414876","./Rectangle-cf3e0e3e","./AttributeCompression-8f752c03","./ComponentDatatype-aaeec80f","./Math-e73894ab","./Matrix4-4c545f70"],(function(t,e,i,a,o,n,r,s,c,u,d){"use strict";function l(t,e){this._ellipsoid=t,this._cameraPosition=new i.Cartesian3,this._cameraPositionInScaledSpace=new i.Cartesian3,this._distanceToLimbInScaledSpaceSquared=0,o.defined(e)&&(this.cameraPosition=e)}Object.defineProperties(l.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},cameraPosition:{get:function(){return this._cameraPosition},set:function(t){const e=this._ellipsoid.transformPositionToScaledSpace(t,this._cameraPositionInScaledSpace),a=i.Cartesian3.magnitudeSquared(e)-1;i.Cartesian3.clone(t,this._cameraPosition),this._cameraPositionInScaledSpace=e,this._distanceToLimbInScaledSpaceSquared=a}}});const m=new i.Cartesian3;l.prototype.isPointVisible=function(t){return N(this._ellipsoid.transformPositionToScaledSpace(t,m),this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)},l.prototype.isScaledSpacePointVisible=function(t){return N(t,this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)};const h=new i.Cartesian3;l.prototype.isScaledSpacePointVisiblePossiblyUnderEllipsoid=function(t,e){const i=this._ellipsoid;let a,n;return o.defined(e)&&e<0&&i.minimumRadius>-e?(n=h,n.x=this._cameraPosition.x/(i.radii.x+e),n.y=this._cameraPosition.y/(i.radii.y+e),n.z=this._cameraPosition.z/(i.radii.z+e),a=n.x*n.x+n.y*n.y+n.z*n.z-1):(n=this._cameraPositionInScaledSpace,a=this._distanceToLimbInScaledSpaceSquared),N(t,n,a)},l.prototype.computeHorizonCullingPoint=function(t,e,i){return C(this._ellipsoid,t,e,i)};const f=n.Ellipsoid.clone(n.Ellipsoid.UNIT_SPHERE);l.prototype.computeHorizonCullingPointPossiblyUnderEllipsoid=function(t,e,i,a){return C(S(this._ellipsoid,i,f),t,e,a)},l.prototype.computeHorizonCullingPointFromVertices=function(t,e,i,a,o){return y(this._ellipsoid,t,e,i,a,o)},l.prototype.computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid=function(t,e,i,a,o,n){return y(S(this._ellipsoid,o,f),t,e,i,a,n)};const p=[];l.prototype.computeHorizonCullingPointFromRectangle=function(t,a,o){const n=r.Rectangle.subsample(t,a,0,p),s=e.BoundingSphere.fromPoints(n);if(!(i.Cartesian3.magnitude(s.center)<.1*a.minimumRadius))return this.computeHorizonCullingPoint(s.center,n,o)};const x=new i.Cartesian3;function S(t,e,a){if(o.defined(e)&&e<0&&t.minimumRadius>-e){const o=i.Cartesian3.fromElements(t.radii.x+e,t.radii.y+e,t.radii.z+e,x);t=n.Ellipsoid.fromCartesian3(o,a)}return t}function C(t,e,a,n){o.defined(n)||(n=new i.Cartesian3);const r=_(t,e);let s=0;for(let e=0,i=a.length;e0:s>n&&s*s/i.Cartesian3.magnitudeSquared(r)>n)}const M=new i.Cartesian3,T=new i.Cartesian3;function b(t,e,a){const o=t.transformPositionToScaledSpace(e,M);let n=i.Cartesian3.magnitudeSquared(o),r=Math.sqrt(n);const s=i.Cartesian3.divideByScalar(o,r,T);n=Math.max(1,n),r=Math.max(1,r);const c=1/r;return 1/(i.Cartesian3.dot(s,a)*c-i.Cartesian3.magnitude(i.Cartesian3.cross(s,a,s))*(Math.sqrt(n-1)*c))}function P(t,e,a){if(!(e<=0||e===1/0||e!=e))return i.Cartesian3.multiplyByScalar(t,e,a)}const z=new i.Cartesian3;function _(t,e){return i.Cartesian3.equals(e,i.Cartesian3.ZERO)?e:(t.transformPositionToScaledSpace(e,z),i.Cartesian3.normalize(z,z))}const E={getHeight:function(t,e,i){return(t-i)*e+i}},H=new i.Cartesian3;E.getPosition=function(t,e,a,o,n){const r=e.cartesianToCartographic(t,H),s=E.getHeight(r.height,a,o);return i.Cartesian3.fromRadians(r.longitude,r.latitude,s,e,n)};var w=Object.freeze({NONE:0,BITS12:1});const A=new i.Cartesian3,I=new i.Cartesian3,V=new n.Cartesian2,q=new d.Matrix4,G=new d.Matrix4,B=Math.pow(2,12);function O(t,e,a,n,r,s,c,u,l,m){let h,f,p=w.NONE;if(o.defined(e)&&o.defined(a)&&o.defined(n)&&o.defined(r)){const t=e.minimum,o=e.maximum,s=i.Cartesian3.subtract(o,t,I),c=n-a;p=Math.max(i.Cartesian3.maximumComponent(s),c)