@arcgis/core 5.1.0-next.40 → 5.1.0-next.42

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 (83) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{0a094337e9922d989aa6.js → 0836964a65f76da35b5c.js} +45 -45
  3. package/assets/esri/core/workers/chunks/{0d321b3496adc640d96a.js → 093aa05fbde548bf9040.js} +1 -1
  4. package/assets/esri/core/workers/chunks/0b661b90f7ee3ae23425.js +1 -0
  5. package/assets/esri/core/workers/chunks/{1f5d9e5d4ddc623fd511.js → 385f1bb9164b2d488b2d.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{cce2d2c60d136e1bac75.js → 5f3f50fec18d1642fdf9.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{6258ae3d991ce652d97f.js → 7132420980f77b6a871b.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{85f309c1888c1c8411b1.js → 7380177f16d914fdbc63.js} +1 -1
  9. package/assets/esri/core/workers/chunks/73a008b48e29eb6f2064.js +2 -0
  10. package/assets/esri/core/workers/chunks/{19cbaeda71486df01d0f.js → 80bfb5e5d613d2c412bf.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{2c12b1488819c038c6b1.js → 8f12a559dbf284c21e2f.js} +1 -1
  12. package/assets/esri/core/workers/chunks/9a9b1250be3e20499d75.js +1 -0
  13. package/assets/esri/core/workers/chunks/c1cae45a159a5373ac00.js +1 -0
  14. package/assets/esri/core/workers/chunks/{78472f69053061a18967.js → dbedd246f4b584583f95.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{604f9e7228a66b6cf2f9.js → e63046a9567d84228644.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{e68d7aec0f095b6d743d.js → eff198e0c21c9767ffaa.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{5e9595eb6ae6a40e7265.js → f4ec2dcdc4bbf7dbcc94.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{e47dd011c06ab42c18e0.js → f835eea9f617556c7276.js} +1 -1
  19. package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
  20. package/chunks/Viewshed.glsl.js +2 -2
  21. package/chunks/vxlLayer.js +1 -1
  22. package/config.js +1 -1
  23. package/kernel.js +1 -1
  24. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  25. package/layers/graphics/sources/MemorySource.js +1 -1
  26. package/layers/raster/datasets/BaseRaster.js +1 -1
  27. package/layers/raster/datasets/FunctionRaster.js +1 -1
  28. package/layers/support/SceneModification.js +1 -1
  29. package/libs/vxl/VxlModule.js +1 -1
  30. package/package.json +2 -2
  31. package/support/revision.js +1 -1
  32. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  33. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  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/environment/EnvironmentManager.js +1 -1
  38. package/views/3d/interactive/manipulators/RotateManipulator.js +1 -1
  39. package/views/3d/layers/SceneLayerWorkerHandle.js +1 -1
  40. package/views/3d/terrain/TerrainRenderer.js +1 -1
  41. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  42. package/views/3d/webgl-engine/core/FBOCacheUsage.js +2 -0
  43. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  44. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  45. package/views/3d/webgl-engine/effects/WeatherFader.js +1 -1
  46. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizer.js +1 -1
  47. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  48. package/views/3d/webgl-engine/lib/CutFillComputationRenderNode.js +1 -1
  49. package/views/3d/webgl-engine/lib/Material.js +1 -1
  50. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  51. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  52. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  53. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  54. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  55. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  56. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  57. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  58. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  59. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  60. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  61. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  62. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  63. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  64. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  65. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  66. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  67. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  68. package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
  69. package/views/3d/webgl-engine/materials/TriangleTechniqueConfiguration.js +2 -0
  70. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  71. package/views/3d/webgl-engine/materials/WaterTechniqueConfiguration.js +1 -1
  72. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  73. package/views/3d/webgl-engine/shaders/CheckerBoardTechniqueConfiguration.js +1 -1
  74. package/views/3d/webgl-engine/shaders/ColorMaterialTechniqueConfiguration.js +1 -1
  75. package/views/3d/webgl-engine/shaders/ImageMaterialTechniqueConfiguration.js +1 -1
  76. package/views/3d/webgl-engine/shaders/PatternTechniqueConfiguration.js +1 -1
  77. package/views/3d/webgl-engine/shaders/SlicePlaneMaterialTechniqueConfiguration.js +1 -1
  78. package/views/3d/webgl-engine/shaders/Viewshed.glsl.js +1 -1
  79. package/assets/esri/core/workers/chunks/49d6249e98f023344e0a.js +0 -1
  80. package/assets/esri/core/workers/chunks/60e4312044fe40dfd41d.js +0 -2
  81. package/assets/esri/core/workers/chunks/92f6d637f4786ba0d3e3.js +0 -1
  82. package/assets/esri/core/workers/chunks/bf9b83e020ff08c51ac1.js +0 -1
  83. /package/assets/esri/core/workers/chunks/{60e4312044fe40dfd41d.js.LICENSE.txt → 73a008b48e29eb6f2064.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/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}from"../../../../core/promiseUtils.js";import{createVolume as n}from"../../../../core/quantity.js";import{whenOnce as s,watch as a,syncAndInitial as l}from"../../../../core/reactiveUtils.js";import{property as u,subclass as p}from"../../../../core/accessorSupport/decorators.js";import{e as c}from"../../../../chunks/earcut.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{scaleAndAdd as d,sqrDist as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as g,clone as f,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as _}from"../../../../core/support/UpdatingHandles.js";import v from"../../../../geometry/Multipoint.js";import{projectOrLoad as w}from"../../../../geometry/projectionUtils.js";import{e as b}from"../../../../chunks/containsOperator.js";import{e as j}from"../../../../chunks/convexHullOperator.js";import{e as R}from"../../../../chunks/simplifyOperator.js";import{e as E}from"../../../../chunks/unionOperator.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBoundingRect as T}from"../../../../geometry/projection/projectBoundingRect.js";import{fromExtent as G,intersects as L,create as O,empty as x}from"../../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as I}from"../../../../geometry/support/DoubleArray.js";import{t as H}from"../../../../chunks/vec3.js";import M from"../../../../symbols/support/ElevationInfo.js";import{logFailedGeometryProjectionError as D}from"../support/projectionUtils.js";import{VolumeMeasurementCutFillComputation as V}from"./VolumeMeasurementCutFillComputation.js";import{VolumeMeasurementInsufficientDataError as A,VolumeMeasurementPerimeterTooLargeError as P,VolumeMeasurementUnsupportedCoordinateSystemError as U,VolumeMeasurementUnsupportedLayerTransparencyError as N}from"./volumeMeasurementErrors.js";import{VolumeMeasurementRawResult as k}from"./VolumeMeasurementRawResult.js";import S from"./VolumeMeasurementResult.js";import{ElevationContext as F}from"../../layers/graphics/ElevationContext.js";import{getElevationAtPoint as W}from"../../support/ElevationProvider.js";import{polygonToRenderInfo as z}from"../../support/renderInfoUtils/polygon.js";import{IteratorPreorder as q}from"../../terrain/tileUtils.js";import{CutFillComputationRenderNode as B,TargetGeometryRenderInfo as Z}from"../../webgl-engine/lib/CutFillComputationRenderNode.js";import{isIntegratedMeshLayerView as J}from"../../../support/layerViewUtils.js";import{MeasurementWorkerHandle as K}from"../../../support/MeasurementWorkerHandle.js";let Q=class extends r{constructor(e){super(e),this._measurementWorkerHandle=new K,this._getElevationProvider=()=>this.view.elevationProvider,this.labelAnchors=null,this._updatingHandles=new _,this._rawResult=null,this._sufficientDataCoverage=!0,this._tileIterator=new q,this._intersectingObbs=[],this._intersectingTiles=[],this._debouncedUpdate=i(async(e,t,r,o)=>{if(!this._computationRenderNode.done)return;const{renderCoordsHelper:i}=this.view,n=new V({extent:t,localOrigin:r,renderCoordsHelper:i});this._computationRenderNode.update(n,o),this._determineDataCoverage(n);const[a]=await Promise.allSettled([this._measurementWorkerHandle.areaHorizontal(e,{returnLength:!0}),s(()=>this._computationRenderNode.done).then(()=>{this._updateLabelAnchors(n,this._computationRenderNode.getResult())})]);if(this.error)return void(this._rawResult=null);const l=this._computationRenderNode.getResult();this._updateResult(n,l,"fulfilled"===a.status?a.value:null)}),this._determineDataCoverage=e=>{const{elevationAlignedGeometry:t}=this,{frustum:r}=this._computationRenderNode,{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._computationRenderNode=new B({view:e}),this.addHandles([this._createElevationUpdateHandle(),a(()=>({projectedGeometry:this._projectedGeometry,localOrigin:this._localOrigin,targetGeometryRenderInfos:this._targetGeometryRenderInfos}),({projectedGeometry:e,localOrigin:t,targetGeometryRenderInfos:r})=>{const o=e?.extent;if(!(e&&o&&t&&r))return this._rawResult=null,void(this._sufficientDataCoverage=!0);this._updatingHandles.consumePromise(this._debouncedUpdate(e,o,t,r))},l)])}destroy(){this._updatingHandles.destroy(),this._computationRenderNode.destroy(),this._measurementWorkerHandle.destroy()}get _projectedGeometry(){const e=this.analysis.geometry;if(!e||!this.analysis.valid)return null;const t=R(e),r=w(t,this.view.spatialReference);return r.pending?(this._updatingHandles.consumePromise(r.pending),null):(t&&!r.geometry&&D(this.analysis,e.spatialReference,o.getLogger(this)),r.geometry)}get _localOrigin(){const e=this._projectedGeometry?.extent;return e?g(e.center.x,e.center.y,0):null}get elevationAlignedGeometry(){const e=this._projectedGeometry;if(!e)return null;const t=e.clone();return X(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 _targetGeometryRenderInfos(){const e=this.targetGeometry,t=this._projectedGeometry?.extent,r=this._localOrigin;if(!e||!t||!r)return null;const{elevationProvider:o,renderCoordsHelper:i}=this.view,n=z(e,o,i,F.fromElevationInfo(new M({mode:"absolute-height"}))),{polygons:s}=n;return s.map(e=>{const o=c(e.position,e.holeIndices,3),n=I(3*e.count),s=m(),a=m();return C(t.spatialReference,r,s,i.spatialReference),a[12]=-s[12],a[13]=-s[13],a[14]=-s[14],H(n,e.position,a),new Z(n,o)})}get updating(){return this._computationRenderNode.updating||this._updatingHandles.updating}get result(){const e=this._rawResult,{volume:t,area:r,length:o}=this.analysisViewData.effectiveDisplayUnits;return e?new S({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=>J(e)).filter(e=>e.visible&&!e.suspended)}get _insufficientDataError(){return this._sufficientDataCoverage?null:new A}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._perimeter,{maxPerimeterLocalWebMercator:i}=t;return null!=o&&o>i?new P:null}get _perimeterTooLargeGlobalError(){if(!this.view.state.isGlobal)return null;const e=this._perimeter,{maxPerimeterGlobal:r}=t;return null!=e&&e>r?new P:null}get _unsupportedCoordinateSystemError(){return this.view.state.isLocal&&this.view.spatialReference.isGeographic?new U:null}get _unsupportedLayerTransparencyError(){return this.view.map.ground&&this.view.map.ground.opacity<1?new N:null}get _perimeter(){if(!this._targetGeometryRenderInfos)return null;let e=null;for(const t of this._targetGeometryRenderInfos){const r=$(ee(t.positions));e=r?Math.max(e??0,r):e}return null!=e?e/this.view.renderCoordsHelper.unitInMeters:null}_createElevationUpdateHandle(){const e=e=>{const t=this._projectedGeometry?.extent;"ground"===e.context&&t&&(T(e.extent,e.spatialReference,re,this.view.spatialReference),G(t,oe),L(re,oe)&&(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:s},cameraNearFar:{near:a,far:l}}=e,u=i/t.width*(s/t.height),p=Y(t.cut.totalDepth,a,l)*u,c=Y(t.fill.totalDepth,a,l)*u,m=o**3;this._rawResult=new k({cutVolume:n(Math.abs(p*m),"cubic-meters"),fillVolume:n(c*m,"cubic-meters"),area:r?.area,perimeter:r?.length})}_updateLabelAnchors(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{labelDepth:p,labelCoords:c,totalDepth:m}=e,h=f(s);return 0!==m&&(d(h,h,l,r*(c[0]/t.width-.5)),d(h,h,a,o*(c[1]/t.height-.5))),d(h,h,u,-Y(p,i,n)),h};this.labelAnchors={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 v({spatialReference:o});if(this._intersectingObbs.forEach(e=>{if(te(e.radius,t)&&(e.getCorners(ne),n.points.length=0,ne.forEach(e=>{const t=r.fromRenderCoords(e,se,o);t&&n.addPoint([t[0],t[1]])}),n.points.length)){const e=j(n);"polygon"===e?.type&&i.push(e)}}),!i.length)return!1;const s=E(i);return!!s&&b(s,e)}_findIntersectingTerrainTiles(e){const{basemapTerrain:t}=this.view;if(this._intersectingTiles.length=0,!e.extent)return;G(e.extent,ie);const r=this._tileIterator;r.reset(t.rootTiles);for(let o=r.next();o;o=r.next())o.intersectsExtent(ie)?o.rendered&&this._intersectingTiles.push(o):r.skipSubtree()}_sufficientTerrainCoverage(e){const{basemapTerrain:{tilingScheme:t}}=this.view,r=256/t.pixelSize;return this._intersectingTiles.every(t=>te(t.radius*r,e))}};function X(e,t){t.hasZ=!0,t.rings.forEach(t=>t.forEach(t=>t[2]=W(e,t,"ground")??0))}function Y(e,t,r){return e*(r-t)+t}function $(e){if(!e)return null;let t=null,r=null,o=0;for(const i of e)t||(t=[i[0],i[1],i[2]??0]),r?o+=h(r,i):r=[0,0,0],r[0]=i[0],r[1]=i[1],r[2]=i[2];return t&&r&&(o+=h(r,t)),Math.sqrt(o)}function*ee(e){const t=y();for(let r=0;r<e.length;r+=3)t[0]=e[r],t[1]=e[r+1],t[2]=e[r+2],yield t}e([u()],Q.prototype,"_projectedGeometry",null),e([u()],Q.prototype,"_localOrigin",null),e([u()],Q.prototype,"_getElevationProvider",void 0),e([u()],Q.prototype,"elevationAlignedGeometry",null),e([u()],Q.prototype,"targetGeometry",null),e([u()],Q.prototype,"_targetGeometryRenderInfos",null),e([u({constructOnly:!0})],Q.prototype,"analysis",void 0),e([u({constructOnly:!0})],Q.prototype,"analysisViewData",void 0),e([u({constructOnly:!0})],Q.prototype,"view",void 0),e([u()],Q.prototype,"updating",null),e([u()],Q.prototype,"result",null),e([u()],Q.prototype,"labelAnchors",void 0),e([u()],Q.prototype,"error",null),e([u()],Q.prototype,"_imLayerViewsAffectingMeasurement",null),e([u()],Q.prototype,"_insufficientDataError",null),e([u()],Q.prototype,"_perimeterTooLargeError",null),e([u()],Q.prototype,"_perimeterTooLargeLocalError",null),e([u()],Q.prototype,"_perimeterTooLargeGlobalError",null),e([u()],Q.prototype,"_unsupportedCoordinateSystemError",null),e([u()],Q.prototype,"_unsupportedLayerTransparencyError",null),e([u()],Q.prototype,"_perimeter",null),e([u()],Q.prototype,"_computationRenderNode",void 0),e([u({readOnly:!0})],Q.prototype,"_updatingHandles",void 0),e([u()],Q.prototype,"_rawResult",void 0),e([u()],Q.prototype,"_sufficientDataCoverage",void 0),Q=e([p("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillController")],Q);const te=(e,t)=>e<(t.width+t.height)/2,re=x(),oe=x(),ie=O(),ne=new Array(8).fill(0).map(()=>y()),se=y();export{Q 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}from"../../../../core/promiseUtils.js";import{createVolume as n}from"../../../../core/quantity.js";import{whenOnce as s,watch as a,syncAndInitial as l}from"../../../../core/reactiveUtils.js";import{property as u,subclass as p}from"../../../../core/accessorSupport/decorators.js";import{e as m}from"../../../../chunks/earcut.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{scaleAndAdd as d,sqrDist as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as g,clone as f,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as _}from"../../../../core/support/UpdatingHandles.js";import v from"../../../../geometry/Multipoint.js";import{projectOrLoad as w}from"../../../../geometry/projectionUtils.js";import{e as j}from"../../../../chunks/containsOperator.js";import{e as R}from"../../../../chunks/convexHullOperator.js";import{e as b}from"../../../../chunks/simplifyOperator.js";import{e as E}from"../../../../chunks/unionOperator.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBoundingRect as x}from"../../../../geometry/projection/projectBoundingRect.js";import{fromExtent as T,intersects as G,create as L,empty as O}from"../../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as I}from"../../../../geometry/support/DoubleArray.js";import{t as D}from"../../../../chunks/vec3.js";import H from"../../../../symbols/support/ElevationInfo.js";import{logFailedGeometryProjectionError as M}from"../support/projectionUtils.js";import{VolumeMeasurementCutFillComputation as P}from"./VolumeMeasurementCutFillComputation.js";import{VolumeMeasurementInsufficientDataError as V,VolumeMeasurementPerimeterTooLargeError as U,VolumeMeasurementUnsupportedCoordinateSystemError as N,VolumeMeasurementUnsupportedLayerTransparencyError as k}from"./volumeMeasurementErrors.js";import{VolumeMeasurementRawResult as A}from"./VolumeMeasurementRawResult.js";import S from"./VolumeMeasurementResult.js";import{ElevationContext as F}from"../../layers/graphics/ElevationContext.js";import{getElevationAtPoint as W}from"../../support/ElevationProvider.js";import{polygonToRenderInfo as z}from"../../support/renderInfoUtils/polygon.js";import{IteratorPreorder as q}from"../../terrain/tileUtils.js";import{CutFillComputationRenderNode as B,TargetGeometryRenderInfo as Z}from"../../webgl-engine/lib/CutFillComputationRenderNode.js";import{isIntegratedMeshLayerView as J}from"../../../support/layerViewUtils.js";import{MeasurementWorkerHandle as K}from"../../../support/MeasurementWorkerHandle.js";let Q=class extends r{constructor(e){super(e),this._measurementWorkerHandle=new K,this._getElevationProvider=()=>this.view.elevationProvider,this.depthExtremaPositions=null,this._updatingHandles=new _,this._rawResult=null,this._sufficientDataCoverage=!0,this._tileIterator=new q,this._intersectingObbs=[],this._intersectingTiles=[],this._debouncedUpdate=i(async(e,t,r,o)=>{if(!this._computationRenderNode.done)return;const{renderCoordsHelper:i}=this.view,n=new P({extent:t,localOrigin:r,renderCoordsHelper:i});this._computationRenderNode.update(n,o),this._determineDataCoverage(n);const[a]=await Promise.allSettled([this._measurementWorkerHandle.areaHorizontal(e,{returnLength:!0}),s(()=>this._computationRenderNode.done).then(()=>{this._updateDepthExtremaPositions(n,this._computationRenderNode.getResult())})]);if(this.error)return void(this._rawResult=null);const l=this._computationRenderNode.getResult();this._updateResult(n,l,"fulfilled"===a.status?a.value:null)}),this._determineDataCoverage=e=>{const{elevationAlignedGeometry:t}=this,{frustum:r}=this._computationRenderNode,{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._computationRenderNode=new B({view:e}),this.addHandles([this._createElevationUpdateHandle(),a(()=>({projectedGeometry:this._projectedGeometry,localOrigin:this._localOrigin,targetGeometryRenderInfos:this._targetGeometryRenderInfos}),({projectedGeometry:e,localOrigin:t,targetGeometryRenderInfos:r})=>{const o=e?.extent;if(!(e&&o&&t&&r))return this._rawResult=null,void(this._sufficientDataCoverage=!0);this._updatingHandles.consumePromise(this._debouncedUpdate(e,o,t,r))},l)])}destroy(){this._updatingHandles.destroy(),this._computationRenderNode.destroy(),this._measurementWorkerHandle.destroy()}get _projectedGeometry(){const e=this.analysis.geometry;if(!e||!this.analysis.valid)return null;const t=b(e),r=w(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?g(e.center.x,e.center.y,0):null}get elevationAlignedGeometry(){const e=this._projectedGeometry;if(!e)return null;const t=e.clone();return X(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 _targetGeometryRenderInfos(){const e=this.targetGeometry,t=this._projectedGeometry?.extent,r=this._localOrigin;if(!e||!t||!r)return null;const{elevationProvider:o,renderCoordsHelper:i}=this.view,n=z(e,o,i,F.fromElevationInfo(new H({mode:"absolute-height"}))),{polygons:s}=n;return s.map(e=>{const o=m(e.position,e.holeIndices,3),n=I(3*e.count),s=c(),a=c();return C(t.spatialReference,r,s,i.spatialReference),a[12]=-s[12],a[13]=-s[13],a[14]=-s[14],D(n,e.position,a),new Z(n,o)})}get updating(){return this._computationRenderNode.updating||this._updatingHandles.updating}get result(){const e=this._rawResult,{volume:t,area:r,length:o}=this.analysisViewData.effectiveDisplayUnits;return e?new S({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=>J(e)).filter(e=>e.visible&&!e.suspended)}get _insufficientDataError(){return this._sufficientDataCoverage?null:new V}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._perimeter,{maxPerimeterLocalWebMercator:i}=t;return null!=o&&o>i?new U:null}get _perimeterTooLargeGlobalError(){if(!this.view.state.isGlobal)return null;const e=this._perimeter,{maxPerimeterGlobal:r}=t;return null!=e&&e>r?new U:null}get _unsupportedCoordinateSystemError(){return this.view.state.isLocal&&this.view.spatialReference.isGeographic?new N:null}get _unsupportedLayerTransparencyError(){return this.view.map.ground&&this.view.map.ground.opacity<1?new k:null}get _perimeter(){if(!this._targetGeometryRenderInfos)return null;let e=null;for(const t of this._targetGeometryRenderInfos){const r=$(ee(t.positions));e=r?Math.max(e??0,r):e}return null!=e?e/this.view.renderCoordsHelper.unitInMeters:null}_createElevationUpdateHandle(){const e=e=>{const t=this._projectedGeometry?.extent;"ground"===e.context&&t&&(x(e.extent,e.spatialReference,re,this.view.spatialReference),T(t,oe),G(re,oe)&&(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:s},cameraNearFar:{near:a,far:l}}=e,u=i/t.width*(s/t.height),p=Y(t.cut.totalDepth,a,l)*u,m=Y(t.fill.totalDepth,a,l)*u,c=o**3;this._rawResult=new A({cutVolume:n(Math.abs(p*c),"cubic-meters"),fillVolume:n(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,g=f(s);return 0!==h&&(d(g,g,l,r*(m/t.width-.5)),d(g,g,a,o*(c/t.height-.5))),d(g,g,u,-Y(p,i,n)),g};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 v({spatialReference:o});if(this._intersectingObbs.forEach(e=>{if(te(e.radius,t)&&(e.getCorners(ne),n.points.length=0,ne.forEach(e=>{const t=r.fromRenderCoords(e,se,o);t&&n.addPoint([t[0],t[1]])}),n.points.length)){const e=R(n);"polygon"===e?.type&&i.push(e)}}),!i.length)return!1;const s=E(i);return!!s&&j(s,e)}_findIntersectingTerrainTiles(e){const{basemapTerrain:t}=this.view;if(this._intersectingTiles.length=0,!e.extent)return;T(e.extent,ie);const r=this._tileIterator;r.reset(t.rootTiles);for(let o=r.next();o;o=r.next())o.intersectsExtent(ie)?o.rendered&&this._intersectingTiles.push(o):r.skipSubtree()}_sufficientTerrainCoverage(e){const{basemapTerrain:{tilingScheme:t}}=this.view,r=256/t.pixelSize;return this._intersectingTiles.every(t=>te(t.radius*r,e))}};function X(e,t){t.hasZ=!0,t.rings.forEach(t=>t.forEach(t=>t[2]=W(e,t,"ground")??0))}function Y(e,t,r){return e*(r-t)+t}function $(e){if(!e)return null;let t=null,r=null,o=0;for(const i of e)t||(t=[i[0],i[1],i[2]??0]),r?o+=h(r,i):r=[0,0,0],r[0]=i[0],r[1]=i[1],r[2]=i[2];return t&&r&&(o+=h(r,t)),Math.sqrt(o)}function*ee(e){const t=y();for(let r=0;r<e.length;r+=3)t[0]=e[r],t[1]=e[r+1],t[2]=e[r+2],yield t}e([u()],Q.prototype,"_projectedGeometry",null),e([u()],Q.prototype,"_localOrigin",null),e([u()],Q.prototype,"_getElevationProvider",void 0),e([u()],Q.prototype,"elevationAlignedGeometry",null),e([u()],Q.prototype,"targetGeometry",null),e([u()],Q.prototype,"_targetGeometryRenderInfos",null),e([u({constructOnly:!0})],Q.prototype,"analysis",void 0),e([u({constructOnly:!0})],Q.prototype,"analysisViewData",void 0),e([u({constructOnly:!0})],Q.prototype,"view",void 0),e([u()],Q.prototype,"updating",null),e([u()],Q.prototype,"result",null),e([u()],Q.prototype,"depthExtremaPositions",void 0),e([u()],Q.prototype,"error",null),e([u()],Q.prototype,"_imLayerViewsAffectingMeasurement",null),e([u()],Q.prototype,"_insufficientDataError",null),e([u()],Q.prototype,"_perimeterTooLargeError",null),e([u()],Q.prototype,"_perimeterTooLargeLocalError",null),e([u()],Q.prototype,"_perimeterTooLargeGlobalError",null),e([u()],Q.prototype,"_unsupportedCoordinateSystemError",null),e([u()],Q.prototype,"_unsupportedLayerTransparencyError",null),e([u()],Q.prototype,"_perimeter",null),e([u()],Q.prototype,"_computationRenderNode",void 0),e([u({readOnly:!0})],Q.prototype,"_updatingHandles",void 0),e([u()],Q.prototype,"_rawResult",void 0),e([u()],Q.prototype,"_sufficientDataCoverage",void 0),Q=e([p("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillController")],Q);const te=(e,t)=>e<(t.width+t.height)/2,re=O(),oe=O(),ie=L(),ne=new Array(8).fill(0).map(()=>y()),se=y();export{Q as VolumeMeasurementCutFillController};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/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 r from"../../../../core/Accessor.js";import{equals as n}from"../../../../core/arrayUtils.js";import{cyclicalPI as l}from"../../../../core/Cyclical.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import{formatDecimal as c,preferredVolumePrecision as u}from"../../../../core/quantityFormatUtils.js";import{watch as m,initial as d}from"../../../../core/reactiveUtils.js";import{adaptiveVolumeUnit as h}from"../../../../core/units.js";import{property as p,subclass as g}from"../../../../core/accessorSupport/decorators.js";import{e as y}from"../../../../chunks/earcut.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 b,dot as L}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as C,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as G}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{newDoubleArray as V}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as P}from"../../../../geometry/support/Indices.js";import{angleAroundAxis as A}from"../../../../geometry/support/vector.js";import{t as x}from"../../../../chunks/vec3.js";import R from"../../../../symbols/support/ElevationInfo.js";import{LabelVisualElement as M}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as O}from"../../interactive/visualElements/LineVisualElement.js";import{OutlineVisualElement as D}from"../../interactive/visualElements/OutlineVisualElement.js";import{EuclideanSegment as F}from"../../interactive/visualElements/support/Segment.js";import{ElevationContext as U}from"../../layers/graphics/ElevationContext.js";import{extrudePolygon as S}from"../../layers/graphics/extrudeUtils.js";import{polygonToRenderInfo as E}from"../../support/renderInfoUtils/polygon.js";import{CutFillVisualizationRenderNode as N,VolumeGeometry as B}from"../../webgl-engine/lib/CutFillVisualizationRenderNode.js";import{createStipplePatternSimple as H}from"../../webgl-engine/materials/lineStippleUtils.js";let T=class extends r{get visible(){return this.analysisViewData.visible&&null!=this.analysisViewData.elevationAlignedGeometry&&null!=this.analysisViewData.targetGeometry}get updating(){return this.loadingMessages}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,{labelAnchors:t,targetGeometry:i}=this.analysisViewData,{targetElevationRange:s}=o;if(!i||!t)return{cut:s,fill:-s};let r=-1/0;for(const o of i.rings)for(const e of o)r=Math.max(r,e[2]);const n=1,l=e.getAltitude(t.fill);return{cut:s,fill:Math.min(l-r,0)-n}}constructor(e){super(e),this.unitsMessages=null,this.messages=null,this.loadingMessages=!0,this._elevationContext=U.fromElevationInfo(new R({mode:"absolute-height"})),this._projectionLines=[]}initialize(){const{view:e}=this,i={view:e,isDecoration:!0},s=o,r={...i,width:s.geometryOutlineWidth};this._elevationAlignedGeometry=new D({...r,isDraped:!0,color:s.geometryOutlineColor.toUnitRGBA()}),this._targetGeometry=new D(r);const n={...i,attached:!0,width:s.projectionLineWidth,renderOccluded:4,polygonOffset:!0},l={...n,stipplePattern:H(s.projectionLineStippleSize)},a=s.cutProjectionLineColor.toUnitRGBA(),c=s.fillProjectionLineColor.toUnitRGBA();this._cutProjectionLines=new O({...n,color:a}),this._occludedCutProjectionLines=new O({...l,color:a}),this._fillProjectionLines=new O({...n,color:c}),this._occludedFillProjectionLines=new O({...l,color:c});const u={...i,attached:!0};this._cutVolumeLabel=new M({...u,distance:s.labelDistance}),this._fillVolumeLabel=new M({...u,distance:-s.labelDistance}),this._renderNode=new N({view:e,cutColor:s.cutColor,fillColor:s.fillColor,borderColor:s.geometryOutlineColor}),this.addHandles([m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry}),({elevationAlignedGeometry:e,targetGeometry:t})=>{this._elevationAlignedGeometry.geometry=e,this._targetGeometry.geometry=t},d),m(()=>({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._renderNode.measureType=i},d),m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry,visible:this.visible}),({elevationAlignedGeometry:e,targetGeometry:t,visible:i})=>this._updateProjectionLines(e,t,i),d),m(()=>({interactive:this.analysisViewData.interactive,accentColor:this.view.effectiveTheme.accentColor,hasResult:!!this.analysisViewData.result}),({interactive:e,accentColor:t,hasResult:i})=>{this._updateColors(e,t,i)},d),m(()=>[this.analysisViewData.targetGeometry,this._extrusionHeights],()=>this._updateCutFillGeometry(),d),m(()=>this.visible&&this.view.state.camera.aboveGround&&!this.hasUnsupportedError,e=>this._updateCutFillVisibility(e),d),m(()=>{const{messages:e,unitsMessages:t,visible:i,analysisViewData:s}=this;return{labelAnchors:s.labelAnchors,effectiveDisplayUnits:s.effectiveDisplayUnits,messages:e,unitsMessages:t,result:s.result,visible:i&&!!s.result}},e=>this._updateLabels(e)),m(()=>this.view.state.camera,e=>this._updateProjectionLineOcclusion(e),d),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._renderNode.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=[],r=[],l=[],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],r=f(C(),o[0],o[1],o[2]);s.toRenderCoords(r,u,r);const n=t.rings[m][e],l=f(C(),n[0],n[1],n[2]);s.toRenderCoords(l,u,l);const a=new F(r,l);p.push(a)}const g=this.view.state.camera;for(let s=0;s<p.length;++s){const i=p[s],n=p[0===s?p.length-1:s-1],u=p[s===p.length-1?0:s+1],d=e.rings[m][s],h=t.rings[m][s],y=d[2]>h[2],_=new I(i,n,u,y);o.push(_),_.updateOccluded(g);const f=_.isOccluded;y?(f?l:r).push(i):(f?c:a).push(i)}}this._projectionLines=o,this._cutProjectionLines.setGeometryFromSegments(r),this._occludedCutProjectionLines.setGeometryFromSegments(l),this._fillProjectionLines.setGeometryFromSegments(a),this._occludedFillProjectionLines.setGeometryFromSegments(c)}_updateProjectionLineOcclusion(e){const t=[],i=[],s=[],o=[];let r=!1,n=!1;for(const l of this._projectionLines){l.updateOccluded(e)&&(r||=l.isCut,n||=!l.isCut);const a=l.isOccluded;(l.isCut?a?i:t:a?o:s).push(l.segment)}n&&(this._fillProjectionLines.setGeometryFromSegments(s),this._occludedFillProjectionLines.setGeometryFromSegments(o)),r&&(this._cutProjectionLines.setGeometryFromSegments(t),this._occludedCutProjectionLines.setGeometryFromSegments(i))}_updateColors(e,t,i){const{geometryOutlineColor:s,cutColor:r,fillColor:n,cutColorMuted:l,fillColorMuted:a,cutProjectionLineColor:c,fillProjectionLineColor:u}=o;if(this._renderNode.cutColor=i?r:l,this._renderNode.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._renderNode.borderColor=t}else{this._targetGeometry.color=s.toUnitRGBA();const e=(i?c:l).toUnitRGBA();this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e;const t=(i?u:a).toUnitRGBA();this._fillProjectionLines.color=t,this._occludedFillProjectionLines.color=t,this._renderNode.borderColor=s}}_updateLabels(e){const{effectiveDisplayUnits:t,labelAnchors:s,messages:o,unitsMessages:r,result:n,visible:l}=e;if(this._cutVolumeLabel.visible=l,this._fillVolumeLabel.visible=l,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==r)return this._cutVolumeLabel.text="-",void(this._fillVolumeLabel.text="-");const a=t.volume,c=i(o.labels.cut,{volume:z(r,n.cutVolume,a)}),u=i(o.labels.fill,{volume:z(r,n.fillVolume,a)});this._cutVolumeLabel.text=c,this._fillVolumeLabel.text=u}_updateCutFillVisibility(e){e?this._renderNode.enable():this._renderNode.disable()}_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,r=w(o.x,o.y,0),n=C();e.toRenderCoords(r,t.spatialReference,n);const l=this._getExtrudedVolumes(t,i,r,n),a=this._getExtrudedVolumes(t,s,r,n);this._renderNode.updateGeometries(l,a,n)}_getExtrudedVolumes(e,t,i,s){const{renderCoordsHelper:o,spatialReference:r,elevationProvider:n}=this.view,l=C(),a=1===o.viewingMode;o.worldUpAtPosition(s,l);const c=E(e,n,o,this._elevationContext),{polygons:u,mapPositions:m,position:d}=c;return u.map(e=>{const s=e.count,n=y(e.mapPositions,e.holeIndices,3),c=n.length,u=6*s,h=P(u+c),p=P(c),g=V(3*u),f=V(3*u);S(d,m,n,e,g,null,f,null,h,p,t,l,a);const v=_(),j=_();if(G(r,i,v,o.spatialReference),j[12]=-v[12],j[13]=-v[13],j[14]=-v[14],x(g,g,j),"stockpile"===this.analysis.measureType)for(let t=0;t<f.length;t+=3)f[t]=l[0],f[t+1]=l[1],f[t+2]=l[2];return new B(g,p,h,f)})}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 z(e,t,i){if(!t||!e)return null;const s=h(t.value,t.unit,i),o=u(s);return c(e,t,s,o)}e([p({constructOnly:!0})],T.prototype,"view",void 0),e([p({constructOnly:!0})],T.prototype,"analysis",void 0),e([p({constructOnly:!0})],T.prototype,"analysisViewData",void 0),e([p()],T.prototype,"unitsMessages",void 0),e([p()],T.prototype,"messages",void 0),e([p()],T.prototype,"loadingMessages",void 0),e([p({readOnly:!0})],T.prototype,"visible",null),e([p()],T.prototype,"updating",null),e([p()],T.prototype,"hasUnsupportedError",null),e([p()],T.prototype,"_extrusionHeights",null),T=e([g("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillVisualization")],T);class I{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(k,j(k,e.endRenderSpace,e.startRenderSpace));v(this._n1,b(this._n1,o,v(W,j(W,t.startRenderSpace,e.startRenderSpace)))),v(this._n2,b(this._n2,o,v(W,j(W,e.startRenderSpace,i.startRenderSpace)))),this._isConvex=l.normalize(A(this._n1,this._n2,o))<0}get isOccluded(){return this._isOccluded}updateOccluded(e){j(k,this.segment.startRenderSpace,e.eye);const t=L(this._n1,k)<0,i=L(this._n2,k)<0,s=this._isOccluded;return this._isOccluded=this._isConvex?t&&i:t||i,this._isOccluded!==s}}const k=C(),W=C();export{T 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 r from"../../../../core/Accessor.js";import{equals as n}from"../../../../core/arrayUtils.js";import{cyclicalPI as l}from"../../../../core/Cyclical.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import{formatDecimal as c,preferredVolumePrecision as u}from"../../../../core/quantityFormatUtils.js";import{watch as m,initial as d}from"../../../../core/reactiveUtils.js";import{adaptiveVolumeUnit as h}from"../../../../core/units.js";import{property as p,subclass as g}from"../../../../core/accessorSupport/decorators.js";import{e as y}from"../../../../chunks/earcut.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 w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as P}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{newDoubleArray as G}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as V}from"../../../../geometry/support/Indices.js";import{angleAroundAxis as x}from"../../../../geometry/support/vector.js";import{t as R}from"../../../../chunks/vec3.js";import A from"../../../../symbols/support/ElevationInfo.js";import{LabelVisualElement as M}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as O}from"../../interactive/visualElements/LineVisualElement.js";import{OutlineVisualElement as D}from"../../interactive/visualElements/OutlineVisualElement.js";import{EuclideanSegment as F}from"../../interactive/visualElements/support/Segment.js";import{ElevationContext as E}from"../../layers/graphics/ElevationContext.js";import{extrudePolygon as U}from"../../layers/graphics/extrudeUtils.js";import{polygonToRenderInfo as S}from"../../support/renderInfoUtils/polygon.js";import{CutFillVisualizationRenderNode as N,VolumeGeometry as B}from"../../webgl-engine/lib/CutFillVisualizationRenderNode.js";import{createStipplePatternSimple as H}from"../../webgl-engine/materials/lineStippleUtils.js";let T=class extends r{get visible(){return this.analysisViewData.visible&&null!=this.analysisViewData.elevationAlignedGeometry&&null!=this.analysisViewData.targetGeometry}get updating(){return this.loadingMessages}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 r=-1/0;for(const o of i.rings)for(const e of o)r=Math.max(r,e[2]);const n=1,l=e.getAltitude(t.fill);return{cut:s,fill:Math.min(l-r,0)-n}}constructor(e){super(e),this.unitsMessages=null,this.messages=null,this.loadingMessages=!0,this._elevationContext=E.fromElevationInfo(new A({mode:"absolute-height"})),this._projectionLines=[]}initialize(){const{view:e}=this,i={view:e,isDecoration:!0},s=o,r={...i,width:s.geometryOutlineWidth};this._elevationAlignedGeometry=new D({...r,isDraped:!0,color:s.geometryOutlineColor.toUnitRGBA()}),this._targetGeometry=new D(r);const n={...i,attached:!0,width:s.projectionLineWidth,renderOccluded:4,polygonOffset:!0},l={...n,stipplePattern:H(s.projectionLineStippleSize)},a=s.cutProjectionLineColor.toUnitRGBA(),c=s.fillProjectionLineColor.toUnitRGBA();this._cutProjectionLines=new O({...n,color:a}),this._occludedCutProjectionLines=new O({...l,color:a}),this._fillProjectionLines=new O({...n,color:c}),this._occludedFillProjectionLines=new O({...l,color:c});const u={...i,attached:!0};this._cutVolumeLabel=new M({...u,distance:s.labelDistance}),this._fillVolumeLabel=new M({...u,distance:-s.labelDistance}),this._renderNode=new N({view:e,cutColor:s.cutColor,fillColor:s.fillColor,borderColor:s.geometryOutlineColor}),this.addHandles([m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry}),({elevationAlignedGeometry:e,targetGeometry:t})=>{this._elevationAlignedGeometry.geometry=e,this._targetGeometry.geometry=t},d),m(()=>({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._renderNode.measureType=i},d),m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry,visible:this.visible}),({elevationAlignedGeometry:e,targetGeometry:t,visible:i})=>this._updateProjectionLines(e,t,i),d),m(()=>({interactive:this.analysisViewData.interactive,accentColor:this.view.effectiveTheme.accentColor,hasResult:!!this.analysisViewData.result}),({interactive:e,accentColor:t,hasResult:i})=>{this._updateColors(e,t,i)},d),m(()=>[this.analysisViewData.targetGeometry,this._extrusionHeights],()=>this._updateCutFillGeometry(),d),m(()=>this.visible&&this.view.state.camera.aboveGround&&!this.hasUnsupportedError,e=>this._updateCutFillVisibility(e),d),m(()=>{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)),m(()=>this.view.state.camera,e=>this._updateProjectionLineOcclusion(e),d),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._renderNode.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=[],r=[],l=[],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],r=f(C(),o[0],o[1],o[2]);s.toRenderCoords(r,u,r);const n=t.rings[m][e],l=f(C(),n[0],n[1],n[2]);s.toRenderCoords(l,u,l);const a=new F(r,l);p.push(a)}const g=this.view.state.camera;for(let s=0;s<p.length;++s){const i=p[s],n=p[0===s?p.length-1:s-1],u=p[s===p.length-1?0:s+1],d=e.rings[m][s],h=t.rings[m][s],y=d[2]>h[2],_=new I(i,n,u,y);o.push(_),_.updateOccluded(g);const f=_.isOccluded;y?(f?l:r).push(i):(f?c:a).push(i)}}this._projectionLines=o,this._cutProjectionLines.setGeometryFromSegments(r),this._occludedCutProjectionLines.setGeometryFromSegments(l),this._fillProjectionLines.setGeometryFromSegments(a),this._occludedFillProjectionLines.setGeometryFromSegments(c)}_updateProjectionLineOcclusion(e){const t=[],i=[],s=[],o=[];let r=!1,n=!1;for(const l of this._projectionLines){l.updateOccluded(e)&&(r||=l.isCut,n||=!l.isCut);const a=l.isOccluded;(l.isCut?a?i:t:a?o:s).push(l.segment)}n&&(this._fillProjectionLines.setGeometryFromSegments(s),this._occludedFillProjectionLines.setGeometryFromSegments(o)),r&&(this._cutProjectionLines.setGeometryFromSegments(t),this._occludedCutProjectionLines.setGeometryFromSegments(i))}_updateColors(e,t,i){const{geometryOutlineColor:s,cutColor:r,fillColor:n,cutColorMuted:l,fillColorMuted:a,cutProjectionLineColor:c,fillProjectionLineColor:u}=o;if(this._renderNode.cutColor=i?r:l,this._renderNode.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._renderNode.borderColor=t}else{this._targetGeometry.color=s.toUnitRGBA();const e=(i?c:l).toUnitRGBA();this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e;const t=(i?u:a).toUnitRGBA();this._fillProjectionLines.color=t,this._occludedFillProjectionLines.color=t,this._renderNode.borderColor=s}}_updateLabels(e){const{effectiveDisplayUnits:t,depthExtremaPositions:s,messages:o,unitsMessages:r,result:n,visible:l}=e;if(this._cutVolumeLabel.visible=l,this._fillVolumeLabel.visible=l,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==r)return this._cutVolumeLabel.text="-",void(this._fillVolumeLabel.text="-");const a=t.volume,c=i(o.labels.cut,{volume:z(r,n.cutVolume,a)}),u=i(o.labels.fill,{volume:z(r,n.fillVolume,a)});this._cutVolumeLabel.text=c,this._fillVolumeLabel.text=u}_updateCutFillVisibility(e){e?this._renderNode.enable():this._renderNode.disable()}_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,r=w(o.x,o.y,0),n=C();e.toRenderCoords(r,t.spatialReference,n);const l=this._getExtrudedVolumes(t,i,r,n),a=this._getExtrudedVolumes(t,s,r,n);this._renderNode.updateGeometries(l,a,n)}_getExtrudedVolumes(e,t,i,s){const{renderCoordsHelper:o,spatialReference:r,elevationProvider:n}=this.view,l=C(),a=1===o.viewingMode;o.worldUpAtPosition(s,l);const c=S(e,n,o,this._elevationContext),{polygons:u,mapPositions:m,position:d}=c;return u.map(e=>{const s=e.count,n=y(e.mapPositions,e.holeIndices,3),c=n.length,u=6*s,h=V(u+c),p=V(c),g=G(3*u),f=G(3*u);U(d,m,n,e,g,null,f,null,h,p,t,l,a);const v=_(),j=_();if(P(r,i,v,o.spatialReference),j[12]=-v[12],j[13]=-v[13],j[14]=-v[14],R(g,g,j),"stockpile"===this.analysis.measureType)for(let t=0;t<f.length;t+=3)f[t]=l[0],f[t+1]=l[1],f[t+2]=l[2];return new B(g,p,h,f)})}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 z(e,t,i){if(!t||!e)return null;const s=h(t.value,t.unit,i),o=u(s);return c(e,t,s,o)}e([p({constructOnly:!0})],T.prototype,"view",void 0),e([p({constructOnly:!0})],T.prototype,"analysis",void 0),e([p({constructOnly:!0})],T.prototype,"analysisViewData",void 0),e([p()],T.prototype,"unitsMessages",void 0),e([p()],T.prototype,"messages",void 0),e([p()],T.prototype,"loadingMessages",void 0),e([p({readOnly:!0})],T.prototype,"visible",null),e([p()],T.prototype,"updating",null),e([p()],T.prototype,"hasUnsupportedError",null),e([p()],T.prototype,"_extrusionHeights",null),T=e([g("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillVisualization")],T);class I{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(k,j(k,e.endRenderSpace,e.startRenderSpace));v(this._n1,L(this._n1,o,v(W,j(W,t.startRenderSpace,e.startRenderSpace)))),v(this._n2,L(this._n2,o,v(W,j(W,e.startRenderSpace,i.startRenderSpace)))),this._isConvex=l.normalize(x(this._n1,this._n2,o))<0}get isOccluded(){return this._isOccluded}updateOccluded(e){j(k,this.segment.startRenderSpace,e.eye);const t=b(this._n1,k)<0,i=b(this._n2,k)<0,s=this._isOccluded;return this._isOccluded=this._isConvex?t&&i:t||i,this._isOccluded!==s}}const k=C(),W=C();export{T as VolumeMeasurementCutFillVisualization};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/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 a 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 a{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",n=i(this.view.spatialReference);if(null!=l&&null!=n)return s(l,r,n);const a=this.elevationAlignedGeometry?.extent;return null==a?.zmin||null==a?.zmax?null:(a.zmax+a.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 labelAnchors(){return this._analysisController?.labelAnchors}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,"labelAnchors",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 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};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../core/Evented.js";import"../../../core/has.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{watch as n,sync as r,syncAndInitial as o,when as s}from"../../../core/reactiveUtils.js";import{property as a,subclass as h}from"../../../core/accessorSupport/decorators.js";import{equals as l,copy as c,scale as g,lerp as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as p,create as m,fromValues as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{isEarth as _}from"../../../geometry/ellipsoidUtils.js";import{isLoadedOrLoadFor as v}from"../../../geometry/projectionUtils.js";import f from"../../../geometry/SpatialReference.js";import{projectPointToVector as w}from"../../../geometry/projection/projectPointToVector.js";import{getGCSForPlanet as P}from"../../../geometry/support/planetGCSUtils.js";import{positionToTimezoneInfo as y}from"../support/earthUtils.js";import{ColorAndIntensity as b,computeColorAndIntensity as T,computeVirtualLightDirection as L,computeShadowsEnabled as j}from"../support/sunUtils.js";import{WeatherFader as G}from"../webgl-engine/effects/WeatherFader.js";import{MainLight as U,AmbientLight as H,FillLight as C}from"../webgl-engine/lighting/Lightsources.js";let E=class extends t{constructor(e){super(e),this.view=null,this._tmpLightParameters=new b,this._defaultLightParameters=new b,this._tmpDate=new Date,this._tmpTz={hours:0,minutes:0,seconds:0},this._viewHandlesKey="viewHandles",this._trackingEnabled=!1,this._mainLight=new U,this._ambientLight=new H,this._moonLight=new C,this._disableWeather=!1,this._renderer=null,this._resetReferencePosition()}destroy(){this.disconnectView()}get updating(){return!!this._renderer?.updating||!this._canProjectCameraPosition}get weatherEnabled(){return null!=this._renderer&&null!=this.view&&this.view.environment.atmosphereEnabled&&!this._disableWeather&&1===this.view.state?.viewingMode&&_(this.view.spatialReference)}get _weatherAvailable(){return this.weatherEnabled&&this._renderer?.weatherAvailable}get referencePositionGeographic(){return this._referencePositionGeographic}get _canProjectCameraPosition(){const e=this.view?.stateManager?.camera?.position?.spatialReference??f.WGS84,t=P(e);return v(e,t)}connectView(e){if(this._renderer)return;this.view=e,this._renderer=new G({view:e});const t=()=>this._updateRenderParameters(),i=()=>this._cameraHandler();this.addHandles([n(()=>e.environment.lighting,e=>this._updateLightingHandler(e),r),n(()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null,e=>this._lightingDateHandler(e),r),n(()=>e.environment.lighting.directShadowsEnabled,t,r),n(()=>e.spatialReference,()=>this._resetReferencePosition(!0),r),n(()=>[e.environment.weather.type,this.weatherEnabled],()=>this._updateLighting(null,1),r),n(()=>e.environment,e=>e.setComputeWeatherAvailable(()=>this._weatherAvailable),o),n(()=>e.viewingMode,()=>this._resetReferencePosition(!0),o),n(()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled,e=>this._updateCameraTracking(e),o),n(()=>e.state.camera,i,o),s(()=>this._canProjectCameraPosition,()=>this._resetReferencePosition(!0),r)],this._viewHandlesKey),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this.removeHandles(this._viewHandlesKey),this._resetReferencePosition(),this._renderer=i(this._renderer)}_updateLightingHandler(e){this._updateCameraTracking("virtual"!==e.type&&e.cameraTrackingEnabled),this._lightingDateHandler("virtual"!==e.type?e.date:null),this._updateRenderParameters()}_updateCameraTracking(e){if(this._trackingEnabled=e,e)this._cameraHandler();else{if(!this.view)return;const e=this.view.environment.lighting;"virtual"!==e?.type&&(e.positionTimezoneInfo.autoUpdated=!1)}}_lightingDateHandler(e){if(!this.view)return;const t=this.view.environment.lighting;if("virtual"!==t?.type){if(e){if(!t.positionTimezoneInfo.autoUpdated&&(this._preupdateTracking(e),null!=this._referencePositionGeographic)){const e=y(this._referencePositionGeographic,this._tmpTz);null!=e&&(t.autoUpdate(null,e),this._trackingEnabled&&(t.positionTimezoneInfo.autoUpdated=!0))}this._updateLighting(e)}}else this._updateLighting()}_preupdateTracking(e){this.view&&!this._trackingEnabled&&"virtual"!==this.view.environment.lighting.type&&this.view.environment.lighting.cameraTrackingEnabled&&this._cameraHandler(e)}_cameraHandler(e=null){const t=this.view;if(!t||!t.ready)return;const i=t.stateManager.camera;if(!i)return;const n=i.position,r=n.spatialReference??f.WGS84,o=P(r);if(!w(n,k,o,M)){if(null==this._referencePositionGeographic)return;return this._referencePositionGeographic=null,void this._updateLighting()}this._referencePositionGeographic?l(this._referencePositionGeographic,k)||(c(this._referencePositionGeographic,k),this.notifyChange("referencePositionGeographic")):this._referencePositionGeographic=p(k),this._autoUpdateTimezone(this._referencePositionGeographic,e)||this._updateLighting(e)}_updateLighting(e,t=0){const i=this.view;if(!i)return;const{lighting:n}=i.environment,r="virtual"===n.type,o=this._referencePositionGeographic,s=null!=o?this._tmpLightParameters:this._defaultLightParameters;if(o){e??=r?null:n.date;const t=this._weatherAvailable?i.environment.weather.type:"disabled";T(e,o,i.state.viewingMode,t,i.state.camera,s)}else r&&L(i.state.camera,i.state.viewingMode,s.direct.directionToLightSource);const a=this._mainLight,h=s.direct;g(a.intensity,h.color,h.intensity*Math.PI),c(a.direction,h.directionToLightSource),a.specularStrength=s.specularStrength,a.environmentStrength=s.environmentStrength;const l=this._ambientLight;g(l.intensity,s.ambient.color,s.ambient.intensity);const p=this._moonLight;d(p.intensity,R,S,s.globalFactor);const m=(1-.5*s.globalFactor)*(1-.4*s.noonFactor*(1-s.globalFactor));g(p.intensity,p.intensity,m),c(p.direction,h.directionToLightSource),i.stage?.renderer.updateLighting([a,l,p],s.noonFactor,s.globalFactor,this._weatherAvailable?t:0),this._updateRenderParameters()}_autoUpdateTimezone(e,t=null){if(!this.view||"virtual"===this.view.environment.lighting.type||!this.view.environment.lighting.cameraTrackingEnabled||null==e)return!1;const i=this._tmpDate;i.setTime((t||this.view.environment.lighting.date).getTime());const n=y(e,this._tmpTz);if(null==n)return!1;let r=this.view.environment.lighting.positionTimezoneInfo;if(r.autoUpdated){if(r.hours===n.hours&&r.minutes===n.minutes&&r.seconds===n.seconds)return!1}else r=n;const o=i.getUTCHours()-(n.hours-r.hours),s=i.getUTCMinutes()-(n.minutes-r.minutes),a=i.getUTCSeconds()-(n.seconds-r.seconds);return i.setUTCHours(o),i.setUTCMinutes(s),i.setUTCSeconds(a),!t&&this.view.environment.lighting.autoUpdate(i,n)}_updateRenderParameters(){const e=this.view?.stage;if(!this.view||!e)return;const t=null==this._referencePositionGeographic||j(this._referencePositionGeographic[2],this.view.state.viewingMode);e.renderer.setParameters({shadowMap:this.view.environment.lighting.directShadowsEnabled&&t})}_resetReferencePosition(e=!1){this._referencePositionGeographic=null,e&&this._cameraHandler()}get test(){}};e([a()],E.prototype,"view",void 0),e([a({type:Boolean,readOnly:!0})],E.prototype,"updating",null),e([a()],E.prototype,"_disableWeather",void 0),e([a()],E.prototype,"weatherEnabled",null),e([a()],E.prototype,"_weatherAvailable",null),e([a()],E.prototype,"referencePositionGeographic",null),e([a()],E.prototype,"_referencePositionGeographic",void 0),e([a()],E.prototype,"_renderer",void 0),e([a()],E.prototype,"_canProjectCameraPosition",null),E=e([h("esri.views.3d.environment.EnvironmentManager")],E);const R=u(.22,.22,.33),S=u(.22,.22,.22),k=m(),M={zConversionDisabled:!0};export{E as EnvironmentManager};
2
+ import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../core/Evented.js";import"../../../core/has.js";import{watch as i,sync as n,syncAndInitial as r,when as o}from"../../../core/reactiveUtils.js";import{property as s,subclass as a}from"../../../core/accessorSupport/decorators.js";import{equals as h,copy as l,scale as c,lerp as g}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as p,create as d,fromValues as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{isEarth as u}from"../../../geometry/ellipsoidUtils.js";import{isLoadedOrLoadFor as v}from"../../../geometry/projectionUtils.js";import _ from"../../../geometry/SpatialReference.js";import{projectPointToVector as f}from"../../../geometry/projection/projectPointToVector.js";import{getGCSForPlanet as w}from"../../../geometry/support/planetGCSUtils.js";import{positionToTimezoneInfo as P}from"../support/earthUtils.js";import{ColorAndIntensity as y,computeColorAndIntensity as b,computeVirtualLightDirection as T,computeShadowsEnabled as L}from"../support/sunUtils.js";import{MainLight as j,AmbientLight as G,FillLight as U}from"../webgl-engine/lighting/Lightsources.js";let H=class extends t{constructor(e){super(e),this.view=null,this._tmpLightParameters=new y,this._defaultLightParameters=new y,this._tmpDate=new Date,this._tmpTz={hours:0,minutes:0,seconds:0},this._viewHandlesKey="viewHandles",this._trackingEnabled=!1,this._mainLight=new j,this._ambientLight=new G,this._moonLight=new U,this._disableWeather=!1,this._resetReferencePosition()}destroy(){this.disconnectView()}get updating(){return!this._canProjectCameraPosition}get weatherEnabled(){return null!=this.view&&null!=this.view.stage&&null!=this.view.stage.renderer.weatherFader&&this.view.environment.atmosphereEnabled&&!this._disableWeather&&1===this.view.state?.viewingMode&&u(this.view.spatialReference)}get _weatherAvailable(){const e=this.view?.stage.renderer.weatherFader?.weatherAvailable??!1;return this.weatherEnabled&&e}get referencePositionGeographic(){return this._referencePositionGeographic}get _canProjectCameraPosition(){const e=this.view?.stateManager?.camera?.position?.spatialReference??_.WGS84,t=w(e);return v(e,t)}connectView(e){this.view=e;const t=()=>this._updateRenderParameters(),s=()=>this._cameraHandler();this.addHandles([i(()=>e.environment.lighting,e=>this._updateLightingHandler(e),n),i(()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null,e=>this._lightingDateHandler(e),n),i(()=>e.environment.lighting.directShadowsEnabled,t,n),i(()=>e.spatialReference,()=>this._resetReferencePosition(!0),n),i(()=>[e.environment.weather.type,this.weatherEnabled],()=>this._updateLighting(null,1),n),i(()=>e.environment,e=>e.setComputeWeatherAvailable(()=>this._weatherAvailable),r),i(()=>e.viewingMode,()=>this._resetReferencePosition(!0),r),i(()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled,e=>this._updateCameraTracking(e),r),i(()=>e.state.camera,s,r),o(()=>this._canProjectCameraPosition,()=>this._resetReferencePosition(!0),n)],this._viewHandlesKey),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this.removeHandles(this._viewHandlesKey),this._resetReferencePosition()}_updateLightingHandler(e){this._updateCameraTracking("virtual"!==e.type&&e.cameraTrackingEnabled),this._lightingDateHandler("virtual"!==e.type?e.date:null),this._updateRenderParameters()}_updateCameraTracking(e){if(this._trackingEnabled=e,e)this._cameraHandler();else{if(!this.view)return;const e=this.view.environment.lighting;"virtual"!==e?.type&&(e.positionTimezoneInfo.autoUpdated=!1)}}_lightingDateHandler(e){if(!this.view)return;const t=this.view.environment.lighting;if("virtual"!==t?.type){if(e){if(!t.positionTimezoneInfo.autoUpdated&&(this._preupdateTracking(e),null!=this._referencePositionGeographic)){const e=P(this._referencePositionGeographic,this._tmpTz);null!=e&&(t.autoUpdate(null,e),this._trackingEnabled&&(t.positionTimezoneInfo.autoUpdated=!0))}this._updateLighting(e)}}else this._updateLighting()}_preupdateTracking(e){this.view&&!this._trackingEnabled&&"virtual"!==this.view.environment.lighting.type&&this.view.environment.lighting.cameraTrackingEnabled&&this._cameraHandler(e)}_cameraHandler(e=null){const t=this.view;if(!t||!t.ready)return;const i=t.stateManager.camera;if(!i)return;const n=i.position,r=n.spatialReference??_.WGS84,o=w(r);if(!f(n,R,o,S)){if(null==this._referencePositionGeographic)return;return this._referencePositionGeographic=null,void this._updateLighting()}this._referencePositionGeographic?h(this._referencePositionGeographic,R)||(l(this._referencePositionGeographic,R),this.notifyChange("referencePositionGeographic")):this._referencePositionGeographic=p(R),this._autoUpdateTimezone(this._referencePositionGeographic,e)||this._updateLighting(e)}_updateLighting(e,t=0){const i=this.view;if(!i)return;const{lighting:n}=i.environment,r="virtual"===n.type,o=this._referencePositionGeographic,s=null!=o?this._tmpLightParameters:this._defaultLightParameters;if(o){e??=r?null:n.date;const t=this._weatherAvailable?i.environment.weather.type:"disabled";b(e,o,i.state.viewingMode,t,i.state.camera,s)}else r&&T(i.state.camera,i.state.viewingMode,s.direct.directionToLightSource);const a=this._mainLight,h=s.direct;c(a.intensity,h.color,h.intensity*Math.PI),l(a.direction,h.directionToLightSource),a.specularStrength=s.specularStrength,a.environmentStrength=s.environmentStrength;const p=this._ambientLight;c(p.intensity,s.ambient.color,s.ambient.intensity);const d=this._moonLight;g(d.intensity,C,E,s.globalFactor);const m=(1-.5*s.globalFactor)*(1-.4*s.noonFactor*(1-s.globalFactor));c(d.intensity,d.intensity,m),l(d.direction,h.directionToLightSource),i.stage?.renderer.updateLighting([a,p,d],s.noonFactor,s.globalFactor,this._weatherAvailable?t:0),this._updateRenderParameters()}_autoUpdateTimezone(e,t=null){if(!this.view||"virtual"===this.view.environment.lighting.type||!this.view.environment.lighting.cameraTrackingEnabled||null==e)return!1;const i=this._tmpDate;i.setTime((t||this.view.environment.lighting.date).getTime());const n=P(e,this._tmpTz);if(null==n)return!1;let r=this.view.environment.lighting.positionTimezoneInfo;if(r.autoUpdated){if(r.hours===n.hours&&r.minutes===n.minutes&&r.seconds===n.seconds)return!1}else r=n;const o=i.getUTCHours()-(n.hours-r.hours),s=i.getUTCMinutes()-(n.minutes-r.minutes),a=i.getUTCSeconds()-(n.seconds-r.seconds);return i.setUTCHours(o),i.setUTCMinutes(s),i.setUTCSeconds(a),!t&&this.view.environment.lighting.autoUpdate(i,n)}_updateRenderParameters(){const e=this.view?.stage;if(!this.view||!e)return;const t=null==this._referencePositionGeographic||L(this._referencePositionGeographic[2],this.view.state.viewingMode);e.renderer.setParameters({shadowMap:this.view.environment.lighting.directShadowsEnabled&&t})}_resetReferencePosition(e=!1){this._referencePositionGeographic=null,e&&this._cameraHandler()}get test(){}};e([s()],H.prototype,"view",void 0),e([s({type:Boolean,readOnly:!0})],H.prototype,"updating",null),e([s()],H.prototype,"_disableWeather",void 0),e([s()],H.prototype,"weatherEnabled",null),e([s()],H.prototype,"_weatherAvailable",null),e([s()],H.prototype,"referencePositionGeographic",null),e([s()],H.prototype,"_referencePositionGeographic",void 0),e([s()],H.prototype,"_canProjectCameraPosition",null),H=e([a("esri.views.3d.environment.EnvironmentManager")],H);const C=m(.22,.22,.33),E=m(.22,.22,.22),R=d(),S={zConversionDisabled:!0};export{H as EnvironmentManager};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{multiplyOpacity as e,getContrast as t}from"../../../../core/colorUtils.js";import{releaseMaybe as r}from"../../../../core/maybe.js";import{watch as i,initial as o}from"../../../../core/reactiveUtils.js";import{DidPointerMoveRecentlyFlag as s}from"../../analysis/Slice/sliceToolUtils.js";import{Manipulator3D as a}from"../Manipulator3D.js";import{rotateManipulatorDefaults as l}from"../manipulatorUtils.js";import{RenderObject as n}from"../RenderObject.js";import{Attribute as c}from"../../webgl-engine/lib/Attribute.js";import{Geometry as m}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as u}from"../../webgl-engine/lib/GeometryUtil.js";import{Parameters as d,ImageMaterial as p}from"../../webgl-engine/materials/ImageMaterial.js";import{RibbonLineMaterial as f}from"../../webgl-engine/materials/RibbonLineMaterial.js";class h extends a{constructor(r,s){const a=e(r.effectiveTheme.accentColor,.5),n=t(r.effectiveTheme.accentColor),c=s(a,n),m=new d(c.managedTexture,!1);m.writeDepth=!1,m.renderOccluded=16,m.isDecoration=!0;const u=new p(m),h=l.calloutWidth,g=new f({width:h,renderOccluded:4,isDecoration:!0},r.state.isGlobal);super({view:r,...w({imageMaterial:u,calloutMaterial:g})}),this._material=u,this._textureHandle=c,this._themeHandle=i(()=>r.effectiveTheme.accentColor,r=>{const i=e(r,.5),o=t(r),a=this._textureHandle;this._textureHandle=s(i,o),u.setParameters({managedTexture:this._textureHandle.managedTexture}),a?.release(),g.setParameters({color:r.toUnitRGBA()})},o)}destroy(){this._textureHandle=r(this._textureHandle),this._themeHandle.remove(),this._material.dispose(),super.destroy()}}function w({imageMaterial:e,calloutMaterial:t}){const{focusMultiplier:r,calloutLength:i,discRadius:o}=l,a=o*r,d=(e,t)=>{const r=[0,1,2,2,3,0];return new m(t,[["position",new c([i-e,-e,0,i+e,-e,0,i+e,e,0,i-e,e,0],r,3,!0)],["uv0",new c([0,0,1,0,1,1,0,1],r,2,!0)]])},p=u(t,[[0,0,0],[i-o,0,0]]),f=u(t,[[0,0,0],[i-a,0,0]]),h=s;return{autoScaleRenderObjects:!1,collisionPriority:1,collisionType:{type:"disc",direction:[0,0,1],offset:[i,0,0]},focusMultiplier:r,radius:o,renderObjects:[new n(d(o,e),1|h),new n(p,1|h),new n(d(a,e),2|h),new n(f,2|h)],state:h}}export{h as RotateManipulator};
2
+ import{multiplyOpacity as e,getContrast as t}from"../../../../core/colorUtils.js";import{releaseMaybe as r}from"../../../../core/maybe.js";import{watch as i,initial as o}from"../../../../core/reactiveUtils.js";import{DidPointerMoveRecentlyFlag as s}from"../../analysis/Slice/sliceToolUtils.js";import{Manipulator3D as a}from"../Manipulator3D.js";import{rotateManipulatorDefaults as l}from"../manipulatorUtils.js";import{RenderObject as n}from"../RenderObject.js";import{Attribute as c}from"../../webgl-engine/lib/Attribute.js";import{Geometry as m}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as u}from"../../webgl-engine/lib/GeometryUtil.js";import{Parameters as d,ImageMaterial as f}from"../../webgl-engine/materials/ImageMaterial.js";import{RibbonLineMaterial as p}from"../../webgl-engine/materials/RibbonLineMaterial.js";class w extends a{constructor(r,s){const a=e(r.effectiveTheme.accentColor,.5),n=t(r.effectiveTheme.accentColor),c=s(a,n),m=new d(c.managedTexture,!1);m.writeDepth=!1,m.renderOccluded=16,m.isDecoration=!0;const u=new f(m),w=l.calloutWidth,h=new p({width:w,renderOccluded:4,isDecoration:!0},r.state.isGlobal);super({view:r,...g({imageMaterial:u,calloutMaterial:h})}),this._textureHandle=c,this._themeHandle=i(()=>r.effectiveTheme.accentColor,r=>{const i=e(r,.5),o=t(r),a=this._textureHandle;this._textureHandle=s(i,o),u.setParameters({managedTexture:this._textureHandle.managedTexture}),a?.release(),h.setParameters({color:r.toUnitRGBA()})},o)}destroy(){this._textureHandle=r(this._textureHandle),this._themeHandle.remove(),super.destroy()}}function g({imageMaterial:e,calloutMaterial:t}){const{focusMultiplier:r,calloutLength:i,discRadius:o}=l,a=o*r,d=(e,t)=>{const r=[0,1,2,2,3,0];return new m(t,[["position",new c([i-e,-e,0,i+e,-e,0,i+e,e,0,i-e,e,0],r,3,!0)],["uv0",new c([0,0,1,0,1,1,0,1],r,2,!0)]])},f=u(t,[[0,0,0],[i-o,0,0]]),p=u(t,[[0,0,0],[i-a,0,0]]),w=s;return{autoScaleRenderObjects:!1,collisionPriority:1,collisionType:{type:"disc",direction:[0,0,1],offset:[i,0,0]},focusMultiplier:r,radius:o,renderObjects:[new n(d(o,e),1|w),new n(f,1|w),new n(d(a,e),2|w),new n(p,2|w)],state:w}}export{w as RotateManipulator};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import s from"../../../core/Logger.js";import t from"../../../core/PooledArray.js";import{create as e}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{WorkerHandle as o}from"../../../core/workers/WorkerHandle.js";import{canProjectWithoutEngine as r}from"../../../geometry/projectionUtils.js";import n from"../../../geometry/SpatialReference.js";import{projectVectorToVector as i}from"../../../geometry/projection/projectVectorToVector.js";class h{constructor(s,t,e,o,r,n){this.layout=s,this.interleavedVertexData=t,this.indices=e,this.hasColors=o,this.hasModifications=r,this.positionData=n}}class a{constructor(s,t,e,o,r,n,i){this.componentOffsets=s,this.featureIds=t,this.anchorIds=e,this.anchors=o,this.transformedGeometry=r,this.globalTrafo=n,this.obb=i}}class c extends o{constructor(s){super("SceneLayerWorker","process",{process:s=>[s.geometryBuffer],project:s=>[s.positions.buffer],transformNormals:s=>[s.normals.buffer]},s,{hasInitialize:!0})}setModifications(s,t,e){const o={context:s,modifications:t,isGeodetic:e};return this.broadcast(o,"setModifications")}setLegacySchema(s,t){const e=JSON.stringify(t);return this.broadcast({context:s,jsonSchema:e},"setLegacySchema")}destroyContext(s){return this.broadcast(s,"destroyContext")}async destroyContextAndSelf(s){await this.destroyContext(s),this.destroy()}project(s,t){return this.invokeMethod("project",s,t)}transformNormals(s,t){return this.invokeMethod("transformNormals",s,t)}}const p=new t({deallocator:null}),l=e();function u(t,e,o){p.clear();let n=1/0,h=1/0,a=-1/0,c=-1/0,u=!1;for(const g of e){const t="clip"===g.type?2:"mask"===g.type?1:0,e=g.geometry;let f=s=>s;if(e.spatialReference){if(!r(e.spatialReference,o)){s.getLogger("esri.views.3d.layers.SceneLayerWorkerHandle").warn("im-modification-projection-failed","Can't project modification polygon into layer spatial reference, ignoring modification",{polygon:e});continue}f=s=>(i(s,e.spatialReference,l,o),l)}u=u||1===t;const m=e.rings.length,d=e.rings.some(s=>s.length<3);if(0===m||d)s.getLogger("esri.views.3d.layers.SceneLayerWorkerHandle").warn("im-modification-invalid-polygon","Ignoring invalid modification polygon (no rings or rings with less than 3 vertices).",{polygon:e});else{p.push(t),p.push(m);for(const s of e.rings){p.push(s.length);for(const t of s){const s=f(t);p.push(s[0]),p.push(s[1]),p.push(s[2]??0),n=Math.min(n,s[0]),h=Math.min(h,s[1]),a=Math.max(a,s[0]),c=Math.max(c,s[1])}}}}if(null!=t)if(u){const s=1e-4;p.push(2),p.push(2),p.push(4),p.push(n-s),p.push(h-s),p.push(0),p.push(a+s),p.push(h-s),p.push(0),p.push(a+s),p.push(c+s),p.push(0),p.push(n-s),p.push(c+s),p.push(0),p.push(4),p.push(t[0]),p.push(t[1]),p.push(0),p.push(t[2]),p.push(t[1]),p.push(0),p.push(t[2]),p.push(t[3]),p.push(0),p.push(t[0]),p.push(t[3]),p.push(0)}else p.push(1),p.push(1),p.push(4),p.push(t[0]),p.push(t[1]),p.push(0),p.push(t[2]),p.push(t[1]),p.push(0),p.push(t[2]),p.push(t[3]),p.push(0),p.push(t[0]),p.push(t[3]),p.push(0);p.push(3);const f=new Float64Array(p.length);for(let s=0;s<p.length;++s)f[s]=p.at(s);return f}function f(s,t){let e=0;for(const o of t){const t=o.geometry,r=t.rings.length,n=t.rings.some(s=>s.length<3);if(0!==r&&!n){e+=1,e+=1;for(let o=0;o<t.rings.length;++o){const r=t.rings[o];e+=1;for(let n=0;n<r.length;++n){const r=[s[e+0],s[e+1],s[e+2]];e+=3,t.setPoint(o,n,r)}}}}}function g(s,t){let e=0,o=t.geometry;const r=o.rings.length,i=o.rings.some(s=>s.length<3);if(0===r||i)return null;o=o.clone(),o.spatialReference=n.WGS84,e+=1,e+=1;for(let n=0;n<o.rings.length;++n){const t=o.rings[n];e+=1;for(let r=0;r<t.length;++r){const t=[s[e+0],s[e+1],s[e+2]];e+=3,o.setPoint(n,r,t)}}return o}export{c as SceneLayerWorkerHandle,a as TransformedData,h as TransformedGeometry,f as fromWasmModificationInLoad,g as fromWasmModificationInSave,u as toWasmModification};
2
+ import s from"../../../core/Logger.js";import t from"../../../core/PooledArray.js";import{create as o}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{WorkerHandle as e}from"../../../core/workers/WorkerHandle.js";import{canProjectWithoutEngine as r}from"../../../geometry/projectionUtils.js";import{projectVectorToVector as n}from"../../../geometry/projection/projectVectorToVector.js";class i{constructor(s,t,o,e,r,n){this.layout=s,this.interleavedVertexData=t,this.indices=o,this.hasColors=e,this.hasModifications=r,this.positionData=n}}class h{constructor(s,t,o,e,r,n,i){this.componentOffsets=s,this.featureIds=t,this.anchorIds=o,this.anchors=e,this.transformedGeometry=r,this.globalTrafo=n,this.obb=i}}class a extends e{constructor(s){super("SceneLayerWorker","process",{process:s=>[s.geometryBuffer],project:s=>[s.positions.buffer],transformNormals:s=>[s.normals.buffer]},s,{hasInitialize:!0})}setModifications(s,t,o){const e={context:s,modifications:t,isGeodetic:o};return this.broadcast(e,"setModifications")}setLegacySchema(s,t){const o=JSON.stringify(t);return this.broadcast({context:s,jsonSchema:o},"setLegacySchema")}destroyContext(s){return this.broadcast(s,"destroyContext")}async destroyContextAndSelf(s){await this.destroyContext(s),this.destroy()}project(s,t){return this.invokeMethod("project",s,t)}transformNormals(s,t){return this.invokeMethod("transformNormals",s,t)}}const p=new t({deallocator:null}),c=o();function u(t,o,e){p.clear();let i=1/0,h=1/0,a=-1/0,u=-1/0,l=!1;for(const m of o){const t="clip"===m.type?2:"mask"===m.type?1:0,o=m.geometry;let f=s=>s;if(o.spatialReference){if(!r(o.spatialReference,e)){s.getLogger("esri.views.3d.layers.SceneLayerWorkerHandle").warn("im-modification-projection-failed","Can't project modification polygon into layer spatial reference, ignoring modification",{polygon:o});continue}f=s=>(n(s,o.spatialReference,c,e),c)}l=l||1===t;const g=o.rings.length,d=o.rings.some(s=>s.length<3);if(0===g||d)s.getLogger("esri.views.3d.layers.SceneLayerWorkerHandle").warn("im-modification-invalid-polygon","Ignoring invalid modification polygon (no rings or rings with less than 3 vertices).",{polygon:o});else{p.push(t),p.push(g);for(const s of o.rings){p.push(s.length);for(const t of s){const s=f(t);p.push(s[0]),p.push(s[1]),p.push(s[2]??0),i=Math.min(i,s[0]),h=Math.min(h,s[1]),a=Math.max(a,s[0]),u=Math.max(u,s[1])}}}}if(null!=t)if(l){const s=1e-4;p.push(2),p.push(2),p.push(4),p.push(i-s),p.push(h-s),p.push(0),p.push(a+s),p.push(h-s),p.push(0),p.push(a+s),p.push(u+s),p.push(0),p.push(i-s),p.push(u+s),p.push(0),p.push(4),p.push(t[0]),p.push(t[1]),p.push(0),p.push(t[2]),p.push(t[1]),p.push(0),p.push(t[2]),p.push(t[3]),p.push(0),p.push(t[0]),p.push(t[3]),p.push(0)}else p.push(1),p.push(1),p.push(4),p.push(t[0]),p.push(t[1]),p.push(0),p.push(t[2]),p.push(t[1]),p.push(0),p.push(t[2]),p.push(t[3]),p.push(0),p.push(t[0]),p.push(t[3]),p.push(0);p.push(3);const f=new Float64Array(p.length);for(let s=0;s<p.length;++s)f[s]=p.at(s);return f}function l(s,t){let o=0;for(const e of t){const t=e.geometry,r=t.rings.length,n=t.rings.some(s=>s.length<3);if(0!==r&&!n){o+=1,o+=1;for(let e=0;e<t.rings.length;++e){const r=t.rings[e];o+=1;for(let n=0;n<r.length;++n){const r=[s[o+0],s[o+1],s[o+2]];o+=3,t.setPoint(e,n,r)}}}}}export{a as SceneLayerWorkerHandle,h as TransformedData,i as TransformedGeometry,l as fromWasmModification,u as toWasmModification};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as i}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as s,sync as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{subtract as o,set as c,dot as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as h,fromValues as u,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as p,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as b}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as T}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as v}from"./TileRenderer.js";import{IteratorPreorder as P,fallsWithinLayerView as O,sortTiles as w,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as S}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as B,ConsumesDepth as E,ConsumesNone as F}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as j}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as q}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as C,MeshIntersectionOptions as A,intersectTriangles as M}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as G}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as U,getVerticalOffsetTerrain as k}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as I}from"../webgl-engine/materials/DrawParameters.js";import{T as N}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as L}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as V}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as z}from"../../webgl/enums.js";const H=7,W=10,Q=200,Z=p();let J=class extends B{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,s,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=s,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new N,this._drawParameters=new I,this._renderDataPool=new r(()=>new x),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new P,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>1===this._desiredSlot],[6,()=>6===this._desiredSlot],[7,()=>7===this._desiredSlot],[10,()=>this._produces()&&this.renderOccludedFlags===b]]),this._tileSize=256,this._configuration=new V(1===t.viewingMode),this._tileTextureCache=new i((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new T(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(s(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),n))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}get _oitEnabled(){return this._stage.renderer.oitEnabled}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?E:F}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get layerViewUid(){return U}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;const{layerInfo:i,surface:r}=t;for(let s=0;s<i[1].length;s++){const i=r.layerViewByIndex(s,1);if(O(e,i)!==O(t,i))return!1}return!0}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=W-H,i=Math.max(0,Math.floor((e.level-t)/H)*H);if(this._isGlobal&&0===i)return h;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new v(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=K,n=X;o(s,r,i),c(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,l=e.results.max,h=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=k(e.verticalOffset),f=e.tolerance;let p,b=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,R=new A(f,!1,T),v=c=>{const _=c.renderData;if(!_?.vao)return;const v=_.geometry;m(Z,v.boundingBox);const P=_.localOrigin;null!=g&&(g.localOrigin=P,g.applyToAabb(Z));const O=Z;if(Y[0]=i[0]-P[0],Y[1]=i[1]-P[1],Y[2]=i[2]-P[2],!C(O,Y,n,f,b))return;const w=(e,t,i)=>{e.set(this.type,c,t,i),b=u&&null!=a.distance?a.distance:1/0},D=(n,o,c)=>{if((!T||null!=c)&&n>=0&&(x.backfacesTerrain||d(c,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==h.distance||n<h.distance)&&w(h,n,c),x.isFiltered)return;2===x.store&&(null==p?(p=new q(e.ray),w(p,n,c),e.results.all.push(p)):n<p.distance&&w(p,n,c)),(null==a.distance||n<a.distance)&&w(a,n,c),0!==x.store&&(null==l.distance||n>l.distance)&&w(l,n,c)}},S=$;o(S,r,P);const{indices:B,indexCount:E}=v,F=v.vertexAttributes,A=F.getField("position",y),U=new j(A.typedBuffer,3,F.stride/4),k=E/3;if(!g&&k>Q){const e=c.renderData;e.intersectionData??=new G(B,k,U),e.intersectionData.intersectRay(Y,S,R,D)}else M(Y,S,0,k,B,U,g,R,D)},P=this._rootTiles;if(null!=P){(()=>{const t=this._tileIterator;t.reset(P);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,f,b)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return this._oitEnabled?7:6;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillEnabled:r,slot:s,oitPass:n,hasEmission:a}=e.bind,l=!!has("enable-feature:terrain-shadows")&&t.enabled;if(l!==this._castShadows&&(this._castShadows=l,this._patchesByOriginDirty=!0),this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),3===this.transparency)return null;if(10===s){if(0===(e.renderOccludedMask&b))return null}else if(s!==this._desiredSlot)return null;const o=this._configuration;switch(o.screenSpaceReflections=o.cloudReflections=o.receiveShadows=o.receiveAmbientOcclusion=o.renderOccluded=o.hasHighlightMixTexture=o.hasEmission=!1,o.overlayMode=this._overlayRenderer.mode,o.oitPass=0,e.output){case 0:{const{ssr:i,clouds:r,ssao:l}=e.bind;o.screenSpaceReflections=null!=i.lastFrameColor,o.cloudReflections=null!=r.data;const c=10===s;return o.receiveShadows=t.ready&&!c,o.renderOccluded=c,o.receiveAmbientOcclusion=!c&&null!=l,o.oitPass=n,o.hasEmission=a,this._acquireTechnique(e.output)}case 3:case 5:return this._castShadows?this._acquireTechnique(3):null;case 6:return this._inViewshed?this._acquireTechnique(6):null;case 7:return this._cutFillEnabled?this._acquireTechnique(7):null;case 1:case 2:return this._acquireTechnique(e.output);case 9:return this._acquireTechnique(9);case 8:return o.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(8):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=S(e.output,e.bind),e.output){case 0:return this._renderMaterialPass(e,t);case 1:case 2:case 9:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 8:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 3:case 5:case 6:case 7:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const t=this._tileRenderer;let i;if(null!=e){const t=e.toUnitRGBA();i=u(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(i),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:null!=t.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)w(i,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange("visibleTiles"),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(i=>{this._drawParameters.origin=i[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let r=0;r<i.length;r++)this._renderPatch(e,t,i[r],z.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e,s=i.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const n=10===r.slot;n&&(s.bindTexture("tex",i.emptyTexture),s.setUniform3fv("textureOpacities",h),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:h;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const l=this._stencilEnabledLayerExtents.length>0,o=this.wireframe?z.LINES:z.TRIANGLES;this._configuration.textureFadingEnabled&&s.bindTexture("texNext",i.emptyTexture);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const i=d[0].renderData.localOrigin;this._drawParameters.origin=i,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of d){const i=r.renderData,a=i.textureReference;if(null!=a){if(!n){s.setUniform4fv("texOffsetAndScale",a.offsetAndScale),s.bindTexture("tex",a.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(2),s.setUniform3fv("textureOpacities",a.opacities)}this._renderPatch(e,t,r,o,l),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,l=a.vao,o=l?.indexBuffer;if(!l||null==o)return void(R&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay);const{rctx:d,bind:h}=e;s&&(t.useStencil=this._useStencilForTile(i),d.setPipelineState(t.getPipeline(h)));const u=a.geometry.indexCount;d.bindVAO(l),c.assertCompatibleVertexAttributeLocations(l),d.drawElements(r,u,o.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(L,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([a({readOnly:!0})],J.prototype,"visibleTiles",null),e([a({readOnly:!0})],J.prototype,"_isGlobal",null),e([a()],J.prototype,"renderOccludedFlags",null),e([a({value:!1})],J.prototype,"renderingDisabled",null),e([a({value:!0})],J.prototype,"visible",null),e([a()],J.prototype,"renderPatchBorders",null),e([a()],J.prototype,"wireframe",null),J=e([l("esri.views.3d.terrain.TerrainRenderer")],J);const K=_(),X=_(),Y=_(),$=_();export{J as TerrainRenderer};
2
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as i}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as s,sync as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{subtract as o,set as c,dot as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as h,fromValues as u,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as p,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as b}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as T}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as v}from"./TileRenderer.js";import{IteratorPreorder as P,fallsWithinLayerView as O,sortTiles as w,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as S}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as B}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as E}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as F}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as j,MeshIntersectionOptions as q,intersectTriangles as C}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as A}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as M,getVerticalOffsetTerrain as G}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as U}from"../webgl-engine/materials/DrawParameters.js";import{T as k}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as I}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as N}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as L}from"../../webgl/enums.js";const V=7,z=10,H=200,Q=p();let W=class extends B{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,s,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=s,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new k,this._drawParameters=new U,this._renderDataPool=new r(()=>new x),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new P,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>1===this._desiredSlot],[6,()=>6===this._desiredSlot],[7,()=>7===this._desiredSlot],[10,()=>this._produces()&&this.renderOccludedFlags===b]]),this._tileSize=256,this._configuration=new N(1===t.viewingMode),this._tileTextureCache=new i((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new T(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(s(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),n))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}get _oitEnabled(){return this._stage.renderer.oitEnabled}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get layerViewUid(){return M}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;const{layerInfo:i,surface:r}=t;for(let s=0;s<i[1].length;s++){const i=r.layerViewByIndex(s,1);if(O(e,i)!==O(t,i))return!1}return!0}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=z-V,i=Math.max(0,Math.floor((e.level-t)/V)*V);if(this._isGlobal&&0===i)return h;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new v(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=Z,n=J;o(s,r,i),c(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,l=e.results.max,h=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=G(e.verticalOffset),f=e.tolerance;let p,b=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,R=new q(f,!1,T),v=c=>{const _=c.renderData;if(!_?.vao)return;const v=_.geometry;m(Q,v.boundingBox);const P=_.localOrigin;null!=g&&(g.localOrigin=P,g.applyToAabb(Q));const O=Q;if(K[0]=i[0]-P[0],K[1]=i[1]-P[1],K[2]=i[2]-P[2],!j(O,K,n,f,b))return;const w=(e,t,i)=>{e.set(this.type,c,t,i),b=u&&null!=a.distance?a.distance:1/0},D=(n,o,c)=>{if((!T||null!=c)&&n>=0&&(x.backfacesTerrain||d(c,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==h.distance||n<h.distance)&&w(h,n,c),x.isFiltered)return;2===x.store&&(null==p?(p=new F(e.ray),w(p,n,c),e.results.all.push(p)):n<p.distance&&w(p,n,c)),(null==a.distance||n<a.distance)&&w(a,n,c),0!==x.store&&(null==l.distance||n>l.distance)&&w(l,n,c)}},S=X;o(S,r,P);const{indices:B,indexCount:q}=v,M=v.vertexAttributes,G=M.getField("position",y),U=new E(G.typedBuffer,3,M.stride/4),k=q/3;if(!g&&k>H){const e=c.renderData;e.intersectionData??=new A(B,k,U),e.intersectionData.intersectRay(K,S,R,D)}else C(K,S,0,k,B,U,g,R,D)},P=this._rootTiles;if(null!=P){(()=>{const t=this._tileIterator;t.reset(P);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,f,b)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return this._oitEnabled?7:6;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillEnabled:r,slot:s,oitPass:n,hasEmission:a}=e.bind,l=!!has("enable-feature:terrain-shadows")&&t.enabled;if(l!==this._castShadows&&(this._castShadows=l,this._patchesByOriginDirty=!0),this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),3===this.transparency)return null;if(10===s){if(0===(e.renderOccludedMask&b))return null}else if(s!==this._desiredSlot)return null;const o=this._configuration;switch(o.screenSpaceReflections=o.cloudReflections=o.receiveShadows=o.receiveAmbientOcclusion=o.renderOccluded=o.hasHighlightMixTexture=o.hasEmission=!1,o.overlayMode=this._overlayRenderer.mode,o.oitPass=0,e.output){case 0:{const{ssr:i,clouds:r,ssao:l}=e.bind;o.screenSpaceReflections=null!=i.lastFrameColor,o.cloudReflections=null!=r.data;const c=10===s;return o.receiveShadows=t.ready&&!c,o.renderOccluded=c,o.receiveAmbientOcclusion=!c&&null!=l,o.oitPass=n,o.hasEmission=a,this._acquireTechnique(e.output)}case 3:case 5:return this._castShadows?this._acquireTechnique(3):null;case 6:return this._inViewshed?this._acquireTechnique(6):null;case 7:return this._cutFillEnabled?this._acquireTechnique(7):null;case 1:case 2:return this._acquireTechnique(e.output);case 9:return this._acquireTechnique(9);case 8:return o.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(8):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=S(e.output,e.bind),e.output){case 0:return this._renderMaterialPass(e,t);case 1:case 2:case 9:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 8:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 3:case 5:case 6:case 7:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const t=this._tileRenderer;let i;if(null!=e){const t=e.toUnitRGBA();i=u(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(i),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:null!=t.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)w(i,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange("visibleTiles"),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(i=>{this._drawParameters.origin=i[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let r=0;r<i.length;r++)this._renderPatch(e,t,i[r],L.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e,s=i.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const n=10===r.slot;n&&(s.bindTexture("tex",i.emptyTexture),s.setUniform3fv("textureOpacities",h),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:h;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const l=this._stencilEnabledLayerExtents.length>0,o=this.wireframe?L.LINES:L.TRIANGLES;this._configuration.textureFadingEnabled&&s.bindTexture("texNext",i.emptyTexture);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const i=d[0].renderData.localOrigin;this._drawParameters.origin=i,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of d){const i=r.renderData,a=i.textureReference;if(null!=a){if(!n){s.setUniform4fv("texOffsetAndScale",a.offsetAndScale),s.bindTexture("tex",a.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(2),s.setUniform3fv("textureOpacities",a.opacities)}this._renderPatch(e,t,r,o,l),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,l=a.vao,o=l?.indexBuffer;if(!l||null==o)return void(R&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay);const{rctx:d,bind:h}=e;s&&(t.useStencil=this._useStencilForTile(i),d.setPipelineState(t.getPipeline(h)));const u=a.geometry.indexCount;d.bindVAO(l),c.assertCompatibleVertexAttributeLocations(l),d.drawElements(r,u,o.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(I,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([a({readOnly:!0})],W.prototype,"visibleTiles",null),e([a({readOnly:!0})],W.prototype,"_isGlobal",null),e([a()],W.prototype,"renderOccludedFlags",null),e([a({value:!1})],W.prototype,"renderingDisabled",null),e([a({value:!0})],W.prototype,"visible",null),e([a()],W.prototype,"renderPatchBorders",null),e([a()],W.prototype,"wireframe",null),W=e([l("esri.views.3d.terrain.TerrainRenderer")],W);const Z=_(),J=_(),K=_(),X=_();export{W as TerrainRenderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import"../../../../core/has.js";import e from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthTexture as t}from"../../webgl/ManagedDepthTexture.js";import a from"../../webgl/ManagedFBO.js";import{isDepthFormat as r,formatString as c,DepthTextureFormats as h,ColorFormats as s}from"./FBOCacheFormats.js";import{FBOPool as i}from"./FBOPool.js";import{DepthStencilAttachment as o,ColorAttachment0 as n}from"../../../webgl/enums.js";import{FramebufferObject as l}from"../../../webgl/FramebufferObject.js";import u from"../../../webgl/Texture.js";class m{constructor(e){this.rctx=e,this._interactive=!1,this._usage=new Map,this._acquired=new Set,this._cache=new i(e.newCache,"FBOCache"),this._depthCache=new i(e.newCache,"DepthAttachmentCache"),this._colorCache=new i(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback?.(),this._usage.clear()}frameEnd(){const{debugCallback:e}=this;e&&this._acquired.forEach(t=>e(t.name,t.fbo,this._usage))}get usedMemory(){return Array.from(this._acquired.values()).reduce((e,t)=>e+t.usedMemory,this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e,this._interactive=e}get interactive(){return this._interactive}acquire(e,t,h,s=5){const i=p(s,e,t);let u=this._cache.pop(i);const{rctx:m}=this;if(u){u.retain(),u.setName(h);const e=u.getAttachment(o);e&&(e.name=_);const t=u.getAttachment(n);t&&(t.name=d(0)),m.unbindTexture(u.fbo.colorTexture)}else{const c=new l(m),p=(a,r,c)=>{r??=5;const h=this._acquireColor(r,e,t,c??d(a-n));return this.rctx.unbindTexture(h.attachment),u.attachColor(h,a),h.release(),u},C=a=>{a??=13;const r=this.acquireDepth(a,e,t,_);return u.attachDepth(r),r.release(),u},g=()=>{if(!u)return;this.debugCallback?.(u.name,u.fbo),this._acquired.delete(u);const e=r(s);e&&null!=u.getAttachment(o)||!e&&null!=u.getAttachment(n)?(e?(u.fbo?.invalidateAttachments([o]),u.detachAllColors()):(u.fbo?.invalidateAttachments([n]),u.detachAllButColor0()),this._cache.put(u)):u.dispose()};u=new a(i,h,c,p,C,g),r(s)?u.acquireDepth(s):u.acquireColor(n,s)}return this._trackUsage(u,"fbo "+c(s),e,t),this._trackHandle(u)}acquireDepth(e,a,r,s){const i=p(e,a,r);let o=this._depthCache.pop(i);if(o)o.retain(),o.attachment.setShadowFiltering(!1);else{const c=new u(this.rctx,{...h[e],width:a,height:r});o=new t(i,c,()=>this._depthCache.put(o))}return o.name=s,this._trackUsage(o,"depth "+c(e),a,r),o}_acquireColor(t,a,r,h){const i=p(t,a,r);let o=this._colorCache.pop(i);if(o)o.retain();else{const c=new u(this.rctx,{...s[t],width:a,height:r,isImmutable:!0});o=new e(i,c,()=>this._colorCache.put(o))}return o.name=h,this._trackUsage(o,"color "+c(t),a,r),o}_trackHandle(e){return this._acquired.add(e),e}_trackUsage(e,t,a,r){this.debugCallback&&(this._usage.has(e)?this._usage.get(e)[2].push(e.name):this._usage.set(e,[t,`${a}x${r}`,[e.name]]))}get test(){return null}}function d(e=0){return`color${e}`}const _="depth";function p(e,t,a){return`${t}x${a}:${e}`}export{m as FBOCache};
2
+ import"../../../../core/has.js";import e from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthTexture as t}from"../../webgl/ManagedDepthTexture.js";import a from"../../webgl/ManagedFBO.js";import{isDepthFormat as r,formatString as c,DepthTextureFormats as h,ColorFormats as i}from"./FBOCacheFormats.js";import{FBOCacheUsage as s}from"./FBOCacheUsage.js";import{FBOPool as o}from"./FBOPool.js";import{DepthStencilAttachment as n,ColorAttachment0 as l}from"../../../webgl/enums.js";import{FramebufferObject as u}from"../../../webgl/FramebufferObject.js";import m from"../../../webgl/Texture.js";class d{constructor(e){this.rctx=e,this._interactive=!1,this._usage=new s,this._acquired=new Set,this._cache=new o(e.newCache,"FBOCache"),this._depthCache=new o(e.newCache,"DepthAttachmentCache"),this._colorCache=new o(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback?.(),this._usage.clear()}frameEnd(){const{debugCallback:e}=this;e&&(this._usage.summarize(),this._acquired.forEach(t=>e(t.name,t.fbo)))}get usedMemory(){return Array.from(this._acquired.values()).reduce((e,t)=>e+t.usedMemory,this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e,this._interactive=e}get interactive(){return this._interactive}acquire(e,t,h,i=5){const s=p(i,e,t);let o=this._cache.pop(s);const{rctx:m}=this;if(o){o.retain(),o.setName(h);const e=o.getAttachment(n);e&&(e.name=C);const t=o.getAttachment(l);t&&(t.name=_(0)),m.unbindTexture(o.fbo.colorTexture)}else{const c=new u(m),d=(a,r,c)=>{r??=5;const h=this._acquireColor(r,e,t,c??_(a-l));return this.rctx.unbindTexture(h.attachment),o.attachColor(h,a),h.release(),o},p=a=>{a??=13;const r=this.acquireDepth(a,e,t,C);return o.attachDepth(r),r.release(),o},f=()=>{if(!o)return;this.debugCallback?.(o.name,o.fbo),this._acquired.delete(o);const e=r(i);e&&null!=o.getAttachment(n)||!e&&null!=o.getAttachment(l)?(e?(o.fbo?.invalidateAttachments([n]),o.detachAllColors()):(o.fbo?.invalidateAttachments([l]),o.detachAllButColor0()),this._trackRelease(o),this._cache.put(o)):o.dispose()};o=new a(s,h,c,d,p,f),r(i)?o.acquireDepth(i):o.acquireColor(l,i)}return this._trackAcquire(o,"f "+c(i),e,t),this._trackHandle(o)}acquireDepth(e,a,r,i){const s=p(e,a,r);let o=this._depthCache.pop(s);if(o)o.retain(),o.attachment.setShadowFiltering(!1);else{const c=new m(this.rctx,{...h[e],width:a,height:r});o=new t(s,c,()=>{this._trackRelease(o),this._depthCache.put(o)})}return o.name=i,this._trackAcquire(o,"d "+c(e),a,r),o}_acquireColor(t,a,r,h){const s=p(t,a,r);let o=this._colorCache.pop(s);if(o)o.retain();else{const c=new m(this.rctx,{...i[t],width:a,height:r,isImmutable:!0});o=new e(s,c,()=>{this._trackRelease(o),this._colorCache.put(o)})}return o.name=h,this._trackAcquire(o,"c "+c(t),a,r),o}_trackHandle(e){return this._acquired.add(e),e}_trackAcquire(e,t,a,r){this.debugCallback&&this._usage.add(e,t,a,r)}_trackRelease(e){this.debugCallback&&this._usage.remove(e)}get test(){return null}}function _(e=0){return`color${e}`}const C="depth";function p(e,t,a){return`${t}x${a}:${e}`}export{d as FBOCache};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ class e{constructor(){this._usage=new Map}clear(){this._usage.clear()}add(e,s,t,o){const r=this._usage.get(e);r?(r[2]=!0,r[3].push(e.name)):this._usage.set(e,[s,`${t}x${o}`,!0,[e.name]]);const u=a(this._usage);console.log(Array.from(this._usage.values()).map(([e,a,s,t])=>(s?t[t.length-1]:"").padStart(u," ")).join(" | "))}remove(e){const a=this._usage.get(e);a&&(a[2]=!1)}summarize(){const e=a(this._usage);console.log(Array.from(this._usage.values()).map(([a,s])=>s.padStart(e," ")).join(" | ")),console.log(Array.from(this._usage.keys()).map(({usedMemory:a})=>`${(a/1024/1024).toFixed(1)}MB`.padStart(e," ")).join(" | ")),console.log(Array.from(this._usage.values()).map(([a])=>a.padStart(e," ")).join(" | ")),console.log("Total",(Array.from(this._usage.keys()).reduce((e,{usedMemory:a})=>e+a,0)/1024/1024).toFixed(1),"MB")}}function a(e){return Array.from(e.values()).reduce((e,[a,s,t,o])=>Math.max(a.length,s.length,o.reduce((e,a)=>Math.max(e,a.length),e)),0)}export{e as FBOCacheUsage};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../../../core/Accessor.js";const r={required:[]},t={required:[1]};class s extends e{precompile(e){return!!this.acquireTechniques(e)}consumes(){return r}get usedMemory(){return 0}get renderOccludedFlags(){return 1}get testsTransparentRenderOrder(){return 0}get isDecoration(){return!1}get readyToRun(){return!1}get numGeometries(){return 0}get hasOccludees(){return!1}get hasEmitters(){return!1}forEachGeometry(e){}}class n extends s{}class u extends s{}export{u as AsyncRenderPlugin,t as ConsumesDepth,r as ConsumesNone,n as SyncRenderPlugin};
2
+ import e from"../../../../core/Accessor.js";const r={required:[]},t={required:[1]};class s extends e{precompile(e){return!!this.acquireTechniques(e)}get usedMemory(){return 0}get renderOccludedFlags(){return 1}get testsTransparentRenderOrder(){return 0}get isDecoration(){return!1}get readyToRun(){return!1}get numGeometries(){return 0}get hasOccludees(){return!1}get hasEmitters(){return!1}forEachGeometry(e){}}class n extends s{}class u extends s{}export{u as AsyncRenderPlugin,t as ConsumesDepth,r as ConsumesNone,n as SyncRenderPlugin};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{removeUnordered as e}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{sort as t}from"../../../../core/heapSort.js";import{isPromiseLike as r,createAbortError as s}from"../../../../core/promiseUtils.js";import{signal as n}from"../../../../core/signal.js";import{DepthRange as o}from"../lib/DepthRange.js";class i{constructor(e){this.context=e,this._renderPlugins=new Array,this._slots=new Array,this._version=n(0);for(let t=0;t<21;++t)this._slots[t]=[]}destroy(){this._renderPlugins.forEach(e=>e.destroy()),this._renderPlugins.length=0}get plugins(){return this._renderPlugins}add(e,t){const n=()=>{if(t?.aborted)throw e.uninitializeRenderContext(),s();this._renderPlugins.push(e),e.produces.forEach((t,r)=>this._slots[r].push(e)),this.context.requestRender(),this._version.value++},o=e.initializeRenderContext(this.context,t);if(r(o))return o.then(n);n()}remove(t){e(this._renderPlugins,t),t.uninitializeRenderContext();for(let e=0;e<this._slots.length;++e)this._slots[e]=this._slots[e].filter(e=>e!==t);this.context.requestRender(),this._version.value++}sortTestsTransparentOrderedSlots(e){if("test"!==process.env.NODE_ENV)return;if(this._renderPlugins.some(e=>0!==e.testsTransparentRenderOrder))for(const r of e){const e=this._slots[r];t(e,0,e.length,(e,t)=>(e.testsTransparentRenderOrder??0)-(t.testsTransparentRenderOrder??0))}}prepareRender(){this._renderPlugins.forEach(e=>{e.prepareRender&&e.prepareRender(this.context.renderContext)})}updateAnimation(e){let t=!1;return this._renderPlugins.forEach(r=>t=r.updateAnimation?.(e)||t),t}precompile(...e){++this.context.techniques.precompiling;const t=this.context.renderContext.bind.slot;for(const r of e)this.context.renderContext.bind.slot=r,this._forEachRender(()=>{});this.context.renderContext.bind.slot=t,--this.context.techniques.precompiling}render(...e){for(const t of e)this.context.renderContext.bind.slot=t,this._forEachRender((e,t)=>e.render(this.context.renderContext,t))}_forEachRender(e){const t=this.context.renderContext.bind.slot,r=this.context.renderContext.output;this._slots[t].forEach(s=>{const n=s.produces.get(t);if(!n?.(r)||s.isDecoration&&!this.context.renderContext.bind.decorations)return;const o=s.acquireTechniques(this.context.renderContext);o&&e(s,o)})}queryDepthRange(e){return this._renderPlugins.reduce((t,r)=>t.union(r.queryDepthRange?.(e)),new o)}get updating(){return this._version.value>=0&&this._renderPlugins.some(e=>e.readyToRun)}produces(e,...t){return t.some(t=>this._slots[t].some(r=>{const s=r.produces.get(t);return!!s&&s(e)}))}consumes(e){return this._renderPlugins.some(t=>t.consumes().required.includes(e))}hasHighlight(e){return d.some(t=>this._slots[t].some(t=>t.hasHighlight(e)))}get hasDecorations(){return this._renderPlugins.some(e=>e.isDecoration)}get hasOccludees(){return this._renderPlugins.some(e=>e.hasOccludees)}get hasEmitters(){return this._renderPlugins.some(e=>e.hasEmitters)}get renderOccludedFlags(){return this._renderPlugins.reduce((e,t)=>e|(t.renderOccludedFlags??0),0)}get usedMemory(){return this._renderPlugins.reduce((e,t)=>t.material?e:e+(t.usedMemory??0),0)}get test(){}}const d=[2,4,19,13,14,15];export{i as RenderPluginManager};
2
+ import{removeUnordered as e}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{sort as t}from"../../../../core/heapSort.js";import{isPromiseLike as r,createAbortError as s}from"../../../../core/promiseUtils.js";import{signal as n}from"../../../../core/signal.js";import{DepthRange as o}from"../lib/DepthRange.js";class i{constructor(e){this.context=e,this._renderPlugins=new Array,this._slots=new Array,this._version=n(0);for(let t=0;t<21;++t)this._slots[t]=[]}destroy(){this._renderPlugins.forEach(e=>e.destroy()),this._renderPlugins.length=0}get plugins(){return this._renderPlugins}add(e,t){const n=()=>{if(t?.aborted)throw e.uninitializeRenderContext(),s();this._renderPlugins.push(e),e.produces.forEach((t,r)=>this._slots[r].push(e)),this.context.requestRender(),this._version.value++},o=e.initializeRenderContext(this.context,t);if(r(o))return o.then(n);n()}remove(t){e(this._renderPlugins,t),t.uninitializeRenderContext();for(let e=0;e<this._slots.length;++e)this._slots[e]=this._slots[e].filter(e=>e!==t);this.context.requestRender(),this._version.value++}sortTestsTransparentOrderedSlots(e){if("test"!==process.env.NODE_ENV)return;if(this._renderPlugins.some(e=>0!==e.testsTransparentRenderOrder))for(const r of e){const e=this._slots[r];t(e,0,e.length,(e,t)=>(e.testsTransparentRenderOrder??0)-(t.testsTransparentRenderOrder??0))}}prepareRender(){this._renderPlugins.forEach(e=>{e.prepareRender&&e.prepareRender(this.context.renderContext)})}updateAnimation(e){let t=!1;return this._renderPlugins.forEach(r=>t=r.updateAnimation?.(e)||t),t}precompile(...e){++this.context.techniques.precompiling;const t=this.context.renderContext.bind.slot;for(const r of e)this.context.renderContext.bind.slot=r,this._forEachRender(()=>{});this.context.renderContext.bind.slot=t,--this.context.techniques.precompiling}render(...e){for(const t of e)this.context.renderContext.bind.slot=t,this._forEachRender((e,t)=>e.render(this.context.renderContext,t))}_forEachRender(e){const t=this.context.renderContext.bind.slot,r=this.context.renderContext.output;this._slots[t].forEach(s=>{const n=s.produces.get(t);if(!n?.(r)||s.isDecoration&&!this.context.renderContext.bind.decorations)return;const o=s.acquireTechniques(this.context.renderContext);o&&e(s,o)})}queryDepthRange(e){return this._renderPlugins.reduce((t,r)=>t.union(r.queryDepthRange?.(e)),new o)}get updating(){return this._version.value>=0&&this._renderPlugins.some(e=>e.readyToRun)}produces(e,...t){return t.some(t=>this._slots[t].some(r=>{const s=r.produces.get(t);return!!s&&s(e)}))}hasHighlight(e){return h.some(t=>this._slots[t].some(t=>t.hasHighlight(e)))}get hasDecorations(){return this._renderPlugins.some(e=>e.isDecoration)}get hasOccludees(){return this._renderPlugins.some(e=>e.hasOccludees)}get hasEmitters(){return this._renderPlugins.some(e=>e.hasEmitters)}get renderOccludedFlags(){return this._renderPlugins.reduce((e,t)=>e|(t.renderOccludedFlags??0),0)}get usedMemory(){return this._renderPlugins.reduce((e,t)=>t.material?e:e+(t.usedMemory??0),0)}get test(){}}const h=[2,4,19,13,14,15];export{i as RenderPluginManager};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import"../../../../core/has.js";import{destroyMaybe as e}from"../../../../core/maybe.js";import{watch as i,sync as r}from"../../../../core/reactiveUtils.js";import{signal as n}from"../../../../core/signal.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{length as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{getReferenceEllipsoid as u}from"../../../../geometry/ellipsoidUtils.js";import{heightLimit as c}from"../../environment/weather.js";import{SyncRenderPlugin as p}from"./RenderPlugin.js";import{cloudPresets as h}from"./clouds/CloudsPresets.js";import{CloudsRenderer as l}from"./clouds/CloudsRenderer.js";import{Precipitation as d}from"./precipitation/Precipitation.js";let _=class extends p{constructor(t){super(t),this.produces=new Map([]),this._clouds=n(null),this._incarnation=0,this._precipitation=null}initialize(){this.view.stage?.addRenderPlugin(this)}destroy(){this.removeHandles(),this.uninitializeRenderContext(),this.view?.stage?.removeRenderPlugin(this),this._set("view",null)}get updating(){return!!this._clouds.value?.readyToRun}get weatherAvailable(){return a(this.view.state.camera.eye)-u(this.view.spatialReference).radius<=c}get usedMemory(){return this._clouds.value?.usedMemory??0}_fadeOutPrecipitation(){this._precipitation&&(this._precipitationOutgoing?.destroy(),this._precipitationOutgoing=this._precipitation,this._precipitationOutgoing.fadeOut(()=>this._precipitationOutgoing=e(this._precipitationOutgoing)),this._precipitation=null,++this._incarnation)}get _snowCover(){return this._precipitationOutgoing?.snowCover??this._precipitation?.snowCover??0}get weather(){return this.view?.environmentManager?.weatherEnabled?this.view.environment.weather:null}initializeRenderContext(t){this._context=t;const e=this.view,n=()=>this._requestRender();this.addHandles([i(()=>this._precipitation,n,r),i(()=>this._clouds.value?.state,n,r),i(()=>e.state.mode,n,r),i(()=>this._updateClouds(),n,r),i(()=>this._updatePrecipitation(),n,r),i(()=>this.weather,t=>this._initWeather(t))])}uninitializeRenderContext(){this._context=null,this._clouds.value=e(this._clouds.value),this._precipitation=e(this._precipitation),this._precipitationOutgoing=e(this._precipitationOutgoing)}prepareRender(t){const{bind:e,time:i}=t;if(1===this.view.state.viewingMode){if(e.clouds.data){e.clouds.fade(e.camera,i,this.view.qualitySettings.fadeDuration);const t=this._clouds.value;0!==t?.state||0!==t.coverage||t.readyToRun||t.destroyCubeMap()}e.snowCover=this._snowCover}}acquireTechniques(){return[]}render(){}_requestRender(){this._context?.requestRender()}_initWeather(t){const i=this._context;if(!t||!i)return void(this._clouds.value=e(this._clouds.value));if(this._clouds.value)return;const r=this.view;this._clouds.value=new l({context:i.renderContext,view:r,requestRender:()=>this._requestRender()})}_updateClouds(){const t=this.view.environment.weather;return null==t||null==this._clouds.value||this._clouds.value.applyPreset(h[t.type],v(t)),++this._incarnation}_updatePrecipitation(){const t=this.view.environment.weather;if(t.type===this._precipitation?.type)return this._incarnation;this._fadeOutPrecipitation();const e="rainy"===t.type||"snowy"===t.type,i=this._context;return e&&i&&(this._precipitation=new d({view:this.view,type:t.type}),++this._incarnation),this._incarnation}hasHighlight(){return!1}get test(){}};function v(t){switch(t.type){case"rainy":case"snowy":case"cloudy":case"sunny":return t.cloudCover;case"foggy":return t.fogStrength}}t([s({constructOnly:!0})],_.prototype,"view",void 0),t([s({type:Boolean,readOnly:!0})],_.prototype,"updating",null),t([s()],_.prototype,"weatherAvailable",null),t([s()],_.prototype,"_context",void 0),_=t([o("esri.views.3d.webgl-engine.effects.WeatherFader")],_);export{_ as WeatherFader};
2
+ import{__decorate as t}from"tslib";import"../../../../core/has.js";import{destroyMaybe as e}from"../../../../core/maybe.js";import{watch as i,sync as r}from"../../../../core/reactiveUtils.js";import{signal as s}from"../../../../core/signal.js";import{property as n,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{length as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{getReferenceEllipsoid as u}from"../../../../geometry/ellipsoidUtils.js";import{heightLimit as c}from"../../environment/weather.js";import{SyncRenderPlugin as p}from"./RenderPlugin.js";import{cloudPresets as h}from"./clouds/CloudsPresets.js";import{CloudsRenderer as l}from"./clouds/CloudsRenderer.js";import{Precipitation as d}from"./precipitation/Precipitation.js";let _=class extends p{constructor(t){super(t),this.produces=new Map([]),this._clouds=s(null),this._incarnation=0,this._precipitation=null}initialize(){}destroy(){this.removeHandles(),this.uninitializeRenderContext(),this._set("view",null)}get readyToRun(){return!!this._clouds.value?.readyToRun}get weatherAvailable(){return a(this.view.state.camera.eye)-u(this.view.spatialReference).radius<=c}get usedMemory(){return this._clouds.value?.usedMemory??0}_fadeOutPrecipitation(){this._precipitation&&(this._precipitationOutgoing?.destroy(),this._precipitationOutgoing=this._precipitation,this._precipitationOutgoing.fadeOut(()=>this._precipitationOutgoing=e(this._precipitationOutgoing)),this._precipitation=null,++this._incarnation)}get _snowCover(){return this._precipitationOutgoing?.snowCover??this._precipitation?.snowCover??0}get weather(){return this.view?.environmentManager?.weatherEnabled?this.view.environment.weather:null}initializeRenderContext(t){this._context=t;const e=this.view,s=()=>this._requestRender();this.addHandles([i(()=>this._precipitation,s,r),i(()=>this._clouds.value?.state,s,r),i(()=>e.state.mode,s,r),i(()=>this._updateClouds(),s,r),i(()=>this._updatePrecipitation(),s,r),i(()=>this.weather,t=>this._initWeather(t))])}uninitializeRenderContext(){this._context=null,this._clouds.value=e(this._clouds.value),this._precipitation=e(this._precipitation),this._precipitationOutgoing=e(this._precipitationOutgoing)}prepareRender(t){const{bind:e,time:i}=t;if(1===this.view.state.viewingMode){if(e.clouds.data){e.clouds.fade(e.camera,i,this.view.qualitySettings.fadeDuration);const t=this._clouds.value;0!==t?.state||0!==t.coverage||t.readyToRun||t.destroyCubeMap()}e.snowCover=this._snowCover}}acquireTechniques(){return[]}render(){}_requestRender(){this._context?.requestRender()}_initWeather(t){const i=this._context;if(!t||!i)return void(this._clouds.value=e(this._clouds.value));if(this._clouds.value)return;const r=this.view;this._clouds.value=new l({context:i.renderContext,view:r,requestRender:()=>this._requestRender()})}_updateClouds(){const t=this.view.environment.weather;return null==t||null==this._clouds.value||this._clouds.value.applyPreset(h[t.type],v(t)),++this._incarnation}_updatePrecipitation(){const t=this.view.environment.weather;if(t.type===this._precipitation?.type)return this._incarnation;this._fadeOutPrecipitation();const e="rainy"===t.type||"snowy"===t.type,i=this._context;return e&&i&&(this._precipitation=new d({view:this.view,type:t.type}),++this._incarnation),this._incarnation}hasHighlight(){return!1}get test(){}};function v(t){switch(t.type){case"rainy":case"snowy":case"cloudy":case"sunny":return t.cloudCover;case"foggy":return t.fogStrength}}t([n({constructOnly:!0})],_.prototype,"view",void 0),t([n()],_.prototype,"weatherAvailable",null),t([n()],_.prototype,"_context",void 0),_=t([o("esri.views.3d.webgl-engine.effects.WeatherFader")],_);export{_ as WeatherFader};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../../core/Logger.js";import{destroyMaybe as i}from"../../../../../core/maybe.js";import{watch as r,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o,cast as n,subclass as l}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as d}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeVisualizerNode as h}from"./RenderNodeVisualizerNode.js";import{ColorAttachment0 as a}from"../../../../webgl/enums.js";import c from"../../../../../widgets/Widget.js";import{tsx as p}from"../../../../../widgets/support/widget.js";let u=class extends c{constructor(){super(...arguments),this.clearColor=d,this.previewSize=v,this.node=null,this.active=!0,this._previews=new Map,this._allPreviews=new Set,this._dirty=!0,this.previewEnabled=!0}castPreviewSize(e){return Math.max(e,v)}get _namedFilters(){const e=this.filter?.filter(e=>"color"!==e&&"depth"!==e);return e&&e.length>0?e:null}initialize(){this.node||(this.node=new h({view:this.view,destroyedCB:()=>{this.node=null,this.destroy()},clearColor:this.clearColor}));const e=this.node;this.addHandles([r(()=>this.active,i=>{this.view.stage.renderer.fboCache.debugCallback=i?(i,r,s)=>{if(null==i||null==r||!this.view.stage.renderView.renderingContext)return this._previews.forEach(([e])=>e.release()),void this._previews.clear();if("fbo visualizer"===i||null!=this._namedFilters&&!this._namedFilters.includes(i)||r&&0===r.colorAttachments.length&&null==r.depthStencilTexture)return;const{width:o,height:n}=r,l=n>this.previewSize?Math.round(o*this.previewSize/n):o,d=n>this.previewSize?this.previewSize:n;if(l/d>4)return void t.getLogger(this).warnOnce(`Skipping preview of wide ${i} FBO (${l}x${d}px)`);const h=this._fboInFocus?.startsWith(`${i}\n`)??!1,a=e.getDownscaledFBO(r,h,i,l,d),c=null!=r.depthStencilTexture,p=this.filter?.includes("color")||!this.filter?.includes("depth"),u=this.filter?.includes("depth")||!this.filter?.includes("color");a.fbo?.colorAttachments.forEach((e,t)=>{const s=a.getAttachment(e);if(s){s.retain();const l=c&&t===r.colorAttachments.length;if(l&&!u||!l&&!p)return;const d=l?`${i}\ndepth`:`${i}\n${w(r,e)}`,h=this._previews.get(d);h?.[0]?.release(),this._previews.set(d,[s,o,n]),this._allPreviews.add(d)}}),a.detachAllColors(),a.release(),this._dirty=!0}:null},s),r(()=>this.previewEnabled,e=>{e?(this._updatePreviews(),this._updateInterval=setInterval(()=>this._updatePreviews())):this._removeUpdate()},s)])}destroy(){this.removeHandles(),this.view.stage?.renderer&&(this.view.stage.renderer.fboCache.debugCallback=null),this._removeUpdate(),this.node&&(this.node.destroyedCB=()=>{},this.node=i(this.node)),this._previews.forEach(([e])=>e.release()),this._previews.clear()}_updatePreviews(){if(!this._dirty)return;this._dirty=!1,this.renderNow();let e=!1;this._previews.forEach((t,i)=>e=i===this._fboInFocus||e),this._fboInFocus&&!e&&this._deselectFocusFBO(),this._allPreviews.forEach((e,t)=>{const i=this._getElement(t);if(!i)return;i.getContext("2d").clearRect(0,0,i.width,i.height)}),this._previews.forEach(([e,t,i],r)=>{const s=this._getElement(r);if(!s)return;const o=i>this.previewSize?Math.round(t*this.previewSize/i):t,n=i>this.previewSize?this.previewSize:i;s.style.width=`${o}px`,s.style.height=`${n}px`;const l=s.width,d=s.height,h=this._getElement(`label-${r}`);h&&(h.innerText=`${r} (${t}x${i})`);const a=this.node?.getPreviewContent(l,d,e,r),c=s.getContext("2d");c.clearRect(0,0,l,d),a&&c.putImageData(a,0,0)})}_getElement(e){return document.querySelector("arcgis-scene")?.shadowRoot?.getElementById(e)??document.getElementById(e)}_fboPreviewStyle(e){return{width:"1px",height:"1px",background:e?"rgba(0, 0, 0, 0.5)":"rgba(0, 0, 0, 0)",transform:"rotateX(180deg)"}}_removeUpdate(){null!=this._updateInterval&&(clearInterval(this._updateInterval),this._updateInterval=null)}_selectFocusFBO(e){this._fboInFocus=e,this.view.stage.renderView.requestRender()}_deselectFocusFBO(){this._fboInFocus=null,this.node?.clearFocusedFBO(),this.view.stage.renderView.requestRender()}_renderFBOPreviews(){const e=this._allPreviews.size>0?Array.from(this._allPreviews.keys()).sort().map(e=>this._renderFBOPreview(e)):p("div",null);return p("div",{styles:{display:"flex",flexFlow:"row wrap",justifyContent:"flex-end",gap:"2px"}},e)}_renderFBOPreview(e){const t=this._previews.has(e);return p("div",{key:e,onclick:()=>this._selectFocusFBO(e),styles:{display:"flex",flexFlow:"column nowrap",alignItems:"center"}},p("canvas",{id:e,styles:this._fboPreviewStyle(t)}),p("div",{id:e,styles:{display:"flex",justifyContent:"center"}},p("p",{id:`label-${e}`,styles:{fontSize:"12px",color:"white",margin:"1px",textShadow:"-1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000"}})))}render(){return p("div",{class:"esri-widget debug-widget",styles:{display:"flex",flexFlow:"column nowrap",alignItems:"flex-end",background:"rgba(255, 255, 255, 0)"}},this._renderFBOPreviews(),p("button",{onclick:()=>this._deselectFocusFBO(),type:"button"},"Reset focus"))}};function w(e,t){return`${e.getColorTexture(t)?.debugName??"color"+(t-a)}`}e([o({constructOnly:!0})],u.prototype,"view",void 0),e([o({constructOnly:!0})],u.prototype,"clearColor",void 0),e([o()],u.prototype,"previewSize",void 0),e([n("previewSize")],u.prototype,"castPreviewSize",null),e([o()],u.prototype,"filter",void 0),e([o()],u.prototype,"_namedFilters",null),e([o()],u.prototype,"node",void 0),e([o()],u.prototype,"active",void 0),e([o()],u.prototype,"previewEnabled",void 0),u=e([l("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizer")],u);const v=140;export{u as RenderNodeVisualizer,v as minimumPreviewSize};
2
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Logger.js";import{destroyMaybe as i}from"../../../../../core/maybe.js";import{watch as r,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o,cast as n,subclass as l}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as d}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeVisualizerNode as h}from"./RenderNodeVisualizerNode.js";import{ColorAttachment0 as a}from"../../../../webgl/enums.js";import c from"../../../../../widgets/Widget.js";import{tsx as p}from"../../../../../widgets/support/widget.js";let u=class extends c{constructor(){super(...arguments),this.clearColor=d,this.previewSize=v,this.node=null,this.active=!0,this._previews=new Map,this._allPreviews=new Set,this._dirty=!0,this.previewEnabled=!0}castPreviewSize(e){return Math.max(e,v)}get _namedFilters(){const e=this.filter?.filter(e=>"color"!==e&&"depth"!==e);return e&&e.length>0?e:null}initialize(){this.node||(this.node=new h({view:this.view,destroyedCB:()=>{this.node=null,this.destroy()},clearColor:this.clearColor}));const e=this.node;this.addHandles([r(()=>this.active,i=>{this.view.stage.renderer.fboCache.debugCallback=i?(i,r)=>{if(null==i||null==r||!this.view.stage.renderView.renderingContext)return this._previews.forEach(([e])=>e.release()),void this._previews.clear();if("fbo visualizer"===i||null!=this._namedFilters&&!this._namedFilters.includes(i)||r&&0===r.colorAttachments.length&&null==r.depthStencilTexture)return;const{width:s,height:o}=r,n=o>this.previewSize?Math.round(s*this.previewSize/o):s,l=o>this.previewSize?this.previewSize:o;if(n/l>4)return void t.getLogger(this).warnOnce(`Skipping preview of wide ${i} FBO (${n}x${l}px)`);const d=this._fboInFocus?.startsWith(`${i}\n`)??!1,h=e.getDownscaledFBO(r,d,i,n,l),a=null!=r.depthStencilTexture,c=this.filter?.includes("color")||!this.filter?.includes("depth"),p=this.filter?.includes("depth")||!this.filter?.includes("color");h.fbo?.colorAttachments.forEach((e,t)=>{const n=h.getAttachment(e);if(n){n.retain();const l=a&&t===r.colorAttachments.length;if(l&&!p||!l&&!c)return;const d=l?`${i}\ndepth`:`${i}\n${w(r,e)}`,h=this._previews.get(d);h?.[0]?.release(),this._previews.set(d,[n,s,o]),this._allPreviews.add(d)}}),h.detachAllColors(),h.release(),this._dirty=!0}:null},s),r(()=>this.previewEnabled,e=>{e?(this._updatePreviews(),this._updateInterval=setInterval(()=>this._updatePreviews())):this._removeUpdate()},s)])}destroy(){this.removeHandles(),this.view.stage?.renderer&&(this.view.stage.renderer.fboCache.debugCallback=null),this._removeUpdate(),this.node&&(this.node.destroyedCB=()=>{},this.node=i(this.node)),this._previews.forEach(([e])=>e.release()),this._previews.clear()}_updatePreviews(){if(!this._dirty)return;this._dirty=!1,this.renderNow();let e=!1;this._previews.forEach((t,i)=>e=i===this._fboInFocus||e),this._fboInFocus&&!e&&this._deselectFocusFBO(),this._allPreviews.forEach((e,t)=>{const i=this._getElement(t);if(!i)return;i.getContext("2d").clearRect(0,0,i.width,i.height)}),this._previews.forEach(([e,t,i],r)=>{const s=this._getElement(r);if(!s)return;const o=i>this.previewSize?Math.round(t*this.previewSize/i):t,n=i>this.previewSize?this.previewSize:i;s.style.width=`${o}px`,s.style.height=`${n}px`;const l=s.width,d=s.height,h=this._getElement(`label-${r}`);h&&(h.innerText=`${r} (${t}x${i})`);const a=this.node?.getPreviewContent(l,d,e,r),c=s.getContext("2d");c.clearRect(0,0,l,d),a&&c.putImageData(a,0,0)})}_getElement(e){return document.querySelector("arcgis-scene")?.shadowRoot?.getElementById(e)??document.getElementById(e)}_fboPreviewStyle(e){return{width:"1px",height:"1px",background:e?"rgba(0, 0, 0, 0.5)":"rgba(0, 0, 0, 0)",transform:"rotateX(180deg)"}}_removeUpdate(){null!=this._updateInterval&&(clearInterval(this._updateInterval),this._updateInterval=null)}_selectFocusFBO(e){this._fboInFocus=e,this.view.stage.renderView.requestRender()}_deselectFocusFBO(){this._fboInFocus=null,this.node?.clearFocusedFBO(),this.view.stage.renderView.requestRender()}_renderFBOPreviews(){const e=this._allPreviews.size>0?Array.from(this._allPreviews.keys()).sort().map(e=>this._renderFBOPreview(e)):p("div",null);return p("div",{styles:{display:"flex",flexFlow:"row wrap",justifyContent:"flex-end",gap:"2px"}},e)}_renderFBOPreview(e){const t=this._previews.has(e);return p("div",{key:e,onclick:()=>this._selectFocusFBO(e),styles:{display:"flex",flexFlow:"column nowrap",alignItems:"center"}},p("canvas",{id:e,styles:this._fboPreviewStyle(t)}),p("div",{id:e,styles:{display:"flex",justifyContent:"center"}},p("p",{id:`label-${e}`,styles:{fontSize:"12px",color:"white",margin:"1px",textShadow:"-1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000"}})))}render(){return p("div",{class:"esri-widget debug-widget",styles:{display:"flex",flexFlow:"column nowrap",alignItems:"flex-end",background:"rgba(255, 255, 255, 0)"}},this._renderFBOPreviews(),p("button",{onclick:()=>this._deselectFocusFBO(),type:"button"},"Reset focus"))}};function w(e,t){return`${e.getColorTexture(t)?.debugName??"color"+(t-a)}`}e([o({constructOnly:!0})],u.prototype,"view",void 0),e([o({constructOnly:!0})],u.prototype,"clearColor",void 0),e([o()],u.prototype,"previewSize",void 0),e([n("previewSize")],u.prototype,"castPreviewSize",null),e([o()],u.prototype,"filter",void 0),e([o()],u.prototype,"_namedFilters",null),e([o()],u.prototype,"node",void 0),e([o()],u.prototype,"active",void 0),e([o()],u.prototype,"previewEnabled",void 0),u=e([l("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizer")],u);const v=140;export{u as RenderNodeVisualizer,v as minimumPreviewSize};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{property as i,subclass as n}from"../../../../../core/accessorSupport/decorators.js";import{copy as s,add as r}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromRay as a,getStart as l,getEnd as h,create as o}from"../../../../../geometry/support/clipRay.js";import{intersectClipRay as c}from"../../../../../geometry/support/frustum.js";import{copy as d}from"../../../../../geometry/support/lineSegment.js";import{wrap as p}from"../../../../../geometry/support/ray.js";import{InternalRenderCategory as u}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{Blit as g}from"../blit/Blit.js";import{LaserlinePathData as _}from"./LaserlinePathData.js";import{LaserlinePathPassParameters as b,LaserlinePathTechnique as f}from"./LaserlinePathTechnique.js";import{LaserlinePathTechniqueConfiguration as P}from"./LaserlinePathTechniqueConfiguration.js";import{LaserlineTechnique as E}from"./LaserlineTechnique.js";import{LaserlineTechniqueConfiguration as q}from"./LaserlineTechniqueConfiguration.js";import{updateParameters as V}from"../../materials/internal/MaterialUtil.js";let L=class extends m{constructor(e){super(e),this.isDecoration=!0,this.produces=u.LASERLINES,this.consumes={required:[u.LASERLINES,"normals"]},this.requireGeometryDepth=!0,this._configuration=new q,this._pathTechniqueConfiguration=new P,this._heightManifoldEnabled=!1,this._pointDistanceEnabled=!1,this._lineVerticalPlaneEnabled=!1,this._intersectsLineEnabled=!1,this._intersectsLineInfinite=!1,this._pathVerticalPlaneEnabled=!1,this._passParameters=new b;const t=e.view.stage.renderView.techniques,i=new P;i.contrastControlEnabled=e.contrastControlEnabled,t.precompile(f,i)}initialize(){this._passParameters.renderCoordsHelper=this.view.renderCoordsHelper,this._pathTechniqueConfiguration.spherical=1===this.view.state.viewingMode,this._pathTechniqueConfiguration.contrastControlEnabled=this.contrastControlEnabled,this._techniques.precompile(f,this._pathTechniqueConfiguration),this._blit=new g(this._techniques,2)}destroy(){this._pathVerticalPlaneData=t(this._pathVerticalPlaneData),this._blit=null}get _techniques(){return this.view.stage.renderView.techniques}get heightManifoldEnabled(){return this._heightManifoldEnabled}set heightManifoldEnabled(e){this._heightManifoldEnabled!==e&&(this._heightManifoldEnabled=e,this.requestRender(1))}get heightManifoldTarget(){return this._passParameters.heightManifoldTarget}set heightManifoldTarget(e){s(this._passParameters.heightManifoldTarget,e),this.requestRender(1)}get pointDistanceEnabled(){return this._pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._pointDistanceEnabled&&(this._pointDistanceEnabled=e,this.requestRender(1))}get pointDistanceTarget(){return this._passParameters.pointDistanceTarget}set pointDistanceTarget(e){s(this._passParameters.pointDistanceTarget,e),this.requestRender(1)}get pointDistanceOrigin(){return this._passParameters.pointDistanceOrigin}set pointDistanceOrigin(e){s(this._passParameters.pointDistanceOrigin,e),this.requestRender(1)}get lineVerticalPlaneEnabled(){return this._lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._lineVerticalPlaneEnabled&&(this._lineVerticalPlaneEnabled=e,this.requestRender(1))}get lineVerticalPlaneSegment(){return this._passParameters.lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){d(e,this._passParameters.lineVerticalPlaneSegment),this.requestRender(1)}get intersectsLineEnabled(){return this._intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._intersectsLineEnabled&&(this._intersectsLineEnabled=e,this.requestRender(1))}get intersectsLineSegment(){return this._passParameters.intersectsLineSegment}set intersectsLineSegment(e){d(e,this._passParameters.intersectsLineSegment),this.requestRender(1)}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this.requestRender(1))}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,null!=this._pathVerticalPlaneData&&this.requestRender(1))}set pathVerticalPlaneVertices(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new _(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this.requestRender(1)}set pathVerticalPlaneBuffers(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new _(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this.requestRender(1)}setParameters(e){V(this._passParameters,e)&&this.requestRender(1)}precompile(){this._acquireTechnique(),this._blit?.precompile(),this.pathVerticalPlaneEnabled&&this._pathVerticalPlaneData&&this._techniques.precompile(f,this._pathTechniqueConfiguration)}render(e){const t=e.find(({name:e})=>e===this.produces);if(this.isDecoration&&!this.bindParameters.decorations||null==this._blit)return t;const i=this.renderingContext,n=e.find(({name:e})=>"normals"===e);this._passParameters.normals=n?.getTexture();const s=()=>{(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(),this.pathVerticalPlaneEnabled&&this._renderPath()};if(!this.contrastControlEnabled)return i.bindFramebuffer(t.fbo),s(),t;this._passParameters.colors=t.getTexture();const r=this.fboCache.acquire(t.fbo.width,t.fbo.height,"laser lines");return i.bindFramebuffer(r.fbo),i.setClearColor(0,0,0,0),i.clear(16640),s(),i.unbindTexture(t.getTexture()),this._blit.blend(i,r,t,this.bindParameters)||this.requestRender(1),r.release(),t}_acquireTechnique(){return this._configuration.heightManifoldEnabled=this.heightManifoldEnabled,this._configuration.lineVerticalPlaneEnabled=this.lineVerticalPlaneEnabled,this._configuration.pointDistanceEnabled=this.pointDistanceEnabled,this._configuration.intersectsLineEnabled=this.intersectsLineEnabled,this._configuration.contrastControlEnabled=this.contrastControlEnabled,this._configuration.spherical=1===this.view.state.viewingMode,this._techniques.getCompiled(E,this._configuration)}_renderUnified(){if(!this._updatePassParameters())return;const e=this._acquireTechnique();if(e){const t=this.renderingContext;t.bindTechnique(e,this.bindParameters,this._passParameters),t.screen.draw()}else this.requestRender(1)}_renderPath(){if(null==this._pathVerticalPlaneData)return;const e=this._techniques.get(f,this._pathTechniqueConfiguration);if(e.compiled){const t=this.renderingContext;this._passParameters.origin=this._pathVerticalPlaneData.origin,t.bindTechnique(e,this.bindParameters,this._passParameters),this._pathVerticalPlaneData.draw(t)}else this.requestRender(1)}_updatePassParameters(){if(!this._intersectsLineEnabled)return!0;const e=this.bindParameters.camera,t=this._passParameters;if(this._intersectsLineInfinite){if(a(p(t.intersectsLineSegment.origin,t.intersectsLineSegment.vector),D),D.c0=-Number.MAX_VALUE,!c(e.frustum,D))return!1;l(D,t.lineStartWorld),h(D,t.lineEndWorld)}else s(t.lineStartWorld,t.intersectsLineSegment.origin),r(t.lineEndWorld,t.intersectsLineSegment.origin,t.intersectsLineSegment.vector);return!0}get test(){}};e([i({constructOnly:!0})],L.prototype,"contrastControlEnabled",void 0),e([i()],L.prototype,"isDecoration",void 0),e([i()],L.prototype,"produces",void 0),e([i()],L.prototype,"consumes",void 0),L=e([n("esri.views.3d.webgl-engine.effects.laserlines.LaserLineRenderer")],L);const D=o();export{L as LaserLineRenderer};
2
+ import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{property as i,subclass as n}from"../../../../../core/accessorSupport/decorators.js";import{copy as s,add as r}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromRay as a,getStart as l,getEnd as h,create as o}from"../../../../../geometry/support/clipRay.js";import{intersectClipRay as c}from"../../../../../geometry/support/frustum.js";import{copy as d}from"../../../../../geometry/support/lineSegment.js";import{wrap as p}from"../../../../../geometry/support/ray.js";import{InternalRenderCategory as u}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{Blit as _}from"../blit/Blit.js";import{LaserlinePathData as g}from"./LaserlinePathData.js";import{LaserlinePathPassParameters as b,LaserlinePathTechnique as f}from"./LaserlinePathTechnique.js";import{LaserlinePathTechniqueConfiguration as P}from"./LaserlinePathTechniqueConfiguration.js";import{LaserlineTechnique as E}from"./LaserlineTechnique.js";import{LaserlineTechniqueConfiguration as q}from"./LaserlineTechniqueConfiguration.js";import{updateParameters as L}from"../../materials/internal/MaterialUtil.js";let V=class extends m{constructor(e){super(e),this.isDecoration=!0,this.produces=u.LASERLINES,this.consumes={required:[u.LASERLINES,"normals"]},this.requireGeometryDepth=!0,this._configuration=new q,this._pathTechniqueConfiguration=new P,this._heightManifoldEnabled=!1,this._pointDistanceEnabled=!1,this._lineVerticalPlaneEnabled=!1,this._intersectsLineEnabled=!1,this._intersectsLineInfinite=!1,this._pathVerticalPlaneEnabled=!1,this._passParameters=new b;const t=e.view.stage.renderView.techniques,i=new P;i.contrastControlEnabled=e.contrastControlEnabled,t.precompile(f,i)}initialize(){this._passParameters.renderCoordsHelper=this.view.renderCoordsHelper,this._pathTechniqueConfiguration.spherical=1===this.view.state.viewingMode,this._pathTechniqueConfiguration.contrastControlEnabled=this.contrastControlEnabled,this._techniques.precompile(f,this._pathTechniqueConfiguration),this._blit=new _(this._techniques,2)}destroy(){this._pathVerticalPlaneData=t(this._pathVerticalPlaneData),this._blit=null}get _techniques(){return this.view.stage.renderView.techniques}get heightManifoldEnabled(){return this._heightManifoldEnabled}set heightManifoldEnabled(e){this._heightManifoldEnabled!==e&&(this._heightManifoldEnabled=e,this.requestRender(1))}get heightManifoldTarget(){return this._passParameters.heightManifoldTarget}set heightManifoldTarget(e){s(this._passParameters.heightManifoldTarget,e),this.requestRender(1)}get pointDistanceEnabled(){return this._pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._pointDistanceEnabled&&(this._pointDistanceEnabled=e,this.requestRender(1))}get pointDistanceTarget(){return this._passParameters.pointDistanceTarget}set pointDistanceTarget(e){s(this._passParameters.pointDistanceTarget,e),this.requestRender(1)}get pointDistanceOrigin(){return this._passParameters.pointDistanceOrigin}set pointDistanceOrigin(e){s(this._passParameters.pointDistanceOrigin,e),this.requestRender(1)}get lineVerticalPlaneEnabled(){return this._lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._lineVerticalPlaneEnabled&&(this._lineVerticalPlaneEnabled=e,this.requestRender(1))}get lineVerticalPlaneSegment(){return this._passParameters.lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){d(e,this._passParameters.lineVerticalPlaneSegment),this.requestRender(1)}get intersectsLineEnabled(){return this._intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._intersectsLineEnabled&&(this._intersectsLineEnabled=e,this.requestRender(1))}get intersectsLineSegment(){return this._passParameters.intersectsLineSegment}set intersectsLineSegment(e){d(e,this._passParameters.intersectsLineSegment),this.requestRender(1)}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this.requestRender(1))}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,null!=this._pathVerticalPlaneData&&this.requestRender(1))}set pathVerticalPlaneVertices(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new g(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this.requestRender(1)}set pathVerticalPlaneBuffers(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new g(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this.requestRender(1)}setParameters(e){L(this._passParameters,e)&&this.requestRender(1)}precompile(){this._acquireTechnique(),this._blit?.precompile(),this.pathVerticalPlaneEnabled&&this._pathVerticalPlaneData&&this._techniques.precompile(f,this._pathTechniqueConfiguration)}render(e){const t=e.find(({name:e})=>e===this.produces);if(this.isDecoration&&!this.bindParameters.decorations||null==this._blit)return t;const i=this.renderingContext,n=e.find(({name:e})=>"normals"===e);if(this._passParameters.normals=n?.getTexture(),!this.contrastControlEnabled)return i.bindFramebuffer(t.fbo),this._renderLaserLines(),t;this._passParameters.colors=t.getTexture();const s=this.fboCache.acquire(t.fbo.width,t.fbo.height,"laser lines");return i.bindFramebuffer(s.fbo),i.setClearColor(0,0,0,0),i.clear(16640),this._renderLaserLines(),i.unbindTexture(t.getTexture()),this._blit.blend(i,s,t,this.bindParameters)||this.requestRender(1),s.release(),t}_renderLaserLines(){(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(),this.pathVerticalPlaneEnabled&&this._renderPath()}_acquireTechnique(){return this._configuration.heightManifoldEnabled=this.heightManifoldEnabled,this._configuration.lineVerticalPlaneEnabled=this.lineVerticalPlaneEnabled,this._configuration.pointDistanceEnabled=this.pointDistanceEnabled,this._configuration.intersectsLineEnabled=this.intersectsLineEnabled,this._configuration.contrastControlEnabled=this.contrastControlEnabled,this._configuration.spherical=1===this.view.state.viewingMode,this._techniques.getCompiled(E,this._configuration)}_renderUnified(){if(!this._updatePassParameters())return;const e=this._acquireTechnique();if(e){const t=this.renderingContext;t.bindTechnique(e,this.bindParameters,this._passParameters),t.screen.draw()}else this.requestRender(1)}_renderPath(){if(null==this._pathVerticalPlaneData)return;const e=this._techniques.get(f,this._pathTechniqueConfiguration);if(e.compiled){const t=this.renderingContext;this._passParameters.origin=this._pathVerticalPlaneData.origin,t.bindTechnique(e,this.bindParameters,this._passParameters),this._pathVerticalPlaneData.draw(t)}else this.requestRender(1)}_updatePassParameters(){if(!this._intersectsLineEnabled)return!0;const e=this.bindParameters.camera,t=this._passParameters;if(this._intersectsLineInfinite){if(a(p(t.intersectsLineSegment.origin,t.intersectsLineSegment.vector),D),D.c0=-Number.MAX_VALUE,!c(e.frustum,D))return!1;l(D,t.lineStartWorld),h(D,t.lineEndWorld)}else s(t.lineStartWorld,t.intersectsLineSegment.origin),r(t.lineEndWorld,t.intersectsLineSegment.origin,t.intersectsLineSegment.vector);return!0}get test(){}};e([i({constructOnly:!0})],V.prototype,"contrastControlEnabled",void 0),e([i()],V.prototype,"isDecoration",void 0),e([i()],V.prototype,"produces",void 0),e([i()],V.prototype,"consumes",void 0),V=e([n("esri.views.3d.webgl-engine.effects.laserlines.LaserLineRenderer")],V);const D=o();export{V as LaserLineRenderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{nextPowerOfTwo as e}from"../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as r}from"../../../../core/maybe.js";import{property as s,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{ortho as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{set as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UNIT_X as l,ZEROS as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as d,InternalRenderCategory as p}from"../../webgl.js";import{Frustum as f}from"../../state/Frustum.js";import{glLayout as _}from"../../support/buffer/glUtil.js";import{newLayout as m}from"../../support/buffer/InterleavedLayout.js";import g from"../../webgl/RenderCamera.js";import C from"../../webgl/RenderNode.js";import{ShaderOutputConfiguration as F}from"../core/shaderLibrary/ShaderOutputConfiguration.js";import{VertexArrayObject as R}from"./VertexArrayObject.js";import{C as w}from"../../../../chunks/CutFillDepth.glsl.js";import{CutFillDepthTechnique as P}from"../shaders/CutFillDepthTechnique.js";import{CutFillDepthTechniqueConfiguration as T}from"../shaders/CutFillDepthTechniqueConfiguration.js";import{C as b}from"../../../../chunks/CutFillReduction.glsl.js";import{CutFillReductionTechnique as x}from"../shaders/CutFillReductionTechnique.js";import{CutFillReductionTechniqueConfiguration as y}from"../shaders/CutFillReductionTechniqueConfiguration.js";import{C as D}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{CutFillTargetDepthTechnique as B}from"../shaders/CutFillTargetDepthTechnique.js";import{ImmediateTask as j,TaskPriority as q}from"../../../support/Scheduler.js";import{Yield as S}from"../../../support/Yield.js";import{PrimitiveType as v,DataType as O}from"../../../webgl/enums.js";import{Sync as V}from"../../../webgl/Sync.js";import{VertexBuffer as E}from"../../../webgl/VertexBuffer.js";let A=class extends C{constructor(t){super(t),this.consumes={required:[d.TRANSPARENT]},this.produces=p.CUTFILL_COMPUTATION,this._cutFillTargetDepthConfiguration=new F,this._cutFillDepthConfiguration=new T,this._cutFillReductionConfiguration=new y,this._cutFillTargetDepthParameters=new D,this._cutFillDepthParameters=new w,this._cutFillReductionParameters=new b,this.needsRender=!1,this.readyToRun=!1,this.done=!0,this._frameTask=j,this._result=new k,this._localOrigin=u(),this._maxTextureSize=512,this._width=0,this._height=0,this._reducedWidth=0,this._reducedHeight=0,this._depthFormat=13,this._colorFormat=10,this._numChannels=2,this._targetGeometryVao=null,this._numReductions=3,this._reductionPasses=0,this._pixelBufferSize=0,this._pixelBufferOffset=0,this._perReductionPixelBufferSize=0}initialize(){this._frameTask=this.view.resourceController.scheduler.registerTask(q.VOLUME_MEASUREMENT,this),this.addHandles(this._frameTask),this._maxTextureSize=Math.min(this._maxTextureSize,this.fboCache.rctx.parameters.maxTextureSize),this._cutFillTargetDepthConfiguration.output=7,this._frustum=new f(this.view.renderCoordsHelper)}destroy(){this._targetGeometryVao=i(this._targetGeometryVao);const t=this.gl;this._sync=r(this._sync),this._pixelBuffer&&(t.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0)}precompile(){this.techniques.precompile(B,this._cutFillTargetDepthConfiguration),this._cutFillDepthConfiguration.preparePass=0,this.techniques.precompile(P,this._cutFillDepthConfiguration),this._cutFillDepthConfiguration.preparePass=1,this.techniques.precompile(P,this._cutFillDepthConfiguration),this._cutFillReductionConfiguration.reductionPass=0,this.techniques.precompile(x,this._cutFillReductionConfiguration),this._cutFillReductionConfiguration.reductionPass=1,this.techniques.precompile(x,this._cutFillReductionConfiguration),this._cutFillReductionConfiguration.reductionPass=2,this.techniques.precompile(x,this._cutFillReductionConfiguration),this.view.stage.renderer.precompileCutFillReferenceDepth()}render(t){const e=t.find(({name:t})=>t===this.produces);if(!this._orthographicCamera||!this._targetGeometryVao||!this.needsRender||this._sync)return e;const i=this.techniques.getCompiled(B,this._cutFillTargetDepthConfiguration);this._cutFillDepthConfiguration.preparePass=0;const r=this.techniques.getCompiled(P,this._cutFillDepthConfiguration);this._cutFillDepthConfiguration.preparePass=1;const s=this.techniques.getCompiled(P,this._cutFillDepthConfiguration);this._cutFillReductionConfiguration.reductionPass=0;const h=this.techniques.getCompiled(x,this._cutFillReductionConfiguration);this._cutFillReductionConfiguration.reductionPass=1;const o=this.techniques.getCompiled(x,this._cutFillReductionConfiguration);this._cutFillReductionConfiguration.reductionPass=2;const n=this.techniques.getCompiled(x,this._cutFillReductionConfiguration);if(!(i&&r&&s&&h&&o&&n))return this.requestRender(1),e;this.needsRender=!1;const a=this.renderingContext,u=this.fboCache,d=this.gl,p=a.getViewport(),f=u.acquire(this._width,this._height,"cutfill reference depth",this._depthFormat);a.bindFramebuffer(f.fbo),a.setViewport(0,0,this._width,this._height),a.clear(1280),this.view.stage.renderer.renderCutFillReferenceDepth(this._orthographicCamera);const _=u.acquire(this._width,this._height,"cutfill target depth",this._depthFormat);a.bindFramebuffer(_.fbo),a.setViewport(0,0,this._width,this._height),a.setClearDepth(1),a.clear(256),this._cutFillTargetDepthParameters.origin=this._localOrigin,this._cutFillTargetDepthParameters.cutFillCamera=this._orthographicCamera,a.bindTechnique(i,this.bindParameters,this._cutFillTargetDepthParameters),a.bindVAO(this._targetGeometryVao),a.drawArrays(v.TRIANGLES,0,this._targetGeometryVao.vertexCount("geometry"));const m=u.acquire(this._width,this._height,"cutfill reduction even",this._colorFormat),g=u.acquire(this._width,this._height,"cutfill reduction odd",this._colorFormat);return this._cutFillDepthParameters.referenceDepthTexture=f.depthTexture,this._cutFillDepthParameters.targetDepthTexture=_.depthTexture,this._pixelBuffer||(this._pixelBuffer=d.createBuffer()),d.bindBuffer(d.PIXEL_PACK_BUFFER,this._pixelBuffer),d.bufferData(d.PIXEL_PACK_BUFFER,this._pixelBufferSize,d.STREAM_READ),this._prepareFBO(m,this.width,this.height),a.bindTechnique(r,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(m,g,h),this._prepareFBO(m,this.width,this.height,l),a.bindTechnique(s,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(m,g,o),this._prepareFBO(m,this.width,this.height,c),a.bindTechnique(s,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(m,g,n),f.release(),_.release(),m.release(),g.release(),d.bindBuffer(d.PIXEL_PACK_BUFFER,null),a.setViewport(p.x,p.y,p.width,p.height),this._sync=new V(d),setTimeout(()=>this.readyToRun=!0,0),e}update(t,i){if(!this.done)return;this.done=!1;const r=this.renderingContext,{cameraDimensions:{width:s,height:h},localOriginRenderSpace:o}=t,n=this._maxTextureSize,a=h/s,u=s>h?n:n/a,l=s>h?n*a:n;this._width=e(u),this._height=e(l);const c=[this._width,this._height];this._orthographicCamera=this._createCamera(t,c),this._frustum?.update(this._orthographicCamera),this._updateTargetVao(r,i),this._localOrigin=o,this._reductionPasses=Math.ceil(Math.log2(Math.min(this._width,this._height))),this._reducedWidth=Math.ceil(this._width/2**this._reductionPasses),this._reducedHeight=Math.ceil(this._height/2**this._reductionPasses),this._perReductionPixelBufferSize=this._reducedWidth*this._reducedHeight*this._numChannels*4,this._pixelBufferSize=this._perReductionPixelBufferSize*this._numReductions,this._pixelBufferOffset=0,this.needsRender=!0,this.requestRender(1)}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return S}catch(e){return this.readyToRun=!1,void(this._sync=r(this._sync))}this.readyToRun=!1,this._sync=r(this._sync);const t=this.gl;this._cpuBuffer=new Float32Array(this._pixelBufferSize/4),t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pixelBuffer),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._cpuBuffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),this._updateResults(this._cpuBuffer),this.done=!0}getResult(){return this._result}get frustum(){return this._frustum}get width(){return this._width}get height(){return this._height}get updating(){return this.readyToRun||!this.done||this._frameTask.updating}_runPyramidReduction(t,e,i){const r=this.renderingContext,s=this.gl;let h=this._width,o=this._height;for(let n=0;n<this._reductionPasses;n++)h=Math.ceil(h/2),o=Math.ceil(o/2),this._cutFillReductionParameters.depthTexture=t.getTexture(),this._prepareFBO(e,h,o),r.bindTechnique(i,this.bindParameters,this._cutFillReductionParameters),r.screen.draw(),[t,e]=[e,t];s.readPixels(0,0,h,o,33319,O.FLOAT,this._pixelBufferOffset),this._pixelBufferOffset+=this._perReductionPixelBufferSize}_updateResults(t){const e=new U(0,1,a()),i=new U(0,0,a());for(let r=0;r<this._reducedWidth;r++)for(let s=0;s<this._reducedHeight;s++){let h=(r+s*this._reducedWidth)*this._numChannels;const o=this._reducedWidth*this._reducedHeight*this._numChannels;e.totalDepth+=t[h],i.totalDepth+=t[h+1],h+=o;const n=t[h];n<e.labelDepth&&(e.labelDepth=n,M(e.labelCoords,t[h+1],this._width)),h+=o;const a=t[h];a>i.labelDepth&&(i.labelDepth=a,M(i.labelCoords,t[h+1],this._width))}this._result=new k(this._width,this._height,e,i)}_prepareFBO(t,e,i,r=c){const s=this.renderingContext;s.bindFramebuffer(t.fbo),s.setViewport(0,0,e,i),s.setClearColor(r[0],r[1],r[2],r[3]),s.clear(16384)}_createCamera(t,e){const{cameraPositionRenderSpace:i,localOriginRenderSpace:r,northVector:s,cameraDimensions:{width:h,height:n},cameraNearFar:{near:a,far:u}}=t,l=new g({eye:i,center:r,up:s,near:a,far:u});return l.viewport=[0,0,e[0],e[1]],o(l.projectionMatrix,-h/2,h/2,-n/2,n/2,a,u),l}_updateTargetVao(t,e){this._targetGeometryVao=i(this._targetGeometryVao);const r=e.reduce((t,e)=>t+e.indices.length,0),s=z.createBuffer(r),h=s.position;let o=0;for(const i of e){const{positions:t,indices:e}=i;for(let i=0;i<e.length;++i){const r=3*e[i];h.set(o,0,t[r]),h.set(o,1,t[r+1]),h.set(o,2,t[r+2]),o++}}const n=new E(t,_(z),s.buffer);this._targetGeometryVao=new R(t,n)}};t([s()],A.prototype,"consumes",void 0),t([s()],A.prototype,"produces",void 0),t([s()],A.prototype,"needsRender",void 0),t([s()],A.prototype,"readyToRun",void 0),t([s()],A.prototype,"done",void 0),t([s()],A.prototype,"updating",null),t([s()],A.prototype,"_frameTask",void 0),A=t([h("esri.views.3d.webgl-engine.lib.CutFillComputationRenderNode")],A);const z=m().vec3f("position").freeze();function M(t,e,i){const r=e%i,s=Math.floor(e/i);n(t,r,s)}class L{constructor(t,e){this.positions=t,this.indices=e}}class U{constructor(t,e,i){this.totalDepth=t,this.labelDepth=e,this.labelCoords=i}}class k{constructor(t=0,e=0,i=new U(0,1,a()),r=new U(0,0,a())){this.width=t,this.height=e,this.cut=i,this.fill=r}}export{A as CutFillComputationRenderNode,k as CutFillComputationResult,U as CutFillDepthResult,L as TargetGeometryRenderInfo};
2
+ import{__decorate as t}from"tslib";import{nextPowerOfTwo as e}from"../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as r}from"../../../../core/maybe.js";import{property as s,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{ortho as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{set as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UNIT_X as c,ZEROS as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as d,InternalRenderCategory as p}from"../../webgl.js";import{Frustum as f}from"../../state/Frustum.js";import{glLayout as _}from"../../support/buffer/glUtil.js";import{newLayout as m}from"../../support/buffer/InterleavedLayout.js";import g from"../../webgl/RenderCamera.js";import C from"../../webgl/RenderNode.js";import{ShaderOutputConfiguration as F}from"../core/shaderLibrary/ShaderOutputConfiguration.js";import{VertexArrayObject as R}from"./VertexArrayObject.js";import{C as w}from"../../../../chunks/CutFillDepth.glsl.js";import{CutFillDepthTechnique as x}from"../shaders/CutFillDepthTechnique.js";import{CutFillDepthTechniqueConfiguration as P}from"../shaders/CutFillDepthTechniqueConfiguration.js";import{C as T}from"../../../../chunks/CutFillReduction.glsl.js";import{CutFillReductionTechnique as y}from"../shaders/CutFillReductionTechnique.js";import{CutFillReductionTechniqueConfiguration as b}from"../shaders/CutFillReductionTechniqueConfiguration.js";import{C as B}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{CutFillTargetDepthTechnique as D}from"../shaders/CutFillTargetDepthTechnique.js";import{ImmediateTask as j,TaskPriority as q}from"../../../support/Scheduler.js";import{Yield as E}from"../../../support/Yield.js";import{PrimitiveType as S,DataType as v}from"../../../webgl/enums.js";import{Sync as O}from"../../../webgl/Sync.js";import{VertexBuffer as V}from"../../../webgl/VertexBuffer.js";let A=class extends C{constructor(t){super(t),this.consumes={required:[d.TRANSPARENT]},this.produces=p.CUTFILL_COMPUTATION,this._cutFillTargetDepthConfiguration=new F,this._cutFillDepthConfiguration=new P,this._cutFillReductionConfiguration=new b,this._cutFillTargetDepthParameters=new B,this._cutFillDepthParameters=new w,this._cutFillReductionParameters=new T,this.needsRender=!1,this.readyToRun=!1,this.done=!0,this._frameTask=j,this._result=new k,this._localOrigin=a(),this._maxTextureSize=512,this._width=0,this._height=0,this._reducedWidth=0,this._reducedHeight=0,this._depthFormat=13,this._colorFormat=10,this._numChannels=2,this._targetGeometryVao=null,this._numReductions=3,this._reductionPasses=0,this._pixelBufferSize=0,this._pixelBufferOffset=0,this._perReductionPixelBufferSize=0}initialize(){this._frameTask=this.view.resourceController.scheduler.registerTask(q.VOLUME_MEASUREMENT,this),this.addHandles(this._frameTask),this._maxTextureSize=Math.min(this._maxTextureSize,this.fboCache.rctx.parameters.maxTextureSize),this._cutFillTargetDepthConfiguration.output=7,this._frustum=new f(this.view.renderCoordsHelper)}destroy(){this._targetGeometryVao=i(this._targetGeometryVao);const t=this.gl;this._sync=r(this._sync),this._pixelBuffer&&(t.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0)}precompile(){this.techniques.precompile(D,this._cutFillTargetDepthConfiguration),this._cutFillDepthConfiguration.preparePass=0,this.techniques.precompile(x,this._cutFillDepthConfiguration),this._cutFillDepthConfiguration.preparePass=1,this.techniques.precompile(x,this._cutFillDepthConfiguration),this._cutFillReductionConfiguration.reductionPass=0,this.techniques.precompile(y,this._cutFillReductionConfiguration),this._cutFillReductionConfiguration.reductionPass=1,this.techniques.precompile(y,this._cutFillReductionConfiguration),this._cutFillReductionConfiguration.reductionPass=2,this.techniques.precompile(y,this._cutFillReductionConfiguration),this.view.stage.renderer.precompileCutFillReferenceDepth()}render(t){const e=t.find(({name:t})=>t===this.produces);if(!this._orthographicCamera||!this._targetGeometryVao||!this.needsRender||this._sync)return e;const i=this.techniques.getCompiled(D,this._cutFillTargetDepthConfiguration);this._cutFillDepthConfiguration.preparePass=0;const r=this.techniques.getCompiled(x,this._cutFillDepthConfiguration);this._cutFillDepthConfiguration.preparePass=1;const s=this.techniques.getCompiled(x,this._cutFillDepthConfiguration);this._cutFillReductionConfiguration.reductionPass=0;const h=this.techniques.getCompiled(y,this._cutFillReductionConfiguration);this._cutFillReductionConfiguration.reductionPass=1;const o=this.techniques.getCompiled(y,this._cutFillReductionConfiguration);this._cutFillReductionConfiguration.reductionPass=2;const n=this.techniques.getCompiled(y,this._cutFillReductionConfiguration);if(!(i&&r&&s&&h&&o&&n))return this.requestRender(1),e;this.needsRender=!1;const u=this.renderingContext,a=this.fboCache,d=this.gl,p=u.getViewport(),f=a.acquire(this._width,this._height,"cutfill reference depth",this._depthFormat);u.bindFramebuffer(f.fbo),u.setViewport(0,0,this._width,this._height),u.clear(1280),this.view.stage.renderer.renderCutFillReferenceDepth(this._orthographicCamera);const _=a.acquire(this._width,this._height,"cutfill target depth",this._depthFormat);u.bindFramebuffer(_.fbo),u.setViewport(0,0,this._width,this._height),u.setClearDepth(1),u.clear(256),this._cutFillTargetDepthParameters.origin=this._localOrigin,this._cutFillTargetDepthParameters.cutFillCamera=this._orthographicCamera,u.bindTechnique(i,this.bindParameters,this._cutFillTargetDepthParameters),u.bindVAO(this._targetGeometryVao),u.drawArrays(S.TRIANGLES,0,this._targetGeometryVao.vertexCount("geometry"));const m=a.acquire(this._width,this._height,"cutfill reduction even",this._colorFormat),g=a.acquire(this._width,this._height,"cutfill reduction odd",this._colorFormat);return this._cutFillDepthParameters.referenceDepthTexture=f.depthTexture,this._cutFillDepthParameters.targetDepthTexture=_.depthTexture,this._pixelBuffer||(this._pixelBuffer=d.createBuffer()),d.bindBuffer(d.PIXEL_PACK_BUFFER,this._pixelBuffer),d.bufferData(d.PIXEL_PACK_BUFFER,this._pixelBufferSize,d.STREAM_READ),this._prepareFBO(m,this.width,this.height),u.bindTechnique(r,this.bindParameters,this._cutFillDepthParameters),u.screen.draw(),this._runPyramidReduction(m,g,h),this._prepareFBO(m,this.width,this.height,c),u.bindTechnique(s,this.bindParameters,this._cutFillDepthParameters),u.screen.draw(),this._runPyramidReduction(m,g,o),this._prepareFBO(m,this.width,this.height,l),u.bindTechnique(s,this.bindParameters,this._cutFillDepthParameters),u.screen.draw(),this._runPyramidReduction(m,g,n),f.release(),_.release(),m.release(),g.release(),d.bindBuffer(d.PIXEL_PACK_BUFFER,null),u.setViewport(p.x,p.y,p.width,p.height),this._sync=new O(d),setTimeout(()=>this.readyToRun=!0,0),e}update(t,i){if(!this.done)return;this.done=!1;const r=this.renderingContext,{cameraDimensions:{width:s,height:h},localOriginRenderSpace:o}=t,n=this._maxTextureSize,u=h/s,a=s>h?n:n/u,c=s>h?n*u:n;this._width=e(a),this._height=e(c);const l=[this._width,this._height];this._orthographicCamera=this._createCamera(t,l),this._frustum?.update(this._orthographicCamera),this._updateTargetVao(r,i),this._localOrigin=o,this._reductionPasses=Math.ceil(Math.log2(Math.min(this._width,this._height))),this._reducedWidth=Math.ceil(this._width/2**this._reductionPasses),this._reducedHeight=Math.ceil(this._height/2**this._reductionPasses),this._perReductionPixelBufferSize=this._reducedWidth*this._reducedHeight*this._numChannels*4,this._pixelBufferSize=this._perReductionPixelBufferSize*this._numReductions,this._pixelBufferOffset=0,this.needsRender=!0,this.requestRender(1)}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return E}catch(e){return this.readyToRun=!1,void(this._sync=r(this._sync))}this.readyToRun=!1,this._sync=r(this._sync);const t=this.gl;this._cpuBuffer=new Float32Array(this._pixelBufferSize/4),t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pixelBuffer),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._cpuBuffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),this._updateResults(this._cpuBuffer),this.done=!0}getResult(){return this._result}get frustum(){return this._frustum}get width(){return this._width}get height(){return this._height}get updating(){return this.readyToRun||!this.done||this._frameTask.updating}_runPyramidReduction(t,e,i){const r=this.renderingContext,s=this.gl;let h=this._width,o=this._height;for(let n=0;n<this._reductionPasses;n++)h=Math.ceil(h/2),o=Math.ceil(o/2),this._cutFillReductionParameters.depthTexture=t.getTexture(),this._prepareFBO(e,h,o),r.bindTechnique(i,this.bindParameters,this._cutFillReductionParameters),r.screen.draw(),[t,e]=[e,t];s.readPixels(0,0,h,o,33319,v.FLOAT,this._pixelBufferOffset),this._pixelBufferOffset+=this._perReductionPixelBufferSize}_updateResults(t){const e=new U(0,1,u()),i=new U(0,0,u());for(let r=0;r<this._reducedWidth;r++)for(let s=0;s<this._reducedHeight;s++){let h=(r+s*this._reducedWidth)*this._numChannels;const o=this._reducedWidth*this._reducedHeight*this._numChannels;e.totalDepth+=t[h],i.totalDepth+=t[h+1],h+=o;const n=t[h];n<e.depthExtremum&&(e.depthExtremum=n,M(e.depthExtremumCoords,t[h+1],this._width)),h+=o;const u=t[h];u>i.depthExtremum&&(i.depthExtremum=u,M(i.depthExtremumCoords,t[h+1],this._width))}this._result=new k(this._width,this._height,e,i)}_prepareFBO(t,e,i,r=l){const s=this.renderingContext;s.bindFramebuffer(t.fbo),s.setViewport(0,0,e,i),s.setClearColor(r[0],r[1],r[2],r[3]),s.clear(16384)}_createCamera(t,e){const{cameraPositionRenderSpace:i,localOriginRenderSpace:r,northVector:s,cameraDimensions:{width:h,height:n},cameraNearFar:{near:u,far:a}}=t,c=new g({eye:i,center:r,up:s,near:u,far:a});return c.viewport=[0,0,e[0],e[1]],o(c.projectionMatrix,-h/2,h/2,-n/2,n/2,u,a),c}_updateTargetVao(t,e){this._targetGeometryVao=i(this._targetGeometryVao);const r=e.reduce((t,e)=>t+e.indices.length,0),s=z.createBuffer(r),h=s.position;let o=0;for(const i of e){const{positions:t,indices:e}=i;for(let i=0;i<e.length;++i){const r=3*e[i];h.set(o,0,t[r]),h.set(o,1,t[r+1]),h.set(o,2,t[r+2]),o++}}const n=new V(t,_(z),s.buffer);this._targetGeometryVao=new R(t,n)}};t([s()],A.prototype,"consumes",void 0),t([s()],A.prototype,"produces",void 0),t([s()],A.prototype,"needsRender",void 0),t([s()],A.prototype,"readyToRun",void 0),t([s()],A.prototype,"done",void 0),t([s()],A.prototype,"updating",null),t([s()],A.prototype,"_frameTask",void 0),A=t([h("esri.views.3d.webgl-engine.lib.CutFillComputationRenderNode")],A);const z=m().vec3f("position").freeze();function M(t,e,i){const r=e%i,s=Math.floor(e/i);n(t,r,s)}class L{constructor(t,e){this.positions=t,this.indices=e}}class U{constructor(t,e,i){this.totalDepth=t,this.depthExtremum=e,this.depthExtremumCoords=i}}class k{constructor(t=0,e=0,i=new U(0,1,u()),r=new U(0,0,u())){this.width=t,this.height=e,this.cut=i,this.fill=r}}export{A as CutFillComputationRenderNode,k as CutFillComputationResult,U as CutFillDepthResult,L as TargetGeometryRenderInfo};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{generateUID as r}from"../../../../core/uid.js";import{isColor as e}from"../core/shaderLibrary/ShaderOutput.js";import{DefaultTechniqueConfiguration as t}from"../materials/DefaultTechniqueConfiguration.js";import{updateParameters as s}from"../materials/internal/MaterialUtil.js";import{NoParameters as i}from"../../../webgl/NoParameters.js";class a{constructor(e,t){this.id=r(),this.supportsEdges=!1,this._renderPriority=0,this._parameters=new t,s(this._parameters,e),this.validateParameters(this._parameters)}get useIndexing(){return this.parameters.useIndexing??!1}get parameters(){return this._parameters}update(r){return!1}setParameters(r,e=!0){s(this._parameters,r)&&(this.validateParameters(this._parameters),e&&this._parametersChanged())}validateParameters(r){}shouldRender(r){return this.visible&&this.isVisibleForOutput(r.output)&&(!this.parameters.isDecoration||r.bind.decorations)&&0!==(this.parameters.renderOccluded&r.renderOccludedMask)}isVisibleForOutput(r){return!0}get renderPriority(){return this._renderPriority}set renderPriority(r){r!==this._renderPriority&&(this._renderPriority=r,this._parametersChanged())}_parametersChanged(){this.repository?.materialChanged(this)}get renderOccludedFlags(){return this.visible?this.parameters.renderOccluded:0}get testsTransparentRenderOrder(){return this.parameters.testsTransparentRenderOrder}get hasEmissions(){return!1}getConfiguration(r,s,i=new t){return i.output=r,i.hasEmission=s.hasEmission&&e(r),i.oitPass=s.oitPass,i.hasHighlightMixTexture=8===r&&null!=s.highlightMixTexture,i.hasFloatOit=s.hasFloatOit,i}}class n extends i{constructor(){super(...arguments),this.renderOccluded=1,this.testsTransparentRenderOrder=0,this.isDecoration=!1}}export{a as Material,n as MaterialParameters};
2
+ import{generateUID as r}from"../../../../core/uid.js";import{isColor as t}from"../core/shaderLibrary/ShaderOutput.js";import{updateParameters as e}from"../materials/internal/MaterialUtil.js";import{NoParameters as i}from"../../../webgl/NoParameters.js";class s{constructor(t,i){this.id=r(),this.supportsEdges=!1,this._renderPriority=0,this._parameters=new i,e(this._parameters,t),this.validateParameters(this._parameters)}get useIndexing(){return this.parameters.useIndexing??!1}get parameters(){return this._parameters}update(r){return!1}setParameters(r,t=!0){e(this._parameters,r)&&(this.validateParameters(this._parameters),t&&this._parametersChanged())}validateParameters(r){}shouldRender(r){return this.visible&&this.isVisibleForOutput(r.output)&&(!this.parameters.isDecoration||r.bind.decorations)&&0!==(this.parameters.renderOccluded&r.renderOccludedMask)}isVisibleForOutput(r){return!0}get renderPriority(){return this._renderPriority}set renderPriority(r){r!==this._renderPriority&&(this._renderPriority=r,this._parametersChanged())}_parametersChanged(){this.repository?.materialChanged(this)}get renderOccludedFlags(){return this.visible?this.parameters.renderOccluded:0}get testsTransparentRenderOrder(){return this.parameters.testsTransparentRenderOrder}get hasEmissions(){return!1}getConfiguration(r,t){return this.updateConfiguration(r,t),this._configuration}updateConfiguration(r,e){this._configuration.output=r,this._configuration.hasEmission=e.hasEmission&&t(r),this._configuration.oitPass=e.oitPass,this._configuration.hasHighlightMixTexture=8===r&&null!=e.highlightMixTexture,this._configuration.hasFloatOit=e.hasFloatOit}}class a extends i{constructor(){super(...arguments),this.renderOccluded=1,this.testsTransparentRenderOrder=0,this.isDecoration=!1}}export{s as Material,a as MaterialParameters};