@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.66 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{makeHandle as e}from"../../../../core/handleUtils.js";import{Object3DHighlightStateID as t}from"../../webgl-engine/lib/Object3DStateID.js";class i{constructor(e){this._context=e,this._highlights=new Map}get empty(){return 0===this._highlights.size}destroy(){this._highlights=null}add(t,i){const s=new h(t,i),d=this._highlights.get(i);return d?d.add(s):this._highlights.set(i,new Set([s])),this._enableSet(s),e((()=>this._removeSet(s)))}_removeSet(e){this._disableSet(e);const{highlightName:t}=e.id,i=this._highlights.get(t);i&&(i.delete(e),0===i.size&&this._highlights.delete(t))}_enableSet(e){e.enabled||(e.enabled=!0,this._context.forEachNode((t=>this._enableSetForNode(e,t))))}_enableSetForNode(e,t){if(!e.enabled)return;const i=e.ids.get(t.id);i&&i.forEach((i=>this._context.addHighlight(t,i,e.id)))}_disableSet(e){e.enabled&&(e.enabled=!1,this._context.forEachNode((t=>this._disableSetForNode(e,t))))}_disableSetForNode(e,t){e.enabled||this._context.removeHighlight(t,e.id)}nodeAdded(e){this._forEachSet((t=>this._enableSetForNode(t,e)))}nodeRemoved(e){this._forEachSet((t=>this._disableSetForNode(t,e)))}removeAll(){this._forEachSet((e=>this._disableSet(e)))}_forEachSet(e){this._highlights.forEach((t=>t.forEach(e)))}has(e){return this._highlights.has(e)}}class h{constructor(e,i){this.ids=new Map,this.enabled=!1;for(const t of e)null!=t&&this._add(t.nodeId,t.pointId);this.id=new t(i)}_add(e,t){const i=this.ids.get(e);i?i.add(t):this.ids.set(e,new Set([t]))}}export{i as PointCloudHighlights};