@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 4.07 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import o from"../../../../core/Logger.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromQuat as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as l,t as c}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as m}from"../../../../geometry/projection/projectBoundingSphere.js";import{empty as u,expand as h}from"../../../../geometry/support/aaBoundingRect.js";import{f as d}from"../../../../chunks/sphere.js";import{ElevationRange as f}from"../../support/ElevationRange.js";import{ElevationUpdateEvent as v}from"../../support/ElevationUpdateEvent.js";import{newIntersector as g}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as E}from"../../webgl-engine/lib/IntersectorInterfaces.js";let x=class extends(r.EventedMixin(t)){constructor(e){super(e),this._tmpEvent=new v,this._renderCoordsHelper=e.view.renderCoordsHelper,this._renderSR=this._renderCoordsHelper.spatialReference,this._layerElevationSource=e.layerElevationSource}initialize(){this._intersector=g(this.view.state.viewingMode),this._intersector.options.store=E.MIN,this._intersector.options.normalRequired=!1,this._tmpEvent.context=this.intersectionHandler.isGround?"ground":"scene"}get spatialReference(){return this.view?.elevationProvider?.spatialReference}getElevation(e,t,r,n){const i=this._renderCoordsHelper,s=l(R,e,t,r);if(!i.toRenderCoords(s,n,s))return o.getLogger(this).error("could not project point to compute elevation"),null;const{layerElevationSource:a,_intersector:c,intersectionHandler:p}=this,m=a.fullExtent,u=null!=m&&Number.isFinite(m.xmin)&&Number.isFinite(m.xmax)&&Number.isFinite(m.ymin)&&Number.isFinite(m.ymax)&&Number.isFinite(m.zmin)&&Number.isFinite(m.zmax)?new f(m.zmin,m.zmax):a.elevationRange;if(null==u)return null;const h=a.elevationOffset,d=u.elevationRangeMin+h,v=u.elevationRangeMax+h,g=i.setAltitude(y,v,s),E=i.setAltitude(b,d,s);return c.reset(g,E,null),p.intersect(c,null,g,E,null,!0),c.results.min.getIntersectionPoint(s)?i.getAltitude(s):null}getSphereElevationBounds(e,t){return m(e,t,j,this._renderSR),this._layerElevationSource.getElevationRange(j)}getRootElevationBounds(){const e=this.layerElevationSource.fullExtent;return e?.hasZ?new f(e.zmin,e.zmax):null}objectsChanged(e){this.spatialReference&&(this._computeLayerExtent(e,this._tmpEvent.extent),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}objectChanged(e){this.spatialReference&&(this._computeObjectExtent(e,this._tmpEvent.extent),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}_computeObjectExtent(e,t){u(t),this._expandExtent(e,t)}_computeLayerExtent(e,t){u(t);for(const r of e)this._expandExtent(r,t)}_expandExtent(e,t){const r=this.spatialReference;if(null==r)return;if(null==e)return;s(_,e.quaternion),_[12]=e.center[0],_[13]=e.center[1],_[14]=e.center[2];const o=e.halfSize;for(let n=0;n<8;++n)R[0]=1&n?o[0]:-o[0],R[1]=2&n?o[1]:-o[1],R[2]=4&n?o[2]:-o[2],c(R,R,_),this._renderCoordsHelper.fromRenderCoords(R,R,r),h(t,R,t)}};e([n({constructOnly:!0})],x.prototype,"layerElevationSource",void 0),e([n({constructOnly:!0})],x.prototype,"intersectionHandler",void 0),e([n({constructOnly:!0})],x.prototype,"view",void 0),e([n()],x.prototype,"spatialReference",null),x=e([i("esri.views.3d.layers.i3s.LayerElevationProvider")],x);const _=a(),j=d(0,0,0,0),R=p(),y=p(),b=p();export{x as LayerElevationProvider};