@arcgis/core 5.2.0-next.34 → 5.2.0-next.36
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/analysis/Viewshed.d.ts +0 -5
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{4316b78fc36bfd893a90.js → 155940ef3d1888272d73.js} +1 -1
- package/assets/esri/core/workers/chunks/24aa98cb2021ddd789ce.js +1 -0
- package/assets/esri/core/workers/chunks/406c7723e8db470822bf.js +1 -0
- package/assets/esri/core/workers/chunks/{37dc6a8495f1f44e2d45.js → 6c746ac4bd2e57b8cb41.js} +1 -1
- package/assets/esri/core/workers/chunks/{3dd8145ef89f32920177.js → 7b5e628ea3d4a51f1c4e.js} +1 -1
- package/assets/esri/core/workers/chunks/8a9b2efa0603e9fa4e8b.js +1 -0
- package/assets/esri/core/workers/chunks/{fe8032905992e6574714.js → 9fb0431b0628dcb53004.js} +54 -54
- package/assets/esri/core/workers/chunks/bccc199af4e2e49f7acd.js +1 -0
- package/assets/esri/core/workers/chunks/{87c7092282214f5b78b8.js → c72121076e438ed28d60.js} +12 -12
- package/assets/esri/core/workers/chunks/{414691f7758c78e2a704.js → cfbbfa5edffa57bd3a8e.js} +1 -1
- package/assets/esri/core/workers/chunks/d0217187aed8bb7038f4.js +1 -0
- package/assets/esri/core/workers/chunks/{b7d7bfcb089a3f1a38b6.js → dd785e595cd08b2d6284.js} +1 -1
- package/assets/esri/core/workers/chunks/{0087ad36f7d38fc7fe11.js → ee446250a40e5d89bb5a.js} +44 -44
- package/assets/esri/core/workers/chunks/{42b1c526c4c9636a169d.js → f1f3fe9d2d96578f4f6b.js} +1 -1
- package/chunks/FocusAreaColor.glsl.js +1 -10
- package/chunks/RibbonLine.glsl.js +22 -22
- package/config.js +1 -1
- package/core/has.js +1 -1
- package/geometry/support/plane.js +1 -1
- package/geometry/support/triangle.js +1 -1
- package/kernel.js +1 -1
- package/layers/MapImageLayer.js +1 -1
- package/layers/raster/datasets/pixelReader.js +1 -1
- package/layers/raster/functions/pixelUtils.js +1 -1
- package/layers/types.d.ts +9 -2
- package/package.json +1 -1
- package/popup/Features.d.ts +2 -2
- package/popup/Features.js +1 -1
- package/renderers/visualVariables/support/visualVariableUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/support/ExportStrategy.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +1 -1
- package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
- package/views/3d/analysis/Viewshed/types.d.ts +17 -0
- package/views/3d/analysis/ViewshedAnalysisView3D.d.ts +3 -14
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
- package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl/ManagedFBO.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaColor.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaVisualization.js +1 -1
- package/views/3d/webgl-engine/lib/Intersector.js +1 -1
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +1 -1
- package/views/3d/webgl-engine/lib/intersectorUtils.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodLevel.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
- package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineLayouts.js +1 -1
- package/views/View2D.js +1 -1
- package/views/interactive/tooltip/fields/fields.js +1 -1
- package/views/interactive/tooltip/fields/parsingAndFormattingUtils.js +1 -1
- package/views/layers/CatalogDynamicGroupLayerView.js +1 -1
- package/views/layers/ViewshedLayerView.d.ts +0 -10
- package/views/support/LayerViewManager.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
- package/widgets/Editor.d.ts +6 -0
- package/assets/esri/core/workers/chunks/3d1021f7ea9617a76ccf.js +0 -1
- package/assets/esri/core/workers/chunks/7a59d39010ed33b8fabb.js +0 -1
- package/assets/esri/core/workers/chunks/a0f7e37d385fc68b138d.js +0 -1
- package/assets/esri/core/workers/chunks/dfae4440afe0ca7c5b25.js +0 -1
- package/assets/esri/core/workers/chunks/fec9ce6ad634c904ffdf.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../analysis/Viewshed.js";import
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../analysis/Viewshed.js";import o from"../../../../core/Accessor.js";import"../../../../core/has.js";import{createAbortError as i,throwIfAborted as s,onAbort as a}from"../../../../core/promiseUtils.js";import{watch as n,sync as r}from"../../../../core/reactiveUtils.js";import{property as l,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{absoluteHeightElevationInfo as d}from"../../../../support/elevationInfoUtils.js";import{createDrawTool as p,getFeatureReference as _}from"./placementUtils.js";import{detachToolFromView as v}from"./toolLifecycleUtils.js";import m from"./ViewshedPlacementOperation.js";import{createViewshedPlacementRootPluginConfiguration as u}from"./ViewshedPlacementRootPlugin.js";import{computeParametersFromTargetPoint as w}from"./viewshedToolUtils.js";import{vectorToRender as P}from"../../interactive/support/viewUtils.js";import{DrawManipulator3D as g}from"../../../draw/DrawManipulator3D.js";import{ViewEventPriorities as b}from"../../../input/InputManager.js";import{sketchKeys as f}from"../../../interactive/keybindings.js";import S from"../../../interactive/sketch/SketchOptions.js";const y="multiple",O=Symbol("hiddenManipulatorHandle");let T=class extends o{constructor(e){super(e),this.placementMode=y,this.observerPlacementElevationInfo=null,this.stagedViewshed=null,this._placeOperation=null,this._drawTool=null,this._renderer=null,this._sketchOptions=new S({tooltips:{enabled:!1}}),this._observerScenePoint=h(),this._targetScenePoint=h(),this._mapPointVector=h()}initialize(){this.addHandles([this.view.on("key-down",e=>this._handleKeyDown(e),b.DEFAULT),n(()=>{const{stagedViewshed:e}=this;return{stagedViewshed:e,stagedViewshedInAnalysis:null!=e&&this.analysis.viewsheds.includes(e)}},({stagedViewshed:e,stagedViewshedInAnalysis:t})=>{null==e||t||this.analysis.viewsheds.add(e)},r)])}destroy(){this._cancelPlacementOperation()}get updating(){return!!this._drawTool?.updating}get active(){return!!this._drawTool?.active}get creationState(){return this._get("creationState")}set creationState(e){this._set("creationState",e),this._sketchOptions.tooltips.enabled="placing-observer"===e}startPlaceOperation(e,t){this._removeStaged(),this.creationState=null,this._rejectPlaceOperation(i()),s(t);const{resolve:o,reject:n,promise:r}=Promise.withResolvers(),l=a(t,()=>this._cancelPlacementOperation());return this._placeOperation=new m({abortHandle:l,reject:n,resolve:o}),this.placementMode=e,this.observerPlacementElevationInfo=t?.elevationInfo,this.callbacks.setSelectedViewshed(null),this._startObserverPlacement(),r}cancelPlaceOperation(){null==this.creationState&&null==this._placeOperation||(this._cancelPlacementOperation(),this.callbacks.cancelTool())}_handleDeleteDuringCreation(){return null!=this.creationState&&(this._destroyDrawTool(),this._removeStaged(),this.callbacks.setSelectedViewshed(null),this._startObserverPlacement(),!0)}_handleKeyDown(e){null!=this.creationState&&(f.cancel===e.key?(this._handleCancelDuringCreation(),e.stopPropagation(),e.preventDefault()):f.delete.includes(e.key)&&(this._handleDeleteDuringCreation(),e.stopPropagation(),e.preventDefault()))}_handleCancelDuringCreation(){if(this._removeStaged()&&"multiple"===this.placementMode)return this.callbacks.setSelectedViewshed(null),void this._startObserverPlacement();this._destroyDrawTool(),this._abortCreation()}_removeStaged(){const{stagedViewshed:e}=this;return this.stagedViewshed=null,!!e&&(this.analysis.viewsheds.remove(e),!0)}_cancelPlacementOperation(){this._destroyDrawTool(),this._removeStaged(),this.creationState=null,this._finishPlaceOperation()}_abortCreation(){this.callbacks.cancelTool(),this.creationState=null,this._finishPlaceOperation()}_handleObserverPlacementComplete(e,o,i){const s=new t({observer:e,elevationInfo:this.observerPlacementElevationInfo,feature:i});this.analysis.viewsheds.add(s),this.stagedViewshed=s,this.creationState="placing-target",this._updateStagedViewshed(o),this.callbacks.setSelectedViewshed(null)}_onCancel(e){const t=this._removeStaged();return"placing-observer"===this.creationState?t&&"multiple"===this.placementMode?(this.callbacks.setSelectedViewshed(null),void this._startObserverPlacement()):(this._destroyDrawTool(e),void this._abortCreation()):t?(this.creationState="placing-observer",this.callbacks.setSelectedViewshed(null),void("multiple"!==this.placementMode?(this._destroyDrawTool(e),this._abortCreation()):this._startPointPlacement())):(this._destroyDrawTool(e),void this._abortCreation())}_handleTargetPlacementComplete(e){this._updateStagedViewshed(e);const t=this.stagedViewshed;this._placeOperation?.markPlacedViewshed(),this.stagedViewshed=null,this.callbacks.setSelectedViewshed(t)}_resolvePlaceOperation(){this._clearPlaceOperationAndRun(e=>e?.resolve())}_finishPlaceOperation(){this._clearPlaceOperationAndRun(e=>e?.finish())}_rejectPlaceOperation(e){this._clearPlaceOperationAndRun(t=>t?.reject(e))}_clearPlaceOperationAndRun(e){const t=this._placeOperation;this._placeOperation=null,this.observerPlacementElevationInfo=null,e(t)}_startObserverPlacement(){this.creationState="placing-observer",this._startPointPlacement()}_startPointPlacement(){this._drawTool&&this._destroyDrawTool(this._drawTool);const{drawTool:e,intersector:t,renderer:o,snappingManager:i}=p({analysisViewData:this.analysisViewData,view:this.view,sketchOptions:this._sketchOptions,elevationInfo:this._observerDrawToolElevationInfo,getSnapToSceneEnabled:()=>this._snapToSceneEnabled,onCancel:e=>this._onCancel(e),onComplete:e=>this._onComplete(e),onManipulatorCountChange:e=>this._onManipulatorCountChange(e),isPlacingObserver:()=>"placing-observer"===this.creationState});this._drawTool=e,this._renderer=o;try{this.view.addAndActivateTool(e),e.begin([u({mode:this.placementMode,onObserverComplete:(e,o)=>this._onObserverMapPointComplete(t,i,e,o),onTargetComplete:e=>this._onTargetMapPointComplete(e),onObserverPreview:e=>this._onObserverMapPointPreview(e),onTargetPreview:e=>this._onTargetMapPointPreview(e)})])}catch(s){this._destroyDrawTool(e),this._rejectPlaceOperation(s instanceof Error?s:new Error(String(s)))}}_onComplete(e){this._removeStaged(),this._resolvePlaceOperation(),this._destroyDrawTool(e),this.creationState=null}_onObserverMapPointComplete(e,t,o,i){const s=o.clone(),a=this._toScenePoint(o,this._targetScenePoint,this._observerDrawToolElevationInfo),n=_({intersector:e,snappingManager:t,screenPoint:i,view:this.view});this._renderer?.updatePlacementLocation(a),this._handleObserverPlacementComplete(s,a,n),this._setDrawToolElevationInfo(d)}_onTargetMapPointComplete(e){const t=this._toScenePoint(e,this._targetScenePoint);this._renderer?.updatePlacementLocation(t),this._handleTargetPlacementComplete(t),"multiple"===this.placementMode&&(this.creationState="placing-observer",this._setDrawToolElevationInfo(this._observerDrawToolElevationInfo),this._onObserverMapPointPreview(e))}_onObserverMapPointPreview(e){const t=e.clone(),o=this._toScenePoint(t,this._observerScenePoint,this._observerDrawToolElevationInfo);this._renderer?.updatePlacementLocation(o)}_onTargetMapPointPreview(e){const t=this._toScenePoint(e,this._targetScenePoint);this._renderer?.updatePlacementLocation(t),this._updateStagedViewshed(t)}_setDrawToolElevationInfo(e){const t=this._drawTool;t&&(t.elevationInfo=e)}get _observerDrawToolElevationInfo(){return this.observerPlacementElevationInfo??d}get _snapToSceneEnabled(){const e=this.observerPlacementElevationInfo?.mode;return("placing-observer"!==this.creationState||null==e||"absolute-height"===e)&&null}_onManipulatorCountChange(e){e.removeHandles(O);const t=[];e.manipulators.forEach(({manipulator:e})=>{e instanceof g&&t.push(e.disableDisplay())}),e.addHandles(t,O)}_destroyDrawTool(e=this._drawTool){this._drawTool=null,this._renderer=null,e&&v(this.view,e)}_toScenePoint(e,t,o=d){const{x:i,y:s,z:a,spatialReference:n}=e,r=this._mapPointVector;return r[0]=i,r[1]=s,r[2]=a??0,P(r,n,o,this.view,t)}_updateStagedViewshed(e){const t=this.stagedViewshed;if(!t)return;const o=this.callbacks.findViewshedComputedData(t);if(!o)return;const{heading:i,tilt:s,farDistance:a}=w(this.view,o,e);t.farDistance=a,t.tilt=s,t.heading=i}get test(){}};e([l({constructOnly:!0})],T.prototype,"analysis",void 0),e([l({constructOnly:!0})],T.prototype,"analysisViewData",void 0),e([l({constructOnly:!0})],T.prototype,"view",void 0),e([l({constructOnly:!0})],T.prototype,"callbacks",void 0),e([l()],T.prototype,"placementMode",void 0),e([l()],T.prototype,"observerPlacementElevationInfo",void 0),e([l()],T.prototype,"stagedViewshed",void 0),e([l()],T.prototype,"_placeOperation",void 0),e([l()],T.prototype,"_drawTool",void 0),e([l()],T.prototype,"_renderer",void 0),e([l()],T.prototype,"_sketchOptions",void 0),e([l()],T.prototype,"updating",null),e([l()],T.prototype,"active",null),e([l({value:null})],T.prototype,"creationState",null),T=e([c("esri.views.3d.analysis.Viewshed.ViewshedPlacementController")],T);export{T as ViewshedPlacementController};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import{equals as i}from"../../../../core/lang.js";import{deg2rad as s}from"../../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{watch as
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import{equals as i}from"../../../../core/lang.js";import{deg2rad as s}from"../../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{watch as a,initial as o}from"../../../../core/reactiveUtils.js";import{property as l,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{fromRotation as h}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{transformMat4 as m,set as d,sub as u,len as p,normalize as v,scale as _,angle as V,negate as f,copy as E,add as b}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g,clone as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{absoluteHeightElevationInfo as C}from"../../../../support/elevationInfoUtils.js";import{isOtherViewshedToolCreating as A}from"./analysisViewRegister.js";import{viewshedVisualizationConfiguration as L,arcAnglePerSegment as D}from"./ViewshedConfiguration.js";import{ViewshedShapeVisualElement as y}from"./ViewshedShapeVisualElement.js";import{LineVisualElement as S}from"../../interactive/visualElements/LineVisualElement.js";import{PointVisualElement as j}from"../../interactive/visualElements/PointVisualElement.js";import{VerticesVisualElement as O}from"../../interactive/visualElements/VerticesVisualElement.js";import{createStipplePatternSimple as R}from"../../webgl-engine/materials/lineStippleUtils.js";let F=class extends t{constructor(e){super(e),this.visible=!0,this._viewshedCorners={topLeft:g(),topRight:g(),bottomLeft:g(),bottomRight:g()},this._arcCenterPoints={top:g(),bottom:g(),left:g(),right:g()},this._parallelCenters={top:g(),bottom:g()}}initialize(){const e={view:this.view,isDecoration:!0},t={...e,color:this._color,renderOccluded:4},s={...t,stipplePattern:R(2)};this._observerVisualElement=new j({...e,...L.observerPointConfiguration,elevationInfo:C}),this._observerStagedVisualElement=new O({...e,...L.observerStagedPointConfiguration,spatialReference:this.view.renderCoordsHelper.spatialReference,elevationInfo:C}),this._shapeVisualElement=new y({...e,isDecoration:this.isDecoration}),this._frameLinesVisualElement=new S(t),this._leftArcVisualElement=new S(t),this._rightArcVisualElement=new S(t),this._topArcVisualElement=new S(t),this._bottomArcVisualElement=new S(t),this._centralLongitude=new S(s),this._centralLatitude=new S(s),this.addHandles([a(()=>{const e=this.viewshedComputedData,t=this._staged;if(null==e)return null;if(!e.valid)return{viewshedComputedData:e,staged:t,valid:!1};const i=this._viewshedCorners,s=this._arcCenterPoints,r=this._parallelCenters;return e.cornerPoints(i),e.arcCentersPoints(s),e.parallelCenterPoints(r),{viewshedComputedData:e,corners:i,arcCenters:s,parallelCenters:r,staged:t,valid:!0}},e=>{const t=!0===e?.valid,i=!t&&!0===e?.staged;this._forEachVisualElement(e=>e.attached=t),this._observerStagedVisualElement.attached=t||i,(t||i)&&this._updateVisualElements(e)},{initial:!0,equals:i}),a(()=>{const{viewshedComputedData:e}=this,{horizontalFieldOfView:t,verticalFieldOfView:i}=e??{};return{viewshedComputedData:e,horizontalFieldOfView:t,verticalFieldOfView:i}},({viewshedComputedData:e})=>{const{_shapeVisualElement:t}=this;e!==t.viewshedComputedData&&(t.viewshedComputedData=e),this._shapeVisualElement.recreateGeometry()},o),a(()=>{const{interactive:e}=this.analysisViewData;return{visible:this.visible,selected:e&&this._selected,staged:e&&this._staged,horFovNot360:360!==this.viewshedComputedData?.horizontalFieldOfView}},({visible:e,selected:t,staged:i,horFovNot360:s})=>{const r=t||i;this._shapeVisualElement.visible=e,this._topArcVisualElement.visible=e,this._bottomArcVisualElement.visible=e,this._frameLinesVisualElement.visible=e&&s;const a=e&&(t||s);this._leftArcVisualElement.visible=a,this._rightArcVisualElement.visible=a,this._forEachLineVisualElement(e=>{e.width=r?L.frameWidthSelected:L.frameWidthNotSelected,e.renderOccluded=t?4:1}),[this._centralLatitude,this._centralLongitude].forEach(i=>{i.width=2*(r?L.frameWidthSelected:L.frameWidthNotSelected),i.visible=e&&t})},o),a(()=>{const{analysisViewData:{interactive:e,effectiveTool:t},_selected:i,_staged:s,visible:r}=this,a=i||s,o=!t?.active&&A(this.view,this.analysisViewData);return{observerVisible:r&&!a&&(!e||(t?.creating??!1)||o),observerStagedVisible:s,color:this._color}},({observerVisible:e,observerStagedVisible:t,color:i})=>{this._observerVisualElement.visible=e,this._observerStagedVisualElement.visible=t,this._forEachLineVisualElement(e=>e.color=i)},o)])}get _color(){const{viewshedComputedData:e,_selected:t,analysisViewData:i}=this;if(null==e)return L.frameColor.toUnitRGBA();const s=i.effectiveTool?.active||i.interactive,r=e.viewshed===i.stagedViewshed;return(s&&(t||r)?this.view.effectiveTheme.accentColor:L.frameColor).toUnitRGBA()}get _selected(){const{viewshedComputedData:e,analysisViewData:{selectedViewshedComputedData:t}}=this;return null!=e&&e===t}get _staged(){const{analysisViewData:e,viewshedComputedData:t}=this,{effectiveTool:i}=e;return null!=i&&i.creating&&e.stagedViewshed===t?.viewshed}destroy(){this._observerVisualElement=r(this._observerVisualElement),this._observerStagedVisualElement=r(this._observerStagedVisualElement),this._shapeVisualElement=r(this._shapeVisualElement),this._frameLinesVisualElement=r(this._frameLinesVisualElement),this._leftArcVisualElement=r(this._leftArcVisualElement),this._rightArcVisualElement=r(this._rightArcVisualElement),this._topArcVisualElement=r(this._topArcVisualElement),this._bottomArcVisualElement=r(this._bottomArcVisualElement),this._centralLongitude=r(this._centralLongitude),this._centralLatitude=r(this._centralLatitude)}_forEachLineVisualElement(e){[this._frameLinesVisualElement,this._leftArcVisualElement,this._rightArcVisualElement,this._topArcVisualElement,this._bottomArcVisualElement,this._centralLatitude,this._centralLongitude].forEach(e)}_forEachVisualElement(e){this._forEachLineVisualElement(e),e(this._observerVisualElement),e(this._observerStagedVisualElement),e(this._shapeVisualElement)}_updateObserverVisualElements(e){const{viewshedComputedData:t}=e,i=g();this.view.renderCoordsHelper.toRenderCoords(t.elevationAlignedObserver,i),this._observerVisualElement.geometry=t.elevationAlignedObserver,this._observerStagedVisualElement.vertices=[i]}_updateVisualElements(e){if(this._updateObserverVisualElements(e),!e.valid)return;const{viewshedComputedData:t,corners:i,arcCenters:s,parallelCenters:r}=e;this._shapeVisualElement.updateTransform(),this._updateFrameLines(t,i),this._updateFrameArcs(t,i,r),this._updateCentralHelperArcs(t,s)}_updateFrameLines(e,t){const i=e.elevationAlignedObserverRenderSpace;this._frameLinesVisualElement.geometry=[[i,t.topLeft],[i,t.topRight],[i,t.bottomLeft],[i,t.bottomRight]]}_updateFrameArcs(e,t,i){const{elevationAlignedObserverRenderSpace:r,rightVector:a,horizontalFieldOfView:o,tiltedUpVector:l}=e,n=s(o),u=g(),p=c();h(p,n/2,l),m(u,a,p),P(this._leftArcVisualElement,r,t.bottomLeft,t.topLeft,"forward",u),h(p,-n/2,l),d(u,0,0,0),m(u,a,p),P(this._rightArcVisualElement,r,t.bottomRight,t.topRight,"forward",u);const v=o>180?"backward":"forward";P(this._topArcVisualElement,i.top,t.topRight,t.topLeft,v,l),P(this._bottomArcVisualElement,i.bottom,t.bottomRight,t.bottomLeft,v,l)}_updateCentralHelperArcs(e,t){const i=e.elevationAlignedObserverRenderSpace,s=e.horizontalFieldOfView>=180?"backward":"forward";P(this._centralLatitude,i,t.right,t.left,s,e.tiltedUpVector),P(this._centralLongitude,i,t.top,t.bottom,"forward",e.leftVector)}get test(){}};function P(e,t,i,s,r,a,o=D){const l=g();u(l,i,t);const n=p(l),d=g();u(d,s,t),v(d,d),_(d,d,n);let C=V(l,d);const A=w(a);"backward"===r&&(f(A,A),C=-(2*Math.PI-C));const L=[],y=Math.ceil(Math.abs(C)/o),S=c();h(S,C/y,A);const j=g();E(j,l);const O=g();E(O,i);for(let h=0;h<y;h++){const e=g();E(e,O),m(j,j,S),b(O,t,j);const i=g();E(i,O),L.push([e,i])}e.geometry=L}e([l()],F.prototype,"view",void 0),e([l({constructOnly:!0})],F.prototype,"isDecoration",void 0),e([l()],F.prototype,"analysisViewData",void 0),e([l()],F.prototype,"viewshedComputedData",void 0),e([l()],F.prototype,"visible",void 0),e([l()],F.prototype,"_color",null),e([l()],F.prototype,"_selected",null),e([l()],F.prototype,"_staged",null),F=e([n("esri.views.3d.analysis.Viewshed.ViewshedSubVisualization")],F);const U=F;export{U as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{destroyHandle as e}from"../../../../core/handleUtils.js";import{watch as n,
|
|
2
|
+
import{destroyHandle as e}from"../../../../core/handleUtils.js";import{watch as n,syncAndInitial as r,sync as t,initial as o}from"../../../../core/reactiveUtils.js";import{createScreenPointArray as i}from"../../../../core/screenUtils.js";import{ViewshedDrawToolRenderer as a}from"./ViewshedDrawToolRenderer.js";import{isValidIntersectorResult as s}from"../../webgl-engine/lib/IntersectorResult.js";import{toGraphic as l}from"../../webgl-engine/lib/intersectorUtilsConversions.js";import{DrawTool as c}from"../../../draw/DrawTool.js";import{newToolIntersector as d}from"../../../interactive/ToolIntersector.js";import{acquire as p}from"../../../interactive/snapping/SnappingManagerPool.js";function g(i){const{analysisViewData:s,view:l,sketchOptions:g,elevationInfo:m,getSnapToSceneEnabled:u,onCancel:b,onComplete:j,onManipulatorCountChange:f,isPlacingObserver:v}=i,w=new a({view:l,isPlacingObserver:v}),I=p(l),M=d(l.state.viewingMode),{snappingManager:h}=I,y=new c({elevationInfo:m,enableVertexVisuals:!1,hasZ:!0,renderer:w,sketchOptions:g,snappingManager:h,view:l});return y.addHandles([I,e(w),y.on("cancel",()=>b(y)),y.on("complete",()=>j(y)),n(()=>[y.surfaceManager,u()],([e,n])=>{e&&(e.snapToSceneEnabled=n)},r),n(()=>y.manipulators.length,()=>f(y),t),n(()=>s.visible,e=>w.analysisVisible=e,o)]),{drawTool:y,intersector:M,renderer:w,snappingManager:h}}function m({intersector:e,snappingManager:n,screenPoint:r,view:t}){const o=n.getMainFeatureCandidate();return o?b(o):r?u(r,t,e):null}function u(e,n,r){n.sceneIntersectionHelper.intersectToolIntersectorScreen(i(e.x,e.y),r);const t=r.results.min;return s(t)?l(t,n):null}function b(e){const n={id:e.layer.id,objectIdField:"objectIdField"in e.layer?e.layer.objectIdField:void 0};return{attributes:{[n.objectIdField??"ObjectId"]:e.objectId},layer:n,objectId:e.objectId,uid:null}}export{g as createDrawTool,m as getFeatureReference};
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
import type ElevationInfo from "../../../../symbols/support/ElevationInfo.js";
|
|
2
|
+
import type { AbortOptions } from "../../../../core/promiseUtils.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Options for placing a viewshed interactively.
|
|
6
|
+
*
|
|
7
|
+
* @since 5.2
|
|
8
|
+
*/
|
|
9
|
+
export interface ViewshedPlacementOptions extends AbortOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Specifies how the placed viewshed observer is positioned on the vertical axis (z).
|
|
12
|
+
*
|
|
13
|
+
* @since 5.2
|
|
14
|
+
*/
|
|
15
|
+
elevationInfo?: ElevationInfo | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
1
18
|
/**
|
|
2
19
|
* Types for the [ViewshedAnalysisView3D](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/ViewshedAnalysisView3D/).
|
|
3
20
|
*
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type Viewshed from "../../../analysis/Viewshed.js";
|
|
2
2
|
import type ViewshedAnalysis from "../../../analysis/ViewshedAnalysis.js";
|
|
3
3
|
import type AnalysisView3D from "./AnalysisView3D.js";
|
|
4
|
-
import type {
|
|
5
|
-
import type { ViewshedPlacementResult } from "./Viewshed/types.js";
|
|
4
|
+
import type { ViewshedPlacementOptions, ViewshedPlacementResult } from "./Viewshed/types.js";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Represents the analysis view of a [ViewshedAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/ViewshedAnalysis/)
|
|
@@ -71,11 +70,6 @@ export default abstract class ViewshedAnalysisView3D extends AnalysisView3D {
|
|
|
71
70
|
*
|
|
72
71
|
* Calling this method sets [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/ViewshedAnalysisView3D/#interactive) to `true`.
|
|
73
72
|
*
|
|
74
|
-
* > [!WARNING]
|
|
75
|
-
* >
|
|
76
|
-
* > Note that when placing viewsheds interactively, the viewshed is created with a 1.5 meter vertical offset from the scene.
|
|
77
|
-
* > _This behavior is subject to change in a future release._
|
|
78
|
-
*
|
|
79
73
|
* @param options - An object specifying additional options.
|
|
80
74
|
* @returns A promise which resolves when creation is completed successfully or rejected if it is
|
|
81
75
|
* canceled.
|
|
@@ -93,7 +87,7 @@ export default abstract class ViewshedAnalysisView3D extends AnalysisView3D {
|
|
|
93
87
|
* // cancel the placement operation at some later point
|
|
94
88
|
* abortController.abort();
|
|
95
89
|
*/
|
|
96
|
-
createViewsheds(options?:
|
|
90
|
+
createViewsheds(options?: ViewshedPlacementOptions | null | undefined): Promise<void>;
|
|
97
91
|
/**
|
|
98
92
|
* Starts the interactive placement of a single viewshed, adding it to the [analysis](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/ViewshedAnalysisView3D/#analysis).
|
|
99
93
|
*
|
|
@@ -104,11 +98,6 @@ export default abstract class ViewshedAnalysisView3D extends AnalysisView3D {
|
|
|
104
98
|
*
|
|
105
99
|
* Calling this method sets [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/ViewshedAnalysisView3D/#interactive) to `true`.
|
|
106
100
|
*
|
|
107
|
-
* > [!WARNING]
|
|
108
|
-
* >
|
|
109
|
-
* > Note that when placing viewsheds interactively, the viewshed is created with a 1.5 meter vertical offset from the scene.
|
|
110
|
-
* > _This behavior is subject to change in a future release._
|
|
111
|
-
*
|
|
112
101
|
* @param options - An object specifying additional options.
|
|
113
102
|
* @returns A promise which
|
|
114
103
|
* resolves when the operation is completed successfully or rejected if it is canceled.
|
|
@@ -127,5 +116,5 @@ export default abstract class ViewshedAnalysisView3D extends AnalysisView3D {
|
|
|
127
116
|
* // cancel the placement operation at some later point
|
|
128
117
|
* abortController.abort();
|
|
129
118
|
*/
|
|
130
|
-
place(options?:
|
|
119
|
+
place(options?: ViewshedPlacementOptions | null | undefined): Promise<ViewshedPlacementResult>;
|
|
131
120
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{volumeMeasurementConfiguration as t}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import r from"../../../../core/Accessor.js";import o from"../../../../core/Logger.js";import{debounce as i,isPromiseLike as n}from"../../../../core/promiseUtils.js";import{createVolume as s}from"../../../../core/quantity.js";import{whenOnce as a,watch as l,syncAndInitial as u}from"../../../../core/reactiveUtils.js";import{property as p,subclass as m}from"../../../../core/accessorSupport/decorators.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sqrDist as h}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{scaleAndAdd as g}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f,fromValues as y,clone as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as v}from"../../../../core/support/UpdatingHandles.js";import w from"../../../../geometry/Multipoint.js";import{projectOrLoad as E}from"../../../../geometry/projectionUtils.js";import{e as j}from"../../../../chunks/containsOperator.js";import{e as b}from"../../../../chunks/convexHullOperator.js";import{e as R}from"../../../../chunks/simplifyOperator.js";import{e as x}from"../../../../chunks/unionOperator.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBoundingRect as T}from"../../../../geometry/projection/projectBoundingRect.js";import{empty as G,create as L,fromExtent as O,intersects as P}from"../../../../geometry/support/aaBoundingRect.js";import{isClockwise as D}from"../../../../geometry/support/coordsUtils.js";import{newDoubleArray as H}from"../../../../geometry/support/DoubleArray.js";import{a as V}from"../../../../chunks/vec3.js";import I from"../../../../symbols/support/ElevationInfo.js";import{logFailedGeometryProjectionError as M}from"../support/projectionUtils.js";import{VolumeMeasurementCutFillComputation as U}from"./VolumeMeasurementCutFillComputation.js";import{VolumeMeasurementInsufficientDataError as k,VolumeMeasurementPerimeterTooLargeError as A,VolumeMeasurementUnsupportedCoordinateSystemError as F,VolumeMeasurementUnsupportedLayerTransparencyError as S}from"./volumeMeasurementErrors.js";import{VolumeMeasurementRawResult as W}from"./VolumeMeasurementRawResult.js";import N from"./VolumeMeasurementResult.js";import{ElevationContext as z}from"../../layers/graphics/ElevationContext.js";import{getElevationAtPoint as q}from"../../support/ElevationProvider.js";import{polygonToRenderInfoElevationAligned as B}from"../../support/renderInfoUtils/polygon.js";import{IteratorPreorder as Z}from"../../terrain/tileUtils.js";import{CutFillComputation as J,TargetGeometryRenderInfo as K}from"../../webgl-engine/lib/CutFillComputation.js";import{GeometryWorkerHandle as Q}from"../../../support/GeometryWorkerHandle.js";import{isIntegratedMeshLayerView as X}from"../../../support/layerViewUtils.js";let Y=class extends r{constructor(e){super(e),this._measurementWorkerHandle=new Q,this._getElevationProvider=()=>this.view.elevationProvider,this.depthExtremaPositions=null,this._updatingHandles=new v,this._rawResult=null,this._sufficientDataCoverage=!0,this._tileIterator=new Z,this._intersectingObbs=[],this._intersectingTiles=[],this._debouncedUpdate=i(async(e,t,r,o)=>{if(!this._computation.done)return;const{renderCoordsHelper:i}=this.view,n=new U({extent:t,localOrigin:r,renderCoordsHelper:i});this._computation.update(n,o),this._determineDataCoverage(n);const[s]=await Promise.allSettled([this._measurementWorkerHandle.areaHorizontal(e,{returnLength:!0}),a(()=>this._computation.done).then(()=>{this._updateDepthExtremaPositions(n,this._computation.getResult())})]);if(this.error)return void(this._rawResult=null);const l=this._computation.getResult();this._updateResult(n,l,"fulfilled"===s.status?s.value:null)}),this._determineDataCoverage=e=>{const{elevationAlignedGeometry:t}=this,{frustum:r}=this._computation,{cameraDimensions:o}=e;t&&r&&(this._intersectingObbs.length=0,this._imLayerViewsAffectingMeasurement.forEach(e=>{this._findIntersectingObbs(e,r)}),this._intersectingObbs.length?this._sufficientDataCoverage=this._sufficientIntegratedMeshCoverage(t,o):(this._findIntersectingTerrainTiles(t),this._sufficientDataCoverage=this._sufficientTerrainCoverage(o)))}}initialize(){const e=this.view;this._computation=new J({view:e}),this.addHandles([this._createElevationUpdateHandle(),l(()=>({projectedGeometry:this._projectedGeometry,localOrigin:this._localOrigin,targetGeometryRenderInfo:this._targetGeometryRenderInfo,transparencyError:!!this._unsupportedLayerTransparencyError}),({projectedGeometry:e,localOrigin:t,targetGeometryRenderInfo:r,transparencyError:o})=>{const i=e?.extent;if(!e||!i||!t||!r||o)return this._rawResult=null,void(this._sufficientDataCoverage=!0);this._updatingHandles.consumePromise(this._debouncedUpdate(e,i,t,r))},u)])}destroy(){this._updatingHandles.destroy(),this._computation.destroy(),this._measurementWorkerHandle.destroy()}get _projectedGeometry(){const e=this.analysis.geometry;if(!e||!this.analysis.valid)return null;const t=R(e),r=E(t,this.view.spatialReference);return r.pending?(this._updatingHandles.consumePromise(r.pending),null):(t&&!r.geometry&&M(this.analysis,e.spatialReference,o.getLogger(this)),r.geometry)}get _localOrigin(){const e=this._projectedGeometry?.extent;return e?y(e.center.x,e.center.y,0):null}get elevationAlignedGeometry(){const e=this._projectedGeometry;if(!e)return null;const t=e.clone();return $(this._getElevationProvider(),t),t}get targetGeometry(){const{elevationAlignedGeometry:e}=this;if(!e)return null;const t=this.analysis.measureType,{effectiveTargetElevation:r}=this.analysisViewData;if("stockpile"===t||null==r)return e;const o=e.clone();return o.rings.forEach(e=>e.forEach(e=>e[2]=r)),o}get _targetGeometryRenderInfo(){const e=this.targetGeometry,t=this._projectedGeometry?.extent,r=this._localOrigin;if(!e||!t||!r)return null;const{elevationProvider:o,renderCoordsHelper:i}=this.view,s=B(e,o,i,z.fromElevationInfo(new I({mode:"absolute-height"})));if(n(s))return this._updatingHandles.consumePromise(s),null;if(null==s)return null;const{positions:a,polygonIndices:l,vertexCount:u}=s,p=H(3*u),m=c(),h=c();return C(t.spatialReference,r,m,i.spatialReference),h[12]=-m[12],h[13]=-m[13],h[14]=-m[14],V(p,a,h),new K(p,l)}get updating(){return this._computation.updating||this._updatingHandles.updating}get result(){const e=this._rawResult,{volume:t,area:r,length:o}=this.analysisViewData.effectiveDisplayUnits;return e?new N({measureType:this.analysis.measureType,rawResult:e,volumeUnit:t,areaUnit:r,lengthUnit:o}):null}get error(){return this._unsupportedCoordinateSystemError??this._unsupportedLayerTransparencyError??this._perimeterTooLargeError??this._insufficientDataError}get _imLayerViewsAffectingMeasurement(){return this.view.allLayerViews.filter(e=>X(e)).filter(e=>e.visible&&!e.suspended)}get _insufficientDataError(){return this._sufficientDataCoverage?null:new k}get _perimeterTooLargeError(){return this._perimeterTooLargeLocalError??this._perimeterTooLargeGlobalError}get _perimeterTooLargeLocalError(){const{spatialReference:e,state:{isLocal:r}}=this.view;if(!r||!e.isWebMercator)return null;const o=this._perimeterForError,{maxPerimeterLocalWebMercator:i}=t;return null!=o&&o>i?new A:null}get _perimeterTooLargeGlobalError(){if(!this.view.state.isGlobal)return null;const e=this._perimeterForError,{maxPerimeterGlobal:r}=t;return null!=e&&e>r?new A:null}get _unsupportedCoordinateSystemError(){return this.view.state.isLocal&&this.view.spatialReference.isGeographic?new F:null}get _unsupportedLayerTransparencyError(){return this.view.map.ground&&this.view.map.ground.opacity<1?new S:null}get _perimeterForError(){const{targetGeometry:e}=this;if(null==e)return null;let t=null;for(const r of e.rings){if(!D(r))continue;const e=te(re(r));t=e?Math.max(t??0,e):t}return null!=t?t*e.spatialReference.metersPerUnit:null}_createElevationUpdateHandle(){const e=e=>{const t=this._projectedGeometry?.extent;"ground"===e.context&&t&&(T(e.extent,e.spatialReference,ie,this.view.spatialReference),O(t,ne),P(ie,ne)&&(this._getElevationProvider=()=>this.view.elevationProvider))};return this.view.elevationProvider.on("elevation-change",t=>e(t))}_updateResult(e,t,r){const{unitInMeters:o}=this.view.renderCoordsHelper,{dimensions:{width:i,height:n},cameraNearFar:{near:a,far:l}}=e,u=i/t.width*(n/t.height),p=ee(t.cut.totalDepth,a,l)*u,m=ee(t.fill.totalDepth,a,l)*u,c=o**3;this._rawResult=new W({cutVolume:s(Math.abs(p*c),"cubic-meters"),fillVolume:s(m*c,"cubic-meters"),area:r?.area,perimeter:r?.length})}_updateDepthExtremaPositions(e,t){const{dimensions:{width:r,height:o},cameraNearFar:{near:i,far:n},cameraPositionRenderSpace:s,northVector:a,eastVector:l,upVector:u}=e,p=e=>{const{depthExtremum:p,depthExtremumCoords:[m,c],totalDepth:h}=e,d=_(s);return 0!==h&&(g(d,d,l,r*(m/t.width-.5)),g(d,d,a,o*(c/t.height-.5))),g(d,d,u,-ee(p,i,n)),d};this.depthExtremaPositions={cut:p(t.cut),fill:p(t.fill)}}_findIntersectingObbs(e,t){const r=this._intersectingObbs;"integrated-mesh-3d"===e.type&&e.getVisibleNodes().forEach(o=>{e.isNodeLoaded(o.index)&&o.geometryObbInRenderSR?.intersectsFrustum(t)&&r.push(o.geometryObbInRenderSR)}),"integrated-mesh-3dtiles"===e.type&&e.forEachVisibleComponentObject(({obb:e})=>{e.intersectsFrustum(t)&&r.push(e)})}_sufficientIntegratedMeshCoverage(e,t){const{renderCoordsHelper:r,spatialReference:o}=this.view,i=[],n=new w({spatialReference:o});if(this._intersectingObbs.forEach(e=>{if(oe(e.radius,t)&&(e.getCorners(ae),n.points.length=0,ae.forEach(e=>{const t=r.fromRenderCoords(e,le,o);t&&n.addPoint([t[0],t[1]])}),n.points.length)){const e=b(n);"polygon"===e?.type&&i.push(e)}}),!i.length)return!1;const s=x(i);return!!s&&j(s,e)}_findIntersectingTerrainTiles(e){const{basemapTerrain:t}=this.view;if(this._intersectingTiles.length=0,!e.extent)return;O(e.extent,se);const r=this._tileIterator;r.reset(t.rootTiles);for(let o=r.next();o;o=r.next())o.intersectsExtent(se)?o.rendered&&this._intersectingTiles.push(o):r.skipSubtree()}_sufficientTerrainCoverage(e){const{basemapTerrain:{tilingScheme:t}}=this.view;if(!this._intersectingTiles.length)return!1;const r=256/t.pixelSize;return this._intersectingTiles.every(t=>oe(t.radius*r,e))}};function $(e,t){t.hasZ=!0,t.rings.forEach(t=>t.forEach(t=>t[2]=q(e,t,"ground")??0))}function ee(e,t,r){return e*(r-t)+t}function te(e){if(!e)return null;let t=null,r=null,o=0;for(const i of e)t||(t=[i[0],i[1]]),r?o+=h(r,i):r=[0,0],r[0]=i[0],r[1]=i[1];return t&&r&&(o+=h(r,t)),Math.sqrt(o)}function*re(e){const t=d();for(let r=0;r<e.length;r++)t[0]=e[r][0],t[1]=e[r][1],yield t}e([p()],Y.prototype,"_projectedGeometry",null),e([p()],Y.prototype,"_localOrigin",null),e([p()],Y.prototype,"_getElevationProvider",void 0),e([p()],Y.prototype,"elevationAlignedGeometry",null),e([p()],Y.prototype,"targetGeometry",null),e([p()],Y.prototype,"_targetGeometryRenderInfo",null),e([p({constructOnly:!0})],Y.prototype,"analysis",void 0),e([p({constructOnly:!0})],Y.prototype,"analysisViewData",void 0),e([p({constructOnly:!0})],Y.prototype,"view",void 0),e([p()],Y.prototype,"updating",null),e([p()],Y.prototype,"result",null),e([p()],Y.prototype,"depthExtremaPositions",void 0),e([p()],Y.prototype,"error",null),e([p()],Y.prototype,"_imLayerViewsAffectingMeasurement",null),e([p()],Y.prototype,"_insufficientDataError",null),e([p()],Y.prototype,"_perimeterTooLargeError",null),e([p()],Y.prototype,"_perimeterTooLargeLocalError",null),e([p()],Y.prototype,"_perimeterTooLargeGlobalError",null),e([p()],Y.prototype,"_unsupportedCoordinateSystemError",null),e([p()],Y.prototype,"_unsupportedLayerTransparencyError",null),e([p()],Y.prototype,"_perimeterForError",null),e([p()],Y.prototype,"_computation",void 0),e([p({readOnly:!0})],Y.prototype,"_updatingHandles",void 0),e([p()],Y.prototype,"_rawResult",void 0),e([p()],Y.prototype,"_sufficientDataCoverage",void 0),Y=e([m("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillController")],Y);const oe=(e,t)=>e<(t.width+t.height)/2,ie=G(),ne=G(),se=L(),ae=new Array(8).fill(0).map(()=>f()),le=f();export{Y as VolumeMeasurementCutFillController};
|
|
2
|
+
import{__decorate as e}from"tslib";import{volumeMeasurementConfiguration as t}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import r from"../../../../core/Accessor.js";import o from"../../../../core/Logger.js";import{debounce as i,isPromiseLike as n}from"../../../../core/promiseUtils.js";import{createVolume as s}from"../../../../core/quantity.js";import{whenOnce as a,watch as l}from"../../../../core/reactiveUtils.js";import{property as u,subclass as p}from"../../../../core/accessorSupport/decorators.js";import{runUntracked as m}from"../../../../core/accessorSupport/tracking.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{setAxes as h}from"../../../../core/libs/gl-matrix-2/math/quat.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{sqrDist as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{scaleAndAdd as y,scale as _,set as v,negate as b}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as w,fromValues as j,clone as E}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as R}from"../../../../core/support/UpdatingHandles.js";import x from"../../../../geometry/Multipoint.js";import{projectOrLoad as C}from"../../../../geometry/projectionUtils.js";import{e as T}from"../../../../chunks/containsOperator.js";import{e as O}from"../../../../chunks/convexHullOperator.js";import{e as L}from"../../../../chunks/simplifyOperator.js";import{e as G}from"../../../../chunks/unionOperator.js";import{computeTranslationToOriginAndRotation as V}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBoundingRect as D}from"../../../../geometry/projection/projectBoundingRect.js";import{empty as H,create as M,fromExtent as I,intersects as P}from"../../../../geometry/support/aaBoundingRect.js";import{vectorCoordinates as U}from"../../../../geometry/support/coordinateSystem.js";import{isClockwise as S}from"../../../../geometry/support/coordsUtils.js";import{newDoubleArray as k}from"../../../../geometry/support/DoubleArray.js";import{a as A}from"../../../../chunks/vec3.js";import F from"../../../../symbols/support/ElevationInfo.js";import{logFailedGeometryProjectionError as W}from"../support/projectionUtils.js";import{VolumeMeasurementCutFillComputation as q}from"./VolumeMeasurementCutFillComputation.js";import{VolumeMeasurementInsufficientDataError as B,VolumeMeasurementPerimeterTooLargeError as N,VolumeMeasurementUnsupportedCoordinateSystemError as z,VolumeMeasurementUnsupportedLayerTransparencyError as Z}from"./volumeMeasurementErrors.js";import{VolumeMeasurementRawResult as J}from"./VolumeMeasurementRawResult.js";import K from"./VolumeMeasurementResult.js";import{ElevationContext as Q}from"../../layers/graphics/ElevationContext.js";import{getElevationAtPoint as X}from"../../support/ElevationProvider.js";import{Obb as Y}from"../../support/orientedBoundingBox.js";import{polygonToRenderInfoElevationAligned as $}from"../../support/renderInfoUtils/polygon.js";import{IteratorPreorder as ee}from"../../terrain/tileUtils.js";import{CutFillComputation as te,TargetGeometryRenderInfo as re}from"../../webgl-engine/lib/CutFillComputation.js";import{GeometryWorkerHandle as oe}from"../../../support/GeometryWorkerHandle.js";import{isIntegratedMeshLayerView as ie}from"../../../support/layerViewUtils.js";let ne=class extends r{constructor(e){super(e),this._measurementWorkerHandle=new oe,this.depthExtremaPositions=null,this.analysisObb=null,this._updatingHandles=new R,this._rawResult=null,this._sufficientDataCoverage=!0,this._tileIterator=new ee,this._intersectingObbs=[],this._intersectingTiles=[],this._debouncedUpdate=i(async(e,t,r,o)=>{if(!this._computation.done)return;const{renderCoordsHelper:i}=this.view,n=new q({extent:t,localOrigin:r,renderCoordsHelper:i});this._computation.update(n,o),this._determineDataCoverage(n,e);const[s]=await Promise.allSettled([this._measurementWorkerHandle.areaHorizontal(e,{returnLength:!0}),a(()=>this._computation.done).then(()=>{this._updateDepthExtremaPositions(n,this._computation.getResult())})]);if(this.error)return void(this._rawResult=null);const l=this._computation.getResult();this._updateResult(n,l,"fulfilled"===s.status?s.value:null)}),this._determineDataCoverage=(e,t)=>{const{frustum:r}=this._computation,{cameraDimensions:o}=e;t.extent&&r&&(this._intersectingObbs.length=0,this._imLayerViewsAffectingMeasurement.forEach(e=>{this._findIntersectingObbs(e,r)}),this._intersectingObbs.length?this._sufficientDataCoverage=this._sufficientIntegratedMeshCoverage(t,o):(this._findIntersectingTerrainTiles(t.extent),this._sufficientDataCoverage=this._sufficientTerrainCoverage(o)))}}initialize(){const e=this.view;this._computation=new te({view:e}),this.addHandles([this._createElevationUpdateHandle(),l(()=>({localOrigin:this._localOrigin,targetGeometryRenderInfo:this._targetGeometryRenderInfo,transparencyError:!!this._unsupportedLayerTransparencyError}),({localOrigin:e,targetGeometryRenderInfo:t,transparencyError:r})=>{const o=this._projectedGeometry,i=o?.extent;if(!o||!i||!e||!t||r)return this._rawResult=null,this.depthExtremaPositions=null,this.analysisObb=null,void(this._sufficientDataCoverage=!0);this._updatingHandles.consumePromise(this._debouncedUpdate(o,i,e,t))})])}destroy(){this._updatingHandles.destroy(),this._computation.destroy(),this._measurementWorkerHandle.destroy()}get _projectedGeometry(){const e=this.analysis.geometry;if(!e||!this.analysis.valid)return null;const t=L(e),r=C(t,this.view.spatialReference);return r.pending?(this._updatingHandles.consumePromise(r.pending),null):(t&&!r.geometry&&W(this.analysis,e.spatialReference,o.getLogger(this)),r.geometry)}get _localOrigin(){const e=this._projectedGeometry?.extent;return e?j(e.center.x,e.center.y,0):null}get elevationAlignedGeometry(){const e=this._projectedGeometry;return e?m(()=>{const t=e.clone();return se(this.view.elevationProvider,t),t}):null}get targetGeometry(){const{elevationAlignedGeometry:e}=this;if(!e)return null;const t=this.analysis.measureType,{effectiveTargetElevation:r}=this.analysisViewData;if("stockpile"===t||null==r)return e;const o=e.clone();return o.rings.forEach(e=>e.forEach(e=>e[2]=r)),o}get _targetGeometryRenderInfo(){const e=this.targetGeometry,t=this._localOrigin;if(!e||!t)return null;const{elevationProvider:r,renderCoordsHelper:o}=this.view,i=$(e,r,o,Q.fromElevationInfo(new F({mode:"absolute-height"})));if(n(i))return this._updatingHandles.consumePromise(i),null;if(null==i)return null;const{positions:s,polygonIndices:a,vertexCount:l}=i,u=k(3*l),p=c(),m=c();return V(e.spatialReference,t,p,o.spatialReference),m[12]=-p[12],m[13]=-p[13],m[14]=-p[14],A(u,s,m),new re(u,a)}get updating(){return this._computation.updating||this._updatingHandles.updating}get result(){const e=this._rawResult,{volume:t,area:r,length:o}=this.analysisViewData.effectiveDisplayUnits;return e?new K({measureType:this.analysis.measureType,rawResult:e,volumeUnit:t,areaUnit:r,lengthUnit:o}):null}get error(){return this._unsupportedCoordinateSystemError??this._unsupportedLayerTransparencyError??this._perimeterTooLargeError??this._insufficientDataError}get _imLayerViewsAffectingMeasurement(){return this.view.allLayerViews.filter(e=>ie(e)).filter(e=>e.visible&&!e.suspended)}get _insufficientDataError(){return this._sufficientDataCoverage?null:new B}get _perimeterTooLargeError(){return this._perimeterTooLargeLocalError??this._perimeterTooLargeGlobalError}get _perimeterTooLargeLocalError(){const{spatialReference:e,state:{isLocal:r}}=this.view;if(!r||!e.isWebMercator)return null;const o=this._perimeterForError,{maxPerimeterLocalWebMercator:i}=t;return null!=o&&o>i?new N:null}get _perimeterTooLargeGlobalError(){if(!this.view.state.isGlobal)return null;const e=this._perimeterForError,{maxPerimeterGlobal:r}=t;return null!=e&&e>r?new N:null}get _unsupportedCoordinateSystemError(){return this.view.state.isLocal&&this.view.spatialReference.isGeographic?new z:null}get _unsupportedLayerTransparencyError(){return this.view.map.ground&&this.view.map.ground.opacity<1?new Z:null}get _perimeterForError(){const e=this._projectedGeometry;if(null==e)return null;let t=null;for(const r of e.rings){if(!S(r))continue;const e=ue(pe(r));t=e?Math.max(t??0,e):t}return null!=t?t*e.spatialReference.metersPerUnit:null}_createElevationUpdateHandle(){const e=e=>{const t=this._projectedGeometry?.extent;"ground"===e.context&&t&&(D(e.extent,e.spatialReference,ce,this.view.spatialReference),I(t,he),P(ce,he)&&this.notifyChange("elevationAlignedGeometry"))};return this.view.elevationProvider.on("elevation-change",t=>e(t))}_updateResult(e,t,r){const{unitInMeters:o}=this.view.renderCoordsHelper,{dimensions:{width:i,height:n},cameraNearFar:{near:a,far:l}}=e,u=i/t.width*(n/t.height),p=ae(t.cut.totalDepth,a,l)*u,m=ae(t.fill.totalDepth,a,l)*u,c=o**3;this._rawResult=new J({cutVolume:s(Math.abs(p*c),"cubic-meters"),fillVolume:s(m*c,"cubic-meters"),area:r?.area,perimeter:r?.length})}_updateDepthExtremaPositions(e,t){const{dimensions:{width:r,height:o},cameraNearFar:{near:i,far:n},cameraPositionRenderSpace:s,northVector:a,eastVector:l,upVector:u}=e,p=e=>{const{depthExtremum:p,depthExtremumCoords:[m,c],totalDepth:h}=e,d=E(s);return 0!==h&&(y(d,d,l,r*(m/t.width-.5)),y(d,d,a,o*(c/t.height-.5))),y(d,d,u,-ae(p,i,n)),d},m={cut:p(t.cut),fill:p(t.fill)};this.depthExtremaPositions=m,this.analysisObb=le(e,m)}_findIntersectingObbs(e,t){const r=this._intersectingObbs;"integrated-mesh-3d"===e.type&&e.getVisibleNodes().forEach(o=>{e.isNodeLoaded(o.index)&&o.geometryObbInRenderSR?.intersectsFrustum(t)&&r.push(o.geometryObbInRenderSR)}),"integrated-mesh-3dtiles"===e.type&&e.forEachVisibleComponentObject(({obb:e})=>{e.intersectsFrustum(t)&&r.push(e)})}_sufficientIntegratedMeshCoverage(e,t){const{renderCoordsHelper:r,spatialReference:o}=this.view,i=[],n=new x({spatialReference:o});if(this._intersectingObbs.forEach(e=>{if(me(e.radius,t)&&(e.getCorners(we),n.points.length=0,we.forEach(e=>{const t=r.fromRenderCoords(e,je,o);t&&n.addPoint([t[0],t[1]])}),n.points.length)){const e=O(n);"polygon"===e?.type&&i.push(e)}}),!i.length)return!1;const s=G(i);return!!s&&T(s,e)}_findIntersectingTerrainTiles(e){const{basemapTerrain:t}=this.view;this._intersectingTiles.length=0,I(e,de);const r=this._tileIterator;r.reset(t.rootTiles);for(let o=r.next();o;o=r.next())o.intersectsExtent(de)?o.rendered&&this._intersectingTiles.push(o):r.skipSubtree()}_sufficientTerrainCoverage(e){const{basemapTerrain:{tilingScheme:t}}=this.view;if(!this._intersectingTiles.length)return!1;const r=256/t.pixelSize;return this._intersectingTiles.every(t=>me(t.radius*r,e))}};function se(e,t){t.hasZ=!0,t.rings.forEach(t=>t.forEach(t=>t[2]=X(e,t,"ground")??0))}function ae(e,t,r){return e*(r-t)+t}function le(e,t){const{boundingRect:r,eastVector:o,northVector:i,upVector:n}=e;U(t.cut,o,i,n,fe),U(t.fill,o,i,n,ge);const s=.5*(r[0]+r[2]),a=.5*(r[1]+r[3]),l=Math.min(fe[2],ge[2]),u=Math.max(fe[2],ge[2]),p=.5*(l+u);return _(ye,o,s),y(ye,ye,i,a),y(ye,ye,n,p),v(_e,.5*(r[2]-r[0]),.5*(r[3]-r[1]),.5*(u-l)),b(ve,n),new Y(ye,_e,h(be,ve,o,i))}function ue(e){if(!e)return null;let t=null,r=null,o=0;for(const i of e)t||(t=[i[0],i[1]]),r?o+=f(r,i):r=[0,0],r[0]=i[0],r[1]=i[1];return t&&r&&(o+=f(r,t)),Math.sqrt(o)}function*pe(e){const t=g();for(let r=0;r<e.length;r++)t[0]=e[r][0],t[1]=e[r][1],yield t}e([u()],ne.prototype,"_projectedGeometry",null),e([u()],ne.prototype,"_localOrigin",null),e([u()],ne.prototype,"elevationAlignedGeometry",null),e([u()],ne.prototype,"targetGeometry",null),e([u()],ne.prototype,"_targetGeometryRenderInfo",null),e([u({constructOnly:!0})],ne.prototype,"analysis",void 0),e([u({constructOnly:!0})],ne.prototype,"analysisViewData",void 0),e([u({constructOnly:!0})],ne.prototype,"view",void 0),e([u()],ne.prototype,"updating",null),e([u()],ne.prototype,"result",null),e([u()],ne.prototype,"depthExtremaPositions",void 0),e([u()],ne.prototype,"analysisObb",void 0),e([u()],ne.prototype,"error",null),e([u()],ne.prototype,"_imLayerViewsAffectingMeasurement",null),e([u()],ne.prototype,"_insufficientDataError",null),e([u()],ne.prototype,"_perimeterTooLargeError",null),e([u()],ne.prototype,"_perimeterTooLargeLocalError",null),e([u()],ne.prototype,"_perimeterTooLargeGlobalError",null),e([u()],ne.prototype,"_unsupportedCoordinateSystemError",null),e([u()],ne.prototype,"_unsupportedLayerTransparencyError",null),e([u()],ne.prototype,"_perimeterForError",null),e([u()],ne.prototype,"_computation",void 0),e([u({readOnly:!0})],ne.prototype,"_updatingHandles",void 0),e([u()],ne.prototype,"_rawResult",void 0),e([u()],ne.prototype,"_sufficientDataCoverage",void 0),ne=e([p("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillController")],ne);const me=(e,t)=>e<(t.width+t.height)/2,ce=H(),he=H(),de=M(),fe=w(),ge=w(),ye=w(),_e=w(),ve=w(),be=d(),we=new Array(8).fill(0).map(()=>w()),je=w();export{ne as VolumeMeasurementCutFillController};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as i,fetchMessageBundle as s}from"../../../../intl.js";import{volumeMeasurementConfiguration as o}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import l from"../../../../core/Accessor.js";import{equals as r}from"../../../../core/arrayUtils.js";import{cyclicalPI as n}from"../../../../core/Cyclical.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import{isPromiseLike as c}from"../../../../core/promiseUtils.js";import{preferredVolumePrecision as u,formatDecimal as m}from"../../../../core/quantityFormatUtils.js";import{watch as d,initial as h}from"../../../../core/reactiveUtils.js";import{adaptiveVolumeUnit as p}from"../../../../core/units.js";import{property as g,subclass as y}from"../../../../core/accessorSupport/decorators.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f,normalize as v,subtract as j,cross as L,dot as b}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as C,fromValues as V}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as w}from"../../../../core/support/UpdatingHandles.js";import{computeTranslationToOriginAndRotation as G}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{angleAroundAxis as P}from"../../../../geometry/support/vector.js";import{a as F}from"../../../../chunks/vec3.js";import x from"../../../../symbols/support/ElevationInfo.js";import{LabelVisualElement as R}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as O}from"../../interactive/visualElements/LineVisualElement.js";import{OutlineVisualElement as M}from"../../interactive/visualElements/OutlineVisualElement.js";import{EuclideanSegment as A}from"../../interactive/visualElements/support/Segment.js";import{ElevationContext as D}from"../../layers/graphics/ElevationContext.js";import{extrudePolygon as U}from"../../layers/graphics/extrudeUtils.js";import{polygonToRenderInfoElevationAligned as E}from"../../support/renderInfoUtils/polygon.js";import{CutFillVisualization as S,VolumeGeometry as z}from"../../webgl-engine/lib/CutFillVisualization.js";import{createStipplePatternSimple as H}from"../../webgl-engine/materials/lineStippleUtils.js";let B=class extends l{get visible(){return this.analysisViewData.visible&&null!=this.analysisViewData.elevationAlignedGeometry&&null!=this.analysisViewData.targetGeometry}get updating(){return this.loadingMessages||this._updatingHandles.updating}get hasUnsupportedError(){const{error:e}=this.analysisViewData;return!!e&&["unsupported-coordinate-system","unsupported-layer-transparency"].includes(e.name)}get _extrusionHeights(){const{renderCoordsHelper:e}=this.view,{depthExtremaPositions:t,targetGeometry:i}=this.analysisViewData,{targetElevationRange:s}=o;if(!i||!t)return{cut:s,fill:-s};let l=-1/0;for(const o of i.rings)for(const e of o)l=Math.max(l,e[2]);const r=1,n=e.getAltitude(t.fill);return{cut:s,fill:Math.min(n-l,0)-r}}constructor(e){super(e),this.unitsMessages=null,this.messages=null,this.loadingMessages=!0,this._updatingHandles=new w,this._elevationContext=D.fromElevationInfo(new x({mode:"absolute-height"})),this._projectionLines=[]}initialize(){const{view:e}=this,i={view:e,isDecoration:!0},s=o,l={...i,width:s.geometryOutlineWidth};this._elevationAlignedGeometry=new M({...l,isDraped:!0,color:s.geometryOutlineColor.toUnitRGBA()}),this._targetGeometry=new M(l);const r={...i,attached:!0,width:s.projectionLineWidth,renderOccluded:4,polygonOffset:3},n={...r,stipplePattern:H(s.projectionLineStippleSize)},a=s.cutProjectionLineColor.toUnitRGBA(),c=s.fillProjectionLineColor.toUnitRGBA();this._cutProjectionLines=new O({...r,color:a}),this._occludedCutProjectionLines=new O({...n,color:a}),this._fillProjectionLines=new O({...r,color:c,renderOccluded:8}),this._occludedFillProjectionLines=new O({...n,color:c});const u={...i,attached:!0};this._cutVolumeLabel=new R({...u,distance:s.labelDistance}),this._fillVolumeLabel=new R({...u,distance:-s.labelDistance}),this._cutFillVisualization=new S({view:e,cutColor:s.cutColor,fillColor:s.fillColor,borderColor:s.geometryOutlineColor}),this.addHandles([d(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry}),({elevationAlignedGeometry:e,targetGeometry:t})=>{this._elevationAlignedGeometry.geometry=e,this._targetGeometry.geometry=t},h),d(()=>({interactive:this.analysisViewData.interactive,measureType:this.analysis.measureType,visible:this.visible}),({visible:e,interactive:t,measureType:i})=>{this._elevationAlignedGeometry.visible=e&&!t,this._targetGeometry.visible=e&&"cut-fill"===i,this._cutFillVisualization.measureType=i},h),d(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry,visible:this.visible}),({elevationAlignedGeometry:e,targetGeometry:t,visible:i})=>this._updateProjectionLines(e,t,i),h),d(()=>({interactive:this.analysisViewData.interactive,accentColor:this.view.effectiveTheme.accentColor,hasResult:!!this.analysisViewData.result}),({interactive:e,accentColor:t,hasResult:i})=>{this._updateColors(e,t,i)},h),d(()=>[this.analysisViewData.targetGeometry,this._extrusionHeights,this._polygonRenderInfo],()=>this._updateCutFillGeometry(),h),d(()=>this.visible&&this.view.state.camera.aboveGround&&!this.hasUnsupportedError,e=>this._updateCutFillVisibility(e),h),d(()=>{const{messages:e,unitsMessages:t,visible:i,analysisViewData:s}=this;return{depthExtremaPositions:s.depthExtremaPositions,effectiveDisplayUnits:s.effectiveDisplayUnits,messages:e,unitsMessages:t,result:s.result,visible:i&&!!s.result}},e=>this._updateLabels(e)),d(()=>this.view.state.camera,e=>this._updateProjectionLineOcclusion(e),h),t(()=>this._updateMessageBundle())]),this._updateMessageBundle()}destroy(){this._elevationAlignedGeometry=a(this._elevationAlignedGeometry),this._targetGeometry=a(this._targetGeometry),this._cutProjectionLines=a(this._cutProjectionLines),this._occludedCutProjectionLines=a(this._occludedCutProjectionLines),this._fillProjectionLines=a(this._fillProjectionLines),this._occludedFillProjectionLines=a(this._occludedFillProjectionLines),this._cutVolumeLabel=a(this._cutVolumeLabel),this._fillVolumeLabel=a(this._fillVolumeLabel),this._cutFillVisualization.destroy(),this._updatingHandles.destroy()}_updateProjectionLines(e,t,i){if(this._cutProjectionLines.visible=i,this._occludedCutProjectionLines.visible=i,this._fillProjectionLines.visible=i,this._occludedFillProjectionLines.visible=i,!e||!t)return;const{renderCoordsHelper:s}=this.view,o=[],l=[],n=[],a=[],c=[],u=e.spatialReference;for(let m=0;m<e.rings.length;m++){const i=e.rings[m],d=i.length>1&&r(i[0],i[i.length-1]),h=i.length-(d?1:0),p=[];for(let e=0;e<h;++e){const o=i[e],l=f(C(),o[0],o[1],o[2]);s.toRenderCoords(l,u,l);const r=t.rings[m][e],n=f(C(),r[0],r[1],r[2]);s.toRenderCoords(n,u,n);const a=new A(l,n);p.push(a)}const g=this.view.state.camera;for(let e=0;e<p.length;++e){const s=p[e],r=p[0===e?p.length-1:e-1],u=p[e===p.length-1?0:e+1],d=i[e],h=t.rings[m][e],y=d[2]>h[2],_=new T(s,r,u,y);o.push(_),_.updateOccluded(g);const f=_.isOccluded;y?(f?n:l).push(s):(f?c:a).push(s)}}this._projectionLines=o,this._cutProjectionLines.setGeometryFromSegments(l),this._occludedCutProjectionLines.setGeometryFromSegments(n),this._fillProjectionLines.setGeometryFromSegments(a),this._occludedFillProjectionLines.setGeometryFromSegments(c)}_updateProjectionLineOcclusion(e){const t=[],i=[],s=[],o=[];let l=!1,r=!1;for(const n of this._projectionLines){n.updateOccluded(e)&&(l||=n.isCut,r||=!n.isCut);const a=n.isOccluded;(n.isCut?a?i:t:a?o:s).push(n.segment)}r&&(this._fillProjectionLines.setGeometryFromSegments(s),this._occludedFillProjectionLines.setGeometryFromSegments(o)),l&&(this._cutProjectionLines.setGeometryFromSegments(t),this._occludedCutProjectionLines.setGeometryFromSegments(i))}_updateColors(e,t,i){const{geometryOutlineColor:s,cutColor:l,fillColor:r,cutColorMuted:n,fillColorMuted:a,cutProjectionLineColor:c,fillProjectionLineColor:u}=o;if(this._cutFillVisualization.cutColor=i?l:n,this._cutFillVisualization.fillColor=i?r:a,e){const e=t.toUnitRGBA();this._targetGeometry.color=e,this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e,this._fillProjectionLines.color=e,this._occludedFillProjectionLines.color=e,this._cutFillVisualization.borderColor=t}else{this._targetGeometry.color=s.toUnitRGBA();const e=(i?c:n).toUnitRGBA();this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e;const t=(i?u:a).toUnitRGBA();this._fillProjectionLines.color=t,this._occludedFillProjectionLines.color=t,this._cutFillVisualization.borderColor=s}}_updateLabels(e){const{effectiveDisplayUnits:t,depthExtremaPositions:s,messages:o,unitsMessages:l,result:r,visible:n}=e;if(this._cutVolumeLabel.visible=n,this._fillVolumeLabel.visible=n,this._cutVolumeLabel.geometry=s?{type:"point",point:s.cut}:null,this._fillVolumeLabel.geometry=s?{type:"point",point:s.fill}:null,null==r||null==o||null==l)return this._cutVolumeLabel.text="-",void(this._fillVolumeLabel.text="-");const a=t.volume,c=i(o.labels.cut,{volume:I(l,r.cutVolume,a)}),u=i(o.labels.fill,{volume:I(l,r.fillVolume,a)});this._cutVolumeLabel.text=c,this._fillVolumeLabel.text=u}_updateCutFillVisibility(e){e?this._cutFillVisualization.enable():this._cutFillVisualization.disable()}get _polygonRenderInfo(){const{renderCoordsHelper:e,elevationProvider:t}=this.view,{targetGeometry:i}=this.analysisViewData;if(null==i)return null;const s=E(i,t,e,this._elevationContext,{outlineOutput:"tessellated-indices"});return c(s)?(this._updatingHandles.consumePromise(s),null):s}_updateCutFillGeometry(){const{renderCoordsHelper:e}=this.view,{targetGeometry:t}=this.analysisViewData,{cut:i,fill:s}=this._extrusionHeights;if(!t?.extent)return;const{center:o}=t.extent,l=V(o.x,o.y,0),r=C();e.toRenderCoords(l,t.spatialReference,r);const n=this._getExtrudedVolume(i,l,r),a=this._getExtrudedVolume(s,l,r);null!=n&&null!=a&&this._cutFillVisualization.updateGeometries(n,a,r)}_getExtrudedVolume(e,t,i){const{renderCoordsHelper:s,spatialReference:o}=this.view,l=C(),r=1===s.viewingMode;s.worldUpAtPosition(i,l);const{_polygonRenderInfo:n}=this;if(null==n)return null;const a=U(n,{height:e,worldUp:l,spherical:r,requireElevation:!1,requireNormals:!0,requireSizes:!1});if(null==a)return null;const c=_(),u=_();if(G(o,t,c,s.spatialReference),u[12]=-c[12],u[13]=-c[13],u[14]=-c[14],F(a.vertices,a.vertices,u),"stockpile"===this.analysis.measureType)for(let m=0;m<a.normals.length;m+=3)a.normals[m]=l[0],a.normals[m+1]=l[1],a.normals[m+2]=l[2];return new z(a.vertices,a.bottomIndices,a.indices,a.normals)}async _updateMessageBundle(){this.loadingMessages=!0;try{this.unitsMessages=await s("esri/core/t9n/Units"),this.messages=await s("esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis")}finally{this.loadingMessages=!1}}};function I(e,t,i){if(!t||!e)return null;const s=p(t.value,t.unit,i),o=u(s);return m(e,t,s,o)}e([g({constructOnly:!0})],B.prototype,"view",void 0),e([g({constructOnly:!0})],B.prototype,"analysis",void 0),e([g({constructOnly:!0})],B.prototype,"analysisViewData",void 0),e([g()],B.prototype,"unitsMessages",void 0),e([g()],B.prototype,"messages",void 0),e([g()],B.prototype,"loadingMessages",void 0),e([g({readOnly:!0})],B.prototype,"_updatingHandles",void 0),e([g({readOnly:!0})],B.prototype,"visible",null),e([g()],B.prototype,"updating",null),e([g()],B.prototype,"hasUnsupportedError",null),e([g()],B.prototype,"_extrusionHeights",null),e([g()],B.prototype,"_polygonRenderInfo",null),B=e([y("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillVisualization")],B);class T{constructor(e,t,i,s){this.segment=e,this.previous=t,this.next=i,this.isCut=s,this._isOccluded=!1,this._n1=C(),this._n2=C();const o=v(q,j(q,e.endRenderSpace,e.startRenderSpace));v(this._n1,L(this._n1,o,v(k,j(k,t.startRenderSpace,e.startRenderSpace)))),v(this._n2,L(this._n2,o,v(k,j(k,e.startRenderSpace,i.startRenderSpace)))),this._isConvex=n.normalize(P(this._n1,this._n2,o))<0}get isOccluded(){return this._isOccluded}updateOccluded(e){j(q,this.segment.startRenderSpace,e.eye);const t=b(this._n1,q)<0,i=b(this._n2,q)<0,s=this._isOccluded;return this._isOccluded=this._isConvex?t&&i:t||i,this._isOccluded!==s}}const q=C(),k=C();export{B as VolumeMeasurementCutFillVisualization};
|
|
2
|
+
import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as i,fetchMessageBundle as s}from"../../../../intl.js";import{volumeMeasurementConfiguration as o}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import l from"../../../../core/Accessor.js";import{equals as n}from"../../../../core/arrayUtils.js";import{cyclicalPI as r}from"../../../../core/Cyclical.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import{isPromiseLike as c}from"../../../../core/promiseUtils.js";import{preferredVolumePrecision as u,formatDecimal as m}from"../../../../core/quantityFormatUtils.js";import{watch as d,initial as h}from"../../../../core/reactiveUtils.js";import{adaptiveVolumeUnit as p}from"../../../../core/units.js";import{property as g,subclass as y}from"../../../../core/accessorSupport/decorators.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f,normalize as v,subtract as j,cross as V,dot as b}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as L,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as C}from"../../../../core/support/UpdatingHandles.js";import{computeTranslationToOriginAndRotation as G}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{angleAroundAxis as P}from"../../../../geometry/support/vector.js";import{a as F}from"../../../../chunks/vec3.js";import x from"../../../../symbols/support/ElevationInfo.js";import{LabelVisualElement as O}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as R}from"../../interactive/visualElements/LineVisualElement.js";import{OutlineVisualElement as D}from"../../interactive/visualElements/OutlineVisualElement.js";import{EuclideanSegment as M}from"../../interactive/visualElements/support/Segment.js";import{ElevationContext as A}from"../../layers/graphics/ElevationContext.js";import{extrudePolygon as U}from"../../layers/graphics/extrudeUtils.js";import{polygonToRenderInfoElevationAligned as E}from"../../support/renderInfoUtils/polygon.js";import{CutFillVisualization as S,VolumeGeometry as z}from"../../webgl-engine/lib/CutFillVisualization.js";import{createStipplePatternSimple as H}from"../../webgl-engine/materials/lineStippleUtils.js";let B=class extends l{get visible(){return this.analysisViewData.visible&&null!=this.analysisViewData.elevationAlignedGeometry&&null!=this.analysisViewData.targetGeometry}get inView(){return this.analysisViewData.analysisObb?.intersectsFrustum(this.view.frustum)??!1}get updating(){return this.loadingMessages||this._updatingHandles.updating}get hasUnsupportedError(){const{error:e}=this.analysisViewData;return!!e&&["unsupported-coordinate-system","unsupported-layer-transparency"].includes(e.name)}get _extrusionHeights(){const{renderCoordsHelper:e}=this.view,{depthExtremaPositions:t,targetGeometry:i}=this.analysisViewData,{targetElevationRange:s}=o;if(!i||!t)return{cut:s,fill:-s};let l=-1/0;for(const o of i.rings)for(const e of o)l=Math.max(l,e[2]);const n=1,r=e.getAltitude(t.fill);return{cut:s,fill:Math.min(r-l,0)-n}}constructor(e){super(e),this.unitsMessages=null,this.messages=null,this.loadingMessages=!0,this._updatingHandles=new C,this._elevationContext=A.fromElevationInfo(new x({mode:"absolute-height"})),this._projectionLines=[]}initialize(){const{view:e}=this,i={view:e,isDecoration:!0},s=o,l={...i,width:s.geometryOutlineWidth};this._elevationAlignedGeometry=new D({...l,isDraped:!0,color:s.geometryOutlineColor.toUnitRGBA()}),this._targetGeometry=new D(l);const n={...i,attached:!0,width:s.projectionLineWidth,renderOccluded:4,polygonOffset:3},r={...n,stipplePattern:H(s.projectionLineStippleSize)},a=s.cutProjectionLineColor.toUnitRGBA(),c=s.fillProjectionLineColor.toUnitRGBA();this._cutProjectionLines=new R({...n,color:a}),this._occludedCutProjectionLines=new R({...r,color:a}),this._fillProjectionLines=new R({...n,color:c,renderOccluded:8}),this._occludedFillProjectionLines=new R({...r,color:c});const u={...i,attached:!0};this._cutVolumeLabel=new O({...u,distance:s.labelDistance}),this._fillVolumeLabel=new O({...u,distance:-s.labelDistance}),this._cutFillVisualization=new S({view:e,cutColor:s.cutColor,fillColor:s.fillColor,borderColor:s.geometryOutlineColor}),this.addHandles([d(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry}),({elevationAlignedGeometry:e,targetGeometry:t})=>{this._elevationAlignedGeometry.geometry=e,this._targetGeometry.geometry=t},h),d(()=>({interactive:this.analysisViewData.interactive,measureType:this.analysis.measureType,visible:this.visible}),({visible:e,interactive:t,measureType:i})=>{this._elevationAlignedGeometry.visible=e&&!t,this._targetGeometry.visible=e&&"cut-fill"===i,this._cutFillVisualization.measureType=i},h),d(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry,visible:this.visible}),({elevationAlignedGeometry:e,targetGeometry:t,visible:i})=>this._updateProjectionLines(e,t,i),h),d(()=>({interactive:this.analysisViewData.interactive,accentColor:this.view.effectiveTheme.accentColor,hasResult:!!this.analysisViewData.result}),({interactive:e,accentColor:t,hasResult:i})=>{this._updateColors(e,t,i)},h),d(()=>[this.analysisViewData.targetGeometry,this.inView,this._extrusionHeights,this._polygonRenderInfo],()=>this._updateCutFillGeometry(),h),d(()=>this.visible&&this.inView&&this.view.state.camera.aboveGround&&!this.hasUnsupportedError,e=>this._updateCutFillVisibility(e),h),d(()=>{const{messages:e,unitsMessages:t,visible:i,analysisViewData:s}=this;return{depthExtremaPositions:s.depthExtremaPositions,effectiveDisplayUnits:s.effectiveDisplayUnits,messages:e,unitsMessages:t,result:s.result,visible:i&&!!s.result}},e=>this._updateLabels(e)),d(()=>this.view.state.camera,e=>this._updateProjectionLineOcclusion(e),h),t(()=>this._updateMessageBundle())]),this._updateMessageBundle()}destroy(){this._elevationAlignedGeometry=a(this._elevationAlignedGeometry),this._targetGeometry=a(this._targetGeometry),this._cutProjectionLines=a(this._cutProjectionLines),this._occludedCutProjectionLines=a(this._occludedCutProjectionLines),this._fillProjectionLines=a(this._fillProjectionLines),this._occludedFillProjectionLines=a(this._occludedFillProjectionLines),this._cutVolumeLabel=a(this._cutVolumeLabel),this._fillVolumeLabel=a(this._fillVolumeLabel),this._cutFillVisualization.destroy(),this._updatingHandles.destroy()}_updateProjectionLines(e,t,i){if(this._cutProjectionLines.visible=i,this._occludedCutProjectionLines.visible=i,this._fillProjectionLines.visible=i,this._occludedFillProjectionLines.visible=i,!e||!t)return;const{renderCoordsHelper:s}=this.view,o=[],l=[],r=[],a=[],c=[],u=e.spatialReference;for(let m=0;m<e.rings.length;m++){const i=e.rings[m],d=i.length>1&&n(i[0],i[i.length-1]),h=i.length-(d?1:0),p=[];for(let e=0;e<h;++e){const o=i[e],l=f(L(),o[0],o[1],o[2]);s.toRenderCoords(l,u,l);const n=t.rings[m][e],r=f(L(),n[0],n[1],n[2]);s.toRenderCoords(r,u,r);const a=new M(l,r);p.push(a)}const g=this.view.state.camera;for(let e=0;e<p.length;++e){const s=p[e],n=p[0===e?p.length-1:e-1],u=p[e===p.length-1?0:e+1],d=i[e],h=t.rings[m][e],y=d[2]>h[2],_=new T(s,n,u,y);o.push(_),_.updateOccluded(g);const f=_.isOccluded;y?(f?r:l).push(s):(f?c:a).push(s)}}this._projectionLines=o,this._cutProjectionLines.setGeometryFromSegments(l),this._occludedCutProjectionLines.setGeometryFromSegments(r),this._fillProjectionLines.setGeometryFromSegments(a),this._occludedFillProjectionLines.setGeometryFromSegments(c)}_updateProjectionLineOcclusion(e){const t=[],i=[],s=[],o=[];let l=!1,n=!1;for(const r of this._projectionLines){r.updateOccluded(e)&&(l||=r.isCut,n||=!r.isCut);const a=r.isOccluded;(r.isCut?a?i:t:a?o:s).push(r.segment)}n&&(this._fillProjectionLines.setGeometryFromSegments(s),this._occludedFillProjectionLines.setGeometryFromSegments(o)),l&&(this._cutProjectionLines.setGeometryFromSegments(t),this._occludedCutProjectionLines.setGeometryFromSegments(i))}_updateColors(e,t,i){const{geometryOutlineColor:s,cutColor:l,fillColor:n,cutColorMuted:r,fillColorMuted:a,cutProjectionLineColor:c,fillProjectionLineColor:u}=o;if(this._cutFillVisualization.cutColor=i?l:r,this._cutFillVisualization.fillColor=i?n:a,e){const e=t.toUnitRGBA();this._targetGeometry.color=e,this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e,this._fillProjectionLines.color=e,this._occludedFillProjectionLines.color=e,this._cutFillVisualization.borderColor=t}else{this._targetGeometry.color=s.toUnitRGBA();const e=(i?c:r).toUnitRGBA();this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e;const t=(i?u:a).toUnitRGBA();this._fillProjectionLines.color=t,this._occludedFillProjectionLines.color=t,this._cutFillVisualization.borderColor=s}}_updateLabels(e){const{effectiveDisplayUnits:t,depthExtremaPositions:s,messages:o,unitsMessages:l,result:n,visible:r}=e;if(this._cutVolumeLabel.visible=r,this._fillVolumeLabel.visible=r,this._cutVolumeLabel.geometry=s?{type:"point",point:s.cut}:null,this._fillVolumeLabel.geometry=s?{type:"point",point:s.fill}:null,null==n||null==o||null==l)return this._cutVolumeLabel.text="-",void(this._fillVolumeLabel.text="-");const a=t.volume,c=i(o.labels.cut,{volume:I(l,n.cutVolume,a)}),u=i(o.labels.fill,{volume:I(l,n.fillVolume,a)});this._cutVolumeLabel.text=c,this._fillVolumeLabel.text=u}_updateCutFillVisibility(e){e?this._cutFillVisualization.enable():this._cutFillVisualization.disable()}get _polygonRenderInfo(){const{renderCoordsHelper:e,elevationProvider:t}=this.view,{targetGeometry:i}=this.analysisViewData;if(null==i)return null;const s=E(i,t,e,this._elevationContext,{outlineOutput:"tessellated-indices"});return c(s)?(this._updatingHandles.consumePromise(s),null):s}_updateCutFillGeometry(){const{view:e,analysisViewData:t,inView:i}=this,{renderCoordsHelper:s}=e,{targetGeometry:o}=t,{cut:l,fill:n}=this._extrusionHeights;if(!o?.extent||!i)return;const{center:r}=o.extent,a=w(r.x,r.y,0),c=L();s.toRenderCoords(a,o.spatialReference,c);const u=this._getExtrudedVolume(l,a,c),m=this._getExtrudedVolume(n,a,c);null!=u&&null!=m&&this._cutFillVisualization.updateGeometries(u,m,c)}_getExtrudedVolume(e,t,i){const{renderCoordsHelper:s,spatialReference:o}=this.view,l=L(),n=1===s.viewingMode;s.worldUpAtPosition(i,l);const{_polygonRenderInfo:r}=this;if(null==r)return null;const a=U(r,{height:e,worldUp:l,spherical:n,requireElevation:!1,requireNormals:!0,requireSizes:!1});if(null==a)return null;const c=_(),u=_();if(G(o,t,c,s.spatialReference),u[12]=-c[12],u[13]=-c[13],u[14]=-c[14],F(a.vertices,a.vertices,u),"stockpile"===this.analysis.measureType)for(let m=0;m<a.normals.length;m+=3)a.normals[m]=l[0],a.normals[m+1]=l[1],a.normals[m+2]=l[2];return new z(a.vertices,a.bottomIndices,a.indices,a.normals)}async _updateMessageBundle(){this.loadingMessages=!0;try{this.unitsMessages=await s("esri/core/t9n/Units"),this.messages=await s("esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis")}finally{this.loadingMessages=!1}}};function I(e,t,i){if(!t||!e)return null;const s=p(t.value,t.unit,i),o=u(s);return m(e,t,s,o)}e([g({constructOnly:!0})],B.prototype,"view",void 0),e([g({constructOnly:!0})],B.prototype,"analysis",void 0),e([g({constructOnly:!0})],B.prototype,"analysisViewData",void 0),e([g()],B.prototype,"unitsMessages",void 0),e([g()],B.prototype,"messages",void 0),e([g()],B.prototype,"loadingMessages",void 0),e([g({readOnly:!0})],B.prototype,"_updatingHandles",void 0),e([g({readOnly:!0})],B.prototype,"visible",null),e([g()],B.prototype,"inView",null),e([g()],B.prototype,"updating",null),e([g()],B.prototype,"hasUnsupportedError",null),e([g()],B.prototype,"_extrusionHeights",null),e([g()],B.prototype,"_polygonRenderInfo",null),B=e([y("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillVisualization")],B);class T{constructor(e,t,i,s){this.segment=e,this.previous=t,this.next=i,this.isCut=s,this._isOccluded=!1,this._n1=L(),this._n2=L();const o=v(q,j(q,e.endRenderSpace,e.startRenderSpace));v(this._n1,V(this._n1,o,v(k,j(k,t.startRenderSpace,e.startRenderSpace)))),v(this._n2,V(this._n2,o,v(k,j(k,e.startRenderSpace,i.startRenderSpace)))),this._isConvex=r.normalize(P(this._n1,this._n2,o))<0}get isOccluded(){return this._isOccluded}updateOccluded(e){j(q,this.segment.startRenderSpace,e.eye);const t=b(this._n1,q)<0,i=b(this._n2,q)<0,s=this._isOccluded;return this._isOccluded=this._isConvex?t&&i:t||i,this._isOccluded!==s}}const q=L(),k=L();export{B as VolumeMeasurementCutFillVisualization};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import"../../../core/has.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{verticalLengthUnitFromSpatialReference as i,convertUnit as s}from"../../../core/units.js";import{property as l,subclass as r}from"../../../core/accessorSupport/decorators.js";import{getDefaultUnitForView as
|
|
2
|
+
import{__decorate as e}from"tslib";import"../../../core/has.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{verticalLengthUnitFromSpatialReference as i,convertUnit as s}from"../../../core/units.js";import{property as l,subclass as r}from"../../../core/accessorSupport/decorators.js";import{getDefaultUnitForView as a}from"../../../support/getDefaultUnitForView.js";import n from"./AnalysisView3D.js";import{VolumeMeasurementCutFillController as o}from"./VolumeMeasurement/VolumeMeasurementCutFillController.js";import{VolumeMeasurementCutFillVisualization as u}from"./VolumeMeasurement/VolumeMeasurementCutFillVisualization.js";import y from"./VolumeMeasurement/VolumeMeasurementTool.js";let p=class extends n{constructor(e){super(e),this.type="volume-measurement-view-3d",this.analysis=null}initialize(){const{analysis:e,view:t}=this;this._analysisController=new o({view:t,analysis:e,analysisViewData:this}),this._analysisTool=new y({analysis:e,view:t,analysisViewData:this}),this._analysisVisualization=new u({view:t,analysis:e,analysisViewData:this})}destroy(){this._analysisController=t(this._analysisController),this._analysisVisualization=t(this._analysisVisualization),this._analysisTool.destroy()}get error(){return this._analysisController?.error??null}get result(){return this._analysisController?.result}get interactive(){return super.interactive}set interactive(e){super.interactive=e}get visible(){return super.visible}set visible(e){super.visible=e}get elevationAlignedGeometry(){return this._analysisController?.elevationAlignedGeometry}get effectiveTargetElevation(){const{cutFillOptions:e,inputUnits:t}=this.analysis,{targetElevation:l}=e,r=t?.elevation??"meters",a=i(this.view.spatialReference);if(null!=l&&null!=a)return s(l,r,a);const n=this.elevationAlignedGeometry?.extent;return null==n?.zmin||null==n?.zmax?null:(n.zmax+n.zmin)/2}get targetGeometry(){return this._analysisController?.targetGeometry}get effectiveDisplayUnits(){const{displayUnits:e}=this.analysis,t=a(this.view);return{elevation:e.elevation??t,volume:e.volume??t,area:e.area??t,length:e.length??t}}get depthExtremaPositions(){return this._analysisController?.depthExtremaPositions}get analysisObb(){return this._analysisController?.analysisObb}get updating(){return this._analysisController?.updating||this._analysisTool?.updating||this._analysisVisualization?.updating}place(e){return this._analysisTool.place(e)}get test(){}};e([l()],p.prototype,"error",null),e([l({readOnly:!0})],p.prototype,"type",void 0),e([l({constructOnly:!0,nonNullable:!0})],p.prototype,"analysis",void 0),e([l({readOnly:!0})],p.prototype,"result",null),e([l()],p.prototype,"elevationAlignedGeometry",null),e([l({type:Number})],p.prototype,"effectiveTargetElevation",null),e([l()],p.prototype,"targetGeometry",null),e([l()],p.prototype,"effectiveDisplayUnits",null),e([l()],p.prototype,"depthExtremaPositions",null),e([l()],p.prototype,"analysisObb",null),e([l()],p.prototype,"updating",null),e([l()],p.prototype,"_analysisController",void 0),p=e([r("esri.views.3d.analysis.VolumeMeasurementAnalysisView3D")],p);const m=p;export{m as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{clone as e}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as t}from"../../../../core/units.js";import{normalFromMat4 as r}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as s,invertOrIdentity as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as a,sub as l,cross as c,add as m,normalize as p,transformMat4 as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ONES as u,create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as g,ZEROS as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as f}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as b,fromBuffer as x,intersectsClippingArea as _}from"../../../../geometry/support/aaBoundingBox.js";import{getZeroIndexArray as C}from"../../../../geometry/support/Indices.js";import{a as w}from"../../../../chunks/vec3.js";import{SnappingCandidateVertex as v,SnappingCandidateEdge as S}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as j}from"../../../../renderers/support/renderingInfoUtils.js";import{needsElevationUpdates3D as I,SampleElevationInfo as P}from"./elevationAlignmentUtils.js";import{extrudePolygon as E}from"./extrudeUtils.js";import{Object3DEdgeState as A,Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as z}from"./Graphics3DSymbolLayer.js";import{computeCentroid as O}from"./graphicUtils.js";import{geometryAsPolygon as D}from"./polygonUtils.js";import{createMaterial as M}from"../support/edgeUtils.js";import{encodeNaNUInt8 as G}from"../support/symbolColorUtils.js";import{debugFlags as L}from"../../support/debugFlags.js";import{SamplePosition as V}from"../../support/ElevationProvider.js";import{loadTessellationUtils as R,preloadedPolygonToRenderInfoElevationAligned as B}from"../../support/renderInfoUtils/polygon.js";import{Attribute as F}from"../../webgl-engine/lib/Attribute.js";import{Geometry as T}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as N}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as H,compressNormal as q}from"../../webgl-engine/lib/Normals.js";import{Object3D as W}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as k}from"../../webgl-engine/materials/DefaultMaterial.js";const Z=["polygon","extent"];class J extends z{constructor(e,t,r,i){super(e,t,r,i,ee(t)),this.ensureDrapedStatus(!1)}async doLoad(){const e=this.symbolLayer,t=e?.material,r=this.symbolLayer.material?.color?.a,i=this._hasDrivenColorOrOpacity,s=this.needsDrivenTransparentPass||i&&null!=r&&r<1,n=t?.emissive,o=("color"===n?.source?n?.strength:void 0)??0,a=!i&&(null==r||0===r),l=i?g:this._materialColor?.toUnitRGBA()??y,c={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,useIndexing:!0,ambient:u,diffuse:u,externalColor:l,opacity:a?0:1,layerOpacity:this._getLayerOpacity(),drivenOpacity:s,hasSymbolColors:i,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:e.castShadows,emissiveStrengthFromSymbol:o,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1},m=new k(c,this._context),p=new k({...c,cullFace:2},this._context);this._materials[0]=m,this._materials[1]=p,this._updateTransparentDepedentMaterialParameters(),await R()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Z,this.symbolLayer.type))return null;const r=this._getDrivenUInt8ColorWithNaNSupport(e.renderingInfo,this._materialColor,!1);G(r,r);const i=this.createElevationContextForGraphic(t);return this._createAs3DShape(t,e.renderingInfo,r,i,t.uid)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:r}),this._materials[1]?.setParameters({layerOpacity:r}),this._updateTransparentDepedentMaterialParameters(),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,I)}slicePlaneEnabledChanged(e,t){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.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={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(e),this._materials[1]?.setParameters(e),!0}_getExtrusionSize(e){let t;return t=e.size&&this._drivenProperties.size?j(e.size.output,2)??0:this._getSymbolSize(),t/=this._context.renderCoordsHelper.unitInMeters,t}_containsRenderableGeometry(e){return"polygonIndexCount"in e&&"outlineIndexCount"in e?e.polygonIndexCount>0||e.outlineIndexCount>0:super._containsRenderableGeometry(e)}applyRendererDiff(e,t){return this._drivenPropertiesChanged(t)?0:1}async queryForSnapping(r,i,s,n){const o=this._getExtrusionSize(s)*this._context.renderCoordsHelper.unitInMeters/t(i),{objectId:a,target:l}=r,c=e(l);switch(c.z=(c.z??0)+o,r.type){case"edge":{const{start:t,end:i}=r,s=e(t),n=e(i);return s.z=(s.z??0)+o,n.z=(n.z??0)+o,[new S(a,c,1/0,s,n)]}case"vertex":return[new v(a,c,1/0),new S(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(e,t,n,a,l){const c=D(e.geometry);if(null==c)return null;if(0===c.rings.length||!c.rings.some(e=>e.length>0))return this._logGeometryValidationWarnings(c.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=B(c,this._context.elevationProvider,this._context.renderCoordsHelper,a,{outlineOutput:"tessellated-indices",owner:this._context.layer});if(null==m)return;this._logGeometryCreationWarnings(m,c.rings,"rings","ExtrudeSymbol3DLayer");const p=O(c);if(null==p)return null;const h=new Array,u=new Array,g=b(),y=o(),C=d(),v=1===this._context.renderCoordsHelper.viewingMode;v||this._context.renderCoordsHelper.worldUpAtPosition(null,C),f(c.spatialReference,[p.x,p.y,0],y,this._context.renderCoordsHelper.spatialReference);const S=o();s(S,y);const j=i();r(j,S);const P=new Map,z=this._materials[0];if(this._context.clippingExtent&&(x(m.mapPositions,g),!_(g,this._context.clippingExtent)))return;if(0===m.polygonIndexCount&&0===m.outlineIndexCount)return;const G=this._getExtrusionSize(t),L=E(m,{height:G,worldUp:C,spherical:v,requireElevation:!0,requireNormals:!0,requireSizes:!0});if(null==L)return;w(L.vertices,L.vertices,S);const V=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:l,layerViewUid:this._context.layerViewUid}),R=new le(L.vertices,L.elevation,H(L.normals),L.sizes),F=K(z,L.indices,L.indices.length-L.bottomIndices.length,R,n,V),T=m.vertexCount,N=L.polygonVertexCount,q=2*m.outlineSegmentCount,k=m.polygonIndexCount/3,Z=new ce(T,N,q,k);if($(F,Z,y),P.set(F,Z),h.push(F),L.bottomIndices.length>0&&h.push(K(this._materials[1],L.bottomIndices,0,R,n,V)),u.push(R.heights),0===h.length)return null;const J=new W({geometries:h,layerViewUid:this._context.layerViewUid,graphicUid:l,isElevationSource:!0});J.transformation=y;const Q=M(this.symbolLayer,{opacity:this._getLayerOpacity()}),X=Q?new A(this._materials[0],Q,this._context.slicePlaneEnabled):null,ee=new U(this,J,null,(e,t,r,i,s)=>Y(e,t,r,i,s,u,P),a,X);return ee.alignedSampledElevation=m.sampledElevation,ee.needsElevationUpdates=I(a.mode),ee}get _materialColor(){return this.symbolLayer.material?.color}_updateTransparentDepedentMaterialParameters(){const e=this._materials[0];e&&e.setParameters({cullFace:e.transparent?0:2})}}function K(e,t,r,i,s,n){const{attributeIndices:o,drawIndices:a}=Q(t),l=[["position",new F(i.positions,o,3,!0)],["normalCompressed",new F(i.normals,o,2,!0)]];if(e.parameters.hasSymbolColors){const e=C(o.length);l.push(["symbolColor",new F(s,e,4,!0)])}return new T(e,l,i.elevation,0,n,r,null,a)}function Q(e){const t=new Array,r=new Map,i=new Array;for(let s=0;s<e.length;++s){const n=e[s];let o=r.get(n);null==o&&(o=t.length,t.push(n),r.set(n,o)),i.push(o)}return{attributeIndices:t,drawIndices:i}}const X=d();function Y(e,t,r,i,s,l,c){const m=e.stageObject,p=m.geometries,u=p.length,d="absolute-height"!==t.mode;let g=0;const y=m.transformation,f=n(o(),y);for(let n=0,o=0;n<u;++n){const e=p[n],t=c.get(e);if(!t||!N(e))continue;const u=e.getMutableAttribute("position").data,b=l[o++],x=new V(e.mapPositions),_=u.length/3;let C=!1,w=0;{let e=0;for(let t=0;t<_;t++){X[0]=u[e],X[1]=u[e+1],X[2]=u[e+2],i(x,ie),d&&(w+=ie.sampledElevation),L.ENABLE_OPTIMIZATIONS?(a(te,u[e],u[e+1],u[e+2]),h(te,te,y),s.setAltitude(te,ie.z+b[e/3]),h(te,te,f)):(a(te,x.array[x.offset],x.array[x.offset+1],ie.z+b[e/3]),null!=r&&s.toRenderCoords(te,r,te),h(te,te,f)),u[e]=te[0],u[e+1]=te[1],u[e+2]=te[2];const t=se/s.unitInMeters;(Math.abs(X[0]-u[e])>=t||Math.abs(X[1]-u[e+1])>=t||Math.abs(X[2]-u[e+2])>=t)&&(C=!0),x.offset+=3,e+=3}}if(C){$(e,t,y),m.geometryVertexAttributeUpdated(p[n],"normalCompressed"),e.invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(p[n],"position");const r=p[n+1],i=!c.has(r);r&&i&&(r.invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(r,"position"))}g+=w/_}return g/u}function $(e,t,r){const i=e.getMutableAttribute("position"),s=e.getMutableAttribute("normalCompressed").data,n=i.data,o=e.primitivePositionIndices,{topVertexStart:u,topVertexCount:d,topFaceStart:g,topFaceCount:y}=t,f=g+y,b=u+d,x=ne,_=oe,C=ae,w=re,v=te;a(v,0,0,0);const S=(e,t)=>{const i=3*e;a(t,n[i+0],n[i+1],n[i+2]),h(t,t,r)};for(let a=g;a<f;++a){const e=3*a;S(o[e+0],x[0]),S(o[e+1],x[1]),S(o[e+2],x[2]),l(_,x[1],x[0]),l(C,x[2],x[0]),c(w,_,C),m(v,v,w)}p(v,v);for(let a=u;a<b;++a){const e=v[0],t=v[1],r=v[2];q(s,a,e,t,r)}}function ee(e){return 1===(e.material?.color?.a??0)}const te=d(),re=d(),ie=new P,se=.01,ne=[d(),d(),d()],oe=d(),ae=d();class le{constructor(e,t,r,i){this.positions=e,this.elevation=t,this.normals=r,this.heights=i}}class ce{constructor(e,t,r,i){this.topVertexStart=e,this.topVertexCount=t,this.topFaceStart=r,this.topFaceCount=i}}export{J as Graphics3DExtrudeSymbolLayer};
|
|
2
|
+
import{clone as e}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as t}from"../../../../core/units.js";import{normalFromMat4 as r}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as i,invertOrIdentity as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as a,sub as l,cross as c,add as m,normalize as p,transformMat4 as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ONES as u,create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as g,ZEROS as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as f}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as b,fromBuffer as x,intersectsClippingArea as _}from"../../../../geometry/support/aaBoundingBox.js";import{getZeroIndexArray as C}from"../../../../geometry/support/Indices.js";import{a as v}from"../../../../chunks/vec3.js";import{SnappingCandidateVertex as w,SnappingCandidateEdge as S}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as j}from"../../../../renderers/support/renderingInfoUtils.js";import{isDrivenOpacityFallbackAlwaysOpaque as I}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{needsElevationUpdates3D as P,SampleElevationInfo as E}from"./elevationAlignmentUtils.js";import{extrudePolygon as A}from"./extrudeUtils.js";import{Object3DEdgeState as U,Graphics3DObject3DGraphicLayer as z}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as O}from"./Graphics3DSymbolLayer.js";import{computeCentroid as D}from"./graphicUtils.js";import{geometryAsPolygon as M}from"./polygonUtils.js";import{createMaterial as G}from"../support/edgeUtils.js";import{encodeNaNUInt8 as L}from"../support/symbolColorUtils.js";import{debugFlags as V}from"../../support/debugFlags.js";import{SamplePosition as R}from"../../support/ElevationProvider.js";import{loadTessellationUtils as B,preloadedPolygonToRenderInfoElevationAligned as F}from"../../support/renderInfoUtils/polygon.js";import{Attribute as T}from"../../webgl-engine/lib/Attribute.js";import{Geometry as N}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as H}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as q,compressNormal as W}from"../../webgl-engine/lib/Normals.js";import{Object3D as k}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Z}from"../../webgl-engine/materials/DefaultMaterial.js";const J=["polygon","extent"];class K extends O{constructor(e,t,r,s){super(e,t,r,s,I(t)),this.ensureDrapedStatus(!1)}async doLoad(){const e=this.symbolLayer,t=e?.material,r=this.symbolLayer.material?.color?.a,s=this._hasDrivenColorOrOpacity,i=this.needsDrivenTransparentPass||s&&null!=r&&r<1,o=t?.emissive,n=("color"===o?.source?o?.strength:void 0)??0,a=!s&&(null==r||0===r),l=s?g:this._materialColor?.toUnitRGBA()??y,c={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,useIndexing:!0,ambient:u,diffuse:u,externalColor:l,opacity:a?0:1,layerOpacity:this._getLayerOpacity(),drivenOpacity:i,hasSymbolColors:s,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:e.castShadows,emissiveStrengthFromSymbol:n,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1},m=new Z(c,this._context),p=new Z({...c,cullFace:2},this._context);this._materials[0]=m,this._materials[1]=p,this._updateTransparentDepedentMaterialParameters(),await B()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,J,this.symbolLayer.type))return null;const r=this._getDrivenUInt8ColorWithNaNSupport(e.renderingInfo,this._materialColor,!1);L(r,r);const s=this.createElevationContextForGraphic(t);return this._createAs3DShape(t,e.renderingInfo,r,s,t.uid)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:r}),this._materials[1]?.setParameters({layerOpacity:r}),this._updateTransparentDepedentMaterialParameters(),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,P)}slicePlaneEnabledChanged(e,t){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.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={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(e),this._materials[1]?.setParameters(e),!0}_getExtrusionSize(e){let t;return t=e.size&&this._drivenProperties.size?j(e.size.output,2)??0:this._getSymbolSize(),t/=this._context.renderCoordsHelper.unitInMeters,t}_containsRenderableGeometry(e){return"polygonIndexCount"in e&&"outlineIndexCount"in e?e.polygonIndexCount>0||e.outlineIndexCount>0:super._containsRenderableGeometry(e)}applyRendererDiff(e,t){return this._drivenPropertiesChanged(t)?0:1}async queryForSnapping(r,s,i,o){const n=this._getExtrusionSize(i)*this._context.renderCoordsHelper.unitInMeters/t(s),{objectId:a,target:l}=r,c=e(l);switch(c.z=(c.z??0)+n,r.type){case"edge":{const{start:t,end:s}=r,i=e(t),o=e(s);return i.z=(i.z??0)+n,o.z=(o.z??0)+n,[new S(a,c,1/0,i,o)]}case"vertex":return[new w(a,c,1/0),new S(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(e,t,o,a,l){const c=M(e.geometry);if(null==c)return null;if(0===c.rings.length||!c.rings.some(e=>e.length>0))return this._logGeometryValidationWarnings(c.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=F(c,this._context.elevationProvider,this._context.renderCoordsHelper,a,{outlineOutput:"tessellated-indices",owner:this._context.layer});if(null==m)return;this._logGeometryCreationWarnings(m,c.rings,"rings","ExtrudeSymbol3DLayer");const p=D(c);if(null==p)return null;const h=new Array,u=new Array,g=b(),y=n(),C=d(),w=1===this._context.renderCoordsHelper.viewingMode;w||this._context.renderCoordsHelper.worldUpAtPosition(null,C),f(c.spatialReference,[p.x,p.y,0],y,this._context.renderCoordsHelper.spatialReference);const S=n();i(S,y);const j=s();r(j,S);const I=new Map,E=this._materials[0];if(this._context.clippingExtent&&(x(m.mapPositions,g),!_(g,this._context.clippingExtent)))return;if(0===m.polygonIndexCount&&0===m.outlineIndexCount)return;const O=this._getExtrusionSize(t),L=A(m,{height:O,worldUp:C,spherical:w,requireElevation:!0,requireNormals:!0,requireSizes:!0});if(null==L)return;v(L.vertices,L.vertices,S);const V=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:l,layerViewUid:this._context.layerViewUid}),R=new le(L.vertices,L.elevation,q(L.normals),L.sizes),B=Q(E,L.indices,L.indices.length-L.bottomIndices.length,R,o,V),T=m.vertexCount,N=L.polygonVertexCount,H=2*m.outlineSegmentCount,W=m.polygonIndexCount/3,Z=new ce(T,N,H,W);if(ee(B,Z,y),I.set(B,Z),h.push(B),L.bottomIndices.length>0&&h.push(Q(this._materials[1],L.bottomIndices,0,R,o,V)),u.push(R.heights),0===h.length)return null;const J=new k({geometries:h,layerViewUid:this._context.layerViewUid,graphicUid:l,isElevationSource:!0});J.transformation=y;const K=G(this.symbolLayer,{opacity:this._getLayerOpacity()}),X=K?new U(this._materials[0],K,this._context.slicePlaneEnabled):null,Y=new z(this,J,null,(e,t,r,s,i)=>$(e,t,r,s,i,u,I),a,X);return Y.alignedSampledElevation=m.sampledElevation,Y.needsElevationUpdates=P(a.mode),Y}get _materialColor(){return this.symbolLayer.material?.color}_updateTransparentDepedentMaterialParameters(){const e=this._materials[0];e&&e.setParameters({cullFace:e.transparent?0:2})}}function Q(e,t,r,s,i,o){const{attributeIndices:n,drawIndices:a}=X(t),l=[["position",new T(s.positions,n,3,!0)],["normalCompressed",new T(s.normals,n,2,!0)]];if(e.parameters.hasSymbolColors){const e=C(n.length);l.push(["symbolColor",new T(i,e,4,!0)])}return new N(e,l,s.elevation,0,o,r,null,a)}function X(e){const t=new Array,r=new Map,s=new Array;for(let i=0;i<e.length;++i){const o=e[i];let n=r.get(o);null==n&&(n=t.length,t.push(o),r.set(o,n)),s.push(n)}return{attributeIndices:t,drawIndices:s}}const Y=d();function $(e,t,r,s,i,l,c){const m=e.stageObject,p=m.geometries,u=p.length,d="absolute-height"!==t.mode;let g=0;const y=m.transformation,f=o(n(),y);for(let o=0,n=0;o<u;++o){const e=p[o],t=c.get(e);if(!t||!H(e))continue;const u=e.getMutableAttribute("position").data,b=l[n++],x=new R(e.mapPositions),_=u.length/3;let C=!1,v=0;{let e=0;for(let t=0;t<_;t++){Y[0]=u[e],Y[1]=u[e+1],Y[2]=u[e+2],s(x,se),d&&(v+=se.sampledElevation),V.ENABLE_OPTIMIZATIONS?(a(te,u[e],u[e+1],u[e+2]),h(te,te,y),i.setAltitude(te,se.z+b[e/3]),h(te,te,f)):(a(te,x.array[x.offset],x.array[x.offset+1],se.z+b[e/3]),null!=r&&i.toRenderCoords(te,r,te),h(te,te,f)),u[e]=te[0],u[e+1]=te[1],u[e+2]=te[2];const t=ie/i.unitInMeters;(Math.abs(Y[0]-u[e])>=t||Math.abs(Y[1]-u[e+1])>=t||Math.abs(Y[2]-u[e+2])>=t)&&(C=!0),x.offset+=3,e+=3}}if(C){ee(e,t,y),m.geometryVertexAttributeUpdated(p[o],"normalCompressed"),e.invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(p[o],"position");const r=p[o+1],s=!c.has(r);r&&s&&(r.invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(r,"position"))}g+=v/_}return g/u}function ee(e,t,r){const s=e.getMutableAttribute("position"),i=e.getMutableAttribute("normalCompressed").data,o=s.data,n=e.primitivePositionIndices,{topVertexStart:u,topVertexCount:d,topFaceStart:g,topFaceCount:y}=t,f=g+y,b=u+d,x=oe,_=ne,C=ae,v=re,w=te;a(w,0,0,0);const S=(e,t)=>{const s=3*e;a(t,o[s+0],o[s+1],o[s+2]),h(t,t,r)};for(let a=g;a<f;++a){const e=3*a;S(n[e+0],x[0]),S(n[e+1],x[1]),S(n[e+2],x[2]),l(_,x[1],x[0]),l(C,x[2],x[0]),c(v,_,C),m(w,w,v)}p(w,w);for(let a=u;a<b;++a){const e=w[0],t=w[1],r=w[2];W(i,a,e,t,r)}}const te=d(),re=d(),se=new E,ie=.01,oe=[d(),d(),d()],ne=d(),ae=d();class le{constructor(e,t,r,s){this.positions=e,this.elevation=t,this.normals=r,this.heights=s}}class ce{constructor(e,t,r,s){this.topVertexStart=e,this.topVertexCount=t,this.topFaceStart=r,this.topFaceCount=s}}export{K as Graphics3DExtrudeSymbolLayer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{result as e,createTask as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import{clone as i}from"../../../../core/lang.js";import{abortMaybe as s,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as o,throwIfAborted as n}from"../../../../core/promiseUtils.js";import{pt2px as l,px2pt as c}from"../../../../core/screenUtils.js";import{numericHash as h}from"../../../../core/string.js";import{dataComponents as u}from"../../../../core/urlUtils.js";import{fromValues as m,fromArray as d,create as p,ONES as _}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{ZEROS as f,fromValues as y,create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as x,ZEROS as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as S}from"../../../../geometry/support/aaBoundingBox.js";import P from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as z}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as C}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as O}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultIconPrimitive as M}from"../../../../symbols/support/primitives.js";import R from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as I}from"../../../../symbols/support/utils.js";import{transparentUnit as j}from"./constants.js";import{perObjectElevationAligner as E}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as F,needsElevationUpdates2D as T}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as U}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as V}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as A}from"./placementUtils.js";import{placePointOnGeometry as L,updateStageObjectGeometry as H,getLocalOriginForPoint as k,extendPointGraphicElevationContext as B,createStageObject as N}from"./pointUtils.js";import{hasTransparencyModeSymbol as $}from"./transparencyUtils.js";import{initFastSymbolUpdatesState as q,updateFastSymbolUpdatesState as J,evaluateModelTransformScale as Z,ConvertOptions as W}from"../support/FastSymbolUpdates.js";import{createTexture as K,requiresHalfTexelOffset as Q,defaultBoundingBox as X,defaultSymbolSizeRatio as Y,defaultTexSize as ee}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as te}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as ie}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as se}from"../../webgl-engine/lib/ManagedTexture.js";import{RenderGeometry as ae}from"../../webgl-engine/lib/RenderGeometry.js";import{HUDMaterial as oe}from"../../webgl-engine/materials/HUDMaterial.js";var ne;const le=y(0,0,1),ce=16,he=1.5,ue=[ee*Y,ee*Y];class me extends D{static{ne=$}static{this.PRIMITIVE_SIZE=ue}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,xe(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=[1,1],this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0},this[ne]=!0}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=I(this.symbolLayer),i=_e(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=G(this._getIconSize());if(e)throw new r("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?l(e.size):ce);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let s=this._cimData;if(r&&s&&s.symbol||this.logger.error("Can't create texture, CIM data is undefined"),s.primitiveOverrides){s=i(s);const a=s.primitiveOverrides;r.evaluateOverrides(a,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(s.symbol,a)}const a=h(JSON.stringify(s));let o=this._cimSymbolTextures.get(a);if(o)return o;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(s.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?C(this._cimScaleFactorOrFunction,e):1;1!==c&&s.symbol&&O(s.symbol,c,!0);const u=w.getEnvelope(s,null,n.resourceManager);if(u?.width&&u.height){const e=u.x+u.width/2,t=u.y+u.height/2,r=n.rasterize({type:"cim",data:s},u.width,u.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),i=new R({x:-u.x/u.width-.5,y:(u.height+u.y)/u.height-.5});this._cimMaterialParametersInfo.anchorPosition=fe("relative",i),o=new se(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else o=new se(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(a,o),this._context.stage.addTexture(o),o}_prepareMaterialParameters(){const{symbolLayer:e,symbol:t,_context:r,_drivenProperties:i,view:s}=this,a=this.symbolLayer.occludedVisibility?.mode??"hidden";return{anchorPosition:fe(e.anchor,e.anchorPosition),rotation:e.angle,hasRotation:0!==e.angle||i.rotation,hasVertexRotation:i.rotation,occludedFragmentOpacity:"hidden"!==a?s.state.ensureOccludedFragmentOpacity():void 0,hasSlicePlane:r.slicePlaneEnabled,verticalOffset:de(t)?new re(t.verticalOffset):void 0,screenSizePerspective:r.screenSizePerspectiveEnabled?s.screenSizePerspective.parameters:void 0}}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(pe(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>K(t));this._textureHandle=r,e.textureId=r.managedTexture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=Q(t),e.distanceFieldBoundingBox=X;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/Y,e.size=m(i*this._symbolTextureRatio,i*this._symbolTextureRatio),this._createMaterials(e)}async _prepareResourcesHref(t,i,s){this._outlineSize=this._getOutlineSize(),t.color=this._getFillColor(),t.outlineColor=this._getOutlineColor(),t.outlineSize=this._outlineSize,t.textureIsSignedDistanceField=!1;const a=this._getIconSize(),n=a*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await e(this._context.sharedResources.textures.fromUrl(i,n,{signal:s}));if(!1===l.ok){o(l.error);throw new r("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${i})`)}this._textureHandle=l.value;const c=l.value.managedTexture;this._size=ye(c,a),t.size=d(this._size),t.textureId=c.id}this._createMaterials(t)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;n(r),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}const s=this._context.sharedResources.cimSymbolRasterizer,a=t,o=a?.symbol,l=[w.normalizeSymbolAndFetchResources(o,s.resourceManager,r)],c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&l.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),l.length>0&&(await Promise.all(l),n(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await z(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new P(c);this._cimScaleFactorOrFunction=(e,t,a)=>{const o=i(r,e,{$view:a},"esriGeometryPoint",s,t);return null!==o?o:1}}}n(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return ge(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(l(t.outline.size),0);return e=pe(this._getPrimitive())?he:0,Math.max(e,0)}_getOutlineColor(){const e=this._getLayerOpacity(),t=this.symbolLayer,r=t?.outline?.color;if(null!=r){const t=r.toUnitRGB(),i=r.a*e;return[t[0],t[1],t[2],i]}return[0,0,0,0]}_getFillColor(){if(pe(this._getPrimitive()))return j;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const e=this._materialColor;if(null==e){return null==this._getPrimitive()?x:v}return e.toUnitRGBA()}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(l(t)):ce)/e}_createCimMaterials(e){const t=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;if(t)return t;const r=Se([],e,this._context.focusAreaStyle,this._context.spherical);return this._cimSymbolMaterials.set(e.textureId??0,r),r}_createMaterials(e){this._fastUpdates=q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),e.hasVertexColor=this._drivenProperties.color&&!this._fastUpdates?.visualVariables.color||this._drivenProperties.opacity&&!this._fastUpdates?.visualVariables.opacity,e.hasVertexSize=this._drivenProperties.size&&!this._fastUpdates?.visualVariables.size,Se(this._materials,e,this._context.focusAreaStyle,this._context.spherical)}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=s(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e.output;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?l(r)/t:"number"==typeof s&&isFinite(s)?l(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading?.output??0:null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=L(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i=this._materials;const s=this.view.focusAreasView?.containsGeometry(r)??!0;if(this._cimData){if(!this._cimData.symbol)return null;const r=this._context.graphicsCoreOwner.view.state.rasterPixelRatio,s=this._generateTextureCIM(t,e),a=m(s.parameters.width/r,s.parameters.height/r);i=this._createCimMaterials({textureId:s.id,size:a,...this._cimMaterialParametersInfo})}const a=i[s?0:2];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=null==this._getPrimitive(),n=e.renderingInfo,l=this._hasDrivenColorOrOpacity?this._getDrivenUInt8Color(n,this._materialColor,o):null,c=this._getDrivenRotation(n);let h=null;if(!this._fastUpdates?.visualVariables.size){const e=this._size,t=e[0]>e[1]?e[0]:e[1];h=this._getScaleFactor(n,t)}const u=null!=h?m(h,h):null,d=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===d.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(n,r,a,l,c,u,t.uid):this._createAs3DShape(n,r,a,l,c,u,d,t.uid)}terrainTransparencyChanged(){return this.draped}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateTransparentMode(e,t){const r=e.stageObject.geometries[0]?.material,i=this._cimData?r?.parameters.textureId:null,s=i?this._cimSymbolMaterials.get(i):this._materials,a=(s?.indexOf(r)??-1)<2,o=t?a?1:3:a?0:2,n=s?.[o];n&&n!==r&&e.updateMaterial(n)}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:i,stageObject:s}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;const a=L(r);if(!a)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);const o=H(s,this._context,a,i);if(null==o)return!1;const n=k(this._context,a);return s.geometries[0].localOrigin===n&&(t.alignedSampledElevation=o,B(t,a,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=F(me.elevationModeChangeTypes,r,i);if(1!==s)return s;const a=T(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!J(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;{const e=this._fastUpdates;this._materials.forEach(t=>t?.setParameters(e.materialParameters))}}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(i,l){if(!l.resource||"partial"!==l.resource.type)return;const c=l.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=_e(h))return;const m=this._getIconSize(),d=m*this._context.graphicsCoreOwner.view.state.pixelRatio;i.symbolLayerStatePatches.push(()=>{this._patchTask=s(this._patchTask),this._patchTask=t(t=>this._context.schedule(async(t,i)=>{const s=await e(u.fromUrl(h,d,{signal:i}));n(i);const l=!s.ok;if(l&&o(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,l){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new r("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.managedTexture;this._size=ye(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},t))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return ve}_createAs3DShape(e,t,r,i,s,a,o,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=ie(r,{normal:le,color:i,rotation:s,size:a,centerOffset:f,groundDistance:1,featureAttribute:l,olidColor:h}),m=N(this._context,t,u,o,n);if(null==m)return null;const d=new V(this,m.object,null,E,o);return d.setOccludedVisibilityMode(this.symbolLayer.occludedVisibility?.mode),d.hiddenIfDeconflicted=!0,d.alignedSampledElevation=m.sampledElevation,d.needsElevationUpdates=T(o.mode)||"absolute-height"===o.mode,d.getScreenSize=this._createScreenSizeGetter(a,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),B(d,t,this._context.elevationProvider),d}_createAsOverlay(e,t,r,i,s,a,o){r.renderPriority=this._renderPriority;const n=g();b(t,n,this._context.overlaySR),n[2]=te;const l=this._context.clippingExtent;if(null!=l&&!S(l,n))return null;const c=this.getFastUpdateAttrValues(e),h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerViewUid:h}),m=ie(r,{normal:le,position:n,color:i,rotation:s,size:a,featureAttribute:c,olidColor:u}),d=new ae(m,{layerViewUid:h,graphicUid:o}),p=new U(this,[d],null,this._context.drapeSourceRenderer);return p.getScreenSize=this._createScreenSizeGetter(a,c),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),p}_createScreenSizeGetter(e,t){e??=_;const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]*this._size[0],s=e[1]*this._size[1];return(e=p())=>{const[a,o]=Z(be,this._fastUpdates.materialParameters,t);return e[0]=a*i+r,e[1]=o*s+r,e}}const i=e[0]*this._size[0]+r,s=e[1]*this._size[1]+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=y(e,e,e),r=c(1),i=e*r,s=y(i,i,i),a=this._getFallbackSize();return new W({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:y(a,a,a)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(t=>t.forEach(e))}test(){return{...super.test(),material:this._materials[0]}}}function de(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function pe(e){return null!=e&&("cross"===e||"x"===e)}function _e(e){const t=u(e);return"application/json"===t?.mediaType?t.data:void 0}function fe(e,t){return"relative"===e?m((t.x||0)+.5,.5-(t.y||0)):e in A?A[e]:A.center}function ye({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function ge(e){return e.resource?.href?null:e.resource?.primitive??M}function xe(e){return 1===(e.material?.color?.a??0)&&null!=ge(e)}const ve={mode:"relative-to-ground",offset:0},be=g();function Se(e,t,r,i){const s={...t,focusAreaStyle:r};return e[0]=new oe(t,i),e[1]=new oe(t,i,!0),e[2]=new oe(s,i),e[3]=new oe(s,i,!0),e}export{me as Graphics3DIconSymbolLayer};
|
|
2
|
+
import{result as e,createTask as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import{clone as i}from"../../../../core/lang.js";import{abortMaybe as s,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as o,throwIfAborted as n}from"../../../../core/promiseUtils.js";import{pt2px as l,px2pt as c}from"../../../../core/screenUtils.js";import{numericHash as h}from"../../../../core/string.js";import{dataComponents as u}from"../../../../core/urlUtils.js";import{fromValues as m,fromArray as d,create as p,ONES as _}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{ZEROS as f,fromValues as y,create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as x,ZEROS as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as S}from"../../../../geometry/support/aaBoundingBox.js";import P from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as z}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as C}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as O}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultIconPrimitive as M}from"../../../../symbols/support/primitives.js";import R from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as I}from"../../../../symbols/support/utils.js";import{transparentUnit as j}from"./constants.js";import{perObjectElevationAligner as E}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as F,needsElevationUpdates2D as T}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as U}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as V}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as A}from"./placementUtils.js";import{placePointOnGeometry as L,updateStageObjectGeometry as H,getLocalOriginForPoint as k,extendPointGraphicElevationContext as B,createStageObject as N}from"./pointUtils.js";import{hasTransparencyModeSymbol as $}from"./transparencyUtils.js";import{initFastSymbolUpdatesState as q,updateFastSymbolUpdatesState as J,evaluateModelTransformScale as Z,ConvertOptions as W}from"../support/FastSymbolUpdates.js";import{createTexture as K,requiresHalfTexelOffset as Q,defaultBoundingBox as X,defaultSymbolSizeRatio as Y,defaultTexSize as ee}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as te}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as ie}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as se}from"../../webgl-engine/lib/ManagedTexture.js";import{RenderGeometry as ae}from"../../webgl-engine/lib/RenderGeometry.js";import{HUDMaterial as oe}from"../../webgl-engine/materials/HUDMaterial.js";var ne;const le=y(0,0,1),ce=16,he=1.5,ue=[ee*Y,ee*Y];class me extends D{static{ne=$}static{this.PRIMITIVE_SIZE=ue}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,xe(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=[1,1],this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0},this[ne]=!0}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=I(this.symbolLayer),i=_e(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=G(this._getIconSize());if(e)throw new r("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?l(e.size):ce);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let s=this._cimData;if(r&&s&&s.symbol||this.logger.error("Can't create texture, CIM data is undefined"),s.primitiveOverrides){s=i(s);const a=s.primitiveOverrides;r.evaluateOverrides(a,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(s.symbol,a)}const a=h(JSON.stringify(s));let o=this._cimSymbolTextures.get(a);if(o)return o;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(s.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?C(this._cimScaleFactorOrFunction,e):1;1!==c&&s.symbol&&O(s.symbol,c,!0);const u=w.getEnvelope(s,null,n.resourceManager);if(u?.width&&u.height){const e=u.x+u.width/2,t=u.y+u.height/2,r=n.rasterize({type:"cim",data:s},u.width,u.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),i=new R({x:-u.x/u.width-.5,y:(u.height+u.y)/u.height-.5});this._cimMaterialParametersInfo.anchorPosition=fe("relative",i),o=new se(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else o=new se(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(a,o),this._context.stage.addTexture(o),o}_prepareMaterialParameters(){const{symbolLayer:e,symbol:t,_context:r,_drivenProperties:i,view:s}=this,a=this.symbolLayer.occludedVisibility?.mode??"hidden";return{anchorPosition:fe(e.anchor,e.anchorPosition),rotation:e.angle,hasRotation:0!==e.angle||i.rotation,hasVertexRotation:i.rotation,occludedFragmentOpacity:"hidden"!==a?s.state.ensureOccludedFragmentOpacity():void 0,hasSlicePlane:r.slicePlaneEnabled,verticalOffset:de(t)?new re(t.verticalOffset):void 0,screenSizePerspective:r.screenSizePerspectiveEnabled?s.screenSizePerspective.parameters:void 0}}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(pe(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>K(t));this._textureHandle=r,e.textureId=r.managedTexture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=Q(t),e.distanceFieldBoundingBox=X;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/Y,e.size=m(i*this._symbolTextureRatio,i*this._symbolTextureRatio),this._createMaterials(e)}async _prepareResourcesHref(t,i,s){this._outlineSize=this._getOutlineSize(),t.color=this._getFillColor(),t.outlineColor=this._getOutlineColor(),t.outlineSize=this._outlineSize,t.textureIsSignedDistanceField=!1;const a=this._getIconSize(),n=a*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await e(this._context.sharedResources.textures.fromUrl(i,n,{signal:s}));if(!1===l.ok){o(l.error);throw new r("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${i})`)}this._textureHandle=l.value;const c=l.value.managedTexture;this._size=ye(c,a),t.size=d(this._size),t.textureId=c.id}this._createMaterials(t)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;n(r),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}const s=this._context.sharedResources.cimSymbolRasterizer,a=t,o=a?.symbol,l=[w.normalizeSymbolAndFetchResources(o,s.resourceManager,r)],c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&l.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),l.length>0&&(await Promise.all(l),n(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await z(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new P(c);this._cimScaleFactorOrFunction=(e,t,a)=>{const o=i(r,e,{$view:a},"esriGeometryPoint",s,t);return null!==o?o:1}}}n(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return ge(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(l(t.outline.size),0);return e=pe(this._getPrimitive())?he:0,Math.max(e,0)}_getOutlineColor(){const e=this._getLayerOpacity(),t=this.symbolLayer,r=t?.outline?.color;if(null!=r){const t=r.toUnitRGB(),i=r.a*e;return[t[0],t[1],t[2],i]}return[0,0,0,0]}_getFillColor(){if(pe(this._getPrimitive()))return j;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const e=this._materialColor;if(null==e){return null==this._getPrimitive()?x:v}return e.toUnitRGBA()}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(l(t)):ce)/e}_createCimMaterials(e){const t=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;if(t)return t;const r=Se([],e,this._context.focusAreaStyle,this._context.spherical);return this._cimSymbolMaterials.set(e.textureId??0,r),r}_createMaterials(e){this._fastUpdates=q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),e.hasVertexColor=this._drivenProperties.color&&!this._fastUpdates?.visualVariables.color||this._drivenProperties.opacity&&!this._fastUpdates?.visualVariables.opacity,e.hasVertexSize=this._drivenProperties.size&&!this._fastUpdates?.visualVariables.size,Se(this._materials,e,this._context.focusAreaStyle,this._context.spherical)}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=s(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e.output;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?l(r)/t:"number"==typeof s&&isFinite(s)?l(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading?.output??0:null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=L(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i=this._materials;const s=this.view.focusAreasView?.containsGeometry(r)??!0;if(this._cimData){if(!this._cimData.symbol)return null;const r=this._context.graphicsCoreOwner.view.state.rasterPixelRatio,s=this._generateTextureCIM(t,e),a=m(s.parameters.width/r,s.parameters.height/r);i=this._createCimMaterials({textureId:s.id,size:a,...this._cimMaterialParametersInfo})}const a=i[s?0:2];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=null==this._getPrimitive(),n=e.renderingInfo,l=this._hasDrivenColorOrOpacity?this._getDrivenUInt8Color(n,this._materialColor,o):null,c=this._getDrivenRotation(n);let h=null;if(!this._fastUpdates?.visualVariables.size){const e=this._size,t=e[0]>e[1]?e[0]:e[1];h=this._getScaleFactor(n,t)}const u=null!=h?m(h,h):null,d=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===d.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(n,r,a,l,c,u,t.uid):this._createAs3DShape(n,r,a,l,c,u,d,t.uid)}terrainTransparencyChanged(){return this.draped}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateTransparentMode(e,t){const r=e.stageObject.geometries[0]?.material,i=this._cimData?r?.parameters.textureId:null,s=i?this._cimSymbolMaterials.get(i):this._materials,a=(s?.indexOf(r)??-1)<2,o=t?a?1:3:a?0:2,n=s?.[o];n&&n!==r&&e.updateMaterial(n)}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:i,stageObject:s}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;const a=L(r);if(!a)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);const o=H(s,this._context,a,i);if(null==o)return!1;const n=k(this._context,a);return s.geometries[0].localOrigin===n&&(t.alignedSampledElevation=o,B(t,a,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=F(me.elevationModeChangeTypes,r,i);if(1!==s)return s;const a=T(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!J(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;{const e=this._fastUpdates;this._materials.forEach(t=>t?.setParameters(e.materialParameters))}}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(i,l){if(!l.resource||"partial"!==l.resource.type)return;const c=l.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=_e(h))return;const m=this._getIconSize(),d=m*this._context.graphicsCoreOwner.view.state.pixelRatio;i.symbolLayerStatePatches.push(()=>{this._patchTask=s(this._patchTask),this._patchTask=t(t=>this._context.schedule(async(t,i)=>{const s=await e(u.fromUrl(h,d,{signal:i}));n(i);const l=!s.ok;if(l&&o(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,l){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new r("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.managedTexture;this._size=ye(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},t))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return ve}_createAs3DShape(e,t,r,i,s,a,o,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=ie(r,{normal:le,color:i,rotation:s,size:a,centerOffset:f,groundDistance:1,featureAttribute:l,olidColor:h}),m=N(this._context,t,u,o,n);if(null==m)return null;const d=new V(this,m.object,null,E,o);return d.setOccludedVisibilityMode(this.symbolLayer.occludedVisibility?.mode),d.hiddenIfDeconflicted=!0,d.alignedSampledElevation=m.sampledElevation,d.needsElevationUpdates=T(o.mode)||"absolute-height"===o.mode,d.getScreenSize=this._createScreenSizeGetter(a,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),B(d,t,this._context.elevationProvider),d}_createAsOverlay(e,t,r,i,s,a,o){r.renderPriority=this._renderPriority;const n=g();b(t,n,this._context.overlaySR),n[2]=te;const l=this._context.clippingExtent;if(null!=l&&!S(l,n))return null;const c=this.getFastUpdateAttrValues(e),h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerViewUid:h}),m=ie(r,{normal:le,position:n,color:i,rotation:s,size:a,featureAttribute:c,olidColor:u}),d=new ae(m,{layerViewUid:h,graphicUid:o}),p=new U(this,[d],null,this._context.drapeSourceRenderer);return p.getScreenSize=this._createScreenSizeGetter(a,c),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),p}_createScreenSizeGetter(e,t){e??=_;const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]*this._size[0],s=e[1]*this._size[1];return(e=p())=>{const[a,o]=Z(be,this._fastUpdates.materialParameters,t);return e[0]=a*i+r,e[1]=o*s+r,e}}const i=e[0]*this._size[0]+r,s=e[1]*this._size[1]+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=y(e,e,e),r=c(1),i=e*r,s=y(i,i,i),a=this._getFallbackSize();return new W({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:y(a,a,a)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(t=>t.forEach(e))}test(){return{...super.test(),material:this._materials[0]}}}function de(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function pe(e){return null!=e&&("cross"===e||"x"===e)}function _e(e){const t=u(e);return"application/json"===t?.mediaType?t.data:void 0}function fe(e,t){return"relative"===e?m((t.x||0)+.5,.5-(t.y||0)):e in A?A[e]:A.center}function ye({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function ge(e){return e.resource?.href?null:e.resource?.primitive??M}function xe(e){return 1===(e.material?.color?.a??1)&&null!=ge(e)}const ve={mode:"relative-to-ground",offset:0},be=g();function Se(e,t,r,i){const s={...t,focusAreaStyle:r};return e[0]=new oe(t,i),e[1]=new oe(t,i,!0),e[2]=new oe(s,i),e[3]=new oe(s,i,!0),e}export{me as Graphics3DIconSymbolLayer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{has}from"../../../../applications/Components/baUtils.js";import e from"../../../../core/Error.js";import{px2pt as t,pt2px as r}from"../../../../core/screenUtils.js";import{fromValues as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as s,clone as o,ones as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import n from"../../../../geometry/Extent.js";import c from"../../../../geometry/Polygon.js";import{create as p,fromBuffer as h,intersectsClippingArea as m,empty as u,expandWithAABB as y,expandWithBuffer as _}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as d}from"../../../../renderers/support/renderingInfoUtils.js";import{sharedGeometryElevationAligner as f}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as g,needsElevationUpdates2D as b}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as v}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as C}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as P,nanFallbackColor as M}from"./Graphics3DSymbolLayer.js";import{parseCapType as k,computeSymbolLayerIndex as w,parseLineMarkerStyle as S}from"./lineUtils.js";import{initFastSymbolUpdatesState as L,updateFastSymbolUpdatesState as x,getAttributeValue as z,getSizeAttributeValue as U,ConvertOptions as j}from"../support/FastSymbolUpdates.js";import{debugFlags as O}from"../../support/debugFlags.js";import{createGeometry as V}from"../../support/engineContent/line.js";import{geometryToRenderInfo as A,geometryToRenderInfoDraped as E}from"../../support/renderInfoUtils/line.js";import{Object3D as G}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as D}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as F}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as R}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as I}from"../../webgl-engine/materials/RibbonLineMaterial.js";const W=["polyline","polygon","extent"];class H extends P{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,N(t))}async doLoad(){this._fastUpdates=L(this._context.renderer,this._fastVisualVariableConvertOptions());const r=!0;if(this._fastMarkerUpdates=L(this._context.renderer,this._fastVisualVariableConvertOptions(r)),!this._drivenProperties.size){if((null!=this.symbolLayer.size?this.symbolLayer.size:t(1))<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values")}}_getMaterialParameters(e,t){const r=this._screenSizePerspective,{symbolLayer:i}=this,a={...this._getMaterialColorParameters(t),width:this._computeMaterialWidth(i?.size),polygonOffset:3,polygonOffsetIndex:w(this._renderPriority,this._renderPriorityStep),join:i.join||"miter",cap:k(i.cap||"butt"),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:R(i.pattern??i.imagePattern),emissiveStrength:this._emissiveStrength,screenSizePerspective:r};return 4===t&&this._fastMarkerUpdates?.visualVariables?{...a,...this._fastMarkerUpdates.materialParameters}:this._fastUpdates?.visualVariables?{...a,...this._fastUpdates.materialParameters}:a}_getMaterialColorParameters(e){const t=4===e,r=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);return this._patternHidesLine&&!t&&(r[3]=0),{color:r}}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){if(has("enable-feature:emissive-on-none-volumetrics")){const e=this.symbolLayer.material?.emissive;return("color"===e?.source?e?.strength:void 0)??0}return 0}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return null==this._materials[0]&&(this._materials[0]=new I(this._getMaterialParameters(!1,0),this.view.state.isGlobal)),this._materials[0]}get _ringMaterial(){return null==this._materials[1]&&(this._materials[1]=new I(this._getMaterialParameters(!0,1),this.view.state.isGlobal)),this._materials[1]}get _wireframeLineMaterial(){return null==this._materials[2]&&(this._materials[2]=new I({...this._getMaterialParameters(!1,2),wireframe:!0},this.view.state.isGlobal)),this._materials[2]}get _wireframeRingMaterial(){return null==this._materials[3]&&(this._materials[3]=new I({...this._getMaterialParameters(!0,3),wireframe:!0},this.view.state.isGlobal)),this._materials[3]}get _markerMaterial(){return null==this._materials[4]&&null!=this.symbolLayer.marker&&(this._materials[4]=new F({...this._getMaterialParameters(!1,4),placement:this.symbolLayer.marker.placement,markerPrimitive:S(this.symbolLayer.marker.style)},this.view.state.isGlobal)),this._materials[4]}_getDrivenSize(e){if(this._drivenProperties.size){const t=e.size;return null!=t?r(d(t.output)):this._getFallbackSize()}return 1}_getDrivenColor({color:e,opacity:t}){const r=l();return this._drivenProperties.color&&(a(r,e?.output??this._getFallbackOpacityAndColor(s)),null==t)||this._drivenProperties.opacity&&(e||this._materialColor)&&(r[3]=t?.output??this._getFallbackOpacity()),r}_getDrivenMarkerColor({color:e,opacity:t}){const r=l();return this._drivenProperties.color&&(a(r,e?.output??this._getFallbackMarkerOpacityAndColor(s)),null==t)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(r[3]=t?.output??this._getFallbackMarkerOpacity()),r}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,W,this.symbolLayer.type))return null;const r=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.draped?this._createAsOverlay(e):this._createAs3DShape(e,r,t.uid)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;{const e=this._fastUpdates;if(!x(e,t,this._fastVisualVariableConvertOptions()))return 0;for(const t of this._materials)t instanceof I&&t.setParameters(e.materialParameters);const r=this._fastMarkerUpdates,i=!0;if(!x(r,t,this._fastVisualVariableConvertOptions(i)))return 0;for(const t of this._materials)t instanceof F&&t.setParameters(r.materialParameters)}}return 2}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff,r={};"complete"===t.size?.type&&(r.width=this._computeMaterialWidth(t.size.newValue),delete t.size),"complete"===t.cap?.type&&(r.cap=k(t.cap.newValue??"butt"),delete t.cap);const i=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,i),e.symbolLayerStatePatches.push(()=>{for(const e of this._materials)e?.setParameters(r)})}layerOpacityChanged(){for(let e=0;e<5;e++)this._materials[e]?.setParameters(this._getMaterialColorParameters(e))}get _screenSizePerspective(){return!this.draped&&this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null}layerScreenSizePerspectiveChanged(){const e=this._screenSizePerspective;for(const t of this._materials)t?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,a=g(H.elevationModeChangeTypes,r,i);if(1!==a)return a;const s=b(i);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>s)}slicePlaneEnabledChanged(){const e={hasSlicePlane:this._context.slicePlaneEnabled};for(const t of this._materials)t?.setParameters(e);return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,r){const i=B(e.graphic.geometry),a="polygon"===i.type?i.rings:i.paths,s=new Array,o=p(),l=A(i,this._context.elevationProvider,this._context.renderCoordsHelper,t),n="polygon"===i.type?"rings":"paths";this._logGeometryCreationWarnings(l,a,n,"LineSymbol3DLayer");for(let p=0;p<l.lines.length;p++){const t=l.lines[p],a=t.position,n=t.mapPositions;if(null!=this._context.clippingExtent&&(h(n,o),!m(o,this._context.clippingExtent)))continue;const c=this._createGeometry("polygon"===i.type?this._ringMaterial:this._lineMaterial,e,a,n,i.type,1,r);if(s.push(c),O.LINE_WIREFRAMES&&s.push(c.instantiate({material:"polygon"===i.type?this._wireframeRingMaterial:this._wireframeLineMaterial})),null!=this._markerMaterial){const t=c.instantiate({material:this._markerMaterial});t.attributes.has("color")&&t.setAttributeData("color",this._getDrivenMarkerColor(e.renderingInfo)),s.push(t)}}if(0===s.length)return null;const c=this._context.layerViewUid,u=new G({geometries:s,castShadow:!1,layerViewUid:c,graphicUid:r}),y=new C(this,u,null,f,t);return y.alignedSampledElevation=l.sampledElevation,y.needsElevationUpdates=b(t.mode),y}_createGeometry(e,t,r,i,a,s,o){const l=0===s?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,n="polygon"===a,c=this._fastUpdates?.visualVariables.color,p=this._fastUpdates?.visualVariables.size,h=this._fastUpdates?.visualVariables.opacity,m=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerViewUid:m}),{renderingInfo:y}=t,_={position:r,size:p?null:this._getDrivenSize(y),color:c?null:this._getDrivenColor(y),sizeFeature:p?U(p,y.size):null,colorFeature:c?z(c,y.color):null,opacityFeature:h?z(h,y.opacity):null};return V(e,{overlayInfo:l,removeDuplicateStartEnd:n,mapPositions:i,attributeData:_},u)}_createAsOverlay(e){const t=e.graphic,r=B(t.geometry),i="polygon"===r.type?r.rings:r.paths,a="polygon"===r.type?this._ringMaterial:this._lineMaterial;a.renderPriority=this._renderPriority;const s=O.LINE_WIREFRAMES?"polygon"===r.type?this._wireframeRingMaterial:this._wireframeLineMaterial:null,o=this._markerMaterial;null!=s&&(s.renderPriority=this._renderPriority-.001),null!=o&&(o.renderPriority=this._renderPriority-.002);const l=new Array,n=p(),c=u(),d=E(r,this._context.overlaySR),f="polygon"===r.type?"rings":"paths";this._logGeometryCreationWarnings(d,i,f,"LineSymbol3DLayer");for(const p of d.lines){if(h(p.position,n),!m(n,this._context.clippingExtent))continue;y(c,n);const i=this._createGeometry(a,e,p.position,void 0,r.type,0,t.uid),u=e=>{const r=this._context.layerViewUid,i=new D(e,{layerViewUid:r,graphicUid:t.uid});l.push(i)};if(null!=o){const t=i.instantiate({material:o});t.attributes.has("color")&&t.setAttributeData("color",this._getDrivenMarkerColor(e.renderingInfo)),u(t);const r=this.symbolLayer.marker.placement;"begin"!==r&&"begin-end"!==r||_(n,p.position,0,1),"end"!==r&&"begin-end"!==r||_(n,p.position,p.position.length-3,1)}u(i),O.LINE_WIREFRAMES&&u(i.instantiate({material:s}))}return new v(this,l,c,this._context.drapeSourceRenderer)}get _patternHidesLine(){const e=this.symbolLayer.pattern;return null!=e&&"style"===e.type&&"none"===e.style}_computeMaterialWidth(e){return e=e??t(1),this._drivenProperties.size?this._fastUpdates?.visualVariables.size?r(1):1:r(e)}_prepareMaterialPatch(e,t,r){const i=t.material;if(null==i)return void(r.changed&&r.useMaterialColor&&T(this._getCombinedOpacityAndColor(this._materialColor),this._materials[4],e));if("collection"===i.type)return;const a="complete"===i.type?i.newValue?.color:"complete"===i.diff.color?.type?i.diff.color.newValue:null,s=this._getCombinedOpacityAndColor(a);r.useMaterialColor&&T(o(s),this._materials[4],e),this._patternHidesLine&&(s[3]=0),T(s,this._materials[0],e),delete t.material}_prepareMarkerPatch(e,t){const r=t.marker,i=this._markerMaterial;if(null==r||"partial"!==r.type||null==r.diff||null!=r.diff.placement||null!=r.diff.style&&"complete"!==r.diff.style.type||null!=r.diff.color&&"complete"!==r.diff.color.type||null==i)return{changed:!1,useMaterialColor:null==this._markerColor};const a=r.diff.color,s=null!=a,o=s?a.newValue:null,l=null==o&&null==this._markerColor;o&&T(this._getCombinedOpacityAndColor(o),i,e);const n=r.diff.style?.newValue;return n&&e.symbolLayerStatePatches.push(()=>i.setParameters({markerPrimitive:S(n)})),delete t.marker,{changed:s,useMaterialColor:l}}_fastVisualVariableConvertOptions(e=!1){const t=this._getFallbackSize();return new j({supports:{size:!0,color:!0,rotation:!1,opacity:!0},fallbackColor:e?this._getFallbackMarkerOpacityAndColor(M):this._getFallbackOpacityAndColor(M),fallbackSize:i(t,t,t)})}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}_getFallbackOpacity(){return this._materialColor?.a??0}_getFallbackMarkerOpacityAndColor(e){return this.symbolLayer?.marker?.color?.toUnitRGBA()??this._getFallbackOpacityAndColor(e)}_getFallbackMarkerOpacity(){return this.symbolLayer?.marker?.color?.a??this._getFallbackOpacity()}_getFallbackSize(){const e=this.symbolLayer?.size;return null!=e?r(e):1}}function B(e){switch(e.type){case"extent":if(e instanceof n)return c.fromExtent(e);break;case"polygon":case"polyline":return e}return null}function T(e,t,r){null!=t&&r.symbolLayerStatePatches.push(()=>t.setParameters({color:e}))}function N(e){const t=e.material?.color,r=e.marker?.color??t;return 1===(t?.a??0)&&1===(r?.a??0)}export{H as Graphics3DLineSymbolLayer};
|
|
2
|
+
import{has}from"../../../../applications/Components/baUtils.js";import e from"../../../../core/Error.js";import{px2pt as t,pt2px as r}from"../../../../core/screenUtils.js";import{fromValues as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as s,clone as o,ones as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import n from"../../../../geometry/Extent.js";import c from"../../../../geometry/Polygon.js";import{create as p,fromBuffer as h,intersectsClippingArea as m,empty as u,expandWithAABB as y,expandWithBuffer as _}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as d}from"../../../../renderers/support/renderingInfoUtils.js";import{sharedGeometryElevationAligner as f}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as g,needsElevationUpdates2D as b}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as v}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as C}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as P,nanFallbackColor as M}from"./Graphics3DSymbolLayer.js";import{parseCapType as k,computeSymbolLayerIndex as w,parseLineMarkerStyle as S}from"./lineUtils.js";import{initFastSymbolUpdatesState as L,updateFastSymbolUpdatesState as x,getAttributeValue as z,getSizeAttributeValue as U,ConvertOptions as j}from"../support/FastSymbolUpdates.js";import{debugFlags as O}from"../../support/debugFlags.js";import{createGeometry as V}from"../../support/engineContent/line.js";import{geometryToRenderInfo as A,geometryToRenderInfoDraped as E}from"../../support/renderInfoUtils/line.js";import{Object3D as G}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as D}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as F}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as R}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as I}from"../../webgl-engine/materials/RibbonLineMaterial.js";const W=["polyline","polygon","extent"];class H extends P{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,N(t))}async doLoad(){this._fastUpdates=L(this._context.renderer,this._fastVisualVariableConvertOptions());const r=!0;if(this._fastMarkerUpdates=L(this._context.renderer,this._fastVisualVariableConvertOptions(r)),!this._drivenProperties.size){if((null!=this.symbolLayer.size?this.symbolLayer.size:t(1))<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values")}}_getMaterialParameters(e,t){const r=this._screenSizePerspective,{symbolLayer:i}=this,a={...this._getMaterialColorParameters(t),width:this._computeMaterialWidth(i?.size),polygonOffset:3,polygonOffsetIndex:w(this._renderPriority,this._renderPriorityStep),join:i.join||"miter",cap:k(i.cap||"butt"),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:R(i.pattern??i.imagePattern),emissiveStrength:this._emissiveStrength,screenSizePerspective:r};return 4===t&&this._fastMarkerUpdates?.visualVariables?{...a,...this._fastMarkerUpdates.materialParameters}:this._fastUpdates?.visualVariables?{...a,...this._fastUpdates.materialParameters}:a}_getMaterialColorParameters(e){const t=4===e,r=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);return this._patternHidesLine&&!t&&(r[3]=0),{color:r}}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){if(has("enable-feature:emissive-on-none-volumetrics")){const e=this.symbolLayer.material?.emissive;return("color"===e?.source?e?.strength:void 0)??0}return 0}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return null==this._materials[0]&&(this._materials[0]=new I(this._getMaterialParameters(!1,0),this.view.state.isGlobal)),this._materials[0]}get _ringMaterial(){return null==this._materials[1]&&(this._materials[1]=new I(this._getMaterialParameters(!0,1),this.view.state.isGlobal)),this._materials[1]}get _wireframeLineMaterial(){return null==this._materials[2]&&(this._materials[2]=new I({...this._getMaterialParameters(!1,2),wireframe:!0},this.view.state.isGlobal)),this._materials[2]}get _wireframeRingMaterial(){return null==this._materials[3]&&(this._materials[3]=new I({...this._getMaterialParameters(!0,3),wireframe:!0},this.view.state.isGlobal)),this._materials[3]}get _markerMaterial(){return null==this._materials[4]&&null!=this.symbolLayer.marker&&(this._materials[4]=new F({...this._getMaterialParameters(!1,4),placement:this.symbolLayer.marker.placement,markerPrimitive:S(this.symbolLayer.marker.style)},this.view.state.isGlobal)),this._materials[4]}_getDrivenSize(e){if(this._drivenProperties.size){const t=e.size;return null!=t?r(d(t.output)):this._getFallbackSize()}return 1}_getDrivenColor({color:e,opacity:t}){const r=l();return this._drivenProperties.color&&(a(r,e?.output??this._getFallbackOpacityAndColor(s)),null==t)||this._drivenProperties.opacity&&(e||this._materialColor)&&(r[3]=t?.output??this._getFallbackOpacity()),r}_getDrivenMarkerColor({color:e,opacity:t}){const r=l();return this._drivenProperties.color&&(a(r,e?.output??this._getFallbackMarkerOpacityAndColor(s)),null==t)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(r[3]=t?.output??this._getFallbackMarkerOpacity()),r}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,W,this.symbolLayer.type))return null;const r=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.draped?this._createAsOverlay(e):this._createAs3DShape(e,r,t.uid)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;{const e=this._fastUpdates;if(!x(e,t,this._fastVisualVariableConvertOptions()))return 0;for(const t of this._materials)t instanceof I&&t.setParameters(e.materialParameters);const r=this._fastMarkerUpdates,i=!0;if(!x(r,t,this._fastVisualVariableConvertOptions(i)))return 0;for(const t of this._materials)t instanceof F&&t.setParameters(r.materialParameters)}}return 2}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff,r={};"complete"===t.size?.type&&(r.width=this._computeMaterialWidth(t.size.newValue),delete t.size),"complete"===t.cap?.type&&(r.cap=k(t.cap.newValue??"butt"),delete t.cap);const i=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,i),e.symbolLayerStatePatches.push(()=>{for(const e of this._materials)e?.setParameters(r)})}layerOpacityChanged(){for(let e=0;e<5;e++)this._materials[e]?.setParameters(this._getMaterialColorParameters(e))}get _screenSizePerspective(){return!this.draped&&this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null}layerScreenSizePerspectiveChanged(){const e=this._screenSizePerspective;for(const t of this._materials)t?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,a=g(H.elevationModeChangeTypes,r,i);if(1!==a)return a;const s=b(i);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>s)}slicePlaneEnabledChanged(){const e={hasSlicePlane:this._context.slicePlaneEnabled};for(const t of this._materials)t?.setParameters(e);return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,r){const i=B(e.graphic.geometry),a="polygon"===i.type?i.rings:i.paths,s=new Array,o=p(),l=A(i,this._context.elevationProvider,this._context.renderCoordsHelper,t),n="polygon"===i.type?"rings":"paths";this._logGeometryCreationWarnings(l,a,n,"LineSymbol3DLayer");for(let p=0;p<l.lines.length;p++){const t=l.lines[p],a=t.position,n=t.mapPositions;if(null!=this._context.clippingExtent&&(h(n,o),!m(o,this._context.clippingExtent)))continue;const c=this._createGeometry("polygon"===i.type?this._ringMaterial:this._lineMaterial,e,a,n,i.type,1,r);if(s.push(c),O.LINE_WIREFRAMES&&s.push(c.instantiate({material:"polygon"===i.type?this._wireframeRingMaterial:this._wireframeLineMaterial})),null!=this._markerMaterial){const t=c.instantiate({material:this._markerMaterial});t.attributes.has("color")&&t.setAttributeData("color",this._getDrivenMarkerColor(e.renderingInfo)),s.push(t)}}if(0===s.length)return null;const c=this._context.layerViewUid,u=new G({geometries:s,castShadow:!1,layerViewUid:c,graphicUid:r}),y=new C(this,u,null,f,t);return y.alignedSampledElevation=l.sampledElevation,y.needsElevationUpdates=b(t.mode),y}_createGeometry(e,t,r,i,a,s,o){const l=0===s?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,n="polygon"===a,c=this._fastUpdates?.visualVariables.color,p=this._fastUpdates?.visualVariables.size,h=this._fastUpdates?.visualVariables.opacity,m=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerViewUid:m}),{renderingInfo:y}=t,_={position:r,size:p?null:this._getDrivenSize(y),color:c?null:this._getDrivenColor(y),sizeFeature:p?U(p,y.size):null,colorFeature:c?z(c,y.color):null,opacityFeature:h?z(h,y.opacity):null};return V(e,{overlayInfo:l,removeDuplicateStartEnd:n,mapPositions:i,attributeData:_},u)}_createAsOverlay(e){const t=e.graphic,r=B(t.geometry),i="polygon"===r.type?r.rings:r.paths,a="polygon"===r.type?this._ringMaterial:this._lineMaterial;a.renderPriority=this._renderPriority;const s=O.LINE_WIREFRAMES?"polygon"===r.type?this._wireframeRingMaterial:this._wireframeLineMaterial:null,o=this._markerMaterial;null!=s&&(s.renderPriority=this._renderPriority-.001),null!=o&&(o.renderPriority=this._renderPriority-.002);const l=new Array,n=p(),c=u(),d=E(r,this._context.overlaySR),f="polygon"===r.type?"rings":"paths";this._logGeometryCreationWarnings(d,i,f,"LineSymbol3DLayer");for(const p of d.lines){if(h(p.position,n),!m(n,this._context.clippingExtent))continue;y(c,n);const i=this._createGeometry(a,e,p.position,void 0,r.type,0,t.uid),u=e=>{const r=this._context.layerViewUid,i=new D(e,{layerViewUid:r,graphicUid:t.uid});l.push(i)};if(null!=o){const t=i.instantiate({material:o});t.attributes.has("color")&&t.setAttributeData("color",this._getDrivenMarkerColor(e.renderingInfo)),u(t);const r=this.symbolLayer.marker.placement;"begin"!==r&&"begin-end"!==r||_(n,p.position,0,1),"end"!==r&&"begin-end"!==r||_(n,p.position,p.position.length-3,1)}u(i),O.LINE_WIREFRAMES&&u(i.instantiate({material:s}))}return new v(this,l,c,this._context.drapeSourceRenderer)}get _patternHidesLine(){const e=this.symbolLayer.pattern;return null!=e&&"style"===e.type&&"none"===e.style}_computeMaterialWidth(e){return e=e??t(1),this._drivenProperties.size?this._fastUpdates?.visualVariables.size?r(1):1:r(e)}_prepareMaterialPatch(e,t,r){const i=t.material;if(null==i)return void(r.changed&&r.useMaterialColor&&T(this._getCombinedOpacityAndColor(this._materialColor),this._materials[4],e));if("collection"===i.type)return;const a="complete"===i.type?i.newValue?.color:"complete"===i.diff.color?.type?i.diff.color.newValue:null,s=this._getCombinedOpacityAndColor(a);r.useMaterialColor&&T(o(s),this._materials[4],e),this._patternHidesLine&&(s[3]=0),T(s,this._materials[0],e),delete t.material}_prepareMarkerPatch(e,t){const r=t.marker,i=this._markerMaterial;if(null==r||"partial"!==r.type||null==r.diff||null!=r.diff.placement||null!=r.diff.style&&"complete"!==r.diff.style.type||null!=r.diff.color&&"complete"!==r.diff.color.type||null==i)return{changed:!1,useMaterialColor:null==this._markerColor};const a=r.diff.color,s=null!=a,o=s?a.newValue:null,l=null==o&&null==this._markerColor;o&&T(this._getCombinedOpacityAndColor(o),i,e);const n=r.diff.style?.newValue;return n&&e.symbolLayerStatePatches.push(()=>i.setParameters({markerPrimitive:S(n)})),delete t.marker,{changed:s,useMaterialColor:l}}_fastVisualVariableConvertOptions(e=!1){const t=this._getFallbackSize();return new j({supports:{size:!0,color:!0,rotation:!1,opacity:!0},fallbackColor:e?this._getFallbackMarkerOpacityAndColor(M):this._getFallbackOpacityAndColor(M),fallbackSize:i(t,t,t)})}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}_getFallbackOpacity(){return this._materialColor?.a??0}_getFallbackMarkerOpacityAndColor(e){return this.symbolLayer?.marker?.color?.toUnitRGBA()??this._getFallbackOpacityAndColor(e)}_getFallbackMarkerOpacity(){return this.symbolLayer?.marker?.color?.a??this._getFallbackOpacity()}_getFallbackSize(){const e=this.symbolLayer?.size;return null!=e?r(e):1}}function B(e){switch(e.type){case"extent":if(e instanceof n)return c.fromExtent(e);break;case"polygon":case"polyline":return e}return null}function T(e,t,r){null!=t&&r.symbolLayerStatePatches.push(()=>t.setParameters({color:e}))}function N(e){return 1===(e.material?.color?.a??1)&&1===(e.marker?.color?.a??1)}export{H as Graphics3DLineSymbolLayer};
|