@arcgis/core 5.2.0-next.34 → 5.2.0-next.35

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.
Files changed (61) hide show
  1. package/analysis/Viewshed.d.ts +0 -5
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{4316b78fc36bfd893a90.js → 155940ef3d1888272d73.js} +1 -1
  4. package/assets/esri/core/workers/chunks/24aa98cb2021ddd789ce.js +1 -0
  5. package/assets/esri/core/workers/chunks/406c7723e8db470822bf.js +1 -0
  6. package/assets/esri/core/workers/chunks/{37dc6a8495f1f44e2d45.js → 6c746ac4bd2e57b8cb41.js} +1 -1
  7. package/assets/esri/core/workers/chunks/8a9b2efa0603e9fa4e8b.js +1 -0
  8. package/assets/esri/core/workers/chunks/{fe8032905992e6574714.js → 9fb0431b0628dcb53004.js} +54 -54
  9. package/assets/esri/core/workers/chunks/{87c7092282214f5b78b8.js → bbcb213d20693fcad5be.js} +12 -12
  10. package/assets/esri/core/workers/chunks/{414691f7758c78e2a704.js → cfbbfa5edffa57bd3a8e.js} +1 -1
  11. package/assets/esri/core/workers/chunks/d0217187aed8bb7038f4.js +1 -0
  12. package/assets/esri/core/workers/chunks/{b7d7bfcb089a3f1a38b6.js → dd785e595cd08b2d6284.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{0087ad36f7d38fc7fe11.js → ee446250a40e5d89bb5a.js} +44 -44
  14. package/assets/esri/core/workers/chunks/{42b1c526c4c9636a169d.js → f1f3fe9d2d96578f4f6b.js} +1 -1
  15. package/chunks/FocusAreaColor.glsl.js +1 -10
  16. package/chunks/RibbonLine.glsl.js +22 -22
  17. package/config.js +1 -1
  18. package/geometry/support/plane.js +1 -1
  19. package/geometry/support/triangle.js +1 -1
  20. package/kernel.js +1 -1
  21. package/layers/raster/datasets/pixelReader.js +1 -1
  22. package/layers/raster/functions/pixelUtils.js +1 -1
  23. package/package.json +1 -1
  24. package/popup/Features.d.ts +2 -2
  25. package/popup/Features.js +1 -1
  26. package/renderers/visualVariables/support/visualVariableUtils.js +1 -1
  27. package/support/revision.js +1 -1
  28. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  29. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  30. package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +1 -1
  31. package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
  32. package/views/3d/analysis/Viewshed/types.d.ts +17 -0
  33. package/views/3d/analysis/ViewshedAnalysisView3D.d.ts +3 -14
  34. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  35. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  36. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
  37. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  38. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  39. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  40. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  41. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  42. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  43. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  44. package/views/3d/webgl/ManagedFBO.js +1 -1
  45. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColor.glsl.js +1 -1
  46. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorTechnique.js +1 -1
  47. package/views/3d/webgl-engine/effects/focusArea/FocusAreaVisualization.js +1 -1
  48. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  49. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +1 -1
  50. package/views/3d/webgl-engine/lib/intersectorUtils.js +1 -1
  51. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  52. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  53. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  54. package/views/3d/webgl-engine/shaders/RibbonLineLayouts.js +1 -1
  55. package/views/layers/ViewshedLayerView.d.ts +0 -10
  56. package/views/support/LayerViewManager.js +1 -1
  57. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  58. package/assets/esri/core/workers/chunks/7a59d39010ed33b8fabb.js +0 -1
  59. package/assets/esri/core/workers/chunks/a0f7e37d385fc68b138d.js +0 -1
  60. package/assets/esri/core/workers/chunks/dfae4440afe0ca7c5b25.js +0 -1
  61. package/assets/esri/core/workers/chunks/fec9ce6ad634c904ffdf.js +0 -1
@@ -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 { AbortOptions } from "../../../core/promiseUtils.js";
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?: AbortOptions | null | undefined): Promise<void>;
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?: AbortOptions | null | undefined): Promise<ViewshedPlacementResult>;
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 n}from"../../../support/getDefaultUnitForView.js";import o from"./AnalysisView3D.js";import{VolumeMeasurementCutFillController as a}from"./VolumeMeasurement/VolumeMeasurementCutFillController.js";import{VolumeMeasurementCutFillVisualization as u}from"./VolumeMeasurement/VolumeMeasurementCutFillVisualization.js";import y from"./VolumeMeasurement/VolumeMeasurementTool.js";let p=class extends o{constructor(e){super(e),this.type="volume-measurement-view-3d",this.analysis=null}initialize(){const{analysis:e,view:t}=this;this._analysisController=new a({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",n=i(this.view.spatialReference);if(null!=l&&null!=n)return s(l,r,n);const o=this.elevationAlignedGeometry?.extent;return null==o?.zmin||null==o?.zmax?null:(o.zmax+o.zmin)/2}get targetGeometry(){return this._analysisController?.targetGeometry}get effectiveDisplayUnits(){const{displayUnits:e}=this.analysis,t=n(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 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,"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};
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};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as h,clone as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as g,add as x,scale as _,transformMat4 as y,transformMat3 as T,normalize as b,scaleAndAdd as v,subtract as w,cross as C,dot as M}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as j,ONES as R,ZEROS as A,create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as F,intersectsClippingArea as O,create as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as Y}from"../../../../chunks/vec3.js";import{transformNormal as K,transformVectorENUPlateCarree as J,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{getEmissiveMode as re}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as ie,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as ce}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ue}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as me}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as fe,nanFallbackColor as he}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as pe,MeshFastUpdateProcessor as de}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as ge}from"./SymbolComplexity.js";import{hasEdges as xe,createMaterial as _e}from"../support/edgeUtils.js";import{debugFlags as ye}from"../../support/debugFlags.js";import{Attribute as Te}from"../../webgl-engine/lib/Attribute.js";import{Geometry as be}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as ve}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as we}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Me}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as je,advancedMRRFactors as Re,schematicMRRFactors as Ae}from"../../webgl-engine/materials/pbrUtils.js";const Pe=["mesh"];class Se extends fe{constructor(e,t,r,o){super(e,t,r,o,Ye(t)),this._materialInfoCache=new pe,this._fastUpdateProcessor=new de,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ye.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Me({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Me({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Me({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Pe,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ie)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=rt,{origin:i,transform:l}=r;if(!B(t,g(Qe,i.x,i.y,i.z??0),s,a))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache)}e.updateFastLocalOrigin(s,l,this._context.localOriginFactory,!1);const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>le(e,u,c,m,t);return e.alignedSampledElevation=se(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=xe(this.symbolLayer)?2:0;return new ge({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=ze(n),h=ze(a),p=qe(s),d=ze(i),g=qe(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${h},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveStrength:c,emissiveTexture:u,emissiveTextureTransform:m,occlusionTexture:f,occlusionTextureTransform:h}=t.material,p=ze(n),d=qe(a),g=ze(i),x=ze(u),_=qe(m),y=ze(f),T=qe(h);o.uid=[o.uid,`mrm:${e}`,`mrr:${r}`,`mrt:${p}`,`mrtt:${d}`,`emuid:${g}`,`ems:${c}`,`etmuid:${x}`,`ett:${_}`,`otmuid:${y}`,`ott:${T}`].join(","),o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveStrength=c,o.emissiveTexture=u,o.occlusionTexture=f,o.colorTextureTransform=Ge(s),o.normalTextureTransform=Ge(l),o.emissiveTextureTransform=Ge(m),o.occlusionTextureTransform=Ge(h),o.metallicRoughnessTextureTransform=Ge(a)}return o}_getInternalTexture(e,t=!1,r=1){const a=ke(e);if(!a)return null;const s=`${e.contentHash}/${r}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:De(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return oe(a)?(l=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(l=a,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new ve(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(e,r){if(null!=e.colorTexture){const t=1!==r.textureAlphaMode,o=this._getInternalTexture(e.colorTexture,t,r.textureAlphaMode);o?(r.textureId=o.id,r.textureAlphaPremultiplied=!!o.parameters.preMultiplyAlpha):r.textureId=void 0}if(e.normalTexture&&(r.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){const o=e.emissiveColor?.toUnitRGB();r.emissiveBaseColor=j(t(o[0]),t(o[1]),t(o[2]))}e.emissiveStrength&&(r.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&He(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ne(e.colorTextureTransform),t.normalTextureTransformMatrix=ne(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ne(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ne(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ne(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){const r=this._drivenProperties.color,o=this._drivenProperties.opacity;if(r)e.externalColor=S;else{const r=t??null;if(r){const t=r.toUnitRGBA();o&&(t[3]=1),e.externalColor=t}else e.externalColor=he}e.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,n=t.material?.alphaMode,a="blend"===n,s=!("opaque"===n)&&(Ne(e)||null!=r&&r.a<1||o?.transparent||a),i=this._materialProperties(e,t,s),l=this._materialInfoCache.byUid(i.uid);if(l)return this._setInternalMaterialTextureParameters(i,l.material.parameters),l.material;const c={uid:i.uid,material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},u=je({normalTexture:i.normalTexture,metallicRoughnessTexture:i.metallicRoughnessTexture,metallicFactor:i.metallic,roughnessFactor:i.roughness,emissiveTexture:i.emissiveTexture,emissiveFactor:i.emissiveColor?.toUnitRGB(),occlusionTexture:i.occlusionTexture}),m={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:A,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||c.isComponentTransparent};m.mrrFactors=u?Ae:[i.metallic,i.roughness,Re[2]],t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?0:2,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTextureAlphaMode(m,c),this._setInternalMaterialParameters(i,m,c);const f=new Ce(m,this._context);return c.material=f,this._materialInfoCache.set(i.uid,c),f}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return ce(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],l=[],c=t[0].transformation,u=a(i(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)$e(r,o,t,et),Ve(r,o,t,Qe,Xe,Ze),x(Qe,Qe,Xe),x(Qe,Qe,Ze),_(Qe,Qe,1/3),y(Qe,Qe,c),s.push(...Qe),T(et,et,u),b(et,et),v(Qe,Qe,et,n),s.push(...Qe),l.push(l.length),l.push(l.length)}return s.length?new be(this._debugFaceNormalMaterial,[["position",new Te(s,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],h=t[0].transformation,p=a(i(),h);"tangent"===r&&s(p,h);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Qe,s[e+0],s[e+1],s[e+2]),y(Qe,Qe,h),m.push(...Qe),g(Xe,l[r+0],l[r+1],l[r+2]),T(Xe,Xe,p),b(Xe,Xe),v(Qe,Qe,Xe,u),m.push(...Qe),f.push(f.length),f.push(f.length)}}return m.length?new be(o,[["position",new Te(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(ye.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new we({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=_e(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new me(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ue(this,c,null,se,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ie(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:h,renderCoordsHelper:p}=this._context,d=(e,t)=>le(e,h,r,p,t);return f.alignedSampledElevation=se(f,r,h.spatialReference,d,p),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return 1===a&&"local"===o||2===a&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=P(),r=g(at,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const a=1===t.reprojection?t.transformBeforeProject:null;a&&(n=Y(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=K(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,0,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,0,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return X(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=Z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,1,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,1,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return ee(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=We(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,s),h=this._createTangentBuffer(e,i,l,s),p=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:m,tangent:h}:this._transformOriginLocal(e,i,m,h);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:p,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===s.reprojection&&s.geometryTransformation?s.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),a=e.transform?.localMatrix??h;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:p(a)}}const s=l(f(),o);return c(s,s,a),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Je[0]=a.x,Je[1]=a.y,Je[2]=a.z??0;const s=f();B(e.spatialReference,Je,s,n),u(tt,s);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,tt);const h=r?r===l?new Float32Array(r.length):r:null,p=o?o===c?new Float32Array(o.length):o:null;return r&&h&&K(r,h,tt),o&&p&&Z(o,p,tt),{transformation:s,position:m,normal:h,tangent:p}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o&&o.length>0){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(F(o,ot),!O(ot,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,h=e.components??nt,p=new Array;let d=!1;const g=m(Qe,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of h){if(!this._validateFaces(e,m))return null;const t=Be(e,m);if(0===t.length)continue;const o=Ue(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new Te(n,t,3,!0)],["normal",new Te(o.normals,o.indices,3,!0)]];s&&u.push(["color",new Te(s,t,4,!0)]),i&&u.push(["symbolColor",new Te(i,G(t.length),4,!0)]),a&&u.push(["uv0",new Te(a,t,2,!0)]),c&&u.push(["tangent",new Te(c,t,4,!0)]);const h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new be(g,u,null,0,h);_.transformation=f,_.localOrigin=x,p.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),0===p.length?null:{geometries:p,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Ie{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Be(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Ue(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Fe(e,t,r,o);case"flat":return Ee(e,o);case"smooth":return Oe(e,o)}}function Ee(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=$e(e,t,n,et);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Ie(r,o,!1)}function Fe(e,t,r,o){if(null==t)return Ee(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){$e(e,o,a,et);for(let e=0;e<3;e++){const r=3*o[a+e];Qe[0]=t[r],Qe[1]=t[r+1],Qe[2]=t[r+2],M(et,Qe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Ie(t,o,n)}function Oe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=$e(e,t,a,et);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:P(),count:0},r[n]=s),x(s.normal,s.normal,o),s.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Ie(o,n,!1)}function Ve(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function $e(e,t,r,o){return Ve(e,t,r,Qe,Xe,Ze),w(Xe,Xe,Qe),w(Ze,Ze,Qe),C(Qe,Xe,Ze),b(o,Qe),o}function Ge(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function De(e="repeat"){if("string"==typeof e){const t=Le(e);return{s:t,t}}return{s:Le(e.horizontal),t:Le(e.vertical)}}function Le(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function Ne(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function He(e,t,r){t.diffuse=e.toUnitRGB(),t.opacity="opaque"===r.alphaMode?1:e.a}function ke(e){return e.data??e.url}function ze(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function qe(e){const{offset:t,scale:r,rotation:o}=e??Ke;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function We(e){return e.vertexAttributes.color}function Ye(e){return 1===(e.material?.color?.a??0)}const Ke=new H,Je=P(),Qe=P(),Xe=P(),Ze=P(),et=P(),tt=f(),rt=f(),ot=V(),nt=[new L],at=P();export{Se as Graphics3DMeshFillSymbolLayer};
2
+ import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as s,fromMat4 as a}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as g,add as x,scale as _,transformMat4 as y,transformMat3 as T,normalize as b,scaleAndAdd as v,subtract as w,cross as C,dot as j}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as M,ONES as R,ZEROS as A,create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as F,intersectsClippingArea as O,create as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as Y}from"../../../../chunks/vec3.js";import{transformNormal as K,transformVectorENUPlateCarree as J,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{isDrivenOpacityFallbackAlwaysOpaque as re}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{getEmissiveMode as oe}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as ne}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as se}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as ie}from"./ElevationAligners.js";import{needsElevationUpdates3D as le,evaluateElevationInfoAtPoint as ce}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as ue}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as me}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as fe}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as pe,nanFallbackColor as he}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as de,MeshFastUpdateProcessor as ge}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as xe}from"./SymbolComplexity.js";import{hasEdges as _e,createMaterial as ye}from"../support/edgeUtils.js";import{debugFlags as Te}from"../../support/debugFlags.js";import{Attribute as be}from"../../webgl-engine/lib/Attribute.js";import{Geometry as ve}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as we}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as Ce}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as je}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Me}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Re,advancedMRRFactors as Ae,schematicMRRFactors as Pe}from"../../webgl-engine/materials/pbrUtils.js";const Se=["mesh"];class Ie extends pe{constructor(e,t,r,o){super(e,t,r,o,re(t)),this._materialInfoCache=new de,this._fastUpdateProcessor=new ge,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){Te.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Me({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Me({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Me({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Se,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,le)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const s=this._context.renderCoordsHelper.spatialReference,a=rt,{origin:i,transform:l}=r;if(!B(t,g(Qe,i.x,i.y,i.z??0),a,s))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache)}e.updateFastLocalOrigin(a,l,this._context.localOriginFactory,!1);const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(a);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>ce(e,u,c,m,t);return e.alignedSampledElevation=ie(e,c,u.spatialReference,f,m,a),e.updateTransform(a,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=_e(this.symbolLayer)?2:0;return new xe({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:s,colorTextureTransform:a,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=qe(n),p=qe(s),h=We(a),d=qe(i),g=We(l);if(o.color=n,o.colorTexture=s,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveStrength:c,emissiveTexture:u,emissiveTextureTransform:m,occlusionTexture:f,occlusionTextureTransform:p}=t.material,h=qe(n),d=We(s),g=qe(i),x=qe(u),_=We(m),y=qe(f),T=We(p);o.uid=[o.uid,`mrm:${e}`,`mrr:${r}`,`mrt:${h}`,`mrtt:${d}`,`emuid:${g}`,`ems:${c}`,`etmuid:${x}`,`ett:${_}`,`otmuid:${y}`,`ott:${T}`].join(","),o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveStrength=c,o.emissiveTexture=u,o.occlusionTexture=f,o.colorTextureTransform=De(a),o.normalTextureTransform=De(l),o.emissiveTextureTransform=De(m),o.occlusionTextureTransform=De(p),o.metallicRoughnessTextureTransform=De(s)}return o}_getInternalTexture(e,t=!1,r=1){const s=ze(e);if(!s)return null;const a=`${e.contentHash}/${r}`;let i=this._textures.get(a);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:Le(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return ne(s)?(l=s.data,u.preMultiplyAlpha=!1,u.encoding=s.encoding):(l=s,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new we(l,u),this._textures.set(a,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(a)}),i}_setInternalMaterialTextureParameters(e,r){if(null!=e.colorTexture){const t=1!==r.textureAlphaMode,o=this._getInternalTexture(e.colorTexture,t,r.textureAlphaMode);o?(r.textureId=o.id,r.textureAlphaPremultiplied=!!o.parameters.preMultiplyAlpha):r.textureId=void 0}if(e.normalTexture&&(r.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){const o=e.emissiveColor?.toUnitRGB();r.emissiveBaseColor=M(t(o[0]),t(o[1]),t(o[2]))}e.emissiveStrength&&(r.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&ke(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=se(e.colorTextureTransform),t.normalTextureTransformMatrix=se(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=se(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=se(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=se(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){const r=this._drivenProperties.color,o=this._drivenProperties.opacity;if(r)e.externalColor=S;else{const r=t??null;if(r){const t=r.toUnitRGBA();o&&(t[3]=1),e.externalColor=t}else e.externalColor=he}e.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=oe(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,n=t.material?.alphaMode,s="blend"===n,a=!("opaque"===n)&&(He(e)||null!=r&&r.a<1||o?.transparent||s),i=this._materialProperties(e,t,a),l=this._materialInfoCache.byUid(i.uid);if(l)return this._setInternalMaterialTextureParameters(i,l.material.parameters),l.material;const c={uid:i.uid,material:null,isComponentTransparent:a,alphaMode:t.material?t.material.alphaMode:"opaque"},u=Re({normalTexture:i.normalTexture,metallicRoughnessTexture:i.metallicRoughnessTexture,metallicFactor:i.metallic,roughnessFactor:i.roughness,emissiveTexture:i.emissiveTexture,emissiveFactor:i.emissiveColor?.toUnitRGB(),occlusionTexture:i.occlusionTexture}),m={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:A,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||c.isComponentTransparent};m.mrrFactors=u?Pe:[i.metallic,i.roughness,Ae[2]],t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?0:2,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTextureAlphaMode(m,c),this._setInternalMaterialParameters(i,m,c);const f=new je(m,this._context);return c.material=f,this._materialInfoCache.set(i.uid,c),f}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return ue(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),a=[],l=[],c=t[0].transformation,u=s(i(),c);for(let s=0;s<r;s++){const e=t[s].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)Ge(r,o,t,et),$e(r,o,t,Qe,Xe,Ze),x(Qe,Qe,Xe),x(Qe,Qe,Ze),_(Qe,Qe,1/3),y(Qe,Qe,c),a.push(...Qe),T(et,et,u),b(et,et),v(Qe,Qe,et,n),a.push(...Qe),l.push(l.length),l.push(l.length)}return a.length?new ve(this._debugFaceNormalMaterial,[["position",new be(a,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=s(i(),p);"tangent"===r&&a(h,p);for(let s=0;s<l;s++){const e=t[s],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const a=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Qe,a[e+0],a[e+1],a[e+2]),y(Qe,Qe,p),m.push(...Qe),g(Xe,l[r+0],l[r+1],l[r+2]),T(Xe,Xe,h),b(Xe,Xe),v(Qe,Qe,Xe,u),m.push(...Qe),f.push(f.length),f.push(f.length)}}return m.length?new ve(o,[["position",new be(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const s=this._createGeometryInfo(n,t,o);if(null==s)return null;const{geometries:a,objectTransformation:i}=s;if(Te.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,a,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,a,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,a);e&&a.push(e),t&&a.push(t),r&&a.push(r)}const l=this._context.layerViewUid,c=new Ce({geometries:a,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=ye(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new fe(a[0].material,u,this._context.slicePlaneEnabled):null,f=new me(this,c,null,ie,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=le(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>ce(e,p,r,h,t);return f.alignedSampledElevation=ie(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:s}=n.state,a=n.spatialReference;return 1===s&&"local"===o||2===s&&q(a,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=P(),r=g(st,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const s=1===t.reprojection?t.transformBeforeProject:null;s&&(n=Y(new Float64Array(n.length),n,s));const{normal:a,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!a&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let s=n;const a=1===o.reprojection?o.transformBeforeProject:null;a&&(s=K(s,new Float32Array(s.length),a));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return s;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return s;if(null==r)return null;if(e.spatialReference.isGeographic){const e=s===n?new Float32Array(s.length):s;return J(s,0,r,e)}if(e.spatialReference.isWebMercator){const e=s===n?new Float32Array(s.length):s;return Q(s,0,r,e)}return s}if(null==r)return null;const l=s===n?new Float32Array(s.length):s,c=this._context.renderCoordsHelper.spatialReference;return X(s,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let s=n;const a=1===o.reprojection?o.transformBeforeProject:null;a&&(s=Z(s,new Float32Array(s.length),a));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return s;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return s;if(null==r)return null;if(e.spatialReference.isGeographic){const e=s===n?new Float32Array(s.length):s;return J(s,1,r,e)}if(e.spatialReference.isWebMercator){const e=s===n?new Float32Array(s.length):s;return Q(s,1,r,e)}return s}if(null==r)return null;const l=s===n?new Float32Array(s.length):s,c=this._context.renderCoordsHelper.spatialReference;return ee(s,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(s&&s.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const a=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,a),c=Ye(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,a),p=this._createTangentBuffer(e,i,l,a),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(a)?{transformation:a.objectTransformation,position:i,normal:m,tangent:p}:this._transformOriginLocal(e,i,m,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===a.reprojection&&a.geometryTransformation?a.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),s=e.transform?.localMatrix??p;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:h(s)}}const a=l(f(),o);return c(a,a,s),{reprojection:r,transformBeforeProject:a}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,s=e.origin;Je[0]=s.x,Je[1]=s.y,Je[2]=s.z??0;const a=f();B(e.spatialReference,Je,a,n),u(tt,a);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,tt);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===c?new Float32Array(o.length):o:null;return r&&p&&K(r,p,tt),o&&h&&Z(o,h,tt),{transformation:a,position:m,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o&&o.length>0){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(F(o,ot),!O(ot,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:s,colorBuffer:a,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,p=e.components??nt,h=new Array;let d=!1;const g=m(Qe,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of p){if(!this._validateFaces(e,m))return null;const t=Ue(e,m);if(0===t.length)continue;const o=Ee(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new be(n,t,3,!0)],["normal",new be(o.normals,o.indices,3,!0)]];a&&u.push(["color",new be(a,t,4,!0)]),i&&u.push(["symbolColor",new be(i,G(t.length),4,!0)]),s&&u.push(["uv0",new be(s,t,2,!0)]),c&&u.push(["tangent",new be(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new ve(g,u,null,0,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),0===h.length?null:{geometries:h,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Be{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Ue(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Ee(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Oe(e,t,r,o);case"flat":return Fe(e,o);case"smooth":return Ve(e,o)}}function Fe(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const s=Ge(e,t,n,et);for(let e=0;e<3;e++)r[n+e]=s[e],o[n+e]=n/3}return new Be(r,o,!1)}function Oe(e,t,r,o){if(null==t)return Fe(e,o);let n=!1;if(!r.trustSourceNormals)for(let s=0;s<o.length;s+=3){Ge(e,o,s,et);for(let e=0;e<3;e++){const r=3*o[s+e];Qe[0]=t[r],Qe[1]=t[r+1],Qe[2]=t[r+2],j(et,Qe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Be(t,o,n)}function Ve(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=Ge(e,t,s,et);for(let e=0;e<3;e++){const n=t[s+e];let a=r[n];a||(a={normal:P(),count:0},r[n]=a),x(a.normal,a.normal,o),a.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];n[s]=s}return new Be(o,n,!1)}function $e(e,t,r,o,n,s){const a=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[a],o[1]=e[a+1],o[2]=e[a+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}function Ge(e,t,r,o){return $e(e,t,r,Qe,Xe,Ze),w(Xe,Xe,Qe),w(Ze,Ze,Qe),C(Qe,Xe,Ze),b(o,Qe),o}function De(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function Le(e="repeat"){if("string"==typeof e){const t=Ne(e);return{s:t,t}}return{s:Ne(e.horizontal),t:Ne(e.vertical)}}function Ne(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function He(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function ke(e,t,r){t.diffuse=e.toUnitRGB(),t.opacity="opaque"===r.alphaMode?1:e.a}function ze(e){return e.data??e.url}function qe(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function We(e){const{offset:t,scale:r,rotation:o}=e??Ke;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function Ye(e){return e.vertexAttributes.color}const Ke=new H,Je=P(),Qe=P(),Xe=P(),Ze=P(),et=P(),tt=f(),rt=f(),ot=V(),nt=[new L],st=P();export{Ie as Graphics3DMeshFillSymbolLayer};