/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{fromTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as r,clone as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{Object3DVisualElement as a}from"./Object3DVisualElement.js";import{lineStripsToParameters as s,createGeometry as m}from"../../support/engineContent/line.js";import{LineMarkerMaterial as l}from"../../webgl-engine/materials/LineMarkerMaterial.js";class o extends a{constructor(e,t){super(e),this._hasExternalMaterial=!1,this._renderOccluded=4,this._width=1,this._color=r(1,0,1,1),this._placement="end",this._markerPrimitive="arrow",this._material=t,this._hasExternalMaterial=null!=t,this.applyProperties(e)}setGeometryFromSegment(t,r){const i=t.endRenderSpace;this.transform=e(h,i),this._normal=r;const{points:a}=t.createRenderGeometry(i,this.view.renderCoordsHelper);this.geometry=[a]}get renderOccluded(){return this._material?.parameters.renderOccluded??this._renderOccluded}set renderOccluded(e){this._renderOccluded=e,this._material?.setParameters({renderOccluded:e})}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get normal(){return this._normal}set normal(e){this._normal=e,this.recreateGeometry()}get width(){return this._material?.parameters.width??this._width}set width(e){this._width=e,this._material?.setParameters({width:e})}get color(){return this._material?.parameters.color??this._color}set color(e){this._color=i(e),this._material?.setParameters({color:this._color})}get placement(){return this._material?.parameters.placement??this._placement}set placement(e){this._placement=e,this._material?.setParameters({placement:this._placement})}get markerPrimitive(){return this._material?.parameters.markerPrimitive??this._markerPrimitive}set markerPrimitive(e){this._markerPrimitive=e,this._material?.setParameters({markerPrimitive:e})}createExternalResources(){this._hasExternalMaterial||(this._material=new l({width:this._width,color:this._color,placement:this._placement,renderOccluded:this._renderOccluded,markerPrimitive:this._markerPrimitive,isDecoration:this.isDecoration},this.view.state.isGlobal))}destroyExternalResources(){this._hasExternalMaterial||(this._material=null)}createGeometries(e){for(const t of s(this.geometry,this.normal)){const r=m(this._material,t);e.addGeometry(r)}}forEachMaterial(e){this._hasExternalMaterial||e(this._material)}}const h=t();export{o as MarkerVisualElement};
