@arcgis/core 4.26.0-next.20230213 → 4.26.0-next.20230214
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{4b41a08d603e846306da.js → 1faf0e2aeabe003e2f64.js} +1 -1
- package/assets/esri/core/workers/chunks/8111fc49f8e8f260981d.js +1 -0
- package/assets/esri/core/workers/chunks/979d5e22dbdcec90029f.js +1 -0
- package/assets/esri/core/workers/chunks/9f8aad19c5973e201604.js +1 -0
- package/assets/esri/core/workers/chunks/{21f1d91121d95ef21604.js → bb6e4affafef9855b8fd.js} +1 -1
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
- package/layers/support/rasterFunctions/LocalFunction.js +1 -1
- package/layers/support/rasterFunctions/LocalFunctionArguments.js +1 -1
- package/layers/support/rasterFunctions/localUtils.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItem.js +1 -1
- package/rest/query/executeQuery.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.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/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
- package/views/interactive/snapping/Settings.js +1 -1
- package/views/interactive/snapping/SnappingAlgorithm.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
- package/widgets/FeatureForm/InputField.js +1 -1
- package/assets/esri/core/workers/chunks/52e40e348c27a0e66f9a.js +0 -1
- package/assets/esri/core/workers/chunks/8be68f08c270c62e38bb.js +0 -1
- package/assets/esri/core/workers/chunks/978220022a8c9a3e9261.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.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,destroyMaybe as a}from"../../../core/maybe.js";import{when as o,syncAndInitial as n,watch as h,initial as p,sync as m}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{l as _,c,h as u}from"../../../chunks/vec3.js";import{f as g}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as w}from"../../../geometry/ellipsoidUtils.js";import{isMoon as f,isEarth as y}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as v}from"../../ViewingMode.js";import{AtmosphereType as P}from"./AtmosphereType.js";import{ChapmanAtmosphere as b}from"./ChapmanAtmosphere.js";import{CloudsComposition as R}from"./CloudsComposition.js";import{FadeInStages as x,FadeInOutStages as A}from"./CloudsCompositionParameters.js";import{isReadyCloudsData as W,CloudsRenderingStages as z}from"./CloudsData.js";import{CloudsGenerator as N}from"./CloudsGenerator.js";import{cloudPresets as j}from"./CloudsPresets.js";import{Fog as E,FogParameters as C}from"./Fog.js";import{PanoramicAtmosphere as T}from"./PanoramicAtmosphere.js";import{Precipitation as O}from"./Precipitation.js";import S from"./SimpleAtmosphere.js";import{SimpleHaze as F,HazeParameters as q}from"./SimpleHaze.js";import{Stars as H}from"./Stars.js";import{weatherHeightLimit as I}from"./weather.js";import{updateWeatherFading as M,weatherFadingNeedsRender as L}from"./weatherUtils.js";import{ShaderOutput as U}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderFeature as V}from"../webgl-engine/lib/RenderFeature.js";import{RenderSlot as k}from"../webgl-engine/lib/RenderSlot.js";import{Update as G}from"../webgl-engine/lib/Update.js";var B;const D=[k.POSTPROCESSING_ENVIRONMENT_OPAQUE,k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT];let Q=B=class extends t{constructor(e){super(e),this._context=null,this._atmosphere=null,this._hqAtmosphere=null,this._oldWeatherParameters=new J,this._newWeatherParameters=new J,this._fadedWeatherParameters=new J,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(D,this)}destroy(){this.removeHandles(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return r(this._hqAtmosphere)&&this.view._stage.renderer.isFeatureEnabled(V.RealisticAtmosphere)?this._hqAtmosphere:this._atmosphere}get _atmosphereType(){return r(this.atmosphere)?this.atmosphere.type:P.None}get canRender(){return!!this.view.basemapTerrain?.renderer.canRender||"global"!==this.view.viewingMode}get needsLinearDepth(){return this._atmosphereType===P.Realistic}updateAnimation(e){return!!r(this._precipitation)&&this._precipitation.update(e)}get updating(){return r(this._stars)&&this._stars.updating||r(this._clouds)&&this._clouds.running}get weatherVisible(){return _(this.view.state.camera.eye)-w(this.view.spatialReference).radius<=I}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return!t||i(this._context)?(a(s),null):r(s)?s:new H({view:e,requestRender:()=>this._setNeedsRender()})}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||i(this._context))return a(e),null;const t=this.view,s=this._context;return r(e)&&e.context===s?e:(a(e),new O({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return a(e),new N({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||i(this._context))return a(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,o=w(this.view.spatialReference).radius;return r(e)&&e.viewingMode===t&&e.planetRadius===o?e:(a(e),new R({rctx:s,viewingMode:t,planetRadius:o,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return new E({context:s,view:t})}get _simpleHaze(){const e=this._get("_simpleHaze");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return new F({context:s,view:t})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([o((()=>this.view?.basemapTerrain),(()=>this._updateBasemapTerrain()),n),h((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled,quality:this.view.environment.atmosphere.quality})),(e=>this._updateAtmosphere(e)),n),h((()=>this._stars),t),h((()=>this._precipitation),t),h((()=>this._clouds),(()=>this._updateWeather()),p),h((()=>this._fog),(()=>this._updateFogHaze()),p),h((()=>this._simpleHaze),(()=>this._updateFogHaze()),p),h((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),m),h((()=>this._atmosphereType),(()=>this._updateBasemapTerrain()),n),h((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),n)])}uninitializeRenderContext(){this._context=null,this._atmosphere=a(this._atmosphere),this._hqAtmosphere=a(this._hqAtmosphere),this._set("_stars",a(this._stars)),this._set("_precipitation",a(this._precipitation)),this._set("_clouds",a(this._clouds)),this._set("_cloudsComposition",a(this._cloudsComposition)),this._set("_fog",a(this._fog)),this._set("_simpleHaze",a(this._simpleHaze))}prepareRender(e){e.bindParameters.cloudsFade.data=W(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&(M(e.bindParameters.cloudsFade,e.bindParameters.camera,this.view.state.mode,e.time,this.view.qualitySettings.fadeDuration),this._updateWeatherFading(e.bindParameters),e.bindParameters.cloudsFade.renderingStage===z.FINISHED&&r(this._clouds)&&0===this._clouds.coverage&&!1===this._clouds.running&&this._clouds.destroyFrameBufferCube())}render(e){if(e.output===U.Color)switch(e.bindParameters.slot){case k.POSTPROCESSING_ENVIRONMENT_OPAQUE:r(this._stars)&&this._stars.render(e),r(this.atmosphere)&&(this.atmosphere.render(e),r(this._cloudsComposition)&&r(e.bindParameters.cloudsFade.data)&&(this.weatherVisible&&r(this._clouds)&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),L(e.bindParameters.cloudsFade)&&r(this._context)&&this._context.requestRender());break;case k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(r(this.atmosphere)&&(this.atmosphere.renderHaze(e,this._weatherParameters.haze.amount),this._weatherParameters.haze.amount>0&&this._atmosphereType!==P.Realistic&&r(this._simpleHaze)&&this._simpleHaze.render(e,this._weatherParameters.haze),this._weatherParameters.fog.amount>0&&r(this._fog)&&this._fog.render(e,this._weatherParameters.fog),r(this._precipitation))){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,i){if(r(this._context)){const r=this._context.renderContext;r.bindParameters.oldLighting.copyFrom(r.bindParameters.lighting),r.bindParameters.newLighting.noonFactor=t,r.bindParameters.newLighting.globalFactor=s,r.bindParameters.newLighting.set(e);i===G.Faded||r.bindParameters.weatherFading?r.bindParameters.fadeLighting(0):r.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return i(e)?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e){if(!e.weatherFading)return;const t=e.cloudsFade;return t.fadeIn.stage===x.FADE_IN?(e.fadeLighting(t.fadeIn.factor),void this._fadeWeather(t.fadeIn.factor)):t.fadeInOut.stage===A.FADE_IN?(e.fadeLighting(t.fadeInOut.factor),void this._fadeWeather(t.fadeInOut.factor)):t.crossFade.enabled?(e.fadeLighting(t.crossFade.factor),void this._fadeWeather(t.crossFade.factor)):(e.fadeLighting(0),void this._fadeWeather(0))}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;i(e)||i(this._clouds)||(this._clouds.applyPreset(j[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){r(this._context)&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(i(this._fog)||i(this._simpleHaze)||i(e)||i(this._context))return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),c(this._newWeatherParameters.fog.color,X),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=this._atmosphereType===P.Realistic?1:0,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),c(this._newWeatherParameters.fog.color,K),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),c(this._newWeatherParameters.fog.color,X),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=this._atmosphereType===P.Realistic?1:0,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.haze.strength=4e-6,this._newWeatherParameters.haze.amount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(r(this._atmosphere)?this._atmosphere.type===t:t===P.None)return;this._atmosphere=a(this._atmosphere),this._hqAtmosphere=a(this._hqAtmosphere);const s=this._getAtmosphereClass(t);s&&r(this._context)&&(this._atmosphere=new s(this.view,this._context),t===P.Simple&&(this._hqAtmosphere=new b(this.view,this._context))),this._setNeedsRender(),this._updateBasemapTerrain()}_getAtmosphereClass(e){switch(e){case P.Realistic:return b;case P.Panoramic:return T;case P.Simple:return S;default:case P.None:return null}}_selectAtmosphereType(e){const{enabled:t,quality:s,viewingMode:i}=e;return!t||f(this.view.spatialReference)?P.None:i===v.Local?P.Panoramic:r(this._context)&&"high"===s&&b.isSupported(this._context)&&y(this.view.spatialReference)?P.Realistic:P.Simple}_updateBasemapTerrain(){this.view.basemapTerrain&&(this.view.basemapTerrain.velvetOverground=this._atmosphereType===P.Simple)}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled,quality:this.view.environment.atmosphere.quality}),stubGetAtmosphereClass:e=>{Y=B.prototype._getAtmosphereClass,B.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{B.prototype._getAtmosphereClass=Y}}}};e([d({constructOnly:!0})],Q.prototype,"view",void 0),e([d({readOnly:!0})],Q.prototype,"atmosphere",null),e([d({readOnly:!0})],Q.prototype,"_atmosphereType",null),e([d({type:Boolean,readOnly:!0})],Q.prototype,"updating",null),e([d({readOnly:!0})],Q.prototype,"weatherVisible",null),e([d()],Q.prototype,"_context",void 0),e([d()],Q.prototype,"_atmosphere",void 0),e([d()],Q.prototype,"_hqAtmosphere",void 0),e([d({readOnly:!0})],Q.prototype,"_stars",null),e([d({readOnly:!0})],Q.prototype,"_precipitation",null),e([d({readOnly:!0})],Q.prototype,"_clouds",null),e([d({readOnly:!0})],Q.prototype,"_cloudsComposition",null),e([d({readOnly:!0})],Q.prototype,"_fog",null),e([d({readOnly:!0})],Q.prototype,"_simpleHaze",null),e([d({readOnly:!0})],Q.prototype,"weatherEnabled",null),e([d({readOnly:!0})],Q.prototype,"_precipitationEnabled",null),e([d({readOnly:!0})],Q.prototype,"_weatherUpdateParameters",null),Q=B=e([l("esri.views.3d.environment.EnvironmentRenderer")],Q);class J{constructor(){this.fog=new C,this.haze=new q}copyFrom(e){this.fog.amount=e.fog.amount,this.haze.amount=e.haze.amount,this.fog.strength=e.fog.strength,this.haze.strength=e.haze.strength,c(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.haze.amount=s(e.haze.amount,t.haze.amount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),this.haze.strength=s(e.haze.strength,t.haze.strength,r),u(this.fog.color,e.fog.color,t.fog.color,r)}}const K=g(.5,.5,.5),X=g(1.5,1.5,1.5);let Y;export{Q as EnvironmentRenderer,J as WeatherParameters};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,destroyMaybe as a}from"../../../core/maybe.js";import{when as o,syncAndInitial as n,watch as h,initial as p,sync as m}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{l as _,c,h as u}from"../../../chunks/vec3.js";import{f as g}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as w}from"../../../geometry/ellipsoidUtils.js";import{isMoon as f,isEarth as y}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as v}from"../../ViewingMode.js";import{AtmosphereType as P}from"./AtmosphereType.js";import{ChapmanAtmosphere as b}from"./ChapmanAtmosphere.js";import{CloudsComposition as R}from"./CloudsComposition.js";import{FadeInStages as x,FadeInOutStages as A}from"./CloudsCompositionParameters.js";import{isReadyCloudsData as W,CloudsRenderingStages as z}from"./CloudsData.js";import{CloudsGenerator as N}from"./CloudsGenerator.js";import{cloudPresets as j}from"./CloudsPresets.js";import{Fog as E,FogParameters as C}from"./Fog.js";import{PanoramicAtmosphere as T}from"./PanoramicAtmosphere.js";import{Precipitation as O}from"./Precipitation.js";import F from"./SimpleAtmosphere.js";import{SimpleHaze as S,HazeParameters as q}from"./SimpleHaze.js";import{Stars as H}from"./Stars.js";import{weatherHeightLimit as I}from"./weather.js";import{updateWeatherFading as M,weatherFadingNeedsRender as L}from"./weatherUtils.js";import{ShaderOutput as U}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderFeature as V}from"../webgl-engine/lib/RenderFeature.js";import{RenderSlot as k}from"../webgl-engine/lib/RenderSlot.js";import{Update as G}from"../webgl-engine/lib/Update.js";var B;const D=[k.POSTPROCESSING_ENVIRONMENT_OPAQUE,k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT];let Q=B=class extends t{constructor(e){super(e),this._context=null,this._atmosphere=null,this._hqAtmosphere=null,this._oldWeatherParameters=new J,this._newWeatherParameters=new J,this._fadedWeatherParameters=new J,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(D,this)}destroy(){this.removeHandles(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return r(this._hqAtmosphere)&&this.view._stage.renderer.isFeatureEnabled(V.RealisticAtmosphere)?this._hqAtmosphere:this._atmosphere}get _atmosphereType(){return r(this.atmosphere)?this.atmosphere.type:P.None}get canRender(){return!!this.view.basemapTerrain?.renderer.canRender||"global"!==this.view.viewingMode}get needsLinearDepth(){return this._atmosphereType===P.Realistic}updateAnimation(e){return!!r(this._precipitation)&&this._precipitation.update(e)}get updating(){return r(this._stars)&&this._stars.updating||r(this._clouds)&&this._clouds.running}get weatherVisible(){return _(this.view.state.camera.eye)-w(this.view.spatialReference).radius<=I}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return!t||i(this._context)?(a(s),null):r(s)?s:new H({view:e,requestRender:()=>this._setNeedsRender()})}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||i(this._context))return a(e),null;const t=this.view,s=this._context;return r(e)&&e.context===s?e:(a(e),new O({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return a(e),new N({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||i(this._context))return a(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,o=w(this.view.spatialReference).radius;return r(e)&&e.viewingMode===t&&e.planetRadius===o?e:(a(e),new R({rctx:s,viewingMode:t,planetRadius:o,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return new E({context:s,view:t})}get _simpleHaze(){const e=this._get("_simpleHaze");if(!this.weatherEnabled||i(this._context))return a(e),null;if(r(e))return e;const t=this.view,s=this._context;return new S({context:s,view:t})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([o((()=>this.view?.basemapTerrain),(()=>this._updateBasemapTerrain()),n),h((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled,quality:this.view.environment.atmosphere.quality})),(e=>this._updateAtmosphere(e)),n),h((()=>this._stars),t),h((()=>this._precipitation),t),h((()=>this._clouds),(()=>this._updateWeather()),p),h((()=>this._fog),(()=>this._updateFogHaze()),p),h((()=>this._simpleHaze),(()=>this._updateFogHaze()),p),h((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),m),h((()=>this._atmosphereType),(()=>this._updateBasemapTerrain()),n),h((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),n)])}uninitializeRenderContext(){this._context=null,this._atmosphere=a(this._atmosphere),this._hqAtmosphere=a(this._hqAtmosphere),this._set("_stars",a(this._stars)),this._set("_precipitation",a(this._precipitation)),this._set("_clouds",a(this._clouds)),this._set("_cloudsComposition",a(this._cloudsComposition)),this._set("_fog",a(this._fog)),this._set("_simpleHaze",a(this._simpleHaze))}prepareRender(e){e.bindParameters.cloudsFade.data=W(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&(M(e.bindParameters.cloudsFade,e.bindParameters.camera,this.view.state.mode,e.time,this.view.qualitySettings.fadeDuration),this._updateWeatherFading(e.bindParameters),e.bindParameters.cloudsFade.renderingStage===z.FINISHED&&r(this._clouds)&&0===this._clouds.coverage&&!1===this._clouds.running&&(this._clouds.destroyFrameBufferCube(),e.bindParameters.cloudsFade.data=null))}render(e){if(e.output===U.Color)switch(e.bindParameters.slot){case k.POSTPROCESSING_ENVIRONMENT_OPAQUE:r(this._stars)&&this._stars.render(e),r(this.atmosphere)&&(this.atmosphere.render(e),r(this._cloudsComposition)&&r(e.bindParameters.cloudsFade.data)&&(this.weatherVisible&&r(this._clouds)&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),L(e.bindParameters.cloudsFade)&&r(this._context)&&this._context.requestRender());break;case k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(r(this.atmosphere)&&(this.atmosphere.renderHaze(e,this._weatherParameters.haze.amount),this._weatherParameters.haze.amount>0&&this._atmosphereType!==P.Realistic&&r(this._simpleHaze)&&this._simpleHaze.render(e,this._weatherParameters.haze),this._weatherParameters.fog.amount>0&&r(this._fog)&&this._fog.render(e,this._weatherParameters.fog),r(this._precipitation))){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,i){if(r(this._context)){const r=this._context.renderContext;r.bindParameters.oldLighting.copyFrom(r.bindParameters.lighting),r.bindParameters.newLighting.noonFactor=t,r.bindParameters.newLighting.globalFactor=s,r.bindParameters.newLighting.set(e);i===G.Faded||r.bindParameters.weatherFading?r.bindParameters.fadeLighting(0):r.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return i(e)?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e){if(!e.weatherFading)return;const t=e.cloudsFade;return t.fadeIn.stage===x.FADE_IN?(e.fadeLighting(t.fadeIn.factor),void this._fadeWeather(t.fadeIn.factor)):t.fadeInOut.stage===A.FADE_IN?(e.fadeLighting(t.fadeInOut.factor),void this._fadeWeather(t.fadeInOut.factor)):t.crossFade.enabled?(e.fadeLighting(t.crossFade.factor),void this._fadeWeather(t.crossFade.factor)):(e.fadeLighting(0),void this._fadeWeather(0))}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;i(e)||i(this._clouds)||(this._clouds.applyPreset(j[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){r(this._context)&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(i(this._fog)||i(this._simpleHaze)||i(e)||i(this._context))return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),c(this._newWeatherParameters.fog.color,X),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=this._atmosphereType===P.Realistic?1:0,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),c(this._newWeatherParameters.fog.color,K),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),c(this._newWeatherParameters.fog.color,X),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.haze.strength=0,this._newWeatherParameters.haze.amount=this._atmosphereType===P.Realistic?1:0,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.haze.strength=4e-6,this._newWeatherParameters.haze.amount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(r(this._atmosphere)?this._atmosphere.type===t:t===P.None)return;this._atmosphere=a(this._atmosphere),this._hqAtmosphere=a(this._hqAtmosphere);const s=this._getAtmosphereClass(t);s&&r(this._context)&&(this._atmosphere=new s(this.view,this._context),t===P.Simple&&(this._hqAtmosphere=new b(this.view,this._context))),this._setNeedsRender(),this._updateBasemapTerrain()}_getAtmosphereClass(e){switch(e){case P.Realistic:return b;case P.Panoramic:return T;case P.Simple:return F;default:case P.None:return null}}_selectAtmosphereType(e){const{enabled:t,quality:s,viewingMode:i}=e;return!t||f(this.view.spatialReference)?P.None:i===v.Local?P.Panoramic:r(this._context)&&"high"===s&&b.isSupported(this._context)&&y(this.view.spatialReference)?P.Realistic:P.Simple}_updateBasemapTerrain(){this.view.basemapTerrain&&(this.view.basemapTerrain.velvetOverground=this._atmosphereType===P.Simple)}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled,quality:this.view.environment.atmosphere.quality}),stubGetAtmosphereClass:e=>{Y=B.prototype._getAtmosphereClass,B.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{B.prototype._getAtmosphereClass=Y}}}};e([d({constructOnly:!0})],Q.prototype,"view",void 0),e([d({readOnly:!0})],Q.prototype,"atmosphere",null),e([d({readOnly:!0})],Q.prototype,"_atmosphereType",null),e([d({type:Boolean,readOnly:!0})],Q.prototype,"updating",null),e([d({readOnly:!0})],Q.prototype,"weatherVisible",null),e([d()],Q.prototype,"_context",void 0),e([d()],Q.prototype,"_atmosphere",void 0),e([d()],Q.prototype,"_hqAtmosphere",void 0),e([d({readOnly:!0})],Q.prototype,"_stars",null),e([d({readOnly:!0})],Q.prototype,"_precipitation",null),e([d({readOnly:!0})],Q.prototype,"_clouds",null),e([d({readOnly:!0})],Q.prototype,"_cloudsComposition",null),e([d({readOnly:!0})],Q.prototype,"_fog",null),e([d({readOnly:!0})],Q.prototype,"_simpleHaze",null),e([d({readOnly:!0})],Q.prototype,"weatherEnabled",null),e([d({readOnly:!0})],Q.prototype,"_precipitationEnabled",null),e([d({readOnly:!0})],Q.prototype,"_weatherUpdateParameters",null),Q=B=e([l("esri.views.3d.environment.EnvironmentRenderer")],Q);class J{constructor(){this.fog=new C,this.haze=new q}copyFrom(e){this.fog.amount=e.fog.amount,this.haze.amount=e.haze.amount,this.fog.strength=e.fog.strength,this.haze.strength=e.haze.strength,c(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.haze.amount=s(e.haze.amount,t.haze.amount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),this.haze.strength=s(e.haze.strength,t.haze.strength,r),u(this.fog.color,e.fog.color,t.fog.color,r)}}const K=g(.5,.5,.5),X=g(1.5,1.5,1.5);let Y;export{Q as EnvironmentRenderer,J as WeatherParameters};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../geometry.js";import{neverReached as e}from"../../../core/compilerUtils.js";import t from"../../../core/Evented.js";import{deg2rad as i}from"../../../core/mathUtils.js";import{isSome as s,isNone as o,unwrapOr as n,unwrap as r}from"../../../core/maybe.js";import{createScreenPointArray as a,createRenderScreenPointArray3 as c,screenPointObjectToArray as l,castRenderScreenPointArray as h}from"../../../core/screenUtils.js";import{once as d}from"../../../core/accessorSupport/utils.js";import{f as _}from"../../../chunks/mat3.js";import{c as u}from"../../../chunks/mat3f64.js";import{c as g,s as m,m as f,i as p}from"../../../chunks/mat4.js";import{c as v}from"../../../chunks/mat4f64.js";import{k as b}from"../../../chunks/vec2.js";import{a as y,t as j,m as L,g as S,c as w,d as R,s as O,b as T}from"../../../chunks/vec3.js";import{c as A,Z as E}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as D}from"../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as F,projectPoint as k,sphericalPCPFtoLonLatElevation as z,computeENUToSphericalPCPFLocalRotation as P}from"../../../geometry/projection.js";import{containsPointObject as C}from"../../../geometry/support/aaBoundingRect.js";import{create as I,distance2 as M,fromPoints as x,closestRayDistance2 as U}from"../../../geometry/support/lineSegment.js";import{create as B,fromPositionAndNormal as W,intersectRay as N}from"../../../geometry/support/plane.js";import{create as H}from"../../../geometry/support/ray.js";import{sv3d as V}from"../../../geometry/support/vectorStacks.js";import{clonePoint as G,hydratedSpatialReference as Y}from"../../../layers/graphics/hydratedFeatures.js";import{getElevationAtPoint as Z}from"../support/ElevationProvider.js";import{fromScreen as q}from"../support/geometryUtils/ray.js";import{Camera as J}from"../webgl-engine/lib/Camera.js";import{Object3D as K}from"../webgl-engine/lib/Object3D.js";import{UpdatePolicy as Q}from"../webgl-engine/lib/UpdatePolicy.js";import{WebGLLayer as X}from"../webgl-engine/lib/WebGLLayer.js";import{ManipulatorStateCustomFlags as $,ManipulatorStateFlags as ee}from"../../interactive/interfaces.js";import te from"../../../geometry/Point.js";class ie{constructor(e){this.metadata=void 0,this._camera=new J,this._elevation={offset:0,override:null},this.collisionType={type:"point"},this.collisionPriority=0,this._renderObjects=new Array,this.autoScaleRenderObjects=!0,this._available=!0,this._noDisplayCount=0,this._radius=10,this._worldSized=!1,this.focusMultiplier=2,this.touchMultiplier=2.5,this.worldOriented=!1,this._modelTransform=v(),this._worldFrame=null,this._renderLocation=A(),this._renderLocationDirty=!0,this._location=new te({x:0,y:0,z:0}),this._elevationAlignedLocation=new te,this._elevationAlignedLocationDirty=!0,this.interactive=!0,this.selectable=!1,this.grabbable=!0,this.cursor=null,this.grabCursor=null,this._grabbing=!1,this.dragging=!1,this._hovering=!1,this._selected=!1,this._state=$.None,this._focused=!1,this.events=new t.EventEmitter,this._screenLocation={screenPointArray:a(),renderScreenPointArray:c(),pixelSize:0},this._screenLocationDirty=!0,this._engineResourcesAddedToStage=!1,this._attached=!1,this._location.spatialReference=e.view.spatialReference;for(const t in e)this[t]=e[t];const i=this.view.state?.camera;i&&this._camera.copyFrom(i)}destroy(){this._removeResourcesFromStage(),this._engineResources=null,this.view=null,this._camera=null}get elevationInfo(){return this._elevationInfo}set elevationInfo(e){this._elevationInfo=e,this._elevationAlignedLocationDirty=!0,this._renderLocationDirty=!0,this._updateEngineObject()}get renderObjects(){return this._renderObjects}set renderObjects(e){this._removeResourcesFromStage(),this._engineResources=null,this._renderObjects=e.slice(),this._updateEngineObject()}set available(e){e!==this._available&&(this._available=e,this._updateEngineObject())}get available(){return this._available}disableDisplay(){return this._noDisplayCount++,1===this._noDisplayCount&&this._updateEngineObject(),{remove:d((()=>{this._noDisplayCount--,0===this._noDisplayCount&&this._updateEngineObject()}))}}set radius(e){e!==this._radius&&(this._radius=e,this._updateEngineObject())}get radius(){return this._radius}set worldSized(e){e!==this._worldSized&&(this._worldSized=e,this._updateEngineObject())}get worldSized(){return this._worldSized}get modelTransform(){return this._modelTransform}set modelTransform(e){se(e)&&(this._screenLocationDirty=!0),g(this._modelTransform,e),this._updateEngineObject()}get renderLocation(){return this._renderLocationDirty&&(this._renderLocationDirty=!1,this.view.renderCoordsHelper.toRenderCoords(this.elevationAlignedLocation,this._renderLocation),this.worldOriented?(this._worldFrame||(this._worldFrame=v()),oe(this.view,this._renderLocation,this._worldFrame)):this._worldFrame&&(this._worldFrame=null)),this._renderLocation}set renderLocation(e){this.view.renderCoordsHelper.fromRenderCoords(e,this._location),this.elevationAlignedLocation=this._location}get location(){return this._location}set location(e){G(e,this._location),this._notifyLocationChanged()}_notifyLocationChanged(){this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!0,this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}get elevationAlignedLocation(){return this._elevationAlignedLocationDirty?(this._evaluateElevationAlignment(),this._updateElevationAlignedLocation(),this._elevationAlignedLocation):this._elevationAlignedLocation}set elevationAlignedLocation(e){G(e,this._location),this._evaluateElevationAlignment(),this._location.z-=this._elevation.offset,this._updateElevationAlignedLocation(),this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}_updateElevationAlignedLocation(){const e=s(this._elevation.override)?this._elevation.override:this.location.z||0;this._elevationAlignedLocation.x=this.location.x,this._elevationAlignedLocation.y=this.location.y,this._elevationAlignedLocation.z=e+this._elevation.offset,this._elevationAlignedLocation.spatialReference=Y(this.location.spatialReference),this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!1}grabbableForEvent(){return!0}get grabbing(){return this._grabbing}set grabbing(e){e!==this._grabbing&&(this._grabbing=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get hovering(){return this._hovering}set hovering(e){e!==this._hovering&&(this._hovering=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get selected(){return this._selected}set selected(e){e!==this._selected&&(this._selected=e,this._updateEngineObject(),this.events.emit("select-changed",{action:e?"select":"deselect"}))}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,this._updateEngineObject())}updateStateEnabled(e,t){t?this.state|=e:this.state&=~e}_setFocused(e){e!==this._focused&&(this._focused=e,this.events.emit("focus-changed",{action:!0===e?"focus":"unfocus"}))}get focused(){return this._focused}get screenLocation(){return this._ensureScreenLocation(),this._screenLocation}_ensureScreenLocation(){if(!this._screenLocationDirty)return;this._screenLocation.pixelSize=this._camera.computeScreenPixelSizeAt(this.renderLocation),this._screenLocationDirty=!1;let e;if(se(this._modelTransform)){const t=this._calculateModelTransformOffset(pe);e=y(t,t,this.renderLocation)}else e=this.renderLocation;this._camera.projectToRenderScreen(e,this._screenLocation.renderScreenPointArray),this._camera.renderToScreen(this._screenLocation.renderScreenPointArray,this._screenLocation.screenPointArray)}get applyObjectTransform(){return this._applyObjectTransform}set applyObjectTransform(e){this._applyObjectTransform=e,this._screenLocationDirty=!0,this._updateEngineObject()}get attached(){return this._attached}intersectionDistance(t,i){if(!this.available)return null;const s=l(t,ne),n=this._getCollisionRadius(i),r=-1*this.collisionPriority;switch(this.collisionType.type){case"point":if(b(this.screenLocation.screenPointArray,s)<n*n)return this.screenLocation.renderScreenPointArray[2]+r;break;case"line":{const e=this.collisionType.paths,t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,he),a=n*this.screenLocation.pixelSize,c=q(this._camera,s,ae);if(o(c))return null;for(const s of e){if(0===s.length)continue;const e=L(_e,s[0],i);for(let t=1;t<s.length;t++){const o=L(ue,s[t],i),n=U(x(e,o,re),c);if(null!=n&&n<a*a){const t=y(V.get(),e,o);S(t,t,.5);const i=h(V.get());return this._camera.projectToRenderScreen(t,i),i[2]+r}w(e,o)}}break}case"disc":{const e=this.collisionType.direction,t=this.collisionType.offset??E,i=this._getWorldToScreenObjectScale(),a=this._calculateObjectTransform(i,he),c=n*this.screenLocation.pixelSize,l=q(this._camera,s,ae);if(o(l))return null;const h=_(ce,a),d=j(me,e,h),u=L(fe,t,a);W(u,d,de);const g=ge;if(N(de,l,g)&&R(g,u)<c*c)return this.screenLocation.renderScreenPointArray[2]+r;break}case"ribbon":{const{paths:e,direction:t}=this.collisionType,i=this._getWorldToScreenObjectScale(),a=this._calculateObjectTransform(i,he),c=n*this._camera.computeScreenPixelSizeAt(this.renderLocation),l=q(this._camera,s,ae);if(o(l))return null;const d=_(ce,a),u=j(me,t,d),g=this._calculateModelTransformPosition(fe);W(g,u,de);const m=ge;if(!N(de,l,m))break;for(const s of e){if(0===s.length)continue;const e=L(_e,s[0],a);for(let t=1;t<s.length;t++){const i=L(ue,s[t],a),o=M(x(e,i,re),m);if(null!=o&&o<c*c){const t=y(V.get(),e,i);S(t,t,.5);const s=h(V.get());return this._camera.projectToRenderScreen(t,s),s[2]+r}w(e,i)}}break}default:e(this.collisionType)}return null}attach(e={manipulator3D:{}}){if(!this.view._stage)return;const t=e.manipulator3D;if(o(t.engineLayerId)){const e=new X({pickable:!1,updatePolicy:Q.SYNC});this.view._stage.add(e),t.engineLayerId=e.id,this._engineLayer=e}else this.view._stage?.getObject&&(this._engineLayer=this.view._stage.getObject(t.engineLayerId));t.engineLayerReferences=(t.engineLayerReferences||0)+1,this._materialIdReferences=t.materialIdReferences,o(this._materialIdReferences)&&(this._materialIdReferences=new Map,t.materialIdReferences=this._materialIdReferences),this._camera.copyFrom(this.view.state.camera),this._attached=!0,this._updateEngineObject(),F(this._location.spatialReference,this.view.spatialReference)||(this.location=new te({x:0,y:0,z:0,spatialReference:this.view.spatialReference}))}detach(e={manipulator3D:{}}){const t=e.manipulator3D;t.engineLayerReferences--;const i=0===t.engineLayerReferences;i&&(t.engineLayerId=null),this._removeResourcesFromStage(i),this._engineResources=null,this._engineLayer=null,this._materialIdReferences=null,this._attached=!1}onViewChange(){this._camera.copyFrom(this.view.state.camera),this._screenLocationDirty=!0,this._updateEngineObject()}onElevationChange(e){k(this.location,ve,e.spatialReference)&&C(e.extent,ve)&&this._notifyLocationChanged()}_evaluateElevationAlignment(){if(o(this.elevationInfo))return;let e=null,t=0;const i=n(this.elevationInfo.offset,0);switch(this.elevationInfo.mode){case"on-the-ground":e=n(Z(this.view.elevationProvider,this.location,"ground"),0);break;case"relative-to-ground":t=n(Z(this.view.elevationProvider,this.location,"ground"),0)+i;break;case"relative-to-scene":t=n(Z(this.view.elevationProvider,this.location,"scene"),0)+i;break;case"absolute-height":t=i}return t!==this._elevation.offset||e!==this._elevation.override?(this._elevation.offset=t,void(this._elevation.override=e)):void 0}_updateEngineObject(){if(!this._attached)return;if(!this.available)return void this._removeResourcesFromStage();const e=this._getWorldToScreenObjectScale(),t=he;if(!0===this.autoScaleRenderObjects){const i=this._getFocusedSize(this._radius,this.focused)*e;this._calculateObjectTransform(i,t)}else this._calculateObjectTransform(e,t);const{objectsByState:i}=this._ensureEngineResources(),s=(this.focused?ee.Focused:ee.Unfocused)|(this.selected?ee.Selected:ee.Unselected),o=this._noDisplayCount>0;for(const{stateMask:n,objects:r}of i){if(o){for(const e of r)e.visible=!1;continue}const e=(n&ee.All)!==ee.None,i=(n&$.All)!==$.None,a=!e||(s&n)==(n&ee.All),c=!i||(this.state&n)==(n&$.All);if(a&&c)for(const s of r)s.visible=!0,s.transformation=t;else for(const t of r)t.visible=!1}}_ensureEngineResources(){if(o(this._engineResources)){const e=r(this._engineLayer),t=[],i=new Set;this.renderObjects.forEach((({geometry:{material:e}})=>{i.has(e)||(t.push(e),i.add(e))}));const s=new Map;this._renderObjects.forEach((e=>{const t=new K({castShadow:!1,geometries:[e.geometry]}),i=s.get(e.stateMask)||[];i.push(t),s.set(e.stateMask,i)}));const o=[];s.forEach(((e,t)=>o.push({stateMask:t,objects:e}))),this._engineResources={objectsByState:o,layer:e,materials:t}}return this._addResourcesToStage(),this._engineResources}_addResourcesToStage(){if(this._engineResourcesAddedToStage||o(this._engineResources))return;const{objectsByState:e,layer:t,materials:i}=this._engineResources;i.forEach((e=>{const t=r(this._materialIdReferences),i=t.get(e.id)||0;0===i&&this.view._stage.add(e),t.set(e.id,i+1)})),e.forEach((({objects:e})=>{t.addMany(e),this.view._stage.addMany(e)})),this._engineResourcesAddedToStage=!0}_removeResourcesFromStage(e=!1){if(!this._engineResourcesAddedToStage||o(this._engineResources)||!this.view._stage)return;const{objectsByState:t,layer:i,materials:s}=this._engineResources;t.forEach((({objects:e})=>{i.removeMany(e),this.view._stage.removeMany(e)})),s.forEach((e=>{const t=r(this._materialIdReferences),i=t.get(e.id);1===i?(this.view._stage.remove(e),t.delete(e.id)):t.set(e.id,i-1)})),e&&this.view._stage.remove(i),this._engineResourcesAddedToStage=!1}_getCollisionRadius(e){return this._getFocusedSize(this.radius,!0)*("touch"===e?this.touchMultiplier:1)}_getFocusedSize(e,t){return e*(t?this.focusMultiplier:1)}_getWorldToScreenObjectScale(){return this._worldSized?1:this.screenLocation.pixelSize}_calculateModelTransformPosition(e){const t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,le);return O(e,i[12],i[13],i[14])}_calculateModelTransformOffset(e){const t=this._calculateModelTransformPosition(e);return T(e,t,this.renderLocation)}_calculateObjectTransform(e,t){return m(t,e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1),this._worldFrame&&f(t,t,this._worldFrame),f(t,t,this._modelTransform),t[12]+=this.renderLocation[0],t[13]+=this.renderLocation[1],t[14]+=this.renderLocation[2],t[15]=1,s(this._applyObjectTransform)&&this._applyObjectTransform(t),t}get test(){let e=!1;if(s(this._engineResources))for(const t in this._engineResources.objectsByState){const i=this._engineResources.objectsByState[t];for(const t of i.objects)if(t.visible){e=!0;break}if(e)break}return{areAnyResourcesVisible:e}}}function se(e){return 0!==e[12]||0!==e[13]||0!==e[14]}function oe(e,t,s){switch(e.viewingMode){case"local":return p(s),!0;case"global":{const o=D(e.renderCoordsHelper.spatialReference);return z(t,0,_e,0,o.radius),P(i(_e[0]),i(_e[1]),s),!0}}}const ne=a(),re=I(),ae=H(),ce=u(),le=v(),he=v(),de=B(),_e=A(),ue=A(),ge=A(),me=A(),fe=A(),pe=A(),ve=new te({x:0,y:0,z:0,spatialReference:null});export{ie as Manipulator3D};
|
|
5
|
+
import"../../../geometry.js";import{neverReached as e}from"../../../core/compilerUtils.js";import t from"../../../core/Evented.js";import{deg2rad as i}from"../../../core/mathUtils.js";import{isSome as s,isNone as o,unwrapOr as n,unwrap as r}from"../../../core/maybe.js";import{createScreenPointArray as a,createRenderScreenPointArray3 as c,screenPointObjectToArray as l,castRenderScreenPointArray as h}from"../../../core/screenUtils.js";import{once as d}from"../../../core/accessorSupport/utils.js";import{f as _}from"../../../chunks/mat3.js";import{c as u}from"../../../chunks/mat3f64.js";import{c as g,s as m,m as f,i as p}from"../../../chunks/mat4.js";import{c as b}from"../../../chunks/mat4f64.js";import{k as v}from"../../../chunks/vec2.js";import{a as y,t as j,m as L,g as S,c as R,d as w,s as O,b as T}from"../../../chunks/vec3.js";import{c as A,Z as E}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as D}from"../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as F,projectPoint as k,sphericalPCPFtoLonLatElevation as z,computeENUToSphericalPCPFLocalRotation as P}from"../../../geometry/projection.js";import{containsPointObject as C}from"../../../geometry/support/aaBoundingRect.js";import{create as I,distance2 as M,fromPoints as x,closestRayDistance2 as U}from"../../../geometry/support/lineSegment.js";import{create as B,fromPositionAndNormal as W,intersectRay as N}from"../../../geometry/support/plane.js";import{create as H}from"../../../geometry/support/ray.js";import{sv3d as V}from"../../../geometry/support/vectorStacks.js";import{clonePoint as G,hydratedSpatialReference as Y}from"../../../layers/graphics/hydratedFeatures.js";import{getElevationAtPoint as Z}from"../support/ElevationProvider.js";import{fromScreen as q}from"../support/geometryUtils/ray.js";import{Camera as J}from"../webgl-engine/lib/Camera.js";import{Object3D as K}from"../webgl-engine/lib/Object3D.js";import{UpdatePolicy as Q}from"../webgl-engine/lib/UpdatePolicy.js";import{WebGLLayer as X}from"../webgl-engine/lib/WebGLLayer.js";import{ManipulatorStateCustomFlags as $,ManipulatorStateFlags as ee}from"../../interactive/interfaces.js";import te from"../../../geometry/Point.js";class ie{constructor(e){this.metadata=void 0,this._camera=new J,this._elevation={offset:0,override:null},this.collisionType={type:"point"},this.collisionPriority=0,this._renderObjects=new Array,this.autoScaleRenderObjects=!0,this._available=!0,this._noDisplayCount=0,this._radius=10,this._worldSized=!1,this.focusMultiplier=2,this.touchMultiplier=2.5,this.worldOriented=!1,this._modelTransform=b(),this._worldFrame=null,this._renderLocation=A(),this._renderLocationDirty=!0,this._location=new te({x:0,y:0,z:0}),this._elevationAlignedLocation=new te,this._elevationAlignedLocationDirty=!0,this.interactive=!0,this.selectable=!1,this.grabbable=!0,this.cursor=null,this.grabCursor=null,this._grabbing=!1,this.dragging=!1,this._hovering=!1,this._selected=!1,this._state=$.None,this._focused=!1,this.events=new t.EventEmitter,this._screenLocation={screenPointArray:a(),renderScreenPointArray:c(),pixelSize:0},this._screenLocationDirty=!0,this._engineResourcesAddedToStage=!1,this._attached=!1,this._location.spatialReference=e.view.spatialReference;for(const t in e)this[t]=e[t];const i=this.view.state?.camera;i&&this._camera.copyFrom(i)}destroy(){this._removeResourcesFromStage(),this._engineResources=null,this.view=null,this._camera=null}get _stage(){return this.view?._stage}get elevationInfo(){return this._elevationInfo}set elevationInfo(e){this._elevationInfo=e,this._elevationAlignedLocationDirty=!0,this._renderLocationDirty=!0,this._updateEngineObject()}get renderObjects(){return this._renderObjects}set renderObjects(e){this._removeResourcesFromStage(),this._engineResources=null,this._renderObjects=e.slice(),this._updateEngineObject()}set available(e){e!==this._available&&(this._available=e,this._updateEngineObject())}get available(){return this._available}disableDisplay(){return this._noDisplayCount++,1===this._noDisplayCount&&this._updateEngineObject(),{remove:d((()=>{this._noDisplayCount--,0===this._noDisplayCount&&this._updateEngineObject()}))}}set radius(e){e!==this._radius&&(this._radius=e,this._updateEngineObject())}get radius(){return this._radius}set worldSized(e){e!==this._worldSized&&(this._worldSized=e,this._updateEngineObject())}get worldSized(){return this._worldSized}get modelTransform(){return this._modelTransform}set modelTransform(e){se(e)&&(this._screenLocationDirty=!0),g(this._modelTransform,e),this._updateEngineObject()}get renderLocation(){return this._renderLocationDirty&&(this._renderLocationDirty=!1,this.view.renderCoordsHelper.toRenderCoords(this.elevationAlignedLocation,this._renderLocation),this.worldOriented?(this._worldFrame||(this._worldFrame=b()),oe(this.view,this._renderLocation,this._worldFrame)):this._worldFrame&&(this._worldFrame=null)),this._renderLocation}set renderLocation(e){this.view.renderCoordsHelper.fromRenderCoords(e,this._location),this.elevationAlignedLocation=this._location}get location(){return this._location}set location(e){G(e,this._location),this._notifyLocationChanged()}_notifyLocationChanged(){this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!0,this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}get elevationAlignedLocation(){return this._elevationAlignedLocationDirty?(this._evaluateElevationAlignment(),this._updateElevationAlignedLocation(),this._elevationAlignedLocation):this._elevationAlignedLocation}set elevationAlignedLocation(e){G(e,this._location),this._evaluateElevationAlignment(),this._location.z-=this._elevation.offset,this._updateElevationAlignedLocation(),this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}_updateElevationAlignedLocation(){const e=s(this._elevation.override)?this._elevation.override:this.location.z||0;this._elevationAlignedLocation.x=this.location.x,this._elevationAlignedLocation.y=this.location.y,this._elevationAlignedLocation.z=e+this._elevation.offset,this._elevationAlignedLocation.spatialReference=Y(this.location.spatialReference),this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!1}grabbableForEvent(){return!0}get grabbing(){return this._grabbing}set grabbing(e){e!==this._grabbing&&(this._grabbing=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get hovering(){return this._hovering}set hovering(e){e!==this._hovering&&(this._hovering=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get selected(){return this._selected}set selected(e){e!==this._selected&&(this._selected=e,this._updateEngineObject(),this.events.emit("select-changed",{action:e?"select":"deselect"}))}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,this._updateEngineObject())}updateStateEnabled(e,t){t?this.state|=e:this.state&=~e}_setFocused(e){e!==this._focused&&(this._focused=e,this.events.emit("focus-changed",{action:!0===e?"focus":"unfocus"}))}get focused(){return this._focused}get screenLocation(){return this._ensureScreenLocation(),this._screenLocation}_ensureScreenLocation(){if(!this._screenLocationDirty)return;this._screenLocation.pixelSize=this._camera.computeScreenPixelSizeAt(this.renderLocation),this._screenLocationDirty=!1;let e;if(se(this._modelTransform)){const t=this._calculateModelTransformOffset(pe);e=y(t,t,this.renderLocation)}else e=this.renderLocation;this._camera.projectToRenderScreen(e,this._screenLocation.renderScreenPointArray),this._camera.renderToScreen(this._screenLocation.renderScreenPointArray,this._screenLocation.screenPointArray)}get applyObjectTransform(){return this._applyObjectTransform}set applyObjectTransform(e){this._applyObjectTransform=e,this._screenLocationDirty=!0,this._updateEngineObject()}get attached(){return this._attached}intersectionDistance(t,i){if(!this.available)return null;const s=l(t,ne),n=this._getCollisionRadius(i),r=-1*this.collisionPriority;switch(this.collisionType.type){case"point":if(v(this.screenLocation.screenPointArray,s)<n*n)return this.screenLocation.renderScreenPointArray[2]+r;break;case"line":{const e=this.collisionType.paths,t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,he),a=n*this.screenLocation.pixelSize,c=q(this._camera,s,ae);if(o(c))return null;for(const s of e){if(0===s.length)continue;const e=L(_e,s[0],i);for(let t=1;t<s.length;t++){const o=L(ue,s[t],i),n=U(x(e,o,re),c);if(null!=n&&n<a*a){const t=y(V.get(),e,o);S(t,t,.5);const i=h(V.get());return this._camera.projectToRenderScreen(t,i),i[2]+r}R(e,o)}}break}case"disc":{const e=this.collisionType.direction,t=this.collisionType.offset??E,i=this._getWorldToScreenObjectScale(),a=this._calculateObjectTransform(i,he),c=n*this.screenLocation.pixelSize,l=q(this._camera,s,ae);if(o(l))return null;const h=_(ce,a),d=j(me,e,h),u=L(fe,t,a);W(u,d,de);const g=ge;if(N(de,l,g)&&w(g,u)<c*c)return this.screenLocation.renderScreenPointArray[2]+r;break}case"ribbon":{const{paths:e,direction:t}=this.collisionType,i=this._getWorldToScreenObjectScale(),a=this._calculateObjectTransform(i,he),c=n*this._camera.computeScreenPixelSizeAt(this.renderLocation),l=q(this._camera,s,ae);if(o(l))return null;const d=_(ce,a),u=j(me,t,d),g=this._calculateModelTransformPosition(fe);W(g,u,de);const m=ge;if(!N(de,l,m))break;for(const s of e){if(0===s.length)continue;const e=L(_e,s[0],a);for(let t=1;t<s.length;t++){const i=L(ue,s[t],a),o=M(x(e,i,re),m);if(null!=o&&o<c*c){const t=y(V.get(),e,i);S(t,t,.5);const s=h(V.get());return this._camera.projectToRenderScreen(t,s),s[2]+r}R(e,i)}}break}default:e(this.collisionType)}return null}attach(e={manipulator3D:{}}){const t=this._stage;if(!t)return;const i=e.manipulator3D;if(o(i.engineLayerId)){const e=new X({pickable:!1,updatePolicy:Q.SYNC});t.add(e),i.engineLayerId=e.id,this._engineLayer=e}else t?.getObject&&(this._engineLayer=t.getObject(i.engineLayerId));i.engineLayerReferences=(i.engineLayerReferences||0)+1,this._materialIdReferences=i.materialIdReferences,o(this._materialIdReferences)&&(this._materialIdReferences=new Map,i.materialIdReferences=this._materialIdReferences),this._camera.copyFrom(this.view.state.camera),this._attached=!0,this._updateEngineObject(),F(this._location.spatialReference,this.view.spatialReference)||(this.location=new te({x:0,y:0,z:0,spatialReference:this.view.spatialReference}))}detach(e={manipulator3D:{}}){const t=e.manipulator3D;t.engineLayerReferences--;const i=0===t.engineLayerReferences;i&&(t.engineLayerId=null),this._removeResourcesFromStage(i),this._engineResources=null,this._engineLayer=null,this._materialIdReferences=null,this._attached=!1}onViewChange(){this._camera.copyFrom(this.view.state.camera),this._screenLocationDirty=!0,this._updateEngineObject()}onElevationChange(e){k(this.location,be,e.spatialReference)&&C(e.extent,be)&&this._notifyLocationChanged()}_evaluateElevationAlignment(){if(o(this.elevationInfo))return;let e=null,t=0;const i=n(this.elevationInfo.offset,0);switch(this.elevationInfo.mode){case"on-the-ground":e=n(Z(this.view.elevationProvider,this.location,"ground"),0);break;case"relative-to-ground":t=n(Z(this.view.elevationProvider,this.location,"ground"),0)+i;break;case"relative-to-scene":t=n(Z(this.view.elevationProvider,this.location,"scene"),0)+i;break;case"absolute-height":t=i}return t!==this._elevation.offset||e!==this._elevation.override?(this._elevation.offset=t,void(this._elevation.override=e)):void 0}_updateEngineObject(){if(!this._attached)return;if(!this.available)return void this._removeResourcesFromStage();const e=this._getWorldToScreenObjectScale(),t=he;if(!0===this.autoScaleRenderObjects){const i=this._getFocusedSize(this._radius,this.focused)*e;this._calculateObjectTransform(i,t)}else this._calculateObjectTransform(e,t);const{objectsByState:i}=this._ensureEngineResources(),s=(this.focused?ee.Focused:ee.Unfocused)|(this.selected?ee.Selected:ee.Unselected),o=this._noDisplayCount>0;for(const{stateMask:n,objects:r}of i){if(o){for(const e of r)e.visible=!1;continue}const e=(n&ee.All)!==ee.None,i=(n&$.All)!==$.None,a=!e||(s&n)==(n&ee.All),c=!i||(this.state&n)==(n&$.All);if(a&&c)for(const s of r)s.visible=!0,s.transformation=t;else for(const t of r)t.visible=!1}}_ensureEngineResources(){if(o(this._engineResources)){const e=r(this._engineLayer),t=[],i=new Set;this.renderObjects.forEach((({geometry:{material:e}})=>{i.has(e)||(t.push(e),i.add(e))}));const s=new Map;this._renderObjects.forEach((e=>{const t=new K({castShadow:!1,geometries:[e.geometry]}),i=s.get(e.stateMask)||[];i.push(t),s.set(e.stateMask,i)}));const o=[];s.forEach(((e,t)=>o.push({stateMask:t,objects:e}))),this._engineResources={objectsByState:o,layer:e,materials:t}}return this._addResourcesToStage(),this._engineResources}_addResourcesToStage(){const e=this._stage;if(this._engineResourcesAddedToStage||o(this._engineResources)||!e)return;const{objectsByState:t,layer:i,materials:s}=this._engineResources;s.forEach((t=>{const i=r(this._materialIdReferences),s=i.get(t.id)||0;0===s&&e.add(t),i.set(t.id,s+1)})),t.forEach((({objects:t})=>{i.addMany(t),e.addMany(t)})),this._engineResourcesAddedToStage=!0}_removeResourcesFromStage(e=!1){const t=this._stage;if(!this._engineResourcesAddedToStage||o(this._engineResources)||!t)return;const{objectsByState:i,layer:s,materials:n}=this._engineResources;i.forEach((({objects:e})=>{s.removeMany(e),t.removeMany(e)})),n.forEach((e=>{const i=r(this._materialIdReferences),s=i.get(e.id);1===s?(t.remove(e),i.delete(e.id)):i.set(e.id,s-1)})),e&&t.remove(s),this._engineResourcesAddedToStage=!1}_getCollisionRadius(e){return this._getFocusedSize(this.radius,!0)*("touch"===e?this.touchMultiplier:1)}_getFocusedSize(e,t){return e*(t?this.focusMultiplier:1)}_getWorldToScreenObjectScale(){return this._worldSized?1:this.screenLocation.pixelSize}_calculateModelTransformPosition(e){const t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,le);return O(e,i[12],i[13],i[14])}_calculateModelTransformOffset(e){const t=this._calculateModelTransformPosition(e);return T(e,t,this.renderLocation)}_calculateObjectTransform(e,t){return m(t,e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1),this._worldFrame&&f(t,t,this._worldFrame),f(t,t,this._modelTransform),t[12]+=this.renderLocation[0],t[13]+=this.renderLocation[1],t[14]+=this.renderLocation[2],t[15]=1,s(this._applyObjectTransform)&&this._applyObjectTransform(t),t}get test(){let e=!1;if(s(this._engineResources))for(const t in this._engineResources.objectsByState){const i=this._engineResources.objectsByState[t];for(const t of i.objects)if(t.visible){e=!0;break}if(e)break}return{areAnyResourcesVisible:e}}}function se(e){return 0!==e[12]||0!==e[13]||0!==e[14]}function oe(e,t,s){switch(e.viewingMode){case"local":return p(s),!0;case"global":{const o=D(e.renderCoordsHelper.spatialReference);return z(t,0,_e,0,o.radius),P(i(_e[0]),i(_e[1]),s),!0}}}const ne=a(),re=I(),ae=H(),ce=u(),le=b(),he=b(),de=B(),_e=A(),ue=A(),ge=A(),me=A(),fe=A(),pe=A(),be=new te({x:0,y:0,z:0,spatialReference:null});export{ie as Manipulator3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Color.js";import"../../../core/has.js";import{destroyHandle as n}from"../../../core/handleUtils.js";import{isNone as i,isSome as t,unwrap as r}from"../../../core/maybe.js";import{h as a}from"../../../chunks/vec3.js";import{c as o}from"../../../chunks/vec3f64.js";import{projectVectorToVector as s}from"../../../geometry/projection.js";import{onTheGroundElevationInfo as l,absoluteHeightElevationInfo as p}from"../../../support/elevationInfoUtils.js";import{ExtendedLineVisualElement as d,ExtensionType as c}from"./visualElements/ExtendedLineVisualElement.js";import{ParallelLineVisualElement as m}from"./visualElements/ParallelLineVisualElement.js";import{PointVisualElement as g}from"./visualElements/PointVisualElement.js";import{RightAngleQuadVisualElement as u}from"./visualElements/RightAngleQuadVisualElement.js";import{DrapedRenderGroup as f}from"../layers/interfaces.js";import{RenderOccludedFlag as h}from"../webgl-engine/lib/Material.js";import{defaults as v}from"../../interactive/snapping/Settings.js";import{SnappingDomain as E}from"../../interactive/snapping/SnappingDomain.js";import{snappingPointToDehydratedPoint as S,createSnappingPoint as R}from"../../interactive/snapping/SnappingPoint.js";import{LineSegmentHintType as j}from"../../interactive/snapping/snappingUtils.js";import{SnappingVisualizer as w}from"../../interactive/snapping/SnappingVisualizer.js";import{LineSnappingHint as _}from"../../interactive/snapping/hints/LineSnappingHint.js";import{vectorToRender as H}from"../../interactive/support/viewUtils.js";class x extends w{sortUniqueHints(e){return e.sort(((e,n)=>(n instanceof _?n.length:0)-(e instanceof _?e.length:0)))}visualizeIntersectionPoint(i,t){const{spatialReference:r,view:a}=t;return n(new g({view:a,primitive:"circle",geometry:S(i.intersectionPoint,r),elevationInfo:i.isDraped?l:p,size:20,outlineSize:2,color:[0,0,0,0],outlineColor:e.toUnitRGBA(v.orange),pixelSnappingEnabled:!1}))}visualizePoint(i,t){const{view:r,spatialReference:a}=t,o=this._alignPoint(i.point,i.domain,t);return n(new g({view:r,primitive:"circle",geometry:S(o,a),elevationInfo:this._hintElevationInfo(i,t),size:20,outlineSize:2,color:[0,0,0,0],outlineColor:e.toUnitRGBA(v.orange),pixelSnappingEnabled:!1}))}visualizeLine(e,i){const{view:t,spatialReference:r}=i,a=this._alignPoint(e.lineStart,e.domain,i),o=this._alignPoint(e.lineEnd,e.domain,i);return n(this._createLineSegmentHint(e.type,a,o,r,this._hintElevationInfo(e,i),t,e.isDraped,e.fadeLeft,e.fadeRight))}visualizeParallelSign(i,t){const{view:r,spatialReference:o}=t,{isDraped:s}=i,l=this._hintElevationInfo(i,t),p=this._alignPoint(i.lineStart,i.domain,t),d=this._alignPoint(i.lineEnd,i.domain,t),c=
|
|
5
|
+
import e from"../../../Color.js";import"../../../core/has.js";import{destroyHandle as n}from"../../../core/handleUtils.js";import{isNone as i,isSome as t,unwrap as r}from"../../../core/maybe.js";import{h as a}from"../../../chunks/vec3.js";import{c as o}from"../../../chunks/vec3f64.js";import{projectVectorToVector as s}from"../../../geometry/projection.js";import{onTheGroundElevationInfo as l,absoluteHeightElevationInfo as p}from"../../../support/elevationInfoUtils.js";import{ExtendedLineVisualElement as d,ExtensionType as c}from"./visualElements/ExtendedLineVisualElement.js";import{ParallelLineVisualElement as m}from"./visualElements/ParallelLineVisualElement.js";import{PointVisualElement as g}from"./visualElements/PointVisualElement.js";import{RightAngleQuadVisualElement as u}from"./visualElements/RightAngleQuadVisualElement.js";import{DrapedRenderGroup as f}from"../layers/interfaces.js";import{RenderOccludedFlag as h}from"../webgl-engine/lib/Material.js";import{defaults as v}from"../../interactive/snapping/Settings.js";import{SnappingDomain as E}from"../../interactive/snapping/SnappingDomain.js";import{snappingPointToDehydratedPoint as S,createSnappingPoint as R}from"../../interactive/snapping/SnappingPoint.js";import{LineSegmentHintType as j}from"../../interactive/snapping/snappingUtils.js";import{SnappingVisualizer as w}from"../../interactive/snapping/SnappingVisualizer.js";import{LineSnappingHint as _}from"../../interactive/snapping/hints/LineSnappingHint.js";import{vectorToRender as H}from"../../interactive/support/viewUtils.js";class x extends w{sortUniqueHints(e){return e.sort(((e,n)=>(n instanceof _?n.length:0)-(e instanceof _?e.length:0)))}visualizeIntersectionPoint(i,t){const{spatialReference:r,view:a}=t;return n(new g({view:a,primitive:"circle",geometry:S(i.intersectionPoint,r),elevationInfo:i.isDraped?l:p,size:20,outlineSize:2,color:[0,0,0,0],outlineColor:e.toUnitRGBA(v.orange),pixelSnappingEnabled:!1}))}visualizePoint(i,t){const{view:r,spatialReference:a}=t,o=this._alignPoint(i.point,i.domain,t);return n(new g({view:r,primitive:"circle",geometry:S(o,a),elevationInfo:this._hintElevationInfo(i,t),size:20,outlineSize:2,color:[0,0,0,0],outlineColor:e.toUnitRGBA(v.orange),pixelSnappingEnabled:!1}))}visualizeLine(e,i){const{view:t,spatialReference:r}=i,a=this._alignPoint(e.lineStart,e.domain,i),o=this._alignPoint(e.lineEnd,e.domain,i);return n(this._createLineSegmentHint(e.type,a,o,r,this._hintElevationInfo(e,i),t,e.isDraped,e.fadeLeft,e.fadeRight))}visualizeParallelSign(i,t){const{view:r,spatialReference:o}=t,{isDraped:s}=i,l=this._hintElevationInfo(i,t),p=this._alignPoint(i.lineStart,i.domain,t),d=this._alignPoint(i.lineEnd,i.domain,t),c=A(p,o,l,r,s),g=A(d,o,l,r,s),u=a(g,c,g,.5),E=new m({view:r,attached:!1,offset:v.parallelLineHintOffset,length:v.parallelLineHintLength,width:v.parallelLineHintWidth,color:e.toUnitRGBA(v.orange),location:u,renderOccluded:s?h.OccludeAndTransparent:h.Opaque,isDraped:s,renderGroup:f.SnappingHint});return E.setDirectionFromPoints(c,u),E.attached=!0,n(E)}visualizeRightAngleQuad(i,t){const{view:r,spatialReference:a}=t,o=this._hintElevationInfo(i,t),{isDraped:s}=i,l=this._alignPoint(i.previousVertex,i.domain,t),p=this._alignPoint(i.centerVertex,i.domain,t),d=this._alignPoint(i.nextVertex,i.domain,t),c=A(l,a,o,r,s),m=A(p,a,o,r,s),g=A(d,a,o,r,s);return n(new u({view:r,attached:!0,color:s?e.toUnitRGBA(v.orangeTransparent):e.toUnitRGBA(v.orange),renderOccluded:s?h.OccludeAndTransparent:h.Transparent,outlineRenderOccluded:s?h.OccludeAndTransparent:h.Opaque,outlineColor:e.toUnitRGBA(v.orange),outlineSize:v.rightAngleHintOutlineSize,size:v.rightAngleHintSize,isDraped:s,geometry:{previous:c,center:m,next:g},renderGroup:f.SnappingHint}))}_createLineSegmentHint(n,i,t,r,a,o,s=!1,l=!0,p=!0){const m=A(i,r,a,o,s),g=A(t,r,a,o,s),u=new d({view:o,extensionType:c.FADED,start:m,end:g,isDraped:s,color:e.toUnitRGBA(v.orange),renderOccluded:s?h.OccludeAndTransparent:h.Opaque,renderGroup:f.SnappingHint});switch(n){case j.TARGET:u.width=v.lineHintWidthTarget,u.fadedExtensions={start:0,end:v.lineHintFadedExtensions};break;case j.REFERENCE_EXTENSION:u.width=v.lineHintWidthReference,u.fadedExtensions={start:0,end:0};break;case j.REFERENCE:u.width=v.lineHintWidthReference,u.fadedExtensions={start:l?v.lineHintFadedExtensions:0,end:p?v.lineHintFadedExtensions:0}}return u.attached=!0,u}_alignPoint(e,n,t){const r=this._getSelfSnappingZ(n,t);return i(r)?e:R(e[0],e[1],r)}_hintElevationInfo(e,n){return t(this._getSelfSnappingZ(e.domain,n))?r(n.selfSnappingZ).elevationInfo:e.isDraped?l:p}_getSelfSnappingZ(e,{selfSnappingZ:n}){return e===E.SELF&&t(n)?n.value:null}}function A(e,n,i,t,r,a=o()){if(r){const i=t.basemapTerrain.overlayManager.renderer.spatialReference;s(e,n,a,i)}else H(e,n,i,t,a);return a}export{x as SnappingVisualizer3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../../Color.js";import a from"../../../../../core/Evented.js";import r from"../../../../../core/Handles.js";import{handlesGroup as e}from"../../../../../core/handleUtils.js";import{destroyMaybe as i,unwrap as o,isNone as s}from"../../../../../core/maybe.js";import{f as n,b as l,m as p,d as u,E as h}from"../../../../../chunks/mat4.js";import{c as m}from"../../../../../chunks/mat4f64.js";import{s as c}from"../../../../../chunks/vec3.js";import{f}from"../../../../../chunks/vec3f64.js";import{sv3d as d,sm4d as _}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as g}from"../../../../../support/elevationInfoUtils.js";import{Manipulator3D as M}from"../../Manipulator3D.js";import{RenderObject as w}from"../../RenderObject.js";import{screenToMapXYAtLocation as j}from"../dragEventPipeline3D.js";import{ManipulatorType as v}from"../ManipulatorType.js";import{colors as A}from"../settings.js";import{DISC_RADIUS as b,DISC_TRANSLATE_ARROW_OFFSET as y,DISC_HEIGHT as I,DISC_TRANSLATE_ARROW_SIZE as T}from"./config.js";import{Manipulation as D}from"./Manipulation.js";import{createGraphicMoveDragPipeline as E}from"./moveUtils.js";import{CullFaceOptions as S}from"../../../webgl-engine/lib/basicInterfaces.js";import{createExtrudedTriangle as x,transformInPlace as P}from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as k}from"../../../webgl-engine/lib/Material.js";import{ColorMaterial as R}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as U,dragAtLocation as O,constrainToMapAxis as L,addScreenDelta as q}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as G}from"../../../../interactive/interfaces.js";class B extends D{constructor(t){super(),this._handles=new r,this._arrowManipulatorInfos=new Array,this._opaqueMaterial=this._createMaterial(),this._transparentMaterial=this._createMaterial(.5),this._angle=0,this._scale=1,this._radius=b,this._updateAfterDrag=!1,this.events=new a,this._tool=t.tool,this._view=t.view,null!=t.radius&&(this._radius=t.radius),this._createManipulators(),this.forEachManipulator((t=>this._tool.manipulators.add(t)))}set orthogonalAvailable(t){this._arrowManipulatorInfos[1].manipulator.available=t,this._arrowManipulatorInfos[3].manipulator.available=t}destroy(){this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()})),this.
|
|
5
|
+
import t from"../../../../../Color.js";import a from"../../../../../core/Evented.js";import r from"../../../../../core/Handles.js";import{handlesGroup as e}from"../../../../../core/handleUtils.js";import{destroyMaybe as i,unwrap as o,isNone as s}from"../../../../../core/maybe.js";import{f as n,b as l,m as p,d as u,E as h}from"../../../../../chunks/mat4.js";import{c as m}from"../../../../../chunks/mat4f64.js";import{s as c}from"../../../../../chunks/vec3.js";import{f}from"../../../../../chunks/vec3f64.js";import{sv3d as d,sm4d as _}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as g}from"../../../../../support/elevationInfoUtils.js";import{Manipulator3D as M}from"../../Manipulator3D.js";import{RenderObject as w}from"../../RenderObject.js";import{screenToMapXYAtLocation as j}from"../dragEventPipeline3D.js";import{ManipulatorType as v}from"../ManipulatorType.js";import{colors as A}from"../settings.js";import{DISC_RADIUS as b,DISC_TRANSLATE_ARROW_OFFSET as y,DISC_HEIGHT as I,DISC_TRANSLATE_ARROW_SIZE as T}from"./config.js";import{Manipulation as D}from"./Manipulation.js";import{createGraphicMoveDragPipeline as E}from"./moveUtils.js";import{CullFaceOptions as S}from"../../../webgl-engine/lib/basicInterfaces.js";import{createExtrudedTriangle as x,transformInPlace as P}from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as k}from"../../../webgl-engine/lib/Material.js";import{ColorMaterial as R}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as U,dragAtLocation as O,constrainToMapAxis as L,addScreenDelta as q}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as G}from"../../../../interactive/interfaces.js";class B extends D{constructor(t){super(),this._handles=new r,this._arrowManipulatorInfos=new Array,this._opaqueMaterial=this._createMaterial(),this._transparentMaterial=this._createMaterial(.5),this._angle=0,this._scale=1,this._radius=b,this._updateAfterDrag=!1,this.events=new a,this._tool=t.tool,this._view=t.view,null!=t.radius&&(this._radius=t.radius),this._createManipulators(),this.forEachManipulator((t=>this._tool.manipulators.add(t)))}set orthogonalAvailable(t){this._arrowManipulatorInfos[1].manipulator.available=t,this._arrowManipulatorInfos[3].manipulator.available=t}destroy(){this._handles=i(this._handles),this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()})),this._tool=null,this._view=null,this._arrowManipulatorInfos.length=0}forEachManipulator(t){for(const{manipulator:a}of this._arrowManipulatorInfos)t(a,v.TRANSLATE_XY)}createGraphicDragPipeline(t,a,r){const e=a.graphic,i=g(e),s=o(e.geometry).spatialReference;return E(a,r,(a=>this.createDragPipeline(((r,e,i,o,s)=>(({steps:e,cancel:i}=t(r,e,i,o,s)),a(r,e,i))),i,s,e)),this._view.state.viewingMode)}createDragPipeline(t,a,r,i){return e(this._arrowManipulatorInfos.map((({manipulator:e},o)=>U(e,((e,s,n,l,p)=>{const u=s.next((t=>({...t,manipulatorType:v.TRANSLATE_XY}))).next(O(this._view,e.elevationAlignedLocation)).next(j(this._view,e.elevationAlignedLocation,a,r,i)).next(L(e.location,this.angle+(o+1)*Math.PI*.5)).next(q());t(e,u,n,l,p)})))))}get angle(){return this._angle}set angle(t){this._angle=t,this.dragging?this._updateAfterDrag=!0:this._updateManipulatorTransform()}get displayScale(){return this._scale}set displayScale(t){this._scale=t,this._updateManipulatorTransform()}get radius(){return this._radius}set radius(t){this._radius!==t&&(this._radius=t,this._updateManipulators())}_updateManipulators(){for(let t=0;t<this._arrowManipulatorInfos.length;t++)this._updateArrowManipulator(this._arrowManipulatorInfos[t],t);this._updateManipulatorTransform()}_updateArrowManipulator({manipulator:t,transform:a},r){const e=this._radius/b,i=T*e,o=i*Math.sqrt(3)/2,s=x(this._opaqueMaterial,o,i/2,i/2,I);P(s,n(_.get(),c(d.get(),0,-o/3,0))),t.renderObjects=[new w(s,G.Focused),new w(s.instantiate({material:this._transparentMaterial}),G.Unfocused)],t.radius=o/3*2*1.2;const u=l(_.get(),r*Math.PI/2),h=n(_.get(),c(d.get(),0,y*e,0));p(a,u,h)}_createManipulators(){for(let t=0;t<4;t++){const a=this._createArrowManipulator(t);this._arrowManipulatorInfos.push(a)}this._updateManipulatorTransform()}_updateManipulatorTransform(){const t=this.angle,a=u(_.get(),t,f(0,0,1));if(s(a))return;const r=h(_.get(),c(d.get(),this.displayScale,this.displayScale,this.displayScale)),e=p(_.get(),r,a);for(const i of this._arrowManipulatorInfos){const t=p(_.get(),e,i.transform);i.manipulator.modelTransform=t}}_createArrowManipulator(t){const a=new M({view:this._view,autoScaleRenderObjects:!1,worldOriented:!0,focusMultiplier:1,touchMultiplier:1,collisionType:{type:"disc",direction:f(0,0,1)}}),r={manipulator:a,transform:m()};return this._updateArrowManipulator(r,t),this._handles.add(a.events.on("drag",(t=>{this._updateAfterDrag&&"end"===t.action&&!this.dragging&&(this._updateManipulatorTransform(),this._updateAfterDrag=!1)}))),r}_createMaterial(a=1){const r=t.toUnitRGBA(A.main);return r[3]*=a,new R({color:r,transparent:1!==a,cullFace:S.Back,renderOccluded:k.Transparent})}get test(){return{arrowManipulators:this._arrowManipulatorInfos.map((({manipulator:t})=>t))}}}export{B as MoveXYAxisManipulation};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import{removeUnordered as t}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import i from"../../../../../core/Evented.js";import{HandleOwner as a}from"../../../../../core/HandleOwner.js";import o from"../../../../../core/Handles.js";import{handlesGroup as n,destroyHandle as r}from"../../../../../core/handleUtils.js";import{destroyMaybe as s,isSome as l,isNone as p,unwrap as h,removeMaybe as d}from"../../../../../core/maybe.js";import{zeroMeters as u,scale as c,createLength as m}from"../../../../../core/quantityUtils.js";import{watch as g,when as _,initial as f}from"../../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../../../core/unitUtils.js";import{property as M}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../../../core/accessorSupport/decorators/subclass.js";import{I as x}from"../../../../../chunks/mat4f64.js";import{l as O,b,h as E,s as G,a as S,g as w}from"../../../../../chunks/vec3.js";import{f as V,c as I}from"../../../../../chunks/vec3f64.js";import T from"../../../../../geometry/Polyline.js";import{hasCompatibleTopology as A}from"../../../../../geometry/support/coordsUtils.js";import{projectPoint as H}from"../../../../../geometry/support/plane.js";import{sv3d as D}from"../../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as L}from"../../../../../layers/graphics/dehydratedFeatures.js";import{getGraphicEffectiveElevationInfo as j}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as P}from"../../../../../symbols/support/utils.js";import{Manipulator3D as U}from"../../Manipulator3D.js";import{createManipulatorMaterial as N,createManipulatorOutlineMaterial as C,placeAtGraphic as R}from"../../manipulatorUtils.js";import{RenderObject as k}from"../../RenderObject.js";import{SegmentLabels3D as F}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as z}from"../../SnappingVisualizer3D.js";import{screenToRenderPlaneFromEvent as X,convertToMapCoordinates as Z,screenToMapXYAtLocation as Y,screenToMapXYForGraphicAtLocation as q}from"../dragEventPipeline3D.js";import{ManipulatorType as W}from"../ManipulatorType.js";import{canMoveZ as K}from"../manipulatorUtils.js";import{settings as B,colors as J}from"../settings.js";import{createVisualElements as Q}from"../visualElementUtils.js";import{DISC_RADIUS_SMALL as $}from"../manipulations/config.js";import{ManipulationType as ee,MoveManipulation as te}from"../manipulations/MoveManipulation.js";import{shapeOrientation as ie,axisConstrainedDragSign as ae}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as oe}from"../manipulations/MoveXYGraphicManipulation.js";import{createEdgeOffsetIntersectionPlane as ne,createEdgeOffsetOperation as re,edgeOffsetRotationMatrix as se,screenEdgeLengthSquared as le}from"./edgeOffsetUtils.js";import{OutlineVisualElement as pe}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as he}from"../../../layers/graphics/GraphicState.js";import{createExtrudedTriangle as de,createSphereGeometry as ue}from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as ce}from"../../../../input/IViewEvents.js";import{sceneSnappingAtLocation as me,addMapDelta as ge,createManipulatorDragEventPipeline as _e,dragAtLocation as fe,addScreenDelta as ve}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as Me,ManipulatorStateCustomFlags as ye}from"../../../../interactive/interfaces.js";import{EditGeometryOperations as xe}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as Oe}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as be}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as Ee}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{ReshapeEdgeOffsetTooltipInfo as Ge}from"../../../../interactive/tooltip/ReshapeTooltipInfos.js";import{Tooltip as Se}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicZTooltipInfo as we,TranslateGraphicXYTooltipInfo as Ve,TranslateGraphicTooltipInfo as Ie,TranslateVertexZTooltipInfo as Te,TranslateVertexXYTooltipInfo as Ae,TranslateVertexTooltipInfo as He}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoAreaByElevationMode as De}from"../../../../support/automaticAreaMeasurementUtils.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as Le,autoLengthByElevationMode as je}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as Pe,elevationOfPoint as Ue}from"../../../../support/euclideanLengthMeasurementUtils.js";import{geodesicDistance as Ne}from"../../../../support/geodesicLengthMeasurementUtils.js";import Ce from"../../../../../geometry/SpatialReference.js";let Re=class extends(i.EventedMixin(a)){constructor(e){super(e),this._vertexManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.vertex.color),B.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.vertex.outlineColor),B.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.vertex.hoverOutlineColor),B.reshapeManipulators.vertex.renderOccluded),this._edgeManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.edge.color),B.reshapeManipulators.edge.renderOccluded),this._edgeManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.edge.outlineColor),B.reshapeManipulators.edge.renderOccluded),this._edgeOffsetManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.edgeOffset.color),B.reshapeManipulators.edgeOffset.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=N(B.colorToVec4(B.reshapeManipulators.edgeOffset.hoverColor),B.reshapeManipulators.edgeOffset.renderOccluded,!1),this._selectedManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.selected.color),B.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.selected.outlineColor),B.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.selected.hoverOutlineColor),B.reshapeManipulators.selected.renderOccluded),this._selectedIndex=0,this._manipulatorHandles=new o,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=qe.NONE,this._removingManipulators=!1,this.outputGeometry=null,this._vertexLaserLineVisualElement=null}initialize(){const{graphic:e,view:t}=this,i=this._graphicState=new he({graphic:e});this._tooltip=new Se({view:t}),this.addHandles([g((()=>i.displaying),(e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e})),g((()=>({labels:this._segmentLabels,enabled:this._labelOptions.enabled,edgeOffsetEnabled:this.enableEdgeOffset})),(({labels:e,enabled:t,edgeOffsetEnabled:i})=>{l(e)&&(e.visible=t,e.edgeDistance=i?"far":"default")}),f),_((()=>!this._tooltipOptions.enabled),(()=>this._tooltip.clear()),f),this.view.trackGraphicState(i)])}destroy(){this._segmentLabels=s(this._segmentLabels),this._tooltip=s(this._tooltip),this._removeManipulators()}get inputGeometry(){return l(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null}set inputGeometry(e){this._recreateEditGeometryAndManipulators(e)}get updating(){return this.updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get graphic(){return this.tool.graphic}get enableZShape(){return this.tool.enableZShape}get enableZVertex(){return this.tool.enableZVertex}get enableMoveGraphic(){return this.tool.enableMoveGraphic}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _labelOptions(){return this.tool.labelOptions}get _tooltipOptions(){return this.tool.tooltipOptions}removeSelectedVertices(){const e=this._manipulatorInfos.filter((e=>e.manipulator.selected&&"vertex"===e.type));this._removeVertices(e)}onManipulatorSelectionChanged(){this.emit("manipulators-changed")}_removeManipulators(){this._removingManipulators=!0,this._manipulatorHandles.removeAll(),this._moveManipulation=s(this._moveManipulation),this._graphicMoveManipulation=s(this._graphicMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._removingManipulators=!1}_createManipulators(e){if(p(this._editGeometryOperations))return;const t=j(this.graphic);for(const i of this._editGeometryOperations.data.components){const a=e?.byComponentIndex.get(i.index);for(const e of i.vertices){const i=a?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of i.edges)this._createVertexOrEdgeManipulator(e,t)}this._createGraphicMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}get canRedo(){return l(this._editGeometryOperations)&&this._editGeometryOperations.canRedo}get canUndo(){return l(this._editGeometryOperations)&&this._editGeometryOperations.canUndo}redo(){if(p(this._editGeometryOperations))return null;const e=this._editGeometryOperations.redo();return l(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}undo(){if(p(this._editGeometryOperations))return null;this.emit("undo");const e=this._editGeometryOperations.undo();return l(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}_recreateManipulators(){this._removeManipulators(),this._tooltip.clear(),this._createManipulators()}_recreateEditGeometryAndManipulators(e){const t={byComponentIndex:new Map};if(l(e)&&l(this.inputGeometry)&&A(e,this.inputGeometry))for(const i of this._manipulatorInfos)if("vertex"===i.type&&i.manipulator.selected){const{index:e,component:{index:a}}=i.handle,{byComponentIndex:o}=t,n=o.get(a)||new Set;n.add(e),o.set(a,n)}this._removeManipulators(),this._tooltip.clear(),this._editGeometryOperations=s(this._editGeometryOperations),this._segmentLabels=s(this._segmentLabels),p(e)||(this._editGeometryOperations=xe.fromGeometry(e,this.view.state.viewingMode),this._createManipulators(t),this._segmentLabels=new F({context:{view:this.view,editGeometryOperations:this._editGeometryOperations,elevationInfo:j(this.graphic),labelOptions:this._labelOptions,graphic:this.graphic,graphicState:this._graphicState},visible:this._labelOptions.enabled}))}_perGraphicManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],o=this._manipulatorInfos.some((e=>"vertex"===e.type&&e.manipulator.selected)),n=e===We.SELECTED_OR_ALL&&o;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.grabbing||n&&!r.manipulator.selected||a.push(r),i++);if(0===a.length)return t;this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(qe.MOVING),this.destroyed)return t;this.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,mover:this.graphic})}else{if(this._updateEventState(qe.RESHAPING),this.destroyed)return t;this.emit("reshape",{type:"reshape",mover:this.graphic})}return t}_isMultiVertexSelection(){return this._manipulatorInfos.reduce(((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e),0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(qe.RESHAPING),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const o=[];for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected&&!n.manipulator.grabbing||n===e.info)&&o.push(n);this._moveVertices(o,e,Oe.ACCUMULATE_STEPS),this.emit("reshape",{type:"reshape",mover:this.graphic})}_updateEventState(e){if(e===this._reshapeEventState)return!1;switch(e){case qe.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case qe.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic})}break;case qe.MOVING:switch(this._reshapeEventState){case qe.NONE:this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic}),this.destroyed||this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic})}break;case qe.RESHAPING:switch(this._reshapeEventState){case qe.NONE:this.emit("reshape",{type:"reshape-start",mover:this.graphic});break;case qe.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic}),this.destroyed||this.emit("reshape",{type:"reshape-start",mover:this.graphic})}}if(this.destroyed)return!1;const t=this._reshapeEventState!==e;return this._reshapeEventState=e,t}_createGraphicMoveManipulation(){const{tool:e,view:t}=this,i=this._graphicState;if(this._graphicMoveManipulation=new oe({tool:e,view:t,graphicState:i}),this.enableMoveGraphic){let e=null;this._manipulatorHandles.add(this._graphicMoveManipulation.createDragPipeline(((t,i,a)=>{i.next((e=>this._trackNumDragging(e))).next((t=>("start"===t.action&&(e=h(this._editGeometryOperations).createUndoGroup()),t))).next((e=>this._perGraphicManipulatorDragAction(We.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(ee.XY,e),e))).next((t=>{"end"===t.action&&(this._tooltip.clear(),e=d(e))})),a.next((()=>this._onDragCancel(!0,(()=>e=d(e)))))}))),this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1))))}else this._graphicMoveManipulation.forEachManipulator((e=>{e.grabbable=!1,e.cursor=null}));this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(e.events.on("immediate-click",(e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()})))))}_createMoveManipulation(e){const{graphic:t,handles:i,tool:a,view:o}=this,n=this._graphicState;this._moveManipulation=new te({tool:a,view:o,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&K(t),snapToScene:!1,radius:te.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator((e=>i.add([e.events.on("immediate-click",(i=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some((e=>e.manipulator.selected))||this.emit("immediate-click",{...i,graphic:t}),i.stopPropagation()})),this._watchAndUpdateGrabState(e,!1)])));const r=e=>t=>{i.add(t.events.on("focus-changed",(({action:t})=>{"focus"===t&&this._tooltipOptions.enabled?this._updateTranslateTooltip(e):this._tooltip.clear()})))};this._moveManipulation.xyManipulation.forEachManipulator(r(ee.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(r(ee.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(r(ee.Z)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=h(t.geometry).spatialReference;i.add([this._moveManipulation.createDragPipeline(((i,o,n,r,s)=>{const{snappingStep:l,cancelSnapping:p}=Ee({predicate:e=>!!e.info,snappingManager:a.snappingManager,snappingContext:new be({editGeometryOperations:h(this._editGeometryOperations),elevationInfo:e,pointer:s,excludeFeature:t,visualizer:new z}),updatingHandles:this.updatingHandles,useZ:!1});return r=r.next((e=>(this._onDragCancel(),e))).next(p),{steps:n=n.next((e=>this._trackNumDragging(e))).next((e=>{const t=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return e.manipulatorType===W.TRANSLATE_XY&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e})).next(me(this.view,e,t)).next(...l).next(ge()).next((e=>this._perGraphicManipulatorDragAction(We.SELECTED_OR_ALL,e))).next((e=>(this._updateTranslateTooltip(i,e),e))),cancel:r}}),e,s,t),g((()=>n.displaying),(()=>{this._updateMoveManipulationPosition()}),f),n.on("changed",(()=>this._updateMoveManipulationPosition())),g((()=>n.isDraped),(e=>{this._updateMoveManipulationPosition();const t="align-move-manipulation";e?i.add(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),t):i.remove(t)}),f)])}_createVisualElements(){const{graphic:e,view:t}=this,i=Q({view:t,graphic:e,forEachManipulator:e=>{if(!this.destroyed){this._graphicMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,W.TRANSLATE_XY)}},onManipulatorsChanged:e=>this.on("manipulators-changed",e)});l(i)&&(this._outlineVisualElement=i.visualElement instanceof pe?i.visualElement:null),l(this._outlineVisualElement)&&this._manipulatorHandles.add(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>{this._graphicState.isDraped||this._updateMoveManipulationPosition()}))),this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=j(this.graphic)){const i=B.reshapeManipulators.edgeOffset,a=i.size/2,o=a+i.collisionPadding,r=a/o,s=r*Math.sqrt(3)/2;p(this._edgeOffsetManipulatorGeometryInside)&&(this._edgeOffsetManipulatorGeometryInside=de(this._edgeOffsetManipulatorMaterial,s,r/2,r/2,i.height,i.offset)),p(this._edgeOffsetManipulatorGeometryOutside)&&(this._edgeOffsetManipulatorGeometryOutside=de(this._edgeOffsetManipulatorMaterial,-s,r/2,r/2,i.height,-i.offset));const h=[new k(this._edgeOffsetManipulatorGeometryInside.instantiate(),Me.Unfocused),new k(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),Me.Focused),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate(),Me.Unfocused),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),Me.Focused)],d=new U({view:this.view,renderObjects:h,elevationInfo:"on-the-ground"!==t.mode||P(this.graphic.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:o,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionType:{type:"disc",direction:V(0,0,1)},collisionPriority:1,metadata:{deleting:!1}}),u=new U({view:this.view,worldSized:!0,worldOriented:!1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionPriority:-10,cursor:this.enableMoveGraphic?"move":"default",metadata:{deleting:!1}}),c={manipulator:d,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:u,elevationInfo:t,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(c,i.minSquaredEdgeLength),this._updateEdgeOffsetManipulator(c);const m=[];for(const n of[c.handle.leftVertex,c.handle.rightVertex]){const e=this._getManipulatorInfoFromHandle(n);l(e)&&m.push(e.manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(c))))}c.locationUpdateHandle=n(m),this._manipulatorHandles.add(c.locationUpdateHandle,d),this._manipulatorHandles.add([this._watchAndUpdateGrabState(d,!0),this._watchAndUpdateGrabState(u,!0)],d),this._manipulatorHandles.add(_e(d,this._createEdgeOffsetPipeline(c,t)),d),this._manipulatorHandles.add(_e(u,((e,i,a,o)=>{if("touch"===o){this._createEdgeOffsetPipeline(c,t)(e,i,a)}else if(this.enableMoveGraphic){const o=this.graphic,n=l(o.geometry)?o.geometry.spatialReference:null;i.next((e=>this._trackNumDragging(e))).next(fe(this.view,e.elevationAlignedLocation)).next(Y(this.view,e.elevationAlignedLocation,t,n,o)).next(ve()).next(ge()).next((e=>this._perGraphicManipulatorDragAction(We.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(ee.XY,e),e))).next((e=>{"end"===e.action&&this._tooltip.clear()})),a.next((()=>this._onDragCancel(!e.metadata.deleting)))}})),d);const g=e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()};return this._manipulatorHandles.add([d.events.on("immediate-click",g),u.events.on("immediate-click",g),d.events.on("focus-changed",(({action:e})=>{const t=this._tooltipOptions;if("focus"===e&&t.enabled){const e=this._tooltip.info=new Ge({tooltipOptions:t});this._updateTooltipAreaOrTotalLength(e)}else this._tooltip.clear()}))],d),this._manipulatorInfos.push(c),this.manipulators.add(d),this.manipulators.add(u),this.emit("manipulators-changed"),c}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,a=e.edgeManipulator,o=()=>{e.visibilityHandle=d(e.visibilityHandle);const o=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),s=l(o)&&l(r)&&le(o.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||s)&&(i.grabbable=!s,a.grabbable=!s,e.visibilityHandle=n([i.disableDisplay(),{remove:()=>{i.grabbable=!0,a.grabbable=this.enableMoveGraphic}}]))};this._manipulatorHandles.add([i.events.on("focus-changed",o),a.events.on("focus-changed",o),{remove:()=>{d(e.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)}}],i),o()}_updateEdgeOffsetManipulator(e){this._updateManipulatorPosition(e);const{coordinateHelper:t}=h(this._editGeometryOperations).data,i=ne(this.view,e.manipulator.elevationAlignedLocation,re(t,e.handle,h(e.manipulator.elevationInfo))),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),o=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(p(a)||p(o))return;const n=a.manipulator.renderLocation,r=o.manipulator.renderLocation,s=l(i)?se(i,n,r):x;e.manipulator.modelTransform=s,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=s;const d=O(b(Xe,n,r))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-d,0,0],[d,0,0]]]}}_createEdgeOffsetPipeline(e,t){return(i,a,o)=>{this._clearSelection();const{step:n,cleanup:r}=this._initializeEdgeOffset(e,t);a.next((e=>this._trackNumDragging(e))).next(fe(this.view,i.elevationAlignedLocation)).next(n).next(X(this.view)).next(Z(this.view,h(this._editGeometryOperations).data.spatialReference)).next(ge()).next(this._applyComputeEdgeOffsetDistanceStep()).next(this._applyEdgeOffsetStep(e)).next(this._showEdgeOffsetTooltip()).next((e=>{"end"===e.action&&r()})),o.next((()=>{i.metadata.deleting||(r(),this._onDragCancel())}))}}_initializeEdgeOffset(e,t){const i=h(this._editGeometryOperations),a=re(i.data.coordinateHelper,e.handle,t),o=i.createUndoGroup(),s=ne(this.view,e.manipulator.elevationAlignedLocation,a);if(a.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftEdge);l(t)&&this._splitEdgeManipulator(t,1)}if(a.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightEdge);l(t)&&this._splitEdgeManipulator(t,0)}const u=()=>new T({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:i.data.spatialReference}),c=new pe({view:this.view,isDraped:this._graphicState.isDraped,geometry:u(),elevationInfo:e.elevationInfo,width:B.visualElements.lineGraphics.outline.width,color:B.colorToVec4(J.main),attached:!0});let m;const _=()=>{this._cleanEdgeOffsetCollapsedEdges(e),m=d(m)},f=this.on("undo",_);return m=n([r(c),g((()=>this._graphicState.isDraped),(e=>c.isDraped=e)),this._graphicState.on("changed",(()=>c.geometry=u())),o,f]),{step:e=>p(a)||p(s)?(_(),null):{...e,operation:a,plane:s},cleanup:_}}_applyEdgeOffsetStep(e){return t=>{if(this.destroyed||p(t.operation))return t;this._updateEventState(qe.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:o}=t;return(i||a||o)&&(this._offsetEdge(e,t),this.emit("reshape",{type:"reshape",mover:this.graphic})),t}}_applyComputeEdgeOffsetDistanceStep(){return e=>{const{operation:t,mapEnd:i}=e;return p(t)||p(i)?e:("start"===e.action&&t.selectArrowFromStartPoint(i),{...e,signedDistance:t.signedDistanceToPoint(i)})}}_showEdgeOffsetTooltip(){return e=>{const{mapEnd:t,signedDistance:i,operation:a}=e,o=this._tooltip,n=this._tooltipOptions;if(!n.enabled||p(i))return o.clear(),e;let r=o.info;(p(r)||"reshape-edge-offset"!==r.type)&&(r=o.info=new Ge({tooltipOptions:n}));const{coordinateHelper:s}=h(this._editGeometryOperations).data;return r.distance="end"===e.action?u:Fe(this._graphicState.isDraped,i*a.selectedArrow,t,a.plane,s),this._updateTooltipAreaOrTotalLength(r),e}}_cleanEdgeOffsetCollapsedEdges(e){const t=e.handle.leftVertex.leftEdge?.leftVertex,i=e.handle.leftVertex,a=e.handle.rightVertex.rightEdge?.rightVertex,o=e.handle.rightVertex,n=h(this._editGeometryOperations).data.coordinateHelper,r=[];if(t&&n.distance(t.pos,i.pos)<Ze){const e=this._getManipulatorInfoFromHandle(i);l(e)&&r.push(e)}if(n.distance(i.pos,o.pos)<Ze||a&&n.distance(a.pos,o.pos)<Ze){const e=this._getManipulatorInfoFromHandle(o);l(e)&&r.push(e)}r.length&&this._removeVertices(r)}_computeVertexManipulatorSizeAndOutline(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}_createVertexOrEdgeManipulator(e,t=j(this.graphic),i=!1){if("edge"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(p(this._vertexManipulatorGeometry)||p(this._vertexManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(B.reshapeManipulators.vertex);this._vertexManipulatorGeometry=ue(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=ue(this._vertexManipulatorOutlineMaterial,t,16,16)}if(p(this._edgeManipulatorGeometry)||p(this._edgeManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(B.reshapeManipulators.edge);this._edgeManipulatorGeometry=ue(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=ue(this._edgeManipulatorOutlineMaterial,t,16,16)}const a=l(this.graphic.geometry)&&"point"===this.graphic.geometry.type?[]:[new k(this._vertexManipulatorGeometry.instantiate(),Ye.Vertex|Me.Unselected),new k(this._vertexManipulatorOutlineGeometry.instantiate(),Ye.Vertex|Me.Unfocused|Me.Unselected),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ye.Vertex|Me.Focused|Me.Unselected),new k(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),Me.Selected),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),Me.Selected|Me.Unfocused),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),Me.Selected|Me.Focused)];this.enableMidpoints&&a.push(new k(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),Ye.Edge|Me.Focused|Me.Unselected),new k(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ye.Edge|Me.Focused|Me.Unselected),new k(this._edgeManipulatorGeometry.instantiate(),Ye.Edge|Me.Unfocused|Me.Unselected),new k(this._edgeManipulatorOutlineGeometry.instantiate(),Ye.Edge|Me.Unfocused|Me.Unselected));const o=new U({view:this.view,renderObjects:a,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),metadata:{deleting:!1}});o.selected=i,this._setTypeSpecificManipulatorSettings(o,e,t);const r="edge"===e.type?{manipulator:o,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:o,handle:e,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(r),this.manipulators.add(o),this._updateManipulatorPosition(r),"edge"===r.type){const e=[];for(const t of[r.handle.leftVertex,r.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);l(i)&&e.push(i.manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(r))))}r.locationUpdateHandle=n(e),this._manipulatorHandles.add(r.locationUpdateHandle,o)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(o,!0),o);const s=_e(o,((e,i,a,o)=>{let n=null;const{snappingStep:s,cancelSnapping:l}=Ee({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new be({editGeometryOperations:h(this._editGeometryOperations),elevationInfo:t,pointer:o,excludeFeature:this.graphic,visualizer:new z}),updatingHandles:this.updatingHandles,useZ:!1});a=a.next((t=>(this._onDragCancel(!e.metadata.deleting,(()=>n=d(n))),t))).next(l),i.next((e=>this._trackNumDragging(e))).next((e=>{if("start"===e.action&&(n=h(this._editGeometryOperations).createUndoGroup()),"edge"===r.type){const t=this._splitEdgeManipulator(r);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:r,snapOrigin:r.handle.pos}})).next(fe(this.view,e.elevationAlignedLocation)).next(q(this.view,this.graphic,e.elevationAlignedLocation,e.location.spatialReference,this.graphic)).next(me(this.view,t,this.graphic)).next(...s).next(ge()).next((t=>{this._perVertexManipulatorDragAction(t),"end"===t.action&&(n=d(n)),this._updateTranslateVertexTooltip(e,ee.XY,t)}))}));return this._manipulatorHandles.add([s,o.events.on("immediate-click",(e=>this._manipulatorClickCallback(e,r))),o.events.on("select-changed",(()=>{r.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition()})),o.events.on("focus-changed",(({action:e})=>{"focus"===e&&"edge"!==r.type?this._updateTranslateVertexTooltip(o,ee.XY):this._tooltip.clear()}))],o),this.emit("manipulators-changed"),r}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&(this.undo(),this.outputGeometry=l(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null),l(this.tool.snappingManager)&&this.tool.snappingManager.doneSnapping(),this._tooltip.clear(),this._reshapeEventState){case qe.NONE:break;case qe.MOVING:this.emit("move",{type:"move",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape",mover:this.graphic})}t&&t(),this.destroyed||this._updateEventState(qe.NONE)}_setTypeSpecificManipulatorSettings(e,t,i){switch(t.type){case"vertex":e.state=Ye.Vertex,e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.radius=B.reshapeManipulators.vertex.size/2+B.reshapeManipulators.vertex.collisionPadding,e.elevationInfo=i,e.interactive=l(this.graphic.geometry)&&"point"!==this.graphic.geometry.type;break;case"edge":e.state=Ye.Edge,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1,e.radius=B.reshapeManipulators.edge.size/2+B.reshapeManipulators.edge.collisionPadding,e.elevationInfo="on-the-ground"!==i.mode||P(this.graphic.symbol)?{mode:"absolute-height",offset:0}:i}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",(i=>this._onGrabStateChanged(e,t,i.action,i.pointerType)))}_onGrabStateChanged(e,t,i,a="mouse"){if(!this._removingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(qe.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((e=>{e.manipulator.interactive=e.manipulator.grabbing||!this._numGrabbing&&l(this.graphic.geometry)&&"point"!==this.graphic.geometry.type,"edgeManipulator"in e&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)})),this._graphicMoveManipulation.forEachManipulator((e=>{e.interactive=e.grabbing||!this._numGrabbing})))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1)}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.emit("manipulators-changed"))}_removeManipulator(e){p(e)||(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),t(this._manipulatorInfos,e),this.emit("manipulators-changed"))}_getManipulatorInfoFromHandle(e){if(e)for(const t of this._manipulatorInfos)if(e===t.handle)return t;return null}_updateManipulatorPosition(e){if(this._removingManipulators)return;if(p(e))return;const t=h(this._editGeometryOperations);if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,ze),e.manipulator.grabbing&&l(this._vertexLaserLineVisualElement)&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(p(i)||p(a))return;const o=i.manipulator,n=a.manipulator;if(l(e.manipulator.elevationInfo)&&"on-the-ground"===e.manipulator.elevationInfo.mode){const i=o.location,a=n.location,r=.5,s=i.x+r*(a.x-i.x),l=i.y+r*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;e.manipulator.location=L(s,l,p,t.data.spatialReference)}else E(Xe,o.renderLocation,n.renderLocation,.5),e.manipulator.renderLocation=Xe}}_splitEdgeManipulator(e,t=.5){const i=h(this._editGeometryOperations),a=h(i.splitEdge(e.handle,t).createdVertex);e.locationUpdateHandle=d(e.locationUpdateHandle);const o=j(this.graphic);let n;this.enableEdgeOffset?(this._removeManipulator(e),n=this._createVertexOrEdgeManipulator(a)):(n=e,n.handle=a,n.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,o)),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(n),this.enableEdgeOffset||this._updateTranslateVertexTooltip(n.manipulator,ee.XY),this._updateSelection(e.manipulator);const r=this._updateEventState(qe.RESHAPING),s=i.data.coordinateHelper.vectorToArray(n.handle.pos),l=i.data.components.indexOf(a.component);return this.emit("vertex-add",{type:"vertex-add",vertices:[{coordinates:s,componentIndex:l,vertexIndex:h(a.index)}],added:s}),r&&this._updateEventState(qe.NONE),n}_updateMoveManipulationPosition(){if(this._removingManipulators)return;const e=G(Xe,0,0,0);let t=0,i=!1,a=null,o=null;for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected?(t++,S(e,e,n.manipulator.renderLocation),p(a)||n.selectedIndex>a.selectedIndex?(o=a,a=n):(p(o)||n.selectedIndex>o.selectedIndex)&&(o=n)):i=!0);if(0===t){const e=this._graphicState.displaying&&this.enableMoveGraphic;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&K(this.graphic),this._moveManipulation.angle=ie(h(this.graphic.geometry)),this._moveManipulation.radius=te.radiusForSymbol(this.graphic.symbol)}else{const e=this._graphicState.displaying;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&K(this.graphic),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(l(a)){const e=a.handle.pos,t=l(o)?o.handle.pos:a.handle.leftEdge&&a.handle.leftEdge.leftVertex?a.handle.leftEdge.leftVertex.pos:null,n=p(o)&&a.handle.rightEdge&&a.handle.rightEdge.rightVertex?a.handle.rightEdge.rightVertex.pos:null;t&&n?this._moveManipulation.xyAxisManipulation.available=!1:t?i=ke(t,e):n&&(i=ke(e,n))}this._moveManipulation.angle=i,this._moveManipulation.radius=$}0!==t&&i?(w(e,e,1/t),ze.spatialReference=h(this._editGeometryOperations).data.spatialReference,ze.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,ze),this._moveManipulation.elevationAlignedLocation=ze):l(this._outlineVisualElement)&&!this._graphicState.isDraped&&l(this._outlineVisualElement.attachmentOrigin)?this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin:R(this.view,this._moveManipulation,this.graphic)}_removeVertices(e){const t=new Array,i=h(this._editGeometryOperations);for(const a of e)if("vertex"===a.type&&i.canRemoveVertex()){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftEdge)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightEdge));const e=i.removeVertices([a.handle]),o=h(e.removedVertices?.[0].createdEdge);o&&this._createVertexOrEdgeManipulator(o)}if(t.length>0){const e=t.map((e=>{const t=i.data.components.indexOf(e.component);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:h(e.index)}}));this.outputGeometry=i.data.geometry;const a=this._updateEventState(qe.RESHAPING);if(this.destroyed)return;if(this.emit("vertex-remove",{type:"vertex-remove",removed:e.map((e=>e.coordinates)),vertices:e}),this.destroyed)return;if(a&&(this._updateEventState(qe.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}_moveVertices(e,t,i=("start"===t.action?Oe.NEW_STEP:Oe.ACCUMULATE_STEPS)){const a=h(this._editGeometryOperations);a.moveVertices(e.map((e=>e.handle)),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i),this.outputGeometry=a.data.geometry;for(const o of e)this._updateManipulatorPosition(o)}_offsetEdge(e,t){if(p(t.operation)||p(t.signedDistance))return;const i=h(this._editGeometryOperations),a=t.operation.clone();a.distance=t.signedDistance,i.updateVertices([e.handle.leftVertex,e.handle.rightVertex],a),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,e.button===ce.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===ce.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){const i=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));1===i.length?this._updateTranslateVertexTooltip(i[0].manipulator,e,t):this._updateTranslateGraphicTooltip(e,t)}_updateTranslateGraphicTooltip(e,t){const i=this._tooltipOptions;if(!i.enabled)return;const a=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(e){case ee.XY:this._tooltip.info=new Ie({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,t)=>Le(e,t,a)));break;case ee.XY_AXIS:this._tooltip.info=new Ve({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,i)=>{const o=Le(e,i,a);return c(o,ae(t))}));break;case ee.Z:this._tooltip.info=new we({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,Pe)}}_updateTranslateVertexTooltip(e,t,i){const a=this._tooltipOptions;if(!a.enabled)return;let o;const n=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(t){case ee.XY:o=new He({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,((e,t)=>Le(e,t,n))),this._updateTooltipAreaOrTotalLength(o);break;case ee.XY_AXIS:o=new Ae({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,((e,t)=>{const a=Le(e,t,n);return c(a,ae(i))})),this._updateTooltipAreaOrTotalLength(o);break;case ee.Z:o=new Te({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,Pe)}const r=Ue(e.elevationAlignedLocation);l(r)&&(o.elevation={mode:"absolute-height",...r}),this._tooltip.info=o}_updateTranslateTooltipDistance(e,t,i){if(l(t)&&"end"!==t.action){const{mapStart:a,mapEnd:o}=t,n=i(a,o);e.distance=l(n)?n:u}}_updateTooltipAreaOrTotalLength(e){const{geometry:t}=this.graphic;if(p(t))return;const i=this._graphicState.isDraped?"on-the-ground":"absolute-height";e.area="polygon"===t.type?De(t,i):null,e.totalLength="polyline"===t.type?je(t,i):null}get test(){return{segmentLabels:this._segmentLabels,tooltip:this._tooltip}}};function ke(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Fe(e,t,i,a,o){if(e){const e=o.toXYZ(o.pointToVector(i)),n=H(a,e,D.get()),r=Ne(n,e,o.spatialReference);if(l(r))return m(r.value*Math.sign(t),r.unit)}return m(t*v(i.spatialReference),"meters")}e([M()],Re.prototype,"_editGeometryOperations",void 0),e([M()],Re.prototype,"_segmentLabels",void 0),e([M({constructOnly:!0})],Re.prototype,"tool",void 0),e([M()],Re.prototype,"_tooltip",void 0),e([M()],Re.prototype,"inputGeometry",null),e([M()],Re.prototype,"outputGeometry",void 0),e([M({readOnly:!0})],Re.prototype,"updating",null),e([M()],Re.prototype,"manipulators",null),e([M()],Re.prototype,"view",null),e([M()],Re.prototype,"graphic",null),e([M()],Re.prototype,"enableZShape",null),e([M()],Re.prototype,"enableZVertex",null),e([M()],Re.prototype,"enableMoveGraphic",null),e([M()],Re.prototype,"enableMidpoints",null),e([M()],Re.prototype,"enableEdgeOffset",null),e([M()],Re.prototype,"_labelOptions",null),e([M()],Re.prototype,"_tooltipOptions",null),Re=e([y("esri.views.3d.interactive.editingTools.reshapeGraphic.ReshapeOperation")],Re);const ze=L(0,0,void 0,Ce.WGS84),Xe=I(),Ze=1e-6;var Ye,qe,We;!function(e){e.Vertex=ye.Custom1,e.Edge=ye.Custom2}(Ye||(Ye={})),function(e){e[e.NONE=0]="NONE",e[e.MOVING=1]="MOVING",e[e.RESHAPING=2]="RESHAPING"}(qe||(qe={})),function(e){e[e.ALL=0]="ALL",e[e.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(We||(We={}));export{Re as ReshapeOperation};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import{removeUnordered as t}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import i from"../../../../../core/Evented.js";import{HandleOwner as a}from"../../../../../core/HandleOwner.js";import o from"../../../../../core/Handles.js";import{handlesGroup as n,destroyHandle as r}from"../../../../../core/handleUtils.js";import{destroyMaybe as s,isSome as l,isNone as p,unwrap as h,removeMaybe as d}from"../../../../../core/maybe.js";import{zeroMeters as u,scale as c,createLength as m}from"../../../../../core/quantityUtils.js";import{watch as g,when as _,initial as f}from"../../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../../../core/unitUtils.js";import{property as M}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../../../core/accessorSupport/decorators/subclass.js";import{I as x}from"../../../../../chunks/mat4f64.js";import{l as O,b,h as E,s as G,a as S,g as w}from"../../../../../chunks/vec3.js";import{f as V,c as I}from"../../../../../chunks/vec3f64.js";import T from"../../../../../geometry/Polyline.js";import{hasCompatibleTopology as A}from"../../../../../geometry/support/coordsUtils.js";import{projectPoint as H}from"../../../../../geometry/support/plane.js";import{sv3d as D}from"../../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as L}from"../../../../../layers/graphics/dehydratedFeatures.js";import{getGraphicEffectiveElevationInfo as j}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as P}from"../../../../../symbols/support/utils.js";import{Manipulator3D as U}from"../../Manipulator3D.js";import{createManipulatorMaterial as N,createManipulatorOutlineMaterial as C,placeAtGraphic as R}from"../../manipulatorUtils.js";import{RenderObject as k}from"../../RenderObject.js";import{SegmentLabels3D as F}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as z}from"../../SnappingVisualizer3D.js";import{screenToRenderPlaneFromEvent as X,convertToMapCoordinates as Z,screenToMapXYAtLocation as Y,screenToMapXYForGraphicAtLocation as q}from"../dragEventPipeline3D.js";import{ManipulatorType as W}from"../ManipulatorType.js";import{canMoveZ as K}from"../manipulatorUtils.js";import{settings as B,colors as J}from"../settings.js";import{createVisualElements as Q}from"../visualElementUtils.js";import{DISC_RADIUS_SMALL as $}from"../manipulations/config.js";import{ManipulationType as ee,MoveManipulation as te}from"../manipulations/MoveManipulation.js";import{shapeOrientation as ie,axisConstrainedDragSign as ae}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as oe}from"../manipulations/MoveXYGraphicManipulation.js";import{createEdgeOffsetIntersectionPlane as ne,createEdgeOffsetOperation as re,edgeOffsetRotationMatrix as se,screenEdgeLengthSquared as le}from"./edgeOffsetUtils.js";import{OutlineVisualElement as pe}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as he}from"../../../layers/graphics/GraphicState.js";import{createExtrudedTriangle as de,createSphereGeometry as ue}from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as ce}from"../../../../input/IViewEvents.js";import{sceneSnappingAtLocation as me,addMapDelta as ge,createManipulatorDragEventPipeline as _e,dragAtLocation as fe,addScreenDelta as ve}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as Me,ManipulatorStateCustomFlags as ye}from"../../../../interactive/interfaces.js";import{EditGeometryOperations as xe}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as Oe}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as be}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as Ee}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{ReshapeEdgeOffsetTooltipInfo as Ge}from"../../../../interactive/tooltip/ReshapeTooltipInfos.js";import{Tooltip as Se}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicZTooltipInfo as we,TranslateGraphicXYTooltipInfo as Ve,TranslateGraphicTooltipInfo as Ie,TranslateVertexZTooltipInfo as Te,TranslateVertexXYTooltipInfo as Ae,TranslateVertexTooltipInfo as He}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoAreaByElevationMode as De}from"../../../../support/automaticAreaMeasurementUtils.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as Le,autoLengthByElevationMode as je}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as Pe,elevationOfPoint as Ue}from"../../../../support/euclideanLengthMeasurementUtils.js";import{geodesicDistance as Ne}from"../../../../support/geodesicLengthMeasurementUtils.js";import Ce from"../../../../../geometry/SpatialReference.js";let Re=class extends(i.EventedMixin(a)){constructor(e){super(e),this._vertexManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.vertex.color),B.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.vertex.outlineColor),B.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.vertex.hoverOutlineColor),B.reshapeManipulators.vertex.renderOccluded),this._edgeManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.edge.color),B.reshapeManipulators.edge.renderOccluded),this._edgeManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.edge.outlineColor),B.reshapeManipulators.edge.renderOccluded),this._edgeOffsetManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.edgeOffset.color),B.reshapeManipulators.edgeOffset.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=N(B.colorToVec4(B.reshapeManipulators.edgeOffset.hoverColor),B.reshapeManipulators.edgeOffset.renderOccluded,!1),this._selectedManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.selected.color),B.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.selected.outlineColor),B.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.selected.hoverOutlineColor),B.reshapeManipulators.selected.renderOccluded),this._selectedIndex=0,this._manipulatorHandles=new o,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=qe.NONE,this._recreatingManipulators=!1,this.outputGeometry=null,this._vertexLaserLineVisualElement=null}initialize(){const{graphic:e,view:t}=this,i=this._graphicState=new he({graphic:e});this._tooltip=new Se({view:t}),this.addHandles([g((()=>i.displaying),(e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e})),g((()=>({labels:this._segmentLabels,enabled:this._labelOptions.enabled,edgeOffsetEnabled:this.enableEdgeOffset})),(({labels:e,enabled:t,edgeOffsetEnabled:i})=>{l(e)&&(e.visible=t,e.edgeDistance=i?"far":"default")}),f),_((()=>!this._tooltipOptions.enabled),(()=>this._tooltip.clear()),f),this.view.trackGraphicState(i)])}destroy(){this._segmentLabels=s(this._segmentLabels),this._tooltip=s(this._tooltip),this._removeManipulators()}get inputGeometry(){return l(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null}set inputGeometry(e){this._recreateEditGeometryAndManipulators(e)}get updating(){return this.updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get graphic(){return this.tool.graphic}get enableZShape(){return this.tool.enableZShape}get enableZVertex(){return this.tool.enableZVertex}get enableMoveGraphic(){return this.tool.enableMoveGraphic}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _labelOptions(){return this.tool.labelOptions}get _tooltipOptions(){return this.tool.tooltipOptions}removeSelectedVertices(){const e=this._manipulatorInfos.filter((e=>e.manipulator.selected&&"vertex"===e.type));this._removeVertices(e)}onManipulatorSelectionChanged(){this.emit("manipulators-changed")}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=s(this._moveManipulation),this._graphicMoveManipulation=s(this._graphicMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(p(this._editGeometryOperations))return;const t=j(this.graphic);for(const i of this._editGeometryOperations.data.components){const a=e?.byComponentIndex.get(i.index);for(const e of i.vertices){const i=a?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of i.edges)this._createVertexOrEdgeManipulator(e,t)}this._createGraphicMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}get canRedo(){return l(this._editGeometryOperations)&&this._editGeometryOperations.canRedo}get canUndo(){return l(this._editGeometryOperations)&&this._editGeometryOperations.canUndo}redo(){if(p(this._editGeometryOperations))return null;const e=this._editGeometryOperations.redo();return l(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}undo(){if(p(this._editGeometryOperations))return null;this.emit("undo");const e=this._editGeometryOperations.undo();return l(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}_recreateManipulators(){this._recreatingManipulators||(this._recreatingManipulators=!0,this._removeManipulators(),this._tooltip.clear(),this._createManipulators(),this._recreatingManipulators=!1)}_recreateEditGeometryAndManipulators(e){const t={byComponentIndex:new Map};if(l(e)&&l(this.inputGeometry)&&A(e,this.inputGeometry))for(const i of this._manipulatorInfos)if("vertex"===i.type&&i.manipulator.selected){const{index:e,component:{index:a}}=i.handle,{byComponentIndex:o}=t,n=o.get(a)||new Set;n.add(e),o.set(a,n)}this._recreatingManipulators=!0,this._removeManipulators(),this._tooltip.clear(),this._editGeometryOperations=s(this._editGeometryOperations),this._segmentLabels=s(this._segmentLabels),p(e)||(this._editGeometryOperations=xe.fromGeometry(e,this.view.state.viewingMode),this._createManipulators(t),this._segmentLabels=new F({context:{view:this.view,editGeometryOperations:this._editGeometryOperations,elevationInfo:j(this.graphic),labelOptions:this._labelOptions,graphic:this.graphic,graphicState:this._graphicState},visible:this._labelOptions.enabled})),this._recreatingManipulators=!1}_perGraphicManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],o=this._manipulatorInfos.some((e=>"vertex"===e.type&&e.manipulator.selected)),n=e===We.SELECTED_OR_ALL&&o;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.grabbing||n&&!r.manipulator.selected||a.push(r),i++);if(0===a.length)return t;this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(qe.MOVING),this.destroyed)return t;this.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,mover:this.graphic})}else{if(this._updateEventState(qe.RESHAPING),this.destroyed)return t;this.emit("reshape",{type:"reshape",mover:this.graphic})}return t}_isMultiVertexSelection(){return this._manipulatorInfos.reduce(((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e),0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(qe.RESHAPING),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const o=[];for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected&&!n.manipulator.grabbing||n===e.info)&&o.push(n);this._moveVertices(o,e,Oe.ACCUMULATE_STEPS),this.emit("reshape",{type:"reshape",mover:this.graphic})}_updateEventState(e){if(e===this._reshapeEventState)return!1;switch(e){case qe.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case qe.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic})}break;case qe.MOVING:switch(this._reshapeEventState){case qe.NONE:this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic}),this.destroyed||this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic})}break;case qe.RESHAPING:switch(this._reshapeEventState){case qe.NONE:this.emit("reshape",{type:"reshape-start",mover:this.graphic});break;case qe.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic}),this.destroyed||this.emit("reshape",{type:"reshape-start",mover:this.graphic})}}if(this.destroyed)return!1;const t=this._reshapeEventState!==e;return this._reshapeEventState=e,t}_createGraphicMoveManipulation(){const{tool:e,view:t}=this,i=this._graphicState;if(this._graphicMoveManipulation=new oe({tool:e,view:t,graphicState:i}),this.enableMoveGraphic){let e=null;this._manipulatorHandles.add(this._graphicMoveManipulation.createDragPipeline(((t,i,a)=>{i.next((e=>this._trackNumDragging(e))).next((t=>("start"===t.action&&(e=h(this._editGeometryOperations).createUndoGroup()),t))).next((e=>this._perGraphicManipulatorDragAction(We.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(ee.XY,e),e))).next((t=>{"end"===t.action&&(this._tooltip.clear(),e=d(e))})),a.next((()=>this._onDragCancel(!0,(()=>e=d(e)))))}))),this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1))))}else this._graphicMoveManipulation.forEachManipulator((e=>{e.grabbable=!1,e.cursor=null}));this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(e.events.on("immediate-click",(e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()})))))}_createMoveManipulation(e){const{graphic:t,handles:i,tool:a,view:o}=this,n=this._graphicState;this._moveManipulation=new te({tool:a,view:o,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&K(t),snapToScene:!1,radius:te.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator((e=>i.add([e.events.on("immediate-click",(i=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some((e=>e.manipulator.selected))||this.emit("immediate-click",{...i,graphic:t}),i.stopPropagation()})),this._watchAndUpdateGrabState(e,!1)])));const r=e=>t=>{i.add(t.events.on("focus-changed",(({action:t})=>{"focus"===t&&this._tooltipOptions.enabled?this._updateTranslateTooltip(e):this._tooltip.clear()})))};this._moveManipulation.xyManipulation.forEachManipulator(r(ee.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(r(ee.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(r(ee.Z)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=h(t.geometry).spatialReference;i.add([this._moveManipulation.createDragPipeline(((i,o,n,r,s)=>{const{snappingStep:l,cancelSnapping:p}=Ee({predicate:e=>!!e.info,snappingManager:a.snappingManager,snappingContext:new be({editGeometryOperations:h(this._editGeometryOperations),elevationInfo:e,pointer:s,excludeFeature:t,visualizer:new z}),updatingHandles:this.updatingHandles,useZ:!1});return r=r.next((e=>(this._onDragCancel(),e))).next(p),{steps:n=n.next((e=>this._trackNumDragging(e))).next((e=>{const t=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return e.manipulatorType===W.TRANSLATE_XY&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e})).next(me(this.view,e,t)).next(...l).next(ge()).next((e=>this._perGraphicManipulatorDragAction(We.SELECTED_OR_ALL,e))).next((e=>(this._updateTranslateTooltip(i,e),e))),cancel:r}}),e,s,t),g((()=>n.displaying),(()=>this._updateMoveManipulationPosition()),f),n.on("changed",(()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()})),g((()=>n.isDraped),(e=>{this._updateMoveManipulationPosition();const t="align-move-manipulation";e?i.add(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),t):i.remove(t)}),f)])}_createVisualElements(){const{graphic:e,view:t}=this,i=Q({view:t,graphic:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._graphicMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,W.TRANSLATE_XY)}},onManipulatorsChanged:e=>this.on("manipulators-changed",e)});l(i)&&(this._outlineVisualElement=i.visualElement instanceof pe?i.visualElement:null),l(this._outlineVisualElement)&&this._manipulatorHandles.add(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>{this._graphicState.isDraped||this._updateMoveManipulationPosition()}))),this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=j(this.graphic)){const i=B.reshapeManipulators.edgeOffset,a=i.size/2,o=a+i.collisionPadding,r=a/o,s=r*Math.sqrt(3)/2;p(this._edgeOffsetManipulatorGeometryInside)&&(this._edgeOffsetManipulatorGeometryInside=de(this._edgeOffsetManipulatorMaterial,s,r/2,r/2,i.height,i.offset)),p(this._edgeOffsetManipulatorGeometryOutside)&&(this._edgeOffsetManipulatorGeometryOutside=de(this._edgeOffsetManipulatorMaterial,-s,r/2,r/2,i.height,-i.offset));const h=[new k(this._edgeOffsetManipulatorGeometryInside.instantiate(),Me.Unfocused),new k(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),Me.Focused),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate(),Me.Unfocused),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),Me.Focused)],d=new U({view:this.view,renderObjects:h,elevationInfo:"on-the-ground"!==t.mode||P(this.graphic.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:o,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionType:{type:"disc",direction:V(0,0,1)},collisionPriority:1,metadata:{deleting:!1}}),u=new U({view:this.view,worldSized:!0,worldOriented:!1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionPriority:-10,cursor:this.enableMoveGraphic?"move":"default",metadata:{deleting:!1}}),c={manipulator:d,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:u,elevationInfo:t,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(c,i.minSquaredEdgeLength),this._updateEdgeOffsetManipulator(c);const m=[];for(const n of[c.handle.leftVertex,c.handle.rightVertex]){const e=this._getManipulatorInfoFromHandle(n);l(e)&&m.push(e.manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(c))))}c.locationUpdateHandle=n(m),this._manipulatorHandles.add(c.locationUpdateHandle,d),this._manipulatorHandles.add([this._watchAndUpdateGrabState(d,!0),this._watchAndUpdateGrabState(u,!0)],d),this._manipulatorHandles.add(_e(d,this._createEdgeOffsetPipeline(c,t)),d),this._manipulatorHandles.add(_e(u,((e,i,a,o)=>{if("touch"===o){this._createEdgeOffsetPipeline(c,t)(e,i,a)}else if(this.enableMoveGraphic){const o=this.graphic,n=l(o.geometry)?o.geometry.spatialReference:null;i.next((e=>this._trackNumDragging(e))).next(fe(this.view,e.elevationAlignedLocation)).next(Y(this.view,e.elevationAlignedLocation,t,n,o)).next(ve()).next(ge()).next((e=>this._perGraphicManipulatorDragAction(We.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(ee.XY,e),e))).next((e=>{"end"===e.action&&this._tooltip.clear()})),a.next((()=>this._onDragCancel(!e.metadata.deleting)))}})),d);const g=e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()};return this._manipulatorHandles.add([d.events.on("immediate-click",g),u.events.on("immediate-click",g),d.events.on("focus-changed",(({action:e})=>{const t=this._tooltipOptions;if("focus"===e&&t.enabled){const e=this._tooltip.info=new Ge({tooltipOptions:t});this._updateTooltipAreaOrTotalLength(e)}else this._tooltip.clear()}))],d),this._manipulatorInfos.push(c),this.manipulators.add(d),this.manipulators.add(u),this.emit("manipulators-changed"),c}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,a=e.edgeManipulator,o=()=>{e.visibilityHandle=d(e.visibilityHandle);const o=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),s=l(o)&&l(r)&&le(o.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||s)&&(i.grabbable=!s,a.grabbable=!s,e.visibilityHandle=n([i.disableDisplay(),{remove:()=>{i.grabbable=!0,a.grabbable=this.enableMoveGraphic}}]))};this._manipulatorHandles.add([i.events.on("focus-changed",o),a.events.on("focus-changed",o),{remove:()=>{d(e.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)}}],i),o()}_updateEdgeOffsetManipulator(e){this._updateManipulatorPosition(e);const{coordinateHelper:t}=h(this._editGeometryOperations).data,i=ne(this.view,e.manipulator.elevationAlignedLocation,re(t,e.handle,h(e.manipulator.elevationInfo))),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),o=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(p(a)||p(o))return;const n=a.manipulator.renderLocation,r=o.manipulator.renderLocation,s=l(i)?se(i,n,r):x;e.manipulator.modelTransform=s,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=s;const d=O(b(Xe,n,r))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-d,0,0],[d,0,0]]]}}_createEdgeOffsetPipeline(e,t){return(i,a,o)=>{this._clearSelection();const{step:n,cleanup:r}=this._initializeEdgeOffset(e,t);a.next((e=>this._trackNumDragging(e))).next(fe(this.view,i.elevationAlignedLocation)).next(n).next(X(this.view)).next(Z(this.view,h(this._editGeometryOperations).data.spatialReference)).next(ge()).next(this._applyComputeEdgeOffsetDistanceStep()).next(this._applyEdgeOffsetStep(e)).next(this._showEdgeOffsetTooltip()).next((e=>{"end"===e.action&&r()})),o.next((()=>{i.metadata.deleting||(r(),this._onDragCancel())}))}}_initializeEdgeOffset(e,t){const i=h(this._editGeometryOperations),a=re(i.data.coordinateHelper,e.handle,t),o=i.createUndoGroup(),s=ne(this.view,e.manipulator.elevationAlignedLocation,a);if(a.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftEdge);l(t)&&this._splitEdgeManipulator(t,1)}if(a.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightEdge);l(t)&&this._splitEdgeManipulator(t,0)}const u=()=>new T({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:i.data.spatialReference}),c=new pe({view:this.view,isDraped:this._graphicState.isDraped,geometry:u(),elevationInfo:e.elevationInfo,width:B.visualElements.lineGraphics.outline.width,color:B.colorToVec4(J.main),attached:!0});let m;const _=()=>{this._cleanEdgeOffsetCollapsedEdges(e),m=d(m)},f=this.on("undo",_);return m=n([r(c),g((()=>this._graphicState.isDraped),(e=>c.isDraped=e)),this._graphicState.on("changed",(()=>c.geometry=u())),o,f]),{step:e=>p(a)||p(s)?(_(),null):{...e,operation:a,plane:s},cleanup:_}}_applyEdgeOffsetStep(e){return t=>{if(this.destroyed||p(t.operation))return t;this._updateEventState(qe.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:o}=t;return(i||a||o)&&(this._offsetEdge(e,t),this.emit("reshape",{type:"reshape",mover:this.graphic})),t}}_applyComputeEdgeOffsetDistanceStep(){return e=>{const{operation:t,mapEnd:i}=e;return p(t)||p(i)?e:("start"===e.action&&t.selectArrowFromStartPoint(i),{...e,signedDistance:t.signedDistanceToPoint(i)})}}_showEdgeOffsetTooltip(){return e=>{const{mapEnd:t,signedDistance:i,operation:a}=e,o=this._tooltip,n=this._tooltipOptions;if(!n.enabled||p(i))return o.clear(),e;let r=o.info;(p(r)||"reshape-edge-offset"!==r.type)&&(r=o.info=new Ge({tooltipOptions:n}));const{coordinateHelper:s}=h(this._editGeometryOperations).data;return r.distance="end"===e.action?u:Fe(this._graphicState.isDraped,i*a.selectedArrow,t,a.plane,s),this._updateTooltipAreaOrTotalLength(r),e}}_cleanEdgeOffsetCollapsedEdges(e){const t=e.handle.leftVertex.leftEdge?.leftVertex,i=e.handle.leftVertex,a=e.handle.rightVertex.rightEdge?.rightVertex,o=e.handle.rightVertex,n=h(this._editGeometryOperations).data.coordinateHelper,r=[];if(t&&n.distance(t.pos,i.pos)<Ze){const e=this._getManipulatorInfoFromHandle(i);l(e)&&r.push(e)}if(n.distance(i.pos,o.pos)<Ze||a&&n.distance(a.pos,o.pos)<Ze){const e=this._getManipulatorInfoFromHandle(o);l(e)&&r.push(e)}r.length&&this._removeVertices(r)}_computeVertexManipulatorSizeAndOutline(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}_createVertexOrEdgeManipulator(e,t=j(this.graphic),i=!1){if("edge"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(p(this._vertexManipulatorGeometry)||p(this._vertexManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(B.reshapeManipulators.vertex);this._vertexManipulatorGeometry=ue(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=ue(this._vertexManipulatorOutlineMaterial,t,16,16)}if(p(this._edgeManipulatorGeometry)||p(this._edgeManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(B.reshapeManipulators.edge);this._edgeManipulatorGeometry=ue(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=ue(this._edgeManipulatorOutlineMaterial,t,16,16)}const a=l(this.graphic.geometry)&&"point"===this.graphic.geometry.type?[]:[new k(this._vertexManipulatorGeometry.instantiate(),Ye.Vertex|Me.Unselected),new k(this._vertexManipulatorOutlineGeometry.instantiate(),Ye.Vertex|Me.Unfocused|Me.Unselected),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ye.Vertex|Me.Focused|Me.Unselected),new k(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),Me.Selected),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),Me.Selected|Me.Unfocused),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),Me.Selected|Me.Focused)];this.enableMidpoints&&a.push(new k(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),Ye.Edge|Me.Focused|Me.Unselected),new k(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ye.Edge|Me.Focused|Me.Unselected),new k(this._edgeManipulatorGeometry.instantiate(),Ye.Edge|Me.Unfocused|Me.Unselected),new k(this._edgeManipulatorOutlineGeometry.instantiate(),Ye.Edge|Me.Unfocused|Me.Unselected));const o=new U({view:this.view,renderObjects:a,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),metadata:{deleting:!1}});o.selected=i,this._setTypeSpecificManipulatorSettings(o,e,t);const r="edge"===e.type?{manipulator:o,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:o,handle:e,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(r),this.manipulators.add(o),this._updateManipulatorPosition(r),"edge"===r.type){const e=[];for(const t of[r.handle.leftVertex,r.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);l(i)&&e.push(i.manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(r))))}r.locationUpdateHandle=n(e),this._manipulatorHandles.add(r.locationUpdateHandle,o)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(o,!0),o);const s=_e(o,((e,i,a,o)=>{let n=null;const{snappingStep:s,cancelSnapping:l}=Ee({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new be({editGeometryOperations:h(this._editGeometryOperations),elevationInfo:t,pointer:o,excludeFeature:this.graphic,visualizer:new z}),updatingHandles:this.updatingHandles,useZ:!1});a=a.next((t=>(this._onDragCancel(!e.metadata.deleting,(()=>n=d(n))),t))).next(l),i.next((e=>this._trackNumDragging(e))).next((e=>{if("start"===e.action&&(n=h(this._editGeometryOperations).createUndoGroup()),"edge"===r.type){const t=this._splitEdgeManipulator(r);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:r,snapOrigin:r.handle.pos}})).next(fe(this.view,e.elevationAlignedLocation)).next(q(this.view,this.graphic,e.elevationAlignedLocation,e.location.spatialReference,this.graphic)).next(me(this.view,t,this.graphic)).next(...s).next(ge()).next((t=>{this._perVertexManipulatorDragAction(t),"end"===t.action&&(n=d(n)),this._updateTranslateVertexTooltip(e,ee.XY,t)}))}));return this._manipulatorHandles.add([s,o.events.on("immediate-click",(e=>this._manipulatorClickCallback(e,r))),o.events.on("select-changed",(()=>{r.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition()})),o.events.on("focus-changed",(({action:e})=>{"focus"===e&&"edge"!==r.type?this._updateTranslateVertexTooltip(o,ee.XY):this._tooltip.clear()}))],o),this.emit("manipulators-changed"),r}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&(this.undo(),this.outputGeometry=l(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null),l(this.tool.snappingManager)&&this.tool.snappingManager.doneSnapping(),this._tooltip.clear(),this._reshapeEventState){case qe.NONE:break;case qe.MOVING:this.emit("move",{type:"move",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape",mover:this.graphic})}t&&t(),this.destroyed||this._updateEventState(qe.NONE)}_setTypeSpecificManipulatorSettings(e,t,i){switch(t.type){case"vertex":e.state=Ye.Vertex,e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.radius=B.reshapeManipulators.vertex.size/2+B.reshapeManipulators.vertex.collisionPadding,e.elevationInfo=i,e.interactive=l(this.graphic.geometry)&&"point"!==this.graphic.geometry.type;break;case"edge":e.state=Ye.Edge,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1,e.radius=B.reshapeManipulators.edge.size/2+B.reshapeManipulators.edge.collisionPadding,e.elevationInfo="on-the-ground"!==i.mode||P(this.graphic.symbol)?{mode:"absolute-height",offset:0}:i}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",(i=>this._onGrabStateChanged(e,t,i.action,i.pointerType)))}_onGrabStateChanged(e,t,i,a="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(qe.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((e=>{e.manipulator.interactive=e.manipulator.grabbing||!this._numGrabbing&&l(this.graphic.geometry)&&"point"!==this.graphic.geometry.type,"edgeManipulator"in e&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)})),this._graphicMoveManipulation.forEachManipulator((e=>{e.interactive=e.grabbing||!this._numGrabbing})))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1)}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.emit("manipulators-changed"))}_removeManipulator(e){p(e)||(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),t(this._manipulatorInfos,e),this.emit("manipulators-changed"))}_getManipulatorInfoFromHandle(e){if(e)for(const t of this._manipulatorInfos)if(e===t.handle)return t;return null}_updateManipulatorPosition(e){if(p(e))return;const t=h(this._editGeometryOperations);if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,ze),e.manipulator.grabbing&&l(this._vertexLaserLineVisualElement)&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(p(i)||p(a))return;const o=i.manipulator,n=a.manipulator;if(l(e.manipulator.elevationInfo)&&"on-the-ground"===e.manipulator.elevationInfo.mode){const i=o.location,a=n.location,r=.5,s=i.x+r*(a.x-i.x),l=i.y+r*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;e.manipulator.location=L(s,l,p,t.data.spatialReference)}else E(Xe,o.renderLocation,n.renderLocation,.5),e.manipulator.renderLocation=Xe}}_splitEdgeManipulator(e,t=.5){const i=h(this._editGeometryOperations),a=h(i.splitEdge(e.handle,t).createdVertex);e.locationUpdateHandle=d(e.locationUpdateHandle);const o=j(this.graphic);let n;this.enableEdgeOffset?(this._removeManipulator(e),n=this._createVertexOrEdgeManipulator(a)):(n=e,n.handle=a,n.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,o)),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(n),this.enableEdgeOffset||this._updateTranslateVertexTooltip(n.manipulator,ee.XY),this._updateSelection(e.manipulator);const r=this._updateEventState(qe.RESHAPING),s=i.data.coordinateHelper.vectorToArray(n.handle.pos),l=i.data.components.indexOf(a.component);return this.emit("vertex-add",{type:"vertex-add",vertices:[{coordinates:s,componentIndex:l,vertexIndex:h(a.index)}],added:s}),r&&this._updateEventState(qe.NONE),n}_updateMoveManipulationPosition(){const e=G(Xe,0,0,0);let t=0,i=!1,a=null,o=null;for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected?(t++,S(e,e,n.manipulator.renderLocation),p(a)||n.selectedIndex>a.selectedIndex?(o=a,a=n):(p(o)||n.selectedIndex>o.selectedIndex)&&(o=n)):i=!0);if(0===t){const e=this._graphicState.displaying&&this.enableMoveGraphic;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&K(this.graphic),this._moveManipulation.angle=ie(h(this.graphic.geometry)),this._moveManipulation.radius=te.radiusForSymbol(this.graphic.symbol)}else{const e=this._graphicState.displaying;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&K(this.graphic),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(l(a)){const e=a.handle.pos,t=l(o)?o.handle.pos:a.handle.leftEdge&&a.handle.leftEdge.leftVertex?a.handle.leftEdge.leftVertex.pos:null,n=p(o)&&a.handle.rightEdge&&a.handle.rightEdge.rightVertex?a.handle.rightEdge.rightVertex.pos:null;t&&n?this._moveManipulation.xyAxisManipulation.available=!1:t?i=ke(t,e):n&&(i=ke(e,n))}this._moveManipulation.angle=i,this._moveManipulation.radius=$}0!==t&&i?(w(e,e,1/t),ze.spatialReference=h(this._editGeometryOperations).data.spatialReference,ze.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,ze),this._moveManipulation.elevationAlignedLocation=ze):l(this._outlineVisualElement)&&!this._graphicState.isDraped&&l(this._outlineVisualElement.attachmentOrigin)?this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin:R(this.view,this._moveManipulation,this.graphic)}_removeVertices(e){const t=new Array,i=h(this._editGeometryOperations);for(const a of e)if("vertex"===a.type&&i.canRemoveVertex()){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftEdge)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightEdge));const e=i.removeVertices([a.handle]),o=h(e.removedVertices?.[0].createdEdge);o&&this._createVertexOrEdgeManipulator(o)}if(t.length>0){const e=t.map((e=>{const t=i.data.components.indexOf(e.component);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:h(e.index)}}));this.outputGeometry=i.data.geometry;const a=this._updateEventState(qe.RESHAPING);if(this.destroyed)return;if(this.emit("vertex-remove",{type:"vertex-remove",removed:e.map((e=>e.coordinates)),vertices:e}),this.destroyed)return;if(a&&(this._updateEventState(qe.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}_moveVertices(e,t,i=("start"===t.action?Oe.NEW_STEP:Oe.ACCUMULATE_STEPS)){const a=h(this._editGeometryOperations);a.moveVertices(e.map((e=>e.handle)),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i),this.outputGeometry=a.data.geometry;for(const o of e)this._updateManipulatorPosition(o)}_offsetEdge(e,t){if(p(t.operation)||p(t.signedDistance))return;const i=h(this._editGeometryOperations),a=t.operation.clone();a.distance=t.signedDistance,i.updateVertices([e.handle.leftVertex,e.handle.rightVertex],a),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,e.button===ce.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===ce.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){const i=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));1===i.length?this._updateTranslateVertexTooltip(i[0].manipulator,e,t):this._updateTranslateGraphicTooltip(e,t)}_updateTranslateGraphicTooltip(e,t){const i=this._tooltipOptions;if(!i.enabled)return;const a=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(e){case ee.XY:this._tooltip.info=new Ie({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,t)=>Le(e,t,a)));break;case ee.XY_AXIS:this._tooltip.info=new Ve({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,i)=>{const o=Le(e,i,a);return c(o,ae(t))}));break;case ee.Z:this._tooltip.info=new we({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,Pe)}}_updateTranslateVertexTooltip(e,t,i){const a=this._tooltipOptions;if(!a.enabled)return;let o;const n=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(t){case ee.XY:o=new He({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,((e,t)=>Le(e,t,n))),this._updateTooltipAreaOrTotalLength(o);break;case ee.XY_AXIS:o=new Ae({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,((e,t)=>{const a=Le(e,t,n);return c(a,ae(i))})),this._updateTooltipAreaOrTotalLength(o);break;case ee.Z:o=new Te({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,Pe)}const r=Ue(e.elevationAlignedLocation);l(r)&&(o.elevation={mode:"absolute-height",...r}),this._tooltip.info=o}_updateTranslateTooltipDistance(e,t,i){if(l(t)&&"end"!==t.action){const{mapStart:a,mapEnd:o}=t,n=i(a,o);e.distance=l(n)?n:u}}_updateTooltipAreaOrTotalLength(e){const{geometry:t}=this.graphic;if(p(t))return;const i=this._graphicState.isDraped?"on-the-ground":"absolute-height";e.area="polygon"===t.type?De(t,i):null,e.totalLength="polyline"===t.type?je(t,i):null}get test(){return{segmentLabels:this._segmentLabels,tooltip:this._tooltip}}};function ke(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Fe(e,t,i,a,o){if(e){const e=o.toXYZ(o.pointToVector(i)),n=H(a,e,D.get()),r=Ne(n,e,o.spatialReference);if(l(r))return m(r.value*Math.sign(t),r.unit)}return m(t*v(i.spatialReference),"meters")}e([M()],Re.prototype,"_editGeometryOperations",void 0),e([M()],Re.prototype,"_segmentLabels",void 0),e([M({constructOnly:!0})],Re.prototype,"tool",void 0),e([M()],Re.prototype,"_tooltip",void 0),e([M()],Re.prototype,"inputGeometry",null),e([M()],Re.prototype,"outputGeometry",void 0),e([M({readOnly:!0})],Re.prototype,"updating",null),e([M()],Re.prototype,"manipulators",null),e([M()],Re.prototype,"view",null),e([M()],Re.prototype,"graphic",null),e([M()],Re.prototype,"enableZShape",null),e([M()],Re.prototype,"enableZVertex",null),e([M()],Re.prototype,"enableMoveGraphic",null),e([M()],Re.prototype,"enableMidpoints",null),e([M()],Re.prototype,"enableEdgeOffset",null),e([M()],Re.prototype,"_labelOptions",null),e([M()],Re.prototype,"_tooltipOptions",null),Re=e([y("esri.views.3d.interactive.editingTools.reshapeGraphic.ReshapeOperation")],Re);const ze=L(0,0,void 0,Ce.WGS84),Xe=I(),Ze=1e-6;var Ye,qe,We;!function(e){e.Vertex=ye.Custom1,e.Edge=ye.Custom2}(Ye||(Ye={})),function(e){e[e.NONE=0]="NONE",e[e.MOVING=1]="MOVING",e[e.RESHAPING=2]="RESHAPING"}(qe||(qe={})),function(e){e[e.ALL=0]="ALL",e[e.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(We||(We={}));export{Re as ReshapeOperation};
|