text: // COPYRIGHT © 2017 Esri
  //
  // All rights reserved under the copyright laws of the United States
  // and applicable international laws, treaties, and conventions.
  //
  // This material is licensed for use under the Esri Master License
  // Agreement (MLA), and is bound by the terms of that agreement.
  // You may redistribute and use this code without modification,
  // provided you adhere to the terms of the MLA and include this
  // copyright notice.
  //
  // See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
  //
  // For additional information, contact:
  // Environmental Systems Research Institute, Inc.
  // Attn: Contracts and Legal Services Department
  // 380 New York Street
  // Redlands, California, USA 92373
  // USA
  //
  // email: contracts@esri.com
  //
  // See http://js.arcgis.com/4.6/esri/copyright.txt for details.
  
  define(["require","exports","../../../../../core/tsSupport/extendsHelper","../../../../webgl/Program","../../../../webgl/VertexArrayObject","../../../../webgl/BufferObject","../../../../webgl/enums","../../../lib/glMatrix","../../../webgl-engine/lib/RenderSlot","../../../webgl-engine/lib/DefaultVertexBufferLayouts","../../../webgl-engine/lib/DefaultVertexAttributeLocations","../../../webgl-engine/materials/internal/MaterialUtil","dojo/text!./LaserLine.xml"],function(e,t,i,r,n,s,o,a,l,p,m,d,h){function f(e,t,i,r){var n=_,s=b;g.multiplyVec3(r,t,n),c.set(i,s),s[3]=0,g.multiplyVec4(r,s),u.set4(s[0],s[1],s[2],-c.dot(s,n),e)}var c=a.vec3d,u=a.vec4d,g=a.mat4d,_=c.create(),b=u.create(),P={glowColor:[1,.5,0],glowWidth:8,innerColor:[1,1,1],innerWidth:.75,globalAlpha:.75},v=function(){function e(e,t){void 0===t&&(t={}),this._projInfo=new Float32Array(4),this._focusPosition=c.create(),this._segmentStartPosition=c.create(),this._segmentEndPosition=c.create(),this._tempNormal=c.create(),this._tempDir=c.create(),this._tempUp=c.create(),this._tempVec3=c.create(),this._tempVec4=u.create(),this.didRender=!1,this.needsRender=!0,this.focusActive=!1,this.segmentActive=!1,this._renderCoordsHelper=e,this._params=d.copyParameters(t,P)}return Object.defineProperty(e.prototype,"renderSlots",{get:function(){return[l.POSTPROCESSING_EXTERNAL]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"needsLinearDepth",{get:function(){return!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"focusPosition",{get:function(){return this._focusPosition},set:function(e){c.set(e,this._focusPosition),this.needsRender=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"segmentStartPosition",{get:function(){return this._segmentStartPosition},set:function(e){c.set(e,this._segmentStartPosition),this.needsRender=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"segmentEndPosition",{get:function(){return this._segmentEndPosition},set:function(e){c.set(e,this._segmentEndPosition),this.needsRender=!0},enumerable:!0,configurable:!0}),e.prototype.setParameterValues=function(e){d.updateParameters(this._params,e)&&(this.needsRender=!0)},e.prototype.initializeRenderContext=function(e){var t=e.rctx,i=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this._quadVAO=new n(t,m.Default3D,{geometry:p.Pos2},{geometry:s.createVertex(t,35044,i)}),e.shaderSnippets.fsLaserLine||e.shaderSnippets._parse(h),this._laserLineProgram=new r(t,e.shaderSnippets.vsUVQuad,e.shaderSnippets.fsLaserLine,m.Default3D)},e.prototype.uninitializeRenderContext=function(e){this._quadVAO.dispose(),this._quadVAO=null,this._laserLineProgram.dispose(),this._laserLineProgram=null,this._projInfo=null},e.prototype.render=function(e){var t=e.rctx,i=e.camera,r=i.width,n=i.height,s=this._renderCoordsHelper,o=this._laserLineProgram,a=this._projInfo;t.bindProgram(o);var l=i.projectionMatrix;if(a[0]=-2/(r*l[0]),a[1]=-2/(n*l[5]),a[2]=(1-l[2])/l[0],a[3]=(1+l[6])/l[5],o.setUniform4fv("projInfo",a),o.setUniform2f("nearFar",i.near,i.far),this.focusActive){var p=this._focusPosition,m=this._tempVec3,d=this._tempVec4;s.worldUpAtPosition(p,m),f(d,p,m,i.viewMatrix),o.setUniform4fv("focusPlane",d)}else o.setUniform4fv("focusPlane",[0,0,0,1e10]);if(this.segmentActive){var h=this._tempVec4,u=this._tempVec3,b=this._tempUp,P=this._tempDir,v=this._tempNormal;c.lerp(this._segmentStartPosition,this._segmentEndPosition,.5,u),s.worldUpAtPosition(u,b),c.subtract(this._segmentEndPosition,this._segmentStartPosition,P),c.normalize(P),c.cross(b,P,v),c.normalize(v),f(h,this._segmentStartPosition,v,i.viewMatrix),o.setUniform4fv("segmentPlane",h)}else o.setUniform4fv("segmentPlane",[0,0,0,1e10]);var w=_;c.set(this._segmentStartPosition,w),s.setAltitude(0,w),g.multiplyVec3(i.viewMatrix,w),o.setUniform3fv("segmentStart",w);var y=_;return c.set(this._segmentEndPosition,y),s.setAltitude(0,y),g.multiplyVec3(i.viewMatrix,y),o.setUniform3fv("segmentEnd",y),o.setUniform1i("depthMap",0),t.bindTexture(e.depth.colorTexture,0),o.setUniform3fv("innerColor",this._params.innerColor),o.setUniform1f("innerWidth",this._params.innerWidth),o.setUniform3fv("glowColor",this._params.glowColor),o.setUniform1f("glowWidth",this._params.glowWidth),o.setUniform1f("globalAlpha",this._params.globalAlpha),t.bindVAO(this._quadVAO),t.setDepthTestEnabled(!1),t.setDepthWriteEnabled(!1),t.setBlendingEnabled(!0),t.setBlendFunctionSeparate(770,771,1,771),t.drawArrays(5,0,4),t.setDepthTestEnabled(!0),t.setDepthWriteEnabled(!0),t.setBlendingEnabled(!1),!0},e}();return v});