/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{set as t,normalize as e,subtract as r,cross as s,distance as o,transformMat4 as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isColor as c}from"../core/shaderLibrary/ShaderOutput.js";import l from"../lib/GLMaterial.js";import{Material as p,MaterialParameters as u}from"../lib/Material.js";import{MeasurementArrowTechnique as h,layout as f}from"../shaders/MeasurementArrowTechnique.js";import{MeasurementArrowTechniqueConfiguration as m}from"../shaders/MeasurementArrowTechniqueConfiguration.js";import{alphaCutoff as g}from"../../../../webscene/support/AlphaCutoff.js";class d extends p{constructor(t){super(t,w),this._configuration=new m,this.intersectDraped=void 0,this.produces=new Map([[2,t=>!this._transparent&&c(t)],[9,t=>this._transparent&&c(t)]])}getConfiguration(t,e){return super.getConfiguration(t,e,this._configuration),this._configuration.polygonOffsetEnabled=this.parameters.polygonOffset,this._configuration.transparent=this._transparent,this._configuration}get visible(){const{outlineColor:t,stripeEvenColor:e,stripeOddColor:r}=this.parameters;return t[3]>=g||e[3]>=g||r[3]>=g}intersect(){}createGLMaterial(t){return new C(t)}createBufferWriter(){return new x}get _transparent(){const{parameters:t}=this;return t.outlineColor[3]<1||t.stripeEvenColor[3]<1||t.stripeOddColor[3]<1}}class C extends l{beginSlot(t){return this.getTechnique(h,t)}}class w extends u{constructor(){super(...arguments),this.width=32,this.outlineSize=.2,this.outlineColor=a(1,.5,0,1),this.stripeEvenColor=a(1,1,1,1),this.stripeOddColor=a(1,.5,0,1),this.stripeLength=1,this.polygonOffset=!1}}const b=n(),j=n(),v=n(),_=n(),M=n();class x{constructor(){this.layout=f}elementCount(t){return 2*(t.get("position").indices.length/2+1)}write(n,a,c,l,p,u){const{data:h,indices:f}=c.get("position"),m=c.get("normal").data,g=h.length/3;f&&f.length!==2*(g-1)&&console.warn("MeasurementArrowMaterial does not support indices");const d=b,C=j,w=v,x=_,O=M,y=p.position,A=p.normal,E=p.uv0;let L=0;for(let b=0;b<g;++b){const c=3*b;if(t(d,h[c],h[c+1],h[c+2]),b<g-1){const o=3*(b+1);t(C,h[o],h[o+1],h[o+2]),t(O,m[o],m[o+1],m[o+2]),e(O,O),r(w,C,d),e(w,w),s(x,O,w),e(x,x)}const l=o(d,C);n&&a&&(i(d,d,n),i(C,C,n),i(x,x,a));const p=u+2*b,f=p+1;y.setVec(p,d),y.setVec(f,d),A.setVec(p,x),A.setVec(f,x),E.set(p,0,L),E.set(p,1,-1),E.set(f,0,L),E.set(f,1,1),b<g-1&&(L+=l)}const V=p.length;for(let t=0;t<2*g;++t)V.set(u+t,L);return null}}export{d as MeasurementArrowMaterial,w as Parameters};
