@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.62 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as s}from"../../../../../chunks/tslib.es6.js";import{getAssetUrl as r}from"../../../../../assets.js";import e 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}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as l}from"../../../../../support/requestImageUtils.js";import{ResourceState as n}from"../../lib/basicInterfaces.js";import{PixelFormat as u,TextureSamplingMode as h}from"../../../../webgl/enums.js";import{NoParameters as g}from"../../../../webgl/NoParameters.js";import{Texture as _}from"../../../../webgl/Texture.js";import{TextureDescriptor as d}from"../../../../webgl/TextureDescriptor.js";let w=class extends e{constructor(){super(...arguments),this._passParameters=new j,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(s){return this._resourcesTask||(this._resourcesTask=t((async e=>{await Promise.allSettled([this._loadImageResource(s,r("esri/images/materials/water/normals.jpg"),(s=>this._passParameters.waveNormal=s),e),this._loadImageResource(s,r("esri/images/materials/water/perturbation.jpg"),(s=>this._passParameters.wavePerturbation=s),e)])}))),this._resourcesTask.finished?n.LOADED:n.LOADING}async _loadImageResource(s,r,e,t){try{const a=await l(r,{signal:t});m(t);const o=new d(a.width,a.height);o.pixelFormat=u.RGB,o.samplingMode=h.LINEAR_MIPMAP_LINEAR,o.hasMipmap=!0,o.maxAnisotropy=8,e(new _(s,o,a))}catch(o){a.getLogger(this).error("Failed to load water material normal texture.",o)}}};s([p()],w.prototype,"_resourcesTask",void 0),s([p({type:Boolean,readOnly:!0})],w.prototype,"updating",null),w=s([c("esri.views.3d.webgl-engine.materials.internal.WaterTextureRepository")],w);class j extends g{}export{j as WaterTexturePassParameters,w as WaterTextureRepository};