@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 1.57 kB
JavaScript
import{makeHandle as t}from"../../../../core/handleUtils.js";import{Graphics3DObjectStateSet as e}from"./Graphics3DObjectStateSet.js";class s{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)}acquireSet(s,a){const i=new e(s,a);this._stateSets.push(i);const h=t((()=>this.releaseSet(i)));return{set:i,handle:h}}releaseSet(t){t.objectStateSet.removeAll();const e=this._stateSets?this._stateSets.indexOf(t):-1;-1!==e&&this._stateSets.splice(e,1)}_addObjectStateSet(t,e){t.addObjectStateSet(e.stateType,e.objectStateSet)}_removeObjectStateSet(t,e){t.removeObjectState(e.objectStateSet)}setUid(t,e){t.ids.add(e);const s=this._graphicsCore.graphics3DGraphics.get(e);s&&this._addObjectStateSet(s,t)}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)&&this._addObjectStateSet(t,e)}))}removeGraphic(t){this._stateSets.forEach((e=>{e.hasGraphic(t)&&this._removeObjectStateSet(t,e)}))}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)&&this._addObjectStateSet(e,t)})):t.ids.forEach((s=>{const a=e.get(s);a&&this._addObjectStateSet(a,t)}))}get test(){return{states:this._stateSets}}}export{s as Graphics3DObjectStates};