@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.16 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{i as e}from"../../../../chunks/vec32.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as r,empty as i,expandWithRect as o,center as s,set as d,toRect as n}from"../../../../geometry/support/aaBoundingBox.js";import{create as a}from"../../../../geometry/support/aaBoundingRect.js";import{demResolutionForBoundingBox as h}from"./graphicUtils.js";import{Object3DState as c}from"../../webgl-engine/lib/basicInterfaces.js";import{DirtyOperation as g,DirtyState as m}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._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,g.ADD);if(e||this._addedToStage){for(const e of this.renderGeometries)e.visible=this._visible;this._drapeSourceRenderer.modifyGeometries(this.renderGeometries,m.VISIBILITY)}}}destroy(){this.stage&&this._addedToStage&&this._drapeSourceRenderer.removeGeometries(this.renderGeometries,g.REMOVE),this._addedToStage=!1,this._visible=!1,this.stage=null}getCenterObjectSpace(r=t()){return e(r,0,0,0)}getBoundingBoxObjectSpace(e=r()){return i(e)}addObjectState(e){e.stateType===c.Highlight&&(this.renderGeometries.forEach((t=>{const r=t.geometry.allocateIdAndHighlight(e.highlightName);e.addRenderGeometry(t,r,this)})),this._addedToStage&&this._drapeSourceRenderer.modifyGeometries(this.renderGeometries,m.HIGHLIGHT))}removeObjectState(e){this.renderGeometries.forEach((t=>e.removeByObject(t)))}updateHighlights(e){}removeRenderGeometryObjectState(e,t){t.channel===c.Highlight&&(e.geometry.removeHighlight(t),this._addedToStage&&this._drapeSourceRenderer.modifyGeometries([e],m.HIGHLIGHT))}computeAttachmentOrigin(e){for(const t of this.renderGeometries)t.geometry.computeAttachmentOrigin(y)&&(e.draped.origin[0]+=y[0],e.draped.origin[1]+=y[1],e.draped.num++)}async getProjectedBoundingBox(e,t,r,d,n){i(n);for(let i=0;i<this.renderGeometries.length;i++){const t=this.renderGeometries[i];this._getRenderGeometryProjectedBoundingRect(t,e,u,r),o(n,u)}if(t){let e;s(n,y);const r=h(n,t.service.spatialReference,t);try{e=await t.service.queryElevation(y[0],y[1],d,r,"ground")}catch(a){}null!=e&&(n[2]=Math.min(n[2],e),n[5]=Math.max(n[5],e))}return n}_getRenderGeometryProjectedBoundingRect(e,t,r,i){if(this.boundingBox)d(p,this.boundingBox);else{const t=e.boundingSphere,r=t[3];p[0]=t[0]-r,p[1]=t[1]-r,p[2]=t[2]-r,p[3]=t[0]+r,p[4]=t[1]+r,p[5]=t[2]+r}return t(p,0,2),this.calculateRelativeScreenBounds&&i.push({location:s(p),screenSpaceBoundingRect:this.calculateRelativeScreenBounds()}),n(p,r)}}const u=a(),p=r(),y=t();export{l as Graphics3DDrapedGraphicLayer};