define(["exports","./BoundingSphere-561b54d0","./Cartographic-3309dd0d","./Check-7b2a090c","./when-b60132fc","./Cartesian2-47311507","./AttributeCompression-90851096","./ComponentDatatype-c140a87d","./Math-119be1a3"],(function(t,e,i,r,a,n,o,s,m){"use strict";function c(t,e){this._ellipsoid=t,this._cameraPosition=new i.Cartesian3,this._cameraPositionInScaledSpace=new i.Cartesian3,this._distanceToLimbInScaledSpaceSquared=0,a.defined(e)&&(this.cameraPosition=e)}Object.defineProperties(c.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},cameraPosition:{get:function(){return this._cameraPosition},set:function(t){var e=this._ellipsoid.transformPositionToScaledSpace(t,this._cameraPositionInScaledSpace),r=i.Cartesian3.magnitudeSquared(e)-1;i.Cartesian3.clone(t,this._cameraPosition),this._cameraPositionInScaledSpace=e,this._distanceToLimbInScaledSpaceSquared=r}}});var u=new i.Cartesian3;c.prototype.isPointVisible=function(t){return y(this._ellipsoid.transformPositionToScaledSpace(t,u),this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)},c.prototype.isScaledSpacePointVisible=function(t){return y(t,this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)};var d=new i.Cartesian3;c.prototype.isScaledSpacePointVisiblePossiblyUnderEllipsoid=function(t,e){var i,r,n=this._ellipsoid;return a.defined(e)&&e<0&&n.minimumRadius>-e?((r=d).x=this._cameraPosition.x/(n.radii.x+e),r.y=this._cameraPosition.y/(n.radii.y+e),r.z=this._cameraPosition.z/(n.radii.z+e),i=r.x*r.x+r.y*r.y+r.z*r.z-1):(r=this._cameraPositionInScaledSpace,i=this._distanceToLimbInScaledSpaceSquared),y(t,r,i)},c.prototype.computeHorizonCullingPoint=function(t,e,i){return x(this._ellipsoid,t,e,i)};var l=n.Ellipsoid.clone(n.Ellipsoid.UNIT_SPHERE);c.prototype.computeHorizonCullingPointPossiblyUnderEllipsoid=function(t,e,i,r){return x(f(this._ellipsoid,i,l),t,e,r)},c.prototype.computeHorizonCullingPointFromVertices=function(t,e,i,r,a){return S(this._ellipsoid,t,e,i,r,a)},c.prototype.computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid=function(t,e,i,r,a,n){return S(f(this._ellipsoid,a,l),t,e,i,r,n)};var p=[];c.prototype.computeHorizonCullingPointFromRectangle=function(t,r,a){var o=n.Rectangle.subsample(t,r,0,p),s=e.BoundingSphere.fromPoints(o);if(!(i.Cartesian3.magnitude(s.center)<.1*r.minimumRadius))return this.computeHorizonCullingPoint(s.center,o,a)};var h=new i.Cartesian3;function f(t,e,r){if(a.defined(e)&&e<0&&t.minimumRadius>-e){var o=i.Cartesian3.fromElements(t.radii.x+e,t.radii.y+e,t.radii.z+e,h);t=n.Ellipsoid.fromCartesian3(o,r)}return t}function x(t,e,r,n){a.defined(n)||(n=new i.Cartesian3);for(var o=P(t,e),s=0,m=0,c=r.length;m0:s>n&&s*s/i.Cartesian3.magnitudeSquared(o)>n)}var b=new i.Cartesian3,g=new i.Cartesian3;function v(t,e,r){var a=t.transformPositionToScaledSpace(e,b),n=i.Cartesian3.magnitudeSquared(a),o=Math.sqrt(n),s=i.Cartesian3.divideByScalar(a,o,g);n=Math.max(1,n);var m=1/(o=Math.max(1,o));return 1/(i.Cartesian3.dot(s,r)*m-i.Cartesian3.magnitude(i.Cartesian3.cross(s,r,s))*(Math.sqrt(n-1)*m))}function M(t,e,r){if(!(e<=0||e===1/0||e!=e))return i.Cartesian3.multiplyByScalar(t,e,r)}var T=new i.Cartesian3;function P(t,e){return i.Cartesian3.equals(e,i.Cartesian3.ZERO)?e:(t.transformPositionToScaledSpace(e,T),i.Cartesian3.normalize(T,T))}var E=Object.freeze({NONE:0,BITS12:1}),z=new i.Cartesian3,N=new i.Cartesian3,I=new n.Cartesian2,B=new e.Matrix4,_=new e.Matrix4,w=Math.pow(2,12);function A(t,r,n,o,s,m){var c,u,d,l=E.NONE;if(a.defined(t)&&a.defined(r)&&a.defined(n)&&a.defined(o)){var p=t.minimum,h=t.maximum,f=i.Cartesian3.subtract(h,p,N),x=n-r;l=Math.max(i.Cartesian3.maximumComponent(f),x)