UNPKG

@arcgis/core

Version:

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

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