@arcgis/core 4.29.0-next.20231019 → 4.29.0-next.20231021
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/arcade/ArcadeDate.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0b5bd015fde83dcc634f.js +1 -0
- package/assets/esri/core/workers/chunks/0fac8a4747b1ad8e1618.js +1 -0
- package/assets/esri/core/workers/chunks/1da721608993783dc9cf.js +1 -0
- package/assets/esri/core/workers/chunks/{0768d33f8cb842e7e309.js → 2a8ec76e6ef0edc4dfb6.js} +1 -1
- package/assets/esri/core/workers/chunks/386d7a038abe36e3bb28.js +1 -0
- package/assets/esri/core/workers/chunks/{5d3f05745338a8e0f48e.js → 3ff3a1053babb2154398.js} +3 -3
- package/assets/esri/core/workers/chunks/{586c6b76bc0e5df7d68c.js → 9786b4869dfc71cdfd19.js} +1 -1
- package/assets/esri/core/workers/chunks/b158e232e111e5aa6b62.js +1 -0
- package/assets/esri/core/workers/chunks/b6bd31674076e543d8b2.js +1 -0
- package/assets/esri/core/workers/chunks/e7317511ce0139a13098.js +1 -0
- package/assets/esri/libs/linkchartlayout/lclayout.wasm +0 -0
- package/assets/esri/themes/base/widgets/_Features.scss +5 -0
- package/assets/esri/themes/base/widgets/_Popup.scss +0 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/OITCompositing.glsl.js +1 -1
- package/interfaces.d.ts +222 -44
- package/layers/FeatureLayer.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/save/imageryUtils.js +1 -1
- package/layers/support/rasterFunctionUtils.js +1 -1
- package/layers/support/rasterFunctions/ArithmeticFunction.js +1 -1
- package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +1 -1
- package/package.json +1 -1
- package/rest/support/networkEnums.js +1 -1
- package/statistics/utils.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
- package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/MultipassTerrainTest.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/RenderContext.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/textureUtils.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/queryEngineUtils.js +1 -1
- package/webdoc/support/writeUtils.js +1 -1
- package/widgets/Directions/support/resources.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.d.ts +4 -0
- package/widgets/support/dateUtils.js +1 -1
- package/assets/esri/core/workers/chunks/214d757bf380844a635e.js +0 -1
- package/assets/esri/core/workers/chunks/279dc76fed79ed8891e7.js +0 -1
- package/assets/esri/core/workers/chunks/41081c921037e543a22f.js +0 -1
- package/assets/esri/core/workers/chunks/8b65814f8b884cfa6733.js +0 -1
- package/assets/esri/core/workers/chunks/9c77d69a13ec22cdd760.js +0 -1
- package/assets/esri/core/workers/chunks/d9e20b106c8ec0e32f8a.js +0 -1
- package/assets/esri/core/workers/chunks/f0d342303fc20e266d27.js +0 -1
- package/assets/esri/themes/base/images/maneuvers/bear-left.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/bear-left@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/bear-right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/bear-right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/disembark.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/disembark@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/elevator.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/elevator@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/embark.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/embark@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/escalator.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/escalator@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/exit-highway-left.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/exit-highway-left@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/exit-highway-right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/exit-highway-right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/fork-left.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/fork-left@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/fork-middle.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/fork-middle@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/fork-right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/fork-right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/highway-change-right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/highway-change-right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/highway-change.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/highway-change@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/left-left.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/left-left@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/left-right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/left-right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/left.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/left@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/merge-on-highway-right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/merge-on-highway-right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/merge-on-highway.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/merge-on-highway@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/ramp-left.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/ramp-left@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/ramp-right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/ramp-right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/right-left.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/right-left@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/right-right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/right-right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/roundabout-left.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/roundabout-left@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/roundabout-right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/roundabout-right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/sharp-left.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/sharp-left@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/sharp-right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/sharp-right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/stairs.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/stairs@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/straight.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/straight@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/take-pedestrian-ramp.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/take-pedestrian-ramp@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/u-turn-left.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/u-turn-left@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/u-turn-right.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/u-turn-right@2x.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/walk-through-door.png +0 -0
- package/assets/esri/themes/base/images/maneuvers/walk-through-door@2x.png +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import h from"../../../../core/PooledArray.js";import{watch as o,syncAndInitial as d,initial as l,sync as _}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as c,invert as m,multiply as f}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as g,create as T}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{fromValues as P,ZEROS as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as E}from"../../../../chunks/boundedPlane.js";import{debugFlags as b}from"../../support/debugFlags.js";import{TransparencyMode as S}from"../../terrain/TerrainRenderer.js";import{DepthFormat as I,FBOCache as y,ColorFormat as C}from"../core/FBOCache.js";import{RenderPassManager as w}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as D}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as O}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{RenderPluginInput as L}from"../effects/RenderPluginInput.js";import{RenderPluginManager as N}from"../effects/RenderPluginManager.js";import{Blit as M}from"../effects/blit/Blit.js";import{Highlight as H}from"../effects/highlight/Highlight.js";import{ShadowHighlight as F}from"../effects/highlight/ShadowHighlight.js";import{SMAA as x}from"../effects/smaa/SMAA.js";import{SSAO as v}from"../effects/ssao/SSAO.js";import{AnimationTimeStep as U}from"./AnimationTimeStep.js";import{Decorations as B,RenderRequestType as G,StencilBits as j}from"./basicInterfaces.js";import{BoundingInfo as q}from"./BoundingInfo.js";import{zero as V,union as Q}from"./depthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{RenderOccludedFlag as k}from"./Material.js";import{OffscreenRendering as Y}from"./OffscreenRendering.js";import{RenderContext as X}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as z}from"./rendererUtils.js";import{setupFeatureDefaults as J,RenderFeature as K}from"./RenderFeature.js";import{RenderSlot as Z}from"./RenderSlot.js";import{ShadowAccumulator as $}from"./ShadowAccumulator.js";import{ShadowMap as ee,SnapshotSlot as re}from"./ShadowMap.js";import te from"./SliceHelper.js";import{TransparencyPassType as se}from"./TransparencyPassType.js";import{EdgeView as ie}from"./edgeRendering/EdgeView.js";import{Transparency as ae}from"./edgeRendering/interfaces.js";import{MergedRenderer as ne}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as he}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as oe,PerformanceCategory as de}from"../statistics/RendererPerformanceInfo.js";import{RenderState as le}from"../../../support/RenderState.js";import{PixelFormat as _e,PixelType as pe,ClearBufferBit as ue}from"../../../webgl/enums.js";let ce=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=J(r,e),this.notifyChange("_renderStateFeatures"),this._renderPlugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(K.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(K.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces(Z.OPAQUE_MATERIAL,D.Highlight)||this._renderPlugins.produces(Z.DRAPED_MATERIAL,D.Highlight)}get hasShadowHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces(Z.OPAQUE_MATERIAL,D.ShadowHighlight)}get _magnifierEnabled(){return this._bindParameters.decorations===B.ON&&this._magnifierHelper.enabled}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(K.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,i,a,n,_,p){super({}),this._stage=e,this._techniqueRepository=i,this._rctx=a,this._compositingHelper=n,this._magnifierHelper=_,this._requestRender=p,this._materialRenderers=new h,this._needsTransparentPass=!1,this._materialRenderersHas={hudElements:!1,highlights:!1,water:!1,decorations:!1,occludees:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._backgroundColor=P(0,0,0,1),this._sliceHelper=new te,this._state=le.IDLE,this._highQualityTransparencyEnabled=!0,this._terrainTransparency=S.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new U,this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new L,this._releaseGeometryLinearDepth=e=>e?.release(),this._geometryLinearDepthFormat=I.DEPTH16_BUFFER,this.fboCache=new y(a),this._renderStateFeatures=J(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._offscreen=new Y(this.fboCache,this._compositingHelper),this.performanceInfo=new oe(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._highlight=new H({view:e.view}),this._shadowHighlight=new F({view:e.view,viewingMode:e.viewingMode}),this._shadowAccumulator=new $(this.fboCache,i,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t,!0,this._stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(D.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),p),this._ssao=new v({view:this._stage.view}),this._renderContext=new X(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._renderPlugins=new N({renderContext:this._renderContext,techniqueRepository:i,textureRepository:t,materialRepository:r,requestRender:p,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new w,this._renderPlugins.add(this.renderPassManager),this._smaa=new x({view:this._stage.view}),this._renderPlugins.add(this._smaa),this._blit=new M({opacity:1,alphaMode:he.None}),this._renderPlugins.add(this._blit),this._renderPlugins.add(this._ssao),this._renderPlugins.add(this._highlight),this._renderPlugins.add(this._shadowHighlight),this.addHandles([o((()=>this._stage.view.state.camera),(()=>p()),d),o((()=>b.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(ae.TRANSPARENT):()=>{},p()}),l),o((()=>this._stage.view.environment.background?.color),(e=>{const r=e?s(e):R;A(this._backgroundColor,r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),p()}),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaa.destroy(),this._blit.destroy(),this._gpuTimerHandle=i(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._shadowMap.dispose(),this._ssao.destroy(),this._highlight.dispose(),this._shadowHighlight.destroy(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),q.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}get updating(){return this._smaa.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._renderPlugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new ie({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:Ee(e)}),this.addHandles(o((()=>this._edgeView?.updating),(()=>this._requestRender()),_)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return c(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=z(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));if(null==i&&t.adds.length>0){const e=new ne({material:s});e.initializeRenderContext(this._renderPlugins._context),i=e,this._materialRenderers.push(i)}i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._materialRenderersHas;has.decorations=!1,has.highlights=!1,has.hudElements=!1,has.water=!1,has.occludees=!1,this._materialRenderers.forAll((e=>{has.highlights||=e.hasHighlights,has.occludees||=e.hasOccludees,has.water||=e.hasWater,has.decorations||=e.isDecoration,has.hudElements||=e.material.produces(Z.LINE_CALLOUTS_HUD_DEPTH,D.Color)||e.material.produces(Z.HUD_MATERIAL,D.Color)||e.material.produces(Z.LABEL_MATERIAL,D.Color)})),this._bindParameters.hasOccludees=has.occludees}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,r,t,s,i){const a=null!=e;this._isRendering=!0,this.performanceInfo.startFrame(),this.fboCache.frame(),this._disposeBindBuffers();const h=this._offscreen,{camera:o,contentCamera:d,mode:l,alignPixelEnabled:_}=t;this._state=l,this._bindParameters.overlay=this.renderOverlay(i),this.performanceInfo.advance(de.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=se.NONE,this._bindParameters.alignPixelEnabled=_,this._bindParameters.decorations=s;const p=E(this._sliceHelper.plane);s===B.OFF&&(this._sliceHelper.plane=null),o.setGLViewport(this._rctx);const u=h.initializeFrame(o,this._backgroundColor,a);this.hasReflections?this._bindParameters.ssr.lastFrameColor=u:u?.release(),this._prepare(o,d),this._renderPlugins.prepareRender(),this.performanceInfo.advance(de.PREPARE);const c=this._computeDepthRange(o);this._renderShadowMap(o,this._bindParameters.lighting.mainLight.direction,c),this.performanceInfo.advance(de.SHADOW_MAP),this._ensureBindParameters(o,d);const m=this._renderPlugins.produces(Z.OPAQUE_TERRAIN)&&(this._terrainTransparency===S.Semitransparent||this._terrainTransparency===S.TransparentWithDraped),f=this._highQualityTransparency&&m,g=this._needsTransparentPass||this._renderPlugins.produces(Z.TRANSPARENT_MATERIAL);this._prepareShaders(f,g),this._renderLinearDepth(),this.performanceInfo.advance(de.LINEAR_DEPTH),this._renderShadowAccumulation(c,o,d),this.performanceInfo.advance(de.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(),this.performanceInfo.advance(de.SSAO),this._renderContext.output=D.Color,h.bindFbo(),this._renderOpaqueGeometry(),this._renderPlugins.render(Z.ENVIRONMENT_OPAQUE),this.performanceInfo.advance(de.OPAQUE),this._renderTerrainLinearDepth(f),this._setMultipassTerrain(f),this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(de.OPAQUE_EDGES),h.bindFbo(),this._renderPlugins.render(Z.VOXEL),this.performanceInfo.advance(de.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOITPass(me.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(de.TRANSPARENT);const T=this._renderGeometryLinearDepth(f);this._renderHUDVisibility(T),f||this._renderInternalSlot(Z.LINE_CALLOUTS),this.performanceInfo.advance(de.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(de.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(ae.TRANSPARENT,T),this._releaseGeometryLinearDepth(T),this.performanceInfo.advance(de.TRANSPARENT_EDGES);const A=m?this._renderTransparentTerrain():null;A&&this._bindParameters.hudVisibility&&(f?this._renderLineCallouts(O.Occluded):h.compositeToHUDVisibility(this._bindParameters,A.colorTexture),this._renderHUD(O.Occluded,h.color),this.performanceInfo.advance(de.HUD_OCCLUDED)),this.performanceInfo.advance(de.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),A&&(h.compositeToFramebuffer(this._bindParameters,A.colorTexture,he.PremultipliedAlpha,1),A.release(),f&&(this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(de.OPAQUE_EDGES),g&&(this._oitEnabled?this._renderOITPass(me.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(de.TRANSPARENT),this._renderEdges(ae.TRANSPARENT),this.performanceInfo.advance(de.TRANSPARENT_EDGES))),this._bindParameters.ssao=n(this._bindParameters.ssao),f&&this._renderLineCallouts(O.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),h.bindFbo(),this._renderInternalSlot(Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.render(Z.ENVIRONMENT_TRANSPARENT),this.performanceInfo.advance(de.ENVIRONMENT),this._renderLaserlines(),this.performanceInfo.advance(de.LASER_LINES),this._renderOccluded(),this.performanceInfo.advance(de.OCCLUDED);const P=this._magnifierEnabled&&null==e?this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height,"magnifier"):null,R=this._renderComposite(P??e,this._offscreen.color)??e;this.performanceInfo.advance(de.ANTIALIASING),this._renderHUD(O.NotOccluded,R),this.performanceInfo.advance(de.HUD),this._renderHighlights(R,this._bindParameters),this.performanceInfo.advance(de.HIGHLIGHTS),this._magnifierEnabled&&this._magnifierHelper.render(this._rctx,this._bindParameters),R!==e&&(this._rctx.bindFramebuffer(e?.fbo),this._compositingHelper.composite(this._bindParameters,P?.colorTexture,he.None)),P!==e&&P?.release(),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=p,this._isRendering=!1,this.performanceInfo.finishFrame(),a&&(this._releaseFBOs(),this._disposeOffscreenBuffers())}_prepareShaders(e,r){this._renderContext.output=D.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._renderPlugins.prepare(Z.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,Z.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.prepare(Z.ENVIRONMENT_TRANSPARENT),this._renderPlugins.prepare(Z.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(e){if(null==e||!has("enable-feature:objectAndLayerId-rendering"))return;const r=this._renderContext.output;this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>this._renderAllGeometry(D.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=O.NotOccluded,this._renderInternalSlot(Z.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===G.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._bindParameters.linearDepth?.fbo;if(s?.colorTexture)return void s.readPixels(r[0],r[1],r[2],r[3],_e.RGBA,pe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height,"depth").acquireDepth(I.DEPTH16_BUFFER);this._rctx.bindFramebuffer(i.fbo),this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const a=ue.COLOR_BUFFER_BIT|ue.DEPTH_BUFFER_BIT|ue.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderAllGeometry(D.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],_e.RGBA,pe.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,_e.RGBA,pe.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(C.RGBA,s,i,"edges"),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,ge),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,he.Alpha,1),n.release()}}_renderShadowMap(e,r,t){const s=this._shadowMap;s.enabled&&(s.start(e,r,t,this.isFeatureEnabled(K.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(e,r),this._needsShadowHighlight?(this._renderShadowCascades(D.ShadowHighlight,this._shadowMap),s.moveSnapshot(re.Highlight),s.clear(),this._renderShadowCascades(D.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(re.Default),this._renderShadowCascades(D.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(D.Shadow),s.finish(),e.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap){for(const t of r.cascades)t.camera.setGLViewport(this._rctx),this._prepare(t.camera,t.camera),this._renderAllGeometry(e)}get _needsLinearDepth(){return this._renderPlugins.consumes(D.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,"linear depth",(()=>this._renderAllGeometry(D.Depth)),[0,0,0,0],C.RGBA,I.DEPTH_STENCIL_BUFFER),this._bindParameters.linearDepth.releaseDepth(),this._offscreen.bindFbo()):this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=D.Depth,this._bindParameters.multipassTerrain.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassTerrain.linearDepth,"terrain depth",(()=>this._renderTransparentTerrain()),[-1e10,-1e10,-1e10,1]),this._bindParameters.multipassTerrain.linearDepth.releaseDepth(),this._renderContext.output=e}else this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth)}_renderGeometryLinearDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth));const r=this._renderContext.output;return this._bindParameters.multipassGeometry.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassGeometry.linearDepth,"geometry depth",(()=>this._renderOpaqueGeometryAndTransparentMaterial(D.Depth)),[1,1,1,1],C.RGBA,this._geometryLinearDepthFormat),this._renderContext.output=r,this._bindParameters.multipassGeometry.linearDepth.detachDepth()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return V;const r=W(e,this._materialRenderers,this._stage.layers);return Q(r,this._renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderAllGeometry(e){this._renderContext.output=e,this._renderPlugins.prepare(Z.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderSSAO(){if(!this._renderPlugins.produces(Z.SSAO))return;const e=this._offscreen.renderToCachedFBO(null,"normals",(()=>this._renderAllGeometry(D.Normal)),[0,0,0,0],C.RGBA,I.DEPTH_STENCIL_BUFFER);e.releaseDepth(),this._offscreen.bindFbo(),this._pluginInput.normal=e,this._bindParameters.ssao=this._renderPlugins.render(Z.SSAO,this._pluginInput),e.release()}_prepareOpaqueGeometrySlots(){this._renderPlugins.prepare(Z.INTEGRATED_MESH),this._renderPlugins.prepare(Z.OPAQUE_TERRAIN),this._renderPlugins.prepare(Z.OPAQUE_MATERIAL),this._renderPlugins.prepare(Z.ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,Z.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderPlugins.render(Z.INTEGRATED_MESH),this._renderPlugins.render(Z.OPAQUE_TERRAIN),this._renderInternalSlot(Z.OPAQUE_MATERIAL),this._renderPlugins.render(Z.OPAQUE_MATERIAL)}_renderTransparentMaterial(){this._renderInternalSlot(Z.TRANSPARENT_MATERIAL),this._renderPlugins.render(Z.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){if(!this._renderPlugins.produces(Z.TRANSPARENT_TERRAIN))return;const e=()=>this._renderPlugins.render(Z.TRANSPARENT_TERRAIN,null);if(this._renderContext.output!==D.Color)return void e();const{width:r,height:t,depth:s}=this._offscreen,i=this.fboCache.acquire(C.RGBA,r,t,"transparent terrain");return this._offscreen.renderToTargets(e,i,s,[0,0,0,0]),i}_renderHUDVisibility(e){this._shouldRenderInternalSlot(this._materialRenderers,Z.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._renderInternalSlot(Z.OCCLUSION_PIXELS)),e),this._offscreen.bindFbo()):this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===O.Occluded){const e=()=>this._renderInternalSlot(Z.LINE_CALLOUTS),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(I.DEPTH16_BUFFER,r,t,"line callouts");this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderInternalSlot(Z.LINE_CALLOUTS)}_renderLaserlines(){if(this._renderPlugins.render(Z.LASERLINES),this._renderPlugins.produces(Z.LASERLINES_CONTRAST_CONTROL)){const e=this._offscreen,{width:r,height:t,depth:s}=e,i=this.fboCache.acquire(C.RGBA,r,t,"laser lines"),a=()=>this._renderPlugins.render(Z.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,ge),e.compositeToFramebuffer(this._bindParameters,i.colorTexture,he.PremultipliedAlpha,1),i.release()}}_renderHUD(e,r){if(this._materialRenderersHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(me.HUD,e);this._rctx.bindFramebuffer(r?.fbo),this._compositingHelper.composite(this._bindParameters,t.colorTexture,he.PremultipliedAlpha),t.release()}else if(e===O.Occluded){const r=()=>this._renderHUDElements(e),{width:t,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(I.DEPTH16_BUFFER,t,s,"hud");this._offscreen.renderToTargets(r,i,a,void 0,!0,!0),a.release()}else this._rctx.bindFramebuffer(null),r?.acquireDepth(I.DEPTH16_BUFFER),this._rctx.bindFramebuffer(r?.fbo),this._renderHUDElements(e),r?.releaseDepth()}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,Z.LINE_CALLOUTS_HUD_DEPTH,Z.HUD_MATERIAL,Z.LABEL_MATERIAL),this._renderInternalSlot(Z.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(Z.HUD_MATERIAL),this._renderInternalSlot(Z.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._renderPlugins.produces(Z.SHADOW_HIGHLIGHT)&&this.hasShadowHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===B.OFF)return;const t=()=>{this._renderAllGeometry(D.Highlight),this._rctx.clearSafe(ue.DEPTH_BUFFER_BIT),this._renderHUDElements(O.Both)},s=this._offscreen.renderToCachedFBO(null,"highlight",t,[0,0,0,0],C.RGBA4,I.DEPTH_STENCIL_BUFFER);s.releaseDepth(),this._needsShadowHighlight&&(this._pluginInput.highlight=s,this._renderPlugins.render(Z.SHADOW_HIGHLIGHT,this._pluginInput,e)),this._renderPlugins.produces(Z.HIGHLIGHT)&&(this._pluginInput.composite=null,this._pluginInput.normal=null,this._pluginInput.highlight=s,this._renderPlugins.render(Z.HIGHLIGHT,this._pluginInput,e)),s.release()}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=D.Alpha,this._bindParameters.transparencyPassType=se.Alpha,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._renderContext.output=D.Color,this._bindParameters.transparencyPassType=se.Color,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=se.FrontFace,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=se.NONE}_renderOITPass(e,r=O.Both){const t=e===me.HUD,s=t?this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height,"oit hud"):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentMaterial(),a=this._renderContext.output;this._renderContext.output=D.Alpha,this._bindParameters.transparencyPassType=se.Alpha;const n=this._offscreen.renderOITPass(i,se.Alpha,t);this._renderContext.output=D.Color,this._bindParameters.transparencyPassType=se.Color;const h=this._offscreen.renderOITPass(i,se.Color,t);this._bindParameters.transparencyPassType=se.FrontFace;const o=this._offscreen.renderOITPass(i,se.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=se.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;Te.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.parameters.renderOccluded===k.OccludeAndTransparentStencil&&(e|=r.material.parameters.renderOccluded,Te.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{if(0==(e&s))return;const{width:h,height:o,depth:d}=r,l=this.fboCache.acquire(C.RGBA,h,o,"tmp color");r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,he.PremultipliedAlpha,t),l.release()};0!==Te.length&&(this._prepareInternalSlots(Te,Z.OCCLUDER_MATERIAL,Z.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(Z.OCCLUDER_MATERIAL,Te),t(.5,k.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(Z.TRANSPARENT_OCCLUDER_MATERIAL,Te)),!1,!1)),Te.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.parameters.renderOccluded===k.OccludeAndTransparent||r.material.parameters.renderOccluded===k.Transparent||r.material.parameters.renderOccluded===k.Opaque)&&(e|=r.material.parameters.renderOccluded,Te.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(Te,Z.OPAQUE_MATERIAL,Z.TRANSPARENT_MATERIAL,Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>k.Occlude&&this._renderPlugins.render(Z.OCCLUDED_TERRAIN),this._renderInternalSlot(Z.OPAQUE_MATERIAL,Te),this._renderInternalSlot(Z.TRANSPARENT_MATERIAL,Te),this._renderInternalSlot(Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Te),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=D.Color,t(.5,k.OccludeAndTransparent,(()=>i(k.OccludeAndTransparent)),!0,j.OutlineVisualElementMask),t(.5,k.Transparent,(()=>i(k.Transparent)),!0,j.OutlineVisualElementMask),t(1,k.Opaque,(()=>i(k.Opaque)),!0,j.OutlineVisualElementMask),Te.clear()}_renderComposite(e,r){this._renderPlugins.consumes(D.CompositeColor)&&(this._pluginInput.composite=r);let t=null;const s=this._renderPlugins.produces(Z.COMPOSITE);s&&(t=this._renderPlugins.renderComposition(Z.COMPOSITE,this._pluginInput),this._pluginInput.composite=t);const i=this._renderPlugins.produces(Z.ANTIALIASING),a=this._renderPlugins.render(i?Z.ANTIALIASING:Z.BLIT,this._pluginInput,e);return s&&t?.release(),a}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.material.produces(Z.TRANSPARENT_MATERIAL,D.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.mainColor=t.colorTexture,this._bindParameters.mainDepth=t.depthTexture}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(m(Pe,this._bindParameters.camera.viewMatrix),m(Ae,this._bindParameters.camera.projectionMatrix),f(Re,Pe,Ae),f(Re,this._renderContext.lastFrameCamera.viewMatrix,Re),f(Re,this._renderContext.lastFrameCamera.projectionMatrix,Re),this._reprojectionMatrix=Re);const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._ssrEnableTime=null}_shouldRenderInternalSlot(e,r){return this._bindParameters.slot=r,e.some((e=>null!=e.prepareTechnique(this._renderContext)))}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>null!=e.prepareTechnique(this._renderContext)))}_renderInternalSlot(e,r=this._materialRenderers){this._bindParameters.slot=e,r.forAll((e=>{const r=e.prepareTechnique(this._renderContext);r&&e.renderNode(this._renderContext,r)}))}get memoryInfo(){return{fbos:this.fboCache.usedMemory,vaos:this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0),plugins:this._renderPlugins.usedMemory}}getMemoryForMaterial(e){if(null==e)return 0;const r=this._materialRenderers.find((r=>r.material===e));return r?.usedMemory??0}get usedMemory(){return this.fboCache.usedMemory+(this.edgeView?.usedMemory??0)+this._renderPlugins.usedMemory}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=J(),this._renderPlugins.renderFeatureChanged(),this._requestRender()},releaseGeometryLinearDepth(r){e._releaseGeometryLinearDepth=r??(e=>e?.release()),e._geometryLinearDepthFormat=r?I.DEPTH_STENCIL_TEXTURE:I.DEPTH16_BUFFER},getFramebufferTexture:r=>{switch(r){case fe.Color:return e._offscreen.colorTexture;case fe.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case fe.ShadowMap:return e._shadowMap.depthTexture;case fe.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var me,fe;e([p()],ce.prototype,"_renderPlugins",void 0),e([p()],ce.prototype,"_shadowAccumulator",void 0),e([p()],ce.prototype,"_state",void 0),e([p()],ce.prototype,"_renderStateFeatures",void 0),e([p({readOnly:!0})],ce.prototype,"fullResolutionAtmosphere",null),e([p()],ce.prototype,"_smaa",void 0),e([p()],ce.prototype,"_blit",void 0),e([p({autoDestroy:!0})],ce.prototype,"_edgeView",void 0),e([p()],ce.prototype,"updating",null),e([p()],ce.prototype,"isCameraFinal",null),ce=e([u("esri.views.3d.webgl-engine.lib.Renderer")],ce),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(me||(me={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(fe||(fe={}));const ge=[0,0,0,0],Te=new h,Ae=T(),Pe=T(),Re=T();function Ee(e){return r=>e.immediate.schedule(r)}export{fe as FramebufferId,ce as Renderer};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import h from"../../../../core/PooledArray.js";import{watch as o,syncAndInitial as d,initial as l,sync as _}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as c,invert as m,multiply as f}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as g,create as T}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{fromValues as P,ZEROS as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as E}from"../../../../chunks/boundedPlane.js";import{debugFlags as b}from"../../support/debugFlags.js";import{TransparencyMode as S}from"../../terrain/TerrainRenderer.js";import{DepthFormat as I,FBOCache as y,ColorFormat as C}from"../core/FBOCache.js";import{RenderPassManager as w}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as D}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as O}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{RenderPluginInput as L}from"../effects/RenderPluginInput.js";import{RenderPluginManager as N}from"../effects/RenderPluginManager.js";import{Blit as M}from"../effects/blit/Blit.js";import{Highlight as H}from"../effects/highlight/Highlight.js";import{ShadowHighlight as F}from"../effects/highlight/ShadowHighlight.js";import{SMAA as x}from"../effects/smaa/SMAA.js";import{SSAO as v}from"../effects/ssao/SSAO.js";import{AnimationTimeStep as U}from"./AnimationTimeStep.js";import{Decorations as B,RenderRequestType as G,StencilBits as j}from"./basicInterfaces.js";import{BoundingInfo as q}from"./BoundingInfo.js";import{zero as V,union as Q}from"./depthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{RenderOccludedFlag as k}from"./Material.js";import{OffscreenRendering as Y}from"./OffscreenRendering.js";import{RenderContext as X,defaultRenderOccludedMask as z}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as J}from"./rendererUtils.js";import{setupFeatureDefaults as K,RenderFeature as Z}from"./RenderFeature.js";import{RenderSlot as $}from"./RenderSlot.js";import{ShadowAccumulator as ee}from"./ShadowAccumulator.js";import{ShadowMap as re,SnapshotSlot as te}from"./ShadowMap.js";import se from"./SliceHelper.js";import{TransparencyPassType as ie}from"./TransparencyPassType.js";import{EdgeView as ae}from"./edgeRendering/EdgeView.js";import{Transparency as ne}from"./edgeRendering/interfaces.js";import{MergedRenderer as he}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as oe}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as de,PerformanceCategory as le}from"../statistics/RendererPerformanceInfo.js";import{RenderState as _e}from"../../../support/RenderState.js";import{PixelFormat as pe,PixelType as ue,ClearBufferBit as ce}from"../../../webgl/enums.js";let me=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=K(r,e),this.notifyChange("_renderStateFeatures"),this._renderPlugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(Z.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(Z.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces($.OPAQUE_MATERIAL,D.Highlight)||this._renderPlugins.produces($.DRAPED_MATERIAL,D.Highlight)}get hasShadowHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces($.OPAQUE_MATERIAL,D.ShadowHighlight)}get _magnifierEnabled(){return this._bindParameters.decorations===B.ON&&this._magnifierHelper.enabled}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(Z.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,i,a,n,_,p){super({}),this._stage=e,this._techniqueRepository=i,this._rctx=a,this._compositingHelper=n,this._magnifierHelper=_,this._requestRender=p,this._materialRenderers=new h,this._needsTransparentPass=!1,this._materialRenderersHas={hudElements:!1,highlights:!1,water:!1,decorations:!1,occludees:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._backgroundColor=P(0,0,0,1),this._sliceHelper=new se,this._state=_e.IDLE,this._highQualityTransparencyEnabled=!0,this._terrainTransparency=S.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new U,this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new L,this._releaseGeometryLinearDepth=e=>e?.release(),this._geometryLinearDepthFormat=I.DEPTH16_BUFFER,this.fboCache=new y(a),this._renderStateFeatures=K(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._offscreen=new Y(this.fboCache,this._compositingHelper),this.performanceInfo=new de(this._rctx),this._shadowMap=new re(this.fboCache,e.viewingMode),this._highlight=new H({view:e.view}),this._shadowHighlight=new F({view:e.view,viewingMode:e.viewingMode}),this._shadowAccumulator=new ee(this.fboCache,i,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t,!0,this._stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(D.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),p),this._ssao=new v({view:this._stage.view}),this._renderContext=new X(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._renderPlugins=new N({renderContext:this._renderContext,techniqueRepository:i,textureRepository:t,materialRepository:r,requestRender:p,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new w,this._renderPlugins.add(this.renderPassManager),this._smaa=new x({view:this._stage.view}),this._renderPlugins.add(this._smaa),this._blit=new M({opacity:1,alphaMode:oe.None}),this._renderPlugins.add(this._blit),this._renderPlugins.add(this._ssao),this._renderPlugins.add(this._highlight),this._renderPlugins.add(this._shadowHighlight),this.addHandles([o((()=>this._stage.view.state.camera),(()=>p()),d),o((()=>b.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(ne.TRANSPARENT):()=>{},p()}),l),o((()=>this._stage.view.environment.background?.color),(e=>{const r=e?s(e):R;A(this._backgroundColor,r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),p()}),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaa.destroy(),this._blit.destroy(),this._gpuTimerHandle=i(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._shadowMap.dispose(),this._ssao.destroy(),this._highlight.dispose(),this._shadowHighlight.destroy(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),q.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}get updating(){return this._smaa.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._renderPlugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new ae({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:be(e)}),this.addHandles(o((()=>this._edgeView?.updating),(()=>this._requestRender()),_)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return c(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=J(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));if(null==i&&t.adds.length>0){const e=new he({material:s});e.initializeRenderContext(this._renderPlugins._context),i=e,this._materialRenderers.push(i)}i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._materialRenderersHas;has.decorations=!1,has.highlights=!1,has.hudElements=!1,has.water=!1,has.occludees=!1,this._materialRenderers.forAll((e=>{has.highlights||=e.hasHighlights,has.occludees||=e.hasOccludees,has.water||=e.hasWater,has.decorations||=e.isDecoration,has.hudElements||=e.material.produces($.LINE_CALLOUTS_HUD_DEPTH,D.Color)||e.material.produces($.HUD_MATERIAL,D.Color)||e.material.produces($.LABEL_MATERIAL,D.Color)})),this._bindParameters.hasOccludees=has.occludees}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,r,t,s,i){const a=null!=e;this._isRendering=!0,this.performanceInfo.startFrame(),this.fboCache.frame(),this._disposeBindBuffers();const h=this._offscreen,{camera:o,contentCamera:d,mode:l,alignPixelEnabled:_}=t;this._state=l,this._bindParameters.overlay=this.renderOverlay(i),this.performanceInfo.advance(le.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=ie.NONE,this._bindParameters.alignPixelEnabled=_,this._bindParameters.decorations=s;const p=E(this._sliceHelper.plane);s===B.OFF&&(this._sliceHelper.plane=null),o.setGLViewport(this._rctx);const u=h.initializeFrame(o,this._backgroundColor,a);this.hasReflections?this._bindParameters.ssr.lastFrameColor=u:u?.release(),this._prepare(o,d),this._renderPlugins.prepareRender(),this.performanceInfo.advance(le.PREPARE);const c=this._computeDepthRange(o);this._renderShadowMap(o,this._bindParameters.lighting.mainLight.direction,c),this.performanceInfo.advance(le.SHADOW_MAP),this._ensureBindParameters(o,d);const m=this._renderPlugins.produces($.OPAQUE_TERRAIN)&&(this._terrainTransparency===S.Semitransparent||this._terrainTransparency===S.TransparentWithDraped),f=this._highQualityTransparency&&m,g=this._needsTransparentPass||this._renderPlugins.produces($.TRANSPARENT_MATERIAL);this._prepareShaders(f,g),this._renderLinearDepth(),this.performanceInfo.advance(le.LINEAR_DEPTH),this._renderShadowAccumulation(c,o,d),this.performanceInfo.advance(le.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(),this.performanceInfo.advance(le.SSAO),this._renderContext.output=D.Color,h.bindFbo(),this._renderOpaqueGeometry(),this._renderPlugins.render($.ENVIRONMENT_OPAQUE),this.performanceInfo.advance(le.OPAQUE),this._renderTerrainLinearDepth(f),this._setMultipassTerrain(f),this._renderEdges(ne.OPAQUE),this.performanceInfo.advance(le.OPAQUE_EDGES),h.bindFbo(),this._renderPlugins.render($.VOXEL),this.performanceInfo.advance(le.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOITPass(fe.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(le.TRANSPARENT);const T=this._renderGeometryLinearDepth(f);this._renderHUDVisibility(T),f||this._renderInternalSlot($.LINE_CALLOUTS),this.performanceInfo.advance(le.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(le.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(ne.TRANSPARENT,T),this._releaseGeometryLinearDepth(T),this.performanceInfo.advance(le.TRANSPARENT_EDGES);const A=m?this._renderTransparentTerrain():null;A&&this._bindParameters.hudVisibility&&(f?this._renderLineCallouts(O.Occluded):h.compositeToHUDVisibility(this._bindParameters,A.colorTexture),this._renderHUD(O.Occluded,h.color),this.performanceInfo.advance(le.HUD_OCCLUDED)),this.performanceInfo.advance(le.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),A&&(h.compositeToFramebuffer(this._bindParameters,A.colorTexture,oe.PremultipliedAlpha,1),A.release(),f&&(this._renderEdges(ne.OPAQUE),this.performanceInfo.advance(le.OPAQUE_EDGES),g&&(this._oitEnabled?this._renderOITPass(fe.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(le.TRANSPARENT),this._renderEdges(ne.TRANSPARENT),this.performanceInfo.advance(le.TRANSPARENT_EDGES))),this._bindParameters.ssao=n(this._bindParameters.ssao),f&&this._renderLineCallouts(O.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),h.bindFbo(),this._renderInternalSlot($.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.render($.ENVIRONMENT_TRANSPARENT),this.performanceInfo.advance(le.ENVIRONMENT),this._renderLaserlines(),this.performanceInfo.advance(le.LASER_LINES),this._renderOccluded(),this.performanceInfo.advance(le.OCCLUDED);const P=this._magnifierEnabled&&null==e?this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height,"magnifier"):null,R=this._renderComposite(P??e,this._offscreen.color)??e;this.performanceInfo.advance(le.ANTIALIASING),this._renderHUD(O.NotOccluded,R),this.performanceInfo.advance(le.HUD),this._renderHighlights(R,this._bindParameters),this.performanceInfo.advance(le.HIGHLIGHTS),this._magnifierEnabled&&this._magnifierHelper.render(this._rctx,this._bindParameters),R!==e&&(this._rctx.bindFramebuffer(e?.fbo),this._compositingHelper.composite(this._bindParameters,P?.colorTexture,oe.None)),P!==e&&P?.release(),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=p,this._isRendering=!1,this.performanceInfo.finishFrame(),a&&(this._releaseFBOs(),this._disposeOffscreenBuffers())}_prepareShaders(e,r){this._renderContext.output=D.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._renderPlugins.prepare($.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,$.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,$.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.prepare($.ENVIRONMENT_TRANSPARENT),this._renderPlugins.prepare($.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(e){if(null==e||!has("enable-feature:objectAndLayerId-rendering"))return;const r=this._renderContext.output;this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>this._renderAllGeometry(D.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=O.NotOccluded,this._renderInternalSlot($.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===G.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._bindParameters.linearDepth?.fbo;if(s?.colorTexture)return void s.readPixels(r[0],r[1],r[2],r[3],pe.RGBA,ue.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height,"depth").acquireDepth(I.DEPTH16_BUFFER);this._rctx.bindFramebuffer(i.fbo),this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const a=ce.COLOR_BUFFER_BIT|ce.DEPTH_BUFFER_BIT|ce.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderAllGeometry(D.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],pe.RGBA,ue.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,pe.RGBA,ue.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(C.RGBA,s,i,"edges"),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,Te),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,oe.Alpha,1),n.release()}}_renderShadowMap(e,r,t){const s=this._shadowMap;s.enabled&&(s.start(e,r,t,this.isFeatureEnabled(Z.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(e,r),this._needsShadowHighlight?(this._renderShadowCascades(D.ShadowHighlight,this._shadowMap),s.moveSnapshot(te.Highlight),s.clear(),this._renderShadowCascades(D.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(te.Default),this._renderShadowCascades(D.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(D.Shadow),s.finish(),e.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap){for(const t of r.cascades)t.camera.setGLViewport(this._rctx),this._prepare(t.camera,t.camera),this._renderAllGeometry(e)}get _needsLinearDepth(){return this._renderPlugins.consumes(D.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,"linear depth",(()=>this._renderAllGeometry(D.Depth)),[0,0,0,0],C.RGBA,I.DEPTH_STENCIL_BUFFER),this._bindParameters.linearDepth.releaseDepth(),this._offscreen.bindFbo()):this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=D.Depth,this._bindParameters.multipassTerrain.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassTerrain.linearDepth,"terrain depth",(()=>this._renderTransparentTerrain()),[-1e10,-1e10,-1e10,1]),this._bindParameters.multipassTerrain.linearDepth.releaseDepth(),this._renderContext.output=e}else this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth)}_renderGeometryLinearDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth));const r=this._renderContext.output;return this._bindParameters.multipassGeometry.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassGeometry.linearDepth,"geometry depth",(()=>this._renderOpaqueGeometryAndTransparentMaterial(D.Depth)),[1,1,1,1],C.RGBA,this._geometryLinearDepthFormat),this._renderContext.output=r,this._bindParameters.multipassGeometry.linearDepth.detachDepth()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return V;const r=W(e,this._materialRenderers,this._stage.layers);return Q(r,this._renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderAllGeometry(e){this._renderContext.output=e,this._renderPlugins.prepare($.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._renderPlugins.prepare($.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderSSAO(){if(!this._renderPlugins.produces($.SSAO))return;const e=this._offscreen.renderToCachedFBO(null,"normals",(()=>this._renderAllGeometry(D.Normal)),[0,0,0,0],C.RGBA,I.DEPTH_STENCIL_BUFFER);e.releaseDepth(),this._offscreen.bindFbo(),this._pluginInput.normal=e,this._bindParameters.ssao=this._renderPlugins.render($.SSAO,this._pluginInput),e.release()}_prepareOpaqueGeometrySlots(){this._renderPlugins.prepare($.INTEGRATED_MESH),this._renderPlugins.prepare($.OPAQUE_TERRAIN),this._renderPlugins.prepare($.OPAQUE_MATERIAL),this._renderPlugins.prepare($.ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,$.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderPlugins.render($.INTEGRATED_MESH),this._renderPlugins.render($.OPAQUE_TERRAIN),this._renderInternalSlot($.OPAQUE_MATERIAL),this._renderPlugins.render($.OPAQUE_MATERIAL)}_renderTransparentMaterial(){this._renderInternalSlot($.TRANSPARENT_MATERIAL),this._renderPlugins.render($.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){if(!this._renderPlugins.produces($.TRANSPARENT_TERRAIN))return;const e=()=>this._renderPlugins.render($.TRANSPARENT_TERRAIN,null);if(this._renderContext.output!==D.Color)return void e();const{width:r,height:t,depth:s}=this._offscreen,i=this.fboCache.acquire(C.RGBA,r,t,"transparent terrain");return this._offscreen.renderToTargets(e,i,s,[0,0,0,0]),i}_renderHUDVisibility(e){this._shouldRenderInternalSlot(this._materialRenderers,$.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._renderInternalSlot($.OCCLUSION_PIXELS)),e),this._offscreen.bindFbo()):this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===O.Occluded){const e=()=>this._renderInternalSlot($.LINE_CALLOUTS),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(I.DEPTH16_BUFFER,r,t,"line callouts");this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderInternalSlot($.LINE_CALLOUTS)}_renderLaserlines(){if(this._renderPlugins.render($.LASERLINES),this._renderPlugins.produces($.LASERLINES_CONTRAST_CONTROL)){const e=this._offscreen,{width:r,height:t,depth:s}=e,i=this.fboCache.acquire(C.RGBA,r,t,"laser lines"),a=()=>this._renderPlugins.render($.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,Te),e.compositeToFramebuffer(this._bindParameters,i.colorTexture,oe.PremultipliedAlpha,1),i.release()}}_renderHUD(e,r){if(this._materialRenderersHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(fe.HUD,e);this._rctx.bindFramebuffer(r?.fbo),this._compositingHelper.composite(this._bindParameters,t.colorTexture,oe.PremultipliedAlpha),t.release()}else if(e===O.Occluded){const r=()=>this._renderHUDElements(e),{width:t,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(I.DEPTH16_BUFFER,t,s,"hud");this._offscreen.renderToTargets(r,i,a,void 0,!0,!0),a.release()}else this._rctx.bindFramebuffer(null),r?.acquireDepth(I.DEPTH16_BUFFER),this._rctx.bindFramebuffer(r?.fbo),this._renderHUDElements(e),r?.releaseDepth()}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,$.LINE_CALLOUTS_HUD_DEPTH,$.HUD_MATERIAL,$.LABEL_MATERIAL),this._renderInternalSlot($.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot($.HUD_MATERIAL),this._renderInternalSlot($.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._renderPlugins.produces($.SHADOW_HIGHLIGHT)&&this.hasShadowHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===B.OFF)return;const t=()=>{this._renderAllGeometry(D.Highlight),this._rctx.clearSafe(ce.DEPTH_BUFFER_BIT),this._renderHUDElements(O.Both)},s=this._offscreen.renderToCachedFBO(null,"highlight",t,[0,0,0,0],C.RGBA4,I.DEPTH_STENCIL_BUFFER);s.releaseDepth(),this._needsShadowHighlight&&(this._pluginInput.highlight=s,this._renderPlugins.render($.SHADOW_HIGHLIGHT,this._pluginInput,e)),this._renderPlugins.produces($.HIGHLIGHT)&&(this._pluginInput.composite=null,this._pluginInput.normal=null,this._pluginInput.highlight=s,this._renderPlugins.render($.HIGHLIGHT,this._pluginInput,e)),s.release()}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=D.Alpha,this._bindParameters.transparencyPassType=ie.Alpha,this._prepareInternalSlots(this._materialRenderers,$.TRANSPARENT_MATERIAL),this._renderPlugins.prepare($.TRANSPARENT_MATERIAL),this._renderContext.output=D.Color,this._bindParameters.transparencyPassType=ie.Color,this._prepareInternalSlots(this._materialRenderers,$.TRANSPARENT_MATERIAL),this._renderPlugins.prepare($.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=ie.FrontFace,this._prepareInternalSlots(this._materialRenderers,$.TRANSPARENT_MATERIAL),this._renderPlugins.prepare($.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=ie.NONE}_renderOITPass(e,r=O.Both){const t=e===fe.HUD,s=t?this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height,"oit hud"):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentMaterial(),a=this._renderContext.output;this._renderContext.output=D.Alpha,this._bindParameters.transparencyPassType=ie.Alpha;const n=this._offscreen.renderOITPass(i,ie.Alpha,t);this._renderContext.output=D.Color,this._bindParameters.transparencyPassType=ie.Color;const h=this._offscreen.renderOITPass(i,ie.Color,t);this._bindParameters.transparencyPassType=ie.FrontFace;const o=this._offscreen.renderOITPass(i,ie.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=ie.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;Ae.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.parameters.renderOccluded===k.OccludeAndTransparentStencil&&(e|=r.material.parameters.renderOccluded,Ae.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{if(0==(e&s))return;const{width:h,height:o,depth:d}=r,l=this.fboCache.acquire(C.RGBA,h,o,"tmp color");r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,oe.PremultipliedAlpha,t),l.release()};0!==Ae.length&&(this._prepareInternalSlots(Ae,$.OCCLUDER_MATERIAL,$.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot($.OCCLUDER_MATERIAL,Ae),t(.5,k.OccludeAndTransparentStencil,(()=>this._renderInternalSlot($.TRANSPARENT_OCCLUDER_MATERIAL,Ae)),!1,!1)),Ae.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.parameters.renderOccluded===k.OccludeAndTransparent||r.material.parameters.renderOccluded===k.Transparent||r.material.parameters.renderOccluded===k.Opaque)&&(e|=r.material.parameters.renderOccluded,Ae.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(Ae,$.OPAQUE_MATERIAL,$.TRANSPARENT_MATERIAL,$.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>k.Occlude&&this._renderPlugins.render($.OCCLUDED_TERRAIN),this._renderInternalSlot($.OPAQUE_MATERIAL,Ae),this._renderInternalSlot($.TRANSPARENT_MATERIAL,Ae),this._renderInternalSlot($.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Ae),this._renderContext.renderOccludedMask=z};this._renderContext.output=D.Color,t(.5,k.OccludeAndTransparent,(()=>i(k.OccludeAndTransparent)),!0,j.OutlineVisualElementMask),t(.5,k.Transparent,(()=>i(k.Transparent)),!0,j.OutlineVisualElementMask),t(1,k.Opaque,(()=>i(k.Opaque)),!0,j.OutlineVisualElementMask),Ae.clear()}_renderComposite(e,r){this._renderPlugins.consumes(D.CompositeColor)&&(this._pluginInput.composite=r);let t=null;const s=this._renderPlugins.produces($.COMPOSITE);s&&(t=this._renderPlugins.renderComposition($.COMPOSITE,this._pluginInput),this._pluginInput.composite=t);const i=this._renderPlugins.produces($.ANTIALIASING),a=this._renderPlugins.render(i?$.ANTIALIASING:$.BLIT,this._pluginInput,e);return s&&t?.release(),a}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.material.produces($.TRANSPARENT_MATERIAL,D.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.mainColor=t.colorTexture,this._bindParameters.mainDepth=t.depthTexture}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(m(Re,this._bindParameters.camera.viewMatrix),m(Pe,this._bindParameters.camera.projectionMatrix),f(Ee,Re,Pe),f(Ee,this._renderContext.lastFrameCamera.viewMatrix,Ee),f(Ee,this._renderContext.lastFrameCamera.projectionMatrix,Ee),this._reprojectionMatrix=Ee);const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._ssrEnableTime=null}_shouldRenderInternalSlot(e,r){return this._bindParameters.slot=r,e.some((e=>null!=e.prepareTechnique(this._renderContext)))}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>null!=e.prepareTechnique(this._renderContext)))}_renderInternalSlot(e,r=this._materialRenderers){this._bindParameters.slot=e,r.forAll((e=>{const r=e.prepareTechnique(this._renderContext);r&&e.renderNode(this._renderContext,r)}))}get memoryInfo(){return{fbos:this.fboCache.usedMemory,vaos:this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0),plugins:this._renderPlugins.usedMemory}}getMemoryForMaterial(e){if(null==e)return 0;const r=this._materialRenderers.find((r=>r.material===e));return r?.usedMemory??0}get usedMemory(){return this.fboCache.usedMemory+(this.edgeView?.usedMemory??0)+this._renderPlugins.usedMemory}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=K(),this._renderPlugins.renderFeatureChanged(),this._requestRender()},releaseGeometryLinearDepth(r){e._releaseGeometryLinearDepth=r??(e=>e?.release()),e._geometryLinearDepthFormat=r?I.DEPTH_STENCIL_TEXTURE:I.DEPTH16_BUFFER},getFramebufferTexture:r=>{switch(r){case ge.Color:return e._offscreen.colorTexture;case ge.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case ge.ShadowMap:return e._shadowMap.depthTexture;case ge.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var fe,ge;e([p()],me.prototype,"_renderPlugins",void 0),e([p()],me.prototype,"_shadowAccumulator",void 0),e([p()],me.prototype,"_state",void 0),e([p()],me.prototype,"_renderStateFeatures",void 0),e([p({readOnly:!0})],me.prototype,"fullResolutionAtmosphere",null),e([p()],me.prototype,"_smaa",void 0),e([p()],me.prototype,"_blit",void 0),e([p({autoDestroy:!0})],me.prototype,"_edgeView",void 0),e([p()],me.prototype,"updating",null),e([p()],me.prototype,"isCameraFinal",null),me=e([u("esri.views.3d.webgl-engine.lib.Renderer")],me),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(fe||(fe={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(ge||(ge={}));const Te=[0,0,0,0],Ae=new h,Pe=T(),Re=T(),Ee=T();function be(e){return r=>e.immediate.schedule(r)}export{ge as FramebufferId,me as Renderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as o,lookAt as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as n,create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as _,add as d,scale as u,lerp as m,squaredDistance as f,subtract as p,dot as g,negate as x,normalize as b,copy as M}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as w}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as C,c as T,E as j,e as y,s as D}from"../../../../chunks/vec32.js";import{create as H}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as v,t as S}from"../../../../chunks/vec42.js";import{create as F}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{ColorFormat as O,DepthFormat as E}from"../core/FBOCache.js";import{CascadeCamera as U}from"./CascadeCamera.js";import{applyTextureResizeModulo as B}from"./textureUtils.js";import{assert as
|
|
5
|
+
import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as o,lookAt as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as n,create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as _,add as d,scale as u,lerp as m,squaredDistance as f,subtract as p,dot as g,negate as x,normalize as b,copy as M}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as w}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as C,c as T,E as j,e as y,s as D}from"../../../../chunks/vec32.js";import{create as H}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as v,t as S}from"../../../../chunks/vec42.js";import{create as F}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{ColorFormat as O,DepthFormat as E}from"../core/FBOCache.js";import{CascadeCamera as U}from"./CascadeCamera.js";import{applyTextureResizeModulo as B,applyTextureResizeFloorModulo as L}from"./textureUtils.js";import{assert as N,logWithBase as Q,verify as V,rayRay2D as I}from"./Util.js";import{TextureType as A,ClearBufferBit as W}from"../../../webgl/enums.js";import{Texture as z}from"../../../webgl/Texture.js";var P;!function(t){t[t.Highlight=0]="Highlight",t[t.Default=1]="Default"}(P||(P={}));class q{constructor(){this.camera=new U,this.lightMat=l()}}class G{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class X{get depthTexture(){return this._handle?.colorTexture}get _textureWidth(){return this._textureHeight*this._numCascades}get numCascades(){return this._numCascades}get cascadeDistances(){return v(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}constructor(t,s){this._fbos=t,this._viewingMode=s,this._enabled=!1,this._snapshots=new Array,this._textureHeight=0,this._numCascades=1,this.settings=new G,this._projectionView=l(),this._projectionViewInverse=l(),this._modelViewLight=l(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=F(),this._cascades=[new q,new q,new q,new q],this._lastOrigin=null,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}disposeOffscreenBuffers(){this._handle=i(this._handle),this._discardSnapshots()}set maxCascades(s){this.settings.maxNumCascadesHighQuality=t(Math.floor(s),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get enabled(){return this._enabled}get ready(){return this._enabled&&null!=this.depthTexture}get cascades(){for(let t=0;t<this._numCascades;++t)it[t]=this._cascades[t];return it.length=this._numCascades,it}start(t,s,e,i,a){N(this.enabled);const{near:r,far:h}=this._clampNearFar(e);this._computeCascadeDistances(r,h,i),this._textureHeight=this._computeTextureHeight(t,a,i),this._setupMatrices(t,s);const{viewMatrix:o,projectionMatrix:c}=t;for(let n=0;n<this._numCascades;++n)this._constructCascade(n,c,o,s);this._lastOrigin=null,this.clear()}finish(){N(this.enabled),this._handle?.releaseDepth()}getShadowMapMatrices(t){if(!this._lastOrigin||!C(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||H(),T(this._lastOrigin,t);for(let s=0;s<this._numCascades;++s){r(at,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)rt[16*s+t]=at[t]}}return rt}moveSnapshot(t){N(this.enabled),this._handle?.releaseDepth(),this._snapshots[t]?.release(),this._snapshots[t]=this._handle,this._handle=null}copySnapshot(t){const s=this._handle?.colorTexture?.descriptor;if(!this.enabled||!s)return;this._snapshots[t]?.release();const{width:e,height:i}=s;this._snapshots[t]=this._fbos.acquire(O.RGBA4,e,i,`shadow snap ${t}`);const a=this._fbos.rctx;this._bindFbo();const r=a.bindTexture(this._snapshots[t]?.colorTexture,z.TEXTURE_UNIT_FOR_UPDATES);a.gl.copyTexSubImage2D(A.TEXTURE_2D,0,0,0,0,0,e,i),a.bindTexture(r,z.TEXTURE_UNIT_FOR_UPDATES)}getSnapshot(t){return this.enabled?this._snapshots[t]?.colorTexture:null}clear(){const t=this._fbos.rctx;this._ensureFbo(),this._bindFbo(),t.setClearColor(1,1,1,1),t.clearSafe(W.COLOR_BUFFER_BIT|W.DEPTH_BUFFER_BIT)}_computeTextureHeight(t,s,e){const i=Math.min(window.devicePixelRatio,s)/t.pixelRatio,a=e?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality,r=B(Math.floor(Math.max(t.fullWidth,t.fullHeight)*i*a)),h=Math.min(this._maxTextureWidth,this._numCascades*r);return L(h/this._numCascades)}_ensureFbo(){this._handle?.fbo.width===this._textureWidth&&this._handle?.fbo.height===this._textureHeight||(this._handle?.release(),this._handle=this._fbos.acquire(O.RGBA4,this._textureWidth,this._textureHeight,"shadow map")),this._handle.acquireDepth(E.DEPTH16_BUFFER)}_discardSnapshot(t){this._snapshots[t]=i(this._snapshots[t])}_discardSnapshots(){for(let t=0;t<this._snapshots.length;++t)this._discardSnapshot(t);this._snapshots.length=0}_bindFbo(){const t=this._fbos.rctx;t.unbindTexture(this.depthTexture),t.bindFramebuffer(this._handle?.fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],o=-this._cascadeDistances[t],c=-this._cascadeDistances[t+1],n=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]),l=(s[10]*c+s[14])/Math.abs(s[11]*c+s[15]);N(n<l);for(let r=0;r<8;++r){v($,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?n:l,1);const t=J[r];S(t,$,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}j(et,J[0]),a.camera.viewMatrix=r(k,this._modelViewLight,et);for(let r=0;r<8;++r)y(J[r],J[r],a.camera.viewMatrix);let _=J[0][2],d=J[0][2];for(let r=1;r<8;++r)_=Math.min(_,J[r][2]),d=Math.max(d,J[r][2]);_-=200,d+=200,a.camera.near=-d,a.camera.far=-_,Tt(e,i,_,d,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const u=this._textureHeight;a.camera.viewport=[t*u,0,u,u]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===R.Global?t.eye:D(et,0,0,1);c(this._modelViewLight,[0,0,0],[-s[0],-s[1],-s[2]],e)}_clampNearFar(t){let{near:s,far:e}=t;return s<2&&(s=2),e<2&&(e=2),s>=e&&(s=2,e=4),{near:s,far:e}}_computeCascadeDistances(t,e,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(Q(e/t,4)),a);const r=(e-t)/this._numCascades,h=(e/t)**(1/this._numCascades);let o=t,c=t;for(let n=0;n<this._numCascades+1;++n)this._cascadeDistances[n]=s(o,c,this.settings.splitSchemeLambda),o*=h,c+=r}get test(){return{cascades:this._cascades,textureHeight:this._textureHeight}}}const k=l(),$=F(),J=[];for(let jt=0;jt<8;++jt)J.push(F());const K=w(),Y=w(),Z=w(),tt=w(),st=w(),et=H(),it=[],at=l(),rt=n.concat(n,n,n,n),ht=w(),ot=w(),ct=[w(),w(),w(),w()],nt=w(),lt=w(),_t=w(),dt=w(),ut=w(),mt=w(),ft=w();function pt(t,s,e,i,a,r,h,o){_(ht,0,0);for(let _=0;_<4;++_)d(ht,ht,t[_]);u(ht,ht,.25),_(ot,0,0);for(let _=4;_<8;++_)d(ot,ot,t[_]);u(ot,ot,.25),m(ct[0],t[4],t[5],.5),m(ct[1],t[5],t[6],.5),m(ct[2],t[6],t[7],.5),m(ct[3],t[7],t[4],.5);let c=0,n=f(ct[0],ht);for(let _=1;_<4;++_){const t=f(ct[_],ht);t<n&&(n=t,c=_)}p(nt,ct[c],t[c+4]);const l=nt[0];let w,C;nt[0]=-nt[1],nt[1]=l,p(lt,ot,ht),g(lt,nt)<0&&x(nt,nt),m(nt,nt,lt,e),b(nt,nt),w=C=g(p(_t,t[0],ht),nt);for(let _=1;_<8;++_){const s=g(p(_t,t[_],ht),nt);s<w?w=s:s>C&&(C=s)}M(i,ht),u(_t,nt,w-s),d(i,i,_t);let T=-1,j=1,y=0,D=0;for(let _=0;_<8;++_){p(dt,t[_],i),b(dt,dt);const s=nt[0]*dt[1]-nt[1]*dt[0];s>0?s>T&&(T=s,y=_):s<j&&(j=s,D=_)}V(T>0,"leftArea"),V(j<0,"rightArea"),u(ut,nt,w),d(ut,ut,ht),u(mt,nt,C),d(mt,mt,ht),ft[0]=-nt[1],ft[1]=nt[0];const H=I(i,t[D],mt,d(_t,mt,ft),1,a),v=I(i,t[y],mt,_t,1,r),S=I(i,t[y],ut,d(_t,ut,ft),1,h),F=I(i,t[D],ut,_t,1,o);V(H,"rayRay"),V(v,"rayRay"),V(S,"rayRay"),V(F,"rayRay")}function gt(t,s){return 3*s+t}const xt=w();function bt(t,s){return _(xt,t[s],t[s+3]),xt}const Mt=w(),wt=a();function Ct(t,s,e,i,a){p(Mt,e,i),u(Mt,Mt,.5),wt[0]=Mt[0],wt[1]=Mt[1],wt[2]=0,wt[3]=Mt[1],wt[4]=-Mt[0],wt[5]=0,wt[6]=Mt[0]*Mt[0]+Mt[1]*Mt[1],wt[7]=Mt[0]*Mt[1]-Mt[1]*Mt[0],wt[8]=1,wt[gt(0,2)]=-g(bt(wt,0),t),wt[gt(1,2)]=-g(bt(wt,1),t);let r=g(bt(wt,0),e)+wt[gt(0,2)],h=g(bt(wt,1),e)+wt[gt(1,2)],o=g(bt(wt,0),i)+wt[gt(0,2)],c=g(bt(wt,1),i)+wt[gt(1,2)];r=-(r+o)/(h+c),wt[gt(0,0)]+=wt[gt(1,0)]*r,wt[gt(0,1)]+=wt[gt(1,1)]*r,wt[gt(0,2)]+=wt[gt(1,2)]*r,r=1/(g(bt(wt,0),e)+wt[gt(0,2)]),h=1/(g(bt(wt,1),e)+wt[gt(1,2)]),wt[gt(0,0)]*=r,wt[gt(0,1)]*=r,wt[gt(0,2)]*=r,wt[gt(1,0)]*=h,wt[gt(1,1)]*=h,wt[gt(1,2)]*=h,wt[gt(2,0)]=wt[gt(1,0)],wt[gt(2,1)]=wt[gt(1,1)],wt[gt(2,2)]=wt[gt(1,2)],wt[gt(1,2)]+=1,r=g(bt(wt,1),s)+wt[gt(1,2)],h=g(bt(wt,2),s)+wt[gt(2,2)],o=g(bt(wt,1),e)+wt[gt(1,2)],c=g(bt(wt,2),e)+wt[gt(2,2)],r=-.5*(r/h+o/c),wt[gt(1,0)]+=wt[gt(2,0)]*r,wt[gt(1,1)]+=wt[gt(2,1)]*r,wt[gt(1,2)]+=wt[gt(2,2)]*r,r=g(bt(wt,1),s)+wt[gt(1,2)],h=g(bt(wt,2),s)+wt[gt(2,2)],o=-h/r,wt[gt(1,0)]*=o,wt[gt(1,1)]*=o,wt[gt(1,2)]*=o,a[0]=wt[0],a[1]=wt[1],a[2]=0,a[3]=wt[2],a[4]=wt[3],a[5]=wt[4],a[6]=0,a[7]=wt[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=wt[6],a[13]=wt[7],a[14]=0,a[15]=wt[8]}function Tt(t,s,i,a,r){const h=1/J[0][3],o=1/J[4][3];N(h<o);let c=h+Math.sqrt(h*o);const n=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));c/=n,pt(J,c,n,K,Y,Z,tt,st),Ct(K,Y,tt,st,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}export{X as ShadowMap,P as SnapshotSlot};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../core/Error.js";const e=16;function n(t){return Math.ceil(t/e)*e}function i(t,e){const n=1048576,i=4096,
|
|
5
|
+
import t from"../../../../core/Error.js";const e=16;function n(t){return Math.ceil(t/e)*e}function i(t){return Math.floor(t/e)*e}function r(t,e){const n=1048576,i=4096,r=2;let h=t.width*t.height;if(h<i)return t instanceof ImageData?a(t):t;let c=t.width,u=t.height;do{c=Math.ceil(c/r),u=Math.ceil(u/r),h=c*u}while(h>n||null!=e&&(c>e||u>e));return o(t,c,u)}function h(t,e){const n=Math.max(t.width,t.height);if(n<=e)return t;const i=e/n;return o(t,Math.round(t.width*i),Math.round(t.height*i))}function o(t,e,n){if(t instanceof ImageData)return o(a(t),e,n);const i=document.createElement("canvas");i.width=e,i.height=n;return i.getContext("2d").drawImage(t,0,0,i.width,i.height),i}function a(e){const n=document.createElement("canvas");n.width=e.width,n.height=e.height;const i=n.getContext("2d");if(null==i)throw new t("Failed to create 2d context from HTMLCanvasElement");return i.putImageData(e,0,0),n}export{i as applyTextureResizeFloorModulo,n as applyTextureResizeModulo,r as downsampleImage,h as ensureImageMaxSize};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as r}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as m}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as f}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as x,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as w,Component as V}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import{fromPoint as T,toDehydratedPoint as b}from"../interactive/sketch/normalizedPoint.js";import M from"../interactive/sketch/SketchLabelOptions.js";import C from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as P}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as D}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as I}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as E}from"../interactive/snapping/snappingUtils.js";const H="crosshair",j="progress";let k=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._stagedPointerId=null,this._updatingHandles=new g,this.constraint=void 0,this.isDraped=!0,this.labelOptions=new M,this.tooltipOptions=new C,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=m(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,o="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=f(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new w(o,this.coordinateHelper)),this._snappingOperation=new I({view:t,constrainResult:e=>e?this._getEffectiveDrawSurface()?.constrainZ(e):void 0}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>r(e,t,u)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new V(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),o=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=o&&null!=this.lastVertex&&u(this.lastVertex,o)||(this.lastVertex=o)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:e})=>{l.cursor=e}),p)]),E(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get effectiveCursor(){return this.loading?j:this._hideDefaultCursor?null:this.cursor||H}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){const e=this._snappingOperation.stagedPoint,{constraint:t,elevationInfo:i,view:n}=this;if(e&&t){const o=t.closestTo(T(e,n,i));if(o)return b(o,e.spatialReference)}return e}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return x(e,((e,t,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=D({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||o&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...r).next((e=>(o&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType,this._stagedPointerId=e.pointerId;const i=this._snappingOperation,n=this._manipulator;this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._pointerDownStates.has(this._stagedPointerId)&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const o=this._screenToMap(e),r=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==o)return this._hideDefaultCursor=!0,void i.abort();this._hideDefaultCursor=!1;const a=this.snappingManager;if(null==a)return this.stagedVertex=o,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:o,scenePoint:r},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&G(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function G(e,t,i){const n=e.x-t.x,o=e.y-t.y;return n*n+o*o<=i}e([l()],k.prototype,"_hideDefaultCursor",void 0),e([l()],k.prototype,"_snappingOperation",void 0),e([l()],k.prototype,"_snappingEnabled",null),e([l({constructOnly:!0})],k.prototype,"graphic",void 0),e([l()],k.prototype,"constraint",void 0),e([l()],k.prototype,"defaultZ",void 0),e([l()],k.prototype,"isDraped",void 0),e([l({value:y})],k.prototype,"drawingMode",null),e([l({constructOnly:!0})],k.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:M})],k.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:C})],k.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],k.prototype,"geometryType",void 0),e([l({constructOnly:!0})],k.prototype,"hasM",void 0),e([l({constructOnly:!0})],k.prototype,"hasZ",void 0),e([l()],k.prototype,"cursor",void 0),e([l()],k.prototype,"effectiveCursor",null),e([l()],k.prototype,"loading",void 0),e([l({constructOnly:!0})],k.prototype,"manipulators",void 0),e([l({constructOnly:!0})],k.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],k.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],k.prototype,"snappingVisualizer",void 0),e([l()],k.prototype,"snapToSceneEnabled",void 0),e([l()],k.prototype,"stagedVertex",null),e([l()],k.prototype,"lastVertex",void 0),e([l()],k.prototype,"updating",null),e([l({constructOnly:!0})],k.prototype,"view",void 0),k=e([d("esri.views.draw.DrawOperation")],k);export{k as DrawOperation,H as defaultCursor,j as defaultLoadingCursor};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as r}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as m}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as f}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as x,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as w,Component as V}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import{fromPoint as T,toDehydratedPoint as b}from"../interactive/sketch/normalizedPoint.js";import M from"../interactive/sketch/SketchLabelOptions.js";import P from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as C}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as D}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as I}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as E}from"../interactive/snapping/snappingUtils.js";const H="crosshair",j="progress";let k=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._stagedPointerId=null,this._updatingHandles=new g,this.constraint=void 0,this.isDraped=!0,this.labelOptions=new M,this.tooltipOptions=new P,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=m(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,o="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=f(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new w(o,this.coordinateHelper)),this._snappingOperation=new I({view:t,constrainResult:e=>e?this._getEffectiveDrawSurface()?.constrainZ(e):void 0}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>r(e,t,u)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new V(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),o=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=o&&null!=this.lastVertex&&u(this.lastVertex,o)||(this.lastVertex=o)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:e})=>{l.cursor=e}),p)]),E(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get effectiveCursor(){return this.loading?j:this._hideDefaultCursor?null:this.cursor||H}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){const e=this._snappingOperation.stagedPoint,{constraint:t,elevationInfo:i,view:n}=this;if(e&&t){const o=t.closestTo(T(e,n,i));if(o)return b(o,e.spatialReference)}return e}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return x(e,((e,t,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=D({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new C({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||o&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...r).next((e=>(o&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType,this._stagedPointerId=e.pointerId;const i=this._snappingOperation,n=this._manipulator;this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._pointerDownStates.has(this._stagedPointerId)&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const o=this._screenToMap(e),r=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==o)return this._hideDefaultCursor=!0,void i.abort();this._hideDefaultCursor=!1;const a=this.snappingManager;if(null==a)return this.stagedVertex=o,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:o,scenePoint:r},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&G(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new C({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function G(e,t,i){const n=e.x-t.x,o=e.y-t.y;return n*n+o*o<=i}e([l()],k.prototype,"_hideDefaultCursor",void 0),e([l()],k.prototype,"_snappingOperation",void 0),e([l()],k.prototype,"_snappingEnabled",null),e([l({constructOnly:!0})],k.prototype,"graphic",void 0),e([l()],k.prototype,"constraint",void 0),e([l()],k.prototype,"defaultZ",void 0),e([l()],k.prototype,"isDraped",void 0),e([l({value:y})],k.prototype,"drawingMode",null),e([l({constructOnly:!0})],k.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:M})],k.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:P})],k.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],k.prototype,"geometryType",void 0),e([l({constructOnly:!0})],k.prototype,"hasM",void 0),e([l({constructOnly:!0})],k.prototype,"hasZ",void 0),e([l()],k.prototype,"cursor",void 0),e([l()],k.prototype,"effectiveCursor",null),e([l()],k.prototype,"loading",void 0),e([l({constructOnly:!0})],k.prototype,"manipulators",void 0),e([l({constructOnly:!0})],k.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],k.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],k.prototype,"snappingVisualizer",void 0),e([l()],k.prototype,"snapToSceneEnabled",void 0),e([l()],k.prototype,"stagedVertex",null),e([l()],k.prototype,"lastVertex",void 0),e([l()],k.prototype,"updating",null),e([l({constructOnly:!0})],k.prototype,"view",void 0),k=e([d("esri.views.draw.DrawOperation")],k);export{k as DrawOperation,H as defaultCursor,j as defaultLoadingCursor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as t,equals as e}from"../../../core/arrayUtils.js";import{asinClamped as r}from"../../../core/mathUtils.js";import{dot as n,subtract as s,squaredDistance as i}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{create as o}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as c,h as u,a,r as f,m as l,s as h,c as p,f as d,G as m,j as L,b as g,n as k}from"../../../chunks/vec32.js";import{clone as P,create as x,fromValues as T,UNIT_Z as j}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as q,g as v}from"../../../chunks/vec42.js";import{create as M}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as y,intersectLine as z,signedDistance as w,projectPoint as b,fromPositionAndNormal as A,fromPoints as E,distance as N,normal as Z}from"../../../geometry/support/plane.js";import{k as I,l as U,p as G,m as S}from"../../../chunks/sphere.js";import{tangentFrame as O}from"../../3d/support/mathUtils.js";import{fromVec3 as C,clone as D,fromValues as F}from"./normalizedPoint.js";import{vectorsHaveCloseZ as H,isClose as R,intersectVerticalPlaneAndVerticalCylinder as V,isPointInsidePlane as Y,projectPointToLineLike as _,projectPointToVerticalCylinder as B,projectPointToVerticalPlane as J,VerticalPlaneType as K,intersectLineLikes as Q,intersectVerticalPlaneAndLineLike as W,intersectLineLikeAndVerticalCylinder as X,intersectLineLikeAndCircle as $,intersectVerticalPlanes as tt,intersectVerticalCylinders as et,pointsInsidePlane as rt,intersectVerticalPlaneAndPoint as nt}from"../../support/geometry3dUtils.js";import{LineType as st}from"../../support/geometry2dUtils.js";class it{intersect(t){return wt(this,t)}closestPoints(t){return[this.closestTo(t)]}}class ot extends it{constructor(t){super(),this.point=t}equals(t){return this===t||re(t)&&u(this.point,t.point)}closestTo(){return D(this.point)}}class ct extends it{constructor(t,e,r){super(),this.start=t,this.end=e,this.lineLike={start:t,end:e,type:r}}equals(t){return this===t||ne(t)&&this.lineLike.type===t.lineLike.type&&u(this.start,t.start)&&u(this.end,t.end)}closestTo(t){const e=_(t,this.lineLike);return C(e)}}class ut extends ct{constructor(t,e){super(t,e,st.LINE)}}class at extends ct{constructor(t,e){super(t,e,st.RAY)}}class ft extends it{constructor(t){super(),this.constraints=t}equals(t){return this===t||ee(t)&&e(this.constraints,t.constraints,((t,e)=>t.equals(e)))}closestTo(t){let e,r=1/0;for(const n of this.constraints){const s=n.closestTo(t),i=a(t,s);i<r&&(r=i,e=s)}return e?D(e):t}closestPoints(t){return this.constraints.flatMap((e=>e===this?[]:e.closestPoints(t)))}}class lt extends it{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||oe(t)&&this.center[0]===t.center[0]&&this.center[1]===t.center[1]&&this.radius===t.radius}closestTo(t){const e=B(t,this.center,this.radius);return C(e)}}class ht extends it{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||ce(t)&&u(this.center,t.center)&&this.radius===t.radius}closestTo(t){const e=B(t,this.center,this.radius);return e[2]=this.center[2],C(e)}asCircle(){return new pt(D(this.center),this.radius,F(0,0,1))}}class pt extends it{constructor(t,e,r,n=void 0){super(),this.center=t,this.radius=e,this.normal=r,this.slicePlane=n}equals(t){return this===t||ue(t)&&u(this.center,t.center)&&u(this.normal,t.normal)&&this.radius===t.radius}closestTo(t){const{center:e,radius:r}=this;b(this.getPlane(mt),t,dt);const n=f(dt,dt,e),s=l(n);if(R(s,0))return D(t);const i=r/Math.sqrt(s),o=c(x(),e,n,i),{slicePlane:u}=this;if(u&&!Y(u,o)){const e=Nt(u,this);return e?.closestTo(t)??D(t)}return C(o)}getPlane(t=y()){return A(this.center,this.normal,t)}}const dt=x(),mt=y();class Lt extends it{constructor(t){super(),this.z=t}equals(t){return this===t||se(t)&&this.z===t.z}closestTo(t){return C(T(t[0],t[1],this.z))}getPlane(t=y()){return h(gt,0,0,this.z),A(gt,j,t)}}const gt=x();class kt extends it{constructor(t,e,r){super(),this.start=t,this.end=e,this.planeLike={start:t,end:e,type:r}}equals(t){return this===t||ie(t)&&this.planeLike.type===t.planeLike.type&&u(this.start,t.start)&&u(this.end,t.end)}closestTo(t){return C(J(t,this.planeLike))}closestEndTo(t){const{start:e,end:r}=this;return Math.sign(n(s(Pt,r,e),s(xt,t,e)))>0?r:e}getPlane(t=y()){const e=p(Tt,this.end);return e[2]+=1,E(this.start,this.end,e,t)}getSlicePlane(t=y()){const{start:e,end:r,type:n}=this.planeLike;if(n===K.PLANE)return;const s=h(Tt,e[0],e[1],0),i=h(jt,r[0],r[1],0),o=d(jt,i,s);return A(s,o,t),t}}const Pt=o(),xt=o(),Tt=x(),jt=x();class qt extends kt{constructor(t,e){super(t,e,K.HALF_PLANE)}}class vt extends kt{constructor(t,e){super(t,e,K.PLANE)}}class Mt extends it{constructor(t,e){super(),this.sphere=I(t,e)}equals(t){return this===t||ae(t)&&U(this.sphere,t.sphere)}closestTo(t){const e=G(this.sphere,t,x());return C(e)}get center(){return this.sphere}get radius(){return this.sphere[3]}}class yt extends it{constructor(t,e,r){super(),this.start=t,this.end=e,this.getZ=r,this.planeLike={start:t,end:e,type:K.PLANE}}equals(t){return this===t||fe(t)&&u(this.start,t.start)&&u(this.end,t.end)&&this.getZ===t.getZ}closestTo(t){return zt(this,t)}addIfOnTheGround(t,e){for(const r of e){const e=this.getZ(r[0],r[1],r[2])??0;R(r[2],e)&&(r[2]=e,t.push(r))}}}function zt(t,e){const r=J(e,t.planeLike);return r[2]=t.getZ(e[0],e[1],e[2])??le,C(r)}function wt(t,e){if(ee(t)){const r=[];for(const n of t.constraints){const t=n.intersect(e);t&&r.push(t)}return te(r)}if(ee(e))return wt(e,t);if(fe(t))return Qt(t,e);if(fe(e))return Qt(e,t);if(re(t)){const{point:r}=t,n=e.closestTo(r);return m(n,r)?t:void 0}if(ne(t)){if(re(e))return wt(e,t);if(ne(e))return Xt(Q(t.lineLike,e.lineLike));if(se(e))return bt(t,e);if(ie(e))return Xt(W(e.planeLike,t.lineLike));if(oe(e))return Xt(X(t.lineLike,e.center,e.radius));if(ue(e))return Xt($(t.lineLike,e));if(ce(e))return At(t,e);if(ae(e))return Et(t,e)}else if(se(t)){if(re(e)||ne(e))return wt(e,t);if(se(e))return Zt(t,e);if(ie(e))return It(t,e);if(oe(e))return Ut(t,e);if(ue(e))return St(t,e);if(ce(e))return Gt(t,e);if(ae(e))return Ot(t,e)}else if(ie(t)){if(re(e)||ne(e)||se(e))return wt(e,t);if(ie(e))return Wt(tt(t.planeLike,e.planeLike));if(oe(e))return Wt(V(t.planeLike,e.center,e.radius));if(ue(e))return Dt(t,e);if(ce(e))return Ct(t,e);if(ae(e))return Ft(t,e)}else if(oe(t)){if(re(e)||ne(e)||se(e)||ie(e))return wt(e,t);if(oe(e))return Wt(et(t.center,t.radius,e.center,e.radius));if(ue(e))return Ht();if(ce(e))return Rt(t,e);if(ae(e))return Vt()}else if(ue(t)){if(re(e)||ne(e)||se(e)||ie(e)||oe(e))return wt(e,t);if(ue(e))return Yt();if(ce(e))return Yt(e.asCircle());if(ae(e))return _t()}else if(ce(t)){if(re(e)||ne(e)||se(e)||ie(e)||oe(e)||ue(e))return wt(e,t);if(ce(e))return Bt(e,t);if(ae(e))return Jt()}else if(ae(t)){if(re(e)||ne(e)||se(e)||ie(e)||oe(e)||ce(e))return wt(e,t);if(ae(e))return Kt()}}const bt=(()=>{const t=y();return(e,r)=>{const{start:n,end:s}=e;if(H(n,s)&&R(n[2],r.z))return e;const i=x();return z(r.getPlane(t),n,s,i)?new ot(C(i)):void 0}})();function At({lineLike:t},{center:e,radius:r}){const n=e[2];return Xt(X(t,e,r).filter((t=>R(t[2],n))))}function Et({lineLike:t},{sphere:e}){return Xt(S(e,t.start,t.end))}const Nt=(()=>{const t=M(),e=x(),n=x();return(s,i,o)=>{const{normal:u,center:a,radius:f}=i;O(u,e,n);const l=Z(s),h=f*L(l,e),p=f*L(l,n);q(t,a[0],a[1],a[2],1);const d=v(s,t),m=Math.hypot(h,p),T=R(m,0);if(R(N(s,a),0)){if(T)return i;if(R(f,0))return!o||Y(o,a)?new ot(D(a)):void 0;g(e,l,u),k(e,e);const t=[],r=P(a);c(r,r,e,f),o&&!Y(o,r)||t.push(r);const n=P(a);return c(n,n,e,-f),o&&!Y(o,n)||t.push(n),Xt(t)}if(T)return;const j=-d/m;if(Math.abs(j)>1||R(j,1))return;const M=[],y=Math.atan(h/p),z=r(j)-y,w=Math.PI-z,b=x();c(b,a,e,f*Math.cos(z)),c(b,b,n,f*Math.sin(z)),M.push(b);const A=x();return c(A,a,e,f*Math.cos(w)),c(A,A,n,f*Math.sin(w)),M.push(A),Xt(o?rt(o,M):M)}})();function Zt(t,e){return R(t.z,e.z)?t:void 0}function It({z:t},{planeLike:e}){const[r,n]=e.start,[s,i]=e.end,o=F(r,n,t),c=F(s,i,t);return e.type===K.PLANE?new ut(o,c):new at(o,c)}function Ut(t,e){const[r,n]=e.center;return new ht(F(r,n,t.z),e.radius)}function Gt(t,e){return R(e.center[2],t.z)?e:void 0}const St=(()=>{const t=y();return(e,r)=>Nt(e.getPlane(t),r,r.slicePlane)})();function Ot(t,{center:e,radius:r}){const n=Math.abs(e[2]-t.z);if(n>r&&!R(n,r))return;const s=F(e[0],e[1],t.z),i=Math.sqrt(r**2-n**2);return R(i,0)?void 0:new ht(s,i)}const Ct=(()=>{const t=y();return(e,{center:r,radius:n})=>{const s=V(e.planeLike,r,n),i=r[2];e.getSlicePlane(t);const o=[];for(const[c,u]of s){const e=[c,u,i];Y(t,e)&&o.push(e)}return Xt(o)}})(),Dt=(()=>{const t=y(),e=y();return(r,n)=>Nt(r.getPlane(t),n,r.getSlicePlane(e))})(),Ft=(()=>{const t=y();return(e,{center:r,radius:n})=>{const s=e.getPlane(t),i=w(s,r),o=Math.abs(i);if(o>n&&!R(o,n))return;const u=P(Z(s)),a=c(x(),r,u,i),f=Math.sqrt(n**2-i**2);return R(f,0)?new ot(C(b(s,r,x()))):new pt(C(a),f,u,e.getSlicePlane())}})();function Ht(t,e){}function Rt(t,e){const r=i(t.center,e.center);if(R(r,0)&&R(t.radius,e.radius))return e;return $t(et(t.center,t.radius,e.center,e.radius),e.center[2])}function Vt(t,e){}function Yt(t,e){}function _t(t,e){}function Bt(t,e){if(!H(t.center,e.center))return;const r=i(t.center,e.center);if(R(r,0)&&R(t.radius,e.radius))return t;return $t(et(t.center,t.radius,e.center,e.radius),t.center[2])}function Jt(t,e){}function Kt(t,e){}function Qt(t,e){const{planeLike:r,getZ:n}=t,s=[];if(re(e))t.addIfOnTheGround(s,nt(r,e.point));else if(ne(e))t.addIfOnTheGround(s,W(r,e.lineLike));else if(oe(e))for(const[i,o]of V(r,e.center,e.radius)){const t=n(i,o,0);null!=t&&s.push(T(i,o,t))}else if(ie(e)||fe(e))for(const[i,o]of tt(r,e.planeLike)){const t=n(i,o,0)??le;s.push(T(i,o,t))}return Xt(s)}function Wt(t){return te(t.map((([t,e])=>{const r=F(t,e,0),n=F(t,e,1);return new ut(r,n)})))}function Xt(t){return te(t.map((t=>t?new ot(C(t)):void 0)))}function $t(t,e){return Xt(t.map((([t,r])=>[t,r,e])))}function te(e){if(0!==e.length)return 1===e.length?e[0]??void 0:new ft(e.filter(t))}function ee(t){return t instanceof ft}function re(t){return t instanceof ot}function ne(t){return t instanceof ct}function se(t){return t instanceof Lt}function ie(t){return t instanceof kt}function oe(t){return t instanceof lt}function ce(t){return t instanceof ht}function ue(t){return t instanceof pt}function ae(t){return t instanceof Mt}function fe(t){return t instanceof yt}const le=0;export{pt as CircleConstraint,it as Constraint,yt as DrapedLineConstraint,ht as HorizontalCircleConstraint,Lt as HorizontalPlaneConstraint,ut as LineConstraint,ct as LineLikeConstraint,ot as PointConstraint,at as RayConstraint,ft as SetConstraint,Mt as SphereConstraint,lt as VerticalCylinderConstraint,qt as VerticalHalfPlaneConstraint,vt as VerticalPlaneConstraint,kt as VerticalPlaneLikeConstraint};
|
|
5
|
+
import{isSome as t,equals as e}from"../../../core/arrayUtils.js";import{asinClamped as r}from"../../../core/mathUtils.js";import{dot as n,subtract as s,squaredDistance as i}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{create as o}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as c,h as u,a,r as f,m as l,s as h,c as p,f as d,G as m,j as L,b as g,n as k}from"../../../chunks/vec32.js";import{clone as P,create as x,fromValues as T,UNIT_Z as j}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as q,g as v}from"../../../chunks/vec42.js";import{create as M}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as y,intersectLine as z,signedDistance as w,projectPoint as b,fromPositionAndNormal as A,fromPoints as E,distance as N,normal as Z}from"../../../geometry/support/plane.js";import{k as I,l as U,p as G,m as S}from"../../../chunks/sphere.js";import{tangentFrame as O}from"../../3d/support/mathUtils.js";import{fromVec3 as C,clone as D,fromValues as F}from"./normalizedPoint.js";import{vectorsHaveCloseZ as H,isClose as R,intersectVerticalPlaneAndVerticalCylinder as V,isPointInsidePlane as Y,projectPointToLineLike as _,projectPointToVerticalCylinder as B,projectPointToVerticalPlane as J,VerticalPlaneType as K,intersectLineLikes as Q,intersectVerticalPlaneAndLineLike as W,intersectLineLikeAndVerticalCylinder as X,intersectLineLikeAndCircle as $,intersectVerticalPlanes as tt,intersectVerticalCylinders as et,pointsInsidePlane as rt,intersectVerticalPlaneAndPoint as nt}from"../../support/geometry3dUtils.js";import{LineType as st}from"../../support/geometry2dUtils.js";class it{intersect(t){return wt(this,t)}closestPoints(t){return[this.closestTo(t)]}}class ot extends it{constructor(t){super(),this.point=t}equals(t){return this===t||re(t)&&u(this.point,t.point)}closestTo(){return D(this.point)}}class ct extends it{constructor(t,e,r){super(),this.start=t,this.end=e,this.lineLike={start:t,end:e,type:r}}equals(t){return this===t||ne(t)&&this.lineLike.type===t.lineLike.type&&u(this.start,t.start)&&u(this.end,t.end)}closestTo(t){const e=_(t,this.lineLike);return C(e)}}class ut extends ct{constructor(t,e){super(t,e,st.LINE)}}class at extends ct{constructor(t,e){super(t,e,st.RAY)}}class ft extends it{constructor(t){super(),this.constraints=t}equals(t){return this===t||ee(t)&&e(this.constraints,t.constraints,((t,e)=>t.equals(e)))}closestTo(t){let e,r=1/0;for(const n of this.constraints){const s=n.closestTo(t),i=a(t,s);i<r&&(r=i,e=s)}return e?D(e):t}closestPoints(t){return this.constraints.flatMap((e=>e===this?[]:e.closestPoints(t)))}}class lt extends it{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||oe(t)&&this.center[0]===t.center[0]&&this.center[1]===t.center[1]&&this.radius===t.radius}closestTo(t){const e=B(t,this.center,this.radius);return C(e)}}class ht extends it{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||ce(t)&&u(this.center,t.center)&&this.radius===t.radius}closestTo(t){const e=B(t,this.center,this.radius);return e[2]=this.center[2],C(e)}asCircle(){return new pt(D(this.center),this.radius,F(0,0,1))}}class pt extends it{constructor(t,e,r,n=void 0){super(),this.center=t,this.radius=e,this.normal=r,this.slicePlane=n}equals(t){return this===t||ue(t)&&u(this.center,t.center)&&u(this.normal,t.normal)&&this.radius===t.radius}closestTo(t){const{center:e,radius:r}=this;b(this.getPlane(mt),t,dt);const n=f(dt,dt,e),s=l(n);if(R(s,0))return D(t);const i=r/Math.sqrt(s),o=c(x(),e,n,i),{slicePlane:u}=this;if(u&&!Y(u,o)){const e=Nt(u,this);return e?.closestTo(t)??D(t)}return C(o)}getPlane(t=y()){return A(this.center,this.normal,t)}}const dt=x(),mt=y();class Lt extends it{constructor(t){super(),this.z=t}equals(t){return this===t||se(t)&&this.z===t.z}closestTo(t){return C(T(t[0],t[1],this.z))}getPlane(t=y()){return h(gt,0,0,this.z),A(gt,j,t)}}const gt=x();class kt extends it{constructor(t,e,r){super(),this.start=t,this.end=e,this.planeLike={start:t,end:e,type:r}}equals(t){return this===t||ie(t)&&this.planeLike.type===t.planeLike.type&&u(this.start,t.start)&&u(this.end,t.end)}closestTo(t){return C(J(t,this.planeLike))}closestEndTo(t){const{start:e,end:r}=this;return Math.sign(n(s(Pt,r,e),s(xt,t,e)))>0?r:e}getPlane(t=y()){const e=p(Tt,this.end);return e[2]+=1,E(this.start,this.end,e,t)}getSlicePlane(t=y()){const{start:e,end:r,type:n}=this.planeLike;if(n===K.PLANE)return;const s=h(Tt,e[0],e[1],0),i=h(jt,r[0],r[1],0),o=d(jt,i,s);return A(s,o,t),t}}const Pt=o(),xt=o(),Tt=x(),jt=x();class qt extends kt{constructor(t,e){super(t,e,K.HALF_PLANE)}}class vt extends kt{constructor(t,e){super(t,e,K.PLANE)}}class Mt extends it{constructor(t,e){super(),this.sphere=I(t,e)}equals(t){return this===t||ae(t)&&U(this.sphere,t.sphere)}closestTo(t){const e=G(this.sphere,t,x());return C(e)}get center(){return this.sphere}get radius(){return this.sphere[3]}}class yt extends it{constructor(t,e,r){super(),this.start=t,this.end=e,this.getZ=r,this.planeLike={start:t,end:e,type:K.PLANE}}equals(t){return this===t||fe(t)&&u(this.start,t.start)&&u(this.end,t.end)&&this.getZ===t.getZ}closestTo(t){return zt(this,t)}addIfOnTheGround(t,e){for(const r of e){const e=this.getZ(r[0],r[1])??0;R(r[2],e)&&(r[2]=e,t.push(r))}}}function zt(t,e){const r=J(e,t.planeLike);return r[2]=t.getZ(r[0],r[1])??le,C(r)}function wt(t,e){if(ee(t)){const r=[];for(const n of t.constraints){const t=n.intersect(e);t&&r.push(t)}return te(r)}if(ee(e))return wt(e,t);if(fe(t))return Qt(t,e);if(fe(e))return Qt(e,t);if(re(t)){const{point:r}=t,n=e.closestTo(r);return m(n,r)?t:void 0}if(ne(t)){if(re(e))return wt(e,t);if(ne(e))return Xt(Q(t.lineLike,e.lineLike));if(se(e))return bt(t,e);if(ie(e))return Xt(W(e.planeLike,t.lineLike));if(oe(e))return Xt(X(t.lineLike,e.center,e.radius));if(ue(e))return Xt($(t.lineLike,e));if(ce(e))return At(t,e);if(ae(e))return Et(t,e)}else if(se(t)){if(re(e)||ne(e))return wt(e,t);if(se(e))return Zt(t,e);if(ie(e))return It(t,e);if(oe(e))return Ut(t,e);if(ue(e))return St(t,e);if(ce(e))return Gt(t,e);if(ae(e))return Ot(t,e)}else if(ie(t)){if(re(e)||ne(e)||se(e))return wt(e,t);if(ie(e))return Wt(tt(t.planeLike,e.planeLike));if(oe(e))return Wt(V(t.planeLike,e.center,e.radius));if(ue(e))return Dt(t,e);if(ce(e))return Ct(t,e);if(ae(e))return Ft(t,e)}else if(oe(t)){if(re(e)||ne(e)||se(e)||ie(e))return wt(e,t);if(oe(e))return Wt(et(t.center,t.radius,e.center,e.radius));if(ue(e))return Ht();if(ce(e))return Rt(t,e);if(ae(e))return Vt()}else if(ue(t)){if(re(e)||ne(e)||se(e)||ie(e)||oe(e))return wt(e,t);if(ue(e))return Yt();if(ce(e))return Yt(e.asCircle());if(ae(e))return _t()}else if(ce(t)){if(re(e)||ne(e)||se(e)||ie(e)||oe(e)||ue(e))return wt(e,t);if(ce(e))return Bt(e,t);if(ae(e))return Jt()}else if(ae(t)){if(re(e)||ne(e)||se(e)||ie(e)||oe(e)||ce(e))return wt(e,t);if(ae(e))return Kt()}}const bt=(()=>{const t=y();return(e,r)=>{const{start:n,end:s}=e;if(H(n,s)&&R(n[2],r.z))return e;const i=x();return z(r.getPlane(t),n,s,i)?new ot(C(i)):void 0}})();function At({lineLike:t},{center:e,radius:r}){const n=e[2];return Xt(X(t,e,r).filter((t=>R(t[2],n))))}function Et({lineLike:t},{sphere:e}){return Xt(S(e,t.start,t.end))}const Nt=(()=>{const t=M(),e=x(),n=x();return(s,i,o)=>{const{normal:u,center:a,radius:f}=i;O(u,e,n);const l=Z(s),h=f*L(l,e),p=f*L(l,n);q(t,a[0],a[1],a[2],1);const d=v(s,t),m=Math.hypot(h,p),T=R(m,0);if(R(N(s,a),0)){if(T)return i;if(R(f,0))return!o||Y(o,a)?new ot(D(a)):void 0;g(e,l,u),k(e,e);const t=[],r=P(a);c(r,r,e,f),o&&!Y(o,r)||t.push(r);const n=P(a);return c(n,n,e,-f),o&&!Y(o,n)||t.push(n),Xt(t)}if(T)return;const j=-d/m;if(Math.abs(j)>1||R(j,1))return;const M=[],y=Math.atan(h/p),z=r(j)-y,w=Math.PI-z,b=x();c(b,a,e,f*Math.cos(z)),c(b,b,n,f*Math.sin(z)),M.push(b);const A=x();return c(A,a,e,f*Math.cos(w)),c(A,A,n,f*Math.sin(w)),M.push(A),Xt(o?rt(o,M):M)}})();function Zt(t,e){return R(t.z,e.z)?t:void 0}function It({z:t},{planeLike:e}){const[r,n]=e.start,[s,i]=e.end,o=F(r,n,t),c=F(s,i,t);return e.type===K.PLANE?new ut(o,c):new at(o,c)}function Ut(t,e){const[r,n]=e.center;return new ht(F(r,n,t.z),e.radius)}function Gt(t,e){return R(e.center[2],t.z)?e:void 0}const St=(()=>{const t=y();return(e,r)=>Nt(e.getPlane(t),r,r.slicePlane)})();function Ot(t,{center:e,radius:r}){const n=Math.abs(e[2]-t.z);if(n>r&&!R(n,r))return;const s=F(e[0],e[1],t.z),i=Math.sqrt(r**2-n**2);return R(i,0)?void 0:new ht(s,i)}const Ct=(()=>{const t=y();return(e,{center:r,radius:n})=>{const s=V(e.planeLike,r,n),i=r[2];e.getSlicePlane(t);const o=[];for(const[c,u]of s){const e=[c,u,i];Y(t,e)&&o.push(e)}return Xt(o)}})(),Dt=(()=>{const t=y(),e=y();return(r,n)=>Nt(r.getPlane(t),n,r.getSlicePlane(e))})(),Ft=(()=>{const t=y();return(e,{center:r,radius:n})=>{const s=e.getPlane(t),i=w(s,r),o=Math.abs(i);if(o>n&&!R(o,n))return;const u=P(Z(s)),a=c(x(),r,u,i),f=Math.sqrt(n**2-i**2);return R(f,0)?new ot(C(b(s,r,x()))):new pt(C(a),f,u,e.getSlicePlane())}})();function Ht(t,e){}function Rt(t,e){const r=i(t.center,e.center);if(R(r,0)&&R(t.radius,e.radius))return e;return $t(et(t.center,t.radius,e.center,e.radius),e.center[2])}function Vt(t,e){}function Yt(t,e){}function _t(t,e){}function Bt(t,e){if(!H(t.center,e.center))return;const r=i(t.center,e.center);if(R(r,0)&&R(t.radius,e.radius))return t;return $t(et(t.center,t.radius,e.center,e.radius),t.center[2])}function Jt(t,e){}function Kt(t,e){}function Qt(t,e){const{planeLike:r,getZ:n}=t,s=[];if(re(e))t.addIfOnTheGround(s,nt(r,e.point));else if(ne(e))t.addIfOnTheGround(s,W(r,e.lineLike));else if(oe(e))for(const[i,o]of V(r,e.center,e.radius)){const t=n(i,o);null!=t&&s.push(T(i,o,t))}else if(ie(e)||fe(e))for(const[i,o]of tt(r,e.planeLike)){const t=n(i,o)??le;s.push(T(i,o,t))}return Xt(s)}function Wt(t){return te(t.map((([t,e])=>{const r=F(t,e,0),n=F(t,e,1);return new ut(r,n)})))}function Xt(t){return te(t.map((t=>t?new ot(C(t)):void 0)))}function $t(t,e){return Xt(t.map((([t,r])=>[t,r,e])))}function te(e){if(0!==e.length)return 1===e.length?e[0]??void 0:new ft(e.filter(t))}function ee(t){return t instanceof ft}function re(t){return t instanceof ot}function ne(t){return t instanceof ct}function se(t){return t instanceof Lt}function ie(t){return t instanceof kt}function oe(t){return t instanceof lt}function ce(t){return t instanceof ht}function ue(t){return t instanceof pt}function ae(t){return t instanceof Mt}function fe(t){return t instanceof yt}const le=0;export{pt as CircleConstraint,it as Constraint,yt as DrapedLineConstraint,ht as HorizontalCircleConstraint,Lt as HorizontalPlaneConstraint,ut as LineConstraint,ct as LineLikeConstraint,ot as PointConstraint,at as RayConstraint,ft as SetConstraint,Mt as SphereConstraint,lt as VerticalCylinderConstraint,qt as VerticalHalfPlaneConstraint,vt as VerticalPlaneConstraint,kt as VerticalPlaneLikeConstraint};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{throwIfAborted as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{memoize as i}from"../../../../core/memoize.js";import{throwIfAborted as o,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{watch as r,initial as a,on as s}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/RandomLCG.js";import"../../../../core/has.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as y}from"../../../../support/elevationInfoUtils.js";import{makeFilter as c,makeSnappingQuery as u}from"../snappingUtils.js";import{convertSnappingCandidate as g,makeGetGroundElevation as h}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as m}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as d}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as v}from"./symbologySnappingCandidates.js";let S=class extends t{get availability(){return 1}get updating(){return this.layerSource.updating}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,i=null!=e&&"3d"===e.type;if(!i||"subtype-group"===t.type)return m();const o=async(i,o)=>(await n(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(i,o);return m(i,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return d(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return null!=e&&"3d"===e.type&&"subtype-group"!==t.type?v(this._symbologySnappingSupported,(async(i,n)=>{const r=await e.whenLayerView(t);return o(n),r.queryForSymbologySnapping({candidates:i,spatialReference:e.spatialReference},n)})):v()}get _symbologySnappingSupported(){return null!=this._layerView3D&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"subtype-group"!==t.type&&(e.whenLayerView(t).then((e=>this._layerView3D=e)),this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{const{elevationInfo:i}=t;y(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()})),r((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),a),r((()=>null!=this._layerView3D?this._layerView3D.processor?.renderer:null),(()=>this._symbologySnappingFetcher.notifySymbologyChange()),a),s((()=>this._layerView3D?.layer),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))]))}constructor(e){super(e),this.view=null,this._layerView3D=null,this._memoizedMakeGetGroundElevation=i(h)}refresh(){}async fetchCandidates(e,t){const{layer:i}=this.layerSource,n=i.source;if(!n?.querySnapping)return[];const r=c(i),a=u(e,this.view?.type??"2d",r),s=await n.querySnapping(a,{signal:t});o(t);const p=e.coordinateHelper.spatialReference,l=await this._snappingElevationAligner.alignCandidates(s.candidates,p,t);o(t);const y=await this._symbologySnappingFetcher.fetch(l,t);o(t);const h=0===y.length?l:[...l,...y],m=this._snappingElevationFilter.filter(a,h),d=this._memoizedMakeGetGroundElevation(this.view,p);return m.map((e=>g(e,d)))}};e([p({constructOnly:!0})],S.prototype,"layerSource",void 0),e([p({constructOnly:!0})],S.prototype,"view",void 0),e([p()],S.prototype,"_snappingElevationAligner",null),e([p()],S.prototype,"_snappingElevationFilter",null),e([p()],S.prototype,"_symbologySnappingFetcher",null),e([p()],S.prototype,"_layerView3D",void 0),e([p()],S.prototype,"_symbologySnappingSupported",null),S=e([l("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],S);export{S as FeatureCollectionSnappingSource};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{destroyHandle as i}from"../../../../core/handleUtils.js";import{throwIfAborted as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{destroyHandle as i}from"../../../../core/handleUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as o,ignoreAbortErrors as a}from"../../../../core/promiseUtils.js";import{watch as n,initial as l,on as u,sync as d,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/RandomLCG.js";import"../../../../core/has.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as f}from"../../../../layers/support/layerUtils.js";import{elevationContextAffectsAlignment as m}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as _}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as g}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{isUtilityNetworkWebMap as w}from"../snappingUtils.js";import{convertSnappingCandidate as S,makeGetGroundElevation as v}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as b}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as I}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as H}from"./featureServiceSource/FeatureServiceTilesSimple.js";import j from"../../../support/debugFlags.js";let F=class extends t{get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get _layerView(){return this.view?.allLayerViews.find((e=>e.layer===this._layer))}get _isSuspended(){if(f(this._layer)){if(!this._layer.sublayers.find((e=>e.visible)))return!0}return!!this.view&&(!1!==this._layerView?.suspended||!this.layerSource.enabled)}get updating(){return this._workerHandle?.updating||this._updatingHandles.updating}get _outFields(){const{view:e,_layerView:t,layerSource:r}=this,{layer:i}=r,{fieldsIndex:s,timeInfo:o,floorInfo:a,subtypeField:n}=i,l=t&&"filter"in t?t.filter:null,u=l?.where&&"1=1"!==l.where?this._getOrLoadWhereFields(l.where,s):[];if(l?.timeExtent&&o){const{startField:e,endField:t}=o,r=s.get(e)?.name??e,i=s.get(t)?.name??t;r&&u.push(r),i&&u.push(i)}if(e?.map&&w(e.map)&&e.map.utilityNetworks?.find((e=>e.isUtilityLayer(i)))){const e=i.fieldsIndex.get("assetGroup")?.name,t=i.fieldsIndex.get("assetType")?.name;e&&t&&(u.push(e),u.push(t))}if(i&&a?.floorField&&e?.floors?.length){const e=s.get(a.floorField)?.name??a.floorField;e&&u.push(e)}if(n){const e=s.get(n)?.name??n;e&&u.push(e)}return new Set(u)}get configuration(){const{view:e}=this,t=null!=e?e.type:"2d";return{filter:this._layer.createQuery(),customParameters:this._layer.customParameters,viewType:t}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._updatingHandles=new y,this._workerHandle=null,this._debug=null,this._memoizedMakeGetGroundElevation=s(v)}initialize(){let e;const t=this.view;if(null!=t)switch(t.type){case"2d":this._tilesOfInterest=new _({view:t,layer:this._layer}),e=this._workerHandle=new I;break;case"3d":{const{resourceController:r}=t,i=this._layer;this._tilesOfInterest=new g({view:t}),e=this._workerHandle=new I({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,r)=>{const s=await t.whenLayerView(i);return o(r),s.elevationAlignPointsInFeatures(e,r)},queryForSymbologySnapping:async(e,r)=>{const s=await t.whenLayerView(i);return o(r),s.queryForSymbologySnapping(e,r)}}),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=i;m(t,r)&&a(e.notifyElevationSourceChange())})),n((()=>i.elevationInfo),(()=>a(e.notifyElevationSourceChange())),l),n((()=>this._layerView?.processor?.renderer),(()=>a(e.notifySymbologyChange())),l),n((()=>this._layerView?.symbologySnappingSupported??!1),(t=>a(e.setSymbologySnappingSupported(t))),l),u((()=>this._layerView?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}else this._tilesOfInterest=new H({layer:this._layer}),e=this._workerHandle=new I;this.addHandles([i(e)]),a(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this._updatingHandles.add((()=>this._updateTilesParameters),(()=>a(e.updateTiles(this._updateTilesParameters,null))),l),this.addHandles([n((()=>this.configuration),(t=>a(e.configure(t,null))),d),n((()=>this._outFields),(t=>a(e.updateOutFields(t))),l),n((()=>this._isSuspended),(t=>a(e.setSuspended(t))),p)]),null!=t&&this.addHandles(n((()=>j.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(r=>{r&&!this._debug?(this._debug=new b({view:t,handle:e}),this.addHandles(i(this._debug),"debug")):!r&&this._debug&&this.removeHandles("debug")}),l)),this.addHandles(this.layerSource.layer.on("apply-edits",(t=>{a(e.applyEdits(t,null))})))}destroy(){this._updatingHandles.destroy()}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._memoizedMakeGetGroundElevation(this.view,r.spatialReference);return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>S(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}_getOrLoadWhereFields(e,t){const{_whereModule:i}=this;if(!this._loadWhereModuleTask&&!i){const e=r((async()=>{const e=await import("../../../../core/sql/WhereClause.js");return this._whereModule=e.WhereClause,this._whereModule}));return this._loadWhereModuleTask=e,this._updatingHandles.addPromise(e.promise),[]}if(!i)return[];try{return i.create(e,t).fieldNames}catch(s){return[]}}};e([h({constructOnly:!0})],F.prototype,"spatialReference",void 0),e([h({constructOnly:!0})],F.prototype,"layerSource",void 0),e([h({constructOnly:!0})],F.prototype,"view",void 0),e([h()],F.prototype,"_tilesOfInterest",void 0),e([h({readOnly:!0})],F.prototype,"_updateTilesParameters",null),e([h()],F.prototype,"_layerView",null),e([h()],F.prototype,"_isSuspended",null),e([h({readOnly:!0})],F.prototype,"updating",null),e([h()],F.prototype,"_outFields",null),e([h({readOnly:!0})],F.prototype,"configuration",null),e([h({readOnly:!0})],F.prototype,"availability",null),e([h()],F.prototype,"_loadWhereModuleTask",void 0),e([h()],F.prototype,"_whereModule",void 0),F=e([c("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],F);export{F as FeatureServiceSnappingSource};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as s}from"../../../../core/arrayUtils.js";import{createTask as o}from"../../../../core/asyncUtils.js";import{throwIfAborted as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as s}from"../../../../core/arrayUtils.js";import{createTask as o}from"../../../../core/asyncUtils.js";import{memoize as r}from"../../../../core/memoize.js";import{throwIfAborted as i,allSettledValues as n,whenOrAbort as a}from"../../../../core/promiseUtils.js";import{initial as p,watch as l,on as d}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import y from"../../../../geometry/Polygon.js";import{initializeProjection as m,canProjectWithoutEngine as g,project as f}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as _}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as S}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as v}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as w}from"../../../../layers/graphics/OptimizedFeature.js";import j from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as b}from"../../../../layers/graphics/data/QueryEngine.js";import E from"../../../../layers/support/FieldsIndex.js";import{elevationContextAffectsAlignment as k}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as F}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as C,makeSnappingQuery as A}from"../snappingUtils.js";import{convertSnappingCandidate as I,makeGetGroundElevation as P}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as G}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as H}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as R}from"./symbologySnappingCandidates.js";import{TaskPriority as x}from"../../../support/Scheduler.js";const z="graphics-collections";let O=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type;if(!s||"map-notes"===t.type)return G();const o=async(s,o)=>(await a(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(s,o);return G(s,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return H(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type,o=this._extrudedPolygonSymbolsCount>0;return s&&"map-notes"!==t.type&&o?R(o,(async(s,o)=>{const r=await e.whenLayerView(t);return i(o),r.queryForSymbologySnapping({candidates:s,spatialReference:e.spatialReference},o)})):R()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new h,this._memoizedMakeGetGroundElevation=r(P)}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e))),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this._updatingHandles.removeHandles(z);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this._updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],z)}),p);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{k(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),l((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),p),d((()=>t),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}async fetchCandidates(e,t){const{point:s,coordinateHelper:{spatialReference:o}}=e,r=await n(this._mapSources((s=>this._fetchCandidatesForSource(s,e,t))));i(t);const a=this._memoizedMakeGetGroundElevation(this.view,o),p=r.flat().map((e=>I(e,a)));return C(s,p),p}async _fetchCandidatesForSource(e,t,s){const o=A(t,this.view?.type??"2d"),r=await e.queryEngine.executeQueryForSnapping(o,s);i(s);const n=await this._snappingElevationAligner.alignCandidates(r.candidates,t.coordinateHelper.spatialReference,s);i(s);const a=await this._symbologySnappingFetcher.fetch(n,s);i(s);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(o,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],s=new Map;for(const o of e)null!=o.geometry&&(this._needsInitializeProjection(o.geometry.spatialReference)?(t.push(o.geometry.spatialReference),s.set(o.uid,o)):this._add(o));this._createPendingAdd(t,s)}_createPendingAdd(e,t){if(!e.length)return;const r=o((async s=>{await m(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:s}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this._updatingHandles.addPromise(r.promise);const i={task:r,graphics:t},n=()=>s(this._pendingAdds,i);r.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e){null!=t.wkid&&this._loadedWkids.add(t.wkid);const e=t.wkt2||t.wkt;e&&this._loadedWkts.add(e)}}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=y.fromExtent(t));const s=this._ensureSource(t.type);if(null==s)return;const o=this._createOptimizedFeature(e.uid,t);null!=o&&(s.featureStore.add(o),F(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){if(null!=e.wkid&&this._loadedWkids.has(e.wkid))return!1;const t=e.wkt2||e.wkt;return(!t||!this._loadedWkts.has(t))&&!g(e,this.spatialReference)}_createOptimizedFeature(e,t){const s=f(_(t),this.spatialReference);if(!s)return null;const o=this._ensureGeometryHasZ(s),r=v(o,this._hasZ,!1);return new w(r,{[U]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},s=e.clone();switch(s.hasZ=!0,s.type){case"point":s.z=s.z??0;break;case"multipoint":s.points.forEach(t);break;case"polyline":s.paths.forEach((e=>e.forEach(t)));break;case"polygon":s.rings.forEach((e=>e.forEach(t)))}return s}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const s=this._createSource(e);return this._sources[e]=s,s}_createSource(e){const t=S.toJSON(e),s=this._hasZ,o=new j({geometryType:t,hasZ:s,hasM:!1});return{featureStore:o,queryEngine:new b({featureStore:o,fieldsIndex:E.fromLayerJSON({fields:[{name:U,type:"esriFieldTypeOID",alias:U}]}),geometryType:t,hasM:!1,hasZ:s,objectIdField:U,spatialReference:this.spatialReference,priority:x.SNAPPING,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const s=t.uid;e.featureStore.has(s)&&(e.featureStore.removeById(t.uid),F(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:s,polyline:o,multipoint:r}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=s&&i.push(e(s)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),i}};e([c()],O.prototype,"getGraphicsLayers",void 0),e([c({constructOnly:!0})],O.prototype,"layerSource",void 0),e([c({constructOnly:!0})],O.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],O.prototype,"view",void 0),e([c({readOnly:!0})],O.prototype,"updating",null),e([c({readOnly:!0})],O.prototype,"availability",void 0),e([c()],O.prototype,"_hasZ",null),e([c()],O.prototype,"_snappingElevationAligner",null),e([c()],O.prototype,"_snappingElevationFilter",null),e([c()],O.prototype,"_symbologySnappingFetcher",null),e([c()],O.prototype,"_extrudedPolygonSymbolsCount",void 0),O=e([u("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],O);const U="OBJECTID";export{O as GraphicsSnappingSource};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{fromValues as e}from"../../sketch/normalizedPoint.js";import{DrapedEdgeSnappingCandidate as t}from"../candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as n}from"../candidates/EdgeSnappingCandidate.js";import{VertexSnappingCandidate as d}from"../candidates/VertexSnappingCandidate.js";function r({x:t,y:n,z:d}){return e(t,n,d??0)}function a(e,a){switch(e.type){case"edge":return e.draped?new t({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,getGroundElevation:a}):new n({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,isDraped:!1});case"vertex":return new d({targetPoint:r(e.target),objectId:e.objectId,isDraped:!1})}}function
|
|
5
|
+
import{fromValues as e}from"../../sketch/normalizedPoint.js";import{DrapedEdgeSnappingCandidate as t}from"../candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as n}from"../candidates/EdgeSnappingCandidate.js";import{VertexSnappingCandidate as d}from"../candidates/VertexSnappingCandidate.js";function r({x:t,y:n,z:d}){return e(t,n,d??0)}function a(e,a){switch(e.type){case"edge":return e.draped?new t({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,getGroundElevation:a}):new n({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,isDraped:!1});case"vertex":return new d({targetPoint:r(e.target),objectId:e.objectId,isDraped:!1})}}function o(e,t){return null!=e&&"3d"===e.type?(n,d)=>e.elevationProvider.getElevation(n,d,0,t,"ground"):()=>null}export{a as convertSnappingCandidate,o as makeGetGroundElevation};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{clone as t}from"../../core/lang.js";import{getDeepValue as n}from"../../core/object.js";import{numberToJSON as r}from"../../core/accessorSupport/extensions/serializableProperty/writer.js";import{isFeatureCollectionLayer as i}from"../../layers/support/layerUtils.js";const o=new Set(["bing-maps","imagery","imagery-tile","map-image","open-street-map","tile","unknown","unsupported","vector-tile","web-tile","wms","wmts"]),l=new Set(["csv","feature","geo-rss","geojson","group","imagery","imagery-tile","kml","map-image","map-notes","media","ogc-feature","oriented-imagery","route","stream","subtype-group","tile","unknown","unsupported","vector-tile","web-tile","wfs","wms","wmts"]);function a(e){o.delete(e),l.delete(e)}function s(e){o.add(e),l.add(e)}function
|
|
5
|
+
import e from"../../core/Error.js";import{clone as t}from"../../core/lang.js";import{getDeepValue as n}from"../../core/object.js";import{numberToJSON as r}from"../../core/accessorSupport/extensions/serializableProperty/writer.js";import{isFeatureCollectionLayer as i}from"../../layers/support/layerUtils.js";const o=new Set(["bing-maps","imagery","imagery-tile","map-image","open-street-map","tile","unknown","unsupported","vector-tile","web-tile","wms","wmts"]),l=new Set(["csv","feature","geo-rss","geojson","group","imagery","imagery-tile","kml","map-image","map-notes","media","ogc-feature","oriented-imagery","route","stream","subtype-group","tile","unknown","unsupported","vector-tile","web-tile","wfs","wms","wmts"]);function a(e){o.delete(e),l.delete(e)}function s(e){o.add(e),l.add(e)}function u(e){return"basemap"===e.layerContainerType?o:"operational-layers"===e.layerContainerType?l:null}function d(e,t){if(t.restrictedWebMapWriting){const n=u(t);return null==n||n.has(e.type)&&!i(e)}return!0}function p(e,t){if(t)if(i(e)){const r=n("featureCollection.layers",t),i=r?.[0]?.layerDefinition;i&&m(e,i)}else"group"!==e.type&&m(e,t)}function m(e,t){"maxScale"in e&&(t.maxScale=r(e.maxScale)??void 0),"minScale"in e&&(t.minScale=r(e.minScale)??void 0)}function c(e,t){if(p(e,t),t&&(t.id=e.id,"blendMode"in e&&(t.blendMode=e.blendMode,"normal"===t.blendMode&&delete t.blendMode),t.opacity=r(e.opacity)??void 0,t.title=e.title||"Layer",t.visibility=e.visible,"legendEnabled"in e&&"wmts"!==e.type))if(i(e)){const n=t.featureCollection;n&&(n.showLegend=e.legendEnabled)}else t.showLegend=e.legendEnabled}function f(n,r,o){if(!n.persistenceEnabled)return null;if(!("write"in n)||!n.write)return o?.messages&&o.messages.push(new e("layer:unsupported",`Layers (${n.title}, ${n.id}) of type '${n.declaredClass}' cannot be persisted`,{layer:n})),null;if(i(n)&&!n.isTable)r=n.resourceInfo;else if(d(n,o)){const e={};return n.write(e,o)?e:null}return null!=r&&c(n,r=t(r)),r}export{s as disableRestrictedWriting,a as enableRestrictedWriting,f as getLayerJSON};
|