/*
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/maybe","../../../../chunks/vec3","../../../../chunks/vec3f64","../../../../chunks/vec4","../editingTools/settings","./Object3DVisualElement","../../layers/graphics/ElevationContext","../../layers/graphics/pointUtils","../../webgl-engine/lib/basicInterfaces","../../webgl-engine/lib/GeometryUtil","../../webgl-engine/lib/Material","../../webgl-engine/materials/ShadedColorMaterial"],(function(e,t,i,r,n,s,a,l,o,c,u,h,d,f){"use strict";let _=function(e){function n(t){var i;return(i=e.call(this,t)||this).view=null,i._renderOccluded=d.RenderOccludedFlag.OccludeAndTransparent,i._vertices=null,i._spatialReference=null,i._color=a.settings.colorToVec4(a.settings.reshapeManipulators.vertex.color),i._size=a.settings.reshapeManipulators.vertex.size,i._outlineColor=a.settings.colorToVec4(a.settings.reshapeManipulators.vertex.outlineColor),i._outlineSize=a.settings.reshapeManipulators.vertex.outlineSize,i._elevationInfo=null,i.applyProps(t),i}t._inheritsLoose(n,e);var l=n.prototype;return l._updateMaterial=function(){this.attached&&this.vertexMaterial.setParameters(this.vertexMaterialParameters)},l._updateOutlineMaterial=function(){this.attached&&this.vertexOutlineMaterial.setParameters(this.vertexOutlineMaterialParameters)},l._createRenderGeometries=function(){const e=this.vertices;if(i.isNone(e)||0===e.length)return[];const t=.5,n=.5,s=c.geometryToRenderInfo(e,this.spatialReference,this.view.elevationProvider,this.view.renderCoordsHelper,o.ElevationContext.fromElevationInfo(this.elevationInfo)),a=[],l=s.numVertices,u=s.position;for(let i=0;i<l;++i){const e=r.set(v,u[3*i+0],u[3*i+1],u[3*i+2]),s=p(t,e),l=p(n,e);a.push({vertexGeometry:s,vertexOutlineGeometry:l})}return a},l.createGeometries=function(e){const t=this._createRenderGeometries();for(const{vertexGeometry:i,vertexOutlineGeometry:r}of t)e.addGeometry(i,this.vertexMaterial),e.addGeometry(r,this.vertexOutlineMaterial)},l.createExternalResources=function(){this.vertexMaterial=new f.ShadedColorMaterial({...this.vertexMaterialParameters,writeDepth:!0,cullFace:u.CullFaceOptions.Back,screenSizeEnabled:!0}),this.vertexOutlineMaterial=new f.ShadedColorMaterial({...this.vertexOutlineMaterialParameters,transparent:!0,writeDepth:!0,cullFace:u.CullFaceOptions.Front,screenSizeEnabled:!0,shadingEnabled:!1})},l.destroyExternalResources=function(){this.vertexMaterial=null,this.vertexOutlineMaterial=null},l.forEachExternalMaterial=function(e){e(this.vertexMaterial),e(this.vertexOutlineMaterial)},t._createClass(n,[{key:"renderOccluded",get:function(){return this._renderOccluded},set:function(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial(),this._updateOutlineMaterial())}},{key:"vertices",get:function(){return this._vertices},set:function(e){this._vertices=e,this.recreateGeometry()}},{key:"spatialReference",get:function(){return this._spatialReference},set:function(e){this._spatialReference=e,this.recreateGeometry()}},{key:"color",get:function(){return this._color},set:function(e){s.exactEquals(e,this._color)||(s.copy(this._color,e),this._updateMaterial())}},{key:"size",get:function(){return this._size},set:function(e){e!==this._size&&(this._size=e,this._updateMaterial())}},{key:"outlineColor",get:function(){return this._outlineColor},set:function(e){s.exactEquals(e,this._outlineColor)||(s.copy(this._outlineColor,e),this._updateOutlineMaterial())}},{key:"outlineSize",get:function(){return this._outlineSize},set:function(e){e!==this._outlineSize&&(this._outlineSize=e,this._updateOutlineMaterial())}},{key:"elevationInfo",get:function(){return this._elevationInfo},set:function(e){this._elevationInfo=e,this.recreateGeometry()}},{key:"vertexMaterialParameters",get:function(){return{color:this._color,transparent:this._color[3]<1,screenSizeScale:this.size,renderOccluded:this._renderOccluded}}},{key:"vertexOutlineMaterialParameters",get:function(){return{color:this._outlineColor,transparent:this._outlineColor[3]<1,screenSizeScale:this.size+2*this.outlineSize,renderOccluded:this._renderOccluded}}}]),n}(l.Object3DVisualElement);const v=n.create();function p(e,t){return h.createSphereGeometry(e,16,16,{offset:t})}e.VerticesVisualElement=_,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
