UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 1.3 kB
import{removeUnordered as e}from"../../../../core/arrayUtils.js";import{ForAllFeaturesReturnType as t}from"../II3SMeshView3D.js";class s{constructor(){this.ids=new Set,this.paused=!1}}class i{constructor({collection:e,forAllFeatures:t,forAllFeaturesOfNode:s}){this._highlights=[],this._collection=e,this._forAllFeatures=t,this._forAllFeaturesOfNode=s}destroy(){this._highlights.forEach((e=>this._releaseSet(e))),this._highlights=null}acquireSet(){const t=new s;this._highlights.push(t);const i={remove:()=>{this._highlights&&(this._releaseSet(t),e(this._highlights,t))},pause:()=>{this._releaseSet(t),t.paused=!0},resume:()=>{t.paused=!1,this._initializeSet(t)}};return{set:t,handle:i}}setFeatureIds(e,t){t.forEach((t=>e.ids.add(t))),this._initializeSet(e)}_initializeSet(e){this._forAllFeatures(((s,i,h)=>(e.ids.has(s)&&this._collection.addComponentHighlight(h.objectHandle,i),t.CONTINUE)))}_releaseSet(e){this._forAllFeatures(((s,i,h)=>(e.ids.has(s)&&this._collection.removeComponentHighlight(h.objectHandle,i),t.CONTINUE)))}objectCreated(e){this._highlights.forEach((s=>{s.paused||this._forAllFeaturesOfNode(e,((i,h)=>(s.ids.has(i)&&this._collection.addComponentHighlight(e.objectHandle,h),t.CONTINUE)))}))}objectDeleted(e){this._collection.clearHighlights(e.objectHandle)}}export{i as default};