define(["exports","./Transforms-d13cc04e","./Matrix2-9aa31791","./RuntimeError-346a3079","./when-4bbc8319","./AttributeCompression-af389d04","./ComponentDatatype-93750d1a"],(function(e,t,i,a,r,o,n){"use strict";function s(e,t){this._ellipsoid=e,this._cameraPosition=new i.Cartesian3,this._cameraPositionInScaledSpace=new i.Cartesian3,this._distanceToLimbInScaledSpaceSquared=0,r.defined(t)&&(this.cameraPosition=t)}Object.defineProperties(s.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},cameraPosition:{get:function(){return this._cameraPosition},set:function(e){var t=this._ellipsoid.transformPositionToScaledSpace(e,this._cameraPositionInScaledSpace),a=i.Cartesian3.magnitudeSquared(t)-1;i.Cartesian3.clone(e,this._cameraPosition),this._cameraPositionInScaledSpace=t,this._distanceToLimbInScaledSpaceSquared=a}}});var c=new i.Cartesian3;s.prototype.isPointVisible=function(e){return S(this._ellipsoid.transformPositionToScaledSpace(e,c),this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)},s.prototype.isScaledSpacePointVisible=function(e){return S(e,this._cameraPositionInScaledSpace,this._distanceToLimbInScaledSpaceSquared)};var d=new i.Cartesian3;s.prototype.isScaledSpacePointVisiblePossiblyUnderEllipsoid=function(e,t){var i,a,o=this._ellipsoid;return r.defined(t)&&t<0&&o.minimumRadius>-t?((a=d).x=this._cameraPosition.x/(o.radii.x+t),a.y=this._cameraPosition.y/(o.radii.y+t),a.z=this._cameraPosition.z/(o.radii.z+t),i=a.x*a.x+a.y*a.y+a.z*a.z-1):(a=this._cameraPositionInScaledSpace,i=this._distanceToLimbInScaledSpaceSquared),S(e,a,i)},s.prototype.computeHorizonCullingPoint=function(e,t,i){return f(this._ellipsoid,e,t,i)};var u=i.Ellipsoid.clone(i.Ellipsoid.UNIT_SPHERE);s.prototype.computeHorizonCullingPointPossiblyUnderEllipsoid=function(e,t,i,a){return f(h(this._ellipsoid,i,u),e,t,a)},s.prototype.computeHorizonCullingPointFromVertices=function(e,t,i,a,r){return x(this._ellipsoid,e,t,i,a,r)},s.prototype.computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid=function(e,t,i,a,r,o){return x(h(this._ellipsoid,r,u),e,t,i,a,o)};var m=[];s.prototype.computeHorizonCullingPointFromRectangle=function(e,a,r){var o=i.Rectangle.subsample(e,a,0,m),n=t.BoundingSphere.fromPoints(o);if(!(i.Cartesian3.magnitude(n.center)<.1*a.minimumRadius))return this.computeHorizonCullingPoint(n.center,o,r)};var l=new i.Cartesian3;function h(e,t,a){if(r.defined(t)&&t<0&&e.minimumRadius>-t){var o=i.Cartesian3.fromElements(e.radii.x+t,e.radii.y+t,e.radii.z+t,l);e=i.Ellipsoid.fromCartesian3(o,a)}return e}function f(e,t,a,o){r.defined(o)||(o=new i.Cartesian3);for(var n=M(e,t),s=0,c=0,d=a.length;c0:s>o&&s*s/i.Cartesian3.magnitudeSquared(n)>o)}var C=new i.Cartesian3,g=new i.Cartesian3;function y(e,t,a){var r=e.transformPositionToScaledSpace(t,C),o=i.Cartesian3.magnitudeSquared(r),n=Math.sqrt(o),s=i.Cartesian3.divideByScalar(r,n,g);o=Math.max(1,o);var c=1/(n=Math.max(1,n));return 1/(i.Cartesian3.dot(s,a)*c-i.Cartesian3.magnitude(i.Cartesian3.cross(s,a,s))*(Math.sqrt(o-1)*c))}function v(e,t,a){if(!(t<=0||t===1/0||t!=t))return i.Cartesian3.multiplyByScalar(e,t,a)}var N=new i.Cartesian3;function M(e,t){return i.Cartesian3.equals(t,i.Cartesian3.ZERO)?t:(e.transformPositionToScaledSpace(t,N),i.Cartesian3.normalize(N,N))}var T={getHeight:function(e,t,i){return(e-i)*t+i}},b=new i.Cartesian3;T.getPosition=function(e,t,a,r,o){var n=t.cartesianToCartographic(e,b),s=T.getHeight(n.height,a,r);return i.Cartesian3.fromRadians(n.longitude,n.latitude,s,t,o)};var P=Object.freeze({NONE:0,BITS12:1}),z=new i.Cartesian3,_=new i.Cartesian3,E=new i.Cartesian2,H=new i.Matrix4,w=new i.Matrix4,A=Math.pow(2,12);function I(e,t,a,o,n,s,c,d,u,m){var l,h,f=P.NONE;if(r.defined(t)&&r.defined(a)&&r.defined(o)&&r.defined(n)){var p=t.minimum,x=t.maximum,S=i.Cartesian3.subtract(x,p,_),C=o-a;f=Math.max(i.Cartesian3.maximumComponent(S),C)