UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.9 kB
import{isSome as e}from"../../../../core/maybe.js";import{s as t}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{create as i,empty as o,expandWithRect as s,center as d,set as n,toRect as a}from"../../../../geometry/support/aaBoundingBox.js";import{create as h}from"../../../../geometry/support/aaBoundingRect.js";import{demResolutionForBoundingBox as c}from"./graphicUtils.js";import{Object3DState as m}from"../../webgl-engine/lib/basicInterfaces.js";import{DirtyOperation as g,DirtyState as u}from"../../webgl-engine/lib/ModelDirtyTypes.js";class l{constructor(e,t,r,i){this.graphics3DSymbolLayer=e,this.renderGeometries=t,this.boundingBox=r,this._drapeSourceRenderer=i,this.type="draped",this.stage=null,this._visible=!1,this._addedToStage=!1,this.isElevationSource=!1}initialize(e){this.stage=e}setVisibility(e){if(null!=this.stage&&this._visible!==e){if(this._visible=e,e&&!this._addedToStage)return this._addedToStage=!0,void this._drapeSourceRenderer.addGeometries(this.renderGeometries,g.ADD);if(e||this._addedToStage){for(const e of this.renderGeometries)e.visible=this._visible;this._drapeSourceRenderer.modifyGeometries(this.renderGeometries,u.VISIBILITY)}}}destroy(){this.stage&&this._addedToStage&&this._drapeSourceRenderer.removeGeometries(this.renderGeometries,g.REMOVE),this._addedToStage=!1,this._visible=!1,this.stage=null}getCenterObjectSpace(e=r()){return t(e,0,0,0)}getBoundingBoxObjectSpace(e=i()){return o(e)}addObjectState(e,t){e===m.Highlight&&(this.renderGeometries.forEach((e=>{const r=e.geometry.addHighlight();t.addRenderGeometry(e,r,this)})),this._addedToStage&&this._drapeSourceRenderer.modifyGeometries(this.renderGeometries,u.HIGHLIGHT))}removeObjectState(e){this.renderGeometries.forEach((t=>{e.removeRenderGeometry(t)}))}removeRenderGeometryObjectState(e,t){e.geometry.removeHighlight(t),this._addedToStage&&this._drapeSourceRenderer.modifyGeometries(this.renderGeometries,u.HIGHLIGHT)}computeAttachmentOrigin(e){for(const t of this.renderGeometries)t.geometry.computeAttachmentOrigin(G)&&(e.draped.origin[0]+=G[0],e.draped.origin[1]+=G[1],e.draped.num++)}async getProjectedBoundingBox(t,r,i,n,a){o(a);for(let e=0;e<this.renderGeometries.length;e++){const r=this.renderGeometries[e];this._getRenderGeometryProjectedBoundingRect(r,t,p,i),s(a,p)}if(r){let t;d(a,G);const i=c(a,r.service.spatialReference,r);try{t=await r.service.queryElevation(G[0],G[1],n,i,"ground")}catch(h){}e(t)&&(a[2]=Math.min(a[2],t),a[5]=Math.max(a[5],t))}return a}_getRenderGeometryProjectedBoundingRect(e,t,r,i){if(this.boundingBox)n(f,this.boundingBox);else{const t=e.boundingSphere,r=t[3];f[0]=t[0]-r,f[1]=t[1]-r,f[2]=t[2]-r,f[3]=t[0]+r,f[4]=t[1]+r,f[5]=t[2]+r}return t(f,0,2),this.calculateRelativeScreenBounds&&i.push({location:d(f),screenSpaceBoundingRect:this.calculateRelativeScreenBounds()}),a(f,r)}}const p=h(),f=i(),G=r();export{l as default};