@arcgis/core 4.30.0-next.20240210 → 4.30.0-next.20240213
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/05ebb9cec0e1826b283f.js +1 -0
- package/assets/esri/core/workers/chunks/0d54451c740f54a59f49.js +1 -0
- package/assets/esri/core/workers/chunks/{2b7513fe57eca6cff7c3.js → 0f30059c4e7a9cb85d1d.js} +1 -1
- package/assets/esri/core/workers/chunks/18551a7eb5a9b88aa0dc.js +1 -0
- package/assets/esri/core/workers/chunks/24d19abc680b341d13bb.js +1 -0
- package/assets/esri/core/workers/chunks/{3f4d63436c3de04a6ebb.js → 254b4ee3621bbe345bb1.js} +1 -1
- package/assets/esri/core/workers/chunks/2d682ee6e5d66f2ea5cd.js +1 -0
- package/assets/esri/core/workers/chunks/{d5484d470121de2b403b.js → 36d091be859bbb1a149b.js} +1 -1
- package/assets/esri/core/workers/chunks/50b41f91be903a0977f9.js +1 -0
- package/assets/esri/core/workers/chunks/50bb67f2eeace5d50673.js +1 -0
- package/assets/esri/core/workers/chunks/784b6a8216b97440b180.js +1 -0
- package/assets/esri/core/workers/chunks/{7f7a4de2cd4ab71b9aee.js → 8d119dc0a92ad3612daa.js} +1 -1
- package/assets/esri/core/workers/chunks/966cc0b54008c7348678.js +1 -0
- package/assets/esri/core/workers/chunks/{2853221e88ed7077a447.js → 9850b0e04cce8c1bdddf.js} +1 -1
- package/assets/esri/core/workers/chunks/{0014635097a32ad38895.js → a854611d1a86b838c6ad.js} +1 -1
- package/assets/esri/core/workers/chunks/{cf6970b490b98aa0a117.js → be562536212360943388.js} +1 -1
- package/assets/esri/core/workers/chunks/{50a5abd75fa7dbb571a5.js → ccd53b81c2688dd11584.js} +1 -1
- package/assets/esri/core/workers/chunks/{b2b8e6a0b3f70ada2799.js → e4da908079417cc2f495.js} +1 -1
- package/assets/esri/core/workers/chunks/{af0314c2b5b7dc4f5bbd.js → e6dbf0a7b7b1cf64f23f.js} +1 -1
- package/assets/esri/core/workers/chunks/{eba72ff1726ff6998204.js → f03d62ab7806b68d0b62.js} +1 -1
- package/assets/esri/core/workers/chunks/{5fcda75ed02b8aee3a3c.js → f89278782ddfb154aa9f.js} +1 -1
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/geometry/Mesh.js +1 -1
- package/geometry/support/meshVertexSpaceUtils.js +1 -1
- package/interfaces.d.ts +174 -16
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/support/PixelBlock.js +1 -1
- package/layers/support/rasterDatasets/BaseRaster.js +1 -1
- package/layers/support/rasterDatasets/MRFRaster.js +1 -1
- package/layers/support/rasterFormats/RasterCodec.js +1 -1
- package/layers/support/rasterFunctions/surfaceUtils.js +1 -1
- package/package.json +2 -2
- package/portal/support/resourceUtils.js +1 -1
- package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
- package/rest/support/meshFeatureSet.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/constants.js +1 -1
- package/symbols/support/previewSymbol2D.js +1 -1
- package/versionManagement/support/versionManagementUtils.js +1 -1
- package/views/2d/engine/webgl/collisions/CollisionEngine.js +1 -1
- package/views/2d/engine/webgl/collisions/CollisionGrid.js +1 -1
- package/views/2d/engine/webgl/collisions/LabelMetric.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/segmentUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/GLSLShaderModule.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/constants.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentScale.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/extentUtils.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
- package/views/support/automaticLengthMeasurementUtils.js +1 -1
- package/views/support/extentUtils.js +5 -0
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/TableList.js +1 -1
- package/assets/esri/core/workers/chunks/062629a9b4695dea8bf8.js +0 -1
- package/assets/esri/core/workers/chunks/3401157faaa8619aaa47.js +0 -1
- package/assets/esri/core/workers/chunks/37803888bd9a537481a7.js +0 -1
- package/assets/esri/core/workers/chunks/560f677a356c7ebde5d3.js +0 -1
- package/assets/esri/core/workers/chunks/5bfc5ffad705aaaafcd4.js +0 -1
- package/assets/esri/core/workers/chunks/655f4560fb36a0d9ff0b.js +0 -1
- package/assets/esri/core/workers/chunks/b927b655e955abe00d48.js +0 -1
- package/assets/esri/core/workers/chunks/d2417d179d015f1193a1.js +0 -1
- package/assets/esri/core/workers/chunks/f75ec599f53c66cab194.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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import has from"../../../../../../core/has.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{invert as r,transpose as o}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as s}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{clone as a}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{H as i}from"../../../../../../chunks/vec32.js";import{fromArray as l,fromValues as n}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as u}from"../../../../../../chunks/vec42.js";import{fromValues as h}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as p}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as c}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as d}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as m,IntegratedMeshMode as g}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as x}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as y}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as f,parameter as b,parameterBlock as T,MaterialParameterBlock as v}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as M}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as O}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as C}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as w}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as S}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as P}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as j}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as q}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as N,CullFaceOptions as A}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as D}from"../../../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as R}from"../../../materials/pbrUtils.js";class F extends f{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=h(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=l(R),this.emissiveFactor=n(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new _,this.componentParameters=new E,this.textureAlphaCutoff=P,this.alphaDiscardMode=N.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=j.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new m;const i=new q(e.position),u=s(e.rotationScale);r(u,u),this.transformNormalGlobalFromModel=a(o(u,u)),this.transformWorldFromModelTL=i.low,this.transformWorldFromModelTH=i.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,o){const s=this._techniqueConfiguration;s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasEmissionTexture=null!=this.emissionTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.transparencyPassType=t.identifier===M.Material&&null!=r.transparencyPassType?r.transparencyPassType:D.NONE,s.multipassEnabled=t.identifier===M.Material&&r.multipassEnabled,s.cullAboveGround=t.identifier===M.Material&&r.multipassTerrain.cullAboveGround,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?w.View:w.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===I.Transparent||a===I.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?V(r)?L(r)?g.ColorOverlayWithWater:g.ColorOverlay:g.NoOverlay:g.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===g.ColorOverlayWithWater?S.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?has("enable-feature:im-shading")&&this.isIntegratedMesh?S.Simplified:S.Schematic:S.Normal:S.Disabled,s.normalType=o.needsNormals?s.hasNormals?C.Compressed:C.ScreenDerivative:C.Ground,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===M.ShadowMap)s.output=O.Shadow,s.vertexDiscardMode=y.None;else if(t.identifier===M.Highlight)s.output=O.Highlight,s.vertexDiscardMode=y.None;else{switch(a===I.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?y.Opaque:y.Transparent:s.vertexDiscardMode=y.None,s.output=t.output,s.receiveAmbientOcclusion=!1,s.receiveShadows=!1,t.output){case O.Color:s.receiveAmbientOcclusion=null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.hasScreenSpaceReflections=null!=r.ssr.lastFrameColor,s.hasCloudsReflections=null!=r.cloudsFade.data;break;case O.Alpha:s.hasOccludees=r.hasOccludees;break;case O.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(d,s,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const o=r.renderable.geometry,s=r.components,a=r.renderable.meta.cameraDepthSquared,i=s.geometryRanges,l=s.highlightRanges,n=s.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case I.Opaque:e.materialOpaque.submitDraw(this,o,i,a);break;case I.Transparent:e.materialTransparent.submitDraw(this,o,i,a);break;case I.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,i,a),e.materialTransparent.submitDraw(this,o,i,a);break;case I.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,i,a),B(t)&&e.highlightIntegratedMesh.submitDraw(this,o,i,a)}const u=this.componentParameters.castShadows!==W.None;u&&e.shadowMap.submitDraw(this,o,i,a),null!=l&&(e.highlight.submitDraw(this,o,l,a),u&&e.highlightShadowMap.submitDraw(this,o,l,a)),u&&null!=n&&e.defaultShadowMap.submitDraw(this,o,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?I.IntegratedMesh:this.objectOpacity<1?I.Transparent:this.componentParameters.opaqueOverride===W.All?I.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===N.Blend||this.alphaDiscardMode===N.MaskBlend?I.Transparent:this.componentParameters.transparent===W.None?I.Opaque:this.componentParameters.transparent===W.All?I.Transparent:I.OpaqueAndTransparent}}var I,W;e([b({vectorOps:u})],F.prototype,"baseColor",void 0),e([b()],F.prototype,"usePBR",void 0),e([b()],F.prototype,"hasParametersFromSource",void 0),e([b({vectorOps:i})],F.prototype,"mrrFactors",void 0),e([b({vectorOps:i})],F.prototype,"emissiveFactor",void 0),e([b({dispose:!0})],F.prototype,"baseColorTexture",void 0),e([b({dispose:!0})],F.prototype,"metallicRoughnessTexture",void 0),e([b({dispose:!0})],F.prototype,"emissionTexture",void 0),e([b({dispose:!0})],F.prototype,"occlusionTexture",void 0),e([b({dispose:!0})],F.prototype,"normalTexture",void 0),e([b()],F.prototype,"objectOpacity",void 0),e([T()],F.prototype,"commonMaterialParameters",void 0),e([T()],F.prototype,"componentParameters",void 0),e([b()],F.prototype,"textureAlphaCutoff",void 0),e([b()],F.prototype,"alphaDiscardMode",void 0),e([b()],F.prototype,"isIntegratedMesh",void 0),e([b()],F.prototype,"polygonOffsetEnabled",void 0),e([b()],F.prototype,"ellipsoidMode",void 0),e([b()],F.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(I||(I={}));class _ extends v{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=A.Back,this.hasSlicePlane=!0}}e([b()],_.prototype,"doubleSided",void 0),e([b()],_.prototype,"cullFace",void 0),e([b()],_.prototype,"hasSlicePlane",void 0);class E extends v{constructor(){super(...arguments),this.externalColor=h(1,1,1,1),this.externalColorMixMode=p.Multiply,this.castShadows=W.All}get transparent(){return this.externalColor[3]<1?W.All:W.None}get opaqueOverride(){return this.externalColorMixMode===p.Replace&&1===this.externalColor[3]?W.All:W.None}get visible(){return this.externalColor[3]>0?W.All:W.None}get type(){return x.Uniform}}e([b({vectorOps:u})],E.prototype,"externalColor",void 0),e([b()],E.prototype,"externalColorMixMode",void 0),e([b()],E.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(W||(W={}));class k extends v{constructor(){super(...arguments),this.texture=null,this.transparent=W.None,this.opaqueOverride=W.None,this.castShadows=W.None}get type(){return x.Varying}}function B(e){return null!=e.overlay?.getTexture(c.Highlight)}function L(e){return null!=e.overlay?.getTexture(c.WaterNormal)}function V(e){return null!=e.overlay?.getTexture(c.ColorNoRasterImage)}e([b()],k.prototype,"texture",void 0),e([b()],k.prototype,"transparent",void 0),e([b()],k.prototype,"opaqueOverride",void 0),e([b()],k.prototype,"castShadows",void 0);export{_ as CommonMaterialParameters,F as ComponentMaterial,W as ComponentParameterSummary,E as ComponentParametersUniform,k as ComponentParametersVarying};
|
|
5
|
+
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import has from"../../../../../../core/has.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{invert as r,transpose as o}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as s}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{H as a}from"../../../../../../chunks/vec32.js";import{fromArray as i,fromValues as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as n}from"../../../../../../chunks/vec42.js";import{fromValues as u}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as h}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as p}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as c}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as d,IntegratedMeshMode as m}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as g}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as x}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as y,parameter as f,parameterBlock as b,MaterialParameterBlock as T}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as v}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as M}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as O}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as C}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as w}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as S}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as P}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as j}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as q,CullFaceOptions as N}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as A}from"../../../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as D}from"../../../materials/pbrUtils.js";class R extends y{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=i(D),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new W,this.componentParameters=new _,this.textureAlphaCutoff=S,this.alphaDiscardMode=q.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=P.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new d;const a=new j(e.position),n=s(e.rotationScale);r(n,n),o(n,n),this.transformNormalGlobalFromModel=n,this.transformWorldFromModelTL=a.low,this.transformWorldFromModelTH=a.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,o){const s=this._techniqueConfiguration;s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasEmissionTexture=null!=this.emissionTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.transparencyPassType=t.identifier===v.Material&&null!=r.transparencyPassType?r.transparencyPassType:A.NONE,s.multipassEnabled=t.identifier===v.Material&&r.multipassEnabled,s.cullAboveGround=t.identifier===v.Material&&r.multipassTerrain.cullAboveGround,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?C.View:C.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===F.Transparent||a===F.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?L(r)?B(r)?m.ColorOverlayWithWater:m.ColorOverlay:m.NoOverlay:m.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===m.ColorOverlayWithWater?w.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?has("enable-feature:im-shading")&&this.isIntegratedMesh?w.Simplified:w.Schematic:w.Normal:w.Disabled,s.normalType=o.needsNormals?s.hasNormals?O.Compressed:O.ScreenDerivative:O.Ground,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===v.ShadowMap)s.output=M.Shadow,s.vertexDiscardMode=x.None;else if(t.identifier===v.Highlight)s.output=M.Highlight,s.vertexDiscardMode=x.None;else{switch(a===F.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?x.Opaque:x.Transparent:s.vertexDiscardMode=x.None,s.output=t.output,s.receiveAmbientOcclusion=!1,s.receiveShadows=!1,t.output){case M.Color:s.receiveAmbientOcclusion=null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.hasScreenSpaceReflections=null!=r.ssr.lastFrameColor,s.hasCloudsReflections=null!=r.cloudsFade.data;break;case M.Alpha:s.hasOccludees=r.hasOccludees;break;case M.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(c,s,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const o=r.renderable.geometry,s=r.components,a=r.renderable.meta.cameraDepthSquared,i=s.geometryRanges,l=s.highlightRanges,n=s.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case F.Opaque:e.materialOpaque.submitDraw(this,o,i,a);break;case F.Transparent:e.materialTransparent.submitDraw(this,o,i,a);break;case F.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,i,a),e.materialTransparent.submitDraw(this,o,i,a);break;case F.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,i,a),k(t)&&e.highlightIntegratedMesh.submitDraw(this,o,i,a)}const u=this.componentParameters.castShadows!==I.None;u&&e.shadowMap.submitDraw(this,o,i,a),null!=l&&(e.highlight.submitDraw(this,o,l,a),u&&e.highlightShadowMap.submitDraw(this,o,l,a)),u&&null!=n&&e.defaultShadowMap.submitDraw(this,o,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?F.IntegratedMesh:this.objectOpacity<1?F.Transparent:this.componentParameters.opaqueOverride===I.All?F.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===q.Blend||this.alphaDiscardMode===q.MaskBlend?F.Transparent:this.componentParameters.transparent===I.None?F.Opaque:this.componentParameters.transparent===I.All?F.Transparent:F.OpaqueAndTransparent}}var F,I;e([f({vectorOps:n})],R.prototype,"baseColor",void 0),e([f()],R.prototype,"usePBR",void 0),e([f()],R.prototype,"hasParametersFromSource",void 0),e([f({vectorOps:a})],R.prototype,"mrrFactors",void 0),e([f({vectorOps:a})],R.prototype,"emissiveFactor",void 0),e([f({dispose:!0})],R.prototype,"baseColorTexture",void 0),e([f({dispose:!0})],R.prototype,"metallicRoughnessTexture",void 0),e([f({dispose:!0})],R.prototype,"emissionTexture",void 0),e([f({dispose:!0})],R.prototype,"occlusionTexture",void 0),e([f({dispose:!0})],R.prototype,"normalTexture",void 0),e([f()],R.prototype,"objectOpacity",void 0),e([b()],R.prototype,"commonMaterialParameters",void 0),e([b()],R.prototype,"componentParameters",void 0),e([f()],R.prototype,"textureAlphaCutoff",void 0),e([f()],R.prototype,"alphaDiscardMode",void 0),e([f()],R.prototype,"isIntegratedMesh",void 0),e([f()],R.prototype,"polygonOffsetEnabled",void 0),e([f()],R.prototype,"ellipsoidMode",void 0),e([f()],R.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(F||(F={}));class W extends T{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=N.Back,this.hasSlicePlane=!0}}e([f()],W.prototype,"doubleSided",void 0),e([f()],W.prototype,"cullFace",void 0),e([f()],W.prototype,"hasSlicePlane",void 0);class _ extends T{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=h.Multiply,this.castShadows=I.All}get transparent(){return this.externalColor[3]<1?I.All:I.None}get opaqueOverride(){return this.externalColorMixMode===h.Replace&&1===this.externalColor[3]?I.All:I.None}get visible(){return this.externalColor[3]>0?I.All:I.None}get type(){return g.Uniform}}e([f({vectorOps:n})],_.prototype,"externalColor",void 0),e([f()],_.prototype,"externalColorMixMode",void 0),e([f()],_.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(I||(I={}));class E extends T{constructor(){super(...arguments),this.texture=null,this.transparent=I.None,this.opaqueOverride=I.None,this.castShadows=I.None}get type(){return g.Varying}}function k(e){return null!=e.overlay?.getTexture(p.Highlight)}function B(e){return null!=e.overlay?.getTexture(p.WaterNormal)}function L(e){return null!=e.overlay?.getTexture(p.ColorNoRasterImage)}e([f()],E.prototype,"texture",void 0),e([f()],E.prototype,"transparent",void 0),e([f()],E.prototype,"opaqueOverride",void 0),e([f()],E.prototype,"castShadows",void 0);export{W as CommonMaterialParameters,R as ComponentMaterial,I as ComponentParameterSummary,_ as ComponentParametersUniform,E as ComponentParametersVarying};
|
package/views/SceneView.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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../Camera.js";import"../geometry.js";import i from"../Viewpoint.js";import r from"../core/Collection.js";import{byId as s}from"../core/domUtils.js";import a from"../core/Error.js";import{on as n}from"../core/events.js";import{makeHandle as o,handlesGroup as l}from"../core/handleUtils.js";import has from"../core/has.js";import p from"../core/Logger.js";import{destroyMaybe as h,maybeProperty as d}from"../core/maybe.js";import{ObservableChangesType as c}from"../core/ObservableChangesType.js";import{throwIfAborted as u}from"../core/promiseUtils.js";import{on as g,watch as m,initial as y,syncAndInitial as f,whenOnce as w,sync as _}from"../core/reactiveUtils.js";import{setFrameDuration as v}from"../core/scheduling.js";import{createScreenPoint as b,createScreenPointArray as M}from"../core/screenUtils.js";import{initialize as S}from"../core/workers/workers.js";import{property as V}from"../core/accessorSupport/decorators/property.js";import{cast as C}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import{subclass as R}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as j,ensureClass as O}from"../core/accessorSupport/ensureType.js";import{overrideDefaultsFrom as T}from"../core/accessorSupport/overrideDefaultsFrom.js";import{create as x}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{owningCollectionProperty as E}from"../core/support/OwningCollection.js";import L from"../geometry/HeightModelInfo.js";import{canProjectWithoutEngine as H,project as P}from"../geometry/projection.js";import{projectBoundingRect as A}from"../geometry/projection/projectBoundingRect.js";import{projectPointToVector as I}from"../geometry/projection/projectPointToVector.js";import{create as G,toExtent as D}from"../geometry/support/aaBoundingRect.js";import{B as F,c as W}from"../chunks/boundedPlane.js";import{renderSRFromViewSR as U}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as k}from"../geometry/support/scaleUtils.js";import{isImageryTileLayer as q,isTiledLayer as z,isVoxelLayer as B,isIntegratedMeshLayer as N}from"../layers/support/layerUtils.js";import{AnalysesCollection as Q}from"../support/AnalysesCollection.js";import{BreakpointsOwner as Y}from"./BreakpointsOwner.js";import{DOMContainer as Z}from"./DOMContainer.js";import $ from"./GroundView.js";import{PopupView as J}from"./PopupView.js";import K from"./View.js";import X from"./ViewAnimation.js";import{ViewingMode as ee,stringFromViewingMode as te,viewingModeFromString as ie}from"./ViewingMode.js";import{layerView3DImporter as re}from"./3d/layerViewModuleImportUtils.js";import se from"./3d/analysis/AnalysisViewManager3D.js";import{Constraints as ae}from"./3d/constraints/Constraints.js";import ne from"./3d/environment/SceneViewEnvironment.js";import{SceneViewEnvironmentManager as oe}from"./3d/environment/SceneViewEnvironmentManager.js";import le from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as pe}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as he}from"./3d/layers/graphics/Labeler.js";import{FeatureTileTree3D as de}from"./3d/layers/support/FeatureTileTree3D.js";import ce from"./3d/state/ViewState.js";import{ViewStateManager as ue}from"./3d/state/ViewStateManager.js";import{SceneIntersectionHelper as ge}from"./3d/state/helpers/SceneIntersectionHelper.js";import{CombinedElevationProvider as me}from"./3d/support/CombinedElevationProvider.js";import{debugFlags as ye}from"./3d/support/debugFlags.js";import fe from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as we}from"./3d/support/ElevationProvider.js";import _e from"./3d/support/HighlightOptions.js";import{toMap as ve,hitTest as be}from"./3d/support/hitTest.js";import{MapCoordsHelper as Me}from"./3d/support/MapCoordsHelper.js";import{popupHitTest as Se}from"./3d/support/popupHitTest.js";import{PropertiesPool as Ve}from"./3d/support/PropertiesPool.js";import Ce from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as Re}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as je}from"./3d/support/ResourceController.js";import Oe from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as Te}from"./3d/support/SharedSymbolResources.js";import{TextureCollection as xe}from"./3d/support/TextureCollection.js";import{PointsOfInterest as Ee}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import Le from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as He,getTiledLayerInfo as Pe,checkIfTileInfoSupportedForView as Ae}from"./3d/terrain/terrainUtils.js";import{Stage as Ie}from"./3d/webgl-engine/Stage.js";import{Decorations as Ge}from"./3d/webgl-engine/lib/basicInterfaces.js";import{defaultTolerance as De}from"./3d/webgl-engine/lib/Intersector.js";import{terrainId as Fe}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{occludeesSupported as We}from"./support/layerViewUtils.js";import{encode as Ue,encodeData as ke,toRenderSettings as qe,screenshotSuperSampleSettings as ze}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as Be,createScreenPointFromSupportedEvent as Ne}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Qe}from"./support/spatialReferenceSupport.js";import{check as Ye}from"./support/WebGLRequirements.js";import Ze from"./ui/DefaultUI.js";import $e from"./ui/3d/DefaultUI3D.js";import Je from"../webscene/Environment.js";import Ke from"../geometry/Extent.js";import Xe from"../geometry/SpatialReference.js";import et from"../geometry/Point.js";let tt=class extends(Y(J(Z(K)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._createGraphicsViewController=null,this._resolveWhenReady=[],this._propertiesPool=new Ve({slicePlane:F},this),this._resourceController=je(this),this._defaultToMapOptions={include:new Set},this._defaultHitTestOptions={exclude:new Set},this.deconflictor=new pe({view:this}),this.labeler=new he({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.analyses=new Q,this.basemapTerrain=null,this.elevationProvider=null,this.canvas=null,this.constraints=new ae,this.environment=new ne,this.environmentManager=new oe,this.floors=new r,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new se({view:this}),this.groundView=null,this.map=null,this.screenSizePerspectiveEnabled=!0,this.state=new ce,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.preserveDrawingBufferEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new $e,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this.highlightOptions=new _e,S();const t=(e=null)=>{null!=e&&e.type===c.MOVE||(this._updatingChanged(),this.map&&this.map.allLayers.forEach((async e=>{try{await e.when()}catch{}this._updatingChanged()})))};this.addHandles([g((()=>this.map?.allLayers),"after-changes",(e=>t(e)),{onListenerAdd:()=>t(),onListenerRemove:()=>t(),sync:!0}),this.allLayerViews.on("after-changes",(e=>this._updateUpdatingMonitors(e))),m((()=>this.map),(e=>{e&&"load"in e&&e.load&&e.load().catch((()=>{}))}))]),this.inputManager=new le({view:this}),this.stateManager=new ue({view:this})}initialize(){this.groundView=new $({view:this}),this._updateUpdatingMonitors();const e=()=>this._updateDefaultToMapOptions();this.addHandles(g((()=>this.map?.allLayers),"after-changes",e,{onListenerAdd:e,onListenerRemove:e})),this.updatingHandles.add((()=>this.qualitySettings.memoryLimit),(e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)}),y),this.updatingHandles.add((()=>this.qualitySettings.additionalCacheMemory),(e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)}),y),this.updatingHandles.add((()=>this.qualitySettings.frameRate??0),(e=>v(e>0?1e3/Math.ceil(e):0)),y),this.updatingHandles.add((()=>this.map?.ground),e,f),this.updatingHandles.add((()=>this.map?.ground?.opacity),(()=>this._updateDefaultHitTestOptions()),f),this.addHandles(m((()=>this.spatialReference),(()=>this.notifyChange("clippingArea")),_))}destroy(){this.destroyed||(this.updatingHandles.removeAll(),this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this._exitSurface(),this._disposeGraphicsView(),this.sharedSymbolResources=h(this.sharedSymbolResources),this._set("labeler",h(this.labeler)),this._set("deconflictor",h(this.deconflictor)),this._resourceController=h(this._resourceController),this._set("stateManager",h(this.stateManager)),this._set("inputManager",h(this.inputManager)),this.state.destroy(),this._propertiesPool.destroy(),this.removeHandles("updatingMonitors"),this._set("environmentManager",h(this.environmentManager)),this._set("environment",h(this.environment)),this.groundView=h(this.groundView),this._exitBasemapTerrain(),this._stage?.destroy())}get renderSpatialReference(){return this.renderCoordsHelper&&this.renderCoordsHelper.spatialReference}get basemapSpatialReference(){return this.basemapTerrain?.spatialReference}get animation(){return this.state?.animation}get camera(){return this.stateManager?.camera}set camera(e){this.stateManager&&(this.stateManager.camera=e)}get contentCamera(){return this.stateManager?.contentCamera}set contentCamera(e){this.stateManager&&(this.stateManager.contentCamera=e)}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get center(){return this.stateManager?.center}set center(e){this.stateManager&&(this.stateManager.center=e)}get clippingArea(){if("global"===this.viewingMode)return null;const e=this.map;let t=this._userClippingArea||d(e,"clippingArea");return!this._userClippingArea&&!d(e,"clippingEnabled")||null==t?(this._clippingArea=null,null):t instanceof Ke?this.spatialReference&&(t=it(t,this.spatialReference),null==t)?(p.getLogger(this).error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(t=t.clone(),null==t.intersection(this._groundAndLayersExtent)&&(t.xmin=t.xmax,t.ymin=t.ymax),t.zmin=void 0,t.zmax=void 0,t.equals(this._clippingArea)||(this._clippingArea=t),this._clippingArea):(p.getLogger(this).error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&null!=e?p.getLogger(this).error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===ee.Global)return null;const e=this.renderSpatialReference,t=this.dataExtent;return null==t||null==e||t.spatialReference.equals(e)?t:it(t,e)}get dataExtent(){let e=this._groundAndLayersExtent;const t=this.spatialReference||Xe.WGS84,i=it(this.clippingArea,t);null!=i&&(e=null!=e?e.intersection(i):i);const r=this._get("dataExtent");return null!=e&&e.equals(r)?r:e}get _groundAndLayersExtent(){const e=this.spatialReference||Xe.WGS84;let t;const i=i=>{const r=it(i,e);null!=r&&(null!=t?t.union(r):t=r.clone())},r=this.basemapTerrain;if(r?.spatialReference){const e=r.groundExtent;i(new Ke({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}if(this.map){const e=e=>{null==e.fullExtent||"graphics"===e.type&&e.internal||i(e.fullExtent)};this.map.allLayers.forEach((t=>e(t)))}if(null==t)return null;t.hasZ?(t.zmin=Math.min(0,t.zmin??0),t.zmax=Math.max(0,t.zmax??0)):(t.zmin=0,t.zmax=0);const s=this._get("_groundAndLayersExtent");return t.equals(s)?s:t}castEnvironment(e){return e?e instanceof ne?e:e instanceof Je?this.environment?.cloneWithWebsceneEnvironment(e)??ne.fromWebsceneEnvironment(e):j(ne,e):new ne}get extent(){return this.stateManager?.extent}set extent(e){this.stateManager&&(this.stateManager.extent=e)}get screenCenter(){return this.stateManager?.screenCenter}get frustum(){return this.stateManager?.frustum}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get _defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||(this.toolViewManager?.interacting??!1)}get stationary(){return!this.animation&&!this.resizing&&(null==this.state||this.state.stationary)}get navigating(){return this.state?.navigating??!1}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}set qualityProfile(e){fe.isValidProfile(e)&&(fe.apply(e,this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||fe.getDefaultProfile()}set slicePlane(e){if(null!=this._stage&&this._stage.renderer.setParameters({slicePlane:e}),null==e)return void this._set("slicePlane",null);const t=this._propertiesPool.get("slicePlane");W(e,t),this._set("slicePlane",t)}get typeSpecificPreconditionsReady(){return!!this.viewingMode&&this.stateManager.preinit(this.spatialReference)}get resolution(){return null!=this.spatialReference?k(this.scale,this.spatialReference):0}get scale(){return this.stateManager?.scale}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?L.deriveUnitFromSR(e,this.spatialReference):null}get updating(){if(this.destroyed)return!1;let e=0,t=this.layerViewManager.updating,i=t?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach((r=>{if(r.isFulfilled()){if(r.updating){if(t=!0,r.suspended||He(r))return;++i,e+=r.updatingProgress}}else++i}));for(const s of this._updatingObjects)if(null!=s&&s.updating){const t=.1;i+=t,e+=.5*t}for(const s of this._updatingObjectsWithProgress)null!=s&&s.updating&&(++i,e+=s.updatingProgress);const r=!this.stateManager.test.updatingIgnoreRenderState&&this.state.updating;if(t=!!(t||i>0||this.updatingHandles.updating||!this.ready||!this.stationary||r||this._createGraphicsViewController||this.inputManager?.updating||this.map?.allLayers?.some((e=>!e.isFulfilled()))||this.textures?.updating),t?(this._numUpdating=Math.max(i,this._numUpdating),e+=this._numUpdating-i):this._numUpdating=0,this._numUpdating>0?e/=this._numUpdating:e=t?0:1,this._get("updatingProgress")!==e){const i=performance.now();if(e<1){const t=Math.min((i-this._lastUpdateTime)/2e3,1);e=this.updatingProgress*(1-t)+e*t}this._set("updatingProgress",e),this._lastUpdateTime=t&&e<1?i:0}return t}get _updatingObjects(){return[this.graphicsView,this.basemapView,this._resourceController,this._stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this._featureTreeDebugger,this.toolViewManager,this.analysisViewManager]}get _updatingObjectsWithProgress(){return[this.deconflictor,this.labeler,this.basemapTerrain]}get viewingMode(){const e=this._predeterminedViewingMode;if(null!=e)return te(e);const t=this.spatialReference;return t?null!=this.defaultsFromMap?.viewingMode&&t.equals(this.defaultsFromMap.spatialReference)?te(this.defaultsFromMap.viewingMode):Qe(t,ee.Global)?"global":"local":"global"}set viewingMode(e){this.ready?p.getLogger(this).error("#viewingMode","viewingMode cannot be set once view is ready"):this._overrideIfSome("viewingMode",e)}get viewpoint(){return this.stateManager?.viewpoint}set viewpoint(e){this.stateManager&&(this.stateManager.viewpoint=e)}get zoom(){return this.stateManager.zoom}set zoom(e){this.stateManager&&(this.stateManager.zoom=e)}get resourceController(){return this._resourceController}get quality(){return this._resourceController?.memoryController?.memoryFactor??1}get resolutionScale(){return Math.sqrt(Math.min(1,this.quality/.75))}get performanceInfo(){return new Oe(this)}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return p.getLogger(this).error("#toMap()","Scene view cannot be used before it is ready"),null;const i=Be(e)?Ne(this,e):e;return ve(this,i,t,this._defaultToMapOptions)}toScreen(e){if(!this.ready)return p.getLogger(this).error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=(null==e.z?we(this.elevationProvider,e):null)??0;return I(e,rt,this.renderSpatialReference,t),this.state.camera.projectToScreen(rt,st),b(st[0],st[1])}pixelSizeAt(e){return this.ready?e?(I(e,rt,this.renderSpatialReference),this.state.camera.computeScreenPixelSizeAt(rt)):0:(p.getLogger(this).error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null)}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e,(()=>this.pixelSizeAt(e))):1}hitTest(e,t){if(!this.ready)return p.getLogger(this).error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=Be(e)?Ne(this,e):e;return be(this,i,t,this._defaultHitTestOptions)}async popupHitTest(e){return Se(this,e)}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(null==e.parent)throw new a("view:no-analysisview-for-analysis","The analysis has not been added to view.analyses",{analysis:e});switch(e.parent.type){case"line-of-sight":case"dimension":return(await this.whenLayerView(e.parent)).whenAnalysisView();default:return this.analysisViewManager.whenAnalysisView(e)}}whenLayerView(e){return super.whenLayerView(e)}async takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return Ue(i,t,this._pixelFormat())}async _takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return ke(i,this._pixelFormat())}async _takeScreenshotWithObjectAndLayerId(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t);return[ke(i[0],this._pixelFormat()),ke(i[1],this._pixelFormat())]}_completeSettings(e){const t=qe(e,this);return t.pixelRatio/=this.state.pixelRatio,ze(t,this.supersampleScreenshotsEnabled,this.padding)}_pixelFormat(){return{flipY:!0,premultipliedAlpha:this._stage.renderView.getAlpha()}}get test(){return{takeScreenshot:e=>this._takeScreenshot(e),takeScreenshotWithObjectAndLayerId:e=>this._takeScreenshotWithObjectAndLayerId(e)}}async takeScreenshotWithObjectAndLayerId(e){if(!has("enable-feature:objectAndLayerId-rendering"))throw new Error("has enable-feature:objectAndLayerId-rendering must be true");const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t),r=Ue(i[0],t,this._pixelFormat()),s=this._completeSettings(e);s.format="png";return[r,Ue(i[1],s,this._pixelFormat())]}getColorToObjectAndLayerIdMapping(){if(null==this._stage.renderView.objectAndLayerIdRenderHelper)throw new Error("has enable-feature:objectAndLayerId-rendering must be true");return this._stage.renderView.objectAndLayerIdRenderHelper.getColorToObjectAndLayerIdMapping()}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return re.importLayerView(e)}hasLayerViewModule(e){return re.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||this.defaultsFromMap?.ready&&this._initialDefaultSpatialReference||null}async validate(){let e=Ye(this.type);const t=has("safari");if(t&&t<9&&(e=new a("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:t})),null!=e)throw p.getLogger(this).warn("#validate()",e.message),e}get _predeterminedViewingMode(){const e=this._isOverridden("viewingMode")?this._get("viewingMode"):(this.map&&"initialViewProperties"in this.map?this.map.initialViewProperties?.viewingMode:null)??null;return null!=e?ie(e):null}getSpatialReferenceSupport({spatialReference:e,layer:t}){const i=this._predeterminedViewingMode;if(null!=i)return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,ee.Local),s=this._validateSpatialReferenceForViewingMode(e,t,ee.Global);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,ee.Local)}:{constraints:this._makeSpatialReferenceConstraints(e,t,ee.Global)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!Qe(e,i)&&(null==t||(!!q(t)||(!z(t)||null!=Pe(t,e,i))&&(!B(t)||i!==ee.Global)))}_makeSpatialReferenceConstraints(e,t,i){if(null==t)return[{spatialReference:e,viewingMode:i}];const r=e.isWebMercator,s=e.isWGS84;if(q(t)&&(r||s)){return!s||i===ee.Local||null===Ae(t.tileInfo,t.fullExtent,e,ee.Global)?[{spatialReference:e,viewingMode:i},{spatialReference:Xe.WebMercator,viewingMode:i}]:[{spatialReference:r?Xe.WGS84:Xe.WebMercator,viewingMode:i}]}return z(t)||B(t)||!r&&!s?z(t)&&r&&i!==ee.Global?[{spatialReference:e,viewingMode:i},{spatialReference:Xe.WGS84,viewingMode:ee.Local}]:[{spatialReference:e,viewingMode:i}]:[{spatialReference:e,viewingMode:i},{spatialReference:r?Xe.WGS84:Xe.WebMercator,viewingMode:i}]}_validateSpatialReference(e){const t=null!=this.getSpatialReferenceSupport({spatialReference:e}),i=this._predeterminedViewingMode;return t||(null!=i?p.getLogger(this).warnOnce(`Spatial reference defined on view not supported in ${te(i)} viewing mode.`):e.isGeographic&&p.getLogger(this).warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}trackGraphicState(e){if(!e.graphic)return p.getLogger(this).error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{!r&&null!=t&&"processor"in t&&"graphics-3d"===t.processor?.type&&t.processor.graphicsCore&&(i=t.processor.graphicsCore.trackGraphicState(e))};return null!=t?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),o((()=>{r=!0,null!=i&&(i.remove(),i=null)}))}highlight(e){if(Array.isArray(e))return l(e.map((e=>this.highlight(e))));if(r.isCollection(e))return l(e.toArray().map((e=>this.highlight(e))));const t=this.getViewForGraphic(e);return t&&"highlight"in t?t.highlight(e):o()}maskOccludee(e){if(!e)return p.getLogger(this).error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&null!=t&&We(t)&&(i=t.maskOccludee(e))};return null!=t?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),o((()=>{r=!0,null!=i&&(i.remove(),i=null)}))}getViewForGraphic(e){return e.layer===this.graphics?this.graphicsView:e.layer?this.allLayerViews.find((t=>t.layer===e.layer)):null}graphicChanged(e){null!=this.graphicsView&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){if(e.layer===this)return await w((()=>this.graphicsView)),this.graphicsView;if(!e.layer||!this.map)throw new a("no-view-for-graphic");return t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise(((t,i)=>{const r=this.map.allLayers.on("change",(s=>{s.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))}))})):this.whenLayerView(e.layer)}_initBasemapTerrain(){this._set("basemapTerrain",new Le({view:this})),this._set("elevationProvider",new me({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){this.basemapTerrain&&(this.elevationProvider.unregister(this.basemapTerrain),this.elevationProvider.destroy(),this._set("elevationProvider",null),this.basemapTerrain.destroy(),this._set("basemapTerrain",null))}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new Ee({view:this})),this._set("featureTiles",new de({renderCoordsHelper:this.renderCoordsHelper,cameraOnSurface:this.pointsOfInterest.cameraOnSurface,focus:this.pointsOfInterest.focus,tilingSchemeOwner:this.basemapTerrain,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}));const e=()=>{const e=this.basemapTerrain?.extent;if(this.clippingArea||e)if(e&&this.basemapTerrain.spatialReference){const e=null!=this.basemapTerrain.extent&&null!=this.basemapTerrain.spatialReference?P(D(this.basemapTerrain.extent,this.basemapTerrain.spatialReference),this.spatialReference):null;null!=this.clippingArea?this.featureTiles.filterExtent=this.clippingArea.intersection(e):this.featureTiles.filterExtent=e}else this.featureTiles.filterExtent=this.clippingArea;else this.featureTiles.filterExtent=null};this.addHandles([this.updatingHandles.add((()=>ye.FEATURE_TILE_TREE_SHOW_TILES),(e=>{e&&this.featureTiles&&!this._featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then((({FeatureTileTree3DDebugger:e})=>{!this._featureTreeDebugger&&ye.FEATURE_TILE_TREE_SHOW_TILES&&(this._featureTreeDebugger=new e({view:this}))})):e||!this._featureTreeDebugger||ye.FEATURE_TILE_TREE_SHOW_TILES||(this._featureTreeDebugger.destroy(),this._featureTreeDebugger=null)}),f),this.updatingHandles.add((()=>this.clippingArea),e,f),this.updatingHandles.add((()=>this.basemapTerrain.extent),e,f)],"feature-tiles"),this.stateManager.init()}_exitGlobe(){this.state&&(this.stateManager.exit(),this.removeHandles("render-coords-helper"),this.removeHandles("feature-tiles"),this.featureTiles.destroy(),this._set("featureTiles",null),this.pointsOfInterest.destroy(),this._set("pointsOfInterest",null),this._exitBasemapTerrain(),this.state.exit(),this._exitCoordinateSystem())}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference;this.mapCoordsHelper&&this.mapCoordsHelper.spatialReference.equals(e)||this._set("mapCoordsHelper",new Me(this.map,e));const t=this.state.isGlobal,i=U(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",Re.create(this.state.viewingMode,i)),t||this.addHandles(m((()=>this.basemapTerrain?.extent),(e=>{const t=this.renderCoordsHelper.spatialReference;null==e||0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!A(e,this.basemapTerrain.spatialReference,at,t)||(this.renderCoordsHelper.extent=at)}),_),"render-coords-helper"),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(De/this.renderCoordsHelper.unitInMeters))}else this._set("mapCoordsHelper",null),this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.mapCoordsHelper&&(this.removeHandles("render-coords-helper"),this._set("renderCoordsHelper",null),this._set("mapCoordsHelper",null))}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){null!=e&&e.type===c.MOVE||(this.removeHandles("updatingMonitors"),this.allLayerViews.forEach((e=>{e.destroyed||(this.addHandles(m((()=>[e.updating,e.updatingProgress]),(()=>this._updatingChanged()),_),"updatingMonitors"),e.when((()=>this._updatingChanged()),(()=>this._updatingChanged())))})),this._updatingChanged())}async _prepareScreenshotOverlay(){this.overlay&&await this.overlay.prepare()}_renderScreenshotOverlay(e,t,i){if(!this.overlay||!this.overlay.hasVisibleItems)return i;const r=e.getContext("2d");return r.putImageData(i,0,0),this.overlay.renderCanvas(e,{disableDecorations:t===Ge.OFF}),r.getImageData(0,0,i.width,i.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,preserveDrawingBuffer:this.preserveDrawingBufferEnabled,canvas:this.renderCanvas,screenshot:{prepareOverlay:()=>this._prepareScreenshotOverlay(),renderOverlay:(e,t,i)=>this._renderScreenshotOverlay(e,t,i)}},t=new ge(this.state.viewingMode,(e=>this._stage.layers.forAll(e)),this);this._set("sceneIntersectionHelper",t);const i=s(this.surface);this._stage=new Ie({view:this,options:e,container:i}),this._stage.renderer.setParameters({slicePlane:this.slicePlane}),this.addHandles([this.updatingHandles.add((()=>this.qualitySettings.highQualityTransparency),(e=>this._stage.renderer.setParameters({highQualityTransparency:e})),y),m((()=>this.magnifier),(e=>this._stage.renderView.magnifier=e),f),this.on("pointer-move",(()=>this._stage?.renderer.resetAnimation())),n(this._stage.renderView.canvas,"webglcontextlost",(e=>{console.error("WebGL context lost",e),this.fatalError=new a("webgl-context-lost",e.statusMessage)}))],"stage"),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(De/this.renderCoordsHelper.unitInMeters),this._set("canvas",this._stage.renderView.canvas)}_exitStage(){this._set("sceneIntersectionHelper",null),this._stage=h(this._stage),this.removeHandles("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this.state.init(e,this.spatialReference),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new Te({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitGlobe(),this._exitStage())}_createGraphicsViewIfNeeded(){if(this.graphicsView||this._createGraphicsViewController)return;if(0===this.graphics.length)return;this.removeHandles("graphics-view"),this._createGraphicsViewController=new AbortController;const e=()=>{this._createGraphicsViewController=null,this._updatingChanged()};this._createGraphicsViewAsync(this._createGraphicsViewController.signal).then(e,e),this._updatingChanged()}async _createGraphicsViewAsync(e){const t=(await import("./3d/layers/GraphicsView3D.js")).default;u(e),await w((()=>this.basemapTerrain?.ready),e),this._set("graphicsView",new t({view:this}))}_disposeGraphicsView(){this._createGraphicsViewController&&(this._createGraphicsViewController.abort(),this._createGraphicsViewController=null),this.removeHandles("graphics-view"),null!=this.graphicsView&&(this.removeHandles(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_startup(){const e=ie(this.viewingMode);e===ee.Global&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.addHandles(g((()=>this.graphics),"after-changes",(()=>this._createGraphicsViewIfNeeded())),"graphics-view"),this._createGraphicsViewIfNeeded();const t=this.map&&"initialViewProperties"in this.map?this.map.initialViewProperties?.environment:void 0;t&&T(this.environment,t),this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect(),this._set("textures",new xe(this._stage,this.resourceController.scheduler));const i=this._resolveWhenReady;this._resolveWhenReady=[],i.forEach((e=>e(this)))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this.labeler.dispose(),this._disposeGraphicsView(),this.removeHandles("graphics-view"),this._set("textures",h(this.textures)),this._exitSurface(),this._set("ready",!1)}_updateDefaultToMapOptions(){if(this._defaultToMapOptions.include.clear(),this.map){this.map.ground&&this._defaultToMapOptions.include.add(Fe);for(const e of this.map.allLayers.items)N(e.type)&&this._defaultToMapOptions.include.add(e.uid)}}_updateDefaultHitTestOptions(){if(this._defaultHitTestOptions.exclude.clear(),this.map){this.map.ground&&this.map.ground.opacity<1&&this._defaultHitTestOptions.exclude.add(Fe);for(const e of this.map.allLayers.items)N(e.type)&&e.opacity<1&&this._defaultHitTestOptions.exclude.add(e.uid)}}};function it(e,t){return null!=e&&H(e.spatialReference,t)?P(e,t):null}tt.type="3d",e([V()],tt.prototype,"_userClippingArea",void 0),e([V()],tt.prototype,"_resourceController",void 0),e([V()],tt.prototype,"_stage",void 0),e([V({readOnly:!0})],tt.prototype,"deconflictor",void 0),e([V({readOnly:!0})],tt.prototype,"labeler",void 0),e([V(E(Q,"analyses"))],tt.prototype,"analyses",void 0),e([V({type:X,readOnly:!0})],tt.prototype,"animation",null),e([V({readOnly:!0})],tt.prototype,"basemapTerrain",void 0),e([V({readOnly:!0})],tt.prototype,"elevationProvider",void 0),e([V()],tt.prototype,"camera",null),e([V({type:t})],tt.prototype,"contentCamera",null),e([V({readOnly:!0})],tt.prototype,"canvas",void 0),e([V({type:et})],tt.prototype,"center",null),e([V({type:Ke})],tt.prototype,"clippingArea",null),e([V({type:ae})],tt.prototype,"constraints",void 0),e([V({type:Ke,readOnly:!0})],tt.prototype,"renderDataExtent",null),e([V({type:Ke,readOnly:!0})],tt.prototype,"dataExtent",null),e([V({type:Ke,readOnly:!0})],tt.prototype,"_groundAndLayersExtent",null),e([V({type:ne})],tt.prototype,"environment",void 0),e([C("environment")],tt.prototype,"castEnvironment",null),e([V({readOnly:!0})],tt.prototype,"environmentManager",void 0),e([V({type:Ke})],tt.prototype,"extent",null),e([V()],tt.prototype,"floors",void 0),e([V()],tt.prototype,"screenCenter",null),e([V()],tt.prototype,"frustum",null),e([V({type:Number,readOnly:!0})],tt.prototype,"fullOpacity",void 0),e([V({readOnly:!0})],tt.prototype,"graphicsView",void 0),e([V({readOnly:!0})],tt.prototype,"analysisViewManager",void 0),e([V()],tt.prototype,"groundView",void 0),e([V({type:Boolean})],tt.prototype,"initialExtentRequired",null),e([V()],tt.prototype,"_defaultsFromMapSettings",null),e([V()],tt.prototype,"interacting",null),e([V()],tt.prototype,"stationary",null),e([V()],tt.prototype,"navigating",null),e([V()],tt.prototype,"map",void 0),e([V({readOnly:!0})],tt.prototype,"mapCoordsHelper",void 0),e([V()],tt.prototype,"padding",null),e([V({type:Ee,readOnly:!0})],tt.prototype,"pointsOfInterest",void 0),e([V({type:de,readOnly:!0})],tt.prototype,"featureTiles",void 0),e([V()],tt.prototype,"_featureTreeDebugger",void 0),e([V({type:Boolean})],tt.prototype,"screenSizePerspectiveEnabled",void 0),e([V({constructOnly:!0})],tt.prototype,"deactivatedWebGLExtensions",void 0),e([V({constructOnly:!0})],tt.prototype,"debugWebGLExtensions",void 0),e([V({constructOnly:!0})],tt.prototype,"renderCanvas",void 0),e([V({constructOnly:!0})],tt.prototype,"state",void 0),e([V({readOnly:!0})],tt.prototype,"inputManager",void 0),e([V({readOnly:!0})],tt.prototype,"stateManager",void 0),e([V({type:["low","medium","high"]})],tt.prototype,"qualityProfile",null),e([V({type:Ce,get(){let e=this._get("qualitySettings");return e||(e=new Ce,fe.apply(this.qualityProfile,e)),e}})],tt.prototype,"qualitySettings",void 0),e([V()],tt.prototype,"slicePlane",null),e([V({readOnly:!0})],tt.prototype,"typeSpecificPreconditionsReady",null),e([V({readOnly:!0})],tt.prototype,"renderCoordsHelper",void 0),e([V({readOnly:!0})],tt.prototype,"sceneIntersectionHelper",void 0),e([V({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],tt.prototype,"resolution",null),e([V({type:Number})],tt.prototype,"scale",null),e([V()],tt.prototype,"heightModelInfo",null),e([V()],tt.prototype,"spatialReference",void 0),e([V({type:Boolean,constructOnly:!0})],tt.prototype,"alphaCompositingEnabled",void 0),e([V({constructOnly:!0})],tt.prototype,"preserveDrawingBufferEnabled",void 0),e([V({type:Boolean})],tt.prototype,"supersampleScreenshotsEnabled",void 0),e([V({readOnly:!0})],tt.prototype,"type",void 0),e([V(),C((e=>e instanceof Ze?e:O($e,e)))],tt.prototype,"ui",void 0),e([V({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","_stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.updating","toolViewManager.updating","analysisViewManager.updating","state.updating","textures.updating"]})],tt.prototype,"updating",null),e([V()],tt.prototype,"_updatingObjects",null),e([V()],tt.prototype,"_updatingObjectsWithProgress",null),e([V({type:Number,readOnly:!0,dependsOn:["updating"]})],tt.prototype,"updatingProgress",void 0),e([V({type:["global","local"]})],tt.prototype,"viewingMode",null),e([V({type:i})],tt.prototype,"viewpoint",null),e([V({type:Number})],tt.prototype,"zoom",null),e([V({type:_e})],tt.prototype,"highlightOptions",void 0),e([V({readOnly:!0})],tt.prototype,"quality",null),e([V({readOnly:!0})],tt.prototype,"resolutionScale",null),e([V()],tt.prototype,"textures",void 0),tt=e([R("esri.views.SceneView")],tt);const rt=x(),st=M(),at=G(),nt=tt;export{nt as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../Camera.js";import"../geometry.js";import i from"../Viewpoint.js";import r from"../core/Collection.js";import{byId as s}from"../core/domUtils.js";import a from"../core/Error.js";import{on as n}from"../core/events.js";import{makeHandle as o,handlesGroup as l}from"../core/handleUtils.js";import has from"../core/has.js";import p from"../core/Logger.js";import{destroyMaybe as h,maybeProperty as d}from"../core/maybe.js";import{ObservableChangesType as c}from"../core/ObservableChangesType.js";import{throwIfAborted as u}from"../core/promiseUtils.js";import{on as g,watch as m,initial as y,syncAndInitial as f,whenOnce as w,sync as _}from"../core/reactiveUtils.js";import{setFrameDuration as v}from"../core/scheduling.js";import{createScreenPoint as b,createScreenPointArray as M}from"../core/screenUtils.js";import{initialize as S}from"../core/workers/workers.js";import{property as V}from"../core/accessorSupport/decorators/property.js";import{cast as C}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import{subclass as R}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as j,ensureClass as O}from"../core/accessorSupport/ensureType.js";import{overrideDefaultsFrom as T}from"../core/accessorSupport/overrideDefaultsFrom.js";import{create as x}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{owningCollectionProperty as E}from"../core/support/OwningCollection.js";import L from"../geometry/HeightModelInfo.js";import{canProjectWithoutEngine as H,project as P}from"../geometry/projection.js";import{projectBoundingRect as A}from"../geometry/projection/projectBoundingRect.js";import{projectPointToVector as I}from"../geometry/projection/projectPointToVector.js";import{create as G,toExtent as D}from"../geometry/support/aaBoundingRect.js";import{B as F,c as W}from"../chunks/boundedPlane.js";import{renderSRFromViewSR as U}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as k}from"../geometry/support/scaleUtils.js";import{isImageryTileLayer as q,isTiledLayer as z,isVoxelLayer as B,isIntegratedMeshLayer as N}from"../layers/support/layerUtils.js";import{AnalysesCollection as Q}from"../support/AnalysesCollection.js";import{BreakpointsOwner as Y}from"./BreakpointsOwner.js";import{DOMContainer as Z}from"./DOMContainer.js";import $ from"./GroundView.js";import{PopupView as J}from"./PopupView.js";import K from"./View.js";import X from"./ViewAnimation.js";import{ViewingMode as ee,stringFromViewingMode as te,viewingModeFromString as ie}from"./ViewingMode.js";import{layerView3DImporter as re}from"./3d/layerViewModuleImportUtils.js";import se from"./3d/analysis/AnalysisViewManager3D.js";import{Constraints as ae}from"./3d/constraints/Constraints.js";import ne from"./3d/environment/SceneViewEnvironment.js";import{SceneViewEnvironmentManager as oe}from"./3d/environment/SceneViewEnvironmentManager.js";import le from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as pe}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as he}from"./3d/layers/graphics/Labeler.js";import{FeatureTileTree3D as de}from"./3d/layers/support/FeatureTileTree3D.js";import ce from"./3d/state/ViewState.js";import{ViewStateManager as ue}from"./3d/state/ViewStateManager.js";import{SceneIntersectionHelper as ge}from"./3d/state/helpers/SceneIntersectionHelper.js";import{CombinedElevationProvider as me}from"./3d/support/CombinedElevationProvider.js";import{debugFlags as ye}from"./3d/support/debugFlags.js";import fe from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as we}from"./3d/support/ElevationProvider.js";import _e from"./3d/support/HighlightOptions.js";import{toMap as ve,hitTest as be}from"./3d/support/hitTest.js";import{MapCoordsHelper as Me}from"./3d/support/MapCoordsHelper.js";import{popupHitTest as Se}from"./3d/support/popupHitTest.js";import{PropertiesPool as Ve}from"./3d/support/PropertiesPool.js";import Ce from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as Re}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as je}from"./3d/support/ResourceController.js";import Oe from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as Te}from"./3d/support/SharedSymbolResources.js";import{TextureCollection as xe}from"./3d/support/TextureCollection.js";import{PointsOfInterest as Ee}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import Le from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as He,getTiledLayerInfo as Pe,checkIfTileInfoSupportedForView as Ae}from"./3d/terrain/terrainUtils.js";import{Stage as Ie}from"./3d/webgl-engine/Stage.js";import{Decorations as Ge}from"./3d/webgl-engine/lib/basicInterfaces.js";import{defaultTolerance as De}from"./3d/webgl-engine/lib/Intersector.js";import{terrainId as Fe}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{occludeesSupported as We}from"./support/layerViewUtils.js";import{encode as Ue,encodeData as ke,toRenderSettings as qe,screenshotSuperSampleSettings as ze}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as Be,createScreenPointFromSupportedEvent as Ne}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Qe}from"./support/spatialReferenceSupport.js";import{check as Ye}from"./support/WebGLRequirements.js";import Ze from"./ui/DefaultUI.js";import $e from"./ui/3d/DefaultUI3D.js";import Je from"../webscene/Environment.js";import Ke from"../geometry/Extent.js";import Xe from"../geometry/SpatialReference.js";import et from"../geometry/Point.js";let tt=class extends(Y(J(Z(K)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._createGraphicsViewController=null,this._resolveWhenReady=[],this._propertiesPool=new Ve({slicePlane:F},this),this._resourceController=je(this),this._defaultToMapOptions={include:new Set},this._defaultHitTestOptions={exclude:new Set},this.deconflictor=new pe({view:this}),this.labeler=new he({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.analyses=new Q,this.basemapTerrain=null,this.elevationProvider=null,this.canvas=null,this.constraints=new ae,this.environment=new ne,this.environmentManager=new oe,this.floors=new r,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new se({view:this}),this.groundView=null,this.map=null,this.screenSizePerspectiveEnabled=!0,this.state=new ce,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.preserveDrawingBufferEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new $e,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this.highlightOptions=new _e,S();const t=(e=null)=>{null!=e&&e.type===c.MOVE||(this._updatingChanged(),this.map&&this.map.allLayers.forEach((async e=>{try{await e.when()}catch{}this._updatingChanged()})))};this.addHandles([g((()=>this.map?.allLayers),"after-changes",(e=>t(e)),{onListenerAdd:()=>t(),onListenerRemove:()=>t(),sync:!0}),this.allLayerViews.on("after-changes",(e=>this._updateUpdatingMonitors(e))),m((()=>this.map),(e=>{e&&"load"in e&&e.load&&e.load().catch((()=>{}))}))]),this.inputManager=new le({view:this}),this.stateManager=new ue({view:this})}initialize(){this.groundView=new $({view:this}),this._updateUpdatingMonitors();const e=()=>this._updateDefaultToMapOptions();this.addHandles(g((()=>this.map?.allLayers),"after-changes",e,{onListenerAdd:e,onListenerRemove:e})),this.updatingHandles.add((()=>this.qualitySettings.memoryLimit),(e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)}),y),this.updatingHandles.add((()=>this.qualitySettings.additionalCacheMemory),(e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)}),y),this.updatingHandles.add((()=>this.qualitySettings.frameRate??0),(e=>v(e>0?1e3/Math.ceil(e):0)),y),this.updatingHandles.add((()=>this.map?.ground),e,f),this.updatingHandles.add((()=>this.map?.ground?.opacity),(()=>this._updateDefaultHitTestOptions()),f),this.addHandles(m((()=>this.spatialReference),(()=>this.notifyChange("clippingArea")),_))}destroy(){this.destroyed||(this.updatingHandles.removeAll(),this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this._exitSurface(),this._disposeGraphicsView(),this.sharedSymbolResources=h(this.sharedSymbolResources),this._set("labeler",h(this.labeler)),this._set("deconflictor",h(this.deconflictor)),this._resourceController=h(this._resourceController),this._set("stateManager",h(this.stateManager)),this._set("inputManager",h(this.inputManager)),this.state.destroy(),this._propertiesPool.destroy(),this.removeHandles("updatingMonitors"),this._set("environmentManager",h(this.environmentManager)),this._set("environment",h(this.environment)),this.groundView=h(this.groundView),this._exitBasemapTerrain(),this._stage?.destroy())}get renderSpatialReference(){return this.renderCoordsHelper&&this.renderCoordsHelper.spatialReference}get basemapSpatialReference(){return this.basemapTerrain?.spatialReference}get animation(){return this.state?.animation}get camera(){return this.stateManager?.camera}set camera(e){this.stateManager&&(this.stateManager.camera=e)}get contentCamera(){return this.stateManager?.contentCamera}set contentCamera(e){this.stateManager&&(this.stateManager.contentCamera=e)}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get center(){return this.stateManager?.center}set center(e){this.stateManager&&(this.stateManager.center=e)}get clippingArea(){if("global"===this.viewingMode)return null;const e=this.map;let t=this._userClippingArea||d(e,"clippingArea");return!this._userClippingArea&&!d(e,"clippingEnabled")||null==t?(this._clippingArea=null,null):t instanceof Ke?this.spatialReference&&(t=it(t,this.spatialReference),null==t)?(p.getLogger(this).error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(t=t.clone(),null==t.intersection(this._groundAndLayersExtent)&&(t.xmin=t.xmax,t.ymin=t.ymax),t.zmin=void 0,t.zmax=void 0,t.equals(this._clippingArea)||(this._clippingArea=t),this._clippingArea):(p.getLogger(this).error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&null!=e?p.getLogger(this).error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===ee.Global)return null;const e=this.renderSpatialReference,t=this.dataExtent;return null==t||null==e||t.spatialReference.equals(e)?t:it(t,e)}get dataExtent(){let e=this._groundAndLayersExtent;const t=this.spatialReference||Xe.WGS84,i=it(this.clippingArea,t);null!=i&&(e=null!=e?e.intersection(i):i);const r=this._get("dataExtent");return null!=e&&e.equals(r)?r:e}get _groundAndLayersExtent(){const e=this.spatialReference||Xe.WGS84;let t;const i=i=>{const r=it(i,e);null!=r&&(null!=t?t.union(r):t=r.clone())},r=this.basemapTerrain;if(r?.spatialReference){const e=r.groundExtent;i(new Ke({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}if(this.map){const e=e=>{null==e.fullExtent||"graphics"===e.type&&e.internal||i(e.fullExtent)};this.map.allLayers.forEach((t=>e(t)))}if(null==t)return null;t.hasZ?(t.zmin=Math.min(0,t.zmin??0),t.zmax=Math.max(0,t.zmax??0)):(t.zmin=0,t.zmax=0);const s=this._get("_groundAndLayersExtent");return t.equals(s)?s:t}castEnvironment(e){return e?e instanceof ne?e:e instanceof Je?this.environment?.cloneWithWebsceneEnvironment(e)??ne.fromWebsceneEnvironment(e):j(ne,e):new ne}get extent(){return this.stateManager?.extent}set extent(e){this.stateManager&&(this.stateManager.extent=e)}get screenCenter(){return this.stateManager?.screenCenter}get frustum(){return this.stateManager?.frustum}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get _defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||(this.toolViewManager?.interacting??!1)}get stationary(){return!this.animation&&!this.resizing&&(null==this.state||this.state.stationary)}get navigating(){return this.state?.navigating??!1}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}set qualityProfile(e){fe.isValidProfile(e)&&(fe.apply(e,this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||fe.getDefaultProfile()}set slicePlane(e){if(null!=this._stage&&this._stage.renderer.setParameters({slicePlane:e}),null==e)return void this._set("slicePlane",null);const t=this._propertiesPool.get("slicePlane");W(e,t),this._set("slicePlane",t)}get typeSpecificPreconditionsReady(){return!!this.viewingMode&&this.stateManager.preinit(this.spatialReference)}get resolution(){return null!=this.spatialReference?k(this.scale,this.spatialReference):0}get scale(){return this.stateManager?.scale}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?L.deriveUnitFromSR(e,this.spatialReference):null}get updating(){if(this.destroyed)return!1;let e=0,t=this.layerViewManager.updating,i=t?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach((r=>{if(r.isFulfilled()){if(r.updating){if(t=!0,r.suspended||He(r))return;++i,e+=r.updatingProgress}}else++i}));for(const s of this._updatingObjects)if(null!=s&&s.updating){const t=.1;i+=t,e+=.5*t}for(const s of this._updatingObjectsWithProgress)null!=s&&s.updating&&(++i,e+=s.updatingProgress);const r=!this.stateManager.test.updatingIgnoreRenderState&&this.state.updating;if(t=!!(t||i>0||this.updatingHandles.updating||!this.ready||!this.stationary||r||this._createGraphicsViewController||this.inputManager?.updating||this.map?.allLayers?.some((e=>!e.isFulfilled()))||this.textures?.updating),t?(this._numUpdating=Math.max(i,this._numUpdating),e+=this._numUpdating-i):this._numUpdating=0,this._numUpdating>0?e/=this._numUpdating:e=t?0:1,this._get("updatingProgress")!==e){const i=performance.now();if(e<1){const t=Math.min((i-this._lastUpdateTime)/2e3,1);e=this.updatingProgress*(1-t)+e*t}this._set("updatingProgress",e),this._lastUpdateTime=t&&e<1?i:0}return t}get _updatingObjects(){return[this.graphicsView,this.basemapView,this._resourceController,this._stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this._featureTreeDebugger,this.toolViewManager,this.analysisViewManager]}get _updatingObjectsWithProgress(){return[this.deconflictor,this.labeler,this.basemapTerrain]}get viewingMode(){const e=this._predeterminedViewingMode;if(null!=e)return te(e);const t=this.spatialReference;return t?null!=this.defaultsFromMap?.viewingMode&&t.equals(this.defaultsFromMap.spatialReference)?te(this.defaultsFromMap.viewingMode):Qe(t,ee.Global)?"global":"local":"global"}set viewingMode(e){this.ready?p.getLogger(this).error("#viewingMode","viewingMode cannot be set once view is ready"):this._overrideIfSome("viewingMode",e)}get viewpoint(){return this.stateManager?.viewpoint}set viewpoint(e){this.stateManager&&(this.stateManager.viewpoint=e)}get zoom(){return this.stateManager.zoom}set zoom(e){this.stateManager&&(this.stateManager.zoom=e)}get resourceController(){return this._resourceController}get quality(){return this._resourceController?.memoryController?.memoryFactor??1}get resolutionScale(){return Math.sqrt(Math.min(1,this.quality/.75))}get performanceInfo(){return new Oe(this)}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return p.getLogger(this).error("#toMap()","Scene view cannot be used before it is ready"),null;const i=Be(e)?Ne(this,e):e;return ve(this,i,t,this._defaultToMapOptions)}toScreen(e){if(!this.ready)return p.getLogger(this).error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=(null==e.z?we(this.elevationProvider,e):null)??0;return I(e,rt,this.renderSpatialReference,t),this.state.camera.projectToScreen(rt,st),b(st[0],st[1])}pixelSizeAt(e){return this.ready?e?(I(e,rt,this.renderSpatialReference),this.state.camera.computeScreenPixelSizeAt(rt)):0:(p.getLogger(this).error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null)}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e,(()=>this.pixelSizeAt(e))):1}hitTest(e,t){if(!this.ready)return p.getLogger(this).error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=Be(e)?Ne(this,e):e;return be(this,i,t,this._defaultHitTestOptions)}async popupHitTest(e){return Se(this,e)}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(null==e.parent)throw new a("view:no-analysisview-for-analysis","The analysis has not been added to view.analyses",{analysis:e});switch(e.parent.type){case"line-of-sight":case"dimension":return(await this.whenLayerView(e.parent)).whenAnalysisView();default:return this.analysisViewManager.whenAnalysisView(e)}}whenLayerView(e){return super.whenLayerView(e)}async takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return Ue(i,t,this._pixelFormat())}async _takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return ke(i,this._pixelFormat())}async _takeScreenshotWithObjectAndLayerId(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t);return[ke(i[0],this._pixelFormat()),ke(i[1],this._pixelFormat())]}_completeSettings(e){const t=qe(e,this);return t.pixelRatio/=this.state.pixelRatio,ze(t,this.supersampleScreenshotsEnabled,this.padding)}_pixelFormat(){return{flipY:!0,premultipliedAlpha:this._stage.renderView.getAlpha()}}get test(){return{takeScreenshot:e=>this._takeScreenshot(e),takeScreenshotWithObjectAndLayerId:e=>this._takeScreenshotWithObjectAndLayerId(e)}}async takeScreenshotWithObjectAndLayerId(e){if(!has("enable-feature:objectAndLayerId-rendering"))throw new Error("has enable-feature:objectAndLayerId-rendering must be true");const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t),r=Ue(i[0],t,this._pixelFormat()),s=this._completeSettings(e);s.format="png";return[r,Ue(i[1],s,this._pixelFormat())]}getColorToObjectAndLayerIdMapping(){if(null==this._stage.renderView.objectAndLayerIdRenderHelper)throw new Error("has enable-feature:objectAndLayerId-rendering must be true");return this._stage.renderView.objectAndLayerIdRenderHelper.getColorToObjectAndLayerIdMapping()}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return re.importLayerView(e)}hasLayerViewModule(e){return re.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||this.defaultsFromMap?.ready&&this._initialDefaultSpatialReference||null}async validate(){let e=Ye(this.type);const t=has("safari");if(t&&t<9&&(e=new a("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:t})),null!=e)throw p.getLogger(this).warn("#validate()",e.message),e}get _predeterminedViewingMode(){const e=this._isOverridden("viewingMode")?this._get("viewingMode"):(this.map&&"initialViewProperties"in this.map?this.map.initialViewProperties?.viewingMode:null)??null;return null!=e?ie(e):null}getSpatialReferenceSupport({spatialReference:e,layer:t}){const i=this._predeterminedViewingMode;if(null!=i)return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,ee.Local),s=this._validateSpatialReferenceForViewingMode(e,t,ee.Global);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,ee.Local)}:{constraints:this._makeSpatialReferenceConstraints(e,t,ee.Global)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!Qe(e,i)&&(null==t||(!!q(t)||(!z(t)||null!=Pe(t,e,i))&&(!B(t)||i!==ee.Global)))}_makeSpatialReferenceConstraints(e,t,i){if(null==t)return[{spatialReference:e,viewingMode:i}];const r=e.isWebMercator,s=e.isWGS84;if(q(t)&&(r||s)){return!s||i===ee.Local||null===Ae(t.tileInfo,t.fullExtent,e,ee.Global)?[{spatialReference:e,viewingMode:i},{spatialReference:Xe.WebMercator,viewingMode:i}]:[{spatialReference:r?Xe.WGS84:Xe.WebMercator,viewingMode:i}]}return z(t)||B(t)||!r&&!s?z(t)&&r&&i!==ee.Global?[{spatialReference:e,viewingMode:i},{spatialReference:Xe.WGS84,viewingMode:ee.Local}]:[{spatialReference:e,viewingMode:i}]:[{spatialReference:e,viewingMode:i},{spatialReference:r?Xe.WGS84:Xe.WebMercator,viewingMode:i}]}_validateSpatialReference(e){const t=null!=this.getSpatialReferenceSupport({spatialReference:e}),i=this._predeterminedViewingMode;return t||(null!=i?p.getLogger(this).warnOnce(`Spatial reference defined on view not supported in ${te(i)} viewing mode.`):e.isGeographic&&p.getLogger(this).warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}trackGraphicState(e){if(!e.graphic)return p.getLogger(this).error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{!r&&null!=t&&"processor"in t&&"graphics-3d"===t.processor?.type&&t.processor.graphicsCore&&(i=t.processor.graphicsCore.trackGraphicState(e))};return null!=t?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),o((()=>{r=!0,null!=i&&(i.remove(),i=null)}))}highlight(e){if(Array.isArray(e))return l(e.map((e=>this.highlight(e))));if(r.isCollection(e))return l(e.toArray().map((e=>this.highlight(e))));const t=this.getViewForGraphic(e);return t&&"highlight"in t?t.highlight(e):o()}maskOccludee(e){if(!e)return p.getLogger(this).error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&null!=t&&We(t)&&(i=t.maskOccludee(e))};return null!=t?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),o((()=>{r=!0,null!=i&&(i.remove(),i=null)}))}getViewForGraphic(e){return e.layer===this.graphics?this.graphicsView:e.layer?this.allLayerViews.find((t=>t.layer===e.layer)):null}graphicChanged(e){null!=this.graphicsView&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){if(e.layer===this)return await w((()=>this.graphicsView)),this.graphicsView;if(!e.layer||!this.map)throw new a("no-view-for-graphic");return t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise(((t,i)=>{const r=this.map.allLayers.on("change",(s=>{s.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))}))})):this.whenLayerView(e.layer)}_initBasemapTerrain(){this._set("basemapTerrain",new Le({view:this})),this._set("elevationProvider",new me({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){this.basemapTerrain&&(this.elevationProvider.unregister(this.basemapTerrain),this.elevationProvider.destroy(),this._set("elevationProvider",null),this.basemapTerrain.destroy(),this._set("basemapTerrain",null))}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new Ee({view:this})),this._set("featureTiles",new de({renderCoordsHelper:this.renderCoordsHelper,cameraOnSurface:this.pointsOfInterest.cameraOnSurface,focus:this.pointsOfInterest.focus,tilingSchemeOwner:this.basemapTerrain,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}));const e=()=>{const e=this.basemapTerrain?.extent;if(this.clippingArea||e)if(e&&this.basemapTerrain.spatialReference){const e=null!=this.basemapTerrain.extent&&null!=this.basemapTerrain.spatialReference?P(D(this.basemapTerrain.extent,this.basemapTerrain.spatialReference),this.spatialReference):null;null!=this.clippingArea?this.featureTiles.filterExtent=this.clippingArea.intersection(e):this.featureTiles.filterExtent=e}else this.featureTiles.filterExtent=this.clippingArea;else this.featureTiles.filterExtent=null};this.addHandles([this.updatingHandles.add((()=>ye.FEATURE_TILE_TREE_SHOW_TILES),(e=>{e&&this.featureTiles&&!this._featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then((({FeatureTileTree3DDebugger:e})=>{!this._featureTreeDebugger&&ye.FEATURE_TILE_TREE_SHOW_TILES&&(this._featureTreeDebugger=new e({view:this}))})):e||!this._featureTreeDebugger||ye.FEATURE_TILE_TREE_SHOW_TILES||(this._featureTreeDebugger.destroy(),this._featureTreeDebugger=null)}),f),this.updatingHandles.add((()=>this.clippingArea),e,f),this.updatingHandles.add((()=>this.basemapTerrain.extent),e,f)],"feature-tiles"),this.stateManager.init()}_exitGlobe(){this.state&&(this.stateManager.exit(),this.removeHandles("render-coords-helper"),this.removeHandles("feature-tiles"),this.featureTiles.destroy(),this._set("featureTiles",null),this.pointsOfInterest.destroy(),this._set("pointsOfInterest",null),this._exitBasemapTerrain(),this.state.exit(),this._exitCoordinateSystem())}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference;this.mapCoordsHelper&&this.mapCoordsHelper.spatialReference.equals(e)||this._set("mapCoordsHelper",new Me(this.map,e));const t=this.state.isGlobal,i=U(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",Re.create(this.state.viewingMode,i)),t||this.addHandles(m((()=>this.basemapTerrain?.extent),(e=>{const t=this.renderCoordsHelper.spatialReference;null==e||0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!A(e,this.basemapTerrain.spatialReference,at,t)||(this.renderCoordsHelper.extent=at)}),_),"render-coords-helper"),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(De/this.renderCoordsHelper.unitInMeters))}else this._set("mapCoordsHelper",null),this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.mapCoordsHelper&&(this.removeHandles("render-coords-helper"),this._set("renderCoordsHelper",null),this._set("mapCoordsHelper",null))}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){null!=e&&e.type===c.MOVE||(this.removeHandles("updatingMonitors"),this.allLayerViews.forEach((e=>{e.destroyed||(this.addHandles(m((()=>[e.updating,e.updatingProgress]),(()=>this._updatingChanged()),_),"updatingMonitors"),e.when((()=>this._updatingChanged()),(()=>this._updatingChanged())))})),this._updatingChanged())}async _prepareScreenshotOverlay(){this.overlay&&await this.overlay.prepare()}_renderScreenshotOverlay(e,t,i){if(!this.overlay||!this.overlay.hasVisibleItems)return i;const r=e.getContext("2d");return r.putImageData(i,0,0),this.overlay.renderCanvas(e,{disableDecorations:t===Ge.OFF}),r.getImageData(0,0,i.width,i.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,preserveDrawingBuffer:this.preserveDrawingBufferEnabled,canvas:this.renderCanvas,screenshot:{prepareOverlay:()=>this._prepareScreenshotOverlay(),renderOverlay:(e,t,i)=>this._renderScreenshotOverlay(e,t,i)}},t=new ge(this.state.viewingMode,(e=>this._stage.layers.forAll(e)),this);this._set("sceneIntersectionHelper",t);const i=s(this.surface);this._stage=new Ie({view:this,options:e,container:i}),this._stage.renderer.setParameters({slicePlane:this.slicePlane}),this.addHandles([this.updatingHandles.add((()=>this.qualitySettings.highQualityTransparency),(e=>this._stage.renderer.setParameters({highQualityTransparency:e})),y),m((()=>this.magnifier),(e=>this._stage.renderView.magnifier=e),f),this.on("pointer-move",(()=>this._stage?.renderer.resetAnimation())),n(this._stage.renderView.canvas,"webglcontextlost",(e=>{this.fatalError=new a("webgl-context-lost",e.statusMessage)}))],"stage"),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(De/this.renderCoordsHelper.unitInMeters),this._set("canvas",this._stage.renderView.canvas)}_exitStage(){this._set("sceneIntersectionHelper",null),this._stage=h(this._stage),this.removeHandles("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this.state.init(e,this.spatialReference),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new Te({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitGlobe(),this._exitStage())}_createGraphicsViewIfNeeded(){if(this.graphicsView||this._createGraphicsViewController)return;if(0===this.graphics.length)return;this.removeHandles("graphics-view"),this._createGraphicsViewController=new AbortController;const e=()=>{this._createGraphicsViewController=null,this._updatingChanged()};this._createGraphicsViewAsync(this._createGraphicsViewController.signal).then(e,e),this._updatingChanged()}async _createGraphicsViewAsync(e){const t=(await import("./3d/layers/GraphicsView3D.js")).default;u(e),await w((()=>this.basemapTerrain?.ready),e),this._set("graphicsView",new t({view:this}))}_disposeGraphicsView(){this._createGraphicsViewController&&(this._createGraphicsViewController.abort(),this._createGraphicsViewController=null),this.removeHandles("graphics-view"),null!=this.graphicsView&&(this.removeHandles(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_startup(){const e=ie(this.viewingMode);e===ee.Global&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.addHandles(g((()=>this.graphics),"after-changes",(()=>this._createGraphicsViewIfNeeded())),"graphics-view"),this._createGraphicsViewIfNeeded();const t=this.map&&"initialViewProperties"in this.map?this.map.initialViewProperties?.environment:void 0;t&&T(this.environment,t),this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect(),this._set("textures",new xe(this._stage,this.resourceController.scheduler));const i=this._resolveWhenReady;this._resolveWhenReady=[],i.forEach((e=>e(this)))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this.labeler.dispose(),this._disposeGraphicsView(),this.removeHandles("graphics-view"),this._set("textures",h(this.textures)),this._exitSurface(),this._set("ready",!1)}_updateDefaultToMapOptions(){if(this._defaultToMapOptions.include.clear(),this.map){this.map.ground&&this._defaultToMapOptions.include.add(Fe);for(const e of this.map.allLayers.items)N(e.type)&&this._defaultToMapOptions.include.add(e.uid)}}_updateDefaultHitTestOptions(){if(this._defaultHitTestOptions.exclude.clear(),this.map){this.map.ground&&this.map.ground.opacity<1&&this._defaultHitTestOptions.exclude.add(Fe);for(const e of this.map.allLayers.items)N(e.type)&&e.opacity<1&&this._defaultHitTestOptions.exclude.add(e.uid)}}};function it(e,t){return null!=e&&H(e.spatialReference,t)?P(e,t):null}tt.type="3d",e([V()],tt.prototype,"_userClippingArea",void 0),e([V()],tt.prototype,"_resourceController",void 0),e([V()],tt.prototype,"_stage",void 0),e([V({readOnly:!0})],tt.prototype,"deconflictor",void 0),e([V({readOnly:!0})],tt.prototype,"labeler",void 0),e([V(E(Q,"analyses"))],tt.prototype,"analyses",void 0),e([V({type:X,readOnly:!0})],tt.prototype,"animation",null),e([V({readOnly:!0})],tt.prototype,"basemapTerrain",void 0),e([V({readOnly:!0})],tt.prototype,"elevationProvider",void 0),e([V()],tt.prototype,"camera",null),e([V({type:t})],tt.prototype,"contentCamera",null),e([V({readOnly:!0})],tt.prototype,"canvas",void 0),e([V({type:et})],tt.prototype,"center",null),e([V({type:Ke})],tt.prototype,"clippingArea",null),e([V({type:ae})],tt.prototype,"constraints",void 0),e([V({type:Ke,readOnly:!0})],tt.prototype,"renderDataExtent",null),e([V({type:Ke,readOnly:!0})],tt.prototype,"dataExtent",null),e([V({type:Ke,readOnly:!0})],tt.prototype,"_groundAndLayersExtent",null),e([V({type:ne})],tt.prototype,"environment",void 0),e([C("environment")],tt.prototype,"castEnvironment",null),e([V({readOnly:!0})],tt.prototype,"environmentManager",void 0),e([V({type:Ke})],tt.prototype,"extent",null),e([V()],tt.prototype,"floors",void 0),e([V()],tt.prototype,"screenCenter",null),e([V()],tt.prototype,"frustum",null),e([V({type:Number,readOnly:!0})],tt.prototype,"fullOpacity",void 0),e([V({readOnly:!0})],tt.prototype,"graphicsView",void 0),e([V({readOnly:!0})],tt.prototype,"analysisViewManager",void 0),e([V()],tt.prototype,"groundView",void 0),e([V({type:Boolean})],tt.prototype,"initialExtentRequired",null),e([V()],tt.prototype,"_defaultsFromMapSettings",null),e([V()],tt.prototype,"interacting",null),e([V()],tt.prototype,"stationary",null),e([V()],tt.prototype,"navigating",null),e([V()],tt.prototype,"map",void 0),e([V({readOnly:!0})],tt.prototype,"mapCoordsHelper",void 0),e([V()],tt.prototype,"padding",null),e([V({type:Ee,readOnly:!0})],tt.prototype,"pointsOfInterest",void 0),e([V({type:de,readOnly:!0})],tt.prototype,"featureTiles",void 0),e([V()],tt.prototype,"_featureTreeDebugger",void 0),e([V({type:Boolean})],tt.prototype,"screenSizePerspectiveEnabled",void 0),e([V({constructOnly:!0})],tt.prototype,"deactivatedWebGLExtensions",void 0),e([V({constructOnly:!0})],tt.prototype,"debugWebGLExtensions",void 0),e([V({constructOnly:!0})],tt.prototype,"renderCanvas",void 0),e([V({constructOnly:!0})],tt.prototype,"state",void 0),e([V({readOnly:!0})],tt.prototype,"inputManager",void 0),e([V({readOnly:!0})],tt.prototype,"stateManager",void 0),e([V({type:["low","medium","high"]})],tt.prototype,"qualityProfile",null),e([V({type:Ce,get(){let e=this._get("qualitySettings");return e||(e=new Ce,fe.apply(this.qualityProfile,e)),e}})],tt.prototype,"qualitySettings",void 0),e([V()],tt.prototype,"slicePlane",null),e([V({readOnly:!0})],tt.prototype,"typeSpecificPreconditionsReady",null),e([V({readOnly:!0})],tt.prototype,"renderCoordsHelper",void 0),e([V({readOnly:!0})],tt.prototype,"sceneIntersectionHelper",void 0),e([V({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],tt.prototype,"resolution",null),e([V({type:Number})],tt.prototype,"scale",null),e([V()],tt.prototype,"heightModelInfo",null),e([V()],tt.prototype,"spatialReference",void 0),e([V({type:Boolean,constructOnly:!0})],tt.prototype,"alphaCompositingEnabled",void 0),e([V({constructOnly:!0})],tt.prototype,"preserveDrawingBufferEnabled",void 0),e([V({type:Boolean})],tt.prototype,"supersampleScreenshotsEnabled",void 0),e([V({readOnly:!0})],tt.prototype,"type",void 0),e([V(),C((e=>e instanceof Ze?e:O($e,e)))],tt.prototype,"ui",void 0),e([V({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","_stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.updating","toolViewManager.updating","analysisViewManager.updating","state.updating","textures.updating"]})],tt.prototype,"updating",null),e([V()],tt.prototype,"_updatingObjects",null),e([V()],tt.prototype,"_updatingObjectsWithProgress",null),e([V({type:Number,readOnly:!0,dependsOn:["updating"]})],tt.prototype,"updatingProgress",void 0),e([V({type:["global","local"]})],tt.prototype,"viewingMode",null),e([V({type:i})],tt.prototype,"viewpoint",null),e([V({type:Number})],tt.prototype,"zoom",null),e([V({type:_e})],tt.prototype,"highlightOptions",void 0),e([V({readOnly:!0})],tt.prototype,"quality",null),e([V({readOnly:!0})],tt.prototype,"resolutionScale",null),e([V()],tt.prototype,"textures",void 0),tt=e([R("esri.views.SceneView")],tt);const rt=x(),st=M(),at=G(),nt=tt;export{nt 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as a}from"../../core/promiseUtils.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{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as f}from"./DrawingMode.js";import{DrawManipulator as x}from"./DrawManipulator.js";import{createCoordinateHelper as b}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as C,sceneSnappingAtLocation as T}from"../interactive/dragEventPipeline.js";import{EditGeometry as S,Component as V}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as P}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as w}from"../interactive/sketch/constraints.js";import O from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as M}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as D}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as I}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as E}from"../interactive/snapping/snappingUtils.js";import{pointToConstraintSpace as j,constraintSpaceToPoint as H,getPointConstraint as G,getPolylineOrPolygonConstraint as k}from"../interactive/tooltip/constraintUtils.js";const Z="crosshair",A="progress";let L=class extends(i.EventedMixin(e)){constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._stagedPointerId=null,this._updatingHandles=new m,this.constraintsEnabled=!1,this.constraintInfo=void 0,this._getPointConstraint=s(G),this._getPolylineOrPolygonConstraint=s(k),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new O,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,n="viewingMode"in e.state?e.state.viewingMode:v.Local,o="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=b(this.hasZ,this.hasM,i),this._editGeometryOperations=new P(new S(o,this.coordinateHelper)),this._snappingOperation=new I({view:e}),this.addHandles([p((()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this.constraint})),(({stagedPoint:t,constraint:e})=>{const{snappingOptions:i}=this;i&&(i.forceDisabled=null!=e&&w(e),i.edgesEnabled=null==this.constraintInfo?.distance&&null==this.constraintInfo?.direction),this._processCursor(t??this._screenToMap(this._stagedScreenPoint))}),{sync:!0,equals:(t,e)=>g(t.stagedPoint,e.stagedPoint)&&r(t.constraint,e.constraint)}),p((()=>this.view.viewpoint),((t,e)=>{t&&e&&u(t,e)&&this._onViewpointChange()}))]),this._activeComponent=new V(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},this.addHandles(p((()=>this.labelOptions.enabled),(t=>{s.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 x({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==t,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(t=>this._onImmediateClick(t))),l.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),p((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:t})=>{l.cursor=t}),c)]),E(this,(()=>{const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);null!=this.snappingManager&&this._updatingHandles.addPromise(a(this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e)))}))}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const 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{constraintInfo:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":return this._getPointConstraint(t.elevation,t.context);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t.distance,t.direction,t.elevation,t.context)}}set drawingMode(t){this._set("drawingMode",t??f)}get effectiveCursor(){return this.loading?A: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&&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=n(this.cursorVertex),i=n(t),o=i&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(i)??i),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||"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}=D({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer}),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 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._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(),"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(!e.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)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||"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;const i=this._snappingOperation,n=this._manipulator;this._pointerDownStates.has(t.pointerId)||n.grabbing||!n.interactive?i.abort():(t.stopPropagation(),this._processCursorMovementRelativeToSurface(e,t.pointerType))}_onViewpointChange(){const t=this._manipulator;"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._pointerDownStates.has(this._stagedPointerId)&&!t.grabbing&&t.interactive?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,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,constraintInfo:i}=this;if(!t||!i||!e)return t;const{context:n}=i,o=j(t,n),r=o?e.closestTo(o):void 0;if(!r)return t;const s=H(r,t,n);return null!=s&&"absolute-height"!==n.elevationInfo.mode&&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 M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null})}};function z(t,e,i){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o<=i}t([d()],L.prototype,"_hideDefaultCursor",void 0),t([d()],L.prototype,"_snappingOperation",void 0),t([d()],L.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],L.prototype,"graphic",void 0),t([d()],L.prototype,"constraintsEnabled",void 0),t([d()],L.prototype,"constraintInfo",void 0),t([d()],L.prototype,"constraint",null),t([d()],L.prototype,"constraintZ",void 0),t([d()],L.prototype,"defaultZ",void 0),t([d()],L.prototype,"isDraped",void 0),t([d({value:f})],L.prototype,"drawingMode",null),t([d({constructOnly:!0})],L.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:O})],L.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],L.prototype,"geometryType",void 0),t([d({constructOnly:!0})],L.prototype,"hasM",void 0),t([d({constructOnly:!0})],L.prototype,"hasZ",void 0),t([d()],L.prototype,"cursor",void 0),t([d()],L.prototype,"effectiveCursor",null),t([d()],L.prototype,"loading",void 0),t([d({constructOnly:!0})],L.prototype,"manipulators",void 0),t([d({constructOnly:!0})],L.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],L.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],L.prototype,"snappingVisualizer",void 0),t([d()],L.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],L.prototype,"cursorVertex",null),t([d({readOnly:!0})],L.prototype,"visualizationCursorVertex",null),t([d()],L.prototype,"committableVertex",null),t([d()],L.prototype,"firstVertex",void 0),t([d()],L.prototype,"lastVertex",void 0),t([d()],L.prototype,"secondToLastVertex",void 0),t([d()],L.prototype,"updating",null),t([d({constructOnly:!0})],L.prototype,"view",void 0),L=t([h("esri.views.draw.DrawOperation")],L);export{L as DrawOperation,Z as defaultCursor,A as defaultLoadingCursor};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as a}from"../../core/promiseUtils.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{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as f}from"./DrawingMode.js";import{DrawManipulator as x}from"./DrawManipulator.js";import{createCoordinateHelper as b}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as C,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 O from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as M}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as D}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as I}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as E}from"../interactive/snapping/snappingUtils.js";import{pointToConstraintSpace as j,constraintSpaceToPoint as H,getPointConstraint as G,getPolylineOrPolygonConstraint as k}from"../interactive/tooltip/constraintUtils.js";const Z="crosshair",A="progress";let L=class extends(i.EventedMixin(e)){constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._stagedPointerId=null,this._updatingHandles=new m,this.constraintsEnabled=!1,this.constraintInfo=void 0,this._getPointConstraint=s(G),this._getPolylineOrPolygonConstraint=s(k),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new O,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,n="viewingMode"in e.state?e.state.viewingMode:v.Local,o="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=b(this.hasZ,this.hasM,i),this._editGeometryOperations=new V(new S(o,this.coordinateHelper)),this._snappingOperation=new I({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&&w(e),n.edgesEnabled=null==this.constraintInfo?.distance&&null==this.constraintInfo?.direction);if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))}),{sync:!0,equals:(t,e)=>t.stagedPoint===e.stagedPoint&&r(t.constraint,e.constraint)}),p((()=>this.view.viewpoint),((t,e)=>{t&&e&&u(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},this.addHandles(p((()=>this.labelOptions.enabled),(t=>{s.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 x({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==t,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(t=>this._onImmediateClick(t))),l.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),p((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:t})=>{l.cursor=t}),c)]),E(this,(()=>{const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);null!=this.snappingManager&&this._updatingHandles.addPromise(a(this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e)))}))}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const 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{constraintInfo:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":return this._getPointConstraint(t.elevation,t.context);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t.distance,t.direction,t.elevation,t.context)}}set drawingMode(t){this._set("drawingMode",t??f)}get effectiveCursor(){return this.loading?A: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&&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=n(this.cursorVertex),i=n(t),o=i&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(i)??i),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||"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}=D({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer}),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 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._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(),"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(!e.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)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||"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;const i=this._snappingOperation,n=this._manipulator;this._pointerDownStates.has(t.pointerId)||n.grabbing||!n.interactive?i.abort():(t.stopPropagation(),this._processCursorMovementRelativeToSurface(e,t.pointerType))}_onKeyboardBasedChange(){const t=this._manipulator;"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._pointerDownStates.has(this._stagedPointerId)&&!t.grabbing&&t.interactive?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,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,constraintInfo:i}=this;if(!t||!i||!e)return t;const{context:n}=i,o=j(t,n),r=o?e.closestTo(o):void 0;if(!r)return t;const s=H(r,t,n);return null!=s&&"absolute-height"!==n.elevationInfo.mode&&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 M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null})}};function z(t,e,i){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o<=i}t([d()],L.prototype,"_hideDefaultCursor",void 0),t([d()],L.prototype,"_snappingOperation",void 0),t([d()],L.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],L.prototype,"graphic",void 0),t([d()],L.prototype,"constraintsEnabled",void 0),t([d()],L.prototype,"constraintInfo",void 0),t([d()],L.prototype,"constraint",null),t([d()],L.prototype,"constraintZ",void 0),t([d()],L.prototype,"defaultZ",void 0),t([d()],L.prototype,"isDraped",void 0),t([d({value:f})],L.prototype,"drawingMode",null),t([d({constructOnly:!0})],L.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:O})],L.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],L.prototype,"geometryType",void 0),t([d({constructOnly:!0})],L.prototype,"hasM",void 0),t([d({constructOnly:!0})],L.prototype,"hasZ",void 0),t([d()],L.prototype,"cursor",void 0),t([d()],L.prototype,"effectiveCursor",null),t([d()],L.prototype,"loading",void 0),t([d({constructOnly:!0})],L.prototype,"manipulators",void 0),t([d({constructOnly:!0})],L.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],L.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],L.prototype,"snappingVisualizer",void 0),t([d()],L.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],L.prototype,"cursorVertex",null),t([d({readOnly:!0})],L.prototype,"visualizationCursorVertex",null),t([d()],L.prototype,"committableVertex",null),t([d()],L.prototype,"firstVertex",void 0),t([d()],L.prototype,"lastVertex",void 0),t([d()],L.prototype,"secondToLastVertex",void 0),t([d()],L.prototype,"updating",null),t([d({constructOnly:!0})],L.prototype,"view",void 0),L=t([h("esri.views.draw.DrawOperation")],L);export{L as DrawOperation,Z as defaultCursor,A 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../Graphic.js";import i from"../../../core/Evented.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{zeroMeters as o}from"../../../core/quantityUtils.js";import{when as r,watch as a,syncAndInitial as h,initial as c}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{create as p}from"../../../geometry/support/aaBoundingRect.js";import{getRingsOrPathsBounds as _}from"../../../geometry/support/boundsUtils.js";import{geometryToCoordinates as d}from"../../../geometry/support/coordsUtils.js";import m from"../../../geometry/support/rotate.js";import u from"../../../symbols/SimpleFillSymbol.js";import g from"../../../symbols/SimpleLineSymbol.js";import v from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as y,scale as f,getScaleRatio as G,getRotationAngle as b}from"./drawUtils.js";import w from"./GraphicMover.js";import x from"./HighlightHelper.js";import{addUniqueLayer as S}from"./layerUtils.js";import{settings as k}from"./settings.js";import R from"../../interactive/sketch/SketchOptions.js";import{ExtentRotateTooltipInfo as I,ExtentScaleTooltipInfo as M}from"../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as C}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as H}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoDistanceBetweenPoints2D as O}from"../../support/automaticLengthMeasurementUtils.js";import j from"../../../geometry/Point.js";import T from"../../../geometry/Polygon.js";import E from"../../../geometry/Polyline.js";class L{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-start"}}class B{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move"}}class z{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-stop"}}class Y{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-start"}}class N{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate"}}class U{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-stop"}}class A{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-start"}}class P{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale"}}class X{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-stop"}}const D=k.transformGraphics,F={centerIndicator:new v({style:"cross",size:D.center.size,color:D.center.color}),fill:{default:new u({color:D.fill.color,outline:{color:D.fill.outlineColor,join:"round",width:1}}),active:new u({color:D.fill.stagedColor,outline:{color:D.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new v({style:"square",size:D.vertex.size,color:D.vertex.color,outline:{color:D.vertex.outlineColor,width:1}}),hover:new v({style:"square",size:D.vertex.hoverSize,color:D.vertex.hoverColor,outline:{color:D.vertex.hoverOutlineColor,width:1}})},rotator:{default:new v({style:"circle",size:D.vertex.size,color:D.vertex.color,outline:{color:D.vertex.outlineColor,width:1}}),hover:new v({style:"circle",size:D.vertex.hoverSize,color:D.vertex.hoverColor,outline:{color:D.vertex.hoverOutlineColor,width:1}})},rotatorLine:new g({color:D.line.color,width:1})};let V=class extends i.EventedAccessor{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.tooltip=null,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=F,this.sketchOptions=new R,this.view=null,this._getBounds=(()=>{const t=p();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const s of i){if(!s)continue;let i,o,r,a;if("point"===s.type)i=r=s.x,o=a=s.y;else if("multipoint"===s.type){const e=d(s);[i,o,r,a]=_(t,[e])}else if("extent"===s.type)[i,o,r,a]=[s.xmin,s.ymin,s.xmax,s.ymax];else{const e=d(s);[i,o,r,a]=_(t,e)}e[0]=Math.min(i,e[0]),e[1]=Math.min(o,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})()}initialize(){const t=this.view;this._highlightHelper=new x({view:t}),this.tooltip=new C({view:t}),this._setup(),this.addHandles([r((()=>t?.ready),(()=>{const{layer:t,view:e}=this;S(e,t)}),{once:!0,initial:!0}),a((()=>this.preserveAspectRatio),(()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))})),a((()=>t?.scale),(()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()})),a((()=>this.graphics),(()=>this.refresh())),a((()=>this.layer),((t,e)=>{e&&this._resetGraphics(e),this.refresh()})),a((()=>this.highlightsEnabled),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()})),a((()=>this.sketchOptions.tooltips.effectiveEnabled),(t=>{this.tooltip=t?new C({view:this.view}):s(this.tooltip)}),h),a((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),c),this.on("move-start",(t=>this.callbacks?.onMoveStart?.(t))),this.on("move",(t=>this.callbacks?.onMove?.(t))),this.on("move-stop",(t=>this.callbacks?.onMoveStop?.(t))),this.on("rotate-start",(t=>this.callbacks?.onRotateStart?.(t))),this.on("rotate",(t=>this.callbacks?.onRotate?.(t))),this.on("rotate-stop",(t=>this.callbacks?.onRotateStop?.(t))),this.on("scale-start",(t=>this.callbacks?.onScaleStart?.(t))),this.on("scale",(t=>this.callbacks?.onScale?.(t))),this.on("scale-stop",(t=>this.callbacks?.onScaleStop?.(t)))])}destroy(){this._reset(),this.tooltip=s(this.tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=y(s,t,e,this.view);i.geometry=o}this.refresh(),this.emit("move-stop",new z(this.graphics,null,t,e))}}scale(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=f(s,t,e);i.geometry=o}this.refresh(),this.emit("scale-stop",new X(this.graphics,null,t,e))}}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new j(t,i,this.view.spatialReference)}for(const i of this.graphics){const s=i.geometry,o=m(s,t,e);i.geometry=o}this.refresh(),this.emit("rotate-stop",new U(this.graphics,null,t))}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_getStartInfo(t){const[e,i,s,o]=this._getBoxBounds(p()),r=Math.abs(s-e),a=Math.abs(o-i),h=(s+e)/2,c=(o+i)/2,{x:n,y:l}=t.geometry;return{width:r,height:a,centerX:h,centerY:c,startX:n,startY:l,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map((t=>this._getGraphicInfo(t)))}_getGraphicInfo(t){const e=t.geometry,[i,s,o,r]=this._getBounds(p(),[e]);return{width:Math.abs(o-i),height:Math.abs(r-s),centerX:(o+i)/2,centerY:(r+s)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:s,_backgroundGraphic:o,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h}=this,c=t.graphic;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),o.symbol=h.fill.active,this._startInfo=this._getStartInfo(c),this._updateTooltip(c,t.viewEvent),c===a?(this.view.cursor="grabbing",this.emit("rotate-start",new Y(this.graphics,c,e))):r.includes(c)?(this._activeHandleGraphic=c,this.emit("scale-start",new A(this.graphics,c,i,s))):this.emit("move-start",new L(this.graphics,c,t.dx,t.dy))}_onGraphicMoveCallback(t){const e=t.graphic;if(this._startInfo)if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",new P(this.graphics,e,this._xScale,this._yScale));else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",new N(this.graphics,e,this._angleOfRotation));else{const{dx:i,dy:s}=t;this._totalDx+=i,this._totalDy+=s,this._moveGraphic(e,i,s),this._updateTooltip(e,t.viewEvent),this.emit("move",new B(this.graphics,e,i,s))}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:s,_totalDy:o,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:c}=this;this.refresh(),e===c?(this.view.cursor="pointer",this.emit("rotate-stop",new U(this.graphics,e,i))):h.includes(e)?this.emit("scale-stop",new X(this.graphics,e,r,a)):this.emit("move-stop",new z(this.graphics,e,s,o))}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:s,_rotateHandleGraphic:o,symbols:r,view:a}=this,h=t.graphic;if(this._hoveredGraphic=h,h===o)return o.symbol=r.rotator.hover,a.cursor="pointer",void this._updateTooltip(h);if(s.includes(h)||h===e)return void(a.cursor="move");if(!i.includes(h))return void(a.cursor="pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const c=a.rotation;let n,l=t.index;switch(l<8&&(c>=0&&c<45?l%=8:l=c>=45&&c<90?(l+1)%8:c>=90&&c<135?(l+2)%8:c>=135&&c<180?(l+3)%8:c>=180&&c<225?(l+4)%8:c>=225&&c<270?(l+5)%8:c>=270&&c<315?(l+6)%8:(l+7)%8),l){case 0:case 4:n="nwse-resize";break;case 1:case 5:n="ns-resize";break;case 2:case 6:n="nesw-resize";break;case 3:case 7:n="ew-resize";break;default:n="pointer"}a.cursor=n}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:s,view:o}=this;this._hoveredGraphic=null,t.graphic===i?i.symbol=s.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=s.handles.default),o.cursor="default",this._updateTooltip()}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:s,view:o}=this,{centerX:r,centerY:a,startX:h,startY:c}=e,{resolution:n,transform:l}=o.state,p=i.indexOf(t);1!==p&&5!==p||this._updateX(t,r),3!==p&&7!==p||this._updateY(t,a);const{x:_,y:d}=t.geometry,m=l[0]*_+l[2]*d+l[4],u=l[1]*_+l[3]*d+l[5],g=e.graphicInfos?.map((t=>t.geometry))??[];if(s){const t=l[0]*r+l[2]*a+l[4],e=l[1]*r+l[3]*a+l[5],i=l[0]*h+l[2]*c+l[4],s=l[1]*h+l[3]*c+l[5];this._xScale=this._yScale=G(t,e,i,s,m,u);for(const o of g){const t=g.indexOf(o);this.graphics[t].geometry=f(o,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{const{width:t,height:i}=e;let s=_-h,l=c-d;if(1===p||5===p?s=0:3!==p&&7!==p||(l=0),0===s&&0===l)return;const m=t+(h>r?s:-1*s),u=i+(c<a?l:-1*l),v=r+s/2,G=a+l/2;this._xScale=m/t||1,this._yScale=u/i||1,1===p||5===p?this._xScale=1:3!==p&&7!==p||(this._yScale=1);const b=(v-r)/n,w=(G-a)/n,x=f(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=y(x,b,w,o,!0);const{centerX:S,centerY:k}=this._getGraphicInfo(this._backgroundGraphic),R=(S-r)/n,I=-1*(k-a)/n;for(const e of g){const t=g.indexOf(e),i=f(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=y(i,R,I,o,!0)}this._centerGraphic.geometry=new j(S,k,o.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:s,startY:o,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,c=new j(s,o,h),n=new j(e,i,h),l=t.geometry;this._angleOfRotation=b(c,l,n);const p=this._startInfo.graphicInfos?.map((t=>t.geometry))??[];for(const _ of p){const t=p.indexOf(_),e=m(_,this._angleOfRotation,n);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=m(r,this._angleOfRotation,n),this._rotateHandleGraphic.geometry=m(a,this._angleOfRotation,n)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const s=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=y(s,e,i,this.view);for(const o of this.graphics)o!==t&&(o.geometry=y(o.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=y(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const s of this.graphics)s.geometry=y(s.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e(null,i.centerIndicator,t),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e(null,i.fill.default,t),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e(null,i.rotatorLine,t),this._rotateHandleGraphic=new e(null,i.rotator.default,t),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let s=0;s<8;s++)this._vertexGraphics.push(new e(null,i.handles.default,t));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={...this.symbols,fill:{active:this.symbols.fill.active?.clone().set("outline.color",t),default:this.symbols.fill.default?.clone().set("outline.color",t)},handles:{...this.symbols.handles,default:this.symbols.handles.default.clone().set("outline.color",t)},rotator:{...this.symbols.rotator,default:this.symbols.rotator.default.clone().set("outline.color",t)},rotatorLine:this.symbols.rotatorLine.clone().set("color",t)};for(const e of this._vertexGraphics)e.symbol=e===this._hoveredGraphic?this.symbols.handles.hover:this.symbols.handles.default;this._backgroundGraphic.symbol=this.symbols.fill.default,this._rotateHandleGraphic.symbol=this._rotateHandleGraphic===this._hoveredGraphic?this.symbols.rotator.hover:this.symbols.rotator.default,this._rotateLineGraphic.symbol=this.symbols.rotatorLine}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach((t=>t.visible=!1))}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach(((e,i)=>{const[s,o]=t[i];this._updateXY(e,s,o)}))}_updateBackgroundGraphic(){const t=this._getCoordinates();this._backgroundGraphic.geometry=new T({rings:t,spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,s]=this._getBoxBounds(p()),o=(i+t)/2,r=(s+e)/2;this._centerGraphic.geometry=new j(o,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new j(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new E({paths:[[t.x,t.y],[e.x,e.y]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new j(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new j(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new j(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some((t=>null!=t?.geometry&&"extent"===t.geometry.type))}_getBoxBounds(t){const e=this.graphics.map((t=>t.geometry));return this._getBounds(t,e)}_getCoordinates(t){const[e,i,s,o]=this._getBoxBounds(p());if(t){const t=(e+s)/2,r=(o+i)/2;return[[e,o],[t,o],[s,o],[s,r],[s,i],[t,i],[e,i],[e,r]]}return[[e,o],[s,o],[s,i],[e,i]]}_updateTooltip(t,e){if(null==this.tooltip)return;if(!t)return void this.tooltip.clear();const{_backgroundGraphic:i,graphics:s,_vertexGraphics:o,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():o.includes(t)?this._updateScaleTooltip():(s.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this.tooltip&&(this.tooltip.info=new I({sketchOptions:this.sketchOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{tooltip:t,_xScale:e,_yScale:i,sketchOptions:s,view:o}=this;if(null==t)return;const r=o.spatialReference,a=this._getCoordinates(),h=new j(a[0][0],a[0][1],r),c=new j(a[1][0],a[1][1],r),n=new j(a[2][0],a[2][1],r),l=O(h,c),p=O(c,n);if(null==l||null==p)return;const _=Math.abs(e),d=Math.abs(i);t.info=new M({sketchOptions:s,xScale:_,yScale:d,xSize:l,ySize:p})}_updateMoveTooltip(t){const{tooltip:e,sketchOptions:i,view:s}=this;if(null==e)return;const r=new H({sketchOptions:i});if(t){const{x:e,y:i}=t.origin,a=s.toMap(t),h=s.toMap({x:e,y:i}),c=O(h,a);r.distance=null!=c?c:o}e.info=r}};t([n()],V.prototype,"tooltip",void 0),t([n({readOnly:!0})],V.prototype,"type",void 0),t([n()],V.prototype,"callbacks",void 0),t([n()],V.prototype,"enableMovement",void 0),t([n()],V.prototype,"enableRotation",void 0),t([n()],V.prototype,"enableScaling",void 0),t([n()],V.prototype,"graphics",void 0),t([n()],V.prototype,"highlightsEnabled",void 0),t([n()],V.prototype,"layer",void 0),t([n()],V.prototype,"preserveAspectRatio",void 0),t([n()],V.prototype,"showCenterGraphic",void 0),t([n({readOnly:!0})],V.prototype,"state",null),t([n()],V.prototype,"symbols",void 0),t([n({type:R})],V.prototype,"sketchOptions",void 0),t([n({constructOnly:!0})],V.prototype,"view",void 0),V=t([l("esri.views.draw.support.Box")],V);const q=V;export{q as default};
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../Graphic.js";import i from"../../../core/Evented.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{zeroMeters as o}from"../../../core/quantityUtils.js";import{when as r,watch as a,syncAndInitial as h,initial as c}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{create as p}from"../../../geometry/support/aaBoundingRect.js";import{getRingsOrPathsBounds as _}from"../../../geometry/support/boundsUtils.js";import{geometryToCoordinates as d}from"../../../geometry/support/coordsUtils.js";import m from"../../../geometry/support/rotate.js";import u from"../../../symbols/SimpleFillSymbol.js";import g from"../../../symbols/SimpleLineSymbol.js";import v from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as y,scale as f,getRotationAngle as G,getScaleRatio as b}from"./drawUtils.js";import w from"./GraphicMover.js";import x from"./HighlightHelper.js";import{addUniqueLayer as S}from"./layerUtils.js";import{settings as k}from"./settings.js";import R from"../../interactive/sketch/SketchOptions.js";import{ExtentRotateTooltipInfo as M,ExtentScaleTooltipInfo as H}from"../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as I}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as C}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoDistanceBetweenPoints2D as O}from"../../support/automaticLengthMeasurementUtils.js";import{autoSize2D as j}from"../../support/extentUtils.js";import T from"../../../geometry/Point.js";import E from"../../../geometry/Polygon.js";import L from"../../../geometry/Polyline.js";class z{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-start"}}class P{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move"}}class B{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-stop"}}class Y{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-start"}}class N{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate"}}class U{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-stop"}}class A{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-start"}}class X{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale"}}class F{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-stop"}}const D=k.transformGraphics,V={centerIndicator:new v({style:"cross",size:D.center.size,color:D.center.color}),fill:{default:new u({color:D.fill.color,outline:{color:D.fill.outlineColor,join:"round",width:1}}),active:new u({color:D.fill.stagedColor,outline:{color:D.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new v({style:"square",size:D.vertex.size,color:D.vertex.color,outline:{color:D.vertex.outlineColor,width:1}}),hover:new v({style:"square",size:D.vertex.hoverSize,color:D.vertex.hoverColor,outline:{color:D.vertex.hoverOutlineColor,width:1}})},rotator:{default:new v({style:"circle",size:D.vertex.size,color:D.vertex.color,outline:{color:D.vertex.outlineColor,width:1}}),hover:new v({style:"circle",size:D.vertex.hoverSize,color:D.vertex.hoverColor,outline:{color:D.vertex.hoverOutlineColor,width:1}})},rotatorLine:new g({color:D.line.color,width:1})};let q=class extends i.EventedAccessor{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.tooltip=null,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=V,this.sketchOptions=new R,this.view=null,this._getBounds=(()=>{const t=p();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const s of i){if(!s)continue;let i,o,r,a;if("point"===s.type)i=r=s.x,o=a=s.y;else if("multipoint"===s.type){const e=d(s);[i,o,r,a]=_(t,[e])}else if("extent"===s.type)[i,o,r,a]=[s.xmin,s.ymin,s.xmax,s.ymax];else{const e=d(s);[i,o,r,a]=_(t,e)}e[0]=Math.min(i,e[0]),e[1]=Math.min(o,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})()}initialize(){const t=this.view;this._highlightHelper=new x({view:t}),this.tooltip=new I({view:t}),this._setup(),this.addHandles([r((()=>t?.ready),(()=>{const{layer:t,view:e}=this;S(e,t)}),{once:!0,initial:!0}),a((()=>this.preserveAspectRatio),(()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))})),a((()=>t?.scale),(()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()})),a((()=>this.graphics),(()=>this.refresh())),a((()=>this.layer),((t,e)=>{e&&this._resetGraphics(e),this.refresh()})),a((()=>this.highlightsEnabled),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()})),a((()=>this.sketchOptions.tooltips.effectiveEnabled),(t=>{this.tooltip=t?new I({view:this.view}):s(this.tooltip)}),h),a((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),c),this.on("move-start",(t=>this.callbacks?.onMoveStart?.(t))),this.on("move",(t=>this.callbacks?.onMove?.(t))),this.on("move-stop",(t=>this.callbacks?.onMoveStop?.(t))),this.on("rotate-start",(t=>this.callbacks?.onRotateStart?.(t))),this.on("rotate",(t=>this.callbacks?.onRotate?.(t))),this.on("rotate-stop",(t=>this.callbacks?.onRotateStop?.(t))),this.on("scale-start",(t=>this.callbacks?.onScaleStart?.(t))),this.on("scale",(t=>this.callbacks?.onScale?.(t))),this.on("scale-stop",(t=>this.callbacks?.onScaleStop?.(t)))])}destroy(){this._reset(),this.tooltip=s(this.tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=y(s,t,e,this.view);i.geometry=o}this.refresh(),this.emit("move-stop",new B(this.graphics,null,t,e))}}scale(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=f(s,t,e);i.geometry=o}this.refresh(),this.emit("scale-stop",new F(this.graphics,null,t,e))}}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new T(t,i,this.view.spatialReference)}for(const i of this.graphics){const s=i.geometry,o=m(s,t,e);i.geometry=o}this.refresh(),this.emit("rotate-stop",new U(this.graphics,null,t))}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics.forEach((t=>!t.destroyed&&t.destroy())),!this._backgroundGraphic.destroyed&&this._backgroundGraphic.destroy(),!this._centerGraphic.destroyed&&this._centerGraphic.destroy(),!this._rotateHandleGraphic.destroyed&&this._rotateHandleGraphic.destroy(),!this._rotateLineGraphic.destroyed&&this._rotateLineGraphic.destroy(),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_getStartInfo(t){const[e,i,s,o]=this._getBoxBounds(p()),r=Math.abs(s-e),a=Math.abs(o-i),h=(s+e)/2,c=(o+i)/2,{x:n,y:l}=t.geometry;return{width:r,height:a,centerX:h,centerY:c,startX:n,startY:l,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map((t=>this._getGraphicInfo(t)))}_getGraphicInfo(t){const e=t.geometry,[i,s,o,r]=this._getBounds(p(),[e]);return{width:Math.abs(o-i),height:Math.abs(r-s),centerX:(o+i)/2,centerY:(r+s)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:s,_backgroundGraphic:o,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h}=this,c=t.graphic;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),o.symbol=h.fill.active,this._startInfo=this._getStartInfo(c),this._updateTooltip(c,t.viewEvent),c===a?(this.view.cursor="grabbing",this.emit("rotate-start",new Y(this.graphics,c,e))):r.includes(c)?(this._activeHandleGraphic=c,this.emit("scale-start",new A(this.graphics,c,i,s))):this.emit("move-start",new z(this.graphics,c,t.dx,t.dy))}_onGraphicMoveCallback(t){const e=t.graphic;if(this._startInfo)if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",new X(this.graphics,e,this._xScale,this._yScale));else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",new N(this.graphics,e,this._angleOfRotation));else{const{dx:i,dy:s}=t;this._totalDx+=i,this._totalDy+=s,this._moveGraphic(e,i,s),this._updateTooltip(e,t.viewEvent),this.emit("move",new P(this.graphics,e,i,s))}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:s,_totalDy:o,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:c}=this;this.refresh(),e===c?(this.view.cursor="pointer",this.emit("rotate-stop",new U(this.graphics,e,i))):h.includes(e)?this.emit("scale-stop",new F(this.graphics,e,r,a)):this.emit("move-stop",new B(this.graphics,e,s,o))}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:s,_rotateHandleGraphic:o,symbols:r,view:a}=this,h=t.graphic;if(this._hoveredGraphic=h,h===o)return o.symbol=r.rotator.hover,a.cursor="pointer",void this._updateTooltip(h);if(s.includes(h)||h===e)return void(a.cursor="move");if(!i.includes(h))return void(a.cursor="pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const c=a.rotation;let n,l=t.index;switch(l<8&&(c>=0&&c<45?l%=8:l=c>=45&&c<90?(l+1)%8:c>=90&&c<135?(l+2)%8:c>=135&&c<180?(l+3)%8:c>=180&&c<225?(l+4)%8:c>=225&&c<270?(l+5)%8:c>=270&&c<315?(l+6)%8:(l+7)%8),l){case 0:case 4:n="nwse-resize";break;case 1:case 5:n="ns-resize";break;case 2:case 6:n="nesw-resize";break;case 3:case 7:n="ew-resize";break;default:n="pointer"}a.cursor=n}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:s,view:o}=this;this._hoveredGraphic=null,t.graphic===i?i.symbol=s.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=s.handles.default),o.cursor="default",this._updateTooltip()}_toPrecision(t,e=2){return Number.parseFloat(t.toFixed(e))}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:s,view:o}=this,{centerX:r,centerY:a,graphicInfos:h,height:c,startX:n,startY:l,width:p}=e,{resolution:_,transform:d}=o.state,m=i.indexOf(t);1!==m&&5!==m||this._updateX(t,r),3!==m&&7!==m||this._updateY(t,a);const{x:u,y:g}=t.geometry,v=d[0]*u+d[2]*g+d[4],G=d[1]*u+d[3]*g+d[5],w=h?.map((t=>t.geometry))??[],x=w.every((t=>"point"===t.type));if((0===p||0===c)&&x){const t=this._toPrecision((u-n)/_),i=this._toPrecision((l-g)/_);for(let e=0;e<w.length;e++)this.graphics[e].geometry=y(w[e],t,i,o,!0);return this._centerGraphic.geometry=new T(u,g,o.spatialReference),void(this._backgroundGraphic.geometry=y(e.box,t,i,o,!0))}if(s){const t=this._toPrecision(d[0]*r+d[2]*a+d[4],2),e=this._toPrecision(d[1]*r+d[3]*a+d[5],2),i=this._toPrecision(d[0]*n+d[2]*l+d[4],2),s=this._toPrecision(d[1]*n+d[3]*l+d[5],2);let o=b(t,e,i,s,v,G);0!==o&&Math.abs(o)!==1/0||(o=1),this._xScale=this._yScale=o;for(const h of w){const t=w.indexOf(h);this.graphics[t].geometry=f(h,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{let t=u-n,i=l-g;if(1===m||5===m?t=0:3!==m&&7!==m||(i=0),0===t&&0===i)return;const s=r+t/2,h=a+i/2;let d=(p+(n>r?t:-1*t))/p,v=(c+(l<a?i:-1*i))/c;1!==m&&5!==m&&0!==d&&Math.abs(d)!==1/0||(d=1),3!==m&&7!==m&&0!==v&&Math.abs(v)!==1/0||(v=1),this._xScale=d,this._yScale=v;const G=(s-r)/_,b=(h-a)/_,x=f(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=y(x,G,b,o,!0);const{centerX:S,centerY:k}=this._getGraphicInfo(this._backgroundGraphic),R=(S-r)/_,M=-1*(k-a)/_;for(const e of w){const t=w.indexOf(e),i=f(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=y(i,R,M,o,!0)}this._centerGraphic.geometry=new T(S,k,o.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:s,startY:o,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,c=new T(s,o,h),n=new T(e,i,h),l=t.geometry;this._angleOfRotation=G(c,l,n);const p=this._startInfo.graphicInfos?.map((t=>t.geometry))??[];for(const _ of p){const t=p.indexOf(_),e=m(_,this._angleOfRotation,n);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=m(r,this._angleOfRotation,n),this._rotateHandleGraphic.geometry=m(a,this._angleOfRotation,n)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const s=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=y(s,e,i,this.view);for(const o of this.graphics)o!==t&&(o.geometry=y(o.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=y(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const s of this.graphics)s.geometry=y(s.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e(null,i.centerIndicator,t),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e(null,i.fill.default,t),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e(null,i.rotatorLine,t),this._rotateHandleGraphic=new e(null,i.rotator.default,t),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let s=0;s<8;s++)this._vertexGraphics.push(new e(null,i.handles.default,t));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={...this.symbols,fill:{active:this.symbols.fill.active?.clone().set("outline.color",t),default:this.symbols.fill.default?.clone().set("outline.color",t)},handles:{...this.symbols.handles,default:this.symbols.handles.default.clone().set("outline.color",t)},rotator:{...this.symbols.rotator,default:this.symbols.rotator.default.clone().set("outline.color",t)},rotatorLine:this.symbols.rotatorLine.clone().set("color",t)};for(const e of this._vertexGraphics)e.symbol=e===this._hoveredGraphic?this.symbols.handles.hover:this.symbols.handles.default;this._backgroundGraphic.symbol=this.symbols.fill.default,this._rotateHandleGraphic.symbol=this._rotateHandleGraphic===this._hoveredGraphic?this.symbols.rotator.hover:this.symbols.rotator.default,this._rotateLineGraphic.symbol=this.symbols.rotatorLine}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach((t=>t.visible=!1))}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach(((e,i)=>{const[s,o]=t[i];this._updateXY(e,s,o)}))}_updateBackgroundGraphic(){const t=this._getCoordinates();this._backgroundGraphic.geometry=new E({rings:t,spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,s]=this._getBoxBounds(p()),o=(i+t)/2,r=(s+e)/2;this._centerGraphic.geometry=new T(o,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new T(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new L({paths:[[t.x,t.y],[e.x,e.y]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new T(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new T(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new T(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some((t=>null!=t?.geometry&&"extent"===t.geometry.type))}_getBoxBounds(t){const e=this.graphics.map((t=>t.geometry));return this._getBounds(t,e)}_getCoordinates(t){const[e,i,s,o]=this._getBoxBounds(p());if(t){const t=(e+s)/2,r=(o+i)/2;return[[e,o],[t,o],[s,o],[s,r],[s,i],[t,i],[e,i],[e,r]]}return[[e,o],[s,o],[s,i],[e,i]]}_updateTooltip(t,e){if(null==this.tooltip)return;if(!t)return void this.tooltip.clear();const{_backgroundGraphic:i,graphics:s,_vertexGraphics:o,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():o.includes(t)?this._updateScaleTooltip():(s.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this.tooltip&&(this.tooltip.info=new M({sketchOptions:this.sketchOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{tooltip:t,_xScale:e,_yScale:i,sketchOptions:s,view:o}=this;if(null==t)return;const r=this._getCoordinates(),a=j({topLeft:r[0],topRight:r[1],bottomRight:r[2],bottomLeft:r[3],spatialReference:o.spatialReference});if(null==a)return;const{xSize:h,ySize:c}=a,n=Math.abs(e),l=Math.abs(i);t.info=new H({sketchOptions:s,xScale:n,yScale:l,xSize:h,ySize:c})}_updateMoveTooltip(t){const{tooltip:e,sketchOptions:i,view:s}=this;if(null==e)return;const r=new C({sketchOptions:i});if(t){const{x:e,y:i}=t.origin,a=s.toMap(t),h=s.toMap({x:e,y:i}),c=O(h,a);r.distance=null!=c?c:o}e.info=r}};t([n()],q.prototype,"tooltip",void 0),t([n({readOnly:!0})],q.prototype,"type",void 0),t([n()],q.prototype,"callbacks",void 0),t([n()],q.prototype,"enableMovement",void 0),t([n()],q.prototype,"enableRotation",void 0),t([n()],q.prototype,"enableScaling",void 0),t([n()],q.prototype,"graphics",void 0),t([n()],q.prototype,"highlightsEnabled",void 0),t([n()],q.prototype,"layer",void 0),t([n()],q.prototype,"preserveAspectRatio",void 0),t([n()],q.prototype,"showCenterGraphic",void 0),t([n({readOnly:!0})],q.prototype,"state",null),t([n()],q.prototype,"symbols",void 0),t([n({type:R})],q.prototype,"sketchOptions",void 0),t([n({constructOnly:!0})],q.prototype,"view",void 0),q=t([l("esri.views.draw.support.Box")],q);const J=q;export{J 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import{watch as e}from"../../../../core/reactiveUtils.js";import{waitAnimationFrame as i}from"../../../../core/scheduling.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{tooltipKeys as s}from"../../keybindings.js";import{base as l}from"../css.js";import a from"../../../../widgets/Widget.js";import{loadCalciteComponents as c}from"../../../../widgets/support/componentsUtils.js";import"../../../../widgets/support/widgetUtils.js";import{tsx as r}from"../../../../widgets/support/jsxFactory.js";const u=`${l}-editable-field`,p={base:u,inputMode:`${u}--input`,locked:`${u}--locked`,title:`${u}__title`,titleContent:`${u}__title__content`,value:`${u}__value`,valueContent:`${u}__value__content`,valueContentReadOnly:`${u}__value__content--read-only`,input:`${u}__input`,inputSuffix:`${u}__input-suffix`,button:`${u}__button`};let d=class extends a{constructor(){super(...arguments),this._input=null,this._selectText=()=>{const t=()=>{this._input===document.activeElement&&this._input?.selectText()};t(),i().then(t)},this._onKeyDown=t=>{t.key===s.discard&&this._discard()},this._onInputKeyDown=t=>{switch(t.key){case s.commit:return this._commit({type:"commit-and-exit",allowLockingCurrentValue:!0});case s.next:return t.preventDefault(),t.stopPropagation(),this._commit({type:t.shiftKey?"commit-and-previous":"commit-and-next",allowLockingCurrentValue:!1})}},this._onInput=t=>{this.field.inputValue=t.target.value},this._onLockClick=()=>{const{field:t}=this;t.locked?t.unlock():this._lock()}}initialize(){this.addHandles(e((()=>this._rawDisplayValue),(()=>{const{committed:t,inputValue:e}=this.field;t||e||this._input!==document.activeElement||this._selectText()})))}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js")})}render(){const{mode:t,field:e}=this,i="input"===t,{locked:n}=e;return r("div",{class:this.classes({[p.base]:!0,[p.inputMode]:"input"===t,[p.locked]:n})},r("div",{class:p.title,key:"title"},r("div",{class:p.titleContent,key:"title-content"},this._title,n&&!i?r("calcite-icon",{icon:"lock",key:"icon",scale:"s"}):null)),r("div",{class:p.value,key:"value"},i?this._renderInputModeValue():this._renderFeedbackModeValue()))}get _initialValue(){const{field:t}=this;return null!=t.actual?t.toInputUnits(t.actual,this.context).value:null}get _formattedValue(){const{context:t,field:e}=this,{actual:i,format:
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import{watch as e}from"../../../../core/reactiveUtils.js";import{waitAnimationFrame as i}from"../../../../core/scheduling.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{tooltipKeys as s}from"../../keybindings.js";import{base as l}from"../css.js";import a from"../../../../widgets/Widget.js";import{loadCalciteComponents as c}from"../../../../widgets/support/componentsUtils.js";import"../../../../widgets/support/widgetUtils.js";import{tsx as r}from"../../../../widgets/support/jsxFactory.js";const u=`${l}-editable-field`,p={base:u,inputMode:`${u}--input`,locked:`${u}--locked`,title:`${u}__title`,titleContent:`${u}__title__content`,value:`${u}__value`,valueContent:`${u}__value__content`,valueContentReadOnly:`${u}__value__content--read-only`,input:`${u}__input`,inputSuffix:`${u}__input-suffix`,button:`${u}__button`};let d=class extends a{constructor(){super(...arguments),this._input=null,this._selectText=()=>{const t=()=>{this._input===document.activeElement&&this._input?.selectText()};t(),i().then(t)},this._onKeyDown=t=>{t.key===s.discard&&this._discard()},this._onInputKeyDown=t=>{switch(t.key){case s.commit:return this._commit({type:"commit-and-exit",allowLockingCurrentValue:!0});case s.next:return t.preventDefault(),t.stopPropagation(),this._commit({type:t.shiftKey?"commit-and-previous":"commit-and-next",allowLockingCurrentValue:!1})}},this._onInput=t=>{this.field.inputValue=t.target.value},this._onLockClick=()=>{const{field:t}=this;t.locked?t.unlock():this._lock()}}initialize(){this.addHandles(e((()=>this._rawDisplayValue),(()=>{const{committed:t,inputValue:e}=this.field;t||e||this._input!==document.activeElement||this._selectText()})))}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js")})}render(){const{mode:t,field:e}=this,i="input"===t,{locked:n}=e;return r("div",{class:this.classes({[p.base]:!0,[p.inputMode]:"input"===t,[p.locked]:n})},r("div",{class:p.title,key:"title"},r("div",{class:p.titleContent,key:"title-content"},this._title,n&&!i?r("calcite-icon",{icon:"lock",key:"icon",scale:"s"}):null)),r("div",{class:p.value,key:"value"},i?this._renderInputModeValue():this._renderFeedbackModeValue()))}get _initialValue(){const{field:t}=this;return null!=t.actual?t.toInputUnits(t.actual,this.context).value:null}get _formattedValue(){const{context:t,field:e}=this,{actual:i,committed:n,format:o}=e;return null!=n?o(n,t):null!=i?o(i,t):_}get _rawDisplayValue(){const{field:t}=this,{inputValue:e,committed:i}=t;return null!=e?e:this._toString(null!=i?t.toInputUnits(i,this.context).value:this._initialValue)}get _suffix(){const{suffix:t}=this.field;return"string"==typeof t?t:t(this.context)}get _title(){const{title:t}=this.field;return"string"==typeof t?t:t(this.context)}_renderFeedbackModeValue(){return r("span",{key:"value-feedback"},this._formattedValue)}_renderInputModeValue(){return this.field.readOnly?this._renderValueReadOnly():this._renderValueWritable()}_renderValueReadOnly(){return r("span",{class:p.valueContentReadOnly,key:"value-readonly"},this._formattedValue)}_renderValueWritable(){const{locked:t,name:e}=this.field,i=this.context?.messages.sketch??{},n=t?i.unlockConstraint:i.lockConstraint;return r("div",{class:p.valueContent,key:"value-writable",onkeydown:this._onKeyDown},r("calcite-input",{afterCreate:t=>{this._input=t},class:p.input,"data-field-name":e,onfocus:this._selectText,onkeydown:this._onInputKeyDown,scale:"s",type:"text",value:this._rawDisplayValue,onCalciteInputInput:this._onInput}),r("div",{class:p.inputSuffix,key:"suffix"},this._suffix),r("calcite-action",{alignment:"center",appearance:"transparent",class:p.button,compact:!0,icon:t?"lock":"unlock",label:n,onclick:this._onLockClick,scale:"s",tabIndex:-1,text:"",title:n}))}_commit({type:t,allowLockingCurrentValue:e}){const{_input:i,field:n}=this;if(!i)return;const{locked:o,inputValue:s}=n;o&&""===s?n.unlock():(e&&!o||null!=s)&&this._lock(),this.context.onCommit(i,t)}_discard(){this._input&&(this.field.inputValue=null,this.context.onDiscard(this._input))}_lock(){const{field:t}=this,e=this._parseNumber(t.inputValue),i=null!=e?t.createQuantity(e,this.context):null;t.lock(i)}_parseNumber(t){if(null==t)return null;const e=parseFloat(t);return isNaN(e)||!isFinite(e)?null:e}_toString(t){return null!=t?t.toFixed(2):_}};t([n()],d.prototype,"field",void 0),t([n()],d.prototype,"context",void 0),t([n()],d.prototype,"mode",void 0),t([n()],d.prototype,"_initialValue",null),t([n()],d.prototype,"_formattedValue",null),t([n()],d.prototype,"_input",void 0),t([n()],d.prototype,"_rawDisplayValue",null),t([n()],d.prototype,"_suffix",null),t([n()],d.prototype,"_title",null),d=t([o("esri.views.interactive.tooltip.components.TooltipEditableField")],d);const _="—";export{d as TooltipEditableField};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{euclideanHorizontalLength as
|
|
5
|
+
import{create as e}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{euclideanHorizontalLength as t,euclideanHorizontalDistanceBetweenPoints as r,euclideanHorizontalDistance as n}from"./euclideanLengthMeasurementUtils.js";import{geodesicLength as o,geodesicDistanceBetweenPoints as i,geodesicDistance as s}from"./geodesicLengthMeasurementUtils.js";function c(e){return o(e)??t(e)}function m(e,t){return i(e,t)??r(e,t)}function u(e,t,r){return f[0]=e[0],f[1]=e[1],f[2]=3===e.length?e[2]:0,l[0]=t[0],l[1]=t[1],l[2]=3===t.length?t[2]:0,s(f,l,r)??n(f,l,r)}const f=e(),l=e();export{u as autoDistance2D,m as autoDistanceBetweenPoints2D,c as autoLength2D};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{max as t}from"../../core/quantityUtils.js";import{autoDistance2D as e}from"./automaticLengthMeasurementUtils.js";function o({topLeft:o,topRight:n,bottomRight:i,bottomLeft:r,spatialReference:l}){const u=t(e(r,i,l),e(o,n,l));if(null==u)return null;const m=t(e(i,n,l),e(r,o,l));return null==m?null:{xSize:u,ySize:m}}export{o as autoSize2D};
|