UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 2.48 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import r from"../../core/Logger.js";import{watch as n,syncAndInitial as o}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import a from"../../views/3d/environment/CloudyWeather.js";import l from"../../views/3d/environment/FoggyWeather.js";import h from"../../views/3d/environment/RainyWeather.js";import p from"../../views/3d/environment/SnowyWeather.js";import y from"../../views/3d/environment/SunnyWeather.js";import{validateWeatherType as m}from"../../views/3d/environment/weather.js";import{WeatherState as u,WeatherError as w}from"./enums.js";let c=class extends t{constructor(e){super(e),this.view=null,this._weatherByType={sunny:new y,cloudy:new a,rainy:new h,snowy:new p,foggy:new l},this._settingWeather=!1}initialize(){this.addHandles([n((()=>this.current),(e=>{this._settingWeather||null==e||(this._weatherByType={...this._weatherByType,[e.type]:e})}),o)])}get state(){const e=this.view;return null!=e&&e.ready?null!=this.error?this.error===w.NotVisible?u.Ready:u.Error:u.Ready:u.Disabled}get weatherByType(){return this._weatherByType}get error(){const e=this.view;return null!=e&&e.ready?"3d"!==e.type?w.UnsupportedView:"local"===e.viewingMode?w.LocalScene:e.environment.atmosphereEnabled?e.environment.weatherAvailable?null:w.NotVisible:w.NoAtmosphere:null}get current(){return this._environment?.weather??this._weatherByType.sunny}set current(e){const t=this._environment;t&&(t.weather=e)}get _environment(){const e=this.view;return null!=e&&"3d"===e.type?e.environment:null}setWeatherByType(e){if(!m(e,r.getLogger(this)))return;const t=this._environment;null!=t&&(this._settingWeather=!0,t.weather=this._weatherByType[e],this._settingWeather=!1)}setSnowCoverEnabled(e){const t=this.current;"snowCover"in t&&(t.snowCover=e?"enabled":"disabled")}};e([s()],c.prototype,"view",void 0),e([s()],c.prototype,"state",null),e([s()],c.prototype,"_weatherByType",void 0),e([s()],c.prototype,"weatherByType",null),e([s()],c.prototype,"error",null),e([s()],c.prototype,"current",null),e([s()],c.prototype,"_environment",null),c=e([i("esri.widgets.Weather.WeatherViewModel")],c);const d=c;export{d as default};