UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 2.16 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{__decorate as e}from"tslib";import{getAssetUrl as s}from"../../../../../assets.js";import r from"../../../../../core/Accessor.js";import{createTask as t}from"../../../../../core/asyncUtils.js";import a from"../../../../../core/Logger.js";import{abortMaybe as o,disposeMaybe as i}from"../../../../../core/maybe.js";import{throwIfAborted as m}from"../../../../../core/promiseUtils.js";import{property as p,subclass as l}from"../../../../../core/accessorSupport/decorators.js";import{requestImage as c}from"../../../../../request/image.js";import{NoParameters as n}from"../../../../webgl/NoParameters.js";import u from"../../../../webgl/Texture.js";import{TextureDescriptor as h}from"../../../../webgl/TextureDescriptor.js";let g=class extends r{constructor(){super(...arguments),this._passParameters=new w,this._resourcesTask=null}get passParameters(){return this._passParameters}destroy(){this._resourcesTask=o(this._resourcesTask),this._passParameters.waveNormal=i(this._passParameters.waveNormal),this._passParameters.wavePerturbation=i(this._passParameters.wavePerturbation)}get updating(){return!!this._resourcesTask&&!this._resourcesTask.finished}ensureResources(e){return this._resourcesTask||(this._resourcesTask=t(async r=>{await Promise.allSettled([this._loadImageResource(e,s("esri/images/materials/water/normals.jpg"),e=>this._passParameters.waveNormal=e,r),this._loadImageResource(e,s("esri/images/materials/water/perturbation.jpg"),e=>this._passParameters.wavePerturbation=e,r)])})),this._resourcesTask.finished?2:1}async _loadImageResource(e,s,r,t){try{const a=await c(s,{signal:t});m(t);const o=new h(a.width,a.height);o.pixelFormat=6407,o.samplingMode=9987,o.hasMipmap=!0,o.maxAnisotropy=8,r(new u(e,o,a))}catch(o){a.getLogger(this).error("Failed to load water material normal texture.",o)}}};e([p()],g.prototype,"_resourcesTask",void 0),e([p({type:Boolean,readOnly:!0})],g.prototype,"updating",null),g=e([l("esri.views.3d.webgl-engine.materials.internal.WaterTextureRepository")],g);class w extends n{}export{w as WaterTexturePassParameters,g as WaterTextureRepository};