@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.79 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 t}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{Graphics3DOccludeeStateSet as e,Graphics3DObjectHighlightStateSet as s}from"./Graphics3DObjectStateSet.js";class a{constructor(t){this._graphicsCore=t,this._stateSets=new Array}destroy(){this.reset(),this._stateSets=null}reset(){this._stateSets&&(this._stateSets.forEach((t=>t.objectStateSet.removeAll())),this._stateSets.length=0)}acquireOccludeeSet(s){const a=new e(s);this._stateSets.push(a);const i=t((()=>this.releaseSet(a)));return{set:a,handle:i}}acquireHighlightSet(e,a){const i=new s(e,a);this._stateSets.push(i);const c=t((()=>this.releaseSet(i)));return{set:i,handle:c}}releaseSet(t){t.objectStateSet.removeAll();const e=this._stateSets?this._stateSets.indexOf(t):-1;-1!==e&&this._stateSets.splice(e,1)}setUid(t,e){t.ids.add(e);const s=this._graphicsCore.graphics3DGraphics.get(e);s&&s.addObjectStateSet(t.objectStateSet)}setUids(t,e){e.forEach((e=>this.setUid(t,e)))}setObjectIds(t,e){e.forEach((e=>t.ids.add(e))),this._initializeSet(t)}addGraphic(t){this._stateSets.forEach((e=>{!e.paused&&e.hasGraphic(t)&&t.addObjectStateSet(e.objectStateSet)}))}removeGraphic(t){this._stateSets.forEach((e=>{e.hasGraphic(t)&&t.removeObjectState(e.objectStateSet)}))}allGraphicsDeleted(){this._stateSets&&this._stateSets.forEach((t=>t.objectStateSet.removeAll()))}_initializeSet(t){const e=this._graphicsCore.graphics3DGraphics;t.objectIdField?e.forEach((e=>{e&&t.hasGraphic(e)&&e.addObjectStateSet(t.objectStateSet)})):t.ids.forEach((s=>{const a=e.get(s);a&&a.addObjectStateSet(t.objectStateSet)}))}get test(){}}export{a as Graphics3DObjectStates};