@arcgis/core 4.33.0-next.20250401 → 4.33.0-next.20250403

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 (116) hide show
  1. package/applications/SceneViewer/sceneViewerUtils.d.ts +1 -0
  2. package/applications/SceneViewer/sceneViewerUtils.js +1 -1
  3. package/arcade/functions/knowledgegraph.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/0cd5f15b8558b23e5fcd.js +1 -0
  6. package/assets/esri/core/workers/chunks/0cec53e6f1464c69448d.js +1 -0
  7. package/assets/esri/core/workers/chunks/48fbf887da6d19838bf0.js +1 -0
  8. package/assets/esri/core/workers/chunks/{ba4d91816f6a0bf0d812.js → 4dc135e0133d58a06d67.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{322cb1b1871d03b69f0a.js → 5beb525b4adde1d98532.js} +33 -33
  10. package/assets/esri/core/workers/chunks/{3577909b8e84959d415b.js → 6a8cf1f51cc4adc268d3.js} +1 -1
  11. package/assets/esri/core/workers/chunks/6b0a6469673417563616.js +1 -0
  12. package/assets/esri/core/workers/chunks/{bdeac9196f28aff93e68.js → 93d06a1a0b700ddb3807.js} +1 -1
  13. package/assets/esri/core/workers/chunks/b28b699de6deb7e9fa53.js +1 -0
  14. package/assets/esri/core/workers/chunks/{1a5f96b1b892ecceb36a.js → b4a1f3f3a036226d6810.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{738e4f46feb3758456e0.js → baa9fd23414f03ef90bc.js} +1 -1
  16. package/assets/esri/core/workers/chunks/c977a47cabc419610277.js +1 -0
  17. package/assets/esri/core/workers/chunks/{7e00122014d0a55363a8.js → ccb289911e7445b17763.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{e2029267cddb8e2effab.js → d58fae2fc9d148e015ae.js} +1 -1
  19. package/core/sql/WhereClause.js +1 -1
  20. package/core/typedArrayUtil.js +1 -1
  21. package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
  22. package/geometry/Polygon.js +1 -1
  23. package/geometry/support/buffer/BufferView.js +1 -1
  24. package/geometry/support/buffer/internals/Vec2.js +1 -1
  25. package/interfaces.d.ts +112 -27
  26. package/layers/graphics/data/QueryEngineResult.js +1 -1
  27. package/layers/support/VideoElement.js +1 -1
  28. package/package.json +1 -1
  29. package/support/revision.js +1 -1
  30. package/symbols/support/ElevationInfo.js +1 -1
  31. package/undoredo/support/Services.js +1 -1
  32. package/views/2d/engine/vectorTiles/decluttering/CollisionJob.js +1 -1
  33. package/views/2d/engine/vectorTiles/decluttering/SymbolDeclutterer.js +1 -1
  34. package/views/2d/engine/vectorTiles/decluttering/SymbolFader.js +1 -1
  35. package/views/2d/layers/StreamLayerView2D.js +1 -1
  36. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  37. package/views/3d/environment/NoiseTextureAtlasTechnique.js +1 -1
  38. package/views/3d/environment/PrecipitationTechnique.js +1 -1
  39. package/views/3d/environment/SimpleAtmosphereTechnique.js +1 -1
  40. package/views/3d/layers/DrapedSubView3D.js +1 -1
  41. package/views/3d/layers/I3SMeshView3D.js +1 -1
  42. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  43. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  44. package/views/3d/layers/i3s/I3SBinaryReader.js +1 -1
  45. package/views/3d/layers/i3s/I3SQueryFeatureAdapter.js +1 -1
  46. package/views/3d/layers/i3s/I3SQueryFeatureStore.js +1 -1
  47. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  48. package/views/3d/layers/support/TemporalSceneLayerView.js +1 -1
  49. package/views/3d/support/buffer/InterleavedLayout.js +1 -1
  50. package/views/3d/terrain/PatchGeometry.js +1 -1
  51. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  52. package/views/3d/terrain/TerrainAttributes.js +1 -1
  53. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +3 -3
  54. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js +1 -1
  55. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  56. package/views/3d/webgl-engine/effects/haze/HazeTechnique.js +1 -1
  57. package/views/3d/webgl-engine/effects/highlight/HighlightApplyTechnique.js +1 -1
  58. package/views/3d/webgl-engine/effects/highlight/ShadowHighlightTechnique.js +1 -1
  59. package/views/3d/webgl-engine/effects/magnifier/MagnifierTechnique.js +1 -1
  60. package/views/3d/webgl-engine/effects/stars/StarsTechnique.js +1 -1
  61. package/views/3d/webgl-engine/effects/transparency/OITBlendTechnique.js +1 -1
  62. package/views/3d/webgl-engine/lib/ChangeSet.js +1 -1
  63. package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
  64. package/views/3d/webgl-engine/lib/ITexture.js +1 -1
  65. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  66. package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
  67. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  68. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  69. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  70. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  71. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  72. package/views/3d/webgl-engine/lib/TextureTechnique.js +1 -1
  73. package/views/3d/webgl-engine/lib/TextureUpdater.js +5 -0
  74. package/views/3d/webgl-engine/lib/rendererUtils.js +1 -1
  75. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  76. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  77. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  78. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  79. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  80. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  81. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  82. package/views/3d/webgl-engine/shaders/CompositingTechnique.js +1 -1
  83. package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
  84. package/views/3d/webgl-engine/shaders/HeatmapDensityTechnique.js +1 -1
  85. package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +1 -1
  86. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  87. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  88. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  89. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  90. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  91. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
  92. package/views/3d/webgl-engine/shaders/SlicePlaneMaterialTechnique.js +1 -1
  93. package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
  94. package/views/3d/webgl-engine/shaders/ViewshedTechnique.js +1 -1
  95. package/views/interactive/snapping/FeatureSnappingSourceInfo.js +1 -1
  96. package/views/layers/PointCloudLayerView.d.ts +1 -1
  97. package/views/layers/PointCloudLayerView.js +5 -0
  98. package/views/webgl/renderState.js +1 -1
  99. package/views/webgl/testFloatBufferBlend.js +1 -1
  100. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  101. package/widgets/Editor/UpdateWorkflow.js +1 -1
  102. package/widgets/Editor/workflowUtils.js +1 -1
  103. package/widgets/Editor.js +1 -1
  104. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  105. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
  106. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  107. package/widgets/FeatureForm.js +1 -1
  108. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  109. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  110. package/widgets/support/GridControls.js +1 -1
  111. package/assets/esri/core/workers/chunks/093421648cc61afdeb3c.js +0 -1
  112. package/assets/esri/core/workers/chunks/4816cf647eca2f4cecc2.js +0 -1
  113. package/assets/esri/core/workers/chunks/8725580f6d2a495051b5.js +0 -1
  114. package/assets/esri/core/workers/chunks/a56da688088404259481.js +0 -1
  115. package/assets/esri/core/workers/chunks/e6469173c65531d6524a.js +0 -1
  116. package/assets/esri/core/workers/chunks/e9e517a2141e504eec64.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as _}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as p,initial as u,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as g}from"../../../../core/time.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as b,invert as A,multiply as T}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as E,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as R}from"../../../../chunks/vec42.js";import{ZEROS as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as I,ZEROS as C}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as w}from"../../../../geometry/support/Indices.js";import{RenderCategory as O,InternalRenderCategory as N}from"../../webgl.js";import{debugFlags as D}from"../../support/debugFlags.js";import{ColorFormat as y,DepthRenderbuffer16f as x}from"../../webgl/formats.js";import{FBOCache as H,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as L}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as v,isColorOrColorEmission as U}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as F}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as G}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as q}from"../effects/RenderNodes.js";import{RenderPluginManager as V}from"../effects/RenderPluginManager.js";import{Blit as j}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as B,renderHighlightBuffer as Q}from"../effects/highlight/Highlight.js";import{OITBlend as W}from"../effects/transparency/OITBlend.js";import{AnimationTimer as k}from"./AnimationTimer.js";import{AnimationTimeStep as z}from"./AnimationTimeStep.js";import{RenderRequestType as Y}from"./basicInterfaces.js";import{BoundingInfo as X}from"./BoundingInfo.js";import{DepthRange as K}from"./DepthRange.js";import{depthRangeFromScene as J}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as Z}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as $}from"./MainFramebuffer.js";import{RenderOccludedFlag as ee}from"./Material.js";import{OITPass as te}from"./OITPass.js";import{RenderContext as re,defaultRenderOccludedMask as ie}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as se,RendererTarget as ae}from"./rendererUtils.js";import{setupFeatureDefaults as ne,RenderFeature as he}from"./RenderFeature.js";import{RenderPluginInput as oe}from"./RenderPluginInput.js";import{RenderSlot as de}from"./RenderSlot.js";import{ShadowAccumulator as _e}from"./ShadowAccumulator.js";import{ShadowMap as le,SnapshotSlot as pe}from"./ShadowMap.js";import ue from"./SliceHelper.js";import{Transparency as me}from"./edgeRendering/interfaces.js";import{MergedRenderer as ce}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as ge}from"../parts/renderUtils.js";import{RendererPerformanceInfo as fe,PerformanceCategory as be}from"../statistics/RendererPerformanceInfo.js";import{RenderState as Ae}from"../../../support/RenderState.js";import{DepthStencilAttachment as Te,PixelFormat as Ee,PixelType as Pe,FramebufferBit as Re,ColorAttachment1 as Se,ColorAttachment2 as Ie}from"../../../webgl/enums.js";class Ce{constructor(e,t,r,s,a,n){this._stage=e,this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._renderers=new Map,this.renderPassManager=new L,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=I(0,0,0,1),this._sliceHelper=new ue,this._blit=null,this._oitblend=null,this._state=c(Ae.IDLE),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new z,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=g(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new oe,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new H(s),this._renderStateFeatures=c(ne(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new $(this.fboCache),this.performanceInfo=new fe(this._rctx),this._shadowMap=new le(this.fboCache,e.viewingMode),this._shadowAccumulator=new _e(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((e,t,r)=>{const i=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,i),this._renderShadowCascades(v.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new re(this._rctx,this._shadowMap,r),this._nodes=new q(this._renderContext),this._plugins=new V({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this._handles=[l((()=>this._stage.view.state.camera),(()=>n()),p),l((()=>D.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(me.TRANSPARENT):()=>{},n()}),u),l((()=>this._stage.view.environment.background?.color),(e=>{const t=e?i(e):C;R(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),p),l((()=>this._stage.view.state.camera.relativeElevation),(e=>this._inGlobeView=(e??1/0)>=G),p),l((()=>this._bindParameters.clouds.fadeFactor),(()=>this._bindParameters.fadeLighting()),m),l((()=>this._bindParameters.clouds.data?.state),(()=>n()),m),l((()=>this._stage.view.state.highlights),(e=>{this._bindParameters.highlights=e,this._updateHighlights(),n()}),u)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._renderers.clear(),this._blit=null,this._oitblend=null,X.prune(),ce.prune(),w()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=ne(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((i=>i.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(he.HighQualityTransparency)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(he.WaterReflection))}get _hasHighlights(){return this._plugins.produces(v.Highlight,de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL,de.DRAPED_MATERIAL,de.HUD_MATERIAL,de.LABEL_MATERIAL)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(v.Highlight,de.HUD_MATERIAL,de.LABEL_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(he.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(he.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(he.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");_(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Fe(this._stage.view.resourceController)});return this._handles.push(l((()=>r.updating),(()=>this._requestRender()),m)),this._requestRender(),this._edgeViewCallbacks.forEach((e=>e(r))),this._edgeViewCallbacks.length=0,r}))),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&b(this._bindParameters.ssr.reprojectionMatrix,E)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slicePlane(e){this._sliceHelper.plane!==e&&(this._sliceHelper.plane=e,this._requestRender())}get plugins(){return this._plugins}getMaterialRenderer(e){return this._renderers.get(e)}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:i,updates:s}=e;if(0===r.length&&0===i.length&&0===s.length)return;se(e).forEach(((r,i)=>{if(t.done)return;let s=this._renderers.get(i);null==s&&r.adds.length>0&&(s=new ce({material:i,highlightOrderMap:this._stage.view.state.highlightOrderMap}),s.initializeRenderContext(this._plugins.context),this._plugins.add(s),this._renderers.set(i,s)),s&&(s.modify(r),s.updateHighlights(this._stage.view.state.highlightOrderMap),0===s.numGeometries&&(this._renderers.delete(s.material),this._plugins.remove(s),s.destroy())),r.removes.forEach((t=>e.removes.removeUnordered(t))),r.adds.forEach((t=>e.adds.removeUnordered(t))),r.updates.forEach((t=>e.updates.removeUnordered(t))),t.madeProgress()})),this.updateHasFlags()}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(v.Color,...He),has.water=this._plugins.produces(v.Normal,de.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new k(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=ae.Default,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new ge(this._pluginInput.get(O.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:_}=Z,l=this._stage.view,p=l.stateManager.camera,u=l.qualitySettings.fadeDuration,m=e===Ae.IDLE?r:i,c=s((p.tilt-h)/(o-h),0,1),g=s(((p.position.z??0)-d)/(_-d),0,1),f=a(a(1,m,c),1,g),b=this._bindParameters.hudOccludedFragmentOpacity;if(u<=0||b===f||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=f,void(this._lastFrameTime=t);const A=t-this._lastFrameTime;this._lastFrameTime=t;const T=Math.max(1-r,Math.abs(r-i)),E=Math.min(T*A/u,n);E>=Math.abs(f-b)?this._bindParameters.hudOccludedFragmentOpacity=f:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(f-b)*E,this._requestRender())}_render(e,t,r=ae.Default,i){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===ae.Default,this._disposeBindBuffers();const{camera:s,contentCamera:a,mode:n,alignPixelEnabled:h}=e;this._state.value=n;const o=this._nodes.produces("magnifier-color"),_=this._nodes.produces(O.FINAL),l=this._nodes.require("emissive",N.TRANSPARENT_ENVIRONMENT,O.COMPOSITE,O.FINAL)>0&&this._plugins.hasEmissions,p=l?v.ColorEmission:v.Color;this._renderContext.time=t,this._renderContext.output=p,this._bindParameters.oitPass=te.NONE,this._bindParameters.alignPixelEnabled=h,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null,this._bindParameters.slicePlane=this._sliceHelper.plane,this._bindParameters.viewshedEnabled=this._nodes.produces(N.VIEWSHED),this._renderOverlay(t),s.setGLViewport(this._rctx);const u=this._framebuffer,m=u.initialize(s.fullWidth,s.fullHeight,this._backgroundColor,l);this.hasReflections?(m?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=m):m?.release(),this._ensureBindParametersCamera(s,a),this._updateHUDOccludedFragmentOpacity(n,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const c=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(v.Color,...ye);this._precompilePrepasses(),this.performanceInfo.advance(be.PREPARE);const f=this._computeDepthRange(s);this._renderShadowMap(s,this._bindParameters.lighting.mainLight.direction,f),this._ensureBindParametersCamera(s,a),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,s,a),this._ensureBindParametersSSR(t),this._precompileShaders(c,g,p),this._renderContext.output=p,u.bind(),this._bindParameters.mainDepth=u.depth.attachment;const b=this.plugins.produces(v.Color,...De);b&&this._renderOpaqueGeometry(),u.update((e=>this._renderNodes(O.OPAQUE,e,b))),this.fboCache.debugCallback?.(O.OPAQUE,u.color.fbo),u.update((e=>this._renderNodes(N.OPAQUE_ENVIRONMENT,e))),this.fboCache.debugCallback?.(N.OPAQUE_ENVIRONMENT,u.color.fbo),this._renderTerrainDepth(c),this._renderEdges(me.OPAQUE),u.bind(),this._renderPlugins(de.VOXEL,be.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOIT(we.Geometry,p):this._renderTransparentGeometry()),u.update((e=>this._renderNodes(O.TRANSPARENT,e,g))),this.fboCache.debugCallback?.(O.TRANSPARENT,u.color.fbo),this._renderGeometryDepth(c),this._renderHUDVisibility(),c||this._plugins.render(this._pluginInput,de.LINE_CALLOUTS),this._renderEdges(me.TRANSPARENT);const A=this._hasTransparentTerrain?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(be.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(F.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,A.getTexture())),this._renderHUD(F.Occluded,u.color,p))),this._bindParameters.cullAboveTerrain=!1,A&&(u.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,A.getTexture()),A.release(),c&&(this._renderEdges(me.OPAQUE),g&&(this._oitEnabled?this._renderOIT(we.Geometry,p):this._renderTransparentGeometry(),this.performanceInfo.advance(be.TRANSPARENT)),this._renderEdges(me.TRANSPARENT))),this._bindParameters.ssao=d(this._bindParameters.ssao),c&&this._renderLineCallouts(F.NotOccluded),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment(),this._pluginInput.set(N.FOCUSAREA,this._renderFocusAreaGeometry()),u.update((e=>this._renderNodes(N.TRANSPARENT_ENVIRONMENT,e))),u.update((e=>this._renderNodes(N.VIEWSHED,e))),u.update((e=>this._renderNodes(N.LASERLINES,e))),u.update((e=>this._renderNodes(N.FOCUSAREA_COLOR,e))),u.update((e=>this._renderNodes(N.OCCLUDED,e))),this._pluginInput.set("highlights",this._renderHighlightPrepass());const T=r===ae.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;u.update((e=>this._renderNodes(O.COMPOSITE,e))),this._pluginInput.release(N.FOCUSAREA);const E=!(r!==ae.Default||_||o&&!i),P=this._pluginInput.get(O.COMPOSITE),R=E?M:this.fboCache.acquire(P.fbo.width,P.fbo.height,N.ANTIALIASING),S=this._nodes.produces(N.ANTIALIASING)?this._renderNodes(N.ANTIALIASING,R):this._blitFBO(P,R,!1);let I;this._pluginInput.set(N.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(F.NotOccluded,S,p),I=this._renderNodes(N.HIGHLIGHTS,S)):(I=this._renderNodes(N.HIGHLIGHTS,S),this._renderHUD(F.NotOccluded,I,p));const C=this._renderNodes(N.MAGNIFIER,I);return o&&!i&&r===ae.Default&&!_&&this._blitFBO(C),_?(C.attachDepth(u.depth),this._blitFBO(this._renderNodes(O.FINAL,C)),C.detachDepth()):this._pluginInput.set(O.FINAL,C),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),u.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ae.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),new ge(this._pluginInput.get(O.FINAL),T)}_precompileShaders(e,t,r){++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._nodes.precompile(N.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=v.Depth,this._plugins.precompile(de.TRANSPARENT_TERRAIN),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(de.TRANSPARENT_TERRAIN),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(N.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(de.OCCLUSION_PIXELS),this._plugins.precompile(de.LINE_CALLOUTS),this._precompileHUD(F.Occluded),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(N.VIEWSHED,N.LASERLINES,N.FOCUSAREA_COLOR,N.OCCLUDED,N.ANTIALIASING,N.HIGHLIGHTS);const i=this._bindParameters;i.highlightMixTexture=i.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(F.NotOccluded),this._hasHighlights&&(i.highlights.forEach(((e,t)=>{i.highlightLevel=t,this._precompileAllGeometry(v.Highlight)})),i.highlightLevel=null),i.highlightMixTexture=null,this._nodes.precompile(O.COMPOSITE,N.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),--this._plugins.context.techniques.precompiling}_updateHighlights(){const e=this._stage.view.state;this._renderers.forEach((t=>t.updateHighlights(e.highlightOrderMap)))}_renderFocusAreaGeometry(){if(!this._nodes.produces(N.FOCUSAREA))return null;const{width:e,height:t}=this._framebufferSize;let r=this.fboCache.acquire(e,t,N.FOCUSAREA);return r=this._nodes.render(r,this._pluginInput),this.performanceInfo.advance(be.FOCUS_AREA_MASK),r}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(Te),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(be.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===Y.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear-depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(C),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],Ee.RGBA,Pe.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,Ee.RGBA,Pe.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=()=>t.render(this._bindParameters,e),a=this._bindParameters.geometryDepth;this.renderToTargets(s,i,a??this._framebuffer.depth,C),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(e===me.OPAQUE?be.OPAQUE_EDGES:be.TRANSPARENT_EDGES)}_renderOverlay(e){this._bindParameters.overlay=this.overlay?.render(e),this._bindParameters.overlay&&this.performanceInfo.advance(be.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(he.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(v.ShadowHighlight,this._shadowMap),i.moveSnapshot(pe.Highlight),this._renderShadowCascades(v.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(pe.ExcludeHighlight),this._renderShadowCascades(v.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(v.Shadow),i.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(be.SHADOW_MAP)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(v.Depth)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._needsShadowAccumulation||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");if(e){const t=this._needsDepth?e.getAttachment(Te):null;t?.retain(),this._pluginInput.set(N.SSAO,this._renderSSAO()),this._renderGeometryWithoutNormalsDepth(t)}else this._renderAllGeometryDepth()}_renderGeometryWithoutNormalsDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=d(this._bindParameters.depth));const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"depth");r.attachDepth(e),e.release(),this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(Re.STENCIL),this._renderGeometryWithoutNormals(v.Depth),d(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(be.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"depth").acquireDepth(Te);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this.renderAllGeometry(v.Depth),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(be.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=v.Depth;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth").acquireDepth(Te);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this._renderTransparentTerrain(),d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth").acquireDepth(Te);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this._renderOpaqueAndTransparentGeometry(v.Depth),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowAccumulation}_computeDepthRange(e){if(!this._needsDepthRange)return K.zero;const t=J(e,this._plugins.plugins,this._stage.layers);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}get _normalsRequired(){const e=this._nodes.require("normals",O.FINAL,O.COMPOSITE,O.OPAQUE,O.TRANSPARENT,N.VIEWSHED,N.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(v.Normal),this._needsDepth&&this._precompileAllGeometry(v.Depth),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(v.ShadowHighlight),this._precompileShadowCascades(v.ShadowExcludeHighlight),this._precompileShadowCascades(v.ShadowHighlight)):this._precompileShadowCascades(v.Shadow)),this._needsShadowAccumulation&&this._precompileAllGeometry(v.Shadow)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",y.RGBA8);r.acquireDepth(Te),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(C,!0,!0),this._renderGeometryWithNormals(v.Normal);const i=this._nodes.optional("normals",O.FINAL,O.COMPOSITE,O.OPAQUE,O.TRANSPARENT,N.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(be.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();M.setName(N.SSAO);const t=this._nodes.render(M,this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(be.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(de.TRANSPARENT_TERRAIN),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...xe);this._renderContext.renderOccludedMask=ie}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll((e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t,this._pluginInput)}))}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>ee.Occlude&&this._plugins.render(this._pluginInput,de.OCCLUDED_TERRAIN),this.renderSlots(e,...xe),this._renderContext.renderOccludedMask=ie}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,de.HUD_MATERIAL)}precompileViewshedShadowMap(){this._precompileAllGeometry(v.ViewshedShadow)}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(v.ViewshedShadow),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Oe),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Ne)}_precompileOpaqueGeometry(){this._plugins.precompile(...De)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...De)}_renderTransparentGeometry(){this._plugins.render(this._pluginInput,...ye)}get _hasTransparentTerrain(){return this._plugins.produces(v.Color,de.TRANSPARENT_TERRAIN)}_renderTransparentTerrain(){const e=()=>this._plugins.render(this._pluginInput,de.TRANSPARENT_TERRAIN);if(!U(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,C),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,de.OCCLUSION_PIXELS)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",y.RGBA4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(this._pluginInput,de.OCCLUSION_PIXELS),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(be.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===F.Occluded){const e=()=>this._plugins.render(this._pluginInput,de.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(x,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(this._pluginInput,de.LINE_CALLOUTS)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=v.Highlight,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&U(this._renderContext.output)?(this._bindParameters.oitPass=te.ColorAlpha,this._plugins.precompile(...He),this._bindParameters.oitPass=te.FrontFace,this._plugins.precompile(...He),this._bindParameters.oitPass=te.NONE):this._plugins.precompile(...He),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(we.HUD,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,e===F.Occluded){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(x,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(x),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===F.Occluded?be.HUD_OCCLUDED:be.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,...He)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(v.ShadowHighlight,de.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>B?y.RG8UI:y.R8UI);a.acquireDepth(Te),t.bindFramebuffer(a.fbo);const{gl:n}=t;return n.clearBufferuiv(n.COLOR,0,[0,0,0,0]),this._renderContext.output=v.Highlight,t.bindFramebuffer(a.fbo),Q(t,e,i,r,(()=>this._renderHighlightGeometries())),this.performanceInfo.advance(be.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(this._pluginInput,...Me),this._rctx.clear(Re.DEPTH),this._renderHUDElements(F.Both)}get _needsShadowAccumulation(){return this._shadowAccumulator.accumulating}_renderShadowAccumulation(e,t,r){this._needsShadowAccumulation&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(be.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&U(this._renderContext.output)?(this._bindParameters.oitPass=te.ColorAlpha,this._plugins.precompile(...ye),this._bindParameters.oitPass=te.FrontFace,this._plugins.precompile(...ye),this._bindParameters.oitPass=te.NONE):this._plugins.precompile(...ye)}_renderOIT(e,t,r=F.Both){const i=e===we.HUD,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=te.ColorAlpha;const d=a?"oit hud color+alpha":"oit color+alpha",_=this.fboCache.acquire(s.width,s.height,d,y.RGBA16F),l=t===v.ColorEmission;l&&_.acquireColor(Se,y.RGBA16F,"emissive"),_.acquireColor(l?Ie:Se,y.R16F),a||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,S),n(),_.detachDepth(),h.oitPass=te.FrontFace;const p=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return l&&p.acquireColor(Se,y.RGBA16F,"emissive"),a?p.acquireDepth(x):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(C,!!a),n(),p.detachDepth(),h.oitPass=te.NONE,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(Re.COLOR)):this._framebuffer.bind(),this._oitblend??=new W(this._techniques),this._oitblend.blend(this._rctx,_,p,h,l),a?.detachDepth(),p.release(),_.release(),this._renderContext.output=o,a}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(be.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(this._pluginInput,de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),this.performanceInfo.advance(be.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}_blitFBO(e,t=M,r=!0){return this._blit??=new j(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=E:(A(ve,this._bindParameters.camera.viewMatrix),A(Le,this._bindParameters.camera.projectionMatrix),T(Ue,ve,Le),T(Ue,this._renderContext.lastFrameCamera.viewMatrix,Ue),T(Ue,this._renderContext.lastFrameCamera.projectionMatrix,Ue),this._reprojectionMatrix=Ue);const t=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=E,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(Y.UPDATE)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}}var we;e([f({readOnly:!0})],Ce.prototype,"fullResolutionAtmosphere",null),e([f()],Ce.prototype,"_edgeView",void 0),e([f()],Ce.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(we||(we={}));const Oe=[de.INTEGRATED_MESH,de.OPAQUE_TERRAIN,de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL],Ne=[de.OPAQUE_MATERIAL_WITHOUT_NORMALS,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],De=[de.INTEGRATED_MESH,de.OPAQUE_TERRAIN,de.OPAQUE_MATERIAL,de.OPAQUE_MATERIAL_WITHOUT_NORMALS],ye=[de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],xe=[de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH],He=[de.LINE_CALLOUTS_HUD_DEPTH,de.HUD_MATERIAL,de.LABEL_MATERIAL],Me=[de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,de.OPAQUE_MATERIAL,de.OPAQUE_MATERIAL_WITHOUT_NORMALS,de.TRANSPARENT_TERRAIN,de.INTEGRATED_MESH,de.OPAQUE_TERRAIN],Le=P(),ve=P(),Ue=P();function Fe(e){return t=>e.immediate.schedule(t)}export{Ce as Renderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as _}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as p,initial as u,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as g}from"../../../../core/time.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as b,invert as A,multiply as T}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as E,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as R}from"../../../../chunks/vec42.js";import{ZEROS as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as I,ZEROS as C}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as w}from"../../../../geometry/support/Indices.js";import{RenderCategory as O,InternalRenderCategory as N}from"../../webgl.js";import{debugFlags as D}from"../../support/debugFlags.js";import{ColorFormat as y,DepthRenderbuffer16f as x}from"../../webgl/formats.js";import{FBOCache as H,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as L}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as F,isColorOrColorEmission as U}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as v}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as G}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as q}from"../effects/RenderNodes.js";import{RenderPluginManager as V}from"../effects/RenderPluginManager.js";import{Blit as j}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as B,renderHighlightBuffer as Q}from"../effects/highlight/Highlight.js";import{OITBlend as W}from"../effects/transparency/OITBlend.js";import{AnimationTimer as k}from"./AnimationTimer.js";import{AnimationTimeStep as z}from"./AnimationTimeStep.js";import{RenderRequestType as Y}from"./basicInterfaces.js";import{BoundingInfo as X}from"./BoundingInfo.js";import{DepthRange as K}from"./DepthRange.js";import{depthRangeFromScene as J}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as Z}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as $}from"./MainFramebuffer.js";import{RenderOccludedFlag as ee}from"./Material.js";import{OITPass as te}from"./OITPass.js";import{RenderContext as re,defaultRenderOccludedMask as ie}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as se,RendererTarget as ae}from"./rendererUtils.js";import{setupFeatureDefaults as ne,RenderFeature as he}from"./RenderFeature.js";import{RenderPluginInput as oe}from"./RenderPluginInput.js";import{RenderSlot as de}from"./RenderSlot.js";import{ShadowAccumulator as _e}from"./ShadowAccumulator.js";import{ShadowMap as le,SnapshotSlot as pe}from"./ShadowMap.js";import ue from"./SliceHelper.js";import{Transparency as me}from"./edgeRendering/interfaces.js";import{MergedRenderer as ce}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as ge}from"../parts/renderUtils.js";import{RendererPerformanceInfo as fe,PerformanceCategory as be}from"../statistics/RendererPerformanceInfo.js";import{RenderState as Ae}from"../../../support/RenderState.js";import{DepthStencilAttachment as Te,PixelFormat as Ee,PixelType as Pe,FramebufferBit as Re,ColorAttachment1 as Se,ColorAttachment2 as Ie}from"../../../webgl/enums.js";class Ce{constructor(e,t,r,s,a,n){this._stage=e,this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._renderers=new Map,this.renderPassManager=new L,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=I(0,0,0,1),this._sliceHelper=new ue,this._blit=null,this._oitblend=null,this._state=c(Ae.IDLE),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new z,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=g(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new oe,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new H(s),this._renderStateFeatures=c(ne(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new $(this.fboCache),this.performanceInfo=new fe(this._rctx),this._shadowMap=new le(this.fboCache,e.viewingMode),this._shadowAccumulator=new _e(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((e,t,r)=>{const i=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,i),this._renderShadowCascades(F.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new re(this._rctx,this._shadowMap,r),this._nodes=new q(this._renderContext),this._plugins=new V({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this._handles=[l((()=>this._stage.view.state.camera),(()=>n()),p),l((()=>D.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(me.TRANSPARENT):()=>{},n()}),u),l((()=>this._stage.view.environment.background?.color),(e=>{const t=e?i(e):C;R(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),p),l((()=>this._stage.view.state.camera.relativeElevation),(e=>this._inGlobeView=(e??1/0)>=G),p),l((()=>this._bindParameters.clouds.fadeFactor),(()=>this._bindParameters.fadeLighting()),m),l((()=>this._bindParameters.clouds.data?.state),(()=>n()),m),l((()=>this._stage.view.state.highlights),(e=>{this._bindParameters.highlights=e,this._updateHighlights(),n()}),u)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._renderers.clear(),this._blit=null,this._oitblend=null,X.prune(),ce.prune(),w()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=ne(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((i=>i.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(he.HighQualityTransparency)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(he.WaterReflection))}get _hasHighlights(){return this._plugins.produces(F.Highlight,de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL,de.DRAPED_MATERIAL,de.HUD_MATERIAL,de.LABEL_MATERIAL)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(F.Highlight,de.HUD_MATERIAL,de.LABEL_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(he.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(he.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(he.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");_(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:ve(this._stage.view.resourceController)});return this._handles.push(l((()=>r.updating),(()=>this._requestRender()),m)),this._requestRender(),this._edgeViewCallbacks.forEach((e=>e(r))),this._edgeViewCallbacks.length=0,r}))),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&b(this._bindParameters.ssr.reprojectionMatrix,E)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slicePlane(e){this._sliceHelper.plane!==e&&(this._sliceHelper.plane=e,this._requestRender())}get plugins(){return this._plugins}getMaterialRenderer(e){return this._renderers.get(e)}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:i,updates:s}=e;if(0===r.length&&0===i.length&&0===s.length)return;se(e).forEach(((e,r)=>{if(t.done)return;let i=this._renderers.get(r);null==i&&e.adds.length>0&&(i=new ce({material:r,highlightOrderMap:this._stage.view.state.highlightOrderMap}),i.initializeRenderContext(this._plugins.context),this._plugins.add(i),this._renderers.set(r,i)),i?(i.modify(e,t),i.updateHighlights(this._stage.view.state.highlightOrderMap),0===i.numGeometries&&(this._renderers.delete(i.material),this._plugins.remove(i),i.destroy())):(e.clear(),t.madeProgress())})),this.updateHasFlags()}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(F.Color,...He),has.water=this._plugins.produces(F.Normal,de.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new k(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=ae.Default,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new ge(this._pluginInput.get(O.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:_}=Z,l=this._stage.view,p=l.stateManager.camera,u=l.qualitySettings.fadeDuration,m=e===Ae.IDLE?r:i,c=s((p.tilt-h)/(o-h),0,1),g=s(((p.position.z??0)-d)/(_-d),0,1),f=a(a(1,m,c),1,g),b=this._bindParameters.hudOccludedFragmentOpacity;if(u<=0||b===f||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=f,void(this._lastFrameTime=t);const A=t-this._lastFrameTime;this._lastFrameTime=t;const T=Math.max(1-r,Math.abs(r-i)),E=Math.min(T*A/u,n);E>=Math.abs(f-b)?this._bindParameters.hudOccludedFragmentOpacity=f:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(f-b)*E,this._requestRender())}_render(e,t,r=ae.Default,i){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===ae.Default,this._disposeBindBuffers();const{camera:s,contentCamera:a,mode:n,alignPixelEnabled:h}=e;this._state.value=n;const o=this._nodes.produces("magnifier-color"),_=this._nodes.produces(O.FINAL),l=this._nodes.require("emissive",N.TRANSPARENT_ENVIRONMENT,O.COMPOSITE,O.FINAL)>0&&this._plugins.hasEmissions,p=l?F.ColorEmission:F.Color;this._renderContext.time=t,this._renderContext.output=p,this._bindParameters.oitPass=te.NONE,this._bindParameters.alignPixelEnabled=h,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null,this._bindParameters.slicePlane=this._sliceHelper.plane,this._bindParameters.viewshedEnabled=this._nodes.produces(N.VIEWSHED),this._renderOverlay(t),s.setGLViewport(this._rctx);const u=this._framebuffer,m=u.initialize(s.fullWidth,s.fullHeight,this._backgroundColor,l);this.hasReflections?(m?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=m):m?.release(),this._ensureBindParametersCamera(s,a),this._updateHUDOccludedFragmentOpacity(n,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const c=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(F.Color,...ye);this._precompilePrepasses(),this.performanceInfo.advance(be.PREPARE);const f=this._computeDepthRange(s);this._renderShadowMap(s,this._bindParameters.lighting.mainLight.direction,f),this._ensureBindParametersCamera(s,a),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,s,a),this._ensureBindParametersSSR(t),this._precompileShaders(c,g,p),this._renderContext.output=p,u.bind(),this._bindParameters.mainDepth=u.depth.attachment;const b=this.plugins.produces(F.Color,...De);b&&this._renderOpaqueGeometry(),u.update((e=>this._renderNodes(O.OPAQUE,e,b))),this.fboCache.debugCallback?.(O.OPAQUE,u.color.fbo),u.update((e=>this._renderNodes(N.OPAQUE_ENVIRONMENT,e))),this.fboCache.debugCallback?.(N.OPAQUE_ENVIRONMENT,u.color.fbo),this._renderTerrainDepth(c),this._renderEdges(me.OPAQUE),u.bind(),this._renderPlugins(de.VOXEL,be.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOIT(we.Geometry,p):this._renderTransparentGeometry()),u.update((e=>this._renderNodes(O.TRANSPARENT,e,g))),this.fboCache.debugCallback?.(O.TRANSPARENT,u.color.fbo),this._renderGeometryDepth(c),this._renderHUDVisibility(),c||this._plugins.render(this._pluginInput,de.LINE_CALLOUTS),this._renderEdges(me.TRANSPARENT);const A=this._hasTransparentTerrain?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(be.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(v.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,A.getTexture())),this._renderHUD(v.Occluded,u.color,p))),this._bindParameters.cullAboveTerrain=!1,A&&(u.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,A.getTexture()),A.release(),c&&(this._renderEdges(me.OPAQUE),g&&(this._oitEnabled?this._renderOIT(we.Geometry,p):this._renderTransparentGeometry(),this.performanceInfo.advance(be.TRANSPARENT)),this._renderEdges(me.TRANSPARENT))),this._bindParameters.ssao=d(this._bindParameters.ssao),c&&this._renderLineCallouts(v.NotOccluded),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment(),this._pluginInput.set(N.FOCUSAREA,this._renderFocusAreaGeometry()),u.update((e=>this._renderNodes(N.TRANSPARENT_ENVIRONMENT,e))),u.update((e=>this._renderNodes(N.VIEWSHED,e))),u.update((e=>this._renderNodes(N.LASERLINES,e))),u.update((e=>this._renderNodes(N.FOCUSAREA_COLOR,e))),u.update((e=>this._renderNodes(N.OCCLUDED,e))),this._pluginInput.set("highlights",this._renderHighlightPrepass());const T=r===ae.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;u.update((e=>this._renderNodes(O.COMPOSITE,e))),this._pluginInput.release(N.FOCUSAREA);const E=!(r!==ae.Default||_||o&&!i),P=this._pluginInput.get(O.COMPOSITE),R=E?M:this.fboCache.acquire(P.fbo.width,P.fbo.height,N.ANTIALIASING),S=this._nodes.produces(N.ANTIALIASING)?this._renderNodes(N.ANTIALIASING,R):this._blitFBO(P,R,!1);let I;this._pluginInput.set(N.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(v.NotOccluded,S,p),I=this._renderNodes(N.HIGHLIGHTS,S)):(I=this._renderNodes(N.HIGHLIGHTS,S),this._renderHUD(v.NotOccluded,I,p));const C=this._renderNodes(N.MAGNIFIER,I);return o&&!i&&r===ae.Default&&!_&&this._blitFBO(C),_?(C.attachDepth(u.depth),this._blitFBO(this._renderNodes(O.FINAL,C)),C.detachDepth()):this._pluginInput.set(O.FINAL,C),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),u.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ae.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),new ge(this._pluginInput.get(O.FINAL),T)}_precompileShaders(e,t,r){++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._nodes.precompile(N.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=F.Depth,this._plugins.precompile(de.TRANSPARENT_TERRAIN),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(de.TRANSPARENT_TERRAIN),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(N.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(de.OCCLUSION_PIXELS),this._plugins.precompile(de.LINE_CALLOUTS),this._precompileHUD(v.Occluded),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(N.VIEWSHED,N.LASERLINES,N.FOCUSAREA_COLOR,N.OCCLUDED,N.ANTIALIASING,N.HIGHLIGHTS);const i=this._bindParameters;i.highlightMixTexture=i.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(v.NotOccluded),this._hasHighlights&&(i.highlights.forEach(((e,t)=>{i.highlightLevel=t,this._precompileAllGeometry(F.Highlight)})),i.highlightLevel=null),i.highlightMixTexture=null,this._nodes.precompile(O.COMPOSITE,N.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),--this._plugins.context.techniques.precompiling}_updateHighlights(){const e=this._stage.view.state;this._renderers.forEach((t=>t.updateHighlights(e.highlightOrderMap)))}_renderFocusAreaGeometry(){if(!this._nodes.produces(N.FOCUSAREA))return null;const{width:e,height:t}=this._framebufferSize;let r=this.fboCache.acquire(e,t,N.FOCUSAREA);return r=this._nodes.render(r,this._pluginInput),this.performanceInfo.advance(be.FOCUS_AREA_MASK),r}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(Te),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(be.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===Y.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear-depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(C),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],Ee.RGBA,Pe.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,Ee.RGBA,Pe.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=()=>t.render(this._bindParameters,e),a=this._bindParameters.geometryDepth;this.renderToTargets(s,i,a??this._framebuffer.depth,C),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(e===me.OPAQUE?be.OPAQUE_EDGES:be.TRANSPARENT_EDGES)}_renderOverlay(e){this._bindParameters.overlay=this.overlay?.render(e),this._bindParameters.overlay&&this.performanceInfo.advance(be.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(he.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(F.ShadowHighlight,this._shadowMap),i.moveSnapshot(pe.Highlight),this._renderShadowCascades(F.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(pe.ExcludeHighlight),this._renderShadowCascades(F.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(F.Shadow),i.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(be.SHADOW_MAP)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(F.Depth)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._needsShadowAccumulation||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");if(e){const t=this._needsDepth?e.getAttachment(Te):null;t?.retain(),this._pluginInput.set(N.SSAO,this._renderSSAO()),this._renderGeometryWithoutNormalsDepth(t)}else this._renderAllGeometryDepth()}_renderGeometryWithoutNormalsDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=d(this._bindParameters.depth));const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"depth");r.attachDepth(e),e.release(),this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(Re.STENCIL),this._renderGeometryWithoutNormals(F.Depth),d(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(be.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"depth").acquireDepth(Te);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this.renderAllGeometry(F.Depth),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(be.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=F.Depth;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth").acquireDepth(Te);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this._renderTransparentTerrain(),d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth").acquireDepth(Te);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(Re.DEPTH|Re.STENCIL),this._renderOpaqueAndTransparentGeometry(F.Depth),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowAccumulation}_computeDepthRange(e){if(!this._needsDepthRange)return K.zero;const t=J(e,this._plugins.plugins,this._stage.layers);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}get _normalsRequired(){const e=this._nodes.require("normals",O.FINAL,O.COMPOSITE,O.OPAQUE,O.TRANSPARENT,N.VIEWSHED,N.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(F.Normal),this._needsDepth&&this._precompileAllGeometry(F.Depth),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(F.ShadowHighlight),this._precompileShadowCascades(F.ShadowExcludeHighlight),this._precompileShadowCascades(F.ShadowHighlight)):this._precompileShadowCascades(F.Shadow)),this._needsShadowAccumulation&&this._precompileAllGeometry(F.Shadow)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",y.RGBA8);r.acquireDepth(Te),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(C,!0,!0),this._renderGeometryWithNormals(F.Normal);const i=this._nodes.optional("normals",O.FINAL,O.COMPOSITE,O.OPAQUE,O.TRANSPARENT,N.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(be.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();M.setName(N.SSAO);const t=this._nodes.render(M,this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(be.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(de.TRANSPARENT_TERRAIN),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...xe);this._renderContext.renderOccludedMask=ie}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll((e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t,this._pluginInput)}))}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>ee.Occlude&&this._plugins.render(this._pluginInput,de.OCCLUDED_TERRAIN),this.renderSlots(e,...xe),this._renderContext.renderOccludedMask=ie}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,de.HUD_MATERIAL)}precompileViewshedShadowMap(){this._precompileAllGeometry(F.ViewshedShadow)}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(F.ViewshedShadow),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Oe),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Ne)}_precompileOpaqueGeometry(){this._plugins.precompile(...De)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...De)}_renderTransparentGeometry(){this._plugins.render(this._pluginInput,...ye)}get _hasTransparentTerrain(){return this._plugins.produces(F.Color,de.TRANSPARENT_TERRAIN)}_renderTransparentTerrain(){const e=()=>this._plugins.render(this._pluginInput,de.TRANSPARENT_TERRAIN);if(!U(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,C),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,de.OCCLUSION_PIXELS)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",y.RGBA4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(this._pluginInput,de.OCCLUSION_PIXELS),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(be.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===v.Occluded){const e=()=>this._plugins.render(this._pluginInput,de.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(x,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(this._pluginInput,de.LINE_CALLOUTS)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=F.Highlight,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&U(this._renderContext.output)?(this._bindParameters.oitPass=te.ColorAlpha,this._plugins.precompile(...He),this._bindParameters.oitPass=te.FrontFace,this._plugins.precompile(...He),this._bindParameters.oitPass=te.NONE):this._plugins.precompile(...He),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(we.HUD,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,e===v.Occluded){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(x,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(x),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===v.Occluded?be.HUD_OCCLUDED:be.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,...He)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(F.ShadowHighlight,de.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>B?y.RG8UI:y.R8UI);a.acquireDepth(Te),t.bindFramebuffer(a.fbo);const{gl:n}=t;return n.clearBufferuiv(n.COLOR,0,[0,0,0,0]),this._renderContext.output=F.Highlight,t.bindFramebuffer(a.fbo),Q(t,e,i,r,(()=>this._renderHighlightGeometries())),this.performanceInfo.advance(be.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(this._pluginInput,...Me),this._rctx.clear(Re.DEPTH),this._renderHUDElements(v.Both)}get _needsShadowAccumulation(){return this._shadowAccumulator.accumulating}_renderShadowAccumulation(e,t,r){this._needsShadowAccumulation&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(be.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&U(this._renderContext.output)?(this._bindParameters.oitPass=te.ColorAlpha,this._plugins.precompile(...ye),this._bindParameters.oitPass=te.FrontFace,this._plugins.precompile(...ye),this._bindParameters.oitPass=te.NONE):this._plugins.precompile(...ye)}_renderOIT(e,t,r=v.Both){const i=e===we.HUD,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=te.ColorAlpha;const d=a?"oit hud color+alpha":"oit color+alpha",_=this.fboCache.acquire(s.width,s.height,d,y.RGBA16F),l=t===F.ColorEmission;l&&_.acquireColor(Se,y.RGBA16F,"emissive"),_.acquireColor(l?Ie:Se,y.R16F),a||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,S),n(),_.detachDepth(),h.oitPass=te.FrontFace;const p=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return l&&p.acquireColor(Se,y.RGBA16F,"emissive"),a?p.acquireDepth(x):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(C,!!a),n(),p.detachDepth(),h.oitPass=te.NONE,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(Re.COLOR)):this._framebuffer.bind(),this._oitblend??=new W(this._techniques),this._oitblend.blend(this._rctx,_,p,h,l),a?.detachDepth(),p.release(),_.release(),this._renderContext.output=o,a}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(be.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(this._pluginInput,de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),this.performanceInfo.advance(be.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}_blitFBO(e,t=M,r=!0){return this._blit??=new j(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=E:(A(Fe,this._bindParameters.camera.viewMatrix),A(Le,this._bindParameters.camera.projectionMatrix),T(Ue,Fe,Le),T(Ue,this._renderContext.lastFrameCamera.viewMatrix,Ue),T(Ue,this._renderContext.lastFrameCamera.projectionMatrix,Ue),this._reprojectionMatrix=Ue);const t=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=E,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(Y.UPDATE)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}}var we;e([f({readOnly:!0})],Ce.prototype,"fullResolutionAtmosphere",null),e([f()],Ce.prototype,"_edgeView",void 0),e([f()],Ce.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(we||(we={}));const Oe=[de.INTEGRATED_MESH,de.OPAQUE_TERRAIN,de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL],Ne=[de.OPAQUE_MATERIAL_WITHOUT_NORMALS,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],De=[de.INTEGRATED_MESH,de.OPAQUE_TERRAIN,de.OPAQUE_MATERIAL,de.OPAQUE_MATERIAL_WITHOUT_NORMALS],ye=[de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],xe=[de.OPAQUE_MATERIAL,de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH],He=[de.LINE_CALLOUTS_HUD_DEPTH,de.HUD_MATERIAL,de.LABEL_MATERIAL],Me=[de.TRANSPARENT_MATERIAL,de.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,de.OPAQUE_MATERIAL,de.OPAQUE_MATERIAL_WITHOUT_NORMALS,de.TRANSPARENT_TERRAIN,de.INTEGRATED_MESH,de.OPAQUE_TERRAIN],Le=P(),Fe=P(),Ue=P();function ve(e){return t=>e.immediate.schedule(t)}export{Ce as Renderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import"../../../../core/has.js";import{someMap as t}from"../../../../core/MapUtils.js";import s from"../../../../core/PooledArray.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{a}from"../../../../chunks/sphere.js";import{OverlayTarget as d}from"../../terrain/Intersector.js";import{ShaderOutput as h}from"../core/shaderLibrary/ShaderOutput.js";import{ChangeSet as l}from"./ChangeSet.js";import{newIntersectorResult as c}from"./Intersector.js";import{StoreResults as p,IntersectorType as m}from"./IntersectorInterfaces.js";import{RenderOccludedFlag as g}from"./Material.js";import{DirtyOperation as u,DirtyState as _}from"./ModelDirtyTypes.js";import{splitRenderGeometryChangeSetByMaterial as y}from"./rendererUtils.js";import{RenderSlot as f}from"./RenderSlot.js";import{MergedRenderer as R}from"../materials/renderers/MergedRenderer.js";let G=class extends r{constructor(e){super(e),this._pending=new v,this._changes=new l,this._renderers=new Map,this._sortedRenderers=new s,this._geometries=new Map,this._hasHighlights=!1,this._hasWater=!1}destroy(){this._changes.prune(),this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._sortedRenderers.clear(),this._geometries.clear(),this._pending.clear()}get updating(){return!this._pending.empty||this._changes.updates.length>0}get rctx(){return this.rendererContext.rctx}get _materials(){return this.rendererContext.materials}get _localOriginFactory(){return this.rendererContext.localOriginFactory}get hasHighlights(){return this._hasHighlights}hasHighlight(e){return t(this._renderers,(r=>r.hasHighlight(e)))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){for(const e of this._renderers.values())if(0!==e.numGeometries&&!e.queryRenderOccludedState(g.Occlude))return!0;return!1}get isEmpty(){return!this.updating&&0===this._renderers.size&&0===this._geometries.size}getMaterialRenderer(e){return this._renderers.get(e)}get sortedRenderers(){return this._sortedRenderers}commitChanges(e){if(!this.updating)return!1;this._processAddsRemoves();const r=y(this._changes);let s=!1;return r.forEach(((r,t)=>{let i=this._renderers.get(t);!i&&r.adds.length>0&&(i=new R({material:t,highlightOrderMap:e}),i.initializeRenderContext(this.rendererContext.pluginContext,this._materials),this._renderers.set(t,i),s=!0),i&&(i.modify(r),i.updateHighlights(e),0===i.numGeometries&&(this._renderers.delete(t),i.destroy(),s=!0))})),this._changes.clear(),s&&this._updateSortedMaterialRenderers(),this._hasHighlights=t(this._renderers,(e=>{const r=e.produces.get(f.DRAPED_MATERIAL);return!!r&&r(h.Highlight)})),this._hasWater=t(this._renderers,(e=>{const r=e.produces.get(f.DRAPED_WATER);return!!r&&r(h.Normal)})),this.notifyChange("updating"),!0}updateHighlights(e){this._renderers.forEach((r=>r.updateHighlights(e)))}addGeometries(e,r){if(0===e.length)return;const t=this._validateRenderGeometries(e);for(const i of t)this._geometries.set(i.id,i);const s=this._pending.empty;for(const i of t)this._pending.adds.add(i);s&&this.notifyChange("updating"),r===u.UPDATE&&this._notifyGraphicGeometryChanged(e)}removeGeometries(e,r){const t=this._pending.empty,s=this._pending.adds;for(const i of e)s.has(i)?(this._pending.removed.add(i),s.delete(i)):this._pending.removed.has(i)||this._pending.removes.add(i),this._geometries.delete(i.id);t&&!this._pending.empty&&this.notifyChange("updating"),r===u.UPDATE&&this._notifyGraphicGeometryChanged(e)}modifyGeometries(e,r){const t=0===this._changes.updates.length;for(const s of e){const e=this._changes.updates.pushNew();e.renderGeometry=this._validateRenderGeometry(s),e.updateType=r}switch(t&&this._changes.updates.length>0&&this.notifyChange("updating"),r){case _.TRANSFORMATION:case _.GEOMETRY:return this._notifyGraphicGeometryChanged(e);case _.VISIBILITY:return this._notifyGraphicVisibilityChanged(e)}}updateAnimation(e){let r=!1;return this._sortedRenderers.forAll((t=>r=!!t.updateAnimation&&t.updateAnimation(e)||r)),r}precompile(e){return this._sortedRenderers.reduce(((r,t)=>t.precompile(e)||r),!1)}render(e){this._sortedRenderers.forAll((r=>{const t=r.acquireTechniques(e);t&&r.render(e,t)}))}intersect(e,r,t,s,i){for(const n of this._geometries.values()){if(!s(n))continue;this._intersectRenderGeometry(n,t,r,0,e,i);const o=this.rendererContext.longitudeCyclical;o&&(n.boundingSphere[0]-n.boundingSphere[3]<o.min&&this._intersectRenderGeometry(n,t,r,o.range,e,i),n.boundingSphere[0]+n.boundingSphere[3]>o.max&&this._intersectRenderGeometry(n,t,r,-o.range,e,i)),i++}return i}_updateSortedMaterialRenderers(){this._sortedRenderers.clear();let e=0;for(const r of this._renderers.values())r.drapedPriority=e++,this._sortedRenderers.push(r);this._sortedRenderers.sort(((e,r)=>r.material?.renderPriority===e.material?.renderPriority?e.drapedPriority-r.drapedPriority:(r.material?.renderPriority||0)-(e.material?.renderPriority||0)))}_processAddsRemoves(){this._changes.adds.clear(),this._changes.removes.clear(),this._changes.adds.pushArray(Array.from(this._pending.adds)),this._changes.removes.pushArray(Array.from(this._pending.removes)),this._changes.updates.filterInPlace((({renderGeometry:e})=>!this._pending.has(e))),this._pending.clear()}_intersectRenderGeometry(e,r,t,s,i,n){if(!e.visible||!e.material.visible)return;let o=0;s+=e.transformation[12],o=e.transformation[13],A[0]=t[0]-s,A[1]=t[1]-o,e.screenToWorldRatio=this.rendererContext.screenToWorldRatio,e.material.intersectDraped(e,null,i,A,((t,s,o)=>{C(r,o,n,e.material.renderPriority,i,e.layerViewUid,e.graphicUid)}),r)}_notifyGraphicGeometryChanged(e){if(null==this.drapeSource.notifyGraphicGeometryChanged)return;let r;for(const{graphicUid:t}of e)null!=t&&t!==r&&(this.drapeSource.notifyGraphicGeometryChanged(t),r=t)}_notifyGraphicVisibilityChanged(e){if(null==this.drapeSource.notifyGraphicVisibilityChanged)return;let r;for(const{graphicUid:t}of e)null!=t&&t!==r&&(this.drapeSource.notifyGraphicVisibilityChanged(t),r=t)}_validateRenderGeometries(e){for(const r of e)this._validateRenderGeometry(r);return e}_validateRenderGeometry(e){return null==e.localOrigin&&(e.localOrigin=this._localOriginFactory.getOrigin(a(e.boundingSphere))),e}get test(){}};e([i()],G.prototype,"drapeSource",void 0),e([i()],G.prototype,"updating",null),e([i()],G.prototype,"rctx",null),e([i({constructOnly:!0})],G.prototype,"rendererContext",void 0),e([i()],G.prototype,"_materials",null),e([i()],G.prototype,"_localOriginFactory",null),e([i({readOnly:!0})],G.prototype,"isEmpty",null),e([i()],G.prototype,"_renderers",void 0),e([i()],G.prototype,"_geometries",void 0),G=e([n("esri.views.3d.webgl-engine.lib.SortedRenderGeometryRenderer")],G);class v{constructor(){this.adds=new Set,this.removes=new Set,this.removed=new Set}get empty(){return 0===this.adds.size&&0===this.removes.size&&0===this.removed.size}has(e){return this.adds.has(e)||this.removes.has(e)||this.removed.has(e)}clear(){this.adds.clear(),this.removes.clear(),this.removed.clear()}}function C(e,r,t,s,i,n,o){const a=new d(n,o,r),h=r=>{r.set(m.OVERLAY,a,e.dist,e.normal,e.transformation,t,s)};if((null==i.results.min.drapedLayerOrder||t>=i.results.min.drapedLayerOrder)&&(null==i.results.min.dist||i.results.ground.dist<=i.results.min.dist)&&h(i.results.min),i.options.store!==p.MIN&&(null==i.results.max.drapedLayerOrder||t<i.results.max.drapedLayerOrder)&&(null==i.results.max.dist||i.results.ground.dist>i.results.max.dist)&&h(i.results.max),i.options.store===p.ALL){const e=c(i.ray);h(e),i.results.all.push(e)}}const A=o();export{G as SortedRenderGeometryRenderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import"../../../../core/has.js";import{someMap as t}from"../../../../core/MapUtils.js";import s from"../../../../core/PooledArray.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{a}from"../../../../chunks/sphere.js";import{OverlayTarget as d}from"../../terrain/Intersector.js";import{ShaderOutput as h}from"../core/shaderLibrary/ShaderOutput.js";import{ChangeSet as l}from"./ChangeSet.js";import{newIntersectorResult as c}from"./Intersector.js";import{StoreResults as p,IntersectorType as m}from"./IntersectorInterfaces.js";import{RenderOccludedFlag as g}from"./Material.js";import{DirtyOperation as u,DirtyState as _}from"./ModelDirtyTypes.js";import{splitRenderGeometryChangeSetByMaterial as y}from"./rendererUtils.js";import{RenderSlot as f}from"./RenderSlot.js";import{MergedRenderer as R}from"../materials/renderers/MergedRenderer.js";import{noBudget as G}from"../../../support/Scheduler.js";let v=class extends r{constructor(e){super(e),this._pending=new C,this._changes=new l,this._renderers=new Map,this._sortedRenderers=new s,this._geometries=new Map,this._hasHighlights=!1,this._hasWater=!1}destroy(){this._changes.prune(),this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._sortedRenderers.clear(),this._geometries.clear(),this._pending.clear()}get updating(){return!this._pending.empty||this._changes.updates.length>0}get rctx(){return this.rendererContext.rctx}get _materials(){return this.rendererContext.materials}get _localOriginFactory(){return this.rendererContext.localOriginFactory}get hasHighlights(){return this._hasHighlights}hasHighlight(e){return t(this._renderers,(r=>r.hasHighlight(e)))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){for(const e of this._renderers.values())if(0!==e.numGeometries&&!e.queryRenderOccludedState(g.Occlude))return!0;return!1}get isEmpty(){return!this.updating&&0===this._renderers.size&&0===this._geometries.size}getMaterialRenderer(e){return this._renderers.get(e)}get sortedRenderers(){return this._sortedRenderers}commitChanges(e){if(!this.updating)return!1;this._processAddsRemoves();const r=y(this._changes);let s=!1;return r.forEach(((r,t)=>{let i=this._renderers.get(t);!i&&r.adds.length>0&&(i=new R({material:t,highlightOrderMap:e}),i.initializeRenderContext(this.rendererContext.pluginContext,this._materials),this._renderers.set(t,i),s=!0),i?(i.modify(r,G),i.updateHighlights(e),0===i.numGeometries&&(this._renderers.delete(t),i.destroy(),s=!0)):r.clear()})),this._changes.clear(),s&&this._updateSortedMaterialRenderers(),this._hasHighlights=t(this._renderers,(e=>{const r=e.produces.get(f.DRAPED_MATERIAL);return!!r&&r(h.Highlight)})),this._hasWater=t(this._renderers,(e=>{const r=e.produces.get(f.DRAPED_WATER);return!!r&&r(h.Normal)})),this.notifyChange("updating"),!0}updateHighlights(e){this._renderers.forEach((r=>r.updateHighlights(e)))}addGeometries(e,r){if(0===e.length)return;const t=this._validateRenderGeometries(e);for(const i of t)this._geometries.set(i.id,i);const s=this._pending.empty;for(const i of t)this._pending.adds.add(i);s&&this.notifyChange("updating"),r===u.UPDATE&&this._notifyGraphicGeometryChanged(e)}removeGeometries(e,r){const t=this._pending.empty,s=this._pending.adds;for(const i of e)s.has(i)?(this._pending.removed.add(i),s.delete(i)):this._pending.removed.has(i)||this._pending.removes.add(i),this._geometries.delete(i.id);t&&!this._pending.empty&&this.notifyChange("updating"),r===u.UPDATE&&this._notifyGraphicGeometryChanged(e)}modifyGeometries(e,r){const t=0===this._changes.updates.length;for(const s of e){const e=this._changes.updates.pushNew();e.renderGeometry=this._validateRenderGeometry(s),e.updateType=r}switch(t&&this._changes.updates.length>0&&this.notifyChange("updating"),r){case _.TRANSFORMATION:case _.GEOMETRY:return this._notifyGraphicGeometryChanged(e);case _.VISIBILITY:return this._notifyGraphicVisibilityChanged(e)}}updateAnimation(e){let r=!1;return this._sortedRenderers.forAll((t=>r=!!t.updateAnimation&&t.updateAnimation(e)||r)),r}precompile(e){return this._sortedRenderers.reduce(((r,t)=>t.precompile(e)||r),!1)}render(e){this._sortedRenderers.forAll((r=>{const t=r.acquireTechniques(e);t&&r.render(e,t)}))}intersect(e,r,t,s,i){for(const n of this._geometries.values()){if(!s(n))continue;this._intersectRenderGeometry(n,t,r,0,e,i);const o=this.rendererContext.longitudeCyclical;o&&(n.boundingSphere[0]-n.boundingSphere[3]<o.min&&this._intersectRenderGeometry(n,t,r,o.range,e,i),n.boundingSphere[0]+n.boundingSphere[3]>o.max&&this._intersectRenderGeometry(n,t,r,-o.range,e,i)),i++}return i}_updateSortedMaterialRenderers(){this._sortedRenderers.clear();let e=0;for(const r of this._renderers.values())r.drapedPriority=e++,this._sortedRenderers.push(r);this._sortedRenderers.sort(((e,r)=>r.material?.renderPriority===e.material?.renderPriority?e.drapedPriority-r.drapedPriority:(r.material?.renderPriority||0)-(e.material?.renderPriority||0)))}_processAddsRemoves(){this._changes.adds.clear(),this._changes.removes.clear(),this._changes.adds.pushArray(Array.from(this._pending.adds)),this._changes.removes.pushArray(Array.from(this._pending.removes)),this._changes.updates.filterInPlace((({renderGeometry:e})=>!this._pending.has(e))),this._pending.clear()}_intersectRenderGeometry(e,r,t,s,i,n){if(!e.visible||!e.material.visible)return;let o=0;s+=e.transformation[12],o=e.transformation[13],A[0]=t[0]-s,A[1]=t[1]-o,e.screenToWorldRatio=this.rendererContext.screenToWorldRatio,e.material.intersectDraped(e,null,i,A,((t,s,o)=>{S(r,o,n,e.material.renderPriority,i,e.layerViewUid,e.graphicUid)}),r)}_notifyGraphicGeometryChanged(e){if(null==this.drapeSource.notifyGraphicGeometryChanged)return;let r;for(const{graphicUid:t}of e)null!=t&&t!==r&&(this.drapeSource.notifyGraphicGeometryChanged(t),r=t)}_notifyGraphicVisibilityChanged(e){if(null==this.drapeSource.notifyGraphicVisibilityChanged)return;let r;for(const{graphicUid:t}of e)null!=t&&t!==r&&(this.drapeSource.notifyGraphicVisibilityChanged(t),r=t)}_validateRenderGeometries(e){for(const r of e)this._validateRenderGeometry(r);return e}_validateRenderGeometry(e){return null==e.localOrigin&&(e.localOrigin=this._localOriginFactory.getOrigin(a(e.boundingSphere))),e}get test(){}};e([i()],v.prototype,"drapeSource",void 0),e([i()],v.prototype,"updating",null),e([i()],v.prototype,"rctx",null),e([i({constructOnly:!0})],v.prototype,"rendererContext",void 0),e([i()],v.prototype,"_materials",null),e([i()],v.prototype,"_localOriginFactory",null),e([i({readOnly:!0})],v.prototype,"isEmpty",null),e([i()],v.prototype,"_renderers",void 0),e([i()],v.prototype,"_geometries",void 0),v=e([n("esri.views.3d.webgl-engine.lib.SortedRenderGeometryRenderer")],v);class C{constructor(){this.adds=new Set,this.removes=new Set,this.removed=new Set}get empty(){return 0===this.adds.size&&0===this.removes.size&&0===this.removed.size}has(e){return this.adds.has(e)||this.removes.has(e)||this.removed.has(e)}clear(){this.adds.clear(),this.removes.clear(),this.removed.clear()}}function S(e,r,t,s,i,n,o){const a=new d(n,o,r),h=r=>{r.set(m.OVERLAY,a,e.dist,e.normal,e.transformation,t,s)};if((null==i.results.min.drapedLayerOrder||t>=i.results.min.drapedLayerOrder)&&(null==i.results.min.dist||i.results.ground.dist<=i.results.min.dist)&&h(i.results.min),i.options.store!==p.MIN&&(null==i.results.max.drapedLayerOrder||t<i.results.max.drapedLayerOrder)&&(null==i.results.max.dist||i.results.ground.dist>i.results.max.dist)&&h(i.results.max),i.options.store===p.ALL){const e=c(i.ray);h(e),i.results.all.push(e)}}const A=o();export{v as SortedRenderGeometryRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import e from"../../../../core/Error.js";import t from"../../../../core/Evented.js";import{disposeMaybe as r,removeMaybe as s}from"../../../../core/maybe.js";import{throwIfAborted as a,onAbort as i,createAbortError as o}from"../../../../core/promiseUtils.js";import{isUint8Array as n,isArrayBuffer as l}from"../../../../core/typedArrayUtil.js";import{isBlobProtocol as m,isDataProtocol as h}from"../../../../core/urlUtils.js";import{requestImage as _}from"../../../../support/requestImageUtils.js";import{loadImageAsync as p}from"../../../../support/requestUtils.js";import{TextureEncodingMimeType as d}from"./basicInterfaces.js";import{createTextureKTX2 as c,createTextureBasis as u,estimateMemoryKTX2 as g,estimateMemoryBasis as T}from"./BasisUtil.js";import{ContentObject as A}from"./ContentObject.js";import{ContentObjectType as E}from"./ContentObjectType.js";import{createDDSTexture as f}from"./DDSUtil.js";import{ensureImageMaxSize as x}from"./textureUtils.js";import{assert as D}from"./Util.js";import{TextureWrapMode as y,TextureSamplingMode as I,PixelFormat as F}from"../../../webgl/enums.js";import{Texture as U}from"../../../webgl/Texture.js";import{TextureDescriptor as H}from"../../../webgl/TextureDescriptor.js";class N extends A{constructor(e,r){super(),this._data=e,this.type=E.Texture,this.events=new t,this._parameters={...R,...r},this._startPreload(e)}dispose(){this.unload(),this._data=this.frameUpdate=void 0}_startPreload(e){e instanceof HTMLVideoElement?(this.frameUpdate=t=>this._frameUpdate(e,t),this._startPreloadVideoElement(e)):e instanceof HTMLImageElement&&this._startPreloadImageElement(e)}_startPreloadVideoElement(e){if(!(m(e.src)||"auto"===e.preload&&e.crossOrigin)){e.preload="auto",e.crossOrigin="anonymous";const t=!e.paused;if(e.src=e.src,t&&e.autoplay){const t=()=>{e.removeEventListener("canplay",t),e.play()};e.addEventListener("canplay",t)}}}_startPreloadImageElement(e){h(e.src)||m(e.src)||e.crossOrigin||(e.crossOrigin="anonymous",e.src=e.src)}_createDescriptor(e){const t=new H;return t.wrapMode=this._parameters.wrap??y.REPEAT,t.flipped=!this._parameters.noUnpackFlip,t.samplingMode=this._parameters.mipmap?I.LINEAR_MIPMAP_LINEAR:I.LINEAR,t.hasMipmap=!!this._parameters.mipmap,t.preMultiplyAlpha=!!this._parameters.preMultiplyAlpha,t.maxAnisotropy=this._parameters.maxAnisotropy??(this._parameters.mipmap?e.parameters.maxMaxAnisotropy:1),t}get glTexture(){return this._glTexture??this._emptyTexture}get loaded(){return null!=this._glTexture}get usedMemory(){return this._glTexture?.usedMemory||w(this._data,this._parameters)}load(e){if(this._loadingPromise)return this._loadingPromise;if(this._glTexture)return this._glTexture;const t=this._data;return null==t?(this._glTexture=new U(e,this._createDescriptor(e),null),this._glTexture):(this._emptyTexture=e.emptyTexture,this._parameters.reloadable||(this._data=void 0),"string"==typeof t?this._loadFromURL(e,t):t instanceof Image?this._loadFromImageElement(e,t):t instanceof HTMLVideoElement?this._loadFromVideoElement(e,t):t instanceof ImageData||t instanceof HTMLCanvasElement?this._loadFromImage(e,t):n(t)&&this._parameters.encoding===d.DDS_ENCODING?this._loadFromDDSData(e,t):l(t)&&this._parameters.encoding===d.DDS_ENCODING?this._loadFromDDSData(e,new Uint8Array(t)):(l(t)||n(t))&&this._parameters.encoding===d.KTX2_ENCODING?this._loadFromKTX2(e,t):(l(t)||n(t))&&this._parameters.encoding===d.BASIS_ENCODING?this._loadFromBasis(e,t):n(t)?this._loadFromPixelData(e,t):l(t)?this._loadFromPixelData(e,new Uint8Array(t)):null)}_frameUpdate(e,t){return null==this._glTexture||e.readyState<M.HAVE_CURRENT_DATA||t===e.currentTime?t:(this._glTexture.setData(e),this._glTexture.descriptor.hasMipmap&&this._glTexture.generateMipmap(),this._parameters.updateCallback&&this._parameters.updateCallback(),e.currentTime)}_loadFromDDSData(e,t){return this._glTexture=f(e,this._createDescriptor(e),t),this._emptyTexture=null,this._glTexture}_loadFromKTX2(e,t){return this._loadAsync((()=>c(e,this._createDescriptor(e),t).then((e=>(this._glTexture=e,e)))))}_loadFromBasis(e,t){return this._loadAsync((()=>u(e,this._createDescriptor(e),t).then((e=>(this._glTexture=e,e)))))}_loadFromPixelData(e,t){D(this._parameters.width>0&&this._parameters.height>0);const r=this._createDescriptor(e);return r.pixelFormat=1===this._parameters.components?F.LUMINANCE:3===this._parameters.components?F.RGB:F.RGBA,r.width=this._parameters.width??0,r.height=this._parameters.height??0,this._glTexture=new U(e,r,t),this._glTexture}_loadFromURL(e,t){return this._loadAsync((async r=>{const s=await _(t,{signal:r});return a(r),this._loadFromImage(e,s)}))}_loadFromImageElement(e,t){return t.complete?this._loadFromImage(e,t):this._loadAsync((async r=>{const s=await p(t,t.src,!1,r);return a(r),this._loadFromImage(e,s)}))}_loadFromVideoElement(e,t){return t.readyState>=M.HAVE_CURRENT_DATA?this._loadFromImage(e,t):this._loadFromVideoElementAsync(e,t)}_loadFromVideoElementAsync(t,r){return this._loadAsync((a=>new Promise(((n,l)=>{const m=()=>{r.removeEventListener("loadeddata",h),r.removeEventListener("error",_),s(p)},h=()=>{r.readyState>=M.HAVE_CURRENT_DATA&&(m(),n(this._loadFromImage(t,r)))},_=t=>{m(),l(t||new e("texture","Failed to load video"))};r.addEventListener("loadeddata",h),r.addEventListener("error",_);const p=i(a,(()=>_(o())))}))))}_loadFromImage(e,t){let r=t;r instanceof HTMLVideoElement||(r=x(r,e.parameters));const s=C(r);this._parameters.width=s.width,this._parameters.height=s.height;const a=this._createDescriptor(e);return a.pixelFormat=3===this._parameters.components?F.RGB:F.RGBA,a.width=s.width,a.height=s.height,a.compressionHandle=this._parameters.compressionHandle,this._glTexture=new U(e,a,r),this._emptyTexture=null,this._glTexture}_loadAsync(e){const t=new AbortController;this._loadingController=t;const r=e(t.signal);this._loadingPromise=r;const s=()=>{this._loadingController===t&&(this._loadingController=null),this._loadingPromise===r&&(this._loadingPromise=null),this._emptyTexture=null};return r.then(s,s),r}unload(){if(this._glTexture=r(this._glTexture),this._emptyTexture=null,null!=this._loadingController){const e=this._loadingController;this._loadingController=null,this._loadingPromise=null,e.abort()}this.events.emit("unloaded")}get parameters(){return this._parameters}}function w(e,t){if(null==e)return 0;if(l(e)||n(e))return t.encoding===d.KTX2_ENCODING?g(e,!!t.mipmap):t.encoding===d.BASIS_ENCODING?T(e,!!t.mipmap):e.byteLength;const{width:r,height:s}=e instanceof Image||e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement?C(e):t;return(t.mipmap?4/3:1)*r*s*(t.components||4)||0}function C(e){return e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e}var M;!function(e){e[e.HAVE_NOTHING=0]="HAVE_NOTHING",e[e.HAVE_METADATA=1]="HAVE_METADATA",e[e.HAVE_CURRENT_DATA=2]="HAVE_CURRENT_DATA",e[e.HAVE_FUTURE_DATA=3]="HAVE_FUTURE_DATA",e[e.HAVE_ENOUGH_DATA=4]="HAVE_ENOUGH_DATA"}(M||(M={}));const R={wrap:{s:y.REPEAT,t:y.REPEAT},mipmap:!0,noUnpackFlip:!1,preMultiplyAlpha:!1};export{N as Texture};
5
+ import"../../../../core/has.js";import e from"../../../../core/Error.js";import t from"../../../../core/Evented.js";import{disposeMaybe as r,removeMaybe as s}from"../../../../core/maybe.js";import{throwIfAborted as i,onAbort as a,createAbortError as o}from"../../../../core/promiseUtils.js";import{isUint8Array as n,isArrayBuffer as l}from"../../../../core/typedArrayUtil.js";import{isBlobProtocol as m,isDataProtocol as h}from"../../../../core/urlUtils.js";import{requestImage as p}from"../../../../support/requestImageUtils.js";import{loadImageAsync as d}from"../../../../support/requestUtils.js";import{TextureEncodingMimeType as _}from"./basicInterfaces.js";import{createTextureKTX2 as u,createTextureBasis as c,estimateMemoryKTX2 as g,estimateMemoryBasis as T}from"./BasisUtil.js";import{ContentObject as E}from"./ContentObject.js";import{ContentObjectType as x}from"./ContentObjectType.js";import{createDDSTexture as y}from"./DDSUtil.js";import{ensureImageMaxSize as f}from"./textureUtils.js";import{assert as A}from"./Util.js";import{TextureWrapMode as D,TextureSamplingMode as I,PixelFormat as F}from"../../../webgl/enums.js";import{Texture as M}from"../../../webgl/Texture.js";import{TextureDescriptor as w}from"../../../webgl/TextureDescriptor.js";class L extends E{constructor(e,r){super(),this._data=e,this.type=x.Texture,this.events=new t,this._parameters={...P,...r},this._startPreload(e)}dispose(){this.unload(),this._data=this.update=void 0}_startPreload(e){e instanceof HTMLVideoElement?(this.update=t=>this._update(e,t),this._startPreloadVideoElement(e)):e instanceof HTMLImageElement&&this._startPreloadImageElement(e)}_startPreloadVideoElement(e){if(!(m(e.src)||"auto"===e.preload&&e.crossOrigin)){e.preload="auto",e.crossOrigin="anonymous";const t=!e.paused;if(e.src=e.src,t&&e.autoplay){const t=()=>{e.removeEventListener("canplay",t),e.play()};e.addEventListener("canplay",t)}}}_startPreloadImageElement(e){h(e.src)||m(e.src)||e.crossOrigin||(e.crossOrigin="anonymous",e.src=e.src)}_createDescriptor(e){const t=new w;return t.wrapMode=this._parameters.wrap??D.REPEAT,t.flipped=!this._parameters.noUnpackFlip,t.samplingMode=this._parameters.mipmap?I.LINEAR_MIPMAP_LINEAR:I.LINEAR,t.hasMipmap=!!this._parameters.mipmap,t.preMultiplyAlpha=!!this._parameters.preMultiplyAlpha,t.maxAnisotropy=this._parameters.maxAnisotropy??(this._parameters.mipmap?e.parameters.maxMaxAnisotropy:1),t}get glTexture(){return this._glTexture??this._emptyTexture}get loaded(){return null!=this._glTexture}get usedMemory(){return this._glTexture?.usedMemory||C(this._data,this._parameters)}load(e){if(this._loadingPromise)return this._loadingPromise;if(this._glTexture)return this._glTexture;const t=this._data;return null==t?(this._glTexture=new M(e,this._createDescriptor(e),null),this._glTexture):(this._emptyTexture=e.emptyTexture,this._parameters.reloadable||(this._data=void 0),"string"==typeof t?this._loadFromURL(e,t):t instanceof Image?this._loadFromImageElement(e,t):t instanceof HTMLVideoElement?this._loadFromVideoElement(e,t):t instanceof ImageData||t instanceof HTMLCanvasElement?this._loadFromImage(e,t):n(t)&&this._parameters.encoding===_.DDS_ENCODING?this._loadFromDDSData(e,t):l(t)&&this._parameters.encoding===_.DDS_ENCODING?this._loadFromDDSData(e,new Uint8Array(t)):(l(t)||n(t))&&this._parameters.encoding===_.KTX2_ENCODING?this._loadFromKTX2(e,t):(l(t)||n(t))&&this._parameters.encoding===_.BASIS_ENCODING?this._loadFromBasis(e,t):n(t)?this._loadFromPixelData(e,t):l(t)?this._loadFromPixelData(e,new Uint8Array(t)):null)}_update(e,t){return null==this._glTexture||e.readyState<HTMLMediaElement.HAVE_CURRENT_DATA||t===e.currentTime?t:(this._glTexture.setData(e),this._glTexture.descriptor.hasMipmap&&this._glTexture.generateMipmap(),this._parameters.updateCallback&&this._parameters.updateCallback(),e.currentTime)}_loadFromDDSData(e,t){return this._glTexture=y(e,this._createDescriptor(e),t),this._emptyTexture=null,this._glTexture}_loadFromKTX2(e,t){return this._loadAsync((()=>u(e,this._createDescriptor(e),t).then((e=>(this._glTexture=e,e)))))}_loadFromBasis(e,t){return this._loadAsync((()=>c(e,this._createDescriptor(e),t).then((e=>(this._glTexture=e,e)))))}_loadFromPixelData(e,t){A(this._parameters.width>0&&this._parameters.height>0);const r=this._createDescriptor(e);return r.pixelFormat=1===this._parameters.components?F.LUMINANCE:3===this._parameters.components?F.RGB:F.RGBA,r.width=this._parameters.width??0,r.height=this._parameters.height??0,this._glTexture=new M(e,r,t),this._glTexture}_loadFromURL(e,t){return this._loadAsync((async r=>{const s=await p(t,{signal:r});return i(r),this._loadFromImage(e,s)}))}_loadFromImageElement(e,t){return t.complete?this._loadFromImage(e,t):this._loadAsync((async r=>{const s=await d(t,t.src,!1,r);return i(r),this._loadFromImage(e,s)}))}_loadFromVideoElement(e,t){return t.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA?this._loadFromImage(e,t):this._loadFromVideoElementAsync(e,t)}_loadFromVideoElementAsync(t,r){return this._loadAsync((i=>new Promise(((n,l)=>{const m=()=>{r.removeEventListener("loadeddata",h),r.removeEventListener("error",p),s(d)},h=()=>{r.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&(m(),n(this._loadFromImage(t,r)))},p=t=>{m(),l(t||new e("texture","Failed to load video"))};r.addEventListener("loadeddata",h),r.addEventListener("error",p);const d=a(i,(()=>p(o())))}))))}_loadFromImage(e,t){let r=t;r instanceof HTMLVideoElement||(r=f(r,e.parameters));const s=j(r);this._parameters.width=s.width,this._parameters.height=s.height;const i=this._createDescriptor(e);return i.pixelFormat=3===this._parameters.components?F.RGB:F.RGBA,i.width=s.width,i.height=s.height,i.compressionHandle=this._parameters.compressionHandle,this._glTexture=new M(e,i,r),this._emptyTexture=null,this._glTexture}_loadAsync(e){const t=new AbortController;this._loadingController=t;const r=e(t.signal);this._loadingPromise=r;const s=()=>{this._loadingController===t&&(this._loadingController=null),this._loadingPromise===r&&(this._loadingPromise=null),this._emptyTexture=null};return r.then(s,s),r}unload(){if(this._glTexture=r(this._glTexture),this._emptyTexture=null,null!=this._loadingController){const e=this._loadingController;this._loadingController=null,this._loadingPromise=null,e.abort()}this.events.emit("unloaded")}get parameters(){return this._parameters}}function C(e,t){if(null==e)return 0;if(l(e)||n(e))return t.encoding===_.KTX2_ENCODING?g(e,!!t.mipmap):t.encoding===_.BASIS_ENCODING?T(e,!!t.mipmap):e.byteLength;const{width:r,height:s}=e instanceof Image||e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement?j(e):t;return(t.mipmap?4/3:1)*r*s*(t.components||4)||0}function j(e){return e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e}const P={wrap:{s:D.REPEAT,t:D.REPEAT},mipmap:!0,noUnpackFlip:!1,preMultiplyAlpha:!1};export{L as Texture};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import s from"../../../../core/Logger.js";import{isPromiseLike as o,isAbortError as i}from"../../../../core/promiseUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{RenderRequestType as u}from"./basicInterfaces.js";import{ContentObjectType as d}from"./ContentObjectType.js";import{isFrameUpdateTexture as l}from"./ITexture.js";import{TaskPriority as p}from"../../../support/Scheduler.js";let h=class extends t{constructor(e){super({}),this._stage=e,this._textures=new Map,this._loadingCount=0,this._frameUpdates=new Map,this.events=new r,this._frameTask=e.view.resourceController.scheduler.registerTask(p.TEXTURE_UNLOAD)}normalizeCtorArgs(){return{}}destroy(){this._frameTask.remove(),this._stage.forEachOfType(d.Texture,(e=>e.unload()))}get updating(){return this._loadingCount>0||this._frameTask.updating}acquire(e){const t=this._textures.get(e);return t?(t.ref(),t.loadingPromise??t):this._createNewRef(e)}update(){let e=!1;this._frameUpdates.forEach((t=>{const r=t.texture.frameUpdate(t.previousToken);r>=0&&r!==t.previousToken&&(t.previousToken=r,e=!0)})),e&&this.events.emit("changed",u.BACKGROUND)}_createNewRef(e){const t=this._stage.getObject(e);if(null==t)return null;const r=t.events.on("unloaded",(()=>{r.remove(),this._onTextureUnloaded(e)})),n=new c(e,(()=>{this._frameTask.schedule((()=>{n.isUnreferenced&&t.unload()}))}));return this._textures.set(e,n),n.ref(),t.loaded?(this._updateGLTexture(n,t.glTexture),l(t)&&this._frameUpdates.set(e,{texture:t,previousToken:-1}),n):(this._loadingCount++,n.loadingPromise=this._stage.schedule((()=>{const r=t.load(this._stage.renderView.renderingContext),a=r=>(this._loadingCount--,n.loadingPromise=null,this._updateGLTexture(n,r),l(t)&&this._frameUpdates.set(e,{texture:t,previousToken:-1}),n),u=e=>(this._loadingCount--,n.loadingPromise=null,i(e)||s.getLogger(this).error(e),null);return o(r)?r.then(a,u):a(r)})),n.loadingPromise)}_updateGLTexture(e,t){e.glTexture=t,this.events.emit("changed",u.UPDATE)}_onTextureUnloaded(e){this._textures.delete(e),this._frameUpdates.delete(e)}};e([n()],h.prototype,"_loadingCount",void 0),e([n()],h.prototype,"_frameTask",void 0),e([n()],h.prototype,"updating",null),h=e([a("esri.views.3d.webgl-engine.lib.TextureRepository")],h);class c{constructor(e,t){this.id=e,this._release=t,this._refCount=0}get isUnreferenced(){return 0===this._refCount}ref(){++this._refCount}release(){--this._refCount,this._refCount>0||(0!==this._refCount?(s.getLogger("esri.views.3d.webgl-engine.lib.TextureRepository.RefCountedTextureImpl").error("Cannot dereference texture that has no references!"),this._refCount=0):this._release())}}export{h as TextureRepository};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import s from"../../../../core/Logger.js";import{isPromiseLike as o,isAbortError as i}from"../../../../core/promiseUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{RenderRequestType as u}from"./basicInterfaces.js";import{ContentObjectType as d}from"./ContentObjectType.js";import{isUpdatableTexture as l}from"./ITexture.js";import{TextureUpdater as h}from"./TextureUpdater.js";import{TaskPriority as p}from"../../../support/Scheduler.js";let c=class extends t{constructor(e){super({}),this._stage=e,this._textures=new Map,this._loadingCount=0,this.events=new r,this.updater=new h,this._frameTask=e.view.resourceController.scheduler.registerTask(p.TEXTURE_UNLOAD)}normalizeCtorArgs(){return{}}destroy(){this._frameTask.remove(),this._stage.forEachOfType(d.Texture,(e=>e.unload()))}get updating(){return this._loadingCount>0||this._frameTask.updating}acquire(e){const t=this._textures.get(e);return t?(t.ref(),t.loadingPromise??t):this._createNewRef(e)}update(){this.updater.run()&&this.events.emit("changed",u.BACKGROUND)}_createNewRef(e){const t=this._stage.getObject(e);if(null==t)return null;const r=t.events.on("unloaded",(()=>{r.remove(),this._onTextureUnloaded(t)})),n=new m(e,(()=>{this._frameTask.schedule((()=>{n.isUnreferenced&&t.unload()}))}));return this._textures.set(e,n),n.ref(),t.loaded?(this._updateGLTexture(n,t.glTexture),l(t)&&this.updater.add(t),n):(this._loadingCount++,n.loadingPromise=this._stage.schedule((()=>{const e=t.load(this._stage.renderView.renderingContext),r=e=>(this._loadingCount--,n.loadingPromise=null,this._updateGLTexture(n,e),l(t)&&this.updater.add(t),n),a=e=>(this._loadingCount--,n.loadingPromise=null,i(e)||s.getLogger(this).error(e),null);return o(e)?e.then(r,a):r(e)})),n.loadingPromise)}_updateGLTexture(e,t){e.glTexture=t,this.events.emit("changed",u.UPDATE)}_onTextureUnloaded(e){this._textures.delete(e.id),this.updater.remove(e)}};e([n()],c.prototype,"_loadingCount",void 0),e([n()],c.prototype,"_frameTask",void 0),e([n()],c.prototype,"updating",null),c=e([a("esri.views.3d.webgl-engine.lib.TextureRepository")],c);class m{constructor(e,t){this.id=e,this._release=t,this._refCount=0}get isUnreferenced(){return 0===this._refCount}ref(){++this._refCount}release(){--this._refCount,this._refCount>0||(0!==this._refCount?(s.getLogger("esri.views.3d.webgl-engine.lib.TextureRepository.RefCountedTextureImpl").error("Cannot dereference texture that has no references!"),this._refCount=0):this._release())}}export{c as TextureRepository};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{a as e}from"../../../../chunks/TextureOnly.glsl.js";import{ReloadableShaderModule as r}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as o}from"../core/shaderTechnique/ShaderTechnique.js";import{makePipelineState as i,premultipliedAlphaToPremultipliedAlpha as l,defaultColorWrite as s}from"../../../webgl/renderState.js";class t extends o{constructor(o,i){super(o,i,new r(e,(()=>import("../core/shaderLibrary/util/TextureOnly.glsl.js"))))}initializePipeline(e){return e.hasAlpha?i({blending:l,colorWrite:s}):i({colorWrite:s})}}export{t as TextureTechnique};
5
+ import{a as e}from"../../../../chunks/TextureOnly.glsl.js";import{ReloadableShaderModule as r}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as o}from"../core/shaderTechnique/ShaderTechnique.js";import{makePipelineState as i,unpremultipliedAlphaToPremultipliedAlpha as l,defaultColorWrite as s}from"../../../webgl/renderState.js";class t extends o{constructor(o,i){super(o,i,new r(e,(()=>import("../core/shaderLibrary/util/TextureOnly.glsl.js"))))}initializePipeline(e){return e.hasAlpha?i({blending:l,colorWrite:s}):i({colorWrite:s})}}export{t as TextureTechnique};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ class t{constructor(){this._updating=new Map}add(t){this._updating.set(t.id,new e(t))}remove(t){this._updating.delete(t.id)}run(){let t=!1;return this._updating.forEach((e=>{const s=e.texture.update(e.previousToken);s>=0&&s!==e.previousToken&&(e.previousToken=s,t=!0)})),t}}class e{constructor(t){this.texture=t,this.previousToken=-1}}export{t as TextureUpdater};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{MaterialChangeSet as e}from"./ChangeSet.js";var r,t;function n(r){const t=new Map,n=r=>{let n=t.get(r);return n||(n=new e,t.set(r,n)),n};return r.removes.forAll((e=>{o(e)&&n(e.material).removes.push(e)})),r.adds.forAll((e=>{o(e)&&n(e.material).adds.push(e)})),r.updates.forAll((e=>{o(e.renderGeometry)&&n(e.renderGeometry.material).updates.push(e)})),t}function o(e){return e.geometry.indexCount>=1}!function(e){e[e.Default=0]="Default",e[e.Screenshot=1]="Screenshot",e[e.ObjectAndLayerID=2]="ObjectAndLayerID"}(r||(r={})),function(e){e[e.TOP=0]="TOP",e[e.RIGHT=1]="RIGHT",e[e.BOTTOM=2]="BOTTOM",e[e.LEFT=3]="LEFT"}(t||(t={}));export{t as PaddingSide,r as RendererTarget,n as splitRenderGeometryChangeSetByMaterial};
5
+ import{MaterialChangeSet as e}from"./ChangeSet.js";var r,t;function n(r){const t=new Map,n=n=>{let o=t.get(n);return o||(o=new e(r),t.set(n,o)),o};return r.removes.forAll((e=>{o(e)&&n(e.material).removes.push(e)})),r.adds.forAll((e=>{o(e)&&n(e.material).adds.push(e)})),r.updates.forAll((e=>{o(e.renderGeometry)&&n(e.renderGeometry.material).updates.push(e)})),t}function o(e){return e.geometry.indexCount>=1}!function(e){e[e.Default=0]="Default",e[e.Screenshot=1]="Screenshot",e[e.ObjectAndLayerID=2]="ObjectAndLayerID"}(r||(r={})),function(e){e[e.TOP=0]="TOP",e[e.RIGHT=1]="RIGHT",e[e.BOTTOM=2]="BOTTOM",e[e.LEFT=3]="LEFT"}(t||(t={}));export{t as PaddingSide,r as RendererTarget,n as splitRenderGeometryChangeSetByMaterial};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{BufferViewFloat as e}from"../../../../geometry/support/buffer/BufferView.js";import{isHighlightOrOID as t,isColor as r}from"../core/shaderLibrary/ShaderOutput.js";import{CullFaceOptions as i}from"../lib/basicInterfaces.js";import s from"../lib/GLMaterial.js";import{MaterialParameters as a}from"../lib/Material.js";import{OITPolygonOffsetLimit as o}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as n}from"../lib/RenderSlot.js";import{assert as u}from"../lib/Util.js";import{VertexAttribute as l}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as p}from"./DefaultBufferWriter.js";import{PositionUvLayout as c}from"./DefaultLayouts.js";import{TriangleMaterial as f}from"./TriangleMaterial.js";import{writeBufferFloat as h,writeDefaultAttribute as m}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocations as g,ImageMaterialTechnique as d}from"../shaders/ImageMaterialTechnique.js";import{ImageMaterialTechniqueConfiguration as T}from"../shaders/ImageMaterialTechniqueConfiguration.js";class E extends f{constructor(e){super(e,A),this.vertexAttributeLocations=g,this.supportsEdges=!0,this.produces=new Map([[n.OPAQUE_MATERIAL,e=>t(e)],[n.TRANSPARENT_MATERIAL,e=>r(e)&&this.parameters.writeDepth],[n.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>r(e)&&!this.parameters.writeDepth],[n.DRAPED_MATERIAL,e=>r(e)||t(e)]]),this._configuration=new T(e.draped)}dispose(){this.setParameters({texture:void 0})}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasOccludees=t.hasOccludees,this._configuration.oitPass=t.oitPass,this._configuration.enableOffset=t.camera.relativeElevation<o,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration.perspectiveInterpolation=this.parameters.perspectiveInterpolation,this._configuration}get visible(){return!0}createGLMaterial(e){return new I(e)}createBufferWriter(){let e=c;return this.parameters.perspectiveInterpolation&&(e=e.clone().f32(l.PERSPECTIVEDIVIDE)),new b(e)}}class I extends s{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){return this.getTechnique(d,e)}}class b extends p{write(t,r,i,s,a,o){for(const n of this.vertexBufferLayout.fields.keys()){const s=i.get(n);if(s)if(n===l.PERSPECTIVEDIVIDE){u(1===s.size);const t=a.getField(n,e);t&&h(s,t,o)}else m(n,s,t,r,a,o)}return null}}class A extends a{constructor(e,t){super(),this.texture=e,this.draped=t,this.writeDepth=!0,this.hasSlicePlane=!1,this.cullFace=i.None,this.opacity=1,this.perspectiveInterpolation=!1}get glTexture(){return this.texture.glTexture}}export{E as ImageMaterial,A as Parameters};
5
+ import{BufferViewFloat as e}from"../../../../geometry/support/buffer/BufferView.js";import{isHighlightOrOID as t,isColor as r}from"../core/shaderLibrary/ShaderOutput.js";import{CullFaceOptions as i}from"../lib/basicInterfaces.js";import s from"../lib/GLMaterial.js";import{isUpdatableTexture as a}from"../lib/ITexture.js";import{MaterialParameters as o}from"../lib/Material.js";import{OITPolygonOffsetLimit as n}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as u}from"../lib/RenderSlot.js";import{assert as p}from"../lib/Util.js";import{VertexAttribute as l}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as c}from"./DefaultBufferWriter.js";import{PositionUvLayout as h}from"./DefaultLayouts.js";import{TriangleMaterial as f}from"./TriangleMaterial.js";import{writeBufferFloat as m,writeDefaultAttribute as g}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocations as d,ImageMaterialTechnique as T}from"../shaders/ImageMaterialTechnique.js";import{ImageMaterialTechniqueConfiguration as I}from"../shaders/ImageMaterialTechniqueConfiguration.js";class _ extends f{constructor(e){super(e,x),this.vertexAttributeLocations=d,this.supportsEdges=!0,this.produces=new Map([[u.OPAQUE_MATERIAL,e=>t(e)],[u.TRANSPARENT_MATERIAL,e=>r(e)&&this.parameters.writeDepth],[u.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>r(e)&&!this.parameters.writeDepth],[u.DRAPED_MATERIAL,e=>r(e)||t(e)]]),this._configuration=new I(e.draped)}dispose(){this.setParameters({texture:void 0})}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasOccludees=t.hasOccludees,this._configuration.oitPass=t.oitPass,this._configuration.enableOffset=t.camera.relativeElevation<n,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration.perspectiveInterpolation=this.parameters.perspectiveInterpolation,this._configuration}get visible(){return!0}createGLMaterial(e){return new b(e)}createBufferWriter(){let e=h;return this.parameters.perspectiveInterpolation&&(e=e.clone().f32(l.PERSPECTIVEDIVIDE)),new E(e)}}class b extends s{constructor(e){super({...e,...e.material.parameters}),this.parameters=e;const t=this._material.parameters.texture;a(t)&&e.textures.updater.add(t)}dispose(){this.parameters.textures.updater.remove(this._material.parameters.texture)}beginSlot(e){return this.getTechnique(T,e)}}class E extends c{write(t,r,i,s,a,o){for(const n of this.vertexBufferLayout.fields.keys()){const s=i.get(n);if(s)if(n===l.PERSPECTIVEDIVIDE){p(1===s.size);const t=a.getField(n,e);t&&m(s,t,o)}else g(n,s,t,r,a,o)}return null}}class x extends o{constructor(e,t){super(),this.texture=e,this.draped=t,this.writeDepth=!0,this.hasSlicePlane=!1,this.cullFace=i.None,this.opacity=1,this.perspectiveInterpolation=!1}get glTexture(){return this.texture.glTexture}}export{_ as ImageMaterial,x as Parameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{Float16Array as e}from"@petamoriken/float16";import{i as t,H as r,t as i}from"../../../../chunks/vec32.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newLayout as s}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as n,isColor as o,isDepth as h,isColorHighlightOrDepth as c,isColorOrColorEmission as p}from"../core/shaderLibrary/ShaderOutput.js";import m from"../lib/GLMaterial.js";import{Material as l,RenderOccludedFlag as u}from"../lib/Material.js";import{RenderSlot as T}from"../lib/RenderSlot.js";import{VertexAttribute as f}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as d}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as A}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocations as v,LineMarkerTechnique as _}from"../shaders/LineMarkerTechnique.js";import{LineMarkerTechniqueConfiguration as E,LineMarkerSpace as g,LineMarkerAnchor as O}from"../shaders/LineMarkerTechniqueConfiguration.js";import{CapType as S}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as R}from"../../../../webscene/support/AlphaCutoff.js";class I extends l{constructor(e){super(e,C),this._configuration=new E,this.vertexAttributeLocations=v,this.produces=new Map([[T.OPAQUE_MATERIAL,e=>e===n.Highlight||o(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[T.OPAQUE_MATERIAL_WITHOUT_NORMALS,e=>h(e)],[T.OCCLUDER_MATERIAL,e=>c(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[T.TRANSPARENT_OCCLUDER_MATERIAL,e=>c(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[T.TRANSPARENT_MATERIAL,e=>o(e)&&this.parameters.writeDepth],[T.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>o(e)&&!this.parameters.writeDepth],[T.DRAPED_MATERIAL,e=>p(e)||e===n.Highlight]]),this._layout=this.createLayout()}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.space=t.slot===T.DRAPED_MATERIAL?g.Draped:this.parameters.worldSpace?g.World:g.Screen,this._configuration.hideOnShortSegments=this.parameters.hideOnShortSegments,this._configuration.hasCap=this.parameters.cap!==S.BUTT,this._configuration.anchor=this.parameters.anchor,this._configuration.hasTip=this.parameters.hasTip,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasOccludees=t.hasOccludees,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.occluder=this.parameters.renderOccluded===u.OccludeAndTransparentStencil,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest&&p(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}get visible(){return this.parameters.color[3]>=R}intersect(){}createLayout(){const e=s().vec3f(f.POSITION).vec4f16(f.PREVIOUSDELTA).vec2f16(f.UV0);return this.parameters.worldSpace&&e.vec3f16(f.NORMAL),this.parameters.vvSize?e.f16(f.SIZEFEATUREATTRIBUTE):e.f16(f.SIZE),this.parameters.vvColor?e.f16(f.COLORFEATUREATTRIBUTE):e.vec4u8(f.COLOR),this.parameters.vvOpacity&&e.f16(f.OPACITYFEATUREATTRIBUTE),e}createBufferWriter(){return new P(this._layout,this.parameters)}createGLMaterial(e){return new L(e)}}class L extends m{constructor(){super(...arguments),this._markerPrimitive=null}dispose(){super.dispose(),this._markerTextures.release(this._markerPrimitive),this._markerPrimitive=null}beginSlot(e){const t=this._material.parameters.markerPrimitive;return t!==this._markerPrimitive&&(this._material.setParameters({markerTexture:this._markerTextures.swap(t,this._markerPrimitive)}),this._markerPrimitive=t),this.getTechnique(_,e)}}class C extends d{constructor(){super(...arguments),this.width=0,this.color=[1,1,1,1],this.markerPrimitive="arrow",this.placement="end",this.cap=S.BUTT,this.anchor=O.Center,this.hasTip=!1,this.worldSpace=!1,this.hideOnShortSegments=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.markerTexture=null}}class P{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t}elementCount(){return"begin-end"===this._parameters.placement?12:6}write(a,s,n,o,h,c){const p=n.get(f.POSITION).data,m=p.length/3;let l=[1,0,0];const u=n.get(f.NORMAL);this._parameters.worldSpace&&null!=u&&(l=u.data);let T=1,d=0;this._parameters.vvSize?d=n.get(f.SIZEFEATUREATTRIBUTE).data[0]:n.has(f.SIZE)&&(T=n.get(f.SIZE).data[0]);let v=[1,1,1,1],_=0;this._parameters.vvColor?_=n.get(f.COLORFEATUREATTRIBUTE).data[0]:n.has(f.COLOR)&&(v=n.get(f.COLOR).data);let E=0;this._parameters.vvOpacity&&(E=n.get(f.OPACITYFEATUREATTRIBUTE).data[0]);const g=new Float32Array(h.buffer),O=new e(h.buffer),S=new Uint8Array(h.buffer);let R=c*(this.vertexBufferLayout.stride/4);const I=(e,t,r,i)=>{g[R++]=e[0],g[R++]=e[1],g[R++]=e[2],A(t,e,O,2*R),R+=2;let a=2*R;if(O[a++]=r[0],O[a++]=r[1],this._parameters.worldSpace&&(O[a++]=l[0],O[a++]=l[1],O[a++]=l[2]),this._parameters.vvSize?O[a++]=d:O[a++]=T,this._parameters.vvColor)O[a++]=_;else{const e=Math.min(4*i,v.length-4),t=2*a;a+=2,S[t]=v[e],S[t+1]=v[e+1],S[t+2]=v[e+2],S[t+3]=v[e+3]}this._parameters.vvOpacity&&(O[a++]=E),R=Math.ceil(.5*a)};let L;!function(e){e[e.ASCENDING=1]="ASCENDING",e[e.DESCENDING=-1]="DESCENDING"}(L||(L={}));const C=(e,s)=>{const n=t(b,p[3*e],p[3*e+1],p[3*e+2]),o=D;let h=e+s;do{t(o,p[3*h],p[3*h+1],p[3*h+2]),h+=s}while(r(n,o)&&h>=0&&h<m);a&&(i(n,n,a),i(o,o,a)),I(n,o,[-1,-1],e),I(n,o,[1,-1],e),I(n,o,[1,1],e),I(n,o,[-1,-1],e),I(n,o,[1,1],e),I(n,o,[-1,1],e)},P=this._parameters.placement;return"begin"!==P&&"begin-end"!==P||C(0,L.ASCENDING),"end"!==P&&"begin-end"!==P||C(m-1,L.DESCENDING),null}}const b=a(),D=a();export{I as LineMarkerMaterial,C as Parameters};
5
+ import{Float16Array as e}from"@petamoriken/float16";import{i as t,H as r,t as i}from"../../../../chunks/vec32.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newLayout as s}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as n,isColor as o,isDepth as h,isColorHighlightOrDepth as c,isColorOrColorEmission as p}from"../core/shaderLibrary/ShaderOutput.js";import l from"../lib/GLMaterial.js";import{Material as m,RenderOccludedFlag as u}from"../lib/Material.js";import{RenderSlot as T}from"../lib/RenderSlot.js";import{VertexAttribute as f}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as d}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as A}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocations as v,LineMarkerTechnique as _}from"../shaders/LineMarkerTechnique.js";import{LineMarkerTechniqueConfiguration as E,LineMarkerSpace as g,LineMarkerAnchor as O}from"../shaders/LineMarkerTechniqueConfiguration.js";import{CapType as S}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as R}from"../../../../webscene/support/AlphaCutoff.js";class I extends m{constructor(e){super(e,C),this._configuration=new E,this.vertexAttributeLocations=v,this.produces=new Map([[T.OPAQUE_MATERIAL,e=>e===n.Highlight||o(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[T.OPAQUE_MATERIAL_WITHOUT_NORMALS,e=>h(e)],[T.OCCLUDER_MATERIAL,e=>c(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[T.TRANSPARENT_OCCLUDER_MATERIAL,e=>c(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[T.TRANSPARENT_MATERIAL,e=>o(e)&&this.parameters.writeDepth],[T.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>o(e)&&!this.parameters.writeDepth],[T.DRAPED_MATERIAL,e=>p(e)||e===n.Highlight]]),this._layout=this.createLayout()}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.space=t.slot===T.DRAPED_MATERIAL?g.Draped:this.parameters.worldSpace?g.World:g.Screen,this._configuration.hideOnShortSegments=this.parameters.hideOnShortSegments,this._configuration.hasCap=this.parameters.cap!==S.BUTT,this._configuration.anchor=this.parameters.anchor,this._configuration.hasTip=this.parameters.hasTip,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasOccludees=t.hasOccludees,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.occluder=this.parameters.renderOccluded===u.OccludeAndTransparentStencil,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest&&p(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}get visible(){return this.parameters.color[3]>=R}intersect(){}createLayout(){const e=s().vec3f(f.POSITION).vec4f16(f.PREVIOUSDELTA).vec2f16(f.UV0);return this.parameters.worldSpace&&e.vec3f16(f.NORMAL),this.parameters.vvSize?e.f16(f.SIZEFEATUREATTRIBUTE):e.f16(f.SIZE),this.parameters.vvColor?e.f16(f.COLORFEATUREATTRIBUTE):e.vec4u8(f.COLOR,{glNormalized:!0}),this.parameters.vvOpacity&&e.f16(f.OPACITYFEATUREATTRIBUTE),e}createBufferWriter(){return new P(this._layout,this.parameters)}createGLMaterial(e){return new L(e)}}class L extends l{constructor(){super(...arguments),this._markerPrimitive=null}dispose(){super.dispose(),this._markerTextures.release(this._markerPrimitive),this._markerPrimitive=null}beginSlot(e){const t=this._material.parameters.markerPrimitive;return t!==this._markerPrimitive&&(this._material.setParameters({markerTexture:this._markerTextures.swap(t,this._markerPrimitive)}),this._markerPrimitive=t),this.getTechnique(_,e)}}class C extends d{constructor(){super(...arguments),this.width=0,this.color=[1,1,1,1],this.markerPrimitive="arrow",this.placement="end",this.cap=S.BUTT,this.anchor=O.Center,this.hasTip=!1,this.worldSpace=!1,this.hideOnShortSegments=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.markerTexture=null}}class P{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t}elementCount(){return"begin-end"===this._parameters.placement?12:6}write(a,s,n,o,h,c){const p=n.get(f.POSITION).data,l=p.length/3;let m=[1,0,0];const u=n.get(f.NORMAL);this._parameters.worldSpace&&null!=u&&(m=u.data);let T=1,d=0;this._parameters.vvSize?d=n.get(f.SIZEFEATUREATTRIBUTE).data[0]:n.has(f.SIZE)&&(T=n.get(f.SIZE).data[0]);let v=[1,1,1,1],_=0;this._parameters.vvColor?_=n.get(f.COLORFEATUREATTRIBUTE).data[0]:n.has(f.COLOR)&&(v=n.get(f.COLOR).data);let E=0;this._parameters.vvOpacity&&(E=n.get(f.OPACITYFEATUREATTRIBUTE).data[0]);const g=new Float32Array(h.buffer),O=new e(h.buffer),S=new Uint8Array(h.buffer);let R=c*(this.vertexBufferLayout.stride/4);const I=(e,t,r,i)=>{g[R++]=e[0],g[R++]=e[1],g[R++]=e[2],A(t,e,O,2*R),R+=2;let a=2*R;if(O[a++]=r[0],O[a++]=r[1],this._parameters.worldSpace&&(O[a++]=m[0],O[a++]=m[1],O[a++]=m[2]),this._parameters.vvSize?O[a++]=d:O[a++]=T,this._parameters.vvColor)O[a++]=_;else{const e=Math.min(4*i,v.length-4),t=2*a;a+=2,S[t]=255*v[e],S[t+1]=255*v[e+1],S[t+2]=255*v[e+2],S[t+3]=255*v[e+3]}this._parameters.vvOpacity&&(O[a++]=E),R=Math.ceil(.5*a)};let L;!function(e){e[e.ASCENDING=1]="ASCENDING",e[e.DESCENDING=-1]="DESCENDING"}(L||(L={}));const C=(e,s)=>{const n=t(b,p[3*e],p[3*e+1],p[3*e+2]),o=D;let h=e+s;do{t(o,p[3*h],p[3*h+1],p[3*h+2]),h+=s}while(r(n,o)&&h>=0&&h<l);a&&(i(n,n,a),i(o,o,a)),I(n,o,[-1,-1],e),I(n,o,[1,-1],e),I(n,o,[1,1],e),I(n,o,[-1,-1],e),I(n,o,[1,1],e),I(n,o,[-1,1],e)},P=this._parameters.placement;return"begin"!==P&&"begin-end"!==P||C(0,L.ASCENDING),"end"!==P&&"begin-end"!==P||C(l-1,L.DESCENDING),null}}const b=a(),D=a();export{I as LineMarkerMaterial,C as Parameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as e}from"../../../../core/mathUtils.js";import{clone as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as i}from"../../../../chunks/vec32.js";import{ZEROS as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as s}from"../../../../geometry/support/aaBoundingBox.js";import{newLayout as a}from"../../support/buffer/InterleavedLayout.js";import{isShadowRelatedOutput as o,is3DGeometryOutputMRT as n,isColorOrColorEmission as c,ShaderOutput as h}from"../core/shaderLibrary/ShaderOutput.js";import{EmissionSource as u}from"../core/shaderLibrary/output/Emissions.glsl.js";import{NormalsDoubleSidedMode as m}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as l}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{olidEnabled as p}from"../effects/geometry/olidUtils.js";import f from"../lib/GLMaterial.js";import{Material as d}from"../lib/Material.js";import{isPathGeometry as b}from"../lib/PathGeometry.js";import{MeshIntersectionOptions as g,intersectAabbInvDir as v}from"../lib/RayIntersections.js";import{RenderSlot as S}from"../lib/RenderSlot.js";import{VertexAttribute as _}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as y}from"./DefaultBufferWriter.js";import{vertexAttributeLocations as A,PathTechnique as O,PathPassParameters as j}from"./PathTechnique.js";import{PathTechniqueConfiguration as P}from"./PathTechniqueConfiguration.js";import{alphaCutoff as L}from"../../../../webscene/support/AlphaCutoff.js";class R extends d{constructor(e,t){super(e,x),this._vertexBufferLayout=T(),this.vertexAttributeLocations=A,this.supportsEdges=!0,this.produces=new Map([[S.OPAQUE_MATERIAL,e=>(this.parameters.castShadows&&o(e)||n(e))&&!this.transparent],[S.TRANSPARENT_MATERIAL,e=>(this.parameters.castShadows&&o(e)||n(e))&&this.transparent]]),this._configuration=new P(t.spherical)}get hasEmissions(){return!i(this.parameters.emissiveFactor,r)}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.transparent,this._configuration.hasOccludees=t.hasOccludees,c(e)?(this._configuration.doubleSidedMode=this.parameters.doubleSided&&"normal"===this.parameters.doubleSidedType?m.View:this.parameters.doubleSided&&"winding-order"===this.parameters.doubleSidedType?m.WindingOrder:m.None,this._configuration.receiveShadows=t.shadowMap.enabled,this._configuration.receiveAmbientOcclusion=null!=t.ssao):this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._configuration.pbrMode=this.parameters.usePBR?l.Schematic:l.Disabled,this._configuration.emissionSource=this.parameters.usePBR?u.Value:u.None,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}isVisibleForOutput(e){return e!==h.Shadow&&e!==h.ShadowExcludeHighlight&&e!==h.ShadowHighlight||this.parameters.castShadows}get visible(){return this.parameters.opacity>=L}intersect(i,r,a,o,n,c){const h=i;if(!b(h))return;const u=h.path,m=t(this.parameters.size);if(this.parameters.vvSize){const{offset:t,factor:i,minSize:r,maxSize:s,fallback:a}=this.parameters.vvSize,o=u.sizeAttributeValue;Number.isNaN(o)?(m[0]*=a[0],m[1]*=a[2]):(m[0]*=e(t[0]+o*i[0],r[0],s[0]),m[1]*=e(t[2]+o*i[2],r[2],s[2]))}const l=new g(!1,a.options.normalRequired),p=Math.max(m[0],m[1]),f=i.boundingInfo;if(null==f)return void M(u,m,o,n,l,c);const d=s(f.bbMin[0]-p,f.bbMin[1]-p,f.bbMin[2]-p,f.bbMax[0]+p,f.bbMax[1]+p,f.bbMax[2]+p),S=[n[0]-o[0],n[1]-o[1],n[2]-o[2]],_=Math.sqrt(S[0]*S[0]+S[1]*S[1]+S[2]*S[2]),y=[_/S[0],_/S[1],_/S[2]];v(d,o,y,a.tolerance)&&M(u,m,o,n,l,c)}createBufferWriter(){return new y(this._vertexBufferLayout)}createGLMaterial(e){return new w(e)}get transparent(){const{parameters:e}=this;return e.drivenOpacity||e.opacity<1}}function T(){const e=a().vec3f(_.POSITION).vec4f16(_.PROFILEVERTEXANDNORMAL).vec4f16(_.FEATUREVALUE).vec2f16(_.PROFILEAUXDATA).vec2i16(_.PROFILERIGHT,{glNormalized:!0}).vec2i16(_.PROFILEUP,{glNormalized:!0});return p()&&e.vec4u8(_.OLIDCOLOR),e}class w extends f{beginSlot(e){return this.getTechnique(O,e)}}function M(e,t,i,r,s,a){e.baked.size&&e.baked.size[0]===t[0]&&e.baked.size[1]===t[1]||e.baked.bake(t),e.baked.intersect(i,r,s,a)}class x extends j{constructor(){super(...arguments),this.doubleSided=!1,this.doubleSidedType="normal",this.castShadows=!0,this.hasSlicePlane=!1,this.drivenOpacity=!1,this.usePBR=!1}}export{x as Parameters,R as PathMaterial};
5
+ import{clamp as e}from"../../../../core/mathUtils.js";import{clone as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as i}from"../../../../chunks/vec32.js";import{ZEROS as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as s}from"../../../../geometry/support/aaBoundingBox.js";import{newLayout as a}from"../../support/buffer/InterleavedLayout.js";import{isShadowRelatedOutput as o,is3DGeometryOutputMRT as n,isColorOrColorEmission as c,ShaderOutput as h}from"../core/shaderLibrary/ShaderOutput.js";import{EmissionSource as u}from"../core/shaderLibrary/output/Emissions.glsl.js";import{NormalsDoubleSidedMode as m}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as l}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{olidEnabled as p}from"../effects/geometry/olidUtils.js";import f from"../lib/GLMaterial.js";import{Material as d}from"../lib/Material.js";import{isPathGeometry as b}from"../lib/PathGeometry.js";import{MeshIntersectionOptions as g,intersectAabbInvDir as v}from"../lib/RayIntersections.js";import{RenderSlot as S}from"../lib/RenderSlot.js";import{VertexAttribute as _}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as y}from"./DefaultBufferWriter.js";import{vertexAttributeLocations as A,PathTechnique as O,PathPassParameters as j}from"./PathTechnique.js";import{PathTechniqueConfiguration as P}from"./PathTechniqueConfiguration.js";import{alphaCutoff as L}from"../../../../webscene/support/AlphaCutoff.js";class R extends d{constructor(e,t){super(e,x),this._vertexBufferLayout=T(),this.vertexAttributeLocations=A,this.supportsEdges=!0,this.produces=new Map([[S.OPAQUE_MATERIAL,e=>(this.parameters.castShadows&&o(e)||n(e))&&!this.transparent],[S.TRANSPARENT_MATERIAL,e=>(this.parameters.castShadows&&o(e)||n(e))&&this.transparent]]),this._configuration=new P(t.spherical)}get hasEmissions(){return!i(this.parameters.emissiveFactor,r)}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.transparent,this._configuration.hasOccludees=t.hasOccludees,c(e)?(this._configuration.doubleSidedMode=this.parameters.doubleSided&&"normal"===this.parameters.doubleSidedType?m.View:this.parameters.doubleSided&&"winding-order"===this.parameters.doubleSidedType?m.WindingOrder:m.None,this._configuration.receiveShadows=t.shadowMap.enabled,this._configuration.receiveAmbientOcclusion=null!=t.ssao):this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._configuration.pbrMode=this.parameters.usePBR?l.Schematic:l.Disabled,this._configuration.emissionSource=this.parameters.usePBR?u.Value:u.None,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}isVisibleForOutput(e){return e!==h.Shadow&&e!==h.ShadowExcludeHighlight&&e!==h.ShadowHighlight||this.parameters.castShadows}get visible(){return this.parameters.opacity>=L}intersect(i,r,a,o,n,c){const h=i;if(!b(h))return;const u=h.path,m=t(this.parameters.size);if(this.parameters.vvSize){const{offset:t,factor:i,minSize:r,maxSize:s,fallback:a}=this.parameters.vvSize,o=u.sizeAttributeValue;Number.isNaN(o)?(m[0]*=a[0],m[1]*=a[2]):(m[0]*=e(t[0]+o*i[0],r[0],s[0]),m[1]*=e(t[2]+o*i[2],r[2],s[2]))}const l=new g(!1,a.options.normalRequired),p=Math.max(m[0],m[1]),f=i.boundingInfo;if(null==f)return void M(u,m,o,n,l,c);const d=s(f.bbMin[0]-p,f.bbMin[1]-p,f.bbMin[2]-p,f.bbMax[0]+p,f.bbMax[1]+p,f.bbMax[2]+p),S=[n[0]-o[0],n[1]-o[1],n[2]-o[2]],_=Math.sqrt(S[0]*S[0]+S[1]*S[1]+S[2]*S[2]),y=[_/S[0],_/S[1],_/S[2]];v(d,o,y,a.tolerance)&&M(u,m,o,n,l,c)}createBufferWriter(){return new y(this._vertexBufferLayout)}createGLMaterial(e){return new w(e)}get transparent(){const{parameters:e}=this;return e.drivenOpacity||e.opacity<1}}function T(){const e=a().vec3f(_.POSITION).vec3f(_.FEATUREVALUE).vec4f16(_.PROFILEVERTEXANDNORMAL).vec3f16(_.PROFILEAUXDATA).vec2i16(_.PROFILERIGHT,{glNormalized:!0}).vec2i16(_.PROFILEUP,{glNormalized:!0});return p()&&e.vec4u8(_.OLIDCOLOR),e}class w extends f{beginSlot(e){return this.getTechnique(O,e)}}function M(e,t,i,r,s,a){e.baked.size&&e.baked.size[0]===t[0]&&e.baked.size[1]===t[1]||e.baked.bake(t),e.baked.intersect(i,r,s,a)}class x extends j{constructor(){super(...arguments),this.doubleSided=!1,this.doubleSidedType="normal",this.castShadows=!0,this.hasSlicePlane=!1,this.drivenOpacity=!1,this.usePBR=!1}}export{x as Parameters,R as PathMaterial};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{freeze as r,create as e,ZEROS as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{isColorOrColorEmission as t,ShaderOutput as i}from"../core/shaderLibrary/ShaderOutput.js";import{PathVertexPositionPassParameters as o}from"../core/shaderLibrary/attributes/PathVertexPosition.glsl.js";import{NormalsDoubleSidedMode as l}from"../core/shaderLibrary/shading/Normals.glsl.js";import{ReloadableShaderModule as n}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as a}from"../core/shaderTechnique/ShaderTechnique.js";import{OITPass as m}from"../lib/OITPass.js";import{blending as c,oitDepthTest as p,getDrawBuffers as u,OITPolygonOffset as h}from"../lib/OrderIndependentTransparency.js";import{stencilWriteMaskOn as d,stencilBaseAllZerosParams as f}from"../lib/StencilUtils.js";import{VertexAttribute as b}from"../lib/VertexAttribute.js";import{advancedMRRFactors as O}from"./pbrUtils.js";import{P as j}from"../../../../chunks/Path.glsl.js";import{SpecialDrawBuffers as P}from"../../../webgl/enums.js";import{makePipelineState as T,frontFaceCullingParams as g,defaultDepthWrite as E,defaultColorWrite as L}from"../../../webgl/renderState.js";class I extends o{constructor(){super(...arguments),this.ambient=r(.2,.2,.2),this.diffuse=r(.8,.8,.8),this.specular=r(0,0,0),this.opacity=1,this.origin=e(),this.modelTransformation=null,this.mrrFactors=O,this.emissiveFactor=s}}class R extends a{constructor(r,e){super(r,e,new n(j,(()=>import("../shaders/Path.glsl.js"))),F)}initializePipeline(r){const{output:e,transparent:s,hasSlicePlane:o,doubleSidedMode:n,hasOccludees:a,oitPass:b}=r,O=b===m.NONE,j=b===m.FrontFace;return T({blending:t(e)&&s?c(b):null,culling:o&&!s&&n!==l.None?g:null,depthTest:{func:p(b)},depthWrite:O||j?E:null,drawBuffers:e===i.Depth?{buffers:[P.NONE]}:u(b,e),colorWrite:L,stencilWrite:a?d:null,stencilTest:a?f:null,polygonOffset:O||j?null:h})}}const F=new Map([[b.POSITION,0],[b.PROFILEVERTEXANDNORMAL,1],[b.FEATUREVALUE,2],[b.PROFILEAUXDATA,3],[b.PROFILERIGHT,4],[b.PROFILEUP,5],[b.OLIDCOLOR,6]]);export{I as PathPassParameters,R as PathTechnique,F as vertexAttributeLocations};
5
+ import{freeze as r,create as e,ZEROS as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{isColorOrColorEmission as t,ShaderOutput as i}from"../core/shaderLibrary/ShaderOutput.js";import{PathVertexPositionPassParameters as o}from"../core/shaderLibrary/attributes/PathVertexPosition.glsl.js";import{NormalsDoubleSidedMode as l}from"../core/shaderLibrary/shading/Normals.glsl.js";import{ReloadableShaderModule as n}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as a}from"../core/shaderTechnique/ShaderTechnique.js";import{OITPass as m}from"../lib/OITPass.js";import{blending as c,oitDepthTest as p,getDrawBuffers as u,OITPolygonOffset as h}from"../lib/OrderIndependentTransparency.js";import{stencilWriteMaskOn as d,stencilBaseAllZerosParams as f}from"../lib/StencilUtils.js";import{VertexAttribute as b}from"../lib/VertexAttribute.js";import{advancedMRRFactors as O}from"./pbrUtils.js";import{P as j}from"../../../../chunks/Path.glsl.js";import{SpecialDrawBuffers as P}from"../../../webgl/enums.js";import{makePipelineState as T,frontFaceCullingParams as g,defaultDepthWrite as E,defaultColorWrite as L}from"../../../webgl/renderState.js";class I extends o{constructor(){super(...arguments),this.ambient=r(.2,.2,.2),this.diffuse=r(.8,.8,.8),this.specular=r(0,0,0),this.opacity=1,this.origin=e(),this.modelTransformation=null,this.mrrFactors=O,this.emissiveFactor=s}}class R extends a{constructor(r,e){super(r,e,new n(j,(()=>import("../shaders/Path.glsl.js"))),F)}initializePipeline(r){const{output:e,transparent:s,hasSlicePlane:o,doubleSidedMode:n,hasOccludees:a,oitPass:b}=r,O=b===m.NONE,j=b===m.FrontFace;return T({blending:t(e)&&s?c(b):null,culling:o&&!s&&n!==l.None?g:null,depthTest:{func:p(b)},depthWrite:O||j?E:null,drawBuffers:e===i.Depth?{buffers:[P.NONE]}:u(b,e),colorWrite:L,stencilWrite:a?d:null,stencilTest:a?f:null,polygonOffset:O||j?null:h})}}const F=new Map([[b.POSITION,0],[b.FEATUREVALUE,1],[b.PROFILEVERTEXANDNORMAL,2],[b.PROFILEAUXDATA,3],[b.PROFILERIGHT,4],[b.PROFILEUP,5],[b.OLIDCOLOR,6]]);export{I as PathPassParameters,R as PathTechnique,F as vertexAttributeLocations};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{Float16Array as e}from"@petamoriken/float16";import t from"../../../../core/Logger.js";import{clamp as r}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{copy as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{i as a,d as n,f as o,h as l,g as c,c as p,l as h,j as f,t as m}from"../../../../chunks/vec32.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as T}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{PlaneIndex as d}from"../../../../geometry/support/frustum.js";import{create as _,distance2 as E,fromPoints as A,closestLineSegmentPoint as R}from"../../../../geometry/support/lineSegment.js";import{create as g,fromPoints as S,signedDistance as O,getNormal as I}from"../../../../geometry/support/plane.js";import{newLayout as v}from"../../support/buffer/InterleavedLayout.js";import{isHighlightOrOID as P,isColorOrColorEmission as N,isDepth as L,isColorEmissionHighlightOIDOrDepth as b,is2DGeometryOutput as C,ShaderOutput as U}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as j}from"../effects/geometry/olidUtils.js";import y from"../lib/GLMaterial.js";import{Material as D,RenderOccludedFlag as w}from"../lib/Material.js";import{RenderSlot as F}from"../lib/RenderSlot.js";import{isTranslationMatrix as M}from"../lib/Util.js";import{VertexAttribute as x}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as J}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as B}from"./internal/bufferWriterUtils.js";import{LineMarkerAnchor as z}from"../shaders/LineMarkerTechniqueConfiguration.js";import{r as H}from"../../../../chunks/RibbonLine.glsl.js";import{vertexAttributeLocations as G,RibbonLineTechnique as k}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as V,CapType as W}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as Z}from"../../../../webscene/support/AlphaCutoff.js";var Y;!function(e){e[e.LEFT_JOIN_START=-2]="LEFT_JOIN_START",e[e.LEFT_JOIN_END=-1]="LEFT_JOIN_END",e[e.LEFT_CAP_START=-4]="LEFT_CAP_START",e[e.LEFT_CAP_END=-5]="LEFT_CAP_END",e[e.RIGHT_JOIN_START=2]="RIGHT_JOIN_START",e[e.RIGHT_JOIN_END=1]="RIGHT_JOIN_END",e[e.RIGHT_CAP_START=4]="RIGHT_CAP_START",e[e.RIGHT_CAP_END=5]="RIGHT_CAP_END"}(Y||(Y={}));class q extends D{constructor(e){super(e,Q),this._configuration=new V,this.vertexAttributeLocations=G,this.produces=new Map([[F.OPAQUE_MATERIAL,e=>P(e)||N(e)&&this.parameters.renderOccluded===w.OccludeAndTransparentStencil],[F.OPAQUE_MATERIAL_WITHOUT_NORMALS,e=>L(e)],[F.OCCLUDER_MATERIAL,e=>b(e)&&this.parameters.renderOccluded===w.OccludeAndTransparentStencil],[F.TRANSPARENT_OCCLUDER_MATERIAL,e=>b(e)&&this.parameters.renderOccluded===w.OccludeAndTransparentStencil],[F.TRANSPARENT_MATERIAL,e=>N(e)&&this.parameters.writeDepth&&this.parameters.renderOccluded!==w.OccludeAndTransparentStencil],[F.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>N(e)&&!this.parameters.writeDepth&&this.parameters.renderOccluded!==w.OccludeAndTransparentStencil],[F.DRAPED_MATERIAL,e=>C(e)]])}getConfiguration(e,t){super.getConfiguration(e,t,this._configuration),this._configuration.oitPass=t.oitPass,this._configuration.draped=t.slot===F.DRAPED_MATERIAL;const r=null!=this.parameters.stipplePattern&&e!==U.Highlight;return this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&te(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=t.hasOccludees,this._configuration.occluder=this.parameters.renderOccluded===w.OccludeAndTransparentStencil,this._configuration.terrainDepthTest=t.terrainDepthTest&&N(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration}get visible(){return this.parameters.color[3]>=Z||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>Z}intersectDraped({attributes:e,screenToWorldRatio:t},i,s,a,n,o){if(!s.options.selectionMode)return;const l=e.get(x.SIZE);let c=this.parameters.width;if(this.parameters.vvSize){const t=e.get(x.SIZEFEATUREATTRIBUTE).data[0];Number.isNaN(t)?c*=this.parameters.vvSize.fallback[0]:c*=r(this.parameters.vvSize.offset[0]+t*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else l&&(c*=l.data[0]);const p=a[0],h=a[1],f=(c/2+4)*t;let m=Number.MAX_VALUE,u=0;const T=e.get(x.POSITION).data,d=ee(this.parameters,e)?T.length-2:T.length-5;for(let _=0;_<d;_+=3){const e=T[_],t=T[_+1],i=(_+3)%T.length,s=p-e,a=h-t,n=T[i]-e,o=T[i+1]-t,l=r((n*s+o*a)/(n*n+o*o),0,1),c=n*l-s,f=o*l-a,d=c*c+f*f;d<m&&(m=d,u=_/3)}m<f*f&&n(o.dist,o.normal,u,!1)}intersect(e,i,m,u,T,_){if(!m.options.selectionMode||!e.visible)return;if(!M(i))return void t.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const g=e.attributes,v=g.get(x.POSITION).data;let P=this.parameters.width;if(this.parameters.vvSize){const e=g.get(x.SIZEFEATUREATTRIBUTE).data[0];Number.isNaN(e)||(P*=r(this.parameters.vvSize.offset[0]+e*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0]))}else g.has(x.SIZE)&&(P*=g.get(x.SIZE).data[0]);const N=m.camera,L=ne;s(L,m.point);const b=P*N.pixelRatio/2+4*N.pixelRatio;a(de[0],L[0]-b,L[1]+b,0),a(de[1],L[0]+b,L[1]+b,0),a(de[2],L[0]+b,L[1]-b,0),a(de[3],L[0]-b,L[1]-b,0);for(let t=0;t<4;t++)if(!N.unprojectFromRenderScreen(de[t],_e[t]))return;S(N.eye,_e[0],_e[1],Ee),S(N.eye,_e[1],_e[2],Ae),S(N.eye,_e[2],_e[3],Re),S(N.eye,_e[3],_e[0],ge);let C=Number.MAX_VALUE,U=0;const j=ee(this.parameters,g)?v.length-2:v.length-5;for(let t=0;t<j;t+=3){re[0]=v[t]+i[12],re[1]=v[t+1]+i[13],re[2]=v[t+2]+i[14];const e=(t+3)%v.length;if(ie[0]=v[e]+i[12],ie[1]=v[e+1]+i[13],ie[2]=v[e+2]+i[14],O(Ee,re)<0&&O(Ee,ie)<0||O(Ae,re)<0&&O(Ae,ie)<0||O(Re,re)<0&&O(Re,ie)<0||O(ge,re)<0&&O(ge,ie)<0)continue;if(N.projectToRenderScreen(re,oe),N.projectToRenderScreen(ie,le),oe[2]<0&&le[2]>0){n(se,re,ie);const e=N.frustum,t=-O(e[d.NEAR],re)/o(se,I(e[d.NEAR]));l(se,se,t),c(re,re,se),N.projectToRenderScreen(re,oe)}else if(oe[2]>0&&le[2]<0){n(se,ie,re);const e=N.frustum,t=-O(e[d.NEAR],ie)/o(se,I(e[d.NEAR]));l(se,se,t),c(ie,ie,se),N.projectToRenderScreen(ie,le)}else if(oe[2]<0&&le[2]<0)continue;oe[2]=0,le[2]=0;const r=E(A(oe,le,he),L);r<C&&(C=r,p(ce,re),p(pe,ie),U=t/3)}const y=m.rayBegin,D=m.rayEnd;if(C<b*b){let e=Number.MAX_VALUE;if(R(A(ce,pe,he),A(y,D,fe),ae)){n(ae,ae,y);const t=h(ae);l(ae,ae,1/t),e=t/f(y,D)}_(e,ae,U,!1)}}get _layout(){const e=v().vec3f(x.POSITION).vec4f16(x.PREVIOUSDELTA).vec4f16(x.NEXTDELTA).f32(x.U0).vec2f16(x.LINEPARAMETERS);return this.parameters.vvColor?e.f16(x.COLORFEATUREATTRIBUTE):e.vec4u8(x.COLOR),this.parameters.vvSize?e.f16(x.SIZEFEATUREATTRIBUTE):e.f16(x.SIZE),this.parameters.vvOpacity&&e.f16(x.OPACITYFEATUREATTRIBUTE),j()&&e.vec4u8(x.OLIDCOLOR),e}createBufferWriter(){return new K(this._layout,this.parameters)}createGLMaterial(e){return new X(e)}validateParameters(e){"miter"!==e.join&&(e.miterLimit=0),null!=e.markerParameters&&(e.markerScale=e.markerParameters.width/e.width)}}class X extends y{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures.release(this._stipplePattern),this._stipplePattern=null}beginSlot(e){const t=this._material.parameters.stipplePattern;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.getTechnique(k,e)}}class Q extends J{constructor(){super(...arguments),this.width=0,this.color=T,this.join="miter",this.cap=W.BUTT,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1}get transparent(){return this.color[3]<1||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}}class K{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t,this.numJoinSubdivisions=0;const r=t.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=r;break;case"round":this.numJoinSubdivisions=H+r}}_isClosed(e){return ee(this._parameters,e)}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(e){const t=2,r=e.get(x.POSITION).indices.length/2+1,i=this._isClosed(e);let s=i?2:2*t;return s+=((i?r:r-1)-(i?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(t,r,i,s,n,o){const l=i.get(x.POSITION),c=l.indices,h=l.data.length/3,u=i.get(x.DISTANCETOSTART)?.data;c&&c.length!==2*(h-1)&&console.warn("RibbonLineMaterial does not support indices");const T=i.get(x.SIZEFEATUREATTRIBUTE)?.data[0]??i.get(x.SIZE)?.data[0]??1;let d=[1,1,1,1],_=0;const E=this.vertexBufferLayout.fields.has(x.COLORFEATUREATTRIBUTE);E?_=i.get(x.COLORFEATUREATTRIBUTE).data[0]:i.has(x.COLOR)&&(d=i.get(x.COLOR).data);const A=this.vertexBufferLayout.fields.has(x.OPACITYFEATUREATTRIBUTE),R=A?i.get(x.OPACITYFEATUREATTRIBUTE).data[0]:0,g=new Float32Array(n.buffer),S=new e(n.buffer),O=new Uint8Array(n.buffer),I=this.vertexBufferLayout.stride/4;let v=o*I;const P=v;let N=0;const L=u?(e,t,r)=>N=u[r]:(e,t,r)=>N+=f(e,t),b=(e,t,r,i,a,n,o)=>{g[v++]=t[0],g[v++]=t[1],g[v++]=t[2],B(e,t,S,2*v),v+=2,B(r,t,S,2*v),v+=2,g[v++]=o;let l=2*v;if(S[l++]=i,S[l++]=a,E)S[l++]=_;else{const e=Math.min(4*n,d.length-4),t=2*l;l+=2,O[t]=d[e],O[t+1]=d[e+1],O[t+2]=d[e+2],O[t+3]=d[e+3]}S[l++]=T,A&&(S[l++]=R);let c=2*l;j()&&s&&(O[c++]=s[0],O[c++]=s[1],O[c++]=s[2],O[c++]=s[3]),v=Math.ceil(.25*c)};v+=I,a(ue,l.data[0],l.data[1],l.data[2]),t&&m(ue,ue,t);const C=this._isClosed(i);if(C){const e=l.data.length-3;a(me,l.data[e],l.data[e+1],l.data[e+2]),t&&m(me,me,t)}else a(Te,l.data[3],l.data[4],l.data[5]),t&&m(Te,Te,t),b(ue,ue,Te,1,Y.LEFT_CAP_START,0,0),b(ue,ue,Te,1,Y.RIGHT_CAP_START,0,0),p(me,ue),p(ue,Te);const U=C?0:1,y=C?h:h-1;for(let e=U;e<y;e++){const r=(e+1)%h*3;a(Te,l.data[r],l.data[r+1],l.data[r+2]),t&&m(Te,Te,t),L(me,ue,e),b(me,ue,Te,0,Y.LEFT_JOIN_END,e,N),b(me,ue,Te,0,Y.RIGHT_JOIN_END,e,N);const i=this.numJoinSubdivisions;for(let t=0;t<i;++t){const r=(t+1)/(i+1);b(me,ue,Te,r,Y.LEFT_JOIN_END,e,N),b(me,ue,Te,r,Y.RIGHT_JOIN_END,e,N)}b(me,ue,Te,1,Y.LEFT_JOIN_START,e,N),b(me,ue,Te,1,Y.RIGHT_JOIN_START,e,N),p(me,ue),p(ue,Te)}C?(a(Te,l.data[3],l.data[4],l.data[5]),t&&m(Te,Te,t),N=L(me,ue,y),b(me,ue,Te,0,Y.LEFT_JOIN_END,U,N),b(me,ue,Te,0,Y.RIGHT_JOIN_END,U,N)):(N=L(me,ue,y),b(me,ue,ue,0,Y.LEFT_CAP_END,y,N),b(me,ue,ue,0,Y.RIGHT_CAP_END,y,N)),$(g,P+I,g,P,I);return v=$(g,v-I,g,v,I),this._parameters.wireframe&&this._addWireframeVertices(n,P,v,I),null}_addWireframeVertices(e,t,r,i){const s=new Float32Array(e.buffer,r*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,r-t);let n=0;const o=e=>n=$(a,e,s,n,i);for(let l=0;l<a.length-1;l+=2*i)o(l),o(l+2*i),o(l+1*i),o(l+2*i),o(l+1*i),o(l+3*i)}}function $(e,t,r,i,s){for(let a=0;a<s;a++)r[i++]=e[t++];return i}function ee(e,t){if(!e.isClosed)return!1;return t.get(x.POSITION).indices.length>2}function te(e){return e.anchor===z.Tip&&e.hideOnShortSegments&&"begin-end"===e.placement&&e.worldSpace}const re=u(),ie=u(),se=u(),ae=u(),ne=u(),oe=i(),le=i(),ce=u(),pe=u(),he=_(),fe=_(),me=u(),ue=u(),Te=u(),de=[i(),i(),i(),i()],_e=[u(),u(),u(),u()],Ee=g(),Ae=g(),Re=g(),ge=g();export{Q as Parameters,q as RibbonLineMaterial};
5
+ import{Float16Array as e}from"@petamoriken/float16";import t from"../../../../core/Logger.js";import{clamp as r}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{copy as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{i as a,d as n,f as o,h as l,g as c,c as p,l as h,j as f,t as m}from"../../../../chunks/vec32.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as T}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{PlaneIndex as d}from"../../../../geometry/support/frustum.js";import{create as _,distance2 as E,fromPoints as A,closestLineSegmentPoint as R}from"../../../../geometry/support/lineSegment.js";import{create as g,fromPoints as S,signedDistance as O,getNormal as I}from"../../../../geometry/support/plane.js";import{newLayout as v}from"../../support/buffer/InterleavedLayout.js";import{isHighlightOrOID as P,isColorOrColorEmission as N,isDepth as L,isColorEmissionHighlightOIDOrDepth as b,is2DGeometryOutput as C,ShaderOutput as U}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as y}from"../effects/geometry/olidUtils.js";import j from"../lib/GLMaterial.js";import{Material as D,RenderOccludedFlag as w}from"../lib/Material.js";import{RenderSlot as F}from"../lib/RenderSlot.js";import{isTranslationMatrix as M}from"../lib/Util.js";import{VertexAttribute as x}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as B}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as J}from"./internal/bufferWriterUtils.js";import{LineMarkerAnchor as z}from"../shaders/LineMarkerTechniqueConfiguration.js";import{r as H}from"../../../../chunks/RibbonLine.glsl.js";import{vertexAttributeLocations as G,RibbonLineTechnique as k}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as Z,CapType as V}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as W}from"../../../../webscene/support/AlphaCutoff.js";var Y;!function(e){e[e.LEFT_JOIN_START=-2]="LEFT_JOIN_START",e[e.LEFT_JOIN_END=-1]="LEFT_JOIN_END",e[e.LEFT_CAP_START=-4]="LEFT_CAP_START",e[e.LEFT_CAP_END=-5]="LEFT_CAP_END",e[e.RIGHT_JOIN_START=2]="RIGHT_JOIN_START",e[e.RIGHT_JOIN_END=1]="RIGHT_JOIN_END",e[e.RIGHT_CAP_START=4]="RIGHT_CAP_START",e[e.RIGHT_CAP_END=5]="RIGHT_CAP_END"}(Y||(Y={}));class q extends D{constructor(e){super(e,Q),this._configuration=new Z,this.vertexAttributeLocations=G,this.produces=new Map([[F.OPAQUE_MATERIAL,e=>P(e)||N(e)&&this.parameters.renderOccluded===w.OccludeAndTransparentStencil],[F.OPAQUE_MATERIAL_WITHOUT_NORMALS,e=>L(e)],[F.OCCLUDER_MATERIAL,e=>b(e)&&this.parameters.renderOccluded===w.OccludeAndTransparentStencil],[F.TRANSPARENT_OCCLUDER_MATERIAL,e=>b(e)&&this.parameters.renderOccluded===w.OccludeAndTransparentStencil],[F.TRANSPARENT_MATERIAL,e=>N(e)&&this.parameters.writeDepth&&this.parameters.renderOccluded!==w.OccludeAndTransparentStencil],[F.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>N(e)&&!this.parameters.writeDepth&&this.parameters.renderOccluded!==w.OccludeAndTransparentStencil],[F.DRAPED_MATERIAL,e=>C(e)]])}getConfiguration(e,t){super.getConfiguration(e,t,this._configuration),this._configuration.oitPass=t.oitPass,this._configuration.draped=t.slot===F.DRAPED_MATERIAL;const r=null!=this.parameters.stipplePattern&&e!==U.Highlight;return this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&te(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=t.hasOccludees,this._configuration.occluder=this.parameters.renderOccluded===w.OccludeAndTransparentStencil,this._configuration.terrainDepthTest=t.terrainDepthTest&&N(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration}get visible(){return this.parameters.color[3]>=W||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>W}intersectDraped({attributes:e,screenToWorldRatio:t},i,s,a,n,o){if(!s.options.selectionMode)return;const l=e.get(x.SIZE);let c=this.parameters.width;if(this.parameters.vvSize){const t=e.get(x.SIZEFEATUREATTRIBUTE).data[0];Number.isNaN(t)?c*=this.parameters.vvSize.fallback[0]:c*=r(this.parameters.vvSize.offset[0]+t*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else l&&(c*=l.data[0]);const p=a[0],h=a[1],f=(c/2+4)*t;let m=Number.MAX_VALUE,u=0;const T=e.get(x.POSITION).data,d=ee(this.parameters,e)?T.length-2:T.length-5;for(let _=0;_<d;_+=3){const e=T[_],t=T[_+1],i=(_+3)%T.length,s=p-e,a=h-t,n=T[i]-e,o=T[i+1]-t,l=r((n*s+o*a)/(n*n+o*o),0,1),c=n*l-s,f=o*l-a,d=c*c+f*f;d<m&&(m=d,u=_/3)}m<f*f&&n(o.dist,o.normal,u,!1)}intersect(e,i,m,u,T,_){if(!m.options.selectionMode||!e.visible)return;if(!M(i))return void t.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const g=e.attributes,v=g.get(x.POSITION).data;let P=this.parameters.width;if(this.parameters.vvSize){const e=g.get(x.SIZEFEATUREATTRIBUTE).data[0];Number.isNaN(e)||(P*=r(this.parameters.vvSize.offset[0]+e*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0]))}else g.has(x.SIZE)&&(P*=g.get(x.SIZE).data[0]);const N=m.camera,L=ne;s(L,m.point);const b=P*N.pixelRatio/2+4*N.pixelRatio;a(de[0],L[0]-b,L[1]+b,0),a(de[1],L[0]+b,L[1]+b,0),a(de[2],L[0]+b,L[1]-b,0),a(de[3],L[0]-b,L[1]-b,0);for(let t=0;t<4;t++)if(!N.unprojectFromRenderScreen(de[t],_e[t]))return;S(N.eye,_e[0],_e[1],Ee),S(N.eye,_e[1],_e[2],Ae),S(N.eye,_e[2],_e[3],Re),S(N.eye,_e[3],_e[0],ge);let C=Number.MAX_VALUE,U=0;const y=ee(this.parameters,g)?v.length-2:v.length-5;for(let t=0;t<y;t+=3){re[0]=v[t]+i[12],re[1]=v[t+1]+i[13],re[2]=v[t+2]+i[14];const e=(t+3)%v.length;if(ie[0]=v[e]+i[12],ie[1]=v[e+1]+i[13],ie[2]=v[e+2]+i[14],O(Ee,re)<0&&O(Ee,ie)<0||O(Ae,re)<0&&O(Ae,ie)<0||O(Re,re)<0&&O(Re,ie)<0||O(ge,re)<0&&O(ge,ie)<0)continue;if(N.projectToRenderScreen(re,oe),N.projectToRenderScreen(ie,le),oe[2]<0&&le[2]>0){n(se,re,ie);const e=N.frustum,t=-O(e[d.NEAR],re)/o(se,I(e[d.NEAR]));l(se,se,t),c(re,re,se),N.projectToRenderScreen(re,oe)}else if(oe[2]>0&&le[2]<0){n(se,ie,re);const e=N.frustum,t=-O(e[d.NEAR],ie)/o(se,I(e[d.NEAR]));l(se,se,t),c(ie,ie,se),N.projectToRenderScreen(ie,le)}else if(oe[2]<0&&le[2]<0)continue;oe[2]=0,le[2]=0;const r=E(A(oe,le,he),L);r<C&&(C=r,p(ce,re),p(pe,ie),U=t/3)}const j=m.rayBegin,D=m.rayEnd;if(C<b*b){let e=Number.MAX_VALUE;if(R(A(ce,pe,he),A(j,D,fe),ae)){n(ae,ae,j);const t=h(ae);l(ae,ae,1/t),e=t/f(j,D)}_(e,ae,U,!1)}}get _layout(){const e=v().vec3f(x.POSITION).vec4f16(x.PREVIOUSDELTA).vec4f16(x.NEXTDELTA).f32(x.U0).vec2f16(x.LINEPARAMETERS);return this.parameters.vvSize?e.f32(x.SIZEFEATUREATTRIBUTE):e.f16(x.SIZE),this.parameters.vvColor?e.f16(x.COLORFEATUREATTRIBUTE):e.vec4u8(x.COLOR,{glNormalized:!0}),this.parameters.vvOpacity&&e.f16(x.OPACITYFEATUREATTRIBUTE),y()&&e.vec4u8(x.OLIDCOLOR),e}createBufferWriter(){return new K(this._layout,this.parameters)}createGLMaterial(e){return new X(e)}validateParameters(e){"miter"!==e.join&&(e.miterLimit=0),null!=e.markerParameters&&(e.markerScale=e.markerParameters.width/e.width)}}class X extends j{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures.release(this._stipplePattern),this._stipplePattern=null}beginSlot(e){const t=this._material.parameters.stipplePattern;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.getTechnique(k,e)}}class Q extends B{constructor(){super(...arguments),this.width=0,this.color=T,this.join="miter",this.cap=V.BUTT,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1}get transparent(){return this.color[3]<1||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}}class K{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t;const r=t.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=r;break;case"round":this.numJoinSubdivisions=H+r}}_isClosed(e){return ee(this._parameters,e)}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(e){const t=2,r=e.get(x.POSITION).indices.length/2+1,i=this._isClosed(e);let s=i?2:2*t;return s+=((i?r:r-1)-(i?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(t,r,i,s,n,o){const l=i.get(x.POSITION),c=l.indices,h=l.data.length/3,u=i.get(x.DISTANCETOSTART)?.data;c&&c.length!==2*(h-1)&&console.warn("RibbonLineMaterial does not support indices");const T=this.vertexBufferLayout.fields.has(x.SIZEFEATUREATTRIBUTE),d=(T?i.get(x.SIZEFEATUREATTRIBUTE)?.data[0]:i.get(x.SIZE)?.data[0])??1;let _=[1,1,1,1],E=0;const A=this.vertexBufferLayout.fields.has(x.COLORFEATUREATTRIBUTE);A?E=i.get(x.COLORFEATUREATTRIBUTE).data[0]:i.has(x.COLOR)&&(_=i.get(x.COLOR).data);const R=this.vertexBufferLayout.fields.has(x.OPACITYFEATUREATTRIBUTE),g=R?i.get(x.OPACITYFEATUREATTRIBUTE).data[0]:0,S=new Float32Array(n.buffer),O=new e(n.buffer),I=new Uint8Array(n.buffer),v=this.vertexBufferLayout.stride/4;let P=o*v;const N=P;let L=0;const b=u?(e,t,r)=>L=u[r]:(e,t,r)=>L+=f(e,t),C=(e,t,r,i,a,n,o)=>{S[P++]=t[0],S[P++]=t[1],S[P++]=t[2],J(e,t,O,2*P),P+=2,J(r,t,O,2*P),P+=2,S[P++]=o;let l=2*P;if(O[l++]=i,O[l++]=a,T?(P=Math.ceil(.5*l),S[P]=d,l+=2):O[l++]=d,A)O[l++]=E;else{const e=Math.min(4*n,_.length-4),t=2*l;l+=2,I[t]=255*_[e],I[t+1]=255*_[e+1],I[t+2]=255*_[e+2],I[t+3]=255*_[e+3]}R&&(O[l++]=g);let c=2*l;y()&&s&&(I[c++]=s[0],I[c++]=s[1],I[c++]=s[2],I[c++]=s[3]),P=Math.ceil(.25*c)};P+=v,a(ue,l.data[0],l.data[1],l.data[2]),t&&m(ue,ue,t);const U=this._isClosed(i);if(U){const e=l.data.length-3;a(me,l.data[e],l.data[e+1],l.data[e+2]),t&&m(me,me,t)}else a(Te,l.data[3],l.data[4],l.data[5]),t&&m(Te,Te,t),C(ue,ue,Te,1,Y.LEFT_CAP_START,0,0),C(ue,ue,Te,1,Y.RIGHT_CAP_START,0,0),p(me,ue),p(ue,Te);const j=U?0:1,D=U?h:h-1;for(let e=j;e<D;e++){const r=(e+1)%h*3;a(Te,l.data[r],l.data[r+1],l.data[r+2]),t&&m(Te,Te,t),b(me,ue,e),C(me,ue,Te,0,Y.LEFT_JOIN_END,e,L),C(me,ue,Te,0,Y.RIGHT_JOIN_END,e,L);const i=this.numJoinSubdivisions;for(let t=0;t<i;++t){const r=(t+1)/(i+1);C(me,ue,Te,r,Y.LEFT_JOIN_END,e,L),C(me,ue,Te,r,Y.RIGHT_JOIN_END,e,L)}C(me,ue,Te,1,Y.LEFT_JOIN_START,e,L),C(me,ue,Te,1,Y.RIGHT_JOIN_START,e,L),p(me,ue),p(ue,Te)}U?(a(Te,l.data[3],l.data[4],l.data[5]),t&&m(Te,Te,t),L=b(me,ue,D),C(me,ue,Te,0,Y.LEFT_JOIN_END,j,L),C(me,ue,Te,0,Y.RIGHT_JOIN_END,j,L)):(L=b(me,ue,D),C(me,ue,ue,0,Y.LEFT_CAP_END,D,L),C(me,ue,ue,0,Y.RIGHT_CAP_END,D,L)),$(S,N+v,S,N,v);return P=$(S,P-v,S,P,v),this._parameters.wireframe&&this._addWireframeVertices(n,N,P,v),null}_addWireframeVertices(e,t,r,i){const s=new Float32Array(e.buffer,r*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,r-t);let n=0;const o=e=>n=$(a,e,s,n,i);for(let l=0;l<a.length-1;l+=2*i)o(l),o(l+2*i),o(l+1*i),o(l+2*i),o(l+1*i),o(l+3*i)}}function $(e,t,r,i,s){for(let a=0;a<s;a++)r[i++]=e[t++];return i}function ee(e,t){if(!e.isClosed)return!1;return t.get(x.POSITION).indices.length>2}function te(e){return e.anchor===z.Tip&&e.hideOnShortSegments&&"begin-end"===e.placement&&e.worldSpace}const re=u(),ie=u(),se=u(),ae=u(),ne=u(),oe=i(),le=i(),ce=u(),pe=u(),he=_(),fe=_(),me=u(),ue=u(),Te=u(),de=[i(),i(),i(),i()],_e=[u(),u(),u(),u()],Ee=g(),Ae=g(),Re=g(),ge=g();export{Q as Parameters,q as RibbonLineMaterial};