@arcgis/core 4.27.0-next.20230521 → 4.27.0-next.20230522
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/Graphic.js +1 -1
- package/arcade/featureset/actions/SpatialFilter.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
- package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0d02856e55d20b99fc8b.js +1 -0
- package/assets/esri/core/workers/chunks/{69242c66492717c7388c.js → 0fcb8d408696075338e2.js} +1 -1
- package/assets/esri/core/workers/chunks/{1edc5c06874cb12c5478.js → 17f313e548281bb5db3e.js} +1 -1
- package/assets/esri/core/workers/chunks/{b91c155de9a89e4e6971.js → 187c3b971ed0fc4363ef.js} +1 -1
- package/assets/esri/core/workers/chunks/{85c6ce93aa41e6b65997.js → 18db07d739a713cc0465.js} +1 -1
- package/assets/esri/core/workers/chunks/28286014a575042619ee.js +1 -0
- package/assets/esri/core/workers/chunks/{692dfeb2e255fdc0ade2.js → 39288fa69561d21f04f8.js} +1 -1
- package/assets/esri/core/workers/chunks/{2b9d3e60977934a6d471.js → 3bc6b5f0643364749ef8.js} +1 -1
- package/assets/esri/core/workers/chunks/45e5ad704d18dd0857ce.js +1 -0
- package/assets/esri/core/workers/chunks/{62d9d15f0d00a75da42c.js → 4670b17ae2ed3c13d344.js} +1 -1
- package/assets/esri/core/workers/chunks/4d24efa01d1accc5a5f0.js +1 -0
- package/assets/esri/core/workers/chunks/52575f021a14dd961de8.js +1 -0
- package/assets/esri/core/workers/chunks/{6312783626bacf52df7a.js → 55486c644e8b01326a0d.js} +1 -1
- package/assets/esri/core/workers/chunks/5576858f56314afcb4d5.js +1 -0
- package/assets/esri/core/workers/chunks/5a4c04bf4f57e74457c5.js +1 -0
- package/assets/esri/core/workers/chunks/70d6e5edf05ef7079fa8.js +1 -0
- package/assets/esri/core/workers/chunks/71bdf8f10aee0077f681.js +1 -0
- package/assets/esri/core/workers/chunks/72b2c3c8e76da699690c.js +1 -0
- package/assets/esri/core/workers/chunks/78ce0b1af62435d8ebf4.js +1 -0
- package/assets/esri/core/workers/chunks/791f529e90135398b3d5.js +1 -0
- package/assets/esri/core/workers/chunks/8d3abfe6fdc5ac8d6cb7.js +1 -0
- package/assets/esri/core/workers/chunks/96d339abcd917f1f0ae1.js +1 -0
- package/assets/esri/core/workers/chunks/97cdbec7532cfcdf9ad2.js +1 -0
- package/assets/esri/core/workers/chunks/{f3f6035a17f7dcd19675.js → 9ab400a89dd701778d2c.js} +1 -1
- package/assets/esri/core/workers/chunks/{1488b3d48232844b8bb4.js → 9fe349f43d5ff5a4ac2d.js} +1 -1
- package/assets/esri/core/workers/chunks/{22396dd3717d17a5d235.js → a1c31bb8c12831539328.js} +1 -1
- package/assets/esri/core/workers/chunks/b4e2dc6b3d06b426e596.js +1 -0
- package/assets/esri/core/workers/chunks/{48abcb2d88f22e6e9fde.js → c2cb9fa18c77f0c5104e.js} +1 -1
- package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +1 -0
- package/assets/esri/core/workers/chunks/d725dbbdeb05322e6d88.js +1 -0
- package/assets/esri/core/workers/chunks/df3e497d12ed77bae168.js +1 -0
- package/assets/esri/core/workers/chunks/{4d5f71d84c85f45c97ea.js → ed6f6e539a915ba9e64d.js} +1 -1
- package/assets/esri/core/workers/chunks/fb080339bfaf32731ca6.js +1 -0
- package/assets/esri/themes/base/_core.scss +2 -0
- package/assets/esri/themes/base/widgets/_FloorFilter.scss +6 -0
- package/assets/esri/themes/base/widgets/_UtilityNetworkValidateTopology.scss +40 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_nb.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_en.json +1 -1
- package/chunks/mat4.js +1 -1
- package/core/accessorSupport/write.js +1 -1
- package/core/fontUtils.js +1 -1
- package/core/libs/gl-matrix-2/math/mat4.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/MeshGeoreferencedRelativeVertexSpace.d.ts +4 -0
- package/geometry/support/MeshGeoreferencedRelativeVertexSpace.js +5 -0
- package/geometry/support/MeshGeoreferencedVertexSpace.d.ts +4 -0
- package/geometry/support/MeshGeoreferencedVertexSpace.js +5 -0
- package/geometry/support/MeshLocalVertexSpace.d.ts +4 -0
- package/geometry/support/MeshLocalVertexSpace.js +5 -0
- package/geometry/support/MeshTransform.d.ts +4 -0
- package/geometry/support/MeshTransform.js +1 -1
- package/geometry/support/meshUtils/ElevationSamplerWorker.js +1 -1
- package/geometry/support/meshUtils/centerAt.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/meshUtils/geographicUtils.js +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/geometry/support/meshUtils/offset.js +1 -1
- package/geometry/support/meshUtils/primitives.js +1 -1
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/geometry/support/meshUtils/scale.js +1 -1
- package/interfaces.d.ts +227 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/graphics/data/attributeSupport.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/networks/support/TopologyValidationJobInfo.js +1 -1
- package/package.json +1 -1
- package/popup/FieldInfo.js +1 -1
- package/portal/Portal.js +1 -1
- package/rest/support/FeatureSet.js +1 -1
- package/rest/support/meshFeatureSet.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/meshFastUpdateUtils.js +1 -1
- package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateMeshAdapter.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/undoRecords.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/DisplayQualityProfile.js +1 -1
- package/views/3d/support/QualitySettings.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
- package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/interactive/dragEventPipeline.js +1 -1
- package/widgets/BasemapGallery/support/PortalBasemapsSource.js +1 -1
- package/widgets/Editor/Edits.js +1 -1
- package/widgets/Editor/Upload.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +5 -0
- package/widgets/UtilityNetworkValidateTopology.js +5 -0
- package/assets/esri/core/workers/chunks/163bf2e13abbdd298374.js +0 -1
- package/assets/esri/core/workers/chunks/23f73f81aea461c0c6e6.js +0 -1
- package/assets/esri/core/workers/chunks/2640204c4655aa535ccb.js +0 -1
- package/assets/esri/core/workers/chunks/2bf42d060f877566b989.js +0 -1
- package/assets/esri/core/workers/chunks/34ec9623a1bece86a82b.js +0 -1
- package/assets/esri/core/workers/chunks/3bf52139340827794c3b.js +0 -1
- package/assets/esri/core/workers/chunks/52d02021e858820bc4fa.js +0 -1
- package/assets/esri/core/workers/chunks/64b8f65e2ef6cbf08380.js +0 -1
- package/assets/esri/core/workers/chunks/78aede1e114deefacb54.js +0 -1
- package/assets/esri/core/workers/chunks/7ef100158ca28631fcaf.js +0 -1
- package/assets/esri/core/workers/chunks/93ad67930aa7d4a4b0ac.js +0 -1
- package/assets/esri/core/workers/chunks/964795dfb57f0d0635d0.js +0 -1
- package/assets/esri/core/workers/chunks/99ce0a202dcd3d7dc290.js +0 -1
- package/assets/esri/core/workers/chunks/abe6c99a1a719543dbe8.js +0 -1
- package/assets/esri/core/workers/chunks/c3bf44146fddfe8990f7.js +0 -1
- package/assets/esri/core/workers/chunks/cbe817e966b57599bafd.js +0 -1
- package/assets/esri/core/workers/chunks/e15b5d7e46a834eacc57.js +0 -1
- package/assets/esri/core/workers/chunks/e1e0b3580e2c3098c9f4.js +0 -1
- package/assets/esri/core/workers/chunks/e305d20e4424451cab5b.js +0 -1
- package/assets/esri/core/workers/chunks/e6836c84470fb6bd25bf.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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../../chunks/tslib.es6.js";import i from"../../../../../core/Collection.js";import e from"../../../../../core/Evented.js";import{HandleOwnerMixin as o}from"../../../../../core/HandleOwner.js";import{makeHandle as a}from"../../../../../core/handleUtils.js";import{destroyMaybe as n}from"../../../../../core/maybe.js";import{scale as s,zeroMeters as r}from"../../../../../core/quantityUtils.js";import{watch as p,when as l,syncAndInitial as h}from"../../../../../core/reactiveUtils.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as u}from"../../../../../core/accessorSupport/decorators/subclass.js";import{makeDehydratedPoint as m}from"../../../../../layers/graphics/dehydratedFeatures.js";import{getGraphicEffectiveElevationInfo as d,getConvertedElevation as g}from"../../../../../support/elevationInfoUtils.js";import{getGraphicAttachmentOrigin as v}from"../../manipulatorUtils.js";import{SnappingVisualizer3D as f}from"../../SnappingVisualizer3D.js";import{SupportedGraphicResult as M}from"../isSupportedGraphicUtils.js";import{canMoveZ as _}from"../manipulatorUtils.js";import{tryDisableMeshTransformFastUpdates as y,tryEnableMeshTransformFastUpdates as w}from"../meshFastUpdateUtils.js";import{createVisualElements as j}from"../visualElementUtils.js";import{DISC_RADIUS as b}from"../manipulations/config.js";import{ManipulationType as x,MoveManipulation as S}from"../manipulations/MoveManipulation.js";import{shapeOrientation as E,axisConstrainedDragSign as T}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as O}from"../manipulations/MoveXYGraphicManipulation.js";import{isSupportedGraphic as H}from"./isSupportedGraphic.js";import{OutlineVisualElement as U}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as D}from"../../../layers/graphics/GraphicState.js";import{dragGraphicMany as X,resetGraphicMany as G}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as A}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as Y}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import z from"../../../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as P}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as k}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{Tooltip as I}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as R,TranslateGraphicZTooltipInfo as F,TranslateGraphicXYTooltipInfo as Z}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as C}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as V}from"../../../../support/euclideanLengthMeasurementUtils.js";class L{constructor(t){this.allGraphics=t,this.type="graphic-move-start"}}class N{constructor(t,i,e){this.dx=t,this.dy=i,this.allGraphics=e,this.type="graphic-move"}}class q{constructor(t){this.allGraphics=t,this.type="graphic-move-stop"}}const B="manipulators";let J=class extends(o(e.EventedMixin(A))){constructor(t){super(t),this._infos=new Map,this.graphics=new i,this.enableZ=!0,this.tooltipOptions=new z,this.type="move-3d",this._moveManipulation=null,this._tooltip=null}initialize(){const{view:t}=this;this.addHandles([this.graphics.on("change",(t=>{t.removed.forEach((t=>this.removeHandles(t))),this._updateGraphicInfos(t),this._setupFastTransformUpdates(t.added),this._refreshManipulators()})),p((()=>this.tooltipOptions.enabled),(i=>{this._tooltip=i?new I({view:t}):n(this._tooltip)}),h)]);const i=this.graphics.toArray();this._updateGraphicInfos({added:i,removed:[]}),this._setupFastTransformUpdates(i),this._refreshManipulators(),this.finishToolCreation()}destroy(){this._tooltip=n(this._tooltip),this._moveManipulation=n(this._moveManipulation),this.removeAllHandles(),this.graphics.drain(y),this._set("view",null)}get updating(){return this.updatingHandles.updating}reset(){}_updateGraphicInfos({added:t,removed:i}){for(const e of t){if(H(e)!==M.SUPPORTED)continue;const t=new K(e),i=this.view.trackGraphicState(t.state);this._infos.set(t.graphic,{info:t,handle:i})}for(const e of i)this._infos.get(e)?.handle.remove(),this._infos.delete(e)}_setupFastTransformUpdates(t){for(const i of t){const{info:t}=this._infos.get(i);this.addHandles(l((()=>t.state.displaying),(()=>w(i)),{...h,once:!0}),i),this.addHandles(a((()=>y(i))),i)}}_refreshManipulators(){if(this.removeHandles(B),this._moveManipulation=n(this._moveManipulation),this.manipulators.removeAll(),0===this._infos.size)return;const t=Array.from(this._infos.values(),(({info:t})=>t));this._createManipulators(t),this._createVisualElements(t),this._updateMoveManipulation(t)}_createManipulators(t){for(const i of t){const e=i.state;i.manipulationXY=new O({tool:this,view:this.view,graphicState:e}),i.manipulationXY.forEachManipulator((t=>this.addHandles([t.events.on("immediate-click",(t=>{this.emit("immediate-click",{...t,graphic:e.graphic}),t.stopPropagation()})),t.events.on("grab-changed",(({action:t})=>{const{tooltipOptions:i,_tooltip:e}=this;null!=e&&("start"===t?e.info=new R({tooltipOptions:i}):e.clear())}))],B))),this.addHandles(i.manipulationXY.createDragPipeline(((i,e,o,a)=>this._buildDragEventPipeline(t,x.XY,i,e,o,a))),B)}this._createMoveManipulation(t)}_createMoveManipulation(t){const i=new S({tool:this,view:this.view,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:1===t.length?S.radiusForSymbol(t[0].graphic.symbol):b});this._moveManipulation=i,i.elevationInfo={mode:"absolute-height",offset:0},i.forEachManipulator((t=>{this.addHandles(t.events.on("immediate-click",(e=>{i.zManipulation.hasManipulator(t)||1!==this.graphics.length||this.emit("immediate-click",{...e,graphic:this.graphics.at(0)}),e.stopPropagation()})),B)}));const e=i=>e=>{this.addHandles(e.events.on("focus-changed",(({action:e})=>{const o=this._tooltip;null!=o&&("focus"===e?this._updateMoveTooltip(t,i):o.clear())})),B)};this._moveManipulation.xyManipulation.forEachManipulator(e(x.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(e(x.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(e(x.Z));const o=()=>this._updateMoveManipulation(t);for(const n of t)this.addHandles([n.state.on("changed",o),p((()=>n.state.displaying),o)],B);const a=t[t.length-1];this.addHandles(a.state.on("changed",(()=>this._updateMoveManipulationAngle(a))),B),this.addHandles(i.createDragPipeline(((i,e,o,a,n)=>this._buildDragEventPipeline(t,i,e,o,a,n)),d(a.graphic),a.graphic.geometry.spatialReference,a.graphic),B),this._updateMoveManipulationAngle(a)}_createVisualElements(t){for(const i of t){const e=i.graphic,o=j({view:this.view,graphic:e,forEachManipulator:t=>{i.manipulationXY?.forEachManipulator(t),this._moveManipulation?.forEachManipulator(t)},onManipulatorsChanged:()=>a()});null!=o&&(i.geometryRepresentation=o.visualElement,i.geometryRepresentation instanceof U&&this.addHandles([i.geometryRepresentation.events.on("attachment-origin-changed",(()=>{i.state.isDraped||this._updateMoveManipulation(t)})),p((()=>i.state.isDraped),(()=>this._updateMoveManipulation(t)))],B),this.addHandles(o,B))}}_updateMoveManipulationAngle(t){this._moveManipulation&&(this._moveManipulation.angle=E(t.graphic.geometry))}_updateMoveManipulation(t){const i=m(0,0,0,this.view.spatialReference);let e=0,o=!1;const a=this._moveManipulation;if(a){for(const a of t){if(!a.state.displaying)continue;const t=a.state.graphic;this.enableZ&&_(t)&&(o=!0);const n=a.geometryRepresentation instanceof U&&!a.state.isDraped?a.geometryRepresentation.attachmentOrigin:v(this.view,t);if(null!=n){const{x:t,y:o,z:a}=n;i.x+=t,i.y+=o,a&&(i.z??=0,i.z+=a),e++}}e>0?(i.x/=e,i.y/=e,i.z??=0,i.z/=e,a.location=i,a.xyManipulation.available=!0,a.xyAxisManipulation.available=!0,a.zManipulation.available=o):a.available=!1}}_buildDragEventPipeline(t,i,e,o,a,n){const s=[],r=[];let p=null,l=null;const h=()=>{for(const t of s)t.dragging=!1;s.length=0,r.length=0,p=null,l=null,this._moveManipulation&&(this._moveManipulation.interactive=!0)};if(1===t.length&&i===x.XY){const i=t[0].graphic;({steps:o,cancel:a}=this._buildSnappingPipelineSteps(i,d(i),o,a,n))}return a=a.next((t=>l?.(t))).next((()=>(this.emit("graphic-move-stop",new q(r)),this.destroyed||h(),null))),{steps:o=o.next((i=>{if("start"===i.action){s.length=0,r.length=0;for(const i of t)i.dragging||!i.manipulationXY?.hasManipulator(e)&&i.manipulationXY?.grabbing||(s.push(i),r.push(i.graphic),i.dragging=!0);if(0!==r.length&&(this._moveManipulation&&(this._moveManipulation.interactive=!1),p=X(r,this.view.state.viewingMode),l=G(r),this.emit("graphic-move-start",new L(r)),this.destroyed))return null}return 0!==r.length?i:null})).next((t=>p?.(t))).next((e=>(this._updateMoveTooltip(t,i,e),e))).next((t=>{switch(t.action){case"start":case"update":if(t.translationX||t.translationY||t.translationZ){const i=this.view.toScreen(t.mapStart),e=this.view.toScreen(t.mapEnd),o=e.x-i.x,a=e.y-i.y;if(this.emit("graphic-move",new N(o,a,r)),this.destroyed)return null}break;case"end":if(this.emit("graphic-move-stop",new q(r)),this.destroyed)return null;h()}return null})),cancel:a}}_updateMoveTooltip(t,i,e){const{tooltipOptions:o,_tooltip:a}=this;if(null==a)return;a.clear();const n=0===t.length?"absolute-height":t[0].state.isDraped?"on-the-ground":"absolute-height";switch(i){case x.XY:a.info=new R({tooltipOptions:o}),this._updateMoveTooltipDistance(a.info,e,((t,i)=>C(t,i,n)));break;case x.XY_AXIS:a.info=new Z({tooltipOptions:o}),this._updateMoveTooltipDistance(a.info,e,((t,i)=>{const o=C(t,i,n);return s(o,T(e))}));break;case x.Z:a.info=new F({tooltipOptions:o}),this._updateMoveTooltipDistance(a.info,e,V)}}_updateMoveTooltipDistance(t,i,e){if(null!=i&&"end"!==i.action){const{mapStart:o,mapEnd:a}=i,n=e(o,a);t.distance=null!=n?n:r}}_buildSnappingPipelineSteps(t,i,e,o,a){const n=t.geometry;if(null==n||"point"!==n.type&&"mesh"!==n.type)return{steps:e,cancel:o};const s=("point"===n.type?n:n.anchor).clone(),r=new P({elevationInfo:i,pointer:a,editGeometryOperations:Y.fromGeometry(s,this.view.state.viewingMode),visualizer:new f,excludeFeature:t}),p=this.snappingManager,{snappingStep:l,cancelSnapping:h}=k({snappingContext:r,snappingManager:p,updatingHandles:this.updatingHandles});return o=o.next(h),{steps:e=e.next((i=>{s.z=g(this.view,s,d(t),{mode:"absolute-height",offset:0});return{...i,snapOrigin:r.coordinateHelper.pointToVector(s)}})).next(...l),cancel:o}}get test(){return{tooltip:this._tooltip}}};t([c({constructOnly:!0,nonNullable:!0})],J.prototype,"view",void 0),t([c()],J.prototype,"graphics",void 0),t([c({constructOnly:!0,nonNullable:!0})],J.prototype,"enableZ",void 0),t([c({constructOnly:!0,type:z})],J.prototype,"tooltipOptions",void 0),t([c({constructOnly:!0})],J.prototype,"snappingManager",void 0),t([c()],J.prototype,"type",void 0),t([c()],J.prototype,"updating",null),J=t([u("esri.views.3d.interactive.editingTools.graphicMove3D.GraphicMoveTool")],J);class K{constructor(t){this.geometryRepresentation=null,this.manipulationXY=null,this.dragging=!1,this.state=new D({graphic:t})}get graphic(){return this.state.graphic}}export{N as GraphicMoveEvent,L as GraphicMoveStartEvent,q as GraphicMoveStopEvent,J as GraphicMoveTool};
|
|
5
|
+
import{_ as t}from"../../../../../chunks/tslib.es6.js";import i from"../../../../../core/Collection.js";import e from"../../../../../core/Evented.js";import{HandleOwnerMixin as o}from"../../../../../core/HandleOwner.js";import{makeHandle as a}from"../../../../../core/handleUtils.js";import{destroyMaybe as n}from"../../../../../core/maybe.js";import{scale as s,zeroMeters as r}from"../../../../../core/quantityUtils.js";import{watch as p,syncAndInitial as l}from"../../../../../core/reactiveUtils.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{makeDehydratedPoint as u}from"../../../../../layers/graphics/dehydratedFeatures.js";import{getGraphicEffectiveElevationInfo as m,getConvertedElevation as d}from"../../../../../support/elevationInfoUtils.js";import{getGraphicAttachmentOrigin as g}from"../../manipulatorUtils.js";import{SnappingVisualizer3D as v}from"../../SnappingVisualizer3D.js";import{SupportedGraphicResult as f}from"../isSupportedGraphicUtils.js";import{canMoveZ as M}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as _}from"../meshFastUpdateUtils.js";import{createVisualElements as y}from"../visualElementUtils.js";import{DISC_RADIUS as w}from"../manipulations/config.js";import{ManipulationType as j,MoveManipulation as b}from"../manipulations/MoveManipulation.js";import{shapeOrientation as x,axisConstrainedDragSign as S}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as E}from"../manipulations/MoveXYGraphicManipulation.js";import{isSupportedGraphic as T}from"./isSupportedGraphic.js";import{OutlineVisualElement as O}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as H}from"../../../layers/graphics/GraphicState.js";import{dragGraphicMany as U,resetGraphicMany as D}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as X}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as G}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import A from"../../../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as Y}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as z}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{Tooltip as P}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as k,TranslateGraphicZTooltipInfo as I,TranslateGraphicXYTooltipInfo as R}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as F}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as Z}from"../../../../support/euclideanLengthMeasurementUtils.js";class C{constructor(t){this.allGraphics=t,this.type="graphic-move-start"}}class V{constructor(t,i,e){this.dx=t,this.dy=i,this.allGraphics=e,this.type="graphic-move"}}class L{constructor(t){this.allGraphics=t,this.type="graphic-move-stop"}}const N="manipulators";let q=class extends(o(e.EventedMixin(X))){constructor(t){super(t),this._infos=new Map,this.graphics=new i,this.enableZ=!0,this.tooltipOptions=new A,this.type="move-3d",this._moveManipulation=null,this._tooltip=null}initialize(){const{view:t}=this;this.addHandles([this.graphics.on("change",(t=>{t.removed.forEach((t=>this.removeHandles(t))),this._updateGraphicInfos(t),this._setupFastTransformUpdates(t.added),this._refreshManipulators()})),p((()=>this.tooltipOptions.enabled),(i=>{this._tooltip=i?new P({view:t}):n(this._tooltip)}),l)]);const i=this.graphics.toArray();this._updateGraphicInfos({added:i,removed:[]}),this._setupFastTransformUpdates(i),this._refreshManipulators(),this.finishToolCreation()}destroy(){this._tooltip=n(this._tooltip),this._moveManipulation=n(this._moveManipulation),this.removeAllHandles(),this._set("view",null)}get updating(){return this.updatingHandles.updating}reset(){}_updateGraphicInfos({added:t,removed:i}){for(const e of t){if(T(e)!==f.SUPPORTED)continue;const t=new B(e),i=this.view.trackGraphicState(t.state);this._infos.set(t.graphic,{info:t,handle:i})}for(const e of i)this._infos.get(e)?.handle.remove(),this._infos.delete(e)}_setupFastTransformUpdates(t){for(const i of t){const{info:t}=this._infos.get(i);this.addHandles(_(t.state),i)}}_refreshManipulators(){if(this.removeHandles(N),this._moveManipulation=n(this._moveManipulation),this.manipulators.removeAll(),0===this._infos.size)return;const t=Array.from(this._infos.values(),(({info:t})=>t));this._createManipulators(t),this._createVisualElements(t),this._updateMoveManipulation(t)}_createManipulators(t){for(const i of t){const e=i.state;i.manipulationXY=new E({tool:this,view:this.view,graphicState:e}),i.manipulationXY.forEachManipulator((t=>this.addHandles([t.events.on("immediate-click",(t=>{this.emit("immediate-click",{...t,graphic:e.graphic}),t.stopPropagation()})),t.events.on("grab-changed",(({action:t})=>{const{tooltipOptions:i,_tooltip:e}=this;null!=e&&("start"===t?e.info=new k({tooltipOptions:i}):e.clear())}))],N))),this.addHandles(i.manipulationXY.createDragPipeline(((i,e,o,a)=>this._buildDragEventPipeline(t,j.XY,i,e,o,a))),N)}this._createMoveManipulation(t)}_createMoveManipulation(t){const i=new b({tool:this,view:this.view,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:1===t.length?b.radiusForSymbol(t[0].graphic.symbol):w});this._moveManipulation=i,i.elevationInfo={mode:"absolute-height",offset:0},i.forEachManipulator((t=>{this.addHandles(t.events.on("immediate-click",(e=>{i.zManipulation.hasManipulator(t)||1!==this.graphics.length||this.emit("immediate-click",{...e,graphic:this.graphics.at(0)}),e.stopPropagation()})),N)}));const e=i=>e=>{this.addHandles(e.events.on("focus-changed",(({action:e})=>{const o=this._tooltip;null!=o&&("focus"===e?this._updateMoveTooltip(t,i):o.clear())})),N)};this._moveManipulation.xyManipulation.forEachManipulator(e(j.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(e(j.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(e(j.Z));const o=()=>this._updateMoveManipulation(t);for(const n of t)this.addHandles([n.state.on("changed",o),p((()=>n.state.displaying),o)],N);const a=t[t.length-1];this.addHandles(a.state.on("changed",(()=>this._updateMoveManipulationAngle(a))),N),this.addHandles(i.createDragPipeline(((i,e,o,a,n)=>this._buildDragEventPipeline(t,i,e,o,a,n)),m(a.graphic),a.graphic.geometry.spatialReference,a.graphic),N),this._updateMoveManipulationAngle(a)}_createVisualElements(t){for(const i of t){const e=i.graphic,o=y({view:this.view,graphic:e,forEachManipulator:t=>{i.manipulationXY?.forEachManipulator(t),this._moveManipulation?.forEachManipulator(t)},onManipulatorsChanged:()=>a()});null!=o&&(i.geometryRepresentation=o.visualElement,i.geometryRepresentation instanceof O&&this.addHandles([i.geometryRepresentation.events.on("attachment-origin-changed",(()=>{i.state.isDraped||this._updateMoveManipulation(t)})),p((()=>i.state.isDraped),(()=>this._updateMoveManipulation(t)))],N),this.addHandles(o,N))}}_updateMoveManipulationAngle(t){this._moveManipulation&&(this._moveManipulation.angle=x(t.graphic.geometry))}_updateMoveManipulation(t){const i=u(0,0,0,this.view.spatialReference);let e=0,o=!1;const a=this._moveManipulation;if(a){for(const a of t){if(!a.state.displaying)continue;const t=a.state.graphic;this.enableZ&&M(t)&&(o=!0);const n=a.geometryRepresentation instanceof O&&!a.state.isDraped?a.geometryRepresentation.attachmentOrigin:g(this.view,t);if(null!=n){const{x:t,y:o,z:a}=n;i.x+=t,i.y+=o,a&&(i.z??=0,i.z+=a),e++}}e>0?(i.x/=e,i.y/=e,i.z??=0,i.z/=e,a.location=i,a.xyManipulation.available=!0,a.xyAxisManipulation.available=!0,a.zManipulation.available=o):a.available=!1}}_buildDragEventPipeline(t,i,e,o,a,n){const s=[],r=[];let p=null,l=null;const c=()=>{for(const t of s)t.dragging=!1;s.length=0,r.length=0,p=null,l=null,this._moveManipulation&&(this._moveManipulation.interactive=!0)};if(1===t.length&&i===j.XY){const i=t[0].graphic;({steps:o,cancel:a}=this._buildSnappingPipelineSteps(i,m(i),o,a,n))}return a=a.next((t=>l?.(t))).next((()=>(this.emit("graphic-move-stop",new L(r)),this.destroyed||c(),null))),{steps:o=o.next((i=>{if("start"===i.action){s.length=0,r.length=0;for(const i of t)i.dragging||!i.manipulationXY?.hasManipulator(e)&&i.manipulationXY?.grabbing||(s.push(i),r.push(i.graphic),i.dragging=!0);if(0!==r.length&&(this._moveManipulation&&(this._moveManipulation.interactive=!1),p=U(r,this.view.state.viewingMode),l=D(r),this.emit("graphic-move-start",new C(r)),this.destroyed))return null}return 0!==r.length?i:null})).next((t=>p?.(t))).next((e=>(this._updateMoveTooltip(t,i,e),e))).next((t=>{switch(t.action){case"start":case"update":if(t.translationX||t.translationY||t.translationZ){const i=this.view.toScreen(t.mapStart),e=this.view.toScreen(t.mapEnd),o=e.x-i.x,a=e.y-i.y;if(this.emit("graphic-move",new V(o,a,r)),this.destroyed)return null}break;case"end":if(this.emit("graphic-move-stop",new L(r)),this.destroyed)return null;c()}return null})),cancel:a}}_updateMoveTooltip(t,i,e){const{tooltipOptions:o,_tooltip:a}=this;if(null==a)return;a.clear();const n=0===t.length?"absolute-height":t[0].state.isDraped?"on-the-ground":"absolute-height";switch(i){case j.XY:a.info=new k({tooltipOptions:o}),this._updateMoveTooltipDistance(a.info,e,((t,i)=>F(t,i,n)));break;case j.XY_AXIS:a.info=new R({tooltipOptions:o}),this._updateMoveTooltipDistance(a.info,e,((t,i)=>{const o=F(t,i,n);return s(o,S(e))}));break;case j.Z:a.info=new I({tooltipOptions:o}),this._updateMoveTooltipDistance(a.info,e,Z)}}_updateMoveTooltipDistance(t,i,e){if(null!=i&&"end"!==i.action){const{mapStart:o,mapEnd:a}=i,n=e(o,a);t.distance=null!=n?n:r}}_buildSnappingPipelineSteps(t,i,e,o,a){const n=t.geometry;if(null==n||"point"!==n.type&&"mesh"!==n.type)return{steps:e,cancel:o};const s=("point"===n.type?n:n.anchor).clone(),r=new Y({elevationInfo:i,pointer:a,editGeometryOperations:G.fromGeometry(s,this.view.state.viewingMode),visualizer:new v,excludeFeature:t}),p=this.snappingManager,{snappingStep:l,cancelSnapping:c}=z({snappingContext:r,snappingManager:p,updatingHandles:this.updatingHandles});return o=o.next(c),{steps:e=e.next((i=>{s.z=d(this.view,s,m(t),{mode:"absolute-height",offset:0});return{...i,snapOrigin:r.coordinateHelper.pointToVector(s)}})).next(...l),cancel:o}}get test(){return{tooltip:this._tooltip}}};t([c({constructOnly:!0,nonNullable:!0})],q.prototype,"view",void 0),t([c()],q.prototype,"graphics",void 0),t([c({constructOnly:!0,nonNullable:!0})],q.prototype,"enableZ",void 0),t([c({constructOnly:!0,type:A})],q.prototype,"tooltipOptions",void 0),t([c({constructOnly:!0})],q.prototype,"snappingManager",void 0),t([c()],q.prototype,"type",void 0),t([c()],q.prototype,"updating",null),q=t([h("esri.views.3d.interactive.editingTools.graphicMove3D.GraphicMoveTool")],q);class B{constructor(t){this.geometryRepresentation=null,this.manipulationXY=null,this.dragging=!1,this.state=new H({graphic:t})}get graphic(){return this.state.graphic}}export{V as GraphicMoveEvent,C as GraphicMoveStartEvent,L as GraphicMoveStopEvent,q as GraphicMoveTool};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Evented.js";import{HandleOwnerMixin as i}from"../../../../../core/HandleOwner.js";import{makeHandle as a}from"../../../../../core/handleUtils.js";import{destroyMaybe as o}from"../../../../../core/maybe.js";import{scale as n,zeroMeters as s}from"../../../../../core/quantityUtils.js";import{watch as r,when as l,syncAndInitial as p}from"../../../../../core/reactiveUtils.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import d from"../../../../../geometry/Point.js";import{getGraphicEffectiveElevationInfo as u}from"../../../../../support/elevationInfoUtils.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{Manipulator3D as g}from"../../Manipulator3D.js";import{placeAtGraphic as v}from"../../manipulatorUtils.js";import{SnappingVisualizer3D as _}from"../../SnappingVisualizer3D.js";import{canMoveZ as M}from"../manipulatorUtils.js";import{tryEnableMeshTransformFastUpdates as f,tryDisableMeshTransformFastUpdates as y}from"../meshFastUpdateUtils.js";import{createVisualElements as S}from"../visualElementUtils.js";import{ALIGN_ARROWS_SCALE_THRESHOLD as R}from"../manipulations/config.js";import{MoveManipulation as w,ManipulationType as b}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as j}from"../manipulations/moveUtils.js";import{GraphicScaleRotateTransform as A}from"./GraphicScaleRotateTransform.js";import{ScaleRotateMeshAdapter as T}from"./ScaleRotateMeshAdapter.js";import{ScaleRotateObjectSymbol3DAdapter as x}from"./ScaleRotateObjectSymbol3DAdapter.js";import{createGraphicGeometryUndoRecord as O}from"./undoRecords.js";import{GraphicState as E}from"../../../layers/graphics/GraphicState.js";import{sceneSnappingAtProjectedLocation as G}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as U}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as z}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import D from"../../../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as I}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as k}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{Tooltip as C}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicZTooltipInfo as L,TranslateGraphicXYTooltipInfo as Z,TranslateGraphicTooltipInfo as H}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as X}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as F}from"../../../../support/euclideanLengthMeasurementUtils.js";let P=class extends(i(e.EventedMixin(U))){constructor(t){super(t),this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.tooltipOptions=new D,this.type="transform-3d",this._scaleRotate=null,this._tooltip=null}initialize(){const{graphic:t,view:e}=this;this.graphicState=new E({graphic:t}),this.addHandles(r((()=>this.tooltipOptions.enabled),(t=>{this._tooltip=t?new C({view:e}):o(this._tooltip)}),p)),this._moveManipulation=new w({tool:this,view:e,snapToScene:this.snapToScene,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZ&&M(t),radius:w.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator((e=>this.handles.add(e.events.on("immediate-click",(e=>{this.emit("immediate-click",{...e,graphic:t}),e.stopPropagation()})))));const i=t=>e=>{this.handles.add(e.events.on("focus-changed",(({action:e})=>{const i=this._tooltip;null!=i&&("focus"===e?this._updateMoveTooltip(t):i.clear())})))};this._moveManipulation.xyManipulation.forEachManipulator(i(b.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(i(b.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(i(b.Z));const n=u(t);this._moveManipulation.elevationInfo=n,this.addHandles(l((()=>this.graphicState.displaying),(()=>{f(t),this.addHandles(a((()=>y(t))))}),{...p,once:!0}));const{geometry:s}=t;if(this._moveManipulation.createGraphicDragPipeline(((i,a,o,r,l)=>{if(null!=s&&i===b.XY){const{snappingStep:i,cancelSnapping:a}=k({snappingContext:new I({elevationInfo:n,pointer:l,editGeometryOperations:z.fromGeometry(new d({spatialReference:s.spatialReference}),e.state.viewingMode),visualizer:new _,excludeFeature:t}),snappingManager:this.snappingManager,updatingHandles:this.updatingHandles,useZ:!1});r=r.next(a),o=o.next(G(this.view,n)).next(...i)}return{steps:o=o.next((t=>(this._updateMoveTooltip(i,t),t))),cancel:r}}),this.graphicState,(t=>{const{action:e,graphic:i,dxScreen:a,dyScreen:o}=t,n={graphic:i,dxScreen:a,dyScreen:o};switch(e){case"start":this.emit("graphic-translate-start",n),this.emit("record-undo",{record:this._createGeometryUndoRecord()});break;case"update":this.emit("graphic-translate",n);break;case"end":this.emit("graphic-translate-stop",n)}})),this._moveManipulation.angle=null!=this._scaleRotate?this._scaleRotate.angle:0,this._scaleRotateAdapter=this._createScaleRotateAdapter(),this.handles.add(r((()=>this._scaleRotateAdapter.angle),(()=>this._updateMoveAngle()))),this.enableScaling||this.enableRotation){const t=this.enableScaling&&this.enableRotation?null:this.enableScaling?"scale":"rotate";this._scaleRotate=new A({tool:this,mode:t,adapter:this._scaleRotateAdapter,tooltipOptions:this.tooltipOptions}),this.handles.add(this._scaleRotate.events.on("scale-changed",(()=>this._onScaleChanged())))}this.handles.add([S({view:this.view,graphic:this.graphic,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>a()}),this.graphicState.on("changed",(()=>this._onGeometryChanged())),this._hideManipulatorsForGraphicState(),r((()=>e.scale),(()=>this._updateMoveAngle()))]),this.handles.add(this.view.trackGraphicState(this.graphicState)),this._onGeometryChanged(),this._updateMoveAngle(),this._forEachManipulator((t=>{t instanceof g&&this.handles.add(t.events.on("grab-changed",(()=>this._updateManipulatorsInteractive())))})),this.finishToolCreation()}destroy(){this._tooltip=o(this._tooltip),this._moveManipulation.destroy(),this._scaleRotate=o(this._scaleRotate),this._scaleRotateAdapter=o(this._scaleRotateAdapter),this._set("view",null),this._set("graphic",null)}_updateManipulatorsInteractive(){null!=this._scaleRotate&&(this._scaleRotate.interactive=!this._moveManipulation.grabbing,this._moveManipulation.interactive=!this._scaleRotate.grabbing)}_createScaleRotateAdapter(){return null!=this.graphic.geometry&&"mesh"===this.graphic.geometry.type?new T({graphic:this.graphic,geometry:this.graphic.geometry,viewingMode:this.view.state.viewingMode}):new x({graphic:this.graphic,sizeFilter:t=>this._enforceNonZeroSize(t),findLayerView:()=>this.view.allLayerViews.find((t=>t.layer===this.graphic.layer)),sizeAxis:this.tooltipOptions?.visualVariables?.size?.axis??null})}_forEachManipulator(t){this._moveManipulation?.forEachManipulator(t),this._scaleRotate?.forEachManipulator(t)}_hideManipulatorsForGraphicState(){return r((()=>this.graphicState.displaying),(t=>{this._forEachManipulator((e=>e.available=t)),this._moveManipulation.zManipulation.available=t&&this.enableZ&&M(this.graphic)}))}_createGeometryUndoRecord(){return O(this.graphic)}set snapToScene(t){this._moveManipulation&&(this._moveManipulation.snapToScene=t),this._set("snapToScene",t)}get updating(){return this.updatingHandles.updating}set location(t){this._moveManipulation.location=t,this._scaleRotate&&(this._scaleRotate.location=t)}set elevationAlignedLocation(t){this._moveManipulation.elevationAlignedLocation=t,this._scaleRotate&&(this._scaleRotate.elevationAlignedLocation=t)}reset(){}onHide(){this._scaleRotate?.cancelActiveAnimation()}_onScaleChanged(){null!=this._scaleRotate&&(this._moveManipulation.displayScale=this._scaleRotate.getScale())}_updateMoveAngle(){this.view.state.viewingMode===m.Local||this.view.scale<R?this._moveManipulation.angle=this._scaleRotateAdapter.angle:this._moveManipulation.angle=0}_onGeometryChanged(){v(this.view,this,this.graphic)}_enforceNonZeroSize(t){return t||this.view.state.camera.computeRenderPixelSizeAt(this._moveManipulation.renderLocation)}_updateMoveTooltip(t,e){const{tooltipOptions:i,_tooltip:a}=this;if(null==a)return;a.clear();const o=this.graphicState.isDraped?"on-the-ground":"absolute-height";switch(t){case b.XY:a.info=new H({tooltipOptions:i}),this._updateMoveTooltipDistance(a.info,e,((t,e)=>X(t,e,o)));break;case b.XY_AXIS:a.info=new Z({tooltipOptions:i}),this._updateMoveTooltipDistance(a.info,e,((t,i)=>{const a=X(t,i,o);return n(a,j(e))}));break;case b.Z:a.info=new L({tooltipOptions:i}),this._updateMoveTooltipDistance(a.info,e,F)}}_updateMoveTooltipDistance(t,e,i){if(null!=e&&"end"!==e.action){const{mapStart:a,mapEnd:o}=e,n=i(a,o);t.distance=null!=n?n:s}}get test(){return{discManipulator:this._moveManipulation.xyManipulation.test.discManipulator,zManipulator:this._moveManipulation.zManipulation.test.manipulator,ringManipulator:null!=this._scaleRotate?this._scaleRotate.test.ringManipulator:null,arrowManipulators:this._moveManipulation.xyAxisManipulation.test.arrowManipulators,setRingIndicatorDelayMs:t=>null!=this._scaleRotate?this._scaleRotate.test.setRingIndicatorDelayMs(t):null,scaleRotateAdapter:this._scaleRotateAdapter,scaleRotateTransform:this._scaleRotate,tooltip:this._tooltip}}};t([c({constructOnly:!0,nonNullable:!0})],P.prototype,"view",void 0),t([c({constructOnly:!0,nonNullable:!0})],P.prototype,"graphic",void 0),t([c({constructOnly:!0,nonNullable:!0})],P.prototype,"enableZ",void 0),t([c()],P.prototype,"enableRotation",void 0),t([c()],P.prototype,"enableScaling",void 0),t([c({constructOnly:!0,type:D})],P.prototype,"tooltipOptions",void 0),t([c()],P.prototype,"graphicState",void 0),t([c({value:!1})],P.prototype,"snapToScene",null),t([c({constructOnly:!0})],P.prototype,"snappingManager",void 0),t([c({readOnly:!0})],P.prototype,"type",void 0),t([c({readOnly:!0})],P.prototype,"updating",null),P=t([h("esri.views.3d.interactive.editingTools.graphicTransform3D.GraphicTransformTool")],P);export{P as GraphicTransformTool};
|
|
5
|
+
import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Evented.js";import{HandleOwnerMixin as i}from"../../../../../core/HandleOwner.js";import{makeHandle as a}from"../../../../../core/handleUtils.js";import{destroyMaybe as o}from"../../../../../core/maybe.js";import{scale as n,zeroMeters as s}from"../../../../../core/quantityUtils.js";import{watch as r,syncAndInitial as l}from"../../../../../core/reactiveUtils.js";import{property as p}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import h from"../../../../../geometry/Point.js";import{getGraphicEffectiveElevationInfo as u}from"../../../../../support/elevationInfoUtils.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{Manipulator3D as d}from"../../Manipulator3D.js";import{placeAtGraphic as g}from"../../manipulatorUtils.js";import{SnappingVisualizer3D as v}from"../../SnappingVisualizer3D.js";import{canMoveZ as _}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as M}from"../meshFastUpdateUtils.js";import{createVisualElements as f}from"../visualElementUtils.js";import{ALIGN_ARROWS_SCALE_THRESHOLD as y}from"../manipulations/config.js";import{MoveManipulation as S,ManipulationType as R}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as w}from"../manipulations/moveUtils.js";import{GraphicScaleRotateTransform as b}from"./GraphicScaleRotateTransform.js";import{ScaleRotateMeshAdapter as j}from"./ScaleRotateMeshAdapter.js";import{ScaleRotateObjectSymbol3DAdapter as A}from"./ScaleRotateObjectSymbol3DAdapter.js";import{createGraphicGeometryUndoRecord as T}from"./undoRecords.js";import{GraphicState as x}from"../../../layers/graphics/GraphicState.js";import{sceneSnappingAtProjectedLocation as O}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as E}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as G}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import U from"../../../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as z}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as D}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{Tooltip as I}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicZTooltipInfo as k,TranslateGraphicXYTooltipInfo as C,TranslateGraphicTooltipInfo as L}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as Z}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as H}from"../../../../support/euclideanLengthMeasurementUtils.js";let X=class extends(i(e.EventedMixin(E))){constructor(t){super(t),this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.tooltipOptions=new U,this.type="transform-3d",this._scaleRotate=null,this._tooltip=null}initialize(){const{graphic:t,view:e}=this;this.graphicState=new x({graphic:t}),this.addHandles(r((()=>this.tooltipOptions.enabled),(t=>{this._tooltip=t?new I({view:e}):o(this._tooltip)}),l)),this._moveManipulation=new S({tool:this,view:e,snapToScene:this.snapToScene,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZ&&_(t),radius:S.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator((e=>this.handles.add(e.events.on("immediate-click",(e=>{this.emit("immediate-click",{...e,graphic:t}),e.stopPropagation()})))));const i=t=>e=>{this.handles.add(e.events.on("focus-changed",(({action:e})=>{const i=this._tooltip;null!=i&&("focus"===e?this._updateMoveTooltip(t):i.clear())})))};this._moveManipulation.xyManipulation.forEachManipulator(i(R.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(i(R.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(i(R.Z));const n=u(t);this._moveManipulation.elevationInfo=n,this.addHandles(M(this.graphicState));const{geometry:s}=t;if(this._moveManipulation.createGraphicDragPipeline(((i,a,o,r,l)=>{if(null!=s&&i===R.XY){const{snappingStep:i,cancelSnapping:a}=D({snappingContext:new z({elevationInfo:n,pointer:l,editGeometryOperations:G.fromGeometry(new h({spatialReference:s.spatialReference}),e.state.viewingMode),visualizer:new v,excludeFeature:t}),snappingManager:this.snappingManager,updatingHandles:this.updatingHandles,useZ:!1});r=r.next(a),o=o.next(O(this.view,n)).next(...i)}return{steps:o=o.next((t=>(this._updateMoveTooltip(i,t),t))),cancel:r}}),this.graphicState,(t=>{const{action:e,graphic:i,dxScreen:a,dyScreen:o}=t,n={graphic:i,dxScreen:a,dyScreen:o};switch(e){case"start":this.emit("graphic-translate-start",n),this.emit("record-undo",{record:this._createGeometryUndoRecord()});break;case"update":this.emit("graphic-translate",n);break;case"end":this.emit("graphic-translate-stop",n)}})),this._moveManipulation.angle=null!=this._scaleRotate?this._scaleRotate.angle:0,this._scaleRotateAdapter=this._createScaleRotateAdapter(),this.handles.add(r((()=>this._scaleRotateAdapter.angle),(()=>this._updateMoveAngle()))),this.enableScaling||this.enableRotation){const t=this.enableScaling&&this.enableRotation?null:this.enableScaling?"scale":"rotate";this._scaleRotate=new b({tool:this,mode:t,adapter:this._scaleRotateAdapter,tooltipOptions:this.tooltipOptions}),this.handles.add(this._scaleRotate.events.on("scale-changed",(()=>this._onScaleChanged())))}this.handles.add([f({view:this.view,graphic:this.graphic,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>a()}),this.graphicState.on("changed",(()=>this._onGeometryChanged())),this._hideManipulatorsForGraphicState(),r((()=>e.scale),(()=>this._updateMoveAngle()))]),this.handles.add(this.view.trackGraphicState(this.graphicState)),this._onGeometryChanged(),this._updateMoveAngle(),this._forEachManipulator((t=>{t instanceof d&&this.handles.add(t.events.on("grab-changed",(()=>this._updateManipulatorsInteractive())))})),this.finishToolCreation()}destroy(){this._tooltip=o(this._tooltip),this._moveManipulation.destroy(),this._scaleRotate=o(this._scaleRotate),this._scaleRotateAdapter=o(this._scaleRotateAdapter),this._set("view",null),this._set("graphic",null)}_updateManipulatorsInteractive(){null!=this._scaleRotate&&(this._scaleRotate.interactive=!this._moveManipulation.grabbing,this._moveManipulation.interactive=!this._scaleRotate.grabbing)}_createScaleRotateAdapter(){return null!=this.graphic.geometry&&"mesh"===this.graphic.geometry.type?new j({graphic:this.graphic,geometry:this.graphic.geometry,viewingMode:this.view.state.viewingMode}):new A({graphic:this.graphic,sizeFilter:t=>this._enforceNonZeroSize(t),findLayerView:()=>this.view.allLayerViews.find((t=>t.layer===this.graphic.layer)),sizeAxis:this.tooltipOptions?.visualVariables?.size?.axis??null})}_forEachManipulator(t){this._moveManipulation?.forEachManipulator(t),this._scaleRotate?.forEachManipulator(t)}_hideManipulatorsForGraphicState(){return r((()=>this.graphicState.displaying),(t=>{this._forEachManipulator((e=>e.available=t)),this._moveManipulation.zManipulation.available=t&&this.enableZ&&_(this.graphic)}))}_createGeometryUndoRecord(){return T(this.graphic)}set snapToScene(t){this._moveManipulation&&(this._moveManipulation.snapToScene=t),this._set("snapToScene",t)}get updating(){return this.updatingHandles.updating}set location(t){this._moveManipulation.location=t,this._scaleRotate&&(this._scaleRotate.location=t)}set elevationAlignedLocation(t){this._moveManipulation.elevationAlignedLocation=t,this._scaleRotate&&(this._scaleRotate.elevationAlignedLocation=t)}reset(){}onHide(){this._scaleRotate?.cancelActiveAnimation()}_onScaleChanged(){null!=this._scaleRotate&&(this._moveManipulation.displayScale=this._scaleRotate.getScale())}_updateMoveAngle(){this.view.state.viewingMode===m.Local||this.view.scale<y?this._moveManipulation.angle=this._scaleRotateAdapter.angle:this._moveManipulation.angle=0}_onGeometryChanged(){g(this.view,this,this.graphic)}_enforceNonZeroSize(t){return t||this.view.state.camera.computeRenderPixelSizeAt(this._moveManipulation.renderLocation)}_updateMoveTooltip(t,e){const{tooltipOptions:i,_tooltip:a}=this;if(null==a)return;a.clear();const o=this.graphicState.isDraped?"on-the-ground":"absolute-height";switch(t){case R.XY:a.info=new L({tooltipOptions:i}),this._updateMoveTooltipDistance(a.info,e,((t,e)=>Z(t,e,o)));break;case R.XY_AXIS:a.info=new C({tooltipOptions:i}),this._updateMoveTooltipDistance(a.info,e,((t,i)=>{const a=Z(t,i,o);return n(a,w(e))}));break;case R.Z:a.info=new k({tooltipOptions:i}),this._updateMoveTooltipDistance(a.info,e,H)}}_updateMoveTooltipDistance(t,e,i){if(null!=e&&"end"!==e.action){const{mapStart:a,mapEnd:o}=e,n=i(a,o);t.distance=null!=n?n:s}}get test(){return{discManipulator:this._moveManipulation.xyManipulation.test.discManipulator,zManipulator:this._moveManipulation.zManipulation.test.manipulator,ringManipulator:null!=this._scaleRotate?this._scaleRotate.test.ringManipulator:null,arrowManipulators:this._moveManipulation.xyAxisManipulation.test.arrowManipulators,setRingIndicatorDelayMs:t=>null!=this._scaleRotate?this._scaleRotate.test.setRingIndicatorDelayMs(t):null,scaleRotateAdapter:this._scaleRotateAdapter,scaleRotateTransform:this._scaleRotate,tooltip:this._tooltip}}};t([p({constructOnly:!0,nonNullable:!0})],X.prototype,"view",void 0),t([p({constructOnly:!0,nonNullable:!0})],X.prototype,"graphic",void 0),t([p({constructOnly:!0,nonNullable:!0})],X.prototype,"enableZ",void 0),t([p()],X.prototype,"enableRotation",void 0),t([p()],X.prototype,"enableScaling",void 0),t([p({constructOnly:!0,type:U})],X.prototype,"tooltipOptions",void 0),t([p()],X.prototype,"graphicState",void 0),t([p({value:!1})],X.prototype,"snapToScene",null),t([p({constructOnly:!0})],X.prototype,"snappingManager",void 0),t([p({readOnly:!0})],X.prototype,"type",void 0),t([p({readOnly:!0})],X.prototype,"updating",null),X=t([c("esri.views.3d.interactive.editingTools.graphicTransform3D.GraphicTransformTool")],X);export{X as GraphicTransformTool};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Accessor.js";import{HandleOwner as o}from"../../../../../core/HandleOwner.js";import{deg2rad as
|
|
5
|
+
import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Accessor.js";import{HandleOwner as o}from"../../../../../core/HandleOwner.js";import{deg2rad as r,rad2deg as i}from"../../../../../core/mathUtils.js";import{when as n,sync as s}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{g as c}from"../../../../../chunks/vec3.js";import{create as p,axis as g,angle as h,composeAxes as u,compose as m}from"../../../../../geometry/support/axisAngleDegrees.js";import d from"../../../../../geometry/support/MeshTransform.js";import{ViewingMode as y}from"../../../../ViewingMode.js";import{createGraphicGeometryUndoRecord as v}from"./undoRecords.js";let f=class extends o{constructor(t){super(t),this._interactionState=null}initialize(){this.addHandles([n((()=>{const t=this._interactionState;return t&&t.angle!==t.previousAngle?{interactionState:t,angle:t.state.angle}:null}),(({interactionState:t})=>{this._updateMeshRotation(t)}),s),n((()=>{const t=this._interactionState;return t&&t.scale!==t.previousScale?{interactionState:t,scale:t.state.scale}:null}),(({interactionState:t})=>{this._updateMeshSize(t)}),s)])}get initialAngle(){return this._interactionState?.initialAngle??0}get angle(){const t=this.geometry.transform;if(null==t)return this._interactionState?.angle??0;const e=g(t.rotation)[2];return Math.abs(e)>.999999?r(h(t.rotation))*Math.sign(e):0}get angleClockwise(){return-this.angle}get relativeAngle(){return this.angle-this.initialAngle}get relativeAngleClockwise(){return-this.relativeAngle}get scale(){return this._interactionState?.scale??1}startInteraction(){const t=new S({angle:this.angle});this._interactionState=t;const e=()=>{this._interactionState=null};return{state:t,done:e,cancel:()=>{t.cancel(),e()}}}createUndoRecord(){return v(this.graphic)}_updateMeshRotation(t){const{angle:e,previousAngle:o}=t;t.previousAngle=e;const{geometry:r}=this,{vertexSpace:n}=r,s=i(e-o);if(n.isGeoreferenced){const t=!n.isRelative&&this.viewingMode===y.Global,e=this.geometry.anchor;this.geometry.rotate(0,0,s,{origin:e,geographic:t}),this.graphic.notifyGeometryChanged()}else{r.transform??=new d;const{transform:t}=r,e=u(0,0,s,A);t.rotation=m(t.rotation,e,t.rotation),this.graphic.notifyMeshTransformChanged()}}_updateMeshSize(t){const{scale:e,previousScale:o}=t;t.previousScale=e;const{geometry:r}=this,{vertexSpace:i}=r,n=e/o;if(i.isGeoreferenced){const t=!i.isRelative&&this.viewingMode===y.Global,e=this.geometry.anchor;this.geometry.scale(n,{origin:e,geographic:t}),this.graphic.notifyGeometryChanged()}else{r.transform??=new d;const{transform:t}=r;t.scale=c(t.scale,t.scale,n),this.graphic.notifyMeshTransformChanged()}}};t([a({constructOnly:!0})],f.prototype,"graphic",void 0),t([a({constructOnly:!0})],f.prototype,"geometry",void 0),t([a({constructOnly:!0})],f.prototype,"viewingMode",void 0),t([a()],f.prototype,"initialAngle",null),t([a()],f.prototype,"angle",null),t([a()],f.prototype,"angleClockwise",null),t([a()],f.prototype,"relativeAngle",null),t([a()],f.prototype,"relativeAngleClockwise",null),t([a()],f.prototype,"scale",null),t([a()],f.prototype,"_interactionState",void 0),f=t([l("esri.views.3d.interactive.editingTools.transformGraphic.ScaleRotateMeshAdapter")],f);let S=class extends e{get state(){const{angle:t,scale:e}=this;return{angle:t,scale:e}}constructor(t){super(t),this.angle=0,this.initialAngle=0,this.previousAngle=0,this.previousScale=1,this.scale=1,this.initialAngle=t.angle,this.previousAngle=t.angle}cancel(){this.angle=this.initialAngle,this.scale=1}};t([a()],S.prototype,"angle",void 0),t([a()],S.prototype,"initialAngle",void 0),t([a()],S.prototype,"previousAngle",void 0),t([a()],S.prototype,"previousScale",void 0),t([a()],S.prototype,"scale",void 0),t([a()],S.prototype,"state",null),S=t([l("InteractionState")],S);const A=p();export{f as ScaleRotateMeshAdapter};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
function
|
|
5
|
+
import{a as e}from"../../../../../chunks/vec3f64.js";function t(e){return null!=e.geometry&&"mesh"===e.geometry.type?r(e.geometry):n(e)}function r(e){return e.vertexSpace.isRelative?o(e,e.transform,e.vertexSpace):i(e)}function n(e){let t=e.geometry,r=null;return{undo(e){r=e.geometry,e.geometry=t},redo(e){t=e.geometry,e.geometry=r}}}function o(t,r,n){let o=r?.clone(),i=e(n.origin),u=null,s=null;return{undo:r=>{u=t.transform?.clone(),s=e(n.origin),t.transform=o,t.vertexSpace.origin=i,r.notifyMeshTransformChanged()},redo:r=>{o=t.transform?.clone(),i=e(n.origin),t.transform=u,t.vertexSpace.origin=s,r.notifyMeshTransformChanged()}}}function i(e){let t,r=e.vertexAttributes.clonePositional();return{undo:n=>{t=e.vertexAttributes.clonePositional(),e.vertexAttributes=r,n.notifyGeometryChanged()},redo:n=>{r=e.vertexAttributes.clonePositional(),e.vertexAttributes=t,n.notifyGeometryChanged()}}}export{t as createGraphicGeometryUndoRecord};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import"../../../../renderers/ClassBreaksRenderer.js";import"../../../../renderers/DictionaryRenderer.js";import"../../../../renderers/DotDensityRenderer.js";import"../../../../renderers/HeatmapRenderer.js";import"../../../../renderers/PieChartRenderer.js";import"../../../../renderers/Renderer.js";import"../../../../renderers/SimpleRenderer.js";import i from"../../../../renderers/UniqueValueRenderer.js";import"../../../../renderers/support/jsonUtils.js";import"../../../../symbols.js";import t from"../../../../core/Accessor.js";import{isSome as r}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import s from"../../../../core/Error.js";import a from"../../../../core/Handles.js";import{makeHandle as n}from"../../../../core/handleUtils.js";import o from"../../../../core/Logger.js";import{someMap as l,findInMap as h}from"../../../../core/MapUtils.js";import{destroyMaybe as d,removeMaybe as p,disposeMaybe as c}from"../../../../core/maybe.js";import y from"../../../../core/PooledArray.js";import{throwIfAborted as m,eachAlways as g,createResolver as u,isAbortError as b}from"../../../../core/promiseUtils.js";import{watch as _,when as f,on as v,syncAndInitial as C,whenOnce as S}from"../../../../core/reactiveUtils.js";import{schedule as w}from"../../../../core/scheduling.js";import{property as G}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as x}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as P,isEmpty as R}from"../../../../core/accessorSupport/diffUtils.js";import{s as D,a as E,g as I}from"../../../../chunks/vec3.js";import{c as U}from"../../../../chunks/vec3f64.js";import{projectVectorToVector as A,projectXYZToVector as O,canProjectWithoutEngine as j,projectBuffer as L}from"../../../../geometry/projection.js";import{create as V,center as F,fromRect as T,equals as k}from"../../../../geometry/support/aaBoundingBox.js";import{create as z}from"../../../../geometry/support/aaBoundingRect.js";import{equals as W}from"../../../../geometry/support/spatialReferenceUtils.js";import M from"../../../../layers/Layer.js";import{getObjectId as N,computeAABB as B,hasGeometry as H}from"../../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as q}from"../../../../layers/graphics/hydratedFeatures.js";import{isSupportedRenderer3D as Y,validateTo3D as $}from"../../../../renderers/support/rendererConversion.js";import{loadArcade as Z}from"../../../../support/arcadeOnDemand.js";import{getDefaultSymbol3D as J}from"../../../../symbols/support/defaults3D.js";import{to3D as Q}from"../../../../symbols/support/symbolConversion.js";import{ViewElevationProvider as K}from"./ElevationQuery.js";import{VisibilityGroup as X,VisibilityFlag as ee}from"./enums.js";import{extractExpressionInfo as ie,createContext as te}from"./featureExpressionInfoUtils.js";import{Graphics3DFeatureStore as re}from"./Graphics3DFeatureStore.js";import se from"./Graphics3DGraphicCreationContext.js";import{Graphics3DSymbolCreationContext as ae}from"./Graphics3DSymbolCreationContext.js";import{make as ne}from"./Graphics3DSymbolFactory.js";import oe from"./Graphics3DWebStyleSymbol.js";import{GraphicStateTracking as le}from"./GraphicStateTracking.js";import{computeCentroid as he}from"./graphicUtils.js";import{ApplyRendererDiffResult as de}from"./interfaces.js";import{LoadStatus as pe}from"./Loadable.js";import{SpatialIndex2D as ce}from"./SpatialIndex2D.js";import{averageSymbolComplexities as ye,defaultSymbolComplexity as me}from"./symbolComplexity.js";import{StageLayerElevationProvider as ge}from"../support/StageLayerElevationProvider.js";import{toBoundingRect as ue}from"../../support/extentUtils.js";import{PropertiesPool as be}from"../../support/PropertiesPool.js";import{GridLocalOriginFactory as _e}from"../../webgl-engine/lib/GridLocalOriginFactory.js";import{UpdatePolicy as fe}from"../../webgl-engine/lib/UpdatePolicy.js";import{WebGLLayer as ve}from"../../webgl-engine/lib/WebGLLayer.js";import{hasPopupTemplate as Ce}from"../../../layers/support/popupUtils.js";import{ImmediateTask as Se,noBudget as we,TaskPriority as Ge,Task as xe}from"../../../support/Scheduler.js";import Pe from"../../../../geometry/Extent.js";import Re from"../../../../geometry/Point.js";import De from"../../../../symbols/LabelSymbol3D.js";import Ee from"../../../../symbols/TextSymbol.js";import Ie from"../../../../symbols/WebStyleSymbol.js";var Ue;const Ae=U(),Oe=V(),je="esri.views.3d.layers.graphics.Graphics3DCore",Le=o.getLogger(je);let Ve=Ue=class extends t{get _viewSpatialReference(){return this.owner.view.spatialReference}get spatialIndex(){return this._spatialIndex||(this._spatialIndex=new ce({objectIdField:this.owner.layer?.objectIdField,spatialReference:this._viewSpatialReference,hasZ:!!this.hasZ,hasM:!!this.hasM}),this._spatialIndex.setup(Array.from(this.graphics3DGraphics.values()))),this._spatialIndex.update(),this._spatialIndex}get numberOfGraphics(){return this._numberOfGraphics}get effectiveUpdatePolicy(){return null!=this.currentRenderer&&"dictionary"===this.currentRenderer.type?fe.ASYNC:this._forcedUpdatePolicy??this.preferredUpdatePolicy}get featureStore(){return this._featureStore}get initializePromise(){return this._initializePromise}get scaleVisibility(){return this._scaleVisibility}get elevationAlignment(){return this._elevationAlignment}get objectStates(){return this._objectStates}get filterVisibility(){return this._filterVisibility}get updating(){return!!(this._graphicsWaitingForSymbol.size>0||this.running||this._elevationAlignment?.updating||null!=this._scaleVisibility&&this._scaleVisibility.updating||null!=this._filterVisibility&&this._filterVisibility.updating||this._rendererChangeAbortController||this._elevationInfoChangeAbortController||this._updatingPendingLoadedGraphicsChange||this._frameTask.updating||this._loadingSymbols>0)}get running(){return this._pendingUpdates.size>0||!!this._spatialIndex?.updating}get suspendedOrOutsideOfView(){return this.owner.suspended||!!this.owner.suspendInfo?.outsideOfView}get updatingRemaining(){return this.updating?this._pendingUpdates.size+.1*(this._spatialIndex?.updatingRemaining||0)+.1*(this._elevationAlignment?.updatingRemaining||0):0}get displayFeatureLimit(){const e=this.owner&&this.owner.view&&this.owner.view.qualitySettings,i=e?e.graphics3D.minTotalNumberOfFeatures:0,t=e?e.graphics3D.maxTotalNumberOfFeatures:0,r=e?e.graphics3D.maxTotalNumberOfPrimitives:0,s=this.averageSymbolComplexity,a=Math.max(1,null!=s?s.primitivesPerFeature:1),n=null!=s&&s.drawCallsPerFeature>0?t/s.drawCallsPerFeature*.3:t,o=Math.ceil(r/a),l=Math.max(i,Math.min(t,o,n)),h=this._get("displayFeatureLimit");return h&&h.minimumTotalNumberOfFeatures===i&&h.maximumTotalNumberOfFeatures===t&&h.maximumTotalNumberOfPrimitives===r&&h.averageSymbolComplexity===s&&h.maximumNumberOfFeatures===l?h:{minimumTotalNumberOfFeatures:i,maximumTotalNumberOfFeatures:t,maximumTotalNumberOfPrimitives:r,averageSymbolComplexity:s,maximumNumberOfFeatures:l}}get averageSymbolComplexity(){const e=ye(this._symbolComplexities),i=this._get("averageSymbolComplexity");return 0===e.numComplexities||null!=i&&(e.estimated&&(i.primitivesPerFeature>=e.primitivesPerFeature||i.primitivesPerCoordinate>=e.primitivesPerCoordinate||i.drawCallsPerFeature>=e.drawCallsPerFeature)||i.primitivesPerFeature===e.primitivesPerFeature&&i.primitivesPerCoordinate===e.primitivesPerCoordinate&&i.drawCallsPerFeature===e.drawCallsPerFeature)?i:e}get usedMemory(){const e=null!=this.averageSymbolComplexity&&this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel*this._numberOfGraphics:0,i=this._getSymbolComplexitiesUsed().reduce(((e,i)=>e+i.memory.resourceBytes),0);return this._usedMemory+e+i}get usedMemoryPerGraphic(){if(this._usedMemory&&this._numberOfGraphics){const e=this._numberOfGraphics/(this._numberOfGraphics+Math.max(this._pendingAdds,this._pendingRemoves));return this._usedMemory/this._numberOfGraphics*e}if(null!=this.averageSymbolComplexity){const e=this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel:0;return this.averageSymbolComplexity.memory.bytesPerFeature+e}return 0}get unprocessedMemoryEstimate(){return(this._pendingAdds-this._pendingRemoves)*this.usedMemoryPerGraphic}get _symbolComplexities(){return this.currentRenderer?this._getSymbolComplexitiesUsedOrRenderer(this.currentRenderer):this._getSymbolComplexitiesUsed()}get visible(){return this._visible}_getConvertedSymbol(e){if("web-style"===e.type)return e.clone();const i=this._symbolConversionCache.get(e.id);if(null!=i)return i;const t=Q(e,{geometryType:this.layer?.geometryType??void 0,retainId:!0,hasLabelingContext:this._hasLabelingContext(e)}),r=t.symbol||null;return null==r&&t.error&&Le.error(t.error.message),this._symbolConversionCache.set(e.id,r),r}_getSymbolComplexitiesUsedOrRenderer(e){if(null==e)return[];const i=e.getSymbols(),t="backgroundFillSymbol"in e?e.backgroundFillSymbol:null;if(!(t||i&&i.length))return[];const r=[],s=this._getSymbolComplexityUsedOrRenderer(t);null!=s&&r.push(s);for(const a of i){const e=this._getSymbolComplexityUsedOrRenderer(a);null!=e&&r.push(e)}return r}_getSymbolComplexityUsedOrRenderer(e){if(null==e)return null;const i=this._symbols.get(e.id);if(null!=i)return i.complexity;const t=this._getConvertedSymbol(e);return null!=t?me(t):null}_getSymbolComplexitiesUsed(){const e=[];return this._symbols.forEach((i=>{null!=i&&e.push(i.complexity)})),e}get _objectIdField(){return this.layer.objectIdField}constructor(e){super(e),this._propertiesPool=new be({computedExtent:Pe},this),this.computedExtent=null,this.currentRenderer=null,this.rendererHasGeometryOperations=!1,this._graphicStateTracking=null,this.graphics3DGraphics=new Map,this.stageLayer=null,this.stage=null,this._graphicsDrapedUids=new Set,this._graphicsBySymbol=new Map,this._symbolConversionCache=new Map,this._symbols=new Map,this._graphicsWithoutSymbol=new Map,this._graphicsWaitingForSymbol=new Map,this._graphicsUpdateId=0,this._handles=new a,this._frameTask=Se,this._suspendSymbolCleanup=!1,this._arcadeOnDemand=null,this._rendererChangeAbortController=null,this._elevationInfoChangeAbortController=null,this._initializeAbortController=null,this._scaleVisibility=null,this._filterVisibility=null,this._spatialIndex=null,this.extentPadding=0,this._updatingPendingLoadedGraphicsChange=null,this._featureStore=null,this._deconflictor=null,this._labeler=null,this._objectStates=null,this._viewElevationProvider=null,this._stageLayerElevationProvider=null,this._sharedSymbolResourcesOwnerHandle=null,this._whenGraphics3DGraphicRequests={},this._pendingUpdates=new Map,this._numberOfGraphics=0,this._numberOfGraphicsProvidingElevation=0,this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this._loadingSymbols=0,this._pendingUpdatesPool=new y({allocator:e=>e||new Te,deallocator:e=>(e.clear(),e)}),this._symbolWarningLogged=!1,this._geometryWarningLogged=!1,this._objectIdInvisibleSet=new Set,this._whenSymbolRemoved=new y,this.preferredUpdatePolicy=fe.SYNC,this._forcedUpdatePolicy=null,this.elevationFeatureExpressionEnabled=!0,this.owner=null,this.layer=null,this.graphicSymbolSupported=!0,this.getRenderingInfoWithoutRenderer=!1,this.setUidToIdOnAdd=!0,this.hasZ=null,this.hasM=null,this._usedMemory=0,this._visible=!1,this._startCreateGraphics=!1,this.symbolCreationContext=new ae(e.owner.view.resourceController.scheduler,((e,i)=>this._frameTask.schedule(e,i)))}initialize(){this._featureStore=new re({objectIdField:this.owner.layer&&this.owner.layer.objectIdField,hasZ:!!this.hasZ,hasM:!!this.hasM,viewSpatialReference:this._viewSpatialReference,featureSpatialReference:this.owner.featureSpatialReference,getSpatialIndex:()=>this.spatialIndex,forEach:e=>this.graphics3DGraphics.forEach(e)});const e=(e,i,t)=>this.spatialIndex.queryGraphicUIDsInExtent(e,i,t),{componentFactories:i}=this;if(null!=i.elevationAlignment){const t=i.elevationAlignment(this,e);this._elevationAlignment=t}if(null!=i.scaleVisibility){const t=i.scaleVisibility(this,e);this._scaleVisibility=t}if(null!=i.filterVisibility){const e=i.filterVisibility({featureStore:this._featureStore,getFeatureCount:()=>this.graphics3DGraphics.size,updateFeatureVisibilities:e=>this.modifyGraphics3DGraphicVisibilities((i=>i.setVisibilityFlag(X.GRAPHIC,ee.FILTER,e(N(i.graphic,this._objectIdField))))),setAllFeaturesVisibility:e=>this.modifyGraphics3DGraphicVisibilities((i=>i.setVisibilityFlag(X.GRAPHIC,ee.FILTER,e))),clearFeaturesVisibility:()=>this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(X.GRAPHIC,ee.FILTER,!0)))});this._filterVisibility=e}if(null!=i.deconflictor){const e=i.deconflictor(this);this._deconflictor=e}if(null!=i.labeler&&null!=this._scaleVisibility){const e=i.labeler(this,this._scaleVisibility);this._labeler=e}if(null!=i.objectStates){const e=i.objectStates(this);this._objectStates=e}this._initializeAbortController=new AbortController,this._initializePromise=this._initializeAsync()}async _initializeAsync(){const e=this._initializeAbortController?.signal,i=this.owner.view;this._viewElevationProvider=new K(this._viewSpatialReference,i),this._initializeStage(i,this.layer.uid);const t=i.sharedSymbolResources;this.symbolCreationContext.sharedResources=t,this._sharedSymbolResourcesOwnerHandle=t.addGraphicsOwner(this.owner),null!=this.currentRenderer&&(this.symbolCreationContext.renderer=this.currentRenderer),this.symbolCreationContext.stage=this.stage,this.symbolCreationContext.streamDataRequester=t.streamDataRequester,this.symbolCreationContext.renderCoordsHelper=i.renderCoordsHelper,this.symbolCreationContext.layer=this.layer,this.symbolCreationContext.graphicsCoreOwner=this.owner,this.symbolCreationContext.localOriginFactory=new _e(i.renderSpatialReference),this.symbolCreationContext.elevationProvider=i.elevationProvider,this.symbolCreationContext.notifyGraphicGeometryChanged=e=>this.notifyGraphicGeometryChanged(e),this.symbolCreationContext.notifyGraphicVisibilityChanged=e=>this.notifyGraphicVisibilityChanged(e);const r=ie(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);if(this.symbolCreationContext.featureExpressionInfoContext=await te(r,this._viewSpatialReference,e,Le),m(e),this.symbolCreationContext.screenSizePerspectiveEnabled=i.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this.symbolCreationContext.physicalBasedRenderingEnabled=!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled,this.symbolCreationContext.skipHighSymbolLods=!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods,"drapeSourceType"in this.owner){const{owner:e}=this;this.symbolCreationContext.drapeSourceRenderer=i.basemapTerrain.overlayManager.registerGeometryDrapeSource(e),this._handles.add(n((()=>i.basemapTerrain.overlayManager.unregisterDrapeSource(e))))}this._handles.add([_((()=>this.suspendedOrOutsideOfView),(()=>this._frameTask.reschedule((()=>this._updateLayerVisibility())))),_((()=>[this.layer?.screenSizePerspectiveEnabled,this.owner.view?.screenSizePerspectiveEnabled]),(()=>{const e=i.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled;e!==this.symbolCreationContext.screenSizePerspectiveEnabled&&(this.symbolCreationContext.screenSizePerspectiveEnabled=e,this._labeler?.reset(),this.recreateAllGraphicsAndSymbols())})),_((()=>this.owner.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(!!e))),_((()=>this.owner.view.state?.rasterPixelRatio),(()=>this._pixelRatioChange())),_((()=>!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._physicalBasedRenderingChange(e))),_((()=>!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods),(e=>this._skipHighSymbolLoDsChange(e))),f((()=>i.basemapTerrain?.tilingScheme),(e=>{if(e.spatialReference.equals(this.symbolCreationContext.overlaySR)||null==i.basemapTerrain.spatialReference||(this.symbolCreationContext.overlaySR=i.basemapTerrain.spatialReference),this._handles.has("loaded-graphics"))this.recreateAllGraphics();else{const e=()=>this.owner?.loadedGraphics;this._handles.add([v(e,"change",(e=>{this._graphicsCollectionChanged(e),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}),{onListenerAdd:()=>{this.recreateAllGraphics(),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}})],"loaded-graphics")}}),{initial:!0}),_((()=>this.effectiveUpdatePolicy),(e=>{null!=this.stageLayer&&(this.stageLayer.updatePolicy=e),this.symbolCreationContext.isAsync=this.effectiveUpdatePolicy===fe.ASYNC,e===fe.SYNC&&this.runTask(we)}),C)]),this._frameTask=i.resourceController.scheduler.registerTask(Ge.GRAPHICS_CORE,this),this.layer&&"featureReduction"in this.layer&&this._handles.add(_((()=>this.layer.featureReduction),(()=>this._deconflictor.featureReductionChange()))),this.notifyChange("averageSymbolComplexity"),this.rendererChange(this.owner.renderer).catch((()=>{})),this._initializeAbortController=null}_abortInitialize(){this._initializeAbortController&&(this._initializeAbortController.abort(),this._initializeAbortController=null)}destroy(){this._abortInitialize(),this._abortRendererChange(),this._abortElevationInfoChange(),this._frameTask.remove(),this._frameTask=Se,this.owner.view?.deconflictor?.removeGraphicsOwner(this),this.owner.view?.labeler?.removeGraphicsOwner(this),this._elevationAlignment=d(this._elevationAlignment),this._scaleVisibility=d(this._scaleVisibility),this._filterVisibility=d(this._filterVisibility),this._deconflictor=null,this._labeler=null,this._objectStates=d(this._objectStates),this.clear(),this._featureStore=d(this._featureStore),this._updatingPendingLoadedGraphicsChange=p(this._updatingPendingLoadedGraphicsChange),this._graphicStateTracking=d(this._graphicStateTracking),this.stage&&(this.stageLayer=d(this.stageLayer),this.stage=null),this._handles=d(this._handles),this._set("owner",null);for(const e in this._whenGraphics3DGraphicRequests)this._whenGraphics3DGraphicRequests[e].reject(new s("graphic:layer-destroyed","Layer has been destroyed"));this._whenGraphics3DGraphicRequests=null,this._sharedSymbolResourcesOwnerHandle=p(this._sharedSymbolResourcesOwnerHandle),this._propertiesPool=d(this._propertiesPool),this._pendingUpdatesPool=null,this._symbolConversionCache.clear(),this._objectIdInvisibleSet.clear(),this._spatialIndex=d(this._spatialIndex)}clear(){this._objectStates?.allGraphicsDeleted(),null!=this._graphicStateTracking&&this._graphicStateTracking.allGraphicsDeleted(),this.graphics3DGraphics.forEach((e=>e.destroy())),this._spatialIndex?.clear(),this.graphics3DGraphics.clear(),this._numberOfGraphics=0,this._usedMemory=0,this._updateLayerVisibility(),this._symbols.forEach(d),this._symbols.clear(),this._graphicsBySymbol.clear(),this._graphicsWithoutSymbol.clear(),this._graphicsWaitingForSymbol.clear(),this._pendingUpdates.clear(),this._pendingUpdatesPool.clear(),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this.notifyChange("updating"),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this._featureStore.events.emit("changed")}_initializeStage(e,i){this.stage=e._stage,this.stageLayer=new ve(this.stage,{pickable:!this.suspendedOrOutsideOfView,updatePolicy:this.effectiveUpdatePolicy},i);const t=this.stageLayer.events;t.on("objectTransformation",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),t.on("objectShaderTransformation",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),t.on("visibilityChanged",(e=>this.notifyGraphicVisibilityChanged(e.graphicUid))),t.on("objectGeometryAdded",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),t.on("objectGeometryRemoved",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),t.on("objectGeometryUpdated",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid)))}notifyGraphicGeometryChanged(e){if(null==this._graphicStateTracking||null==e)return;const i=this.graphics3DGraphics.get(e);i&&this._graphicStateTracking.updateGraphicGeometry(i)}notifyGraphicVisibilityChanged(e){if(null==this._graphicStateTracking||null==e)return;const i=this.graphics3DGraphics.get(e);i&&this._graphicStateTracking.updateGraphicVisibility(i)}_updateLayerVisibility(){const e=this.displayFeatureLimit.maximumNumberOfFeatures,i=this._numberOfGraphics>e*ke,t=!this.suspendedOrOutsideOfView&&!i;t!==this._visible&&(this._visible=t,t?(this.stageLayer.pickable=!0,this.updateAllGraphicsVisibility()):(this.stageLayer.pickable=!1,this._hideAllGraphics()),this._updateStageLayerVisibility())}_updateStageLayerVisibility(){this.stageLayer.visible=this._visible&&(null==this.layer.opacity||this.layer.opacity>0)}getGraphics3DGraphicById(e){return null!=e?this.graphics3DGraphics.get(e):void 0}getGraphics3DGraphicByObjectId(e){return this.owner.layer?.objectIdField?this._findGraphics3DGraphicByObjectId(e):null}_getGraphicObjectID(e,i=this.owner.layer&&this.owner.layer.objectIdField){return N(e,i)}get graphics3DGraphicsByObjectID(){const e=this.owner.layer&&this.owner.layer.objectIdField;if(!e)return;const i=new Map;return this.graphics3DGraphics.forEach((t=>{if(!t)return;const r=t.graphic,s=this._getGraphicObjectID(r,e);null!=s&&i.set(s,t)})),i}get labelsEnabled(){return!(!this._labeler||!this._labeler.layerLabelsEnabled())}async updateLabelingInfo(e){const i=this._deconflictor&&this._deconflictor.labelingInfoChange(e),t=this._labeler&&this._labeler.labelingInfoChange(e);await g([i,t])}updateVisibilityInfo(){this._deconflictor&&this._deconflictor.labelingInfoChange(),this._labeler&&this._labeler.visibilityInfoChange()}get symbolUpdateType(){if(this._pendingUpdates.size>0)return"unknown";let e=0,i=0;return l(this._symbols,((t,r)=>{if(null!=t){const s=t.getFastUpdateStatus();if(s.loading>0)return!0;this._graphicsBySymbol.has(r)&&(i+=s.fast,e+=s.slow)}return!1}))?"unknown":i>=0&&0===e?"fast":e>=0&&0===i?"slow":"mixed"}runTask(e){if(this._frameTask.processQueue(e),this._applyPendingUpdates(e),this.notifyChange("running"),this.running||this.notifyChange("updating"),this.notifyChange("updatingRemaining"),!e.hasProgressed)return xe.YIELD}setObjectIdVisibility(e,i){i?this._objectIdInvisibleSet.delete(e):this._objectIdInvisibleSet.add(e);const t=this._findGraphics3DGraphicByObjectId(e);null!=t&&this._updateUserVisibility(t)}_findGraphics3DGraphicByObjectId(e){return h(this.graphics3DGraphics,(i=>this._getGraphicObjectID(i.graphic)===e))}_updateUserVisibility(e){if(null==e)return!1;const i=e.graphic,t=this._getGraphicObjectID(i),r=i.visible&&!this.owner.suspended&&(null==t||!this._objectIdInvisibleSet.has(t));return e.setVisibilityFlag(X.GRAPHIC,ee.USER,r)}_whenGraphics3DGraphic(e){const i=this.graphics3DGraphics.get(e.uid);if(i)return Promise.resolve(i);const t=this._whenGraphics3DGraphicRequests[e.uid];if(t)return t.promise;const r=u();return this._whenGraphics3DGraphicRequests[e.uid]=r,r.promise}async _boundsForGraphics3DGraphic(e,i){const t=this._viewSpatialReference,r=this.owner.view.renderSpatialReference,s=this.owner.view.basemapTerrain.spatialReference,a=(e,i,s)=>L(e,r,i,e,t,i,s),n=(e,i,r)=>L(e,s,i,e,t,i,r),o=this._viewElevationProvider?{service:this._viewElevationProvider,useViewElevation:null!=i&&!!i.useViewElevation,minDemResolution:null!=i?i.minDemResolution:null,minDemResolutionForPoints:this.owner.view.resolution}:null,l=await e.getProjectedBoundingBox(a,n,o,i?.signal);if(!l)return null;const h=l.boundingBox;if(l.requiresDrapedElevation){const e=this.symbolCreationContext.elevationProvider;if(e){F(h,Ae);const i=e.getElevation(Ae[0],Ae[1],0,t,"ground")??0;h[2]=Math.min(h[2],i),h[5]=Math.max(h[5],i)}}return{boundingBox:h,screenSpaceObjects:l.screenSpaceObjects}}async whenGraphicBounds(e,i){await S((()=>this.owner?.loadedGraphics));const t=this.owner.layer&&this.owner.layer.objectIdField,r=this.owner.loadedGraphics.find((i=>i===e||null!=t&&null!=i.attributes&&e.attributes&&i.attributes[t]===e.attributes[t]));if(!r)throw new s("internal:graphic-not-part-of-view","Graphic is not part of this view");const a=await this._whenGraphics3DGraphic(r);return this._boundsForGraphics3DGraphic(a,i)}computeAttachmentOrigin(e,i){const t=this.graphics3DGraphics.get(e.uid);if(!t)return null;const r=t.computeAttachmentOrigin();if(0===r.render.num&&0===r.draped.num)return null;D(ze,0,0,0);let s=0;if(r.render.num>0){if(!A(r.render.origin,this.symbolCreationContext.renderCoordsHelper.spatialReference,We,i))return null;E(ze,ze,We),s++}if(r.draped.num>0){const[e,t]=r.draped.origin,a=this._viewElevationProvider.getElevation(e,t,"ground")??0;if(D(We,e,t,a),!A(We,this._viewElevationProvider.spatialReference,We,i))return null;E(ze,ze,We),s++}return s>1&&I(ze,ze,1/s),new Re({x:ze[0],y:ze[1],z:ze[2],spatialReference:i})}getSymbolLayerSize(e,i){const t=this._symbols.get(e.id);if(null==t)throw new s("internal:symbol-not-part-of-view","Symbol is not part of this view");const r=e.symbolLayers.indexOf(i);if(-1===r)throw new s("internal:missing-symbol-layer","Symbol layer is not in symbol");const a=t.getSymbolLayerSize(r);if(null==a)throw new s("internal:missing-size","Symbol layer has no valid size");return a}_graphicsCollectionChanged(e){this._startCreateGraphics&&(this.add(e.added),this.remove(e.removed))}graphicUpdateHandler(e){const i=e.graphic.uid,t=this.graphics3DGraphics.get(i);if(null!=t||null!=this._graphicsWithoutSymbol.get(i))switch(e.property){case"visible":this._graphicUpdateVisibleHandler(t);break;case"geometry":this._graphicUpdateGeometryHandler(t,e);break;case"symbol":this._graphicUpdateSymbolHandler(t,e);break;case"attributes":break;case"transform":this._graphicUpdateTransformHandler(t,e)}}_graphicUpdateGeometryHandler(e,i){this._graphicUpdateGeometryOrTransformHandler(e,i,(()=>null!=i.newValue&&null!=e&&e.graphics3DSymbol.updateGeometry(e,i.newValue)));const t=i.graphic.geometry;null!=t&&this._expandComputedExtent(t)}_graphicUpdateTransformHandler(e,i){const t=i.graphic.geometry;this._graphicUpdateGeometryOrTransformHandler(e,i,(()=>null!=i.newValue&&null!=e&&null!=t&&e.graphics3DSymbol.updateTransform(e,t.spatialReference,i.newValue,i.action)))}_graphicUpdateGeometryOrTransformHandler(e,i,t){if(null!=i.graphic.geometry)if(null!=e)t()||this._recreateGraphic(e.graphic);else{const e=i.graphic.symbol&&i.graphic.symbol.id;if(e){const i=this._symbols.get(e);if(null!=i&&i.loadStatus===pe.LOADING)return}this._recreateGraphic(i.graphic)}else this._recreateGraphic(i.graphic)}_graphicUpdateSymbolHandler(e,i){const t=i.graphic,r=null!=e?e.graphics3DSymbol:null!=i.oldValue?this._symbols.get(i.oldValue.id):null;if(null==r||null==i.newValue)return void this._recreateGraphic(t);const s=r.symbol,a=this._getConvertedSymbol(i.newValue);if(null!=a&&(a.type!==s.type||"web-style"===a.type)||"web-style"===s.type)return void this._recreateGraphic(t);const n=this._graphicsBySymbol.get(s.id);if(n&&1!==n.size)return void this._recreateGraphic(t);const o=P(s,a);if(null==o)return void this._updateSymbolMapping(s.id,a);const l={diff:o,graphics3DGraphicPatches:[],symbolStatePatches:[]};if(r.prepareSymbolPatch(l),!R(l.diff))return void this._recreateGraphic(t);const h=this._getRenderingInfo(t);if(null==h)return void this._recreateGraphic(t);const d=r.extentPadding;for(const p of l.symbolStatePatches)p();if(d!==r.extentPadding&&this._recomputeExtentPadding(),null!=e)for(const p of l.graphics3DGraphicPatches)p(e,h);this._updateSymbolMapping(s.id,a)}_graphicUpdateVisibleHandler(e){this._updateUserVisibility(e)&&(this._labeler&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty())}recreateGraphics(e){this._suspendSymbolCleanup=!0,this.remove(e),this.add(e),this._suspendSymbolCleanup=!1,this.effectiveUpdatePolicy===fe.SYNC&&this._cleanupSymbols()}_recreateGraphic(e){this.recreateGraphics([e])}_beginGraphicUpdate(e){const i=this._graphicsUpdateId;return this._graphicsUpdateId++,this._graphicsWaitingForSymbol.set(e.uid,i),1===this._graphicsWaitingForSymbol.size&&this.notifyChange("updating"),i}_endGraphicUpdate(e){e&&(this._graphicsWaitingForSymbol.delete(e.uid),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("updating")))}_recomputeExtentPadding(){let e=0;this._symbols.forEach((i=>{null!=i&&(e=Math.max(e,i.extentPadding))})),this._set("extentPadding",e)}_expandComputedExtent(e){const i=Oe,t=e.spatialReference;B(e,i);const r=this._viewSpatialReference,s=Ue.tmpVec;if(W(t,r)||O(i[0],i[1],0,t,s,r)&&(i[0]=s[0],i[1]=s[1],O(i[3],i[4],0,t,s,r),i[3]=s[0],i[4]=s[1]),!(isFinite(i[0])&&isFinite(i[3])&&isFinite(i[1])&&isFinite(i[4])))return;const a=this.computedExtent;let n=null;const o=isFinite(i[2])&&isFinite(i[5]),l=o&&(!a||null==a.zmin||i[2]<a.zmin),h=o&&(!a||null==a.zmax||i[5]>a.zmax);if(a){(i[0]<a.xmin||i[1]<a.ymin||i[3]>a.xmax||i[4]>a.ymax||l||h)&&(n=this._propertiesPool.get("computedExtent"),n.xmin=Math.min(i[0],a.xmin),n.ymin=Math.min(i[1],a.ymin),n.xmax=Math.max(i[3],a.xmax),n.ymax=Math.max(i[4],a.ymax),n.spatialReference=r)}else n=this._propertiesPool.get("computedExtent"),n.xmin=i[0],n.ymin=i[1],n.xmax=i[3],n.ymax=i[4],n.spatialReference=r;n&&(l&&(n.zmin=i[2]),h&&(n.zmax=i[5]),this._set("computedExtent",n))}_abortElevationInfoChange(){this._elevationInfoChangeAbortController&&(this._elevationInfoChangeAbortController.abort(),this._elevationInfoChangeAbortController=null)}async elevationInfoChange(){this._abortElevationInfoChange();const e=new AbortController;this._elevationInfoChangeAbortController=e;const i=ie(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);this.symbolCreationContext.featureExpressionInfoContext=await te(i,this._viewSpatialReference,e.signal,Le),m(e.signal),this._elevationInfoChangeAbortController=null,this._labeler?.elevationInfoChange(),this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("elevationInfo",i)?i.forEach((e=>{const i=e.graphic,t=e.labelLayers;for(const r of t){r.graphics3DSymbolLayer.updateGraphicElevationContext(i,r)}})):this._recreateSymbol(t)})),this.updateStageLayerElevationProvider(),this._elevationAlignment?.elevationInfoChange()}updateStageLayerElevationProvider(){this._stageLayerElevationProvider?(this.layer.elevationInfo&&"relative-to-scene"===this.layer.elevationInfo.mode||0===this._numberOfGraphicsProvidingElevation)&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=c(this._stageLayerElevationProvider)):(!this.layer.elevationInfo||this.layer.elevationInfo&&"relative-to-scene"!==this.layer.elevationInfo.mode)&&this._numberOfGraphicsProvidingElevation>0&&(this._stageLayerElevationProvider=new ge({layer:this.layer,stageLayer:this.stageLayer,view:this.owner.view}),this.owner.view.elevationProvider.register("scene",this._stageLayerElevationProvider))}_clearSymbolsAndGraphics(){this.clear(),null!=this._filterVisibility&&this._filterVisibility.clear(),this._labeler?.reset(),this._deconflictor?.clear(),this._elevationAlignment?.clear(),this.stageLayer?.invalidateSpatialQueryAccelerator(),this._stageLayerElevationProvider&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=c(this._stageLayerElevationProvider))}startCreateGraphics(){this._startCreateGraphics=!0,this.recreateAllGraphics()}recreateAllGraphics(){this._recreateAllGraphics(!1)}recreateAllGraphicsAndSymbols(){this._recreateAllGraphics(!0)}_recreateAllGraphics(e=!1){if(!this._startCreateGraphics)return;const{loadedGraphics:i,view:t}=this.owner,r=t.basemapTerrain.tilingScheme&&i&&i.length?i.toArray():null;!e&&r||this._clearSymbolsAndGraphics(),this.symbolCreationContext.screenSizePerspectiveEnabled=this.owner.view.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this._set("computedExtent",null),r&&(e?this.add(r):this.recreateGraphics(r))}_recreateSymbol(e){const i=this._graphicsBySymbol.get(e),t=[];i&&(i.forEach(((e,i)=>{const r=e.usedMemory;this._conditionalRemove(e,i),this._spatialIndex?.remove(e),t.push(e.graphic),e.destroy(),this._removeGraphics3DGraphic(i,r),this._updateLayerVisibility(),this._featureStore.events.emit("changed")})),this._graphicsBySymbol.set(e,new Map));const r=this._symbols.get(e);d(r),this._symbols.delete(e),this.add(t)}_recreateGraphicsForSymbol(e){const i=this._graphicsBySymbol.get(e);if(i){const e=[];i.forEach((i=>e.push(i.graphic))),this.recreateGraphics(e)}}_conditionalRemove(e,i){this._graphicsDrapedUids.delete(i),this._objectStates?.removeGraphic(e),this._labeler?.removeGraphic(e),this._deconflictor?.removeGraphic(e),null!=this._graphicStateTracking&&this._graphicStateTracking.removeGraphic(e)}add(e){e&&0!==e.length&&(this.owner.view.basemapTerrain&&this.owner.view.basemapTerrain.tilingScheme?(this._updatePolicyForGraphics(e)===fe.ASYNC?this._addDelayed(e):this._addImmediate(e),this.notifyChange("updating")):Le.error("#add()","Cannot add graphics before terrain surface has been initialized"))}_updatePolicyForGraphics(e){if(this.effectiveUpdatePolicy===fe.SYNC&&("mesh"===this.layer.geometryType||null==this.layer.geometryType))for(const i of e)if(null!=i.geometry&&"mesh"===i.geometry.type&&!i.geometry.loaded)return fe.ASYNC;return this.effectiveUpdatePolicy}_addImmediate(e){this._geometryWarningLogged=!1,this._symbolWarningLogged=!1;for(const i of e)this._addGraphic(i,this._getRenderingInfo(i,Le),fe.SYNC);this._cleanupSymbols(),this._labeler&&(this.owner.view.labeler.setDirty(),this._cleanupSymbols()),this.owner.view.deconflictor.setDirty()}_addDelayed(e){for(const i of e){const e=i.uid;let t=this._pendingUpdates.get(e);t?t.add?t.state!==Fe.NEW&&t.abortController?.abort():this._pendingAdds++:(t=this._pendingUpdatesPool.pushNew(),this._pendingAdds++,this._pendingUpdates.set(e,t)),t.add=i}this.notifyChange("running"),this.notifyChange("updatingRemaining")}remove(e){this.effectiveUpdatePolicy===fe.ASYNC?this._removeDelayed(e):this._removeImmediate(e),this.notifyChange("updating")}_removeImmediate(e){for(const i of e)this._removeGraphic(i);this._cleanupSymbols(),this._labeler&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty()}_removeDelayed(e){for(const i of e){const e=i.uid,t=this._pendingUpdates.get(e);if(t)t.add&&(t.remove?t.add=null:this._pendingUpdates.delete(e),t.state===Fe.LOADING&&t.abortController?.abort(),this._pendingAdds--);else{const t=this._pendingUpdatesPool.pushNew();t.remove=i,this._pendingUpdates.set(e,t),this._pendingRemoves++,this._applyPendingRemovesFirst=!0}}0===this._pendingUpdates.size&&this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("updatingRemaining")}_finishPendingUpdates(){this._pendingUpdatesPool.clear(),this._cleanupSymbols(),(this._pendingAdds||this._pendingRemoves)&&Le.warn("pendingAdds/Removes in inconsistent state!"),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1}_applyPendingUpdates(e){if(this._geometryWarningLogged=!1,this._symbolWarningLogged=!1,0===this._pendingUpdates.size&&this._spatialIndex?.updating)return this._spatialIndex.update(),void e.madeProgress();if(this._applyPendingRemovesFirst){this._applyPendingRemovesFirst=!1;for(const[i,t]of this._pendingUpdates){if(e.done){this._applyPendingRemovesFirst=!0;break}if(t.remove&&!t.add&&(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(t.remove),t.remove=null,this._pendingUpdates.delete(i),0===this._pendingRemoves))break}}for(const[i,t]of this._pendingUpdates){if(e.done)break;t.add&&t.state===Fe.NEW&&this._processPendingUpdateNew(t);let r=this.effectiveUpdatePolicy;if(!t.remove||t.add&&t.state!==Fe.READY||(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(t.remove),t.remove=null,r=fe.SYNC),t.add)switch(t.state){case Fe.READY:this._addGraphic(t.add,t.renderingInfo,r),t.add=null,this._pendingAdds--,e.madeProgress();break;case Fe.REJECTED:t.add=null,this._pendingAdds--;case Fe.LOADING:}null==t.remove&&null==t.add&&this._pendingUpdates.delete(i)}0===this._pendingUpdates.size&&(this._finishPendingUpdates(),this.notifyChange("running"))}_processPendingUpdateNew(e){if(!e.add)return void(e.state=Fe.READY);const i=e.add.geometry;null==i||"mesh"!==i.type||i.loaded?this._processPendingUpdateNewRenderingInfo(e):this._processPendingUpdateNewMesh(e,i)}async _processPendingUpdateNewMesh(e,i){e.state=Fe.LOADING,e.abortController=new AbortController;const t=e.abortController.signal;try{await i.load({signal:t})}catch(r){return this._processPendingUpdateNewError(e,r)}e.abortController=null,this._processPendingUpdateNewRenderingInfo(e)}_processPendingUpdateNewError(e,i){e.abortController=null,b(i)?e.state=Fe.NEW:e.state=Fe.REJECTED}async _processPendingUpdateNewRenderingInfo(e){if(null==this.layer.renderer||"dictionary"!==this.layer.renderer.type)return e.renderingInfo=this._getRenderingInfo(e.add,Le),void(e.state=Fe.READY);e.state=Fe.LOADING,e.abortController=new AbortController;let i=null;try{i=await this._getRenderingInfoAsync(e.add,{signal:e.abortController.signal})}catch(t){return e.abortController=null,void(b(t)?e.state=Fe.NEW:e.state=Fe.REJECTED)}null==i||null==i.symbol?(Le&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,Le.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),e.renderingInfo=null):e.renderingInfo=i,e.state=Fe.READY}_addGraphic(e,i,t){if(this._graphicsWithoutSymbol.set(e.uid,e),null==i||null==i.symbol||!H(e))return;null!=this.stage.renderView.objectAndLayerIdRenderHelper&&this.setUidToIdOnAdd&&this.stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(e.objectId,e.uid,this.layer.id,this.layer.uid,!!this.layer.popupEnabled&&Ce(this.layer,this.owner.view.popup?.defaultPopupTemplateEnabled));const r=i.symbol,s=this.getOrCreateGraphics3DSymbol(r,i.renderer);if(null==s)return;this._expandComputedExtent(e.geometry);const a=this._beginGraphicUpdate(e),n=new se(e,i,this.layer);let o=!1;const l=e=>{e===s.symbol.id&&(o=!0)};this._whenSymbolRemoved.push(l);const h=()=>{if(--this._loadingSymbols,this.destroyed)return;this._whenSymbolRemoved.removeUnordered(l);if(this._graphicsWaitingForSymbol.get(e.uid)!==a||o||s.destroyed||this.graphicSymbolSupported&&e.symbol&&e.symbol.id!==s.symbol.id)--s.referenced,this._cleanupSymbols();else{const i=this._createGraphics3DGraphic(s,n);this._spatialIndex&&null!=i&&this._spatialIndex.add(i),--s.referenced,this._endGraphicUpdate(e)}this._featureStore.events.emit("changed"),this._labeler&&this.owner.view.labeler.setDirty()},d=i=>{--this._loadingSymbols,this.destroyed||(this._whenSymbolRemoved.removeUnordered(l),o||(b(i)?this.add([e]):s.destroyed||this._endGraphicUpdate(e)))};++this._loadingSymbols,t===fe.ASYNC?s.load((()=>this._frameTask.schedule(h)),(e=>this._frameTask.schedule((()=>d(e))))):s.load(h,d)}_removeGraphic(e){const i=e.uid,t=this.graphics3DGraphics.get(i);if(t){t.graphics3DSymbol.onRemoveGraphic(t);const e=t.usedMemory,r=t.isElevationSource;this._conditionalRemove(t,i),this._spatialIndex?.remove(t);const s=t.graphics3DSymbol.symbol.id;this._graphicsBySymbol.get(s)?.delete(i),this._graphicsWithoutSymbol.delete(i),this._removeGraphics3DGraphic(i,e,r),t.destroy(),this._featureStore.events.emit("changed")}else this._graphicsWithoutSymbol.delete(i),this._graphicsWaitingForSymbol.delete(i),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("updating"))}_hasLabelingContext(e){if(e instanceof De||e instanceof Ee){const i=this.symbolCreationContext.layer;return!!i.labelingInfo&&i.labelingInfo.some((i=>i.symbol===e))}return!1}_hasValidSymbolCreationContext(e){return!(e instanceof De&&!this._hasLabelingContext(e))||(Le.error("LabelSymbol3D is only valid as part of a LabelClass. Using LabelSymbol3D as a renderer symbol is not supported."),!1)}_getRenderingInfo(e,i){const t=e.geometry;if(null==t)return i&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!j(t.spatialReference,this._viewSpatialReference))return i&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has incompatible spatial reference and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return i&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?q(e,this.layer):e;let s;if(this.owner.getRenderingInfo&&(this.getRenderingInfoWithoutRenderer||null!=this.currentRenderer))s=this.owner.getRenderingInfo(r,this.currentRenderer,this._arcadeOnDemand);else{s={symbol:r.symbol||J(r.geometry)}}return null==s||null==s.symbol?(i&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),null):s}_getRenderingInfoAsync(e,i){if(null==e.geometry)return Le&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,Le.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return Le&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,Le.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const t=this.rendererHasGeometryOperations?q(e,this.layer):e;return this.owner.getRenderingInfoAsync(t,this.currentRenderer,this._arcadeOnDemand,i)}_createGraphics3DSymbol(e,i){if(!this._hasValidSymbolCreationContext(e))return null;const t=this._getConvertedSymbol(e);if(!t)return null;let r;if(null!=i&&"backgroundFillSymbol"in i&&i.backgroundFillSymbol){const e=Q(i.backgroundFillSymbol,{ignoreDrivers:!0});null!=e.symbol&&"web-style"!==e.symbol.type&&"cim"!==e.symbol.type&&(r=e.symbol.symbolLayers)}const s=ne(t,this.symbolCreationContext,r);return s.load((()=>{const e=s.extentPadding;e>this.extentPadding&&this._set("extentPadding",e),this.notifyChange("averageSymbolComplexity")}),(()=>{})),s}getOrCreateGraphics3DSymbol(e,i){let t=this._symbols.get(e.id);return void 0===t&&(t=e instanceof Ie?new oe(e,(e=>this._frameTask.schedule(e)),(e=>this._createGraphics3DSymbol(e,i))):this._createGraphics3DSymbol(e,i),this._symbols.set(e.id,t)),null!=t&&++t.referenced,t}trackGraphicState(e){return null==this._graphicStateTracking&&(this._graphicStateTracking=new le(this)),this._graphicStateTracking.add(e)}_addGraphics3DGraphic(e){this._usedMemory+=e.usedMemory,this.graphics3DGraphics.set(e.graphic.uid,e),this._numberOfGraphics++,e.isElevationSource&&(this._numberOfGraphicsProvidingElevation++,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_removeGraphics3DGraphic(e,i,t=!1){this._usedMemory-=i,this.graphics3DGraphics.delete(e),this._numberOfGraphics--,t&&(this._numberOfGraphicsProvidingElevation--,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_createGraphics3DGraphic(e,i){const t=i.graphic;if(this._graphicsWithoutSymbol.delete(t.uid),!this._symbols.has(e.symbol.id))return this.add([t]),null;if(this.graphics3DGraphics.has(t.uid))return null;const r=e.createGraphics3DGraphic(i);if(null==r)return null;this._addGraphics3DGraphic(r);const s=e.symbol.id;this._graphicsBySymbol.has(s)||this._graphicsBySymbol.set(s,new Map),this._graphicsBySymbol.get(s).set(t.uid,r);if(r.isDraped&&this._graphicsDrapedUids.add(t.uid),r.centroid=null,null!=t.geometry&&"point"!==t.geometry.type&&(r.centroid=he(t.geometry,this._viewSpatialReference)),this._updateUserVisibility(r),null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(r),null!=this._filterVisibility){const{defaultVisibility:e}=this._filterVisibility;r.setVisibilityFlag(X.GRAPHIC,ee.FILTER,e),e||this._filterVisibility.reapply()}this._deconflictor?.addGraphic(r),this._labeler?.addGraphic(r),this._objectStates?.addGraphic(r),this._deconflictor&&this.owner.view.deconflictor.setInitialIconVisibilityFlag(this,r),r.initialize(this.stageLayer,this.owner),null!=this._graphicStateTracking&&this._graphicStateTracking.addGraphic(r);const a=this._whenGraphics3DGraphicRequests[t.uid];return a&&(delete this._whenGraphics3DGraphicRequests[t.uid],a.resolve(r)),r}_abortRendererChange(){this._rendererChangeAbortController&&(this._rendererChangeAbortController.abort(),this._rendererChangeAbortController=null)}async rendererChange(e){if(this._abortRendererChange(),e!==this.currentRenderer)if(this._validateRenderer(e),null==e&&this._currentRendererChange(null,!1),Y(e))if(null!=e&&e.arcadeRequired){const i=new AbortController;this._rendererChangeAbortController=i;const{arcadeUtils:t}=await this._ensureArcade();m(i);const r=t.hasGeometryOperations(e);r&&(await t.enableGeometryOperations(),m(i)),this.effectiveUpdatePolicy===fe.ASYNC?await this._frameTask.schedule((()=>this._currentRendererChange(e,r)),i.signal):this._currentRendererChange(e,r),this._rendererChangeAbortController=null}else if(this.effectiveUpdatePolicy===fe.ASYNC){const i=new AbortController;this._rendererChangeAbortController=i,await this._frameTask.schedule((()=>this._currentRendererChange(e,!1)),i.signal),this._rendererChangeAbortController=null}else this._currentRendererChange(e,!1);else this._currentRendererChange(e,!1)}async _ensureArcade(){return null==this._arcadeOnDemand?(this._arcadeOnDemand=await Z(),this._arcadeOnDemand):this._arcadeOnDemand}_currentRendererChange(e,i){this.currentRenderer=e,this.rendererHasGeometryOperations=i,this.symbolCreationContext.arcade=this._arcadeOnDemand;const t=this.symbolCreationContext.renderer;if(e===t)return;if(this._symbolConversionCache.clear(),null==e)return this.symbolCreationContext.renderer=null,void this.recreateAllGraphicsAndSymbols();const r=P(t,e);this._updateUnchangedSymbolMappings(r,e,t),this.symbolCreationContext.renderer=e,null!=r&&("complete"===r.type?this.recreateAllGraphicsAndSymbols():"partial"===r.type&&(this._applyRendererDiff(r,e,t)?this._volatileGraphicsUpdated():this.recreateAllGraphicsAndSymbols()),this.notifyChange("averageSymbolComplexity"))}_diffHasSymbolChange(e){for(const i in e.diff)switch(i){case"visualVariables":case"defaultSymbol":case"uniqueValueInfos":break;case"uniqueValueGroups":case"authoringInfo":case"fieldDelimiter":delete e.diff[i];break;default:return!0}return!1}_applySymbolSetDiff(e,i,t){e=e||[],i=i||[];const r=[];for(const s of i){const i=this._graphicsBySymbol.get(s.id);i&&i.forEach(((a,n)=>{const o=a.graphic,l=this.layer instanceof M?this.layer:null,h=this._arcadeOnDemand;if(s===t.defaultSymbol&&t.getSymbol(q(o,l),{arcade:h})===t.defaultSymbol)return;const d=a.usedMemory;e.length||t.defaultSymbol?r.push(o):this._graphicsWithoutSymbol.set(n,o);const p=this.graphics3DGraphics.get(n);this._conditionalRemove(p,n),a.destroy(),i.delete(n),this._removeGraphics3DGraphic(n,d),this._updateLayerVisibility()})),this._whenSymbolRemoved.forAll((e=>e(s.id)))}(e.length||r.length)&&(this._graphicsWithoutSymbol.forEach((e=>r.push(e))),this._graphicsWithoutSymbol.clear(),this.add(r)),this._cleanupSymbols(),this._labeler&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty()}_applyUniqueValueRendererDiff(e,i,t){const s=e.diff.defaultSymbol,a=e.diff.uniqueValueInfos;if(s||a){const n=a?a.added.map((e=>e.symbol)).filter(r):[],o=a?a.removed.map((e=>e.symbol)).filter(r):[];if(a)for(let e=0;e<a.changed.length;e++)n.push(a.changed[e].newValue.symbol),o.push(a.changed[e].oldValue.symbol);return s?(t.defaultSymbol&&o.push(t.defaultSymbol),i.defaultSymbol&&n.push(i.defaultSymbol)):t.defaultSymbol&&n.length&&o.push(i.defaultSymbol),this._applySymbolSetDiff(n,o,i),delete e.diff.defaultSymbol,delete e.diff.uniqueValueInfos,!0}return!1}_calculateUnchangedSymbolMapping(e,i,t){if("unique-value"!==i?.type||"unique-value"!==t?.type||null!=e&&"partial"!==e.type)return[];const r=e=>null!=e?e.id:null,s=e&&e.diff,a=s&&s.defaultSymbol,n=s&&s.uniqueValueInfos;let o;if(n)o=n.unchanged.map((e=>({oldId:r(e.oldValue.symbol),newId:r(e.newValue.symbol)})));else{o=[];for(const e of t.uniqueValueInfos??[]){const t=r(e.symbol),s=i.uniqueValueInfos?.find((i=>i.value===e.value));s&&t!==r(s.symbol)&&o.push({oldId:t,newId:r(s.symbol)})}}return!a&&t.defaultSymbol&&o.push({oldId:r(t.defaultSymbol),newId:r(i.defaultSymbol)}),o}_updateSymbolMapping(e,i){const t=null!=i&&i?"string"==typeof i?i:i.id:null;if(null==e||e===t)return;const r=this._graphicsBySymbol.get(e);this._graphicsBySymbol.delete(e),void 0!==r&&this._graphicsBySymbol.set(t,r);const s=this._symbols.get(e);if(void 0!==s&&(this._symbols.delete(e),this._symbols.set(t,s),null!=s)){const e="string"==typeof i?null:i;null!=e?s.symbol=e:s.symbol.id=t}}_updateUnchangedSymbolMappings(e,i,t){const r=this._calculateUnchangedSymbolMapping(e,i,t);for(const{oldId:s,newId:a}of r)this._updateSymbolMapping(s,a)}_applyRendererDiff(e,t,r){if(this._diffHasSymbolChange(e))return!1;if(t instanceof i&&r instanceof i&&this._applyUniqueValueRendererDiff(e,t,r)&&0===Object.keys(e.diff).length)return!0;for(const[i]of this._graphicsBySymbol){const r=this._symbols.get(i);if(null!=r)switch(r.applyRendererDiff(e,t)){case de.RecreateSymbol:this._recreateSymbol(i);break;case de.RecreateGraphics:this._recreateGraphicsForSymbol(i);case de.FastUpdate:}}return!0}opacityChange(){this.forEachGraphics3DSymbol(((e,i)=>e.globalPropertyChanged("opacity",i))),this._updateStageLayerVisibility()}_slicePlaneEnabledChange(e){e!==this.symbolCreationContext.slicePlaneEnabled&&(this.symbolCreationContext.slicePlaneEnabled=e,this.stageLayer.sliceable=e,this.forEachGraphics3DSymbol(((e,i)=>e.globalPropertyChanged("slicePlaneEnabled",i))),this._deconflictor&&this._deconflictor.slicePlaneEnabledChange(),this._labeler&&this._labeler.slicePlaneEnabledChange())}_physicalBasedRenderingChange(e){this.symbolCreationContext.physicalBasedRenderingEnabled=e,this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("physicalBasedRenderingEnabled",i)||this._recreateSymbol(t)}))}_skipHighSymbolLoDsChange(e){this.symbolCreationContext.skipHighSymbolLods=e,this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("skipHighSymbolLods",i)||this._recreateSymbol(t)}))}_pixelRatioChange(){this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("pixelRatio",i)||this._recreateSymbol(t)}))}_signalUpdatingDuringAsyncLoadedGraphicsChange(){this._updatingPendingLoadedGraphicsChange&&this._updatingPendingLoadedGraphicsChange.remove(),this._updatingPendingLoadedGraphicsChange=w((()=>{this._updatingPendingLoadedGraphicsChange=null}))}setClippingExtent(e,i){const t=this.symbolCreationContext.clippingExtent,r=z();return ue(e,r,i)?this.symbolCreationContext.clippingExtent=T(V(),r):this.symbolCreationContext.clippingExtent=null,!k(this.symbolCreationContext.clippingExtent,t)}modifyGraphics3DGraphicVisibilities(e){if(this.destroyed)return;let i=!1;this.graphics3DGraphics.forEach((t=>{e(t)&&(i=!0)})),i&&(this.owner.view.labeler?.setDirty(),this.owner.view.deconflictor?.setDirty())}forEachGraphics3DSymbol(e){for(const[i,t]of this._symbols){if(null==t)return;e(t,this._graphicsBySymbol.get(i)||Me,i)}}updateAllGraphicsVisibility(){null!=this._filterVisibility&&this._filterVisibility.reapply(),this.modifyGraphics3DGraphicVisibilities((e=>{const i=this._updateUserVisibility(e),t=null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(e);return i||t}))}_hideAllGraphics(){this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(X.GRAPHIC,ee.USER,!1)))}_validateRenderer(e){const i=$(e,{geometryType:this.layer?.geometryType});if(i){const e=`Renderer for layer '${this.layer.title?`${this.layer.title}, `:""}, id:${this.layer.id}' is not supported in a SceneView`;Le.warn(e,i.message)}}_volatileGraphicsUpdated(){this._labeler?.reset(),this.stageLayer.shaderTransformationChanged(),this.notifyChange("updating")}_cleanupSymbols(){if(this._graphicsWaitingForSymbol.size>0||this._suspendSymbolCleanup)return;let e=!1;this._symbols.forEach(((i,t)=>{if(null==i||i.referenced>0)return;const r=this._graphicsBySymbol.get(t);r&&0!==r.size||(this._graphicsBySymbol.delete(t),this._symbols.delete(t),d(i),e=!0)})),e&&(this._recomputeExtentPadding(),this.notifyChange("averageSymbolComplexity"))}get test(){return{snapshotInternals:()=>({graphics:[...this.graphics3DGraphics.keys()].sort(),symbols:[...this._symbols.keys()].sort(),graphicsBySymbol:[...this._graphicsBySymbol.keys()].sort().map((e=>({symbolId:e,graphics:[...this._graphicsBySymbol.get(e).keys()].sort()}))),graphicsWithoutSymbol:[...this._graphicsWithoutSymbol.keys()].sort(),graphicsDrapedUids:[...this._graphicsDrapedUids].sort(),pendingUpdates:this._pendingUpdates}),symbols:this._symbols,filterVisibility:this._filterVisibility,numPending:this._pendingUpdates.size,forceUpdatePolicy:e=>{this._forcedUpdatePolicy=e}}}get performanceInfo(){return{visible:this.graphics3DGraphics.size,missing:this._graphicsWithoutSymbol.size,pending:this._pendingUpdates.size}}};var Fe;Ve.tmpVec=U(),e([G({readOnly:!0})],Ve.prototype,"computedExtent",void 0),e([G()],Ve.prototype,"currentRenderer",void 0),e([G()],Ve.prototype,"rendererHasGeometryOperations",void 0),e([G()],Ve.prototype,"_frameTask",void 0),e([G({readOnly:!0})],Ve.prototype,"_viewSpatialReference",null),e([G()],Ve.prototype,"_rendererChangeAbortController",void 0),e([G()],Ve.prototype,"_elevationInfoChangeAbortController",void 0),e([G()],Ve.prototype,"_initializeAbortController",void 0),e([G()],Ve.prototype,"_elevationAlignment",void 0),e([G()],Ve.prototype,"_scaleVisibility",void 0),e([G()],Ve.prototype,"_filterVisibility",void 0),e([G()],Ve.prototype,"_initializePromise",void 0),e([G()],Ve.prototype,"_spatialIndex",void 0),e([G({readOnly:!0})],Ve.prototype,"extentPadding",void 0),e([G()],Ve.prototype,"_updatingPendingLoadedGraphicsChange",void 0),e([G()],Ve.prototype,"_featureStore",void 0),e([G()],Ve.prototype,"_deconflictor",void 0),e([G()],Ve.prototype,"_labeler",void 0),e([G()],Ve.prototype,"_objectStates",void 0),e([G()],Ve.prototype,"_loadingSymbols",void 0),e([G()],Ve.prototype,"preferredUpdatePolicy",void 0),e([G()],Ve.prototype,"_forcedUpdatePolicy",void 0),e([G({readOnly:!0})],Ve.prototype,"effectiveUpdatePolicy",null),e([G({constructOnly:!0})],Ve.prototype,"elevationFeatureExpressionEnabled",void 0),e([G({constructOnly:!0})],Ve.prototype,"owner",void 0),e([G({constructOnly:!0})],Ve.prototype,"layer",void 0),e([G({constructOnly:!0})],Ve.prototype,"graphicSymbolSupported",void 0),e([G({constructOnly:!0})],Ve.prototype,"getRenderingInfoWithoutRenderer",void 0),e([G({constructOnly:!0})],Ve.prototype,"componentFactories",void 0),e([G({constructOnly:!0})],Ve.prototype,"setUidToIdOnAdd",void 0),e([G()],Ve.prototype,"featureStore",null),e([G()],Ve.prototype,"initializePromise",null),e([G()],Ve.prototype,"scaleVisibility",null),e([G()],Ve.prototype,"elevationAlignment",null),e([G()],Ve.prototype,"objectStates",null),e([G()],Ve.prototype,"filterVisibility",null),e([G({readOnly:!0})],Ve.prototype,"updating",null),e([G({readOnly:!0})],Ve.prototype,"running",null),e([G({readOnly:!0})],Ve.prototype,"suspendedOrOutsideOfView",null),e([G({readOnly:!0,dependsOn:[]})],Ve.prototype,"updatingRemaining",null),e([G({readOnly:!0,dependsOn:["owner.view.qualitySettings.graphics3D.maxTotalNumberOfPrimitives","owner.view.qualitySettings.graphics3D.maxTotalNumberOfFeatures","averageSymbolComplexity"]})],Ve.prototype,"displayFeatureLimit",null),e([G({readOnly:!0,dependsOn:[]})],Ve.prototype,"averageSymbolComplexity",null),e([G({constructOnly:!0})],Ve.prototype,"hasZ",void 0),e([G({constructOnly:!0})],Ve.prototype,"hasM",void 0),e([G()],Ve.prototype,"_objectIdField",null),Ve=Ue=e([x(je)],Ve),function(e){e[e.NEW=0]="NEW",e[e.LOADING=1]="LOADING",e[e.READY=2]="READY",e[e.REJECTED=3]="REJECTED"}(Fe||(Fe={}));class Te{constructor(){this.add=null,this.renderingInfo=null,this.state=Fe.NEW,this.abortController=null,this.remove=null}clear(){this.add=null,this.renderingInfo=null,this.state=Fe.NEW,this.abortController=null,this.remove=null}}const ke=10,ze=U(),We=U(),Me=new Map;export{Ve as Graphics3DCore};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import"../../../../renderers/ClassBreaksRenderer.js";import"../../../../renderers/DictionaryRenderer.js";import"../../../../renderers/DotDensityRenderer.js";import"../../../../renderers/HeatmapRenderer.js";import"../../../../renderers/PieChartRenderer.js";import"../../../../renderers/Renderer.js";import"../../../../renderers/SimpleRenderer.js";import i from"../../../../renderers/UniqueValueRenderer.js";import"../../../../renderers/support/jsonUtils.js";import"../../../../symbols.js";import t from"../../../../core/Accessor.js";import{isSome as r}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import s from"../../../../core/Error.js";import a from"../../../../core/Handles.js";import{makeHandle as n}from"../../../../core/handleUtils.js";import o from"../../../../core/Logger.js";import{someMap as l,findInMap as h}from"../../../../core/MapUtils.js";import{destroyMaybe as d,removeMaybe as p,disposeMaybe as c}from"../../../../core/maybe.js";import y from"../../../../core/PooledArray.js";import{throwIfAborted as m,eachAlways as g,createResolver as u,isAbortError as b}from"../../../../core/promiseUtils.js";import{watch as _,when as f,on as v,syncAndInitial as C,whenOnce as S}from"../../../../core/reactiveUtils.js";import{schedule as w}from"../../../../core/scheduling.js";import{property as G}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as x}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as P,isEmpty as R}from"../../../../core/accessorSupport/diffUtils.js";import{s as D,a as E,g as I}from"../../../../chunks/vec3.js";import{c as U}from"../../../../chunks/vec3f64.js";import{projectVectorToVector as A,projectXYZToVector as O,canProjectWithoutEngine as j,projectBuffer as L}from"../../../../geometry/projection.js";import{create as V,center as F,fromRect as T,equals as k}from"../../../../geometry/support/aaBoundingBox.js";import{create as z}from"../../../../geometry/support/aaBoundingRect.js";import{equals as W}from"../../../../geometry/support/spatialReferenceUtils.js";import M from"../../../../layers/Layer.js";import{getObjectId as N,computeAABB as B,hasGeometry as H}from"../../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as q}from"../../../../layers/graphics/hydratedFeatures.js";import{isSupportedRenderer3D as Y,validateTo3D as $}from"../../../../renderers/support/rendererConversion.js";import{loadArcade as Z}from"../../../../support/arcadeOnDemand.js";import{getDefaultSymbol3D as J}from"../../../../symbols/support/defaults3D.js";import{to3D as Q}from"../../../../symbols/support/symbolConversion.js";import{ViewElevationProvider as K}from"./ElevationQuery.js";import{VisibilityGroup as X,VisibilityFlag as ee}from"./enums.js";import{extractExpressionInfo as ie,createContext as te}from"./featureExpressionInfoUtils.js";import{Graphics3DFeatureStore as re}from"./Graphics3DFeatureStore.js";import se from"./Graphics3DGraphicCreationContext.js";import{Graphics3DSymbolCreationContext as ae}from"./Graphics3DSymbolCreationContext.js";import{make as ne}from"./Graphics3DSymbolFactory.js";import oe from"./Graphics3DWebStyleSymbol.js";import{GraphicStateTracking as le}from"./GraphicStateTracking.js";import{computeCentroid as he}from"./graphicUtils.js";import{ApplyRendererDiffResult as de}from"./interfaces.js";import{LoadStatus as pe}from"./Loadable.js";import{SpatialIndex2D as ce}from"./SpatialIndex2D.js";import{averageSymbolComplexities as ye,defaultSymbolComplexity as me}from"./symbolComplexity.js";import{StageLayerElevationProvider as ge}from"../support/StageLayerElevationProvider.js";import{toBoundingRect as ue}from"../../support/extentUtils.js";import{PropertiesPool as be}from"../../support/PropertiesPool.js";import{GridLocalOriginFactory as _e}from"../../webgl-engine/lib/GridLocalOriginFactory.js";import{UpdatePolicy as fe}from"../../webgl-engine/lib/UpdatePolicy.js";import{WebGLLayer as ve}from"../../webgl-engine/lib/WebGLLayer.js";import{hasPopupTemplate as Ce}from"../../../layers/support/popupUtils.js";import{ImmediateTask as Se,noBudget as we,TaskPriority as Ge,Task as xe}from"../../../support/Scheduler.js";import Pe from"../../../../geometry/Extent.js";import Re from"../../../../geometry/Point.js";import De from"../../../../symbols/LabelSymbol3D.js";import Ee from"../../../../symbols/TextSymbol.js";import Ie from"../../../../symbols/WebStyleSymbol.js";var Ue;const Ae=U(),Oe=V(),je="esri.views.3d.layers.graphics.Graphics3DCore",Le=o.getLogger(je);let Ve=Ue=class extends t{get _viewSpatialReference(){return this.owner.view.spatialReference}get spatialIndex(){return this._spatialIndex||(this._spatialIndex=new ce({objectIdField:this.owner.layer?.objectIdField,spatialReference:this._viewSpatialReference,hasZ:!!this.hasZ,hasM:!!this.hasM}),this._spatialIndex.setup(Array.from(this.graphics3DGraphics.values()))),this._spatialIndex.update(),this._spatialIndex}get numberOfGraphics(){return this._numberOfGraphics}get effectiveUpdatePolicy(){return null!=this.currentRenderer&&"dictionary"===this.currentRenderer.type?fe.ASYNC:this._forcedUpdatePolicy??this.preferredUpdatePolicy}get featureStore(){return this._featureStore}get initializePromise(){return this._initializePromise}get scaleVisibility(){return this._scaleVisibility}get elevationAlignment(){return this._elevationAlignment}get objectStates(){return this._objectStates}get filterVisibility(){return this._filterVisibility}get updating(){return!!(this._graphicsWaitingForSymbol.size>0||this.running||this._elevationAlignment?.updating||null!=this._scaleVisibility&&this._scaleVisibility.updating||null!=this._filterVisibility&&this._filterVisibility.updating||this._rendererChangeAbortController||this._elevationInfoChangeAbortController||this._updatingPendingLoadedGraphicsChange||this._frameTask.updating||this._loadingSymbols>0)}get running(){return this._pendingUpdates.size>0||!!this._spatialIndex?.updating}get suspendedOrOutsideOfView(){return this.owner.suspended||!!this.owner.suspendInfo?.outsideOfView}get updatingRemaining(){return this.updating?this._pendingUpdates.size+.1*(this._spatialIndex?.updatingRemaining||0)+.1*(this._elevationAlignment?.updatingRemaining||0):0}get displayFeatureLimit(){const e=this.owner&&this.owner.view&&this.owner.view.qualitySettings,i=e?e.graphics3D.minTotalNumberOfFeatures:0,t=e?e.graphics3D.maxTotalNumberOfFeatures:0,r=e?e.graphics3D.maxTotalNumberOfPrimitives:0,s=this.averageSymbolComplexity,a=Math.max(1,null!=s?s.primitivesPerFeature:1),n=null!=s&&s.drawCallsPerFeature>0?t/s.drawCallsPerFeature*.3:t,o=Math.ceil(r/a),l=Math.max(i,Math.min(t,o,n)),h=this._get("displayFeatureLimit");return h&&h.minimumTotalNumberOfFeatures===i&&h.maximumTotalNumberOfFeatures===t&&h.maximumTotalNumberOfPrimitives===r&&h.averageSymbolComplexity===s&&h.maximumNumberOfFeatures===l?h:{minimumTotalNumberOfFeatures:i,maximumTotalNumberOfFeatures:t,maximumTotalNumberOfPrimitives:r,averageSymbolComplexity:s,maximumNumberOfFeatures:l}}get averageSymbolComplexity(){const e=ye(this._symbolComplexities),i=this._get("averageSymbolComplexity");return 0===e.numComplexities||null!=i&&(e.estimated&&(i.primitivesPerFeature>=e.primitivesPerFeature||i.primitivesPerCoordinate>=e.primitivesPerCoordinate||i.drawCallsPerFeature>=e.drawCallsPerFeature)||i.primitivesPerFeature===e.primitivesPerFeature&&i.primitivesPerCoordinate===e.primitivesPerCoordinate&&i.drawCallsPerFeature===e.drawCallsPerFeature)?i:e}get usedMemory(){const e=null!=this.averageSymbolComplexity&&this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel*this._numberOfGraphics:0,i=this._getSymbolComplexitiesUsed().reduce(((e,i)=>e+i.memory.resourceBytes),0);return this._usedMemory+e+i}get usedMemoryPerGraphic(){if(this._usedMemory&&this._numberOfGraphics){const e=this._numberOfGraphics/(this._numberOfGraphics+Math.max(this._pendingAdds,this._pendingRemoves));return this._usedMemory/this._numberOfGraphics*e}if(null!=this.averageSymbolComplexity){const e=this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel:0;return this.averageSymbolComplexity.memory.bytesPerFeature+e}return 0}get unprocessedMemoryEstimate(){return(this._pendingAdds-this._pendingRemoves)*this.usedMemoryPerGraphic}get _symbolComplexities(){return this.currentRenderer?this._getSymbolComplexitiesUsedOrRenderer(this.currentRenderer):this._getSymbolComplexitiesUsed()}get visible(){return this._visible}_getConvertedSymbol(e){if("web-style"===e.type)return e.clone();const i=this._symbolConversionCache.get(e.id);if(null!=i)return i;const t=Q(e,{geometryType:this.layer?.geometryType??void 0,retainId:!0,hasLabelingContext:this._hasLabelingContext(e)}),r=t.symbol||null;return null==r&&t.error&&Le.error(t.error.message),this._symbolConversionCache.set(e.id,r),r}_getSymbolComplexitiesUsedOrRenderer(e){if(null==e)return[];const i=e.getSymbols(),t="backgroundFillSymbol"in e?e.backgroundFillSymbol:null;if(!(t||i&&i.length))return[];const r=[],s=this._getSymbolComplexityUsedOrRenderer(t);null!=s&&r.push(s);for(const a of i){const e=this._getSymbolComplexityUsedOrRenderer(a);null!=e&&r.push(e)}return r}_getSymbolComplexityUsedOrRenderer(e){if(null==e)return null;const i=this._symbols.get(e.id);if(null!=i)return i.complexity;const t=this._getConvertedSymbol(e);return null!=t?me(t):null}_getSymbolComplexitiesUsed(){const e=[];return this._symbols.forEach((i=>{null!=i&&e.push(i.complexity)})),e}get _objectIdField(){return this.layer.objectIdField}constructor(e){super(e),this._propertiesPool=new be({computedExtent:Pe},this),this.computedExtent=null,this.currentRenderer=null,this.rendererHasGeometryOperations=!1,this._graphicStateTracking=null,this.graphics3DGraphics=new Map,this.stageLayer=null,this.stage=null,this._graphicsDrapedUids=new Set,this._graphicsBySymbol=new Map,this._symbolConversionCache=new Map,this._symbols=new Map,this._graphicsWithoutSymbol=new Map,this._graphicsWaitingForSymbol=new Map,this._graphicsUpdateId=0,this._handles=new a,this._frameTask=Se,this._suspendSymbolCleanup=!1,this._arcadeOnDemand=null,this._rendererChangeAbortController=null,this._elevationInfoChangeAbortController=null,this._initializeAbortController=null,this._scaleVisibility=null,this._filterVisibility=null,this._spatialIndex=null,this.extentPadding=0,this._updatingPendingLoadedGraphicsChange=null,this._featureStore=null,this._deconflictor=null,this._labeler=null,this._objectStates=null,this._viewElevationProvider=null,this._stageLayerElevationProvider=null,this._sharedSymbolResourcesOwnerHandle=null,this._whenGraphics3DGraphicRequests={},this._pendingUpdates=new Map,this._numberOfGraphics=0,this._numberOfGraphicsProvidingElevation=0,this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this._loadingSymbols=0,this._pendingUpdatesPool=new y({allocator:e=>e||new Te,deallocator:e=>(e.clear(),e)}),this._symbolWarningLogged=!1,this._geometryWarningLogged=!1,this._objectIdInvisibleSet=new Set,this._whenSymbolRemoved=new y,this.preferredUpdatePolicy=fe.SYNC,this._forcedUpdatePolicy=null,this.elevationFeatureExpressionEnabled=!0,this.owner=null,this.layer=null,this.graphicSymbolSupported=!0,this.getRenderingInfoWithoutRenderer=!1,this.setUidToIdOnAdd=!0,this.hasZ=null,this.hasM=null,this._usedMemory=0,this._visible=!1,this._startCreateGraphics=!1,this.symbolCreationContext=new ae(e.owner.view.resourceController.scheduler,((e,i)=>this._frameTask.schedule(e,i)))}initialize(){this._featureStore=new re({objectIdField:this.owner.layer&&this.owner.layer.objectIdField,hasZ:!!this.hasZ,hasM:!!this.hasM,viewSpatialReference:this._viewSpatialReference,featureSpatialReference:this.owner.featureSpatialReference,getSpatialIndex:()=>this.spatialIndex,forEach:e=>this.graphics3DGraphics.forEach(e)});const e=(e,i,t)=>this.spatialIndex.queryGraphicUIDsInExtent(e,i,t),{componentFactories:i}=this;if(null!=i.elevationAlignment){const t=i.elevationAlignment(this,e);this._elevationAlignment=t}if(null!=i.scaleVisibility){const t=i.scaleVisibility(this,e);this._scaleVisibility=t}if(null!=i.filterVisibility){const e=i.filterVisibility({featureStore:this._featureStore,getFeatureCount:()=>this.graphics3DGraphics.size,updateFeatureVisibilities:e=>this.modifyGraphics3DGraphicVisibilities((i=>i.setVisibilityFlag(X.GRAPHIC,ee.FILTER,e(N(i.graphic,this._objectIdField))))),setAllFeaturesVisibility:e=>this.modifyGraphics3DGraphicVisibilities((i=>i.setVisibilityFlag(X.GRAPHIC,ee.FILTER,e))),clearFeaturesVisibility:()=>this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(X.GRAPHIC,ee.FILTER,!0)))});this._filterVisibility=e}if(null!=i.deconflictor){const e=i.deconflictor(this);this._deconflictor=e}if(null!=i.labeler&&null!=this._scaleVisibility){const e=i.labeler(this,this._scaleVisibility);this._labeler=e}if(null!=i.objectStates){const e=i.objectStates(this);this._objectStates=e}this._initializeAbortController=new AbortController,this._initializePromise=this._initializeAsync()}async _initializeAsync(){const e=this._initializeAbortController?.signal,i=this.owner.view;this._viewElevationProvider=new K(this._viewSpatialReference,i),this._initializeStage(i,this.layer.uid);const t=i.sharedSymbolResources;this.symbolCreationContext.sharedResources=t,this._sharedSymbolResourcesOwnerHandle=t.addGraphicsOwner(this.owner),null!=this.currentRenderer&&(this.symbolCreationContext.renderer=this.currentRenderer),this.symbolCreationContext.stage=this.stage,this.symbolCreationContext.streamDataRequester=t.streamDataRequester,this.symbolCreationContext.renderCoordsHelper=i.renderCoordsHelper,this.symbolCreationContext.layer=this.layer,this.symbolCreationContext.graphicsCoreOwner=this.owner,this.symbolCreationContext.localOriginFactory=new _e(i.renderSpatialReference),this.symbolCreationContext.elevationProvider=i.elevationProvider,this.symbolCreationContext.notifyGraphicGeometryChanged=e=>this.notifyGraphicGeometryChanged(e),this.symbolCreationContext.notifyGraphicVisibilityChanged=e=>this.notifyGraphicVisibilityChanged(e);const r=ie(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);if(this.symbolCreationContext.featureExpressionInfoContext=await te(r,this._viewSpatialReference,e,Le),m(e),this.symbolCreationContext.screenSizePerspectiveEnabled=i.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this.symbolCreationContext.physicalBasedRenderingEnabled=!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled,this.symbolCreationContext.skipHighSymbolLods=!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods,"drapeSourceType"in this.owner){const{owner:e}=this;this.symbolCreationContext.drapeSourceRenderer=i.basemapTerrain.overlayManager.registerGeometryDrapeSource(e),this._handles.add(n((()=>i.basemapTerrain.overlayManager.unregisterDrapeSource(e))))}this._handles.add([_((()=>this.suspendedOrOutsideOfView),(()=>this._frameTask.reschedule((()=>this._updateLayerVisibility())))),_((()=>[this.layer?.screenSizePerspectiveEnabled,this.owner.view?.screenSizePerspectiveEnabled]),(()=>{const e=i.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled;e!==this.symbolCreationContext.screenSizePerspectiveEnabled&&(this.symbolCreationContext.screenSizePerspectiveEnabled=e,this._labeler?.reset(),this.recreateAllGraphicsAndSymbols())})),_((()=>this.owner.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(!!e))),_((()=>this.owner.view.state?.rasterPixelRatio),(()=>this._pixelRatioChange())),_((()=>!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._physicalBasedRenderingChange(e))),_((()=>!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods),(e=>this._skipHighSymbolLoDsChange(e))),f((()=>i.basemapTerrain?.tilingScheme),(e=>{if(e.spatialReference.equals(this.symbolCreationContext.overlaySR)||null==i.basemapTerrain.spatialReference||(this.symbolCreationContext.overlaySR=i.basemapTerrain.spatialReference),this._handles.has("loaded-graphics"))this.recreateAllGraphics();else{const e=()=>this.owner?.loadedGraphics;this._handles.add([v(e,"change",(e=>{this._graphicsCollectionChanged(e),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}),{onListenerAdd:()=>{this.recreateAllGraphics(),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}})],"loaded-graphics")}}),{initial:!0}),_((()=>this.effectiveUpdatePolicy),(e=>{null!=this.stageLayer&&(this.stageLayer.updatePolicy=e),this.symbolCreationContext.isAsync=this.effectiveUpdatePolicy===fe.ASYNC,e===fe.SYNC&&this.runTask(we)}),C)]),this._frameTask=i.resourceController.scheduler.registerTask(Ge.GRAPHICS_CORE,this),this.layer&&"featureReduction"in this.layer&&this._handles.add(_((()=>this.layer.featureReduction),(()=>this._deconflictor.featureReductionChange()))),this.notifyChange("averageSymbolComplexity"),this.rendererChange(this.owner.renderer).catch((()=>{})),this._initializeAbortController=null}_abortInitialize(){this._initializeAbortController&&(this._initializeAbortController.abort(),this._initializeAbortController=null)}destroy(){this._abortInitialize(),this._abortRendererChange(),this._abortElevationInfoChange(),this._frameTask.remove(),this._frameTask=Se,this.owner.view?.deconflictor?.removeGraphicsOwner(this),this.owner.view?.labeler?.removeGraphicsOwner(this),this._elevationAlignment=d(this._elevationAlignment),this._scaleVisibility=d(this._scaleVisibility),this._filterVisibility=d(this._filterVisibility),this._deconflictor=null,this._labeler=null,this._objectStates=d(this._objectStates),this.clear(),this._featureStore=d(this._featureStore),this._updatingPendingLoadedGraphicsChange=p(this._updatingPendingLoadedGraphicsChange),this._graphicStateTracking=d(this._graphicStateTracking),this.stage&&(this.stageLayer=d(this.stageLayer),this.stage=null),this._handles=d(this._handles),this._set("owner",null);for(const e in this._whenGraphics3DGraphicRequests)this._whenGraphics3DGraphicRequests[e].reject(new s("graphic:layer-destroyed","Layer has been destroyed"));this._whenGraphics3DGraphicRequests=null,this._sharedSymbolResourcesOwnerHandle=p(this._sharedSymbolResourcesOwnerHandle),this._propertiesPool=d(this._propertiesPool),this._pendingUpdatesPool=null,this._symbolConversionCache.clear(),this._objectIdInvisibleSet.clear(),this._spatialIndex=d(this._spatialIndex)}clear(){this._objectStates?.allGraphicsDeleted(),null!=this._graphicStateTracking&&this._graphicStateTracking.allGraphicsDeleted(),this.graphics3DGraphics.forEach((e=>e.destroy())),this._spatialIndex?.clear(),this.graphics3DGraphics.clear(),this._numberOfGraphics=0,this._usedMemory=0,this._updateLayerVisibility(),this._symbols.forEach(d),this._symbols.clear(),this._graphicsBySymbol.clear(),this._graphicsWithoutSymbol.clear(),this._graphicsWaitingForSymbol.clear(),this._pendingUpdates.clear(),this._pendingUpdatesPool.clear(),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this.notifyChange("updating"),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this._featureStore.events.emit("changed")}_initializeStage(e,i){this.stage=e._stage,this.stageLayer=new ve(this.stage,{pickable:!this.suspendedOrOutsideOfView,updatePolicy:this.effectiveUpdatePolicy},i);const t=this.stageLayer.events;t.on("objectTransformation",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),t.on("objectShaderTransformation",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),t.on("visibilityChanged",(e=>this.notifyGraphicVisibilityChanged(e.graphicUid))),t.on("objectGeometryAdded",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),t.on("objectGeometryRemoved",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),t.on("objectGeometryUpdated",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid)))}notifyGraphicGeometryChanged(e){if(null==this._graphicStateTracking||null==e)return;const i=this.graphics3DGraphics.get(e);i&&this._graphicStateTracking.updateGraphicGeometry(i)}notifyGraphicVisibilityChanged(e){if(null==this._graphicStateTracking||null==e)return;const i=this.graphics3DGraphics.get(e);i&&this._graphicStateTracking.updateGraphicVisibility(i)}_updateLayerVisibility(){const e=this.displayFeatureLimit.maximumNumberOfFeatures,i=this._numberOfGraphics>e*ke,t=!this.suspendedOrOutsideOfView&&!i;t!==this._visible&&(this._visible=t,t?(this.stageLayer.pickable=!0,this.updateAllGraphicsVisibility()):(this.stageLayer.pickable=!1,this._hideAllGraphics()),this._updateStageLayerVisibility())}_updateStageLayerVisibility(){this.stageLayer.visible=this._visible&&(null==this.layer.opacity||this.layer.opacity>0)}getGraphics3DGraphicById(e){return null!=e?this.graphics3DGraphics.get(e):void 0}getGraphics3DGraphicByObjectId(e){return this.owner.layer?.objectIdField?this._findGraphics3DGraphicByObjectId(e):null}_getGraphicObjectID(e,i=this.owner.layer&&this.owner.layer.objectIdField){return N(e,i)}get graphics3DGraphicsByObjectID(){const e=this.owner.layer&&this.owner.layer.objectIdField;if(!e)return;const i=new Map;return this.graphics3DGraphics.forEach((t=>{if(!t)return;const r=t.graphic,s=this._getGraphicObjectID(r,e);null!=s&&i.set(s,t)})),i}get labelsEnabled(){return!(!this._labeler||!this._labeler.layerLabelsEnabled())}async updateLabelingInfo(e){const i=this._deconflictor&&this._deconflictor.labelingInfoChange(e),t=this._labeler&&this._labeler.labelingInfoChange(e);await g([i,t])}updateVisibilityInfo(){this._deconflictor&&this._deconflictor.labelingInfoChange(),this._labeler&&this._labeler.visibilityInfoChange()}get symbolUpdateType(){if(this._pendingUpdates.size>0)return"unknown";let e=0,i=0;return l(this._symbols,((t,r)=>{if(null!=t){const s=t.getFastUpdateStatus();if(s.loading>0)return!0;this._graphicsBySymbol.has(r)&&(i+=s.fast,e+=s.slow)}return!1}))?"unknown":i>=0&&0===e?"fast":e>=0&&0===i?"slow":"mixed"}runTask(e){if(this._frameTask.processQueue(e),this._applyPendingUpdates(e),this.notifyChange("running"),this.running||this.notifyChange("updating"),this.notifyChange("updatingRemaining"),!e.hasProgressed)return xe.YIELD}setObjectIdVisibility(e,i){i?this._objectIdInvisibleSet.delete(e):this._objectIdInvisibleSet.add(e);const t=this._findGraphics3DGraphicByObjectId(e);null!=t&&this._updateUserVisibility(t)}_findGraphics3DGraphicByObjectId(e){return h(this.graphics3DGraphics,(i=>this._getGraphicObjectID(i.graphic)===e))}_updateUserVisibility(e){if(null==e)return!1;const i=e.graphic,t=this._getGraphicObjectID(i),r=i.visible&&!this.owner.suspended&&(null==t||!this._objectIdInvisibleSet.has(t));return e.setVisibilityFlag(X.GRAPHIC,ee.USER,r)}_whenGraphics3DGraphic(e){const i=this.graphics3DGraphics.get(e.uid);if(i)return Promise.resolve(i);const t=this._whenGraphics3DGraphicRequests[e.uid];if(t)return t.promise;const r=u();return this._whenGraphics3DGraphicRequests[e.uid]=r,r.promise}async _boundsForGraphics3DGraphic(e,i){const t=this._viewSpatialReference,r=this.owner.view.renderSpatialReference,s=this.owner.view.basemapTerrain.spatialReference,a=(e,i,s)=>L(e,r,i,e,t,i,s),n=(e,i,r)=>L(e,s,i,e,t,i,r),o=this._viewElevationProvider?{service:this._viewElevationProvider,useViewElevation:null!=i&&!!i.useViewElevation,minDemResolution:null!=i?i.minDemResolution:null,minDemResolutionForPoints:this.owner.view.resolution}:null,l=await e.getProjectedBoundingBox(a,n,o,i?.signal);if(!l)return null;const h=l.boundingBox;if(l.requiresDrapedElevation){const e=this.symbolCreationContext.elevationProvider;if(e){F(h,Ae);const i=e.getElevation(Ae[0],Ae[1],0,t,"ground")??0;h[2]=Math.min(h[2],i),h[5]=Math.max(h[5],i)}}return{boundingBox:h,screenSpaceObjects:l.screenSpaceObjects}}async whenGraphicBounds(e,i){await S((()=>this.owner?.loadedGraphics));const t=this.owner.layer&&this.owner.layer.objectIdField,r=this.owner.loadedGraphics.find((i=>i===e||null!=t&&null!=i.attributes&&e.attributes&&i.attributes[t]===e.attributes[t]));if(!r)throw new s("internal:graphic-not-part-of-view","Graphic is not part of this view");const a=await this._whenGraphics3DGraphic(r);return this._boundsForGraphics3DGraphic(a,i)}computeAttachmentOrigin(e,i){const t=this.graphics3DGraphics.get(e.uid);if(!t)return null;const r=t.computeAttachmentOrigin();if(0===r.render.num&&0===r.draped.num)return null;D(ze,0,0,0);let s=0;if(r.render.num>0){if(!A(r.render.origin,this.symbolCreationContext.renderCoordsHelper.spatialReference,We,i))return null;E(ze,ze,We),s++}if(r.draped.num>0){const[e,t]=r.draped.origin,a=this._viewElevationProvider.getElevation(e,t,"ground")??0;if(D(We,e,t,a),!A(We,this._viewElevationProvider.spatialReference,We,i))return null;E(ze,ze,We),s++}return s>1&&I(ze,ze,1/s),new Re({x:ze[0],y:ze[1],z:ze[2],spatialReference:i})}getSymbolLayerSize(e,i){const t=this._symbols.get(e.id);if(null==t)throw new s("internal:symbol-not-part-of-view","Symbol is not part of this view");const r=e.symbolLayers.indexOf(i);if(-1===r)throw new s("internal:missing-symbol-layer","Symbol layer is not in symbol");const a=t.getSymbolLayerSize(r);if(null==a)throw new s("internal:missing-size","Symbol layer has no valid size");return a}_graphicsCollectionChanged(e){this._startCreateGraphics&&(this.add(e.added),this.remove(e.removed))}graphicUpdateHandler(e){const i=e.graphic.uid,t=this.graphics3DGraphics.get(i);if(null!=t||null!=this._graphicsWithoutSymbol.get(i))switch(e.property){case"visible":this._graphicUpdateVisibleHandler(t);break;case"geometry":this._graphicUpdateGeometryHandler(t,e);break;case"symbol":this._graphicUpdateSymbolHandler(t,e);break;case"attributes":break;case"origin-transform":this._graphicUpdateTransformHandler(t,e)}}_graphicUpdateGeometryHandler(e,i){this._graphicUpdateGeometryOrTransformHandler(e,i,(()=>null!=i.newValue&&null!=e&&e.graphics3DSymbol.updateGeometry(e,i.newValue)));const t=i.graphic.geometry;null!=t&&this._expandComputedExtent(t)}_graphicUpdateTransformHandler(e,i){const t=i.graphic.geometry;this._graphicUpdateGeometryOrTransformHandler(e,i,(()=>null!=i.newValue&&null!=e&&null!=t&&e.graphics3DSymbol.updateTransform(e,t.spatialReference,i.newValue,i.action)))}_graphicUpdateGeometryOrTransformHandler(e,i,t){if(null!=i.graphic.geometry)if(null!=e)t()||this._recreateGraphic(e.graphic);else{const e=i.graphic.symbol&&i.graphic.symbol.id;if(e){const i=this._symbols.get(e);if(null!=i&&i.loadStatus===pe.LOADING)return}this._recreateGraphic(i.graphic)}else this._recreateGraphic(i.graphic)}_graphicUpdateSymbolHandler(e,i){const t=i.graphic,r=null!=e?e.graphics3DSymbol:null!=i.oldValue?this._symbols.get(i.oldValue.id):null;if(null==r||null==i.newValue)return void this._recreateGraphic(t);const s=r.symbol,a=this._getConvertedSymbol(i.newValue);if(null!=a&&(a.type!==s.type||"web-style"===a.type)||"web-style"===s.type)return void this._recreateGraphic(t);const n=this._graphicsBySymbol.get(s.id);if(n&&1!==n.size)return void this._recreateGraphic(t);const o=P(s,a);if(null==o)return void this._updateSymbolMapping(s.id,a);const l={diff:o,graphics3DGraphicPatches:[],symbolStatePatches:[]};if(r.prepareSymbolPatch(l),!R(l.diff))return void this._recreateGraphic(t);const h=this._getRenderingInfo(t);if(null==h)return void this._recreateGraphic(t);const d=r.extentPadding;for(const p of l.symbolStatePatches)p();if(d!==r.extentPadding&&this._recomputeExtentPadding(),null!=e)for(const p of l.graphics3DGraphicPatches)p(e,h);this._updateSymbolMapping(s.id,a)}_graphicUpdateVisibleHandler(e){this._updateUserVisibility(e)&&(this._labeler&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty())}recreateGraphics(e){this._suspendSymbolCleanup=!0,this.remove(e),this.add(e),this._suspendSymbolCleanup=!1,this.effectiveUpdatePolicy===fe.SYNC&&this._cleanupSymbols()}_recreateGraphic(e){this.recreateGraphics([e])}_beginGraphicUpdate(e){const i=this._graphicsUpdateId;return this._graphicsUpdateId++,this._graphicsWaitingForSymbol.set(e.uid,i),1===this._graphicsWaitingForSymbol.size&&this.notifyChange("updating"),i}_endGraphicUpdate(e){e&&(this._graphicsWaitingForSymbol.delete(e.uid),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("updating")))}_recomputeExtentPadding(){let e=0;this._symbols.forEach((i=>{null!=i&&(e=Math.max(e,i.extentPadding))})),this._set("extentPadding",e)}_expandComputedExtent(e){const i=Oe,t=e.spatialReference;B(e,i);const r=this._viewSpatialReference,s=Ue.tmpVec;if(W(t,r)||O(i[0],i[1],0,t,s,r)&&(i[0]=s[0],i[1]=s[1],O(i[3],i[4],0,t,s,r),i[3]=s[0],i[4]=s[1]),!(isFinite(i[0])&&isFinite(i[3])&&isFinite(i[1])&&isFinite(i[4])))return;const a=this.computedExtent;let n=null;const o=isFinite(i[2])&&isFinite(i[5]),l=o&&(!a||null==a.zmin||i[2]<a.zmin),h=o&&(!a||null==a.zmax||i[5]>a.zmax);if(a){(i[0]<a.xmin||i[1]<a.ymin||i[3]>a.xmax||i[4]>a.ymax||l||h)&&(n=this._propertiesPool.get("computedExtent"),n.xmin=Math.min(i[0],a.xmin),n.ymin=Math.min(i[1],a.ymin),n.xmax=Math.max(i[3],a.xmax),n.ymax=Math.max(i[4],a.ymax),n.spatialReference=r)}else n=this._propertiesPool.get("computedExtent"),n.xmin=i[0],n.ymin=i[1],n.xmax=i[3],n.ymax=i[4],n.spatialReference=r;n&&(l&&(n.zmin=i[2]),h&&(n.zmax=i[5]),this._set("computedExtent",n))}_abortElevationInfoChange(){this._elevationInfoChangeAbortController&&(this._elevationInfoChangeAbortController.abort(),this._elevationInfoChangeAbortController=null)}async elevationInfoChange(){this._abortElevationInfoChange();const e=new AbortController;this._elevationInfoChangeAbortController=e;const i=ie(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);this.symbolCreationContext.featureExpressionInfoContext=await te(i,this._viewSpatialReference,e.signal,Le),m(e.signal),this._elevationInfoChangeAbortController=null,this._labeler?.elevationInfoChange(),this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("elevationInfo",i)?i.forEach((e=>{const i=e.graphic,t=e.labelLayers;for(const r of t){r.graphics3DSymbolLayer.updateGraphicElevationContext(i,r)}})):this._recreateSymbol(t)})),this.updateStageLayerElevationProvider(),this._elevationAlignment?.elevationInfoChange()}updateStageLayerElevationProvider(){this._stageLayerElevationProvider?(this.layer.elevationInfo&&"relative-to-scene"===this.layer.elevationInfo.mode||0===this._numberOfGraphicsProvidingElevation)&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=c(this._stageLayerElevationProvider)):(!this.layer.elevationInfo||this.layer.elevationInfo&&"relative-to-scene"!==this.layer.elevationInfo.mode)&&this._numberOfGraphicsProvidingElevation>0&&(this._stageLayerElevationProvider=new ge({layer:this.layer,stageLayer:this.stageLayer,view:this.owner.view}),this.owner.view.elevationProvider.register("scene",this._stageLayerElevationProvider))}_clearSymbolsAndGraphics(){this.clear(),null!=this._filterVisibility&&this._filterVisibility.clear(),this._labeler?.reset(),this._deconflictor?.clear(),this._elevationAlignment?.clear(),this.stageLayer?.invalidateSpatialQueryAccelerator(),this._stageLayerElevationProvider&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=c(this._stageLayerElevationProvider))}startCreateGraphics(){this._startCreateGraphics=!0,this.recreateAllGraphics()}recreateAllGraphics(){this._recreateAllGraphics(!1)}recreateAllGraphicsAndSymbols(){this._recreateAllGraphics(!0)}_recreateAllGraphics(e=!1){if(!this._startCreateGraphics)return;const{loadedGraphics:i,view:t}=this.owner,r=t.basemapTerrain.tilingScheme&&i&&i.length?i.toArray():null;!e&&r||this._clearSymbolsAndGraphics(),this.symbolCreationContext.screenSizePerspectiveEnabled=this.owner.view.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this._set("computedExtent",null),r&&(e?this.add(r):this.recreateGraphics(r))}_recreateSymbol(e){const i=this._graphicsBySymbol.get(e),t=[];i&&(i.forEach(((e,i)=>{const r=e.usedMemory;this._conditionalRemove(e,i),this._spatialIndex?.remove(e),t.push(e.graphic),e.destroy(),this._removeGraphics3DGraphic(i,r),this._updateLayerVisibility(),this._featureStore.events.emit("changed")})),this._graphicsBySymbol.set(e,new Map));const r=this._symbols.get(e);d(r),this._symbols.delete(e),this.add(t)}_recreateGraphicsForSymbol(e){const i=this._graphicsBySymbol.get(e);if(i){const e=[];i.forEach((i=>e.push(i.graphic))),this.recreateGraphics(e)}}_conditionalRemove(e,i){this._graphicsDrapedUids.delete(i),this._objectStates?.removeGraphic(e),this._labeler?.removeGraphic(e),this._deconflictor?.removeGraphic(e),null!=this._graphicStateTracking&&this._graphicStateTracking.removeGraphic(e)}add(e){e&&0!==e.length&&(this.owner.view.basemapTerrain&&this.owner.view.basemapTerrain.tilingScheme?(this._updatePolicyForGraphics(e)===fe.ASYNC?this._addDelayed(e):this._addImmediate(e),this.notifyChange("updating")):Le.error("#add()","Cannot add graphics before terrain surface has been initialized"))}_updatePolicyForGraphics(e){if(this.effectiveUpdatePolicy===fe.SYNC&&("mesh"===this.layer.geometryType||null==this.layer.geometryType))for(const i of e)if(null!=i.geometry&&"mesh"===i.geometry.type&&!i.geometry.loaded)return fe.ASYNC;return this.effectiveUpdatePolicy}_addImmediate(e){this._geometryWarningLogged=!1,this._symbolWarningLogged=!1;for(const i of e)this._addGraphic(i,this._getRenderingInfo(i,Le),fe.SYNC);this._cleanupSymbols(),this._labeler&&(this.owner.view.labeler.setDirty(),this._cleanupSymbols()),this.owner.view.deconflictor.setDirty()}_addDelayed(e){for(const i of e){const e=i.uid;let t=this._pendingUpdates.get(e);t?t.add?t.state!==Fe.NEW&&t.abortController?.abort():this._pendingAdds++:(t=this._pendingUpdatesPool.pushNew(),this._pendingAdds++,this._pendingUpdates.set(e,t)),t.add=i}this.notifyChange("running"),this.notifyChange("updatingRemaining")}remove(e){this.effectiveUpdatePolicy===fe.ASYNC?this._removeDelayed(e):this._removeImmediate(e),this.notifyChange("updating")}_removeImmediate(e){for(const i of e)this._removeGraphic(i);this._cleanupSymbols(),this._labeler&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty()}_removeDelayed(e){for(const i of e){const e=i.uid,t=this._pendingUpdates.get(e);if(t)t.add&&(t.remove?t.add=null:this._pendingUpdates.delete(e),t.state===Fe.LOADING&&t.abortController?.abort(),this._pendingAdds--);else{const t=this._pendingUpdatesPool.pushNew();t.remove=i,this._pendingUpdates.set(e,t),this._pendingRemoves++,this._applyPendingRemovesFirst=!0}}0===this._pendingUpdates.size&&this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("updatingRemaining")}_finishPendingUpdates(){this._pendingUpdatesPool.clear(),this._cleanupSymbols(),(this._pendingAdds||this._pendingRemoves)&&Le.warn("pendingAdds/Removes in inconsistent state!"),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1}_applyPendingUpdates(e){if(this._geometryWarningLogged=!1,this._symbolWarningLogged=!1,0===this._pendingUpdates.size&&this._spatialIndex?.updating)return this._spatialIndex.update(),void e.madeProgress();if(this._applyPendingRemovesFirst){this._applyPendingRemovesFirst=!1;for(const[i,t]of this._pendingUpdates){if(e.done){this._applyPendingRemovesFirst=!0;break}if(t.remove&&!t.add&&(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(t.remove),t.remove=null,this._pendingUpdates.delete(i),0===this._pendingRemoves))break}}for(const[i,t]of this._pendingUpdates){if(e.done)break;t.add&&t.state===Fe.NEW&&this._processPendingUpdateNew(t);let r=this.effectiveUpdatePolicy;if(!t.remove||t.add&&t.state!==Fe.READY||(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(t.remove),t.remove=null,r=fe.SYNC),t.add)switch(t.state){case Fe.READY:this._addGraphic(t.add,t.renderingInfo,r),t.add=null,this._pendingAdds--,e.madeProgress();break;case Fe.REJECTED:t.add=null,this._pendingAdds--;case Fe.LOADING:}null==t.remove&&null==t.add&&this._pendingUpdates.delete(i)}0===this._pendingUpdates.size&&(this._finishPendingUpdates(),this.notifyChange("running"))}_processPendingUpdateNew(e){if(!e.add)return void(e.state=Fe.READY);const i=e.add.geometry;null==i||"mesh"!==i.type||i.loaded?this._processPendingUpdateNewRenderingInfo(e):this._processPendingUpdateNewMesh(e,i)}async _processPendingUpdateNewMesh(e,i){e.state=Fe.LOADING,e.abortController=new AbortController;const t=e.abortController.signal;try{await i.load({signal:t})}catch(r){return this._processPendingUpdateNewError(e,r)}e.abortController=null,this._processPendingUpdateNewRenderingInfo(e)}_processPendingUpdateNewError(e,i){e.abortController=null,b(i)?e.state=Fe.NEW:e.state=Fe.REJECTED}async _processPendingUpdateNewRenderingInfo(e){if(null==this.layer.renderer||"dictionary"!==this.layer.renderer.type)return e.renderingInfo=this._getRenderingInfo(e.add,Le),void(e.state=Fe.READY);e.state=Fe.LOADING,e.abortController=new AbortController;let i=null;try{i=await this._getRenderingInfoAsync(e.add,{signal:e.abortController.signal})}catch(t){return e.abortController=null,void(b(t)?e.state=Fe.NEW:e.state=Fe.REJECTED)}null==i||null==i.symbol?(Le&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,Le.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),e.renderingInfo=null):e.renderingInfo=i,e.state=Fe.READY}_addGraphic(e,i,t){if(this._graphicsWithoutSymbol.set(e.uid,e),null==i||null==i.symbol||!H(e))return;null!=this.stage.renderView.objectAndLayerIdRenderHelper&&this.setUidToIdOnAdd&&this.stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(e.objectId,e.uid,this.layer.id,this.layer.uid,!!this.layer.popupEnabled&&Ce(this.layer,this.owner.view.popup?.defaultPopupTemplateEnabled));const r=i.symbol,s=this.getOrCreateGraphics3DSymbol(r,i.renderer);if(null==s)return;this._expandComputedExtent(e.geometry);const a=this._beginGraphicUpdate(e),n=new se(e,i,this.layer);let o=!1;const l=e=>{e===s.symbol.id&&(o=!0)};this._whenSymbolRemoved.push(l);const h=()=>{if(--this._loadingSymbols,this.destroyed)return;this._whenSymbolRemoved.removeUnordered(l);if(this._graphicsWaitingForSymbol.get(e.uid)!==a||o||s.destroyed||this.graphicSymbolSupported&&e.symbol&&e.symbol.id!==s.symbol.id)--s.referenced,this._cleanupSymbols();else{const i=this._createGraphics3DGraphic(s,n);this._spatialIndex&&null!=i&&this._spatialIndex.add(i),--s.referenced,this._endGraphicUpdate(e)}this._featureStore.events.emit("changed"),this._labeler&&this.owner.view.labeler.setDirty()},d=i=>{--this._loadingSymbols,this.destroyed||(this._whenSymbolRemoved.removeUnordered(l),o||(b(i)?this.add([e]):s.destroyed||this._endGraphicUpdate(e)))};++this._loadingSymbols,t===fe.ASYNC?s.load((()=>this._frameTask.schedule(h)),(e=>this._frameTask.schedule((()=>d(e))))):s.load(h,d)}_removeGraphic(e){const i=e.uid,t=this.graphics3DGraphics.get(i);if(t){t.graphics3DSymbol.onRemoveGraphic(t);const e=t.usedMemory,r=t.isElevationSource;this._conditionalRemove(t,i),this._spatialIndex?.remove(t);const s=t.graphics3DSymbol.symbol.id;this._graphicsBySymbol.get(s)?.delete(i),this._graphicsWithoutSymbol.delete(i),this._removeGraphics3DGraphic(i,e,r),t.destroy(),this._featureStore.events.emit("changed")}else this._graphicsWithoutSymbol.delete(i),this._graphicsWaitingForSymbol.delete(i),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("updating"))}_hasLabelingContext(e){if(e instanceof De||e instanceof Ee){const i=this.symbolCreationContext.layer;return!!i.labelingInfo&&i.labelingInfo.some((i=>i.symbol===e))}return!1}_hasValidSymbolCreationContext(e){return!(e instanceof De&&!this._hasLabelingContext(e))||(Le.error("LabelSymbol3D is only valid as part of a LabelClass. Using LabelSymbol3D as a renderer symbol is not supported."),!1)}_getRenderingInfo(e,i){const t=e.geometry;if(null==t)return i&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!j(t.spatialReference,this._viewSpatialReference))return i&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has incompatible spatial reference and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return i&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?q(e,this.layer):e;let s;if(this.owner.getRenderingInfo&&(this.getRenderingInfoWithoutRenderer||null!=this.currentRenderer))s=this.owner.getRenderingInfo(r,this.currentRenderer,this._arcadeOnDemand);else{s={symbol:r.symbol||J(r.geometry)}}return null==s||null==s.symbol?(i&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),null):s}_getRenderingInfoAsync(e,i){if(null==e.geometry)return Le&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,Le.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return Le&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,Le.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const t=this.rendererHasGeometryOperations?q(e,this.layer):e;return this.owner.getRenderingInfoAsync(t,this.currentRenderer,this._arcadeOnDemand,i)}_createGraphics3DSymbol(e,i){if(!this._hasValidSymbolCreationContext(e))return null;const t=this._getConvertedSymbol(e);if(!t)return null;let r;if(null!=i&&"backgroundFillSymbol"in i&&i.backgroundFillSymbol){const e=Q(i.backgroundFillSymbol,{ignoreDrivers:!0});null!=e.symbol&&"web-style"!==e.symbol.type&&"cim"!==e.symbol.type&&(r=e.symbol.symbolLayers)}const s=ne(t,this.symbolCreationContext,r);return s.load((()=>{const e=s.extentPadding;e>this.extentPadding&&this._set("extentPadding",e),this.notifyChange("averageSymbolComplexity")}),(()=>{})),s}getOrCreateGraphics3DSymbol(e,i){let t=this._symbols.get(e.id);return void 0===t&&(t=e instanceof Ie?new oe(e,(e=>this._frameTask.schedule(e)),(e=>this._createGraphics3DSymbol(e,i))):this._createGraphics3DSymbol(e,i),this._symbols.set(e.id,t)),null!=t&&++t.referenced,t}trackGraphicState(e){return null==this._graphicStateTracking&&(this._graphicStateTracking=new le(this)),this._graphicStateTracking.add(e)}_addGraphics3DGraphic(e){this._usedMemory+=e.usedMemory,this.graphics3DGraphics.set(e.graphic.uid,e),this._numberOfGraphics++,e.isElevationSource&&(this._numberOfGraphicsProvidingElevation++,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_removeGraphics3DGraphic(e,i,t=!1){this._usedMemory-=i,this.graphics3DGraphics.delete(e),this._numberOfGraphics--,t&&(this._numberOfGraphicsProvidingElevation--,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_createGraphics3DGraphic(e,i){const t=i.graphic;if(this._graphicsWithoutSymbol.delete(t.uid),!this._symbols.has(e.symbol.id))return this.add([t]),null;if(this.graphics3DGraphics.has(t.uid))return null;const r=e.createGraphics3DGraphic(i);if(null==r)return null;this._addGraphics3DGraphic(r);const s=e.symbol.id;this._graphicsBySymbol.has(s)||this._graphicsBySymbol.set(s,new Map),this._graphicsBySymbol.get(s).set(t.uid,r);if(r.isDraped&&this._graphicsDrapedUids.add(t.uid),r.centroid=null,null!=t.geometry&&"point"!==t.geometry.type&&(r.centroid=he(t.geometry,this._viewSpatialReference)),this._updateUserVisibility(r),null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(r),null!=this._filterVisibility){const{defaultVisibility:e}=this._filterVisibility;r.setVisibilityFlag(X.GRAPHIC,ee.FILTER,e),e||this._filterVisibility.reapply()}this._deconflictor?.addGraphic(r),this._labeler?.addGraphic(r),this._objectStates?.addGraphic(r),this._deconflictor&&this.owner.view.deconflictor.setInitialIconVisibilityFlag(this,r),r.initialize(this.stageLayer,this.owner),null!=this._graphicStateTracking&&this._graphicStateTracking.addGraphic(r);const a=this._whenGraphics3DGraphicRequests[t.uid];return a&&(delete this._whenGraphics3DGraphicRequests[t.uid],a.resolve(r)),r}_abortRendererChange(){this._rendererChangeAbortController&&(this._rendererChangeAbortController.abort(),this._rendererChangeAbortController=null)}async rendererChange(e){if(this._abortRendererChange(),e!==this.currentRenderer)if(this._validateRenderer(e),null==e&&this._currentRendererChange(null,!1),Y(e))if(null!=e&&e.arcadeRequired){const i=new AbortController;this._rendererChangeAbortController=i;const{arcadeUtils:t}=await this._ensureArcade();m(i);const r=t.hasGeometryOperations(e);r&&(await t.enableGeometryOperations(),m(i)),this.effectiveUpdatePolicy===fe.ASYNC?await this._frameTask.schedule((()=>this._currentRendererChange(e,r)),i.signal):this._currentRendererChange(e,r),this._rendererChangeAbortController=null}else if(this.effectiveUpdatePolicy===fe.ASYNC){const i=new AbortController;this._rendererChangeAbortController=i,await this._frameTask.schedule((()=>this._currentRendererChange(e,!1)),i.signal),this._rendererChangeAbortController=null}else this._currentRendererChange(e,!1);else this._currentRendererChange(e,!1)}async _ensureArcade(){return null==this._arcadeOnDemand?(this._arcadeOnDemand=await Z(),this._arcadeOnDemand):this._arcadeOnDemand}_currentRendererChange(e,i){this.currentRenderer=e,this.rendererHasGeometryOperations=i,this.symbolCreationContext.arcade=this._arcadeOnDemand;const t=this.symbolCreationContext.renderer;if(e===t)return;if(this._symbolConversionCache.clear(),null==e)return this.symbolCreationContext.renderer=null,void this.recreateAllGraphicsAndSymbols();const r=P(t,e);this._updateUnchangedSymbolMappings(r,e,t),this.symbolCreationContext.renderer=e,null!=r&&("complete"===r.type?this.recreateAllGraphicsAndSymbols():"partial"===r.type&&(this._applyRendererDiff(r,e,t)?this._volatileGraphicsUpdated():this.recreateAllGraphicsAndSymbols()),this.notifyChange("averageSymbolComplexity"))}_diffHasSymbolChange(e){for(const i in e.diff)switch(i){case"visualVariables":case"defaultSymbol":case"uniqueValueInfos":break;case"uniqueValueGroups":case"authoringInfo":case"fieldDelimiter":delete e.diff[i];break;default:return!0}return!1}_applySymbolSetDiff(e,i,t){e=e||[],i=i||[];const r=[];for(const s of i){const i=this._graphicsBySymbol.get(s.id);i&&i.forEach(((a,n)=>{const o=a.graphic,l=this.layer instanceof M?this.layer:null,h=this._arcadeOnDemand;if(s===t.defaultSymbol&&t.getSymbol(q(o,l),{arcade:h})===t.defaultSymbol)return;const d=a.usedMemory;e.length||t.defaultSymbol?r.push(o):this._graphicsWithoutSymbol.set(n,o);const p=this.graphics3DGraphics.get(n);this._conditionalRemove(p,n),a.destroy(),i.delete(n),this._removeGraphics3DGraphic(n,d),this._updateLayerVisibility()})),this._whenSymbolRemoved.forAll((e=>e(s.id)))}(e.length||r.length)&&(this._graphicsWithoutSymbol.forEach((e=>r.push(e))),this._graphicsWithoutSymbol.clear(),this.add(r)),this._cleanupSymbols(),this._labeler&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty()}_applyUniqueValueRendererDiff(e,i,t){const s=e.diff.defaultSymbol,a=e.diff.uniqueValueInfos;if(s||a){const n=a?a.added.map((e=>e.symbol)).filter(r):[],o=a?a.removed.map((e=>e.symbol)).filter(r):[];if(a)for(let e=0;e<a.changed.length;e++)n.push(a.changed[e].newValue.symbol),o.push(a.changed[e].oldValue.symbol);return s?(t.defaultSymbol&&o.push(t.defaultSymbol),i.defaultSymbol&&n.push(i.defaultSymbol)):t.defaultSymbol&&n.length&&o.push(i.defaultSymbol),this._applySymbolSetDiff(n,o,i),delete e.diff.defaultSymbol,delete e.diff.uniqueValueInfos,!0}return!1}_calculateUnchangedSymbolMapping(e,i,t){if("unique-value"!==i?.type||"unique-value"!==t?.type||null!=e&&"partial"!==e.type)return[];const r=e=>null!=e?e.id:null,s=e&&e.diff,a=s&&s.defaultSymbol,n=s&&s.uniqueValueInfos;let o;if(n)o=n.unchanged.map((e=>({oldId:r(e.oldValue.symbol),newId:r(e.newValue.symbol)})));else{o=[];for(const e of t.uniqueValueInfos??[]){const t=r(e.symbol),s=i.uniqueValueInfos?.find((i=>i.value===e.value));s&&t!==r(s.symbol)&&o.push({oldId:t,newId:r(s.symbol)})}}return!a&&t.defaultSymbol&&o.push({oldId:r(t.defaultSymbol),newId:r(i.defaultSymbol)}),o}_updateSymbolMapping(e,i){const t=null!=i&&i?"string"==typeof i?i:i.id:null;if(null==e||e===t)return;const r=this._graphicsBySymbol.get(e);this._graphicsBySymbol.delete(e),void 0!==r&&this._graphicsBySymbol.set(t,r);const s=this._symbols.get(e);if(void 0!==s&&(this._symbols.delete(e),this._symbols.set(t,s),null!=s)){const e="string"==typeof i?null:i;null!=e?s.symbol=e:s.symbol.id=t}}_updateUnchangedSymbolMappings(e,i,t){const r=this._calculateUnchangedSymbolMapping(e,i,t);for(const{oldId:s,newId:a}of r)this._updateSymbolMapping(s,a)}_applyRendererDiff(e,t,r){if(this._diffHasSymbolChange(e))return!1;if(t instanceof i&&r instanceof i&&this._applyUniqueValueRendererDiff(e,t,r)&&0===Object.keys(e.diff).length)return!0;for(const[i]of this._graphicsBySymbol){const r=this._symbols.get(i);if(null!=r)switch(r.applyRendererDiff(e,t)){case de.RecreateSymbol:this._recreateSymbol(i);break;case de.RecreateGraphics:this._recreateGraphicsForSymbol(i);case de.FastUpdate:}}return!0}opacityChange(){this.forEachGraphics3DSymbol(((e,i)=>e.globalPropertyChanged("opacity",i))),this._updateStageLayerVisibility()}_slicePlaneEnabledChange(e){e!==this.symbolCreationContext.slicePlaneEnabled&&(this.symbolCreationContext.slicePlaneEnabled=e,this.stageLayer.sliceable=e,this.forEachGraphics3DSymbol(((e,i)=>e.globalPropertyChanged("slicePlaneEnabled",i))),this._deconflictor&&this._deconflictor.slicePlaneEnabledChange(),this._labeler&&this._labeler.slicePlaneEnabledChange())}_physicalBasedRenderingChange(e){this.symbolCreationContext.physicalBasedRenderingEnabled=e,this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("physicalBasedRenderingEnabled",i)||this._recreateSymbol(t)}))}_skipHighSymbolLoDsChange(e){this.symbolCreationContext.skipHighSymbolLods=e,this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("skipHighSymbolLods",i)||this._recreateSymbol(t)}))}_pixelRatioChange(){this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("pixelRatio",i)||this._recreateSymbol(t)}))}_signalUpdatingDuringAsyncLoadedGraphicsChange(){this._updatingPendingLoadedGraphicsChange&&this._updatingPendingLoadedGraphicsChange.remove(),this._updatingPendingLoadedGraphicsChange=w((()=>{this._updatingPendingLoadedGraphicsChange=null}))}setClippingExtent(e,i){const t=this.symbolCreationContext.clippingExtent,r=z();return ue(e,r,i)?this.symbolCreationContext.clippingExtent=T(V(),r):this.symbolCreationContext.clippingExtent=null,!k(this.symbolCreationContext.clippingExtent,t)}modifyGraphics3DGraphicVisibilities(e){if(this.destroyed)return;let i=!1;this.graphics3DGraphics.forEach((t=>{e(t)&&(i=!0)})),i&&(this.owner.view.labeler?.setDirty(),this.owner.view.deconflictor?.setDirty())}forEachGraphics3DSymbol(e){for(const[i,t]of this._symbols){if(null==t)return;e(t,this._graphicsBySymbol.get(i)||Me,i)}}updateAllGraphicsVisibility(){null!=this._filterVisibility&&this._filterVisibility.reapply(),this.modifyGraphics3DGraphicVisibilities((e=>{const i=this._updateUserVisibility(e),t=null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(e);return i||t}))}_hideAllGraphics(){this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(X.GRAPHIC,ee.USER,!1)))}_validateRenderer(e){const i=$(e,{geometryType:this.layer?.geometryType});if(i){const e=`Renderer for layer '${this.layer.title?`${this.layer.title}, `:""}, id:${this.layer.id}' is not supported in a SceneView`;Le.warn(e,i.message)}}_volatileGraphicsUpdated(){this._labeler?.reset(),this.stageLayer.shaderTransformationChanged(),this.notifyChange("updating")}_cleanupSymbols(){if(this._graphicsWaitingForSymbol.size>0||this._suspendSymbolCleanup)return;let e=!1;this._symbols.forEach(((i,t)=>{if(null==i||i.referenced>0)return;const r=this._graphicsBySymbol.get(t);r&&0!==r.size||(this._graphicsBySymbol.delete(t),this._symbols.delete(t),d(i),e=!0)})),e&&(this._recomputeExtentPadding(),this.notifyChange("averageSymbolComplexity"))}get test(){return{snapshotInternals:()=>({graphics:[...this.graphics3DGraphics.keys()].sort(),symbols:[...this._symbols.keys()].sort(),graphicsBySymbol:[...this._graphicsBySymbol.keys()].sort().map((e=>({symbolId:e,graphics:[...this._graphicsBySymbol.get(e).keys()].sort()}))),graphicsWithoutSymbol:[...this._graphicsWithoutSymbol.keys()].sort(),graphicsDrapedUids:[...this._graphicsDrapedUids].sort(),pendingUpdates:this._pendingUpdates}),symbols:this._symbols,filterVisibility:this._filterVisibility,numPending:this._pendingUpdates.size,forceUpdatePolicy:e=>{this._forcedUpdatePolicy=e}}}get performanceInfo(){return{visible:this.graphics3DGraphics.size,missing:this._graphicsWithoutSymbol.size,pending:this._pendingUpdates.size}}};var Fe;Ve.tmpVec=U(),e([G({readOnly:!0})],Ve.prototype,"computedExtent",void 0),e([G()],Ve.prototype,"currentRenderer",void 0),e([G()],Ve.prototype,"rendererHasGeometryOperations",void 0),e([G()],Ve.prototype,"_frameTask",void 0),e([G({readOnly:!0})],Ve.prototype,"_viewSpatialReference",null),e([G()],Ve.prototype,"_rendererChangeAbortController",void 0),e([G()],Ve.prototype,"_elevationInfoChangeAbortController",void 0),e([G()],Ve.prototype,"_initializeAbortController",void 0),e([G()],Ve.prototype,"_elevationAlignment",void 0),e([G()],Ve.prototype,"_scaleVisibility",void 0),e([G()],Ve.prototype,"_filterVisibility",void 0),e([G()],Ve.prototype,"_initializePromise",void 0),e([G()],Ve.prototype,"_spatialIndex",void 0),e([G({readOnly:!0})],Ve.prototype,"extentPadding",void 0),e([G()],Ve.prototype,"_updatingPendingLoadedGraphicsChange",void 0),e([G()],Ve.prototype,"_featureStore",void 0),e([G()],Ve.prototype,"_deconflictor",void 0),e([G()],Ve.prototype,"_labeler",void 0),e([G()],Ve.prototype,"_objectStates",void 0),e([G()],Ve.prototype,"_loadingSymbols",void 0),e([G()],Ve.prototype,"preferredUpdatePolicy",void 0),e([G()],Ve.prototype,"_forcedUpdatePolicy",void 0),e([G({readOnly:!0})],Ve.prototype,"effectiveUpdatePolicy",null),e([G({constructOnly:!0})],Ve.prototype,"elevationFeatureExpressionEnabled",void 0),e([G({constructOnly:!0})],Ve.prototype,"owner",void 0),e([G({constructOnly:!0})],Ve.prototype,"layer",void 0),e([G({constructOnly:!0})],Ve.prototype,"graphicSymbolSupported",void 0),e([G({constructOnly:!0})],Ve.prototype,"getRenderingInfoWithoutRenderer",void 0),e([G({constructOnly:!0})],Ve.prototype,"componentFactories",void 0),e([G({constructOnly:!0})],Ve.prototype,"setUidToIdOnAdd",void 0),e([G()],Ve.prototype,"featureStore",null),e([G()],Ve.prototype,"initializePromise",null),e([G()],Ve.prototype,"scaleVisibility",null),e([G()],Ve.prototype,"elevationAlignment",null),e([G()],Ve.prototype,"objectStates",null),e([G()],Ve.prototype,"filterVisibility",null),e([G({readOnly:!0})],Ve.prototype,"updating",null),e([G({readOnly:!0})],Ve.prototype,"running",null),e([G({readOnly:!0})],Ve.prototype,"suspendedOrOutsideOfView",null),e([G({readOnly:!0,dependsOn:[]})],Ve.prototype,"updatingRemaining",null),e([G({readOnly:!0,dependsOn:["owner.view.qualitySettings.graphics3D.maxTotalNumberOfPrimitives","owner.view.qualitySettings.graphics3D.maxTotalNumberOfFeatures","averageSymbolComplexity"]})],Ve.prototype,"displayFeatureLimit",null),e([G({readOnly:!0,dependsOn:[]})],Ve.prototype,"averageSymbolComplexity",null),e([G({constructOnly:!0})],Ve.prototype,"hasZ",void 0),e([G({constructOnly:!0})],Ve.prototype,"hasM",void 0),e([G()],Ve.prototype,"_objectIdField",null),Ve=Ue=e([x(je)],Ve),function(e){e[e.NEW=0]="NEW",e[e.LOADING=1]="LOADING",e[e.READY=2]="READY",e[e.REJECTED=3]="REJECTED"}(Fe||(Fe={}));class Te{constructor(){this.add=null,this.renderingInfo=null,this.state=Fe.NEW,this.abortController=null,this.remove=null}clear(){this.add=null,this.renderingInfo=null,this.state=Fe.NEW,this.abortController=null,this.remove=null}}const ke=10,ze=U(),We=U(),Me=new Map;export{Ve as Graphics3DCore};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f64.js";import{f as n,m as s,a as i}from"../../../../chunks/mat4.js";import{c as l,b as u}from"../../../../chunks/mat4f64.js";import{a as c,g as m,e as h,n as f,b as p,f as d}from"../../../../chunks/vec3.js";import{Z as g,O as x,c as _}from"../../../../chunks/vec3f64.js";import{O as T}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as b,projectVectorToDehydratedPoint as y,projectBuffer as v,canProjectWithoutEngine as C}from"../../../../geometry/projection.js";import{create as O,empty as w,expandWithBuffer as M,intersectsClippingArea as P}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as j}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as A,getZeroIndexArray as I}from"../../../../geometry/support/Indices.js";import R from"../../../../geometry/support/MeshComponent.js";import E from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import N from"../../../../geometry/support/MeshTextureTransform.js";import{t as B,a as F}from"../../../../chunks/vec32.js";import{transformNormal as S,projectNormalToPCPF as U,transformTangent as L,projectTangentToPCPF as $}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as G}from"../../../../layers/graphics/dehydratedFeatures.js";import{MeshTransformUpdateAction as V}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as D}from"../../../ViewingMode.js";import{isEncodedMeshTexture as k}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as H}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as q}from"./ElevationAligners.js";import{needsElevationUpdates3D as W,evaluateElevationInfoAtPoint as z}from"./elevationAlignmentUtils.js";import{ElevationContext as Y}from"./ElevationContext.js";import{Graphics3DMeshObject3DGraphicLayer as Z}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as J}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as K}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as Q,MeshFastUpdateProcessor as X}from"./MeshFastUpdateProcessor.js";import{createMaterial as ee}from"../support/edgeUtils.js";import{parseColorMixMode as te,encodeSymbolColor as re}from"../support/symbolColorUtils.js";import oe from"../../support/debugFlags.js";import{Attribute as ae}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ne,CullFaceOptions as se}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ie}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as le}from"../../webgl-engine/lib/Geometry.js";import{Object3D as ue}from"../../webgl-engine/lib/Object3D.js";import{Texture as ce}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as me}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as he}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as fe}from"../../webgl-engine/materials/NativeLineMaterial.js";import{TextureWrapMode as pe}from"../../../webgl/enums.js";const de=["mesh"];class ge extends K{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new Q,this._fastUpdateProcessor=new X,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){oe.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new fe({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new fe({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,de,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new Y),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,W)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=we;switch(b(t,r.origin,n,a),o){case V.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case V.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case V.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,r,this._context.localOriginFactory)}const{elevationContext:s}=e;s.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:i,renderCoordsHelper:l}=this._context,u=(e,t)=>z(e,i,s,l,t);return e.alignedSampledElevation=q(e,s,i.spatialReference,u,l,n),e.updateTransform(n,r,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??je;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:u,alphaCutoff:c,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(n),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=n,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${u},ac:${c},am:${m}`,t.material instanceof E){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:u,emissiveTextureTransform:c,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(u),x=this._textureTransformUid(c),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=u,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(s),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(c),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ne.Opaque);return null!=t?t.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new ce(k(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!k(r)&&t!==ne.Opaque,encoding:k(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),this._context.stage.add(a),this._context.stage.loadImmediate(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return pe.CLAMP_TO_EDGE;case"mirror":return pe.MIRRORED_REPEAT;default:return pe.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=H(t.colorTextureTransform),r.normalTextureTransformMatrix=H(t.normalTextureTransform),r.occlusionTextureTransformMatrix=H(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=H(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=H(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=T;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=T)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,a=t.material?.alphaMode,n="blend"===a,s=!("opaque"===a)&&(this._hasTransparentVertexColors(e)||null!=r&&r.a<1||null!=o&&o.transparent||n),i=this._materialProperties(e,t,s),l=this._materialInfoCache.byUid(i.uid);if(l)return l.material;const u={uid:i.uid,material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},c=null==i.metallicRoughnessTexture&&null==i.metallic&&null==i.roughness,m={usePBR:this._usePBR(),isSchematic:c,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:g,diffuse:x,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:se.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};c||(m.mrrFactors=[null!=i.metallic?i.metallic:1,null!=i.roughness?i.roughness:1,.5]),t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?se.None:se.Back,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTransparentParameter(m,u),this._setInternalMaterialParameters(i,m);const h=new he(m);return u.material=h,this._materialInfoCache.set(i.uid,u),this._context.stage.add(h),h}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ne.MaskBlend:ne.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ne.Opaque:"mask"===t.alphaMode?ne.Mask:ne.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(me.POSITION),o=e.vertexAttributes.get(me.NORMAL),u=e.indices.get(me.POSITION),h=e.indices.get(me.NORMAL),f=r.data,d=o.data;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*h[t];for(let t=0;t<3;t++)n.push(f[e+t]);for(let t=0;t<3;t++)n.push(f[e+t]+d[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(f,u,t,ve),this._getFaceVertices(f,u,t,Te,be,ye),c(Te,Te,be),c(Te,Te,ye),m(Te,Te,1/3);for(let e=0;e<3;e++)i.push(Te[e]);for(let e=0;e<3;e++)i.push(Te[e]+ve[e]*a);l.push(l.length),l.push(l.length)}}}const u=t[0].transformation,h=new le(this._debugVertexNormalMaterial,[[me.POSITION,new ae(n,3,!0)]],[[me.POSITION,s]],null,ie.Line);t.push(h),h.transformation=u;const f=new le(this._debugFaceNormalMaterial,[[me.POSITION,new ae(i,3,!0)]],[[me.POSITION,l]],null,ie.Line);f.transformation=u,t.push(f)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;oe.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,s);const l=new ue({geometries:s,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const u=ee(this.symbolLayer,{opacity:this._getLayerOpacity()}),c=null!=u?new J(s[0].material,[u],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new Z(this,l,s,null,null,q,r,c);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=W(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>z(e,h,r,f,t);return m.alignedSampledElevation=q(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=G(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return y([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){this._calculateFaceNormal(e,o,n,ve);for(let e=0;e<3;e++){const r=3*o[n+e];Te[0]=t[r],Te[1]=t[r+1],Te[2]=t[r+2],h(ve,Te)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new xe(t,o,a)}_createComponentNormalsFlat(e,t){const r=j(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,ve);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new xe(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,ve);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:_(),count:0},r[a]=s),c(s.normal,s.normal,o),s.count++}}const o=j(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(f(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new xe(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Te,be,ye),p(be,be,Te),p(ye,ye,Te),d(Te,be,ye),f(o,Te),o}_getOrCreateComponents(e){return e.components??Pe}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Ae.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=B(new Float64Array(r.length),r,o)),t.reprojection===Ae.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=null!=o?r:new Float64Array(r.length);return v(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Ae.ECEF?r.transformBeforeProject:null;null!=a&&(o=S(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Ae.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return U(o,n,t,e.spatialReference,s)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Ae.ECEF?r.transformBeforeProject:null;null!=a&&(o=L(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Ae.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return $(o,n,t,e.spatialReference,s)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=te(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return re(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=n&&n.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,s),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,s),h=this._createTangentBuffer(e,i,s);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:u,symbolColorBuffer:c,objectTransformation:s.reprojection===Ae.NONE&&null!=s.objectTransformation?s.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:s.reprojection===Ae.NONE&&null!=s.geometryTransformation?s.geometryTransformation:l()}}_computeReprojectionInfo(e){const t=null!=e.transform,r=t&&e.transform.geographic||this._context.renderCoordsHelper.viewingMode===D.Local?Ae.NONE:Ae.ECEF;if(t){if(r===Ae.NONE){const t=l();b(e.spatialReference,e.transform.origin,t,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:t,geometryTransformation:u(e.transform.localMatrix),needsBufferCopy:!1}}const t=n(l(),e.transform.origin);return s(t,t,e.transform.localMatrix),{reprojection:r,transformBeforeProject:t,needsBufferCopy:!0}}return{reprojection:r,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,n){const s=this._context.renderCoordsHelper.spatialReference,u=e.anchor;_e[0]=u.x,_e[1]=u.y,_e[2]=u.z;const c=l();return b(e.spatialReference,_e,c,s),i(Ce,c),B(t,t,Ce),null==a&&null==n||(r(Oe,c),o(Oe,Oe),null!=a&&F(a,a,Oe),null!=n&&F(n,n,Oe,4)),c}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??A(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes&&e.vertexAttributes.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference;let o;const a=t.length/3;return null==r||e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),v(e.vertexAttributes.position,e.spatialReference,0,o,r,0,a)),w(Me),M(Me,o,0,a),!P(Me,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!C(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:u,objectTransformation:c,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const c=[[me.POSITION,new ae(a,3,!0)],[me.NORMAL,new ae(o.normals,3,!0)]],h=[[me.POSITION,t],[me.NORMAL,o.indices]];null!=s&&(c.push([me.COLOR,new ae(s,4,!0)]),h.push([me.COLOR,t])),null!=i&&(c.push([me.SYMBOLCOLOR,new ae(i,4,!0)]),h.push([me.SYMBOLCOLOR,I(t.length)])),null!=n&&(c.push([me.UV0,new ae(n,2,!0)]),h.push([me.UV0,t])),null!=u&&(c.push([me.TANGENT,new ae(u,4,!0)]),h.push([me.TANGENT,t]));const g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,d),_=new le(x,c,h,null,ie.Mesh,g);_.transformation=m,f.push(_)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:c}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class xe{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const _e=_(),Te=_(),be=_(),ye=_(),ve=_(),Ce=l(),Oe=a(),we=l(),Me=O(),Pe=[new R],je=new N;var Ae;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Ae||(Ae={}));export{ge as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f64.js";import{f as n,m as s,a as i}from"../../../../chunks/mat4.js";import{c as l,I as u,b as c}from"../../../../chunks/mat4f64.js";import{s as m,a as h,g as f,e as p,n as d,b as g,f as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as b}from"../../../../chunks/vec3f64.js";import{O as y}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as v,projectVectorToDehydratedPoint as C,projectBuffer as O,canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{create as M,empty as P,expandWithBuffer as j,intersectsClippingArea as A}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as I}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as R,getZeroIndexArray as E}from"../../../../geometry/support/Indices.js";import N from"../../../../geometry/support/MeshComponent.js";import B from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import F from"../../../../geometry/support/MeshTextureTransform.js";import{t as S,a as U}from"../../../../chunks/vec32.js";import{transformNormal as L,projectNormalToPCPF as $,transformTangent as G,projectTangentToPCPF as V}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{MeshTransformUpdateAction as k}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as H}from"../../../ViewingMode.js";import{isEncodedMeshTexture as q}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as W}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as Y,evaluateElevationInfoAtPoint as Z}from"./elevationAlignmentUtils.js";import{ElevationContext as J}from"./ElevationContext.js";import{Graphics3DMeshObject3DGraphicLayer as K}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Q}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as X}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ee,MeshFastUpdateProcessor as te}from"./MeshFastUpdateProcessor.js";import{createMaterial as re}from"../support/edgeUtils.js";import{parseColorMixMode as oe,encodeSymbolColor as ae}from"../support/symbolColorUtils.js";import ne from"../../support/debugFlags.js";import{Attribute as se}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ie,CullFaceOptions as le}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ue}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ce}from"../../webgl-engine/lib/Geometry.js";import{Object3D as me}from"../../webgl-engine/lib/Object3D.js";import{Texture as he}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as fe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as de}from"../../webgl-engine/materials/NativeLineMaterial.js";import{TextureWrapMode as ge}from"../../../webgl/enums.js";const xe=["mesh"];class _e extends X{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ee,this._fastUpdateProcessor=new te,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ne.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new de({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new de({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,xe,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new J),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Y)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=Pe,{origin:s,transform:i}=r;switch(v(t,m(ye,s.x,s.y,s.z??0),n,a),o){case k.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case k.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case k.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:u,renderCoordsHelper:c}=this._context,h=(e,t)=>Z(e,u,l,c,t);return e.alignedSampledElevation=z(e,l,u.spatialReference,h,c,n),e.updateTransform(n,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Ie;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:u,alphaCutoff:c,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(n),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=n,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${u},ac:${c},am:${m}`,t.material instanceof B){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:u,emissiveTextureTransform:c,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(u),x=this._textureTransformUid(c),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=u,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(s),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(c),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ie.Opaque);return null!=t?t.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new he(q(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!q(r)&&t!==ie.Opaque,encoding:q(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),this._context.stage.add(a),this._context.stage.loadImmediate(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return ge.CLAMP_TO_EDGE;case"mirror":return ge.MIRRORED_REPEAT;default:return ge.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=W(t.colorTextureTransform),r.normalTextureTransformMatrix=W(t.normalTextureTransform),r.occlusionTextureTransformMatrix=W(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=W(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=W(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=y;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=y)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,a=t.material?.alphaMode,n="blend"===a,s=!("opaque"===a)&&(this._hasTransparentVertexColors(e)||null!=r&&r.a<1||null!=o&&o.transparent||n),i=this._materialProperties(e,t,s),l=this._materialInfoCache.byUid(i.uid);if(l)return l.material;const u={uid:i.uid,material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},c=null==i.metallicRoughnessTexture&&null==i.metallic&&null==i.roughness,m={usePBR:this._usePBR(),isSchematic:c,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:le.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};c||(m.mrrFactors=[null!=i.metallic?i.metallic:1,null!=i.roughness?i.roughness:1,.5]),t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?le.None:le.Back,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTransparentParameter(m,u),this._setInternalMaterialParameters(i,m);const h=new pe(m);return u.material=h,this._materialInfoCache.set(i.uid,u),this._context.stage.add(h),h}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ie.MaskBlend:ie.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ie.Opaque:"mask"===t.alphaMode?ie.Mask:ie.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(fe.POSITION),o=e.vertexAttributes.get(fe.NORMAL),u=e.indices.get(fe.POSITION),c=e.indices.get(fe.NORMAL),m=r.data,d=o.data;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*c[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+d[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,u,t,Oe),this._getFaceVertices(m,u,t,ye,ve,Ce),h(ye,ye,ve),h(ye,ye,Ce),f(ye,ye,1/3);for(let e=0;e<3;e++)i.push(ye[e]);for(let e=0;e<3;e++)i.push(ye[e]+Oe[e]*a);l.push(l.length),l.push(l.length)}}}const u=t[0].transformation,c=new ce(this._debugVertexNormalMaterial,[[fe.POSITION,new se(n,3,!0)]],[[fe.POSITION,s]],null,ue.Line);t.push(c),c.transformation=u;const m=new ce(this._debugFaceNormalMaterial,[[fe.POSITION,new se(i,3,!0)]],[[fe.POSITION,l]],null,ue.Line);m.transformation=u,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;ne.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,s);const l=new me({geometries:s,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const u=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),c=null!=u?new Q(s[0].material,[u],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,s,null,null,z,r,c);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Y(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>Z(e,h,r,f,t);return m.alignedSampledElevation=z(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=D(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return C([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){this._calculateFaceNormal(e,o,n,Oe);for(let e=0;e<3;e++){const r=3*o[n+e];ye[0]=t[r],ye[1]=t[r+1],ye[2]=t[r+2],p(Oe,ye)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Te(t,o,a)}_createComponentNormalsFlat(e,t){const r=I(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,Oe);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new Te(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,Oe);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:b(),count:0},r[a]=s),h(s.normal,s.normal,o),s.count++}}const o=I(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new Te(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,ye,ve,Ce),g(ve,ve,ye),g(Ce,Ce,ye),x(ye,ve,Ce),d(o,ye),o}_getOrCreateComponents(e){return e.components??Ae}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Re.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=S(new Float64Array(r.length),r,o)),t.reprojection===Re.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=null!=o?r:new Float64Array(r.length);return O(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Re.ECEF?r.transformBeforeProject:null;null!=a&&(o=L(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Re.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return $(o,n,t,e.spatialReference,s)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Re.ECEF?r.transformBeforeProject:null;null!=a&&(o=G(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Re.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return V(o,n,t,e.spatialReference,s)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=oe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ae(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=n&&n.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,s),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,s),h=this._createTangentBuffer(e,i,s);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:u,symbolColorBuffer:c,objectTransformation:s.reprojection===Re.NONE&&null!=s.objectTransformation?s.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:s.reprojection===Re.NONE&&null!=s.geometryTransformation?s.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===H.Local?Re.NONE:Re.ECEF:Re.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??u;if(o===Re.NONE){v(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:c(i),needsBufferCopy:!1}}const m=n(l(),r);return s(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,n){const s=this._context.renderCoordsHelper.spatialReference,u=e.anchor;be[0]=u.x,be[1]=u.y,be[2]=u.z??0;const c=l();return v(e.spatialReference,be,c,s),i(we,c),S(t,t,we),null==a&&null==n||(r(Me,c),o(Me,Me),null!=a&&U(a,a,Me),null!=n&&U(n,n,Me,4)),c}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??R(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes&&e.vertexAttributes.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference;let o;const a=t.length/3;return null==r||e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),O(e.vertexAttributes.position,e.spatialReference,0,o,r,0,a)),P(je),j(je,o,0,a),!A(je,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!w(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:u,objectTransformation:c,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const c=[[fe.POSITION,new se(a,3,!0)],[fe.NORMAL,new se(o.normals,3,!0)]],h=[[fe.POSITION,t],[fe.NORMAL,o.indices]];null!=s&&(c.push([fe.COLOR,new se(s,4,!0)]),h.push([fe.COLOR,t])),null!=i&&(c.push([fe.SYMBOLCOLOR,new se(i,4,!0)]),h.push([fe.SYMBOLCOLOR,E(t.length)])),null!=n&&(c.push([fe.UV0,new se(n,2,!0)]),h.push([fe.UV0,t])),null!=u&&(c.push([fe.TANGENT,new se(u,4,!0)]),h.push([fe.TANGENT,t]));const g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,d),_=new ce(x,c,h,null,ue.Mesh,g);_.transformation=m,f.push(_)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:c}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Te{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const be=b(),ye=b(),ve=b(),Ce=b(),Oe=b(),we=l(),Me=a(),Pe=l(),je=M(),Ae=[new N],Ie=new F;var Re;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Re||(Re={}));export{_e as Graphics3DMeshFillSymbolLayer};
|