1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vxlLayer-Dmur8zFy.js","assets/_commonjsHelpers-DCkdB7M8.js"])))=>i.map(i=>d[i]); 2import{cd as $,f4 as D,r as B,m as N,a as z,kv as H,kw as j,dx as G,y as R,E as I,P as A,kx as K,ky as F,kz as L,aq as M,a1 as X,kA as q,kB as T,kC as V,kD as Y,d1 as Q,kE as J,kF as Z,kG as ee,I as U,dR as te,da as se,kH as ie,ay as re,kI as ae}from"./index-CqO0JfRZ.js";import{t as ne}from"./VoxelGraphic-CTpMZPzU.js";var O,P,C,W,b,E;(function(e){e[e.Binary=0]="Binary",e[e.JSON=1]="JSON"})(O||(O={})),function(e){e[e.TreeIndex=0]="TreeIndex",e[e.TreeStats=1]="TreeStats",e[e.TreeData=2]="TreeData",e[e.BrickBundles=3]="BrickBundles",e[e.Section=4]="Section",e[e.VariableStats=5]="VariableStats"}(P||(P={})),function(e){e[e.None=1]="None",e[e.Front=2]="Front",e[e.Back=3]="Back"}(C||(C={})),function(e){e[e.Low=0]="Low",e[e.Medium=1]="Medium",e[e.High=2]="High"}(W||(W={})),function(e){e[e.None=0]="None",e[e.StaticSections=1]="StaticSections",e[e.Slices=2]="Slices",e[e.DynamicSections=4]="DynamicSections",e[e.GhostShell=8]="GhostShell",e[e.Isosurface=16]="Isosurface",e[e.Quality=32]="Quality",e[e.SunLocation=64]="SunLocation",e[e.StaticSectionSelection=128]="StaticSectionSelection",e[e.ExaggerationAndOffset=256]="ExaggerationAndOffset",e[e.CurrentTime=512]="CurrentTime",e[e.CurrentVariable=1024]="CurrentVariable",e[e.DeleteIsosurface=2048]="DeleteIsosurface",e[e.ContainerVisibility=4096]="ContainerVisibility",e[e.RenderMode=8192]="RenderMode",e[e.Optimization=16384]="Optimization",e[e.VariableStyles=32768]="VariableStyles",e[e.VolumeStyles=65536]="VolumeStyles",e[e.AnalysisSlice=131072]="AnalysisSlice"}(b||(b={})),function(e){e[e.Isosurfaces=0]="Isosurfaces",e[e.DynamicSections=1]="DynamicSections",e[e.StaticSections=2]="StaticSections"}(E||(E={}));function le(e){return new Promise(t=>$(()=>import("./vxlLayer-Dmur8zFy.js"),__vite__mapDeps([0,1])).then(s=>s.v).then(({default:s})=>{const i=s({locateFile:oe,preinitializedWebGLContext:e,onRuntimeInitialized:()=>t(i)})})).catch(t=>{throw t})}function oe(e){return D(`esri/libs/vxl/${e}`)}var u;(function(e){e[e.Lifetime=1]="Lifetime",e[e.RequestResponse=2]="RequestResponse",e[e.Rendering=3]="Rendering",e[e.Error=4]="Error"})(u||(u={}));let k=class extends H{constructor(e){super(e),this._halfIntTexturesAvailable=!1,this._textureFloatLinearAvailable=!1,this._havePreparedWithAllLayers=!1,this._renderPluginContext=null,this._vxlPromise=null,this._vxl=null,this._pluginIsActive=!1,this._moreToLoad=!1,this._viewportWidth=-1,this._viewportHeight=-1,this._newLayers=[],this._layers=new Map,this._rctx=null,this._renderTargetToRestore=null,this._lastFrameWasStationary=!1,this._wasmMemBlockSizes=[512,1024,2048,4096,8192,16384,32768,65536],this._wasmMemBlocks=new Map,this._dbgFlags=new Set,this._captureFrustum=!1,this._frustum=null,this._frustumRenderableId=-1,this._renderCoordsHelper=null,this.produces=new Map([[j.VOXEL,()=>!!this._vxl&&this.view.viewingMode==="local"]]),this.type=G.VOXEL,this.slicePlaneEnabled=!0,this.isGround=!1,this.layerUid=[]}_dbg(e,t){this._dbgFlags.has(e)&&(e===u.Error?R.getLogger(this).error(t):R.getLogger(this).warn(t))}_removeRenderPlugin(){this._pluginIsActive&&this.view._stage&&(this._dbg(u.Lifetime,"--removeRenderPlugin--"),this.view._stage.removeRenderPlugin(this)),this._pluginIsActive=!1}initialize(){this._dbg(u.Lifetime,"--initialize--");for(const e of this._wasmMemBlockSizes)this._wasmMemBlocks.set(e,0);this.addHandles([I(()=>this.view.ready,e=>{e&&this.view.viewingMode==="local"?(this._dbg(u.Lifetime,"view ready status changed to ready on a local view, calling addRenderPlugin"),this.view._stage.addRenderPlugin(this),this._pluginIsActive=!0):(this._dbg(u.Lifetime,"view ready status changed, not ready or not a local view!"),this._removeRenderPlugin())},A),I(()=>{var e;return(e=this.view)==null?void 0:e.qualityProfile},e=>{this._dbg(u.Rendering,"qualityProfile changed to "+e),this._vxl&&this._vxl.set_quality(this._toWasmQuality(e))},A),I(()=>{var e;return(e=this.view)==null?void 0:e.timeExtent},()=>{var e;if(this._vxl){const t=this._getTimeArgs((e=this.view)==null?void 0:e.timeExtent);this._dbg(u.Rendering,"sceneView timeExtent changed to useTime="+t.hasTime+" st="+t.startTime+" et="+t.endTime),this._vxl.set_scene_time_extent(t.startTime,t.endTime,t.hasTime),this._renderPluginContext.requestRender()}},A),I(()=>{var e;return(e=this.view)==null?void 0:e.stationary},e=>{this._vxl&&e&&!this._lastFrameWasStationary&&this._renderPluginContext.requestRender()})])}initializeRenderContext(e){this._dbg(u.Lifetime,"--initializeRenderContext--");const t=e.renderContext.rctx;this._renderPluginContext=e,this._rctx=e.renderContext.rctx,this._halfIntTexturesAvailable=!!this._rctx.capabilities.textureNorm16,this._textureFloatLinearAvailable=this._rctx.capabilities.textureFloatLinear,this._initializeWasm(t.gl)}uninitializeRenderContext(){this._renderPluginContext=null,this._rctx=null,this._dbg(u.Lifetime,"--uninitializeRenderContext--")}_restoreFramebuffer(){if(!this._renderTargetToRestore)return;const e=this._renderTargetToRestore.fbo;if(!this._rctx)return void this._dbg(u.Error,"no context in restoreFramebuffer!");this._rctx.bindFramebuffer(e,!0);const t=this._renderTargetToRestore.viewport;this._rctx.setViewport(t.x,t.y,t.width,t.height)}_bindPreviousDepthToSlot(e,t){const s=!!this._rctx,i=!!this._renderTargetToRestore;if(!s||!i)return 0;const a=this._renderTargetToRestore.fbo.depthStencilTexture;return a?(t===0?this._rctx.bindTexture(null,e,!0):this._rctx.bindTexture(a,e,!0),1):(this._dbg(u.Error,"no depth/stencil texture exists!"),0)}_modifyResourceCount(e,t,s){if(!this._rctx)return void this._dbg(u.Error,"modifyAllocation callback has no rendering context!");const i=e;s===1?this._rctx.instanceCounter.increment(i,t):this._rctx.instanceCounter.decrement
2(i,t)}_setBlendState(e,t,s,i){this._rctx?(this._rctx.setBlendingEnabled(e===1),this._rctx.setBlendFunction(t,s),this._rctx.setBlendEquation(i)):this._dbg(u.Error,"setBlendState callback has no rendering context!")}_setFrontFace(e){this._rctx?this._rctx.setFrontFace(e):this._dbg(u.Error,"setFrontFace callback has no rendering context!")}_setDepthStencilStateFunction(e,t,s){this._rctx?(this._rctx.setDepthFunction(s),this._rctx.setDepthTestEnabled(e===1),this._rctx.setDepthWriteEnabled(t===1),this._rctx.setStencilTestEnabled(!1),this._rctx.setStencilFunction(K.ALWAYS,0,255),this._rctx.setStencilOpSeparate(F.FRONT,L.KEEP,L.INCR,L.KEEP),this._rctx.setStencilOpSeparate(F.BACK,L.KEEP,L.DECR,L.KEEP)):this._dbg(u.Error,"setDepthStencilStateFunction callback has no rendering context!")}_setRasterizerState(e){if(this._rctx)switch(e){case C.None:this._rctx.setFaceCullingEnabled(!1);break;case C.Back:this._rctx.setCullFace(F.BACK),this._rctx.setFaceCullingEnabled(!0);break;case C.Front:this._rctx.setCullFace(F.FRONT),this._rctx.setFaceCullingEnabled(!0)}else this._dbg(u.Error,"setRasterizerState callback has no rendering context!")}_setViewport(e,t,s,i){this._rctx?this._rctx.setViewport(e,t,s,i):this._dbg(u.Error,"setViewport callback has no rendering context!")}_updateMemoryUsage(){this._layers.forEach((e,t)=>{if(e.needMemoryUsageUpdate){const s=this._vxl.estimate_memory_usage(t);s>=0&&(e.needMemoryUsageUpdate=!1,e.layerView.setUsedMemory(s))}})}_syncRequestsResponses(){this._layers.forEach((e,t)=>{const s=[];e.responses.forEach((r,h)=>{s.push(h),this._dbg(u.RequestResponse,"responding for requestID:"+h+" size:"+r.size),this._vxl.respond(t,h,r),r.requestType!==P.TreeIndex&&r.requestType!==P.Section||(e.needMemoryUsageUpdate=!0)});const i=e.responses;for(const r of s)i.delete(r);const a=this._vxl.get_new_requests(t),n=e.abortController.signal;for(const r in a){e.outstandingRequestCount+=1,e.outstandingRequestCount===1&&e.layerView.updatingFlagChanged();const h=a[r],y={responseType:"array-buffer",signal:n,query:{...e.layerView.layer.customParameters,token:e.layerView.layer.apiKey}};this._dbg(u.RequestResponse,"making requestID:"+r+" url:"+h.url),M(h.url,y).then(o=>{e.outstandingRequestCount-=1,e.outstandingRequestCount===0&&e.layerView.updatingFlagChanged(),this._dbg(u.RequestResponse,"have response for requestID:"+r);let g=0;if(o.data.byteLength>0){g=this._vxl._malloc(o.data.byteLength);const m=new Uint8Array(this._vxl.HEAPU8.buffer,g,o.data.byteLength),l=new Uint8Array(o.data);for(let x=0;x<o.data.byteLength;++x)m[x]=l[x]}i.set(+r,{responseType:h.responseType,ptr:g,size:o.data.byteLength,success:!0,requestType:h.requestType})}).catch(o=>{e.outstandingRequestCount-=1,e.outstandingRequestCount===0&&e.layerView.updatingFlagChanged(),X(o)||(this._dbg(u.Error,`requestID:${r} failed, error=${o.toString()}`),i.set(+r,{responseType:h.responseType,ptr:0,size:0,success:!1,requestType:h.requestType}))})}})}updateWasmCamera(e){this._vxl.set_projection_matrix.apply(this._vxl,e.projectionMatrix),this._vxl.set_view_matrix.apply(this._vxl,e.viewMatrix),this._vxl.set_near_far(e.near,e.far)}isUpdating(e){if(!this._vxl&&this._vxlPromise)return!0;const t=this._layers.get(e);return!!t&&t.outstandingRequestCount>0}getLayerTimes(e){const t=[];return this._layers.forEach((s,i)=>{if(s.layerView.wasmLayerId===e.wasmLayerId){const a=this._vxl.get_layer_epoch_times(i,e.layer.currentVariableId);for(let n=0;n<a.length;++n)t.push(a[n])}}),t}getCurrentLayerTimeIndex(e){let t=0;return this._layers.forEach((s,i)=>{s.layerView.wasmLayerId===e.wasmLayerId&&(t=this._vxl.get_layer_current_time_id(i))}),t}setEnabled(e,t){this._layers.forEach((s,i)=>{s.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.set_enabled(i,t),s.needMemoryUsageUpdate=!0,this._renderPluginContext.requestRender())})}setIsInScaleRange(e,t){const s=this._layers.get(e.wasmLayerId);s&&t!==s.isInScaleRange&&(s.isInScaleRange=t,this._vxl.set_is_in_scale_range(e.wasmLayerId,t),s.needMemoryUsageUpdate=!t,this._renderPluginContext.requestRender())}setStaticSections(e,t){const s={mask:b.StaticSections,staticSections:t};return this._doMaskedUIUpdate(e,s,!0)}setCurrentVariable(e,t){const s={mask:b.CurrentVariable,currentVariable:t};return this._doMaskedUIUpdate(e,s,!0)}setRenderMode(e,t){const s={mask:b.RenderMode,renderMode:t};return this._doMaskedUIUpdate(e,s,!0)}setVerticalExaggerationAndOffset(e,t,s,i){const a={mask:b.ExaggerationAndOffset,volStyleDesc:{volumeId:t,verticalExaggeration:s,verticalOffset:i}};return this._doMaskedUIUpdate(e,a,!0)}setVariableStyles(e,t){const s={mask:b.VariableStyles,variableStyles:t};return this._doMaskedUIUpdate(e,s,!0)}setVolumeStyles(e,t){const s={mask:b.VolumeStyles,volumeStyles:t};return this._doMaskedUIUpdate(e,s,!0)}setEnableDynamicSections(e,t){const s={mask:b.ContainerVisibility,containerIsVisible:t,container:E.DynamicSections};return this._doMaskedUIUpdate(e,s,!0)}setEnableIsosurfaces(e,t){const s={mask:b.ContainerVisibility,containerIsVisible:t,container:E.Isosurfaces};return this._doMaskedUIUpdate(e,s,!0)}setEnableSections(e,t){const s={mask:b.ContainerVisibility,containerIsVisible:t,container:E.StaticSections};return this._doMaskedUIUpdate(e,s,!0)}
2setAnalysisSlice(e,t,s,i){const a={mask:b.AnalysisSlice,analysisSlice:{point:s,normal:i,enabled:t}};return this._doMaskedUIUpdate(e,a,!0)}updateLayerTimeProperties(e){if(!this._vxl)return;const t=this._layers.get(e.wasmLayerId);if(t){const s=t.layerView.layer;let i=0;s.timeOffset&&(i=q(s.timeOffset.value,s.timeOffset.unit,"seconds"));const a=this._getTimeArgs(s.timeExtent);this._vxl.set_layer_time_properties(e.wasmLayerId,a.startTime,a.endTime,a.hasTime,s.useViewTime,i),this._renderPluginContext.requestRender()}}_doMaskedUIUpdate(e,t,s){if(!this._vxl)return!1;let i=!1;return this._layers.forEach((a,n)=>{if(a.layerView.wasmLayerId===e.wasmLayerId){const r={str:JSON.stringify(t),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(r)&&(i=this._vxl.handle_masked_ui_update(n,r.ptr,r.byteCount)===1,r.isReusable||this._vxl._free(r.ptr))}}),i&&s&&this._renderPluginContext.requestRender(),i}_addTriangleToWasmBuffer(e,t,s,i,a){return e[3*t]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],e[3*(t+=1)]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],e[3*(t+=1)]=a[0],e[3*t+1]=a[1],e[3*t+2]=a[2],t+=1}
2_addNormalToWasmBuffer(e,t,s){return e[3*t]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],t+=1}_doCaptureFrustum(){if(!this._vxl)return;const e=36,t=e/3,s=this._vxl._malloc(3*e*Float32Array.BYTES_PER_ELEMENT),i=new Float32Array(this._vxl.HEAPF32.buffer,s,3*e),a=this._vxl._malloc(3*t*Float32Array.BYTES_PER_ELEMENT),n=new Float32Array(this._vxl.HEAPF32.buffer,a,e),r=this._frustum.points[T.NEAR_BOTTOM_LEFT],h=this._frustum.points[T.NEAR_BOTTOM_RIGHT],y=this._frustum.points[T.NEAR_TOP_RIGHT],o=this._frustum.points[T.NEAR_TOP_LEFT],g=this._frustum.points[T.FAR_BOTTOM_LEFT],m=this._frustum.points[T.FAR_BOTTOM_RIGHT],l=this._frustum.points[T.FAR_TOP_RIGHT],x=this._frustum.points[T.FAR_TOP_LEFT];let d=0,f=0;const v=this._frustum.planes[V.NEAR];d=this._addTriangleToWasmBuffer(i,d,y,h,r),f=this._addNormalToWasmBuffer(n,f,v),d=this._addTriangleToWasmBuffer(i,d,r,o,y),f=this._addNormalToWasmBuffer(n,f,v);const _=this._frustum.planes[V.FAR];d=this._addTriangleToWasmBuffer(i,d,g,m,l),f=this._addNormalToWasmBuffer(n,f,_),d=this._addTriangleToWasmBuffer(i,d,l,x,g),f=this._addNormalToWasmBuffer(n,f,_);const p=this._frustum.planes[V.TOP];d=this._addTriangleToWasmBuffer(i,d,l,y,o),f=this._addNormalToWasmBuffer(n,f,p),d=this._addTriangleToWasmBuffer(i,d,o,x,l),f=this._addNormalToWasmBuffer(n,f,p);const c=this._frustum.planes[V.BOTTOM];d=this._addTriangleToWasmBuffer(i,d,r,h,m),f=this._addNormalToWasmBuffer(n,f,c),d=this._addTriangleToWasmBuffer(i,d,m,g,r),f=this._addNormalToWasmBuffer(n,f,c);const w=this._frustum.planes[V.LEFT];d=this._addTriangleToWasmBuffer(i,d,o,r,g),f=this._addNormalToWasmBuffer(n,f,w),d=this._addTriangleToWasmBuffer(i,d,g,x,o),f=this._addNormalToWasmBuffer(n,f,w);const S=this._frustum.planes[V.RIGHT];d=this._addTriangleToWasmBuffer(i,d,y,l,m),f=this._addNormalToWasmBuffer(n,f,S),d=this._addTriangleToWasmBuffer(i,d,m,h,y),f=this._addNormalToWasmBuffer(n,f,S),this._frustumRenderableId!==-1&&this._vxl.remove_generic_mesh(this._frustumRenderableId),this._frustumRenderableId=this._vxl.add_generic_mesh(s,3*e,a,e,255,0,0,64),this._vxl._free(s),this._vxl._free(a),this._captureFrustum=!1,this._renderPluginContext.requestRender()}captureFrustum(){this._renderCoordsHelper===null&&(this._renderCoordsHelper=Y.create(Q.Local,J(!1,this.view.spatialReference))),this._frustum===null&&(this._frustum=new Z(this._renderCoordsHelper)),this._captureFrustum=!0,this._renderPluginContext!==null&&this._renderPluginContext.requestRender()}toggleFullVolumeExtentDraw(e){this._vxl&&this._layers.forEach((t,s)=>{t.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.toggle_full_volume_extent_draw(s),this._renderPluginContext.requestRender())})}dropQueryRenderTarget(){this._vxl&&this._vxl.drop_query_rt()}addVoxelLayer(e){if(!this._vxl){const s={layerView:e,resolveCallback:null,rejectCallback:null},i=new Promise((a,n)=>{s.resolveCallback=a,s.rejectCallback=n});return this._newLayers.push(s),i}const t=this._addVoxelLayer(e);return t<0?Promise.reject(-1):Promise.resolve(t)}removeVoxelLayer(e){if(!this._vxl){const i=this._newLayers.findIndex(n=>e.uid===n.layerView.uid);i>=0&&(this._newLayers[i].resolveCallback(-1),this._newLayers.splice(i,1));const a=this._newLayers.length;return a===0&&(this._dbg(u.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),a}let t=-1;this._layers.forEach((i,a)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){t=a,i.abortController.abort(),this._vxl.remove_layer(t);const n=this.layerUid.indexOf(e.layer.uid);n!==-1&&this.layerUid.splice(n,1)}}),t>=0&&this._layers.delete(t);const s=this._layers.size;return s===0&&(this._dbg(u.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),s}_getBlockSize(e){for(const t of this._wasmMemBlockSizes)if(e<t)return t;return-1}_allocateBlock(e){e.byteCount=this._vxl.lengthBytesUTF8(e.str)+1;const t=this._getBlockSize(e.byteCount);return t<0?(e.isReusable=!1,e.ptr=this._vxl._malloc(e.byteCount)):(e.isReusable=!0,e.ptr=this._wasmMemBlocks.get(t),e.ptr===0&&(e.ptr=this._vxl._malloc(t),this._wasmMemBlocks.set(t,e.ptr))),e.ptr!==0&&(this._vxl.stringToUTF8(e.str,e.ptr,e.byteCount),!0)}_getTimeArgs(e){let t=-Number.MAX_VALUE,s=Number.MAX_VALUE,i=!1;return e!=null&&(e.isAllTime?i=!0:(e.start!=null&&(i=!0,t=e.start.getTime()/1e3),e.end!=null&&(i=!0,s=e.end.getTime()/1e3))),{startTime:t,endTime:s,hasTime:i}}_addVoxelLayer(e){var y;const t=e.layer;let s=-1;const i=t.getConfiguration();if(i.length<1)return-1;const a={str:i,byteCount:0,ptr:0,isReusable:!1};if(!this._allocateBlock(a))return-1;const n=this._getTimeArgs(t.timeExtent),r=this.view.spatialReference.isWGS84&&t.spatialReference.isWGS84?111319.49079327357:1;let h=0;if(t.timeOffset&&(h=q(t.timeOffset.value,t.timeOffset.unit,"seconds")),s=this._vxl.add_layer(t.serviceRoot,a.ptr,a.byteCount,r,r,n.startTime,n.endTime,n.hasTime,t.useViewTime,h,this._toWasmQuality(this.view.qualityProfile)),a.isReusable||this._vxl._free(a.ptr),s>=0){(y=t.test)!=null&&y.constantUpscaling&&(this._setUpscalingLimits(0,.25,.25),this._setUpscalingLimits(1,.5,.5),this._setUpscalingLimits(2,.75,.75));const o=new AbortController;if(this._layers.set(s,{layerView:e,responses:new Map,outstandingRequestCount:0,abortController:o,needMemoryUsageUpdate:!1,isInScaleRange:!0}),this.layerUid.push(e.layer.uid),!this._halfIntTexturesAvailable||U("mac")){const g=[];let m="";for(const l of e.layer.variables)l.renderingFormat.type!=="Int16"&&l.renderingFormat.type!=="UInt16"||(g.push(l.name),l.id===e.layer.currentVariableId&&(m=l.name));m!==""&&R.getLogger(this).error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${m}' in this browser`),g.length>
20&&R.getLogger(this).warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${g.toString()}' in this browser`)}if(!this._textureFloatLinearAvailable){const g=[];let m="";for(const l of e.layer.variables)l.renderingFormat.type==="Float32"&&(g.push(l.name),l.id===e.layer.currentVariableId&&(m=l.name));m!==""&&R.getLogger(this).error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${m}' in this browser`),g.length>0&&R.getLogger(this).warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${g.toString()}' in this browser`)}return U("esri-mobile")&&R.getLogger(this).warnOnce("Mobile support differs across devices. Voxel layer might not display as expected."),s}return-1}prepareRender(e){if(!this._vxl)return;const t=e.bind.camera.viewForward,s=e.bind.camera.eye;this._vxl.update_camera_pos_and_direction(s[0],s[1],s[2],t[0],t[1],t[2]);const i=this._vxl.cull();this._dbg(u.RequestResponse,"missingResourceCount="+i),this._moreToLoad=i>0,this._havePreparedWithAllLayers=this._newLayers.length===0,this._updateMemoryUsage()}acquireTechniques(){return[]}render(e){if(!this._vxl)return;for(const s of this._newLayers){const i=this._addVoxelLayer(s.layerView);i===-1?s.rejectCallback(-1):s.resolveCallback(i)}if(this._newLayers=[],this._layers.size===0)return void this._dbg(u.Error,"No voxel layers but RenderPlugin instance is being asked to render!");this._lastFrameWasStationary=this.view.stationary,this._syncRequestsResponses(),this._beforeDraw(),this._vxl.begin_color_frame(!this.view._stage.renderer.isFeatureEnabled(ee.HighResolutionVoxel),e.bind.lighting.mainLight.direction[0],e.bind.lighting.mainLight.direction[1],e.bind.lighting.mainLight.direction[2]);const t=this._renderTargetToRestore.viewport;t.width===this._viewportWidth&&t.height===this._viewportHeight||(this._viewportWidth=t.width,this._viewportHeight=t.height,this._vxl.set_viewport(t.width,t.height),this._layers.forEach(s=>{s.needMemoryUsageUpdate=!0})),t.x===0&&t.y===0||this._dbg(u.Error,"Unsupported viewport parameters detected!"),this.updateWasmCamera(e.bind.camera),this._captureFrustum&&(this._frustum.update(e.bind.camera),this._doCaptureFrustum()),this._vxl.draw(),this._afterDraw(),(this._moreToLoad||!this._havePreparedWithAllLayers&&this._layers.size>0)&&this._renderPluginContext.requestRender()}destroy(){this._dbg(u.Lifetime,"--destroy--"),this._vxl&&(this._layers.forEach(e=>{e.abortController.abort()}),this._wasmMemBlocks.forEach(e=>{e!==0&&this._vxl._free(e)}),this._vxl.uninitialize_voxel_wasm(),this._removeRenderPlugin(),this._vxl=null)}_initializeWasm(e){return this._vxl?Promise.resolve():(this._vxlPromise||(this._vxlPromise=le(e).then(t=>{var x;if(this._vxl=t,this._vxlPromise=null,this._newLayers.length<=0)return this._dbg(u.Lifetime," no voxel layers left after WASM downloaded, removing RenderPlugin and destroying"),void this.destroy();const s=this._getTimeArgs((x=this.view)==null?void 0:x.timeExtent),i=this._vxl.addFunction(this._restoreFramebuffer.bind(this),"v"),a=this._vxl.addFunction(this._setBlendState.bind(this),"viiii"),n=this._vxl.addFunction(this._setFrontFace.bind(this),"vi"),r=this._vxl.addFunction(this._setRasterizerState.bind(this),"vi"),h=this._vxl.addFunction(this._setDepthStencilStateFunction.bind(this),"viii"),y=this._vxl.addFunction(this._setViewport.bind(this),"viiii"),o=this._vxl.addFunction(this._bindPreviousDepthToSlot.bind(this),"iii"),g=this._vxl.addFunction(this._modifyResourceCount.bind(this),"viii"),m=this._halfIntTexturesAvailable&&!U("mac"),l=this._textureFloatLinearAvailable;this._vxl.initialize_voxel_wasm(i,a,n,r,h,y,o,g,s.startTime,s.endTime,s.hasTime,m,l),this._renderPluginContext&&this._renderPluginContext.requestRender()}).catch(()=>{for(const t of this._newLayers)t.rejectCallback(-2);this._dbg(u.Error," WASM failed to download, removing RenderPlugin and destroying"),this.destroy()})),this._vxlPromise)}pickDepth(e,t,s){if(!this._vxl||!this._rctx||this._layers.size===0)return null;const i=s.viewport[3]-t;if(e<0||e>s.viewport[2]||t<0||t>s.viewport[3])return this._dbg(u.Error,`[js] pickDepth: outOfRange, screenXY=[${e.toFixed(0)}, ${i.toFixed(0)}]]`),null;this._beforeDraw();const a=s.viewForward,n=s.eye;this._vxl.update_camera_pos_and_direction(n[0],n[1],n[2],a[0],a[1],a[2]),this.updateWasmCamera(s),this._vxl.begin_frame();const r=this._vxl.pick_depth(e,i);return this._afterDraw(),r.success?r.distanceToCamera:null}pickObject(e,t,s,i){if(!this._vxl||!this._rctx||this._layers.size===0)return null;const a=Math.round(e),n=Math.round(t);if(a<0||a>s.viewport[2]||n<0||n>s.viewport[3])return this._dbg(u.Error,`[js] pickObject: outOfRange, screenXY=[${a}, ${n}], vp=[${s.viewport.toString()}]`),null;this._beforeDraw();const r=s.viewForward,h=s.eye;this._vxl.update_camera_pos_and_direction(h[0],h[1],h[2],r[0],r[1],r[2]),this.updateWasmCamera(s),this._vxl.begin_frame();let y=null;if(i.length===0)y=this._vxl.pick_object(a,n,0,0);else{const o={str:JSON.stringify({layerIds:i}),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(o)&&(y=this._vxl.pick_object(a,n,o.ptr,o.byteCount),o.isReusable||this._vxl._free(o.ptr))}return this._afterDraw(),y}async getOtherFieldPopupValues(e,t){var s;for(const i of e){const a=i.gpuResult;if(!a)continue;const n=this._layers.get(a.layerId);if(!n||!n.layerView.layer.url)continue;const r=n.layerView.layer,h={responseType:"array-buffer",signal:n.abortController.signal,query:{...n.layerView.layer.customParameters,token:n.layerView.layer.apiKey}},y=a.voxelSpacePosition,o=[Math.floor(y[0]/32),Math.floor(y[1]/32),Math.floor(y[2]/32)],g=[-4&o[0],-4&o[1],-4&o[2]];let m=0;if(a.epochTime){const _=this._vxl.get_layer_epoch_times(n.layerView.wasmLayerId,r.currentVariableId);for(let p=0;p<_.length;++p)if(_[p]===a.epochTime/1e3){m=p;break}}const l=[],x={varIds:[],ptrs:[],sizes:[]};for(const _ of t){const p=r.variables.findIndex(S=>S.name===_);if(p===-1)continue;const c=(s=r.variables.getItemAt(p))==null?void 0:s.id;if(c==null)continue;const w=`${r.url}/variables/${c}/${m}/bundles/0/${g[0]}-${g[1]}-${g[2]}`;l.push(M(w,h).then(S=>S.data)),x.varIds.push(c)}const d=await Promise.allSettled(l),f=d.length;for(let _=0;_<f;++_){const p=d[_];if(p.status==="fulfilled"){const c=p.value,w=this._vxl._malloc(c.byteLength);
2new Uint8Array(this._vxl.HEAPU8.buffer,w,c.byteLength).set(new Uint8Array(c)),x.ptrs.push(w),x.sizes.push(c.byteLength)}else x.varIds.splice(_,1)}const v=this._vxl.get_other_field_popup_values(a,x);for(let _=0;_<x.ptrs.length;++_)this._vxl._free(x.ptrs[_]);if(v.continuousValues)for(const _ in v.continuousValues)i.attributes[_]=v.continuousValues[_];if(v.uniqueValues)for(const _ in v.uniqueValues)i.attributes[_]=v.uniqueValues[_]}return e}_beforeDraw(){this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()},this._rctx.setPolygonOffsetFillEnabled(!1),this._rctx.setScissorTestEnabled(!1),this._rctx.setColorMask(!0,!0,!0,!0)}_afterDraw(){this._renderTargetToRestore.fbo=null,this._rctx.externalTextureUnitUpdate(this._vxl.get_texture_units_bound_in_frame(),this._vxl.get_active_texture_unit()),this._rctx.externalVertexArrayObjectUpdate(),this._rctx.externalVertexBufferUpdate(),this._rctx.externalProgramUpdate()}intersect(e,t,s,i,a){var y;if(!this._vxl||!this._rctx||this._layers.size===0||!e.options.selectionMode||e.options.isFiltered)return;if(a==null||a[0]<0||a[0]>e.camera.viewport[2]||a[1]<0||a[1]>e.camera.viewport[3])return this._dbg(u.Error,`[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=[${a[0].toFixed(0)}, ${a[1].toFixed(0)}]`),null;const n=[];this._layers.forEach(o=>{e.options.filteredLayerUids.includes(o.layerView.layer.uid)&&n.push(o.layerView.wasmLayerId)});const r=this.pickObject(a[0],a[1],e.camera,n);if(r==null||r.layerId===-1)return;const h=this._layers.get(r.layerId);if(h){const o=h.layerView.layer.uid,g=r.distanceToCamera/te(s,i),m=re();m[0]=r.worldX,m[1]=r.worldY,m[2]=r.worldZ;const l={},x=h.layerView.layer,d=x.variables.findIndex(c=>c.id===x.currentVariableId);if(d>=0){const c=x.variables.getItemAt(d);c!=null&&(r.continuousValue!=null?l[c.name]=r.continuousValue:r.uniqueValueLabel!=null&&r.uniqueValue!=null?l[c.name]=`${r.uniqueValueLabel} (${r.uniqueValue})`:r.uniqueValue!=null&&(l[c.name]=`${r.uniqueValue}`),c.description.length>0?l["Voxel.CurrentVariable"]=c.description:((y=c.name)==null?void 0:y.length)>0&&(l["Voxel.CurrentVariable"]=c.name))}if(l["Voxel.Position"]=`[${r.voxelSpacePosition.toString()}]`,r.epochTime!=null&&r.nativeTime!=null&&r.nativeTimeUnits!=null){const c=new Date(r.epochTime);l["Voxel.LocalTime"]=c,l["Voxel.SourceTime"]=`${r.nativeTime.toLocaleString()} ${r.nativeTimeUnits}`}r.depth!=null&&(l["Voxel.Depth"]=r.depth);const f=r.faceNormal;l["Voxel.WorldPosition"]=`[${m[0]}, ${m[1]}, ${m[2]}]`;const v=c=>{const w=new ae(m,o,()=>this._createVoxelGraphic(h.layerView.layer,l,r));c.set(this.type,w,g,f)},_=e.results,p=e.options.store===se.ALL;if((_.min.dist==null||g<_.min.dist)&&v(_.min),(_.max.dist==null||g>_.max.dist)&&v(_.max),p){const c=ie(e.ray);v(c),e.results.all.push(c)}}}_createVoxelGraphic(e,t,s){return new ne({layer:e,sourceLayer:e,attributes:t,gpuResult:s})}_toWasmQuality(e){switch(e){case"low":return 0;case"medium":return 1;case"high":return 2}}_setUpscalingLimits(e,t,s){this._vxl&&this._vxl.set_upscaling_limits(e,t,s)}};B([N({constructOnly:!0})],k.prototype,"view",void 0),k=B([z("esri.layers.VoxelWasmPerSceneView")],k);const de=k;export{de as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.