@arcgis/core 6.0.0-next.49 → 6.0.0-next.50

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 (133) hide show
  1. package/applications/WebEditor/sketchUtils.js +1 -1
  2. package/arcade/treeAnalysis.js +1 -1
  3. package/arcgisGlobal.d.ts +0 -6
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/08dd03bc068862160cb2.js +1 -0
  6. package/assets/esri/core/workers/chunks/38a5be53c3a11adc82e2.js +1 -0
  7. package/assets/esri/core/workers/chunks/5f12213ccda1f222f244.js +1 -0
  8. package/assets/esri/core/workers/chunks/aa6f8ee1e1734488ff10.js +1 -0
  9. package/assets/esri/core/workers/chunks/d781b7e6f9f9f399cf03.js +1 -0
  10. package/assets/esri/core/workers/chunks/fb4fe32b0b53d8e57f92.js +1 -0
  11. package/chunks/Pattern.glsl.js +31 -42
  12. package/config.js +1 -1
  13. package/interfaces.d.ts +0 -36
  14. package/kernel.js +1 -1
  15. package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +8 -8
  16. package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
  17. package/layers/geospatialPDF/LGIDictMapFrame.js +1 -1
  18. package/layers/geospatialPDF/ViewportMeasureFrame.js +1 -1
  19. package/layers/geospatialPDF/geospatialPDFParserUtils.js +1 -1
  20. package/layers/geospatialPDF/parseAttachmentUtils.js +2 -0
  21. package/layers/geospatialPDF/sharedUtils.js +1 -1
  22. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  23. package/layers/raster/datasets/TIFFRaster.js +1 -1
  24. package/layers/raster/formats/TiffDecoder.js +1 -1
  25. package/layers/raster/formats/tiffParser.js +1 -1
  26. package/package.json +3 -3
  27. package/views/2d/analysis/AreaMeasurementAnalysisView2D.d.ts +2 -2
  28. package/views/2d/analysis/AreaMeasurementAnalysisView2D.js +1 -1
  29. package/views/2d/analysis/DistanceMeasurementAnalysisView2D.d.ts +2 -2
  30. package/views/2d/analysis/DistanceMeasurementAnalysisView2D.js +1 -1
  31. package/views/3d/analysis/Dimension/LengthDimensionLineRenderObject.js +2 -0
  32. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  33. package/views/3d/interactive/BufferManipulator3D.js +2 -0
  34. package/views/3d/interactive/BufferRenderObject.js +2 -0
  35. package/views/3d/interactive/Manipulator3D.js +1 -1
  36. package/views/3d/interactive/Manipulator3DBase.js +1 -1
  37. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  38. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  39. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  40. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  41. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  42. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  43. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  44. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  45. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  46. package/views/3d/layers/graphics/Graphics3DSymbolCreationContext.js +1 -1
  47. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  48. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  49. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  50. package/views/3d/terrain/OverlayRenderer.js +1 -1
  51. package/views/LinkChartView.js +1 -1
  52. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  53. package/views/draw/DrawOperation.js +1 -1
  54. package/views/interactive/Tooltip.js +1 -1
  55. package/views/interactive/options/InteractiveToolOptions.js +1 -1
  56. package/views/interactive/options/ViewOptions.d.ts +5 -1
  57. package/views/interactive/options/bindViewToolOptions.js +1 -1
  58. package/views/interactive/sketch/SketchOptions.d.ts +1 -26
  59. package/views/interactive/sketch/SketchOptions.js +1 -1
  60. package/views/interactive/snapping/FeatureSnappingLayerSource.d.ts +4 -4
  61. package/views/interactive/snapping/SnappingManager.js +1 -1
  62. package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
  63. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  64. package/views/interactive/tooltip/content/TooltipContentDrawCircle.js +1 -1
  65. package/views/interactive/tooltip/content/TooltipContentDrawMesh.js +1 -1
  66. package/views/interactive/tooltip/content/TooltipContentDrawPoint.js +1 -1
  67. package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
  68. package/views/interactive/tooltip/content/TooltipContentDrawPolyline.js +1 -1
  69. package/views/interactive/tooltip/content/TooltipContentDrawRectangle.js +1 -1
  70. package/views/interactive/tooltip/content/TooltipContentElevation.js +1 -1
  71. package/views/interactive/tooltip/content/TooltipContentExtentRotate.js +1 -1
  72. package/views/interactive/tooltip/content/TooltipContentExtentScale.js +1 -1
  73. package/views/interactive/tooltip/content/TooltipContentMovePoint.js +1 -1
  74. package/views/interactive/tooltip/content/TooltipContentReshapeEdgeOffset.js +1 -1
  75. package/views/interactive/tooltip/content/TooltipContentSelectedVertex.js +1 -1
  76. package/views/interactive/tooltip/content/TooltipContentTransformMesh.js +1 -1
  77. package/views/interactive/tooltip/content/TooltipContentTransformPoint.js +1 -1
  78. package/views/interactive/tooltip/content/TooltipContentTranslate.js +1 -1
  79. package/views/interactive/tooltip/content/TooltipContentTranslateVertex.js +1 -1
  80. package/views/interactive/tooltip/content/TooltipContentTranslateXY.js +1 -1
  81. package/views/interactive/tooltip/content/TooltipContentTranslateZ.js +1 -1
  82. package/views/interactive/tooltip/fields/TooltipField.js +1 -1
  83. package/views/interactive/tooltip/infos/DynamicTooltipInfo.js +1 -1
  84. package/views/interactive/tooltip/infos/SketchTooltipInfo.js +1 -1
  85. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  86. package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.d.ts +8 -8
  87. package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.js +1 -1
  88. package/widgets/AreaMeasurement2D.d.ts +8 -8
  89. package/widgets/AreaMeasurement2D.js +1 -1
  90. package/widgets/BatchAttributeForm/attachmentUtils.d.ts +7 -0
  91. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.d.ts +18 -0
  92. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  93. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DViewModel.d.ts +8 -8
  94. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DViewModel.js +1 -1
  95. package/widgets/DistanceMeasurement2D.d.ts +8 -8
  96. package/widgets/DistanceMeasurement2D.js +1 -1
  97. package/widgets/Editor/EditorViewModel.d.ts +23 -23
  98. package/widgets/Editor/EditorViewModel.js +1 -1
  99. package/widgets/Editor.d.ts +24 -24
  100. package/widgets/Editor.js +1 -1
  101. package/widgets/Sketch/SketchViewModel.d.ts +25 -25
  102. package/widgets/Sketch/SketchViewModel.js +1 -1
  103. package/widgets/Sketch.d.ts +24 -24
  104. package/widgets/Sketch.js +1 -1
  105. package/widgets/UtilityNetworkTrace/support/GraphicHandler.js +1 -1
  106. package/widgets/support/GridControls/GridControlsViewModel.d.ts +3 -3
  107. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  108. package/widgets/support/GridControls.d.ts +4 -4
  109. package/widgets/support/GridControls.js +1 -1
  110. package/widgets/support/SnappingControls/SnappingControlsViewModel.d.ts +5 -5
  111. package/widgets/support/SnappingControls/SnappingControlsViewModel.js +1 -1
  112. package/widgets/support/SnappingControls/VisibleElements.d.ts +3 -3
  113. package/widgets/support/SnappingControls.d.ts +7 -7
  114. package/widgets/support/SnappingControls.js +1 -1
  115. package/assets/esri/core/workers/chunks/0fd5ff5b6037c89257ec.js +0 -1
  116. package/assets/esri/core/workers/chunks/27a91b52d1bee92b6f20.js +0 -1
  117. package/assets/esri/core/workers/chunks/3ce7120056040af3bab1.js +0 -1
  118. package/assets/esri/core/workers/chunks/630a36c4817f33f4cad2.js +0 -1
  119. package/assets/esri/core/workers/chunks/a0e2a1c6f37454547193.js +0 -1
  120. package/assets/esri/core/workers/chunks/c4974a4dc081e23899ba.js +0 -1
  121. package/views/interactive/sketch/SketchLabelOptions.d.ts +0 -72
  122. package/views/interactive/sketch/SketchLabelOptions.js +0 -2
  123. package/views/interactive/sketch/SketchTooltipElevationOptions.js +0 -2
  124. package/views/interactive/sketch/SketchTooltipOptions.d.ts +0 -87
  125. package/views/interactive/sketch/SketchTooltipOptions.js +0 -2
  126. package/views/interactive/sketch/SketchTooltipVisibleElements.d.ts +0 -19
  127. package/views/interactive/sketch/SketchTooltipVisibleElements.js +0 -2
  128. package/views/interactive/sketch/SketchValueOptions.d.ts +0 -27
  129. package/views/interactive/sketch/SketchValueOptions.js +0 -2
  130. package/views/interactive/sketch/Units.d.ts +0 -20
  131. package/views/interactive/sketch/Units.js +0 -2
  132. package/views/interactive/snapping/SnappingOptions.d.ts +0 -75
  133. package/views/interactive/snapping/SnappingOptions.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{onePixelInPoints as t,pt2px as n,onePointInPixels as r}from"../../../../core/screenUtils.js";import{fromValues as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as o,clone as s,ones as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as l,fromBuffer as u,intersectsClippingArea as d,empty as f,expandWithAABB as p}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as m}from"../../../../renderers/support/renderingInfoUtils.js";import{getTransformationType as h}from"../../../../renderers/visualVariables/support/sizeVariableUtils.js";import{perBufferLineElevationAligner as g}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as _,needsElevationUpdates2D as v}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as y}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as b}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as x,nanFallbackColor as S}from"./Graphics3DSymbolLayer.js";import{parseCapType as C,computeSymbolLayerIndex as w,parseLineMarkerStyle as T}from"./lineUtils.js";import{initFastSymbolUpdatesState as E,updateFastSymbolUpdatesState as D,getAttributeValue as O,getSizeAttributeValue as k,ConvertOptions as A}from"../support/FastSymbolUpdates.js";import{debugFlags as j}from"../../support/debugFlags.js";import{selectLocalOrigin as M,createBufferGeometry as N}from"../../support/engineContent/line.js";import{geometryToRenderInfo as P,geometryToRenderInfoDraped as F}from"../../support/renderInfoUtils/line.js";import{BufferObject3D as I}from"../../webgl-engine/lib/BufferObject3D.js";import{LineMarkerMaterial as L}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as R,patternHidesLine as z}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as B}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createLineMarkerBufferGeometry as V}from"../../webgl-engine/materials/internal/lineMarkerBufferUtils.js";const H=[`polyline`];class U extends x{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,K(t))}async doLoad(){if(this._fastUpdates=E(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastMarkerUpdates=E(this._context.renderer,this._fastVisualVariableConvertOptions(!0)),!this._drivenProperties.size&&(this.symbolLayer.size==null?t:this.symbolLayer.size)<0)throw new e(`graphics3dlinesymbollayer:invalid-size`,`Symbol sizes may not be negative values`)}_getMaterialParameters(e,t){let n=this._screenSizePerspective,r=!!has(`enable-feature:emissive-on-non-volumetric`)&&!this.draped,{symbolLayer:i}=this,{worldSized:a}=this.symbol,o={...this._getMaterialColorParameters(t),shadingEnabled:r,width:this._computeMaterialWidth(i.size,a),worldSized:a,polygonOffset:3,polygonOffsetIndex:w(this._renderPriority,this._renderPriorityStep),join:i.join||`miter`,cap:C(i.cap||`butt`),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:R(i.pattern??i.imagePattern),emissiveStrength:this._emissiveStrength,screenSizePerspective:n};if(t===2){if(this._fastMarkerUpdates?.visualVariables)return{...o,...this._fastMarkerUpdates.materialParameters}}else if(o.hasVertexColor=this._hasDrivenColorOrOpacity,o.hasVertexSize=this._drivenProperties.size,o.hasLineDistance=o.stipplePattern!=null,this._fastUpdates?.visualVariables)return{...o,...this._fastUpdates.materialParameters};return o}_getMaterialColorParameters(e){let t=e===2,n=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);return this._patternHidesLine&&!t&&(n[3]=0),{color:n}}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return this._materials[0]??=new B(this._getMaterialParameters(!1,0),this.view),this._materials[0]}get _wireframeLineMaterial(){return this._materials[1]??=new B({...this._getMaterialParameters(!1,1),wireframe:!0},this.view),this._materials[1]}get _markerMaterial(){return this._materials[2]==null&&this.symbolLayer.marker!=null&&(this._materials[2]=new L({...this._getMaterialParameters(!1,2),placement:this.symbolLayer.marker.placement,markerPrimitive:T(this.symbolLayer.marker.style)},this.view.state.isGlobal)),this._materials[2]}_getDrivenSize(e){if(this._drivenProperties.size){let t=e.size;if(t==null)return this._getFallbackSize();let n=m(t.output);return this._getWorldOrScreenSize(n)}return 1}_getDrivenColor({color:e,opacity:t}){let n=c();return this._drivenProperties.color&&(a(n,e?.output??this._getFallbackOpacityAndColor(o)),t==null)||this._drivenProperties.opacity&&(e||this._materialColor)&&(n[3]=t?.output??this._getFallbackOpacity()),n}_getDrivenMarkerColor({color:e,opacity:t}){let n=c();return this._drivenProperties.color&&(a(n,e?.output??this._getFallbackMarkerOpacityAndColor(o)),t==null)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(n[3]=t?.output??this._getFallbackMarkerOpacity()),n}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validatePolylineContext(e))return null;this._warnIfVVRequiresWorldSized(e.renderingInfo);let n=this.createElevationContextForGraphic(t),r=n.mode===`on-the-ground`;return this.ensureDrapedStatus(r),this.draped?this._createAsOverlay(e):this._createAs3DShape(e,n,t.uid)}_validatePolylineContext(e){let t=e.graphic.geometry;return this._validateGeometry(t,H,this.symbolLayer.type)&&t.type===`polyline`}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:{let e=this._fastUpdates;if(D(e,t,this._fastVisualVariableConvertOptions()))for(let t of this._materials)t instanceof B&&t.setParameters(e.materialParameters);else return 0;let n=this._fastMarkerUpdates;if(D(n,t,this._fastVisualVariableConvertOptions(!0)))for(let e of this._materials)e instanceof L&&e.setParameters(n.materialParameters);else return 0}break;default:return 0}return`visualVariables`in e.diff&&this._warnIfVVRequiresWorldSized(),2}_warnIfVVRequiresWorldSized(e){if(this.symbol.worldSized||this.ignoreDrivers)return;let t=this._getSizeVariable(e);t==null||t.useSymbolValue||t.target===`outline`||h(t)===`real-world-size`&&this.logger.warnOnce(`SizeVariable uses real-world units, but LineSymbol3D.worldSized is false. Set LineSymbol3D.worldSized to true to render real-world line widths.`)}_getSizeVariable(e){let t=this._fastUpdates?.visualVariables.size;if(t)return t.variables[0];let n=e?.size,r=n?.output.findIndex(e=>typeof e==`number`);return r==null?null:n?.variables[r]}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff,n={};t.size?.type===`complete`&&(n.width=this._computeMaterialWidth(t.size.newValue,this.symbol.worldSized),delete t.size),t.cap?.type===`complete`&&(n.cap=C(t.cap.newValue??`butt`),delete t.cap);let r=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,r),e.symbolLayerStatePatches.push(()=>{for(let e of this._materials)e?.setParameters(n)})}layerOpacityChanged(){for(let e=0;e<3;e++)this._materials[e]?.setParameters(this._getMaterialColorParameters(e))}get _screenSizePerspective(){return!this.draped&&this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null}layerScreenSizePerspectiveChanged(){let e=this._screenSizePerspective;for(let t of this._materials)t?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=_(U.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=v(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){let e={hasSlicePlane:this._context.slicePlaneEnabled};for(let t of this._materials)t?.setParameters(e);return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,n){let r=W(e.graphic.geometry);if(r==null)return null;let i=[],a=[],o=l(),s=P(r,this._context.elevationProvider,this._context.renderCoordsHelper,t);this._logGeometryCreationWarnings(s,r.paths,`paths`,`LineSymbol3DLayer`);for(let t=0;t<s.lines.length;t++){let r=s.lines[t],c=r.position,l=r.mapPositions;if(this._context.clippingExtent!=null&&(u(l,o),!d(o,this._context.clippingExtent)))continue;let f=this._createGeometryParts(e,c,l,1,n);a.push(f),i.push(f.line),f.wireframe!=null&&i.push(f.wireframe),f.marker!=null&&i.push(f.marker)}if(i.length===0)return null;let c=this._context.layerViewUid,f=new I({geometries:i,castShadow:!1,layerViewUid:c,graphicUid:n}),p=new y(this,f,null,(e,t,n,r,i)=>g(e,t,n,r,i,a),t);return p.alignedSampledElevation=s.sampledElevation,p.needsElevationUpdates=v(t.mode),p}_createGeometryParts(e,t,n,r,i){let a=r===0?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,o=this._fastUpdates?.visualVariables.color,s=this._fastUpdates?.visualVariables.size,c=this._fastUpdates?.visualVariables.opacity,l=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:i,layerViewUid:l}),{renderingInfo:d}=e,f={position:t,size:s?null:this._getDrivenSize(d),color:o?null:this._getDrivenColor(d),sizeFeature:s?k(s,d.size):null,colorFeature:o?O(o,d.color):null,opacityFeature:c?O(c,d.opacity):null},p=r===0?this._context.drapeSourceRenderer.rendererContext.localOriginFactory:this._context.localOriginFactory,m=M(t,p),h={overlayInfo:a,removeDuplicateStartEnd:!1,mapPositions:n,attributeData:f},g=N(this._lineMaterial,h,m,u),_=j.LINE_WIREFRAMES?N(this._wireframeLineMaterial,h,m,u):null,v=this._markerMaterial,y=null;v!=null&&(h.attributeData={...f,color:o?null:this._getDrivenMarkerColor(d)},y=V(v,h,m));for(let e of[g,y,_])e!=null&&(e.layerViewUid=l,e.graphicUid=i);return{line:g,marker:y,wireframe:_}}_createAsOverlay(e){let t=e.graphic,{geometry:n}=t;this._lineMaterial.renderPriority=this._renderPriority;let r=j.LINE_WIREFRAMES?this._wireframeLineMaterial:null,i=this._markerMaterial;r!=null&&(r.renderPriority=this._renderPriority-.001),i!=null&&(i.renderPriority=this._renderPriority-.002);let a=[],o=l(),s=f(),c=F(n,this._context.overlaySR);this._logGeometryCreationWarnings(c,n.paths,`paths`,`LineSymbol3DLayer`);for(let n of c.lines){if(u(n.position,o),!d(o,this._context.clippingExtent))continue;p(s,o);let r=this._createGeometryParts(e,n.position,void 0,0,t.uid);r.marker!=null&&a.push(r.marker),a.push(r.line),r.wireframe!=null&&a.push(r.wireframe)}return new b(this,a,s,this._context.drapeSourceRenderer)}get _patternHidesLine(){return z(this.symbolLayer.pattern)}_computeMaterialWidth(e,i){return i?this._drivenProperties.size?1:e??1:(e??=t,this._drivenProperties.size?this._fastUpdates?.visualVariables.size?r:1:n(e))}_prepareMaterialPatch(e,t,n){let r=t.material;if(r==null){n.changed&&n.useMaterialColor&&G(this._getCombinedOpacityAndColor(this._materialColor),this._materials[2],e);return}if(r.type===`collection`)return;let i=r.type===`complete`?r.newValue?.color:r.diff.color?.type===`complete`?r.diff.color.newValue:null,a=this._getCombinedOpacityAndColor(i);n.useMaterialColor&&G(s(a),this._materials[2],e),this._patternHidesLine&&(a[3]=0),G(a,this._materials[0],e),delete t.material}_prepareMarkerPatch(e,t){let n=t.marker,r=this._markerMaterial;if(n==null||n.type!==`partial`||n.diff==null||n.diff.placement!=null||n.diff.style!=null&&n.diff.style.type!==`complete`||n.diff.color!=null&&n.diff.color.type!==`complete`||r==null)return{changed:!1,useMaterialColor:this._markerColor==null};let i=n.diff.color,a=i!=null,o=a?i.newValue:null,s=o==null&&this._markerColor==null;o&&G(this._getCombinedOpacityAndColor(o),r,e);let c=n.diff.style?.newValue;return c&&e.symbolLayerStatePatches.push(()=>r.setParameters({markerPrimitive:T(c)})),delete t.marker,{changed:a,useMaterialColor:s}}_fastVisualVariableConvertOptions(e=!1){let t=this._getFallbackSize(),{size:n}=this.symbolLayer;return new A({supports:{size:!0,color:!0,rotation:!1,opacity:!0},symbolSize:i(n,n,n),fallbackColor:e?this._getFallbackMarkerOpacityAndColor(S):this._getFallbackOpacityAndColor(S),fallbackSize:i(t,t,t)})}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}_getFallbackOpacity(){return this._materialColor?.a??0}_getFallbackMarkerOpacityAndColor(e){return this.symbolLayer.marker?.color?.toUnitRGBA()??this._getFallbackOpacityAndColor(e)}_getFallbackMarkerOpacity(){return this.symbolLayer.marker?.color?.a??this._getFallbackOpacity()}_getWorldOrScreenSize(e){return this.symbol.worldSized?e:n(e)}_getFallbackSize(){return this._getWorldOrScreenSize(this.symbolLayer.size)}}function W(e){return e.type===`polyline`?e:null}function G(e,t,n){t!=null&&n.symbolLayerStatePatches.push(()=>t.setParameters({color:e}))}function K(e){return(e.material?.color?.a??1)===1&&(e.marker?.color?.a??1)===1}export{U as Graphics3DLineSymbolLayer};
