UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 8.86 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import s from"../../../core/Error.js";import t from"../../../core/Logger.js";import{watch as i,initial as a}from"../../../core/reactiveUtils.js";import{property as o,subclass as r}from"../../../core/accessorSupport/decorators.js";import{cross as l,normalize as n,set as h}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../geometry/SpatialReference.js";import{projectVectorToVector as u}from"../../../geometry/projection/projectVectorToVector.js";import{empty as m,expandWithVec3 as p}from"../../../geometry/support/aaBoundingBox.js";import{equals as y}from"../../../geometry/support/spatialReferenceUtils.js";import{LayerView3D as _}from"./LayerView3D.js";import{VoxelGraphic as b}from"./VoxelGraphic.js";import{addLayerViewToWasm as w,getVoxelWasm as V,removeLayerViewFromWasm as f}from"./VoxelWasm.js";import{LayerViewPerformanceInfo as g}from"./support/LayerViewPerformanceInfo.js";import{PopupSceneLayerView as S}from"./support/PopupSceneLayerView.js";import v from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as W,isInEffectiveScaleRange as T}from"../../support/layerViewUtils.js";const x=d(),L=d();let M=class extends(S(_(v))){constructor(){super(...arguments),this._suspendedHandle=null,this._usedMemory=0,this._futureMemory=0,this.type="voxel-3d",this.slicePlaneEnabled=!1,this._wasmLayerId=-1,this.ignoresMemoryFactor=!0,this._dbgFlags=new Set}get baseUrl(){return this.layer.parsedUrl?.path??""}get wasmLayerId(){return this._wasmLayerId}initialize(){if(this._dbgFlags.add(3),"local"!==this.view.viewingMode)throw new s("voxel:unsupported-viewingMode","Voxel layers support local viewingMode only.",{});if(!!!this.view.stage.renderView.renderingContext.capabilities.colorBufferFloat?.textureFloat)throw new s("voxel:missing-color-buffer-float","Voxel layers require the WebGL2 extension EXT_color_buffer_float",{});const e=this.layer.spatialReference;if(!y(e,this.view.spatialReference))throw W("voxel layer",e.wkid,this.view.spatialReference.wkid);const t=this.layer.currentVariableId,o=this.layer.getVolume(t),r=this.layer.getVariable(t);if(null!=o&&null!=r){const e=o.dimensions[0],s=o.dimensions[1],t=o.zDimension;if(t>1){const i=o.dimensions[t],a=e.size*s.size*i.size;let l=1;switch(r.renderingFormat.type){case"Int16":case"UInt16":l=2;break;case"Int32":case"UInt32":case"Float32":l=4}this._futureMemory=l*a}}const l=w(this).then(e=>{this._wasmLayerId=e,this._suspendedHandle=i(()=>this.suspended,e=>{const s=V(this.view);s&&s.setEnabled(this,!e)},a),this.addHandles([i(()=>this.layer.renderMode,e=>this._pushRenderModeToWasm(e)),i(()=>this.layer.currentVariableId,e=>this._pushCurrentVariableIdToWasm(e)),i(()=>this.layer.getSections(),e=>this._pushSectionsToWasm(e)),i(()=>this.layer.getVariableStyles(),e=>this._pushVariableStylesToWasm(e)),i(()=>this.layer.getVolumeStyles(),e=>this._pushVolumeStylesToWasm(e)),i(()=>this.layer.enableDynamicSections,e=>this._pushEnableDynamicSectionsToWasm(e)),i(()=>this.layer.enableIsosurfaces,e=>this._pushEnableIsosurfacesToWasm(e)),i(()=>this.layer.enableSections,e=>this._pushEnableSectionsToWasm(e)),i(()=>this.layer.enableSlices,e=>this._pushEnableSlicesToWasm(e)),i(()=>[this.layer.timeOffset,this.layer.timeExtent,this.layer.useViewTime],()=>this._updateLayerTimeProperties()),i(()=>this.slicePlaneEnabled,e=>this._pushAnalysisSliceToWasm(e,this.view.slice.plane)),i(()=>this.view.slice.plane,e=>this._pushAnalysisSliceToWasm(this.slicePlaneEnabled,e))])}).catch(e=>{if(f(this),this._wasmLayerId=-1,-1===e)throw new s("voxel:addLayer-failure","The voxel layer description was invalid.",{});if(-2===e)throw new s("voxel:addLayer-failure","The voxel layer web assembly module failed to download.",{})});this.addResolvingPromise(l)}destroy(){f(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null)}isUpdating(){const e=V(this.view);return!(this._wasmLayerId<0||null==e)&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}get usedMemory(){return this._usedMemory}get unloadedMemory(){return this._futureMemory}get performanceInfo(){return new g(this.usedMemory)}get visibleAtCurrentScale(){return T(this.layer.effectiveScaleRange,this.view.scale)}whenGraphicBounds(e,s){const t=e.attributes["Voxel.WorldPosition"];if(t){const e=m(),s=JSON.parse(t);if(u(s,this.view.renderSpatialReference,L,this.view.spatialReference||c.WGS84))return p(e,L),Promise.resolve({boundingBox:e,screenSpaceObjects:[]})}return Promise.reject()}async whenGraphicAttributes(e,s){const t=V(this.view);if(!t)return e;const i=[];for(const a of e)this._isValidVoxelGraphic(a)&&i.push(a);return i.length&&await t.getOtherFieldPopupValues(i,s),e}_isValidVoxelGraphic(e){return e instanceof b}setUsedMemory(e){this._usedMemory=e,this._futureMemory=0}captureFrustum(){const e=V(this.view);e?.captureFrustum()}toggleFullVolumeExtentDraw(){const e=V(this.view);e?.toggleFullVolumeExtentDraw(this)}getLayerTimes(){const e=V(this.view);return e?.getLayerTimes(this)??[]}getCurrentLayerTimeIndex(){const e=V(this.view);return e?.getCurrentLayerTimeIndex(this)??0}dropQueryRenderTarget(){const e=V(this.view);e?.dropQueryRenderTarget()}_pushRenderModeToWasm(e){const s=V(this.view);this._dbg(2,"VoxelLayerView3D._pushRenderModeToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setRenderMode(this,e)||this._dbg(3,"VoxelLayerView3D._pushRenderModeToWasm() failed!")}_pushSectionsToWasm(e){const s=V(this.view);this._dbg(2,"VoxelLayerView3D._pushSectionsToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setStaticSections(this,e)||this._dbg(3,"VoxelLayerView3D._pushSectionsToWasm() failed!")}_pushCurrentVariableIdToWasm(e){const s=V(this.view);this._dbg(2,"VoxelLayerView3D._pushCurrentVariableIdToWasm() called!, "+(s?"have WASM":"don't have WASM!!!")),s?.setCurrentVariable(this,e)||this._dbg(3,"VoxelLayerView3D._pushCurrentVariableIdToWasm() failed!")}_pushVariableStylesToWasm(e){const s=V(this.view);this._dbg(2,"VoxelLayerView3D._pushVariableStylesToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setVariableStyles(this,e)||this._dbg(3,"VoxelLayerView3D._pushVariableStylesToWasm() failed!")}_accountForEnableSlices(e,s){const t=null!=s?s:this.layer.enableSlices;for(let i=0;i<e.length;++i){const s=e[i];for(const e of s.slices)e.enabled=e.enabled&&t}}_pushVolumeStylesToWasm(e){const s=V(this.view);this._dbg(2,"VoxelLayerView3D._pushVolumeStylesToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s&&(this._accountForEnableSlices(e,null),s.setVolumeStyles(this,e)||this._dbg(3,"VoxelLayerView3D._pushVolumeStylesToWasm() failed!"))}_pushAnalysisSliceToWasm(e,s){const t=V(this.view);this._dbg(2,"VoxelLayerView3D._pushAnalysisSliceToWasm() called, "+(t?"have WASM":"don't have WASM!!!"));let i=!1;if(t){if(s){const a=s.origin;l(x,s.basis1,s.basis2),n(x,x),i=t.setAnalysisSlice(this,e,a,x)}else h(x,0,0,1),i=t.setAnalysisSlice(this,!1,x,x);i||this._dbg(3,"VoxelLayerView3D._pushAnalysisSliceToWasm() failed!")}}_updateLayerTimeProperties(){const e=V(this.view);this._dbg(2,"VoxelLayerView3D._updateLayerTimeProperties() called, "+(e?"have WASM":"don't have WASM!!!")),e&&e.updateLayerTimeProperties(this)}_pushEnableDynamicSectionsToWasm(e){const s=V(this.view);this._dbg(2,"VoxelLayerView3D._pushEnableDynamicSectionsToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setEnableDynamicSections(this,e)||this._dbg(3,"VoxelLayerView3D._pushEnableDynamicSectionsToWasm() failed!")}_pushEnableSlicesToWasm(e){const s=V(this.view);if(this._dbg(2,"VoxelLayerView3D._pushEnableSlicesToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s){const t=this.layer.getVolumeStyles();this._accountForEnableSlices(t,e),s.setVolumeStyles(this,t)||this._dbg(3,"VoxelLayerView3D._pushEnableSlicesToWasm() failed!")}}_pushEnableIsosurfacesToWasm(e){const s=V(this.view);this._dbg(2,"VoxelLayerView3D._pushEnableIsosurfacesToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setEnableIsosurfaces(this,e)||this._dbg(3,"VoxelLayerView3D._pushEnableIsosurfacesToWasm() failed!")}_pushEnableSectionsToWasm(e){const s=V(this.view);this._dbg(2,"VoxelLayerView3D._pushEnableSectionsToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setEnableSections(this,e)||this._dbg(3,"VoxelLayerView3D._pushEnableSectionsToWasm() failed!")}_dbg(e,s){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(s):t.getLogger(this).warn(s))}};e([o()],M.prototype,"layer",void 0),e([o()],M.prototype,"baseUrl",null),e([o({type:Boolean})],M.prototype,"slicePlaneEnabled",void 0),e([o({readOnly:!0})],M.prototype,"visibleAtCurrentScale",null),M=e([r("esri.views.3d.layers.VoxelLayerView3D")],M);const A=M;export{A as default};