@arcgis/core 4.34.0-next.61 → 4.34.0-next.62
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/applications/Components/actionUtils.d.ts +3 -0
- package/applications/Components/actionUtils.js +5 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/226833d408eb1225e168.js +1 -0
- package/assets/esri/core/workers/chunks/33718ea851645d9078d1.js +1 -0
- package/assets/esri/core/workers/chunks/f542bdc994a5ea3aa9d1.js +1 -0
- package/chunks/BloomComposition.glsl.js +6 -5
- package/chunks/Fog.glsl.js +20 -13
- package/config.js +1 -1
- package/core/Collection.js +1 -1
- package/core/has.js +1 -1
- package/interfaces.d.ts +100 -8
- package/kernel.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/package.json +2 -2
- package/support/revision.js +1 -1
- package/symbols/IconSymbol3DLayer.js +1 -1
- package/symbols/TextSymbol3DLayer.js +1 -1
- package/symbols/support/IconSymbol3DLayerResource.js +1 -1
- package/symbols/support/OccludedVisibility.js +5 -0
- package/symbols/support/Symbol3DAnchorPosition2D.js +1 -1
- package/symbols/support/Symbol3DIconOutline.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileInputVisualization.js +1 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
- package/views/3d/environment/Fog.glsl.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/environment/FogTechniqueConfiguration.js +5 -0
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
- package/views/3d/webgl-engine/effects/bloom/BloomComposition.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/bloom/BloomCompositionTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileInputLineComputation.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileTool.js +5 -0
- package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
- package/widgets/CoordinateConversion/support/Format.js +1 -1
- package/widgets/Popup/actionUtils.js +1 -1
- package/assets/esri/core/workers/chunks/232c76f122b1f519e099.js +0 -1
- package/assets/esri/core/workers/chunks/5e1afea05b624b315d9f.js +0 -1
- package/assets/esri/core/workers/chunks/63f3e46bfa820436161c.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as m}from"../../../../core/urlUtils.js";import{fromValues as p,create as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y,ZEROS as g,fromValues as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as v}from"../../../../geometry/support/aaBoundingBox.js";import S from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as P}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as C}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as z}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as R}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as O}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as M}from"../../../../symbols/support/utils.js";import{transparentUnit as j}from"./constants.js";import{perObjectElevationAligner as I}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as F,needsElevationUpdates2D as T}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as E}from"./focusAreaStyle.js";import{Graphics3DDrapedGraphicLayer as D}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as L}from"./placementUtils.js";import{placePointOnGeometry as A,updateStageObjectGeometry as H,getLocalOriginForPoint as k,extendPointGraphicElevationContext as B,createStageObject as $}from"./pointUtils.js";import{initFastSymbolUpdatesState as N,updateFastSymbolUpdatesState as q,evaluateModelTransformScale as J,ConvertOptions as Z}from"../support/FastSymbolUpdates.js";import{createTexture as W,requiresHalfTexelOffset as K,defaultBoundingBox as Q,defaultSymbolSizeRatio as X,defaultTexSize as Y}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as ee}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as te}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as re}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as ie}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as se}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as oe}from"../../webgl-engine/materials/HUDMaterial.js";const ae=_(0,0,1),ne=16,le=1.5,ce=[Y*X,Y*X];class he extends V{static{this.PRIMITIVE_SIZE=ce}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,ye(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=M(this.symbolLayer),i=pe(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=G(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):ne);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let i=this._cimData;if(r&&i&&i.symbol||this.logger.error("Can't create texture, CIM data is undefined"),i.primitiveOverrides){i=s(i);const o=i.primitiveOverrides;r.evaluateOverrides(o,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(i.symbol,o)}const o=u(JSON.stringify(i));let a=this._cimSymbolTextures.get(o);if(a)return a;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(i.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?C(this._cimScaleFactorOrFunction,e):1;1!==c&&i.symbol&&z(i.symbol,c,!0);const h=w.getEnvelope(i,null,n.resourceManager);if(h?.width&&h.height){const e=h.x+h.width/2,t=h.y+h.height/2,r=n.rasterize({type:"cim",data:i},h.width,h.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),s=new O({x:-h.x/h.width-.5,y:(h.height+h.y)/h.height-.5});this._cimMaterialParametersInfo.anchorPosition=de("relative",s),a=new se(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else a=new se(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(o,a),this._context.stage.addTexture(a),a}_prepareMaterialParameters(){const e={anchorPosition:de(this.symbolLayer.anchor,this.symbolLayer.anchorPosition),rotation:this.symbolLayer.angle},t=this.symbol;ue(t)&&(e.verticalOffset=new te(t.verticalOffset)),this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),(0!==e.rotation||this._drivenProperties.rotation)&&(e.hasRotation=!0);const r=!has("disable-feature:non-occluded-hud");return e.occlusionTest=!r,e.occludedFragmentFade=r,e.horizonCullingEnabled=r&&this._context.spherical,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(me(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>W(t));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=K(t),e.distanceFieldBoundingBox=Q;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/X,this._createMaterial(e)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=_e(c,o),e.textureId=c.id}this._createMaterial(e)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference))}const s=this._context.sharedResources.cimSymbolRasterizer,o=[],a=t,n=a?.symbol;w.fetchResources(n,s.resourceManager,o,r),w.fetchFonts(n,s.resourceManager,o);const c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&o.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),o.length>0&&(await Promise.all(o),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await P(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new S(c);this._cimScaleFactorOrFunction=(e,t,o)=>{const a=i(r,e,{$view:o},"esriGeometryPoint",s,t);return null!==a?a:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return fe(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=me(this._getPrimitive())?le:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(me(this._getPrimitive()))return j;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const t=this._materialColor;if(null==t){return null==this._getPrimitive()?y:g}return e.toUnitRGBA(t)}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(c(t)):ne)/e}_createMaterial(e){const t=this._context.spherical;if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new oe(e,t),this._cimSymbolMaterials.set(e.textureId??0,r)),r}this._fastUpdates=N(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new oe(e,t),e.isFocused=!1;const r=this.view.map?.focusAreas.style;return e.color=E(e.color,r),e.outlineColor=E(e.outlineColor,r),this._materials[1]=new oe(e,t),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?c(r)/t:"number"==typeof s&&isFinite(s)?c(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading??0:0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=A(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i,s=[0,0];const o=this.view.focusAreasView?.containsGeometry(r)??!0;if(this._cimData){if(!this._cimData.symbol)return null;const r=this._generateTextureCIM(t,e),a={textureId:r.id,isFocused:o,...this._cimMaterialParametersInfo};i=this._createMaterial(a);const n=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;s=[r.parameters.width/n,r.parameters.height/n]}else s=this._size,i=o?this._materials[0]:this._materials[1];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const a=e.renderingInfo,n=this._getDrivenUInt8Color(a,this._materialColor,null==this._getPrimitive()),l=this._getDrivenRotation(a);let c=1;if(!this._fastUpdates?.visualVariables.size){const e=s[0]>s[1]?s[0]:s[1];c=this._getScaleFactor(a,e)}c*=this._symbolTextureRatio;const h=p(s[0]*c,s[1]*c),u=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===u.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,r,i,n,l,h):this._createAs3DShape(t,r,i,n,l,h,u,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}updateGeometry(e,t){if(this.draped||!this._validateGeometry(t))return!1;const{elevationContext:r,stageObject:i}=e;if(r.mode!==this.getGeometryElevationMode(t))return!1;const s=A(t);if(!s)return!1;const o=H(i,this._context,s,r);if(null==o)return!1;const a=k(this._context,s);return i.geometries[0].localOrigin===a&&(e.alignedSampledElevation=o,B(e,s,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=F(he.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=T(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!q(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}updateFocus(e,t){t.forEach(t=>{const r=A(t.graphic.geometry);if(null==r)return void this.logger.warn(`unsupported geometry type for text symbol: ${t.graphic.geometry.type}`);const i=this.view.focusAreasView?.containsGeometry(r)??!0;t.layers.forEach(r=>{if(r?.graphics3DSymbolLayer===this&&r.stageObject){r.stageObject.geometries.some(e=>e.material.parameters.isFocused!==i)&&e(t)}})})}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=pe(h))return;const m=this._getIconSize(),p=m*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push(()=>{this._patchTask=o(this._patchTask),this._patchTask=r(e=>this._context.schedule(async(e,r)=>{const s=await t(u.fromUrl(h,p,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=_e(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},e))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return ge}_createAs3DShape(e,t,r,i,s,o,a,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=re(r,{normal:ae,color:i,rotation:s,size:o,centerOffsetAndDistance:xe,featureAttribute:l,olidColor:h}),m=$(this._context,t,u,a,n);if(null==m)return null;const p=new U(this,m.object,null,I,a);return p.alignedSampledElevation=m.sampledElevation,p.needsElevationUpdates=T(a.mode)||"absolute-height"===a.mode,p.getScreenSize=this._createScreenSizeGetter(o,l),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),B(p,t,this._context.elevationProvider),p}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=f();b(t,a,this._context.overlaySR),a[2]=ee;const n=this._context.clippingExtent;if(null!=n&&!v(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=e.uid,h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:h}),m=re(r,{normal:ae,position:a,color:i,rotation:s,size:o,featureAttribute:l,olidColor:u}),p=new ie(m,{layerViewUid:h,graphicUid:c}),d=new D(this,[p],null,this._context.drapeSourceRenderer);return d.getScreenSize=this._createScreenSizeGetter(o,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),d}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=d())=>{const[o,a]=J(be,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=d())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),r=h(1),i=e*r,s=_(i,i,i),o=this._getFallbackSize();return new Z({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(o,o,o)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function ue(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function me(e){return null!=e&&("cross"===e||"x"===e)}function pe(e){const t=m(e);return"application/json"===t?.mediaType?t.data:void 0}function de(e,t){return"relative"===e?p((t.x||0)+.5,.5-(t.y||0)):e in L?L[e]:L.center}function _e({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function fe(e){return e.resource?.href?null:e.resource?.primitive??R}function ye(e){return 1===(e.material?.color?.a??0)&&null!=fe(e)}const ge={mode:"relative-to-ground",offset:0},xe=x(0,0,0,1),be=f();export{he as Graphics3DIconSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as m}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y,ZEROS as g,fromValues as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as v}from"../../../../geometry/support/aaBoundingBox.js";import S from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as P}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as C}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as z}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as R}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as M}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as I}from"../../../../symbols/support/utils.js";import{transparentUnit as O}from"./constants.js";import{perObjectElevationAligner as j}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as T,needsElevationUpdates2D as F}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as U}from"./focusAreaStyle.js";import{Graphics3DDrapedGraphicLayer as E}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as L}from"./placementUtils.js";import{placePointOnGeometry as A,updateStageObjectGeometry as H,getLocalOriginForPoint as k,extendPointGraphicElevationContext as B,createStageObject as $}from"./pointUtils.js";import{initFastSymbolUpdatesState as N,updateFastSymbolUpdatesState as q,evaluateModelTransformScale as J,ConvertOptions as Z}from"../support/FastSymbolUpdates.js";import{createTexture as W,requiresHalfTexelOffset as K,defaultBoundingBox as Q,defaultSymbolSizeRatio as X,defaultTexSize as Y}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as ee}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as te}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as re}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as ie}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as se}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as oe}from"../../webgl-engine/materials/HUDMaterial.js";const ae=_(0,0,1),ne=16,le=1.5,ce=[Y*X,Y*X];class he extends V{static{this.PRIMITIVE_SIZE=ce}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,ye(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=I(this.symbolLayer),i=de(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=G(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):ne);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let i=this._cimData;if(r&&i&&i.symbol||this.logger.error("Can't create texture, CIM data is undefined"),i.primitiveOverrides){i=s(i);const o=i.primitiveOverrides;r.evaluateOverrides(o,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(i.symbol,o)}const o=u(JSON.stringify(i));let a=this._cimSymbolTextures.get(o);if(a)return a;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(i.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?C(this._cimScaleFactorOrFunction,e):1;1!==c&&i.symbol&&z(i.symbol,c,!0);const h=w.getEnvelope(i,null,n.resourceManager);if(h?.width&&h.height){const e=h.x+h.width/2,t=h.y+h.height/2,r=n.rasterize({type:"cim",data:i},h.width,h.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),s=new M({x:-h.x/h.width-.5,y:(h.height+h.y)/h.height-.5});this._cimMaterialParametersInfo.anchorPosition=pe("relative",s),a=new se(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else a=new se(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(o,a),this._context.stage.addTexture(a),a}_prepareMaterialParameters(){const e={anchorPosition:pe(this.symbolLayer.anchor,this.symbolLayer.anchorPosition),rotation:this.symbolLayer.angle},t=this.symbol;ue(t)&&(e.verticalOffset=new te(t.verticalOffset)),this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),(0!==e.rotation||this._drivenProperties.rotation)&&(e.hasRotation=!0);const r=!has("disable-feature:non-occluded-hud");return e.occlusionTest=!r,e.occludedFragmentFade=r,e.horizonCullingEnabled=r&&this._context.spherical,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(me(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>W(t));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=K(t),e.distanceFieldBoundingBox=Q;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/X,this._createMaterial(e)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=_e(c,o),e.textureId=c.id}this._createMaterial(e)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference))}const s=this._context.sharedResources.cimSymbolRasterizer,o=[],a=t,n=a?.symbol;w.fetchResources(n,s.resourceManager,o,r),w.fetchFonts(n,s.resourceManager,o);const c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&o.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),o.length>0&&(await Promise.all(o),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await P(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new S(c);this._cimScaleFactorOrFunction=(e,t,o)=>{const a=i(r,e,{$view:o},"esriGeometryPoint",s,t);return null!==a?a:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return fe(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=me(this._getPrimitive())?le:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(me(this._getPrimitive()))return O;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const t=this._materialColor;if(null==t){return null==this._getPrimitive()?y:g}return e.toUnitRGBA(t)}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(c(t)):ne)/e}_createMaterial(e){const t=this._context.spherical;if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new oe(e,t),this._cimSymbolMaterials.set(e.textureId??0,r)),r}this._fastUpdates=N(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new oe(e,t),e.isFocused=!1;const r=this.view.map?.focusAreas.style;return e.color=U(e.color,r),e.outlineColor=U(e.outlineColor,r),this._materials[1]=new oe(e,t),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?c(r)/t:"number"==typeof s&&isFinite(s)?c(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading??0:0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=A(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i,s=[0,0];const o=this.view.focusAreasView?.containsGeometry(r)??!0;if(this._cimData){if(!this._cimData.symbol)return null;const r=this._generateTextureCIM(t,e),a={textureId:r.id,isFocused:o,...this._cimMaterialParametersInfo};i=this._createMaterial(a);const n=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;s=[r.parameters.width/n,r.parameters.height/n]}else s=this._size,i=o?this._materials[0]:this._materials[1];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const a=e.renderingInfo,n=this._getDrivenUInt8Color(a,this._materialColor,null==this._getPrimitive()),l=this._getDrivenRotation(a);let c=1;if(!this._fastUpdates?.visualVariables.size){const e=s[0]>s[1]?s[0]:s[1];c=this._getScaleFactor(a,e)}c*=this._symbolTextureRatio;const h=d(s[0]*c,s[1]*c),u=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===u.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,r,i,n,l,h):this._createAs3DShape(t,r,i,n,l,h,u,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}updateGeometry(e,t){if(this.draped||!this._validateGeometry(t))return!1;const{elevationContext:r,stageObject:i}=e;if(r.mode!==this.getGeometryElevationMode(t))return!1;const s=A(t);if(!s)return!1;const o=H(i,this._context,s,r);if(null==o)return!1;const a=k(this._context,s);return i.geometries[0].localOrigin===a&&(e.alignedSampledElevation=o,B(e,s,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(he.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=F(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!q(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=de(h))return;const m=this._getIconSize(),d=m*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push(()=>{this._patchTask=o(this._patchTask),this._patchTask=r(e=>this._context.schedule(async(e,r)=>{const s=await t(u.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=_e(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},e))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return ge}_createAs3DShape(e,t,r,i,s,o,a,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=re(r,{normal:ae,color:i,rotation:s,size:o,centerOffsetAndDistance:xe,featureAttribute:l,olidColor:h}),m=$(this._context,t,u,a,n);if(null==m)return null;const d=new D(this,m.object,null,j,a);return d.alignedSampledElevation=m.sampledElevation,d.needsElevationUpdates=F(a.mode)||"absolute-height"===a.mode,d.getScreenSize=this._createScreenSizeGetter(o,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),B(d,t,this._context.elevationProvider),d}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=f();b(t,a,this._context.overlaySR),a[2]=ee;const n=this._context.clippingExtent;if(null!=n&&!v(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=e.uid,h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:h}),m=re(r,{normal:ae,position:a,color:i,rotation:s,size:o,featureAttribute:l,olidColor:u}),d=new ie(m,{layerViewUid:h,graphicUid:c}),p=new E(this,[d],null,this._context.drapeSourceRenderer);return p.getScreenSize=this._createScreenSizeGetter(o,l),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),p}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=J(be,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),r=h(1),i=e*r,s=_(i,i,i),o=this._getFallbackSize();return new Z({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(o,o,o)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function ue(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function me(e){return null!=e&&("cross"===e||"x"===e)}function de(e){const t=m(e);return"application/json"===t?.mediaType?t.data:void 0}function pe(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in L?L[e]:L.center}function _e({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function fe(e){return e.resource?.href?null:e.resource?.primitive??R}function ye(e){return 1===(e.material?.color?.a??0)&&null!=fe(e)}const ge={mode:"relative-to-ground",offset:0},xe=x(0,0,0,1),be=f();export{he as Graphics3DIconSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as
|
|
5
|
+
import{isSome as e}from"../../../../core/arrayUtils.js";import{forEach as t}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{onAbortOrThrow as s,throwIfAborted as r}from"../../../../core/promiseUtils.js";import{totalSymbolComplexities as o}from"./defaultSymbolComplexity.js";import{Graphics3DGraphic as a}from"./Graphics3DGraphic.js";import{Graphics3DObject3DGraphicLayer as i}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayerCreationContext as n}from"./Graphics3DSymbolCreationContext.js";import{Loadable as l}from"./Loadable.js";import{getSymbolMemorySize as y}from"./symbolMemory.js";class h extends l{set symbol(e){this._symbol=e,e.symbolLayers.forEach((t,s)=>{const r=this.symbolLayers[s];null!=r&&(r.symbol=e,r.symbolLayer=t)})}get symbol(){return this._symbol}constructor(e,t,s){super(t.schedule),this._symbol=e,this._context=t,this._backgroundLayers=s,this._destroyed=!1,this.symbolLayers=new Array,this.referenced=0,this._extentPadding=0}async doLoad(e){let o=this._symbol.symbolLayers;this._extentPadding=0,this._backgroundLayers&&(o=this._backgroundLayers.concat(o));const a=o.length;for(;this.symbolLayers.length<o.length;)this.symbolLayers.push(null);this.symbolLayers.length=o.length;const i=[];if(!m){const{make:e}=await import("./Graphics3DSymbolLayerFactory.js");m=e}for(let t=0;t<a;t++){const r=o.at(t);if(!1===r.enabled)continue;c.renderPriority=1-(1+t)/a,c.renderPriorityStep=1/a,c.ignoreDrivers=r.ignoreDrivers;const n=m(this.symbol,r,this._context,c),l=s(e,()=>{this.symbolLayers[t]=null,n.destroy()});l&&i.push(l),this.symbolLayers[t]=n}if(await t(this.symbolLayers,async(e,t)=>{if(null!=e)try{await e.load(),this._extentPadding+=Math.max(this._extentPadding,e.extentPadding)}catch{this.symbolLayers[t]=null}}),i.forEach(e=>e.remove()),r(e),this.symbolLayers.length&&!this.symbolLayers.some(e=>!!e))throw new Error}getSymbolLayerSize(e){const t=this.symbolLayers[e];return null!=t?t.getCachedSize():null}get extentPadding(){return this._extentPadding}get symbologySnappingSupported(){return this.symbolLayers.some(e=>e?.queryForSnapping)}get needsUpdateFocus(){return this.symbolLayers.some(e=>!0===e?.needsUpdateFocus)}createGraphics3DGraphic(e,t){const{graphic:s}=e,r=this.symbolLayers.map(t=>t?.createGraphics3DGraphic(e)??null),o=this._context.arcade||this._context.featureExpressionInfoContext?.arcade?.modules||null;return new a(s,t||this,r,e.layer,o)}get complexity(){return o(this.symbolLayers.map(e=>e?.complexity))}globalPropertyChanged(e,t){const s=this.symbolLayers.length;for(let r=0;r<s;r++){const s=this.symbolLayers[r],o=e=>{const t=e.layers[r];return t instanceof i?t:null};if(null!=s&&!s.globalPropertyChanged(e,t,o))return!1}return!0}applyRendererDiff(e,t){return 1!==this.loadStatus?0:this.symbolLayers.reduce((s,r)=>0!==s&&null!=r?Math.min(s,r.applyRendererDiff(e,t)):s,2)}prepareSymbolPatch(e){if(2===this.loadStatus)return;if("partial"!==e.diff.type)return;const t=e.diff.diff;if(!t.symbolLayers||"partial"!==t.symbolLayers.type)return;const s=t.symbolLayers.diff;this.symbolLayers.forEach((t,r)=>{if(null==t)return;const o=s[r];if(o){const s={diff:o,graphics3DGraphicPatches:[],symbolLayerStatePatches:[]};t.prepareSymbolLayerPatch(s),e.symbolStatePatches.push(...s.symbolLayerStatePatches),s.graphics3DGraphicPatches.length&&e.graphics3DGraphicPatches.push((e,t)=>{const o=e.layers[r];null!=o&&s.graphics3DGraphicPatches.forEach(e=>e(o,t))})}})}updateGeometry(e,t){return this._updateGeometryOrTransform(e,(e,s)=>e.updateGeometry(s,t))}updateTransform(e,t,s,r){return this._updateGeometryOrTransform(e,(e,o)=>e.updateTransform(o,t,s,r))}_updateGeometryOrTransform(e,t){for(let s=0;s<this.symbolLayers.length;s++){const r=this.symbolLayers[s];if(null==r)continue;const o=e.layers[s];if(!o||!t(r,o))return!1}return!0}onRemoveGraphic(e){for(let t=0;t<this.symbolLayers.length;t++){const s=this.symbolLayers[t];if(null==s)continue;const r=e.layers[t];null!=r&&s.onRemoveGraphic(r)}}getFastUpdateStatus(){let e=!1,t=!1;for(const s of this.symbolLayers)if(null!=s){if(0===s.loadStatus)return 3;s.isFastUpdatesEnabled()?t=!0:e=!0}return t?e?2:1:e?0:4}async queryForSnapping(t,s,o,a){const i=this.symbolLayers.filter(e).filter(e=>null!=e.queryForSnapping).map(e=>e.queryForSnapping(t,s,o,a)),n=await Promise.all(i);return r(a),n.flat()}destroy(){if(!this.destroyed){super.destroy();for(const e of this.symbolLayers)null!=e&&e.destroy();this.symbolLayers.length=0,this._destroyed=!0}}get destroyed(){return this._destroyed}get cachedMemory(){return y(this)}}let m=null;const c=new n;export{h as Graphics3DSymbol};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Logger.js";import{ONES as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d as i,c as o}from"../../../../chunks/vec42.js";import{fromValues as s,ONES as n,ZEROS as a,fromArray as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as p}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as c}from"./defaultSymbolComplexity.js";import{ElevationContext as d}from"./ElevationContext.js";import{zeroContext as u}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as h}from"./graphicUtils.js";import{Loadable as y}from"./Loadable.js";import{getAttributeValue as f}from"../support/FastSymbolUpdates.js";import{encodeNaNUInt8 as m}from"../support/symbolColorUtils.js";const g=()=>t.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class v extends y{constructor(e,t,r,i,o=!0){super(r.schedule),this.symbol=e,this.symbolLayer=t,this._context=r,this._drivenOpacityFallbackAlwaysOpaque=o,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1,rotation:!1},this._materials=[],this.logger=g(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=i.renderPriority,this._renderPriorityStep=i.renderPriorityStep,this._elevationContext=new d,this.updateComplexity(),this.ignoreDrivers=i.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=_(this._context.renderer,o)),this._updateElevationContext()}destroy(){this.complexity=null,this._materials.length=0,super.destroy()}get view(){return this._context.stage.view}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get estimatedMemory(){const{complexity:e}=this;if(null==e)return 0;return(this.draped?e.memory.draped:e.memory).bytesPerFeature}get usedMemory(){return this.estimatedMemory}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,r=_(e,this._drivenOpacityFallbackAlwaysOpaque);return r.color!==t.color||r.opacity!==t.opacity||r.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||r.size!==t.size||r.rotation!==t.rotation}get needsDrivenTransparentPass(){return this._hasDrivenColorOrOpacity&&!this._drivenProperties.opacityAlwaysOpaque}get _hasDrivenColorOrOpacity(){return this._drivenProperties.color||this._drivenProperties.opacity}_logGeometryCreationWarnings(e,t,r,i){const o=e.projectionSuccess,s="polygons"in e?e.polygons:null,n=`${i} geometry failed to be created`;o?!this._logGeometryValidationWarnings(t,r,i)&&s&&0===s.length&&"rings"===r&&t.length>0&&t[0].length>2&&g().warnOncePerTick(`${n} (filled rings should use clockwise winding - try reversing the order of vertices)`):g().warnOncePerTick(`${n} (failed to project geometry to view spatial reference)`)}
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Logger.js";import{ONES as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d as i,c as o}from"../../../../chunks/vec42.js";import{fromValues as s,ONES as n,ZEROS as a,fromArray as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as p}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as c}from"./defaultSymbolComplexity.js";import{ElevationContext as d}from"./ElevationContext.js";import{zeroContext as u}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as h}from"./graphicUtils.js";import{Loadable as y}from"./Loadable.js";import{getAttributeValue as f}from"../support/FastSymbolUpdates.js";import{encodeNaNUInt8 as m}from"../support/symbolColorUtils.js";const g=()=>t.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class v extends y{constructor(e,t,r,i,o=!0){super(r.schedule),this.symbol=e,this.symbolLayer=t,this._context=r,this._drivenOpacityFallbackAlwaysOpaque=o,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1,rotation:!1},this._materials=[],this.logger=g(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=i.renderPriority,this._renderPriorityStep=i.renderPriorityStep,this._elevationContext=new d,this.updateComplexity(),this.ignoreDrivers=i.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=_(this._context.renderer,o)),this._updateElevationContext()}destroy(){this.complexity=null,this._materials.length=0,super.destroy()}get view(){return this._context.stage.view}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get estimatedMemory(){const{complexity:e}=this;if(null==e)return 0;return(this.draped?e.memory.draped:e.memory).bytesPerFeature}get usedMemory(){return this.estimatedMemory}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,r=_(e,this._drivenOpacityFallbackAlwaysOpaque);return r.color!==t.color||r.opacity!==t.opacity||r.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||r.size!==t.size||r.rotation!==t.rotation}get needsDrivenTransparentPass(){return this._hasDrivenColorOrOpacity&&!this._drivenProperties.opacityAlwaysOpaque}get _hasDrivenColorOrOpacity(){return this._drivenProperties.color||this._drivenProperties.opacity}_logGeometryCreationWarnings(e,t,r,i){const o=e.projectionSuccess,s="polygons"in e?e.polygons:null,n=`${i} geometry failed to be created`;o?!this._logGeometryValidationWarnings(t,r,i)&&s&&0===s.length&&"rings"===r&&t.length>0&&t[0].length>2&&g().warnOncePerTick(`${n} (filled rings should use clockwise winding - try reversing the order of vertices)`):g().warnOncePerTick(`${n} (failed to project geometry to view spatial reference)`)}get needsUpdateFocus(){return!1}_logGeometryValidationWarnings(e,t,r){const i=`${r} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(g().warnOncePerTick(`${i} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(g().warnOncePerTick(`${i} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,r=null){if(null!=t&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+r+` symbol: ${e.type}`),!1;switch(e.type){case"point":{const t=e;if(!isFinite(t.x)||!isFinite(t.y))return g().warn("point coordinate is not a valid number, graphic skipped"),!1;break}case"polygon":p(e)}return!0}_defaultElevationInfoNoZ(){return x}_defaultElevationInfoZ(){return C}_updateElevationContext(){null!=this._elevationInfoOverride?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.updateFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.updateFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}setGraphicElevationContext(e,t=new d){const r=e.geometry,i=this.getDefaultElevationInfo(r);t.unit=null!=this._elevationContext.unit?this._elevationContext.unit:i.unit,t.mode=this.getGeometryElevationMode(r,i),t.offsetMeters=this._elevationContext.meterUnitOffset??i.offset??0;const o=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===t.mode;o&&(t.mode="relative-to-ground",t.offsetMeters=0);const s=o?u:this._elevationContext.featureExpressionInfoContext;return t.updateFeatureExpressionInfoContext(s,e,this._context.layer),t}prepareSymbolLayerPatch(e){}updateGeometry(e,t){return!1}updateTransform(e,t,r,i){return!1}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=b){const r=this.draped?1:this._getLayerOpacity();return this._drivenProperties.color?r:e?r*(this._drivenProperties.opacity?1:e.a):t.hasIntrinsicColor?r:0}_getCombinedOpacityAndColor(t,i=b){const o=this._getCombinedOpacity(t,i);if(this._drivenProperties.color)return h(null,o);const s=null!=t?e.toUnitRGB(t):r;return h(s,o)}_getDrivenUInt8Color({color:t,opacity:r},i,o){const{color:s,opacity:l}=this._drivenProperties,p=e.toUnitRGBA(i)??(o?n:a),c=s?t??p:null,d=t||i||o,u=s?null:p[3];return h(c,l&&d?r??u:null,255)}_getDrivenUInt8ColorWithNaNSupport({color:t,opacity:r},n,a){const p=n?l(e.toUnitRGBA(n)):s(NaN,NaN,NaN,a?NaN:0);return this._drivenProperties.color&&null!=t&&i(p,t),this._drivenProperties.opacity&&null!=r&&(p[3]=r),o(p,p,255),m(p,p)}isFastUpdatesEnabled(){return null!=this._fastUpdates}updateComplexity(){this.complexity=this.computeComplexity()}computeComplexity(){return c(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,r){switch(e){case"opacity":return this.layerOpacityChanged(t,r),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return 2!==this.layerElevationInfoChanged(t,r,e)}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,r);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged;case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged;default:return!1}}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,r){let i=1;return e?.forEach(e=>{const o=t(e);if(null!=o){const t=e.graphic;this.setGraphicElevationContext(t,o.elevationContext),o.needsElevationUpdates=r(o.elevationContext.mode)}else i=2}),i}applyRendererDiff(e,t){return 0}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;const t=this._fastUpdates.visualVariables,r=t.size?f(t.size.field,e):0,i=t.color?f(t.color.field,e):0,o=t.opacity?f(t.opacity.field,e):0;return s(r,i,o,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&g().warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables.size?.field??null,color:this._fastUpdates?.visualVariables.color?.field??null,opacity:this._fastUpdates?.visualVariables.opacity?.field??null,rotation:this._fastUpdates?.visualVariables.rotation?.field??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function _(e,t){const r={color:!1,opacity:!1,opacityAlwaysOpaque:t,size:!1,rotation:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach(e=>{switch(e.type){case"color":if(r.color=!0,e.stops)for(let t=0;t<e.stops.length;t++){const i=e.stops[t].color;i&&i.a<1&&(r.opacityAlwaysOpaque=!1)}break;case"opacity":r.opacity=!0,r.opacityAlwaysOpaque=!1;break;case"size":r.size=!0;break;case"rotation":r.rotation=!0}}),r}const x={mode:"on-the-ground",offset:0,unit:"meters"},C={mode:"absolute-height",offset:0,unit:"meters"},b={hasIntrinsicColor:!1},O=s(NaN,NaN,NaN,NaN);export{v as Graphics3DSymbolLayer,_ as getDrivenProperties,O as nanFallbackColor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{isPromiseLike as s}from"../../../../core/promiseUtils.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{fromValues as
|
|
5
|
+
import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{isPromiseLike as s}from"../../../../core/promiseUtils.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{fromValues as n,ZEROS as o,create as i}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{freeze as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{hasCalloutSupport as c,textSymbolLayerSupportsVerticalOffset as m}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as f}from"./ElevationAligners.js";import{needsElevationUpdates2D as h}from"./elevationAlignmentUtils.js";import{ElevationContext as u}from"./ElevationContext.js";import{focusAreaHUDColor as p}from"./focusAreaStyle.js";import{Graphics3DObject3DGraphicLayer as d}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as g}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as y}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as v}from"./graphicUtils.js";import{LabelPlacement as x,LabelParameters as b}from"./LabelParameters.js";import{verticalScreenOffsetFromAlignment as O,verticalPlacementFromAlignment as w,textRenderAlignmentFromHorizontalPlacement as P,horizontalPlacementToAnchorX as j,anchorFromPlacements as _,namedAnchorToHUDMaterialAnchorPos as E}from"./placementUtils.js";import{placePointOnGeometry as S,updateStageObjectGeometry as L,getLocalOriginForPoint as C,extendPointGraphicElevationContext as G,createStageObject as z}from"./pointUtils.js";import{getFontMetrics as A}from"../../webgl-engine/lib/FontMetrics.js";import{createPointGeometry as U}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as F}from"../../webgl-engine/lib/TextRenderParameters.js";import D from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as R}from"../../webgl-engine/materials/HUDMaterial.js";const T=a(0,0,1);class H extends y{constructor(e,t,s,r){super(e,t,s,r),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=v(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){const e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await F.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const t=e.graphic,s=S(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;const r=this.view.focusAreasView?.containsGeometry(s)??!0,n=this.symbolLayer.text;if(null==n||""===n)return null;const o=c(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(null!=o&&!m(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;const{verticalAlignment:i}=this.symbolLayer,a=new x(o);O(i,a.screenOffset);const l=new b(a,this.symbolLayer.horizontalAlignment,w(i));return l.isFocused=r??l.isFocused,this._createAs3DShape(t,s,n,l)}get needsUpdateFocus(){return!0}createLabel(e,t,s,r,n){const o=e.graphic,i=S(o.geometry);if(null==i)return this.logger.warn(`unsupported geometry type for label: ${o.geometry.type}`),null;const a=this.view.focusAreasView?.containsGeometry(i)??!0,l=t.text;return!l||/^\s+$/.test(l)?null:(t.isFocused=a??t.isFocused,this._createAs3DShape(o,i,l,t,s,r,n))}setGraphicElevationContext(e,t=new u,s=0){return super.setGraphicElevationContext(e,t),t.addOffsetRenderUnits(s),t}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerElevationInfoChanged(e,t){return V(e,t,(e,t)=>{this.updateGraphicElevationContext(t,e)}),1}slicePlaneEnabledChanged(e,t){return V(e,t,e=>{for(const t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return!1}updateGraphicElevationContext(e,t){const{elevationContext:s,metadata:r}=t;this.setGraphicElevationContext(e,s,r?.elevationOffset??0),t.needsElevationUpdates=h(s.mode)||"absolute-height"===s.mode}updateGeometry(e,t){if(this.draped||!this._validateGeometry(t))return!1;const{elevationContext:s,stageObject:r}=e;if(s.mode!==this.getGeometryElevationMode(t))return!1;const n=S(t);if(!n)return!1;const o=L(r,this._context,n,s);if(null==o)return!1;const i=C(this._context,n);return r.geometries[0].localOrigin===i&&(e.alignedSampledElevation=o,G(e,n,this._context.elevationProvider),!0)}_defaultElevationInfoNoZ(){return I}_createAs3DShape(e,a,c,m,y,v=null,x=()=>m.placement.elevationOffset){const b=this.setGraphicElevationContext(e,new u,m.placement.elevationOffset),O=e.uid;let w=null,j=null;if(null==v){const e=P(m.horizontalPlacement);w=new D(c,e,this._textRenderParameters);let r=null;if(null!=this._context.sharedResources.textures){j=this._context.sharedResources.textures.fromData(w.key,()=>w.create()),j.texture.events.on("unloaded",()=>r=t(r));const e=this._context.stage.renderView.textures.acquire(j.texture.id);if(null==e||s(e))return j.release(),null;r=e}}const _=!has("disable-feature:non-occluded-hud"),E=W(w,m),S={occlusionTest:!_,occludedFragmentFade:_,horizonCullingEnabled:_&&this._context.spherical,screenOffset:m.placement.screenOffset,anchorPosition:E,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:m.placement.centerOffsetUnits,depthEnabled:!1,drawAsLabel:!0,isLabel:!0,isFocused:m.isFocused};if("polyline"===e.geometry?.type&&(S.shaderPolygonOffset=1e-4),v?S.textureId=v.id:j&&(S.textureId=j.texture.id),null!=m.placement.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:s}=m.placement.verticalOffset;S.verticalOffset={screenLength:r(e),minWorldLength:t||0,maxWorldLength:null!=s?s:1/0}}const L=this._context.graphicsCoreOwner.view.focusAreasView?.polygons.length,C={screenOffset:S.screenOffset,anchorPosition:E,centerOffsetUnits:S.centerOffsetUnits,verticalOffset:S.verticalOffset,shaderPolygonOffset:S.shaderPolygonOffset,occlusionTest:S.occlusionTest,isFocused:m.isFocused,focusStyle:this.view.map?.focusAreas.style??"none"};if(this._context.screenSizePerspectiveEnabled){const{screenSizePerspectiveSettings:e,screenSizePerspectiveSettingsLabels:t}=this._context.sharedResources,s=A(this._textRenderParameters);S.screenSizePerspective=t.overrideFontHeight(s.maxHeight),S.screenSizePerspectiveAlignment=e,C.fontHeight=s.maxHeight}S.hasSlicePlane=this._context.slicePlaneEnabled;const F=this._context.spherical,H=y?JSON.stringify(C):"";let V=y?.get(H);if(null==V){if(!m.isFocused&&L){const e=this.view.map?.focusAreas.style;S.color=p(S.color,e),S.outlineColor=p(S.outlineColor,e)}V=new R(S,F),y?.set(H,V)}const I=m.placement.translation,M=w?n(w.displayWidth,w.displayHeight):o,$=m.placement.centerOffset,k=T,N=v?l(0,0,0,0):null,q=U(V,{normal:k,position:I,size:M,centerOffsetAndDistance:$,uvi:N}),B=z(this._context,a,q,b,O);if(null==B)return null;const J=(t,s,r,n,o,i)=>{const a=x()||m.placement.elevationOffset,l=this.setGraphicElevationContext(e,s,a);return f(t,l,r,n,o,i)},Y=new d(this,B.object,j,J,b);Y.alignedSampledElevation=B.sampledElevation,Y.needsElevationUpdates=h(b.mode)||"absolute-height"===b.mode,Y.getScreenSize=(e=i())=>(e[0]=w?w.displayWidth:m.displaySize[0],e[1]=w?w.displayHeight:m.displaySize[1],e);const Z=new g(m.placement.elevationOffset,c);return Y.metadata=Z,G(Y,a,this._context.elevationProvider),Y}}function V(e,t,s){e?.forEach(e=>{const r=t(e);null!=r&&s(r,e.graphic)})}function W(e,t){if("baseline"===t.verticalPlacement){const s=j[t.horizontalPlacement],r=null!=e?e.baselineAnchorY:0;return n(s,r)}const s=_(t.horizontalPlacement,t.verticalPlacement);return E[s]}const I={mode:"relative-to-ground",offset:0};export{H as Graphics3DTextSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{emptySymbolComplexity as t}from"./defaultSymbolComplexity.js";import{Loadable as r}from"./Loadable.js";import{getSymbolMemorySize as s}from"./symbolMemory.js";class
|
|
5
|
+
import{emptySymbolComplexity as t}from"./defaultSymbolComplexity.js";import{Loadable as r}from"./Loadable.js";import{getSymbolMemorySize as s}from"./symbolMemory.js";class e extends r{constructor(t,r,s){super(r),this.symbol=t,this._convert=s,this.symbologySnappingSupported=!1,this.graphics3DSymbol=null,this.referenced=0}getSymbolLayerSize(t){return null!=this.graphics3DSymbol?this.graphics3DSymbol.getSymbolLayerSize(t):null}get symbolLayers(){return null!=this.graphics3DSymbol?this.graphics3DSymbol.symbolLayers:[]}get extentPadding(){return null!=this.graphics3DSymbol?this.graphics3DSymbol.extentPadding:0}async doLoad(t){const r=await this.symbol.fetchSymbol({signal:t});r.id=this.symbol.id,this.graphics3DSymbol=this._convert(r),null!=this.graphics3DSymbol&&await this.graphics3DSymbol.load()}createGraphics3DGraphic(t){return null!=this.graphics3DSymbol?this.graphics3DSymbol.createGraphics3DGraphic(t,this):null}get complexity(){return null!=this.graphics3DSymbol?this.graphics3DSymbol.complexity:t}globalPropertyChanged(t,r){return null!=this.graphics3DSymbol&&this.graphics3DSymbol.globalPropertyChanged(t,r)}applyRendererDiff(t,r){return null!=this.graphics3DSymbol?this.graphics3DSymbol.applyRendererDiff(t,r):0}prepareSymbolPatch(t){null!=this.graphics3DSymbol&&this.graphics3DSymbol.prepareSymbolPatch(t)}updateGeometry(t,r){return null!=this.graphics3DSymbol&&this.graphics3DSymbol.updateGeometry(t,r)}updateTransform(t,r,s,e){return this.graphics3DSymbol?.updateTransform(t,r,s,e)??!1}onRemoveGraphic(){}get needsUpdateFocus(){return!1}getFastUpdateStatus(){return this.graphics3DSymbol?.getFastUpdateStatus()??3}destroy(){null!=this.graphics3DSymbol&&this.graphics3DSymbol.destroy(),this.graphics3DSymbol=void 0,super.destroy()}get destroyed(){return void 0===this.graphics3DSymbol}get cachedMemory(){return s(this)}}export{e as Graphics3DWebStyleSymbol};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{forEach as s,result as i}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import l from"../../../../core/Logger.js";import{disposeMaybe as a,abortMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as o,isAbortError as n}from"../../../../core/promiseUtils.js";import{watch as c}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{hydrateGraphic as p}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as d}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as y}from"../../../../symbols/callouts/calloutUtils.js";import{make as g}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutCreationContext as f,LineCalloutSymbolLayerRenderingInfo as m}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as C}from"./graphicSymbolUtils.js";import{LabelInfo as x}from"./LabelInfo.js";import{LabelParameters as _}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as L,verticalPlacementFromAnchor as v,textRenderAlignmentFromHorizontalPlacement as G}from"./placementUtils.js";import{placePointOnGeometry as w}from"./pointUtils.js";import{TextRenderer as D}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as A}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as T}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as I}from"../../webgl-engine/lib/WebGLLayer.js";import{hasLayerBasedScaleVisibility as S,isInEffectiveScaleRange as R}from"../../../support/layerViewUtils.js";import{TaskPriority as P}from"../../../support/Scheduler.js";import{Yield as j}from"../../../support/Yield.js";class V{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class O{constructor(e,t,s,i,l){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=i,this.labelFunction=l,this.calloutSymbolLayerIndex=0,this.graphics=new Map,this.scaleVisibility=null}}class z{constructor(e,t,s,i,l,a,r,o){this.layer=t,this.graphics3DCore=s,this.scaleVisibility=i,this.emptySymbolLabelSupported=l,this.elevationInfoOverride=a,this.disablePlacement=r,this.active=o,this.labelClassAbortController=new AbortController,this._labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new I(e,{pickable:!0},s.owner.layerViewUid)}destroy(){this.stageLayer.destroy()}get labelClassContexts(){return this._labelClassContexts}setLabelClassContext(e,t){this._labelClassContexts[e]=t}resetLabelClassContext(){this._labelClassContexts.length=0}}let E=class extends t{constructor(e){super(e),this._hudMaterials=new Map,this._calloutMaterials=new Map,this._dirty=!1,this._labels=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this.addHandles([c(()=>this.view.state?.camera,()=>this.setDirty()),c(()=>this.view.state?.rasterPixelRatio,()=>this._resetAllLabels()),c(()=>this.view.focusAreasView?.polygons,()=>this._updateFocus()),this.view.resourceController.scheduler.registerTask(P.LABELER,this)]),S()&&this.addHandles(c(()=>this.view.scale,()=>this._updateScaleVisibility())),this._textTextureAtlas=new T({view:this.view})}dispose(){this.removeAllHandles(),this._textTextureAtlas=a(this._textTextureAtlas),this._hudMaterials.clear(),this._calloutMaterials.clear(),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),B.graphic=null,B.renderingInfo=null,B.layer=null}_updateFocus(){this._labelingContexts.forEach(e=>{e.graphics.forEach(t=>{if(0===t.labelLayers.length)return;const s=w(t.graphic.geometry);if(null==s)return;const i=this.view.focusAreasView?.containsGeometry(s)??!0;t.labelLayers.forEach(s=>{s.stageObject.geometries.some(e=>e.material.parameters.isFocused!==i)&&(this._removeGraphic(e,t),this._addGraphic(e,t),this.setDirty())})})})}_activateLabelingContext(e){e.graphics.forEach((t,s)=>{const i=new V(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i),t.setVisibilityFlag(16,1,!0)}),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach((e,t)=>{e.setVisibilityFlag(16,1,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)}),e.active=!1}_addLabelTextureToAtlas(e){if(this._textTextureAtlas)for(const t of e.graphics3DGraphic.labelLayers){if(!t.labelClass)continue;const s=e.textRenderers[t.labelClassContextIndex];s&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(s,e=>M(t.stageObject,e))),F(t.stageObject,s))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach(e=>e.remove()),e.textureAtlasHandles.length=0}get readyToRun(){return this.view.ready&&(this._dirty||this.deconflictor.readyToRun)}runTask(e){return this._updateLabels(e),!this._dirty&&this.deconflictor.readyToRun&&this.deconflictor.runTask(e),j}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active)if(H(t))this._dirty=!0;else if(U(t.labelClassContexts)){if(null===t.labelClassContexts){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(const[s,i]of t.labelsToInitialize)if(this._ensureGraphics3DResources(i)&&(this._labels.set(s,i),this.deconflictor.setDirty(),e.madeProgress()),(i.visible&&i.textInitialized||!i.visible&&i.hasGraphics3DResources)&&(t.labelsToInitialize.delete(s),e.madeProgress()),e.done){this._dirty=!0;break}this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),o(t),e.scaleVisibility?.updateScaleRangeActive();const a=e.graphics3DCore,r=a.layer,n=r.labelingInfo?.filter(e=>!!e.symbol);if(!n||0===n.length)return;let c=!1;await s(n,async(s,r)=>{const n=s.symbol,h=C(a.getOrCreateGraphics3DSymbol(n));if(null==h)return void l.getLogger(this).error("Failed to create Graphics3DSymbol for label");await h.load(),o(t);let b=null;y(n)&&n.hasVisibleCallout()&&(b=g(n,a.symbolCreationContext),await b.load(),o(t));const u=await i(d(s,e.layer.fieldsIndex,this.view.spatialReference));if(o(t),!0===u.ok){const i=await this._createTextRenderParameters(h.symbol);o(t);const l=new O(s,h,b,i,u.value);this._updateLabelClassContextVisibility(l),e.setLabelClassContext(r,l)}else l.getLogger(this).error(`Label expression failed to evaluate: ${u.error}`),c=!0}),o(t)}async _createLabelClassContext(e){return null==e.labelClassPromise&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch(t=>{if(n(t))throw t;e.resetLabelClassContext()}).then(()=>{e.labelClassAbortController=null,this.notifyChange("updating")}).catch(()=>{}),this.notifyChange("updating")),e.labelClassPromise}async _createTextRenderParameters(e){const t=e.symbolLayers.at(0);return"text"!==t?.type?null:A.fromSymbol(t,this.view.state.rasterPixelRatio)}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,r(t),e.resetLabelClassContext(),e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,i,l,a){if(!this._textTextureAtlas)return null;const r=new _(s,L(s.anchor),v(s.anchor),e.text,u(e.displayWidth,e.displayHeight));return B.graphic=t,B.layer=i,B.renderingInfo=null,l.createLabel(B,r,this._hudMaterials,this._textTextureAtlas,()=>a.placement?.elevationOffset??null)}_createLineCalloutGraphic(e,t,s,i,l){B.graphic=e,B.layer=l;const a=i.screenOffset[0];return B.renderingInfo=new m(null,t,i.translation,i.centerOffset,a,i.centerOffsetUnits,i.elevationOffset),s.createGraphics3DGraphic(B,this._calloutMaterials)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,i=s.labelClassContexts;if(U(i)||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let l=!1;const a=t.graphic,r=s.layer,o=W(s.layer);for(let n=0;n<i.length;n++){const c=e.textRenderers[n],h=e.textLabelPlacements[n];if(null==c||null==h)continue;const b=i[n],u=b.graphics3DSymbol,p=k(u),d=u.symbolLayers[0];if(!d)continue;d.setElevationInfoOverride(s.elevationInfoOverride);const y=new x(t,p,b.labelClass),g=this._createTextSymbolGraphic(c,a,h,r,d,y);if(null==g)return!1;g.labelClass=b.labelClass,g.labelClassContextIndex=n,t.addLabelGraphic(g,s.stageLayer),this.deconflictor.setPriority(t,b.textRenderParameters?.definition.size??0),t.setVisibilityFlag(16,1,o),t.setVisibilityFlag(16,2,b.scaleVisibility??!0),t.setVisibilityFlag(16,8,!1),S()&&b.graphics.set(a.uid,t),l=!0;const f=b.graphics3DCalloutSymbolLayer;if(f&&h.hasLabelVerticalOffset){f.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(a,p,f,h,r);null!=e&&(b.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,s.stageLayer))}break}return l&&s.scaleVisibility?.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelLayers){if(null==s.labelClass)continue;const e=t[s.labelClassContextIndex].graphics3DSymbol.symbolLayers[0];e?.onRemoveGraphic(s)}e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(U(s))return;const i=e.graphics3DGraphic.graphic;for(let a=0;a<s.length;a++){const r=s[a];if(e.textRenderers[a]=null,e.textLabelPlacements[a]=null,null==r?.textRenderParameters)continue;const o=r.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?p(i,t.layer,null):i;n=o.evaluate(e)}catch(l){n=null}else n=o.evaluate(i);if(null==n||""===n||/^\s+$/.test(n))continue;const c=r.graphics3DSymbol;if(!c.symbolLayers[0])continue;const h=e.graphics3DGraphic,b="label-3d"===c.symbol?.type?c.symbol:null,u=r.labelClass,d=t.disablePlacement,y=new x(h,b,u,d).placement;if(null==y)continue;const g=L(y.anchor),f=G(g);e.textRenderers[a]=new D(n,f,r.textRenderParameters,T.maxSize),e.textLabelPlacements[a]=y}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){const s=t.graphic.uid;if(e.graphics.set(s,t),e.active){const i=new V(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){const s=t.graphic.uid,i=this._labels.get(s);if(!i)return!0;for(const l of i.graphics3DGraphic.labelLayers){if(null==l.labelClass)continue;if(!e.labelClassContexts[l.labelClassContextIndex].graphics3DSymbol.symbolLayers[0].updateGeometry(l,t.graphic.geometry))return!1}return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){const s=t.graphic.uid,i=this._labels.get(s);e.graphics.delete(s),e.labelClassContexts.forEach(e=>e.graphics.delete(s)),i&&(this._destroyGraphic(i,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.graphics.get(s);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const i=new Map;t.graphics.forEach(e=>i.set(e.graphic.uid,e));const l=e=>e.labelLayers[0];if(s.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,i,l),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,i,t)}}}_visibilityInfoChange(e){const t=W(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.graphics.forEach((t,s)=>{const i=this._labels.get(s);i&&(this._destroyGraphic(i,s),i.visible=!1,e.labelsToInitialize.set(s,i))}),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const i=s?.emptySymbolLabelSupported||!1,l=s?.elevationInfoOverride||null,a=s?.disablePlacement||null;if(this._findLabelingContext(e))return;const r=e.layer,o=new z(this.view.stage,r,e,t,i,l,a,W(r));return this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(o,e),layerLabelsEnabled:()=>W(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.graphics.forEach(e=>this._removeGraphic(t,e)),t.destroy(),this.setDirty()}_updateScaleVisibility(){for(const e of this._labelingContexts)if(e.active&&!H(e))for(const t of e.labelClassContexts)this._updateLabelClassContextVisibility(t)}_updateLabelClassContextVisibility(e){if(!S())return;const{labelClass:t,graphics:s}=e,i={minScale:t.minScale,maxScale:t.maxScale},l=R(i,this.view.scale),a=null==e.scaleVisibility||e.scaleVisibility!==l;e.scaleVisibility=l,a&&s.size&&(s.forEach(e=>e.setVisibilityFlag(16,2,l)),this.deconflictor.setDirty(),this.setDirty())}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,i=this._labels.get(s);i&&i.visible!==t&&(t&&!i.textureAtlasHandles.length?(this._addLabelTextureToAtlas(i),i.textInitialized||i.labelingContext.labelsToInitialize.set(s,i)):!t&&i.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(i),i.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some(e=>H(e))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce((e,t)=>e+(H(t)?0:1),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get usedMemory(){return this._textTextureAtlas?.usedMemory??0}get test(){}};function F(e,t){e.geometries[0].setAttributeData("size",[t.displayWidth,t.displayHeight]),e.geometryVertexAttributeUpdated(e.geometries[0],"size")}function M(e,t){e.geometries[0].setAttributeData("uvi",t),e.geometryVertexAttributeUpdated(e.geometries[0],"uvi",!0)}function H(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function U(e){return!e||0===e.length}function k(e){return"label-3d"===e.symbol?.type?e.symbol:null}function W(e){return!!e.labelsVisible&&!!e.labelingInfo?.some(e=>!!e.symbol)}e([h({constructOnly:!0})],E.prototype,"view",void 0),e([h({constructOnly:!0})],E.prototype,"deconflictor",void 0),e([h()],E.prototype,"_textTextureAtlas",void 0),e([h({type:Boolean,readOnly:!0})],E.prototype,"updating",null),E=e([b("esri.views.3d.layers.graphics.Labeler")],E);const B=new f(null,null,null);export{E as Labeler,W as areLabelsVisible};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{forEach as s,result as i}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import a from"../../../../core/Logger.js";import{disposeMaybe as l,abortMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as o,isAbortError as n}from"../../../../core/promiseUtils.js";import c from"../../../../core/Queue.js";import{watch as h}from"../../../../core/reactiveUtils.js";import{property as b}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{hydrateGraphic as d}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as y}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as g}from"../../../../symbols/callouts/calloutUtils.js";import{make as f}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutCreationContext as m,LineCalloutSymbolLayerRenderingInfo as C}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as x}from"./graphicSymbolUtils.js";import{LabelInfo as _}from"./LabelInfo.js";import{LabelParameters as L}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as v,verticalPlacementFromAnchor as G,textRenderAlignmentFromHorizontalPlacement as w}from"./placementUtils.js";import{placePointOnGeometry as D}from"./pointUtils.js";import{TextRenderer as A}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as T}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as I}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as S}from"../../webgl-engine/lib/WebGLLayer.js";import{hasLayerBasedScaleVisibility as R,isInEffectiveScaleRange as P}from"../../../support/layerViewUtils.js";import{TaskPriority as j}from"../../../support/Scheduler.js";import{Yield as V}from"../../../support/Yield.js";class O{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class F{constructor(e,t,s,i,a){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=i,this.labelFunction=a,this.calloutSymbolLayerIndex=0,this.graphics=new Map,this.scaleVisibility=null}}class z{constructor(e,t,s,i,a,l,r,o){this.layer=t,this.graphics3DCore=s,this.scaleVisibility=i,this.emptySymbolLabelSupported=a,this.elevationInfoOverride=l,this.disablePlacement=r,this.active=o,this.labelClassAbortController=new AbortController,this._labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new S(e,{pickable:!0},s.owner.layerViewUid)}destroy(){this.stageLayer.destroy()}get labelClassContexts(){return this._labelClassContexts}setLabelClassContext(e,t){this._labelClassContexts[e]=t}resetLabelClassContext(){this._labelClassContexts.length=0}}let E=class extends t{constructor(e){super(e),this._hudMaterials=new Map,this._calloutMaterials=new Map,this._dirty=!1,this._focusAreasLabelsQueue=new c,this._labels=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this.addHandles([h(()=>this.view.state?.camera,()=>this.setDirty()),h(()=>this.view.state?.rasterPixelRatio,()=>this._resetAllLabels()),h(()=>this.view.focusAreasView?.polygons,()=>this._updateFocus()),this.view.resourceController.scheduler.registerTask(j.LABELER,this)]),R()&&this.addHandles(h(()=>this.view.scale,()=>this._updateScaleVisibility())),this._textTextureAtlas=new I({view:this.view})}dispose(){this.removeAllHandles(),this._textTextureAtlas=l(this._textTextureAtlas),this._hudMaterials.clear(),this._calloutMaterials.clear(),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),B.graphic=null,B.renderingInfo=null,B.layer=null}_updateFocus(){this._focusAreasLabelsQueue.clear(),this._labelingContexts.forEach(e=>{e.graphics.forEach(t=>{this._focusAreasLabelsQueue.push({graphic3DGraphic:t,labelingContext:e})})})}_activateLabelingContext(e){e.graphics.forEach((t,s)=>{const i=new O(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i),t.setVisibilityFlag(16,1,!0)}),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach((e,t)=>{e.setVisibilityFlag(16,1,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)}),e.active=!1}_addLabelTextureToAtlas(e){if(this._textTextureAtlas)for(const t of e.graphics3DGraphic.labelLayers){if(!t.labelClass)continue;const s=e.textRenderers[t.labelClassContextIndex];s&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(s,e=>U(t.stageObject,e))),M(t.stageObject,s))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach(e=>e.remove()),e.textureAtlasHandles.length=0}get readyToRun(){return this.view.ready&&(this._dirty||this.deconflictor.readyToRun||this._focusAreasLabelsQueue.length>0)}runTask(e){return this._updateLabels(e),this._applyFocusAreasUpdates(e),!this._dirty&&this.deconflictor.readyToRun&&this.deconflictor.runTask(e),V}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active)if(H(t))this._dirty=!0;else if(Q(t.labelClassContexts)){if(null===t.labelClassContexts){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(const[s,i]of t.labelsToInitialize)if(this._ensureGraphics3DResources(i)&&(this._labels.set(s,i),this.deconflictor.setDirty(),e.madeProgress()),(i.visible&&i.textInitialized||!i.visible&&i.hasGraphics3DResources)&&(t.labelsToInitialize.delete(s),e.madeProgress()),e.done){this._dirty=!0;break}this._dirty||this.notifyChange("updating")}}_applyFocusAreasUpdates(e){for(;this._focusAreasLabelsQueue.length>0&&!e.done;){const{graphic3DGraphic:e,labelingContext:t}=this._focusAreasLabelsQueue.pop();if(0===e.labelLayers.length)return;const s=D(e.graphic.geometry);if(null==s)return;const i=this.view.focusAreasView?.containsGeometry(s)??!0;e.labelLayers.forEach(s=>{s.stageObject.geometries.some(e=>e.material.parameters.isFocused!==i)&&(this._removeGraphic(t,e),this._addGraphic(t,e),this.setDirty())})}0===this._focusAreasLabelsQueue.length&&this.notifyChange("readyToRun")}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),o(t),e.scaleVisibility?.updateScaleRangeActive();const l=e.graphics3DCore,r=l.layer,n=r.labelingInfo?.filter(e=>!!e.symbol);if(!n||0===n.length)return;let c=!1;await s(n,async(s,r)=>{const n=s.symbol,h=x(l.getOrCreateGraphics3DSymbol(n));if(null==h)return void a.getLogger(this).error("Failed to create Graphics3DSymbol for label");await h.load(),o(t);let b=null;g(n)&&n.hasVisibleCallout()&&(b=f(n,l.symbolCreationContext),await b.load(),o(t));const u=await i(y(s,e.layer.fieldsIndex,this.view.spatialReference));if(o(t),!0===u.ok){const i=await this._createTextRenderParameters(h.symbol);o(t);const a=new F(s,h,b,i,u.value);this._updateLabelClassContextVisibility(a),e.setLabelClassContext(r,a)}else a.getLogger(this).error(`Label expression failed to evaluate: ${u.error}`),c=!0}),o(t)}async _createLabelClassContext(e){return null==e.labelClassPromise&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch(t=>{if(n(t))throw t;e.resetLabelClassContext()}).then(()=>{e.labelClassAbortController=null,this.notifyChange("updating")}).catch(()=>{}),this.notifyChange("updating")),e.labelClassPromise}async _createTextRenderParameters(e){const t=e.symbolLayers.at(0);return"text"!==t?.type?null:T.fromSymbol(t,this.view.state.rasterPixelRatio)}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,r(t),e.resetLabelClassContext(),e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,i,a,l){if(!this._textTextureAtlas)return null;const r=new L(s,v(s.anchor),G(s.anchor),e.text,p(e.displayWidth,e.displayHeight));return B.graphic=t,B.layer=i,B.renderingInfo=null,a.createLabel(B,r,this._hudMaterials,this._textTextureAtlas,()=>l.placement?.elevationOffset??null)}_createLineCalloutGraphic(e,t,s,i,a){B.graphic=e,B.layer=a;const l=i.screenOffset[0];return B.renderingInfo=new C(null,t,i.translation,i.centerOffset,l,i.centerOffsetUnits,i.elevationOffset),s.createGraphics3DGraphic(B,this._calloutMaterials)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,i=s.labelClassContexts;if(Q(i)||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let a=!1;const l=t.graphic,r=s.layer,o=W(s.layer);for(let n=0;n<i.length;n++){const c=e.textRenderers[n],h=e.textLabelPlacements[n];if(null==c||null==h)continue;const b=i[n],u=b.graphics3DSymbol,p=k(u),d=u.symbolLayers[0];if(!d)continue;d.setElevationInfoOverride(s.elevationInfoOverride);const y=new _(t,p,b.labelClass),g=this._createTextSymbolGraphic(c,l,h,r,d,y);if(null==g)return!1;g.labelClass=b.labelClass,g.labelClassContextIndex=n,t.addLabelGraphic(g,s.stageLayer),this.deconflictor.setPriority(t,b.textRenderParameters?.definition.size??0),t.setVisibilityFlag(16,1,o),t.setVisibilityFlag(16,2,b.scaleVisibility??!0),t.setVisibilityFlag(16,8,!1),R()&&b.graphics.set(l.uid,t),a=!0;const f=b.graphics3DCalloutSymbolLayer;if(f&&h.hasLabelVerticalOffset){f.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(l,p,f,h,r);null!=e&&(b.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,s.stageLayer))}break}return a&&s.scaleVisibility?.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelLayers){if(null==s.labelClass)continue;const e=t[s.labelClassContextIndex].graphics3DSymbol.symbolLayers[0];e?.onRemoveGraphic(s)}e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(Q(s))return;const i=e.graphics3DGraphic.graphic;for(let l=0;l<s.length;l++){const r=s[l];if(e.textRenderers[l]=null,e.textLabelPlacements[l]=null,null==r?.textRenderParameters)continue;const o=r.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?d(i,t.layer,null):i;n=o.evaluate(e)}catch(a){n=null}else n=o.evaluate(i);if(null==n||""===n||/^\s+$/.test(n))continue;const c=r.graphics3DSymbol;if(!c.symbolLayers[0])continue;const h=e.graphics3DGraphic,b="label-3d"===c.symbol?.type?c.symbol:null,u=r.labelClass,p=t.disablePlacement,y=new _(h,b,u,p).placement;if(null==y)continue;const g=v(y.anchor),f=w(g);e.textRenderers[l]=new A(n,f,r.textRenderParameters,I.maxSize),e.textLabelPlacements[l]=y}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){const s=t.graphic.uid;if(e.graphics.set(s,t),e.active){const i=new O(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){const s=t.graphic.uid,i=this._labels.get(s);if(!i)return!0;for(const a of i.graphics3DGraphic.labelLayers){if(null==a.labelClass)continue;if(!e.labelClassContexts[a.labelClassContextIndex].graphics3DSymbol.symbolLayers[0].updateGeometry(a,t.graphic.geometry))return!1}return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){const s=t.graphic.uid,i=this._labels.get(s);e.graphics.delete(s),e.labelClassContexts.forEach(e=>e.graphics.delete(s)),i&&(this._destroyGraphic(i,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.graphics.get(s);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const i=new Map;t.graphics.forEach(e=>i.set(e.graphic.uid,e));const a=e=>e.labelLayers[0];if(s.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,i,a),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,i,t)}}}_visibilityInfoChange(e){const t=W(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.graphics.forEach((t,s)=>{const i=this._labels.get(s);i&&(this._destroyGraphic(i,s),i.visible=!1,e.labelsToInitialize.set(s,i))}),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const i=s?.emptySymbolLabelSupported||!1,a=s?.elevationInfoOverride||null,l=s?.disablePlacement||null;if(this._findLabelingContext(e))return;const r=e.layer,o=new z(this.view.stage,r,e,t,i,a,l,W(r));return this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(o,e),layerLabelsEnabled:()=>W(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.graphics.forEach(e=>this._removeGraphic(t,e)),t.destroy(),this.setDirty()}_updateScaleVisibility(){for(const e of this._labelingContexts)if(e.active&&!H(e))for(const t of e.labelClassContexts)this._updateLabelClassContextVisibility(t)}_updateLabelClassContextVisibility(e){if(!R())return;const{labelClass:t,graphics:s}=e,i={minScale:t.minScale,maxScale:t.maxScale},a=P(i,this.view.scale),l=null==e.scaleVisibility||e.scaleVisibility!==a;e.scaleVisibility=a,l&&s.size&&(s.forEach(e=>e.setVisibilityFlag(16,2,a)),this.deconflictor.setDirty(),this.setDirty())}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,i=this._labels.get(s);i&&i.visible!==t&&(t&&!i.textureAtlasHandles.length?(this._addLabelTextureToAtlas(i),i.textInitialized||i.labelingContext.labelsToInitialize.set(s,i)):!t&&i.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(i),i.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some(e=>H(e))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce((e,t)=>e+(H(t)?0:1),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get usedMemory(){return this._textTextureAtlas?.usedMemory??0}get test(){}};function M(e,t){e.geometries[0].setAttributeData("size",[t.displayWidth,t.displayHeight]),e.geometryVertexAttributeUpdated(e.geometries[0],"size")}function U(e,t){e.geometries[0].setAttributeData("uvi",t),e.geometryVertexAttributeUpdated(e.geometries[0],"uvi",!0)}function H(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function Q(e){return!e||0===e.length}function k(e){return"label-3d"===e.symbol?.type?e.symbol:null}function W(e){return!!e.labelsVisible&&!!e.labelingInfo?.some(e=>!!e.symbol)}e([b({constructOnly:!0})],E.prototype,"view",void 0),e([b({constructOnly:!0})],E.prototype,"deconflictor",void 0),e([b()],E.prototype,"_textTextureAtlas",void 0),e([b({type:Boolean,readOnly:!0})],E.prototype,"updating",null),E=e([u("esri.views.3d.layers.graphics.Labeler")],E);const B=new m(null,null,null);export{E as Labeler,W as areLabelsVisible};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{C as e}from"../../../../../chunks/Compositing.glsl.js";import{CompositingTechnique as t}from"../../shaders/CompositingTechnique.js";import{CompositingTechniqueConfiguration as i}from"../../shaders/CompositingTechniqueConfiguration.js";class r{constructor(r,s=0){this._techniques=r,this._parameters=new e,this._configuration=new i,this._configuration.blitMode=s,r.precompile(t,this._configuration)}blit(e,i,r,s){e.bindFramebuffer(r.fbo),e.setClearColor(0,0,0,1),e.clear(16384),this._parameters.texture=i
|
|
5
|
+
import{C as e}from"../../../../../chunks/Compositing.glsl.js";import{CompositingTechnique as t}from"../../shaders/CompositingTechnique.js";import{CompositingTechniqueConfiguration as i}from"../../shaders/CompositingTechniqueConfiguration.js";class r{constructor(r,s=0){this._techniques=r,this._parameters=new e,this._configuration=new i,this._configuration.blitMode=s,r.precompile(t,this._configuration)}blit(e,t,i,r){this.blitTexture(e,t.getTexture(),i,r)}blitTexture(e,i,r,s){e.bindFramebuffer(r.fbo),e.setClearColor(0,0,0,1),e.clear(16384),this._parameters.texture=i;const o=this._techniques.get(t,this._configuration);e.bindTechnique(o,s,this._parameters),e.screen.draw()}blend(e,i,r,s,o=1){this._configuration.hasOpacityFactor=o<1;const n=this._techniques.get(t,this._configuration);return!!n.compiled&&(e.bindFramebuffer(r.fbo),this._parameters.texture=i.getTexture(),this._parameters.opacity=o,e.bindTechnique(n,s,this._parameters),e.screen.draw(),!0)}}export{r as Blit};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderModules/
|
|
5
|
+
import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderModules/FloatsPassUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/IntegerPassUniform.js";import"../../core/shaderModules/Texture2DPassUniform.js";import"./BloomPresets.glsl.js";import"../../shaders/ToneMapping.glsl.js";import"../../../../webgl/NoParameters.js";import"../../../../webgl/ShaderBuilder.js";export{B as BloomCompositionPassParameters,b as build,d as defaultCompositionParameters}from"../../../../../chunks/BloomComposition.glsl.js";
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ReloadableShaderModule as e}from"../../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as
|
|
5
|
+
import{ReloadableShaderModule as e}from"../../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as r}from"../../core/shaderTechnique/ShaderTechnique.js";import{a as o}from"../../../../../chunks/BloomComposition.glsl.js";import{Pos2Locations as s}from"../../lib/DefaultVertexBufferLayouts.js";import{ColorAttachment0 as i,ColorAttachment1 as t}from"../../../../webgl/enums.js";import{makePipelineState as m,defaultColorWrite as l}from"../../../../webgl/renderState.js";class a extends r{constructor(r,i){super(r,i,new e(o,()=>import("./BloomComposition.glsl.js")),s)}initializePipeline(){return m({colorWrite:l,drawBuffers:{buffers:[i,t]}})}}export{a as BloomCompositionTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{lerp as t}from"../../../../../core/mathUtils.js";import{watch as o,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{property as i}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{
|
|
5
|
+
import{__decorate as e}from"tslib";import{lerp as t}from"../../../../../core/mathUtils.js";import{watch as o,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{property as i}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ZEROS as a}from"../../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{InternalRenderCategory as n}from"../../../webgl.js";import{TransparentEnvironment as m}from"../TransparentEnvironment.js";import{B as l}from"../../../../../chunks/BloomBlur.glsl.js";import{BloomBlurTechnique as c}from"./BloomBlurTechnique.js";import{BloomBlurTechniqueConfiguration as h}from"./BloomBlurTechniqueConfiguration.js";import{B as u}from"../../../../../chunks/BloomComposition.glsl.js";import{BloomCompositionTechnique as p}from"./BloomCompositionTechnique.js";import{BloomCompositionTechniqueConfiguration as b}from"./BloomCompositionTechniqueConfiguration.js";import{blurRadiusPresets as d,lodFactorsPresets as g,normalizePreset as _}from"./BloomPresets.glsl.js";import{ColorAttachment1 as f,DepthStencilAttachment as P}from"../../../../webgl/enums.js";let T=class extends m{constructor(e){super(e),this.consumes={required:[n.TRANSPARENT_ENVIRONMENT,"emissive"]},this.produces=n.TRANSPARENT_ENVIRONMENT,this._blurHorizontalConfiguration=new h,this._blurVerticalConfiguration=new h,this._compositionConfiguration=new b,this._compositionParameters=new u,this._blurParameters=new l,this._blurScale=3.06,this._glowEnabled=!1,this._bloomResults=new Array;e.view.stage.renderView.techniques.precompile(p,this._compositionConfiguration)}initialize(){this.addHandles([o(()=>this._updateFogParameters(),()=>{},r),o(()=>this.view.qualitySettings.bloom,e=>{this._glowEnabled=e,this.precompile(),this.requestRender(1)},r)])}_updateFogParameters(){const e=this.view.environment.weather;if("sunny"===e.type||"cloudy"===e.type)this._blurParameters.blurRadius=d[e.type];else{const o="foggy"===e.type?e.fogStrength:e.precipitation;this._blurParameters.blurRadius=t(d.cloudy,d[e.type],o)}this._compositionParameters.lodFactors=g[e.type].far,this._compositionParameters.lodFactorsFront=g[e.type].near,this.requestRender(1)}precompile(){this._glowEnabled&&(this.techniques.precompile(c,this._blurHorizontalConfiguration),this._blurVerticalConfiguration.bloomStage=1,this.techniques.precompile(c,this._blurVerticalConfiguration)),this._compositionConfiguration.blurEnabled=this._glowEnabled,this.techniques.precompile(p,this._compositionConfiguration)}render(e){const t=e.find(({name:e})=>e===n.TRANSPARENT_ENVIRONMENT),o=t.getAttachment(f)?.attachment;if(!o)return t;const r=t.getAttachment(P);if(!this._glowEnabled){const e=this.techniques.get(p,this._compositionConfiguration);if(!e.compiled)return this.requestRender(1),t;const i=t.getTexture(),s=this.fboCache,{fullWidth:a,fullHeight:n}=this.bindParameters.camera,m=this.renderingContext,l=s.acquire(i.descriptor.width,i.descriptor.height,this.produces);return this._prepareFBO(l,a,n),this._compositionParameters.color=i,this._compositionParameters.emission=o,m.bindTechnique(e,this.bindParameters,this._compositionParameters),m.screen.draw(),l.attachDepth(r),l.attachColor(t.getAttachment(f),f),l}const i=this.techniques.get(c,this._blurHorizontalConfiguration),s=this.techniques.get(c,this._blurVerticalConfiguration),a=this.techniques.get(p,this._compositionConfiguration);if(!i.compiled||!s.compiled||!a.compiled)return this.requestRender(1),t;const m=t.getTexture(),l=this.fboCache,{fullWidth:h,fullHeight:u}=this.bindParameters.camera,b=this.renderingContext;let d=o,g=Math.ceil(h/2),_=Math.ceil(u/2);const T=5,R=this._blurParameters.blurRadius;for(let n=0;n<T;n++){const e=l.acquire(g,_,"bloomHorizontal",8);this._blurParameters.color=d,this._prepareFBO(e,g,_),b.bindTechnique(i,this.bindParameters,this._blurParameters),b.screen.draw();const t=l.acquire(g,_,"bloomVertical",8);this._blurParameters.color=e.getTexture(),this._prepareFBO(t,g,_),b.bindTechnique(s,this.bindParameters,this._blurParameters),b.screen.draw(),e.release(),this._bloomResults[n]=t,g=Math.ceil(g/2),_=Math.ceil(_/2),d=this._bloomResults[n].getTexture(),this._blurParameters.blurRadius*=this._blurScale}this._blurParameters.blurRadius=R,this._compositionParameters.color=m,this._compositionParameters.emission=o,this._compositionParameters.bloomTexture0=this._bloomResults[0].getTexture(),this._compositionParameters.bloomTexture1=this._bloomResults[1].getTexture(),this._compositionParameters.bloomTexture2=this._bloomResults[2].getTexture(),this._compositionParameters.bloomTexture3=this._bloomResults[3].getTexture(),this._compositionParameters.bloomTexture4=this._bloomResults[4].getTexture();const C=l.acquire(m.descriptor.width,m.descriptor.height,this.produces);return C.acquireColor(f,8,"emissive bloom"),this._prepareFBO(C,h,u,!0),b.bindTechnique(a,this.bindParameters,this._compositionParameters),b.screen.draw(),this._bloomResults.forEach(e=>e.release()),C.attachDepth(r),C}_prepareFBO(e,t,o,r=!1){const i=this.renderingContext;i.bindFramebuffer(e.fbo),i.setViewport(0,0,t,o),i.setClearColor(0,0,0,0),i.clear(16384),r&&i.clearBuffer(1,a)}get test(){return{compositionParameters:this._compositionParameters,blurParameters:this._blurParameters,setLodFactors:e=>{this._compositionParameters.lodFactors=_(e)},toggleTonemapping:e=>{this._compositionConfiguration.tonemappingEnabled=e,this.requestRender(1)}}}};e([i()],T.prototype,"consumes",void 0),e([i()],T.prototype,"produces",void 0),T=e([s("esri.views.3d.webgl-engine.effects.bloom.BloomRenderNode")],T);export{T as BloomRenderNode};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{memoize as t}from"../../../core/memoize.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{GeometryDescriptor as n}from"../../../layers/support/ElevationQuery.js";import{getGraphicEffectiveElevationInfo as s}from"../../../support/elevationInfoUtils.js";import{getInputGraphic as a}from"./elevationProfileGeometryUtils.js";import{ElevationProfileLineComputation as l}from"./ElevationProfileLineComputation.js";let p=class extends l{constructor(){super(...arguments),this.type="input",this.numSamplesForPreview=50,this.numSamplesPerChunk=500,this._getQueryElevationDependenciesMemoized=t((e,t,o,r,i)=>e&&o?{elevationInfo:e,visibleLayers:t,view:o,stationary:r,spatialReference:i}:null)}get available(){return!this.controller.analysisViewData.
|
|
5
|
+
import{__decorate as e}from"tslib";import{memoize as t}from"../../../core/memoize.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{GeometryDescriptor as n}from"../../../layers/support/ElevationQuery.js";import{getGraphicEffectiveElevationInfo as s}from"../../../support/elevationInfoUtils.js";import{getInputGraphic as a}from"./elevationProfileGeometryUtils.js";import{ElevationProfileLineComputation as l}from"./ElevationProfileLineComputation.js";let p=class extends l{constructor(){super(...arguments),this.type="input",this.numSamplesForPreview=50,this.numSamplesPerChunk=500,this._getQueryElevationDependenciesMemoized=t((e,t,o,r,i)=>e&&o?{elevationInfo:e,visibleLayers:t,view:o,stationary:r,spatialReference:i}:null)}get available(){return!this.controller.analysisViewData.sketchGraphic?.geometry}initialize(){const e=()=>this.onInvalidate(this);this.addHandles([o(()=>this._queryElevationDependencies,e),this.controller.onElevationChange(e)])}async queryElevation(e,{noDataValue:t,signal:o}){const r=this._queryElevationDependencies;if(null==r)throw new Error(`${this.declaredClass}: no dependencies`);const{view:i,elevationInfo:s,spatialReference:a}=r;if("on-the-ground"===s.mode&&"3d"===i.type&&a){const r=await n.fromGeometry(e).project(a,o);if(!r)return{geometry:e,noDataValue:t};const s=i.elevationProvider;return r.coordinates.forEach(e=>{e.z=s.getElevation(e.x,e.y,0,a,"ground")??0}),{geometry:r.export(),noDataValue:t}}return{geometry:e,noDataValue:t}}get _queryElevationDependencies(){const{view:e}=this.controller;return this._getQueryElevationDependenciesMemoized(this._elevationInfo,this._visibleLayers,e,e.stationary,e.spatialReference)}get _elevationInfo(){const e=a(this.controller.analysis.input);return e?s(e):null}get _visibleLayers(){return this.controller.view?.map?.allLayers?.filter(e=>e.visible).toArray()??[]}};e([r()],p.prototype,"available",null),e([r()],p.prototype,"_queryElevationDependencies",null),e([r()],p.prototype,"_elevationInfo",null),e([r()],p.prototype,"_visibleLayers",null),p=e([i("esri.views.analysis.ElevationProfile.ElevationProfileInputLineComputation")],p);export{p as ElevationProfileInputLineComputation};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import i from"../../../core/Accessor.js";import{isSome as s}from"../../../core/arrayUtils.js";import{createTask as a}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{makeHandle as r,handlesGroup as o}from"../../../core/handleUtils.js";import{ignoreAbortErrors as n,isAborted as c,createResolver as p,throwIfAborted as l,createAbortError as h,onAbort as m}from"../../../core/promiseUtils.js";import{watch as y,syncAndInitial as d}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import k from"../../../layers/GraphicsLayer.js";import f from"../../../symbols/CIMSymbol.js";import g from"../../../symbols/SimpleLineSymbol.js";import{isPolylineGraphic as v,isPolyline as w,isValidInputGraphic as b}from"./elevationProfileGeometryUtils.js";import{ViewEventPriorities as G}from"../../input/InputManager.js";import{isCancelEvent as O}from"../../interactive/interactiveToolUtils.js";import S from"../../../widgets/Sketch/SketchViewModel.js";const I=Symbol("main"),V=Symbol("interactive-operation");let j=class extends i{constructor(e){super(e),this._activeOperationInfo=null}initialize(){const{view:e}=this;this._graphicsLayer=new k({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height",offset:null},title:"Elevation profile graphics layer"}),this._sketchViewModel=new S({layer:this._graphicsLayer,view:e,defaultCreateOptions:{mode:"click",hasZ:!0},updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{shapeOperation:"none"},enableRotation:!1,enableScaling:!1,enableMoveAllGraphics:!1,enableZ:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"reshape"},polylineSymbol:this._lineSymbol,activeLineSymbol:this._lineSymbol}),this.addHandles(y(()=>({map:e.map,internalGraphicsLayer:this._graphicsLayer,state:this.state}),({map:e,internalGraphicsLayer:t,state:i})=>{switch(L(e,t),i){case"idle":case"selected":this._stopOperation();break;case"picking":case"awaiting-sketch":case"sketching":break;case"reshaping":this._startReshape();break;case"reshaping-disabled":this._stopOperation(),this._graphicsLayer.visible=!1,this._ensureUpdatedSketchGraphic()}},d),I)}destroy(){this._sketchViewModel.destroy();const e=this._graphicsLayer;e&&this.view.map?.remove(e),e.destroy()}get sketchGraphic(){return this._get("sketchGraphic")}set sketchGraphic(e){e!==this._get("sketchGraphic")&&(this._set("sketchGraphic",e),D(this._graphicsLayer,e),this._updateInputFromSketchGraphic())}get state(){const{analysis:e,visible:t,interactive:i}=this.analysisViewData;if(!t)return"idle";switch(this._activeOperationInfo?.type){case"place":return this._sketchViewModel.createGraphic===this.sketchGraphic?"sketching":"awaiting-sketch";case"pick-graphic":return"picking";default:{const{input:t}=e;return t?v(t)?"selected":i?"reshaping":"reshaping-disabled":"idle"}}}get updating(){return this._sketchViewModel.updating}get _lineSymbol(){return M(this.view.type)}place(e){return this._startOperation("place",e,(t,i)=>{const s=this.analysisViewData.analysis.clone(),a=this._sketchViewModel.on("create",e=>{switch(e.state){case"complete":this._updateInputFromSketchGraphic(),this._stopOperation();break;case"cancel":this._stopOperation();break;case"active":this._updateInputFromSketchGraphic();break;case"start":this.sketchGraphic=e.graphic}});return n(this._sketchViewModel.create("polyline")),r(()=>(a.remove(),this._sketchViewModel.cancel(),this._updateInputFromSketchGraphic(),this.analysisViewData.analysis.valid?c(e)||s.equals(this.analysisViewData.analysis)?i():void t():(this._clearInput(),i())))})}async pickGraphic(e){return this._startOperation("pick-graphic",e,(e,t)=>{const{view:i}=this;i.closePopup();let s=null;const n=r=>{r.defer(async()=>{s?.abort(),s=a(async s=>{const{results:a}=await i.hitTest(r);l(s);const o=a.filter(e=>"graphic"===e.type).map(e=>e.graphic).find(b);o?(r.preventDefault(),r.stopPropagation(),this.sketchGraphic=null,this.analysisViewData.analysis.input=o,e(),this._stopOperation()):t()}),await s.promise})},c=e=>{O(e)&&(t(),this._stopOperation())};return i.focus(),o([i.on("immediate-click",n,G.TOOL),i.on("key-down",c,G.TOOL),i.acquireCursor("crosshair","high"),r(()=>{s?.abort(),t()})])})}_startReshape(){this._stopOperation();const e=this._sketchViewModel.on("update",e=>{this._updateInputFromSketchGraphic(),"complete"===e.state&&this._stopOperation()});this._replaceHandles(r(()=>{e.remove(),this._sketchViewModel.cancel()}),V);const t=this._ensureUpdatedSketchGraphic();t&&(this._graphicsLayer.visible=!0,n(this._sketchViewModel.update(t,{tool:"reshape"})))}async _startOperation(e,t,i){const s=this._activeOperationInfo,a=p(),r={type:e,promise:a.promise};if(this._activeOperationInfo=r,s){const e=s.promise.catch(()=>{});this._stopOperation(),await e,l(t)}this.analysisViewData.interactive=!0;const o=i(()=>a.resolve({}),()=>a.reject(h()));this._replaceHandles([o,m(t,()=>this._stopOperation())],V);try{return await a.promise}finally{this._activeOperationInfo===r&&(this._activeOperationInfo=null)}}_stopOperation(){this.removeHandles(V)}_ensureUpdatedSketchGraphic(){const{input:e}=this.analysisViewData.analysis;return w(e)?(this.sketchGraphic??=new t({symbol:this._lineSymbol,geometry:e}),this.sketchGraphic.geometry=e,this.sketchGraphic):(this.sketchGraphic=null,null)}_clearInput(){this.sketchGraphic=null,this.analysisViewData.analysis.input=null}_updateInputFromSketchGraphic(){const e=this.sketchGraphic,{analysis:t}=this.analysisViewData;t.input=v(e)?e.geometry:null}_replaceHandles(e,t){this.removeHandles(t),this.addHandles((Array.isArray(e)?e:[e]).filter(s),t)}};function M(e){if("2d"===e){const e={type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",width:1.5};return new f({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{...e,effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[5,4],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],color:[0,0,0,255]},{...e,color:[255,255,255,255]}]}}})}return new g({color:[0,0,0,0]})}function L(e,t){t&&(t.parent&&"remove"in t.parent&&t.parent.remove(t),e?.add(t))}function D({graphics:e},t){t?(e.includes(t)||e.add(t),1!==e.length&&e.removeMany(e.filter(e=>e!==t))):e.removeAll()}e([u({constructOnly:!0})],j.prototype,"analysisViewData",void 0),e([u({constructOnly:!0})],j.prototype,"view",void 0),e([u()],j.prototype,"sketchGraphic",null),e([u({nonNullable:!0})],j.prototype,"state",null),e([u()],j.prototype,"updating",null),e([u()],j.prototype,"_activeOperationInfo",void 0),e([u()],j.prototype,"_lineSymbol",null),j=e([_("esri.views.analysis.ElevationProfile.ElevationProfileTool")],j);export{j as ElevationProfileTool};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{floatEqualUlp as e,lerp as t}from"../../../core/mathUtils.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/unitUtils.js";import{distance as o,lerp as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{m as i}from"../../../chunks/vec32.js";import a from"../../../geometry/Polyline.js";import{initializeProjection as c,project as u}from"../../../geometry/projectionUtils.js";import l from"../../../geometry/SpatialReference.js";import{geodesicLengths as f,isSupported as p,inverseGeodeticSolver as h,directGeodeticSolver as m}from"../../../geometry/support/geodesicUtils.js";import{getElevationOffset as d}from"../../../support/elevationInfoUtils.js";import{ElevationProfileGenerationError as g}from"./ElevationProfileGenerationError.js";async function y(e,t,o,s,i,a,p){let h,m,d;const y=e.spatialReference,j=y.isGeographic||y.isWebMercator;let v=0;if(!j){const{execute:t}=await import("../../../geometry/operators/lengthOperator.js");n(p),v=t(e,{unit:"meters"}),n(p)}const P=1/r(s);if(j){await c([{source:y,dest:s},{source:y,dest:l.WGS84}],p);const n=
|
|
5
|
+
import{floatEqualUlp as e,lerp as t}from"../../../core/mathUtils.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/unitUtils.js";import{distance as o,lerp as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{m as i}from"../../../chunks/vec32.js";import a from"../../../geometry/Polyline.js";import{initializeProjection as c,project as u}from"../../../geometry/projectionUtils.js";import l from"../../../geometry/SpatialReference.js";import{geodesicLengths as f,isSupported as p,inverseGeodeticSolver as h,directGeodeticSolver as m}from"../../../geometry/support/geodesicUtils.js";import{getElevationOffset as d}from"../../../support/elevationInfoUtils.js";import{ElevationProfileGenerationError as g}from"./ElevationProfileGenerationError.js";async function y(e,t,o,s,i,a,p){let h,m,d;const y=e.spatialReference,j=y.isGeographic||y.isWebMercator;let v=0;if(!j){const{execute:t}=await import("../../../geometry/operators/lengthOperator.js");n(p),v=t(e,{unit:"meters"}),n(p)}const P=1/r(s);if(j){await c([{source:y,dest:s},{source:y,dest:l.WGS84}],p);const n=B(e);h=f([n],"meters")[0];const r=w(h,i);if(F(e,h,r)>a)throw new g("too-complex");const j=R(n,t,o);({densifiedPath:m,distances:d}=W(j,r,P)),m=u(m,s)}else{await c([{source:y,dest:s}],p),h=v;const r=w(h,i);if(F(e,h,r)>a)throw new g("too-complex");const l=R(e,t,o);({densifiedPath:m,distances:d}=E(l,r,P)),n(p),m=u(m,s)}return{densifiedPath:m,pathLength:h*P,distances:d}}function w(e,t){const n=e/t.densificationMaxSamples;return Math.max(t.samplingDistance,n)}function R(e,t,n){if(null==t)return P(e);const r=e.spatialReference,o=t.mode,s=d(t,r);let i=null;switch(n.type){case"2d":i=j(e,o,s);break;case"3d":i=v(e,o,s,n)}return null==i?P(e):new a({hasZ:!0,hasM:!1,spatialReference:r,paths:Z(e.paths,i)})}function j({hasZ:e},t,n){return"absolute-height"===t?e?([e,t,r])=>[e,t,r+n]:([e,t])=>[e,t,n]:null}function v({spatialReference:e,hasZ:t},n,r,{elevationProvider:o}){const s=(t,n,r,s)=>o?.getElevation(t,n,r,e,s)??0;switch(n){case"on-the-ground":return([e,t])=>[e,t,s(e,t,0,"ground")];case"absolute-height":return t?([e,t,n])=>[e,t,n+r]:([e,t])=>[e,t,r];case"relative-to-ground":return t?([e,t,n])=>[e,t,n+s(e,t,n,"ground")+r]:([e,t])=>[e,t,s(e,t,0,"ground")+r];case"relative-to-scene":return t?([e,t,n])=>[e,t,n+s(e,t,n,"scene")+r]:([e,t])=>[e,t,s(e,t,0,"scene")+r];default:return null}}function P(e){return e.hasZ?new a({hasZ:!1,hasM:!1,spatialReference:e.spatialReference,paths:Z(e.paths,([e,t])=>[e,t])}):e}function Z(e,t){const n=e.length,r=new Array(n);for(let o=0;o<n;++o){const n=e[o],s=n.length,i=new Array(n.length);r[o]=i;for(let e=0;e<s;++e)i[e]=t(n[e])}return r}function x(e){return null!=e&&"polyline"===e.type&&e.paths.length>0&&e.paths.every(e=>e.length>=2)}function M(e){return S(e)&&x(e.geometry)}function S(e){return z(e)&&U(e?.geometry)}function U(e){return!z(e)&&null!=e&&"polyline"===e.type}function b(e){return z(e)?e:null}function A(e){return z(e)?e.geometry:e}function z(e){return null!=e&&"geometry"in e}function G(t,n,o,s,i){const{spatialReference:c,hasZ:u}=t,l={from:null,to:null,distance:0,azimuth:0,reverseAzimuth:0,spatialReference:c,metersPerSR:r(c)},f=[],p=[];let h=0;for(let r=0;r<t.paths.length;++r){const a=t.paths[r],c=new Array,u=new Array;let m=0;for(let t=1;t<a.length;++t){const r=a[t-1],f=a[t],p=s(l,r,f);let d;for(d=m;d<p.distance&&!e(d,p.distance);d+=n)c.push(i(p,d)),u.push((h+d)*o);m=d-p.distance,h+=p.distance,c.push(f),u.push(h*o)}f[r]=c,p[r]=u}return{densifiedPath:new a({spatialReference:c,hasZ:u,paths:f}),distances:p}}function E(e,t,n){const{hasZ:r}=e;return G(e,t,n,D,r?q:O)}function W(e,t,n){const{hasZ:r}=e;return G(e,t,n,k,r?L:I)}function k(e,t,n){return e.distance=0,h(e,t,n,e.spatialReference),e.from=t,e.to=n,e}function D(e,t,n){return e.from=t,e.to=n,e.distance=o(n,t)*e.metersPerSR,e}function I({from:e,azimuth:t,spatialReference:n},r){return m([0,0],e,t,r,n)}function L({from:e,to:n,azimuth:r,distance:o,spatialReference:s},i){const a=i/o,c=[0,0,t(e[2],n[2],a)];return m(c,e,r,i,s),c}function O({from:e,to:t,distance:n},r){return s([0,0],e,t,r/n)}function q({from:e,to:t,distance:n},r){return i([0,0,0],e,t,r/n)}function B(e){return p(e.spatialReference)?e:u(e,l.WGS84)}function C(e){return e.paths.reduce((e,t)=>e+t.length,0)}function F(e,t,n){return C(e)+Math.floor(t/n)+Math.max(0,e.paths.reduce(e=>1+e,0)-1)}export{C as countPoints,y as densifyPath,A as getInputGeometry,b as getInputGraphic,z as isGraphic,U as isPolyline,S as isPolylineGraphic,M as isValidInputGraphic,x as isValidInputPath,R as toAbsoluteHeightElevation};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{fromUsng as i,fromUtm as s,fromMgrs as a,fromLatitudeLongitude as l,toUtm as c,toUsng as p,toMgrs as u,toLatitudeLongitude as m}from"../../../geometry/coordinateFormatter.js";import{isLoaded as d,project as h}from"../../../geometry/projectionUtils.js";import f from"../../../geometry/SpatialReference.js";import{equals as v}from"../../../geometry/support/spatialReferenceUtils.js";import{project as g}from"../../../geometry/support/webMercatorUtils.js";import{isValidPoint as y,fromXY as w,pointToCoordinate as b,getDegreePrecision as S}from"./coordinateConversionUtils.js";let _=class extends t{constructor(e){super(e),this.conversionInfo=null,this.coordinateSegments=null,this._currentPattern=void 0,this.defaultPattern=null,this.name=null,this.viewModel=null}get currentPattern(){return(this._currentPattern||this.defaultPattern)??""}set currentPattern(e){this._currentPattern=e}get label(){return this.name??""}set label(e){this._overrideIfSome("label",e)}get hasDisplayProperties(){return!(!this.defaultPattern||!this.coordinateSegments)}get spatialReference(){return"basemap"===this.name?this._viewSpatialReference:this.conversionInfo?.spatialReference??f.WGS84}set spatialReference(e){this._overrideIfSome("spatialReference",e)}get _viewSpatialReference(){return this.viewModel?.view?.spatialReference??f.WGS84}get _additionalCharactersPattern(){const e=this.coordinateSegments;if(!e)return null;const t=e.map(e=>e.alias),r=this.currentPattern.replaceAll(new RegExp(`["nsew${t.join()}]`,"gi"),"").replaceAll(" ","");return new RegExp(`[${r}]`,"g")}get test(){}async convert(e){if(!y(e))throw new r("format:invalid-point","Could not convert invalid point.",{point:e});const t=this.conversionInfo?.convert;if(t)return Promise.resolve().then(()=>t(e));const n=this._project(e,this.spatialReference);return{location:n,coordinate:this._getCoordinate(n)}}getConversionStrategy(){const e=this._viewSpatialReference;return this.conversionInfo?.convert||this.viewModel?.formatterAvailable||"xy"===this.name&&(e.isWebMercator||e.isWGS84)||"basemap"===this.name?"client":"server"}getDisplayCoordinate(e){if(!e)return null;if(!this.coordinateSegments||!this.currentPattern)return e;let t=this.currentPattern;const r=this._getSegmentMatches(e,!1);for(let n=this.coordinateSegments.length-1;n>=0;n--){const e=this.coordinateSegments[n];t=t.replace(e.alias,r[n])}return t}_parseUserInput(e){const{defaultPattern:t,_additionalCharactersPattern:r,coordinateSegments:n}=this;if(!t||!r)return"";let o=t.replace(r,"");e=e.replace(r,"");const i=this._getSegmentMatches(e,!0);if(n)for(let s=n.length-1;s>=0;s--){const e=n[s];o=o.replace(e.alias,i[s])}return o}_getSegmentMatches(e,t){const r=new Array,{coordinateSegments:n}=this;if(!n)return r;for(let o=0;o<n.length;o++){const i=n[o],s=e.match(i.searchPattern);if(!s){r.push("");continue}let a=s[0];if(e=e.replace(a,"").trim(),i.substitution){const e=t?i.substitution.input(a):i.substitution.output(a);e&&(a=`${e}`)}r.push(a)}return r}async reverseConvert(e){const t=this._parseUserInput(e),n=this.conversionInfo?.reverseConvert;let o;if(n)o=n(t);else if("xy"===this.name||"basemap"===this.name)o=w(t,this.spatialReference);else if(this.viewModel?.formatterAvailable)switch(this.name){case"dd":case"ddm":case"dms":o=l(t,this.spatialReference);break;case"mgrs":{const e="automatic";o=a(t,this.spatialReference,e);break}case"utm":{const e="latitude-band-indicators";o=s(t,this.spatialReference,e);break}case"usng":o=i(t,this.spatialReference);break;default:o=null}if(!o)throw new r("format:invalid-input","Could not parse input into point.",{
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{fromUsng as i,fromUtm as s,fromMgrs as a,fromLatitudeLongitude as l,toUtm as c,toUsng as p,toMgrs as u,toLatitudeLongitude as m}from"../../../geometry/coordinateFormatter.js";import{isLoaded as d,project as h}from"../../../geometry/projectionUtils.js";import f from"../../../geometry/SpatialReference.js";import{equals as v}from"../../../geometry/support/spatialReferenceUtils.js";import{project as g}from"../../../geometry/support/webMercatorUtils.js";import{isValidPoint as y,fromXY as w,pointToCoordinate as b,getDegreePrecision as S}from"./coordinateConversionUtils.js";let _=class extends t{constructor(e){super(e),this.conversionInfo=null,this.coordinateSegments=null,this._currentPattern=void 0,this.defaultPattern=null,this.name=null,this.viewModel=null}get currentPattern(){return(this._currentPattern||this.defaultPattern)??""}set currentPattern(e){this._currentPattern=e}get label(){return this.name??""}set label(e){this._overrideIfSome("label",e)}get hasDisplayProperties(){return!(!this.defaultPattern||!this.coordinateSegments)}get spatialReference(){return"basemap"===this.name?this._viewSpatialReference:this.conversionInfo?.spatialReference??f.WGS84}set spatialReference(e){this._overrideIfSome("spatialReference",e)}get _viewSpatialReference(){return this.viewModel?.view?.spatialReference??f.WGS84}get _additionalCharactersPattern(){const e=this.coordinateSegments;if(!e)return null;const t=e.map(e=>e.alias),r=this.currentPattern.replaceAll(new RegExp(`["nsew${t.join()}]`,"gi"),"").replaceAll(" ","");return new RegExp(`[${r}]`,"g")}get test(){}async convert(e){if(!y(e))throw new r("format:invalid-point","Could not convert invalid point.",{point:e});const t=this.conversionInfo?.convert;if(t)return Promise.resolve().then(()=>t(e));const n=this._project(e,this.spatialReference);return{location:n,coordinate:this._getCoordinate(n)}}getConversionStrategy(){const e=this._viewSpatialReference;return this.conversionInfo?.convert||this.viewModel?.formatterAvailable||"xy"===this.name&&(e.isWebMercator||e.isWGS84)||"basemap"===this.name?"client":"server"}getDisplayCoordinate(e){if(!e)return null;if(!this.coordinateSegments||!this.currentPattern)return e;let t=this.currentPattern;const r=this._getSegmentMatches(e,!1);for(let n=this.coordinateSegments.length-1;n>=0;n--){const e=this.coordinateSegments[n];t=t.replace(e.alias,r[n])}return t}_parseUserInput(e){const{defaultPattern:t,_additionalCharactersPattern:r,coordinateSegments:n}=this;if(!t||!r)return"";let o=t.replace(r,"");e=e.replace(r,"");const i=this._getSegmentMatches(e,!0);if(n)for(let s=n.length-1;s>=0;s--){const e=n[s];o=o.replace(e.alias,i[s])}return o}_getSegmentMatches(e,t){const r=new Array,{coordinateSegments:n}=this;if(!n)return r;for(let o=0;o<n.length;o++){const i=n[o],s=e.match(i.searchPattern);if(!s){r.push("");continue}let a=s[0];if(e=e.replace(a,"").trim(),i.substitution){const e=t?i.substitution.input(a):i.substitution.output(a);e&&(a=`${e}`)}r.push(a)}return r}async reverseConvert(e){const t=this._parseUserInput(e),n=this.conversionInfo?.reverseConvert;let o;if(n)o=n(t);else if("xy"===this.name||"basemap"===this.name)o=w(t,this.spatialReference);else if(this.viewModel?.formatterAvailable)switch(this.name){case"dd":case"ddm":case"dms":o=l(t,this.spatialReference);break;case"mgrs":{const e="automatic";o=a(t,this.spatialReference,e);break}case"utm":{const e="latitude-band-indicators";o=s(t,this.spatialReference,e);break}case"usng":o=i(t,this.spatialReference);break;default:o=null}if(!o)throw new r("format:invalid-input","Could not parse input into point.",{coordinate:e});return this._project(o,this._viewSpatialReference)}_getCoordinate(e){const t=this.viewModel?.view?.scale??0;if(!y(e))throw new r("format:invalid-point","Could not transform invalid point into coordinate.",{point:e});if(this.viewModel?.formatterAvailable||"basemap"===this.name||"xy"===this.name)switch(this.name){case"dd":case"ddm":case"dms":{const r=S(t);return m(e,this.name,r)}case"mgrs":return u(e,"automatic",5,!1);case"usng":return p(e,5,!1);case"utm":return c(e,"latitude-band-indicators",!0);default:return b(e,t)}return b(e,t)}_project(e,t){if(v(e.spatialReference,t)||!t)return e;if(this.viewModel?.formatterAvailable&&d())return h(e,t);if(!this.viewModel?.formatterAvailable){const r=g(e,t);if(null!=r)return r}return null}};e([n()],_.prototype,"conversionInfo",void 0),e([n()],_.prototype,"coordinateSegments",void 0),e([n()],_.prototype,"currentPattern",null),e([n()],_.prototype,"_currentPattern",void 0),e([n()],_.prototype,"label",null),e([n()],_.prototype,"defaultPattern",void 0),e([n({readOnly:!0})],_.prototype,"hasDisplayProperties",null),e([n()],_.prototype,"name",void 0),e([n({type:f})],_.prototype,"spatialReference",null),e([n()],_.prototype,"viewModel",void 0),e([n({readOnly:!0})],_.prototype,"_viewSpatialReference",null),e([n({readOnly:!0})],_.prototype,"_additionalCharactersPattern",null),_=e([o("esri.widgets.CoordinateConversion.support.Format")],_);const R=_;export{R 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/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import t from"../../core/Logger.js";import{isAbortError as r,throwIfNotAbortError as o}from"../../core/promiseUtils.js";import{zoomToFeature as i,zoomToClusteredFeatures as n,browseClusteredFeatures as a,removeSelectedFeature as s}from"./actions.js";const c="esri.widgets.Popup.PopupViewModel",u=()=>t.getLogger(c),l=t=>{const{event:r,view:c,viewModel:u}=t,{action:l}=r;if(!l)return Promise.reject(new e("trigger-action:missing-arguments","Event has no action"));const{disabled:d,id:g}=l;if(!g)return Promise.reject(new e("trigger-action:invalid-action","action.id is missing"));if(d)return Promise.reject(new e("trigger-action:invalid-action","Action is disabled"));if(g===i.id)return f(u).catch(o);if(g===n.id)return m(u);if(g===a.id)return u.browseClusterEnabled=!u.browseClusterEnabled,u.featureMenuOpen=u.browseClusterEnabled,Promise.resolve();if(g===s.id){u.visible=!1;const{selectedFeature:t}=u;if(!t)return Promise.reject(new e(`trigger-action:${s.id}`,"selectedFeature is required",{selectedFeature:t}));const{sourceLayer:r}=t;return r?r.remove(t):c?.graphics.remove(t),Promise.resolve()}return Promise.resolve()};function d(e){const{selectedFeature:t,location:r,view:o}=e;return o?t??r??null:null}function g(e){return!!e&&e.isAggregate&&"cluster"===e.sourceLayer?.featureReduction?.type}async function w(e,t){if("3d"!==t?.type||!e||"esri.Graphic"!==e.declaredClass)return!0;const r=t.getViewForGraphic(e);if(r&&"whenGraphicBounds"in r){let t=null;try{t=await r.whenGraphicBounds(e,{useViewElevation:!0})}catch(o){}return!t||!t.boundingBox||t.boundingBox[0]===t.boundingBox[3]&&t.boundingBox[1]===t.boundingBox[4]&&t.boundingBox[2]===t.boundingBox[5]}return!0}async function f(t,o){const{location:n,selectedFeature:a,view:s,zoomFactor:c}=t;await(o?.viewModel?.updateGeometry());const l=o?.graphic,g=l?.geometry?l:d(t);if(!s||!g){const t=new e("zoom-to:invalid-target-or-view","Cannot zoom to location without a target and view.",{target:g,view:s});throw u().error(t),t}const f=s.scale/c,m=l?.geometry??t.selectedFeature?.geometry??n,v=null!=m&&"point"===m.type&&await w(l??a,s);i.active=!0,i.disabled=!0;try{await t.zoomTo({target:{target:g,scale:v?f:void 0}})}catch(p){if(r(p))return;const t=new e("zoom-to:invalid-graphic","Could not zoom to the location of the graphic.",{graphic:l??a});u().error(t)}finally{i.active=!1,i.disabled=!1,t.zoomToLocation=null,v&&(t.location=m)}}async function m(t){const{selectedFeature:r,view:o}=t;if("2d"!==o?.type){const t=new e("zoomToCluster:invalid-view","View must be 2d MapView.",{view:o});throw u().error(t),t}if(!r||!g(r)){const t=new e("zoomToCluster:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw u().error(t),t}const[i,a]=await y(o,r);n.active=!0,n.disabled=!0;const{extent:s}=await i.queryExtent(a);s&&await t.zoomTo({target:s}),n.active=!1,n.disabled=!1}async function v(e){const{view:t,selectedFeature:r}=e;if(!t||!r)return;const[o,i]=await y(t,r),{extent:n}=await o.queryExtent(i);e.selectedClusterBoundaryFeature.geometry=n,t.graphics.add(e.selectedClusterBoundaryFeature)}async function p(e){const{selectedFeature:t,view:r}=e;if(!r||!t)return;const[o,i]=await y(r,t);a.active=!0,a.disabled=!0;const{features:n}=await o.queryFeatures(i);a.active=!1,a.disabled=!1,a.value=!0;const s={features:[t].concat(n)};"feature"===e?.initialDisplayMode&&(s.featureMenuOpen=!0),e?.open(s)}async function y(e,t){const r=await e.whenLayerView(t.sourceLayer),o=r.createQuery(),i=t.getObjectId();return o.aggregateIds=null!=i?[i]:[],[r,o]}function h(e){a.value=!1;const t=e.features.filter(e=>g(e));t.length&&(e.features=t)}export{p as browseAggregateFeatures,v as displayClusterExtent,d as getSelectedTarget,g as isClusterFeature,h as removeClusteredFeaturesForBrowsing,l as triggerAction,m as zoomToClusterExtent,f as zoomToLocation};
|
|
5
|
+
import e from"../../core/Error.js";import t from"../../core/Logger.js";import{isAbortError as r,throwIfNotAbortError as o}from"../../core/promiseUtils.js";import{zoomToFeature as i,zoomToClusteredFeatures as n,browseClusteredFeatures as a,removeSelectedFeature as s}from"./actions.js";const c="esri.widgets.Popup.PopupViewModel",u=()=>t.getLogger(c),l=t=>{const{event:r,view:c,viewModel:u}=t,{action:l}=r;if(!l)return Promise.reject(new e("trigger-action:missing-arguments","Event has no action"));const{disabled:d,id:g}=l;if(!g)return Promise.reject(new e("trigger-action:invalid-action","action.id is missing"));if(d)return Promise.reject(new e("trigger-action:invalid-action","Action is disabled"));if(g===i.id)return f(u).catch(o);if(g===n.id)return m(u);if(g===a.id)return u.browseClusterEnabled=!u.browseClusterEnabled,u.featureMenuOpen=u.browseClusterEnabled,Promise.resolve();if(g===s.id){u.visible=!1;const{selectedFeature:t}=u;if(!t)return Promise.reject(new e(`trigger-action:${s.id}`,"selectedFeature is required",{selectedFeature:t}));const{sourceLayer:r}=t;return r?r.remove(t):c?.graphics.remove(t),Promise.resolve()}return Promise.resolve()};function d(e){const{selectedFeature:t,location:r,view:o}=e;return o?t??r??null:null}function g(e){return!!e&&e.isAggregate&&"cluster"===e.sourceLayer?.featureReduction?.type}async function w(e,t){if("3d"!==t?.type||!e||"esri.Graphic"!==e.declaredClass)return!0;const r=t.getViewForGraphic(e);if(r&&"whenGraphicBounds"in r){let t=null;try{t=await r.whenGraphicBounds(e,{useViewElevation:!0})}catch(o){}return!t||!t.boundingBox||t.boundingBox[0]===t.boundingBox[3]&&t.boundingBox[1]===t.boundingBox[4]&&t.boundingBox[2]===t.boundingBox[5]}return!0}async function f(t,o){const{location:n,selectedFeature:a,view:s,zoomFactor:c}=t;await(o?.viewModel?.updateGeometry());const l=o?.graphic,g=l?.geometry?l:d(t);if(!s||!g){const t=new e("zoom-to:invalid-target-or-view","Cannot zoom to location without a target and view.",{target:g,view:s});throw u().error(t),t}const f=s.scale/c,m=l?.geometry??t.selectedFeature?.geometry??n,v=null!=m&&"point"===m.type&&await w(l??a,s);i.active=!0,i.disabled=!0;try{await t.zoomTo({target:{target:g,scale:v?f:void 0}})}catch(p){if(r(p))return;const t=new e("zoom-to:invalid-graphic","Could not zoom to the location of the graphic.",{graphic:l??a});u().error(t)}finally{i.active=!1,i.disabled=!1,t.zoomToLocation=null,v&&(t.location=m)}}async function m(t){const{selectedFeature:r,view:o}=t;if("2d"!==o?.type){const t=new e("zoomToCluster:invalid-view","View must be 2d MapView.",{view:o});throw u().error(t),t}if(!r||!g(r)){const t=new e("zoomToCluster:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw u().error(t),t}const[i,a]=await y(o,r);n.active=!0,n.disabled=!0;const{extent:s}=await i.queryExtent(a);s&&await t.zoomTo({target:s}),n.active=!1,n.disabled=!1}async function v(e){const{view:t,selectedFeature:r}=e;if(!t||!r)return;const[o,i]=await y(t,r),{extent:n}=await o.queryExtent(i);e.selectedClusterBoundaryFeature.geometry=n,t.graphics.add(e.selectedClusterBoundaryFeature)}async function p(e){const{selectedFeature:t,view:r}=e;if(!r||!t)return;const[o,i]=await y(r,t);a.active=!0,a.disabled=!0;const{features:n}=await o.queryFeatures(i);a.active=!1,a.disabled=!1,a.value=!0;const s={features:[t].concat(n)};"feature"===e?.initialDisplayMode&&(s.featureMenuOpen=!0),e?.open(s)}async function y(e,t){const r=await e.whenLayerView(t.sourceLayer),o=r.createQuery(),i=t.getObjectId();return o.aggregateIds=null!=i?[i]:[],[r,o]}function h(e){a.value=!1;const t=e.features.filter(e=>g(e));t.length&&(e.features=t)}export{p as browseAggregateFeatures,v as displayClusterExtent,d as getSelectedTarget,g as isClusterFeature,w as isZoomScreenSize,h as removeClusteredFeaturesForBrowsing,l as triggerAction,m as zoomToClusterExtent,f as zoomToLocation};
|