UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.23 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{BufferViewFloat as e}from"../../../../geometry/support/buffer/BufferView.js";import{isHighlightOrOID as t,isColor as r}from"../core/shaderLibrary/ShaderOutput.js";import{CullFaceOptions as i}from"../lib/basicInterfaces.js";import s from"../lib/GLMaterial.js";import{isUpdatableTexture as a}from"../lib/ITexture.js";import{MaterialParameters as o}from"../lib/Material.js";import{OITPolygonOffsetLimit as n}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as u}from"../lib/RenderSlot.js";import{assert as p}from"../lib/Util.js";import{VertexAttribute as l}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as c}from"./DefaultBufferWriter.js";import{PositionUvLayout as h}from"./DefaultLayouts.js";import{TriangleMaterial as f}from"./TriangleMaterial.js";import{writeBufferFloat as m,writeDefaultAttribute as g}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocations as d,ImageMaterialTechnique as T}from"../shaders/ImageMaterialTechnique.js";import{ImageMaterialTechniqueConfiguration as I}from"../shaders/ImageMaterialTechniqueConfiguration.js";class _ extends f{constructor(e){super(e,x),this.vertexAttributeLocations=d,this.supportsEdges=!0,this.produces=new Map([[u.OPAQUE_MATERIAL,e=>t(e)],[u.TRANSPARENT_MATERIAL,e=>r(e)&&this.parameters.writeDepth],[u.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>r(e)&&!this.parameters.writeDepth],[u.DRAPED_MATERIAL,e=>r(e)||t(e)]]),this._configuration=new I(e.draped)}dispose(){this.setParameters({texture:void 0})}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasOccludees=t.hasOccludees,this._configuration.oitPass=t.oitPass,this._configuration.enableOffset=t.camera.relativeElevation<n,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration.perspectiveInterpolation=this.parameters.perspectiveInterpolation,this._configuration}get visible(){return!0}createGLMaterial(e){return new b(e)}createBufferWriter(){let e=h;return this.parameters.perspectiveInterpolation&&(e=e.clone().f32(l.PERSPECTIVEDIVIDE)),new E(e)}}class b extends s{constructor(e){super({...e,...e.material.parameters}),this.parameters=e;const t=this._material.parameters.texture;a(t)&&e.textures.updater.add(t)}dispose(){this.parameters.textures.updater.remove(this._material.parameters.texture)}beginSlot(e){return this.getTechnique(T,e)}}class E extends c{write(t,r,i,s,a,o){for(const n of this.vertexBufferLayout.fields.keys()){const s=i.get(n);if(s)if(n===l.PERSPECTIVEDIVIDE){p(1===s.size);const t=a.getField(n,e);t&&m(s,t,o)}else g(n,s,t,r,a,o)}return null}}class x extends o{constructor(e,t){super(),this.texture=e,this.draped=t,this.writeDepth=!0,this.hasSlicePlane=!1,this.cullFace=i.None,this.opacity=1,this.perspectiveInterpolation=!1}get glTexture(){return this.texture.glTexture}}export{_ as ImageMaterial,x as Parameters};