import { CubemapSky , GradientSky } from "@here/harp-datasource-protocol" ; import { ProjectionType } from "@here/harp-geoutils" ; import * as THREE from "three" ; import { SkyCubemapTexture } from "./SkyCubemapTexture" ; import { SkyGradientTexture } from "./SkyGradientTexture" ; /**
 * Class that handles  MapView 's sky background.
  export class SkyBackground { private m_skyTexture ? : SkyGradientTexture | SkyCubemapTexture ; param m_sky param m_projectionType -  MapView 's projection type.
     *  param camera -  MapView 's camera.
      constructor ( private m_sky , private m_projectionType , camera ) { switch ( this . m_sky . type ) { case "gradient" : this . m_skyTexture = new SkyGradientTexture ( this . m_sky , this . m_projectionType ) ; this . updateCamera ( camera ) ; break ; case "cubemap" : { this . m_skyTexture = new SkyCubemapTexture ( this . m_sky ) ; break ; } } } /**
     * Disposes allocated resources.
     */ dispose ( ) { this . m_skyTexture ! . dispose ( ) ; } /**
     * Sky texture.
     */ get texture ( ) : THREE . Texture { return this . m_skyTexture ! . texture ; } param camera updateCamera ( camera ) { if ( this . m_sky . type === "gradient" ) { ( this . m_skyTexture ! as SkyGradientTexture ) . update ( camera ) ; } } param params param projectionType updateTexture ( params , projectionType ) { const isSameSkyType = this . m_sky . type === params . type && this . m_projectionType === projectionType ; switch ( params . type ) { case "gradient" : if ( isSameSkyType ) { ( this . m_skyTexture ! as SkyGradientTexture ) . updateTexture ( params ) ; } else { this . m_skyTexture = new SkyGradientTexture ( params , projectionType ) ; } break ; case "cubemap" : { if ( isSameSkyType ) { ( this . m_skyTexture ! as SkyCubemapTexture ) . updateTexture ( params ) ; } else { this . m_skyTexture = new SkyCubemapTexture ( params ) ; } break ; } } this . m_projectionType = projectionType ; this . m_sky = params ; } }