/*
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","../../../../../core/promiseUtils","../utils","../../../../webgl/BufferObject","../../../../webgl/enums","../../../../webgl/VertexArrayObject","../../../../webgl/VertexElementDescriptor"],(function(e,t,a,r,s,i,n,o){"use strict";let l=function(){function e(e){this._params=e}var s=e.prototype;return s.isCompatible=function(t){return t instanceof e&&r.areStreamlinesCompatible(this._params,t._params)},s.load=function(){var e=t._asyncToGenerator((function*(e,t){const{extent:r,size:s}=e;a.throwIfAborted(t);const i=yield this._params.loadImagery(r,s[0],s[1],this._params.timeExtent,t),{vertexData:n,indexData:o}=yield this._params.createFlowMesh("Particles",this._params.simulationSettings,i,t);return new u(n,o,{color:this._params.color,opacity:this._params.opacity,size:this._params.size})}));function r(t,a){return e.apply(this,arguments)}return r}(),s.render=function(e,t,a){const{context:s}=e,{program:n}=a;s.setFaceCullingEnabled(!1),s.setBlendingEnabled(!0),s.setBlendFunction(i.BlendFactor.ONE,i.BlendFactor.ONE_MINUS_SRC_ALPHA),s.useProgram(n),n.setUniform1f("u_time",t.time),n.setUniform1f("u_trailLength",this._params.trailLength),n.setUniform1f("u_flowSpeed",this._params.flowSpeed),n.setUniform1f("u_featheringSize",this._params.featheringSize),n.setUniform1f("u_featheringOffset",this._params.featheringOffset),n.setUniform1f("u_introFade",this._params.introFade?1:0),n.setUniform1f("u_fadeToZero",this._params.fadeToZero?1:0),n.setUniform1f("u_decayRate",this._params.decayRate),n.setUniformMatrix3fv("u_dvsMat3",t.dvsMat3),n.setUniformMatrix3fv("u_displayViewMat3",t.displayViewMat3),r.setUniforms(n,"color","vec4",this._params.color),r.setUniforms(n,"opacity","float",this._params.opacity),r.setUniforms(n,"size","float",this._params.size),s.bindVAO(a.vertexArray),s.drawElements(i.PrimitiveType.TRIANGLES,a.indexCount,i.DataType.UNSIGNED_INT,0)},t._createClass(e,[{key:"animated",get:function(){return this._params.flowSpeed>0}}]),e}();const p=new Map;p.set("a_xyts0",0),p.set("a_xyts1",1),p.set("a_typeIdDurationSeed",2),p.set("a_extrudeInfo",3);const c={geometry:[new o.VertexElementDescriptor("a_xyts0",4,i.DataType.FLOAT,0,64),new o.VertexElementDescriptor("a_xyts1",4,i.DataType.FLOAT,16,64),new o.VertexElementDescriptor("a_typeIdDurationSeed",4,i.DataType.FLOAT,32,64),new o.VertexElementDescriptor("a_extrudeInfo",4,i.DataType.FLOAT,48,64)]},f={vsPath:"raster/flow/particles",fsPath:"raster/flow/particles",attributes:p};let u=function(){function e(e,t,a){this._vertexData=e,this._indexData=t,this._values=a}var a=e.prototype;return a.attach=function(e){const{context:t}=e,a=s.BufferObject.createVertex(t,i.Usage.STATIC_DRAW,this._vertexData),r=s.BufferObject.createIndex(t,i.Usage.STATIC_DRAW,this._indexData),o={geometry:a},l=new n.VertexArrayObject(t,p,c,o,r),u=[];"ramp"===this._values.color.kind&&u.push("vvColor"),"ramp"===this._values.opacity.kind&&u.push("vvOpacity"),"ramp"===this._values.size.kind&&u.push("vvSize");const m=e.painter.materialManager.getProgram(f,u);this.vertexArray=l,this.program=m,this.indexCount=this._indexData.length,this._vertexData=null,this._indexData=null},a.detach=function(){this.vertexArray.dispose()},t._createClass(e,[{key:"ready",get:function(){return this.program.isCompiled}}]),e}();e.ParticlesResources=u,e.default=l,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
