@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.57 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{removeUnordered as t}from"../../../../core/arrayUtils.js";import{makeHandle as e}from"../../../../core/handleUtils.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{ForAllFeaturesReturnType as s}from"../II3SMeshView3D.js";class h{constructor(t){this.highlightName=t,this.ids=new Set}}class l{constructor({collection:t,forAllFeatures:e,forAllFeaturesOfNode:i}){this._highlights=new Map,this._collection=t,this._forAllFeatures=e,this._forAllFeaturesOfNode=i}destroy(){this._highlights.forEach((t=>t.forEach((t=>this._releaseSet(t))))),this._highlights=null}acquireSet(s){const l=new h(s);i(this._highlights,s,(()=>[])).push(l);const o=e((()=>{const e=this._highlights?.get(s);e&&(this._releaseSet(l),t(e,l))}));return{set:l,handle:o}}setFeatureIds(t,e){e.forEach((e=>t.ids.add(e))),this._initializeSet(t)}_initializeSet(t){this._forAllFeatures(((e,i,h)=>(t.ids.has(e)&&this._collection.addComponentHighlight(h.objectHandle,i,t.highlightName),s.CONTINUE)))}_releaseSet(t){this._forAllFeatures(((e,i,h)=>(t.ids.has(e)&&this._collection.removeComponentHighlight(h.objectHandle,i,t.highlightName),s.CONTINUE)))}objectCreated(t){this._highlights.forEach(((e,i)=>{e.forEach((e=>{this._forAllFeaturesOfNode(t,((h,l)=>(e.ids.has(h)&&this._collection.addComponentHighlight(t.objectHandle,l,i),s.CONTINUE)))}))}))}objectDeleted(t){this._collection.clearHighlights(t.objectHandle)}}export{l as default};