@arcgis/core 4.34.0-next.29 → 4.34.0-next.30
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/Map.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0260b33daf48fc207880.js +1 -0
- package/assets/esri/core/workers/chunks/{f469224c6e4804fd835a.js → 140efe4735605258ecc9.js} +1 -1
- package/assets/esri/core/workers/chunks/173c5b8fa1ac7aa6e072.js +1 -0
- package/assets/esri/core/workers/chunks/1aa6719be3afbdc7c880.js +1 -0
- package/assets/esri/core/workers/chunks/{8552fdb3230f4dd082c6.js → 20a96c17d1a117dfdf77.js} +1 -1
- package/assets/esri/core/workers/chunks/28e04ef3575f164f611a.js +1 -0
- package/assets/esri/core/workers/chunks/{2173012af606ac4cdf87.js → 2a695b50a384c45ace9a.js} +1 -1
- package/assets/esri/core/workers/chunks/{cf635f7ca998dd33d947.js → 439ce953a25b2776cb7f.js} +1 -1
- package/assets/esri/core/workers/chunks/{ecdbbfebca1fcef567bb.js → 4e267a813e8b10d10b3b.js} +9 -9
- package/assets/esri/core/workers/chunks/7099ff8dc699fedea931.js +1 -0
- package/assets/esri/core/workers/chunks/{e89698fc404379627349.js → 949dc266ac6f3505d357.js} +1 -1
- package/assets/esri/core/workers/chunks/{0aba41e0ee0a591b254b.js → 971b16677b66c16fb6b9.js} +1 -1
- package/assets/esri/core/workers/chunks/a809042fdce7ced2a415.js +1 -0
- package/assets/esri/core/workers/chunks/{16d82cbec34bc434efcd.js → a82d7e2eecfe654a65de.js} +1 -1
- package/assets/esri/core/workers/chunks/{27e089acb1cc76758b0a.js → ac30cf2f9a94597f7665.js} +8 -8
- package/assets/esri/core/workers/chunks/{ec4428250dbd807df0bd.js → c50c2f014e8567870686.js} +1 -1
- package/assets/esri/core/workers/chunks/{ce3a1ac43e8579db65cd.js → c854c3bb4440fd942c12.js} +1 -1
- package/assets/esri/core/workers/chunks/{9cbed3b43d7aadc7e627.js → ca88859fc69fcb4568c0.js} +1 -1
- package/assets/esri/core/workers/chunks/e7209654ecdfde926272.js +1 -0
- package/assets/esri/core/workers/chunks/e82b1f91465d569012c4.js +1 -0
- package/assets/esri/core/workers/chunks/e9311386f58f3cb95c22.js +1 -0
- package/assets/esri/core/workers/chunks/{45485d8f0b0e0e0a6365.js → efec0f496491a0647051.js} +1 -1
- package/chunks/RealisticTree.glsl.js +6 -6
- package/colorUtils.js +1 -1
- package/config.js +1 -1
- package/core/Evented.js +1 -1
- package/interfaces.d.ts +2 -2
- package/kernel.js +1 -1
- package/layers/CatalogLayer.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/GeoJSONLayer.js +1 -1
- package/layers/GraphicsLayer.js +1 -1
- package/layers/OGCFeatureLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/graphics/data/FeatureStore.js +1 -1
- package/layers/graphics/dehydratedPoint.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/mixins/SublayersOwner.js +1 -1
- package/layers/support/LayerContingentValuesCache.js +1 -1
- package/networks/UtilityNetwork.js +1 -1
- package/package.json +1 -1
- package/portal/support/layersLoader.js +1 -1
- package/rest/networks/support/CircuitTraceResult.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/ManagedCanvas.js +1 -1
- package/views/2d/engine/imagery/RasterTileContainer.js +1 -1
- package/views/2d/engine/webgl/Profiler.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ReprojectTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/BaseRasterColorizerShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/features/FeatureSourceEventLog.js +1 -1
- package/views/2d/layers/features/processor/AAggregateStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/2d/support/hitTestUtils.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/CutFillVolumeMeasurementController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/CutFillVolumeMeasurementVisualization.js +5 -0
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementConfiguration.js +5 -0
- package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
- package/views/3d/interactive/editingTools/transform/ExtentTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
- package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DElevationAlignment.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/pipeline/featureSet/TiledFeatureStore.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SQueryFeatureStore.js +1 -1
- package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
- package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/support/CombinedElevationProvider.js +1 -1
- package/views/3d/support/pointsOfInterest/ContentGeometryUpdates.js +1 -1
- package/views/3d/support/pointsOfInterest/SurfaceGeometryUpdates.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
- package/views/3d/webgl-engine/lib/ChangeSet.js +1 -1
- package/views/3d/webgl-engine/lib/Geometry.js +1 -1
- package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
- package/views/3d/webgl-engine/lib/WebGLLayer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
- package/views/3d/webgl-engine/lib/rendererUtils.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/Viewport2DMixin.js +1 -1
- package/views/draw/DrawManipulator.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/interactive/snapping/SnappingManager.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/layers/support/editableLayerViews.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/support/GeolocationPositioning.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/230e7b817ae16505ccf0.js +0 -1
- package/assets/esri/core/workers/chunks/450a7ebe2535a55c5193.js +0 -1
- package/assets/esri/core/workers/chunks/4599f5cebbafddb6720e.js +0 -1
- package/assets/esri/core/workers/chunks/676fec273f2f660a614d.js +0 -1
- package/assets/esri/core/workers/chunks/6aced8e446beceefaf2c.js +0 -1
- package/assets/esri/core/workers/chunks/9f459805a6698708830a.js +0 -1
- package/assets/esri/core/workers/chunks/a4104b21f2b282dfb14f.js +0 -1
- package/assets/esri/core/workers/chunks/cab3199d37411c8ed074.js +0 -1
- package/assets/esri/core/workers/chunks/fbfe2195ba87d18bc37a.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../../../../core/Accessor.js";import{reallocGrowthFactor as s}from"../../../../../core/arrayUtils.js";import i from"../../../../../core/Evented.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as o,invert as n,transpose as l}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as c}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as g}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as m}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{BufferViewMat4f64 as f,BufferViewVec3f64 as p,BufferViewMat3f as u,BufferViewVec2f as _,BufferViewVec4f64 as v,BufferViewVec4f as b,BufferViewVec4u8 as M,BufferViewUint8 as F}from"../../../../../geometry/support/buffer/BufferView.js";import{scaleFromMatrix as T}from"../../../support/mathUtils.js";import{newLayout as y}from"../../../support/buffer/InterleavedLayout.js";import{assert as w}from"../Util.js";import{initialCapacity as S}from"./RenderInstanceData.js";function j(t){let e=y().mat4f64("localTransform").mat4f64("globalTransform").vec4f64("boundingSphere").vec3f64("modelOrigin").mat3f("instanceModel").mat3f("instanceModelNormal").vec2f("modelScaleFactors");return t.includes("featureAttribute")&&(e=e.vec4f("featureAttribute")),t.includes("color")&&(e=e.vec4u8("color")),t.includes("objectAndLayerIdColor")&&(e=e.vec4u8("objectAndLayerIdColor")),e=e.u8("state").u8("lodLevel"),e}class O{constructor(t){this.localTransform=t.getField("localTransform",f),this.globalTransform=t.getField("globalTransform",f),this.modelOrigin=t.getField("modelOrigin",p),this.model=t.getField("instanceModel",u),this.modelNormal=t.getField("instanceModelNormal",u),this.modelScaleFactors=t.getField("modelScaleFactors",_),this.boundingSphere=t.getField("boundingSphere",v),this.featureAttribute=t.getField("featureAttribute",b),this.color=t.getField("color",M),this.objectAndLayerIdColor=t.getField("objectAndLayerIdColor",M),this.state=t.getField("state",F),this.lodLevel=t.getField("lodLevel",F)}}let x=class extends e{constructor(t,e){super(t),this.events=new i,this._capacity=0,this._size=0,this._next=0,this._highlightOptionsMap=new Map,this._highlightOptionsMapPrev=new Map,this._layout=j(e),this._capacity=S,this._buffer=this._layout.createBuffer(this._capacity),this._view=new O(this._buffer)}get capacity(){return this._capacity}get size(){return this._size}get view(){return this._view}addInstance(){this._size+1>this._capacity&&this._grow();const t=this._findSlot();return this._view.state.set(t,1),this._size++,this.events.emit("instances-changed"),t}removeInstance(t){const e=this._view.state;w(t>=0&&t<this._capacity&&!!(1&e.get(t)),"invalid instance handle"),this._getStateFlag(t,18)?this._setStateFlags(t,32):this.freeInstance(t),this.events.emit("instances-changed")}freeInstance(t){const e=this._view.state;w(t>=0&&t<this._capacity&&!!(1&e.get(t)),"invalid instance handle"),e.set(t,0),this._size--}setLocalTransform(t,e,s=!0){this._view.localTransform.setMat(t,e),s&&this.updateModelTransform(t)}getLocalTransform(t,e){this._view.localTransform.getMat(t,e)}setGlobalTransform(t,e,s=!0){this._view.globalTransform.setMat(t,e),s&&this.updateModelTransform(t)}getGlobalTransform(t,e){this._view.globalTransform.getMat(t,e)}updateModelTransform(t){const e=this._view,s=A,i=I;e.localTransform.getMat(t,C),e.globalTransform.getMat(t,V);const a=c(V,V,C);m(s,a[12],a[13],a[14]),e.modelOrigin.setVec(t,s),o(i,a),e.model.setMat(t,i);const r=T(A,a);r.sort(),e.modelScaleFactors.set(t,0,r[1]),e.modelScaleFactors.set(t,1,r[2]),n(i,i),l(i,i),e.modelNormal.setMat(t,i),this._setStateFlags(t,64),this.events.emit("instance-transform-changed",{index:t})}getModelTransform(t,e){const s=this._view;s.model.getMat(t,I),s.modelOrigin.getVec(t,A),e[0]=I[0],e[1]=I[1],e[2]=I[2],e[3]=0,e[4]=I[3],e[5]=I[4],e[6]=I[5],e[7]=0,e[8]=I[6],e[9]=I[7],e[10]=I[8],e[11]=0,e[12]=A[0],e[13]=A[1],e[14]=A[2],e[15]=1}applyShaderTransformation(t,e){null!=this.shaderTransformation&&this.shaderTransformation.applyTransform(this,t,e)}getCombinedModelTransform(t,e){return this.getModelTransform(t,e),null!=this.shaderTransformation&&this.shaderTransformation.applyTransform(this,t,e),e}getCombinedLocalTransform(t,e){this._view.localTransform.getMat(t,e),null!=this.shaderTransformation&&this.shaderTransformation.applyTransform(this,t,e)}getCombinedMaxScaleFactor(t){let e=this._view.modelScaleFactors.get(t,1);return null!=this.shaderTransformation&&(this.shaderTransformation.scaleFactor(A,this,t),e*=Math.max(A[0],A[1],A[2])),e}getCombinedMedianScaleFactor(t){let e=this._view.modelScaleFactors.get(t,0);return null!=this.shaderTransformation&&(this.shaderTransformation.scaleFactor(A,this,t),e*=L(A[0],A[1],A[2])),e}getModel(t,e){this._view.model.getMat(t,e)}setFeatureAttribute(t,e){this._view.featureAttribute.setVec(t,e)}getFeatureAttribute(t,e){this._view.featureAttribute.getVec(t,e)}setColor(t,e){this._view.color.setVec(t,e)}setObjectAndLayerIdColor(t,e){this._view.objectAndLayerIdColor.setVec(t,e)}setVisible(t,e){e!==this.getVisible(t)&&(this._setStateFlag(t,4,e),this.events.emit("instance-visibility-changed",{index:t}))}getVisible(t){return this._getStateFlag(t,4)}setHighlight(t,e){const{_highlightOptionsMap:s}=this,i=s.get(t);e?e!==i&&(s.set(t,e),this._setStateFlag(t,8,!0),this.events.emit("instance-highlight-changed")):i&&(s.delete(t),this._setStateFlag(t,8,!1),this.events.emit("instance-highlight-changed"))}get highlightOptionsMap(){return this._highlightOptionsMap}getHighlightStateFlag(t){return this._getStateFlag(t,8)}geHighlightOptionsPrev(t){const e=this._highlightOptionsMapPrev.get(t)??null;return this._highlightOptionsMapPrev.delete(t),e}getHighlightName(t){const e=this.highlightOptionsMap.get(t)??null;return e?this._highlightOptionsMapPrev.set(t,e):this._highlightOptionsMapPrev.delete(t),e}getState(t){return this._view.state.get(t)}getLodLevel(t){return this._view.lodLevel.get(t)}countFlags(t){let e=0;for(let s=0;s<this._capacity;++s){this.getState(s)&t&&++e}return e}_setStateFlags(t,e){const s=this._view.state;e=s.get(t)|e,s.set(t,e)}_clearStateFlags(t,e){const s=this._view.state;e=s.get(t)&~e,s.set(t,e)}_setStateFlag(t,e,s){s?this._setStateFlags(t,e):this._clearStateFlags(t,e)}_getStateFlag(t,e){return!!(this._view.state.get(t)&e)}_grow(){this._capacity=Math.max(S,Math.floor(this._capacity*s)),this._buffer=this._layout.createBuffer(this._capacity).copyFrom(this._buffer),this._view=new O(this._buffer)}_findSlot(){const t=this._view.state;let e=this._next;for(;1&t.get(e);)e=e+1===this._capacity?0:e+1;return this._next=e+1===this._capacity?0:e+1,e}};function L(t,e,s){return Math.max(Math.min(t,e),Math.min(Math.max(t,e),s))}t([a({constructOnly:!0})],x.prototype,"shaderTransformation",void 0),t([a()],x.prototype,"_size",void 0),t([a({readOnly:!0})],x.prototype,"size",null),x=t([r("esri.views.3d.webgl-engine.lib.lodRendering.InstanceData")],x);const A=d(),I=h(),C=g(),V=g();export{x as InstanceData,O as InstanceDataView};
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../../../core/Accessor.js";import{reallocGrowthFactor as s}from"../../../../../core/arrayUtils.js";import i from"../../../../../core/Evented.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as o,invert as n,transpose as l}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as c}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as g}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as m}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{BufferViewMat4f64 as f,BufferViewVec3f64 as p,BufferViewMat3f as u,BufferViewVec2f as _,BufferViewVec4f64 as v,BufferViewVec4f as b,BufferViewVec4u8 as M,BufferViewUint8 as F}from"../../../../../geometry/support/buffer/BufferView.js";import{scaleFromMatrix as T}from"../../../support/mathUtils.js";import{newLayout as y}from"../../../support/buffer/InterleavedLayout.js";import{assert as w}from"../Util.js";import{initialCapacity as S}from"./RenderInstanceData.js";function j(t){let e=y().mat4f64("localTransform").mat4f64("globalTransform").vec4f64("boundingSphere").vec3f64("modelOrigin").mat3f("instanceModel").mat3f("instanceModelNormal").vec2f("modelScaleFactors");return t.includes("featureAttribute")&&(e=e.vec4f("featureAttribute")),t.includes("color")&&(e=e.vec4u8("color")),t.includes("objectAndLayerIdColor")&&(e=e.vec4u8("objectAndLayerIdColor")),e=e.u8("state").u8("lodLevel"),e}class O{constructor(t){this.localTransform=t.getField("localTransform",f),this.globalTransform=t.getField("globalTransform",f),this.modelOrigin=t.getField("modelOrigin",p),this.model=t.getField("instanceModel",u),this.modelNormal=t.getField("instanceModelNormal",u),this.modelScaleFactors=t.getField("modelScaleFactors",_),this.boundingSphere=t.getField("boundingSphere",v),this.featureAttribute=t.getField("featureAttribute",b),this.color=t.getField("color",M),this.objectAndLayerIdColor=t.getField("objectAndLayerIdColor",M),this.state=t.getField("state",F),this.lodLevel=t.getField("lodLevel",F)}}let x=class extends e{constructor(t,e){super(t),this.events=new i.EventEmitter,this._capacity=0,this._size=0,this._next=0,this._highlightOptionsMap=new Map,this._highlightOptionsMapPrev=new Map,this._layout=j(e),this._capacity=S,this._buffer=this._layout.createBuffer(this._capacity),this._view=new O(this._buffer)}get capacity(){return this._capacity}get size(){return this._size}get view(){return this._view}addInstance(){this._size+1>this._capacity&&this._grow();const t=this._findSlot();return this._view.state.set(t,1),this._size++,this.events.emit("instances-changed"),t}removeInstance(t){const e=this._view.state;w(t>=0&&t<this._capacity&&!!(1&e.get(t)),"invalid instance handle"),this._getStateFlag(t,18)?this._setStateFlags(t,32):this.freeInstance(t),this.events.emit("instances-changed")}freeInstance(t){const e=this._view.state;w(t>=0&&t<this._capacity&&!!(1&e.get(t)),"invalid instance handle"),e.set(t,0),this._size--}setLocalTransform(t,e,s=!0){this._view.localTransform.setMat(t,e),s&&this.updateModelTransform(t)}getLocalTransform(t,e){this._view.localTransform.getMat(t,e)}setGlobalTransform(t,e,s=!0){this._view.globalTransform.setMat(t,e),s&&this.updateModelTransform(t)}getGlobalTransform(t,e){this._view.globalTransform.getMat(t,e)}updateModelTransform(t){const e=this._view,s=A,i=I;e.localTransform.getMat(t,C),e.globalTransform.getMat(t,V);const a=c(V,V,C);m(s,a[12],a[13],a[14]),e.modelOrigin.setVec(t,s),o(i,a),e.model.setMat(t,i);const r=T(A,a);r.sort(),e.modelScaleFactors.set(t,0,r[1]),e.modelScaleFactors.set(t,1,r[2]),n(i,i),l(i,i),e.modelNormal.setMat(t,i),this._setStateFlags(t,64),this.events.emit("instance-transform-changed",{index:t})}getModelTransform(t,e){const s=this._view;s.model.getMat(t,I),s.modelOrigin.getVec(t,A),e[0]=I[0],e[1]=I[1],e[2]=I[2],e[3]=0,e[4]=I[3],e[5]=I[4],e[6]=I[5],e[7]=0,e[8]=I[6],e[9]=I[7],e[10]=I[8],e[11]=0,e[12]=A[0],e[13]=A[1],e[14]=A[2],e[15]=1}applyShaderTransformation(t,e){null!=this.shaderTransformation&&this.shaderTransformation.applyTransform(this,t,e)}getCombinedModelTransform(t,e){return this.getModelTransform(t,e),null!=this.shaderTransformation&&this.shaderTransformation.applyTransform(this,t,e),e}getCombinedLocalTransform(t,e){this._view.localTransform.getMat(t,e),null!=this.shaderTransformation&&this.shaderTransformation.applyTransform(this,t,e)}getCombinedMaxScaleFactor(t){let e=this._view.modelScaleFactors.get(t,1);return null!=this.shaderTransformation&&(this.shaderTransformation.scaleFactor(A,this,t),e*=Math.max(A[0],A[1],A[2])),e}getCombinedMedianScaleFactor(t){let e=this._view.modelScaleFactors.get(t,0);return null!=this.shaderTransformation&&(this.shaderTransformation.scaleFactor(A,this,t),e*=L(A[0],A[1],A[2])),e}getModel(t,e){this._view.model.getMat(t,e)}setFeatureAttribute(t,e){this._view.featureAttribute.setVec(t,e)}getFeatureAttribute(t,e){this._view.featureAttribute.getVec(t,e)}setColor(t,e){this._view.color.setVec(t,e)}setObjectAndLayerIdColor(t,e){this._view.objectAndLayerIdColor.setVec(t,e)}setVisible(t,e){e!==this.getVisible(t)&&(this._setStateFlag(t,4,e),this.events.emit("instance-visibility-changed",{index:t}))}getVisible(t){return this._getStateFlag(t,4)}setHighlight(t,e){const{_highlightOptionsMap:s}=this,i=s.get(t);e?e!==i&&(s.set(t,e),this._setStateFlag(t,8,!0),this.events.emit("instance-highlight-changed")):i&&(s.delete(t),this._setStateFlag(t,8,!1),this.events.emit("instance-highlight-changed"))}get highlightOptionsMap(){return this._highlightOptionsMap}getHighlightStateFlag(t){return this._getStateFlag(t,8)}geHighlightOptionsPrev(t){const e=this._highlightOptionsMapPrev.get(t)??null;return this._highlightOptionsMapPrev.delete(t),e}getHighlightName(t){const e=this.highlightOptionsMap.get(t)??null;return e?this._highlightOptionsMapPrev.set(t,e):this._highlightOptionsMapPrev.delete(t),e}getState(t){return this._view.state.get(t)}getLodLevel(t){return this._view.lodLevel.get(t)}countFlags(t){let e=0;for(let s=0;s<this._capacity;++s){this.getState(s)&t&&++e}return e}_setStateFlags(t,e){const s=this._view.state;e=s.get(t)|e,s.set(t,e)}_clearStateFlags(t,e){const s=this._view.state;e=s.get(t)&~e,s.set(t,e)}_setStateFlag(t,e,s){s?this._setStateFlags(t,e):this._clearStateFlags(t,e)}_getStateFlag(t,e){return!!(this._view.state.get(t)&e)}_grow(){this._capacity=Math.max(S,Math.floor(this._capacity*s)),this._buffer=this._layout.createBuffer(this._capacity).copyFrom(this._buffer),this._view=new O(this._buffer)}_findSlot(){const t=this._view.state;let e=this._next;for(;1&t.get(e);)e=e+1===this._capacity?0:e+1;return this._next=e+1===this._capacity?0:e+1,e}};function L(t,e,s){return Math.max(Math.min(t,e),Math.min(Math.max(t,e),s))}t([a({constructOnly:!0})],x.prototype,"shaderTransformation",void 0),t([a()],x.prototype,"_size",void 0),t([a({readOnly:!0})],x.prototype,"size",null),x=t([r("esri.views.3d.webgl-engine.lib.lodRendering.InstanceData")],x);const A=d(),I=h(),C=g(),V=g();export{x as InstanceData,O as InstanceDataView};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{MaterialChangeSet as e}from"./ChangeSet.js";function r(r){const
|
|
5
|
+
import{MaterialChangeSet as e}from"./ChangeSet.js";function r(r){const a=new Map,n=t=>{let n=a.get(t);return n||(n=new e(r),a.set(t,n)),n};return r.removes.forEach(e=>{t(e)&&n(e.material).removes.push(e)}),r.adds.forEach(e=>{t(e)&&n(e.material).adds.push(e)}),r.updates.forEach(e=>{t(e.renderGeometry)&&n(e.renderGeometry.material).updates.push(e)}),a}function t(e){return e.geometry.indexCount>=1}export{r as splitRenderGeometryChangeSetByMaterial};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{removeUnordered as t,filterInPlace as r}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{nextHighestPowerOfTwo as s}from"../../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{NestedMap as a}from"../../../../../core/NestedMap.js";import o from"../../../../../core/PooledArray.js";import{addMany as n}from"../../../../../core/SetUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as u,invert as f,transpose as c}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as m}from"../../../support/buffer/glUtil.js";import{SyncRenderPlugin as g}from"../../effects/RenderPlugin.js";import{GLMaterials as p}from"../../lib/GLMaterials.js";import{assert as y}from"../../lib/Util.js";import{DrawParameters as _}from"../DrawParameters.js";import{BufferRange as b,mergeAdjacentRanges as v}from"./BufferRange.js";import{Instance as w}from"./Instance.js";import{PerBufferData as C,hasVao as O}from"./PerBufferData.js";import{PerOriginData as A}from"./PerOriginData.js";import{defaultHighlightName as B}from"../../../../support/HighlightDefaults.js";let E=class extends g{get _hasHighlights(){return this._highlightNames.size>0}hasHighlight(e){return this._highlightNames.has(e)}constructor(e){super(e),this._dataByOrigin=new Map,this._drawParameters=new _,this._highlightNames=new Set,this.drapedPriority=0,this._produces=new Map,this._hasOccludees=!1}destroy(){this._glMaterials=i(this._glMaterials),this._dataByOrigin.forEach(e=>e.dispose()),this._dataByOrigin.clear(),this._vaoCache=null}initialize(){this._updateProduces()}_updateProduces(){this.material.produces.forEach((e,t)=>{this._produces.set(t,t=>!(0===this._dataByOrigin.size||!(8!==t&&5!==t||this._hasHighlights))&&e(t))})}initializeRenderContext(e){U??=e.renderContext.rctx.isAssumedMetalDriver,this._glMaterials=new p(this.material,e.materials),this._bufferWriter=this.material.createBufferWriter(),this._vaoCache=e.renderContext.rctx.getVaoCache(this.material.vertexAttributeLocations,m(this._bufferWriter.vertexBufferLayout))}uninitializeRenderContext(){}get produces(){return this._produces}get hasOccludees(){return this._hasOccludees}get hasOnlyOccluders(){return!!(-2&this.renderOccludedFlags)}get hasEmissions(){return this.material.hasEmissions}get isDecoration(){return this.material.parameters.isDecoration}get renderOccludedFlags(){return this.material.renderOccludedFlags}get numGeometries(){let e=0;return this._dataByOrigin.forEach(t=>e+=t.buffers.reduce((e,t)=>e+t.instances.size,0)),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach(t=>e+=t.buffers.reduce((e,t)=>e+t.vao.cachedMemory,0)),e}forEachGeometry(e){this._dataByOrigin.forEach(t=>t.buffers.forEach(t=>t.instances.forEach(({geometry:t})=>e(t))))}modify(e,t){this._applyUpdates(e,t),this._applyAddsAndRemoves(e),this._updateDrawCommands()}get canCompact(){for(const e of this._dataByOrigin.values())if(e.buffers.some(e=>e.holes.length>1))return!0;return!1}compact(e){if(!this.canCompact)return!1;let t=!1;for(const r of this._dataByOrigin.values()){const s=new Array;for(let t=0;t<r.buffers.length&&!e.done;){const i=r.buffers[t];i.holes.length<=1?++t:(i.instances.forEach(({geometry:e})=>s.push(e)),this._vaoCache.deleteVao(i.vao),r.buffers[t]=r.buffers[r.buffers.length-1],--r.buffers.length,e.madeProgress())}if(s.length>0){for(r.buffers.forEach(e=>this._applyAdds(e,s));s.length>0;)r.buffers.push(this._applyAndRebuild(new C,s,null));t=!0}}return t}updateHighlights(e){this.highlightOrderMap=e,this._highlightNames.clear(),this._dataByOrigin.forEach(t=>{t.buffers.forEach(t=>{t.updateHighlights(e),t.highlightNames.forEach(e=>this._highlightNames.add(e))})}),this._updateProduces()}_applyUpdates(e,t){const r=this._bufferWriter;if(null==r)return void e.clearUpdates();const s=r.vertexBufferLayout.stride/4;for(const i of e.updates){if(t.done)return;const{renderGeometry:a,updateType:o}=i;e.pending.updates.removeUnordered(i),t.madeProgress();const n=this._dataByOrigin.get(a.localOrigin.id),l=n?.findBuffer(a.id);if(null==l)return;const h=l.instances.get(a.id);if(6&o){const e=V(r.elementCount(h.geometry.geometry.attributes)*s),t=r.vertexBufferLayout.createView(e.buffer);this._writeGeometry(a,t,0),l.vao.vertexBuffers.get("geometry").setSubData(e,h.from*s,0,h.numElements*s)}25&o&&(l.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new a;for(const s of e){const e=s.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new x(e.vec3),r.set(e.id,null,t)),t.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),i=t?.findBuffer(s.id);if(null==i)continue;let a=r.get(e.id,i);null==a&&(a=new x(e.vec3),r.set(e.id,i,a)),a.changes.push(s)}return r}_applyAddsAndRemoves(e){const{_bufferWriter:r,_dataByOrigin:s,_vaoCache:i}=this;if(null==r||null==i)return void e.clearAddsAndRemoves();const a=r.vertexBufferLayout.stride/4,o=this._computeDeltas(e.adds,e.removes);o.forEach((e,n)=>{const l=e.get(null),h=l?.changes??[];o.delete(n,null);let u=s.get(n);if(e.forEach((e,l)=>{if(o.delete(n,l),null==l&&y(!1,"No VAO for removed geometries"),l.instances.size===e.changes.length)return i.deleteVao(l.vao),t(u.buffers,l),void(0===u.buffers.length&&0===h.length&&s.delete(n));const f=l.numElements,c=l.vao.getByteLength("geometry")/4,d=h.reduce((e,t)=>e+r.elementCount(t.geometry.attributes),0),m=e.changes.reduce((e,t)=>e+r.elementCount(t.geometry.attributes),0),g=Math.min((f+d-m)*a,N),p=g>c;g>R&&g<c/2?(e.changes.forEach(({id:e})=>l.deleteInstance(e)),l.instances.forEach(({geometry:e})=>h.push(e)),this._vaoCache.deleteVao(l.vao),t(u.buffers,l)):p?this._applyAndRebuild(l,h,e):this._applyRemoves(l,e)}),h.length>0)for(null==u&&(u=new A(l.origin),s.set(n,u)),u.buffers.forEach(e=>this._applyAdds(e,h));h.length>0;)u.buffers.push(this._applyAndRebuild(new C,h,null))}),e.clearAddsAndRemoves()}_updateDrawCommands(){this._highlightNames.clear(),this._hasOccludees=!1,this._dataByOrigin.forEach(e=>{e.buffers.forEach(e=>{e.updateIfDrawCommandsDirty(this.highlightOrderMap,this._bufferWriter.vertexBufferLayout.stride),e.hasHighlights&&n(this._highlightNames,e.highlightNames),this._hasOccludees||=e.hasOccludees})})}_applyAndRebuild(e,t,r){if(r)for(const d of r.changes)e.deleteInstance(d.id);const s=this._bufferWriter,i=s.vertexBufferLayout.stride,a=i/4,o=Math.floor(N/a);let n=e.numElements;for(;t.length>0;){const r=t.pop(),i=s.elementCount(r.geometry.attributes);if(n+i>o&&n>0){t.push(r);break}n+=i;const a=new w(r,0,0,this.highlightOrderMap);y(null==e.instances.get(r.id)),e.addInstance(r.id,a)}const l=n*a,h=V(l),u=s.vertexBufferLayout.createView(h.buffer);let f=0;e.resetInstanceSummary(),e.instances.forEach((t,r)=>{this._writeGeometry(t.geometry,u,f);const i=f;f+=s.elementCount(t.geometry.geometry.attributes),e.updateInstance(r,i,f),e.updateDrawState(t)}),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(G(l)),e.vao.vertexBuffers.get("geometry").setSubData(h,0,0,f*a),e.holes.clear();const c=e.holes.pushNew();return c.from=f,c.to=Math.floor(e.vao.getByteLength("geometry")/i),e.updateDrawCommands(this.highlightOrderMap,i),e}_applyRemoves(e,t){if(0===t.changes.length||null==this._bufferWriter)return;let r=1/0,s=-1/0;for(const o of t.changes){const t=o.id,i=e.instances.get(t);if(!i)continue;e.deleteInstance(t),U&&(r=Math.min(r,i.from),s=Math.max(s,i.to));const a=L.back();if(a){if(a.to===i.from){a.to=i.to;continue}if(a.from===i.to){a.from=i.from;continue}}const n=L.pushNew();n.from=i.from,n.to=i.to}v(L);const i=this._bufferWriter.vertexBufferLayout.stride/4,a=e.vao.vertexBuffers.get("geometry");if(U){const t=(s-r)*i,o=V(t),n=this._bufferWriter.vertexBufferLayout.createView(o.buffer);o.fill(0,0,t),e.instances.forEach(e=>{if(!(e.from>=r&&e.to<=s))return;const t=e.from-r;this._writeGeometry(e.geometry,n,t)}),a.setSubData(o,r*i,0,t)}else{const e=L.reduce((e,t)=>Math.max(e,t.numElements),0)*i,t=V(e);t.fill(0,0,e),L.forAll(e=>a.setSubData(t,e.from*i,0,e.numElements*i))}e.holes.pushArray(L.data,L.length),L.forAll((e,t)=>L.data[t]=null),L.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t){if(0===t.length||null==this._bufferWriter)return;if(!O(e))return void this._applyAndRebuild(e,t,null);const s=this._bufferWriter,i=s.vertexBufferLayout.stride/4,a=e.numElements,o=t.reduce((e,t)=>e+s.elementCount(t.geometry.attributes),0),n=Math.min((a+o)*i,N),l=4*n;if(e.vao.getByteLength("geometry")<G(N-R)&&l>e.vao.getByteLength("geometry"))return void this._applyAndRebuild(e,t,null);v(e.holes);const h=new Array;let u=1/0,f=-1/0;for(const r of t){const t=s.elementCount(r.geometry.attributes),i=M(e.holes,t);h.push(i),U&&null!=i&&(u=Math.min(i,u),f=Math.max(i+t,f))}const c=e.vao.vertexBuffers.get("geometry");let d=0,m=0,g=0;const p=V(U?(f-u)*i:n),_=s.vertexBufferLayout.createView(p.buffer);if(t.forEach((t,r)=>{const a=h[r];if(null==a)return;const o=s.elementCount(t.geometry.attributes);if(!U){if(!(g===a)){const e=g-m;e>0&&c.setSubData(p,m*i,0,e*i),m=a,d=0}this._writeGeometry(t,_,d),d+=o,g=a+o}const n=new w(t,a,a+o,this.highlightOrderMap);y(null==e.instances.get(t.id)),e.addInstance(t.id,n),e.drawCommandsDirty=!0}),U){const t=(f-u)*i;p.fill(0,0,t),e.instances.forEach(e=>{if(!(e.from>=u&&e.to<=f))return;const t=e.from-u;this._writeGeometry(e.geometry,_,t)}),m=u,g=f}const b=g-m;b>0&&c.setSubData(p,m*i,0,b*i),r(t,(e,t)=>null==h[t])}_writeGeometry(e,t,r){null!=this._bufferWriter&&(u(D,e.transformation),D[12]-=e.localOrigin.vec3[0],D[13]-=e.localOrigin.vec3[1],D[14]-=e.localOrigin.vec3[2],f(j,D),c(j,j),this._bufferWriter.write(D,j,e.geometry.attributes,e.geometry.objectAndLayerIdColor,t,r))}updateAnimation(e){return this.material.update(e)}acquireTechniques(e){if(!this.material.shouldRender(e))return null;const{output:t,bind:r}=e,s=this.material.produces.get(r.slot);if(!s?.(t))return null;const{highlight:i,slot:a}=r,o=5===t,n=8===t,l=n||o,h=i?.name;if(l&&(0===this._highlightNames.size||n&&h&&!this._highlightNames.has(h)))return null;const u=e=>n&&!!h&&!e.has(h),f=6===t,c=!(l||f);for(const{buffers:d}of this._dataByOrigin.values())for(const s of d){if(u(s.highlightNames))continue;const i=o?s.drawCommandsHighlights.get(B):l?h?s.drawCommandsHighlights.get(h):s.drawCommandsHighlights.size>0:((f&&s.needsMultipleCommands()?s.drawCommandsShadowHighlightRest:s.drawCommandsDefault)||null)?.length??!1,n=c&&s.drawCommandsOccludees||null;if(i||n?.length){const s=this._glMaterials.load(e.rctx,a,t),i=s?.beginSlot(r);if(i)return i}}return null}render(e,t){const{output:r,bind:s}=e,{slot:i,highlight:a}=s,n=8===r,l=a?.name??"";if(n&&!a)return;const h=5===r,u=n||h,f=6===r,c=!(u||f),d=9===i||10===i?i:null,{rctx:m}=e;m.runAppleAmdDriverHelper();const g=m.bindTechnique(t,s,this.material.parameters);for(const p of this._dataByOrigin.values())for(const e of p.buffers){if(n&&(!e.hasHighlights||!e.drawCommandsHighlights.has(l)))continue;if(h&&(!e.hasHighlights||!e.drawCommandsHighlights.has(B)))continue;const r=()=>{const t=[],r=e.drawCommandsHighlights.get(B)??new o;return r&&t.push(r),t},i=u&&!h?e.drawCommandsHighlights.get(l)??null:null,a=h?r():u?i?[i]:I:f&&e.needsMultipleCommands()?[e.drawCommandsShadowHighlightRest]:[e.drawCommandsDefault],y=a.some(e=>e.length>0),_=c&&e.drawCommandsOccludees||null;if(y||_?.length){if(this._drawParameters.origin=p.origin,g.bindDraw(s,this.material.parameters,this._drawParameters),t.ensureAttributeLocations(e.vao),m.bindVAO(e.vao),y)for(const e of a)m.setPipelineState(t.getPipeline(!1,d)),e.forAll(e=>m.drawArrays(t.primitiveType,e.first,e.count));_?.length&&(m.setPipelineState(t.getPipeline(!0,d)),_.forAll(e=>m.drawArrays(t.primitiveType,e.first,e.count)))}}}static prune(){W=new Float32Array(R)}get test(){}};e([l({constructOnly:!0})],E.prototype,"material",void 0),e([l({})],E.prototype,"highlightOrderMap",void 0),E=e([h("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],E);class x{constructor(e){this.origin=e,this.changes=new Array}}function M(e,t){const r=e.find(e=>e.numElements>=t);if(null==r)return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}const D=d(),j=d(),L=new o({allocator:e=>e||new b,deallocator:null}),R=65536,H=4*R,P=1024,S=16777216,N=S/4;let W=new Float32Array(R);function V(e){return W.length<e&&(W=new Float32Array(e)),W}function G(e){const t=4*e;return t<=P?P:t<H?s(t):Math.max(Math.min(Math.ceil(1.5*t/H)*H,S),t)}const I=[];let U;export{E as MergedRenderer,G as sizeForVao};
|
|
5
|
+
import{__decorate as e}from"tslib";import{removeUnordered as t,filterInPlace as r}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{nextHighestPowerOfTwo as s}from"../../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{NestedMap as a}from"../../../../../core/NestedMap.js";import o from"../../../../../core/PooledArray.js";import{addMany as n}from"../../../../../core/SetUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as u,invert as f,transpose as c}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as m}from"../../../support/buffer/glUtil.js";import{SyncRenderPlugin as g}from"../../effects/RenderPlugin.js";import{GLMaterials as p}from"../../lib/GLMaterials.js";import{assert as y}from"../../lib/Util.js";import{DrawParameters as _}from"../DrawParameters.js";import{BufferRange as b,mergeAdjacentRanges as v}from"./BufferRange.js";import{Instance as w}from"./Instance.js";import{PerBufferData as C,hasVao as O}from"./PerBufferData.js";import{PerOriginData as A}from"./PerOriginData.js";import{defaultHighlightName as B}from"../../../../support/HighlightDefaults.js";let E=class extends g{get _hasHighlights(){return this._highlightNames.size>0}hasHighlight(e){return this._highlightNames.has(e)}constructor(e){super(e),this._dataByOrigin=new Map,this._drawParameters=new _,this._highlightNames=new Set,this.drapedPriority=0,this._produces=new Map,this._hasOccludees=!1}destroy(){this._glMaterials=i(this._glMaterials),this._dataByOrigin.forEach(e=>e.dispose()),this._dataByOrigin.clear(),this._vaoCache=null}initialize(){this._updateProduces()}_updateProduces(){this.material.produces.forEach((e,t)=>{this._produces.set(t,t=>!(0===this._dataByOrigin.size||!(8!==t&&5!==t||this._hasHighlights))&&e(t))})}initializeRenderContext(e){z??=e.renderContext.rctx.isAssumedMetalDriver,this._glMaterials=new p(this.material,e.materials),this._bufferWriter=this.material.createBufferWriter(),this._vaoCache=e.renderContext.rctx.getVaoCache(this.material.vertexAttributeLocations,m(this._bufferWriter.vertexBufferLayout))}uninitializeRenderContext(){}get produces(){return this._produces}get hasOccludees(){return this._hasOccludees}get hasOnlyOccluders(){return!!(-2&this.renderOccludedFlags)}get hasEmissions(){return this.material.hasEmissions}get isDecoration(){return this.material.parameters.isDecoration}get renderOccludedFlags(){return this.material.renderOccludedFlags}get numGeometries(){let e=0;return this._dataByOrigin.forEach(t=>e+=t.buffers.reduce((e,t)=>e+t.instances.size,0)),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach(t=>e+=t.buffers.reduce((e,t)=>e+t.vao.cachedMemory,0)),e}forEachGeometry(e){this._dataByOrigin.forEach(t=>t.buffers.forEach(t=>t.instances.forEach(({geometry:t})=>e(t))))}modify(e,t){this._applyUpdates(e,t),this._applyAddsAndRemoves(e),this._updateDrawCommands()}get canCompact(){for(const e of this._dataByOrigin.values())if(e.buffers.some(e=>e.holes.length>1))return!0;return!1}compact(e){if(!this.canCompact)return!1;let t=!1;for(const r of this._dataByOrigin.values()){const s=new Array;for(let t=0;t<r.buffers.length&&!e.done;){const i=r.buffers[t];i.holes.length<=1?++t:(i.instances.forEach(({geometry:e})=>s.push(e)),this._vaoCache.deleteVao(i.vao),r.buffers[t]=r.buffers[r.buffers.length-1],--r.buffers.length,e.madeProgress())}if(s.length>0){for(r.buffers.forEach(e=>this._applyAdds(e,s));s.length>0;)r.buffers.push(this._applyAndRebuild(new C,s,null));t=!0}}return t}updateHighlights(e){this.highlightOrderMap=e,this._highlightNames.clear(),this._dataByOrigin.forEach(t=>{t.buffers.forEach(t=>{t.updateHighlights(e),t.highlightNames.forEach(e=>this._highlightNames.add(e))})}),this._updateProduces()}_applyUpdates(e,r){const s=this._bufferWriter;if(null==s)return void e.clearUpdates();const i=s.vertexBufferLayout.stride/4;for(const a of e.updates){if(r.done)return;const{renderGeometry:o,updateType:n}=a;t(e.pending.updates,a),r.madeProgress();const l=this._dataByOrigin.get(o.localOrigin.id),h=l?.findBuffer(o.id);if(null==h)return;const u=h.instances.get(o.id);if(6&n){const e=V(s.elementCount(u.geometry.geometry.attributes)*i),t=s.vertexBufferLayout.createView(e.buffer);this._writeGeometry(o,t,0),h.vao.vertexBuffers.get("geometry").setSubData(e,u.from*i,0,u.numElements*i)}25&n&&(h.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new a;for(const s of e){const e=s.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new x(e.vec3),r.set(e.id,null,t)),t.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),i=t?.findBuffer(s.id);if(null==i)continue;let a=r.get(e.id,i);null==a&&(a=new x(e.vec3),r.set(e.id,i,a)),a.changes.push(s)}return r}_applyAddsAndRemoves(e){const{_bufferWriter:r,_dataByOrigin:s,_vaoCache:i}=this;if(null==r||null==i)return void e.clearAddsAndRemoves();const a=r.vertexBufferLayout.stride/4,o=this._computeDeltas(e.adds,e.removes);o.forEach((e,n)=>{const l=e.get(null),h=l?.changes??[];o.delete(n,null);let u=s.get(n);if(e.forEach((e,l)=>{if(o.delete(n,l),null==l&&y(!1,"No VAO for removed geometries"),l.instances.size===e.changes.length)return i.deleteVao(l.vao),t(u.buffers,l),void(0===u.buffers.length&&0===h.length&&s.delete(n));const f=l.numElements,c=l.vao.getByteLength("geometry")/4,d=h.reduce((e,t)=>e+r.elementCount(t.geometry.attributes),0),m=e.changes.reduce((e,t)=>e+r.elementCount(t.geometry.attributes),0),g=Math.min((f+d-m)*a,N),p=g>c;g>R&&g<c/2?(e.changes.forEach(({id:e})=>l.deleteInstance(e)),l.instances.forEach(({geometry:e})=>h.push(e)),this._vaoCache.deleteVao(l.vao),t(u.buffers,l)):p?this._applyAndRebuild(l,h,e):this._applyRemoves(l,e)}),h.length>0)for(null==u&&(u=new A(l.origin),s.set(n,u)),u.buffers.forEach(e=>this._applyAdds(e,h));h.length>0;)u.buffers.push(this._applyAndRebuild(new C,h,null))}),e.clearAddsAndRemoves()}_updateDrawCommands(){this._highlightNames.clear(),this._hasOccludees=!1,this._dataByOrigin.forEach(e=>{e.buffers.forEach(e=>{e.updateIfDrawCommandsDirty(this.highlightOrderMap,this._bufferWriter.vertexBufferLayout.stride),e.hasHighlights&&n(this._highlightNames,e.highlightNames),this._hasOccludees||=e.hasOccludees})})}_applyAndRebuild(e,t,r){if(r)for(const d of r.changes)e.deleteInstance(d.id);const s=this._bufferWriter,i=s.vertexBufferLayout.stride,a=i/4,o=Math.floor(N/a);let n=e.numElements;for(;t.length>0;){const r=t.pop(),i=s.elementCount(r.geometry.attributes);if(n+i>o&&n>0){t.push(r);break}n+=i;const a=new w(r,0,0,this.highlightOrderMap);y(null==e.instances.get(r.id)),e.addInstance(r.id,a)}const l=n*a,h=V(l),u=s.vertexBufferLayout.createView(h.buffer);let f=0;e.resetInstanceSummary(),e.instances.forEach((t,r)=>{this._writeGeometry(t.geometry,u,f);const i=f;f+=s.elementCount(t.geometry.geometry.attributes),e.updateInstance(r,i,f),e.updateDrawState(t)}),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(G(l)),e.vao.vertexBuffers.get("geometry").setSubData(h,0,0,f*a),e.holes.clear();const c=e.holes.pushNew();return c.from=f,c.to=Math.floor(e.vao.getByteLength("geometry")/i),e.updateDrawCommands(this.highlightOrderMap,i),e}_applyRemoves(e,t){if(0===t.changes.length||null==this._bufferWriter)return;let r=1/0,s=-1/0;for(const o of t.changes){const t=o.id,i=e.instances.get(t);if(!i)continue;e.deleteInstance(t),z&&(r=Math.min(r,i.from),s=Math.max(s,i.to));const a=L.back();if(a){if(a.to===i.from){a.to=i.to;continue}if(a.from===i.to){a.from=i.from;continue}}const n=L.pushNew();n.from=i.from,n.to=i.to}v(L);const i=this._bufferWriter.vertexBufferLayout.stride/4,a=e.vao.vertexBuffers.get("geometry");if(z){const t=(s-r)*i,o=V(t),n=this._bufferWriter.vertexBufferLayout.createView(o.buffer);o.fill(0,0,t),e.instances.forEach(e=>{if(!(e.from>=r&&e.to<=s))return;const t=e.from-r;this._writeGeometry(e.geometry,n,t)}),a.setSubData(o,r*i,0,t)}else{const e=L.reduce((e,t)=>Math.max(e,t.numElements),0)*i,t=V(e);t.fill(0,0,e),L.forAll(e=>a.setSubData(t,e.from*i,0,e.numElements*i))}e.holes.pushArray(L.data,L.length),L.forAll((e,t)=>L.data[t]=null),L.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t){if(0===t.length||null==this._bufferWriter)return;if(!O(e))return void this._applyAndRebuild(e,t,null);const s=this._bufferWriter,i=s.vertexBufferLayout.stride/4,a=e.numElements,o=t.reduce((e,t)=>e+s.elementCount(t.geometry.attributes),0),n=Math.min((a+o)*i,N),l=4*n;if(e.vao.getByteLength("geometry")<G(N-R)&&l>e.vao.getByteLength("geometry"))return void this._applyAndRebuild(e,t,null);v(e.holes);const h=new Array;let u=1/0,f=-1/0;for(const r of t){const t=s.elementCount(r.geometry.attributes),i=M(e.holes,t);h.push(i),z&&null!=i&&(u=Math.min(i,u),f=Math.max(i+t,f))}const c=e.vao.vertexBuffers.get("geometry");let d=0,m=0,g=0;const p=V(z?(f-u)*i:n),_=s.vertexBufferLayout.createView(p.buffer);if(t.forEach((t,r)=>{const a=h[r];if(null==a)return;const o=s.elementCount(t.geometry.attributes);if(!z){if(!(g===a)){const e=g-m;e>0&&c.setSubData(p,m*i,0,e*i),m=a,d=0}this._writeGeometry(t,_,d),d+=o,g=a+o}const n=new w(t,a,a+o,this.highlightOrderMap);y(null==e.instances.get(t.id)),e.addInstance(t.id,n),e.drawCommandsDirty=!0}),z){const t=(f-u)*i;p.fill(0,0,t),e.instances.forEach(e=>{if(!(e.from>=u&&e.to<=f))return;const t=e.from-u;this._writeGeometry(e.geometry,_,t)}),m=u,g=f}const b=g-m;b>0&&c.setSubData(p,m*i,0,b*i),r(t,(e,t)=>null==h[t])}_writeGeometry(e,t,r){null!=this._bufferWriter&&(u(D,e.transformation),D[12]-=e.localOrigin.vec3[0],D[13]-=e.localOrigin.vec3[1],D[14]-=e.localOrigin.vec3[2],f(j,D),c(j,j),this._bufferWriter.write(D,j,e.geometry.attributes,e.geometry.objectAndLayerIdColor,t,r))}updateAnimation(e){return this.material.update(e)}acquireTechniques(e){if(!this.material.shouldRender(e))return null;const{output:t,bind:r}=e,s=this.material.produces.get(r.slot);if(!s?.(t))return null;const{highlight:i,slot:a}=r,o=5===t,n=8===t,l=n||o,h=i?.name;if(l&&(0===this._highlightNames.size||n&&h&&!this._highlightNames.has(h)))return null;const u=e=>n&&!!h&&!e.has(h),f=6===t,c=!(l||f);for(const{buffers:d}of this._dataByOrigin.values())for(const s of d){if(u(s.highlightNames))continue;const i=o?s.drawCommandsHighlights.get(B):l?h?s.drawCommandsHighlights.get(h):s.drawCommandsHighlights.size>0:((f&&s.needsMultipleCommands()?s.drawCommandsShadowHighlightRest:s.drawCommandsDefault)||null)?.length??!1,n=c&&s.drawCommandsOccludees||null;if(i||n?.length){const s=this._glMaterials.load(e.rctx,a,t),i=s?.beginSlot(r);if(i)return i}}return null}render(e,t){const{output:r,bind:s}=e,{slot:i,highlight:a}=s,n=8===r,l=a?.name??"";if(n&&!a)return;const h=5===r,u=n||h,f=6===r,c=!(u||f),d=9===i||10===i?i:null,{rctx:m}=e;m.runAppleAmdDriverHelper();const g=m.bindTechnique(t,s,this.material.parameters);for(const p of this._dataByOrigin.values())for(const e of p.buffers){if(n&&(!e.hasHighlights||!e.drawCommandsHighlights.has(l)))continue;if(h&&(!e.hasHighlights||!e.drawCommandsHighlights.has(B)))continue;const r=()=>{const t=[],r=e.drawCommandsHighlights.get(B)??new o;return r&&t.push(r),t},i=u&&!h?e.drawCommandsHighlights.get(l)??null:null,a=h?r():u?i?[i]:I:f&&e.needsMultipleCommands()?[e.drawCommandsShadowHighlightRest]:[e.drawCommandsDefault],y=a.some(e=>e.length>0),_=c&&e.drawCommandsOccludees||null;if(y||_?.length){if(this._drawParameters.origin=p.origin,g.bindDraw(s,this.material.parameters,this._drawParameters),t.ensureAttributeLocations(e.vao),m.bindVAO(e.vao),y)for(const e of a)m.setPipelineState(t.getPipeline(!1,d)),e.forAll(e=>m.drawArrays(t.primitiveType,e.first,e.count));_?.length&&(m.setPipelineState(t.getPipeline(!0,d)),_.forAll(e=>m.drawArrays(t.primitiveType,e.first,e.count)))}}}static prune(){W=new Float32Array(R)}get test(){}};e([l({constructOnly:!0})],E.prototype,"material",void 0),e([l({})],E.prototype,"highlightOrderMap",void 0),E=e([h("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],E);class x{constructor(e){this.origin=e,this.changes=new Array}}function M(e,t){const r=e.find(e=>e.numElements>=t);if(null==r)return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}const D=d(),j=d(),L=new o({allocator:e=>e||new b,deallocator:null}),R=65536,H=4*R,P=1024,S=16777216,N=S/4;let W=new Float32Array(R);function V(e){return W.length<e&&(W=new Float32Array(e)),W}function G(e){const t=4*e;return t<=P?P:t<H?s(t):Math.max(Math.min(Math.ceil(1.5*t/H)*H,S),t)}const I=[];let z;export{E as MergedRenderer,G as sizeForVao};
|
package/views/DOMContainer.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{byId as t,reparent as s}from"../core/domUtils.js";import{on as i}from"../core/events.js";import{makeHandle as r}from"../core/handleUtils.js";import o from"../core/Logger.js";import{removeMaybe as n}from"../core/maybe.js";import{watch as a,initial as h}from"../core/reactiveUtils.js";import{addFrameTask as d}from"../core/scheduling.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import c from"./overlay/ViewOverlay.js";const p=[0,0];function m(e){const t=(e.ownerDocument||window.document).defaultView,s=e.getBoundingClientRect();return p[0]=s.left+(t?.pageXOffset??0),p[1]=s.top+(t?.pageYOffset??0),p}function f(e){e&&(e.textContent="",e.parentNode&&e.parentNode.removeChild(e))}function y(e){const t=document.createElement("div");return e.appendChild(t),t}const g=16,_=750,v=512,w=2,C=p=>{const C=p;let H=class extends C{constructor(...e){super(...e),this._freqInfo={freq:g,time:_},this._overlayRenderTaskHandle=null,this.height=0,this.messagesCommon=null,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([a(()=>this.cursor,e=>{const{surface:t}=this;t&&t.setAttribute("data-cursor",e)}),a(()=>this.navigating,e=>{const{surface:t}=this;t&&t.setAttribute("data-navigating",e.toString())})])}initialize(){this.addHandles([a(()=>this.ui,(e,t)=>this._handleUIChange(e,t),h),
|
|
5
|
+
import{__decorate as e}from"tslib";import{byId as t,reparent as s}from"../core/domUtils.js";import{on as i}from"../core/events.js";import{makeHandle as r}from"../core/handleUtils.js";import o from"../core/Logger.js";import{removeMaybe as n}from"../core/maybe.js";import{watch as a,initial as h}from"../core/reactiveUtils.js";import{addFrameTask as d}from"../core/scheduling.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import c from"./overlay/ViewOverlay.js";const p=[0,0];function m(e){const t=(e.ownerDocument||window.document).defaultView,s=e.getBoundingClientRect();return p[0]=s.left+(t?.pageXOffset??0),p[1]=s.top+(t?.pageYOffset??0),p}function f(e){e&&(e.textContent="",e.parentNode&&e.parentNode.removeChild(e))}function y(e){const t=document.createElement("div");return e.appendChild(t),t}const g=16,_=750,v=512,w=2,C=p=>{const C=p;let H=class extends C{constructor(...e){super(...e),this._freqInfo={freq:g,time:_},this._overlayRenderTaskHandle=null,this.height=0,this.messagesCommon=null,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([a(()=>this.cursor,e=>{const{surface:t}=this;t&&t.setAttribute("data-cursor",e)}),a(()=>this.navigating,e=>{const{surface:t}=this;t&&t.setAttribute("data-navigating",e.toString())})])}initialize(){const e=this;this.addHandles([a(()=>this.ui,(e,t)=>this._handleUIChange(e,t),h),e.on("focus",()=>this.notifyChange("focused")),e.on("blur",()=>this.notifyChange("focused"))])}destroy(){this.destroyed||(this.ui?.destroy(),this.container=null)}get container(){return this._get("container")??null}set container(e){const i=this._get("container"),r=t(e);if(r||"string"!=typeof e||o.getLogger(this).error("#container",`element with id '${e}' not found`),i===r)return;if(this._stopMeasuring(),i&&(i.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this.root&&(f(this.root),this._set("root",null)),this.userContent&&(s(this.userContent,i),f(this.userContent),this._set("userContent",null))),!r)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);r.classList.add("esri-view");const h=document.createElement("div");h.className="esri-view-user-storage",s(r,h),r.appendChild(h),this._set("userContent",h);const l=document.createElement("div");l.className="esri-view-root",r.insertBefore(l,r.firstChild),this._set("root",l);const u=document.createElement("div");u.className="esri-view-surface",u.setAttribute("role","application"),u.tabIndex=0,l.appendChild(u),this._set("surface",u);const p=new c;l.appendChild(p.surface),this._set("overlay",p),this.addHandles(a(()=>p.needsRender,e=>{e&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=d({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=n(this._overlayRenderTaskHandle)})),this.forceDOMReadyCycle(),this._set("container",r),this._startMeasuring()}get focused(){const e=document.activeElement===this.surface;return document.hasFocus()&&e}get size(){return[this.width,this.height]}set ui(e){const t=this._get("ui");t!==e&&t?.destroy(),this._set("ui",e)}blur(){this.surface?.blur()}focus(){this.surface?.focus()}pageToContainer(e,t,s){const i=this.position;return e-=i?i[0]:0,t-=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}containerToPage(e,t,s){const i=this.position;return e+=i?i[0]:0,t+=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}_handleUIChange(e,t){this.removeHandles("ui"),t&&t!==e&&t.destroy(),e&&(e.view=this,this.addHandles(a(()=>this.root,t=>{e.container=t?y(t):null},h),"ui")),this._set("ui",e)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const e=this._freqInfo;e.freq=g,e.time=_;const t=d({prepare:e=>{const s=this._measure(),i=this._freqInfo;if(i.time+=e.deltaTime,s&&(i.freq=g,this._get("resizing")||this._set("resizing",!0)),i.time<i.freq)return;i.time=0;const r=this._position();i.freq=r||s?g:Math.min(_,i.freq*w),!s&&i.freq>=v&&(t.pause(),this._get("resizing")&&this._set("resizing",!1))}}),s=new ResizeObserver(s=>{e.freq=g,e.time=_,t.resume()});null!=this.container&&s.observe(this.container);const o=r(()=>s.disconnect());this.addHandles([i(window,"resize",()=>{e.freq=g,e.time=_,t.resume()}),o,t],"measuring"),this._measure(),this._position()}_measure(){const e=this.container,t=e?e.clientWidth:0,s=e?e.clientHeight:0;if(0===t||0===s)return this.suspended||this._set("suspended",!0),!1;const i=this.width,r=this.height;if(t===i&&s===r)return this.suspended&&this._set("suspended",!1),!1;this._set("width",t),this._set("height",s),this.suspended&&this._set("suspended",!1);return this.emit("resize",{oldWidth:i,oldHeight:r,width:t,height:s}),!0}_position(){const e=this.container,t=this.position,s=e&&m(e);return!!s&&((!t||s[0]!==t[0]||s[1]!==t[1])&&(this._set("position",[s[0],s[1]]),!0))}forceDOMReadyCycle(){}};return e([l()],H.prototype,"container",null),e([l({readOnly:!0})],H.prototype,"focused",null),e([l({readOnly:!0})],H.prototype,"height",void 0),e([l()],H.prototype,"messagesCommon",void 0),e([l({type:c})],H.prototype,"overlay",void 0),e([l({readOnly:!0})],H.prototype,"position",void 0),e([l({readOnly:!0})],H.prototype,"resizing",void 0),e([l({readOnly:!0})],H.prototype,"root",void 0),e([l({value:null,readOnly:!0})],H.prototype,"size",null),e([l({readOnly:!0})],H.prototype,"surface",void 0),e([l({readOnly:!0})],H.prototype,"suspended",void 0),e([l({nonNullable:!0})],H.prototype,"ui",null),e([l({readOnly:!0})],H.prototype,"userContent",void 0),e([l({readOnly:!0})],H.prototype,"width",void 0),e([l()],H.prototype,"widthBreakpoint",void 0),H=e([u("esri.views.DOMContainer")],H),H};export{C as DOMContainer};
|
package/views/Viewport2DMixin.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as e}from"../core/accessorSupport/decorators/subclass.js";import{GoToManager as o}from"./2d/GoToManager.js";import s from"./2d/input/MapViewInputManager.js";import{isSupportedScreenPointEvent as i,createScreenPointFromSupportedEvent as n}from"./support/screenUtils.js";const a=a=>{const p=a;let g=class extends p{constructor(...t){super(...t),this.goToManager=new o({view:this}),this.inputManager=new s({view:this}),this.addHandles([this.on("resize",t=>this.stateManager.resize(t.width,t.height))])}get interacting(){return this.navigating}get stationary(){return!this.animation&&!this.navigating&&!this.resizing&&this.stationaryManager.stationary}on(t,r,e,o){const s=this.
|
|
5
|
+
import{__decorate as t}from"tslib";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as e}from"../core/accessorSupport/decorators/subclass.js";import{GoToManager as o}from"./2d/GoToManager.js";import s from"./2d/input/MapViewInputManager.js";import{isSupportedScreenPointEvent as i,createScreenPointFromSupportedEvent as n}from"./support/screenUtils.js";const a=a=>{const p=a;let g=class extends p{constructor(...t){super(...t),this.goToManager=new o({view:this}),this.inputManager=new s({view:this}),this.addHandles([this.on("resize",t=>this.stateManager.resize(t.width,t.height))])}get interacting(){return this.navigating}get stationary(){return!this.animation&&!this.navigating&&!this.resizing&&this.stationaryManager.stationary}on(t,r,e,o){const s=this.viewEvents.on(t,r,e,o);return s||super.on(t,r)}hasEventListener(t){return super.hasEventListener(t)||this.viewEvents.hasHandler(t)}goTo(t,r){return this.goToManager.goTo(t,r)}toMap(t){if(!this.ready)return null;const r=i(t)?n(this,t):t;return this.stateManager.toMap(r)}};return t([r()],g.prototype,"goToManager",void 0),t([r({readOnly:!0})],g.prototype,"interacting",null),t([r()],g.prototype,"stationary",null),t([r({readOnly:!0})],g.prototype,"inputManager",void 0),g=t([e("esri.views.Viewport2DMixin")],g),g};export{a as Viewport2DMixin};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Evented.js";class t{constructor({consumesClicks:t,grabbableForEvent:s}){this.events=new e,this.interactive=!0,this.selectable=!1,this.cursor=null,this.grabbable=!0,this.consumesClicks=t,this.grabbableForEvent=s}destroy(){}intersectionDistance(e,t){return 0}attach(){}detach(){}onElevationChange(){}onViewChange(){}}export{t as DrawManipulator};
|
|
5
|
+
import e from"../../core/Evented.js";class t{constructor({consumesClicks:t,grabbableForEvent:s}){this.events=new e.EventEmitter,this.interactive=!0,this.selectable=!1,this.cursor=null,this.grabbable=!0,this.consumesClicks=t,this.grabbableForEvent=s}destroy(){}intersectionDistance(e,t){return 0}attach(){}detach(){}onElevationChange(){}onViewChange(){}}export{t as DrawManipulator};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{equalsMaybe as o,destroyMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as a}from"../../core/promiseUtils.js";import p from"../../core/ReactiveSet.js";import{watch as c,syncAndInitial as l}from"../../core/reactiveUtils.js";import{createScreenPoint as d}from"../../core/screenUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{diff as m}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as y,pointNear as _}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as v}from"../../support/elevationInfoUtils.js";import{defaultDrawingMode as f}from"./DrawingMode.js";import{DrawManipulator as x}from"./DrawManipulator.js";import{createCoordinateHelper as C}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as b,sceneSnappingAtLocation as T}from"../interactive/dragEventPipeline.js";import{EditGeometry as S,Component as P}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as V}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as w}from"../interactive/sketch/constraints.js";import{pointToConstraintSpace as O,constraintSpaceToPoint as M,getPointConstraint as D,getPolylineOrPolygonConstraint as E}from"../interactive/sketch/constraintUtils.js";import I from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as H}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as j}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as G}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as k}from"../interactive/snapping/snappingUtils.js";const Z="crosshair",L="progress",U=Symbol(),A=Symbol();let z=class extends(i.EventedMixin(e)){constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new p,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=s(D),this._getPolylineOrPolygonConstraint=s(E),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new I,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=v(!!t.hasZ))}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,n="viewingMode"in e.state?e.state.viewingMode:2,r="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=C(this.hasZ,this.hasM,i),this._editGeometryOperations=new V(new S(r,this.coordinateHelper),n),this._snappingOperation=new G({view:e}),this.addHandles([c(()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint}),({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&w(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))},{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&o(t.constraint,e.constraint)}),c(()=>this.view.viewpoint,(t,e)=>{t&&e&&m(t,e)&&this._onKeyboardBasedChange()})]),this._activeComponent=new P(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const s=this.segmentLabels;null!=s&&(s.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions,automaticLengthMeasurementUtils:this.automaticLengthMeasurementUtils},this.addHandles(c(()=>this.labelOptions.enabled,t=>{s.visible=t},l))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],t=>{const e=t.vertices.map(t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)})),i=e.map(t=>t.coordinates),n=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getFirstVertex()?.pos)??null;y(n,this.firstVertex)||(this.firstVertex=n);const o=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getLastVertex()?.pos)??null;y(o,this.lastVertex)||(this.lastVertex=o);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.edges.at(-1)?.leftVertex?.pos)??null;switch(y(r,this.secondToLastVertex)||(this.secondToLastVertex=r),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}));const p=this._manipulator=new x({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(p),p.grabbable="point"!==t&&"multipoint"!==t,this.addHandles([p.events.on("immediate-click",t=>this._onImmediateClick(t)),p.events.on("immediate-double-click",t=>this._onImmediateDoubleClick(t)),c(()=>this.drawingMode,()=>{this.removeHandles(U),this.addHandles(this._createManipulatorDragPipeline(p),U)},l),c(()=>({effectiveCursor:this.effectiveCursor}),({effectiveCursor:t})=>{p.cursor=t},l)]),k(this,()=>{const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);if(null!=this.snappingManager){const t=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e);this._updatingHandles.addPromise(a(t))}})}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){const{_stagedPointerId:t,_manipulator:e}=this;return null!=t&&this._pointerDownStates.has(t)||e.grabbing||!e.interactive}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map(t=>this.coordinateHelper.vectorToArray(t.pos))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":case"multipoint":return this._getPointConstraint(t);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t)}}set drawingMode(t){this._set("drawingMode",t??f)}get effectiveCursor(){return this.loading?L:this._hideDefaultCursor?null:this.cursor||Z}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&_(t,i)||_(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,o="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!o,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t})),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=n(this.cursorVertex),i=n(t),o=i&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(i)??i),r=this._snapToClosingVertex(o),s=this._applyConstraints(r);_(e,s)||(this._set("cursorVertex",s),this.segmentLabels?.set("stagedVertex",null!=s?this.coordinateHelper.pointToVector(s):null),null==s||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(s)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||this._isDragging||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activeComponent;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return b(t,(t,e,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=j({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new H({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next(t=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t)).next(s),e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||o&&!this.numCommittedVertices)&&this.commitStagedVertex()),t)).next(T(this.view,this.elevationInfo)).next(...r).next(t=>(o&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t)).next(t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))})}_createManipulatorDragPipelineFreehand(t){return b(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t})})}_createManipulatorDragPipelineHybrid(t){return b(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),A),this._processCursor(t.mapStart),this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),this.removeHandles(A),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t})})}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:o}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const r=this.elevationInfo?.mode;let s=this.defaultZ,a=t||"absolute-height"===r;if(null!=o&&(a=o),"on-the-ground"===r&&(a=!1),this._drawAtFixedElevation){s=(t?this.constraintZ:null)??e.getZ(this._activeComponent.vertices[0].pos),a=!1}return a?i:(n.defaultZ=s,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i&&"multipoint"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e&&"multipoint"!==this.geometryType||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=d(t.x,t.y);this._stagedScreenPoint=e,this._stagedPointerType=t.pointerType,this._stagedPointerId=t.pointerId,this._isDragging?this._snappingOperation.abort():(t.stopPropagation(),this._processCursorMovementRelativeToSurface(e,t.pointerType))}_onKeyboardBasedChange(){"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._isDragging?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),o=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const r=this.snappingManager;if(null==r)return this._processCursor(n),void i.abort();const s=this._getSnappingContext(e);this._updatingHandles.addPromise(a(i.snap({point:n,scenePoint:o},r,s)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,o=O(t,n),r=o?e.closestTo(o):void 0;if(!r)return t;const s=M(r,t,n),a="2d"===this.view.type||"absolute-height"!==n.elevationInfo.mode;return null!=s&&a&&null!=this.constraintZ&&this.hasZ&&(s.z=this.constraintZ),s}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&F(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new H({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function F(t,e,i){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o<=i}t([h()],z.prototype,"_hideDefaultCursor",void 0),t([h()],z.prototype,"_stagedPointerId",void 0),t([h()],z.prototype,"_isDragging",null),t([h()],z.prototype,"_snappingOperation",void 0),t([h()],z.prototype,"_snappingEnabled",null),t([h({constructOnly:!0})],z.prototype,"graphic",void 0),t([h()],z.prototype,"constraintsEnabled",void 0),t([h()],z.prototype,"constraints",void 0),t([h()],z.prototype,"_constraint",null),t([h()],z.prototype,"constraintZ",void 0),t([h()],z.prototype,"defaultZ",void 0),t([h()],z.prototype,"isDraped",void 0),t([h({constructOnly:!0})],z.prototype,"automaticLengthMeasurementUtils",void 0),t([h({value:f})],z.prototype,"drawingMode",null),t([h({constructOnly:!0})],z.prototype,"elevationDrawSurface",void 0),t([h({constructOnly:!0})],z.prototype,"elevationInfo",void 0),t([h({constructOnly:!0,type:I})],z.prototype,"labelOptions",void 0),t([h({constructOnly:!0})],z.prototype,"geometryType",void 0),t([h({constructOnly:!0})],z.prototype,"hasM",void 0),t([h({constructOnly:!0})],z.prototype,"hasZ",void 0),t([h()],z.prototype,"cursor",void 0),t([h()],z.prototype,"effectiveCursor",null),t([h()],z.prototype,"loading",void 0),t([h({constructOnly:!0})],z.prototype,"manipulators",void 0),t([h({constructOnly:!0})],z.prototype,"drawSurface",void 0),t([h({constructOnly:!0})],z.prototype,"segmentLabels",void 0),t([h({constructOnly:!0})],z.prototype,"snappingManager",void 0),t([h({constructOnly:!0})],z.prototype,"snappingVisualizer",void 0),t([h()],z.prototype,"snapToSceneEnabled",void 0),t([h({readOnly:!0})],z.prototype,"cursorVertex",null),t([h({readOnly:!0})],z.prototype,"visualizationCursorVertex",null),t([h()],z.prototype,"committableVertex",null),t([h()],z.prototype,"firstVertex",void 0),t([h()],z.prototype,"lastVertex",void 0),t([h()],z.prototype,"secondToLastVertex",void 0),t([h()],z.prototype,"updating",null),t([h({constructOnly:!0})],z.prototype,"view",void 0),z=t([u("esri.views.draw.DrawOperation")],z);export{z as DrawOperation,Z as defaultCursor,L as defaultLoadingCursor};
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../core/Evented.js";import{clone as i}from"../../core/lang.js";import{equalsMaybe as n,destroyMaybe as o}from"../../core/maybe.js";import{memoize as r}from"../../core/memoize.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import a from"../../core/ReactiveSet.js";import{watch as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{createScreenPoint as l}from"../../core/screenUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import{pointEquals as g,pointNear as y}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{defaultDrawingMode as v}from"./DrawingMode.js";import{DrawManipulator as f}from"./DrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as C,sceneSnappingAtLocation as b}from"../interactive/dragEventPipeline.js";import{EditGeometry as T,Component as S}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as P}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as V}from"../interactive/sketch/constraints.js";import{pointToConstraintSpace as w,constraintSpaceToPoint as O,getPointConstraint as M,getPolylineOrPolygonConstraint as D}from"../interactive/sketch/constraintUtils.js";import E from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as I}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as H}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as j}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as G}from"../interactive/snapping/snappingUtils.js";const k="crosshair",Z="progress",L=Symbol(),U=Symbol();let A=class extends e.EventedAccessor{constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new a,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new m,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=r(M),this._getPolylineOrPolygonConstraint=r(D),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new E,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=_(!!t.hasZ))}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,o="viewingMode"in e.state?e.state.viewingMode:2,r="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new P(new T(r,this.coordinateHelper),o),this._snappingOperation=new j({view:e}),this.addHandles([p(()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint}),({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&V(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))},{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&n(t.constraint,e.constraint)}),p(()=>this.view.viewpoint,(t,e)=>{t&&e&&u(t,e)&&this._onKeyboardBasedChange()})]),this._activeComponent=new S(i,o),this._editGeometryOperations.data.components.push(this._activeComponent);const a=this.segmentLabels;null!=a&&(a.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions,automaticLengthMeasurementUtils:this.automaticLengthMeasurementUtils},this.addHandles(p(()=>this.labelOptions.enabled,t=>{a.visible=t},c))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],t=>{const e=t.vertices.map(t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)})),i=e.map(t=>t.coordinates),n=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getFirstVertex()?.pos)??null;g(n,this.firstVertex)||(this.firstVertex=n);const o=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getLastVertex()?.pos)??null;g(o,this.lastVertex)||(this.lastVertex=o);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.edges.at(-1)?.leftVertex?.pos)??null;switch(g(r,this.secondToLastVertex)||(this.secondToLastVertex=r),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}));const l=this._manipulator=new f({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==t&&"multipoint"!==t,this.addHandles([l.events.on("immediate-click",t=>this._onImmediateClick(t)),l.events.on("immediate-double-click",t=>this._onImmediateDoubleClick(t)),p(()=>this.drawingMode,()=>{this.removeHandles(L),this.addHandles(this._createManipulatorDragPipeline(l),L)},c),p(()=>({effectiveCursor:this.effectiveCursor}),({effectiveCursor:t})=>{l.cursor=t},c)]),G(this,()=>{const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);if(null!=this.snappingManager){const t=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e);this._updatingHandles.addPromise(s(t))}})}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){const{_stagedPointerId:t,_manipulator:e}=this;return null!=t&&this._pointerDownStates.has(t)||e.grabbing||!e.interactive}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map(t=>this.coordinateHelper.vectorToArray(t.pos))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":case"multipoint":return this._getPointConstraint(t);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t)}}set drawingMode(t){this._set("drawingMode",t??v)}get effectiveCursor(){return this.loading?Z:this._hideDefaultCursor?null:this.cursor||k}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&y(t,i)||y(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,o="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!o,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t})),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=i(this.cursorVertex),n=i(t),o=n&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(n)??n),r=this._snapToClosingVertex(o),s=this._applyConstraints(r);y(e,s)||(this._set("cursorVertex",s),this.segmentLabels?.set("stagedVertex",null!=s?this.coordinateHelper.pointToVector(s):null),null==s||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(s)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||this._isDragging||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activeComponent;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return C(t,(t,e,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=H({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next(t=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t)).next(s),e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||o&&!this.numCommittedVertices)&&this.commitStagedVertex()),t)).next(b(this.view,this.elevationInfo)).next(...r).next(t=>(o&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t)).next(t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))})}_createManipulatorDragPipelineFreehand(t){return C(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t})})}_createManipulatorDragPipelineHybrid(t){return C(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),U),this._processCursor(t.mapStart),this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),this.removeHandles(U),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t})})}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:o}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const r=this.elevationInfo?.mode;let s=this.defaultZ,a=t||"absolute-height"===r;if(null!=o&&(a=o),"on-the-ground"===r&&(a=!1),this._drawAtFixedElevation){s=(t?this.constraintZ:null)??e.getZ(this._activeComponent.vertices[0].pos),a=!1}return a?i:(n.defaultZ=s,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i&&"multipoint"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e&&"multipoint"!==this.geometryType||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=l(t.x,t.y);this._stagedScreenPoint=e,this._stagedPointerType=t.pointerType,this._stagedPointerId=t.pointerId,this._isDragging?this._snappingOperation.abort():(t.stopPropagation(),this._processCursorMovementRelativeToSurface(e,t.pointerType))}_onKeyboardBasedChange(){"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._isDragging?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),o=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const r=this.snappingManager;if(null==r)return this._processCursor(n),void i.abort();const a=this._getSnappingContext(e);this._updatingHandles.addPromise(s(i.snap({point:n,scenePoint:o},r,a)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,o=w(t,n),r=o?e.closestTo(o):void 0;if(!r)return t;const s=O(r,t,n),a="2d"===this.view.type||"absolute-height"!==n.elevationInfo.mode;return null!=s&&a&&null!=this.constraintZ&&this.hasZ&&(s.z=this.constraintZ),s}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&z(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function z(t,e,i){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o<=i}t([d()],A.prototype,"_hideDefaultCursor",void 0),t([d()],A.prototype,"_stagedPointerId",void 0),t([d()],A.prototype,"_isDragging",null),t([d()],A.prototype,"_snappingOperation",void 0),t([d()],A.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],A.prototype,"graphic",void 0),t([d()],A.prototype,"constraintsEnabled",void 0),t([d()],A.prototype,"constraints",void 0),t([d()],A.prototype,"_constraint",null),t([d()],A.prototype,"constraintZ",void 0),t([d()],A.prototype,"defaultZ",void 0),t([d()],A.prototype,"isDraped",void 0),t([d({constructOnly:!0})],A.prototype,"automaticLengthMeasurementUtils",void 0),t([d({value:v})],A.prototype,"drawingMode",null),t([d({constructOnly:!0})],A.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],A.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:E})],A.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],A.prototype,"geometryType",void 0),t([d({constructOnly:!0})],A.prototype,"hasM",void 0),t([d({constructOnly:!0})],A.prototype,"hasZ",void 0),t([d()],A.prototype,"cursor",void 0),t([d()],A.prototype,"effectiveCursor",null),t([d()],A.prototype,"loading",void 0),t([d({constructOnly:!0})],A.prototype,"manipulators",void 0),t([d({constructOnly:!0})],A.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],A.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],A.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],A.prototype,"snappingVisualizer",void 0),t([d()],A.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],A.prototype,"cursorVertex",null),t([d({readOnly:!0})],A.prototype,"visualizationCursorVertex",null),t([d()],A.prototype,"committableVertex",null),t([d()],A.prototype,"firstVertex",void 0),t([d()],A.prototype,"lastVertex",void 0),t([d()],A.prototype,"secondToLastVertex",void 0),t([d()],A.prototype,"updating",null),t([d({constructOnly:!0})],A.prototype,"view",void 0),A=t([h("esri.views.draw.DrawOperation")],A);export{A as DrawOperation,k as defaultCursor,Z 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import
|
|
5
|
+
import{__decorate as e}from"tslib";import{createTask as t}from"../../../core/asyncUtils.js";import n from"../../../core/Evented.js";import"../../../core/has.js";import{throwIfAborted as i,isAborted as s}from"../../../core/promiseUtils.js";import{watch as a,syncAndInitial as r,sync as o}from"../../../core/reactiveUtils.js";import{property as p}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{project as c,initializeProjection as l}from"../../../geometry/projectionUtils.js";import{absoluteHeightElevationInfo as h}from"../../../support/elevationInfoUtils.js";import{fromPoint as u,markAsTarget as f,toElevationAlignedDehydratedPoint as g}from"../sketch/normalizedPoint.js";import{defaults as _}from"./Settings.js";import S from"./SnappingOptions.js";import{sortCandidatesInPlace as m,squaredScreenDistance as v}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as y}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as w}from"./candidates/EdgeSnappingCandidate.js";import{IntersectionSnappingCandidate as C}from"./candidates/IntersectionSnappingCandidate.js";import{LineSnappingCandidate as P}from"./candidates/LineSnappingCandidate.js";import{ParallelLineSnappingCandidate as E}from"./candidates/ParallelLineSnappingCandidate.js";import{RightAngleSnappingCandidate as T}from"./candidates/RightAngleSnappingCandidate.js";import{RightAngleTriangleSnappingCandidate as j}from"./candidates/RightAngleTriangleSnappingCandidate.js";import{vectorToScreenPoint as R}from"../support/viewUtils.js";import{loadGeodesicLengthMeasurementUtils as M}from"../../support/geodesicLengthMeasurementUtils.js";let q=class extends n.EventedAccessor{constructor(e){super(e),this.options=new S,this._engineCache=new Map,this._loadTask=null,this._engines=[],this._currentMainCandidate=null,this._currentOtherActiveCandidates=[],this._currentSnappedType=0}initialize(){this.addHandles([a(()=>{const{distance:e,touchSensitivityMultiplier:t,effectiveSelfEnabled:n,effectiveFeatureEnabled:i,effectiveGridEnabled:s}=this.options;return{selfEnabled:n,featureEnabled:i,gridEnabled:"2d"===this.view.type&&s,viewReady:this.view.ready,viewSpatialReference:this.view.spatialReference,distance:e,touchSensitivityMultiplier:t}},(e,n)=>{n&&(this.doneSnapping(),this.emit("changed")),this._loadTask?.abort(),this._loadTask=t(t=>this._updateEngines(e,n,t))},r),a(()=>this.options,e=>{for(const t of this._engines)t.options=e},o)])}destroy(){this._loadTask?.abort(),this._destroyEngines()}get updating(){return this._engines.some(e=>e.updating)||!this._loadTask?.finished}_destroyEngines(){this._engineCache.forEach(e=>e.destroy()),this._engineCache.clear(),this._engines=[]}async _updateEngines(e,t,n){if(!e.viewReady)return void this._destroyEngines();t?.viewSpatialReference!==e.viewSpatialReference&&this._destroyEngines();const i=this._engineCache,s=await Promise.allSettled([e.featureEnabled&&!i.has("feature")?this._createFeatureSnappingEngine(n):void 0,e.selfEnabled&&!i.has("self")?this._createSelfSnappingEngine(n):void 0,e.gridEnabled&&!i.has("grid")?this._createGridSnappingEngine(n):void 0]);if(n.aborted)for(const a of s)"fulfilled"===a.status&&a.value?.engine.destroy();else{for(const e of s)"fulfilled"===e.status&&e.value&&i.set(e.value.type,e.value.engine);this._engines=Array.from(i.values())}}async _createSelfSnappingEngine(e){const[{SelfSnappingEngine:t},n]=await Promise.all([import("./SelfSnappingEngine.js"),M()]);return i(e),{type:"self",engine:new t({view:this.view,options:this.options,geodesicLengthMeasurementUtils:n})}}async _createGridSnappingEngine(e){const{view:t}=this;if("2d"!==t.type)return;const{GridSnappingEngine:n}=await import("./GridSnappingEngine.js");return i(e),{type:"grid",engine:new n({view:t,options:this.options})}}async _createFeatureSnappingEngine(e){const{FeatureSnappingEngine:t}=await import("./FeatureSnappingEngine.js");i(e);const{view:n,options:s}=this,{spatialReference:a}=n;return{type:"feature",engine:new t({view:n,options:s,spatialReference:a})}}get _squaredMouseProximityThreshold(){return this.options.distance*this.options.distance}get _squaredTouchProximityThreshold(){const{distance:e,touchSensitivityMultiplier:t}=this.options,n=e*t;return n*n}snap(e){return O(e)?this._snapMultiPoint(e):this._snapSinglePoint(e)}update(e){const{point:t,context:n}=e;this._removeVisualization();const i=this._currentMainCandidate;if(null==i)return t;const s=this._selectUpdateInput(e);if(null==s)return t;const{spatialReference:a}=n,r=c(s,a);if(null==r)return t;const{view:o}=this,{elevationInfo:p,visualizer:d}=n,l=[],h=u(r,o,p),_=i.constraint.closestTo(h);if(!this._arePointsWithinScreenThreshold(h,_,n)||!z(i,n.drawConstraints))return this._resetSnappingState(),t;i.targetPoint=f(_),l.push(...i.hints);for(const c of this._currentOtherActiveCandidates)z(c,n.drawConstraints)&&(c.targetPoint=f(_),l.push(...c.hints));return null!=d&&this.addHandles(d.draw(l,{spatialReference:a,elevationInfo:H(n),view:o,selfSnappingZ:n.selfSnappingZ}),b),g(_,o,t,n)}doneSnapping(){this._removeVisualization(),this._resetSnappingState()}_selectUpdateInput({point:e,scenePoint:t}){switch(this._currentSnappedType){case 0:return e;case 1:return t}}_resetSnappingState(){this._currentMainCandidate=null,this._currentOtherActiveCandidates=[],this._currentSnappedType=0}_removeVisualization(){this.removeHandles(b)}async _snapSinglePoint({point:e,context:t,signal:n}){const{view:i}=this,{elevationInfo:s}=t,a=u(e,i,s),r=await this._fetchCandidates(a,3,t,n);return this._createSnapResult(a,0,r,i,e,t,n)}async _snapMultiPoint({point:e,scenePoint:t,context:n,signal:i}){const{view:s}=this,{coordinateHelper:a,elevationInfo:r,spatialReference:o}=n;await l(t.spatialReference,o);const p=c(t,o),d=u(p,s,r),h=await this._fetchCandidates(d,1,n,i);if(h.length>0){const e=await this._fetchCandidates(d,2,n,i);return this._createSnapResult(d,1,[...h,...e],s,p,n,i)}const f=u(e,s,r),g=await this._fetchCandidates(f,2,n,i);return this._createSnapResult(f,0,g,s,{z:a.hasZ()&&e.hasZ?e.z??0:void 0,m:a.hasM()&&e.hasM?e.m??0:void 0},n,i)}async _fetchCandidates(e,t,n,i){return(await Promise.all(this._engines.map(s=>s.fetchCandidates(e,t,n,i)))).flat()}_createSnapResult(e,t,n,i,a,r,o){return{get valid(){return!s(o)},apply:()=>{const{spatialReference:s}=r,{snappedPoint:o,hints:p}=this._processCandidates(e,t,n,r);return this._removeVisualization(),null!=r.visualizer&&this.addHandles(r.visualizer.draw(p,{spatialReference:s,elevationInfo:h,view:i,selfSnappingZ:r.selfSnappingZ}),b),g(o,i,a,r)}}}_processCandidates(e,t,n,i){if(n.length<1)return this.doneSnapping(),{snappedPoint:e,hints:[]};this._currentSnappedType!==t&&this._resetSnappingState(),m(e,n);const s=this._currentMainCandidate;if(null!=s){const a=U(s,n);if(a>=0){if(!(n[a]instanceof C))return this._intersectWithOtherCandidates(a,n,e,t,i);if(this._arePointsWithinScreenThreshold(e,s.targetPoint,i))return this._updateSnappingCandidate(s,t,n,i)}}return this._intersectWithOtherCandidates(0,n,e,t,i)}_intersectWithOtherCandidates(e,t,n,i,s){const{coordinateHelper:a}=s,r=t[e],o=[];for(let p=0;p<t.length;++p){if(p===e)continue;const i=t[p],s=r.constraint.intersect(i.constraint);if(s)for(const e of s.closestPoints(r.targetPoint))o.push([new C(f(e),r,i,i.isDraped),this._squaredScreenDistance(n,e,a)])}return o.length>0&&(o.sort((e,t)=>e[1]-t[1]),o[0][1]<this._squaredPointProximityThreshold(s.pointer))?this._updateSnappingCandidate(o[0][0],i,t,s):z(r,s.drawConstraints)?this._updateSnappingCandidate(r,i,t,s):{snappedPoint:n,hints:[]}}_updateSnappingCandidate(e,t,n,i){this.doneSnapping(),this._currentMainCandidate=e,this._currentSnappedType=t;const s=this._currentMainCandidate.targetPoint,a=[];a.push(...e.hints);for(const r of n){if(e instanceof C){if(r.constraint.equals(e.first.constraint)||r.constraint.equals(e.second.constraint))continue}else if(r.constraint.equals(e.constraint))continue;const t=r.constraint.closestTo(s);this._squaredScreenDistance(t,s,i.coordinateHelper)<x()&&(r.targetPoint=s,this._currentOtherActiveCandidates.push(r),a.push(...r.hints))}return{snappedPoint:s,hints:a}}_squaredPointProximityThreshold(e){return"touch"===e?this._squaredTouchProximityThreshold:this._squaredMouseProximityThreshold}_arePointsWithinScreenThreshold(e,t,n){return this._squaredScreenDistance(e,t,n.coordinateHelper)<this._squaredPointProximityThreshold(n.pointer)}_squaredScreenDistance(e,t,n){return v(this._toScreen(e,n),this._toScreen(t,n))}_toScreen(e,t){return R(e,t.spatialReference,h,this.view)}get test(){}};e([p({constructOnly:!0})],q.prototype,"view",void 0),e([p()],q.prototype,"options",void 0),e([p({readOnly:!0})],q.prototype,"updating",null),e([p()],q.prototype,"_loadTask",void 0),e([p()],q.prototype,"_engines",void 0),e([p()],q.prototype,"_squaredMouseProximityThreshold",null),e([p()],q.prototype,"_squaredTouchProximityThreshold",null),q=e([d("esri.views.interactive.snapping.SnappingManager")],q);const b="visualization-handle";function x(){return _.satisfiesConstraintScreenThreshold*_.satisfiesConstraintScreenThreshold}function z(e,t){return!t||null==t.direction&&null==t.distance||!(e instanceof y||e instanceof w||e instanceof P||e instanceof E||e instanceof j)&&(!(e instanceof T)||null==t.direction&&1===e.selfSnappingType)}function U(e,t){return e instanceof C?I(t,e.first)>=0&&I(t,e.second)>=0?0:-1:I(t,e)}function I(e,t){let n=-1;for(let i=0;i<e.length;++i)if(t.constraint.equals(e[i].constraint)){n=i;break}return n}function O(e){return null!=e.scenePoint}function H({coordinateHelper:e,elevationInfo:t}){return e.hasZ()?h:t}export{q as SnappingManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{memoize as i}from"../../../../core/memoize.js";import{throwIfAborted as r,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{watch as o,on as a,initial as s}from"../../../../core/reactiveUtils.js";import{sqlAnd as l}from"../../../../core/sql.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as c}from"../../../../support/elevationInfoUtils.js";import{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 f=class extends t{get availability(){return 1}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 r=async(i,r)=>(await n(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(i,r);return m(i,{elevationInfo:t.elevationInfo,alignPointsInFeatures:r})}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 o=await e.whenLayerView(t);return r(n),o.queryForSymbologySnapping({candidates:i,spatialReference:e.spatialReference},n)}):v()}get _layerView(){const{view:e}=this;if(null==e)return null;const{layer:t}=this.layerSource;return e.allLayerViews.find(e=>e.layer===t)}get _layerView3D(){const{view:e}=this;return null==e||"2d"===e.type?null:this._layerView}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&&this.addHandles([e.elevationProvider.on("elevation-change",({context:e})=>{const{elevationInfo:i}=t;c(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()}),o(()=>t.elevationInfo,()=>this._snappingElevationAligner.notifyElevationSourceChange(),s),o(()=>null!=this._layerView3D?this._layerView3D.layer?.renderer:null,()=>this._symbologySnappingFetcher.notifySymbologyChange(),s),a(()=>this._layerView3D?.layer,["edits","apply-edits"
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{memoize as i}from"../../../../core/memoize.js";import{throwIfAborted as r,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{watch as o,on as a,initial as s}from"../../../../core/reactiveUtils.js";import{sqlAnd as l}from"../../../../core/sql.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as c}from"../../../../support/elevationInfoUtils.js";import{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 f=class extends t{get availability(){return 1}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 r=async(i,r)=>(await n(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(i,r);return m(i,{elevationInfo:t.elevationInfo,alignPointsInFeatures:r})}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 o=await e.whenLayerView(t);return r(n),o.queryForSymbologySnapping({candidates:i,spatialReference:e.spatialReference},n)}):v()}get _layerView(){const{view:e}=this;if(null==e)return null;const{layer:t}=this.layerSource;return e.allLayerViews.find(e=>e.layer===t)}get _layerView3D(){const{view:e}=this;return null==e||"2d"===e.type?null:this._layerView}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&&this.addHandles([e.elevationProvider.on("elevation-change",({context:e})=>{const{elevationInfo:i}=t;c(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()}),o(()=>t.elevationInfo,()=>this._snappingElevationAligner.notifyElevationSourceChange(),s),o(()=>null!=this._layerView3D?this._layerView3D.layer?.renderer:null,()=>this._symbologySnappingFetcher.notifySymbologyChange(),s),a(()=>this._layerView3D?.layer,["edits","apply-edits"],()=>this._symbologySnappingFetcher.notifySymbologyChange())])}constructor(e){super(e),this.view=null,this.updating=!1,this._memoizedMakeGetGroundElevation=i(h)}refresh(){}async fetchCandidates(e,t){const{layer:i}=this.layerSource,{source:n}=i;if(!n?.querySnapping)return[];const o=i.createQuery();this._layerView&&"effectiveDisplayFilter"in this._layerView&&(o.where=l(o.where,this._layerView.effectiveDisplayFilter?.where));const a="returnZ"in i?i.returnZ:void 0,s=u({parameters:e,mode:this.view?.type??"2d",returnZ:a,filter:o}),p=await n.querySnapping(s,{signal:t});r(t);const y=e.coordinateHelper.spatialReference,c=await this._snappingElevationAligner.alignCandidates(p.candidates,y,t);r(t);const h=await this._symbologySnappingFetcher.fetch(c,t);r(t);const m=0===h.length?c:[...c,...h],d=this._snappingElevationFilter.filter(s,m),v=this._memoizedMakeGetGroundElevation(this.view,y);return d.map(e=>g(e,v))}};e([p({constructOnly:!0})],f.prototype,"layerSource",void 0),e([p({constructOnly:!0})],f.prototype,"view",void 0),e([p()],f.prototype,"_snappingElevationAligner",null),e([p()],f.prototype,"_snappingElevationFilter",null),e([p()],f.prototype,"_symbologySnappingFetcher",null),e([p()],f.prototype,"_layerView",null),e([p()],f.prototype,"_layerView3D",null),e([p()],f.prototype,"_symbologySnappingSupported",null),f=e([y("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],f);export{f 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../../core/has.js";import t from"../../core/Logger.js";import{throwIfAborted as i}from"../../core/promiseUtils.js";import{watch as r,on as l,syncAndInitial as s}from"../../core/reactiveUtils.js";import{sqlOr as o,sqlIn as n,sqlAnd as a}from"../../core/sql.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{getFeatureIdInfoFieldNames as d}from"../../layers/graphics/data/FeatureIdInfo.js";import{systemIsSpatialFieldName as f}from"../../layers/knowledgeGraph/constants.js";import{getEffectiveDisplayFilter as y}from"../../layers/support/displayFilterUtils.js";import h from"../../layers/support/FeatureEffect.js";import m from"../../layers/support/FeatureFilter.js";import{getSignedInUser as c}from"../../layers/support/featureLayerUtils.js";import{fetchFeaturePopupFeatures as F,loadFeaturePopupArcadeModules as g}from"../../layers/support/featurePopupQueryUtils.js";import{fixFields as I,unpackFieldNames as b,collectLabelingFields as w,collectElevationFields as v,collectFilterFields as E,collectFeatureReductionFields as x,collectOrderByInfos as q,collectFields as R,collectTrackInfoFields as j,collectDisplayFilterFields as C,collectField as _,featureHasFields as O}from"../../layers/support/fieldUtils.js";import{getFloorFilterClause as k}from"../../layers/support/floorFilterUtils.js";import{getUtilityNetworkFields as U}from"../../networks/support/networkFieldUtils.js";import P from"../../rest/support/Query.js";import{createFeatureIdInfo as T}from"../2d/layers/features/layerAdapters/featureServiceUtils.js";import{getRequiredFields as L,getFetchPopupTemplate as S}from"./support/popupUtils.js";import{WhereClauseVisitor as D}from"./support/WhereClauseVisitor.js";const N=N=>{const Q=N;let G=class extends Q{constructor(...e){super(...e),this._updatingRequiredPromise=null,this.filter=null,this.layer=null,this.requiresCurrentUser=!1,this.requiredFields=[],this.view=null}initialize(){this.addHandles([r(()=>{const e=this.layer,t=this.view;return[e&&"elevationInfo"in e?e.elevationInfo?.featureExpressionInfo:null,e&&"displayField"in e?e.displayField:null,e&&"timeInfo"in e&&e.timeInfo,e&&"renderer"in e&&e.renderer,e&&"labelingInfo"in e&&e.labelingInfo,e&&"floorInfo"in e&&e.floorInfo,t?.requiredFieldsOptions?.featureTitleFields&&e&&"featureTitleFields"in e&&e.featureTitleFields,t?.requiredFieldsOptions?.utilityNetworkFields&&U(t,e),e.displayFilterInfo,this.displayFilterEnabled,this.filter,this.featureEffect,this.timeExtent,"knowledge-graph-sublayer"===e?.type&&"link-chart"===e.parentCompositeLayer.type&&e.parentCompositeLayer.linkChart?.linkChartProperties.nonspatialDataDisplay?.mode,"parquet"===e?.type&&e.popupTemplate]},()=>this._handleChange(),s),l(()=>this.view?.floors,"change",()=>this._handleChange()),l(()=>this.layer.displayFilterInfo?.filters,"change",()=>this._handleChange()),l(()=>this.layer&&"sublayers"in this.layer?this.layer.sublayers:null,"change",()=>this._handleChange())])}get availableFields(){if(!this.layer)return[];const{layer:e,layer:{fieldsIndex:t},requiredFields:i}=this;return"outFields"in e&&e.outFields?I(t,[...b(t,e.outFields),...i]):I(t,i)}get displayFilterEnabled(){return(this.view?.displayFilterEnabled??!0)&&(!("displayFilterEnabled"in this.layer)||(this.layer?.displayFilterEnabled??!0))}get effectiveDisplayFilter(){const e=this.layer;return this.displayFilterEnabled&&e.displayFilterInfo?y(e.displayFilterInfo,this.view):null}get effectiveDisplayFilterClause(){const e=this.effectiveDisplayFilter?.where??null;return e&&this.hasHighlight?o(e,n(this.layer.objectIdField,this.highlightIds)):e}get featureEffect(){return this.layer&&"featureEffect"in this.layer?this.layer.featureEffect:null}set featureEffect(e){this._override("featureEffect",e)}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(e){t.getLogger(this).error("#maximumNumberOfFeatures=","Setting maximum number of features is not supported")}get maximumNumberOfFeaturesExceeded(){return!1}get signedInUser(){return this.layer?.url?c(this.layer.url):Promise.resolve(null)}highlight(e,t){throw new Error("missing implementation")}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference},t=null!=this.filter?this.filter.createQuery(e):new P(e);return"floorInfo"in this.layer&&this.layer.floorInfo&&(t.where=a(t.where,k(this))),this.displayFilterEnabled&&(t.where=a(t.where,this.effectiveDisplayFilter?.where)),null!=this.timeExtent&&(t.timeExtent=null!=t.timeExtent?t.timeExtent.intersection(this.timeExtent):this.timeExtent.clone()),t}createAggregateQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return new P(e)}queryFeatures(e,t){throw new Error("missing implementation")}queryObjectIds(e,t){throw new Error("missing implementation")}queryFeatureCount(e,t){throw new Error("missing implementation")}queryExtent(e,t){throw new Error("missing implementation")}async fetchPopupFeaturesFromGraphics(e,t){const i=await this._createPopupQuery(e.map(e=>e.origin?.layer??e.layer),t);return await F(this.layer,e,i,{getPopupTemplate:e=>e&&"popupEnabled"in e&&e.popupEnabled?S(e,t):null,hasRequiredFields:(e,t)=>this._popupFeatureHasRequiredFields(e,t),...t})}_handleChange(){const e=Promise.all([this._updateRequiredFields(),this._updateClientWhereClauseRequirements()]).then(()=>{});return this._set("_updatingRequiredPromise",e),e.then(()=>{this._updatingRequiredPromise===e&&this._set("_updatingRequiredPromise",null)}),e}async _updateClientWhereClauseRequirements(){if(!this.layer||!this.view)return;const{layer:e}=this,i=new D(e.fieldsIndex);if(i.visitFilter(this.filter),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction),"labelingInfo"in e&&i.visitLabelingInfo(e.labelsVisible,e.labelingInfo),"trackInfo"in e&&i.visitTrackInfo(e.trackInfo),"2d"===this.view.type&&(i.visitFilter(this.featureEffect?.filter),i.visitDisplayFilter(this.displayFilterEnabled,e.displayFilterInfo),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction)),"subtype-group"===e.type)for(const t of e.sublayers)i.visitLabelingInfo(t.labelsVisible,t.labelingInfo);try{const e=await i.finish();this._set("requiresCurrentUser",e.requiresCurrentUser)}catch(r){t.getLogger(this).error(r)}}async _updateRequiredFields(){if(!this.layer||!this.view)return;const e="3d"===this.view.type,{layer:i,layer:{fieldsIndex:r}}=this,l="renderer"in i&&i.renderer,s="orderBy"in i&&i.orderBy,o="featureReduction"in i?i.featureReduction:null,n=new Set,a=[l?l.collectRequiredFields(n,r):null,w(n,i),e&&"elevationInfo"in i?v(n,i):null,null!=this.filter?E(n,i,this.filter):null,e||null==this.featureEffect?null:E(n,i,this.featureEffect.filter),!e&&o?x(n,i,o):null,!e&&s?q(n,i,s):null];if("timeInfo"in i&&i.timeInfo&&this.timeExtent&&R(n,i.fieldsIndex,[i.timeInfo.startField,i.timeInfo.endField]),"timeInfo"in i&&i.timeInfo&&"trackInfo"in i&&i.trackInfo){const{trackInfo:e}=i;R(n,i.fieldsIndex,[i.timeInfo.trackIdField]),"feature"!==i.type&&"startTimeField"!==e.timeField||R(n,i.fieldsIndex,[i.timeInfo.startField]),"endTimeField"===e.timeField&&R(n,i.fieldsIndex,[i.timeInfo.endField]),await j(n,i)}if("floorInfo"in i&&i.floorInfo&&R(n,i.fieldsIndex,[i.floorInfo.floorField]),"featureTitleFields"in i&&this.view?.requiredFieldsOptions?.featureTitleFields&&i.featureTitleFields&&R(n,i.fieldsIndex,i.featureTitleFields),"feature"===i.type&&i.globalIdField&&this.view?.requiredFieldsOptions?.globalIdField&&R(n,i.fieldsIndex,[i.globalIdField]),this.displayFilterEnabled&&a.push(C(n,i,i.displayFilterInfo)),"feature"===i.type&&e&&null!=i.infoFor3D&&(null==i.globalIdField&&t.getLogger(this).error("globalIdField missing on 3DObjectFeatureLayer"),R(n,i.fieldsIndex,[i.globalIdField])),"subtype-group"===i.type){_(n,r,i.subtypeField);const e=i.sublayers.map(e=>Promise.all([e.renderer?.collectRequiredFields(n,r),w(n,e)]));a.push(Promise.all(e))}if("catalog-footprint"===i.type&&i.parent){const e=i.parent;R(n,r,[e.itemNameField,e.itemSourceField,e.itemTypeField,e.maxScaleField,e.minScaleField])}"knowledge-graph-sublayer"===i.type&&"link-chart"===i.parentCompositeLayer.type&&_(n,r,f),"parquet"===i.type&&a.push(L(i,i.popupTemplate).then(e=>{for(const t of e)n.add(t)}));const u=await Promise.allSettled(a);if(e)_(n,r,i.objectIdField);else for(const t of d(T(i)))_(n,r,t);e&&"displayField"in i&&i.displayField&&_(n,r,i.displayField);for(const d of u)"rejected"===d.status&&t.getLogger(this).error(d.reason);const p=Array.from(n).sort();this._set("requiredFields",p)}_popupFeatureHasRequiredFields(e,t){return O(e,t)}async _createPopupQuery(e,t){const r=this.layer.createQuery(),l=new Set;let s=!1;const o=e??[this.layer];for(const n of o){if(!("popupEnabled"in n))continue;const e=S(n,t);if(null==e)continue;const r=await g(e);i(t);const o=r&&r.arcadeUtils.hasGeometryOperations(e);s=!("point"!==this.layer.geometryType&&!o);const a=await L(this.layer,e);i(t);for(const t of a)l.add(t)}return r.returnGeometry=s,r.returnZ=s,r.returnM=s,r.outFields=Array.from(l),r.outSpatialReference=this.view.spatialReference,"floorInfo"in this.layer&&this.layer.floorInfo&&(r.where=a(r.where,k(this))),r}canResume(){return!!super.canResume()&&(null==this.timeExtent||!this.timeExtent.isEmpty)}getTest(){}get test(){}};return e([u()],G.prototype,"_updatingRequiredPromise",void 0),e([u({readOnly:!0})],G.prototype,"availableFields",null),e([u({readOnly:!0})],G.prototype,"displayFilterEnabled",null),e([u({readOnly:!0})],G.prototype,"effectiveDisplayFilter",null),e([u({readOnly:!0})],G.prototype,"effectiveDisplayFilterClause",null),e([u({type:h})],G.prototype,"featureEffect",null),e([u({type:m})],G.prototype,"filter",void 0),e([u()],G.prototype,"layer",void 0),e([u({type:Number})],G.prototype,"maximumNumberOfFeatures",null),e([u({readOnly:!0,type:Boolean})],G.prototype,"maximumNumberOfFeaturesExceeded",null),e([u()],G.prototype,"requiresCurrentUser",void 0),e([u({readOnly:!0})],G.prototype,"requiredFields",void 0),e([u({readOnly:!0})],G.prototype,"signedInUser",null),e([u()],G.prototype,"suspended",void 0),e([u()],G.prototype,"view",void 0),G=e([p("esri.views.layers.FeatureLayerView")],G),G};export{N as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../core/has.js";import t from"../../core/Logger.js";import{throwIfAborted as i}from"../../core/promiseUtils.js";import{watch as r,on as l,syncAndInitial as s}from"../../core/reactiveUtils.js";import{sqlOr as o,sqlIn as n,sqlAnd as a}from"../../core/sql.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{getFeatureIdInfoFieldNames as d}from"../../layers/graphics/data/FeatureIdInfo.js";import{systemIsSpatialFieldName as f}from"../../layers/knowledgeGraph/constants.js";import{getEffectiveDisplayFilter as y}from"../../layers/support/displayFilterUtils.js";import m from"../../layers/support/FeatureEffect.js";import h from"../../layers/support/FeatureFilter.js";import{getSignedInUser as c}from"../../layers/support/featureLayerUtils.js";import{fetchFeaturePopupFeatures as F,loadFeaturePopupArcadeModules as g}from"../../layers/support/featurePopupQueryUtils.js";import{fixFields as I,unpackFieldNames as b,collectLabelingFields as w,collectElevationFields as v,collectFilterFields as E,collectFeatureReductionFields as x,collectOrderByInfos as q,collectFields as R,collectTrackInfoFields as j,collectDisplayFilterFields as C,collectField as _,featureHasFields as O}from"../../layers/support/fieldUtils.js";import{getFloorFilterClause as T}from"../../layers/support/floorFilterUtils.js";import{getUtilityNetworkFields as k}from"../../networks/support/networkFieldUtils.js";import U from"../../rest/support/Query.js";import{createFeatureIdInfo as P}from"../2d/layers/features/layerAdapters/featureServiceUtils.js";import{getRequiredFields as L,getFetchPopupTemplate as S}from"./support/popupUtils.js";import{WhereClauseVisitor as D}from"./support/WhereClauseVisitor.js";const N=N=>{const Q=N;let G=class extends Q{constructor(...e){super(...e),this._updatingRequiredPromise=null,this.filter=null,this.layer=null,this.requiresCurrentUser=!1,this.requiredFields=[],this.view=null}initialize(){this.addHandles([r(()=>{const e=this.layer,t=this.view;return[e&&"elevationInfo"in e?e.elevationInfo?.featureExpressionInfo:null,e&&"displayField"in e?e.displayField:null,e&&"timeInfo"in e&&e.timeInfo,e&&"renderer"in e&&e.renderer,e&&"labelingInfo"in e&&e.labelingInfo,e&&"floorInfo"in e&&e.floorInfo,t?.requiredFieldsOptions?.featureTitleFields&&e&&"featureTitleFields"in e&&e.featureTitleFields,t?.requiredFieldsOptions?.utilityNetworkFields&&k(t,e),e.displayFilterInfo,this.displayFilterEnabled,this.filter,this.featureEffect,this.timeExtent,"knowledge-graph-sublayer"===e?.type&&"link-chart"===e.parentCompositeLayer.type&&e.parentCompositeLayer.linkChart?.linkChartProperties.nonspatialDataDisplay?.mode,"parquet"===e?.type&&e.popupTemplate]},()=>this._handleChange(),s),l(()=>this.view?.floors,"change",()=>this._handleChange()),l(()=>this.layer.displayFilterInfo?.filters,"change",()=>this._handleChange()),l(()=>this.layer&&"sublayers"in this.layer?this.layer.sublayers:null,"change",()=>this._handleChange())])}get availableFields(){if(!this.layer)return[];const{layer:e,layer:{fieldsIndex:t},requiredFields:i}=this;return"outFields"in e&&e.outFields?I(t,[...b(t,e.outFields),...i]):I(t,i)}get displayFilterEnabled(){return(this.view?.displayFilterEnabled??!0)&&(!("displayFilterEnabled"in this.layer)||(this.layer?.displayFilterEnabled??!0))}get effectiveDisplayFilter(){const e=this.layer;return this.displayFilterEnabled&&e.displayFilterInfo?y(e.displayFilterInfo,this.view):null}get effectiveDisplayFilterClause(){const e=this.effectiveDisplayFilter?.where??null;return e&&this.hasHighlight?o(e,n(this.layer.objectIdField,this.highlightIds)):e}get featureEffect(){return this.layer&&"featureEffect"in this.layer?this.layer.featureEffect:null}set featureEffect(e){this._override("featureEffect",e)}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(e){t.getLogger(this).error("#maximumNumberOfFeatures=","Setting maximum number of features is not supported")}get maximumNumberOfFeaturesExceeded(){return!1}get signedInUser(){return this.layer?.url?c(this.layer.url):Promise.resolve(null)}highlight(e,t){throw new Error("missing implementation")}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference},t=null!=this.filter?this.filter.createQuery(e):new U(e);return"floorInfo"in this.layer&&this.layer.floorInfo&&(t.where=a(t.where,T(this))),this.displayFilterEnabled&&(t.where=a(t.where,this.effectiveDisplayFilter?.where)),null!=this.timeExtent&&(t.timeExtent=null!=t.timeExtent?t.timeExtent.intersection(this.timeExtent):this.timeExtent.clone()),t}createAggregateQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return new U(e)}queryFeatures(e,t){throw new Error("missing implementation")}queryObjectIds(e,t){throw new Error("missing implementation")}queryFeatureCount(e,t){throw new Error("missing implementation")}queryExtent(e,t){throw new Error("missing implementation")}async fetchPopupFeaturesFromGraphics(e,t){const i=await this._createPopupQuery(e.map(e=>e.origin?.layer??e.layer),t);return await F(this.layer,e,i,{getPopupTemplate:e=>e&&"popupTemplate"in e&&e.popupEnabled?S(e,t):null,hasRequiredFields:(e,t)=>this._popupFeatureHasRequiredFields(e,t),...t})}_handleChange(){const e=Promise.all([this._updateRequiredFields(),this._updateClientWhereClauseRequirements()]).then(()=>{});return this._set("_updatingRequiredPromise",e),e.then(()=>{this._updatingRequiredPromise===e&&this._set("_updatingRequiredPromise",null)}),e}async _updateClientWhereClauseRequirements(){if(!this.layer||!this.view)return;const{layer:e}=this,i=new D(e.fieldsIndex);if(i.visitFilter(this.filter),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction),"labelingInfo"in e&&i.visitLabelingInfo(e.labelsVisible,e.labelingInfo),"trackInfo"in e&&i.visitTrackInfo(e.trackInfo),"2d"===this.view.type&&(i.visitFilter(this.featureEffect?.filter),i.visitDisplayFilter(this.displayFilterEnabled,e.displayFilterInfo),"featureReduction"in e&&i.visitFeatureReduction(e.featureReduction)),"subtype-group"===e.type)for(const t of e.sublayers)i.visitLabelingInfo(t.labelsVisible,t.labelingInfo);try{const e=await i.finish();this._set("requiresCurrentUser",e.requiresCurrentUser)}catch(r){t.getLogger(this).error(r)}}async _updateRequiredFields(){if(!this.layer||!this.view)return;const e="3d"===this.view.type,{layer:i,layer:{fieldsIndex:r}}=this,l="renderer"in i&&i.renderer,s="orderBy"in i&&i.orderBy,o="featureReduction"in i?i.featureReduction:null,n=new Set,a=[l?l.collectRequiredFields(n,r):null,w(n,i),e&&"elevationInfo"in i?v(n,i):null,null!=this.filter?E(n,i,this.filter):null,e||null==this.featureEffect?null:E(n,i,this.featureEffect.filter),!e&&o?x(n,i,o):null,!e&&s?q(n,i,s):null];if("timeInfo"in i&&i.timeInfo&&this.timeExtent&&R(n,i.fieldsIndex,[i.timeInfo.startField,i.timeInfo.endField]),"timeInfo"in i&&i.timeInfo&&"trackInfo"in i&&i.trackInfo){const{trackInfo:e}=i;R(n,i.fieldsIndex,[i.timeInfo.trackIdField]),"feature"!==i.type&&"startTimeField"!==e.timeField||R(n,i.fieldsIndex,[i.timeInfo.startField]),"endTimeField"===e.timeField&&R(n,i.fieldsIndex,[i.timeInfo.endField]),await j(n,i)}if("floorInfo"in i&&i.floorInfo&&R(n,i.fieldsIndex,[i.floorInfo.floorField]),"featureTitleFields"in i&&this.view?.requiredFieldsOptions?.featureTitleFields&&i.featureTitleFields&&R(n,i.fieldsIndex,i.featureTitleFields),"feature"===i.type&&i.globalIdField&&this.view?.requiredFieldsOptions?.globalIdField&&R(n,i.fieldsIndex,[i.globalIdField]),this.displayFilterEnabled&&a.push(C(n,i,i.displayFilterInfo)),"feature"===i.type&&e&&null!=i.infoFor3D&&(null==i.globalIdField&&t.getLogger(this).error("globalIdField missing on 3DObjectFeatureLayer"),R(n,i.fieldsIndex,[i.globalIdField])),"subtype-group"===i.type){_(n,r,i.subtypeField);const e=i.sublayers.map(e=>Promise.all([e.renderer?.collectRequiredFields(n,r),w(n,e)]));a.push(Promise.all(e))}if("catalog-footprint"===i.type&&i.parent){const e=i.parent;R(n,r,[e.itemNameField,e.itemSourceField,e.itemTypeField,e.maxScaleField,e.minScaleField])}"knowledge-graph-sublayer"===i.type&&"link-chart"===i.parentCompositeLayer.type&&_(n,r,f),"parquet"===i.type&&a.push(L(i,i.popupTemplate).then(e=>{for(const t of e)n.add(t)}));const u=await Promise.allSettled(a);if(e)_(n,r,i.objectIdField);else for(const t of d(P(i)))_(n,r,t);e&&"displayField"in i&&i.displayField&&_(n,r,i.displayField);for(const d of u)"rejected"===d.status&&t.getLogger(this).error(d.reason);const p=Array.from(n).sort();this._set("requiredFields",p)}_popupFeatureHasRequiredFields(e,t){return O(e,t)}async _createPopupQuery(e,t){const r=this.layer.createQuery(),l=new Set;let s=!1;const o=e??[this.layer];for(const n of o){if(!("popupTemplate"in n))continue;const e=S(n,t);if(null==e)continue;const r=await g(e);i(t);const o=r&&r.arcadeUtils.hasGeometryOperations(e);s=!("point"!==this.layer.geometryType&&!o);const a=await L(this.layer,e);i(t);for(const t of a)l.add(t)}return r.returnGeometry=s,r.returnZ=s,r.returnM=s,r.outFields=Array.from(l),r.outSpatialReference=this.view.spatialReference,"floorInfo"in this.layer&&this.layer.floorInfo&&(r.where=a(r.where,T(this))),r}canResume(){return!!super.canResume()&&(null==this.timeExtent||!this.timeExtent.isEmpty)}getTest(){}get test(){}};return e([u()],G.prototype,"_updatingRequiredPromise",void 0),e([u({readOnly:!0})],G.prototype,"availableFields",null),e([u({readOnly:!0})],G.prototype,"displayFilterEnabled",null),e([u({readOnly:!0})],G.prototype,"effectiveDisplayFilter",null),e([u({readOnly:!0})],G.prototype,"effectiveDisplayFilterClause",null),e([u({type:m})],G.prototype,"featureEffect",null),e([u({type:h})],G.prototype,"filter",void 0),e([u()],G.prototype,"layer",void 0),e([u({type:Number})],G.prototype,"maximumNumberOfFeatures",null),e([u({readOnly:!0,type:Boolean})],G.prototype,"maximumNumberOfFeaturesExceeded",null),e([u()],G.prototype,"requiresCurrentUser",void 0),e([u({readOnly:!0})],G.prototype,"requiredFields",void 0),e([u({readOnly:!0})],G.prototype,"signedInUser",null),e([u()],G.prototype,"suspended",void 0),e([u()],G.prototype,"view",void 0),G=e([p("esri.views.layers.FeatureLayerView")],G),G};export{N as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../core/Logger.js";import{equals as t,isGeographic as r,isWebMercator as i,isWGS84 as s}from"../../../geometry/support/spatialReferenceUtils.js";import{getGlbFormatId as o}from"../../../layers/support/infoFor3D.js";const n="esri.views.layers.support.editableLayerViews";function a(a,d){const{associatedLayer:c}=a,l=c?.infoFor3D;if(!!!l)return!1;const g=o(l);if(!(null!=g&&l.queryFormats.includes(g)))return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits because it does not support GLB queries.`),!1;const p=a.spatialReference,u=c.spatialReference;if(!t(p,u))return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits because its spatial reference (wkid:${p.wkid}) is different from its associated FeatureLayer's spatial reference (wkid:${u.wkid}).`),!1;const f=c.sourceJSON
|
|
5
|
+
import e from"../../../core/Logger.js";import{equals as t,isGeographic as r,isWebMercator as i,isWGS84 as s}from"../../../geometry/support/spatialReferenceUtils.js";import{getGlbFormatId as o}from"../../../layers/support/infoFor3D.js";const n="esri.views.layers.support.editableLayerViews";function a(a,d){const{associatedLayer:c}=a,l=c?.infoFor3D;if(!!!l)return!1;const g=o(l);if(!(null!=g&&l.queryFormats.includes(g)))return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits because it does not support GLB queries.`),!1;const p=a.spatialReference,u=c.spatialReference;if(!t(p,u))return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits because its spatial reference (wkid:${p.wkid}) is different from its associated FeatureLayer's spatial reference (wkid:${u.wkid}).`),!1;const f=c.sourceJSON?.sourceSpatialReference;if(!(null==f||t(f,u)))return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits because the spatial reference of its associated FeatureLayer's service (wkid:${u.wkid}) is different from its source spatial reference (wkid:${f.wkid}).`),!1;const{view:w}=d;if(d.destroyed||null==w)return!1;const y=w.spatialReference,{viewingMode:m}=w.state,$=r(p),L=1===m;if($&&!L)return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits in local viewing mode because its spatial reference (wkid:${p.wkid}) is geographic. Please consider changing the viewing mode to global.`),!1;if(!$&&L)return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits in global viewing mode because its spatial reference (wkid:${p.wkid}) is projected. Please consider changing the viewing mode to local.`),!1;return!!(t(p,y)||L&&i(y)&&s(p))||(e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits because its spatial reference (wkid:${p.wkid}) does not match the view spatial reference (wkid:${y.wkid}).`),!1)}export{a as isGeometryEditableSceneLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Handles.js";import"../../core/has.js";import t from"../../core/Logger.js";import{removeMaybe as s}from"../../core/maybe.js";import r from"../../core/PerformanceSampler.js";import i from"../../core/PooledArray.js";import{isAborted as a,createAbortError as n,when as _}from"../../core/promiseUtils.js";import{watch as u,initial as h,when as o}from"../../core/reactiveUtils.js";import{signal as d}from"../../core/signal.js";import{Milliseconds as E}from"../../core/time.js";import{PromiseQueue as l}from"../../layers/support/PromiseQueue.js";import T from"./debugFlags.js";import{Yield as m}from"./Yield.js";function c(){return new N.Scheduler}var g;!function(e){e.RESOURCE_CONTROLLER_IMMEDIATE="immediate",e.RESOURCE_CONTROLLER="schedule",e.SLIDE="slide",e.STREAM_DATA_LOADER="stream loader",e.ELEVATION_QUERY="elevation query",e.TERRAIN_SURFACE="terrain",e.SURFACE_GEOMETRY_UPDATES="surface geometry updates",e.LOD_RENDERER="LoD renderer",e.GRAPHICS_CORE="Graphics3D",e.I3S_CONTROLLER="I3S",e.POINT_CLOUD_LAYER="point cloud",e.FEATURE_TILE_FETCHER="feature fetcher",e.STREAM_CONTROLLER="stream controller",e.OVERLAY="overlay",e.OVERLAY_RENDERER="overlay renderer",e.STAGE="stage",e.GRAPHICS_DECONFLICTOR="graphics deconflictor",e.FILTER_VISIBILITY="Graphics3D filter visibility",e.SCALE_VISIBILITY="Graphics3D scale visibility",e.FRUSTUM_VISIBILITY="Graphics3D frustum visibility",e.POINT_OF_INTEREST_FREQUENT="POI frequent",e.POINT_OF_INTEREST_INFREQUENT="POI infrequent",e.LABELER="labeler",e.FEATURE_QUERY_ENGINE="feature query",e.FEATURE_TILE_TREE="feature tile tree",e.FEATURE_TILE_TREE_ACTIVE="fast feature tile tree",e.ELEVATION_ALIGNMENT="elevation alignment",e.ELEVATION_ALIGNMENT_SCENE="elevation alignment scene",e.TEXT_TEXTURE_ATLAS="text texture atlas",e.TEXTURE_UNLOAD="texture unload",e.LINE_OF_SIGHT_TOOL="line of sight tool",e.LINE_OF_SIGHT_TOOL_INTERACTIVE="interactive line of sight tool",e.ELEVATION_PROFILE="elevation profile",e.SNAPPING="snapping",e.SHADOW_ACCUMULATOR="shadow accumulator",e.CLOUDS_GENERATOR="clouds generator",e.MAPVIEW_FETCH_QUEUE="mapview fetch queue",e.MAPVIEW_LAYERVIEW_UPDATE="mapview layerview update",e.MAPVIEW_VECTOR_TILE_PARSING_QUEUE="mapview vector tile parsing queue",e[e.NONE=0]="NONE",e[e.TEST_PRIO=1]="TEST_PRIO"}(g||(g={}));const R=0,I=new Map([[g.RESOURCE_CONTROLLER_IMMEDIATE,R],[g.RESOURCE_CONTROLLER,4],[g.SLIDE,R],[g.STREAM_DATA_LOADER,R],[g.ELEVATION_QUERY,R],[g.TERRAIN_SURFACE,1],[g.SURFACE_GEOMETRY_UPDATES,1],[g.LOD_RENDERER,2],[g.GRAPHICS_CORE,2],[g.I3S_CONTROLLER,2],[g.POINT_CLOUD_LAYER,2],[g.FEATURE_TILE_FETCHER,2],[g.STREAM_CONTROLLER,2],[g.CLOUDS_GENERATOR,2],[g.OVERLAY,4],[g.OVERLAY_RENDERER,4],[g.STAGE,4],[g.GRAPHICS_DECONFLICTOR,4],[g.FILTER_VISIBILITY,4],[g.SCALE_VISIBILITY,4],[g.FRUSTUM_VISIBILITY,4],[g.POINT_OF_INTEREST_FREQUENT,6],[g.POINT_OF_INTEREST_INFREQUENT,30],[g.LABELER,8],[g.FEATURE_QUERY_ENGINE,8],[g.FEATURE_TILE_TREE,16],[g.FEATURE_TILE_TREE_ACTIVE,R],[g.ELEVATION_ALIGNMENT,12],[g.ELEVATION_ALIGNMENT_SCENE,14],[g.TEXT_TEXTURE_ATLAS,12],[g.TEXTURE_UNLOAD,12],[g.LINE_OF_SIGHT_TOOL,16],[g.LINE_OF_SIGHT_TOOL_INTERACTIVE,R],[g.SNAPPING,R],[g.SHADOW_ACCUMULATOR,30],[g.MAPVIEW_FETCH_QUEUE,R],[g.MAPVIEW_LAYERVIEW_UPDATE,2],[g.MAPVIEW_VECTOR_TILE_PARSING_QUEUE,R]]);function p(e){return I.has(e)?I.get(e):"number"==typeof e?e:1}const f=E(6.5),A=E(1),L=E(30),O=E(1e3/30),S=E(100),b=.9;var N;!function(a){class n{get updating(){return this._updating.value}_updatingChanged(){this._updating.value=this._tasks.some(e=>e.needsUpdate)}constructor(){this._updating=d(!0),this._microTaskQueued=!1,this._frameNumber=0,this.performanceInfo={total:new r("total"),tasks:new Map},this._frameTaskTimes=new Map,this._budget=new c,this._state=1,this._tasks=new i,this._runQueue=new i,this._load=0,this._idleStateCallbacks=new i,this._idleUpdatesStartFired=!1,this._forceTask=!1,this._debug=!1,this._debugHandle=u(()=>T.SCHEDULER_LOG_SLOW_TASKS,e=>this._debug=e,h);for(const e of Object.keys(g))this.performanceInfo.tasks.set(g[e],new r(g[e]))}destroy(){this._tasks.toArray().forEach(e=>e.remove()),this._tasks.prune(),this._idleStateCallbacks.prune(),this._runQueue.prune(),s(this._debugHandle),this._microTaskQueued=!1,this._updatingChanged()}taskRunningChanged(e){this._updatingChanged(),e&&this._budget.remaining>0&&!this._microTaskQueued&&(this._microTaskQueued=!0,queueMicrotask(()=>{this._microTaskQueued&&(this._microTaskQueued=!1,this._budget.remaining>0&&this._schedule()&&this._runFrame())}))}registerTask(e,t){const s=new _(this,e,t);return this._tasks.push(s),this._updatingChanged(),this.performanceInfo.tasks.has(e)||this.performanceInfo.tasks.set(e,new r(e)),s}registerIdleStateCallbacks(e,t){const s={idleBegin:e,idleEnd:t};this._idleStateCallbacks.push(s),2===this.state&&this._idleUpdatesStartFired&&s.idleBegin();const r=this;return{remove:()=>this._removeIdleStateCallbacks(s),set idleBegin(e){r._idleUpdatesStartFired&&(s.idleEnd(),2===r._state&&e()),s.idleBegin=e},set idleEnd(e){s.idleEnd=e}}}get load(){return this._load}set state(e){this._state!==e&&(this._state=e,2!==this.state&&this._idleUpdatesStartFired&&(this._idleUpdatesStartFired=!1,this._idleStateCallbacks.forAll(e=>e.idleEnd())))}get state(){return this._state}frame(e){this._startFrameTaskTimes();const t=this._updateBudget(e);if(t){const e=this._budget.now();this._runFrame(),this._recordFrameTaskTimes(this._budget.now()-e)}else this._recordFrameTaskTimes(0);return t}_updateBudget(e){this._test&&(this._test.usedBudget=0),++this._frameNumber;let t=f,s=e.frameDuration,r=A;switch(this.state){case 2:t=E(0),s=E(Math.max(S,e.frameDuration)),r=L;break;case 1:s=E(Math.max(O,e.frameDuration))}return s=E(s-e.elapsedFrameTime-t),2!==this.state&&s<A&&!this._forceTask?(this._forceTask=!0,!1):(s=E(Math.max(s,r)),this._budget.reset(s),this._updateLoad(),this._schedule())}_runFrame(){switch(this._forceTask=!1,this._microTaskQueued=!1,this.state){case 2:this._idleUpdatesStartFired||(this._idleUpdatesStartFired=!0,this._idleStateCallbacks.forAll(e=>e.idleBegin())),this._runIdle();break;case 1:this._runInteracting();break;default:this._runAnimating()}this._test&&(this._test.usedBudget=this._budget.elapsed)}stopFrame(){this._budget.reset(E(0)),this._budget.madeProgress()}_removeIdleStateCallbacks(e){this._idleUpdatesStartFired&&e.idleEnd(),this._idleStateCallbacks.removeUnordered(e)}removeTask(e){this._tasks.removeUnordered(e),this._runQueue.removeUnordered(e),this._updatingChanged()}_updateTask(e){this._tasks.forAll(t=>{t.name===e&&t.setPriority(e)})}_getState(e){if(this._runQueue.some(t=>t.name===e))return"s";let t="i";return this._tasks.forAll(s=>{s.name===e&&s.needsUpdate&&(s.schedulePriority<=1?t="r":"r"!==t&&(t="w"))}),t}_getRuntime(e){let t=0;return this._tasks.forAll(s=>{s.name===e&&(t+=s.runtime)}),t}_resetRuntimes(){this._tasks.forAll(e=>e.runtime=0)}_getRunning(){const e=new Map;if(this._tasks.forAll(t=>{t.needsUpdate&&e.set(t.name,(e.get(t.name)||0)+1)}),0===e.size)return null;let t="";return e.forEach((e,s)=>{t+=e>1?` ${e}x ${s}`:` ${s}`}),t}_runIdle(){this._run()}_runInteracting(){this._run()}_runAnimating(){this._run()}_updateLoad(){const e=this._tasks.reduce((e,t)=>t.needsUpdate?++e:e,0);this._load=this._load*b+e*(1-b)}_schedule(){for(this._runQueue.filterInPlace(e=>!!e.needsUpdate||(e.schedulePriority=e.basePriority,!1)),this._tasks.forAll(e=>{e.basePriority===R&&e.needsUpdate&&!this._runQueue.includes(e)&&e.blockFrame!==this._frameNumber&&this._runQueue.unshift(e)});0===this._runQueue.length;){let e=!1,t=0;if(this._tasks.forAll(s=>{if(s.needsUpdate&&0!==s.schedulePriority&&s.basePriority!==R&&s.blockFrame!==this._frameNumber)if(e=!0,t=Math.max(t,s.basePriority),1===s.schedulePriority)s.schedulePriority=0,this._runQueue.push(s);else--s.schedulePriority}),!e)return this._updatingChanged(),!1}return this._updatingChanged(),!0}_run(){do{for(;this._runQueue.length>0;){const s=this._budget.now(),r=this._runQueue.pop();this._budget.resetProgress();try{r.task.runTask(this._budget)===m&&(r.blockFrame=this._frameNumber)}catch(e){t.getLogger("esri.views.support.Scheduler").error(`Exception in task "${r.name}"`,e),r.blockFrame=this._frameNumber}!this._budget.hasProgressed&&r.blockFrame!==this._frameNumber&&r.needsUpdate&&(r.name,g.I3S_CONTROLLER,r.blockFrame=this._frameNumber),r.schedulePriority=r.basePriority;const i=this._budget.now()-s;if(r.runtime+=i,this._frameTaskTimes.set(r.priority,this._frameTaskTimes.get(r.priority)+i),this._budget.remaining<=0)return void this._updatingChanged()}}while(this._schedule());this._updatingChanged()}_startFrameTaskTimes(){for(const e of Object.keys(g))this._frameTaskTimes.set(g[e],0)}_recordFrameTaskTimes(e){this._frameTaskTimes.forEach((e,t)=>this.performanceInfo.tasks.get(t).push(e)),this.performanceInfo.total.push(e)}get test(){return this._test}}a.Scheduler=n;class _{get task(){return this._task.value}get updating(){return this._queue.running}constructor(t,s,r){this._scheduler=t,this.name=s,this.blockFrame=0,this.runtime=0,this._queue=new l,this._handles=new e,this._basePriority=p(s),this.schedulePriority=this._basePriority,this._task=d(null!=r?r:this._queue),this._handles.add(o(()=>this.task.running,e=>t.taskRunningChanged(e)))}remove(){this.processQueue(k),this._scheduler.removeTask(this),this.schedule=P.schedule,this.reschedule=P.reschedule,this._handles.destroy()}get basePriority(){return this._basePriority}setPriority(e){if(this.name===e)return;this.name=e;const t=p(e);this._basePriority!==R&&0===this.schedulePriority||(this.schedulePriority=t),this._basePriority=t}get priority(){return this.name}set priority(e){this.setPriority(e)}get needsUpdate(){return this.updating||!this.task.destroyed&&this.task.running}schedule(e,t,s){return this._queue.push(e,t,s)}reschedule(e,t,s){return this._queue.unshift(e,t,s)}processQueue(e){return this._queue.runTask(e)}}class c{constructor(){this._begin=performance?.now()??0,this._budget=0,this._done=!1,this._progressed=!1,this._enabled=!0}run(e){return!this.done&&(!0===e()&&this.madeProgress(),!0)}get done(){return this._done}get budget(){return this._budget}madeProgress(){return this._progressed=!0,this._done=this.elapsed>=this._budget&&this._enabled,this._done}get enabled(){return this._enabled}set enabled(e){this._enabled=e}reset(e){this._begin=this.now(),this._budget=e,this.resetProgress()}get remaining(){return Math.max(this._budget-this.elapsed,0)}now(){return performance.now()}get elapsed(){return this.now()-this._begin}resetProgress(){this._progressed=!1,this._done=!1}get hasProgressed(){return this._progressed}}a.Budget=c}(N||(N={}));const k=new N.Budget;function U(e){const t=new N.Budget;return t.reset(e),t}k.enabled=!1;class C{remove(){}processQueue(){}schedule(e,t,s){try{if(a(t)){const e=n();return s?Promise.resolve(s(e)):Promise.reject(e)}return _(e(k))}catch(r){return Promise.reject(r)}}reschedule(e,t,s){return this.schedule(e,t,s)}}const P=new C;export{P as ImmediateTask,g as TaskPriority,p as getTaskPriority,U as makeBudget,c as newScheduler,k as noBudget,I as taskPriorities};
|
|
5
|
+
import{removeUnordered as e,filterInPlace as t}from"../../core/arrayUtils.js";import s from"../../core/Handles.js";import"../../core/has.js";import r from"../../core/Logger.js";import{removeMaybe as i}from"../../core/maybe.js";import a from"../../core/PerformanceSampler.js";import{isAborted as n,createAbortError as _,when as h}from"../../core/promiseUtils.js";import{watch as u,initial as o,when as d}from"../../core/reactiveUtils.js";import{signal as E}from"../../core/signal.js";import{Milliseconds as l}from"../../core/time.js";import{PromiseQueue as T}from"../../layers/support/PromiseQueue.js";import c from"./debugFlags.js";import{Yield as m}from"./Yield.js";function g(){return new k.Scheduler}var R;!function(e){e.RESOURCE_CONTROLLER_IMMEDIATE="immediate",e.RESOURCE_CONTROLLER="schedule",e.SLIDE="slide",e.STREAM_DATA_LOADER="stream loader",e.ELEVATION_QUERY="elevation query",e.TERRAIN_SURFACE="terrain",e.SURFACE_GEOMETRY_UPDATES="surface geometry updates",e.LOD_RENDERER="LoD renderer",e.GRAPHICS_CORE="Graphics3D",e.I3S_CONTROLLER="I3S",e.POINT_CLOUD_LAYER="point cloud",e.FEATURE_TILE_FETCHER="feature fetcher",e.STREAM_CONTROLLER="stream controller",e.OVERLAY="overlay",e.OVERLAY_RENDERER="overlay renderer",e.STAGE="stage",e.GRAPHICS_DECONFLICTOR="graphics deconflictor",e.FILTER_VISIBILITY="Graphics3D filter visibility",e.SCALE_VISIBILITY="Graphics3D scale visibility",e.FRUSTUM_VISIBILITY="Graphics3D frustum visibility",e.POINT_OF_INTEREST_FREQUENT="POI frequent",e.POINT_OF_INTEREST_INFREQUENT="POI infrequent",e.LABELER="labeler",e.FEATURE_QUERY_ENGINE="feature query",e.FEATURE_TILE_TREE="feature tile tree",e.FEATURE_TILE_TREE_ACTIVE="fast feature tile tree",e.ELEVATION_ALIGNMENT="elevation alignment",e.ELEVATION_ALIGNMENT_SCENE="elevation alignment scene",e.TEXT_TEXTURE_ATLAS="text texture atlas",e.TEXTURE_UNLOAD="texture unload",e.LINE_OF_SIGHT_TOOL="line of sight tool",e.LINE_OF_SIGHT_TOOL_INTERACTIVE="interactive line of sight tool",e.ELEVATION_PROFILE="elevation profile",e.SNAPPING="snapping",e.SHADOW_ACCUMULATOR="shadow accumulator",e.CLOUDS_GENERATOR="clouds generator",e.MAPVIEW_FETCH_QUEUE="mapview fetch queue",e.MAPVIEW_LAYERVIEW_UPDATE="mapview layerview update",e.MAPVIEW_VECTOR_TILE_PARSING_QUEUE="mapview vector tile parsing queue",e[e.NONE=0]="NONE",e[e.TEST_PRIO=1]="TEST_PRIO"}(R||(R={}));const I=0,p=new Map([[R.RESOURCE_CONTROLLER_IMMEDIATE,I],[R.RESOURCE_CONTROLLER,4],[R.SLIDE,I],[R.STREAM_DATA_LOADER,I],[R.ELEVATION_QUERY,I],[R.TERRAIN_SURFACE,1],[R.SURFACE_GEOMETRY_UPDATES,1],[R.LOD_RENDERER,2],[R.GRAPHICS_CORE,2],[R.I3S_CONTROLLER,2],[R.POINT_CLOUD_LAYER,2],[R.FEATURE_TILE_FETCHER,2],[R.STREAM_CONTROLLER,2],[R.CLOUDS_GENERATOR,2],[R.OVERLAY,4],[R.OVERLAY_RENDERER,4],[R.STAGE,4],[R.GRAPHICS_DECONFLICTOR,4],[R.FILTER_VISIBILITY,4],[R.SCALE_VISIBILITY,4],[R.FRUSTUM_VISIBILITY,4],[R.POINT_OF_INTEREST_FREQUENT,6],[R.POINT_OF_INTEREST_INFREQUENT,30],[R.LABELER,8],[R.FEATURE_QUERY_ENGINE,8],[R.FEATURE_TILE_TREE,16],[R.FEATURE_TILE_TREE_ACTIVE,I],[R.ELEVATION_ALIGNMENT,12],[R.ELEVATION_ALIGNMENT_SCENE,14],[R.TEXT_TEXTURE_ATLAS,12],[R.TEXTURE_UNLOAD,12],[R.LINE_OF_SIGHT_TOOL,16],[R.LINE_OF_SIGHT_TOOL_INTERACTIVE,I],[R.SNAPPING,I],[R.SHADOW_ACCUMULATOR,30],[R.MAPVIEW_FETCH_QUEUE,I],[R.MAPVIEW_LAYERVIEW_UPDATE,2],[R.MAPVIEW_VECTOR_TILE_PARSING_QUEUE,I]]);function f(e){return p.has(e)?p.get(e):"number"==typeof e?e:1}const L=l(6.5),A=l(1),O=l(30),S=l(1e3/30),b=l(100),N=.9;var k;!function(n){class _{get updating(){return this._updating.value}_updatingChanged(){this._updating.value=this._tasks.some(e=>e.needsUpdate)}constructor(){this._updating=E(!0),this._microTaskQueued=!1,this._frameNumber=0,this.performanceInfo={total:new a("total"),tasks:new Map},this._frameTaskTimes=new Map,this._budget=new g,this._state=1,this._tasks=new Array,this._runQueue=new Array,this._load=0,this._idleStateCallbacks=new Array,this._idleUpdatesStartFired=!1,this._forceTask=!1,this._debug=!1,this._debugHandle=u(()=>c.SCHEDULER_LOG_SLOW_TASKS,e=>this._debug=e,o);for(const e of Object.keys(R))this.performanceInfo.tasks.set(R[e],new a(R[e]))}destroy(){this._tasks.forEach(e=>e.remove()),this._tasks.length=0,this._idleStateCallbacks.length=0,this._runQueue.length=0,i(this._debugHandle),this._microTaskQueued=!1,this._updatingChanged()}taskRunningChanged(e){this._updatingChanged(),e&&this._budget.remaining>0&&!this._microTaskQueued&&(this._microTaskQueued=!0,queueMicrotask(()=>{this._microTaskQueued&&(this._microTaskQueued=!1,this._budget.remaining>0&&this._schedule()&&this._runFrame())}))}registerTask(e,t){const s=new h(this,e,t);return this._tasks.push(s),this._updatingChanged(),this.performanceInfo.tasks.has(e)||this.performanceInfo.tasks.set(e,new a(e)),s}registerIdleStateCallbacks(e,t){const s={idleBegin:e,idleEnd:t};this._idleStateCallbacks.push(s),2===this.state&&this._idleUpdatesStartFired&&s.idleBegin();const r=this;return{remove:()=>this._removeIdleStateCallbacks(s),set idleBegin(e){r._idleUpdatesStartFired&&(s.idleEnd(),2===r._state&&e()),s.idleBegin=e},set idleEnd(e){s.idleEnd=e}}}get load(){return this._load}set state(e){this._state!==e&&(this._state=e,2!==this.state&&this._idleUpdatesStartFired&&(this._idleUpdatesStartFired=!1,this._idleStateCallbacks.forEach(e=>e.idleEnd())))}get state(){return this._state}frame(e){this._startFrameTaskTimes();const t=this._updateBudget(e);if(t){const e=this._budget.now();this._runFrame(),this._recordFrameTaskTimes(this._budget.now()-e)}else this._recordFrameTaskTimes(0);return t}_updateBudget(e){this._test&&(this._test.usedBudget=0),++this._frameNumber;let t=L,s=e.frameDuration,r=A;switch(this.state){case 2:t=l(0),s=l(Math.max(b,e.frameDuration)),r=O;break;case 1:s=l(Math.max(S,e.frameDuration))}return s=l(s-e.elapsedFrameTime-t),2!==this.state&&s<A&&!this._forceTask?(this._forceTask=!0,!1):(s=l(Math.max(s,r)),this._budget.reset(s),this._updateLoad(),this._schedule())}_runFrame(){switch(this._forceTask=!1,this._microTaskQueued=!1,this.state){case 2:this._idleUpdatesStartFired||(this._idleUpdatesStartFired=!0,this._idleStateCallbacks.forEach(e=>e.idleBegin())),this._runIdle();break;case 1:this._runInteracting();break;default:this._runAnimating()}this._test&&(this._test.usedBudget=this._budget.elapsed)}stopFrame(){this._budget.reset(l(0)),this._budget.madeProgress()}_removeIdleStateCallbacks(t){this._idleUpdatesStartFired&&t.idleEnd(),e(this._idleStateCallbacks,t)}removeTask(t){e(this._tasks,t),e(this._runQueue,t),this._updatingChanged()}_updateTask(e){this._tasks.forEach(t=>{t.name===e&&t.setPriority(e)})}_getState(e){if(this._runQueue.some(t=>t.name===e))return"s";let t="i";return this._tasks.forEach(s=>{s.name===e&&s.needsUpdate&&(s.schedulePriority<=1?t="r":"r"!==t&&(t="w"))}),t}_getRuntime(e){let t=0;return this._tasks.forEach(s=>{s.name===e&&(t+=s.runtime)}),t}_resetRuntimes(){this._tasks.forEach(e=>e.runtime=0)}_getRunning(){const e=new Map;if(this._tasks.forEach(t=>{t.needsUpdate&&e.set(t.name,(e.get(t.name)||0)+1)}),0===e.size)return null;let t="";return e.forEach((e,s)=>{t+=e>1?` ${e}x ${s}`:` ${s}`}),t}_runIdle(){this._run()}_runInteracting(){this._run()}_runAnimating(){this._run()}_updateLoad(){const e=this._tasks.reduce((e,t)=>t.needsUpdate?++e:e,0);this._load=this._load*N+e*(1-N)}_schedule(){for(t(this._runQueue,e=>!!e.needsUpdate||(e.schedulePriority=e.basePriority,!1)),this._tasks.forEach(e=>{e.basePriority===I&&e.needsUpdate&&!this._runQueue.includes(e)&&e.blockFrame!==this._frameNumber&&this._runQueue.unshift(e)});0===this._runQueue.length;){let e=!1,t=0;if(this._tasks.forEach(s=>{if(s.needsUpdate&&0!==s.schedulePriority&&s.basePriority!==I&&s.blockFrame!==this._frameNumber)if(e=!0,t=Math.max(t,s.basePriority),1===s.schedulePriority)s.schedulePriority=0,this._runQueue.push(s);else--s.schedulePriority}),!e)return this._updatingChanged(),!1}return this._updatingChanged(),!0}_run(){do{for(;this._runQueue.length>0;){const t=this._budget.now(),s=this._runQueue.pop();this._budget.resetProgress();try{s.task.runTask(this._budget)===m&&(s.blockFrame=this._frameNumber)}catch(e){r.getLogger("esri.views.support.Scheduler").error(`Exception in task "${s.name}"`,e),s.blockFrame=this._frameNumber}!this._budget.hasProgressed&&s.blockFrame!==this._frameNumber&&s.needsUpdate&&(s.name,R.I3S_CONTROLLER,s.blockFrame=this._frameNumber),s.schedulePriority=s.basePriority;const i=this._budget.now()-t;if(s.runtime+=i,this._frameTaskTimes.set(s.priority,this._frameTaskTimes.get(s.priority)+i),this._budget.remaining<=0)return void this._updatingChanged()}}while(this._schedule());this._updatingChanged()}_startFrameTaskTimes(){for(const e of Object.keys(R))this._frameTaskTimes.set(R[e],0)}_recordFrameTaskTimes(e){this._frameTaskTimes.forEach((e,t)=>this.performanceInfo.tasks.get(t).push(e)),this.performanceInfo.total.push(e)}get test(){return this._test}}n.Scheduler=_;class h{get task(){return this._task.value}get updating(){return this._queue.running}constructor(e,t,r){this._scheduler=e,this.name=t,this.blockFrame=0,this.runtime=0,this._queue=new T,this._handles=new s,this._basePriority=f(t),this.schedulePriority=this._basePriority,this._task=E(null!=r?r:this._queue),this._handles.add(d(()=>this.task.running,t=>e.taskRunningChanged(t)))}remove(){this.processQueue(U),this._scheduler.removeTask(this),this.schedule=F.schedule,this.reschedule=F.reschedule,this._handles.destroy()}get basePriority(){return this._basePriority}setPriority(e){if(this.name===e)return;this.name=e;const t=f(e);this._basePriority!==I&&0===this.schedulePriority||(this.schedulePriority=t),this._basePriority=t}get priority(){return this.name}set priority(e){this.setPriority(e)}get needsUpdate(){return this.updating||!this.task.destroyed&&this.task.running}schedule(e,t,s){return this._queue.push(e,t,s)}reschedule(e,t,s){return this._queue.unshift(e,t,s)}processQueue(e){return this._queue.runTask(e)}}class g{constructor(){this._begin=performance?.now()??0,this._budget=0,this._done=!1,this._progressed=!1,this._enabled=!0}run(e){return!this.done&&(!0===e()&&this.madeProgress(),!0)}get done(){return this._done}get budget(){return this._budget}madeProgress(){return this._progressed=!0,this._done=this.elapsed>=this._budget&&this._enabled,this._done}get enabled(){return this._enabled}set enabled(e){this._enabled=e}reset(e){this._begin=this.now(),this._budget=e,this.resetProgress()}get remaining(){return Math.max(this._budget-this.elapsed,0)}now(){return performance.now()}get elapsed(){return this.now()-this._begin}resetProgress(){this._progressed=!1,this._done=!1}get hasProgressed(){return this._progressed}}n.Budget=g}(k||(k={}));const U=new k.Budget;function C(e){const t=new k.Budget;return t.reset(e),t}U.enabled=!1;class P{remove(){}processQueue(){}schedule(e,t,s){try{if(n(t)){const e=_();return s?Promise.resolve(s(e)):Promise.reject(e)}return h(e(U))}catch(r){return Promise.reject(r)}}reschedule(e,t,s){return this.schedule(e,t,s)}}const F=new P;export{F as ImmediateTask,R as TaskPriority,f as getTaskPriority,C as makeBudget,g as newScheduler,U as noBudget,p as taskPriorities};
|