UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 9.41 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as e}from"../../../chunks/tslib.es6.js";import s from"../../../core/Error.js";import t from"../../../core/Logger.js";import{watch as i,initial as r}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{h as l,n,i as h}from"../../../chunks/vec32.js";import{create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import d 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 b}from"./LayerView3D.js";import{VoxelGraphic as V}from"./VoxelGraphic.js";import{addLayerViewToWasm as _,getVoxelWasm as w,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";var x;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(x||(x={}));const L=c(),A=c();let E=class extends(S(b(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(x.Error),"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),a=this.layer.getVariable(t);if(null!=o&&null!=a){const e=o.dimensions[0],s=o.dimensions[1],t=o.zDimension;if(t>1){const i=o.dimensions[t],r=e.size*s.size*i.size;let l=1;switch(a.renderingFormat.type){case"Int16":case"UInt16":l=2;break;case"Int32":case"UInt32":case"Float32":l=4}this._futureMemory=l*r}}const l=_(this).then((e=>{this._wasmLayerId=e,this._suspendedHandle=i((()=>this.suspended),(e=>{const s=w(this.view);s&&s.setEnabled(this,!e)}),r),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=w(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,A,this.view.spatialReference||d.WGS84))return p(e,A),Promise.resolve({boundingBox:e,screenSpaceObjects:[]})}return Promise.reject()}async whenGraphicAttributes(e,s){const t=w(this.view);if(!t)return e;const i=[];for(const r of e)this._isValidVoxelGraphic(r)&&i.push(r);return i.length&&await t.getOtherFieldPopupValues(i,s),e}_isValidVoxelGraphic(e){return e instanceof V}setUsedMemory(e){this._usedMemory=e,this._futureMemory=0}captureFrustum(){const e=w(this.view);e?.captureFrustum()}toggleFullVolumeExtentDraw(){const e=w(this.view);e?.toggleFullVolumeExtentDraw(this)}getLayerTimes(){const e=w(this.view);return e?.getLayerTimes(this)??[]}getCurrentLayerTimeIndex(){const e=w(this.view);return e?.getCurrentLayerTimeIndex(this)??0}dropQueryRenderTarget(){const e=w(this.view);e?.dropQueryRenderTarget()}_pushRenderModeToWasm(e){const s=w(this.view);this._dbg(x.VerboseAPI,"VoxelLayerView3D._pushRenderModeToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setRenderMode(this,e)||this._dbg(x.Error,"VoxelLayerView3D._pushRenderModeToWasm() failed!")}_pushSectionsToWasm(e){const s=w(this.view);this._dbg(x.VerboseAPI,"VoxelLayerView3D._pushSectionsToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setStaticSections(this,e)||this._dbg(x.Error,"VoxelLayerView3D._pushSectionsToWasm() failed!")}_pushCurrentVariableIdToWasm(e){const s=w(this.view);this._dbg(x.VerboseAPI,"VoxelLayerView3D._pushCurrentVariableIdToWasm() called!, "+(s?"have WASM":"don't have WASM!!!")),s?.setCurrentVariable(this,e)||this._dbg(x.Error,"VoxelLayerView3D._pushCurrentVariableIdToWasm() failed!")}_pushVariableStylesToWasm(e){const s=w(this.view);this._dbg(x.VerboseAPI,"VoxelLayerView3D._pushVariableStylesToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setVariableStyles(this,e)||this._dbg(x.Error,"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=w(this.view);this._dbg(x.VerboseAPI,"VoxelLayerView3D._pushVolumeStylesToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s&&(this._accountForEnableSlices(e,null),s.setVolumeStyles(this,e)||this._dbg(x.Error,"VoxelLayerView3D._pushVolumeStylesToWasm() failed!"))}_pushAnalysisSliceToWasm(e,s){const t=w(this.view);this._dbg(x.VerboseAPI,"VoxelLayerView3D._pushAnalysisSliceToWasm() called, "+(t?"have WASM":"don't have WASM!!!"));let i=!1;if(t){if(s){const r=s.origin;l(L,s.basis1,s.basis2),n(L,L),i=t.setAnalysisSlice(this,e,r,L)}else h(L,0,0,1),i=t.setAnalysisSlice(this,!1,L,L);i||this._dbg(x.Error,"VoxelLayerView3D._pushAnalysisSliceToWasm() failed!")}}_updateLayerTimeProperties(){const e=w(this.view);this._dbg(x.VerboseAPI,"VoxelLayerView3D._updateLayerTimeProperties() called, "+(e?"have WASM":"don't have WASM!!!")),e&&e.updateLayerTimeProperties(this)}_pushEnableDynamicSectionsToWasm(e){const s=w(this.view);this._dbg(x.VerboseAPI,"VoxelLayerView3D._pushEnableDynamicSectionsToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setEnableDynamicSections(this,e)||this._dbg(x.Error,"VoxelLayerView3D._pushEnableDynamicSectionsToWasm() failed!")}_pushEnableSlicesToWasm(e){const s=w(this.view);if(this._dbg(x.VerboseAPI,"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(x.Error,"VoxelLayerView3D._pushEnableSlicesToWasm() failed!")}}_pushEnableIsosurfacesToWasm(e){const s=w(this.view);this._dbg(x.VerboseAPI,"VoxelLayerView3D._pushEnableIsosurfacesToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setEnableIsosurfaces(this,e)||this._dbg(x.Error,"VoxelLayerView3D._pushEnableIsosurfacesToWasm() failed!")}_pushEnableSectionsToWasm(e){const s=w(this.view);this._dbg(x.VerboseAPI,"VoxelLayerView3D._pushEnableSectionsToWasm() called, "+(s?"have WASM":"don't have WASM!!!")),s?.setEnableSections(this,e)||this._dbg(x.Error,"VoxelLayerView3D._pushEnableSectionsToWasm() failed!")}_dbg(e,s){this._dbgFlags.has(e)&&(e===x.Error?t.getLogger(this).error(s):t.getLogger(this).warn(s))}};e([o()],E.prototype,"layer",void 0),e([o()],E.prototype,"baseUrl",null),e([o({type:Boolean})],E.prototype,"slicePlaneEnabled",void 0),e([o({readOnly:!0})],E.prototype,"visibleAtCurrentScale",null),E=e([a("esri.views.3d.layers.VoxelLayerView3D")],E);const M=E;export{M as default};