/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import{ZEROS as e}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isColorOrOLID as t,isDepth as r,is2DGeometryOutput as s}from"../core/shaderLibrary/ShaderOutput.js";import i from"../lib/GLMaterial.js";import{DefaultBufferWriter as a}from"./DefaultBufferWriter.js";import{TriangleMaterial as o}from"./TriangleMaterial.js";import{VisualVariablePassParameters as n}from"./VisualVariablePassParameters.js";import{getLayout as h,ColorMaterialTechnique as p}from"../shaders/ColorMaterialTechnique.js";import{ColorMaterialTechniqueConfiguration as u}from"../shaders/ColorMaterialTechniqueConfiguration.js";import{alphaCutoff as c}from"../../../../webscene/support/AlphaCutoff.js";class l extends o{constructor(e){super(e,f),this._configuration=new u,this.supportsEdges=!0,this.produces=new Map([[2,e=>this._isOpaqueMaterialPass(e)],[3,e=>this._isOpaqueNoSSAODepthPass(e)],[4,e=>t(e)&&this.transparent&&this.parameters.writeDepth],[5,e=>r(e)&&this.transparent&&this.parameters.writeDepth],[8,e=>t(e)&&this.transparent&&!this.parameters.writeDepth],[18,e=>s(e)]])}updateConfiguration(e){super.updateConfiguration(e),this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasVertexColors=this.parameters.hasVertexColors&&!this.parameters.vvColor,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasOccludees=e.hasOccludees,this._configuration.hasVVColor=!!this.parameters.vvColor,this._configuration.draped=this.parameters.draped,this._configuration.emissionSource=this.emissions?1:0}get visible(){return this.parameters.color[3]>=c}get transparent(){return this.parameters.color[3]<1||this.parameters.forceTransparentMode}get emissions(){return this.parameters.emissiveStrength>0?this.transparent?2:1:0}_isOpaqueMaterialPass(e){return 10===e||t(e)&&!this.transparent}_isOpaqueNoSSAODepthPass(e){return r(e)&&this.parameters.writeDepth&&!this.transparent}createGLMaterial(e){return new m(e)}createBufferWriter(){return new a(h(this.parameters))}}class m extends i{beginSlot(e){return this.getTechnique(p,e)}}class f extends n{constructor(){super(...arguments),this.color=e,this.forceTransparentMode=!1,this.writeDepth=!0,this.hasVertexColors=!1,this.polygonOffset=0,this.hasSlicePlane=!1,this.cullFace=0,this.draped=!1,this.emissiveStrength=0,this.useIndexing=!1}}export{l as ColorMaterial,f as Parameters};
