UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 2.88 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{set as e}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as r,create as i,expandWithRect as o,center as s,set as d,toRect as a}from"../../../../geometry/support/aaBoundingBox.js";import{create as n}from"../../../../geometry/support/aaBoundingRect.js";import{demResolutionForBoundingBox as h}from"./graphicUtils.js";class c{constructor(e,t,r,i){this.graphics3DSymbolLayer=e,this.renderGeometries=t,this.boundingBox=r,this._drapeSourceRenderer=i,this.type="draped",this._visible=!1,this._addedToStage=!1,this.isElevationSource=!1}initialize(e){this.stage=e.stage}get usedMemory(){return this.graphics3DSymbolLayer.usedMemory}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,0);if(e||this._addedToStage){for(const e of this.renderGeometries)e.visible=this._visible;this._drapeSourceRenderer.modifyGeometries(this.renderGeometries,1)}}}destroy(){this.stage&&this._addedToStage&&this._drapeSourceRenderer.removeGeometries(this.renderGeometries,2),this._addedToStage=!1,this._visible=!1,this.stage=null}getCenterObjectSpace(r=t()){return e(r,0,0,0)}getBoundingBoxObjectSpace(e=i()){return r(e)}addObjectState(e){0===e.stateType&&(this.renderGeometries.forEach(t=>{const r=t.geometry.allocateIdAndHighlight(e.highlightName);e.addRenderGeometry(t,r,this)}),this._addedToStage&&this._drapeSourceRenderer.modifyGeometries(this.renderGeometries,8))}removeObjectState(e){this.renderGeometries.forEach(t=>e.removeByObject(t))}updateHighlights(e){}removeRenderGeometryObjectState(e,t){0===t.channel&&(e.geometry.removeHighlight(t),this._addedToStage&&this._drapeSourceRenderer.modifyGeometries([e],8))}computeAttachmentOrigin(e){for(const t of this.renderGeometries)t.geometry.computeAttachmentOrigin(u)&&(e.draped.origin[0]+=u[0],e.draped.origin[1]+=u[1],e.draped.num++)}async getProjectedBoundingBox(e,t,i,d,a){r(a);for(let r=0;r<this.renderGeometries.length;r++){const t=this.renderGeometries[r];this._getRenderGeometryProjectedBoundingRect(t,e,m,i),o(a,m)}if(t){let e;s(a,u);const r=h(a,t.service.spatialReference,t);try{e=await t.service.queryElevation(u[0],u[1],d,r,"ground")}catch(n){}null!=e&&(a[2]=Math.min(a[2],e),a[5]=Math.max(a[5],e))}return a}_getRenderGeometryProjectedBoundingRect(e,t,r,i){if(this.boundingBox)d(g,this.boundingBox);else{const{center:t,radius:r}=e.boundingSphere;g[0]=t[0]-r,g[1]=t[1]-r,g[2]=t[2]-r,g[3]=t[0]+r,g[4]=t[1]+r,g[5]=t[2]+r}return t(g,0,2),this.calculateRelativeScreenBounds&&i.push({location:s(g),screenSpaceBoundingRect:this.calculateRelativeScreenBounds()}),a(g,r)}}const m=n(),g=i(),u=t();export{c as Graphics3DDrapedGraphicLayer};