2
+ import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{onePixelInPoints as t,pt2px as n,onePointInPixels as r}from"../../../../core/screenUtils.js";import{fromValues as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as o,clone as s,ones as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as l,fromBuffer as u,intersectsClippingArea as d,empty as f,expandWithAABB as p}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as m}from"../../../../renderers/support/renderingInfoUtils.js";import{getTransformationType as h}from"../../../../renderers/visualVariables/support/sizeVariableUtils.js";import{perBufferLineElevationAligner as g}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as _,needsElevationUpdates2D as v}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as y}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as b}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as x,nanFallbackColor as S}from"./Graphics3DSymbolLayer.js";import{parseCapType as C,computeSymbolLayerIndex as w,parseLineMarkerStyle as T}from"./lineUtils.js";import{initFastSymbolUpdatesState as E,updateFastSymbolUpdatesState as D,getAttributeValue as O,getSizeAttributeValue as k,ConvertOptions as A}from"../support/FastSymbolUpdates.js";import{debugFlags as j}from"../../support/debugFlags.js";import{selectLocalOrigin as M,createBufferGeometry as N}from"../../support/engineContent/line.js";import{geometryToRenderInfo as P,geometryToRenderInfoDraped as F}from"../../support/renderInfoUtils/line.js";import{BufferObject3D as I}from"../../webgl-engine/lib/BufferObject3D.js";import{LineMarkerMaterial as L}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as R,patternHidesLine as z}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as B}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createLineMarkerBufferGeometry as V}from"../../webgl-engine/materials/internal/lineMarkerBufferUtils.js";const H=[`polyline`];class U extends x{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,K(t))}async doLoad(){if(this._fastUpdates=E(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastMarkerUpdates=E(this._context.renderer,this._fastVisualVariableConvertOptions(!0)),!this._drivenProperties.size&&(this.symbolLayer.size==null?t:this.symbolLayer.size)<0)throw new e(`graphics3dlinesymbollayer:invalid-size`,`Symbol sizes may not be negative values`)}_getMaterialParameters(e,t){let n=this._screenSizePerspective,r=!!has(`enable-feature:emissive-on-non-volumetric`)&&!this.draped,{symbolLayer:i}=this,{worldSized:a}=this.symbol,o={...this._getMaterialColorParameters(t),shadingEnabled:r,width:this._computeMaterialWidth(i.size,a),worldSized:a,polygonOffset:3,polygonOffsetIndex:w(this._renderPriority,this._renderPriorityStep),join:i.join||`miter`,cap:C(i.cap||`butt`),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:R(i.pattern??i.imagePattern),emissiveStrength:this._emissiveStrength,screenSizePerspective:n};if(t===2){if(this._fastMarkerUpdates?.visualVariables)return{...o,...this._fastMarkerUpdates.materialParameters}}else if(o.hasVertexColor=this._hasDrivenColorOrOpacity,o.hasVertexSize=this._drivenProperties.size,o.hasLineDistance=o.stipplePattern!=null,this._fastUpdates?.visualVariables)return{...o,...this._fastUpdates.materialParameters};return o}_getMaterialColorParameters(e){let t=e===2,n=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);return this._patternHidesLine&&!t&&(n[3]=0),{color:n}}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return this._materials[0]??=new B(this._getMaterialParameters(!1,0),this.view),this._materials[0]}get _wireframeLineMaterial(){return this._materials[1]??=new B({...this._getMaterialParameters(!1,1),wireframe:!0},this.view),this._materials[1]}get _markerMaterial(){return this._materials[2]==null&&this.symbolLayer.marker!=null&&(this._materials[2]=new L({...this._getMaterialParameters(!1,2),placement:this.symbolLayer.marker.placement,markerPrimitive:T(this.symbolLayer.marker.style)},this.view.state.isGlobal)),this._materials[2]}_getDrivenSize(e){if(this._drivenProperties.size){let t=e.size;if(t==null)return this._getFallbackSize();let n=m(t.output);return this._getWorldOrScreenSize(n)}return 1}_getDrivenColor({color:e,opacity:t}){let n=c();return this._drivenProperties.color&&(a(n,e?.output??this._getFallbackOpacityAndColor(o)),t==null)||this._drivenProperties.opacity&&(e||this._materialColor)&&(n[3]=t?.output??this._getFallbackOpacity()),n}_getDrivenMarkerColor({color:e,opacity:t}){let n=c();return this._drivenProperties.color&&(a(n,e?.output??this._getFallbackMarkerOpacityAndColor(o)),t==null)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(n[3]=t?.output??this._getFallbackMarkerOpacity()),n}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validatePolylineContext(e))return null;this._warnIfVVRequiresWorldSized(e.renderingInfo);let n=this.createElevationContextForGraphic(t),r=n.mode===`on-the-ground`;return this.ensureDrapedStatus(r),this.draped?this._createAsOverlay(e):this._createAs3DShape(e,n,t.uid)}_validatePolylineContext(e){let t=e.graphic.geometry;return this._validateGeometry(t,H,this.symbolLayer.type)&&t.type===`polyline`}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:{let e=this._fastUpdates;if(D(e,t,this._fastVisualVariableConvertOptions()))for(let t of this._materials)t instanceof B&&t.setParameters(e.materialParameters);else return 0;let n=this._fastMarkerUpdates;if(D(n,t,this._fastVisualVariableConvertOptions(!0)))for(let e of this._materials)e instanceof L&&e.setParameters(n.materialParameters);else return 0}break;default:return 0}return`visualVariables`in e.diff&&this._warnIfVVRequiresWorldSized(),2}_warnIfVVRequiresWorldSized(e){if(this.symbol.worldSized||this.ignoreDrivers)return;let t=this._getSizeVariable(e);t==null||t.useSymbolValue||t.target===`outline`||h(t)===`real-world-size`&&this.logger.warnOnce(`SizeVariable uses real-world units, but LineSymbol3D.worldSized is false. Set LineSymbol3D.worldSized to true to render real-world line widths.`)}_getSizeVariable(e){let t=this._fastUpdates?.visualVariables.size;if(t)return t.variables[0];let n=e?.size,r=n?.output.findIndex(e=>typeof e==`number`);return r==null?null:n?.variables[r]}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff,n={};t.size?.type===`complete`&&(n.width=this._computeMaterialWidth(t.size.newValue,this.symbol.worldSized),delete t.size),t.cap?.type===`complete`&&(n.cap=C(t.cap.newValue??`butt`),delete t.cap);let r=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,r),e.symbolLayerStatePatches.push(()=>{for(let e of this._materials)e?.setParameters(n)})}layerOpacityChanged(){for(let e=0;e<3;e++)this._materials[e]?.setParameters(this._getMaterialColorParameters(e))}get _screenSizePerspective(){return!this.draped&&this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null}layerScreenSizePerspectiveChanged(){let e=this._screenSizePerspective;for(let t of this._materials)t?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=_(U.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=v(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){let e={hasSlicePlane:this._context.slicePlaneEnabled};for(let t of this._materials)t?.setParameters(e);return!0}physicallyBasedRenderingChanged(){return!0}_createAs3DShape(e,t,n){let r=W(e.graphic.geometry);if(r==null)return null;let i=[],a=[],o=l(),s=P(r,this._context.elevationProvider,this._context.renderCoordsHelper,t);this._logGeometryCreationWarnings(s,r.paths,`paths`,`LineSymbol3DLayer`);for(let t=0;t<s.lines.length;t++){let r=s.lines[t],c=r.position,l=r.mapPositions;if(this._context.clippingExtent!=null&&(u(l,o),!d(o,this._context.clippingExtent)))continue;let f=this._createGeometryParts(e,c,l,1,n);a.push(f),i.push(f.line),f.wireframe!=null&&i.push(f.wireframe),f.marker!=null&&i.push(f.marker)}if(i.length===0)return null;let c=this._context.layerViewUid,f=new I({geometries:i,castShadow:!1,layerViewUid:c,graphicUid:n}),p=new y(this,f,null,(e,t,n,r,i)=>g(e,t,n,r,i,a),t);return p.alignedSampledElevation=s.sampledElevation,p.needsElevationUpdates=v(t.mode),p}_createGeometryParts(e,t,n,r,i){let a=r===0?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,o=this._fastUpdates?.visualVariables.color,s=this._fastUpdates?.visualVariables.size,c=this._fastUpdates?.visualVariables.opacity,l=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:i,layerViewUid:l}),{renderingInfo:d}=e,f={position:t,size:s?null:this._getDrivenSize(d),color:o?null:this._getDrivenColor(d),sizeFeature:s?k(s,d.size):null,colorFeature:o?O(o,d.color):null,opacityFeature:c?O(c,d.opacity):null},p=r===0?this._context.drapeSourceRenderer.rendererContext.localOriginFactory:this._context.localOriginFactory,m=M(t,p),h={overlayInfo:a,removeDuplicateStartEnd:!1,mapPositions:n,attributeData:f},g=N(this._lineMaterial,h,m,u),_=j.LINE_WIREFRAMES?N(this._wireframeLineMaterial,h,m,u):null,v=this._markerMaterial,y=null;v!=null&&(h.attributeData={...f,color:o?null:this._getDrivenMarkerColor(d)},y=V(v,h,m));for(let e of[g,y,_])e!=null&&(e.layerViewUid=l,e.graphicUid=i);return{line:g,marker:y,wireframe:_}}_createAsOverlay(e){let t=e.graphic,{geometry:n}=t;this._lineMaterial.renderPriority=this._renderPriority;let r=j.LINE_WIREFRAMES?this._wireframeLineMaterial:null,i=this._markerMaterial;r!=null&&(r.renderPriority=this._renderPriority-.001),i!=null&&(i.renderPriority=this._renderPriority-.002);let a=[],o=l(),s=f(),c=F(n,this._context.overlaySR);this._logGeometryCreationWarnings(c,n.paths,`paths`,`LineSymbol3DLayer`);for(let n of c.lines){if(u(n.position,o),!d(o,this._context.clippingExtent))continue;p(s,o);let r=this._createGeometryParts(e,n.position,void 0,0,t.uid);r.marker!=null&&a.push(r.marker),a.push(r.line),r.wireframe!=null&&a.push(r.wireframe)}return new b(this,a,s,this._context.drapeSourceRenderer)}get _patternHidesLine(){return z(this.symbolLayer.pattern)}_computeMaterialWidth(e,i){return i?this._drivenProperties.size?1:e??1:(e??=t,this._drivenProperties.size?this._fastUpdates?.visualVariables.size?r:1:n(e))}_prepareMaterialPatch(e,t,n){let r=t.material;if(r==null){n.changed&&n.useMaterialColor&&G(this._getCombinedOpacityAndColor(this._materialColor),this._materials[2],e);return}if(r.type===`collection`)return;let i=r.type===`complete`?r.newValue?.color:r.diff.color?.type===`complete`?r.diff.color.newValue:null,a=this._getCombinedOpacityAndColor(i);n.useMaterialColor&&G(s(a),this._materials[2],e),this._patternHidesLine&&(a[3]=0),G(a,this._materials[0],e),delete t.material}_prepareMarkerPatch(e,t){let n=t.marker,r=this._markerMaterial;if(n==null||n.type!==`partial`||n.diff==null||n.diff.placement!=null||n.diff.style!=null&&n.diff.style.type!==`complete`||n.diff.color!=null&&n.diff.color.type!==`complete`||r==null)return{changed:!1,useMaterialColor:this._markerColor==null};let i=n.diff.color,a=i!=null,o=a?i.newValue:null,s=o==null&&this._markerColor==null;o&&G(this._getCombinedOpacityAndColor(o),r,e);let c=n.diff.style?.newValue;return c&&e.symbolLayerStatePatches.push(()=>r.setParameters({markerPrimitive:T(c)})),delete t.marker,{changed:a,useMaterialColor:s}}_fastVisualVariableConvertOptions(e=!1){let t=this._getFallbackSize(),{size:n}=this.symbolLayer;return new A({supports:{size:!0,color:!0,rotation:!1,opacity:!0},symbolSize:i(n,n,n),fallbackColor:e?this._getFallbackMarkerOpacityAndColor(S):this._getFallbackOpacityAndColor(S),fallbackSize:i(t,t,t)})}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}_getFallbackOpacity(){return this._materialColor?.a??0}_getFallbackMarkerOpacityAndColor(e){return this.symbolLayer.marker?.color?.toUnitRGBA()??this._getFallbackOpacityAndColor(e)}_getFallbackMarkerOpacity(){return this.symbolLayer.marker?.color?.a??this._getFallbackOpacity()}_getWorldOrScreenSize(e){return this.symbol.worldSized?e:n(e)}_getFallbackSize(){return this._getWorldOrScreenSize(this.symbolLayer.size)}}function W(e){return e.type===`polyline`?e:null}function G(e,t,n){t!=null&&n.symbolLayerStatePatches.push(()=>t.setParameters({color:e}))}function K(e){return(e.material?.color?.a??1)===1&&(e.marker?.color?.a??1)===1}export{U as Graphics3DLineSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{releaseMaybe as n}from"../../../../core/maybe.js";import{isPromiseLike as r}from"../../../../core/promiseUtils.js";import{normalFromMat4 as i,fromMat4 as a}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as s,multiply as c,invert as l,getTranslation as u}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as d,IDENTITY as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as m}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as h,add as g,scale as _,transformMat4 as v,transformMat3 as y,normalize as b,scaleAndAdd as x,subtract as S,cross as ee,dot as te}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as ne,ZEROS as re,ONES as ie,create as C}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as ae}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as oe}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as w}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as se}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as ce}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as le,intersectsClippingArea as ue,create as de}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as T}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as E,getContinuousIndexArray as fe}from"../../../../geometry/support/Indices.js";import pe from"../../../../geometry/support/MeshComponent.js";import me from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import he from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as ge,isAbsoluteVertexSpace as _e}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as D,isPlateCarree as O}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as k}from"../../../../chunks/vec3.js";import{transformNormal as A,transformVectorENUPlateCarree as j,transformVectorWMPlateCarree as M,projectNormalToPCPF as ve,transformTangent as N,projectTangentToPCPF as ye}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as be}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{projectLocalVertexSpaceToPCPF as xe}from"../../../../geometry/support/meshUtils/vertexSpaceConversion.js";import{isDrivenOpacityFallbackAlwaysOpaque as Se}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{getEmissiveMode as Ce}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as we}from"../../glTF/internal/resourceUtils.js";import{convertMeshTextureTransformToGLTF as P,getTransformMatrix as F}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as Te}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as I}from"./ElevationAligners.js";import{needsElevationUpdates3D as L,evaluateElevationInfoAtPoint as R}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as Ee}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as De}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Oe}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ke,nanFallbackColor as Ae}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as je,MeshFastUpdateProcessor as Me}from"./MeshFastUpdateProcessor.js";import{addOlidAttribute as Ne}from"./olidUtils.js";import{SymbolComplexity as Pe}from"./SymbolComplexity.js";import{hasEdges as Fe,createMaterial as Ie}from"../support/edgeUtils.js";import{debugFlags as Le}from"../../support/debugFlags.js";import{Attribute as z}from"../../webgl-engine/lib/Attribute.js";import{Geometry as B}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as Re}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as ze}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Be}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as V}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Ve,advancedMRRFactors as He,schematicMRRFactors as Ue}from"../../webgl-engine/materials/pbrUtils.js";const We=[`mesh`];class Ge extends ke{constructor(e,t,n,r){super(e,t,n,r,Se(t)),this._materialInfoCache=new je,this._fastUpdateProcessor=new Me,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){Le.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new V({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new V({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new V({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,We,`fill on mesh-3d`))return null;let n=this.createElevationContextForGraphic(t),r=e.renderingInfo;return this._createAs3DShape(t,r,n,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){let n=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:n});let t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(n,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,L)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){let e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateMeshTransform(e,t,n,r,i){if(!e.fastTransformUpdatesAllowed)return!1;let a=e.fastTransformUpdatesEnabled;switch(i){case 0:if(a)return!0;break;case 1:if(!a)return!0}let o=this._context.renderCoordsHelper.spatialReference,s=it,{origin:c,transform:l}=n;if(!w(t.spatialReference,h(J,c.x,c.y,c.z??0),s,o))return!1;switch(i){case void 0:a||this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context,!0);break;case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:if(this._fastUpdateProcessor.disable(e,this._materialInfoCache),t.vertexSpace.type===`local`)return!1}e.updateFastLocalOrigin(s,l,this._context.localOriginFactory,!1);let{elevationContext:u}=e;u.centerInElevationSR=this._getCenterInElevationSR(s);let{elevationProvider:d,renderCoordsHelper:f}=this._context;return e.alignedSampledElevation=I(e,u,d.spatialReference,(e,t)=>R(e,d,u,f,t),f,s),e.updateTransform(s,l,this._context.isAsync,r),!0}computeComplexity(){if(!this._textures||this._textures.size===0)return super.computeComplexity();let e=0;for(let t of this._textures.values())e+=t.usedMemory;let t={...Te(this.symbol,this.symbolLayer),resourceBytes:e},n=Fe(this.symbolLayer)?2:0;return new Pe({drawCallsPerFeature:n,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){let n=this._requiresSymbolVertexColors(),r=!!e.vertexAttributes.color,i=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:n,hasVertexColors:r,hasVertexTangents:i,unlit:!1,uid:`vc:${r},vt:${i},vct${t},svc:${n}`}}_materialProperties(e,t,n){let r=this._materialPropertiesDefault(e,n);if(!t.material)return r;let{color:i,colorTexture:a,colorTextureTransform:o,normalTexture:s,normalTextureTransform:c,doubleSided:l,alphaCutoff:u,alphaMode:d}=t.material,f=G(i),p=G(a),m=K(o),h=G(s),g=K(c);if(r.color=i,r.colorTexture=a,r.normalTexture=s,r.uid=`${r.uid},cmuid:${f},ctmuid:${p},cttuid:${m},ntmuid:${h},nttuid:${g},ds:${l},ac:${u},am:${d}`,t.material instanceof me){let{metallic:e,roughness:n,metallicRoughnessTexture:i,metallicRoughnessTextureTransform:a,emissiveColor:s,emissiveStrength:l,emissiveTexture:u,emissiveTextureTransform:d,occlusionTexture:f,occlusionTextureTransform:p,unlit:m}=t.material,h=G(i),g=K(a),_=G(s),v=G(u),y=K(d),b=G(f),x=K(p);r.uid=[r.uid,`mrm:${e}`,`mrr:${n}`,`mrt:${h}`,`mrtt:${g}`,`emuid:${_}`,`ems:${l}`,`etmuid:${v}`,`ett:${y}`,`otmuid:${b}`,`ott:${x}`,`unlit:${m}`].join(`,`),r.metallic=e,r.roughness=n,r.metallicRoughnessTexture=i,r.emissiveColor=m?void 0:s,r.emissiveStrength=l,r.emissiveTexture=m?void 0:u,r.occlusionTexture=f,r.unlit=m,r.colorTextureTransform=P(o),r.normalTextureTransform=P(c),r.emissiveTextureTransform=P(d),r.occlusionTextureTransform=P(p),r.metallicRoughnessTextureTransform=P(a)}return r}_getInternalTexture(e,t=!1,i=1){let a=tt(e);if(!a)return null;let o=`${e.contentHash}/${i}`,s=this._textures.get(o);if(s){let e=this._context.stage.renderView.textures,t=null,i=e.acquire(s.id);return i!=null&&!r(i)&&(s.events.on(`unloaded`,()=>t=n(t)),t=i),s}let c=null,l=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:Qe(e.wrap),noUnpackFlip:!0,maxAnisotropy:l,mipmap:l>1};return we(a)?(c=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(c=a,u.preMultiplyAlpha=i!==1,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),s=new Re(c,u),this._textures.set(o,s),s.events.on(`loaded`,()=>this.updateComplexity()),s.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(s),s.events.on(`unloaded`,()=>{this._textures.delete(o)}),s}_setInternalMaterialTextureParameters(e,n){if(e.colorTexture!=null){let t=n.textureAlphaMode!==1,r=this._getInternalTexture(e.colorTexture,t,n.textureAlphaMode);r?(n.textureId=r.id,n.textureAlphaPremultiplied=!!r.parameters.preMultiplyAlpha):n.textureId=void 0}if(e.normalTexture&&(n.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){let r=e.emissiveColor?.toUnitRGB();n.emissiveBaseColor=ne(t(r[0]),t(r[1]),t(r[2]))}e.emissiveStrength&&(n.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(n.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(n.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(n.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,n){e.color!=null&&et(e.color,t,n),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=F(e.colorTextureTransform),t.normalTextureTransformMatrix=F(e.normalTextureTransform);let r=e.normalTextureTransform?.scale==null?m:e.normalTextureTransform?.scale;t.normalScale=[r[0],r[1]],t.occlusionTextureTransformMatrix=F(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=F(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=F(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){let n=this._drivenProperties.color,r=this._drivenProperties.opacity;if(n)e.externalColor=ae;else{let n=t??null;if(n){let t=n.toUnitRGBA();r&&(t[3]=1),e.externalColor=t}else e.externalColor=Ae}e.colorMixMode=this.symbolLayer.material?.colorMixMode??`multiply`,e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=Ce(this.symbolLayer?.material?.emissive?.source??`emissive`)}_getOrCreateMaterial(e,t){let n=t.material?.color,r=t.material?.colorTexture,i=t.material?.alphaMode,a=i===`blend`,o=i!==`opaque`&&($e(e)||n!=null&&n.a<1||r?.transparent||a),s=this._materialProperties(e,t,o),c=this._materialInfoCache.byUid(s.uid);if(c)return this._setInternalMaterialTextureParameters(s,c.material.parameters),c.material;let l={uid:s.uid,material:null,isComponentTransparent:o,alphaMode:t.material?t.material.alphaMode:`opaque`},u=Ve({normalTexture:s.normalTexture,metallicRoughnessTexture:s.metallicRoughnessTexture,metallicFactor:s.metallic,roughnessFactor:s.roughness,emissiveTexture:s.unlit?void 0:s.emissiveTexture,emissiveFactor:s.unlit?re:s.emissiveColor?.toUnitRGB(),occlusionTexture:s.occlusionTexture}),d={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:s.hasVertexColors,hasSymbolColors:s.hasSymbolVertexColors,hasVertexTangents:s.hasVertexTangents,ambient:re,diffuse:ie,opacity:1,doubleSided:!0,doubleSidedType:`winding-order`,cullFace:0,unlit:s.unlit,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||l.isComponentTransparent};d.mrrFactors=u?Ue:[s.metallic,s.roughness,He[2]],t.material&&(d.doubleSided=t.material.doubleSided,d.cullFace=t.material.doubleSided?0:2,d.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(d),this._setMaterialTextureAlphaMode(d,l),this._setInternalMaterialParameters(s,d,l);let f=new Be(d,this._context.spherical);return l.material=f,this._materialInfoCache.set(s.uid,l),f}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||t.material.type!==`partial`)return;let n=t.material.diff;if(!n.color||n.color.type!==`complete`||n.color.newValue==null||n.color.oldValue==null)return;let r=n.color.newValue;delete n.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{let t=e.material.parameters;this._setExternalMaterialParameters(t,r),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return Ee(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){e.textureAlphaMode=t.alphaMode===`auto`?this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1?3:1:t.alphaMode===`opaque`?1:t.alphaMode===`mask`?2:0}_createFaceDebugNormals(e,t){let n=t.length,r=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*r,e.extent.height*r,e.extent.zmax-e.extent.zmin),s=[],c=[],l=t[0].transformation,u=i(o(),l);for(let e=0;e<n;e++){let n=t[e].attributes.get(`position`);if(!n)continue;let r=n.data,i=n.indices;for(let e=0;e<i.length;e+=3)U(r,i,e,Z),Ze(r,i,e,J,Y,X),g(J,J,Y),g(J,J,X),_(J,J,1/3),v(J,J,l),s.push(...J),y(Z,Z,u),b(Z,Z),x(J,J,Z,a),s.push(...J),c.push(c.length),c.push(c.length)}return s.length?new B(this._debugFaceNormalMaterial,[[`position`,new z(s,c,3,!0)]],null):null}_createPerVertexDebugVectors(e,t,n,r,s){let c=t.length,l=e.spatialReference.isGeographic?20015077/180:1,u=s*.1*Math.max(e.extent.width*l,e.extent.height*l,e.extent.zmax-e.extent.zmin),d=[],f=[],p=t[0].transformation,m=i(o(),p);n===`tangent`&&a(m,p);for(let e=0;e<c;e++){let r=t[e],i=r.attributes.get(`position`),a=r.attributes.get(n);if(!i||!a)continue;let o=i.data,s=i.indices,c=a.data,l=a.indices;for(let e=0;e<s.length;e++){let t=s[e]*3,n=l[e]*a.stride;h(J,o[t+0],o[t+1],o[t+2]),v(J,J,p),d.push(...J),h(Y,c[n+0],c[n+1],c[n+2]),y(Y,Y,m),b(Y,Y),x(J,J,Y,u),d.push(...J),f.push(f.length),f.push(f.length)}}return d.length?new B(r,[[`position`,new z(d,f,3,!0)]],null):null}_createAs3DShape(e,t,n,r){let i=e.geometry;if(i.type!==`mesh`)return null;let a=this._createGeometryInfo(i,t,r);if(a==null)return null;let{geometries:o,objectTransformation:s}=a;if(Le.DRAW_MESH_GEOMETRY_NORMALS){let e=this._createPerVertexDebugVectors(i,o,`normal`,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(i,o,`tangent`,this._debugTangentNormalMaterial,.5),n=this._createFaceDebugNormals(i,o);e&&o.push(e),t&&o.push(t),n&&o.push(n)}let c=this._context.layerViewUid,l=new ze({geometries:o,layerViewUid:c,graphicUid:r,isElevationSource:!0});l.transformation=s;let u=Ie(this.symbolLayer,{opacity:this._getLayerOpacity()}),d=u?new Oe(o[0].material,u,this._context.slicePlaneEnabled):null,f=new De(this,l,null,I,n,d);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=L(n.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(i),n.centerInElevationSR=this._getCenterInElevationSR(l.transformation);let{elevationProvider:p,renderCoordsHelper:m}=this._context;return f.alignedSampledElevation=I(f,n,p.spatialReference,(e,t)=>R(e,p,n,m,t),m),f}_fastTransformUpdatesAllowed(e){let{vertexSpace:t,spatialReference:n}=e;if(!ge(t))return!1;let{type:r}=t,{view:i}=this._context.graphicsCoreOwner,{viewingMode:a}=i.state,o=i.spatialReference;return a===1&&r===`local`||a===2&&D(o,n)&&r===`georeferenced`&&!n.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){let t=C(),n=h(ot,e[12],e[13],e[14]);return ce(n,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return e.reprojection===0&&!!e.objectTransformation}_createPositionBuffer(e,t,n){let r=n.position,i=r,a;if(t.reprojection===0)return{position:i,georeferencedPositionBuffer:a};let o=t.reprojection===1?t.transformBeforeProject:null;o&&(i=k(new Float64Array(i.length),i,o));let{normal:s,tangent:c}=n;!this._passthroughReprojectionInfo(t)&&(s||c)&&(a=i);let l=i===r||i===a?new Float64Array(i.length):i;return se(i,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:a}}_createNormalBuffer(e,t,n,r,i){let a=i.normal;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;s&&(o=A(o,new Float32Array(o.length),s));let c=this._context.graphicsCoreOwner.view.viewingMode;if(r.reprojection===0)return o;if(c===`local`){if(!O(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return j(o,0,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return M(o,0,n,e)}return o}if(n==null)return null;let l=o===a?new Float32Array(o.length):o,u=this._context.renderCoordsHelper.spatialReference;return ve(o,n,e.spatialReference,t,u,l)}_createTangentBuffer(e,t,n,r,i){let a=i.tangent;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;s&&(o=N(o,new Float32Array(o.length),s));let c=this._context.graphicsCoreOwner.view.viewingMode;if(r.reprojection===0)return o;if(c===`local`){if(!O(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return j(o,1,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return M(o,1,n,e)}return o}if(n==null)return null;let l=o===a?new Float32Array(o.length):o,u=this._context.renderCoordsHelper.spatialReference;return ye(o,n,e.spatialReference,t,u,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){let n=e.vertexAttributes&&e.vertexAttributes.position;if(!n)return this.logger.warn(`Mesh geometry must contain position vertex attributes`),null;let r=e.vertexAttributes.normal,i=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(r&&r.length!==n.length)return this.logger.warn(`Mesh normal vertex buffer must contain the same number of elements as the position buffer`),null;if(a&&a.length/4!=n.length/3)return this.logger.warn(`Mesh tangent vertex buffer must contain the same number of elements as the position buffer`),null;if(i&&i.length/2!=n.length/3)return this.logger.warn(`Mesh uv vertex buffer must contain the same number of elements as the position buffer`),null;let o=this._computeReprojectionInfo(e),s=o.reprojection===1&&o.convertLocalVertexSpace,c=s&&e.vertexSpace.type===`local`?xe(e,e.vertexSpace,this._context.renderCoordsHelper.spatialReference):null;if(s&&!c)return this.logger.warn(`Local mesh vertex space could not be converted for rendering`),null;let{position:l,georeferencedPositionBuffer:u}=c?{position:c.position,georeferencedPositionBuffer:null}:this._createPositionBuffer(e,o,e.vertexAttributes),d=nt(e),f=this._createSymbolColorBuffer(t),p=c?c.normal:this._createNormalBuffer(e,l,u,o,e.vertexAttributes),m=c?c.tangent:this._createTangentBuffer(e,l,u,o,e.vertexAttributes),h=i,{geometryTransformation:g}=o,{transformation:_,position:v,normal:y,tangent:b}=this._passthroughReprojectionInfo(o)?{transformation:o.objectTransformation,position:l,normal:p,tangent:m}:this._expressInOriginLocalSpace(e,l,p,m,g);return{positionBuffer:v,normalBuffer:y,tangentBuffer:b,uvBuffer:h,colorBuffer:d,symbolColorBuffer:f,objectTransformation:_,geometryTransformation:g}}_computeReprojectionInfo(e){let{vertexSpace:t}=e,n=t.type===`georeferenced`,r=t.type===`local`&&this._context.graphicsCoreOwner.view.state.isGlobal,i=n?+!D(this._context.renderCoordsHelper.spatialReference,e.spatialReference):+!!r;if(_e(t))return{reprojection:i,geometryTransformation:d()};let a=t.origin,o=e.transform?.localMatrix??f;if(i===0){let t=d();return w(e.spatialReference,a,t,this._context.renderCoordsHelper.spatialReference),{reprojection:i,objectTransformation:t,geometryTransformation:p(o)}}if(r)return{reprojection:i,convertLocalVertexSpace:!0,geometryTransformation:p(o)};let l=s(d(),a);return c(l,l,o),{reprojection:i,transformBeforeProject:l,geometryTransformation:d()}}_expressInOriginLocalSpace(e,t,n,r,i){let a=this._context.renderCoordsHelper.spatialReference,o=e.origin;q[0]=o.x,q[1]=o.y,q[2]=o.z??0;let s=d();w(e.spatialReference,q,s,a),c(Q,s,i),l(Q,Q);let{position:u,normal:f,tangent:p}=e.vertexAttributes,m=t===u?new Float64Array(t.length):t;k(m,t,Q);let h=n?n===f?new Float32Array(n.length):n:null,g=r?r===p?new Float32Array(r.length):r:null;return n&&h&&A(n,h,Q),r&&g&&N(r,g,Q),{transformation:s,position:m,normal:h,tangent:g}}_validateFaces(e,t){let n=e.vertexAttributes.position.length/3,r=t.faces;if(r&&r.length>0){let e=-1;for(let t=0;t<r.length;t++){let n=r[t];n>e&&(e=n)}if(n<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(n%3!=0)return this.logger.warn(`Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)`),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent||!e.vertexAttributes?.position)return!1;let t=this._context.elevationProvider.spatialReference,n=be(e,t??e.spatialReference);return n?(le(n,$),!ue($,this._context.clippingExtent)):!1}_createGeometryInfo(e,t,n){if(!oe(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn(`Geometry spatial reference is not compatible with the view`),null;if(!this._validateVertexSpace(e)||this._isOutsideClippingArea(e))return null;let r=this._createBuffers(e,t);if(r==null)return null;let{positionBuffer:i,uvBuffer:a,colorBuffer:o,symbolColorBuffer:s,normalBuffer:c,tangentBuffer:l,objectTransformation:d,geometryTransformation:f}=r,p=e.components??at,m=[],h=!1,g=u(J,d),_=this._context.localOriginFactory.getOrigin(g);for(let t of p){if(!this._validateFaces(e,t))return null;let r=Ke(e,t);if(r.length===0)continue;let u=qe(i,c,t,r);u.didFlipNormals&&(h=!0);let d=[[`position`,new z(i,r,3,!0)],[`normal`,new z(u.normals,u.indices,3,!0)]];o&&d.push([`color`,new z(o,r,4,!0)]);let p=null;s&&(p=E(r.length),d.push([`symbolColor`,new z(s,p,4,!0)])),a&&d.push([`uv0`,new z(a,r,2,!0)]),l&&d.push([`tangent`,new z(l,r,4,!0)]);let g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:this._context.layerViewUid});g&&(p??=E(r.length),Ne(d,g,p));let v=this._getOrCreateMaterial(e,t),y=new B(v,d,null);y.transformation=f,y.localOrigin=_,m.push(y)}return h&&this.logger.warn(`Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals.`),m.length===0?null:{geometries:m,objectTransformation:d}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){let{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:n}=e;return t===2&&n.type===`local`?(this.logger.warn(`Displaying a mesh with a local vertex space in a view in local viewing mode is not supported.`),!1):!0}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class H{constructor(e,t,n){this.normals=e,this.indices=t,this.didFlipNormals=n}}function Ke(e,t){return t.faces??fe(e.vertexAttributes.position.length/3)}function qe(e,t,n,r){switch(n.shading||`flat`){default:case`source`:return Ye(e,t,n,r);case`flat`:return Je(e,r);case`smooth`:return Xe(e,r)}}function Je(e,t){let n=T(t.length),r=Array(t.length*3);for(let i=0;i<t.length;i+=3){let a=U(e,t,i,Z);for(let e=0;e<3;e++)n[i+e]=a[e],r[i+e]=i/3}return new H(n,r,!1)}function Ye(e,t,n,r){if(t==null)return Je(e,r);let i=!1;if(!n.trustSourceNormals)for(let n=0;n<r.length;n+=3){U(e,r,n,Z);for(let e=0;e<3;e++){let a=r[n+e]*3;J[0]=t[a],J[1]=t[a+1],J[2]=t[a+2],te(Z,J)<0&&(t[a]=-t[a],t[a+1]=-t[a+1],t[a+2]=-t[a+2],i=!0)}}return new H(t,r,i)}function Xe(e,t){let n={};for(let r=0;r<t.length;r+=3){let i=U(e,t,r,Z);for(let e=0;e<3;e++){let a=t[r+e],o=n[a];o||(o={normal:C(),count:0},n[a]=o),g(o.normal,o.normal,i),o.count++}}let r=T(t.length*3),i=Array(t.length*3);for(let e=0;e<t.length;e++){let a=n[t[e]];a.count!==1&&(b(a.normal,a.normal),a.count=1);for(let t=0;t<3;t++)r[e*3+t]=a.normal[t];i[e]=e}return new H(r,i,!1)}function Ze(e,t,n,r,i,a){let o=t[n]*3,s=t[n+1]*3,c=t[n+2]*3;r[0]=e[o],r[1]=e[o+1],r[2]=e[o+2],i[0]=e[s],i[1]=e[s+1],i[2]=e[s+2],a[0]=e[c],a[1]=e[c+1],a[2]=e[c+2]}function U(e,t,n,r){return Ze(e,t,n,J,Y,X),S(Y,Y,J),S(X,X,J),ee(J,Y,X),b(r,J),r}function Qe(e=`repeat`){if(typeof e==`string`){let t=W(e);return{s:t,t}}return{s:W(e.horizontal),t:W(e.vertical)}}function W(e){switch(e){case`clamp`:return 33071;case`mirror`:return 33648;default:return 10497}}function $e(e){let t=e.vertexAttributes.color;if(t==null)return!1;for(let e=3;e<t.length;e+=4)if(t[e]!==255)return!0;return!1}function et(e,t,n){t.diffuse=e.toUnitRGB(),t.opacity=n.alphaMode===`opaque`?1:e.a}function tt(e){return e.data??e.url}function G(t){return t==null?`-`:t instanceof e?t.toHex():t.contentHash}function K(e){let{offset:t,scale:n,rotation:r}=e??rt;return`${t[0]},${t[1]},${r},${n[0]},${n[1]}`}function nt(e){return e.vertexAttributes.color}const rt=new he,q=C(),J=C(),Y=C(),X=C(),Z=C(),Q=d(),it=d(),$=de(),at=[new pe],ot=C();export{Ge as Graphics3DMeshFillSymbolLayer};
2
+ import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{releaseMaybe as n}from"../../../../core/maybe.js";import{isPromiseLike as r}from"../../../../core/promiseUtils.js";import{normalFromMat4 as i,fromMat4 as a}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as s,multiply as c,invert as l,getTranslation as u}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as d,IDENTITY as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as m}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as h,add as g,scale as _,transformMat4 as v,transformMat3 as y,normalize as b,scaleAndAdd as x,subtract as S,cross as ee,dot as te}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as ne,ZEROS as re,ONES as ie,create as C}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as ae}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as oe}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as w}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as se}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as ce}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as le,intersectsClippingArea as ue,create as de}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as T}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as E,getContinuousIndexArray as fe}from"../../../../geometry/support/Indices.js";import pe from"../../../../geometry/support/MeshComponent.js";import me from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import he from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as ge,isAbsoluteVertexSpace as _e}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as D,isPlateCarree as O}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as k}from"../../../../chunks/vec3.js";import{transformNormal as A,transformVectorENUPlateCarree as j,transformVectorWMPlateCarree as M,projectNormalToPCPF as ve,transformTangent as N,projectTangentToPCPF as ye}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as be}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{projectLocalVertexSpaceToPCPF as xe}from"../../../../geometry/support/meshUtils/vertexSpaceConversion.js";import{isDrivenOpacityFallbackAlwaysOpaque as Se}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{getEmissiveMode as Ce}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as we}from"../../glTF/internal/resourceUtils.js";import{convertMeshTextureTransformToGLTF as P,getTransformMatrix as F}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as Te}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as I}from"./ElevationAligners.js";import{needsElevationUpdates3D as L,evaluateElevationInfoAtPoint as R}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as Ee}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as De}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Oe}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ke,nanFallbackColor as Ae}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as je,MeshFastUpdateProcessor as Me}from"./MeshFastUpdateProcessor.js";import{addOlidAttribute as Ne}from"./olidUtils.js";import{SymbolComplexity as Pe}from"./SymbolComplexity.js";import{hasEdges as Fe,createMaterial as Ie}from"../support/edgeUtils.js";import{debugFlags as Le}from"../../support/debugFlags.js";import{Attribute as z}from"../../webgl-engine/lib/Attribute.js";import{Geometry as B}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as Re}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as ze}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Be}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as V}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Ve,advancedMRRFactors as He,schematicMRRFactors as Ue}from"../../webgl-engine/materials/pbrUtils.js";const We=[`mesh`];class Ge extends ke{constructor(e,t,n,r){super(e,t,n,r,Se(t)),this._materialInfoCache=new je,this._fastUpdateProcessor=new Me,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){Le.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new V({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new V({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new V({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,We,`fill on mesh-3d`))return null;let n=this.createElevationContextForGraphic(t),r=e.renderingInfo;return this._createAs3DShape(t,r,n,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){let n=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:n});let t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(n,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,L)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicallyBasedRenderingChanged(){let e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateMeshTransform(e,t,n,r,i){if(!e.fastTransformUpdatesAllowed)return!1;let a=e.fastTransformUpdatesEnabled;switch(i){case 0:if(a)return!0;break;case 1:if(!a)return!0}let o=this._context.renderCoordsHelper.spatialReference,s=it,{origin:c,transform:l}=n;if(!w(t.spatialReference,h(J,c.x,c.y,c.z??0),s,o))return!1;switch(i){case void 0:a||this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context,!0);break;case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:if(this._fastUpdateProcessor.disable(e,this._materialInfoCache),t.vertexSpace.type===`local`)return!1}e.updateFastLocalOrigin(s,l,this._context.localOriginFactory,!1);let{elevationContext:u}=e;u.centerInElevationSR=this._getCenterInElevationSR(s);let{elevationProvider:d,renderCoordsHelper:f}=this._context;return e.alignedSampledElevation=I(e,u,d.spatialReference,(e,t)=>R(e,d,u,f,t),f,s),e.updateTransform(s,l,this._context.isAsync,r),!0}computeComplexity(){if(!this._textures||this._textures.size===0)return super.computeComplexity();let e=0;for(let t of this._textures.values())e+=t.usedMemory;let t={...Te(this.symbol,this.symbolLayer),resourceBytes:e},n=Fe(this.symbolLayer)?2:0;return new Pe({drawCallsPerFeature:n,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){let n=this._requiresSymbolVertexColors(),r=!!e.vertexAttributes.color,i=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:n,hasVertexColors:r,hasVertexTangents:i,unlit:!1,uid:`vc:${r},vt:${i},vct${t},svc:${n}`}}_materialProperties(e,t,n){let r=this._materialPropertiesDefault(e,n);if(!t.material)return r;let{color:i,colorTexture:a,colorTextureTransform:o,normalTexture:s,normalTextureTransform:c,doubleSided:l,alphaCutoff:u,alphaMode:d}=t.material,f=G(i),p=G(a),m=K(o),h=G(s),g=K(c);if(r.color=i,r.colorTexture=a,r.normalTexture=s,r.uid=`${r.uid},cmuid:${f},ctmuid:${p},cttuid:${m},ntmuid:${h},nttuid:${g},ds:${l},ac:${u},am:${d}`,t.material instanceof me){let{metallic:e,roughness:n,metallicRoughnessTexture:i,metallicRoughnessTextureTransform:a,emissiveColor:s,emissiveStrength:l,emissiveTexture:u,emissiveTextureTransform:d,occlusionTexture:f,occlusionTextureTransform:p,unlit:m}=t.material,h=G(i),g=K(a),_=G(s),v=G(u),y=K(d),b=G(f),x=K(p);r.uid=[r.uid,`mrm:${e}`,`mrr:${n}`,`mrt:${h}`,`mrtt:${g}`,`emuid:${_}`,`ems:${l}`,`etmuid:${v}`,`ett:${y}`,`otmuid:${b}`,`ott:${x}`,`unlit:${m}`].join(`,`),r.metallic=e,r.roughness=n,r.metallicRoughnessTexture=i,r.emissiveColor=m?void 0:s,r.emissiveStrength=l,r.emissiveTexture=m?void 0:u,r.occlusionTexture=f,r.unlit=m,r.colorTextureTransform=P(o),r.normalTextureTransform=P(c),r.emissiveTextureTransform=P(d),r.occlusionTextureTransform=P(p),r.metallicRoughnessTextureTransform=P(a)}return r}_getInternalTexture(e,t=!1,i=1){let a=tt(e);if(!a)return null;let o=`${e.contentHash}/${i}`,s=this._textures.get(o);if(s){let e=this._context.stage.renderView.textures,t=null,i=e.acquire(s.id);return i!=null&&!r(i)&&(s.events.on(`unloaded`,()=>t=n(t)),t=i),s}let c=null,l=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:Qe(e.wrap),noUnpackFlip:!0,maxAnisotropy:l,mipmap:l>1};return we(a)?(c=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(c=a,u.preMultiplyAlpha=i!==1,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),s=new Re(c,u),this._textures.set(o,s),s.events.on(`loaded`,()=>this.updateComplexity()),s.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(s),s.events.on(`unloaded`,()=>{this._textures.delete(o)}),s}_setInternalMaterialTextureParameters(e,n){if(e.colorTexture!=null){let t=n.textureAlphaMode!==1,r=this._getInternalTexture(e.colorTexture,t,n.textureAlphaMode);r?(n.textureId=r.id,n.textureAlphaPremultiplied=!!r.parameters.preMultiplyAlpha):n.textureId=void 0}if(e.normalTexture&&(n.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){let r=e.emissiveColor?.toUnitRGB();n.emissiveBaseColor=ne(t(r[0]),t(r[1]),t(r[2]))}e.emissiveStrength&&(n.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(n.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(n.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(n.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,n){e.color!=null&&et(e.color,t,n),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=F(e.colorTextureTransform),t.normalTextureTransformMatrix=F(e.normalTextureTransform);let r=e.normalTextureTransform?.scale==null?m:e.normalTextureTransform?.scale;t.normalScale=[r[0],r[1]],t.occlusionTextureTransformMatrix=F(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=F(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=F(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){let n=this._drivenProperties.color,r=this._drivenProperties.opacity;if(n)e.externalColor=ae;else{let n=t??null;if(n){let t=n.toUnitRGBA();r&&(t[3]=1),e.externalColor=t}else e.externalColor=Ae}e.colorMixMode=this.symbolLayer.material?.colorMixMode??`multiply`,e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=Ce(this.symbolLayer?.material?.emissive?.source??`emissive`)}_getOrCreateMaterial(e,t){let n=t.material?.color,r=t.material?.colorTexture,i=t.material?.alphaMode,a=i===`blend`,o=i!==`opaque`&&($e(e)||n!=null&&n.a<1||r?.transparent||a),s=this._materialProperties(e,t,o),c=this._materialInfoCache.byUid(s.uid);if(c)return this._setInternalMaterialTextureParameters(s,c.material.parameters),c.material;let l={uid:s.uid,material:null,isComponentTransparent:o,alphaMode:t.material?t.material.alphaMode:`opaque`},u=Ve({normalTexture:s.normalTexture,metallicRoughnessTexture:s.metallicRoughnessTexture,metallicFactor:s.metallic,roughnessFactor:s.roughness,emissiveTexture:s.unlit?void 0:s.emissiveTexture,emissiveFactor:s.unlit?re:s.emissiveColor?.toUnitRGB(),occlusionTexture:s.occlusionTexture}),d={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:s.hasVertexColors,hasSymbolColors:s.hasSymbolVertexColors,hasVertexTangents:s.hasVertexTangents,ambient:re,diffuse:ie,opacity:1,doubleSided:!0,doubleSidedType:`winding-order`,cullFace:0,unlit:s.unlit,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||l.isComponentTransparent};d.mrrFactors=u?Ue:[s.metallic,s.roughness,He[2]],t.material&&(d.doubleSided=t.material.doubleSided,d.cullFace=t.material.doubleSided?0:2,d.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(d),this._setMaterialTextureAlphaMode(d,l),this._setInternalMaterialParameters(s,d,l);let f=new Be(d,this._context.spherical);return l.material=f,this._materialInfoCache.set(s.uid,l),f}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||t.material.type!==`partial`)return;let n=t.material.diff;if(!n.color||n.color.type!==`complete`||n.color.newValue==null||n.color.oldValue==null)return;let r=n.color.newValue;delete n.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{let t=e.material.parameters;this._setExternalMaterialParameters(t,r),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return Ee(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicallyBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){e.textureAlphaMode=t.alphaMode===`auto`?this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1?3:1:t.alphaMode===`opaque`?1:t.alphaMode===`mask`?2:0}_createFaceDebugNormals(e,t){let n=t.length,r=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*r,e.extent.height*r,e.extent.zmax-e.extent.zmin),s=[],c=[],l=t[0].transformation,u=i(o(),l);for(let e=0;e<n;e++){let n=t[e].attributes.get(`position`);if(!n)continue;let r=n.data,i=n.indices;for(let e=0;e<i.length;e+=3)U(r,i,e,Z),Ze(r,i,e,J,Y,X),g(J,J,Y),g(J,J,X),_(J,J,1/3),v(J,J,l),s.push(...J),y(Z,Z,u),b(Z,Z),x(J,J,Z,a),s.push(...J),c.push(c.length),c.push(c.length)}return s.length?new B(this._debugFaceNormalMaterial,[[`position`,new z(s,c,3,!0)]],null):null}_createPerVertexDebugVectors(e,t,n,r,s){let c=t.length,l=e.spatialReference.isGeographic?20015077/180:1,u=s*.1*Math.max(e.extent.width*l,e.extent.height*l,e.extent.zmax-e.extent.zmin),d=[],f=[],p=t[0].transformation,m=i(o(),p);n===`tangent`&&a(m,p);for(let e=0;e<c;e++){let r=t[e],i=r.attributes.get(`position`),a=r.attributes.get(n);if(!i||!a)continue;let o=i.data,s=i.indices,c=a.data,l=a.indices;for(let e=0;e<s.length;e++){let t=s[e]*3,n=l[e]*a.stride;h(J,o[t+0],o[t+1],o[t+2]),v(J,J,p),d.push(...J),h(Y,c[n+0],c[n+1],c[n+2]),y(Y,Y,m),b(Y,Y),x(J,J,Y,u),d.push(...J),f.push(f.length),f.push(f.length)}}return d.length?new B(r,[[`position`,new z(d,f,3,!0)]],null):null}_createAs3DShape(e,t,n,r){let i=e.geometry;if(i.type!==`mesh`)return null;let a=this._createGeometryInfo(i,t,r);if(a==null)return null;let{geometries:o,objectTransformation:s}=a;if(Le.DRAW_MESH_GEOMETRY_NORMALS){let e=this._createPerVertexDebugVectors(i,o,`normal`,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(i,o,`tangent`,this._debugTangentNormalMaterial,.5),n=this._createFaceDebugNormals(i,o);e&&o.push(e),t&&o.push(t),n&&o.push(n)}let c=this._context.layerViewUid,l=new ze({geometries:o,layerViewUid:c,graphicUid:r,isElevationSource:!0});l.transformation=s;let u=Ie(this.symbolLayer,{opacity:this._getLayerOpacity()}),d=u?new Oe(o[0].material,u,this._context.slicePlaneEnabled):null,f=new De(this,l,null,I,n,d);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=L(n.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(i),n.centerInElevationSR=this._getCenterInElevationSR(l.transformation);let{elevationProvider:p,renderCoordsHelper:m}=this._context;return f.alignedSampledElevation=I(f,n,p.spatialReference,(e,t)=>R(e,p,n,m,t),m),f}_fastTransformUpdatesAllowed(e){let{vertexSpace:t,spatialReference:n}=e;if(!ge(t))return!1;let{type:r}=t,{view:i}=this._context.graphicsCoreOwner,{viewingMode:a}=i.state,o=i.spatialReference;return a===1&&r===`local`||a===2&&D(o,n)&&r===`georeferenced`&&!n.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){let t=C(),n=h(ot,e[12],e[13],e[14]);return ce(n,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return e.reprojection===0&&!!e.objectTransformation}_createPositionBuffer(e,t,n){let r=n.position,i=r,a;if(t.reprojection===0)return{position:i,georeferencedPositionBuffer:a};let o=t.reprojection===1?t.transformBeforeProject:null;o&&(i=k(new Float64Array(i.length),i,o));let{normal:s,tangent:c}=n;!this._passthroughReprojectionInfo(t)&&(s||c)&&(a=i);let l=i===r||i===a?new Float64Array(i.length):i;return se(i,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:a}}_createNormalBuffer(e,t,n,r,i){let a=i.normal;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;s&&(o=A(o,new Float32Array(o.length),s));let c=this._context.graphicsCoreOwner.view.viewingMode;if(r.reprojection===0)return o;if(c===`local`){if(!O(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return j(o,0,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return M(o,0,n,e)}return o}if(n==null)return null;let l=o===a?new Float32Array(o.length):o,u=this._context.renderCoordsHelper.spatialReference;return ve(o,n,e.spatialReference,t,u,l)}_createTangentBuffer(e,t,n,r,i){let a=i.tangent;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;s&&(o=N(o,new Float32Array(o.length),s));let c=this._context.graphicsCoreOwner.view.viewingMode;if(r.reprojection===0)return o;if(c===`local`){if(!O(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return j(o,1,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return M(o,1,n,e)}return o}if(n==null)return null;let l=o===a?new Float32Array(o.length):o,u=this._context.renderCoordsHelper.spatialReference;return ye(o,n,e.spatialReference,t,u,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){let n=e.vertexAttributes&&e.vertexAttributes.position;if(!n)return this.logger.warn(`Mesh geometry must contain position vertex attributes`),null;let r=e.vertexAttributes.normal,i=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(r&&r.length!==n.length)return this.logger.warn(`Mesh normal vertex buffer must contain the same number of elements as the position buffer`),null;if(a&&a.length/4!=n.length/3)return this.logger.warn(`Mesh tangent vertex buffer must contain the same number of elements as the position buffer`),null;if(i&&i.length/2!=n.length/3)return this.logger.warn(`Mesh uv vertex buffer must contain the same number of elements as the position buffer`),null;let o=this._computeReprojectionInfo(e),s=o.reprojection===1&&o.convertLocalVertexSpace,c=s&&e.vertexSpace.type===`local`?xe(e,e.vertexSpace,this._context.renderCoordsHelper.spatialReference):null;if(s&&!c)return this.logger.warn(`Local mesh vertex space could not be converted for rendering`),null;let{position:l,georeferencedPositionBuffer:u}=c?{position:c.position,georeferencedPositionBuffer:null}:this._createPositionBuffer(e,o,e.vertexAttributes),d=nt(e),f=this._createSymbolColorBuffer(t),p=c?c.normal:this._createNormalBuffer(e,l,u,o,e.vertexAttributes),m=c?c.tangent:this._createTangentBuffer(e,l,u,o,e.vertexAttributes),h=i,{geometryTransformation:g}=o,{transformation:_,position:v,normal:y,tangent:b}=this._passthroughReprojectionInfo(o)?{transformation:o.objectTransformation,position:l,normal:p,tangent:m}:this._expressInOriginLocalSpace(e,l,p,m,g);return{positionBuffer:v,normalBuffer:y,tangentBuffer:b,uvBuffer:h,colorBuffer:d,symbolColorBuffer:f,objectTransformation:_,geometryTransformation:g}}_computeReprojectionInfo(e){let{vertexSpace:t}=e,n=t.type===`georeferenced`,r=t.type===`local`&&this._context.graphicsCoreOwner.view.state.isGlobal,i=n?+!D(this._context.renderCoordsHelper.spatialReference,e.spatialReference):+!!r;if(_e(t))return{reprojection:i,geometryTransformation:d()};let a=t.origin,o=e.transform?.localMatrix??f;if(i===0){let t=d();return w(e.spatialReference,a,t,this._context.renderCoordsHelper.spatialReference),{reprojection:i,objectTransformation:t,geometryTransformation:p(o)}}if(r)return{reprojection:i,convertLocalVertexSpace:!0,geometryTransformation:p(o)};let l=s(d(),a);return c(l,l,o),{reprojection:i,transformBeforeProject:l,geometryTransformation:d()}}_expressInOriginLocalSpace(e,t,n,r,i){let a=this._context.renderCoordsHelper.spatialReference,o=e.origin;q[0]=o.x,q[1]=o.y,q[2]=o.z??0;let s=d();w(e.spatialReference,q,s,a),c(Q,s,i),l(Q,Q);let{position:u,normal:f,tangent:p}=e.vertexAttributes,m=t===u?new Float64Array(t.length):t;k(m,t,Q);let h=n?n===f?new Float32Array(n.length):n:null,g=r?r===p?new Float32Array(r.length):r:null;return n&&h&&A(n,h,Q),r&&g&&N(r,g,Q),{transformation:s,position:m,normal:h,tangent:g}}_validateFaces(e,t){let n=e.vertexAttributes.position.length/3,r=t.faces;if(r&&r.length>0){let e=-1;for(let t=0;t<r.length;t++){let n=r[t];n>e&&(e=n)}if(n<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(n%3!=0)return this.logger.warn(`Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)`),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent||!e.vertexAttributes?.position)return!1;let t=this._context.elevationProvider.spatialReference,n=be(e,t??e.spatialReference);return n?(le(n,$),!ue($,this._context.clippingExtent)):!1}_createGeometryInfo(e,t,n){if(!oe(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn(`Geometry spatial reference is not compatible with the view`),null;if(!this._validateVertexSpace(e)||this._isOutsideClippingArea(e))return null;let r=this._createBuffers(e,t);if(r==null)return null;let{positionBuffer:i,uvBuffer:a,colorBuffer:o,symbolColorBuffer:s,normalBuffer:c,tangentBuffer:l,objectTransformation:d,geometryTransformation:f}=r,p=e.components??at,m=[],h=!1,g=u(J,d),_=this._context.localOriginFactory.getOrigin(g);for(let t of p){if(!this._validateFaces(e,t))return null;let r=Ke(e,t);if(r.length===0)continue;let u=qe(i,c,t,r);u.didFlipNormals&&(h=!0);let d=[[`position`,new z(i,r,3,!0)],[`normal`,new z(u.normals,u.indices,3,!0)]];o&&d.push([`color`,new z(o,r,4,!0)]);let p=null;s&&(p=E(r.length),d.push([`symbolColor`,new z(s,p,4,!0)])),a&&d.push([`uv0`,new z(a,r,2,!0)]),l&&d.push([`tangent`,new z(l,r,4,!0)]);let g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:this._context.layerViewUid});g&&(p??=E(r.length),Ne(d,g,p));let v=this._getOrCreateMaterial(e,t),y=new B(v,d,null);y.transformation=f,y.localOrigin=_,m.push(y)}return h&&this.logger.warn(`Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals.`),m.length===0?null:{geometries:m,objectTransformation:d}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){let{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:n}=e;return t===2&&n.type===`local`?(this.logger.warn(`Displaying a mesh with a local vertex space in a view in local viewing mode is not supported.`),!1):!0}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class H{constructor(e,t,n){this.normals=e,this.indices=t,this.didFlipNormals=n}}function Ke(e,t){return t.faces??fe(e.vertexAttributes.position.length/3)}function qe(e,t,n,r){switch(n.shading||`flat`){default:case`source`:return Ye(e,t,n,r);case`flat`:return Je(e,r);case`smooth`:return Xe(e,r)}}function Je(e,t){let n=T(t.length),r=Array(t.length*3);for(let i=0;i<t.length;i+=3){let a=U(e,t,i,Z);for(let e=0;e<3;e++)n[i+e]=a[e],r[i+e]=i/3}return new H(n,r,!1)}function Ye(e,t,n,r){if(t==null)return Je(e,r);let i=!1;if(!n.trustSourceNormals)for(let n=0;n<r.length;n+=3){U(e,r,n,Z);for(let e=0;e<3;e++){let a=r[n+e]*3;J[0]=t[a],J[1]=t[a+1],J[2]=t[a+2],te(Z,J)<0&&(t[a]=-t[a],t[a+1]=-t[a+1],t[a+2]=-t[a+2],i=!0)}}return new H(t,r,i)}function Xe(e,t){let n={};for(let r=0;r<t.length;r+=3){let i=U(e,t,r,Z);for(let e=0;e<3;e++){let a=t[r+e],o=n[a];o||(o={normal:C(),count:0},n[a]=o),g(o.normal,o.normal,i),o.count++}}let r=T(t.length*3),i=Array(t.length*3);for(let e=0;e<t.length;e++){let a=n[t[e]];a.count!==1&&(b(a.normal,a.normal),a.count=1);for(let t=0;t<3;t++)r[e*3+t]=a.normal[t];i[e]=e}return new H(r,i,!1)}function Ze(e,t,n,r,i,a){let o=t[n]*3,s=t[n+1]*3,c=t[n+2]*3;r[0]=e[o],r[1]=e[o+1],r[2]=e[o+2],i[0]=e[s],i[1]=e[s+1],i[2]=e[s+2],a[0]=e[c],a[1]=e[c+1],a[2]=e[c+2]}function U(e,t,n,r){return Ze(e,t,n,J,Y,X),S(Y,Y,J),S(X,X,J),ee(J,Y,X),b(r,J),r}function Qe(e=`repeat`){if(typeof e==`string`){let t=W(e);return{s:t,t}}return{s:W(e.horizontal),t:W(e.vertical)}}function W(e){switch(e){case`clamp`:return 33071;case`mirror`:return 33648;default:return 10497}}function $e(e){let t=e.vertexAttributes.color;if(t==null)return!1;for(let e=3;e<t.length;e+=4)if(t[e]!==255)return!0;return!1}function et(e,t,n){t.diffuse=e.toUnitRGB(),t.opacity=n.alphaMode===`opaque`?1:e.a}function tt(e){return e.data??e.url}function G(t){return t==null?`-`:t instanceof e?t.toHex():t.contentHash}function K(e){let{offset:t,scale:n,rotation:r}=e??rt;return`${t[0]},${t[1]},${r},${n[0]},${n[1]}`}function nt(e){return e.vertexAttributes.color}const rt=new he,q=C(),J=C(),Y=C(),X=C(),Z=C(),Q=d(),it=d(),$=de(),at=[new pe],ot=C();export{Ge as Graphics3DMeshFillSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{throwIfAborted as e}from"../../../../core/promiseUtils.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{identity as n,scale as r,translate as i,copy as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as s,negate as c,copy as l,multiply as u,add as d,set as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as p,ONES as m,ZEROS as h,fromValues as g,create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as v,ONES as y,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as S}from"../../../../geometry/projection/projectPointToVector.js";import{create as C,size as w,containsPoint as T,center as E}from"../../../../geometry/support/aaBoundingBox.js";import{getEmissiveMode as ee}from"../../../../symbols/support/materialUtils.js";import{defaultObjectPrimitive as D}from"../../../../symbols/support/primitives.js";import{objectSymbolLayerPrimitiveBoundingBox as te,objectSymbolLayerSizeWithResourceSize as O}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as ne,defaultSymbolLayerMemoryComplexity as re}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as ie}from"./ElevationAligners.js";import{needsElevationUpdates3D as k,SampleElevationInfo as A,evaluateElevationInfoAtPoint as j}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as M}from"./emissiveUtils.js";import{Graphics3DLodInstanceGraphicLayer as ae}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as oe,nanFallbackColor as N}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as P,computeObjectScale as F,computeObjectRotation as I}from"./graphicUtils.js";import{makeLodResources as se}from"./lodResourceUtils.js";import{fetch as ce}from"./objectResourceUtils.js";import{placePointOnGeometry as L,extendPointGraphicElevationContext as R}from"./pointUtils.js";import{isValidPrimitive as z,primitiveLodResources as B}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as V}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as H}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as U,updateFastSymbolUpdatesState as W,ConvertOptions as le,evaluateModelTransformScale as ue,evaluateModelTransform as de}from"../support/FastSymbolUpdates.js";import{VerticalOffsetParameters as fe}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{LodRenderer as pe}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as me}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as he}from"../../webgl-engine/materials/pbrUtils.js";class G{constructor(e,t,n,r,i,a,o,s,c,l,u=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=n,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=a,this.resourceBoundingBox=o,this.symbolSize=s,this.extentPadding=c,this.physicalBasedRenderingEnabled=l,this.pivotOffset=u}}class ge extends oe{getCachedSize(){let[e,t,n]=this._resources==null?[1,1,1]:this._resources.symbolSize;return{width:e,depth:t,height:n}}constructor(e,t,n,r){super(e,t,n,r,_e(t)),this._resources=null,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=[],this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=n.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){let e=P(this.symbolLayer);if(e)throw Error(e)}if(this._isPrimitive){let t=this.symbolLayer.resource,n=t&&z(t?.primitive)?t.primitive:D;this._resources=await this._createResourcesForPrimitive(n,e)}else{let t=(await H(this.symbol.styleOrigin))?.href??this.symbolLayer.resource?.href;this._resources=await this._createResourcesForUrl(t,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.updateComplexity()}get extentPadding(){return this._resources==null?0:this._resources.extentPadding}get _isPrimitive(){return this._primitive!=null}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}async _createResourcesForPrimitive(t,n){let r=this.symbolLayer,i=C(te(t)),a=p(w(i)),o=p(O(a,r)),c=s(o),l=r.material?.emissive,u=(l?.source===`color`?l?.strength:void 0)??0,d={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:he,ambient:m,diffuse:m,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:r.castShadows,emissiveStrengthFromSymbol:u,emissiveSource:1,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass,normalType:1},f=!!d.usePBR,h=this.symbol;h.type===`point-3d`&&h.verticalOffset&&(d.verticalOffset=new fe(h.verticalOffset),d.castShadows=!1),this._context.screenSizePerspectiveEnabled&&(d.screenSizePerspective=this.view.screenSizePerspective.parameters),d.externalColor=this._hasDrivenColorOrOpacity?N:this._materialColor?.toUnitRGBA()??v,this._fastUpdates=U(this._context.renderer,this._fastVisualVariableConvertOptions(i,o,a,null)),d.instanced=!0,this._fastUpdates?(Object.assign(d,this._fastUpdates.materialParameters),d.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(d.instancedColor=!0);let g=new me(d,this._context.spherical);g.setParameters({cullFace:J(g.transparent)});let _=B(t,g);if(!_)throw Error(`Unknown object symbol primitive: ${t}`);let y=await this._createStageResources(_,f,n);e(n);let b=await this._createLodRenderer(_,n);return new G(_,b,y,a,!1,!1,i,o,c,f)}async _createResourcesForUrl(n,r){let i={instanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},a={spherical:this._context.spherical,materialParameters:i,cache:this._context.sharedResources.objectResourceCache,compressionOptions:{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}};this._fastUpdates=U(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(a.materialParameters,this._fastUpdates.materialParameters),a.materialParameters.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(a.materialParameters.instancedColor=!0);let o=this.symbol;if(o.type===`point-3d`&&o.verticalOffset){let{screenLength:e,minWorldLength:n,maxWorldLength:r}=o.verticalOffset;a.materialParameters.verticalOffset={screenLength:t(e),minWorldLength:n||0,maxWorldLength:r??1/0},a.materialParameters.castShadows=!1}let c=this._context.physicalBasedRenderingEnabled;a.signal=r,a.usePBR=c,a.useEmissive=this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result,a.skipHighLods=this._context.skipHighSymbolLods;let l=this.symbolLayer.material;a.materialParameters.emissiveStrengthFromSymbol=l?.emissive?.strength??1,a.materialParameters.emissiveSource=ee(l?.emissive?.source??`emissive`);let u=await ce(n,a),d=u.isEsriSymbolResource,f=u.isWosr,m=se(u.lods),h=this._context,g=this._getExternalColorParameters(l),_=this.needsDrivenTransparentPass,v=m.getMaterials();v.forEach(e=>{e.setParameters({...g,drivenOpacity:_}),h.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:this.view.screenSizePerspective.parameters})});let y=u.referenceBoundingBox,b=p(w(y)),x=p(m.levels[0].pivotOffset),S=p(O(b,this.symbolLayer)),C=s(S),T=this._fastUpdates;W(T,this._context.renderer,this._fastVisualVariableConvertOptions(y,S,b,x))&&v.forEach(e=>e.setParameters(T.materialParameters));let E=await this._createStageResources(m,c,r);e(r);let D=await this._createLodRenderer(m,r);return new G(m,D,E,b,d,f,y,S,C,c,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(t,n,r){let i=this._context.stage,a=t.getMaterials();n!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged();let o=t.getTextures();return i.addTextures(o),this._addDisposeResource(()=>{o.forEach(e=>e.unload()),i.removeTextures(o)}),await Promise.all(o.map(e=>this._context.stage.schedule(()=>e.load(i.renderView.renderingContext),r))),e(r),{materials:a,textures:o,geometries:t.getEngineGeometries()}}async _createLodRenderer(e,t){let n=this._context.stage,r={layerViewUid:this._context.layerViewUid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,o=new pe({symbol:e,metadata:r,shaderTransformation:i?{applyTransform:(e,t,n)=>{e.getFeatureAttribute(t,Q),a(n,de(i.materialParameters,Q,n))},scaleFactor:(e,t,n)=>{t.getFeatureAttribute(n,Q),ue(e,i.materialParameters,Q)}}:null},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource(()=>{n.removeRenderPlugin(o),o.destroy()}),await n.addRenderPlugin(o,t),o}_getExternalColorParameters(e){let t={};if(t.externalColor=N,!this._drivenProperties.color&&e?.color!=null){let n=e.color.toUnitRGBA();this._drivenProperties.opacity&&(n[3]=NaN),t.externalColor=n}return t}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach(e=>e()),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let n=L(t.geometry);if(n==null)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;let r=this.createElevationContextForGraphic(t),i=e.renderingInfo;return this._createAs3DShape(n,i,r,t.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(this._resources==null)return;let e=this._getLayerOpacity(),t=this._resources.stageResources.materials;for(let n=0;n<t.length;n++){let r=t[n];r.setParameters({layerOpacity:e}),this._isPrimitive&&r.setParameters({cullFace:J(r.transparent)})}}layerScreenSizePerspectiveChanged(){if(this._resources==null)return;let e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;for(let t of this._resources.stageResources.materials)t.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,k)}slicePlaneEnabledChanged(){if(this._resources==null)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(let e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(this._resources==null)return!0;let{stageResources:e,isWosr:t}=this._resources;for(let n of e.materials)this._isPrimitive?n.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||n.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return this._hasLoadedPBRTextures===!1&&this._context.physicalBasedRenderingEnabled===!0?(this._hasLoadedPBRTextures=!0,!1):!0}applyRendererDiff(e,t){if(this._resources==null)return 0;let{stageResources:{materials:n},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:s}=this._resources;for(let c in e.diff)switch(c){case`visualVariables`:if(W(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,s))){for(let e of n)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}else return 0;break;default:return 0}return 2}computeComplexity(){if(this._resources==null)return super.computeComplexity();let e=this._resources.lodResources,t=ne(e.levels),n=e.computeUsedMemory(),r={...re(this.symbol,this.symbolLayer),resourceBytes:n};return new V({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return this._resources!=null}_createAs3DShape(e,t,n,r){if(!this._hasLodRenderer()||this._resources==null)return null;let i=this.getFastUpdateAttrValues(t),a=this._context.clippingExtent;if(S(e,Y,this._context.elevationProvider.spatialReference),a!=null&&!T(a,Y))return null;let o=q(n),s=this._computeGlobalTransform(e,n,Z,$),c=this._computeLocalTransform(this._resources,this.symbolLayer,t,X),l=this._resources.lodRenderer.instanceData,u=l.addInstance();this._instanceIndexToGraphicUid.set(u,r),l.setLocalTransform(u,c,!1),l.setGlobalTransform(u,s),i&&l.setFeatureAttribute(u,i),this._fastUpdates==null&&this._hasDrivenColorOrOpacity&&l.setColor(u,this._getDrivenUInt8ColorWithNaNSupport(t,this._materialColor,!this._isPrimitive));let d=this._context.stage.renderView.olidRenderHelper;if(d){let e=d.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid});l.setObjectAndLayerIdColor(u,e)}let f=new ae(this,u,ie,n,this._context.stage.view.state.highlightOrderMap);return o&&(f.alignedSampledElevation=$.sampledElevation),f.needsElevationUpdates=k(n.mode),R(f,e,this._context.elevationProvider),f}_computeGlobalTransform(e,t,n,r){return j(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),Y[0]=e.x,Y[1]=e.y,Y[2]=r.z,x(e.spatialReference,Y,n,this._context.renderCoordsHelper.spatialReference),n}_computeLocalTransform(e,t,r,i){return n(i),this._applyObjectRotationVisualVariables(r,!1,i),this._applyObjectRotation(t,!0,i),this._applyObjectScale(e,r,i),this._applyAnchor(e,t,i),i}_applyObjectScale(e,t,n){if(this._fastUpdates?.requiresShaderTransformation)return;let i=this._drivenProperties.size&&t.size?t.size.output:e.symbolSize,a=F(i,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);if(a[0]!==1||a[1]!==1||a[2]!==1)r(n,n,a);else return}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}updateGeometry(e,t){if(this._resources==null)return!0;let n=e.geometry;if(!n)return!1;let r=L(n);if(r==null)return!1;let i=this.getGeometryElevationMode(n),{elevationContext:a}=t;return a.mode===i&&(a.updateFeatureExpressionFeature(e,this._context.layer),this._computeGlobalTransform(r,a,Z,$),q(a)&&(t.alignedSampledElevation=$.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(t.instanceIndex,Z,!0),R(t,r,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!t.heading&&!t.tilt&&!t.roll&&!t.width&&!t.height&&!t.depth&&!t.anchor&&!t.anchorPosition||this._resources==null)return;let n=(e,t,n)=>(e!=null&&e.type===`complete`?e.newValue:t)??n,r=n(t.heading,this.symbolLayer.heading,0),i=n(t.tilt,this.symbolLayer.tilt,0),a=n(t.roll,this.symbolLayer.roll,0),o=n(t.width,this.symbolLayer.width,void 0),s=n(t.height,this.symbolLayer.height,void 0),c=n(t.depth,this.symbolLayer.depth,void 0),l=n(t.anchor,this.symbolLayer.anchor,void 0),u=n(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;let d={heading:r,tilt:i,roll:a,anchor:l,anchorPosition:u},f=this._resources;this.loadStatus===1&&e.symbolLayerStatePatches.push(()=>{f.symbolSize=p(O(f.resourceSize,{width:o,height:s,depth:c,isPrimitive:this._isPrimitive}))}),e.graphics3DGraphicPatches.push(({instanceIndex:e},t)=>{let n=this._computeLocalTransform(f,d,t,X);f.lodRenderer.instanceData.setLocalTransform(e,n,!0)})}_preparePatchColor(e,t){if(!t.material||t.material.type!==`partial`)return;let n=t.material.diff;if(!n.color||n.color.type!==`complete`||n.color.newValue==null||n.color.oldValue==null)return;let r=n.color.newValue,i=r==null?y:r.toUnitRGBA();delete n.color;let a=this._resources;if(a==null)return;let o=this._isPrimitive;e.graphics3DGraphicPatches.push(({instanceIndex:e})=>{if(this._hasDrivenColorOrOpacity)a.lodRenderer.instanceData.setColor(e,i);else{let e={externalColor:i};for(let t of a.stageResources.materials)t.setParameters(e),o&&t.setParameters({cullFace:J(t.transparent)})}})}_preparePatchEmissive(e,t){return M(e,t,e=>{this._resources?.stageResources.materials.forEach(t=>{if(!this._isPrimitive){t.setParameters({emissiveStrengthFromSymbol:e??1});return}let n=this.symbolLayer.material?.emissive?.source===`color`;t.setParameters({emissiveStrengthFromSymbol:n?e??0:0})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_applyObjectRotationVisualVariables(e,t,n){this._fastUpdates?.requiresShaderTransformation&&t||I(e.heading?.output,e.tilt?.output,e.roll?.output,n)}_applyObjectRotation(e,t,n){this._fastUpdates?.requiresShaderTransformation&&t||I(e.heading,e.tilt,e.roll,n)}_applyAnchor(e,t,n){if(this._fastUpdates?.requiresShaderTransformation)return;let r=K(e.resourceBoundingBox,e.pivotOffset,t);r&&i(n,n,r)}_fastVisualVariableConvertOptions(e,t,n,r){let i=e==null?m:p(w(e)),a=e==null?h:K(e,r,this.symbolLayer),o=this._context.renderCoordsHelper.unitInMeters,s=F(t??void 0,t,n,o),c=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new le({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??m,unitInMeters:o,anchor:a,scale:s,rotation:c,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:s})}get _primitive(){let{resource:e}=this.symbolLayer;return e?.href==null?e?.primitive??D:null}_getFallbackOpacityAndColor(){return this._materialColor?.toUnitRGBA()??(this._isPrimitive?v:N)}get _materialColor(){return this.symbolLayer.material?.color}}function K(e,t,n){let r=_();switch(n.anchor){case`center`:l(r,E(e)),c(r,r);break;case`top`:{let t=E(e);f(r,-t[0],-t[1],-e[5]);break}case`bottom`:{let t=E(e);f(r,-t[0],-t[1],-e[2]);break}case`relative`:{let t=E(e),i=w(e),a=n.anchorPosition,o=a?g(a.x,a.y,a.z):h;u(r,i,o),d(r,r,t),c(r,r);break}default:t==null?l(r,h):c(r,t)}return r}function q(e){return e.mode!==`absolute-height`}function _e(e){return(e.material?.color?.a??1)===1&&e.resource?.href==null}function J(e){return e?0:2}const Y=_(),X=o(),Z=o(),Q=b(),$=new A;export{ge as Graphics3DObjectSymbolLayer};
2
+ import{throwIfAborted as e}from"../../../../core/promiseUtils.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{identity as n,scale as r,translate as i,copy as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as s,negate as c,copy as l,multiply as u,add as d,set as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as p,ONES as m,ZEROS as h,fromValues as g,create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as v,ONES as y,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as S}from"../../../../geometry/projection/projectPointToVector.js";import{create as C,size as w,containsPoint as T,center as E}from"../../../../geometry/support/aaBoundingBox.js";import{getEmissiveMode as ee}from"../../../../symbols/support/materialUtils.js";import{defaultObjectPrimitive as D}from"../../../../symbols/support/primitives.js";import{objectSymbolLayerPrimitiveBoundingBox as te,objectSymbolLayerSizeWithResourceSize as O}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as ne,defaultSymbolLayerMemoryComplexity as re}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as ie}from"./ElevationAligners.js";import{needsElevationUpdates3D as k,SampleElevationInfo as A,evaluateElevationInfoAtPoint as j}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as M}from"./emissiveUtils.js";import{Graphics3DLodInstanceGraphicLayer as ae}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as oe,nanFallbackColor as N}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as P,computeObjectScale as F,computeObjectRotation as I}from"./graphicUtils.js";import{makeLodResources as se}from"./lodResourceUtils.js";import{fetch as ce}from"./objectResourceUtils.js";import{placePointOnGeometry as L,extendPointGraphicElevationContext as R}from"./pointUtils.js";import{isValidPrimitive as z,primitiveLodResources as B}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as V}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as H}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as U,updateFastSymbolUpdatesState as W,ConvertOptions as le,evaluateModelTransformScale as ue,evaluateModelTransform as de}from"../support/FastSymbolUpdates.js";import{VerticalOffsetParameters as fe}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{LodRenderer as pe}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as me}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as he}from"../../webgl-engine/materials/pbrUtils.js";class G{constructor(e,t,n,r,i,a,o,s,c,l,u=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=n,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=a,this.resourceBoundingBox=o,this.symbolSize=s,this.extentPadding=c,this.physicallyBasedRenderingEnabled=l,this.pivotOffset=u}}class ge extends oe{getCachedSize(){let[e,t,n]=this._resources==null?[1,1,1]:this._resources.symbolSize;return{width:e,depth:t,height:n}}constructor(e,t,n,r){super(e,t,n,r,_e(t)),this._resources=null,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=[],this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=n.physicallyBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){let e=P(this.symbolLayer);if(e)throw Error(e)}if(this._isPrimitive){let t=this.symbolLayer.resource,n=t&&z(t?.primitive)?t.primitive:D;this._resources=await this._createResourcesForPrimitive(n,e)}else{let t=(await H(this.symbol.styleOrigin))?.href??this.symbolLayer.resource?.href;this._resources=await this._createResourcesForUrl(t,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicallyBasedRenderingChanged(),this.updateComplexity()}get extentPadding(){return this._resources==null?0:this._resources.extentPadding}get _isPrimitive(){return this._primitive!=null}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}async _createResourcesForPrimitive(t,n){let r=this.symbolLayer,i=C(te(t)),a=p(w(i)),o=p(O(a,r)),c=s(o),l=r.material?.emissive,u=(l?.source===`color`?l?.strength:void 0)??0,d={usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!0,mrrFactors:he,ambient:m,diffuse:m,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:r.castShadows,emissiveStrengthFromSymbol:u,emissiveSource:1,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass,normalType:1},f=!!d.usePBR,h=this.symbol;h.type===`point-3d`&&h.verticalOffset&&(d.verticalOffset=new fe(h.verticalOffset),d.castShadows=!1),this._context.screenSizePerspectiveEnabled&&(d.screenSizePerspective=this.view.screenSizePerspective.parameters),d.externalColor=this._hasDrivenColorOrOpacity?N:this._materialColor?.toUnitRGBA()??v,this._fastUpdates=U(this._context.renderer,this._fastVisualVariableConvertOptions(i,o,a,null)),d.instanced=!0,this._fastUpdates?(Object.assign(d,this._fastUpdates.materialParameters),d.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(d.instancedColor=!0);let g=new me(d,this._context.spherical);g.setParameters({cullFace:J(g.transparent)});let _=B(t,g);if(!_)throw Error(`Unknown object symbol primitive: ${t}`);let y=await this._createStageResources(_,f,n);e(n);let b=await this._createLodRenderer(_,n);return new G(_,b,y,a,!1,!1,i,o,c,f)}async _createResourcesForUrl(n,r){let i={instanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},a={spherical:this._context.spherical,materialParameters:i,cache:this._context.sharedResources.objectResourceCache,compressionOptions:{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}};this._fastUpdates=U(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(a.materialParameters,this._fastUpdates.materialParameters),a.materialParameters.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(a.materialParameters.instancedColor=!0);let o=this.symbol;if(o.type===`point-3d`&&o.verticalOffset){let{screenLength:e,minWorldLength:n,maxWorldLength:r}=o.verticalOffset;a.materialParameters.verticalOffset={screenLength:t(e),minWorldLength:n||0,maxWorldLength:r??1/0},a.materialParameters.castShadows=!1}let c=this._context.physicallyBasedRenderingEnabled;a.signal=r,a.usePBR=c,a.useEmissive=this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result,a.skipHighLods=this._context.skipHighSymbolLods;let l=this.symbolLayer.material;a.materialParameters.emissiveStrengthFromSymbol=l?.emissive?.strength??1,a.materialParameters.emissiveSource=ee(l?.emissive?.source??`emissive`);let u=await ce(n,a),d=u.isEsriSymbolResource,f=u.isWosr,m=se(u.lods),h=this._context,g=this._getExternalColorParameters(l),_=this.needsDrivenTransparentPass,v=m.getMaterials();v.forEach(e=>{e.setParameters({...g,drivenOpacity:_}),h.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:this.view.screenSizePerspective.parameters})});let y=u.referenceBoundingBox,b=p(w(y)),x=p(m.levels[0].pivotOffset),S=p(O(b,this.symbolLayer)),C=s(S),T=this._fastUpdates;W(T,this._context.renderer,this._fastVisualVariableConvertOptions(y,S,b,x))&&v.forEach(e=>e.setParameters(T.materialParameters));let E=await this._createStageResources(m,c,r);e(r);let D=await this._createLodRenderer(m,r);return new G(m,D,E,b,d,f,y,S,C,c,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(t,n,r){let i=this._context.stage,a=t.getMaterials();n!==this._context.physicallyBasedRenderingEnabled&&this.physicallyBasedRenderingChanged();let o=t.getTextures();return i.addTextures(o),this._addDisposeResource(()=>{o.forEach(e=>e.unload()),i.removeTextures(o)}),await Promise.all(o.map(e=>this._context.stage.schedule(()=>e.load(i.renderView.renderingContext),r))),e(r),{materials:a,textures:o,geometries:t.getEngineGeometries()}}async _createLodRenderer(e,t){let n=this._context.stage,r={layerViewUid:this._context.layerViewUid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,o=new pe({symbol:e,metadata:r,shaderTransformation:i?{applyTransform:(e,t,n)=>{e.getFeatureAttribute(t,Q),a(n,de(i.materialParameters,Q,n))},scaleFactor:(e,t,n)=>{t.getFeatureAttribute(n,Q),ue(e,i.materialParameters,Q)}}:null},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource(()=>{n.removeRenderPlugin(o),o.destroy()}),await n.addRenderPlugin(o,t),o}_getExternalColorParameters(e){let t={};if(t.externalColor=N,!this._drivenProperties.color&&e?.color!=null){let n=e.color.toUnitRGBA();this._drivenProperties.opacity&&(n[3]=NaN),t.externalColor=n}return t}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach(e=>e()),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let n=L(t.geometry);if(n==null)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;let r=this.createElevationContextForGraphic(t),i=e.renderingInfo;return this._createAs3DShape(n,i,r,t.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(this._resources==null)return;let e=this._getLayerOpacity(),t=this._resources.stageResources.materials;for(let n=0;n<t.length;n++){let r=t[n];r.setParameters({layerOpacity:e}),this._isPrimitive&&r.setParameters({cullFace:J(r.transparent)})}}layerScreenSizePerspectiveChanged(){if(this._resources==null)return;let e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;for(let t of this._resources.stageResources.materials)t.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,k)}slicePlaneEnabledChanged(){if(this._resources==null)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(let e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicallyBasedRenderingChanged(){if(this._resources==null)return!0;let{stageResources:e,isWosr:t}=this._resources;for(let n of e.materials)this._isPrimitive?n.setParameters({usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!0}):t||n.setParameters({usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!1});return this._hasLoadedPBRTextures===!1&&this._context.physicallyBasedRenderingEnabled===!0?(this._hasLoadedPBRTextures=!0,!1):!0}applyRendererDiff(e,t){if(this._resources==null)return 0;let{stageResources:{materials:n},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:s}=this._resources;for(let c in e.diff)switch(c){case`visualVariables`:if(W(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,s))){for(let e of n)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}else return 0;break;default:return 0}return 2}computeComplexity(){if(this._resources==null)return super.computeComplexity();let e=this._resources.lodResources,t=ne(e.levels),n=e.computeUsedMemory(),r={...re(this.symbol,this.symbolLayer),resourceBytes:n};return new V({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return this._resources!=null}_createAs3DShape(e,t,n,r){if(!this._hasLodRenderer()||this._resources==null)return null;let i=this.getFastUpdateAttrValues(t),a=this._context.clippingExtent;if(S(e,Y,this._context.elevationProvider.spatialReference),a!=null&&!T(a,Y))return null;let o=q(n),s=this._computeGlobalTransform(e,n,Z,$),c=this._computeLocalTransform(this._resources,this.symbolLayer,t,X),l=this._resources.lodRenderer.instanceData,u=l.addInstance();this._instanceIndexToGraphicUid.set(u,r),l.setLocalTransform(u,c,!1),l.setGlobalTransform(u,s),i&&l.setFeatureAttribute(u,i),this._fastUpdates==null&&this._hasDrivenColorOrOpacity&&l.setColor(u,this._getDrivenUInt8ColorWithNaNSupport(t,this._materialColor,!this._isPrimitive));let d=this._context.stage.renderView.olidRenderHelper;if(d){let e=d.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid});l.setObjectAndLayerIdColor(u,e)}let f=new ae(this,u,ie,n,this._context.stage.view.state.highlightOrderMap);return o&&(f.alignedSampledElevation=$.sampledElevation),f.needsElevationUpdates=k(n.mode),R(f,e,this._context.elevationProvider),f}_computeGlobalTransform(e,t,n,r){return j(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),Y[0]=e.x,Y[1]=e.y,Y[2]=r.z,x(e.spatialReference,Y,n,this._context.renderCoordsHelper.spatialReference),n}_computeLocalTransform(e,t,r,i){return n(i),this._applyObjectRotationVisualVariables(r,!1,i),this._applyObjectRotation(t,!0,i),this._applyObjectScale(e,r,i),this._applyAnchor(e,t,i),i}_applyObjectScale(e,t,n){if(this._fastUpdates?.requiresShaderTransformation)return;let i=this._drivenProperties.size&&t.size?t.size.output:e.symbolSize,a=F(i,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);if(a[0]!==1||a[1]!==1||a[2]!==1)r(n,n,a);else return}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}updateGeometry(e,t){if(this._resources==null)return!0;let n=e.geometry;if(!n)return!1;let r=L(n);if(r==null)return!1;let i=this.getGeometryElevationMode(n),{elevationContext:a}=t;return a.mode===i&&(a.updateFeatureExpressionFeature(e,this._context.layer),this._computeGlobalTransform(r,a,Z,$),q(a)&&(t.alignedSampledElevation=$.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(t.instanceIndex,Z,!0),R(t,r,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!t.heading&&!t.tilt&&!t.roll&&!t.width&&!t.height&&!t.depth&&!t.anchor&&!t.anchorPosition||this._resources==null)return;let n=(e,t,n)=>(e!=null&&e.type===`complete`?e.newValue:t)??n,r=n(t.heading,this.symbolLayer.heading,0),i=n(t.tilt,this.symbolLayer.tilt,0),a=n(t.roll,this.symbolLayer.roll,0),o=n(t.width,this.symbolLayer.width,void 0),s=n(t.height,this.symbolLayer.height,void 0),c=n(t.depth,this.symbolLayer.depth,void 0),l=n(t.anchor,this.symbolLayer.anchor,void 0),u=n(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;let d={heading:r,tilt:i,roll:a,anchor:l,anchorPosition:u},f=this._resources;this.loadStatus===1&&e.symbolLayerStatePatches.push(()=>{f.symbolSize=p(O(f.resourceSize,{width:o,height:s,depth:c,isPrimitive:this._isPrimitive}))}),e.graphics3DGraphicPatches.push(({instanceIndex:e},t)=>{let n=this._computeLocalTransform(f,d,t,X);f.lodRenderer.instanceData.setLocalTransform(e,n,!0)})}_preparePatchColor(e,t){if(!t.material||t.material.type!==`partial`)return;let n=t.material.diff;if(!n.color||n.color.type!==`complete`||n.color.newValue==null||n.color.oldValue==null)return;let r=n.color.newValue,i=r==null?y:r.toUnitRGBA();delete n.color;let a=this._resources;if(a==null)return;let o=this._isPrimitive;e.graphics3DGraphicPatches.push(({instanceIndex:e})=>{if(this._hasDrivenColorOrOpacity)a.lodRenderer.instanceData.setColor(e,i);else{let e={externalColor:i};for(let t of a.stageResources.materials)t.setParameters(e),o&&t.setParameters({cullFace:J(t.transparent)})}})}_preparePatchEmissive(e,t){return M(e,t,e=>{this._resources?.stageResources.materials.forEach(t=>{if(!this._isPrimitive){t.setParameters({emissiveStrengthFromSymbol:e??1});return}let n=this.symbolLayer.material?.emissive?.source===`color`;t.setParameters({emissiveStrengthFromSymbol:n?e??0:0})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_applyObjectRotationVisualVariables(e,t,n){this._fastUpdates?.requiresShaderTransformation&&t||I(e.heading?.output,e.tilt?.output,e.roll?.output,n)}_applyObjectRotation(e,t,n){this._fastUpdates?.requiresShaderTransformation&&t||I(e.heading,e.tilt,e.roll,n)}_applyAnchor(e,t,n){if(this._fastUpdates?.requiresShaderTransformation)return;let r=K(e.resourceBoundingBox,e.pivotOffset,t);r&&i(n,n,r)}_fastVisualVariableConvertOptions(e,t,n,r){let i=e==null?m:p(w(e)),a=e==null?h:K(e,r,this.symbolLayer),o=this._context.renderCoordsHelper.unitInMeters,s=F(t??void 0,t,n,o),c=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new le({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??m,unitInMeters:o,anchor:a,scale:s,rotation:c,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:s})}get _primitive(){let{resource:e}=this.symbolLayer;return e?.href==null?e?.primitive??D:null}_getFallbackOpacityAndColor(){return this._materialColor?.toUnitRGBA()??(this._isPrimitive?v:N)}get _materialColor(){return this.symbolLayer.material?.color}}function K(e,t,n){let r=_();switch(n.anchor){case`center`:l(r,E(e)),c(r,r);break;case`top`:{let t=E(e);f(r,-t[0],-t[1],-e[5]);break}case`bottom`:{let t=E(e);f(r,-t[0],-t[1],-e[2]);break}case`relative`:{let t=E(e),i=w(e),a=n.anchorPosition,o=a?g(a.x,a.y,a.z):h;u(r,i,o),d(r,r,t),c(r,r);break}default:t==null?l(r,h):c(r,t)}return r}function q(e){return e.mode!==`absolute-height`}function _e(e){return(e.material?.color?.a??1)===1&&e.resource?.href==null}function J(e){return e?0:2}const Y=_(),X=o(),Z=o(),Q=b(),$=new A;export{ge as Graphics3DObjectSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__addDisposableResource as e,__disposeResources as t}from"tslib";import n from"../../../../core/Error.js";import{disposable as r}from"../../../../core/handleUtils.js";import{translate as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as a,create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as s,scale as c,multiply as l}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as u,fromArray as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as p,create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as h}from"../../../../geometry/projection/projectBuffer.js";import{create as g,fromSubBuffer as _,intersectsClippingArea as v}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as y,doubleArrayFrom as b}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as x}from"../../../../geometry/support/FloatArray.js";import{getCoordinateEquals as S}from"../../../../geometry/support/geometryUtils.js";import{isDrivenOpacityFallbackAlwaysOpaque as ee}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{needsElevationUpdates3D as C,evaluateElevationAlignmentAtPoint as w,SampleElevationInfo as T}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as E}from"./Graphics3DObject3DGraphicLayer.js";import{maxPathLength as D}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as O,nanFallbackColor as k}from"./Graphics3DSymbolLayer.js";import{isValidSize as A}from"./graphicUtils.js";import{ConvertOptions as j,initFastSymbolUpdatesState as te,updateFastSymbolUpdatesState as ne,getSizeAttributeValue as re,getAttributeValue as M}from"../support/FastSymbolUpdates.js";import{SamplePosition as N}from"../../support/ElevationProvider.js";import{Object3D as P}from"../../webgl-engine/lib/Object3D.js";import{Path as F}from"../../webgl-engine/lib/Path.js";import{PathBuilder as I}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as L,TriangulationCapBuilder as R,NoCapBuilder as z}from"../../webgl-engine/lib/PathCapBuilder.js";import{PathExtruder as B}from"../../webgl-engine/lib/PathExtruder.js";import{PathGeometry as V,isPathGeometry as H}from"../../webgl-engine/lib/PathGeometry.js";import{computeMinimumRotationTangentFrame as U}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as W,circleProfiles as G}from"../../webgl-engine/lib/PathProfile.js";import{PathMaterial as K}from"../../webgl-engine/materials/PathMaterial.js";const q=[`polyline`];class J extends O{constructor(e,t,n,r){super(e,t,n,r,ee(t)),this._intrinsicSize=u(1,1),this._upVectorAlignment=1,this.ensureDrapedStatus(!1)}_validateGeometry(e,t,n){return!super._validateGeometry(e,t,n)||e.type!==`polyline`?!1:!e.paths.some(e=>e.length>D)||(this.logger.warn(`Geometry has a path longer than ${D} vertices and cannot be displayed by PathSymbol3DLayer`),!1)}async doLoad(){let e=this.symbolLayer,t=e.width==null?e.height:e.width,r=e.height==null?t:e.height;this._vvConvertOptions=new j({supports:{size:!0,color:!0,rotation:!1,opacity:!0},modelSize:[1,1,1],symbolSize:[t,1,r],unitInMeters:this._context.renderCoordsHelper.unitInMeters,fallbackColor:this._getFallbackOpacityAndColor(k),fallbackSize:[t,1,r]});let i=this._context.renderer?.visualVariables;this._fastUpdates=i?.length?te(this._context.renderer,this._vvConvertOptions):null;let a=e.anchor||`center`;this._upVectorAlignment=e.profileRotation===`heading`?0:1;let o=e.profile||`circle`;switch(o){default:case`circle`:this._profile=G[a];break;case`quad`:this._profile=W[a]}switch(e.join){case`round`:this._extruder=new B(2);break;default:case`bevel`:this._extruder=new B(1);break;case`miter`:this._extruder=new B(0)}switch(this._cap){case`none`:this._capBuilder=new z;break;case`butt`:default:this._capBuilder=new R(this._profile,1);break;case`square`:this._capBuilder=new R(this._profile,2);break;case`round`:{let e=o===`quad`;this._capBuilder=new L(this._profile,e);break}}let l=this._materialColor,u=this._getCombinedOpacityAndColor(l),f=p(u),m=u[3],h=this.needsDrivenTransparentPass,g=e.material?.emissive,_={diffuse:f,ambient:f,emissiveStrength:(g?.source===`color`?g?.strength:void 0)??0,emissiveSource:1,opacity:m,drivenOpacity:h,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows};if(!this._drivenProperties.size&&(s(this._intrinsicSize,t,r),!(A(this._intrinsicSize[0])&&A(this._intrinsicSize[1]))))throw new n(`graphics3dpathsymbollayer:invalid-size`,`Symbol sizes may not be negative values`);this._fastUpdates?.visualVariables.size||c(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters);let v=this._fastUpdates!=null,y=new K({..._,...this._fastUpdates?.materialParameters,size:d(this._intrinsicSize),upVectorAlignment:this._upVectorAlignment,profile:this._profile,pathCapType:this._capBuilder.type,cutoffAngle:this._extruder.cutoffAngle,pathJoinType:this._extruder.join,hasPathColor:!v&&this._drivenProperties.color,hasPathOpacity:!v&&this._drivenProperties.opacity&&!this._drivenProperties.color,hasPathSize:!v&&this._drivenProperties.size,usePBR:this._context.physicalBasedRenderingEnabled},this._context);this._materials[0]=y,this._updateTransparentDepedentMaterialParameters()}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,q,this.symbolLayer.type))return null;let n=this.createElevationContextForGraphic(t);return this._createAs3DShape(e,n)}layerOpacityChanged(){let e=this._materialColor,t=this._getCombinedOpacity(e),n=this._materials[0];n&&(n.setParameters({opacity:t}),this._updateTransparentDepedentMaterialParameters())}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,C)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._materials[0]?.setParameters({usePBR:this._context.physicalBasedRenderingEnabled}),!0}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:if(ne(this._fastUpdates,t,this._vvConvertOptions))this._materials[0]?.setParameters(this._fastUpdates.materialParameters);else return 0;break;default:return 0}return 2}_getVertexData(n){let r=0,i=n.paths,a=[],o=n.spatialReference,s=this._context.elevationProvider.spatialReference,c=this._context.renderCoordsHelper.spatialReference,l=S(n.hasZ),u=i.map(n=>{let r={stack:[],error:void 0,hasError:!1};try{let t=$;e(r,oe,!1);for(let e=1;e<n.length;++e)l(n[e],n[e-1])&&t.add(e);return t.size===0?n:n.filter((e,n)=>!t.has(n))}catch(e){r.error=e,r.hasError=!0}finally{t(r)}});for(let e of u)r+=e.length;let d=y(r*3),f=0;for(let e of u){a.push({offset:f,numVertices:e.length});for(let t of e)d[f++]=t[0],d[f++]=t[1],d[f++]=n.hasZ?t[2]:0}if(s!=null&&!o.equals(s)&&!h(d,o,0,d,s,0,r))return null;let p;return s!=null&&!s.equals(c)?(p=y(r*3),h(d,s,0,p,c,0,r)):p=b(d),{pathVertexDataInfos:a,vertexDataES:d,vertexDataRS:p}}_createAs3DShape(e,t){let{graphic:n,renderingInfo:r}=e,s=n.geometry,c=this._getVertexData(s);if(c==null)return this.logger.warn(`PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)`),null;if(c.pathVertexDataInfos.length===0)return s.paths.length!==0&&s.paths.some(e=>e.length>0)||this.logger.warn(`PathSymbol3DLayer geometry failed to be created (no paths were defined)`),null;let l=[],u=g(),d=this._context.renderCoordsHelper,p=new N(c.vertexDataES),m=n.uid,h=x(c.vertexDataRS.length);for(let e of c.pathVertexDataInfos){let n=e.numVertices;if(n<2)continue;let s=e.offset;if(this._context.clippingExtent!=null&&(_(c.vertexDataES,s,n,u),!v(u,this._context.clippingExtent)))continue;let g=s+n*3;for(let e=s;e<g;e+=3){p.offset=e;let n=w(p,this._context.elevationProvider,t,d);f(Z,c.vertexDataRS[e],c.vertexDataRS[e+1],c.vertexDataRS[e+2]),d.setAltitude(Z,n),c.vertexDataRS[e]=Z[0],c.vertexDataRS[e+1]=Z[1],c.vertexDataRS[e+2]=Z[2]}let y=new F(n,this._upVectorAlignment,c.vertexDataES,c.vertexDataRS,s,h);Y(y,this._upVectorAlignment,this._context.renderCoordsHelper);let b=new I(y,this._profile,this._extruder,this._capBuilder,this._upVectorAlignment),x=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:m,layerViewUid:this._context.layerViewUid}),S=new V(this._materials[0],b,this._getVisualVariableData(r),x);S.transformation=i(o(),a,b.path.origin),l.push(S)}if(l.length===0)return null;let y=new P({geometries:l,layerViewUid:this._context.layerViewUid,graphicUid:m}),b=new E(this,y,null,(e,t,n,r,i)=>ae(e,t,r,i,this._upVectorAlignment),t,null);return b.alignedSampledElevation=0,b.needsElevationUpdates=C(t.mode),b}_getVisualVariableData(e){if(this._fastUpdates){let{size:t,color:n,opacity:r}=this._fastUpdates.visualVariables;return{sizeAttributeValue:re(t,e.size),colorAttributeValue:M(n,e.color),opacityAttributeValue:M(r,e.opacity)}}return{size:this._getDrivenSize(e),color:this._getDrivenColor(e),opacity:this._getDrivenOpacity(e)}}_getDrivenSize(e){if(!this._drivenProperties.size)return null;let t=e.size?.output??[`symbol-value`,`symbol-value`,`symbol-value`],n=u(X(t[0],t[2]===`symbol-value`?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),X(t[2],t[0]===`symbol-value`?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0));return l(n,n,this._intrinsicSize),n}_getDrivenColor(e){return this._drivenProperties.color?this._getDrivenUInt8Color(e,this._materialColor,!1):null}_getDrivenOpacity(e){return this._drivenProperties.opacity&&!this._drivenProperties.color?e.opacity?.output??this._materialColor?.a??0:null}get _materialColor(){return this.symbolLayer.material?.color}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}get _cap(){return this.symbolLayer.cap||`butt`}_updateTransparentDepedentMaterialParameters(){let e=this._materials[0];e&&e.setParameters({cullFace:e.transparent||this._cap===`none`?0:2})}}function Y(e,t,n){let{origin:r,positions:i}=e,a=e.offset;switch(t){default:case 0:for(let t=0;t<e.numVertices;++t)Z[0]=i[a++]+r[0],Z[1]=i[a++]+r[1],Z[2]=i[a++]+r[2],n.worldUpAtPosition(Z,Z),e.setFrameFromUpVector(t,Z);break;case 1:Z[0]=i[a]+r[0],Z[1]=i[a+1]+r[1],Z[2]=i[a+2]+r[2],n.worldUpAtPosition(Z,Z),U(e,Z)}}function X(e,t,n){switch(e){case`symbol-value`:return n;case`proportional`:return t;default:return e}}function ie(e,t,n,r){let i=0,{origin:a,numVertices:o,positions:s,positionsES:c}=e,l=e.offset+o*3;for(let t=e.offset;t<l;t+=3)f(Z,c[t],c[t+1],c[t+2]),n(Z,Q),i+=Q.sampledElevation,Z[0]=s[t]+a[0],Z[1]=s[t+1]+a[1],Z[2]=s[t+2]+a[2],r.setAltitude(Z,Q.z),s[t]=Z[0]-a[0],s[t+1]=Z[1]-a[1],s[t+2]=Z[2]-a[2];return e.updatePathVertexInformation(),i/o}function ae(e,t,n,r,i){let a=e.stageObject,o=a.geometries,s=0;for(let e of o){if(!H(e))continue;let o=e.builder.path;s+=ie(o,t,n,r),i!==0&&Y(o,i,r),e.onPathChanged(),a.geometryVertexAttributeUpdated(e,`position`)}return s/o.length}const Z=m(),Q=new T,$=new Set,oe=r({remove:()=>$.clear()});export{J as Graphics3DPathSymbolLayer};
2
+ import{__addDisposableResource as e,__disposeResources as t}from"tslib";import n from"../../../../core/Error.js";import{disposable as r}from"../../../../core/handleUtils.js";import{translate as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as a,create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as s,scale as c,multiply as l}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as u,fromArray as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as p,create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as h}from"../../../../geometry/projection/projectBuffer.js";import{create as g,fromSubBuffer as _,intersectsClippingArea as v}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as y,doubleArrayFrom as b}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as x}from"../../../../geometry/support/FloatArray.js";import{getCoordinateEquals as S}from"../../../../geometry/support/geometryUtils.js";import{isDrivenOpacityFallbackAlwaysOpaque as ee}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{needsElevationUpdates3D as C,evaluateElevationAlignmentAtPoint as w,SampleElevationInfo as T}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as E}from"./Graphics3DObject3DGraphicLayer.js";import{maxPathLength as D}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as O,nanFallbackColor as k}from"./Graphics3DSymbolLayer.js";import{isValidSize as A}from"./graphicUtils.js";import{ConvertOptions as j,initFastSymbolUpdatesState as te,updateFastSymbolUpdatesState as ne,getSizeAttributeValue as re,getAttributeValue as M}from"../support/FastSymbolUpdates.js";import{SamplePosition as N}from"../../support/ElevationProvider.js";import{Object3D as P}from"../../webgl-engine/lib/Object3D.js";import{Path as F}from"../../webgl-engine/lib/Path.js";import{PathBuilder as I}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as L,TriangulationCapBuilder as R,NoCapBuilder as z}from"../../webgl-engine/lib/PathCapBuilder.js";import{PathExtruder as B}from"../../webgl-engine/lib/PathExtruder.js";import{PathGeometry as V,isPathGeometry as H}from"../../webgl-engine/lib/PathGeometry.js";import{computeMinimumRotationTangentFrame as U}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as W,circleProfiles as G}from"../../webgl-engine/lib/PathProfile.js";import{PathMaterial as K}from"../../webgl-engine/materials/PathMaterial.js";const q=[`polyline`];class J extends O{constructor(e,t,n,r){super(e,t,n,r,ee(t)),this._intrinsicSize=u(1,1),this._upVectorAlignment=1,this.ensureDrapedStatus(!1)}_validateGeometry(e,t,n){return!super._validateGeometry(e,t,n)||e.type!==`polyline`?!1:!e.paths.some(e=>e.length>D)||(this.logger.warn(`Geometry has a path longer than ${D} vertices and cannot be displayed by PathSymbol3DLayer`),!1)}async doLoad(){let e=this.symbolLayer,t=e.width==null?e.height:e.width,r=e.height==null?t:e.height;this._vvConvertOptions=new j({supports:{size:!0,color:!0,rotation:!1,opacity:!0},modelSize:[1,1,1],symbolSize:[t,1,r],unitInMeters:this._context.renderCoordsHelper.unitInMeters,fallbackColor:this._getFallbackOpacityAndColor(k),fallbackSize:[t,1,r]});let i=this._context.renderer?.visualVariables;this._fastUpdates=i?.length?te(this._context.renderer,this._vvConvertOptions):null;let a=e.anchor||`center`;this._upVectorAlignment=e.profileRotation===`heading`?0:1;let o=e.profile||`circle`;switch(o){default:case`circle`:this._profile=G[a];break;case`quad`:this._profile=W[a]}switch(e.join){case`round`:this._extruder=new B(2);break;default:case`bevel`:this._extruder=new B(1);break;case`miter`:this._extruder=new B(0)}switch(this._cap){case`none`:this._capBuilder=new z;break;case`butt`:default:this._capBuilder=new R(this._profile,1);break;case`square`:this._capBuilder=new R(this._profile,2);break;case`round`:{let e=o===`quad`;this._capBuilder=new L(this._profile,e);break}}let l=this._materialColor,u=this._getCombinedOpacityAndColor(l),f=p(u),m=u[3],h=this.needsDrivenTransparentPass,g=e.material?.emissive,_={diffuse:f,ambient:f,emissiveStrength:(g?.source===`color`?g?.strength:void 0)??0,emissiveSource:1,opacity:m,drivenOpacity:h,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows};if(!this._drivenProperties.size&&(s(this._intrinsicSize,t,r),!(A(this._intrinsicSize[0])&&A(this._intrinsicSize[1]))))throw new n(`graphics3dpathsymbollayer:invalid-size`,`Symbol sizes may not be negative values`);this._fastUpdates?.visualVariables.size||c(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters);let v=this._fastUpdates!=null,y=new K({..._,...this._fastUpdates?.materialParameters,size:d(this._intrinsicSize),upVectorAlignment:this._upVectorAlignment,profile:this._profile,pathCapType:this._capBuilder.type,cutoffAngle:this._extruder.cutoffAngle,pathJoinType:this._extruder.join,hasPathColor:!v&&this._drivenProperties.color,hasPathOpacity:!v&&this._drivenProperties.opacity&&!this._drivenProperties.color,hasPathSize:!v&&this._drivenProperties.size,usePBR:this._context.physicallyBasedRenderingEnabled},this._context);this._materials[0]=y,this._updateTransparentDepedentMaterialParameters()}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,q,this.symbolLayer.type))return null;let n=this.createElevationContextForGraphic(t);return this._createAs3DShape(e,n)}layerOpacityChanged(){let e=this._materialColor,t=this._getCombinedOpacity(e),n=this._materials[0];n&&(n.setParameters({opacity:t}),this._updateTransparentDepedentMaterialParameters())}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,C)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicallyBasedRenderingChanged(){return this._materials[0]?.setParameters({usePBR:this._context.physicallyBasedRenderingEnabled}),!0}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:if(ne(this._fastUpdates,t,this._vvConvertOptions))this._materials[0]?.setParameters(this._fastUpdates.materialParameters);else return 0;break;default:return 0}return 2}_getVertexData(n){let r=0,i=n.paths,a=[],o=n.spatialReference,s=this._context.elevationProvider.spatialReference,c=this._context.renderCoordsHelper.spatialReference,l=S(n.hasZ),u=i.map(n=>{let r={stack:[],error:void 0,hasError:!1};try{let t=$;e(r,oe,!1);for(let e=1;e<n.length;++e)l(n[e],n[e-1])&&t.add(e);return t.size===0?n:n.filter((e,n)=>!t.has(n))}catch(e){r.error=e,r.hasError=!0}finally{t(r)}});for(let e of u)r+=e.length;let d=y(r*3),f=0;for(let e of u){a.push({offset:f,numVertices:e.length});for(let t of e)d[f++]=t[0],d[f++]=t[1],d[f++]=n.hasZ?t[2]:0}if(s!=null&&!o.equals(s)&&!h(d,o,0,d,s,0,r))return null;let p;return s!=null&&!s.equals(c)?(p=y(r*3),h(d,s,0,p,c,0,r)):p=b(d),{pathVertexDataInfos:a,vertexDataES:d,vertexDataRS:p}}_createAs3DShape(e,t){let{graphic:n,renderingInfo:r}=e,s=n.geometry,c=this._getVertexData(s);if(c==null)return this.logger.warn(`PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)`),null;if(c.pathVertexDataInfos.length===0)return s.paths.length!==0&&s.paths.some(e=>e.length>0)||this.logger.warn(`PathSymbol3DLayer geometry failed to be created (no paths were defined)`),null;let l=[],u=g(),d=this._context.renderCoordsHelper,p=new N(c.vertexDataES),m=n.uid,h=x(c.vertexDataRS.length);for(let e of c.pathVertexDataInfos){let n=e.numVertices;if(n<2)continue;let s=e.offset;if(this._context.clippingExtent!=null&&(_(c.vertexDataES,s,n,u),!v(u,this._context.clippingExtent)))continue;let g=s+n*3;for(let e=s;e<g;e+=3){p.offset=e;let n=w(p,this._context.elevationProvider,t,d);f(Z,c.vertexDataRS[e],c.vertexDataRS[e+1],c.vertexDataRS[e+2]),d.setAltitude(Z,n),c.vertexDataRS[e]=Z[0],c.vertexDataRS[e+1]=Z[1],c.vertexDataRS[e+2]=Z[2]}let y=new F(n,this._upVectorAlignment,c.vertexDataES,c.vertexDataRS,s,h);Y(y,this._upVectorAlignment,this._context.renderCoordsHelper);let b=new I(y,this._profile,this._extruder,this._capBuilder,this._upVectorAlignment),x=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:m,layerViewUid:this._context.layerViewUid}),S=new V(this._materials[0],b,this._getVisualVariableData(r),x);S.transformation=i(o(),a,b.path.origin),l.push(S)}if(l.length===0)return null;let y=new P({geometries:l,layerViewUid:this._context.layerViewUid,graphicUid:m}),b=new E(this,y,null,(e,t,n,r,i)=>ae(e,t,r,i,this._upVectorAlignment),t,null);return b.alignedSampledElevation=0,b.needsElevationUpdates=C(t.mode),b}_getVisualVariableData(e){if(this._fastUpdates){let{size:t,color:n,opacity:r}=this._fastUpdates.visualVariables;return{sizeAttributeValue:re(t,e.size),colorAttributeValue:M(n,e.color),opacityAttributeValue:M(r,e.opacity)}}return{size:this._getDrivenSize(e),color:this._getDrivenColor(e),opacity:this._getDrivenOpacity(e)}}_getDrivenSize(e){if(!this._drivenProperties.size)return null;let t=e.size?.output??[`symbol-value`,`symbol-value`,`symbol-value`],n=u(X(t[0],t[2]===`symbol-value`?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),X(t[2],t[0]===`symbol-value`?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0));return l(n,n,this._intrinsicSize),n}_getDrivenColor(e){return this._drivenProperties.color?this._getDrivenUInt8Color(e,this._materialColor,!1):null}_getDrivenOpacity(e){return this._drivenProperties.opacity&&!this._drivenProperties.color?e.opacity?.output??this._materialColor?.a??0:null}get _materialColor(){return this.symbolLayer.material?.color}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}get _cap(){return this.symbolLayer.cap||`butt`}_updateTransparentDepedentMaterialParameters(){let e=this._materials[0];e&&e.setParameters({cullFace:e.transparent||this._cap===`none`?0:2})}}function Y(e,t,n){let{origin:r,positions:i}=e,a=e.offset;switch(t){default:case 0:for(let t=0;t<e.numVertices;++t)Z[0]=i[a++]+r[0],Z[1]=i[a++]+r[1],Z[2]=i[a++]+r[2],n.worldUpAtPosition(Z,Z),e.setFrameFromUpVector(t,Z);break;case 1:Z[0]=i[a]+r[0],Z[1]=i[a+1]+r[1],Z[2]=i[a+2]+r[2],n.worldUpAtPosition(Z,Z),U(e,Z)}}function X(e,t,n){switch(e){case`symbol-value`:return n;case`proportional`:return t;default:return e}}function ie(e,t,n,r){let i=0,{origin:a,numVertices:o,positions:s,positionsES:c}=e,l=e.offset+o*3;for(let t=e.offset;t<l;t+=3)f(Z,c[t],c[t+1],c[t+2]),n(Z,Q),i+=Q.sampledElevation,Z[0]=s[t]+a[0],Z[1]=s[t+1]+a[1],Z[2]=s[t+2]+a[2],r.setAltitude(Z,Q.z),s[t]=Z[0]-a[0],s[t+1]=Z[1]-a[1],s[t+2]=Z[2]-a[2];return e.updatePathVertexInformation(),i/o}function ae(e,t,n,r,i){let a=e.stageObject,o=a.geometries,s=0;for(let e of o){if(!H(e))continue;let o=e.builder.path;s+=ie(o,t,n,r),i!==0&&Y(o,i,r),e.onPathChanged(),a.geometryVertexAttributeUpdated(e,`position`)}return s/o.length}const Z=m(),Q=new T,$=new Set,oe=r({remove:()=>$.clear()});export{J as Graphics3DPathSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{has}from"../../../../applications/Components/baUtils.js";import{pt2px as e}from"../../../../core/screenUtils.js";import{ZEROS as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromBuffer as n,intersectsClippingArea as r,empty as i,expandWithAABB as a,create as o}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as s,doubleSubArray as c}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as l}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as u}from"../../../../geometry/support/Indices.js";import{isDrivenOpacityFallbackAlwaysOpaque as d}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{elevationModeChangeUpdateType as f,needsElevationUpdates2D as p}from"./elevationAlignmentUtils.js";import{PlateLayoutInformation as m,updatePlateNormals as h}from"./extrudePolygon.js";import{Graphics3DDrapedGraphicLayer as g}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as _}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as v}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as y}from"./graphicUtils.js";import{parseCapType as b,computeSymbolLayerIndex as x}from"./lineUtils.js";import{geometryAsPolygon as S,createColorGeometry as C,PolygonCreationDataBase as w}from"./polygonUtils.js";import{initFastSymbolUpdatesState as T,updateFastSymbolUpdatesState as E,getAttributeValue as D,ConvertOptions as O}from"../support/FastSymbolUpdates.js";import{createMaterial as k,uvElevationAligner as A}from"../support/patternUtils.js";import{writeMapSpaceUVCoordsPerConnectedPart as j,writeMapSpaceUVCoordsDraped as M}from"../support/uvUtils.js";import{createGeometry as N}from"../../support/engineContent/line.js";import{loadTessellationUtils as P,preloadedPolygonToRenderInfoElevationAligned as F,preloadedPolygonToRenderInfoDraped as I}from"../../support/renderInfoUtils/polygon.js";import{Object3D as L}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as R}from"../../webgl-engine/lib/RenderGeometry.js";import{isScreenSizePerspectiveEnabled as z}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{getStipplePatternForLinePattern as B}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as V}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as H}from"../../webgl-engine/materials/RibbonLineMaterial.js";const U=[`polyline`,`polygon`,`extent`];class W extends v{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,d(t)),this._needsUV=!1,this._materials=[]}async doLoad(){this._fastUpdates=T(this._context.renderer,this._vvConvertOptions),await P()}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _shadingEnabled(){return!this.draped&&!!has(`enable-feature:emissive-on-non-volumetric`)}_createMaterials(){if(this._materials.length>0)return;let{_materialColor:t,draped:n,_shadingEnabled:r}=this,i=this._getCombinedOpacityAndColor(t);this._materials[0]=k(this.symbolLayer,{color:i,forceTransparentMode:this.needsDrivenTransparentPass,hasVertexColors:this._drivenProperties.color||this._drivenProperties.opacity,draped:n,shading:+!!r,castShadows:r&&this.symbolLayer.castShadows,hasSlicePlane:this._context.slicePlaneEnabled,emissiveStrength:this._emissiveStrength,...this._fastUpdates?.materialParameters},this._context),this._needsUV=this._materials[0]instanceof V;let a=this.symbolLayer.outline;if(J(a)){let t=B(a.pattern),n=b(a.pattern?a.patternCap||`butt`:`square`);this._materials[1]=new H({color:this._getOutlineColor(),width:e(a.size),polygonOffset:3,polygonOffsetIndex:x(this._renderPriority,this._renderPriorityStep),shadingEnabled:r,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:t,cap:n,screenSizePerspective:this._outlineScreenSizePerspective},this.view)}}get _outlineScreenSizePerspective(){return!this.draped&&z(this._context.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,U,this.symbolLayer.type))return null;let n=this._getDrivenUInt8Color(e.renderingInfo,this._materialColor,!1),r=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(r.mode===`on-the-ground`),this._createMaterials(),this.draped?this._createAsOverlay(e.renderingInfo,t,n):this._createAs3DShape(e.renderingInfo,t,n,r)}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:if(E(this._fastUpdates,t,this._vvConvertOptions))this._materials[0]?.setParameters(this._fastUpdates.materialParameters);else return 0;break;default:return 0}return 2}layerOpacityChanged(){if(this._materials[0]!=null){let e=this._materials[0].parameters.color,t=this._materialColor,n=this._getCombinedOpacity(t);this._materials[0].setParameters({color:[e[0],e[1],e[2],n],forceTransparentMode:this.needsDrivenTransparentPass})}if(this._materials[1]!=null){let e=this._materials[1].parameters.color;this._materials[1].setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerScreenSizePerspectiveChanged(){this._materials[1]?.setParameters({screenSizePerspective:this._outlineScreenSizePerspective})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=f(W.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=p(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){if(this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]){let e={hasSlicePlane:this._context.slicePlaneEnabled};this._materials[1].setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}_containsRenderableGeometry(e){return e.polygonIndexCount>0?!0:this._materials[1]==null?!1:e.outline.output===`vertex-data`?e.outline.outlines.length>0:e.outlineIndexCount>0}_createAs3DShape(e,t,n,r){let i=S(t.geometry);if(!i)return null;let a=this._shadingEnabled,o=F(i,this._context.elevationProvider,this._context.renderCoordsHelper,r,{projectIfNearlyVertical:!0,requireNormals:a,outlineOutput:`vertex-data`,owner:this._context.layer});if(o==null)return null;let d=new K(o,n,this._context.layerViewUid,t.uid),f=d.renderInfo.vertexCount;if(this._needsUV){d.uvMapSpace=l(f*4,!0),d.textureElementIndices=Array(f),d.boundingRect=s(9*(d.renderInfo.polygonIndices.length/3));let e=j(d.uvMapSpace,d.boundingRect,d.textureElementIndices,d.renderInfo.positions,d.renderInfo.polygonIndices,this._context.renderCoordsHelper);d.boundingRect=c(d.boundingRect,0,9*e),d.boundingRectIndices=u(e)}if(d.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(d),this._createAs3DShapeFill(e,d),this._materials[1]&&this._createAs3DShapeOutline(d),this._logGeometryCreationWarnings(d.renderInfo,i.rings,`rings`,`FillSymbol3DLayer`),d.outGeometries.length===0)return null;let m=new L({geometries:d.outGeometries,castShadow:this._shadingEnabled,layerViewUid:this._context.layerViewUid,graphicUid:t.uid}),h=d.plateLayout,g=new _(this,m,null,(e,t,n,r,i)=>A(e,t,n,r,i,h),r);return g.alignedSampledElevation=d.renderInfo.sampledElevation,g.needsElevationUpdates=p(r.mode),g}_createAs3DShapeFill(e,t){let{mapPositions:i,positions:a,polygonIndices:o,polygonIndexCount:s,vertexCount:c,compressedNormals:l}=t.renderInfo;if(s===0||this._context.clippingExtent!=null&&(n(i,G),!r(G,this._context.clippingExtent)))return;let u=this._fastUpdates?.visualVariables.color,d=C({material:this._materials[0],indices:o,mapPositions:i,attributeData:{position:a,color:u?null:t.color,compressedNormals:l,colorFeature:u?D(u,e.color):null,uvMapSpace:this._needsUV?t.uvMapSpace:null,boundingRect:this._needsUV?t.boundingRect:null,textureElementIndices:this._needsUV?t.textureElementIndices:null,boundingRectIndices:this._needsUV?t.boundingRectIndices:null,olidColor:t.olidColor}});t.plateLayout=new m(c,0,null,0,s/3),h(d,t.plateLayout),t.outGeometries.push(d)}_createAs3DShapeOutline(e){if(this._materials[1]==null)return;let{outline:t}=e.renderInfo;if(t.output!==`vertex-data`)return;let{outlines:i}=t;if(i!=null&&i.length!==0)for(let{mapPositions:t,position:a}of i){if(this._context.clippingExtent!=null&&(n(t,G),!r(G,this._context.clippingExtent)))continue;let i=N(this._materials[1],{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:t,attributeData:{position:a}},e.olidColor);e.outGeometries.push(i)}}_createAsOverlay(e,t,n){let r=S(t.geometry);if(r==null)return null;this._materials[0].renderPriority=this._renderPriority+this._renderPriorityStep/2,this._materials[1]!=null&&(this._materials[1].renderPriority=this._renderPriority);let a=I(r,{drapedSpatialReference:this._context.overlaySR,outlineOutput:`vertex-data`,owner:this._context.layer});if(a==null)return null;let o=new q(a,n,this._context.layerViewUid,t.uid);return this._needsUV&&(o.uvMapSpace=l(o.renderInfo.vertexCount*4,!0),M(o.uvMapSpace,o.renderInfo.positions,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode)),o.outBoundingBox=i(),o.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(o),this._createAsOverlayFill(e,o),this._materials[1]&&this._createAsOverlayOutline(o),this._logGeometryCreationWarnings(o.renderInfo,r.rings,`rings`,`FillSymbol3DLayer`),new g(this,o.outGeometries,o.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,t){let{positions:i,polygonIndices:o,polygonIndexCount:s}=t.renderInfo;if(s===0)return;let c=n(i,G);if(!r(c,this._context.clippingExtent))return;a(t.outBoundingBox,c);let l=this._fastUpdates?.visualVariables.color,u=C({material:this._materials[0],indices:o,attributeData:{position:i,color:l?null:t.color,colorFeature:l?D(l,e.color):null,uvMapSpace:this._needsUV?t.uvMapSpace:null,olidColor:t.olidColor}});t.outGeometries.push(new R(u,t))}_createAsOverlayOutline(e){if(this._materials[1]==null)return;let{outline:t}=e.renderInfo;if(t.output!==`vertex-data`)return;let{outlines:i}=t;for(let{position:t}of i){if(n(t,G),!r(G,this._context.clippingExtent))continue;a(e.outBoundingBox,G);let i=N(this._materials[1],{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:t}},e.olidColor);e.outGeometries.push(new R(i,e))}}_getOutlineOpacity(){let e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(e==null?0:e.a)}_getOutlineColor(){let e=this.symbolLayer?.outline?.color,t=this._getOutlineOpacity();return y(e?.toUnitRGB(),t)}test(){return{...super.test(),createAsOverlay:(e,t,n)=>this._createAsOverlay(e,t,n),createAs3DShape:(e,t,n,r)=>this._createAs3DShape(e,t,n,r)}}get _vvConvertOptions(){return new O({supports:{size:!1,color:!0,rotation:!1,opacity:!1},fallbackColor:this._materialColor?.toUnitRGBA()??t})}}const G=o();class K extends w{constructor(e,t,n,r){super(e,n,r),this.color=t}}class q extends w{constructor(e,t,n,r){super(e,n,r),this.color=t}}function J(e){return e?.size!=null&&e.size>0&&e.color!=null&&(e.pattern==null||e.pattern.type!==`style`||e.pattern.style!==`none`)}export{W as Graphics3DPolygonFillSymbolLayer};
2
+ import{has}from"../../../../applications/Components/baUtils.js";import{pt2px as e}from"../../../../core/screenUtils.js";import{ZEROS as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromBuffer as n,intersectsClippingArea as r,empty as i,expandWithAABB as a,create as o}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as s,doubleSubArray as c}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as l}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as u}from"../../../../geometry/support/Indices.js";import{isDrivenOpacityFallbackAlwaysOpaque as d}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{elevationModeChangeUpdateType as f,needsElevationUpdates2D as p}from"./elevationAlignmentUtils.js";import{PlateLayoutInformation as m,updatePlateNormals as h}from"./extrudePolygon.js";import{Graphics3DDrapedGraphicLayer as g}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as _}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as v}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as y}from"./graphicUtils.js";import{parseCapType as b,computeSymbolLayerIndex as x}from"./lineUtils.js";import{geometryAsPolygon as S,createColorGeometry as C,PolygonCreationDataBase as w}from"./polygonUtils.js";import{initFastSymbolUpdatesState as T,updateFastSymbolUpdatesState as E,getAttributeValue as D,ConvertOptions as O}from"../support/FastSymbolUpdates.js";import{createMaterial as k,uvElevationAligner as A}from"../support/patternUtils.js";import{writeMapSpaceUVCoordsPerConnectedPart as j,writeMapSpaceUVCoordsDraped as M}from"../support/uvUtils.js";import{createGeometry as N}from"../../support/engineContent/line.js";import{loadTessellationUtils as P,preloadedPolygonToRenderInfoElevationAligned as F,preloadedPolygonToRenderInfoDraped as I}from"../../support/renderInfoUtils/polygon.js";import{Object3D as L}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as R}from"../../webgl-engine/lib/RenderGeometry.js";import{isScreenSizePerspectiveEnabled as z}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{getStipplePatternForLinePattern as B}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as V}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as H}from"../../webgl-engine/materials/RibbonLineMaterial.js";const U=[`polyline`,`polygon`,`extent`];class W extends v{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,d(t)),this._needsUV=!1,this._materials=[]}async doLoad(){this._fastUpdates=T(this._context.renderer,this._vvConvertOptions),await P()}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _shadingEnabled(){return!this.draped&&!!has(`enable-feature:emissive-on-non-volumetric`)}_createMaterials(){if(this._materials.length>0)return;let{_materialColor:t,draped:n,_shadingEnabled:r}=this,i=this._getCombinedOpacityAndColor(t);this._materials[0]=k(this.symbolLayer,{color:i,forceTransparentMode:this.needsDrivenTransparentPass,hasVertexColors:this._drivenProperties.color||this._drivenProperties.opacity,draped:n,shading:+!!r,castShadows:r&&this.symbolLayer.castShadows,hasSlicePlane:this._context.slicePlaneEnabled,emissiveStrength:this._emissiveStrength,...this._fastUpdates?.materialParameters},this._context),this._needsUV=this._materials[0]instanceof V;let a=this.symbolLayer.outline;if(J(a)){let t=B(a.pattern),n=b(a.pattern?a.patternCap||`butt`:`square`);this._materials[1]=new H({color:this._getOutlineColor(),width:e(a.size),polygonOffset:3,polygonOffsetIndex:x(this._renderPriority,this._renderPriorityStep),shadingEnabled:r,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:t,cap:n,screenSizePerspective:this._outlineScreenSizePerspective},this.view)}}get _outlineScreenSizePerspective(){return!this.draped&&z(this._context.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,U,this.symbolLayer.type))return null;let n=this._getDrivenUInt8Color(e.renderingInfo,this._materialColor,!1),r=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(r.mode===`on-the-ground`),this._createMaterials(),this.draped?this._createAsOverlay(e.renderingInfo,t,n):this._createAs3DShape(e.renderingInfo,t,n,r)}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:if(E(this._fastUpdates,t,this._vvConvertOptions))this._materials[0]?.setParameters(this._fastUpdates.materialParameters);else return 0;break;default:return 0}return 2}layerOpacityChanged(){if(this._materials[0]!=null){let e=this._materials[0].parameters.color,t=this._materialColor,n=this._getCombinedOpacity(t);this._materials[0].setParameters({color:[e[0],e[1],e[2],n],forceTransparentMode:this.needsDrivenTransparentPass})}if(this._materials[1]!=null){let e=this._materials[1].parameters.color;this._materials[1].setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerScreenSizePerspectiveChanged(){this._materials[1]?.setParameters({screenSizePerspective:this._outlineScreenSizePerspective})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=f(W.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=p(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){if(this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]){let e={hasSlicePlane:this._context.slicePlaneEnabled};this._materials[1].setParameters(e)}return!0}physicallyBasedRenderingChanged(){return!0}_containsRenderableGeometry(e){return e.polygonIndexCount>0?!0:this._materials[1]==null?!1:e.outline.output===`vertex-data`?e.outline.outlines.length>0:e.outlineIndexCount>0}_createAs3DShape(e,t,n,r){let i=S(t.geometry);if(!i)return null;let a=this._shadingEnabled,o=F(i,this._context.elevationProvider,this._context.renderCoordsHelper,r,{projectIfNearlyVertical:!0,requireNormals:a,outlineOutput:`vertex-data`,owner:this._context.layer});if(o==null)return null;let d=new K(o,n,this._context.layerViewUid,t.uid),f=d.renderInfo.vertexCount;if(this._needsUV){d.uvMapSpace=l(f*4,!0),d.textureElementIndices=Array(f),d.boundingRect=s(9*(d.renderInfo.polygonIndices.length/3));let e=j(d.uvMapSpace,d.boundingRect,d.textureElementIndices,d.renderInfo.positions,d.renderInfo.polygonIndices,this._context.renderCoordsHelper);d.boundingRect=c(d.boundingRect,0,9*e),d.boundingRectIndices=u(e)}if(d.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(d),this._createAs3DShapeFill(e,d),this._materials[1]&&this._createAs3DShapeOutline(d),this._logGeometryCreationWarnings(d.renderInfo,i.rings,`rings`,`FillSymbol3DLayer`),d.outGeometries.length===0)return null;let m=new L({geometries:d.outGeometries,castShadow:this._shadingEnabled,layerViewUid:this._context.layerViewUid,graphicUid:t.uid}),h=d.plateLayout,g=new _(this,m,null,(e,t,n,r,i)=>A(e,t,n,r,i,h),r);return g.alignedSampledElevation=d.renderInfo.sampledElevation,g.needsElevationUpdates=p(r.mode),g}_createAs3DShapeFill(e,t){let{mapPositions:i,positions:a,polygonIndices:o,polygonIndexCount:s,vertexCount:c,compressedNormals:l}=t.renderInfo;if(s===0||this._context.clippingExtent!=null&&(n(i,G),!r(G,this._context.clippingExtent)))return;let u=this._fastUpdates?.visualVariables.color,d=C({material:this._materials[0],indices:o,mapPositions:i,attributeData:{position:a,color:u?null:t.color,compressedNormals:l,colorFeature:u?D(u,e.color):null,uvMapSpace:this._needsUV?t.uvMapSpace:null,boundingRect:this._needsUV?t.boundingRect:null,textureElementIndices:this._needsUV?t.textureElementIndices:null,boundingRectIndices:this._needsUV?t.boundingRectIndices:null,olidColor:t.olidColor}});t.plateLayout=new m(c,0,null,0,s/3),h(d,t.plateLayout),t.outGeometries.push(d)}_createAs3DShapeOutline(e){if(this._materials[1]==null)return;let{outline:t}=e.renderInfo;if(t.output!==`vertex-data`)return;let{outlines:i}=t;if(i!=null&&i.length!==0)for(let{mapPositions:t,position:a}of i){if(this._context.clippingExtent!=null&&(n(t,G),!r(G,this._context.clippingExtent)))continue;let i=N(this._materials[1],{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:t,attributeData:{position:a}},e.olidColor);e.outGeometries.push(i)}}_createAsOverlay(e,t,n){let r=S(t.geometry);if(r==null)return null;this._materials[0].renderPriority=this._renderPriority+this._renderPriorityStep/2,this._materials[1]!=null&&(this._materials[1].renderPriority=this._renderPriority);let a=I(r,{drapedSpatialReference:this._context.overlaySR,outlineOutput:`vertex-data`,owner:this._context.layer});if(a==null)return null;let o=new q(a,n,this._context.layerViewUid,t.uid);return this._needsUV&&(o.uvMapSpace=l(o.renderInfo.vertexCount*4,!0),M(o.uvMapSpace,o.renderInfo.positions,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode)),o.outBoundingBox=i(),o.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(o),this._createAsOverlayFill(e,o),this._materials[1]&&this._createAsOverlayOutline(o),this._logGeometryCreationWarnings(o.renderInfo,r.rings,`rings`,`FillSymbol3DLayer`),new g(this,o.outGeometries,o.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,t){let{positions:i,polygonIndices:o,polygonIndexCount:s}=t.renderInfo;if(s===0)return;let c=n(i,G);if(!r(c,this._context.clippingExtent))return;a(t.outBoundingBox,c);let l=this._fastUpdates?.visualVariables.color,u=C({material:this._materials[0],indices:o,attributeData:{position:i,color:l?null:t.color,colorFeature:l?D(l,e.color):null,uvMapSpace:this._needsUV?t.uvMapSpace:null,olidColor:t.olidColor}});t.outGeometries.push(new R(u,t))}_createAsOverlayOutline(e){if(this._materials[1]==null)return;let{outline:t}=e.renderInfo;if(t.output!==`vertex-data`)return;let{outlines:i}=t;for(let{position:t}of i){if(n(t,G),!r(G,this._context.clippingExtent))continue;a(e.outBoundingBox,G);let i=N(this._materials[1],{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:t}},e.olidColor);e.outGeometries.push(new R(i,e))}}_getOutlineOpacity(){let e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(e==null?0:e.a)}_getOutlineColor(){let e=this.symbolLayer?.outline?.color,t=this._getOutlineOpacity();return y(e?.toUnitRGB(),t)}test(){return{...super.test(),createAsOverlay:(e,t,n)=>this._createAsOverlay(e,t,n),createAs3DShape:(e,t,n,r)=>this._createAs3DShape(e,t,n,r)}}get _vvConvertOptions(){return new O({supports:{size:!1,color:!0,rotation:!1,opacity:!1},fallbackColor:this._materialColor?.toUnitRGBA()??t})}}const G=o();class K extends w{constructor(e,t,n,r){super(e,n,r),this.color=t}}class q extends w{constructor(e,t,n,r){super(e,n,r),this.color=t}}function J(e){return e?.size!=null&&e.size>0&&e.color!=null&&(e.pattern==null||e.pattern.type!==`style`||e.pattern.style!==`none`)}export{W as Graphics3DPolygonFillSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- class e{constructor(e,t,n,r){this.scheduler=e,this.schedule=t,this.layerViewUid=n,this.compressionTracker=r,this.sharedResources=null,this.elevationProvider=null,this.renderer=null,this.stage=null,this.clippingExtent=null,this.renderCoordsHelper=null,this.overlaySR=null,this.layer=null,this.drapeSourceRenderer=null,this.graphicsCoreOwner=null,this.localOriginFactory=null,this.featureExpressionInfoContext=null,this.focusAreaStyle=null,this.screenSizePerspectiveEnabled=!0,this.slicePlaneEnabled=!1,this.physicalBasedRenderingEnabled=!1,this.skipHighSymbolLods=!1,this.isAsync=!1}get spherical(){return this.stage.view.state.isGlobal}}class t{constructor(){this.renderPriority=0,this.renderPriorityStep=1,this.ignoreDrivers=!1}}export{e as Graphics3DSymbolCreationContext,t as Graphics3DSymbolLayerCreationContext};
2
+ class e{constructor(e,t,n,r){this.scheduler=e,this.schedule=t,this.layerViewUid=n,this.compressionTracker=r,this.sharedResources=null,this.elevationProvider=null,this.renderer=null,this.stage=null,this.clippingExtent=null,this.renderCoordsHelper=null,this.overlaySR=null,this.layer=null,this.drapeSourceRenderer=null,this.graphicsCoreOwner=null,this.localOriginFactory=null,this.featureExpressionInfoContext=null,this.focusAreaStyle=null,this.screenSizePerspectiveEnabled=!0,this.slicePlaneEnabled=!1,this.physicallyBasedRenderingEnabled=!1,this.skipHighSymbolLods=!1,this.isAsync=!1}get spherical(){return this.stage.view.state.isGlobal}}class t{constructor(){this.renderPriority=0,this.renderPriorityStep=1,this.ignoreDrivers=!1}}export{e as Graphics3DSymbolCreationContext,t as Graphics3DSymbolLayerCreationContext};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{ONES as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as n,scale as r}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ONES as i,ZEROS as a,fromArray as o,fromValues as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as c}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as l}from"./defaultSymbolComplexity.js";import{DrivenProperties as u}from"./DrivenProperties.js";import{ElevationContext as d}from"./ElevationContext.js";import{zeroContext as f}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as p}from"./graphicUtils.js";import{Loadable as m}from"./Loadable.js";import{getSizeAttributeValue as h,getAttributeValue as g}from"../support/FastSymbolUpdates.js";import{encodeNaNUInt8 as _}from"../support/symbolColorUtils.js";const v=()=>e.getLogger(`esri.views.3d.layers.graphics.Graphics3DSymbolLayer`);class y extends m{constructor(e,t,n,r,i=!0){super(n.schedule),this.symbol=e,this.symbolLayer=t,this._context=n,this._drivenOpacityFallbackAlwaysOpaque=i,this.ignoreDrivers=!1,this._drivenProperties=new u,this._materials=[],this.logger=v(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=r.renderPriority,this._renderPriorityStep=r.renderPriorityStep,this._elevationContext=new d,this.updateComplexity(),this.ignoreDrivers=r.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=b(this._context.renderer,i)),this._updateElevationContext()}destroy(){this.complexity=null,this._materials.length=0,super.destroy()}get view(){return this._context.stage.view}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get estimatedMemory(){let{complexity:e}=this;return e==null?0:(this.draped?e.memory.draped:e.memory).bytesPerFeature}get usedMemory(){return this.estimatedMemory}_drivenPropertiesChanged(e){return!this.ignoreDrivers&&!this._drivenProperties.equals(b(e,this._drivenOpacityFallbackAlwaysOpaque))}get needsDrivenTransparentPass(){return this._hasDrivenColorOrOpacity&&!this._drivenProperties.opacityAlwaysOpaque}get _hasDrivenColorOrOpacity(){return this._drivenProperties.color||this._drivenProperties.opacity}_logGeometryCreationWarnings(e,t,n,r){let i=e.projectionSuccess,a=`${r} geometry failed to be created`;i?this._logGeometryValidationWarnings(t,n,r):v().warnOncePerTick(`${a} (failed to project geometry to view spatial reference)`)}_containsRenderableGeometry(e){return`polygonIndices`in e?e.polygonIndices.length>0:e.lines.length>0}get needsUpdateFocus(){return!1}_logGeometryValidationWarnings(e,t,n){let r=`${n} geometry failed to be created`;return!e.length||e.length===1&&!e[0].length?(v().warnOncePerTick(`${r} (no ${t} were defined)`),!0):!Array.isArray(e)||!Array.isArray(e[0])?(v().warnOncePerTick(`${r} (${t} should be defined as a 2D array)`),!0):!1}_validateGeometry(e,t=null,n=null){if(t!=null&&!t.includes(e.type))return this.logger.warn(`unsupported geometry type for `+n+` symbol: ${e.type}`),!1;switch(e.type){case`point`:{let t=e;if(!isFinite(t.x)||!isFinite(t.y))return v().warn(`point coordinate is not a valid number, graphic skipped`),!1;break}case`polygon`:c(e)}return!0}_defaultElevationInfoNoZ(){return x}_defaultElevationInfoZ(){return S}_updateElevationContext(){this._elevationInfoOverride==null?this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.setFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset():(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.setFeatureExpressionInfoContext(null))}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}createElevationContextForGraphic(e){let t=new d;return this.updateElevationContextForGraphic(t,e),t}updateElevationContextForGraphic(e,t){let n=t.geometry,r=this.getDefaultElevationInfo(n);e.unit=this._elevationContext.unit==null?r.unit:this._elevationContext.unit,e.mode=this.getGeometryElevationMode(n,r),e.offsetMeters=this._elevationContext.meterUnitOffset??r.offset??0;let i=!this._elevationOptions.supportsOnTheGround&&e.mode===`on-the-ground`;i&&(e.mode=`relative-to-ground`,e.offsetMeters=0);let a=i?f:this._elevationContext.featureExpressionInfoContext;a?e.updateFeatureExpressionInfoContextForGraphic(a,t,this._context.layer):e.setFeatureExpressionInfoContext(null)}prepareSymbolLayerPatch(e){}onRemoveGraphic(e){}_getLayerOpacity(){return this._context.graphicsCoreOwner&&`fullOpacity`in this._context.graphicsCoreOwner?this._context.graphicsCoreOwner.fullOpacity??0:this._context.layer.opacity??1}_getCombinedOpacity(e,t=C){let n=this.draped?1:this._getLayerOpacity();return this._drivenProperties.color?n:e?n*(this._drivenProperties.opacity?1:e.a):t.hasIntrinsicColor?n:0}_getCombinedOpacityAndColor(e,n=C){let r=this._getCombinedOpacity(e,n);if(this._drivenProperties.color)return p(null,r);let i=e?.toUnitRGB()??t;return p(i,r)}_getDrivenUInt8Color({color:e,opacity:t},n,r){let{color:o,opacity:s}=this._drivenProperties,c=n?.toUnitRGBA()??(r?i:a),l=o?e?.output??c:null,u=e||n||r,d=o?null:c[3],f=s&&u?t?.output??d:null;return p(l,f,255)}_getDrivenUInt8ColorWithNaNSupport({color:e,opacity:t},i,a){let c=i?o(i.toUnitRGBA()):s(NaN,NaN,NaN,a?NaN:0);return this._drivenProperties.color&&e!=null&&n(c,e.output),this._drivenProperties.opacity&&t!=null&&(c[3]=t.output),r(c,c,255),_(c,c)}isFastUpdatesEnabled(){return this._fastUpdates!=null}updateComplexity(){this.complexity=this.computeComplexity()}computeComplexity(){return l(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,n){switch(e){case`opacity`:return this.layerOpacityChanged(t,n),!0;case`screenSizePerspectiveEnabled`:return this.layerScreenSizePerspectiveChanged(t,n),!0;case`elevationInfo`:{let e=this._elevationContext.mode;return this._updateElevationContext(),this.layerElevationInfoChanged(t,n,e)!==2}case`slicePlaneEnabled`:return this.slicePlaneEnabledChanged(t,n);case`physicalBasedRenderingEnabled`:return this.physicalBasedRenderingChanged();case`pixelRatio`:return this.pixelRatioChanged;case`skipHighSymbolLods`:return this.skipHighSymbolLodsChanged;case`terrainTransparency`:return this.terrainTransparencyChanged();default:return!1}}terrainTransparencyChanged(){return!0}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,n){let r=1;return e?.forEach(e=>{let i=t(e);if(i!=null){let t=e.graphic;this.updateElevationContextForGraphic(i.elevationContext,t),i.needsElevationUpdates=n(i.elevationContext.mode)}else r=2}),r}applyRendererDiff(e,t){return 0}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;let t=this._fastUpdates.visualVariables,n=h(t.size,e.size),r=g(t.color,e.color),i=g(t.opacity,e.opacity);return s(n,r,i,0)}get draped(){return this._draped}ensureDrapedStatus(e){return this._draped==null?(this._draped=e,!0):(e!==this.draped&&v().warnOnce(`A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary.`),!1)}test(){return{drivenProperties:this._drivenProperties,getVisVarFields:()=>({size:this._fastUpdates?.visualVariables.size?.source??null,color:this._fastUpdates?.visualVariables.color?.source??null,opacity:this._fastUpdates?.visualVariables.opacity?.source??null,rotation:this._fastUpdates?.visualVariables.rotation?.source??null})}}}function b(e,t){let n=new u;return n.opacityAlwaysOpaque=t,e&&`visualVariables`in e&&e.visualVariables&&e.visualVariables.forEach(e=>{switch(e.type){case`color`:if(n.color=!0,e.stops)for(let t=0;t<e.stops.length;t++){let r=e.stops[t].color;r&&r.a<1&&(n.opacityAlwaysOpaque=!1)}break;case`opacity`:n.opacity=!0,n.opacityAlwaysOpaque=!1;break;case`size`:n.size=!0;break;case`rotation`:n.rotation=!0}}),n}const x={mode:`on-the-ground`,offset:0,unit:`meters`},S={mode:`absolute-height`,offset:0,unit:`meters`},C={hasIntrinsicColor:!1},w=s(NaN,NaN,NaN,NaN);export{y as Graphics3DSymbolLayer,b as getDrivenProperties,w as nanFallbackColor};
2
+ import e from"../../../../core/Logger.js";import{ONES as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as n,scale as r}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ONES as i,ZEROS as a,fromArray as o,fromValues as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as c}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as l}from"./defaultSymbolComplexity.js";import{DrivenProperties as u}from"./DrivenProperties.js";import{ElevationContext as d}from"./ElevationContext.js";import{zeroContext as f}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as p}from"./graphicUtils.js";import{Loadable as m}from"./Loadable.js";import{getSizeAttributeValue as h,getAttributeValue as g}from"../support/FastSymbolUpdates.js";import{encodeNaNUInt8 as _}from"../support/symbolColorUtils.js";const v=()=>e.getLogger(`esri.views.3d.layers.graphics.Graphics3DSymbolLayer`);class y extends m{constructor(e,t,n,r,i=!0){super(n.schedule),this.symbol=e,this.symbolLayer=t,this._context=n,this._drivenOpacityFallbackAlwaysOpaque=i,this.ignoreDrivers=!1,this._drivenProperties=new u,this._materials=[],this.logger=v(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=r.renderPriority,this._renderPriorityStep=r.renderPriorityStep,this._elevationContext=new d,this.updateComplexity(),this.ignoreDrivers=r.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=b(this._context.renderer,i)),this._updateElevationContext()}destroy(){this.complexity=null,this._materials.length=0,super.destroy()}get view(){return this._context.stage.view}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get estimatedMemory(){let{complexity:e}=this;return e==null?0:(this.draped?e.memory.draped:e.memory).bytesPerFeature}get usedMemory(){return this.estimatedMemory}_drivenPropertiesChanged(e){return!this.ignoreDrivers&&!this._drivenProperties.equals(b(e,this._drivenOpacityFallbackAlwaysOpaque))}get needsDrivenTransparentPass(){return this._hasDrivenColorOrOpacity&&!this._drivenProperties.opacityAlwaysOpaque}get _hasDrivenColorOrOpacity(){return this._drivenProperties.color||this._drivenProperties.opacity}_logGeometryCreationWarnings(e,t,n,r){let i=e.projectionSuccess,a=`${r} geometry failed to be created`;i?this._logGeometryValidationWarnings(t,n,r):v().warnOncePerTick(`${a} (failed to project geometry to view spatial reference)`)}_containsRenderableGeometry(e){return`polygonIndices`in e?e.polygonIndices.length>0:e.lines.length>0}get needsUpdateFocus(){return!1}_logGeometryValidationWarnings(e,t,n){let r=`${n} geometry failed to be created`;return!e.length||e.length===1&&!e[0].length?(v().warnOncePerTick(`${r} (no ${t} were defined)`),!0):!Array.isArray(e)||!Array.isArray(e[0])?(v().warnOncePerTick(`${r} (${t} should be defined as a 2D array)`),!0):!1}_validateGeometry(e,t=null,n=null){if(t!=null&&!t.includes(e.type))return this.logger.warn(`unsupported geometry type for `+n+` symbol: ${e.type}`),!1;switch(e.type){case`point`:{let t=e;if(!isFinite(t.x)||!isFinite(t.y))return v().warn(`point coordinate is not a valid number, graphic skipped`),!1;break}case`polygon`:c(e)}return!0}_defaultElevationInfoNoZ(){return x}_defaultElevationInfoZ(){return S}_updateElevationContext(){this._elevationInfoOverride==null?this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.setFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset():(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.setFeatureExpressionInfoContext(null))}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}createElevationContextForGraphic(e){let t=new d;return this.updateElevationContextForGraphic(t,e),t}updateElevationContextForGraphic(e,t){let n=t.geometry,r=this.getDefaultElevationInfo(n);e.unit=this._elevationContext.unit==null?r.unit:this._elevationContext.unit,e.mode=this.getGeometryElevationMode(n,r),e.offsetMeters=this._elevationContext.meterUnitOffset??r.offset??0;let i=!this._elevationOptions.supportsOnTheGround&&e.mode===`on-the-ground`;i&&(e.mode=`relative-to-ground`,e.offsetMeters=0);let a=i?f:this._elevationContext.featureExpressionInfoContext;a?e.updateFeatureExpressionInfoContextForGraphic(a,t,this._context.layer):e.setFeatureExpressionInfoContext(null)}prepareSymbolLayerPatch(e){}onRemoveGraphic(e){}_getLayerOpacity(){return this._context.graphicsCoreOwner&&`fullOpacity`in this._context.graphicsCoreOwner?this._context.graphicsCoreOwner.fullOpacity??0:this._context.layer.opacity??1}_getCombinedOpacity(e,t=C){let n=this.draped?1:this._getLayerOpacity();return this._drivenProperties.color?n:e?n*(this._drivenProperties.opacity?1:e.a):t.hasIntrinsicColor?n:0}_getCombinedOpacityAndColor(e,n=C){let r=this._getCombinedOpacity(e,n);if(this._drivenProperties.color)return p(null,r);let i=e?.toUnitRGB()??t;return p(i,r)}_getDrivenUInt8Color({color:e,opacity:t},n,r){let{color:o,opacity:s}=this._drivenProperties,c=n?.toUnitRGBA()??(r?i:a),l=o?e?.output??c:null,u=e||n||r,d=o?null:c[3],f=s&&u?t?.output??d:null;return p(l,f,255)}_getDrivenUInt8ColorWithNaNSupport({color:e,opacity:t},i,a){let c=i?o(i.toUnitRGBA()):s(NaN,NaN,NaN,a?NaN:0);return this._drivenProperties.color&&e!=null&&n(c,e.output),this._drivenProperties.opacity&&t!=null&&(c[3]=t.output),r(c,c,255),_(c,c)}isFastUpdatesEnabled(){return this._fastUpdates!=null}updateComplexity(){this.complexity=this.computeComplexity()}computeComplexity(){return l(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,n){switch(e){case`opacity`:return this.layerOpacityChanged(t,n),!0;case`screenSizePerspectiveEnabled`:return this.layerScreenSizePerspectiveChanged(t,n),!0;case`elevationInfo`:{let e=this._elevationContext.mode;return this._updateElevationContext(),this.layerElevationInfoChanged(t,n,e)!==2}case`slicePlaneEnabled`:return this.slicePlaneEnabledChanged(t,n);case`physicallyBasedRenderingEnabled`:return this.physicallyBasedRenderingChanged();case`pixelRatio`:return this.pixelRatioChanged;case`skipHighSymbolLods`:return this.skipHighSymbolLodsChanged;case`terrainTransparency`:return this.terrainTransparencyChanged();default:return!1}}terrainTransparencyChanged(){return!0}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,n){let r=1;return e?.forEach(e=>{let i=t(e);if(i!=null){let t=e.graphic;this.updateElevationContextForGraphic(i.elevationContext,t),i.needsElevationUpdates=n(i.elevationContext.mode)}else r=2}),r}applyRendererDiff(e,t){return 0}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;let t=this._fastUpdates.visualVariables,n=h(t.size,e.size),r=g(t.color,e.color),i=g(t.opacity,e.opacity);return s(n,r,i,0)}get draped(){return this._draped}ensureDrapedStatus(e){return this._draped==null?(this._draped=e,!0):(e!==this.draped&&v().warnOnce(`A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary.`),!1)}test(){return{drivenProperties:this._drivenProperties,getVisVarFields:()=>({size:this._fastUpdates?.visualVariables.size?.source??null,color:this._fastUpdates?.visualVariables.color?.source??null,opacity:this._fastUpdates?.visualVariables.opacity?.source??null,rotation:this._fastUpdates?.visualVariables.rotation?.source??null})}}}function b(e,t){let n=new u;return n.opacityAlwaysOpaque=t,e&&`visualVariables`in e&&e.visualVariables&&e.visualVariables.forEach(e=>{switch(e.type){case`color`:if(n.color=!0,e.stops)for(let t=0;t<e.stops.length;t++){let r=e.stops[t].color;r&&r.a<1&&(n.opacityAlwaysOpaque=!1)}break;case`opacity`:n.opacity=!0,n.opacityAlwaysOpaque=!1;break;case`size`:n.size=!0;break;case`rotation`:n.rotation=!0}}),n}const x={mode:`on-the-ground`,offset:0,unit:`meters`},S={mode:`absolute-height`,offset:0,unit:`meters`},C={hasIntrinsicColor:!1},w=s(NaN,NaN,NaN,NaN);export{y as Graphics3DSymbolLayer,b as getDrivenProperties,w as nanFallbackColor};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../core/Error.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{fromValues as i,ONES as a,create as o,ZEROS as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{copy as c}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as l,create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as d}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{hasCalloutSupport as f,textSymbolLayerSupportsVerticalOffset as p}from"../../../../symbols/callouts/calloutUtils.js";import{perTranslatedBufferPointElevationAligner as m}from"./ElevationAligners.js";import{needsElevationUpdates2D as h}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as g}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DObjectMetadata as _}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as v}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as y}from"./graphicUtils.js";import{LabelPlacement as b,LabelParameters as x}from"./LabelParameters.js";import{verticalScreenOffsetFromAlignment as S,verticalPlacementFromAlignment as C,textRenderAlignmentFromHorizontalPlacement as w,horizontalPlacementToAnchorX as T,anchorFromPlacements as E,namedAnchorToHUDMaterialAnchorPos as D}from"./placementUtils.js";import{placePointOnGeometry as O,updateTranslatedBufferStageObjectGeometry as k,extendPointGraphicElevationContext as A,createTranslatedBufferStageObject as j}from"./pointUtils.js";import{getFontMetrics as M}from"../../webgl-engine/lib/FontMetrics.js";import{createPointBufferGeometry as N}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as P}from"../../webgl-engine/lib/TextRenderParameters.js";import F from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as I}from"../../webgl-engine/materials/HUDMaterial.js";class L extends v{constructor(e,t,n,r){super(e,t,n,r),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){let t=y(this.symbolLayer.size);if(t)throw new e(`graphics3dtextsymbollayer:invalid-size`,t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){let e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await P.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){let t=e.graphic,n=O(t.geometry);if(n==null)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let r=this.view.focusAreasView?.containsGeometry(n)??!0,i=this.symbolLayer.text;if(i==null||i===``)return null;let a=f(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(a!=null&&!p(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;let{verticalAlignment:o}=this.symbolLayer,s=new b(a);S(o,s.screenOffset);let c=new x(s,this.symbolLayer.horizontalAlignment,C(o)),l=r?null:this._context.focusAreaStyle;return this._createAs3DShape(t,n,i,c,l)}get needsUpdateFocus(){return!0}createLabel(e,t,n,r,i){let a=e.graphic,o=O(a.geometry);if(o==null)return this.logger.warn(`unsupported geometry type for label: ${a.geometry.type}`),null;let s=this.view.focusAreasView?.containsGeometry(o)??!0,c=t.text;if(!c||/^\s+$/.test(c))return null;let l=s?null:this._context.focusAreaStyle;return this._createAs3DShape(a,o,c,t,l,n,r,i)}createElevationContextForGraphic(e,t=0){let n=super.createElevationContextForGraphic(e);return n.addOffsetRenderUnits(t),n}updateElevationContextForGraphic(e,t,n=0){super.updateElevationContextForGraphic(e,t),e.addOffsetRenderUnits(n)}layerOpacityChanged(){return this.logger.warn(`layer opacity change not yet implemented in Graphics3DTextSymbolLayer`),!1}layerScreenSizePerspectiveChanged(e,t){let n=!this.draped&&this._context.screenSizePerspectiveEnabled,r=n?this.view.screenSizePerspective.labelParameters:null,i=n?this.view.screenSizePerspective.parameters:null;R(e,t,e=>{for(let t of e.stageObject.geometries)t.material.setParameters({screenSizePerspective:r,screenSizePerspectiveAlignment:i})})}layerElevationInfoChanged(e,t){return R(e,t,(e,t)=>{this.graphics3DGraphicLayerElevationInfoChanged(t,e)}),1}slicePlaneEnabledChanged(e,t){return R(e,t,e=>{for(let t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}terrainTransparencyChanged(){return this.draped}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return!1}graphics3DGraphicLayerElevationInfoChanged(e,t){let{elevationContext:n,metadata:r}=t;this.updateElevationContextForGraphic(n,e,r?.elevationOffset??0),t.needsElevationUpdates=h(n.mode)||n.mode===`absolute-height`}updateGeometry(e,t,n){let r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;let{elevationContext:i,stageObject:a}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;let o=O(r);if(!o)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);let s=k(a,this._context,o,i,n?.translation??l,V);return s!=null&&(n&&c(n.renderTranslation,V),t.alignedSampledElevation=s,A(t,o,this._context.elevationProvider),!0)}_defaultElevationInfoNoZ(){return B}_createAs3DShape(e,c,l,u,f,p,v=null,y=()=>u.placement.elevationOffset){let b=u.placement.renderTranslation,x=this.createElevationContextForGraphic(e,u.placement.elevationOffset),S=e.uid,C=null,T=null;if(v==null){let e=w(u.horizontalPlacement);C=new F(l,e,this._textRenderParameters);let r=null;if(this._context.sharedResources.textures!=null){T=this._context.sharedResources.textures.fromData(C.key,()=>C.create()),T.managedTexture.events.on(`unloaded`,()=>r=t(r));let e=this._context.stage.renderView.textures.acquire(T.managedTexture.id);if(e==null||n(e))return T.release(),null;r=e}}let E=this.symbolLayer.occludedVisibility?.mode??`hidden`,D=z(C,u),O=v!=null,k={occludedFragmentOpacity:E===`hidden`?null:this.view.state.ensureOccludedFragmentOpacity(!0,E),screenOffset:u.placement.screenOffset,anchorPosition:D,polygonOffset:2,color:[1,1,1,1],centerOffsetUnits:u.placement.centerOffsetUnits,depthEnabled:!1,drawAsLabel:!0,isLabel:!0,hasVertexSize:O,hasVertexUVi:O,hasVertexCenterOffset:O,size:C?i(C.displayWidth,C.displayHeight):a,focusAreaStyle:f};if(e.geometry?.type===`polyline`&&(k.shaderPolygonOffset=1e-4),O?k.textureId=v.id:T&&(k.textureId=T.managedTexture.id),u.placement.verticalOffset!=null){let{screenLength:e,minWorldLength:t,maxWorldLength:n}=u.placement.verticalOffset;k.verticalOffset={screenLength:r(e),minWorldLength:t||0,maxWorldLength:n??1/0}}let P={screenOffset:k.screenOffset,anchorPosition:D,centerOffsetUnits:k.centerOffsetUnits,verticalOffset:k.verticalOffset,shaderPolygonOffset:k.shaderPolygonOffset,focusAreaStyle:k.focusAreaStyle};if(this._context.screenSizePerspectiveEnabled){let{parameters:e,labelParameters:t}=this.view.screenSizePerspective,n=M(this._textRenderParameters);k.screenSizePerspective=t,k.screenSizePerspectiveMinPixelReferenceSize=n.maxHeight,k.screenSizePerspectiveAlignment=e,P.fontHeight=n.maxHeight}k.hasSlicePlane=this._context.slicePlaneEnabled;let L=p?JSON.stringify(P):``,R=p?.get(L);R??(R=new I(k,this._context.spherical),p?.set(L,R));let B=O?s:null,V=O?u.placement.centerOffset:null,H=O?d(0,0,0,0):null,U=j(this._context,c,R,{size:B,centerOffset:V,uvi:H},x,S,u.placement.translation,b,N);if(U==null)return null;let W=new g(this,U.object,T,(t,n,r,i,a)=>{let o=y()||u.placement.elevationOffset;return this.updateElevationContextForGraphic(n,e,o),m(t,n,r,i,a,b)},x);return W.setOccludedVisibilityMode(this.symbolLayer.occludedVisibility?.mode),W.hiddenIfDeconflicted=!0,W.alignedSampledElevation=U.sampledElevation,W.needsElevationUpdates=h(x.mode)||x.mode===`absolute-height`,W.getScreenSize=(e=o())=>(e[0]=C?C.displayWidth:u.displaySize[0],e[1]=C?C.displayHeight:u.displaySize[1],e),W.metadata=new _(u.placement.elevationOffset,l),A(W,c,this._context.elevationProvider),W}}function R(e,t,n){e?.forEach(e=>{let r=t(e);r!=null&&n(r,e.graphic)})}function z(e,t){let n=t.horizontalPlacement;if(t.verticalPlacement===`baseline`){let t=T[n],r=e==null?0:e.baselineAnchorY;return i(t,r)}let r=E(n,t.verticalPlacement);return D[r]}const B={mode:`relative-to-ground`,offset:0},V=u();export{L as Graphics3DTextSymbolLayer};
2
+ import e from"../../../../core/Error.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{fromValues as i,ONES as a,create as o,ZEROS as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{copy as c}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as l,create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as d}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{hasCalloutSupport as f,textSymbolLayerSupportsVerticalOffset as p}from"../../../../symbols/callouts/calloutUtils.js";import{perTranslatedBufferPointElevationAligner as m}from"./ElevationAligners.js";import{needsElevationUpdates2D as h}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as g}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DObjectMetadata as _}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as v}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as y}from"./graphicUtils.js";import{LabelPlacement as b,LabelParameters as x}from"./LabelParameters.js";import{verticalScreenOffsetFromAlignment as S,verticalPlacementFromAlignment as C,textRenderAlignmentFromHorizontalPlacement as w,horizontalPlacementToAnchorX as T,anchorFromPlacements as E,namedAnchorToHUDMaterialAnchorPos as D}from"./placementUtils.js";import{placePointOnGeometry as O,updateTranslatedBufferStageObjectGeometry as k,extendPointGraphicElevationContext as A,createTranslatedBufferStageObject as j}from"./pointUtils.js";import{getFontMetrics as M}from"../../webgl-engine/lib/FontMetrics.js";import{createPointBufferGeometry as N}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as P}from"../../webgl-engine/lib/TextRenderParameters.js";import F from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as I}from"../../webgl-engine/materials/HUDMaterial.js";class L extends v{constructor(e,t,n,r){super(e,t,n,r),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){let t=y(this.symbolLayer.size);if(t)throw new e(`graphics3dtextsymbollayer:invalid-size`,t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){let e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await P.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){let t=e.graphic,n=O(t.geometry);if(n==null)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let r=this.view.focusAreasView?.containsGeometry(n)??!0,i=this.symbolLayer.text;if(i==null||i===``)return null;let a=f(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(a!=null&&!p(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;let{verticalAlignment:o}=this.symbolLayer,s=new b(a);S(o,s.screenOffset);let c=new x(s,this.symbolLayer.horizontalAlignment,C(o)),l=r?null:this._context.focusAreaStyle;return this._createAs3DShape(t,n,i,c,l)}get needsUpdateFocus(){return!0}createLabel(e,t,n,r,i){let a=e.graphic,o=O(a.geometry);if(o==null)return this.logger.warn(`unsupported geometry type for label: ${a.geometry.type}`),null;let s=this.view.focusAreasView?.containsGeometry(o)??!0,c=t.text;if(!c||/^\s+$/.test(c))return null;let l=s?null:this._context.focusAreaStyle;return this._createAs3DShape(a,o,c,t,l,n,r,i)}createElevationContextForGraphic(e,t=0){let n=super.createElevationContextForGraphic(e);return n.addOffsetRenderUnits(t),n}updateElevationContextForGraphic(e,t,n=0){super.updateElevationContextForGraphic(e,t),e.addOffsetRenderUnits(n)}layerOpacityChanged(){return this.logger.warn(`layer opacity change not yet implemented in Graphics3DTextSymbolLayer`),!1}layerScreenSizePerspectiveChanged(e,t){let n=!this.draped&&this._context.screenSizePerspectiveEnabled,r=n?this.view.screenSizePerspective.labelParameters:null,i=n?this.view.screenSizePerspective.parameters:null;R(e,t,e=>{for(let t of e.stageObject.geometries)t.material.setParameters({screenSizePerspective:r,screenSizePerspectiveAlignment:i})})}layerElevationInfoChanged(e,t){return R(e,t,(e,t)=>{this.graphics3DGraphicLayerElevationInfoChanged(t,e)}),1}slicePlaneEnabledChanged(e,t){return R(e,t,e=>{for(let t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}terrainTransparencyChanged(){return this.draped}physicallyBasedRenderingChanged(){return!0}get pixelRatioChanged(){return!1}graphics3DGraphicLayerElevationInfoChanged(e,t){let{elevationContext:n,metadata:r}=t;this.updateElevationContextForGraphic(n,e,r?.elevationOffset??0),t.needsElevationUpdates=h(n.mode)||n.mode===`absolute-height`}updateGeometry(e,t,n){let r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;let{elevationContext:i,stageObject:a}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;let o=O(r);if(!o)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);let s=k(a,this._context,o,i,n?.translation??l,V);return s!=null&&(n&&c(n.renderTranslation,V),t.alignedSampledElevation=s,A(t,o,this._context.elevationProvider),!0)}_defaultElevationInfoNoZ(){return B}_createAs3DShape(e,c,l,u,f,p,v=null,y=()=>u.placement.elevationOffset){let b=u.placement.renderTranslation,x=this.createElevationContextForGraphic(e,u.placement.elevationOffset),S=e.uid,C=null,T=null;if(v==null){let e=w(u.horizontalPlacement);C=new F(l,e,this._textRenderParameters);let r=null;if(this._context.sharedResources.textures!=null){T=this._context.sharedResources.textures.fromData(C.key,()=>C.create()),T.managedTexture.events.on(`unloaded`,()=>r=t(r));let e=this._context.stage.renderView.textures.acquire(T.managedTexture.id);if(e==null||n(e))return T.release(),null;r=e}}let E=this.symbolLayer.occludedVisibility?.mode??`hidden`,D=z(C,u),O=v!=null,k={occludedFragmentOpacity:E===`hidden`?null:this.view.state.ensureOccludedFragmentOpacity(!0,E),screenOffset:u.placement.screenOffset,anchorPosition:D,polygonOffset:2,color:[1,1,1,1],centerOffsetUnits:u.placement.centerOffsetUnits,depthEnabled:!1,drawAsLabel:!0,isLabel:!0,hasVertexSize:O,hasVertexUVi:O,hasVertexCenterOffset:O,size:C?i(C.displayWidth,C.displayHeight):a,focusAreaStyle:f};if(e.geometry?.type===`polyline`&&(k.shaderPolygonOffset=1e-4),O?k.textureId=v.id:T&&(k.textureId=T.managedTexture.id),u.placement.verticalOffset!=null){let{screenLength:e,minWorldLength:t,maxWorldLength:n}=u.placement.verticalOffset;k.verticalOffset={screenLength:r(e),minWorldLength:t||0,maxWorldLength:n??1/0}}let P={screenOffset:k.screenOffset,anchorPosition:D,centerOffsetUnits:k.centerOffsetUnits,verticalOffset:k.verticalOffset,shaderPolygonOffset:k.shaderPolygonOffset,focusAreaStyle:k.focusAreaStyle};if(this._context.screenSizePerspectiveEnabled){let{parameters:e,labelParameters:t}=this.view.screenSizePerspective,n=M(this._textRenderParameters);k.screenSizePerspective=t,k.screenSizePerspectiveMinPixelReferenceSize=n.maxHeight,k.screenSizePerspectiveAlignment=e,P.fontHeight=n.maxHeight}k.hasSlicePlane=this._context.slicePlaneEnabled;let L=p?JSON.stringify(P):``,R=p?.get(L);R??(R=new I(k,this._context.spherical),p?.set(L,R));let B=O?s:null,V=O?u.placement.centerOffset:null,H=O?d(0,0,0,0):null,U=j(this._context,c,R,{size:B,centerOffset:V,uvi:H},x,S,u.placement.translation,b,N);if(U==null)return null;let W=new g(this,U.object,T,(t,n,r,i,a)=>{let o=y()||u.placement.elevationOffset;return this.updateElevationContextForGraphic(n,e,o),m(t,n,r,i,a,b)},x);return W.setOccludedVisibilityMode(this.symbolLayer.occludedVisibility?.mode),W.hiddenIfDeconflicted=!0,W.alignedSampledElevation=U.sampledElevation,W.needsElevationUpdates=h(x.mode)||x.mode===`absolute-height`,W.getScreenSize=(e=o())=>(e[0]=C?C.displayWidth:u.displaySize[0],e[1]=C?C.displayHeight:u.displaySize[1],e),W.metadata=new _(u.placement.elevationOffset,l),A(W,c,this._context.elevationProvider),W}}function R(e,t,n){e?.forEach(e=>{let r=t(e);r!=null&&n(r,e.graphic)})}function z(e,t){let n=t.horizontalPlacement;if(t.verticalPlacement===`baseline`){let t=T[n],r=e==null?0:e.baselineAnchorY;return i(t,r)}let r=E(n,t.verticalPlacement);return D[r]}const B={mode:`relative-to-ground`,offset:0},V=u();export{L as Graphics3DTextSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{getMetersPerUnitForSR as e}from"../../../../core/units.js";import{fromValues as t,create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{scale as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{toRadian as a}from"../../../../core/libs/gl-matrix-2/math/common.js";import{fromBuffer as o,intersectsClippingArea as s,empty as c,expandWithAABB as l,create as u,center as d}from"../../../../geometry/support/aaBoundingBox.js";import{empty as f,expandXYInPlace as p,create as m}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec3f as h,BufferViewVec2f as g,BufferViewVec4u8 as _}from"../../../../geometry/support/buffer/BufferView.js";import{perBufferVertexElevationAligner as v}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as y,needsElevationUpdates2D as b}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as x}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as S}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as C}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as w,PolygonCreationDataBase as T}from"./polygonUtils.js";import{loadTessellationUtils as E,preloadedPolygonToRenderInfoElevationAligned as D,preloadedPolygonToRenderInfoDraped as O}from"../../support/renderInfoUtils/polygon.js";import{BufferGeometry as k}from"../../webgl-engine/lib/BufferGeometry.js";import{BufferObject3D as A}from"../../webgl-engine/lib/BufferObject3D.js";import{Buffers as j}from"../../webgl-engine/lib/Buffers.js";import{Parameters as M,WaterMaterial as N,getWaterLayout as P}from"../../webgl-engine/materials/WaterMaterial.js";import{wavePresets as F}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";const I=[`polyline`,`polygon`,`extent`];class L extends C{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r)}async doLoad(){await E()}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,I,this.symbolLayer.type))return null;let n=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(n.mode===`on-the-ground`),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,n,t.uid)}ensureMaterial(){if(this._materials[0])return;let e=new M,n=this.symbolLayer.color.toUnitRGBA();n[3]*=this._getLayerOpacity(),e.color=n,e.transparent=n[3]<1||this.needsDrivenTransparentPass,e.waveDirection=this.symbolLayer.waveDirection==null?t(0,0):R(this.symbolLayer.waveDirection);let r=this.symbolLayer.waveStrength+`-`+this.symbolLayer.waterbodySize,i=F[r];e.waveStrength=i.waveStrength,e.waveTextureRepeat=i.textureRepeat,e.waveVelocity=i.waveVelocity,e.flowStrength=i.perturbationStrength,e.hasSlicePlane=this._context.slicePlaneEnabled,e.draped=this.draped,e.useIndexing=!0,this._materials[0]=new N(e,this._context)}layerOpacityChanged(){if(this._materials[0]==null)return;let e=this._materials[0].parameters.color,t=this.symbolLayer.color.a*this._getLayerOpacity(),n=t<1||this.needsDrivenTransparentPass;this._materials[0].setParameters({color:[e[0],e[1],e[2],t],transparent:n})}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=y(L.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=b(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}get needsDrivenTransparentPass(){return!1}_createAs3DShape(e,t,n){let r=w(e.geometry);if(r==null)return null;let i=D(r,this._context.elevationProvider,this._context.renderCoordsHelper,t,{owner:this._context.layer});if(i==null)return null;let a=new W(i,this._context.layerViewUid,e.uid);if(a.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(a),this._create3DShapeGeometries(a),this._logGeometryCreationWarnings(a.renderInfo,r.rings,`rings`,`WaterSymbol3DLayer`),a.outGeometries.length===0)return null;let o=new A({geometries:a.outGeometries,castShadow:!1,layerViewUid:this._context.layerViewUid,graphicUid:n}),s=new x(this,o,null,v,t);return s.alignedSampledElevation=a.renderInfo.sampledElevation,s.needsElevationUpdates=b(t.mode),s}_create3DShapeGeometries(e){let{mapPositions:t}=e.renderInfo;if(e.renderInfo.polygonIndexCount===0||this._context.clippingExtent!=null&&(o(t,V),!s(V,this._context.clippingExtent)))return;let n=z(e.renderInfo,this._materials[0],this._context.localOriginFactory,this._context.elevationProvider.spatialReference,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}_createAsOverlay(e){let t=w(e.geometry);if(t==null)return null;this._materials[0].renderPriority=this._renderPriority;let n=O(t,{drapedSpatialReference:this._context.overlaySR,owner:this._context.layer});if(n==null)return null;let r=new G(n,this._context.layerViewUid,e.uid);return r.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(r),r.outBoundingBox=c(),this._createAsOverlayWater(r),this._logGeometryCreationWarnings(r.renderInfo,t.rings,`rings`,`WaterSymbol3DLayer`),r.outGeometries.length===0?null:new S(this,r.outGeometries,r.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayWater(e){let{positions:t}=e.renderInfo;if(o(t,V),!s(V,this._context.clippingExtent)||(l(e.outBoundingBox,V),e.renderInfo.polygonIndexCount===0))return;let n=z(e.renderInfo,this._materials[0],this._context.drapeSourceRenderer.rendererContext.localOriginFactory,this._context.overlaySR,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}test(){return{...super.test(),create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}function R(e){let t=n(),r=a(e);return t[0]=Math.sin(r),t[1]=Math.cos(r),t}function z(t,n,r,a,s,c,l){let{positions:u,polygonIndices:m,vertexCount:v}=t,y=`mapPositions`in t?t.mapPositions:null,b=y??u;o(u,V),d(V,U);let x=r.getOrigin(U),S=P().createBuffer(v),C=S.getField(`position`,h),w=S.getField(`uv0`,g),T=S.getField(`olidColor`,_),E=e(a);f(H);for(let e=0;e<v;e++)p(H,b[e*3],b[e*3+1]);i(H,H,E);let[D,O]=H,A=D-D%B,M=O-O%B,N=x.vec3;for(let e=0;e<v;e++){let t=e*3;C.setValues(e,u[t]-N[0],u[t+1]-N[1],u[t+2]-N[2]),w.setValues(e,(b[t]*E-A)/B,(b[t+1]*E-M)/B),T!=null&&s!=null&&T.setVec(e,s)}let F=new k(n,new j(S,void 0,m),x,y);return F.layerViewUid=c,F.graphicUid=l,F}const B=100,V=u(),H=m(),U=r();class W extends T{}class G extends T{}export{L as Graphics3DWaterSymbolLayer,z as createWaterGeometry,R as headingVectorFromAngle};
2
+ import{getMetersPerUnitForSR as e}from"../../../../core/units.js";import{fromValues as t,create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{scale as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{toRadian as a}from"../../../../core/libs/gl-matrix-2/math/common.js";import{fromBuffer as o,intersectsClippingArea as s,empty as c,expandWithAABB as l,create as u,center as d}from"../../../../geometry/support/aaBoundingBox.js";import{empty as f,expandXYInPlace as p,create as m}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec3f as h,BufferViewVec2f as g,BufferViewVec4u8 as _}from"../../../../geometry/support/buffer/BufferView.js";import{perBufferVertexElevationAligner as v}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as y,needsElevationUpdates2D as b}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as x}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as S}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as C}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as w,PolygonCreationDataBase as T}from"./polygonUtils.js";import{loadTessellationUtils as E,preloadedPolygonToRenderInfoElevationAligned as D,preloadedPolygonToRenderInfoDraped as O}from"../../support/renderInfoUtils/polygon.js";import{BufferGeometry as k}from"../../webgl-engine/lib/BufferGeometry.js";import{BufferObject3D as A}from"../../webgl-engine/lib/BufferObject3D.js";import{Buffers as j}from"../../webgl-engine/lib/Buffers.js";import{Parameters as M,WaterMaterial as N,getWaterLayout as P}from"../../webgl-engine/materials/WaterMaterial.js";import{wavePresets as F}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";const I=[`polyline`,`polygon`,`extent`];class L extends C{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r)}async doLoad(){await E()}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,I,this.symbolLayer.type))return null;let n=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(n.mode===`on-the-ground`),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,n,t.uid)}ensureMaterial(){if(this._materials[0])return;let e=new M,n=this.symbolLayer.color.toUnitRGBA();n[3]*=this._getLayerOpacity(),e.color=n,e.transparent=n[3]<1||this.needsDrivenTransparentPass,e.waveDirection=this.symbolLayer.waveDirection==null?t(0,0):R(this.symbolLayer.waveDirection);let r=this.symbolLayer.waveStrength+`-`+this.symbolLayer.waterbodySize,i=F[r];e.waveStrength=i.waveStrength,e.waveTextureRepeat=i.textureRepeat,e.waveVelocity=i.waveVelocity,e.flowStrength=i.perturbationStrength,e.hasSlicePlane=this._context.slicePlaneEnabled,e.draped=this.draped,e.useIndexing=!0,this._materials[0]=new N(e,this._context)}layerOpacityChanged(){if(this._materials[0]==null)return;let e=this._materials[0].parameters.color,t=this.symbolLayer.color.a*this._getLayerOpacity(),n=t<1||this.needsDrivenTransparentPass;this._materials[0].setParameters({color:[e[0],e[1],e[2],t],transparent:n})}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=y(L.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=b(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicallyBasedRenderingChanged(){return!0}get needsDrivenTransparentPass(){return!1}_createAs3DShape(e,t,n){let r=w(e.geometry);if(r==null)return null;let i=D(r,this._context.elevationProvider,this._context.renderCoordsHelper,t,{owner:this._context.layer});if(i==null)return null;let a=new W(i,this._context.layerViewUid,e.uid);if(a.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(a),this._create3DShapeGeometries(a),this._logGeometryCreationWarnings(a.renderInfo,r.rings,`rings`,`WaterSymbol3DLayer`),a.outGeometries.length===0)return null;let o=new A({geometries:a.outGeometries,castShadow:!1,layerViewUid:this._context.layerViewUid,graphicUid:n}),s=new x(this,o,null,v,t);return s.alignedSampledElevation=a.renderInfo.sampledElevation,s.needsElevationUpdates=b(t.mode),s}_create3DShapeGeometries(e){let{mapPositions:t}=e.renderInfo;if(e.renderInfo.polygonIndexCount===0||this._context.clippingExtent!=null&&(o(t,V),!s(V,this._context.clippingExtent)))return;let n=z(e.renderInfo,this._materials[0],this._context.localOriginFactory,this._context.elevationProvider.spatialReference,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}_createAsOverlay(e){let t=w(e.geometry);if(t==null)return null;this._materials[0].renderPriority=this._renderPriority;let n=O(t,{drapedSpatialReference:this._context.overlaySR,owner:this._context.layer});if(n==null)return null;let r=new G(n,this._context.layerViewUid,e.uid);return r.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(r),r.outBoundingBox=c(),this._createAsOverlayWater(r),this._logGeometryCreationWarnings(r.renderInfo,t.rings,`rings`,`WaterSymbol3DLayer`),r.outGeometries.length===0?null:new S(this,r.outGeometries,r.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayWater(e){let{positions:t}=e.renderInfo;if(o(t,V),!s(V,this._context.clippingExtent)||(l(e.outBoundingBox,V),e.renderInfo.polygonIndexCount===0))return;let n=z(e.renderInfo,this._materials[0],this._context.drapeSourceRenderer.rendererContext.localOriginFactory,this._context.overlaySR,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}test(){return{...super.test(),create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}function R(e){let t=n(),r=a(e);return t[0]=Math.sin(r),t[1]=Math.cos(r),t}function z(t,n,r,a,s,c,l){let{positions:u,polygonIndices:m,vertexCount:v}=t,y=`mapPositions`in t?t.mapPositions:null,b=y??u;o(u,V),d(V,U);let x=r.getOrigin(U),S=P().createBuffer(v),C=S.getField(`position`,h),w=S.getField(`uv0`,g),T=S.getField(`olidColor`,_),E=e(a);f(H);for(let e=0;e<v;e++)p(H,b[e*3],b[e*3+1]);i(H,H,E);let[D,O]=H,A=D-D%B,M=O-O%B,N=x.vec3;for(let e=0;e<v;e++){let t=e*3;C.setValues(e,u[t]-N[0],u[t+1]-N[1],u[t+2]-N[2]),w.setValues(e,(b[t]*E-A)/B,(b[t+1]*E-M)/B),T!=null&&s!=null&&T.setVec(e,s)}let F=new k(n,new j(S,void 0,m),x,y);return F.layerViewUid=c,F.graphicUid=l,F}const B=100,V=u(),H=m(),U=r();class W extends T{}class G extends T{}export{L as Graphics3DWaterSymbolLayer,z as createWaterGeometry,R as headingVectorFromAngle};