@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.05 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as t}from"tslib";import{destroyHandle as i}from"../../../core/handleUtils.js";import{clone as e}from"../../../core/lang.js";import{property as n,cast as r,subclass as s}from"../../../core/accessorSupport/decorators.js";import{ensureOneOfType as g}from"../../../core/accessorSupport/ensureType.js";import{lightingTypes as h}from"./lightingUtils.js";import o from"./SunLighting.js";import l from"./VirtualLighting.js";import a from"../../../webscene/Environment.js";import c from"../../../webscene/SunLighting.js";import p from"../../../webscene/VirtualLighting.js";var u;let m=class extends a{static{u=this}constructor(t){super(t),this.lighting=this.castLighting(),this._computeWeatherAvailable=void 0,this.cachedCameraTrackingEnabled=null}static fromWebsceneEnvironment(t){const i=t.cloneConstructProperties();return new u({...i,lighting:i.lighting?"virtual"===i.lighting.type?l.fromWebsceneLighting(i.lighting):o.fromWebsceneLighting(i.lighting):void 0})}get weatherAvailable(){return this._computeWeatherAvailable?.()??!1}setComputeWeatherAvailable(t){this._computeWeatherAvailable=t}castLighting(t){return this._convertLightingWithDestroy(t)}applyLighting(t){this.lighting=this._convertLightingWithDestroy(t)}_convertLightingWithDestroy(t){const e=this._convertLighting(t);return e!==t&&this.addHandles(i(e)),e}_convertLighting(t){return t?t instanceof o||t instanceof l?t:t instanceof c?this.lighting&&"virtual"!==this.lighting.type?this.lighting.cloneWithWebsceneLighting(t):new o({...t.cloneConstructProperties(),...this.lighting?.cloneNonPersistentConstructProperties()}):t instanceof p?this.lighting&&"virtual"===this.lighting.type?this.lighting.cloneWithWebsceneLighting(t):new l({...t.cloneConstructProperties(),...this.lighting?.cloneNonPersistentConstructProperties()}):g(h,t):new o}clone(){return new u({lighting:this.lighting.clone(),weather:this.weather.clone(),atmosphereEnabled:this.atmosphereEnabled,starsEnabled:this.starsEnabled,background:e(this.background)})}cloneWithWebsceneEnvironment(t){return new u({weather:this.weather.clone(),atmosphereEnabled:this.atmosphereEnabled,starsEnabled:this.starsEnabled,background:e(this.background),...t.cloneConstructProperties(),lighting:this._getLighting(t)})}_getLighting(t){switch(t.lighting.type){case"sun":return this.lighting&&"sun"===this.lighting.type?this.lighting.cloneWithWebsceneLighting(t.lighting):o.fromWebsceneLighting(t.lighting);case"virtual":return this.lighting&&"virtual"===this.lighting.type?this.lighting.cloneWithWebsceneLighting(t.lighting):l.fromWebsceneLighting(t.lighting);default:return t.lighting,o.fromWebsceneLighting(t.lighting)}}};t([n({types:{defaultKeyValue:"sun",...h},nonNullable:!0})],m.prototype,"lighting",void 0),t([n()],m.prototype,"_computeWeatherAvailable",void 0),t([n({readOnly:!0})],m.prototype,"weatherAvailable",null),t([r("lighting")],m.prototype,"castLighting",null),m=u=t([s("esri.views.3d.environment.Environment")],m);const b=m;export{b as default};