declare function require ( name ) ; import Kernel from '../Kernel' ; import MeshTextureGraphic from './MeshTextureGraphic' ; import AtmosphereGeometry from '../geometries/Atmosphere' ; import MeshTextureMaterial from '../materials/MeshTextureMaterial' ; import Camera from '../Camera' ; import Vector from '../math/Vector' ; const atmosphereImgUrl = require ( "../images/atmosphere.png" ) ; export default class Atmosphere extends MeshTextureGraphic { private constructor ( public geometry , public material ) { super ( geometry , material ) ; } static getInstance ( ) { var geometry = new AtmosphereGeometry ( ) ; var material = new MeshTextureMaterial ( atmosphereImgUrl , false ) ; return new Atmosphere ( geometry , material ) ; } shouldDraw ( camera ) { return ! camera . isEarthFullOverlapScreen ( ) && super . shouldDraw ( camera ) ; } onDraw ( camera ) { var gl = Kernel . gl ; gl . disable ( Kernel . gl . DEPTH_TEST ) ; gl . depthMask ( false ) ; gl . enable ( Kernel . gl . BLEND ) ; gl . blendFunc ( Kernel . gl . SRC_ALPHA , Kernel . gl . ONE_MINUS_SRC_ALPHA ) ; this . geometry . getMatrix ( ) . setUnitMatrix ( ) ; var R = Kernel . EARTH_RADIUS ; var distanceCamera2Origin = camera . getDistance2EarthOrigin ( ) ; var distanceCamera2EarthTangent = Math . sqrt ( distanceCamera2Origin * distanceCamera2Origin - R * R ) ; var sinθ = distanceCamera2EarthTangent / distanceCamera2Origin ; var distanceCamera2Atmosphere = distanceCamera2EarthTangent * sinθ ; var vector = camera . getLightDirection ( ) . setLength ( distanceCamera2Atmosphere ) ; var atmosphereNewPosition = Vector . verticePlusVector ( camera . getPosition ( ) , vector ) ; this . geometry . setPosition ( atmosphereNewPosition ) ; this . geometry . setVectorX ( camera . getVectorX ( ) ) ; this . geometry . setVectorY ( camera . getVectorY ( ) ) ; this . geometry . setVectorZ ( camera . getVectorZ ( ) ) ; this . geometry . localScale ( sinθ , sinθ , sinθ ) ; super . onDraw ( camera ) ; gl . enable ( Kernel . gl . DEPTH_TEST ) ; gl . depthMask ( true ) ; gl . disable ( Kernel . gl . BLEND ) ; } } ;