@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 3.55 kB
JavaScript
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{IdentifiableMixin as s}from"../../../../core/Identifiable.js";import{isSome as t,toNullable as o,isNone as i}from"../../../../core/maybe.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{DrapeSourceType as a,DrapedRenderGroup as d}from"../../layers/interfaces.js";import{DirtyOperation as n}from"../../webgl-engine/lib/ModelDirtyTypes.js";import{UpdatePolicy as h}from"../../webgl-engine/lib/UpdatePolicy.js";class _{constructor(e){this._resourceFactory=e,this._resources=null,this._visible=!0,this._attached=!1,this._renderGroup=d.Outline}destroy(){this._destroyResources()}get resources(){return t(this._resources)?this._resources.external:null}get visible(){return this._visible}set visible(e){e!==this._visible&&(this._visible=e,this._syncGeometriesToRenderer())}get attached(){return this._attached}set attached(e){e!==this._attached&&(this._attached=e,this._createOrDestroyResources())}get renderGroup(){return this._renderGroup}set renderGroup(e){this._renderGroup=e;const r=o(this._resources)?.layerView;r&&(r.renderGroup=e)}recreate(){this.attached&&this._createResources()}recreateGeometry(){this._resourceFactory.recreateGeometry?i(this._resources)||(this._ensureRenderGeometriesRemoved(),this._resourceFactory.recreateGeometry(this._resources.external),this._syncGeometriesToRenderer()):this.recreate()}_createOrDestroyResources(){this._attached?i(this._resources)&&this._createResources():this._destroyResources()}_createResources(){this._destroyResources();const e=this._resourceFactory.createResources(),r=new p({view:this._resourceFactory.view,renderGroup:this._renderGroup}),s=this._resourceFactory.view.basemapTerrain?.overlayManager;this._resources={layerView:new p({view:this._resourceFactory.view,renderGroup:this._renderGroup}),external:e,geometriesAdded:!1},s&&(this._resources.drapeSourceRenderer=s.registerGeometryDrapeSource(r)),this._syncGeometriesToRenderer()}_destroyResources(){if(i(this._resources))return;this._ensureRenderGeometriesRemoved();const e=this._resourceFactory.view.basemapTerrain?.overlayManager;e&&e.unregisterDrapeSource(this._resources.layerView),this._resourceFactory.destroyResources(this._resources.external),this._resources=null}_syncGeometriesToRenderer(){this._visible?this._ensureRenderGeometriesAdded():this._ensureRenderGeometriesRemoved()}_ensureRenderGeometriesRemoved(){if(i(this._resources)||i(this._resources.drapeSourceRenderer))return;if(!this._resources.geometriesAdded)return;this._resources.drapeSourceRenderer.removeGeometries(this._resources.external.geometries,n.UPDATE),this._resources.geometriesAdded=!1}_ensureRenderGeometriesAdded(){if(i(this._resources)||i(this._resources.drapeSourceRenderer))return;if(this._resources.geometriesAdded)return;this._resources.drapeSourceRenderer.addGeometries(this._resources.external.geometries,n.UPDATE),this._resources.geometriesAdded=!0}}let p=class extends(s(r)){constructor(e){super(e),this.drapeSourceType=a.Features,this.updatePolicy=h.SYNC,this.renderGroup=d.Outline}};e([c({constructOnly:!0})],p.prototype,"view",void 0),e([c({readOnly:!0})],p.prototype,"drapeSourceType",void 0),e([c()],p.prototype,"renderGroup",void 0),p=e([u("DrapedVisualElementLayerView")],p);export{_ as DrapedVisualElementResources};