@arcgis/core 5.0.0-next.17 → 5.0.0-next.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{adf7ccf4ef629211c7ee.js → 08aacbfb651cc2e1c054.js} +1 -1
- package/assets/esri/core/workers/chunks/{658cd45b5fb304fd840a.js → 3aa77696c5ea54a238da.js} +1 -1
- package/assets/esri/core/workers/chunks/{49571d6875de1f2e7e25.js → 4b9dfdc23ba3d6ebcc1b.js} +2 -2
- package/assets/esri/core/workers/chunks/{888f188541f8bd68e33e.js → 72f1c3d97e7b9546c113.js} +1 -1
- package/assets/esri/core/workers/chunks/{a4518f25b9f8fe704286.js → 76e945da8f30d8641c3d.js} +4 -4
- package/chunks/ImageMaterial.glsl.js +1 -1
- package/config.js +1 -1
- package/interfaces.d.ts +47 -28
- package/intl/locale.js +1 -1
- package/kernel.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/LabelManager.js +1 -1
- package/views/2d/engine/webgl/FeatureTile.js +1 -1
- package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
- package/views/2d/engine/webgl/VideoScreenRenderer.js +1 -1
- package/views/2d/engine/webgl/animations/store/AnimationStore.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/colorize/ColorizeTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityResources.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/drop-shadow/DropShadowTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/opacity/OpacityTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
- package/views/2d/engine/webgl/textureUtils.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
- package/views/3d/analysis/images/Factory.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/EnvironmentManager.js +1 -1
- package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
- package/views/3d/layers/DrapedSubView3D.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/SceneLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
- package/views/3d/layers/graphics/wosrLoader.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/support/QualityProfile.js +5 -0
- package/views/3d/support/QualitySettings.js +1 -1
- package/views/3d/support/StreamTextureCollection.js +1 -1
- package/views/3d/support/TextureCollection.js +1 -1
- package/views/3d/support/engineContent/marker.js +1 -1
- package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/webgl-engine/Stage.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/material/MaterialBase.js +1 -1
- package/views/3d/webgl-engine/core/material/RenderTexture.js +1 -1
- package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/lib/AnimationTimeStep.js +1 -1
- package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
- package/views/3d/webgl-engine/lib/DDSUtil.js +1 -1
- package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
- package/views/3d/webgl-engine/lib/ManagedTexture.js +5 -0
- package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/lib/TextTextureFactory.js +1 -1
- package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
- package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
- package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/WaterTextureRepository.js +1 -1
- package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/GroundView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/support/layerViewUtils.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
- package/views/3d/support/DisplayQualityProfile.js +0 -5
- package/views/3d/webgl-engine/lib/Texture.js +0 -5
- /package/views/3d/webgl-engine/lib/{ITexture.js → IManagedTexture.js} +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import i from"../request.js";import t from"../core/Accessor.js";import s from"../core/Logger.js";import{isAbortError as r}from"../core/promiseUtils.js";import{watch as a}from"../core/reactiveUtils.js";import{addFrameTask as n}from"../core/scheduling.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{isGeographic as d}from"../geometry/support/spatialReferenceUtils.js";import h from"../geometry/support/WKIDUnitConversion.js";import{wasmFailedToInit as _,invalidLayerView as y}from"./ILyr3DWasmPerSceneView.js";import{Lyr3DWorkerHandle as u}from"./Lyr3DWorkerHandle.js";import{loadLyr3DMainWASM as c}from"../libs/lyr3d/Lyr3DModule.js";import{getElevationOffsetInMeters as m}from"../support/elevationInfoUtils.js";import{makeScheduleFunction as g}from"../views/3d/layers/support/makeScheduleFunction.js";const w=3857,p=32662,f=4326,b=5773,D=115700;let M=class extends t{constructor(e){super(e),this._lyr3DMainPromise=null,this._lyr3DMain=null,this._layers=new Map,this._viewSR=null,this._lyr3DBusyCount=0,this._debugFlags=new Set,this._debugLevel=2,this._wasmNotLoaded="method requiring WASM was called when WASM isn't loaded",this._pulseTaskHandle=null,this._debugFlags.add(0),this._debugFlags.add(1),this._debugFlags.add(2)}_debugLog(e,i,t,r=!0){if(this._debugFlags.has(e)&&this._debugLevel>=i){const e=r?`[js] ${t}`:`${t}`;0===i||1===i?s.getLogger(this).error(e):2===i&&s.getLogger(this).warn(e),s.getLogger(this).info(e)}}initialize(){this._debugLevel>2&&(s.getLogger(this).level="info"),this._debugLog(0,3,"Lyr3DWasmPerSceneView.initialize()"),this.addHandles([a(()=>this.view.state?.contentCamera,()=>this._updateWasmCamera())]),this._pulseTaskHandle=n({preRender:()=>this._pulseTask()})}destroy(){this._debugLog(0,3,"Lyr3DWasmPerSceneView.destroy()"),this._lyr3DMain&&(this._layers.forEach(e=>{e.abortController.abort()}),this._lyr3DMain.uninitialize_lyr3d_wasm(),this._lyr3DMain=null);const e=this._workerHandle;e&&e.destroyWasm().then(()=>{this._workerHandle?.destroy(),this._workerHandle=null}),this._pulseTaskHandle?.remove(),this._pulseTaskHandle=null}addLayerView(e){return this._lyr3DMain?this._addLayerView(e):(this._debugLog(0,1,"Lyr3DWasmPerSceneView.add3DTilesLayerView() called when WASM wasn't initialized"),{wasmLayerId:_})}removeLayerView(e){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;this._doRemoveLayerView(e);const i=this._layers.size;return 0===i&&(this._debugLog(0,3,"Lyr3DWasmPerSceneView.remove3DTilesLayerView() no Lyr3D layers left after removing a layer, destroying"),this.destroy()),i}getValidLayerViewCount(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;let e=0;return this._layers.forEach(i=>{i.layerView.wasmLayerId>=0&&++e}),e}setEnabled(e,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const t=this._layers.get(e.wasmLayerId);if(t){this._lyr3DMain.set_enabled(e.wasmLayerId,i),t.needMemoryUsageUpdate=!0;const s=t.needFrame||this._lyr3DBusyCount>0;t.needFrame=!0,s||t.layerView.updatingFlagChanged()}}setLayerOffset(e,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);this._layers.get(e.wasmLayerId)&&this._lyr3DMain.set_carto_offset_z(e.wasmLayerId,i)}getAttributionText(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),[];return this._lyr3DMain.get_current_attribution_text().split("|")}onRenderableEvicted(e,i,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);this._layers.get(e.wasmLayerId)&&this._lyr3DMain.on_renderable_evicted(e.wasmLayerId,i,t)}setMeshModifications(e,i,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const s=this._layers.get(e.wasmLayerId);if(s){const r=this._lyr3DMain._malloc(8*i.length),a=new Float64Array(this._lyr3DMain.HEAPF64.buffer,r,i.length);for(let e=0;e<i.length;++e)a[e]=i[e];this._lyr3DMain.set_mesh_modification_polygons(e.wasmLayerId,r,i.length,t),this._lyr3DMain._free(r);const n=s.needFrame||this._lyr3DBusyCount>0;s.needFrame=!0,n||s.layerView.updatingFlagChanged()}}isUpdating(e){if(!this._lyr3DMain&&this._lyr3DMainPromise)return!0;const i=this._layers.get(e);return!!i&&(i.needFrame||this._lyr3DBusyCount>0)}initializeWasm(e,i){return this._lyr3DMain?Promise.resolve():this.view.renderSpatialReference?(this._debugLog(0,3,"Lyr3DWasmPerSceneView.initializeWasm()"),this._lyr3DMainPromise||(this._lyr3DMainPromise=c().then(t=>{this._lyr3DMain=t,this._lyr3DMainPromise=null;const s=this._lyr3DMain.addFunction(this._onNewJob.bind(this),"v"),r=this._lyr3DMain.addFunction(this._onNewRenderable.bind(this),"v"),a=this._lyr3DMain.addFunction(this._freeRenderables.bind(this),"viii"),n=this._lyr3DMain.addFunction(this._setRenderableVisibility.bind(this),"viiii"),o=this._lyr3DMain.addFunction(this._onWasmError.bind(this),"viiii");if(!this.view.renderSpatialReference)return void(this._lyr3DMain=null);this._viewSR=this.view.renderSpatialReference?.toJSON();const l="global"===this.view.viewingMode?5:3;if(5===l)this._viewSR.wkid=this._viewSR.latestWkid=f,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=b;else if(this.view.renderSpatialReference?.isWebMercator)this._viewSR.wkid=this._viewSR.latestWkid=w,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=b;else if(this.view.renderSpatialReference?.wkid===p)this._viewSR.wkid=this._viewSR.latestWkid=f,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=b;else if(!this._viewSR.latestVcsWkid&&!this._viewSR.vcsWkid){const e=this.view.heightModelInfo?.heightModel,i=!e||"gravity-related-height"===e;this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=i?b:D}return this._lyr3DMain.initialize_lyr3d_wasm(o,s,r,a,n,e,i,l,this._cleanUpSR(this._makeSRWasmSerializable(this._viewSR)),Math.max(this._debugLevel,0))?(this._workerHandle=new u(g(this.view.resourceController)),this._workerHandle.promise?this._workerHandle.promise:void 0):(this._lyr3DMain=null,void this._debugLog(0,0,"Lyr3d Main WASM failed to initialize",!1))}).catch(e=>{this._debugLog(0,0,`Lyr3d WASM failed to download error = ${e}`,!1)})),this._lyr3DMainPromise):Promise.reject()}setLodPixelThreshold(e,i){this._lyr3DMain?.set_lod_pixel_threshold(i);const t=this._layers.get(e.wasmLayerId);t&&(t.needFrame=!0)}_pulseTask(){if(this._lyr3DMain){let e=0,i=0;this._layers.forEach(t=>{e+=t.layerView.usedMemory,i+=t.layerView.cachedMemory}),e/=1048576,i/=1048576;const t=this.view.resourceController.memoryController,s=t.usedMemory*t.maxMemory-e,r=this._lyr3DBusyCount>0;this._lyr3DBusyCount=this._lyr3DMain.frame_pulse(t.memoryFactor,e,i,s,t.maxMemory);const a=this._lyr3DBusyCount>0;this._layers.forEach(e=>{const i=(r||e.needFrame)!==a;e.needFrame=!1,i&&e.layerView.updatingFlagChanged()})}}_onJobFailed(e,i){e.error.length&&this._debugLog(1,1,e.error,!1),this._lyr3DMain&&this._lyr3DMain.on_job_failed(i.jobId,i.desc)}_onJobSucceeded(e,i){if(this._lyr3DMain){const t=e.data.byteLength,s=this._lyr3DMain._malloc(t);new Uint8Array(this._lyr3DMain.HEAPU8.buffer,s,t).set(e.data),this._lyr3DMain.on_job_completed(i.jobId,e.jobDescJson,s,t),this._lyr3DMain._free(s)}}_getRequestPromises(e,t,s,r){const a=[];for(const n of e){const e=new URL(n);if("integrated-mesh-3dtiles"===r.type){if(e.origin===s.origin&&e.pathname===s.pathname){if(r.rootTileset){a.push(Promise.resolve(r.rootTileset.slice()));continue}}else r.session&&e.searchParams.append("session",r.session)}a.push(i(e.toString(),t).then(e=>e.data))}return a}_getInitialPromise(e,i,t,s,a,n,o){const l=this._getRequestPromises(e.urls,i,t,s);return Promise.all(l).then(e=>(a.inputs=e,this._workerHandle.invoke(a,n))).then(e=>e).catch(i=>{let t=1;return r(i)?this._debugLog(1,2,`job ${e.jobId} was cancelled.`):o&&400===i.details?.httpStatus?(t=3,this._debugLog(1,2,"Session expired, trying to create new Session.")):this._debugLog(1,1,`job ${e.jobId} failed with error ${i}.`),{status:t,error:"",jobDescJson:"",data:new Uint8Array(0),missingInputUrls:[],inputs:[]}})}async _onNewJob(){const e=this._lyr3DMain.get_next_job(),i=this._layers.get(e.layerId);if(!i)return;const t=i.abortController.signal,s=i.layerView.layer,a="integrated-mesh-3dtiles"===s.type?s.key:null,n="integrated-mesh-3dtiles"===s.type?s.session:null,o={responseType:"array-buffer",signal:t,query:{...i.customParameters,token:i.apiKey,key:a}},l={id:e.jobId,inputs:[],jobDescJson:e.desc.slice(),isMissingResourceCase:!1},d=new URL(s.url),h=i=>{if(1===i.status)this._onJobFailed(i,e);else if(0===i.status)this._onJobSucceeded(i,e);else if(2===i.status){const a=this._getRequestPromises(i.missingInputUrls,o,d,s);Promise.all(a).then(e=>{l.jobDescJson=i.jobDescJson,i.originalInputs?l.inputs=i.originalInputs:l.inputs=[],l.isMissingResourceCase=!0;for(const i of e)l.inputs.push(i);return this._workerHandle.invoke(l,t)}).then(i=>{1===i.status?this._onJobFailed(i,e):0===i.status&&this._onJobSucceeded(i,e)}).catch(i=>{r(i)?this._debugLog(1,2,`job ${e.jobId} was cancelled.`):this._debugLog(1,1,`job ${e.jobId} failed with error2 ${i}.`),this._lyr3DMain&&this._lyr3DMain.on_job_failed(e.jobId,e.desc)})}};try{const i=await this._getInitialPromise(e,o,d,s,l,t,n);if(3===i.status&&"integrated-mesh-3dtiles"===s.type){n===s.session&&null!==s.session&&await s.requestRootAndSession(t);h(await this._getInitialPromise(e,o,d,s,l,t,s.session))}else h(i)}catch(_){_&&this._debugLog(1,1,_.toString(),!1),this._lyr3DMain&&this._lyr3DMain.on_job_failed(e.jobId,e.desc)}}_onNewRenderable(){const e=this._lyr3DMain.get_next_renderable(),i=e.meshData;if(i.data&&i.data.byteLength>0){const e=i.data.slice();i.data=e}const t=this._layers.get(e.layerId);t&&t.layerView.createRenderable(e).then(i=>{this._lyr3DMain&&this._lyr3DMain.on_renderable_created(!0,e.layerId,e.handle,i.memUsageBytes)}).catch(i=>{r(i)||this._debugLog(2,1,`createRenderable failed with error ${i}.`),this._lyr3DMain&&this._lyr3DMain.on_renderable_created(!1,e.layerId,e.handle,0)})}_freeRenderables(e,i,t){if(t<1)return;const s=this._layers.get(e);if(!s)return;const r=s.layerView,a=[],n=new Uint32Array(this._lyr3DMain.HEAPU32.buffer,i,t);for(let o=0;o<t;++o)a.push(n[o]);for(let o=0;o<t;++o)r.freeRenderable(a[o])}_setRenderableVisibility(e,i,t,s){if(s<1)return;const r=this._layers.get(e);if(!r)return;const a=r.layerView,n=[],o=[],l=new Uint32Array(this._lyr3DMain.HEAPU32.buffer,i,s),d=new Uint8Array(this._lyr3DMain.HEAPU8.buffer,t,s);for(let h=0;h<s;++h)n.push(l[h]),o.push(1===d[h]);a.setRenderableVisibility(n,o,s)}_onWasmError(e,i,t,s){this._lyr3DMain&&this._debugLog(t,s,this._lyr3DMain.UTF8ToString(e,i),!1)}_doRemoveLayerView(e){const i=this._layers.get(e.wasmLayerId);return!!i&&(i.abortController.abort(),this._lyr3DMain.remove_layer(e.wasmLayerId),this._layers.delete(e.wasmLayerId),!0)}_isGaussianSplatLayerView(e){return"gaussian-splat"===e.layer.type}_isGaussianSplatLayer(e){return"gaussian-splat"===e.type}_toWasmQuality(e){switch(e){case"low":return 1;case"medium":return 2;case"high":return 3}}_addLayerView(e){const i=e.layer;if(!i.url||!i.rootTilesetJSON)return{wasmLayerId:y};const t="integrated-mesh-3dtiles"===i.type?0:2,r=this._lyr3DMain.validate_root_tileset(JSON.stringify(i.rootTilesetJSON),t);if(0!==r.errorCode)return{wasmLayerId:y,check:r};const a=this._lyr3DMain.get_next_layer_id(),n=new AbortController;this._layers.set(a,{layerView:e,abortController:n,needMemoryUsageUpdate:!1,outstandingJobCount:0,outstandingRenderableCount:0,customParameters:i.customParameters,apiKey:i.apiKey,needFrame:!1});const o=m(i.elevationInfo),l=this._toWasmQuality(this.view?.qualityProfile),_=e=>s.getLogger(this).error("add-spatial-reference-error","Error when adding SR:",e);let u=!1;if(this._isGaussianSplatLayerView(e)&&this._isGaussianSplatLayer(i)){let t=i.spatialReference;if(e.useEsriCrs&&i.esriCrsSpatialReference){t=i.esriCrsSpatialReference;const s=d(t);let r=1,a=1;!s&&t.wkid&&-1!==t.wkid&&(r=h.values[h[t.wkid]],a=e.metersPerVCSUnit),this._workerHandle.addSpatialReferenceInfo(this._cleanUpSR(this._makeSRWasmSerializable(t)),s,r,a).catch(_)}u=this._lyr3DMain.add_gaussian_splat_layer(l,i.url,a,o)}else u=this._lyr3DMain.add_3dtiles_layer(l,i.url,a,o);return u?(this._updateWasmCamera(),{wasmLayerId:a}):(this._layers.delete(a),{wasmLayerId:y})}_updateWasmCamera(){const e=this.view.state?.contentCamera;if(!e||!this._lyr3DMain)return;const{eye:i,center:t,up:s,near:r,far:a,fovY:n}=e,o=[e.viewport[2],e.viewport[3]],l=e.width/e.height;this._lyr3DMain.set_camera_parameters({eye:i,center:t,up:s,near:r,far:a,fov:n,aspectRatio:l,viewport:o})}_makeSRWasmSerializable(e){return{wkid:e?.wkid??-1,latestWkid:e?.latestWkid??-1,vcsWkid:e?.vcsWkid??-1,latestVcsWkid:e?.latestVcsWkid??-1,wkt:e?.wkt??""}}_cleanUpSR(e){return-1===e?.wkid&&e.latestWkid&&-1!==e.latestWkid?e.wkid=e.latestWkid:-1===e?.latestWkid&&e.wkid&&-1!==e.wkid&&(e.latestWkid=e.wkid),-1===e?.vcsWkid&&e.latestVcsWkid&&-1!==e.latestVcsWkid?e.vcsWkid=e.latestVcsWkid:-1===e?.latestVcsWkid&&e.vcsWkid&&-1!==e.vcsWkid&&(e.latestVcsWkid=e.vcsWkid),e}};e([o({constructOnly:!0})],M.prototype,"view",void 0),M=e([l("esri.layers.Lyr3DWasmPerSceneView")],M);const L=M;export{L as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import i from"../request.js";import t from"../core/Accessor.js";import s from"../core/Logger.js";import{isAbortError as r}from"../core/promiseUtils.js";import{watch as a}from"../core/reactiveUtils.js";import{addFrameTask as n}from"../core/scheduling.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{isGeographic as d}from"../geometry/support/spatialReferenceUtils.js";import h from"../geometry/support/WKIDUnitConversion.js";import{wasmFailedToInit as _,invalidLayerView as y}from"./ILyr3DWasmPerSceneView.js";import{Lyr3DWorkerHandle as u}from"./Lyr3DWorkerHandle.js";import{loadLyr3DMainWASM as c}from"../libs/lyr3d/Lyr3DModule.js";import{getElevationOffsetInMeters as m}from"../support/elevationInfoUtils.js";import{makeScheduleFunction as g}from"../views/3d/layers/support/makeScheduleFunction.js";const w=3857,p=32662,f=4326,b=5773,D=115700;let L=class extends t{constructor(e){super(e),this._lyr3DMainPromise=null,this._lyr3DMain=null,this._layers=new Map,this._viewSR=null,this._lyr3DBusyCount=0,this._debugFlags=new Set,this._debugLevel=2,this._wasmNotLoaded="method requiring WASM was called when WASM isn't loaded",this._pulseTaskHandle=null,this._debugFlags.add(0),this._debugFlags.add(1),this._debugFlags.add(2)}_debugLog(e,i,t,r=!0){if(this._debugFlags.has(e)&&this._debugLevel>=i){const e=r?`[js] ${t}`:`${t}`;0===i||1===i?s.getLogger(this).error(e):2===i&&s.getLogger(this).warn(e),s.getLogger(this).info(e)}}initialize(){this._debugLevel>2&&(s.getLogger(this).level="info"),this._debugLog(0,3,"Lyr3DWasmPerSceneView.initialize()"),this.addHandles([a(()=>this.view.state?.contentCamera,()=>this._updateWasmCamera())]),this._pulseTaskHandle=n({preRender:()=>this._pulseTask()})}destroy(){this._debugLog(0,3,"Lyr3DWasmPerSceneView.destroy()"),this._lyr3DMain&&(this._layers.forEach(e=>{e.abortController.abort()}),this._lyr3DMain.uninitialize_lyr3d_wasm(),this._lyr3DMain=null);const e=this._workerHandle;e&&e.destroyWasm().then(()=>{this._workerHandle?.destroy(),this._workerHandle=null}),this._pulseTaskHandle?.remove(),this._pulseTaskHandle=null}addLayerView(e){return this._lyr3DMain?this._addLayerView(e):(this._debugLog(0,1,"Lyr3DWasmPerSceneView.add3DTilesLayerView() called when WASM wasn't initialized"),{wasmLayerId:_})}removeLayerView(e){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;this._doRemoveLayerView(e);const i=this._layers.size;return 0===i&&(this._debugLog(0,3,"Lyr3DWasmPerSceneView.remove3DTilesLayerView() no Lyr3D layers left after removing a layer, destroying"),this.destroy()),i}getValidLayerViewCount(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;let e=0;return this._layers.forEach(i=>{i.layerView.wasmLayerId>=0&&++e}),e}setEnabled(e,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const t=this._layers.get(e.wasmLayerId);if(t){this._lyr3DMain.set_enabled(e.wasmLayerId,i),t.needMemoryUsageUpdate=!0;const s=t.needFrame||this._lyr3DBusyCount>0;t.needFrame=!0,s||t.layerView.updatingFlagChanged()}}setLayerOffset(e,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);this._layers.get(e.wasmLayerId)&&this._lyr3DMain.set_carto_offset_z(e.wasmLayerId,i)}getAttributionText(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),[];return this._lyr3DMain.get_current_attribution_text().split("|")}onRenderableEvicted(e,i,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);this._layers.get(e.wasmLayerId)&&this._lyr3DMain.on_renderable_evicted(e.wasmLayerId,i,t)}setMeshModifications(e,i,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const s=this._layers.get(e.wasmLayerId);if(s){const r=this._lyr3DMain._malloc(8*i.length),a=new Float64Array(this._lyr3DMain.HEAPF64.buffer,r,i.length);for(let e=0;e<i.length;++e)a[e]=i[e];this._lyr3DMain.set_mesh_modification_polygons(e.wasmLayerId,r,i.length,t),this._lyr3DMain._free(r);const n=s.needFrame||this._lyr3DBusyCount>0;s.needFrame=!0,n||s.layerView.updatingFlagChanged()}}isUpdating(e){if(!this._lyr3DMain&&this._lyr3DMainPromise)return!0;const i=this._layers.get(e);return!!i&&(i.needFrame||this._lyr3DBusyCount>0)}initializeWasm(e,i){return this._lyr3DMain?Promise.resolve():this.view.renderSpatialReference?(this._debugLog(0,3,"Lyr3DWasmPerSceneView.initializeWasm()"),this._lyr3DMainPromise||(this._lyr3DMainPromise=c().then(t=>{this._lyr3DMain=t,this._lyr3DMainPromise=null;const s=this._lyr3DMain.addFunction(this._onNewJob.bind(this),"v"),r=this._lyr3DMain.addFunction(this._onNewRenderable.bind(this),"v"),a=this._lyr3DMain.addFunction(this._freeRenderables.bind(this),"viii"),n=this._lyr3DMain.addFunction(this._setRenderableVisibility.bind(this),"viiii"),o=this._lyr3DMain.addFunction(this._onWasmError.bind(this),"viiii");if(!this.view.renderSpatialReference)return void(this._lyr3DMain=null);this._viewSR=this.view.renderSpatialReference?.toJSON();const l="global"===this.view.viewingMode?5:3;if(5===l)this._viewSR.wkid=this._viewSR.latestWkid=f,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=b;else if(this.view.renderSpatialReference?.isWebMercator)this._viewSR.wkid=this._viewSR.latestWkid=w,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=b;else if(this.view.renderSpatialReference?.wkid===p)this._viewSR.wkid=this._viewSR.latestWkid=f,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=b;else if(!this._viewSR.latestVcsWkid&&!this._viewSR.vcsWkid){const e=this.view.heightModelInfo?.heightModel,i=!e||"gravity-related-height"===e;this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=i?b:D}return this._lyr3DMain.initialize_lyr3d_wasm(o,s,r,a,n,e,i,l,this._cleanUpSR(this._makeSRWasmSerializable(this._viewSR)),Math.max(this._debugLevel,0))?(this._workerHandle=new u(g(this.view.resourceController)),this._workerHandle.promise?this._workerHandle.promise:void 0):(this._lyr3DMain=null,void this._debugLog(0,0,"Lyr3d Main WASM failed to initialize",!1))}).catch(e=>{this._debugLog(0,0,`Lyr3d WASM failed to download error = ${e}`,!1)})),this._lyr3DMainPromise):Promise.reject()}setLodPixelThreshold(e,i){this._lyr3DMain?.set_lod_pixel_threshold(i);const t=this._layers.get(e.wasmLayerId);t&&(t.needFrame=!0)}_pulseTask(){if(this._lyr3DMain){let e=0,i=0;this._layers.forEach(t=>{e+=t.layerView.usedMemory,i+=t.layerView.cachedMemory}),e/=1048576,i/=1048576;const t=this.view.resourceController.memoryController,s=t.usedMemory*t.maxMemory-e,r=this._lyr3DBusyCount>0;this._lyr3DBusyCount=this._lyr3DMain.frame_pulse(t.memoryFactor,e,i,s,t.maxMemory);const a=this._lyr3DBusyCount>0;this._layers.forEach(e=>{const i=(r||e.needFrame)!==a;e.needFrame=!1,i&&e.layerView.updatingFlagChanged()})}}_onJobFailed(e,i){e.error.length&&this._debugLog(1,1,e.error,!1),this._lyr3DMain&&this._lyr3DMain.on_job_failed(i.jobId,i.desc)}_onJobSucceeded(e,i){if(this._lyr3DMain){const t=e.data.byteLength,s=this._lyr3DMain._malloc(t);new Uint8Array(this._lyr3DMain.HEAPU8.buffer,s,t).set(e.data),this._lyr3DMain.on_job_completed(i.jobId,e.jobDescJson,s,t),this._lyr3DMain._free(s)}}_getRequestPromises(e,t,s,r){const a=[];for(const n of e){const e=new URL(n);if("integrated-mesh-3dtiles"===r.type){if(e.origin===s.origin&&e.pathname===s.pathname){if(r.rootTileset){a.push(Promise.resolve(r.rootTileset.slice()));continue}}else r.session&&e.searchParams.append("session",r.session)}a.push(i(e.toString(),t).then(e=>e.data))}return a}_getInitialPromise(e,i,t,s,a,n,o){const l=this._getRequestPromises(e.urls,i,t,s);return Promise.all(l).then(e=>(a.inputs=e,this._workerHandle.invoke(a,n))).then(e=>e).catch(i=>{let t=1;return r(i)?this._debugLog(1,2,`job ${e.jobId} was cancelled.`):o&&400===i.details?.httpStatus?(t=3,this._debugLog(1,2,"Session expired, trying to create new Session.")):this._debugLog(1,1,`job ${e.jobId} failed with error ${i}.`),{status:t,error:"",jobDescJson:"",data:new Uint8Array(0),missingInputUrls:[],inputs:[]}})}async _onNewJob(){const e=this._lyr3DMain.get_next_job(),i=this._layers.get(e.layerId);if(!i)return;const t=i.abortController.signal,s=i.layerView.layer,a="integrated-mesh-3dtiles"===s.type?s.key:null,n="integrated-mesh-3dtiles"===s.type?s.session:null,o={responseType:"array-buffer",signal:t,query:{...i.customParameters,token:i.apiKey,key:a}},l={id:e.jobId,inputs:[],jobDescJson:e.desc.slice(),isMissingResourceCase:!1},d=new URL(s.url),h=i=>{if(1===i.status)this._onJobFailed(i,e);else if(0===i.status)this._onJobSucceeded(i,e);else if(2===i.status){const a=this._getRequestPromises(i.missingInputUrls,o,d,s);Promise.all(a).then(e=>{l.jobDescJson=i.jobDescJson,i.originalInputs?l.inputs=i.originalInputs:l.inputs=[],l.isMissingResourceCase=!0;for(const i of e)l.inputs.push(i);return this._workerHandle.invoke(l,t)}).then(i=>{1===i.status?this._onJobFailed(i,e):0===i.status&&this._onJobSucceeded(i,e)}).catch(i=>{r(i)?this._debugLog(1,2,`job ${e.jobId} was cancelled.`):this._debugLog(1,1,`job ${e.jobId} failed with error2 ${i}.`),this._lyr3DMain&&this._lyr3DMain.on_job_failed(e.jobId,e.desc)})}};try{const i=await this._getInitialPromise(e,o,d,s,l,t,n);if(3===i.status&&"integrated-mesh-3dtiles"===s.type){n===s.session&&null!==s.session&&await s.requestRootAndSession(t);h(await this._getInitialPromise(e,o,d,s,l,t,s.session))}else h(i)}catch(_){_&&this._debugLog(1,1,_.toString(),!1),this._lyr3DMain&&this._lyr3DMain.on_job_failed(e.jobId,e.desc)}}_onNewRenderable(){const e=this._lyr3DMain.get_next_renderable(),{meshData:i}=e;if(i.data&&i.data.byteLength>0){const e=i.data.slice();i.data=e}const t=this._layers.get(e.layerId);t&&t.layerView.createRenderable(e).then(i=>this._lyr3DMain?.on_renderable_created(!0,e.layerId,e.handle,i.memUsageBytes)).catch(i=>{r(i)||this._debugLog(2,1,`createRenderable failed with error ${i}.`),this._lyr3DMain?.on_renderable_created(!1,e.layerId,e.handle,0)})}_freeRenderables(e,i,t){if(t<1)return;const s=this._layers.get(e);if(!s)return;const r=s.layerView,a=[],n=new Uint32Array(this._lyr3DMain.HEAPU32.buffer,i,t);for(let o=0;o<t;++o)a.push(n[o]);for(let o=0;o<t;++o)r.freeRenderable(a[o])}_setRenderableVisibility(e,i,t,s){if(s<1)return;const r=this._layers.get(e);if(!r)return;const a=r.layerView,n=[],o=[],l=new Uint32Array(this._lyr3DMain.HEAPU32.buffer,i,s),d=new Uint8Array(this._lyr3DMain.HEAPU8.buffer,t,s);for(let h=0;h<s;++h)n.push(l[h]),o.push(1===d[h]);a.setRenderableVisibility(n,o,s)}_onWasmError(e,i,t,s){this._lyr3DMain&&this._debugLog(t,s,this._lyr3DMain.UTF8ToString(e,i),!1)}_doRemoveLayerView(e){const i=this._layers.get(e.wasmLayerId);return!!i&&(i.abortController.abort(),this._lyr3DMain.remove_layer(e.wasmLayerId),this._layers.delete(e.wasmLayerId),!0)}_isGaussianSplatLayerView(e){return"gaussian-splat"===e.layer.type}_isGaussianSplatLayer(e){return"gaussian-splat"===e.type}_toWasmQuality(e){switch(e){case"low":return 1;case"medium":return 2;case"high":return 3}}_addLayerView(e){const i=e.layer;if(!i.url||!i.rootTilesetJSON)return{wasmLayerId:y};const t="integrated-mesh-3dtiles"===i.type?0:2,r=this._lyr3DMain.validate_root_tileset(JSON.stringify(i.rootTilesetJSON),t);if(0!==r.errorCode)return{wasmLayerId:y,check:r};const a=this._lyr3DMain.get_next_layer_id(),n=new AbortController;this._layers.set(a,{layerView:e,abortController:n,needMemoryUsageUpdate:!1,outstandingJobCount:0,outstandingRenderableCount:0,customParameters:i.customParameters,apiKey:i.apiKey,needFrame:!1});const o=m(i.elevationInfo),l=this._toWasmQuality(this.view?.qualityProfile),_=e=>s.getLogger(this).error("add-spatial-reference-error","Error when adding SR:",e);let u=!1;if(this._isGaussianSplatLayerView(e)&&this._isGaussianSplatLayer(i)){let t=i.spatialReference;if(e.useEsriCrs&&i.esriCrsSpatialReference){t=i.esriCrsSpatialReference;const s=d(t);let r=1,a=1;!s&&t.wkid&&-1!==t.wkid&&(r=h.values[h[t.wkid]],a=e.metersPerVCSUnit),this._workerHandle.addSpatialReferenceInfo(this._cleanUpSR(this._makeSRWasmSerializable(t)),s,r,a).catch(_)}u=this._lyr3DMain.add_gaussian_splat_layer(l,i.url,a,o)}else u=this._lyr3DMain.add_3dtiles_layer(l,i.url,a,o);return u?(this._updateWasmCamera(),{wasmLayerId:a}):(this._layers.delete(a),{wasmLayerId:y})}_updateWasmCamera(){const e=this.view.state?.contentCamera;if(!e||!this._lyr3DMain)return;const{eye:i,center:t,up:s,near:r,far:a,fovY:n}=e,o=[e.viewport[2],e.viewport[3]],l=e.width/e.height;this._lyr3DMain.set_camera_parameters({eye:i,center:t,up:s,near:r,far:a,fov:n,aspectRatio:l,viewport:o})}_makeSRWasmSerializable(e){return{wkid:e?.wkid??-1,latestWkid:e?.latestWkid??-1,vcsWkid:e?.vcsWkid??-1,latestVcsWkid:e?.latestVcsWkid??-1,wkt:e?.wkt??""}}_cleanUpSR(e){return-1===e?.wkid&&e.latestWkid&&-1!==e.latestWkid?e.wkid=e.latestWkid:-1===e?.latestWkid&&e.wkid&&-1!==e.wkid&&(e.latestWkid=e.wkid),-1===e?.vcsWkid&&e.latestVcsWkid&&-1!==e.latestVcsWkid?e.vcsWkid=e.latestVcsWkid:-1===e?.latestVcsWkid&&e.vcsWkid&&-1!==e.vcsWkid&&(e.latestVcsWkid=e.vcsWkid),e}};e([o({constructOnly:!0})],L.prototype,"view",void 0),L=e([l("esri.layers.Lyr3DWasmPerSceneView")],L);const M=L;export{M as default};
|
package/package.json
CHANGED
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const e="20251017",f="31ffce02f738214e9cf444827db910a1aa5e4f3e";export{e as buildDate,f as commitHash};
|
package/views/2d/LabelManager.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import has from"../../core/has.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{SymbolFader as o}from"./engine/vectorTiles/decluttering/SymbolFader.js";import{tileSize as a}from"./engine/webgl/definitions.js";const i=
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import has from"../../core/has.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{SymbolFader as o}from"./engine/vectorTiles/decluttering/SymbolFader.js";import{tileSize as a}from"./engine/webgl/definitions.js";const i=64;class n{constructor(){this.styles=new Map,this.layerContexts=new Map}get cachedStyles(){return this.styles}setLabelClassStyle(e,t,s){this.layerContexts.set(e,t),this.styles.set(e,s)}removeContainer(e){for(const[t,s]of this.layerContexts.entries())s===e&&this.layerContexts.delete(t)}}let l=class extends t{constructor(e){super(e),this._faderWorkingSet=[],this._styleRepository=new n,this.lastUpdateId=-1,this.updateRequested=!1,this.view=null;const t=(e,t)=>{e.updateLabelVisibility(),e.requestRender(),e.isReady&&(e.decluttered=!0)};this.symbolFader=new o("feature-tile",this._styleRepository,t,this._faderWorkingSet,a,i)}get updating(){return has("esri-2d-log-updating")&&console.log(`Updating LabelManager ${this.updateRequested}:\n-> updateRequested: ${this.updateRequested}`),this.updateRequested}viewChange(){this.requestUpdate()}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.view?.requestUpdate())}processUpdate(e){this.doUpdate(e)?this.updateRequested=!1:(this.updateRequested=!0,this.view?.requestUpdate())}setLabelSchemaStyles(e,t){let s;switch(e.type){case"label":s=e.classes;break;case"subtype":s=Array.from(Object.values(e.renderers).flatMap(e=>e.classes));break;case"cluster":s=[...e.cluster.classes,...e.feature.classes];break;case"track":s=[...e.latestObservation.classes,...e.previousObservation.classes,...e.trackLine.classes]}for(const r of s){const e=c(r);this._styleRepository.setLabelClassStyle(r.labelClassId,t,e)}}removeContainer(e){this._styleRepository.removeContainer(e),this.requestUpdate()}doUpdate(e){this._faderWorkingSet.length=0;const t=this.view;if(!t)return!1;const s=t.allLayerViews.map(e=>e.featureContainer).filter(e=>!!e&&e?.hasLabels);if(s.length>0){for(const t of s)for(const s of t.tiles||[])s.setTransform(e.state),this._faderWorkingSet.push(s);const r=e.state.scale,o=t.featuresTilingScheme.scaleToZoom(r);return this.symbolFader.update(o,e.state)}return!0}};function c(e){const t="esriGeometryPolyline"===e.geometryType?0:1,s="esriGeometryPolyline"===e.geometryType?0:1;return{geometryType:e.geometryType,iconAllowOverlap:!e.deconflictionEnabled,iconIgnorePlacement:!1,textAllowOverlap:!e.deconflictionEnabled,textIgnorePlacement:!1,iconRotationAlignment:t,textRotationAlignment:t,iconTranslateAnchor:s,iconTranslate:[0,0],textTranslateAnchor:s,textTranslate:[0,0]}}e([s()],l.prototype,"updateRequested",void 0),e([s()],l.prototype,"updating",null),e([s()],l.prototype,"view",void 0),l=e([r("esri.views.2d.LabelManager")],l);export{n as LabelClassStyleRepository,l as LabelManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import e from"../../../../core/Logger.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{AFeatureTile as i}from"./AFeatureTile.js";import{RESHUFFLING_EXEMPT_MEMORY_BYTES as r,RESHUFFLING_TARGET_MEMORY_EFFICIENCY as o,RESHUFFLING_EXEMPT_DRAW_CALLS as n,RESHUFFLING_TARGET_DRAW_EFFICIENCY as d,tileSize as h}from"./definitions.js";import a from"./DisplayEntity.js";import{DisplayList as l}from"./FeatureDisplayList.js";import{ReshufflePlan as c}from"./ReshufflePlan.js";import{LabelMetric as f}from"./collisions/LabelMetric.js";import{MappedMesh as _}from"./cpuMapped/MappedMesh.js";import{debugMeshDataInfo as u}from"./mesh/meshDebugUtils.js";import m from"./util/Reader.js";import{deserializeList as y}from"./util/serializationUtils.js";const p=()=>e.getLogger("esri.views.2d.engine.webgl.FeatureTile");let g=0;class b extends i{constructor(e,i,r,o,n,d,h=!1){super(e,i,r,o),this._fader=n,this._labelInstanceId=d,this._meshes=new Map,this._entities=[],this._entityIndex=new Map,this._invalidated=!1,this._nextUploadAllowed=!1,this.tileAge=g++,this._metrics=[],this._metricsVisibility=new Set,this._entityIds=new Set,this._entityIdsFromBuffer=new Set,this._attributeEpoch=0,this._encounteredEnd=!1,this._decluttered=!1,this._objectIdMap=null,this.isCoverage=!1,this.rendering=!1,this.visible=!0,this.transforms.labelMat2d=t(),this.transforms.tileUnitsToPixels=s(),this.enableDeferredUploads=h}destroy(){super.destroy(),this.clear()}clear(){for(const e of this._meshes.values())e.destroy();this._meshes.clear(),this._entities=[],this._fader?.removeFeatureTileMetrics(this,this._metrics),this._metrics=[],this._displayList=null,this._invalidated=!0,this._entityIds.clear(),this._nextUploadAllowed=!0}beforeRender(e){super.beforeRender(e),this._needsReshuffle&&e.reshuffleManager.schedule(this)}tryReady(e){const t=this._invalidated&&!this._uploadAllowed;return!(this.isReady||t||!this._encounteredEnd||!(e>=this._attributeEpoch))&&(has("esri-2d-update-debug")&&console.debug(`Tile[${this.key.id}] FeatureTile.ready [epoch=${e}]`),this.ready(),this.requestRender(),this.decluttered=!1,!0)}get symbols(){const e=new Map;for(const t of this._metrics)e.get(t.labelClassId)||e.set(t.labelClassId,[]),e.get(t.labelClassId).push(t);return e}get decluttered(){return this._decluttered}set decluttered(e){this._decluttered=e,this.requestRender()}get id(){return this.key.id}get hasData(){return!!this._meshes.size}get hasAnimations(){return!!this._objectIdMap}get needsUpload(){return this._invalidated}get usedMemory(){let e=0;for(const t of this._meshes.values())e+=t.usedMemory;if(this._entities.length){let t=0;const s=Math.min(this._entities.length,10);for(let e=0;e<s;e++)t+=this._entities[0].records.length;const i=t/s;e+=a.estimateMemory(i)*this._entities.length,e+=4*this._entities.length}return e+=25*this._entityIndex.size,e+=18*this._entityIds.size,e+=25*this._entityIdsFromBuffer.size,this._displayList&&(e+=this._displayList.usedMemory),this._objectIdMap&&(e+=25*this._entities.length),e}get _uploadAllowed(){return!this.enableDeferredUploads||this._nextUploadAllowed}get
|
|
5
|
+
import has from"../../../../core/has.js";import e from"../../../../core/Logger.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{AFeatureTile as i}from"./AFeatureTile.js";import{RESHUFFLING_EXEMPT_MEMORY_BYTES as r,RESHUFFLING_TARGET_MEMORY_EFFICIENCY as o,RESHUFFLING_EXEMPT_DRAW_CALLS as n,RESHUFFLING_TARGET_DRAW_EFFICIENCY as d,tileSize as h}from"./definitions.js";import a from"./DisplayEntity.js";import{DisplayList as l}from"./FeatureDisplayList.js";import{ReshufflePlan as c}from"./ReshufflePlan.js";import{LabelMetric as f}from"./collisions/LabelMetric.js";import{MappedMesh as _}from"./cpuMapped/MappedMesh.js";import{debugMeshDataInfo as u}from"./mesh/meshDebugUtils.js";import m from"./util/Reader.js";import{deserializeList as y}from"./util/serializationUtils.js";const p=()=>e.getLogger("esri.views.2d.engine.webgl.FeatureTile");let g=0;class b extends i{constructor(e,i,r,o,n,d,h=!1){super(e,i,r,o),this._fader=n,this._labelInstanceId=d,this._meshes=new Map,this._entities=[],this._entityIndex=new Map,this._invalidated=!1,this._nextUploadAllowed=!1,this.tileAge=g++,this._metrics=[],this._metricsVisibility=new Set,this._entityIds=new Set,this._entityIdsFromBuffer=new Set,this._attributeEpoch=0,this._encounteredEnd=!1,this._decluttered=!1,this._objectIdMap=null,this.isCoverage=!1,this.rendering=!1,this.visible=!0,this.transforms.labelMat2d=t(),this.transforms.tileUnitsToPixels=s(),this.enableDeferredUploads=h}destroy(){super.destroy(),this.clear()}clear(){for(const e of this._meshes.values())e.destroy();this._meshes.clear(),this._entities=[],this._fader?.removeFeatureTileMetrics(this,this._metrics),this._metrics=[],this._displayList=null,this._invalidated=!0,this._entityIds.clear(),this._nextUploadAllowed=!0}beforeRender(e){super.beforeRender(e),this._needsReshuffle&&e.reshuffleManager.schedule(this)}tryReady(e){const t=this._invalidated&&!this._uploadAllowed;return!(this.isReady||t||!this._encounteredEnd||!(e>=this._attributeEpoch))&&(has("esri-2d-update-debug")&&console.debug(`Tile[${this.key.id}] FeatureTile.ready [epoch=${e}]`),this.ready(),this.requestRender(),this.decluttered=!1,!0)}get symbols(){const e=new Map;for(const t of this._metrics)e.get(t.labelClassId)||e.set(t.labelClassId,[]),e.get(t.labelClassId).push(t);return e}get decluttered(){return this._decluttered}set decluttered(e){this._decluttered=e,this.requestRender()}get id(){return this.key.id}get hasData(){return!!this._meshes.size}get hasAnimations(){return!!this._objectIdMap}get needsUpload(){return this._invalidated}get usedMemory(){let e=0;for(const t of this._meshes.values())e+=t.usedMemory;if(this._entities.length){let t=0;const s=Math.min(this._entities.length,10);for(let e=0;e<s;e++)t+=this._entities[0].records.length;const i=t/s;e+=a.estimateMemory(i)*this._entities.length,e+=4*this._entities.length}return e+=25*this._entityIndex.size,e+=18*this._entityIds.size,e+=25*this._entityIdsFromBuffer.size,this._displayList&&(e+=this._displayList.usedMemory),this._objectIdMap&&(e+=25*this._entities.length),e}get _uploadAllowed(){return!this.enableDeferredUploads||this._nextUploadAllowed}get hasMetrics(){return this._metrics.length>0}upload(){this._nextUploadAllowed=!0}getDisplayList(e,t){if(this._uploadAllowed&&this._invalidated){this._entities.sort((e,t)=>{const s=t.sortKey,i=e.sortKey;return i===s?e.id-t.id:i-s}),0===t&&this.reshuffle(!0),this._displayList=l.fromDisplayEntities(this._entities,this,e,t);for(const e of this._meshes.values())e.upload();this.debugInfo.display.length=this._displayList.length,this.debugInfo.display.minOrderedLength=this._displayList.minOrderedLength,this.debugInfo.display.minUnorderedLength=this._displayList.minUnorderedLength,this.requestRender(),this._invalidated=!1,this._nextUploadAllowed=!1}return this._displayList}getMesh(e){if(!this._meshes.has(e))throw new Error(`InternalError: Unable to find VAO for instance: ${e}`);return this._meshes.get(e)}getSortKeys(e){const t=new Map;for(const{id:s,sortKey:i}of this._entities)if(e.has(s)&&t.set(s,i),t.size===e.size)break;return t}onMessage(e){if(e.objectIdMap)for(const t in e.objectIdMap)this._objectIdMap||(this._objectIdMap={}),this._objectIdMap[t]=e.objectIdMap[t];switch(e.type){case"append":this._onAppendMessage(e);break;case"update":this._onUpdateMessage(e)}if(this._aggregateMemoryStats(),this.requestRender(),e.end){if(has("esri-2d-update-debug")&&console.debug(`Tile[${this.key.id}] FeatureTile.end [epoch=${e.attributeEpoch}]`),!e.attributeEpoch)throw new Error("InternalError: Attribute epoch not defined.");this._attributeEpoch=e.attributeEpoch,this._encounteredEnd=!0}this._writeLabelVisibilityToMesh()}_onAppendMessage(e){if(has("esri-2d-update-debug")&&console.debug(`Tile[${this.key.id}] FeatureTile.append`,{append:u(e?.append)}),e.clear&&this.clear(),!e.append)return;const t=y(new m(e.append.entities),a);this._insert(t,e.append.data,!1)}_onUpdateMessage(e){has("esri-2d-update-debug")&&console.debug(`Tile[${this.key.id}] FeatureTile.update`,{isPixelBuffer:e.isPixelBuffer,modify:u(e.modify),remove:e.remove});const t=y(new m(e.modify.entities),a),s=t.map(e=>e.id),i=e.isPixelBuffer??!1,r=[...e.remove,...s];i?this._removeByIdsFromBuffer(r):this._removeByIds(r),this._insert(t,e.modify.data,i)}reshuffle(e=!1){if(this.destroyed)return;const t=new Map;for(const s of this._entities)for(const i of s.records){const s=this._meshes.get(i.instanceId);let r=t.get(s);r||(r=new c(e),t.set(s,r)),r.copyRecord(i)}for(const[s,i]of t)s.reshuffle(i);this._invalidated=!0,this._aggregateMemoryStats(),has("esri-2d-update-debug")&&p().info(`Tile ${this.key.id} was reshuffled.`)}copyPixelBufferedEntitesFrom(e,t,s,i){const r=s*h,o=i*h;for(const n of e._entities){let s=null;for(const i of n.records)if(i.overlaps&t){const t=e.getMesh(i.instanceId),d=this._ensureMesh(i.instanceId,t.layout,t.useVisibility).copyRecordFrom(t,i,r,o);s||(s=new a(n.id,n.sortKey),this._entityIdsFromBuffer.add(n.id),this._entityIndex.set(s.id,s),this._entities.push(s)),s.records.push(d)}}this._invalidated=!0}get metricsVisibility(){return this._metricsVisibility}copyMetricsVisibility(e){for(const t of e)this._metricsVisibility.add(t);this._writeLabelVisibilityToMesh()}updateLabelVisibility(){this._metricsVisibility.clear();for(const e of this._metrics){e.uniqueSymbol.show&&e.selectedForRendering&&this._metricsVisibility.add(e.hash)}this._writeLabelVisibilityToMesh()}_writeLabelVisibilityToMesh(){const e=this._meshes.get(this._labelInstanceId);if(e&&this.hasMetrics){for(const t of this._metrics){const s=this._entityIndex.get(t.id);if(!s)continue;const i=this._metricsVisibility.has(t.hash);e.setEntityRecordRangeVisibility(s.records,t.recordStart,t.recordCount,i?0:255)}this._invalidated=!0}}_ensureMesh(e,t,s){return this._meshes.has(e)||this._meshes.set(e,new _(this._stage.bufferPool,t,s)),this._meshes.get(e)}_insert(e,t,s){if(!e.length)return;this._removeDuplicatedBufferedEntites(e);const i=this._insertVertexData(t);for(const r of e){for(const e of r.records)e.updateBaseOffsets(i.get(e.instanceId));s?this._tryInsertBufferedEntity(r):this._insertEntity(r)}this._invalidated=!0}_insertMetrics(e){for(const t of e)t.tile=this;this._metrics.push(...e),this._fader?.insertFeatureTileMetrics(this,e)}_insertVertexData(e){const t=new Map;for(const s of e){const{instanceId:e,layout:i}=s,r=i.attributes.some(e=>"visibility"===e.name),o=this._ensureMesh(e,i,r).append(s);if(s.metrics){const e=y(new m(s.metrics),f)??[];this._insertMetrics(e)}t.set(e,o)}return t}_insertEntity(e){has("esri-2d-update-debug")&&this._entityIds.has(e.id)&&console.error(`Tile ${this.key.id} insertEntity: Already have entityId ${e.id}`),this._entityIds.add(e.id),this._entityIndex.set(e.id,e),this._entities.push(e)}_tryInsertBufferedEntity(e){this._entityIds.has(e.id)?this._removeRecordsFromMesh(e.records):(this._entityIdsFromBuffer.add(e.id),this._entityIndex.set(e.id,e),this._entities.push(e))}_removeDuplicatedBufferedEntites(e){if(!this._entityIdsFromBuffer.size)return;const t=[];for(const s of e)this._entityIdsFromBuffer.has(s.id)&&t.push(s.id);this._removeByIds(t)}_removeByIdsFromBuffer(e){this._removeByIds(e.filter(e=>this._entityIdsFromBuffer.has(e)))}_removeByIds(e){if(0===e.length)return;const t=new Set(e),s=[];for(const r of this._entities)t.has(r.id)?(this._remove(r),this._entityIndex.delete(r.id)):s.push(r);this._entities=s;const i=this._metrics.filter(e=>t.has(e.displayId));this._metrics=this._metrics.filter(e=>!t.has(e.displayId)),this._fader?.removeFeatureTileMetrics(this,i),this._invalidated=!0}_remove(e){this._removeRecordsFromMesh(e.records),this._entityIds.delete(e.id),this._entityIdsFromBuffer.delete(e.id)}_removeRecordsFromMesh(e){for(const t of e){const{instanceId:e,indexStart:s,indexCount:i,vertexStart:r,vertexCount:o}=t;this._meshes.get(e)?.remove(s,i,r,o)}}_aggregateMemoryStats(){this.debugInfo.memory.bytesUsed=0,this.debugInfo.memory.bytesReserved=0;for(const e of this._meshes.values())this.debugInfo.memory.bytesUsed+=e.memoryStats.bytesUsed,this.debugInfo.memory.bytesReserved+=e.memoryStats.bytesReserved}get _needsReshuffle(){if(this.destroyed)return!1;const{bytesUsed:e,bytesReserved:t}=this.debugInfo.memory,s=e/t,{minOrderedLength:i,length:h}=this.debugInfo.display;return t>r&&s<o||h>n&&i/h<d}get entityIds(){return this._objectIdMap?this._entities.map(({id:e})=>({objectId:this._objectIdMap[e],displayId:e})):[]}}export{b as FeatureTile};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{on as t}from"../../../../core/events.js";import e from"../../../../core/Handles.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{when as i,initial as
|
|
5
|
+
import{on as t}from"../../../../core/events.js";import e from"../../../../core/Handles.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{when as i,initial as o}from"../../../../core/reactiveUtils.js";import{createScreenPoint as s}from"../../../../core/screenUtils.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import a from"../../../../geometry/Point.js";import l from"../../../../geometry/Polygon.js";import{project as h}from"../../../../geometry/projectionUtils.js";import u from"../../../../layers/support/ControlPoint.js";import{DisplayObject as m}from"../DisplayObject.js";import p from"../../../layers/support/Geometry.js";import{Texture as d}from"../../../webgl/Texture.js";import{TextureDescriptor as c}from"../../../webgl/TextureDescriptor.js";const f=2;class x extends m{constructor(r){super(),this.element=r,this._handles=new e,this.isWrapAround=!1,this.perspectiveTransform=n(),this.wrapAroundShift=0,this.clipGeometry=null,this._handles.add(i(()=>this.element,()=>{const e=this.element;this.ready(),e&&this._handles.add(t(e,"play",()=>this.requestRender()))},o))}getMesh(t){throw new Error("Method not implemented.")}destroy(){super.destroy(),this._handles.destroy(),this.texture=r(this.texture)}get textureSize(){if(!this.texture)return[1,1];const t=this.texture.descriptor;return[t.width,t.height]}get dvsMat3(){return this.parent.dvsMat3}beforeRender(t){const e=this.element;if(null==e)return;const{context:r}=t,{videoWidth:i,videoHeight:o}=e;if(0!==i&&0!==o){if(this.texture)e.paused||t.animationsEnabled&&this.texture.setData(e);else{const t=new c(i,o);t.wrapMode=33071,t.preMultiplyAlpha=!0,this.texture=new d(r,t,e)}e.paused||this.texture.generateMipmap(),super.beforeRender(t)}}_createTransforms(){return null}updateDrawCoords(t,e,r,i){const o=this.element,s=this._getFrameInfo();if(!o||!s)return;const{spatialReference:n}=r;this._initializeData(t,s,n);const{controlPoints:a,horizon:u}=s,m=Math.sqrt(a.length),d=m,{x:c,y:x}=t,y=this._vertices,g=a[0],w=a[m-1],P=a[(d-1)*m],_=a[(d-1)*m+m-1],v=h(u?u[0].mapPoint:g.mapPoint,n),j=h(u?u[1].mapPoint:w.mapPoint,n),M=h(P.mapPoint,n),A=h(_.mapPoint,n);this.clipGeometry=u?new p({geometry:l.fromJSON({rings:[[[M.x,M.y],[A.x,A.y],[j.x,j.y],[v.x,v.y],[M.x,M.y]]],spatialReference:n})}):null;for(let l=0;l<a.length;l++){const t=a[l],{sourcePoint:e,mapPoint:r}=t;if(null==e||null==r)continue;const i=h(r,n);y[l*f+0]=i.x-c,y[l*f+1]=i.y-x}let b=e;if(i){const t=Math.min(v.x,j.x,M.x,A.x),e=Math.max(v.x,j.x,M.x,A.x),{worldWidth:r,xBounds:o}=i,[s,n]=o;t<s&&e>s?b=r:e>n&&t<n&&(b=-r)}this.wrapAroundShift=b,this.isWrapAround=0!==b}draw(t,e){if(!this.visible)return;if(!(this.isReady&&this._vertices&&this._indices&&this._texCoords))return void this.requestRender();this.stage||console.warn("OverlayMultipoint: stage is null"),e.render(t,{transform:{dvs:this.dvsMat3},config:{perspective:this.perspectiveTransform,texSize:this.textureSize,wrapAroundShift:this.wrapAroundShift,isWrapAround:this.isWrapAround,opacity:this.opacity,texture:{texture:this.texture,unit:0}},position:this._vertices,tex:this._texCoords,index:this._indices})}_initializeData(t,e,r){if(null!=this._vertices&&null!=this._indices)return;const{controlPoints:i}=e,o=Math.sqrt(i.length),s=o,n=new Float32Array(f*i.length),a=new Uint16Array(2*i.length);for(let m=0;m<i.length;m++){const e=i[m],{sourcePoint:o,mapPoint:s}=e;if(null==o||null==s)continue;const l=h(s,r);n[m*f+0]=l.x-t.x,n[m*f+1]=l.y-t.y,a[2*m+0]=o.x,a[2*m+1]=o.y}const l=new Uint16Array(s*o+(s-2)*(o+2));let u=0;for(let h=0;h<s;h++){for(let t=0;t<o;t++)l[u++]=h*o+t,l[u++]=(h+1)*o+t;h<s-2&&(l[u++]=(h+1)*o+(o-1),l[u++]=(h+1)*o)}this._vertices=n,this._texCoords=a,this._indices=l}_getFrameInfo(){if(!this.groundControlPoints)return null;const t=this._getFrameControlPoints(),e=this.frameHorizonPoints;let r=null;if(e){const t=e.startX,i=e.startY,o=e.endX,n=e.endY;r=[new u({sourcePoint:s(t,i),mapPoint:new a(e.startLongitude,e.startLatitude)}),new u({sourcePoint:s(o,n),mapPoint:new a(e.endLongitude,e.endLatitude)})]}return{controlPoints:t,horizon:r}}_getFrameControlPoints(){const t=this.groundControlPoints,e=t?.length;if(!e)return[];const r=new Array(e),i=Math.max(...t.map(({x:t})=>t)),o=this.element.videoWidth/i;for(let n=0;n<e;n++){const{x:e,y:i,lat:l,lon:h}=t[n];r[n]=new u({sourcePoint:s(e*o,-i*o),mapPoint:new a(h,l)})}return r}}export{x as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{disposeMaybe as e}from"../../../../core/maybe.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import o from"../../../../geometry/Point.js";import{load as s,execute as i}from"../../../../geometry/operators/projectOperator.js";import{DisplayObject as a}from"../DisplayObject.js";import{VideoScreenTechnique as n}from"./shaderGraph/techniques/videoScreenRenderer/VideoScreenTechnique.js";import{ColorAttachment0 as c,SizedPixelFormat as d}from"../../../webgl/enums.js";import{FramebufferObject as h}from"../../../webgl/FramebufferObject.js";import{Texture as u}from"../../../webgl/Texture.js";import{TextureDescriptor as l}from"../../../webgl/TextureDescriptor.js";class m extends a{constructor(e,t){super(),this._controlPointsOwner=t,this.readbackScreenCoords=r(),this.videoTextureCoords=new Array(36),this.overlayTextureCoords=new Array(36),this._prevFBO=null,this._acquiredFBO=null,this._isBound=!1,this._hasCoordinates=!1,this._geIsLoaded=!1,this._ndcRect=[0,0,2,2],this._technique=new n,this.visible=!1,this.stage=e;for(let r=0;r<6;r++){const e=r/5;for(let t=0;t<6;t++){const o=t/5;this.videoTextureCoords[6*r+t]={u:o,v:e}}}}getMesh(e){throw new Error("Method not implemented.")}destroy(){super.destroy(),e(this._readbackTexture)}bind(e){const{context:t,pixelRatio:r,state:o}=e;if(this._update(e),!this.ready||0===this.readbackScreenCoords[2]||0===this.readbackScreenCoords[3])return this.requestRender(),!1;const{size:s}=o,i=Math.round(r*s[0]),a=Math.round(r*s[1]),n=new l(i,a);return n.samplingMode=9729,n.wrapMode=33071,this._acquiredFBO||(this._acquiredFBO=new h(t,n)),this._acquiredFBO.resize(i,a),t.bindFramebuffer(this._acquiredFBO),this._isBound=!0,!0}unbind(e){if(!this._isBound)return;const{context:t,pixelRatio:r,state:o}=e,{size:s}=o,i=this._acquiredFBO;if(!i.getColorTexture(c))throw new Error("Failed to get color texture from FBO.");const a=this._getReadbackTexture(e),n=this.readbackScreenCoords,d=Math.round(r*n[0]),h=Math.round(r*(s[1]-n[1]))-a.descriptor.height,u=d+a.descriptor.width,l=h+a.descriptor.height,m=Math.max(d,0),_=Math.max(h,0),
|
|
5
|
+
import{disposeMaybe as e}from"../../../../core/maybe.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import o from"../../../../geometry/Point.js";import{load as s,execute as i}from"../../../../geometry/operators/projectOperator.js";import{DisplayObject as a}from"../DisplayObject.js";import{VideoScreenTechnique as n}from"./shaderGraph/techniques/videoScreenRenderer/VideoScreenTechnique.js";import{ColorAttachment0 as c,SizedPixelFormat as d}from"../../../webgl/enums.js";import{FramebufferObject as h}from"../../../webgl/FramebufferObject.js";import{Texture as u}from"../../../webgl/Texture.js";import{TextureDescriptor as l}from"../../../webgl/TextureDescriptor.js";class m extends a{constructor(e,t){super(),this._controlPointsOwner=t,this.readbackScreenCoords=r(),this.videoTextureCoords=new Array(36),this.overlayTextureCoords=new Array(36),this._prevFBO=null,this._acquiredFBO=null,this._isBound=!1,this._hasCoordinates=!1,this._geIsLoaded=!1,this._ndcRect=[0,0,2,2],this._technique=new n,this.visible=!1,this.stage=e;for(let r=0;r<6;r++){const e=r/5;for(let t=0;t<6;t++){const o=t/5;this.videoTextureCoords[6*r+t]={u:o,v:e}}}}getMesh(e){throw new Error("Method not implemented.")}destroy(){super.destroy(),e(this._readbackTexture)}bind(e){const{context:t,pixelRatio:r,state:o}=e;if(this._update(e),!this.ready||0===this.readbackScreenCoords[2]||0===this.readbackScreenCoords[3])return this.requestRender(),!1;const{size:s}=o,i=Math.round(r*s[0]),a=Math.round(r*s[1]),n=new l(i,a);return n.samplingMode=9729,n.wrapMode=33071,this._acquiredFBO||(this._acquiredFBO=new h(t,n)),this._acquiredFBO.resize(i,a),t.bindFramebuffer(this._acquiredFBO),this._isBound=!0,!0}unbind(e){if(!this._isBound)return;const{context:t,pixelRatio:r,state:o}=e,{size:s}=o,i=this._acquiredFBO;if(!i.getColorTexture(c))throw new Error("Failed to get color texture from FBO.");const a=this._getReadbackTexture(e),n=this.readbackScreenCoords,d=Math.round(r*n[0]),h=Math.round(r*(s[1]-n[1]))-a.descriptor.height,u=d+a.descriptor.width,l=h+a.descriptor.height,m=Math.max(d,0),_=Math.max(h,0),b=Math.min(u,i.width)-m,f=Math.min(l,i.height)-_;b>0&&f>0&&i.copyToTexture(m,_,b,f,m-d,_-h,a),t.bindFramebuffer(this._prevFBO)}_update(e){const{state:r}=e,a=this._controlPointsOwner,n=a.groundControlPoints(),c=a.getSize(),d=r.size,h=n?.length;if(!h)return;if(s().then(()=>{this._geIsLoaded=!0}),!this._geIsLoaded)return void this.requestRender();const u=c[0],l=c[1],m=d[0],_=l/d[1],b=u/m;if(_>b){const e=b/_*2,t=(2-e)/2;this._ndcRect[0]=-1+t,this._ndcRect[1]=1,this._ndcRect[2]=e,this._ndcRect[3]=2}else{const e=_/b*2,t=(2-e)/2;this._ndcRect[0]=-1,this._ndcRect[1]=1-t,this._ndcRect[2]=2,this._ndcRect[3]=e}const f=new Array(h),x=r.spatialReference;for(let t=0;t<h;t++){const{lat:e,lon:r}=n[t],s=new o(r,e);f[t]=i(s,x)}const p=[];let M=1/0,g=1/0,w=-1/0,C=-1/0;for(const o of f){const e=t();r.toScreen(e,o.x,o.y),p.push({x:e[0],y:e[1]}),M=Math.min(M,e[0]),g=Math.min(g,e[1]),w=Math.max(w,e[0]),C=Math.max(C,e[1])}const R=[M,C],k=[w,g];this.readbackScreenCoords[0]=Math.max(Math.floor(R[0]),0),this.readbackScreenCoords[1]=Math.max(Math.floor(k[1]),0),this.readbackScreenCoords[2]=Math.ceil(k[0]),this.readbackScreenCoords[3]=Math.ceil(R[1]);for(let t=0;t<p.length;t++){const e=p[t],r=(e.x-M)/(w-M),o=(C-e.y)/(C-g);this.overlayTextureCoords[t]={u:r,v:o}}this._hasCoordinates=!0}_createTransforms(){return null}doRender(e){this._readbackTexture&&this._hasCoordinates?this._technique.render(e,{texture:this._readbackTexture,textureCoords:this.overlayTextureCoords,opacity:1,ndcRect:this._ndcRect}):this.requestRender()}_getReadbackTexture(e){const{context:t,pixelRatio:r}=e,o=Math.round(r*Math.abs(this.readbackScreenCoords[2]-this.readbackScreenCoords[0])),s=Math.round(r*Math.abs(this.readbackScreenCoords[3]-this.readbackScreenCoords[1]));if(this._readbackTexture)this._readbackTexture.resize(o,s);else{const e=new l(o,s);e.wrapMode=33071,e.internalFormat=d.RGBA8,this._readbackTexture=new u(t,e)}return this._readbackTexture}}export{m as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{PixelType as t}from"../../../../../webgl/enums.js";import{Texture as e}from"../../../../../webgl/Texture.js";import{TextureDescriptor as s}from"../../../../../webgl/TextureDescriptor.js";import{ValidatedTextureDescriptor as r}from"../../../../../webgl/ValidatedTextureDescriptor.js";class o{constructor(){this._entries=new n,this._nodes=new Map,this._book=new h}add(t){let e=this._entries.get(t);if(!e){const s=this._book.add(t),r=new Object;e={location:s,references:0,handle:r};const o=this._entries.set(t,e);this._nodes.set(r,o)}return e.references++,e}remove(t){const e=this._nodes.get(t.handle);e&&e.payload&&(e.payload.references--,0===e.payload.references&&(this._book.remove(e.payload.location),this._entries.delete(e),this._nodes.delete(t.handle)))}getTexture(t,e){return this._book.getTexture(t,e)}destroy(){this._book.destroy()}}class i{constructor(t,e){this.parent=t,this.key=e,this.payload=null,this._children=new Map}get(t){return this._children.get(t)}ensure(t){let e=this._children.get(t);return e||(e=new i(this,t),this._children.set(t,e)),e}delete(t){this._children.delete(t)}}class n{constructor(){this._root=new i(null,NaN)}set(t,e){let s=this._root;for(const r of t)for(const t of r)s=s.ensure(t);return s.payload=e,s}delete(t){t.parent?.delete(t.key)}get(t){let e=this._root;for(const s of t)for(const t of s){const s=e.get(t);if(!s)return;e=s}return e.payload||void 0}}class h{constructor(){this._pages=[]}add(t){0===this._pages.length&&this._pages.push(new
|
|
5
|
+
import{PixelType as t}from"../../../../../webgl/enums.js";import{Texture as e}from"../../../../../webgl/Texture.js";import{TextureDescriptor as s}from"../../../../../webgl/TextureDescriptor.js";import{ValidatedTextureDescriptor as r}from"../../../../../webgl/ValidatedTextureDescriptor.js";class o{constructor(){this._entries=new n,this._nodes=new Map,this._book=new h}add(t){let e=this._entries.get(t);if(!e){const s=this._book.add(t),r=new Object;e={location:s,references:0,handle:r};const o=this._entries.set(t,e);this._nodes.set(r,o)}return e.references++,e}remove(t){const e=this._nodes.get(t.handle);e&&e.payload&&(e.payload.references--,0===e.payload.references&&(this._book.remove(e.payload.location),this._entries.delete(e),this._nodes.delete(t.handle)))}getTexture(t,e){return this._book.getTexture(t,e)}destroy(){this._book.destroy()}}class i{constructor(t,e){this.parent=t,this.key=e,this.payload=null,this._children=new Map}get(t){return this._children.get(t)}ensure(t){let e=this._children.get(t);return e||(e=new i(this,t),this._children.set(t,e)),e}delete(t){this._children.delete(t)}}class n{constructor(){this._root=new i(null,NaN)}set(t,e){let s=this._root;for(const r of t)for(const t of r)s=s.ensure(t);return s.payload=e,s}delete(t){t.parent?.delete(t.key)}get(t){let e=this._root;for(const s of t)for(const t of s){const s=e.get(t);if(!s)return;e=s}return e.payload||void 0}}class h{constructor(){this._pages=[]}add(t){0===this._pages.length&&this._pages.push(new l);let e=this._pages.length-1,s=this._pages[e].add(t);if(s||(this._pages.push(new l),e=this._pages.length-1,s=this._pages[e].add(t)),!s)throw new Error("Data allocation failed.");return{...s,page:e}}remove(t){this._pages[t.page].remove(t)}getTexture(t,e){return this._pages[e].getTexture(t)}destroy(){}}class l{constructor(){this._cursor={row:0,column:0},this._columns=1024,this._rows=1024,this._data=new Float32Array(this._columns*this._rows*4),this._texture=null,this._textureCursor={row:0,column:0}}add(t){if(t.length>this._columns)throw new Error(`The maximum allocation size is ${this._columns} texels.`);const e={...this._cursor};if(e.column+=t.length,e.column>=this._columns&&(e.column=t.length,e.row++),e.row>=this._rows)return null;this._cursor=e;const s={...this._cursor};s.column-=t.length;let r=4*(s.row*this._columns+s.column);for(let o=0;o<t.length;o++)this._data[r++]=t[o][0],this._data[r++]=t[o][1],this._data[r++]=t[o][2],this._data[r++]=t[o][3];return s}remove(t){}getTexture(o){if(!this._texture){const i=new s(this._columns,this._rows);i.pixelFormat=6408,i.dataType=t.FLOAT,i.wrapMode=33071,i.samplingMode=9728,i.hasMipmap=!1;const n=new r(o,i);this._texture=new e(o,n)}if(this._cursor.row===this._textureCursor.row&&this._cursor.column===this._textureCursor.column)return this._texture;const i=this._textureCursor.row,n=this._cursor.row-i+1;return this._texture.updateData(0,0,i,this._columns,n,this._data,i),this._textureCursor.row=this._cursor.row,this._textureCursor.column=this._cursor.column,this._texture}destroy(){this._texture?.dispose()}}export{o as AnimationStore,n as PrefixMap};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{simplePipelineState as t}from"../../utils.js";import{Technique as r}from"../Technique.js";import{FilterEffectShader as s}from"../shaders/ColorizeShader.js";import{Texture as i}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as o}from"../../../../../../webgl/TextureDescriptor.js";class l extends r{constructor(){super(...arguments),this.type=8,this._layerFBOTexture=null,this._size=[0,0],this.shaders={filterEffect:new s}}shutdown(){super.shutdown(),this._layerFBOTexture=e(this._layerFBOTexture)}render(e,r){const{width:s,height:i}=r.layerFBO;this._createOrResizeResources(e,s,i);const{context:o,painter:l}=e,
|
|
5
|
+
import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{simplePipelineState as t}from"../../utils.js";import{Technique as r}from"../Technique.js";import{FilterEffectShader as s}from"../shaders/ColorizeShader.js";import{Texture as i}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as o}from"../../../../../../webgl/TextureDescriptor.js";class l extends r{constructor(){super(...arguments),this.type=8,this._layerFBOTexture=null,this._size=[0,0],this.shaders={filterEffect:new s}}shutdown(){super.shutdown(),this._layerFBOTexture=e(this._layerFBOTexture)}render(e,r){const{width:s,height:i}=r.layerFBO;this._createOrResizeResources(e,s,i);const{context:o,painter:l}=e,n=r.effect.colorMatrix,a=this._layerFBOTexture;o.bindFramebuffer(r.layerFBO),r.layerFBO.copyToTexture(0,0,s,i,0,0,a);const u={color:{write:[!0,!0,!0,!0],blendMode:"none"},depth:!1,stencil:!1};l.setPipelineState(u);const c={colorTexture:{texture:a,unit:2},coefficients:n};l.submitDrawMesh(o,{shader:this.shaders.filterEffect,uniforms:{filterEffectConfig:c},defines:null,optionalAttributes:null,useComputeBuffer:!1},l.quadMesh),l.setPipelineState({...t,stencil:{test:{mask:255,compare:514,op:{fail:7680,zFail:7680,zPass:7680}},write:!1}})}_createOrResizeResources(e,t,r){const{context:s}=e;if(!this._layerFBOTexture||this._size[0]!==t||this._size[1]!==r)if(this._size[0]=t,this._size[1]=r,this._layerFBOTexture)this._layerFBOTexture.resize(t,r);else{const e=new o(t,r);e.internalFormat=6408,e.wrapMode=33071,this._layerFBOTexture=new i(s,e)}}}export{l as ColorizeTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../../../../core/RandomLCG.js";import{tileSize as e}from"../../../definitions.js";import{SimpleMesh as s}from"../../../meshing/SimpleMesh.js";import{SizedDepthStencilFormat as o,DataType as r,PrimitiveType as i,PixelType as n}from"../../../../../../webgl/enums.js";import{FramebufferObject as d}from"../../../../../../webgl/FramebufferObject.js";import{Renderbuffer as h}from"../../../../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as u}from"../../../../../../webgl/RenderbufferDescriptor.js";import{Texture as l}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as _}from"../../../../../../webgl/TextureDescriptor.js";const
|
|
5
|
+
import t from"../../../../../../../core/RandomLCG.js";import{tileSize as e}from"../../../definitions.js";import{SimpleMesh as s}from"../../../meshing/SimpleMesh.js";import{SizedDepthStencilFormat as o,DataType as r,PrimitiveType as i,PixelType as n}from"../../../../../../webgl/enums.js";import{FramebufferObject as d}from"../../../../../../webgl/FramebufferObject.js";import{Renderbuffer as h}from"../../../../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as u}from"../../../../../../webgl/RenderbufferDescriptor.js";import{Texture as l}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as _}from"../../../../../../webgl/TextureDescriptor.js";const m={pos:{count:2,type:r.UNSIGNED_SHORT}};class T{constructor(){this._dotTextureSize=0,this._dotTextures=null,this._dotMesh=null}destroy(){this._disposeTextures(),this._dotFBO&&this._dotFBO.dispose(),this._dotMesh&&this._dotMesh.destroy()}getFBO(t){if(null==this._dotFBO){const s=e,r=e,i=new _(s,r);i.samplingMode=9728,i.wrapMode=33071;const n=new h(t,new u(o.DEPTH24_STENCIL8,s,r));this._dotFBO=new d(t,i,n)}return this._dotFBO}getDotDensityMesh(t){if(null==this._dotMesh){const o=e,r=o*o,n=2,d=new Int16Array(r*n);for(let t=0;t<o;t++)for(let e=0;e<o;e++)d[n*(e+t*o)]=e,d[n*(e+t*o)+1]=t;this._dotMesh=s.create(t,{primitive:i.POINTS,vertex:d,count:r,layout:m})}return this._dotMesh}getDotDensityTextures(e,s,o){if(this._dotTextureSize===s&&this._seed===o||(this._disposeTextures(),this._dotTextureSize=s,this._seed=o),null===this._dotTextures){const r=new t(o);this._dotTextures=[this._allocDotDensityTexture(e,s,r),this._allocDotDensityTexture(e,s,r)]}return this._dotTextures}_disposeTextures(){if(this._dotTextures){for(let t=0;t<this._dotTextures.length;t++)this._dotTextures[t].dispose();this._dotTextures=null}}_allocDotDensityTexture(t,e,s){const o=new Float32Array(e*e*4);for(let i=0;i<o.length;i++)o[i]=s.getFloat();const r=new _(e);return r.dataType=n.FLOAT,r.samplingMode=9728,new l(t,r,o)}}export{T as DotDensityResources};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{simplePipelineState as r}from"../../utils.js";import{Technique as s}from"../Technique.js";import{BlitShader as i}from"../shaders/BlitShader.js";import{GaussianBlurShader as o}from"../shaders/BlurShader.js";import{DropShadowCompositeShader as a}from"../shaders/DropShadowShader.js";import{FramebufferObject as u}from"../../../../../../webgl/FramebufferObject.js";import{Texture as l}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as n}from"../../../../../../webgl/TextureDescriptor.js";const h=[1,0],B=[0,1];class c extends s{constructor(){super(...arguments),this.type=12,this._layerFBOTexture=null,this._horizontalBlurFBO=null,this._verticalBlurFBO=null,this._size=[0,0],this.shaders={gaussianBlur:new o,composite:new a,blit:new i}}shutdown(){super.shutdown(),this._horizontalBlurFBO=e(this._horizontalBlurFBO),this._verticalBlurFBO=e(this._verticalBlurFBO),this._layerFBOTexture=e(this._layerFBOTexture)}render(e,s){const{context:i,state:o,painter:a}=e,{layerFBO:u}=s,l=u.width,n=u.height,c=[Math.round(l),Math.round(n)],{blurRadius:f,offsetX:d,offsetY:m,color:p}=s.effect,F=[t(d),t(m)];this._createOrResizeResources(e,l,n,c);const w=this._horizontalBlurFBO,_=this._verticalBlurFBO,
|
|
5
|
+
import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{simplePipelineState as r}from"../../utils.js";import{Technique as s}from"../Technique.js";import{BlitShader as i}from"../shaders/BlitShader.js";import{GaussianBlurShader as o}from"../shaders/BlurShader.js";import{DropShadowCompositeShader as a}from"../shaders/DropShadowShader.js";import{FramebufferObject as u}from"../../../../../../webgl/FramebufferObject.js";import{Texture as l}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as n}from"../../../../../../webgl/TextureDescriptor.js";const h=[1,0],B=[0,1];class c extends s{constructor(){super(...arguments),this.type=12,this._layerFBOTexture=null,this._horizontalBlurFBO=null,this._verticalBlurFBO=null,this._size=[0,0],this.shaders={gaussianBlur:new o,composite:new a,blit:new i}}shutdown(){super.shutdown(),this._horizontalBlurFBO=e(this._horizontalBlurFBO),this._verticalBlurFBO=e(this._verticalBlurFBO),this._layerFBOTexture=e(this._layerFBOTexture)}render(e,s){const{context:i,state:o,painter:a}=e,{layerFBO:u}=s,l=u.width,n=u.height,c=[Math.round(l),Math.round(n)],{blurRadius:f,offsetX:d,offsetY:m,color:p}=s.effect,F=[t(d),t(m)];this._createOrResizeResources(e,l,n,c);const w=this._horizontalBlurFBO,_=this._verticalBlurFBO,O={color:{write:[!0,!0,!0,!0],blendMode:"none"},depth:{write:!1,test:!1},stencil:{write:{mask:0},test:!1}};a.setPipelineState(O);const x=this._layerFBOTexture;u.copyToTexture(0,0,l,n,0,0,x),i.setViewport(0,0,c[0],c[1]),i.bindFramebuffer(w),a.submitDrawMesh(i,{shader:this.shaders.gaussianBlur,uniforms:{gaussianBlurConfig:{texture:{texture:u.colorTexture,unit:4},texSize:c,direction:h,sigma:f}},defines:{kernelRadius:Math.ceil(f)},optionalAttributes:null,useComputeBuffer:!1},a.quadMesh),i.bindFramebuffer(_),a.submitDrawMesh(i,{shader:this.shaders.gaussianBlur,uniforms:{gaussianBlurConfig:{texture:{texture:w?.colorTexture,unit:5},texSize:c,direction:B,sigma:f}},defines:{kernelRadius:Math.ceil(f)},optionalAttributes:null,useComputeBuffer:!1},a.quadMesh),i.bindFramebuffer(u),i.setViewport(0,0,l,n),a.submitDrawMesh(i,{shader:this.shaders.composite,uniforms:{compositeConfig:{blurTexture:{texture:_?.colorTexture,unit:2},layerFBOTexture:{texture:x,unit:3},shadowColor:[p[3]*(p[0]/255),p[3]*(p[1]/255),p[3]*(p[2]/255),p[3]],displayViewMat3:o.displayMat3,shadowOffset:F}},defines:null,optionalAttributes:null,useComputeBuffer:!1},a.quadMesh),a.setPipelineState({...r,stencil:{test:{mask:255,compare:514,op:{fail:7680,zFail:7680,zPass:7680}},write:!1}})}_createOrResizeResources(e,t,r,s){const{context:i}=e;if(!this._horizontalBlurFBO||this._size[0]!==t||this._size[1]!==r){if(this._size[0]=t,this._size[1]=r,this._horizontalBlurFBO)this._horizontalBlurFBO.resize(s[0],s[1]);else{const e=new n(s[0],s[1]);e.internalFormat=6408,e.wrapMode=33071,this._horizontalBlurFBO=new u(i,e)}if(this._verticalBlurFBO)this._verticalBlurFBO.resize(s[0],s[1]);else{const e=new n(s[0],s[1]);e.internalFormat=6408,e.wrapMode=33071,this._verticalBlurFBO=new u(i,e)}if(this._layerFBOTexture)this._layerFBOTexture.resize(t,r);else{const e=new n(t,r);e.internalFormat=6408,e.wrapMode=33071,this._layerFBOTexture=new l(i,e)}}}}export{c as DropShadowTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{Technique as t}from"../Technique.js";import{OpacityShader as r}from"../shaders/OpacityShader.js";import{Texture as s}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as i}from"../../../../../../webgl/TextureDescriptor.js";class o extends t{constructor(){super(...arguments),this.type=23,this._layerFBOTexture=null,this._size=[0,0],this.shaders={opacity:new r}}shutdown(){super.shutdown(),this._layerFBOTexture=e(this._layerFBOTexture)}render(e,t){const{layerFBO:r}=t,{width:s,height:i}=r;this._createOrResizeResources(e,s,i);const{context:o,painter:a}=e,{amount:
|
|
5
|
+
import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{Technique as t}from"../Technique.js";import{OpacityShader as r}from"../shaders/OpacityShader.js";import{Texture as s}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as i}from"../../../../../../webgl/TextureDescriptor.js";class o extends t{constructor(){super(...arguments),this.type=23,this._layerFBOTexture=null,this._size=[0,0],this.shaders={opacity:new r}}shutdown(){super.shutdown(),this._layerFBOTexture=e(this._layerFBOTexture)}render(e,t){const{layerFBO:r}=t,{width:s,height:i}=r;this._createOrResizeResources(e,s,i);const{context:o,painter:a}=e,{amount:l}=t.effect,n=this._layerFBOTexture;o.bindFramebuffer(r),t.layerFBO.copyToTexture(0,0,s,i,0,0,n);const u={color:{write:[!0,!0,!0,!0],blendMode:"custom",blendParameters:{srcRGB:1,dstRGB:771,srcAlpha:1,dstAlpha:771}},depth:!1,stencil:!1},h={layerTexture:{texture:n,unit:0},opacity:l};n.setSamplingMode(9728),o.setClearColor(0,0,0,0),o.clear(16384),a.setPipelineState(u),a.submitDrawMesh(o,{shader:this.shaders.opacity,uniforms:{config:h},defines:null,optionalAttributes:null,useComputeBuffer:!1},a.quadMesh)}_createOrResizeResources(e,t,r){const{context:o}=e;if(!this._layerFBOTexture||this._size[0]!==t||this._size[1]!==r)if(this._size[0]=t,this._size[1]=r,this._layerFBOTexture)this._layerFBOTexture.resize(t,r);else{const e=new i(t,r);e.internalFormat=6408,e.wrapMode=33071,e.samplingMode=9728,this._layerFBOTexture=new s(o,e)}}}export{o as OpacityTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{Technique as t}from"../Technique.js";import{TextureStatisticsTechnique as i}from"../TextureStatisticsTechnique.js";import{getInterpolationDefines as
|
|
5
|
+
import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{Technique as t}from"../Technique.js";import{TextureStatisticsTechnique as i}from"../TextureStatisticsTechnique.js";import{getInterpolationDefines as o}from"./processor/textureUtils.js";import{RasterColorizerLUTShader as s}from"../shaders/raster/RasterColorizerLUTShader.js";import{RasterColorizerShadedReliefShader as r}from"../shaders/raster/RasterColorizerShadedReliefShader.js";import{RasterColorizerStretchShader as n}from"../shaders/raster/RasterColorizerStretchShader.js";import{SizedPixelFormat as a,PixelType as u}from"../../../../../../webgl/enums.js";import{FramebufferObject as c}from"../../../../../../webgl/FramebufferObject.js";import{Texture as m}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as l}from"../../../../../../webgl/TextureDescriptor.js";class p extends t{constructor(){super(...arguments),this.name="BrushRasterColorizer",this.type=0,this.shaders={lut:new s,stretch:new n,shadedRelief:new r},this._mosaicFbo=null,this._statisticsTechnique=null}shutdown(t){super.shutdown(t),this._mosaicFbo=e(this._mosaicFbo),this._statisticsTechnique=e(this._statisticsTechnique)}render(t,i){const o=i.bitmaps.some(f);o||(this._mosaicFbo=e(this._mosaicFbo),this._statisticsTechnique=e(this._statisticsTechnique));const s=o?this._computeStatisticsTextures(t,i):void 0;for(const e of i.bitmaps){if(!e.source||e.suspended)continue;t.timeline.begin(this.name);const{painter:i}=t;i.setPipelineState({depth:!1,stencil:{test:{mask:255,compare:514,op:{fail:7680,zFail:7680,zPass:7680}},write:!1},color:{write:[!0,!0,!0,!0],blendMode:"composite"}}),e.updateTexture(t),e.updateProcessedTexture();const{type:o}=e.symbolizerParameters,r="stretch"===o?this._getStretchOptions(e,s):"lut"===o?this._getLutOptions(e):this._getShadedReliefOptions(e);"bilinear"!==e.interpolation||t.context.capabilities.textureFloatLinear||(r.defines.bilinear=!0),i.submitDrawMesh(t.context,r,i.quadMesh,e),t.timeline.end(this.name)}}_computeStatisticsTextures(e,t){this._statisticsTechnique??=new i;const o=this._statisticsTechnique;return this._mosaic(e,t),o.render(e,{fbo:this._mosaicFbo}),{minTexture:o.minValuesTexture,maxTexture:o.maxValuesTexture,meanTexture:o.meanValuesTexture,stddevTexture:o.stdDevValuesTexture}}_mosaic(e,t){const{context:i,painter:o}=e,s=i.getBoundFramebufferObject();if(this._mosaicFbo)this._mosaicFbo.resize(s.width,s.height);else{const e=h(i,s.width,s.height);this._mosaicFbo=new c(i,e)}i.bindFramebuffer(this._mosaicFbo);const r="RasterColorizerMosaic";for(const n of t.bitmaps){if(!f(n))continue;e.timeline.begin(r),o.setPipelineState({depth:!1,stencil:{test:{mask:255,compare:514,op:{fail:7680,zFail:7680,zPass:7680}},write:!1},color:{write:[!0,!0,!0,!0],blendMode:"composite"}});const t=n.interpolation;n.interpolation="nearest",n.updateTexture(e),n.updateProcessedTexture();const i=this._getStretchOptions(n);i.defines.noOp=!0,o.submitDrawMesh(e.context,i,o.quadMesh,n),n.interpolation=t,e.timeline.end(r)}i.bindFramebuffer(s)}_getLutOptions(e){const{config:t,projectionConfig:i,colormapConfig:s,pixelMaskConfig:r,highlightConfig:n,projectionDefines:a}=this._getCommonConfig(e),u=o(e);return{shader:this.shaders.lut,uniforms:{projectionConfig:i,config:t,colormapConfig:s,pixelMaskConfig:r,highlightConfig:n},defines:{...a,...u,applyPixelMask:!!r,applyPixelHighlights:!!n},optionalAttributes:null,useComputeBuffer:!1}}_getStretchOptions(e,t){const i=e.symbolizerParameters,{config:s,projectionConfig:r,colormapConfig:n,pixelMaskConfig:a,highlightConfig:u,projectionDefines:c,textureUnit:m}=this._getCommonConfig(e),l=o(e),p=t?{minTexture:{texture:t.minTexture,unit:m},maxTexture:{texture:t.maxTexture,unit:m+1},meanTexture:{texture:t.meanTexture,unit:m+2},stddevTexture:{texture:t.stddevTexture,unit:m+3},numberOfStandardDeviations:i.numberOfStandardDeviations||2}:void 0,h=t?"standardDeviation"===i.stretchType?2:1:0;return{shader:this.shaders.stretch,uniforms:{projectionConfig:r,config:s,stretchConfig:i,colormapConfig:n,pixelMaskConfig:a,highlightConfig:u,statisticsConfig:p},defines:{...c,...l,isMultiband:i.bandCount>1,applyColormap:!!n,useGamma:i.useGamma,noOp:e.isRendereredSource&&!e.processed,applyPixelMask:!!a,applyPixelHighlights:!!u,draStretchType:h},optionalAttributes:null,useComputeBuffer:!1}}_getShadedReliefOptions(e){const t=e.symbolizerParameters,{config:i,projectionConfig:s,colormapConfig:r,pixelMaskConfig:n,highlightConfig:a,projectionDefines:u}=this._getCommonConfig(e),c=o(e);return{shader:this.shaders.shadedRelief,uniforms:{projectionConfig:s,config:i,hillshadeConfig:t,colormapConfig:r,pixelMaskConfig:n,highlightConfig:a},defines:{...u,...c,isMultidirectional:t.hillshadeType>0,applyColormap:!!r,applyPixelMask:!!n,applyPixelHighlights:!!a},optionalAttributes:null,useComputeBuffer:!1}}_getCommonConfig(e){const{coordScale:t,computedOpacity:i,transforms:o}=e,{names:s,textures:r}=e.getTextures({useProcessedTexture:e.processed}),n=r[s.indexOf("u_image")],a=e.getRasterTextureSize();let u=0;const c={texture:{texture:n,unit:u++},dvsMat3:o.displayViewScreenMat3,coordScale:t,srcImageSize:a,opacity:i},m=r[s.indexOf("u_transformGrid")],{transformGrid:l}=e,p=!(!m||!l),h=p?{transformTexture:{texture:m,unit:u++},targetImageSize:[e.width,e.height],transformSpacing:l.spacing,transformGridSize:l.size}:void 0,f=r[s.indexOf("u_colormap")],{colormap:d,colormapOffset:g}=e.symbolizerParameters,x=f&&d?{colormapTexture:{texture:f,unit:u++},colormapOffset:g??0,colormapMaxIndex:d.length/4-1}:void 0,C=r[s.indexOf("u_mask")],b=C?{maskTexture:{texture:C,unit:u++}}:void 0,{highlightTexture:T}=e;return{config:c,projectionConfig:h,colormapConfig:x,pixelMaskConfig:b,highlightConfig:T?{highlightTexture:{texture:T,unit:u++}}:void 0,projectionDefines:{applyProjection:p,lookupProjection:p&&1===l.spacing[0]},textureUnit:u}}}function h(e,t,i){const o=new l(t,i);return o.internalFormat=a.RGBA32F,o.samplingMode=9728,o.dataType=u.FLOAT,o.wrapMode=33071,new m(e,o)}function f(e){return!e.suspended&&null!=e.source&&!e.isRendereredSource&&"stretch"===e.symbolizerParameters.type&&!!e.symbolizerParameters.dynamicRangeAdjustment}export{p as RasterColorizerTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{tileSize as e}from"../../../definitions.js";import{Technique as t}from"../Technique.js";import{getInterpolationDefines as i}from"./processor/textureUtils.js";import{RasterRangeHighlightShader as r}from"../shaders/raster/RasterRangeHighlightShader.js";import{SizedPixelFormat as o,PixelType as
|
|
5
|
+
import{tileSize as e}from"../../../definitions.js";import{Technique as t}from"../Technique.js";import{getInterpolationDefines as i}from"./processor/textureUtils.js";import{RasterRangeHighlightShader as r}from"../shaders/raster/RasterRangeHighlightShader.js";import{SizedPixelFormat as o,PixelType as n}from"../../../../../../webgl/enums.js";import{FramebufferObject as s}from"../../../../../../webgl/FramebufferObject.js";import{Texture as a}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as h}from"../../../../../../webgl/TextureDescriptor.js";class g extends t{constructor(){super(...arguments),this.name="BrushRasterHighlight",this.type=2,this.shaders={range:new r}}shutdown(e){super.shutdown(e),this._fbo?.dispose(),this._fbo=void 0}render(t,r){const{context:o}=t;if(!this._fbo){const i=u(t.context,e,e);this._fbo=new s(o,i)}const n=o.getBoundFramebufferObject(),a=o.getViewport(),{pixelHighlightOptions:h}=t;for(const s of r.bitmaps){if(!h||!s.source||s.highlighted||s.suspended||s.isRendereredSource)continue;const r=s.bandIds?.length?s.bandIds.indexOf(h.bandId):0;if(r<0||r>2)continue;t.timeline.begin(this.name);const{painter:n}=t;n.setPipelineState({depth:!1,stencil:{test:!1,write:!1},color:{write:[!0,!0,!0,!0],blendMode:"custom",blendParameters:{srcRGB:1,dstRGB:0,srcAlpha:1,dstAlpha:0}}}),s.updateTexture(t),s.updateProcessedTexture(!1);const{config:a,projectionConfig:g,highlightConfig:c,projectionDefines:d}=this._getCommonConfig(s),f=i(s);"bilinear"!==s.interpolation||t.context.capabilities.textureFloatLinear||(f.bilinear=!0);const p=new Float32Array(9);p[3*r]=1;const l={...h,bandSwap:p},m={shader:this.shaders.range,uniforms:{projectionConfig:g,config:a,rangeHighlightConfig:l,highlightConfig:c},defines:{...d,...f,applyPixelMask:!1,applyPixelHighlights:!1,hasExistingHighlights:!!c},optionalAttributes:null,useComputeBuffer:!1};o.bindFramebuffer(this._fbo),o.setViewport(0,0,e,e),n.submitDrawMesh(t.context,m,n.quadMesh);const x=u(t.context,e,e);this._fbo.copyToTexture(0,0,e,e,0,0,x),s.highlightTexture=x,t.timeline.end(this.name)}o.bindFramebuffer(n),o.setViewport(a.x,a.y,a.width,a.height)}_getCommonConfig(e){const{names:t,textures:i}=e.getTextures({forProcessing:!0,useProcessedTexture:e.processed}),r=i[t.indexOf("u_image")],o=e.getRasterTextureSize(),n={texture:{texture:r,unit:0},dvsMat3:new Float32Array([2,0,0,0,2,0,-1,-1,0]),coordScale:[1,1],srcImageSize:o,opacity:1},s=i[t.indexOf("u_transformGrid")],{transformGrid:a}=e,h=!(!s||!a),g=h?{transformTexture:{texture:s,unit:1},targetImageSize:[e.width,e.height],transformSpacing:a.spacing,transformGridSize:a.size}:void 0,{highlightTexture:u}=e;return{config:n,projectionConfig:g,highlightConfig:u?{highlightTexture:{texture:u,unit:2}}:void 0,projectionDefines:{applyProjection:h,lookupProjection:h&&1===a.spacing[0]}}}}function u(e,t,i){const r=new h(t,i);return r.internalFormat=o.RGBA8,r.samplingMode=9728,r.dataType=n.UNSIGNED_BYTE,r.isImmutable=!0,r.wrapMode=33071,new a(e,r)}export{g as RasterHighlightTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import{Texture as e}from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import"../../../webgl/enums.js";import"../../../webgl/checkWebGLError.js";import{TextureDescriptor as p}from"../../../webgl/TextureDescriptor.js";function r(r,t,
|
|
5
|
+
import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import{Texture as e}from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import"../../../webgl/enums.js";import"../../../webgl/checkWebGLError.js";import{TextureDescriptor as p}from"../../../webgl/TextureDescriptor.js";function r(r,t,i){const a=new p(t.width,t.height);return a.dataType=t.dataType,t.depth&&(a.depth=t.depth),t.flipped&&(a.flipped=t.flipped),t.hasMipmap&&(a.hasMipmap=t.hasMipmap),a.internalFormat=t.internalFormat,t.isImmutable&&(a.isImmutable=t.isImmutable),t.isOpaque&&(a.isOpaque=t.isOpaque),t.maxAnisotropy&&(a.maxAnisotropy=t.maxAnisotropy),a.pixelFormat=t.pixelFormat,t.preMultiplyAlpha&&(a.preMultiplyAlpha=t.preMultiplyAlpha),t.samplingMode&&(a.samplingMode=t.samplingMode),t.target&&(a.target=t.target),a.uniform=t.uniform,t.unpackAlignment&&(a.unpackAlignment=t.unpackAlignment),t.wrapMode&&(a.wrapMode=t.wrapMode),new e(r,a,i)}export{r as createTexture};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import{destroyMaybe as e}from"../../../../core/maybe.js";import{throwIfAborted as t,createResolver as s}from"../../../../core/promiseUtils.js";import{UpdatingHandles as r}from"../../../../core/support/UpdatingHandles.js";import{AFeatureContainer as i}from"../../engine/AFeatureContainer.js";import n from"../../engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js";import{Techniques as a}from"../../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import{RenderState as o}from"./RenderState.js";import{renderHighlight as h}from"../support/util.js";class d{constructor(e,t){this.id=e,this.version=t,this._resolver=s(),this._done=!1}get done(){return this._done}get promise(){return this._resolver.promise}end(){this._resolver.resolve(),this._done=!0}destroy(){this._resolver.reject()}}class l extends i{constructor(e){super(e.view.featuresTilingScheme),this.updatingHandles=new r,this._hitTestsRequests=[],this._store=new n,this._visibleTiles=new Set,this._subscriptions=new Map,this._updateStatisticsRequests=[],this._lockStatisticUpdates=!1,this._shouldUnlockAttributeView=!1,this._layerView=e,this.addTransitionable(this._layerView.featureEffectView)}destroy(){this.updatingHandles.destroy(),super.destroy(),this._renderState=e(this._renderState),this._renderStateNext=e(this._renderStateNext)}renderChildren(e){if(this._updateAttributeView(),this._renderState?.update(this.attributeView.currentEpoch),this._layerView.requestUpdate(),this._renderState){const e=Array.from(this._renderState.tiles()).filter(e=>e.needsUpload);if(e.length){e[Math.floor(Math.random()*e.length)].upload(),e.length>=2&&this.requestRender()}for(const t of this._renderState.tiles())t.tryReady(this.attributeView.currentEpoch)&&(this._subscriptions.get(t.key.id)?.end(),this._layerView.requestUpdate(),this.hasLabels&&this._layerView.view.labelManager.requestUpdate(),this._layerView.view.labelManager.symbolFader.restartDeclutter(),this.requestRender())}const t=this._layerView.subscriptionManager.updateVisibility();this.setVisibleTiles(t);for(const s of this.children)s.setTransform(e.state);switch(super.renderChildren(e),e.drawPhase){case 1:return this._renderMapPhase(e);case 16:return this._renderHighlightPhase(e);case 2:return this._renderLabelPhase(e)}}subscriptions(){return this._subscriptions.values()}get hasLabels(){return this._layerView.labelingCollisionInfos.length>0}get hasHighlight(){return this._layerView.hasHighlight}get children(){return this._renderState?Array.from(this._renderState.tiles()).filter(e=>this._visibleTiles.has(e.key.id)):[]}get usedMemory(){let e=0;return this._renderState&&(e+=this._renderState.usedMemory),this._renderStateNext&&(e+=this._renderStateNext.usedMemory),e+=this.attributeView.usedMemory,e}get instanceStore(){return this._store}get layerView(){return this._layerView}get tiles(){return this._renderState?.tiles()}get _instanceStore(){return this._store}get _layer(){return this._layerView.layer}_getHeatmapInstance(e){if(null==this._instanceStore||!(e.drawPhase&a.heatmap.drawPhase))return null;for(const t of this._instanceStore.values())if(u(t))return t;return null}updateAttributeView(e){this.requestRender(),this.attributeView.requestUpdate(e),this.hasLabels&&(this._layerView.view.labelManager.requestUpdate(),this._layerView.view.labelManager.symbolFader.restartDeclutter())}updateSubscriptions(e){for(const{tileId:t,version:s}of e.subscribe){if(!this._subscriptions.has(t)){const e=new d(t,s);this._subscriptions.set(t,e),this.updatingHandles.addPromise(e.promise);continue}this._subscriptions.get(t).version=s}for(const t of e.unsubscribe){const e=this._subscriptions.get(t);e?.destroy(),this._subscriptions.delete(t),this.removeTile(t)}}isDone(e){return!!this._renderState&&this._renderState.isTileDone(e)}async updateRenderState(e){has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureContainer.updateRenderState`),this._renderStateNext=new o(()=>this._stage,e=>this._subscriptions.get(e)?.version,e,this.layerView.view.labelManager.symbolFader,this,this.tileInfoView)}getDisplayStatistics(e,t){const s=this._statisticsByLevel.get(e);return s?s.get(t):null}updateStatistics(e,t){if(this._lockStatisticUpdates)return void this._updateStatisticsRequests.push({level:e,statistics:t});let s=this._statisticsByLevel.get(e);s||(s=new Map,this._statisticsByLevel.set(e,s));for(const r of t)s.set(r.fieldName,{minValue:r.minValue,maxValue:r.maxValue})}lockForOverrides(){this._renderState?.lockUploads(),this._lockStatisticUpdates=!0,this.attributeView.locked||(this.attributeView.lockTextureUploads(),this._shouldUnlockAttributeView=!0)}unlockForOverrides(){this._renderState?.unlockUploads(),this._shouldUnlockAttributeView&&(this.attributeView.unlockTextureUploads(),this._shouldUnlockAttributeView=!1),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this._renderState?.flush(),this.requestRender()}trySwapRenderState(){if(this._renderStateNext){has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`);const e=new Map;for(const t of this._renderState?.tiles()||[])e.set(t.id,t.metricsVisibility);this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderState.flush();for(const t of this._renderState.tiles())t.copyMetricsVisibility(e.get(t.id)||new Set);this._renderStateNext=null}this.requestRender()}setVisibleTiles(e){this._visibleTiles=e;for(const t of this.tiles??[])t.rendering=e.has(t.key.id)}async onMessage(e,s){t(s);const r=e.inner;if(!this._subscriptions.has(r.id))return;const i=this._subscriptions.get(r.id);if(i.version!==r.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${r.subscriptionVesrion} != ${i.version}`;console.debug(`Version[${e}] Tile[${r.id}] FeatureContainer - Dropping message, outdated version]`,r)}return}const n=this._renderStateNext??this._renderState;if(!n)throw new Error("InternalError: No renderState defined");n.version!==r.version&&console.error(`InternalError: Version mismatch. [renderState: ${n.version}, message: ${r.version}]`),n.enqueueUpdate(e),this.requestRender(),this._layerView.view.labelManager.requestUpdate(),this._layerView.requestUpdate()}removeTile(e){(this._renderState||this._renderStateNext)&&(this._renderState&&this._renderState.removeTile(e),this._renderStateNext&&this._renderStateNext.removeTile(e))}hitTest(e){let t=this._hitTestsRequests.find(({x:t,y:s})=>t===e.x&&s===e.y);const r=s();return t?t.resolvers.push(r):(t={x:e.x,y:e.y,resolvers:[r]},this._hitTestsRequests.push(t)),this.requestRender(),r.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const r of this.children)if(r.getSortKeys(t).forEach((e,t)=>s.set(t,e)),s.size===t.size)break;return s}get hasAnimation(){return this.hasLabels}doRender(e){const{minScale:t,maxScale:s}=this._layer.effectiveScaleRange,r=e.state.scale;r<=(t||1/0)&&r>=s&&super.doRender(e)}afterRender(e){super.afterRender(e),this._hitTestsRequests.length&&this.requestRender()}setStencilReference(e){if(null==this._getHeatmapInstance(e))super.setStencilReference(e);else for(const t of this.children)t.stencilRef=a.heatmap.getStencilReference(t)}_renderMapPhase(e){this._layerView.featureEffectView.hasEffects?(this._renderOutsideEffect(e),this._renderInsideEffect(e)):this._renderFeatures(e,0),this._hitTestsRequests.length>0&&this._renderHittest(e)}_renderHighlightPhase(e){this.hasHighlight&&h(e,!1,e=>{this._renderFeatures(e,1)})}_renderLabelPhase(e){this._renderFeatures(e,0)}_renderInsideEffect(e){const t=e.painter.effects.insideEffect;t.bind(e),this._renderFeatures(e,2),t.draw(e,this._layerView.featureEffectView.includedEffects),t.unbind()}_renderOutsideEffect(e){const t=e.painter.effects.outsideEffect;t.bind(e),this._renderFeatures(e,3),t.draw(e,this._layerView.featureEffectView.excludedEffects),t.unbind()}_renderHittest(e){const{context:t}=e,s=e.painter.effects.hittest,r=t.getBoundFramebufferObject(),i=t.getViewport(),n=e.passOptions,a=e.drawPhase;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),e.drawPhase=8;const{distance:o,smallSymbolDistance:h}=e.passOptions,d=Math.max(o,h);for(const l of this.children)l.visible&&l.containsScreenPoint(e.state,e.passOptions.position,2*d)&&this._renderTile(l,e,0);s.draw(e),s.unbind(),t.bindFramebuffer(r),t.restoreViewport(i),e.passOptions=n,e.drawPhase=a}_renderFeatures(e,t){const s=this._getHeatmapInstance(e);null!=s?this._renderHeatmapFeatures(e,t,s):this._renderGeometryFeatures(e,t)}_renderGeometryFeatures(e,t){for(const s of this.children)s.visible&&this._renderTile(s,e,t)}_renderHeatmapFeatures(e,t,s){for(const r of this.children)r.visible&&this._renderTile(r,e,t,17);s.techniqueRef.renderResolvePass(e,s)}_renderTile(e,t,s,r){const i=has("featurelayer-strict-draw-order")?1:has("featurelayer-force-marker-text-draw-order")?2:0,n=e.getDisplayList(this._instanceStore,i);t.selection=s,n?.render(t,r)}}function u(e){return 17===e.techniqueRef.type}export{l as FeatureContainer};
|
|
5
|
+
import has from"../../../../core/has.js";import{destroyMaybe as e}from"../../../../core/maybe.js";import{throwIfAborted as t,createResolver as s}from"../../../../core/promiseUtils.js";import{UpdatingHandles as r}from"../../../../core/support/UpdatingHandles.js";import{AFeatureContainer as i}from"../../engine/AFeatureContainer.js";import n from"../../engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js";import{Techniques as a}from"../../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import{RenderState as o}from"./RenderState.js";import{renderHighlight as h}from"../support/util.js";class d{constructor(e,t){this.id=e,this.version=t,this._resolver=s(),this._done=!1}get done(){return this._done}get promise(){return this._resolver.promise}end(){this._resolver.resolve(),this._done=!0}destroy(){this._resolver.reject()}}class l extends i{constructor(e){super(e.view.featuresTilingScheme),this.updatingHandles=new r,this._hitTestsRequests=[],this._store=new n,this._visibleTiles=new Set,this._subscriptions=new Map,this._updateStatisticsRequests=[],this._lockStatisticUpdates=!1,this._shouldUnlockAttributeView=!1,this._layerView=e,this.addTransitionable(this._layerView.featureEffectView)}destroy(){this.updatingHandles.destroy(),super.destroy(),this._renderState=e(this._renderState),this._renderStateNext=e(this._renderStateNext)}renderChildren(e){if(this._updateAttributeView(),this._renderState?.update(this.attributeView.currentEpoch),this._layerView.requestUpdate(),this._renderState){const e=Array.from(this._renderState.tiles()).filter(e=>e.needsUpload);if(e.length){e[Math.floor(Math.random()*e.length)].upload(),e.length>=2&&this.requestRender();for(const t of e.filter(e=>e.hasMetrics))t.upload()}for(const t of this._renderState.tiles())t.tryReady(this.attributeView.currentEpoch)&&(this._subscriptions.get(t.key.id)?.end(),this._layerView.requestUpdate(),this.hasLabels&&this._layerView.view.labelManager.requestUpdate(),this._layerView.view.labelManager.symbolFader.restartDeclutter(),this.requestRender())}const t=this._layerView.subscriptionManager.updateVisibility();this.setVisibleTiles(t);for(const s of this.children)s.setTransform(e.state);switch(super.renderChildren(e),e.drawPhase){case 1:return this._renderMapPhase(e);case 16:return this._renderHighlightPhase(e);case 2:return this._renderLabelPhase(e)}}subscriptions(){return this._subscriptions.values()}get hasLabels(){return this._layerView.labelingCollisionInfos.length>0}get hasHighlight(){return this._layerView.hasHighlight}get children(){return this._renderState?Array.from(this._renderState.tiles()).filter(e=>this._visibleTiles.has(e.key.id)):[]}get usedMemory(){let e=0;return this._renderState&&(e+=this._renderState.usedMemory),this._renderStateNext&&(e+=this._renderStateNext.usedMemory),e+=this.attributeView.usedMemory,e}get instanceStore(){return this._store}get layerView(){return this._layerView}get tiles(){return this._renderState?.tiles()}get _instanceStore(){return this._store}get _layer(){return this._layerView.layer}_getHeatmapInstance(e){if(null==this._instanceStore||!(e.drawPhase&a.heatmap.drawPhase))return null;for(const t of this._instanceStore.values())if(u(t))return t;return null}updateAttributeView(e){this.requestRender(),this.attributeView.requestUpdate(e),this.hasLabels&&(this._layerView.view.labelManager.requestUpdate(),this._layerView.view.labelManager.symbolFader.restartDeclutter())}updateSubscriptions(e){for(const{tileId:t,version:s}of e.subscribe){if(!this._subscriptions.has(t)){const e=new d(t,s);this._subscriptions.set(t,e),this.updatingHandles.addPromise(e.promise);continue}this._subscriptions.get(t).version=s}for(const t of e.unsubscribe){const e=this._subscriptions.get(t);e?.destroy(),this._subscriptions.delete(t),this.removeTile(t)}}isDone(e){return!!this._renderState&&this._renderState.isTileDone(e)}async updateRenderState(e){has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureContainer.updateRenderState`),this._renderStateNext=new o(()=>this._stage,e=>this._subscriptions.get(e)?.version,e,this.layerView.view.labelManager.symbolFader,this,this.tileInfoView)}getDisplayStatistics(e,t){const s=this._statisticsByLevel.get(e);return s?s.get(t):null}updateStatistics(e,t){if(this._lockStatisticUpdates)return void this._updateStatisticsRequests.push({level:e,statistics:t});let s=this._statisticsByLevel.get(e);s||(s=new Map,this._statisticsByLevel.set(e,s));for(const r of t)s.set(r.fieldName,{minValue:r.minValue,maxValue:r.maxValue})}lockForOverrides(){this._renderState?.lockUploads(),this._lockStatisticUpdates=!0,this.attributeView.locked||(this.attributeView.lockTextureUploads(),this._shouldUnlockAttributeView=!0)}unlockForOverrides(){this._renderState?.unlockUploads(),this._shouldUnlockAttributeView&&(this.attributeView.unlockTextureUploads(),this._shouldUnlockAttributeView=!1),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this._renderState?.flush(),this.requestRender()}trySwapRenderState(){if(this._renderStateNext){has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`);const e=new Map;for(const t of this._renderState?.tiles()||[])e.set(t.id,t.metricsVisibility);this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderState.flush();for(const t of this._renderState.tiles())t.copyMetricsVisibility(e.get(t.id)||new Set);this._renderStateNext=null}this.requestRender()}setVisibleTiles(e){this._visibleTiles=e;for(const t of this.tiles??[])t.rendering=e.has(t.key.id)}async onMessage(e,s){t(s);const r=e.inner;if(!this._subscriptions.has(r.id))return;const i=this._subscriptions.get(r.id);if(i.version!==r.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${r.subscriptionVesrion} != ${i.version}`;console.debug(`Version[${e}] Tile[${r.id}] FeatureContainer - Dropping message, outdated version]`,r)}return}const n=this._renderStateNext??this._renderState;if(!n)throw new Error("InternalError: No renderState defined");n.version!==r.version&&console.error(`InternalError: Version mismatch. [renderState: ${n.version}, message: ${r.version}]`),n.enqueueUpdate(e),this.requestRender(),this._layerView.view.labelManager.requestUpdate(),this._layerView.requestUpdate()}removeTile(e){(this._renderState||this._renderStateNext)&&(this._renderState&&this._renderState.removeTile(e),this._renderStateNext&&this._renderStateNext.removeTile(e))}hitTest(e){let t=this._hitTestsRequests.find(({x:t,y:s})=>t===e.x&&s===e.y);const r=s();return t?t.resolvers.push(r):(t={x:e.x,y:e.y,resolvers:[r]},this._hitTestsRequests.push(t)),this.requestRender(),r.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const r of this.children)if(r.getSortKeys(t).forEach((e,t)=>s.set(t,e)),s.size===t.size)break;return s}get hasAnimation(){return this.hasLabels}doRender(e){const{minScale:t,maxScale:s}=this._layer.effectiveScaleRange,r=e.state.scale;r<=(t||1/0)&&r>=s&&super.doRender(e)}afterRender(e){super.afterRender(e),this._hitTestsRequests.length&&this.requestRender()}setStencilReference(e){if(null==this._getHeatmapInstance(e))super.setStencilReference(e);else for(const t of this.children)t.stencilRef=a.heatmap.getStencilReference(t)}_renderMapPhase(e){this._layerView.featureEffectView.hasEffects?(this._renderOutsideEffect(e),this._renderInsideEffect(e)):this._renderFeatures(e,0),this._hitTestsRequests.length>0&&this._renderHittest(e)}_renderHighlightPhase(e){this.hasHighlight&&h(e,!1,e=>{this._renderFeatures(e,1)})}_renderLabelPhase(e){this._renderFeatures(e,0)}_renderInsideEffect(e){const t=e.painter.effects.insideEffect;t.bind(e),this._renderFeatures(e,2),t.draw(e,this._layerView.featureEffectView.includedEffects),t.unbind()}_renderOutsideEffect(e){const t=e.painter.effects.outsideEffect;t.bind(e),this._renderFeatures(e,3),t.draw(e,this._layerView.featureEffectView.excludedEffects),t.unbind()}_renderHittest(e){const{context:t}=e,s=e.painter.effects.hittest,r=t.getBoundFramebufferObject(),i=t.getViewport(),n=e.passOptions,a=e.drawPhase;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),e.drawPhase=8;const{distance:o,smallSymbolDistance:h}=e.passOptions,d=Math.max(o,h);for(const l of this.children)l.visible&&l.containsScreenPoint(e.state,e.passOptions.position,2*d)&&this._renderTile(l,e,0);s.draw(e),s.unbind(),t.bindFramebuffer(r),t.restoreViewport(i),e.passOptions=n,e.drawPhase=a}_renderFeatures(e,t){const s=this._getHeatmapInstance(e);null!=s?this._renderHeatmapFeatures(e,t,s):this._renderGeometryFeatures(e,t)}_renderGeometryFeatures(e,t){for(const s of this.children)s.visible&&this._renderTile(s,e,t)}_renderHeatmapFeatures(e,t,s){for(const r of this.children)r.visible&&this._renderTile(r,e,t,17);s.techniqueRef.renderResolvePass(e,s)}_renderTile(e,t,s,r){const i=has("featurelayer-strict-draw-order")?1:has("featurelayer-force-marker-text-draw-order")?2:0,n=e.getDisplayList(this._instanceStore,i);t.selection=s,n?.render(t,r)}}function u(e){return 17===e.techniqueRef.type}export{l as FeatureContainer};
|
package/views/3d/GroundView3D.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{EventedMixin as t}from"../../core/Evented.js";import{when as r}from"../../core/reactiveUtils.js";import{property as
|
|
5
|
+
import{__decorate as e}from"tslib";import{EventedMixin as t}from"../../core/Evented.js";import{when as r}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import i from"../GroundView.js";import{isIntegratedMeshLayerView as s}from"../support/layerViewUtils.js";let o=class extends(t(i)){constructor(){super(...arguments),this._integratedMeshElevationUpdateHandles=new Map}initialize(){super.initialize(),this.addHandles(r(()=>this._terrainSurface,e=>e.on("elevation-change",e=>this._elevationChange(e))));const e=this._integratedMeshElevationUpdateHandles;this.addHandles(this.view.allLayerViews.on("change",t=>{t.added.forEach(t=>{s(t)&&e.set(t,t.elevationProvider.on("elevation-change",e=>this._elevationChange(e)))}),t.removed.forEach(t=>{s(t)&&(e.get(t)?.remove(),e.delete(t))})}))}destroy(){this._integratedMeshElevationUpdateHandles.forEach(e=>e.remove()),this._integratedMeshElevationUpdateHandles.clear()}_elevationChange(e){this.emit("elevation-change",e)}get _integratedMeshGroundLayerView(){const e=this.ground?.integratedMeshGround;if(e)return this.view.basemapView?.groundLayerViews.find(t=>t.layer===e)}get _terrainSurface(){return this.view.basemapTerrain}get _usingTerrain(){return this._terrainSurface?.enabled??!1}get _usingIntegratedMesh(){return this._integratedMeshGroundLayerView?.visible??!1}get spatialReference(){return this._terrainSurface?.spatialReference}intersect(e,t,r,n){this._usingTerrain&&this._terrainSurface?.intersect(e,t,r,n);for(const a of this._integratedMeshElevationUpdateHandles.keys())a.intersect(e,t,r,n)}get updating(){return!this.suspended&&((this._source?.updating??!1)||this.layerViews.some(({updating:e})=>e))}get elevationQueryCache(){return this._usingTerrain?this._terrainSurface?.elevationQueryCache:null}get extentAABR(){return this._terrainSurface?.extent}get suspended(){return this._source?.suspended??!1}get ready(){return this._source?.ready??!0}updateOverlayParameters(){this._terrainSurface?.updateOverlayParameters()}get _source(){return this._usingTerrain?this._terrainSurface:this._usingIntegratedMesh?this._integratedMeshGroundLayerView:null}requestRender(e){this.view.stage.renderView?.requestRender(e)}};e([n({readOnly:!0})],o.prototype,"_integratedMeshGroundLayerView",null),e([n({readOnly:!0})],o.prototype,"_terrainSurface",null),e([n({readOnly:!0})],o.prototype,"_usingTerrain",null),e([n({readOnly:!0})],o.prototype,"_usingIntegratedMesh",null),e([n({readOnly:!0})],o.prototype,"spatialReference",null),e([n({type:Boolean,readOnly:!0})],o.prototype,"updating",null),e([n({readOnly:!0})],o.prototype,"elevationQueryCache",null),e([n({readOnly:!0})],o.prototype,"extentAABR",null),e([n({readOnly:!0})],o.prototype,"suspended",null),e([n({readOnly:!0})],o.prototype,"ready",null),o=e([a("esri.views.3d.GroundView3D")],o);export{o as GroundView3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../../../Color.js";import i from"../../../../analysis/LengthDimension.js";import a from"../../../../core/Accessor.js";import n from"../../../../core/Handles.js";import{destroyHandle as s,handlesGroup as o}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{equals as r}from"../../../../core/lang.js";import{mapCollection as p}from"../../../../core/mapCollectionUtils.js";import{releaseMaybe as l,destroyMaybe as u}from"../../../../core/maybe.js";import{memoize as d}from"../../../../core/memoize.js";import{ignoreAbortErrors as c}from"../../../../core/promiseUtils.js";import{watch as m,initial as h,sync as g,syncAndInitial as f,when as _}from"../../../../core/reactiveUtils.js";import{property as M}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as v}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as S}from"../../../../core/support/UpdatingHandles.js";import C from"../../../../geometry/Point.js";import{clonePoint as w}from"../../../../layers/graphics/hydratedFeatures.js";import{reapplyConstraint as b,applyConstraint as P,computeConstraint as O,constraintDependencies as D}from"./lengthDimensionConstraintUtils.js";import{LengthDimensionManipulators as H,LengthDimensionPointManipulator as j,pointManipulatorHandles as T,createOffsetManipulator as x,offsetManipulatorHandles as G,LineOfSightOrientationManipulator as z,headingManipulatorHandles as U,rotationManipulatorHandles as R,createMeasureTypeManipulator as I,measureTypeManipulatorHandles as V,updateOffsetManipulatorTransform as A,updateHeadingManipulatorTransform as E,updateRotationManipulatorTransform as k,updateMeasureTypeManipulatorTransform as L,unfocusedOffsetWidth as F,focusedOffsetWidth as q}from"./lengthDimensionManipulatorUtils.js";import{isValidComputation as B,arePointsVerticallyAligned as N,computationToGeometryDependencies as J,computeGeometryFromDimension as K}from"./lengthDimensionUtils.js";import{disabledPointColor as Q,pointRadius as W,getTransparentAccentColor as X,getContrastColor as Y,initialOffsetPx as Z}from"./settings.js";import{getRotateHeadingTexture as $}from"../images/Factory.js";import{SnappingVisualizer3D as tt}from"../../interactive/SnappingVisualizer3D.js";import{LineVisualElement as et}from"../../interactive/visualElements/LineVisualElement.js";import{VerticesVisualElement as it}from"../../interactive/visualElements/VerticesVisualElement.js";import{ImageMaterial as at}from"../../webgl-engine/materials/ImageMaterial.js";import{createStipplePatternSimple as nt}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as st}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createCoordinateHelper as ot}from"../../../interactive/coordinateHelper.js";import{EditGeometry as rt}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as pt}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as lt}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as ut}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{acquire as dt}from"../../../interactive/snapping/SnappingManagerPool.js";import{SnappingOperation as ct}from"../../../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as mt}from"../../../interactive/snapping/snappingUtils.js";let ht=class extends a{constructor(t){super(t),this._stagedDimension=null,this._snappingManagerResult=null,this._computationManipulators=new Map,this._computationHandles=new n,this._updatingHandles=new S,this._getSnappingContext=d(t=>new lt({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new pt(new rt("point",ot(!0,!1,this.view.spatialReference)),this.view.state.viewingMode),visualizer:new tt}));const{view:i}=t;this._unfocusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(i),this._focusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(i),this._thinOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(i),this._thinOffsetManipulatorMaterial.setParameters({stipplePattern:nt(2)}),this._constraintSnappingIndicator=new et({view:i,attached:!0,width:1,renderOccluded:4,stipplePattern:nt(5),isDecoration:!0});const a=e.toUnitRGBA(Q);this._stagedStartIndicator=new it({view:i,attached:!1,elevationInfo:{mode:"absolute-height",offset:0},spatialReference:t.view.renderCoordsHelper.spatialReference,color:a,size:2*W,outlineSize:0,renderOccluded:4,isDecoration:!0})}initialize(){const{view:t}=this;this._snappingOperation=new ct({view:t});const i=X(t.effectiveTheme),a=Y(t.effectiveTheme),n=!t.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._textureHandle=$(t.stage.textures,{accentColor:i,contrastColor:a,preMultiplyAlpha:n}),this._orientationManipulatorMaterial=new at({draped:!1,texture:this._textureHandle.texture,writeDepth:!1,renderOccluded:16,isDecoration:!0});const o=p(()=>this.analysisViewData.computations,({computation:t})=>this._createManipulators(t));this.addHandles([m(()=>({accentColor:X(t.effectiveTheme),contrastColor:Y(t.effectiveTheme)}),({accentColor:i,contrastColor:a})=>{const s=this._textureHandle;this._textureHandle=$(t.stage.textures,{accentColor:i,contrastColor:a,preMultiplyAlpha:n}),this._orientationManipulatorMaterial.setParameters({texture:this._textureHandle.texture}),s?.release();const o=e.toUnitRGBA(i);this._unfocusedOffsetManipulatorMaterial.setParameters({color:o}),this._focusedOffsetManipulatorMaterial.setParameters({color:o}),this._thinOffsetManipulatorMaterial.setParameters({color:o}),this._constraintSnappingIndicator.color=o},h),s(o),m(()=>({stagedPoint:this._snappingOperation.stagedPoint,stagedComputation:this._stagedComputation}),({stagedPoint:t,stagedComputation:e})=>{if(null==e||null==t)return;const i=w(t,new C);this._applyPointUpdate(e,{endPoint:i})},g),m(()=>({stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}),(t,e)=>{const{stagedDimension:i,selectedComputation:a,firstGrabbedManipulator:n}=t;if(i===e?.stagedDimension&&n===e?.firstGrabbedManipulator){for(const s of[a,e?.selectedComputation])if(null!=s){const e=this._computationManipulators.get(s);null!=e&&this._updateManipulators(s,e,t)}}else for(const[s,o]of this._computationManipulators)this._updateManipulators(s,o,t)},f),m(()=>this.analysis.style.lineSize,t=>this._updateManipulatorStyle(t),h),m(()=>this.view.state.camera,()=>{null!=this._stagedComputation&&this._updateStagedDimensionOffset(this._stagedComputation)}),m(()=>{const t=this._stagedComputation;if(!t)return null;const e=t.elevationAlignedStartPoint,i=y();return null!=e&&this.view.renderCoordsHelper.toRenderCoords(e,i)?i:null},t=>{null!=t?(this._stagedStartIndicator.vertices=[t],this._stagedStartIndicator.attached=!0):this._stagedStartIndicator.attached=!1})]),this.addHandles(this._constraintHandles),this.addHandles(this._snappingIndicatorHandles),mt(this,()=>{const t=this._activeComputation,e=this._stagedComputation;if(null==t||null!=e){const t=this.view.inputManager.latestPointerInfo?.type??"mouse",e=this._getSnappingContext(t);this._updatingHandles.addPromise(c(this._snappingOperation.snapAgainNearPreviousMapPoint(this._ensureSnappingManager(),e)))}if(null!=t){const{start:e,end:i}=this._computationManipulators.get(t);if(e.grabbing||i.grabbing){const i=e.grabbing?"start":"end",a=this._computeConstraint(t);b(t,i,{constraint:a,view:this.view})}}})}destroy(){this._textureHandle=l(this._textureHandle),this._snappingOperation=u(this._snappingOperation),this._computationHandles.destroy(),this._constraintSnappingIndicator.destroy(),this._stagedStartIndicator.destroy(),this._orientationManipulatorMaterial.dispose()}get updating(){return this._updatingHandles.updating||!!this._snappingManager?.updating}get firstGrabbedManipulator(){return this.parentTool.firstGrabbedManipulator}get hasGrabbedManipulators(){return this.parentTool.hasGrabbedManipulators}get snappingOptions(){return this._snappingManager?.options}get _snappingManager(){return this._snappingManagerResult?.snappingManager}_ensureSnappingManager(){return this._snappingManagerResult||(this._snappingManagerResult=dt(this.view),this.addHandles(this._snappingManagerResult)),this._snappingManagerResult.snappingManager}get _activeComputation(){if(null!=this._stagedComputation)return this._stagedComputation;const{selectedComputation:t}=this.analysisViewData;return this.hasGrabbedManipulators&&null!=t?t:null}get _stagedComputation(){const t=this._stagedDimension,e=this.analysisViewData.computations.at(-1)?.computation;return null==t||null==e||e.dimension!==t?null:e}get _constraintHandles(){return[_(()=>this.analysisViewData.selectedComputation,t=>{t.previousConstraint=this._computeConstraint(t)},{...f,equals:r}),m(()=>{const t=this._activeComputation;if(null==t)return null;const{measureType:e,orientation:i}=t.dimension;return{measureType:e,orientation:i,computation:t}},(t,e)=>{if(null!=t&&null==e){const{measureType:e,orientation:i,computation:a}=t;switch(a.previousConstraint){case 0:a.preConstraintProperties={measureType:"horizontal",orientation:0};break;case 1:a.preConstraintProperties={measureType:"vertical",orientation:0};break;case 2:a.preConstraintProperties={measureType:"direct",orientation:i};break;default:a.preConstraintProperties={measureType:e,orientation:i}}}null==t&&null!=e&&(e.computation.preConstraintProperties=null)},g)]}get _snappingIndicatorHandles(){const t="snapping-indicator-event-handles";return[m(()=>({stagedComputation:this._stagedComputation,activeComputation:this._activeComputation}),({stagedComputation:e,activeComputation:i})=>{const a=this._constraintSnappingIndicator;if(this.removeHandles(t),null!=i)if(i===e)a.attached=!0;else{const{start:e,end:n}=this._computationManipulators.get(i),s=()=>{a.attached=e.grabbing||n.grabbing};s(),this.addHandles([e.events.on("grab-changed",s),n.events.on("grab-changed",s)],t)}else a.attached=!1}),m(()=>{const t=this._activeComputation;return null!=t?{geometry:t.geometry,constraint:t.previousConstraint}:{}},({geometry:t,constraint:e})=>{const i=this._constraintSnappingIndicator;null!=t&&null!=e&&2!==e?(i.visible=!0,i.setGeometryFromSegment(t.directSegment)):i.visible=!1})]}removeStaged(){return null!=this._stagedDimension&&(this.analysis.dimensions.remove(this._stagedDimension),this._stagedDimension=null,!0)}onDeactivate(){this.removeStaged(),this._resetSnappingState()}onClick(t){const{_stagedDimension:e}=this;if(null==e){const e=this._onUnstagedClick(t);return this.analysis.dimensions.add(e),null}return this._onStagedClick(t),e}onPointerMove({mapPoint:t,pointerType:e}){if("touch"===e)return;const i=this._getSnappingContext(e);this._updatingHandles.addPromise(c(this._snappingOperation.snap({point:t},this._ensureSnappingManager(),i)))}onManipulatorSelectionChanged(){if(null!=this.analysisViewData.selectedComputation){this._computationManipulators.get(this.analysisViewData.selectedComputation).offset.selected||(this.analysisViewData.selectedDimension=null)}}_onUnstagedClick({mapPoint:t,pointerType:e}){let a=t;if("mouse"===e){const i=this._getSnappingContext(e);a=this._ensureSnappingManager().update({point:t,context:i})}const n=new i({startPoint:w(a,new C),endPoint:null,measureType:"horizontal"});return this._stagedDimension=n,this._resetSnappingState(),n}_onStagedClick({mapPoint:t,pointerType:e}){const i=this._stagedComputation;if(null==i)return;let a=t;if("mouse"===e){const i=this._getSnappingContext(e);a=this._ensureSnappingManager().update({point:t,context:i})}const n=w(a,new C);this._applyPointUpdate(i,{endPoint:n}),this._stagedDimension=null,this._resetSnappingState()}_resetSnappingState(){this._ensureSnappingManager().doneSnapping(),this._snappingOperation.abort(),this._snappingOperation.stagedPoint=null}_createManipulators(t){const e=this._setupPointManipulator(t,{isStart:!0}),i=this._setupPointManipulator(t,{isStart:!1}),a=this._setupOffsetManipulator(t),n=this._setupHeadingManipulator(t),s=this._setupRotationManipulator(t),r=this._setupMeasureTypeManipulator(t,"direct"),p=this._setupMeasureTypeManipulator(t,"horizontal"),l=this._setupMeasureTypeManipulator(t,"vertical"),u=new H({start:e,end:i,offset:a,heading:n,rotation:s,direct:r,horizontal:p,vertical:l});this._setupComputationToManipulatorsSync(t,u),this._computationManipulators.set(t,u),this.manipulators.addMany(u.values());const d=o(u.values().map(t=>t.events.on("focus-changed",()=>{u.values().some(t=>t.focused)&&this._resetSnappingState()})));return{manipulators:u,remove:()=>{d.remove(),this._computationHandles.remove(t),this._computationManipulators.delete(t);for(const t of u.values())this.manipulators.remove(t)}}}_setupComputationToManipulatorsSync(t,e){this._computationHandles.add([m(()=>t.geometry,()=>this._updateManipulators(t,e),{...f,equals:r})],t)}_setupPointManipulator(t,e){const{view:i}=this,{dimension:a}=t,n=new j(i,{metadata:a}),s=T(n,{isStart:e.isStart,createSnappingPipelineStep:t=>ut({snappingContext:this._getSnappingContext(t),snappingManager:this._snappingManager,updatingHandles:this._updatingHandles}),dimension:a,onUpdate:e=>this._applyPointUpdate(t,e),view:i});return this._computationHandles.add(s,t),n}_setupOffsetManipulator(t){const{view:e}=this,i=x(e,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,metadata:t.dimension}),a=G(i,{computation:t,view:e});return this._computationHandles.add(a,t),i}_setupHeadingManipulator(t){const{view:e}=this,i=new z(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),a=U(i,{computation:t,view:e});return this._computationHandles.add(a,t),i}_setupRotationManipulator(t){const{view:e}=this,i=new z(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),a=R(i,{computation:t,view:e});return this._computationHandles.add(a,t),i}_setupMeasureTypeManipulator(t,e){const{view:i}=this,a=I(i,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,thinOffsetManipulatorMaterial:this._thinOffsetManipulatorMaterial,metadata:t.dimension}),n=V(a,{computation:t,manipulatorMeasureType:e,view:i});return this._computationHandles.add(n,t),a}_updateManipulators(t,e,i={stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}){const{stagedDimension:a,selectedComputation:n,firstGrabbedManipulator:s}=i,{start:o,end:r,offset:p,heading:l,rotation:u}=e,d=n===t,c=B(t),{dimension:m}=t;for(const f of e.values()){const t=c&&null==a&&(null==s||f===s);f===p?(f.available=t,f.selected=d):f.available=t&&d}if(!c)return;null!=this._computeConstraint(t)?e.forEachMeasureTypeManipulator(t=>t.available=!1):e.manipulatorForMeasureType(m.measureType).available=!1;for(const f of[l,u])"direct"===m.measureType&&0!==m.offset||(f.available=!1);N(t)?u.available=!1:l.available=!1;const{geometry:h}=t;o.renderLocation=h.directSegment.startRenderSpace,r.renderLocation=h.directSegment.endRenderSpace;const{renderCoordsHelper:g}=this.view;A(p,h,g),l.available&&E(l,t,g),u.available&&k(u,t,g),e.forEachMeasureTypeManipulator((e,i)=>{e.available&&L(e,t,i,g)})}_updateManipulatorStyle(t){const e=F(t),i=q(t),a={lineSizePt:t,material:this._orientationManipulatorMaterial};for(const{offset:n,heading:s,rotation:o}of this._computationManipulators.values())n.radius=i/2,s.update(a),o.update(a);this._unfocusedOffsetManipulatorMaterial.setParameters({width:e}),this._focusedOffsetManipulatorMaterial.setParameters({width:i})}_applyPointUpdate(t,e){const{view:i}=this,a=J(t);"startPoint"in e&&(a.elevationAlignedStartPoint=e.startPoint),"endPoint"in e&&(a.elevationAlignedEndPoint=e.endPoint);const n=K(a,i.renderCoordsHelper);if(null==n)return;const s=this._computeConstraint({...a,geometry:n});P(t,e,{...a,constraint:s,unconstrainedGeometry:n,view:i}),t===this._stagedComputation&&this._updateStagedDimensionOffset(t)}_updateStagedDimensionOffset(t){if(null==t.geometry)return;t.geometry.directSegment.eval(.5,gt);const{state:e,renderCoordsHelper:i}=this.view,a=e.camera.computeScreenPixelSizeAt(gt);t.dimension.offset=Z*a*i.unitInMeters}_computeConstraint(t){return O(D(t,this._ensureSnappingManager().options),this.view)}_createOffsetManipulatorMaterial(t){return new st({width:1,renderOccluded:4,writeDepth:!1,hasPolygonOffset:!0,isDecoration:!0},t.state.isGlobal)}get test(){}};t([M({constructOnly:!0})],ht.prototype,"analysis",void 0),t([M({constructOnly:!0})],ht.prototype,"analysisViewData",void 0),t([M({constructOnly:!0})],ht.prototype,"manipulators",void 0),t([M({constructOnly:!0})],ht.prototype,"parentTool",void 0),t([M({constructOnly:!0,nonNullable:!0})],ht.prototype,"view",void 0),t([M({readOnly:!0})],ht.prototype,"updating",null),t([M()],ht.prototype,"firstGrabbedManipulator",null),t([M()],ht.prototype,"hasGrabbedManipulators",null),t([M()],ht.prototype,"snappingOptions",null),t([M()],ht.prototype,"_stagedDimension",void 0),t([M()],ht.prototype,"_snappingManager",null),t([M()],ht.prototype,"_activeComputation",null),t([M()],ht.prototype,"_stagedComputation",null),t([M()],ht.prototype,"_snappingManagerResult",void 0),ht=t([v("esri.views.3d.analysis.Dimension.LengthDimensionSubTool")],ht);const gt=y();export{ht as LengthDimensionSubTool};
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../../Color.js";import i from"../../../../analysis/LengthDimension.js";import a from"../../../../core/Accessor.js";import n from"../../../../core/Handles.js";import{destroyHandle as s,handlesGroup as o}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{equals as r}from"../../../../core/lang.js";import{mapCollection as p}from"../../../../core/mapCollectionUtils.js";import{releaseMaybe as l,destroyMaybe as u}from"../../../../core/maybe.js";import{memoize as d}from"../../../../core/memoize.js";import{ignoreAbortErrors as c}from"../../../../core/promiseUtils.js";import{watch as m,initial as h,sync as g,syncAndInitial as f,when as _}from"../../../../core/reactiveUtils.js";import{property as M}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as v}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as S}from"../../../../core/support/UpdatingHandles.js";import C from"../../../../geometry/Point.js";import{clonePoint as w}from"../../../../layers/graphics/hydratedFeatures.js";import{reapplyConstraint as b,applyConstraint as P,computeConstraint as O,constraintDependencies as D}from"./lengthDimensionConstraintUtils.js";import{LengthDimensionManipulators as H,LengthDimensionPointManipulator as j,pointManipulatorHandles as T,createOffsetManipulator as x,offsetManipulatorHandles as G,LineOfSightOrientationManipulator as z,headingManipulatorHandles as U,rotationManipulatorHandles as R,createMeasureTypeManipulator as I,measureTypeManipulatorHandles as V,updateOffsetManipulatorTransform as A,updateHeadingManipulatorTransform as E,updateRotationManipulatorTransform as k,updateMeasureTypeManipulatorTransform as L,unfocusedOffsetWidth as F,focusedOffsetWidth as q}from"./lengthDimensionManipulatorUtils.js";import{isValidComputation as B,arePointsVerticallyAligned as N,computationToGeometryDependencies as J,computeGeometryFromDimension as K}from"./lengthDimensionUtils.js";import{disabledPointColor as Q,pointRadius as W,getTransparentAccentColor as X,getContrastColor as Y,initialOffsetPx as Z}from"./settings.js";import{getRotateHeadingTexture as $}from"../images/Factory.js";import{SnappingVisualizer3D as tt}from"../../interactive/SnappingVisualizer3D.js";import{LineVisualElement as et}from"../../interactive/visualElements/LineVisualElement.js";import{VerticesVisualElement as it}from"../../interactive/visualElements/VerticesVisualElement.js";import{ImageMaterial as at}from"../../webgl-engine/materials/ImageMaterial.js";import{createStipplePatternSimple as nt}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as st}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createCoordinateHelper as ot}from"../../../interactive/coordinateHelper.js";import{EditGeometry as rt}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as pt}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as lt}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as ut}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{acquire as dt}from"../../../interactive/snapping/SnappingManagerPool.js";import{SnappingOperation as ct}from"../../../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as mt}from"../../../interactive/snapping/snappingUtils.js";let ht=class extends a{constructor(t){super(t),this._stagedDimension=null,this._snappingManagerResult=null,this._computationManipulators=new Map,this._computationHandles=new n,this._updatingHandles=new S,this._getSnappingContext=d(t=>new lt({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new pt(new rt("point",ot(!0,!1,this.view.spatialReference)),this.view.state.viewingMode),visualizer:new tt}));const{view:i}=t;this._unfocusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(i),this._focusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(i),this._thinOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(i),this._thinOffsetManipulatorMaterial.setParameters({stipplePattern:nt(2)}),this._constraintSnappingIndicator=new et({view:i,attached:!0,width:1,renderOccluded:4,stipplePattern:nt(5),isDecoration:!0});const a=e.toUnitRGBA(Q);this._stagedStartIndicator=new it({view:i,attached:!1,elevationInfo:{mode:"absolute-height",offset:0},spatialReference:t.view.renderCoordsHelper.spatialReference,color:a,size:2*W,outlineSize:0,renderOccluded:4,isDecoration:!0})}initialize(){const{view:t}=this;this._snappingOperation=new ct({view:t});const i=X(t.effectiveTheme),a=Y(t.effectiveTheme),n=!t.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._textureHandle=$(t.stage.textures,{accentColor:i,contrastColor:a,preMultiplyAlpha:n}),this._orientationManipulatorMaterial=new at({draped:!1,managedTexture:this._textureHandle.managedTexture,writeDepth:!1,renderOccluded:16,isDecoration:!0});const o=p(()=>this.analysisViewData.computations,({computation:t})=>this._createManipulators(t));this.addHandles([m(()=>({accentColor:X(t.effectiveTheme),contrastColor:Y(t.effectiveTheme)}),({accentColor:i,contrastColor:a})=>{const s=this._textureHandle;this._textureHandle=$(t.stage.textures,{accentColor:i,contrastColor:a,preMultiplyAlpha:n}),this._orientationManipulatorMaterial.setParameters({managedTexture:this._textureHandle.managedTexture}),s?.release();const o=e.toUnitRGBA(i);this._unfocusedOffsetManipulatorMaterial.setParameters({color:o}),this._focusedOffsetManipulatorMaterial.setParameters({color:o}),this._thinOffsetManipulatorMaterial.setParameters({color:o}),this._constraintSnappingIndicator.color=o},h),s(o),m(()=>({stagedPoint:this._snappingOperation.stagedPoint,stagedComputation:this._stagedComputation}),({stagedPoint:t,stagedComputation:e})=>{if(null==e||null==t)return;const i=w(t,new C);this._applyPointUpdate(e,{endPoint:i})},g),m(()=>({stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}),(t,e)=>{const{stagedDimension:i,selectedComputation:a,firstGrabbedManipulator:n}=t;if(i===e?.stagedDimension&&n===e?.firstGrabbedManipulator){for(const s of[a,e?.selectedComputation])if(null!=s){const e=this._computationManipulators.get(s);null!=e&&this._updateManipulators(s,e,t)}}else for(const[s,o]of this._computationManipulators)this._updateManipulators(s,o,t)},f),m(()=>this.analysis.style.lineSize,t=>this._updateManipulatorStyle(t),h),m(()=>this.view.state.camera,()=>{null!=this._stagedComputation&&this._updateStagedDimensionOffset(this._stagedComputation)}),m(()=>{const t=this._stagedComputation;if(!t)return null;const e=t.elevationAlignedStartPoint,i=y();return null!=e&&this.view.renderCoordsHelper.toRenderCoords(e,i)?i:null},t=>{null!=t?(this._stagedStartIndicator.vertices=[t],this._stagedStartIndicator.attached=!0):this._stagedStartIndicator.attached=!1})]),this.addHandles(this._constraintHandles),this.addHandles(this._snappingIndicatorHandles),mt(this,()=>{const t=this._activeComputation,e=this._stagedComputation;if(null==t||null!=e){const t=this.view.inputManager.latestPointerInfo?.type??"mouse",e=this._getSnappingContext(t);this._updatingHandles.addPromise(c(this._snappingOperation.snapAgainNearPreviousMapPoint(this._ensureSnappingManager(),e)))}if(null!=t){const{start:e,end:i}=this._computationManipulators.get(t);if(e.grabbing||i.grabbing){const i=e.grabbing?"start":"end",a=this._computeConstraint(t);b(t,i,{constraint:a,view:this.view})}}})}destroy(){this._textureHandle=l(this._textureHandle),this._snappingOperation=u(this._snappingOperation),this._computationHandles.destroy(),this._constraintSnappingIndicator.destroy(),this._stagedStartIndicator.destroy(),this._orientationManipulatorMaterial.dispose()}get updating(){return this._updatingHandles.updating||!!this._snappingManager?.updating}get firstGrabbedManipulator(){return this.parentTool.firstGrabbedManipulator}get hasGrabbedManipulators(){return this.parentTool.hasGrabbedManipulators}get snappingOptions(){return this._snappingManager?.options}get _snappingManager(){return this._snappingManagerResult?.snappingManager}_ensureSnappingManager(){return this._snappingManagerResult||(this._snappingManagerResult=dt(this.view),this.addHandles(this._snappingManagerResult)),this._snappingManagerResult.snappingManager}get _activeComputation(){if(null!=this._stagedComputation)return this._stagedComputation;const{selectedComputation:t}=this.analysisViewData;return this.hasGrabbedManipulators&&null!=t?t:null}get _stagedComputation(){const t=this._stagedDimension,e=this.analysisViewData.computations.at(-1)?.computation;return null==t||null==e||e.dimension!==t?null:e}get _constraintHandles(){return[_(()=>this.analysisViewData.selectedComputation,t=>{t.previousConstraint=this._computeConstraint(t)},{...f,equals:r}),m(()=>{const t=this._activeComputation;if(null==t)return null;const{measureType:e,orientation:i}=t.dimension;return{measureType:e,orientation:i,computation:t}},(t,e)=>{if(null!=t&&null==e){const{measureType:e,orientation:i,computation:a}=t;switch(a.previousConstraint){case 0:a.preConstraintProperties={measureType:"horizontal",orientation:0};break;case 1:a.preConstraintProperties={measureType:"vertical",orientation:0};break;case 2:a.preConstraintProperties={measureType:"direct",orientation:i};break;default:a.preConstraintProperties={measureType:e,orientation:i}}}null==t&&null!=e&&(e.computation.preConstraintProperties=null)},g)]}get _snappingIndicatorHandles(){const t="snapping-indicator-event-handles";return[m(()=>({stagedComputation:this._stagedComputation,activeComputation:this._activeComputation}),({stagedComputation:e,activeComputation:i})=>{const a=this._constraintSnappingIndicator;if(this.removeHandles(t),null!=i)if(i===e)a.attached=!0;else{const{start:e,end:n}=this._computationManipulators.get(i),s=()=>{a.attached=e.grabbing||n.grabbing};s(),this.addHandles([e.events.on("grab-changed",s),n.events.on("grab-changed",s)],t)}else a.attached=!1}),m(()=>{const t=this._activeComputation;return null!=t?{geometry:t.geometry,constraint:t.previousConstraint}:{}},({geometry:t,constraint:e})=>{const i=this._constraintSnappingIndicator;null!=t&&null!=e&&2!==e?(i.visible=!0,i.setGeometryFromSegment(t.directSegment)):i.visible=!1})]}removeStaged(){return null!=this._stagedDimension&&(this.analysis.dimensions.remove(this._stagedDimension),this._stagedDimension=null,!0)}onDeactivate(){this.removeStaged(),this._resetSnappingState()}onClick(t){const{_stagedDimension:e}=this;if(null==e){const e=this._onUnstagedClick(t);return this.analysis.dimensions.add(e),null}return this._onStagedClick(t),e}onPointerMove({mapPoint:t,pointerType:e}){if("touch"===e)return;const i=this._getSnappingContext(e);this._updatingHandles.addPromise(c(this._snappingOperation.snap({point:t},this._ensureSnappingManager(),i)))}onManipulatorSelectionChanged(){if(null!=this.analysisViewData.selectedComputation){this._computationManipulators.get(this.analysisViewData.selectedComputation).offset.selected||(this.analysisViewData.selectedDimension=null)}}_onUnstagedClick({mapPoint:t,pointerType:e}){let a=t;if("mouse"===e){const i=this._getSnappingContext(e);a=this._ensureSnappingManager().update({point:t,context:i})}const n=new i({startPoint:w(a,new C),endPoint:null,measureType:"horizontal"});return this._stagedDimension=n,this._resetSnappingState(),n}_onStagedClick({mapPoint:t,pointerType:e}){const i=this._stagedComputation;if(null==i)return;let a=t;if("mouse"===e){const i=this._getSnappingContext(e);a=this._ensureSnappingManager().update({point:t,context:i})}const n=w(a,new C);this._applyPointUpdate(i,{endPoint:n}),this._stagedDimension=null,this._resetSnappingState()}_resetSnappingState(){this._ensureSnappingManager().doneSnapping(),this._snappingOperation.abort(),this._snappingOperation.stagedPoint=null}_createManipulators(t){const e=this._setupPointManipulator(t,{isStart:!0}),i=this._setupPointManipulator(t,{isStart:!1}),a=this._setupOffsetManipulator(t),n=this._setupHeadingManipulator(t),s=this._setupRotationManipulator(t),r=this._setupMeasureTypeManipulator(t,"direct"),p=this._setupMeasureTypeManipulator(t,"horizontal"),l=this._setupMeasureTypeManipulator(t,"vertical"),u=new H({start:e,end:i,offset:a,heading:n,rotation:s,direct:r,horizontal:p,vertical:l});this._setupComputationToManipulatorsSync(t,u),this._computationManipulators.set(t,u),this.manipulators.addMany(u.values());const d=o(u.values().map(t=>t.events.on("focus-changed",()=>{u.values().some(t=>t.focused)&&this._resetSnappingState()})));return{manipulators:u,remove:()=>{d.remove(),this._computationHandles.remove(t),this._computationManipulators.delete(t);for(const t of u.values())this.manipulators.remove(t)}}}_setupComputationToManipulatorsSync(t,e){this._computationHandles.add([m(()=>t.geometry,()=>this._updateManipulators(t,e),{...f,equals:r})],t)}_setupPointManipulator(t,e){const{view:i}=this,{dimension:a}=t,n=new j(i,{metadata:a}),s=T(n,{isStart:e.isStart,createSnappingPipelineStep:t=>ut({snappingContext:this._getSnappingContext(t),snappingManager:this._snappingManager,updatingHandles:this._updatingHandles}),dimension:a,onUpdate:e=>this._applyPointUpdate(t,e),view:i});return this._computationHandles.add(s,t),n}_setupOffsetManipulator(t){const{view:e}=this,i=x(e,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,metadata:t.dimension}),a=G(i,{computation:t,view:e});return this._computationHandles.add(a,t),i}_setupHeadingManipulator(t){const{view:e}=this,i=new z(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),a=U(i,{computation:t,view:e});return this._computationHandles.add(a,t),i}_setupRotationManipulator(t){const{view:e}=this,i=new z(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),a=R(i,{computation:t,view:e});return this._computationHandles.add(a,t),i}_setupMeasureTypeManipulator(t,e){const{view:i}=this,a=I(i,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,thinOffsetManipulatorMaterial:this._thinOffsetManipulatorMaterial,metadata:t.dimension}),n=V(a,{computation:t,manipulatorMeasureType:e,view:i});return this._computationHandles.add(n,t),a}_updateManipulators(t,e,i={stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}){const{stagedDimension:a,selectedComputation:n,firstGrabbedManipulator:s}=i,{start:o,end:r,offset:p,heading:l,rotation:u}=e,d=n===t,c=B(t),{dimension:m}=t;for(const f of e.values()){const t=c&&null==a&&(null==s||f===s);f===p?(f.available=t,f.selected=d):f.available=t&&d}if(!c)return;null!=this._computeConstraint(t)?e.forEachMeasureTypeManipulator(t=>t.available=!1):e.manipulatorForMeasureType(m.measureType).available=!1;for(const f of[l,u])"direct"===m.measureType&&0!==m.offset||(f.available=!1);N(t)?u.available=!1:l.available=!1;const{geometry:h}=t;o.renderLocation=h.directSegment.startRenderSpace,r.renderLocation=h.directSegment.endRenderSpace;const{renderCoordsHelper:g}=this.view;A(p,h,g),l.available&&E(l,t,g),u.available&&k(u,t,g),e.forEachMeasureTypeManipulator((e,i)=>{e.available&&L(e,t,i,g)})}_updateManipulatorStyle(t){const e=F(t),i=q(t),a={lineSizePt:t,material:this._orientationManipulatorMaterial};for(const{offset:n,heading:s,rotation:o}of this._computationManipulators.values())n.radius=i/2,s.update(a),o.update(a);this._unfocusedOffsetManipulatorMaterial.setParameters({width:e}),this._focusedOffsetManipulatorMaterial.setParameters({width:i})}_applyPointUpdate(t,e){const{view:i}=this,a=J(t);"startPoint"in e&&(a.elevationAlignedStartPoint=e.startPoint),"endPoint"in e&&(a.elevationAlignedEndPoint=e.endPoint);const n=K(a,i.renderCoordsHelper);if(null==n)return;const s=this._computeConstraint({...a,geometry:n});P(t,e,{...a,constraint:s,unconstrainedGeometry:n,view:i}),t===this._stagedComputation&&this._updateStagedDimensionOffset(t)}_updateStagedDimensionOffset(t){if(null==t.geometry)return;t.geometry.directSegment.eval(.5,gt);const{state:e,renderCoordsHelper:i}=this.view,a=e.camera.computeScreenPixelSizeAt(gt);t.dimension.offset=Z*a*i.unitInMeters}_computeConstraint(t){return O(D(t,this._ensureSnappingManager().options),this.view)}_createOffsetManipulatorMaterial(t){return new st({width:1,renderOccluded:4,writeDepth:!1,hasPolygonOffset:!0,isDecoration:!0},t.state.isGlobal)}get test(){}};t([M({constructOnly:!0})],ht.prototype,"analysis",void 0),t([M({constructOnly:!0})],ht.prototype,"analysisViewData",void 0),t([M({constructOnly:!0})],ht.prototype,"manipulators",void 0),t([M({constructOnly:!0})],ht.prototype,"parentTool",void 0),t([M({constructOnly:!0,nonNullable:!0})],ht.prototype,"view",void 0),t([M({readOnly:!0})],ht.prototype,"updating",null),t([M()],ht.prototype,"firstGrabbedManipulator",null),t([M()],ht.prototype,"hasGrabbedManipulators",null),t([M()],ht.prototype,"snappingOptions",null),t([M()],ht.prototype,"_stagedDimension",void 0),t([M()],ht.prototype,"_snappingManager",null),t([M()],ht.prototype,"_activeComputation",null),t([M()],ht.prototype,"_stagedComputation",null),t([M()],ht.prototype,"_snappingManagerResult",void 0),ht=t([v("esri.views.3d.analysis.Dimension.LengthDimensionSubTool")],ht);const gt=y();export{ht as LengthDimensionSubTool};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{multiplyOpacity as t,getContrast as r}from"../../../../core/colorUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{watch as o,initial as
|
|
5
|
+
import e from"../../../../Color.js";import{multiplyOpacity as t,getContrast as r}from"../../../../core/colorUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{watch as o,initial as a}from"../../../../core/reactiveUtils.js";import{DidPointerMoveRecentlyFlag as s}from"./sliceToolUtils.js";import{Manipulator3D as l}from"../../interactive/Manipulator3D.js";import{rotateManipulatorDefaults as n}from"../../interactive/manipulatorUtils.js";import{RenderObject as m}from"../../interactive/RenderObject.js";import{Attribute as c}from"../../webgl-engine/lib/Attribute.js";import{Geometry as d}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as u}from"../../webgl-engine/lib/GeometryUtil.js";import{ImageMaterial as p}from"../../webgl-engine/materials/ImageMaterial.js";import{RibbonLineMaterial as f}from"../../webgl-engine/materials/RibbonLineMaterial.js";class h extends l{constructor(i,s){const l=t(i.effectiveTheme.accentColor,.5),m=r(i.effectiveTheme.accentColor),c=s(l,m),d=new p({draped:!1,managedTexture:c.managedTexture,writeDepth:!1,renderOccluded:16,isDecoration:!0}),u=n.calloutWidth,h=new f({width:u,renderOccluded:4,isDecoration:!0},i.state.isGlobal);super({view:i,...g({imageMaterial:d,calloutMaterial:h})}),this._material=d,this._textureHandle=c,this._themeHandle=o(()=>i.effectiveTheme.accentColor,i=>{const o=t(i,.5),a=r(i),l=this._textureHandle;this._textureHandle=s(o,a),d.setParameters({managedTexture:this._textureHandle.managedTexture}),l?.release(),h.setParameters({color:e.toUnitRGBA(i)})},a)}destroy(){this._textureHandle=i(this._textureHandle),this._themeHandle.remove(),this._material.dispose(),super.destroy()}}function g({imageMaterial:e,calloutMaterial:t}){const{focusMultiplier:r,calloutLength:i,discRadius:o}=n,a=o*r,l=(e,t)=>{const r=[0,1,2,2,3,0];return new d(t,[["position",new c([i-e,-e,0,i+e,-e,0,i+e,e,0,i-e,e,0],r,3,!0)],["uv0",new c([0,0,1,0,1,1,0,1],r,2,!0)]])},p=u(t,[[0,0,0],[i-o,0,0]]),f=u(t,[[0,0,0],[i-a,0,0]]),h=s;return{autoScaleRenderObjects:!1,collisionPriority:1,collisionType:{type:"disc",direction:[0,0,1],offset:[i,0,0]},focusMultiplier:r,radius:o,renderObjects:[new m(l(o,e),1|h),new m(p,1|h),new m(l(a,e),2|h),new m(f,2|h)],state:h}}export{h as RotateManipulator};
|