/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../chunks/vec3","../../../../chunks/vec3f64","../../../../chunks/vec4f64","../../../../geometry/support/aaBoundingBox","../../../../geometry/support/buffer/BufferView","../../support/buffer/InterleavedLayout","../core/shaderLibrary/ShaderOutputOptions","../lib/basicInterfaces","../lib/GLMaterial","../lib/GLMaterials","../lib/Material","../lib/RenderSlot","../lib/Util","../lib/VertexAttribute","./internal/bufferWriterUtils","./internal/MaterialUtil","../shaders/ShadedColorMaterialTechnique"],(function(e,t,r,i,n,a,s,o,u,l,c,h,f,p,d,S,b,A,g){"use strict";let T=function(e){function i(t){var r;return(r=e.call(this,t,new m)||this).supportsEdges=!0,r.techniqueConfig=new g.ShadedColorMaterialTechniqueConfiguration,r._vertexAttributeLocations=g.ShadedColorMaterialVertexAttrLocations,r}t._inheritsLoose(i,e);var n=i.prototype;return n.getConfiguration=function(e,t){return this.techniqueConfig.output=e,this.techniqueConfig.cullFace=this.parameters.cullFace,this.techniqueConfig.hasSlicePlane=this.parameters.hasSlicePlane,this.techniqueConfig.transparent=this.parameters.transparent,this.techniqueConfig.writeDepth=this.parameters.writeDepth,this.techniqueConfig.screenSizeEnabled=this.parameters.screenSizeEnabled,this.techniqueConfig.shadingEnabled=this.parameters.shadingEnabled,this.techniqueConfig.transparencyPassType=t.transparencyPassType,this.techniqueConfig.hasMultipassTerrain=t.multipassTerrain.enabled,this.techniqueConfig.cullAboveGround=t.multipassTerrain.cullAboveGround,this.techniqueConfig},n.intersect=function(e,t,i,n,s,o,u){if(this.parameters.screenSizeEnabled){const i=e.vertexAttributes.get(S.VertexAttribute.OFFSET),l={applyToVertex:(e,t,a,s)=>{const o=r.set(x,i.data[3*s+0],i.data[3*s+1],i.data[3*s+2]),u=r.set(C,e,t,a);return r.scale(o,o,this.parameters.screenSizeScale*n.camera.computeRenderPixelSizeAt(o)),r.add(u,u,o),[u[0],u[1],u[2]]},applyToAabb:e=>{const t=a.center(e,x);return a.scale(e,this.parameters.screenSizeScale*n.camera.computeRenderPixelSizeAt(t))}};A.intersectTriangleGeometry(e,t,n,s,o,l,u)}else A.intersectTriangleGeometry(e,t,n,s,o,void 0,u)},n.requiresSlot=function(e,t){if(h.outputFromPass(t)===u.ShaderOutput.Highlight)return e===p.RenderSlot.OPAQUE_MATERIAL;let r=p.RenderSlot.OPAQUE_MATERIAL;return this.parameters.transparent&&(r=this.parameters.writeDepth?p.RenderSlot.TRANSPARENT_MATERIAL:p.RenderSlot.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),e===r||e===p.RenderSlot.DRAPED_MATERIAL},n.createGLMaterial=function(e){return e.output===u.ShaderOutput.Color||e.output===u.ShaderOutput.Alpha||e.output===u.ShaderOutput.Highlight?new E(e):null},n.createBufferWriter=function(){return new v(this.parameters.screenSizeEnabled)},i}(f.Material),E=function(e){function r(){return e.apply(this,arguments)||this}return t._inheritsLoose(r,e),r.prototype.beginSlot=function(e){return this.ensureTechnique(g.ShadedColorMaterialTechnique,e)},r}(c),m=function(e){function a(){var t;return(t=e.apply(this,arguments)||this).color=n.fromValues(1,1,1,1),t.shadingTint=n.fromValues(0,0,0,.25),t.shadingDirection=r.normalize(i.create(),[.5,-.5,-.5]),t.screenSizeScale=14,t.transparent=!1,t.writeDepth=!0,t.hasSlicePlane=!1,t.cullFace=l.CullFaceOptions.None,t.screenSizeEnabled=!1,t.shadingEnabled=!0,t}return t._inheritsLoose(a,e),a}(f.MaterialParameters),v=function(){function e(e){this.screenSizeEnabled=e;const t=o.newLayout().vec3f(S.VertexAttribute.POSITION).vec3f(S.VertexAttribute.NORMAL);this.screenSizeEnabled&&t.vec3f(S.VertexAttribute.OFFSET),this.vertexBufferLayout=t}var t=e.prototype;return t.allocate=function(e){return this.vertexBufferLayout.createBuffer(e)},t.elementCount=function(e){return e.indices.get(S.VertexAttribute.POSITION).length},t.write=function(e,t,r,i){if(b.writeDefaultAttributes(t,this.vertexBufferLayout,e.transformation,e.invTranspTransformation,r,i),this.screenSizeEnabled){if(!t.vertexAttributes.has(S.VertexAttribute.OFFSET))throw new Error(`${S.VertexAttribute.OFFSET} vertex attribute required for screenSizeEnabled ShadedColorMaterial`);{const n=t.vertexAttributes.get(S.VertexAttribute.OFFSET),a=t.indices.get(S.VertexAttribute.OFFSET);d.assert(3===n.size);const o=r.getField(S.VertexAttribute.OFFSET,s.BufferViewVec3f);if(!o)throw new Error("unable to acquire view for "+S.VertexAttribute.OFFSET);b.writePosition(a,n.data,e.invTranspTransformation,o,i)}}},e}();const x=i.create(),C=i.create();e.ShadedColorMaterial=T,e.ShadedColorMaterialParameters=m,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
