/*
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/time","../../../../chunks/vec2f64","../../../../chunks/vec4f64","../core/shaderLibrary/ShaderOutputOptions","../lib/AnimationTimer","../lib/GLMaterials","../lib/Material","../lib/OrderIndependentTransparency","../lib/RenderSlot","./WaterGLMaterial","./WaterTechnique","./internal/DefaultBufferWriter","./internal/MaterialUtil"],(function(e,t,r,a,i,n,s,o,u,h,l,c,p,f,d){"use strict";let m=function(e){function a(t){var r;return(r=e.call(this,t,new S)||this)._techniqueConfig=new p.WaterTechniqueConfiguration,r.animation=new s.AnimationTimer,r}t._inheritsLoose(a,e);var i=a.prototype;return i.getConfiguration=function(e,t){return this._techniqueConfig.output=e,this._techniqueConfig.writeDepth=this.parameters.writeDepth,this._techniqueConfig.receiveShadows=this.parameters.receiveShadows,this._techniqueConfig.hasSlicePlane=this.parameters.hasSlicePlane,this._techniqueConfig.transparent=this.parameters.transparent,this._techniqueConfig.hasScreenSpaceReflections=this.parameters.hasScreenSpaceReflections,this._techniqueConfig.hasCloudsReflections=this.parameters.hasCloudsReflections,this._techniqueConfig.isDraped=this.parameters.isDraped,this._techniqueConfig.transparencyPassType=t.transparencyPassType,this._techniqueConfig.enableOffset=t.camera.relativeElevation<h.OITPolygonOffsetLimit,this._techniqueConfig.hasMultipassTerrain=t.multipassTerrain.enabled,this._techniqueConfig.cullAboveGround=t.multipassTerrain.cullAboveGround,this._techniqueConfig},i.update=function(e){const t=Math.min(e.camera.relativeElevation,e.camera.distance);this.animation.enabled=Math.sqrt(this.parameters.waveTextureRepeat/this.parameters.waveStrength)*t<R;const a=this.animation.advance(e);return this.setParameters({timeElapsed:r.secondsFromMilliseconds(this.animation.time)*this.parameters.animationSpeed},!1),this.animation.enabled&&a},i.intersect=function(e,t,r,a,i,n,s){d.intersectTriangleGeometry(e,t,a,i,n,void 0,s)},i.requiresSlot=function(e,t){switch(o.outputFromPass(t)){case n.ShaderOutput.Normal:return e===l.RenderSlot.DRAPED_WATER;case n.ShaderOutput.Color:if(this.parameters.isDraped)return e===l.RenderSlot.DRAPED_MATERIAL;break;case n.ShaderOutput.Highlight:return e===l.RenderSlot.OPAQUE_MATERIAL||e===l.RenderSlot.DRAPED_MATERIAL}let r=l.RenderSlot.OPAQUE_MATERIAL;return this.parameters.transparent&&(r=this.parameters.writeDepth?l.RenderSlot.TRANSPARENT_MATERIAL:l.RenderSlot.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),e===r},i.createGLMaterial=function(e){if(e.output===n.ShaderOutput.Color&&this.parameters.isDraped)return e.output=n.ShaderOutput.Draped,new c.WaterGLMaterial(e);switch(e.output){case n.ShaderOutput.Color:case n.ShaderOutput.Normal:case n.ShaderOutput.Highlight:case n.ShaderOutput.Alpha:return new c.WaterGLMaterial(e)}return null},i.createBufferWriter=function(){return new f.DefaultBufferWriter(f.PositionUVLayout)},a}(u.Material),S=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).waveStrength=.06,t.waveTextureRepeat=32,t.waveDirection=a.fromValues(1,0),t.waveVelocity=.05,t.flowStrength=.015,t.flowOffset=-.5,t.animationSpeed=.35,t.timeElapsed=0,t.color=i.fromValues(0,0,0,0),t.transparent=!0,t.writeDepth=!0,t.hasSlicePlane=!1,t.isDraped=!1,t.receiveShadows=!0,t.hasScreenSpaceReflections=!1,t.hasCloudsReflections=!1,t}return t._inheritsLoose(r,e),r}(u.MaterialParameters);const R=35e3;e.WaterMaterial=m,e.WaterMaterialParameters=S,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
