@arcgis/core 4.32.0-next.20241228 → 4.32.0-next.20241230

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.
@@ -2,7 +2,7 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{earth as e,mars as o,moon as r}from"../geometry/support/Ellipsoid.js";import{OverlayContent as a}from"../views/3d/terrain/OverlayContent.js";import{IntegratedMeshMode as i}from"../views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js";import{ComponentData as l,ComponentDataType as t}from"../views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js";import{VertexDiscardMode as n}from"../views/3d/webgl-engine/collections/Component/Material/shader/VertexDiscardMode.js";import{ForwardLinearDepth as d}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{ShaderOutput as s,isColorOrColorEmission as g}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SlicePass as m}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{TextureCoordinateAttribute as c}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexColor as v}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js";import{VertexNormal as h}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js";import{VertexPosition as u}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js";import{OutputDepth as w}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js";import{OutputHighlight as p}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js";import{computeFragmentNormals as b}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js";import{ComputeMaterialColor as C}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import{ComputeNormalTexture as f}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import{EvaluateSceneLighting as y,addLightingGlobalFactor as x}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightIntensity as L}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{PBRMode as j,PhysicallyBasedRenderingParameters as O}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReadBaseColorTexture as S}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import{ReadShadowMapPass as M}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{terrainDepthTest as N}from"../views/3d/webgl-engine/core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import{OverlayIM as T,getIMColorTexture as $}from"../views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{alphaCutoff as A}from"../views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{DiscardOrAdjustAlphaDraw as W}from"../views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import{EllipsoidMode as D}from"../views/3d/webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{If as P,glsl as B}from"../views/3d/webgl-engine/core/shaderModules/interfaces.js";import{ShaderBuilder as R}from"../views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js";import{Texture2DPassUniform as z}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{outputColorHighlightOID as E}from"../views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js";function H(H){const I=new R;I.include(u,H),I.include(h,H),I.include(v,H),I.include(c,H),I.include(d,H),I.include(l,H),I.include(W,H),I.fragment.include(m,H),I.include(S,H),I.include(N,H);const{vertex:V,fragment:F}=I,{output:_,pbrMode:G,hasNormalTexture:k,snowCover:q,receiveShadows:U,spherical:J,ellipsoidMode:K}=H,Q=G===j.Normal||G===j.Schematic;Q&&(I.include(O,H),k&&I.include(f,H));const X=_===s.Shadow||_===s.ShadowHighlight||_===s.ShadowExcludeHighlight,Y=X&&H.componentData===t.Varying,Z=H.integratedMeshMode===i.ColorOverlay||H.integratedMeshMode===i.ColorOverlayWithWater;if(Z){I.include(y,H),I.include(T,H);const a=K===D.Earth,i=K===D.Earth,l=a?e.radius:i?o.radius:r.radius;V.code.add(`\n ${P(J,`const float invRadius = ${B.float(1/l)};`)}\n vec2 projectOverlay(vec3 pos) { return pos.xy ${P(J,"/ (1.0 + invRadius * pos.z);")}; }`)}const ee=Z&&g(_)&&G===j.WaterOnIntegratedMesh;ee&&(I.varyings.add("tbnTangent","vec3"),I.varyings.add("tbnBiTangent","vec3"),I.varyings.add("groundNormal","vec3"));const oe=H.vertexDiscardMode===n.None,re=H.vertexDiscardMode===n.Opaque,ae=1-1/255;if(V.main.add(B`
5
+ import{earth as e,mars as o,moon as r}from"../geometry/support/Ellipsoid.js";import{OverlayContent as a}from"../views/3d/terrain/OverlayContent.js";import{IntegratedMeshMode as i}from"../views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js";import{ComponentData as l,ComponentDataType as t}from"../views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js";import{VertexDiscardMode as n}from"../views/3d/webgl-engine/collections/Component/Material/shader/VertexDiscardMode.js";import{ForwardLinearDepth as d}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{ShaderOutput as s,isColorOrColorEmission as g}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SlicePass as m}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{TextureCoordinateAttribute as c}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexColor as v}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js";import{VertexNormal as h}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js";import{VertexPosition as u}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js";import{OutputDepth as w}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js";import{OutputHighlight as p}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js";import{computeFragmentNormals as b}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js";import{ComputeMaterialColor as C}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import{ComputeNormalTexture as f}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import{EvaluateSceneLighting as y,addLightingGlobalFactor as x}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightIntensity as L}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{PBRMode as j,PhysicallyBasedRenderingParameters as S}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReadBaseColorTexture as M}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import{ReadShadowMapPass as O}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{terrainDepthTest as N}from"../views/3d/webgl-engine/core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import{OverlayIM as T,getIMColorTexture as $}from"../views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{alphaCutoff as A}from"../views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{DiscardOrAdjustAlphaDraw as W}from"../views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import{EllipsoidMode as D}from"../views/3d/webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{If as P,glsl as B}from"../views/3d/webgl-engine/core/shaderModules/interfaces.js";import{ShaderBuilder as R}from"../views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js";import{Texture2DPassUniform as z}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{outputColorHighlightOID as E}from"../views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js";function H(H){const I=new R;I.include(u,H),I.include(h,H),I.include(v,H),I.include(c,H),I.include(d,H),I.include(l,H),I.include(W,H),I.fragment.include(m,H),I.include(M,H),I.include(N,H);const{vertex:V,fragment:F}=I,{output:_,pbrMode:G,hasNormalTexture:k,snowCover:q,receiveShadows:U,spherical:J,ellipsoidMode:K}=H,Q=G===j.Normal||G===j.Schematic;Q&&(I.include(S,H),k&&I.include(f,H));const X=_===s.Shadow||_===s.ShadowHighlight||_===s.ShadowExcludeHighlight,Y=X&&H.componentData===t.Varying,Z=H.integratedMeshMode===i.ColorOverlay||H.integratedMeshMode===i.ColorOverlayWithWater;if(Z){I.include(y,H),I.include(T,H);const a=K===D.Earth,i=K===D.Earth,l=a?e.radius:i?o.radius:r.radius;V.code.add(`\n ${P(J,`const float invRadius = ${B.float(1/l)};`)}\n vec2 projectOverlay(vec3 pos) { return pos.xy ${P(J,"/ (1.0 + invRadius * pos.z);")}; }`)}const ee=Z&&g(_)&&G===j.WaterOnIntegratedMesh;ee&&(I.varyings.add("tbnTangent","vec3"),I.varyings.add("tbnBiTangent","vec3"),I.varyings.add("groundNormal","vec3"));const oe=H.vertexDiscardMode===n.None,re=H.vertexDiscardMode===n.Opaque,ae=1-1/255;if(V.main.add(B`
6
6
  bool castShadows;
7
7
  vec4 externalColor = forwardExternalColor(castShadows);
8
8
  ${P(Y,"if(!castShadows) { gl_Position = vec4(vec3(1e38), 1.0); return; }")}
@@ -32,7 +32,7 @@ import{earth as e,mars as o,moon as r}from"../geometry/support/Ellipsoid.js";imp
32
32
  tbnTangent = vec3(1.0, 0.0, 0.0);
33
33
  tbnBiTangent = vec3(0.0, 1.0, 0.0);`:""}
34
34
  ${Z?B`setOverlayVTC(projectOverlay(position));`:""}
35
- `),g(_))return I.include(C,H),I.include(b,H),I.include(y,H),I.include(E,H),U&&I.include(M,H),F.code.add(B`
35
+ `),g(_))return I.include(C,H),I.include(b,H),I.include(y,H),I.include(E,H),U&&I.include(O,H),F.code.add(B`
36
36
  float evaluateShadow() {
37
37
  return ${U?"readShadowMap(vPositionWorldCameraRelative, linearDepth)":"0.0"};
38
38
  }`),Z&&F.uniforms.add(new z("ovColorTex",((e,o)=>$(e,o)))),F.main.add(B`
@@ -102,7 +102,7 @@ import{earth as e,mars as o,moon as r}from"../geometry/support/Ellipsoid.js";imp
102
102
 
103
103
  ${P(ne,"outputDepth(linearDepth);")}
104
104
  ${P(ie,B`fragColor = vec4(vec3(0.5) + 0.5 * fragmentFaceNormalView, 1.0);`)}
105
- ${P(le,Z?"fragColor = getOverlayColorTexel(vtcOverlay);":"outputObjectAndLayerIdColor();")}
105
+ ${P(le,Z?"fragColor = getOverlayColorTexel();":"outputObjectAndLayerIdColor();")}
106
106
  ${P(te,B`${P(Z,B`
107
107
  vec2 overlayHighlightTexel = getAllOverlayHighlightValuesEncoded();
108
108
  outputAllHighlights(overlayHighlightTexel);`,B`calculateOcclusionAndOutputHighlight();`)}`)}`),I}const I=Object.freeze(Object.defineProperty({__proto__:null,build:H},Symbol.toStringTag,{value:"Module"}));export{I as C,H as b};
@@ -112,4 +112,4 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
112
112
  vec2 overlayHighlightTexel = getAllOverlayHighlightValuesEncoded();
113
113
  outputAllHighlights(overlayHighlightTexel);`,"calculateOcclusionAndOutputHighlight();")}
114
114
  `)}if(G===d.ObjectAndLayerIdColor)if(re)r.pbrMode=O.Disabled,i.include(P,r),r.pbrMode=R,M.main.add(F`gl_Position = transformPosition(proj, view, position);
115
- setOverlayVTC(getUV0());`),B.main.add(F`fragColor = getOverlayColorTexel(vtcOverlay);`);else{const e=X===t.Opaque;M.main.add(F`${U(e,"gl_Position = transformPosition(proj, view, position);")}`),B.main.add(F`fragColor = vec4(0.0);`)}return i}const I=r(),q=i(),G=Object.freeze(Object.defineProperty({__proto__:null,TerrainPassParameters:B,build:E},Symbol.toStringTag,{value:"Module"}));export{B as T,G as a,E as b};
115
+ setOverlayVTC(getUV0());`),B.main.add(F`fragColor = getOverlayColorTexel();`);else{const e=X===t.Opaque;M.main.add(F`${U(e,"gl_Position = transformPosition(proj, view, position);")}`),B.main.add(F`fragColor = vec4(0.0);`)}return i}const I=r(),q=i(),G=Object.freeze(Object.defineProperty({__proto__:null,TerrainPassParameters:B,build:E},Symbol.toStringTag,{value:"Module"}));export{B as T,G as a,E as b};
package/core/has.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- let e;function has(a){return"function"==typeof e[a]?e[a]=e[a](globalThis):e[a]}e=globalThis.dojoConfig?.has||globalThis.esriConfig?.has?{...globalThis.dojoConfig?.has,...globalThis.esriConfig?.has}:{},has.add=(a,d,o,i)=>{(i||void 0===e[a])&&(e[a]=d),o&&has(a)},has.cache=e,has.add("big-integer-warning-enabled",!0),has.add("esri-deprecation-warnings",!0),has.add("esri-tests-disable-screenshots",!1),has.add("esri-tests-use-full-window",!1),has.add("esri-tests-post-to-influx",!0),has.add("esri-cim-animations-enable-status","enabled"),has.add("esri-cim-animations-spotlight",!1),has.add("esri-cim-animations-freeze-time",!1),has.add("enable-feature:multiple-highlights",!1),(()=>{has.add("host-webworker",void 0!==globalThis.WorkerGlobalScope&&self instanceof globalThis.WorkerGlobalScope);const e="undefined"!=typeof window&&"undefined"!=typeof location&&"undefined"!=typeof document&&window.location===location&&window.document===document;if(has.add("host-browser",e),has.add("host-node","object"==typeof globalThis.process&&globalThis.process.versions?.node&&globalThis.process.versions.v8),has.add("dom",e),has("host-browser")){const e=navigator,a=e.userAgent,d=e.appVersion,o=parseFloat(d);if(has.add("wp",parseFloat(a.split("Windows Phone")[1])||void 0),has.add("msapp",parseFloat(a.split("MSAppHost/")[1])||void 0),has.add("khtml",d.includes("Konqueror")?o:void 0),has.add("edge",parseFloat(a.split("Edge/")[1])||void 0),has.add("opr",parseFloat(a.split("OPR/")[1])||void 0),has.add("webkit",!has("wp")&&!has("edge")&&parseFloat(a.split("WebKit/")[1])||void 0),has.add("chrome",!has("edge")&&!has("opr")&&parseFloat(a.split("Chrome/")[1])||void 0),has.add("android",!has("wp")&&parseFloat(a.split("Android ")[1])||void 0),has.add("safari",!d.includes("Safari")||has("wp")||has("chrome")||has("android")||has("edge")||has("opr")?void 0:parseFloat(d.split("Version/")[1])),has.add("mac",d.includes("Macintosh")),!has("wp")&&/(iPhone|iPod|iPad)/.test(a)){const e=RegExp.$1.replace(/P/,"p"),d=/OS ([\d_]+)/.test(a)?RegExp.$1:"1",o=parseFloat(d.replace(/_/,".").replaceAll("_",""));has.add(e,o),has.add("ios",o)}has("webkit")||(!a.includes("Gecko")||has("wp")||has("khtml")||has("edge")||has.add("mozilla",o),has("mozilla")&&has.add("ff",parseFloat(a.split("Firefox/")[1]||a.split("Minefield/")[1])||void 0))}})(),(()=>{if(globalThis.navigator){const e=navigator.userAgent,a=/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini|IEMobile/i.test(e),d=/iPhone/i.test(e);a&&has.add("esri-mobile",a),d&&has.add("esri-iPhone",d),has.add("esri-geolocation",!!navigator.geolocation)}has.add("esri-wasm","WebAssembly"in globalThis),has.add("esri-performance-mode-frames-between-render",20),has.add("esri-force-performance-mode",!1),has.add("esri-shared-array-buffer",(()=>{const e="SharedArrayBuffer"in globalThis,a=!1===globalThis.crossOriginIsolated;return e&&!a})),has.add("wasm-simd",(()=>{const e=[0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11];return WebAssembly.validate(new Uint8Array(e))})),has.add("esri-atomics","Atomics"in globalThis),has.add("esri-workers","Worker"in globalThis),has.add("web-feat:cache","caches"in globalThis),has.add("esri-workers-arraybuffer-transfer",!has("safari")||Number(has("safari"))>=12),has.add("workers-pool-size",8),has.add("featurelayer-simplify-thresholds",[.5,.5,.5,.5]),has.add("featurelayer-simplify-payload-size-factors",[1,1,4]),has.add("featurelayer-fast-triangulation-enabled",!0),has.add("featurelayer-animation-enabled",!0),has.add("featurelayer-snapshot-enabled",!0),has.add("featurelayer-snapshot-point-min-threshold",8e4),has.add("featurelayer-snapshot-point-max-threshold",4e5),has.add("featurelayer-snapshot-point-coverage",.1),has.add("featurelayer-query-max-depth",4),has.add("featurelayer-query-pausing-enabled",!1),has.add("featurelayer-advanced-symbols",!1),has.add("featurelayer-pbf",!0),has.add("featurelayer-pbf-statistics",!1),has.add("feature-layers-workers",!0),has.add("feature-polyline-generalization-factor",1),has.add("mapview-transitions-duration",200),has.add("mapview-essential-goto-duration",200),has.add("mapview-srswitch-adjust-rotation-scale-threshold",24e6),has.add("mapserver-pbf-version-support",10.81),has.add("mapservice-popup-identify-max-tolerance",20),has("host-webworker")||has("host-browser")&&(has.add("esri-csp-restrictions",(()=>{try{new Function}catch{return!0}return!1})),has.add("esri-image-decode",(()=>{if("decode"in new Image){const e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg version="1.1" xmlns="http://www.w3.org/2000/svg"></svg>',void e.decode().then((()=>{has.add("esri-image-decode",!0,!0,!0)})).catch((()=>{has.add("esri-image-decode",!1,!0,!0)}))}return!1})),has.add("esri-url-encodes-apostrophe",(()=>{const e=window.document.createElement("a");return e.href="?'",e.href.includes("?%27")})))})();export{has as default};
5
+ let e;function has(a){return"function"==typeof e[a]?e[a]=e[a](globalThis):e[a]}e=globalThis.dojoConfig?.has||globalThis.esriConfig?.has?{...globalThis.dojoConfig?.has,...globalThis.esriConfig?.has}:{},has.add=(a,d,o,i)=>{(i||void 0===e[a])&&(e[a]=d),o&&has(a)},has.cache=e,has.add("big-integer-warning-enabled",!0),has.add("esri-deprecation-warnings",!0),has.add("esri-tests-disable-screenshots",!1),has.add("esri-tests-use-full-window",!1),has.add("esri-tests-post-to-influx",!0),has.add("esri-cim-animations-enable-status","enabled"),has.add("esri-cim-animations-spotlight",!1),has.add("esri-cim-animations-freeze-time",!1),has.add("enable-feature:multiple-highlights",!0),(()=>{has.add("host-webworker",void 0!==globalThis.WorkerGlobalScope&&self instanceof globalThis.WorkerGlobalScope);const e="undefined"!=typeof window&&"undefined"!=typeof location&&"undefined"!=typeof document&&window.location===location&&window.document===document;if(has.add("host-browser",e),has.add("host-node","object"==typeof globalThis.process&&globalThis.process.versions?.node&&globalThis.process.versions.v8),has.add("dom",e),has("host-browser")){const e=navigator,a=e.userAgent,d=e.appVersion,o=parseFloat(d);if(has.add("wp",parseFloat(a.split("Windows Phone")[1])||void 0),has.add("msapp",parseFloat(a.split("MSAppHost/")[1])||void 0),has.add("khtml",d.includes("Konqueror")?o:void 0),has.add("edge",parseFloat(a.split("Edge/")[1])||void 0),has.add("opr",parseFloat(a.split("OPR/")[1])||void 0),has.add("webkit",!has("wp")&&!has("edge")&&parseFloat(a.split("WebKit/")[1])||void 0),has.add("chrome",!has("edge")&&!has("opr")&&parseFloat(a.split("Chrome/")[1])||void 0),has.add("android",!has("wp")&&parseFloat(a.split("Android ")[1])||void 0),has.add("safari",!d.includes("Safari")||has("wp")||has("chrome")||has("android")||has("edge")||has("opr")?void 0:parseFloat(d.split("Version/")[1])),has.add("mac",d.includes("Macintosh")),!has("wp")&&/(iPhone|iPod|iPad)/.test(a)){const e=RegExp.$1.replace(/P/,"p"),d=/OS ([\d_]+)/.test(a)?RegExp.$1:"1",o=parseFloat(d.replace(/_/,".").replaceAll("_",""));has.add(e,o),has.add("ios",o)}has("webkit")||(!a.includes("Gecko")||has("wp")||has("khtml")||has("edge")||has.add("mozilla",o),has("mozilla")&&has.add("ff",parseFloat(a.split("Firefox/")[1]||a.split("Minefield/")[1])||void 0))}})(),(()=>{if(globalThis.navigator){const e=navigator.userAgent,a=/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini|IEMobile/i.test(e),d=/iPhone/i.test(e);a&&has.add("esri-mobile",a),d&&has.add("esri-iPhone",d),has.add("esri-geolocation",!!navigator.geolocation)}has.add("esri-wasm","WebAssembly"in globalThis),has.add("esri-performance-mode-frames-between-render",20),has.add("esri-force-performance-mode",!1),has.add("esri-shared-array-buffer",(()=>{const e="SharedArrayBuffer"in globalThis,a=!1===globalThis.crossOriginIsolated;return e&&!a})),has.add("wasm-simd",(()=>{const e=[0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11];return WebAssembly.validate(new Uint8Array(e))})),has.add("esri-atomics","Atomics"in globalThis),has.add("esri-workers","Worker"in globalThis),has.add("web-feat:cache","caches"in globalThis),has.add("esri-workers-arraybuffer-transfer",!has("safari")||Number(has("safari"))>=12),has.add("workers-pool-size",8),has.add("featurelayer-simplify-thresholds",[.5,.5,.5,.5]),has.add("featurelayer-simplify-payload-size-factors",[1,1,4]),has.add("featurelayer-fast-triangulation-enabled",!0),has.add("featurelayer-animation-enabled",!0),has.add("featurelayer-snapshot-enabled",!0),has.add("featurelayer-snapshot-point-min-threshold",8e4),has.add("featurelayer-snapshot-point-max-threshold",4e5),has.add("featurelayer-snapshot-point-coverage",.1),has.add("featurelayer-query-max-depth",4),has.add("featurelayer-query-pausing-enabled",!1),has.add("featurelayer-advanced-symbols",!1),has.add("featurelayer-pbf",!0),has.add("featurelayer-pbf-statistics",!1),has.add("feature-layers-workers",!0),has.add("feature-polyline-generalization-factor",1),has.add("mapview-transitions-duration",200),has.add("mapview-essential-goto-duration",200),has.add("mapview-srswitch-adjust-rotation-scale-threshold",24e6),has.add("mapserver-pbf-version-support",10.81),has.add("mapservice-popup-identify-max-tolerance",20),has("host-webworker")||has("host-browser")&&(has.add("esri-csp-restrictions",(()=>{try{new Function}catch{return!0}return!1})),has.add("esri-image-decode",(()=>{if("decode"in new Image){const e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg version="1.1" xmlns="http://www.w3.org/2000/svg"></svg>',void e.decode().then((()=>{has.add("esri-image-decode",!0,!0,!0)})).catch((()=>{has.add("esri-image-decode",!1,!0,!0)}))}return!1})),has.add("esri-url-encodes-apostrophe",(()=>{const e=window.document.createElement("a");return e.href="?'",e.href.includes("?%27")})))})();export{has as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.32.0-next.20241228",
3
+ "version": "4.32.0-next.20241230",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- const c="20241228",d="6f2aeabc77930f3507de4bdc256bc0a0494d2c3d";export{c as buildDate,d as commitHash};
5
+ const c="20241230",e="1428528de162a2ca858776f7bcf20832d3b649ef";export{c as buildDate,e as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as c}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,i as h,f as u}from"../../../chunks/vec32.js";import{ZEROS as _,fromValues as f,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as b,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as T}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as R}from"../../ViewingMode.js";import{TextureUpdate as x}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlayContent as v}from"./OverlayContent.js";import{overlayRenderOccludedFlag as w}from"./OverlayRenderer.js";import{PatchRenderData as P}from"./PatchRenderData.js";import{RenderOrder as D}from"./RenderOrder.js";import{TerrainAttributesCache as S}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as E}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{TileUpdate as A}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as N,compareTiles as B}from"./tileUtils.js";import{TransparencyMode as I}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as q,ComponentIntersectionData as F}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as U}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncRenderPlugin as M,ConsumesDepth as L,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as z}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as V}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as Y}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as Q,StoreResults as W}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as X}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as K,intersectTriangles as Z,MeshIntersectionOptions as J}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as $}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as ee}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as te}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ie,getVerticalOffsetTerrain as re}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as se}from"../webgl-engine/materials/DrawParameters.js";import{T as ne}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as ae}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as oe}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as le}from"../../webgl/enums.js";const ce=7,de=10,he=b();let ue=class extends M{get _isGlobal(){return this._stage.viewingMode===R.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=Q.TERRAIN,this.isGround=!0,this._passParameters=new ne,this._drawParameters=new se,this._renderDataPool=new s(P),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new j,this._castShadows=!1,this._inViewshed=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=X.Occlude,this.produces=new Map([[$.OPAQUE_TERRAIN,()=>this._produces()&&this.transparency===I.Opaque],[$.TRANSPARENT_TERRAIN,()=>this._produces()&&(this.transparency===I.Transparent||this.transparency===I.InvisibleWithDraped)],[$.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileSize=256,this._configuration=new oe(t.viewingMode===R.Global),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new S(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?w:X.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?L:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return ie}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,A.TEXTURE_FADING)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===A.TEXTURE_FADING?x.FADING:x.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[O.ELEVATION])i.pendingUpdates&=~A.GEOMETRY;e.resetPendingUpdate(A.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=de-ce,i=Math.max(0,Math.floor((e.level-t)/ce)*ce);if(this._isGlobal&&0===i)return _;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=V.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=V.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=V.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C({rctx:this._rctx,tileSize:this._tileSize,techniques:this._techniques,cache:this._tileTextureCache}),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==I.Opaque)return;const s=_e,n=fe;d(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,_=e.options.store===W.MIN,f=!!e.results.ground.target,p=re(e.verticalOffset),g=e.tolerance;let m,b=_&&null!=a.dist?a.dist:1/0;const R=e.options,x=R.normalRequired||!R.backfacesTerrain,O=new J(!1,x),v=h=>{const f=h.renderData;if(!f?.vao)return;const v=f.geometry;y(he,v.boundingBox);const w=f.localOrigin;null!=p&&(p.localOrigin=w,p.applyToAabb(he));const P=he;if(pe[0]=i[0]-w[0],pe[1]=i[1]-w[1],pe[2]=i[2]-w[2],!K(P,pe,n,g,b))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),b=_&&null!=a.dist?a.dist:1/0},S=(n,c,d)=>{if((!x||null!=d)&&n>=0&&(R.backfacesTerrain||u(d,s)<0)&&(R.invisibleTerrain||!R.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),R.isFiltered)return;R.store===W.ALL&&(null==m?(m=Y(e.ray),D(m,n,d),e.results.all.push(m)):n<m.dist&&D(m,n,d)),(null==a.dist||n<a.dist)&&D(a,n,d),R.store!==W.MIN&&(null==o.dist||n>o.dist)&&D(o,n,d)}},E=ge;d(E,r,w);const{indices:C,indexCount:A}=v,j=v.vertexAttributes,N=j.getField(te.POSITION,T),B=new z(N.typedBuffer,3,j.stride/4),I=A/3;if(!p&&I>q){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new F(C,0,I,B)),e.intersectionData.intersectRay(pe,E,O,S)}else Z(pe,E,0,I,C,B,p,O,S)},w=this._rootTiles;if(null!=w){(()=>{const t=this._tileIterator;t.reset(w);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==p&&!e.intersectsRay(i,s,g,b)||f&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}acquireTechniques(e){const t=!!has("enable-feature:terrain-shadows")&&e.bind.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bind.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bind.slot===$.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&w))return null}else{const t=this.transparency===I.Opaque?$.OPAQUE_TERRAIN:$.TRANSPARENT_TERRAIN;if(e.bind.slot!==t)return null}if(this.transparency===I.Invisible)return null;switch(this._configuration.screenSpaceReflections=this._configuration.cloudReflections=this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._configuration.overlayMode=this._overlayRenderer.mode,e.output){case U.Color:case U.ColorEmission:return this._configuration.screenSpaceReflections=null!=e.bind.ssr.lastFrameColor,this._configuration.cloudReflections=null!=e.bind.clouds.data,this._configuration.receiveShadows=e.bind.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bind.ssao,this._acquireTechnique(e.output,e.bind.slot===$.OCCLUDED_TERRAIN);case U.Shadow:case U.ShadowExcludeHighlight:return this._castShadows?this._acquireTechnique(U.Shadow,!1):null;case U.ViewshedShadow:return this._inViewshed?this._acquireTechnique(U.ViewshedShadow,!1):null;case U.Depth:case U.Normal:return this._acquireTechnique(e.output,!1);case U.ObjectAndLayerIdColor:return this._acquireTechnique(U.ObjectAndLayerIdColor,!1);case U.Highlight:return this._overlayRenderer.hasHighlights?this._acquireTechnique(U.Highlight,!1):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case U.Color:case U.ColorEmission:{const i=e.bind.slot===$.OCCLUDED_TERRAIN?v.Occluded:v.Color;this._renderMaterialPass(e,t,i);break}case U.Depth:case U.Normal:this._renderAuxiliaryPass(e,t,v.Color,this._visiblePatchesByOrigin);break;case U.Highlight:this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(v.Highlight)&&this._renderAuxiliaryPass(e,t,v.Highlight,this._visiblePatchesByOrigin);break;case U.Shadow:case U.ShadowExcludeHighlight:case U.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case U.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,v.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=f(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,x.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?G.GridComposite:null!=i.backgroundColor?G.ColorComposite:G.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==D.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>B(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bind,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],le.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bind,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bind.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=ee(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===v.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",_),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:_;this._configuration.tileBlendInput===G.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?le.LINES:le.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;this._drawParameters.origin=r,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._configuration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,c,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(E&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.rctx.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._techniques.acquire(ae,this._configuration)}get test(){}};e([o({readOnly:!0})],ue.prototype,"_isGlobal",null),e([o()],ue.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],ue.prototype,"renderingDisabled",null),e([o({value:!0})],ue.prototype,"visible",null),e([o()],ue.prototype,"renderPatchBorders",null),e([o()],ue.prototype,"visualizeNormals",null),e([o()],ue.prototype,"cullBackFaces",null),e([o({value:D.FRONT_TO_BACK})],ue.prototype,"renderOrder",null),e([o()],ue.prototype,"wireframe",null),ue=e([l("esri.views.3d.terrain.TerrainRenderer")],ue);const _e=p(),fe=p(),pe=p(),ge=p();export{ue as TerrainRenderer};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as c}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,i as h,f as u}from"../../../chunks/vec32.js";import{ZEROS as _,fromValues as f,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as b,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as T}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as R}from"../../ViewingMode.js";import{TextureUpdate as x}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlayContent as v}from"./OverlayContent.js";import{overlayRenderOccludedFlag as w}from"./OverlayRenderer.js";import{PatchRenderData as P}from"./PatchRenderData.js";import{RenderOrder as D}from"./RenderOrder.js";import{TerrainAttributesCache as S}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as E}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{TileUpdate as A}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as N,compareTiles as B}from"./tileUtils.js";import{TransparencyMode as I}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as q,ComponentIntersectionData as F}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as U}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncRenderPlugin as L,ConsumesDepth as M,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as z}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as V}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as Y}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as Q,StoreResults as W}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as X}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as K,intersectTriangles as Z,MeshIntersectionOptions as J}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as $}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as ee}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as te}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ie,getVerticalOffsetTerrain as re}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as se}from"../webgl-engine/materials/DrawParameters.js";import{T as ne}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as ae}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as oe}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as le}from"../../webgl/enums.js";const ce=7,de=10,he=b();let ue=class extends L{get _isGlobal(){return this._stage.viewingMode===R.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=Q.TERRAIN,this.isGround=!0,this._passParameters=new ne,this._drawParameters=new se,this._renderDataPool=new s(P),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new j,this._castShadows=!1,this._inViewshed=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=X.Occlude,this.produces=new Map([[$.OPAQUE_TERRAIN,()=>this._produces()&&this.transparency===I.Opaque],[$.TRANSPARENT_TERRAIN,()=>this._produces()&&(this.transparency===I.Transparent||this.transparency===I.InvisibleWithDraped)],[$.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileSize=256,this._configuration=new oe(t.viewingMode===R.Global),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new S(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?w:X.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?M:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return ie}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,A.TEXTURE_FADING)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===A.TEXTURE_FADING?x.FADING:x.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[O.ELEVATION])i.pendingUpdates&=~A.GEOMETRY;e.resetPendingUpdate(A.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=de-ce,i=Math.max(0,Math.floor((e.level-t)/ce)*ce);if(this._isGlobal&&0===i)return _;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=V.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=V.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=V.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C({rctx:this._rctx,tileSize:this._tileSize,techniques:this._techniques,cache:this._tileTextureCache}),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==I.Opaque)return;const s=_e,n=fe;d(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,_=e.options.store===W.MIN,f=!!e.results.ground.target,p=re(e.verticalOffset),g=e.tolerance;let m,b=_&&null!=a.dist?a.dist:1/0;const R=e.options,x=R.normalRequired||!R.backfacesTerrain,O=new J(!1,x),v=h=>{const f=h.renderData;if(!f?.vao)return;const v=f.geometry;y(he,v.boundingBox);const w=f.localOrigin;null!=p&&(p.localOrigin=w,p.applyToAabb(he));const P=he;if(pe[0]=i[0]-w[0],pe[1]=i[1]-w[1],pe[2]=i[2]-w[2],!K(P,pe,n,g,b))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),b=_&&null!=a.dist?a.dist:1/0},S=(n,c,d)=>{if((!x||null!=d)&&n>=0&&(R.backfacesTerrain||u(d,s)<0)&&(R.invisibleTerrain||!R.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),R.isFiltered)return;R.store===W.ALL&&(null==m?(m=Y(e.ray),D(m,n,d),e.results.all.push(m)):n<m.dist&&D(m,n,d)),(null==a.dist||n<a.dist)&&D(a,n,d),R.store!==W.MIN&&(null==o.dist||n>o.dist)&&D(o,n,d)}},E=ge;d(E,r,w);const{indices:C,indexCount:A}=v,j=v.vertexAttributes,N=j.getField(te.POSITION,T),B=new z(N.typedBuffer,3,j.stride/4),I=A/3;if(!p&&I>q){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new F(C,0,I,B)),e.intersectionData.intersectRay(pe,E,O,S)}else Z(pe,E,0,I,C,B,p,O,S)},w=this._rootTiles;if(null!=w){(()=>{const t=this._tileIterator;t.reset(w);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==p&&!e.intersectsRay(i,s,g,b)||f&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}acquireTechniques(e){const t=!!has("enable-feature:terrain-shadows")&&e.bind.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bind.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bind.slot===$.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&w))return null}else{const t=this.transparency===I.Opaque?$.OPAQUE_TERRAIN:$.TRANSPARENT_TERRAIN;if(e.bind.slot!==t)return null}if(this.transparency===I.Invisible)return null;switch(this._configuration.screenSpaceReflections=this._configuration.cloudReflections=this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._configuration.overlayMode=this._overlayRenderer.mode,e.output){case U.Color:case U.ColorEmission:return this._configuration.screenSpaceReflections=null!=e.bind.ssr.lastFrameColor,this._configuration.cloudReflections=null!=e.bind.clouds.data,this._configuration.receiveShadows=e.bind.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bind.ssao,this._acquireTechnique(e.output,e.bind.slot===$.OCCLUDED_TERRAIN);case U.Shadow:case U.ShadowExcludeHighlight:return this._castShadows?this._acquireTechnique(U.Shadow,!1):null;case U.ViewshedShadow:return this._inViewshed?this._acquireTechnique(U.ViewshedShadow,!1):null;case U.Depth:case U.Normal:return this._acquireTechnique(e.output,!1);case U.ObjectAndLayerIdColor:return this._acquireTechnique(U.ObjectAndLayerIdColor,!1);case U.Highlight:return this._overlayRenderer.hasHighlights?this._acquireTechnique(U.Highlight,!1):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case U.Color:case U.ColorEmission:{const i=e.bind.slot===$.OCCLUDED_TERRAIN?v.Occluded:v.Color;this._renderMaterialPass(e,t,i);break}case U.Depth:case U.Normal:this._renderAuxiliaryPass(e,t,v.Color,this._visiblePatchesByOrigin);break;case U.Highlight:this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(v.Highlight)&&0===e.bind.highlightLevel&&this._renderAuxiliaryPass(e,t,v.Highlight,this._visiblePatchesByOrigin);break;case U.Shadow:case U.ShadowExcludeHighlight:case U.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case U.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,v.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=f(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,x.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?G.GridComposite:null!=i.backgroundColor?G.ColorComposite:G.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==D.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>B(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bind,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],le.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bind,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bind.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=ee(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===v.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",_),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:_;this._configuration.tileBlendInput===G.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?le.LINES:le.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;this._drawParameters.origin=r,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._configuration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,c,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(E&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.rctx.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._techniques.acquire(ae,this._configuration)}get test(){}};e([o({readOnly:!0})],ue.prototype,"_isGlobal",null),e([o()],ue.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],ue.prototype,"renderingDisabled",null),e([o({value:!0})],ue.prototype,"visible",null),e([o()],ue.prototype,"renderPatchBorders",null),e([o()],ue.prototype,"visualizeNormals",null),e([o()],ue.prototype,"cullBackFaces",null),e([o({value:D.FRONT_TO_BACK})],ue.prototype,"renderOrder",null),e([o()],ue.prototype,"wireframe",null),ue=e([l("esri.views.3d.terrain.TerrainRenderer")],ue);const _e=p(),fe=p(),pe=p(),ge=p();export{ue as TerrainRenderer};
@@ -2,7 +2,7 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{ShaderOutput as i}from"../ShaderOutput.js";import{Integer2PassUniform as e}from"../../shaderModules/Integer2PassUniform.js";import{IntegerPassUniform as t}from"../../shaderModules/IntegerPassUniform.js";import{glsl as h}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as l}from"../../shaderModules/Texture2DPassUniform.js";function g(g,d){const{fragment:c}=g;d.output===i.Highlight?(c.uniforms.add(new l("depthTexture",((i,e)=>e.mainDepth)),new l("highlightTexture",((i,e)=>e.highlightMixTexture)),new t("highlightLevel",((i,e)=>e.highlightLevel??0)),new e("highlightMixOrigin",((i,e)=>e.highlightMixOrigin))),g.outputs.add("fragHighlight","vec2",0),c.code.add(h`vec2 getAccumulatedHighlight() {
5
+ import{ShaderOutput as i}from"../ShaderOutput.js";import{Integer2PassUniform as e}from"../../shaderModules/Integer2PassUniform.js";import{IntegerPassUniform as t}from"../../shaderModules/IntegerPassUniform.js";import{glsl as h}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as l}from"../../shaderModules/Texture2DPassUniform.js";function g(g,d){const{fragment:u}=g;d.output===i.Highlight?(u.uniforms.add(new l("depthTexture",((i,e)=>e.mainDepth)),new l("highlightTexture",((i,e)=>e.highlightMixTexture)),new t("highlightLevel",((i,e)=>e.highlightLevel??0)),new e("highlightMixOrigin",((i,e)=>e.highlightMixOrigin))),g.outputs.add("fragHighlight","vec2",0),u.code.add(h`vec2 getAccumulatedHighlight() {
6
6
  return texelFetch(highlightTexture, ivec2(gl_FragCoord.xy) - highlightMixOrigin, 0).rg;
7
7
  }
8
8
  void outputHighlight(bool occluded) {
@@ -30,10 +30,10 @@ return gl_FragCoord.z > sceneDepth + 5e-7;
30
30
  }
31
31
  void calculateOcclusionAndOutputHighlight() {
32
32
  outputHighlight(isHighlightOccluded());
33
- }`),d.canHaveOverlay&&(c.constants.add("occlusionAndMask","int",85),c.code.add(h`void outputAllHighlights(vec2 highlightToAdd) {
33
+ }`),d.canHaveOverlay&&(u.constants.add("occlusionAndMask","int",85),u.code.add(h`void outputAllHighlights(vec2 highlightToAdd) {
34
34
  if (highlightToAdd == vec2(0.0)) { discard; }
35
- int occludedOrMask = isHighlightOccluded() ? 0xaa : 0;
36
- ivec2 added = ivec2(highlightToAdd * 255.0);
37
- ivec2 masked = (added & ivec2(occlusionAndMask)) | (ivec2(occludedOrMask) & (added<<1));
35
+ uint occludedOrMask = isHighlightOccluded() ? 0xaau : 0u;
36
+ uvec2 added = uvec2(highlightToAdd * 255.0);
37
+ uvec2 masked = (added & uvec2(occlusionAndMask)) | (uvec2(occludedOrMask) & (added<<1));
38
38
  fragHighlight = vec2(masked) / 255.0;
39
- }`))):c.code.add(h`void calculateOcclusionAndOutputHighlight() {}`)}export{g as OutputHighlight};
39
+ }`))):u.code.add(h`void calculateOcclusionAndOutputHighlight() {}`)}export{g as OutputHighlight};
@@ -15,7 +15,8 @@ bool isValid1 = isValid(texCoords.zw, vec2(0.0, 0.0));
15
15
  return mix(color1 * float(isValid1), color0, float(isValid0));
16
16
  }`),a.code.add(y`vec4 getCombinedOverlayColor() {
17
17
  return overlayOpacity * getOverlayColor(ovColorTex, vtcOverlay);
18
- }`),a.code.add(y`vec4 getOverlayColorTexel(vec4 texCoords) {
18
+ }`),a.code.add(y`vec4 getOverlayColorTexel() {
19
+ vec4 texCoords = vtcOverlay;
19
20
  vec2 texDim = vec2(textureSize(ovColorTex, 0));
20
21
  vec4 color0 = texelFetch(ovColorTex, ivec2(vec2(texCoords.x * 0.5, texCoords.y) * texDim), 0);
21
22
  vec4 color1 = texelFetch(ovColorTex, ivec2(vec2(texCoords.z * 0.5 + 0.5, texCoords.w) * texDim), 0);
@@ -28,8 +29,8 @@ vec2 uvInner = texCoords.xy;
28
29
  vec2 uvOuter = texCoords.zw;
29
30
  bool isValidInner = isValid(uvInner, fwidth(uvInner));
30
31
  bool isValidOuter = isValid(uvOuter, vec2(0.0, 0.0));
31
- vec2 texelCoordInner = vec2(uvInner.x * 0.5, uvInner.y);
32
- vec2 texelCoordOuter = vec2(uvOuter.x * 0.5 + 0.5, uvOuter.y);
32
+ vec2 texelCoordInner = uvInner * vec2(0.5, 1.0);
33
+ vec2 texelCoordOuter = uvOuter * vec2(0.5, 1.0) + vec2(0.5,0.0);
33
34
  vec2 texDim = vec2(textureSize(ovColorTex, 0));
34
35
  vec2 texelValueInner = texelFetch(ovColorTex, ivec2(texelCoordInner * texDim), 0).rg;
35
36
  vec2 texelValueOuter = texelFetch(ovColorTex, ivec2(texelCoordOuter * texDim), 0).rg;
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ZEROS as t}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderCategory as n}from"../../../webgl.js";import{ColorFormat as i}from"../../../webgl/formats.js";import s from"../../../webgl/RenderNode.js";import{alphaCutoff as a}from"../../core/shaderLibrary/util/AlphaCutoff.js";import{If as c,glsl as l}from"../../core/shaderModules/interfaces.js";import{Default3D as u}from"../../lib/DefaultVertexAttributeLocations.js";import{FramebufferBit as p,ColorAttachment as d,BlendFactor as f,SizedPixelFormat as h,PixelFormat as m,DataType as T}from"../../../../webgl/enums.js";let v=class extends s{constructor(e){super(e),this.destroyedCB=null,this.produces=n.FINAL,this.consumes={required:[n.FINAL]},this.clearColor=t,this._focusedFBOType=0,this._program=new Map}destroy(){this._program.forEach((e=>e.dispose())),this._program.clear(),this.destroyedCB()}render(e){const r=e.find((({name:e})=>e===n.FINAL));if(!this._focusedFBO)return r;const o=this.renderingContext;o.bindFramebuffer(r.fbo),o.setClearColor(0,0,0,0),o.clear(p.COLOR);const t=this._ensureShader(o,!1,0);return o.useProgram(t),o.bindTexture(this._focusedFBO.getTexture(),0),t.setUniform1i("colorTex",0),t.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&t.setUniform2fv("nearFar",this.camera.nearFar),o.screen.draw(),r}getDownscaledFBO(e,r,o,t,n,s){o===g.ON&&(n=e.width,s=e.height);const a=this.renderingContext,{colorTexture:c,depthStencilTexture:l}=e,u=c?.descriptor,m=this._ensureShader(a,null!=l,r),T=this.fboCache.acquire(n,s,"fbo visualizer"),v=!u?.hasMipmap&&!u?.isImmutable;v&&c?.generateMipmap(),a.useProgram(m),a.bindFramebuffer(T.fbo);let F=0;const x=[d.COLOR_ATTACHMENT0],C=null!=l;if(a.bindTexture(c,F),m.setUniform1i("colorTex",F),l){F++,a.bindTexture(l,F),m.setUniform1i("depthTex",F);const e=d.COLOR_ATTACHMENT0+F;T.acquireColor(e,i.RGBA,"depth to color"),x.push(e)}for(let p=0;p<r;p++){F++;const r=d.COLOR_ATTACHMENT0+F,o=C?1:0;a.bindTexture(e.getColorTexture(r-o),F),m.setUniform1i("colorTex"+(F-o-1),F),T.acquireColor(r,i.RGBA),x.push(r)}a.gl.drawBuffers(x);const b=a.getViewport();a.setViewport(0,0,n,s),a.setClearColor(0,0,0,0),a.clear(p.COLOR),a.setBlendingEnabled(!0),a.setBlendFunction(f.ONE,f.ONE_MINUS_SRC_ALPHA);const O="linear-depth"===t||t.includes("shadow"),_=u?.internalFormat,A=O?3:_===h.R16F||_===h.R32F||_===h.R8?1:_===h.RG8?2:_===h.RGBA16F?4:0;return m.setUniform1i("inputType",A),O&&m.setUniform2fv("nearFar",this.camera.nearFar),a.screen.draw(),a.bindFramebuffer(null),a.setViewport(b.x,b.y,b.width,b.height),o===g.ON&&(this._focusedFBO=T,this._focusedFBOType=A),v&&e.colorTexture?.clearMipmap(),T}clearFocusedFBO(){this._focusedFBO=null}getPreviewContent(e,r,o,t){if(!o)return null;const n=this.renderingContext,i=this.fboCache.acquire(e,r,"fbo visualizer");n.bindFramebuffer(i?.fbo),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(p.COLOR),n.setBlendingEnabled(!0),n.setBlendFunction(f.ONE,f.ONE_MINUS_SRC_ALPHA),n.setViewport(0,0,e,r);const s=this._ensureShader(n,!1,0);n.useProgram(s),n.bindTexture(o.getColorTexture(t),0),s.setUniform1i("colorTex",0),s.setUniform1i("inputType",0),n.screen.draw();const a=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,m.RGBA,T.UNSIGNED_BYTE,new Uint8Array(a.data.buffer)),n.bindFramebuffer(null),i?.release(),a}_ensureShader(e,r,o){const t={hasDepth:r,attachments:o},n=this._program.get(t);if(n)return n;const i="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",s=(e,r)=>{let o="";const t=e?2:1;for(let n=0;n<r;n++)o+=`layout(location = ${l.int(t+n)}) out vec4 fragColor${l.int(n)};\n uniform sampler2D colorTex${l.int(n)};`;return o},p=e=>{let r="";for(let o=0;o<e;o++)r+=`fragColor${l.int(o)} = texture(colorTex${l.int(o)}, uv);`;return r},d=`#version 300 es\n precision highp float;\n\n in vec2 uv;\n uniform sampler2D colorTex;\n layout(location = 0) out vec4 fragColor;\n ${c(r,"layout(location = 1) out vec4 fragDepth;\n uniform sampler2D depthTex;")}\n ${s(r,o)}\n uniform int inputType;\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgbaTofloat(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgbaTofloat(depth));\n }\n\n float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }\n\n void main() {\n vec4 color;\n if(inputType == 1) {\n color = vec4(vec3(texture(colorTex, uv).r), 1.0);\n } else if(inputType == 2) {\n color = vec4(texture(colorTex, uv).rg, 0.0, 1.0);\n } else if(inputType == 3) {\n float depth = 1.0 - (-linearDepthFromTexture(colorTex, uv) / (nearFar[1] - nearFar[0]));\n color = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if(inputType == 4) {\n color = texture(colorTex, uv);\n color = vec4(color.rgb / color.a, color.a);\n } else {\n color = texture(colorTex, uv);\n }\n\n\n if(color.a < ${l.float(a)})\n discard;\n else {\n fragColor = color;\n ${c(r,"float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);")}\n ${c(o>0,p(o))}\n }\n }`;return this._program.set(t,e.programCache.acquire(i,d,u)),this._program.get(t)}};var g;e([r()],v.prototype,"destroyedCB",void 0),e([r()],v.prototype,"produces",void 0),e([r()],v.prototype,"consumes",void 0),e([r()],v.prototype,"clearColor",void 0),v=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],v),function(e){e[e.ON=0]="ON",e[e.OFF=1]="OFF"}(g||(g={}));export{g as FocusState,v as RenderNodeVisualizerNode};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ZEROS as t}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderCategory as n}from"../../../webgl.js";import{ColorFormat as i}from"../../../webgl/formats.js";import s from"../../../webgl/RenderNode.js";import{alphaCutoff as a}from"../../core/shaderLibrary/util/AlphaCutoff.js";import{If as c,glsl as l}from"../../core/shaderModules/interfaces.js";import{Default3D as u}from"../../lib/DefaultVertexAttributeLocations.js";import{FramebufferBit as p,ColorAttachment as h,BlendFactor as d,SizedPixelFormat as f,PixelFormat as m,DataType as v}from"../../../../webgl/enums.js";let g=class extends s{constructor(e){super(e),this.destroyedCB=null,this.produces=n.FINAL,this.consumes={required:[n.FINAL]},this.clearColor=t,this._focusedFBOType=0,this._program=new Map}destroy(){this._program.forEach((e=>e.dispose())),this._program.clear(),this.destroyedCB()}render(e){const r=e.find((({name:e})=>e===n.FINAL));if(!this._focusedFBO)return r;const o=this.renderingContext;o.bindFramebuffer(r.fbo),o.setClearColor(0,0,0,0),o.clear(p.COLOR);const t=this._ensureShader(o,!1,0);return o.useProgram(t),o.bindTexture(this._focusedFBO.getTexture(),0),t.setUniform1i("colorTex",0),t.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&t.setUniform2fv("nearFar",this.camera.nearFar),o.screen.draw(),r}getDownscaledFBO(e,r,o,t,n,s){o===T.ON&&(n=e.width,s=e.height);const a=this.renderingContext,{colorTexture:c,depthStencilTexture:l}=e,u=c?.descriptor,m=this._ensureShader(a,null!=l,r),v=this.fboCache.acquire(n,s,"fbo visualizer"),g=!u?.hasMipmap&&!u?.isImmutable;g&&c?.generateMipmap(),a.useProgram(m),a.bindFramebuffer(v.fbo);let x=0;const F=[h.COLOR_ATTACHMENT0],C=null!=l;if(a.bindTexture(c,x),m.setUniform1i("colorTex",x),l){x++,a.bindTexture(l,x),m.setUniform1i("depthTex",x);const e=h.COLOR_ATTACHMENT0+x;v.acquireColor(e,i.RGBA,"depth to color"),F.push(e)}for(let p=0;p<r;p++){x++;const r=h.COLOR_ATTACHMENT0+x,o=C?1:0;a.bindTexture(e.getColorTexture(r-o),x),m.setUniform1i("colorTex"+(x-o-1),x),v.acquireColor(r,i.RGBA),F.push(r)}a.gl.drawBuffers(F);const b=a.getViewport();a.setViewport(0,0,n,s),a.setClearColor(0,0,0,0),a.clear(p.COLOR),a.setBlendingEnabled(!0),a.setBlendFunction(d.ONE,d.ONE_MINUS_SRC_ALPHA);const O="linear-depth"===t||t.includes("shadow"),_="overlay highlight"===t||"highlights"===t||"highlight mix"===t,y=u?.internalFormat,A=O?3:_?5:y===f.R16F||y===f.R32F||y===f.R8?1:y===f.RG8?2:y===f.RGBA16F?4:0;return m.setUniform1i("inputType",A),O&&m.setUniform2fv("nearFar",this.camera.nearFar),a.screen.draw(),a.bindFramebuffer(null),a.setViewport(b.x,b.y,b.width,b.height),o===T.ON&&(this._focusedFBO=v,this._focusedFBOType=A),g&&e.colorTexture?.clearMipmap(),v}clearFocusedFBO(){this._focusedFBO=null}getPreviewContent(e,r,o,t){if(!o)return null;const n=this.renderingContext,i=this.fboCache.acquire(e,r,"fbo visualizer");n.bindFramebuffer(i?.fbo),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(p.COLOR),n.setBlendingEnabled(!0),n.setBlendFunction(d.ONE,d.ONE_MINUS_SRC_ALPHA),n.setViewport(0,0,e,r);const s=this._ensureShader(n,!1,0);n.useProgram(s),n.bindTexture(o.getColorTexture(t),0),s.setUniform1i("colorTex",0),s.setUniform1i("inputType",0),n.screen.draw();const a=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,m.RGBA,v.UNSIGNED_BYTE,new Uint8Array(a.data.buffer)),n.bindFramebuffer(null),i?.release(),a}_ensureShader(e,r,o){const t={hasDepth:r,attachments:o},n=this._program.get(t);if(n)return n;const i="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",s=(e,r)=>{let o="";const t=e?2:1;for(let n=0;n<r;n++)o+=`layout(location = ${l.int(t+n)}) out vec4 fragColor${l.int(n)};\n uniform sampler2D colorTex${l.int(n)};`;return o},p=e=>{let r="";for(let o=0;o<e;o++)r+=`fragColor${l.int(o)} = texture(colorTex${l.int(o)}, uv);`;return r},h=`#version 300 es\n precision highp float;\n\n in vec2 uv;\n uniform sampler2D colorTex;\n layout(location = 0) out vec4 fragColor;\n ${c(r,"layout(location = 1) out vec4 fragDepth;\n uniform sampler2D depthTex;")}\n ${s(r,o)}\n uniform int inputType;\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgbaTofloat(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgbaTofloat(depth));\n }\n\n float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }\n\n void main() {\n vec4 color;\n if(inputType == 1) {\n color = vec4(vec3(texture(colorTex, uv).r), 1.0);\n } else if(inputType == 2) {\n color = vec4(texture(colorTex, uv).rg, 0.0, 1.0);\n } else if(inputType == 3) {\n float depth = 1.0 - (-linearDepthFromTexture(colorTex, uv) / (nearFar[1] - nearFar[0]));\n color = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if(inputType == 4) {\n color = texture(colorTex, uv);\n color = vec4(color.rgb / color.a, color.a);\n } else if(inputType == 5) {\n vec2 texDim = vec2(textureSize(colorTex, 0));\n ivec2 iuv = ivec2(uv*texDim);\n vec2 hh = texelFetch(colorTex,iuv,0).rg;\n uvec2 uhh = uvec2(vec2(hh) * 255.0);\n color = vec4(\n ((uhh.x & 0x3u) != 0u) ? 1.0 : 0.0, \n ((uhh.x & 0xcu) != 0u) ? 1.0 : 0.0,\n ((uhh.y & 0xfu) != 0u) ? 1.0 : 0.0, \n 1.0);\n } else {\n color = texture(colorTex, uv);\n }\n\n\n if(color.a < ${l.float(a)})\n discard;\n else {\n fragColor = color;\n ${c(r,"float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);")}\n ${c(o>0,p(o))}\n }\n }`;return this._program.set(t,e.programCache.acquire(i,h,u)),this._program.get(t)}};var T;e([r()],g.prototype,"destroyedCB",void 0),e([r()],g.prototype,"produces",void 0),e([r()],g.prototype,"consumes",void 0),e([r()],g.prototype,"clearColor",void 0),g=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],g),function(e){e[e.ON=0]="ON",e[e.OFF=1]="OFF"}(T||(T={}));export{T as FocusState,g as RenderNodeVisualizerNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import has from"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as h}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as a}from"../../../webgl.js";import{ColorFormat as c}from"../../../webgl/formats.js";import g from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as u}from"./HighlightApplyTechnique.js";import{HighlightDownsampleTechnique as p}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as m}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as d}from"./HighlightToSingleTechnique.js";import{SingleHighlightApplyTechnique as f}from"./SingleHighlightApplyTechnique.js";import{SingleHighlightBlurTechnique as b}from"./SingleHighlightBlurTechnique.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{Default3D as x}from"../../lib/DefaultVertexAttributeLocations.js";import{NoVertex as w}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as C}from"../../lib/VertexArrayObject.js";import{H as _,g as v}from"../../../../../chunks/HighlightDownsample.glsl.js";import{S as q}from"../../../../../chunks/SingleHighlightBlur.glsl.js";import{BufferObject as j}from"../../../../webgl/BufferObject.js";import{PixelFormat as H,TextureSamplingMode as P,FramebufferBit as R,Usage as D,TextureType as O,PrimitiveType as y,DataType as S}from"../../../../webgl/enums.js";import{Texture as A}from"../../../../webgl/Texture.js";import{TextureDescriptor as M}from"../../../../webgl/TextureDescriptor.js";let I=class extends g{constructor(e){super(e),this.produces=a.HIGHLIGHTS,this.consumes={required:[a.HIGHLIGHTS,"highlights"]},this._useMultipleHighlights=!!has("enable-feature:multiple-highlights"),this._downsampleDrawParameters=new _,this._passParameters=new m,this._singleHighlightBlurDrawParameters=new q,this._grid=new E,e.techniques.precompile(p),this._useMultipleHighlights?e.techniques.precompile(u):(e.techniques.precompile(d),e.techniques.precompile(b),e.techniques.precompile(f))}initialize(){this.addHandles([i((()=>this._updateOptionsTexture()),(()=>{}),s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=r(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new M(16,2);e.internalFormat=H.RGBA,e.samplingMode=P.NEAREST,this._passParameters.highlightOptionsTexture=new A(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(G(this.view.state.highlights)),this.requestRender(T.UPDATE)}render(e){const t=e.find((({name:e})=>e===a.HIGHLIGHTS)),{techniques:r,bindParameters:i,_passParameters:s,renderingContext:o}=this;if(!i.decorations)return t;const l=r.acquire(p);if(!l.compiled)return l.release(),this.requestRender(T.UPDATE),t;const h=e.find((({name:e})=>"highlights"===e)).getTexture(),n=()=>{this._gridUpdateResources(h);const e=this._gridComputeCoverage(l,h,i);l.release();const{horizontalCellCount:t,verticalCellCount:r}=e;return s.horizontalCellCount=t,s.verticalCellCount=r,s.coverageTexture=e.coverage?.getTexture(),e},c=e=>{const t=e.verticalCellCount*e.horizontalCellCount;o.bindVAO(e.vao),o.drawElementsInstanced(y.TRIANGLES,6,S.UNSIGNED_BYTE,0,t)},{camera:g}=i,u=()=>{o.bindFramebuffer(t.fbo),o.setViewport4fv(g.fullViewport)};return this._useMultipleHighlights?this._renderMultiple(h,n,c,u):this._renderSingle(h,n,c,u),s.highlightTexture=null,s.coverageTexture=null,t}_renderMultiple(e,t,r,i){const{techniques:s,bindParameters:o,_passParameters:l,renderingContext:h}=this,n=s.acquire(u);if(!n.compiled)return n.release(),void this.requestRender(T.UPDATE);const a=t();l.highlightTexture=e,l.pixelRatio=o.camera.pixelRatio,h.bindTechnique(n,o,l),i(),r(a),n.release()}_renderSingle(e,t,r,i){const{fboCache:s,techniques:o,bindParameters:l,_passParameters:n,renderingContext:a}=this,g=o.acquire(d),u=o.acquire(b),p=o.acquire(f);if(!p.compiled||!u.compiled||!g.compiled)return p.release(),u.release(),g.release(),void this.requestRender(T.UPDATE);const m=t(),{width:x,height:w}=e.descriptor;n.highlightTexture=e;const{camera:C}=l,{fullWidth:_,fullHeight:v,pixelRatio:q}=C,j=Math.ceil(_/q),H=Math.ceil(v/q),{_singleHighlightBlurDrawParameters:P}=this;for(let d=0;d<l.highlights.length;++d){n.highlightLevel=d,a.setClearColor(0,0,0,0);const e=s.acquire(x,w,"single highlight",c.RG);a.bindFramebuffer(e.fbo),a.setViewport(0,0,x,w),a.clear(R.COLOR),a.bindTechnique(g,l,n),r(m),P.blurInput=e.getTexture(),h(P.blurSize,1/j,0);const t=s.acquire(j,H,"single highlight blur h",c.RG);a.unbindTexture(t.fbo?.colorTexture),a.bindFramebuffer(t.fbo),a.setViewport(0,0,j,H),a.clear(R.COLOR),a.bindTechnique(u,l,n,P),r(m),e.release(),h(P.blurSize,0,1/H),n.singleHighlightBlurTexture=t.getTexture(),i(),a.bindTechnique(p,l,n,P),r(m),t.release()}g.release(),u.release(),p.release()}_gridUpdateResources(e){const t=this._grid,{width:r,height:i}=e.descriptor;if(t.horizontalCellCount=Math.ceil(r/v),t.verticalCellCount=Math.ceil(i/v),t.vao)return;const s=this.renderingContext,o=j.createIndex(s,D.STATIC_DRAW,B);t.vao=new C(s,x,new Map([["geometry",w]]),new Map([["geometry",j.createVertex(s,D.STATIC_DRAW)]]),o)}_gridComputeCoverage(e,t,r){const i=this.renderingContext,s=this._grid,o=t.descriptor,l=Math.ceil(o.width/v),h=Math.ceil(o.height/v);this._downsampleDrawParameters.input=t,s.coverage?.release();const n=this.fboCache.acquire(l,h,"highlight coverage",c.RG);return s.coverage=n,i.bindFramebuffer(n.fbo),i.bindTechnique(e,r,this._passParameters,this._downsampleDrawParameters),i.setViewport(0,0,l,h),i.screen.draw(),s}get test(){}};e([o()],I.prototype,"produces",void 0),e([o()],I.prototype,"consumes",void 0),e([o({constructOnly:!0})],I.prototype,"techniques",void 0),I=e([l("esri.views.3d.webgl-engine.effects.highlight.Highlight")],I);class E{constructor(){this.coverage=null,this.vao=null,this.verticalCellCount=0,this.horizontalCellCount=0,this.viewportWidth=0,this.viewportHeight=0}}function G(e){const t=new Uint8Array(128);let r=0;for(const i of e){const e=i.options,s=4*r,o=4*r+64;++r;const{color:l}=e,h=e.haloColor??l;t[s+0]=l.r,t[s+1]=l.g,t[s+2]=l.b,t[s+3]=e.fillOpacity*l.a*255,t[o+0]=h.r,t[o+1]=h.g,t[o+2]=h.b,t[o+3]=e.haloOpacity*h.a*255}return t}let L=0;function U(e){let t=0;for(const{name:i,options:s}of e){t+=i.length;const{color:e,fillOpacity:r,haloColor:o,haloOpacity:l}=s;t+=e.r+e.g+e.b+e.a+r,t+=o?o.r+o.g+o.b+o.a+l:0}const r=e.at(0);if(r){const{shadowOpacity:e,shadowDifference:i,shadowColor:s}=r.options;t+=e+i+s.r+s.g+s.b+s.a}return L+++(t>=0?0:1)}const B=new Uint8Array([0,1,2,2,1,3]);function V(e,t,r,i,s,o=0){const l=i.highlights,a=l.length>1?t.acquire(r.width,r.height,"highlight mix",c.RG):null;if(a){const t=e.getBoundFramebufferObject();e.bindFramebuffer(a.fbo),e.clearFramebuffer(n),e.bindFramebuffer(t)}const g=a?.getTexture();i.highlightMixTexture=g,h(i.highlightMixOrigin,o,0),l.forEach(((t,l)=>{l>0&&(e.bindTexture(g,0),e.gl.copyTexSubImage2D(O.TEXTURE_2D,0,0,0,o,0,r.width,r.height),e.bindTexture(null,0)),e.clear(R.DEPTH),i.highlightLevel=l,s()})),i.highlightLevel=i.highlightMixTexture=null,a?.release()}export{I as Highlight,V as renderHighlightBuffer,U as trackHighlightOptions};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as h}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as a}from"../../../webgl.js";import{ColorFormat as c}from"../../../webgl/formats.js";import g from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as u}from"./HighlightApplyTechnique.js";import{HighlightDownsampleTechnique as p}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as m}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as d}from"./HighlightToSingleTechnique.js";import{SingleHighlightApplyTechnique as f}from"./SingleHighlightApplyTechnique.js";import{SingleHighlightBlurTechnique as b}from"./SingleHighlightBlurTechnique.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{Default3D as x}from"../../lib/DefaultVertexAttributeLocations.js";import{NoVertex as w}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as C}from"../../lib/VertexArrayObject.js";import{H as _,g as v}from"../../../../../chunks/HighlightDownsample.glsl.js";import{S as q}from"../../../../../chunks/SingleHighlightBlur.glsl.js";import{BufferObject as j}from"../../../../webgl/BufferObject.js";import{PixelFormat as H,TextureSamplingMode as P,FramebufferBit as R,Usage as D,TextureType as O,PrimitiveType as y,DataType as S}from"../../../../webgl/enums.js";import{Texture as A}from"../../../../webgl/Texture.js";import{TextureDescriptor as M}from"../../../../webgl/TextureDescriptor.js";let I=class extends g{constructor(e){super(e),this.produces=a.HIGHLIGHTS,this.consumes={required:[a.HIGHLIGHTS,"highlights"]},this._useMultipleHighlights=!1,this._downsampleDrawParameters=new _,this._passParameters=new m,this._singleHighlightBlurDrawParameters=new q,this._grid=new E,e.techniques.precompile(p),this._useMultipleHighlights?e.techniques.precompile(u):(e.techniques.precompile(d),e.techniques.precompile(b),e.techniques.precompile(f))}initialize(){this.addHandles([i((()=>this._updateOptionsTexture()),(()=>{}),s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=r(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new M(16,2);e.internalFormat=H.RGBA,e.samplingMode=P.NEAREST,this._passParameters.highlightOptionsTexture=new A(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(G(this.view.state.highlights)),this.requestRender(T.UPDATE)}render(e){const t=e.find((({name:e})=>e===a.HIGHLIGHTS)),{techniques:r,bindParameters:i,_passParameters:s,renderingContext:o}=this;if(!i.decorations)return t;const l=r.acquire(p);if(!l.compiled)return l.release(),this.requestRender(T.UPDATE),t;const h=e.find((({name:e})=>"highlights"===e)).getTexture(),n=()=>{this._gridUpdateResources(h);const e=this._gridComputeCoverage(l,h,i);l.release();const{horizontalCellCount:t,verticalCellCount:r}=e;return s.horizontalCellCount=t,s.verticalCellCount=r,s.coverageTexture=e.coverage?.getTexture(),e},c=e=>{const t=e.verticalCellCount*e.horizontalCellCount;o.bindVAO(e.vao),o.drawElementsInstanced(y.TRIANGLES,6,S.UNSIGNED_BYTE,0,t)},{camera:g}=i,u=()=>{o.bindFramebuffer(t.fbo),o.setViewport4fv(g.fullViewport)};return this._useMultipleHighlights?this._renderMultiple(h,n,c,u):this._renderSingle(h,n,c,u),s.highlightTexture=null,s.coverageTexture=null,t}_renderMultiple(e,t,r,i){const{techniques:s,bindParameters:o,_passParameters:l,renderingContext:h}=this,n=s.acquire(u);if(!n.compiled)return n.release(),void this.requestRender(T.UPDATE);const a=t();l.highlightTexture=e,l.pixelRatio=o.camera.pixelRatio,h.bindTechnique(n,o,l),i(),r(a),n.release()}_renderSingle(e,t,r,i){const{fboCache:s,techniques:o,bindParameters:l,_passParameters:n,renderingContext:a}=this,g=o.acquire(d),u=o.acquire(b),p=o.acquire(f);if(!p.compiled||!u.compiled||!g.compiled)return p.release(),u.release(),g.release(),void this.requestRender(T.UPDATE);const m=t(),{width:x,height:w}=e.descriptor;n.highlightTexture=e;const{camera:C}=l,{fullWidth:_,fullHeight:v,pixelRatio:q}=C,j=Math.ceil(_/q),H=Math.ceil(v/q),{_singleHighlightBlurDrawParameters:P}=this;for(let d=0;d<l.highlights.length;++d){n.highlightLevel=d,a.setClearColor(0,0,0,0);const e=s.acquire(x,w,"single highlight",c.RG);a.bindFramebuffer(e.fbo),a.setViewport(0,0,x,w),a.clear(R.COLOR),a.bindTechnique(g,l,n),r(m),P.blurInput=e.getTexture(),h(P.blurSize,1/j,0);const t=s.acquire(j,H,"single highlight blur h",c.RG);a.unbindTexture(t.fbo?.colorTexture),a.bindFramebuffer(t.fbo),a.setViewport(0,0,j,H),a.clear(R.COLOR),a.bindTechnique(u,l,n,P),r(m),e.release(),h(P.blurSize,0,1/H),n.singleHighlightBlurTexture=t.getTexture(),i(),a.bindTechnique(p,l,n,P),r(m),t.release()}g.release(),u.release(),p.release()}_gridUpdateResources(e){const t=this._grid,{width:r,height:i}=e.descriptor;if(t.horizontalCellCount=Math.ceil(r/v),t.verticalCellCount=Math.ceil(i/v),t.vao)return;const s=this.renderingContext,o=j.createIndex(s,D.STATIC_DRAW,B);t.vao=new C(s,x,new Map([["geometry",w]]),new Map([["geometry",j.createVertex(s,D.STATIC_DRAW)]]),o)}_gridComputeCoverage(e,t,r){const i=this.renderingContext,s=this._grid,o=t.descriptor,l=Math.ceil(o.width/v),h=Math.ceil(o.height/v);this._downsampleDrawParameters.input=t,s.coverage?.release();const n=this.fboCache.acquire(l,h,"highlight coverage",c.RG);return s.coverage=n,i.bindFramebuffer(n.fbo),i.bindTechnique(e,r,this._passParameters,this._downsampleDrawParameters),i.setViewport(0,0,l,h),i.screen.draw(),s}get test(){}};e([o()],I.prototype,"produces",void 0),e([o()],I.prototype,"consumes",void 0),e([o({constructOnly:!0})],I.prototype,"techniques",void 0),I=e([l("esri.views.3d.webgl-engine.effects.highlight.Highlight")],I);class E{constructor(){this.coverage=null,this.vao=null,this.verticalCellCount=0,this.horizontalCellCount=0,this.viewportWidth=0,this.viewportHeight=0}}function G(e){const t=new Uint8Array(128);let r=0;for(const i of e){const e=i.options,s=4*r,o=4*r+64;++r;const{color:l}=e,h=e.haloColor??l;t[s+0]=l.r,t[s+1]=l.g,t[s+2]=l.b,t[s+3]=e.fillOpacity*l.a*255,t[o+0]=h.r,t[o+1]=h.g,t[o+2]=h.b,t[o+3]=e.haloOpacity*h.a*255}return t}let L=0;function U(e){let t=0;for(const{name:i,options:s}of e){t+=i.length;const{color:e,fillOpacity:r,haloColor:o,haloOpacity:l}=s;t+=e.r+e.g+e.b+e.a+r,t+=o?o.r+o.g+o.b+o.a+l:0}const r=e.at(0);if(r){const{shadowOpacity:e,shadowDifference:i,shadowColor:s}=r.options;t+=e+i+s.r+s.g+s.b+s.a}return L+++(t>=0?0:1)}const B=new Uint8Array([0,1,2,2,1,3]);function V(e,t,r,i,s,o=0){const l=i.highlights,a=l.length>1?t.acquire(r.width,r.height,"highlight mix",c.RG):null;if(a){const t=e.getBoundFramebufferObject();e.bindFramebuffer(a.fbo),e.clearFramebuffer(n),e.bindFramebuffer(t)}const g=a?.getTexture();i.highlightMixTexture=g,h(i.highlightMixOrigin,o,0),l.forEach(((t,l)=>{l>0&&(e.bindTexture(g,0),e.gl.copyTexSubImage2D(O.TEXTURE_2D,0,0,0,o,0,r.width,r.height),e.bindTexture(null,0)),e.clear(R.DEPTH),i.highlightLevel=l,s()})),i.highlightLevel=null,i.highlightMixTexture=null,a?.release()}export{I as Highlight,V as renderHighlightBuffer,U as trackHighlightOptions};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/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{removeMaybe as s,abortMaybe as a,destroyMaybe as n,releaseMaybe as h}from"../../../../core/maybe.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{watch as d,syncAndInitial as _,initial as l,sync as p}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as m}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 c,invert as g,multiply as f}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as T}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{fromValues as E,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as R}from"../../../../geometry/support/Indices.js";import{RenderCategory as S,InternalRenderCategory as I}from"../../webgl.js";import{debugFlags as w}from"../../support/debugFlags.js";import{DepthFormat as C,ColorFormat as D}from"../../webgl/formats.js";import{FBOCache as N,defaultWebGLFBO as O}from"../core/FBOCache.js";import{RenderPassManager as y}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as H,isColorOrColorEmission as x}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as L}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as M}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as v}from"../effects/RenderNodes.js";import{releaseTechniques as U}from"../effects/RenderPlugin.js";import{RenderPluginManager as F}from"../effects/RenderPluginManager.js";import{Blit as G}from"../effects/blit/Blit.js";import{renderHighlightBuffer as q}from"../effects/highlight/Highlight.js";import{OITBlend as V}from"../effects/transparency/OITBlend.js";import{AnimationTimer as j}from"./AnimationTimer.js";import{AnimationTimeStep as B}from"./AnimationTimeStep.js";import{RenderRequestType as Q}from"./basicInterfaces.js";import{BoundingInfo as W}from"./BoundingInfo.js";import{DepthRange as k}from"./DepthRange.js";import{depthRangeFromScene as z}from"./depthRangeUtils.js";import{MainFramebuffer as X}from"./MainFramebuffer.js";import{RenderOccludedFlag as Y}from"./Material.js";import{OITPass as K}from"./OITPass.js";import{RenderContext as J,defaultRenderOccludedMask as $}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as Z,RendererTarget as ee}from"./rendererUtils.js";import{setupFeatureDefaults as te,RenderFeature as re}from"./RenderFeature.js";import{RenderPluginInput as ie}from"./RenderPluginInput.js";import{RenderSlot as se}from"./RenderSlot.js";import{ShadowAccumulator as ae}from"./ShadowAccumulator.js";import{ShadowMap as ne,SnapshotSlot as he}from"./ShadowMap.js";import oe from"./SliceHelper.js";import{Transparency as de}from"./edgeRendering/interfaces.js";import{MergedRenderer as _e}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as le}from"../parts/renderUtils.js";import{RendererPerformanceInfo as pe,PerformanceCategory as ue}from"../statistics/RendererPerformanceInfo.js";import{RenderState as me}from"../../../support/RenderState.js";import{PixelFormat as ce,PixelType as ge,DepthStencilAttachment as fe,FramebufferBit as be,ColorAttachment as Te}from"../../../webgl/enums.js";class Ae{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 y,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=E(0,0,0,1),this._sliceHelper=new oe,this._blit=null,this._oitblend=null,this._state=u(me.IDLE),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new B,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new ie,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new N(s),this._renderStateFeatures=u(te(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new X(this.fboCache),this.performanceInfo=new pe(this._rctx),this._shadowMap=new ne(this.fboCache,e.viewingMode),this._shadowAccumulator=new ae(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(H.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new J(this._rctx,this._shadowMap,r),this._nodes=new v(this._renderContext),this._plugins=new F({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=[d((()=>this._stage.view.state.camera),(()=>n()),_),d((()=>w.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(de.TRANSPARENT):()=>{},n()}),l),d((()=>this._stage.view.environment.background?.color),(e=>{const t=e?i(e):P;A(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),_),d((()=>this._stage.view.state.camera.relativeElevation),(e=>this._inGlobeView=(e??1/0)>=M),_),d((()=>this._bindParameters.clouds.fadeFactor),(()=>this._bindParameters.fadeLighting()),p),d((()=>this._bindParameters.clouds.data?.state),(()=>n()),p),d((()=>this._stage.view.state.highlights),(e=>{this._bindParameters.highlights=e,this._updateHighlights(),n()}),l)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=s(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=a(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._renderers.clear(),this._blit=null,this._oitblend=null,W.prune(),_e.prune(),R()}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=te(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(re.HighQualityTransparency)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(re.WaterReflection))}get _hasHighlights(){return this._plugins.produces(H.Highlight,se.OPAQUE_MATERIAL,se.TRANSPARENT_MATERIAL,se.DRAPED_MATERIAL,se.HUD_MATERIAL,se.LABEL_MATERIAL)}get _hasHUDHighlights(){return this._plugins.produces(H.Highlight,se.HUD_MATERIAL,se.LABEL_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(re.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(re.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(re.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=h(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=h(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=h(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.hudVisibility=h(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");o(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:xe(this._stage.view.resourceController)});return this._handles.push(d((()=>r.updating),(()=>this._requestRender()),p)),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&&c(this._bindParameters.ssr.reprojectionMatrix,b)}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;Z(e).forEach(((r,i)=>{if(t.done)return;let s=this._renderers.get(i);null==s&&r.adds.length>0&&(s=new _e({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),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(H.Color,...Ce),has.water=this._plugins.produces(H.Normal,se.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new j(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation),null!=e.forcedAnimationTime&&this._animationTimer.forceTime(e.forcedAnimationTime);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations=this.overlay?.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?s(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=ee.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 le(this._pluginInput.get(S.FINAL),null)}_render(e,t,r=ee.Default,i){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===ee.Default,this._disposeBindBuffers();const s=this._framebuffer,{camera:a,contentCamera:n,mode:o,alignPixelEnabled:d}=e;this._state.value=o,this._bindParameters.overlay=this.overlay?.render(t),this._bindParameters.overlay&&this.performanceInfo.advance(ue.OVERLAY),this._renderContext.time=t,this._bindParameters.oitPass=K.NONE,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null,this._bindParameters.viewshedEnabled=this._nodes.produces(I.VIEWSHED);const _=this._nodes.produces("magnifier-color"),l=this._nodes.produces(S.FINAL);this._bindParameters.slicePlane=this._sliceHelper.plane,a.setGLViewport(this._rctx);const p=this._emissiveRequired,u=p?H.ColorEmission:H.Color,m=s.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,p);this.hasReflections?(m?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=m):m?.release(),this._ensureBindParametersCamera(a,n),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const c=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(H.Color,...Ie);this._precompilePrepasses(),this.performanceInfo.advance(ue.PREPARE);const f=this._computeDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,f),this._ensureBindParametersCamera(a,n),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,a,n),this._ensureBindParametersSSR(t),this._precompileShaders(c,g,u),this._renderContext.output=u,s.bind(),this._bindParameters.mainDepth=s.depth.attachment;const b=this.plugins.produces(H.Color,...Se);b&&this._renderOpaqueGeometry(),s.update((e=>this._renderNodes(S.OPAQUE,e,b))),this.fboCache.debugCallback?.("opaque-color",s.color.fbo),s.update((e=>this._renderNodes(I.OPAQUE_ENVIRONMENT,e))),this.fboCache.debugCallback?.(I.OPAQUE_ENVIRONMENT,s.color.fbo),this._renderTerrainDepth(c),this._renderEdges(de.OPAQUE),s.bind(),this._renderPlugins(se.VOXEL,ue.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOIT(Ee.Geometry,u):this._renderTransparentGeometry()),s.update((e=>this._renderNodes(S.TRANSPARENT,e,g))),this.fboCache.debugCallback?.("transparent-color",s.color.fbo),this._renderGeometryDepth(c),this._renderHUDVisibility(),c||this._plugins.render(this._pluginInput,se.LINE_CALLOUTS);const T=r===ee.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this._renderEdges(de.TRANSPARENT);const A=this._hasTransparentTerrain?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(ue.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(L.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,A.getTexture())),this._renderHUD(L.Occluded,s.color,u))),this._bindParameters.cullAboveTerrain=!1,A&&(s.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,A.getTexture()),A.release(),c&&(this._renderEdges(de.OPAQUE),g&&(this._oitEnabled?this._renderOIT(Ee.Geometry,u):this._renderTransparentGeometry(),this.performanceInfo.advance(ue.TRANSPARENT)),this._renderEdges(de.TRANSPARENT))),this._bindParameters.ssao=h(this._bindParameters.ssao),c&&this._renderLineCallouts(L.NotOccluded),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment(),this._pluginInput.set("focusArea",this._renderFocusAreaGeometry()),s.update((e=>this._renderNodes(I.TRANSPARENT_ENVIRONMENT,e))),s.update((e=>this._renderNodes(I.VIEWSHED,e))),s.update((e=>this._renderNodes(I.LASERLINES,e))),s.update((e=>this._renderNodes(I.OCCLUDED,e))),this._pluginInput.set("highlights",this._renderHighlightPrepass()),s.update((e=>this._renderNodes(S.COMPOSITE,e)));const E=!(r!==ee.Default||l||_&&!i&&r===ee.Default),P=this._pluginInput.get(S.COMPOSITE),R=E?O:this.fboCache.acquire(P.fbo.width,P.fbo.height,I.ANTIALIASING),w=this._nodes.produces(I.ANTIALIASING)?this._renderNodes(I.ANTIALIASING,R):this._blitFBO(P,R,!1);let C;this._pluginInput.set(I.ANTIALIASING,w),this._hasHUDHighlights?(this._renderHUD(L.NotOccluded,w,u),C=this._renderNodes(I.HIGHLIGHTS,w)):(C=this._renderNodes(I.HIGHLIGHTS,w),this._renderHUD(L.NotOccluded,C,u));const D=this._renderNodes(I.MAGNIFIER,C);return _&&!i&&r===ee.Default&&!l&&this._blitFBO(D),l?(D.attachDepth(s.depth),this._blitFBO(this._renderNodes(S.FINAL,D)),D.detachDepth()):this._pluginInput.set(S.FINAL,D),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),s.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ee.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),new le(this._pluginInput.get(S.FINAL),T)}_precompileShaders(e,t,r){if(++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=H.Depth,this._plugins.precompile(se.TRANSPARENT_TERRAIN),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(se.TRANSPARENT_TERRAIN),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._needsHUDVisibility&&this._plugins.precompile(se.OCCLUSION_PIXELS),this._plugins.precompile(se.LINE_CALLOUTS),this._precompileHUD(L.Occluded),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(I.VIEWSHED,I.LASERLINES,I.OCCLUDED),this._precompileHUD(L.NotOccluded),this._hasHighlights){const e=this._bindParameters;e.highlights.forEach(((t,r)=>{e.highlightLevel=r,this._precompileAllGeometry(H.Highlight)})),e.highlightLevel=null}this._nodes.precompile(S.COMPOSITE,I.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(se.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("focusArea")){const e=this._framebufferSize;let t=this.fboCache.acquire(e.width,e.height,"focusArea");return t=this._nodes.render(t,this._pluginInput),this.performanceInfo.advance(ue.FOCUS_AREA_MASK),t}return null}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;++this._techniques.precompiling;const e=this._framebufferSize;let t=this.fboCache.acquire(e.width,e.height,"olid");return t.acquireDepth(C.DEPTH_STENCIL_TEXTURE),t=this._nodes.render(t,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ue.OBJECT_AND_LAYER_ID_COLOR),t}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===Q.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(P),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],ce.RGBA,ge.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,ce.RGBA,ge.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,P),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(e===de.OPAQUE?ue.OPAQUE_EDGES:ue.TRANSPARENT_EDGES)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(re.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(H.ShadowHighlight,this._shadowMap),i.moveSnapshot(he.Highlight),this._renderShadowCascades(H.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(he.ExcludeHighlight),this._renderShadowCascades(H.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(H.Shadow),i.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(ue.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(H.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(fe):null;t?.retain(),this._pluginInput.set(I.SSAO,this._renderSSAO()),this._renderGeometryWithoutNormalsDepth(t)}else this._renderAllGeometryDepth()}_renderGeometryWithoutNormalsDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=h(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(be.STENCIL),this._renderGeometryWithoutNormals(H.Depth),h(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(ue.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=h(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"depth").acquireDepth(C.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(be.DEPTH|be.STENCIL),this.renderAllGeometry(H.Depth),h(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(ue.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=h(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=H.Depth;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth").acquireDepth(C.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(be.DEPTH|be.STENCIL),this._renderTransparentTerrain(),h(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=h(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth").acquireDepth(C.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(be.DEPTH|be.STENCIL),this._renderOpaqueAndTransparentGeometry(H.Depth),this._renderContext.output=t,h(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=z(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 _emissiveRequired(){return this._nodes.require("emissive",S.FINAL,S.COMPOSITE)>0&&this._plugins.hasEmissions}get _normalsRequired(){const e=this._nodes.require("normals",S.FINAL,S.COMPOSITE,"opaque-color","transparent-color","laserline-color");return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(H.Normal),this._needsDepth&&this._precompileAllGeometry(H.Depth),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(H.ShadowHighlight),this._precompileShadowCascades(H.ShadowExcludeHighlight),this._precompileShadowCascades(H.ShadowHighlight)):this._precompileShadowCascades(H.Shadow)),this._needsShadowAccumulation&&this._precompileAllGeometry(H.Shadow)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",D.RGBA);r.acquireDepth(C.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(P,!0,!0),this._renderGeometryWithNormals(H.Normal);const i=this._nodes.optional("normals",S.FINAL,S.COMPOSITE,"opaque-color","transparent-color","viewshed-color");return r.retain(e+i-1),this.performanceInfo.advance(ue.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();O.setName(I.SSAO);const t=this._nodes.render(O,this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(ue.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(se.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,...we);this._renderContext.renderOccludedMask=$}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),U(t))}))}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>Y.Occlude&&this._plugins.render(this._pluginInput,se.OCCLUDED_TERRAIN),this.renderSlots(e,...we),this._renderContext.renderOccludedMask=$}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,se.HUD_MATERIAL)}precompileViewshedShadowMap(){this._precompileAllGeometry(H.ViewshedShadow)}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(H.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,...Pe),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Re)}_precompileOpaqueGeometry(){this._plugins.precompile(...Se)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...Se)}_renderTransparentGeometry(){this._plugins.render(this._pluginInput,...Ie)}get _hasTransparentTerrain(){return this._plugins.produces(H.Color,se.TRANSPARENT_TERRAIN)}_renderTransparentTerrain(){const e=()=>this._plugins.render(this._pluginInput,se.TRANSPARENT_TERRAIN);if(!x(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,P),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,se.OCCLUSION_PIXELS)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=h(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",D.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,se.OCCLUSION_PIXELS),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(ue.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===L.Occluded){const e=()=>this._plugins.render(this._pluginInput,se.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(C.DEPTH16_BUFFER,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,se.LINE_CALLOUTS)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=H.Highlight,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&x(this._renderContext.output)?(this._bindParameters.oitPass=K.ColorAlpha,this._plugins.precompile(...Ce),this._bindParameters.oitPass=K.FrontFace,this._plugins.precompile(...Ce),this._bindParameters.oitPass=K.NONE):this._plugins.precompile(...Ce),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(Ee.HUD,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,e===L.Occluded){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(C.DEPTH16_BUFFER,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(C.DEPTH16_BUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===L.Occluded?ue.HUD_OCCLUDED:ue.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,...Ce)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(H.ShadowHighlight,se.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,s=e.acquire(i.width,i.height,"highlights",D.RG);return s.acquireDepth(C.DEPTH_STENCIL_TEXTURE),t.bindFramebuffer(s.fbo),t.clearFramebuffer(P,!0),this._renderContext.output=H.Highlight,t.bindFramebuffer(s.fbo),q(t,e,i,r,(()=>this._renderHighlightGeometries()),0),this.performanceInfo.advance(ue.HIGHLIGHTS),s}_renderHighlightGeometries(){const e=0===this._bindParameters.highlightLevel?Ne:De;this._plugins.render(this._pluginInput,...e),this._rctx.clear(be.DEPTH),this._renderHUDElements(L.Both)}get _needsShadowAccumulation(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,t,r){this._needsShadowAccumulation&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(ue.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&x(this._renderContext.output)?(this._bindParameters.oitPass=K.ColorAlpha,this._plugins.precompile(...Ie),this._bindParameters.oitPass=K.FrontFace,this._plugins.precompile(...Ie),this._bindParameters.oitPass=K.NONE):this._plugins.precompile(...Ie)}_renderOIT(e,t,r=L.Both){const i=e===Ee.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=K.ColorAlpha;const d=a?"oit hud color alpha":"oit color alpha",_=this.fboCache.acquire(s.width,s.height,d,D.RGBA16F),l=t===H.ColorEmission;_.acquireColor(Te.COLOR_ATTACHMENT1,D.R16F),a||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),n(),_.detachDepth(),h.oitPass=K.FrontFace;const p=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return a?p.acquireDepth(C.DEPTH16_BUFFER):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(P,!!a),n(),p.detachDepth(),h.oitPass=K.NONE,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(be.COLOR)):this._framebuffer.bind(),this._oitblend??=new V(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(ue.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(this._pluginInput,se.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),this.performanceInfo.advance(ue.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=O,r=!0){return this._blit??=new G(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=b:(g(ye,this._bindParameters.camera.viewMatrix),g(Oe,this._bindParameters.camera.projectionMatrix),f(He,ye,Oe),f(He,this._renderContext.lastFrameCamera.viewMatrix,He),f(He,this._renderContext.lastFrameCamera.projectionMatrix,He),this._reprojectionMatrix=He);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=b,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(Q.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 Ee;e([m({readOnly:!0})],Ae.prototype,"fullResolutionAtmosphere",null),e([m()],Ae.prototype,"_edgeView",void 0),e([m()],Ae.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(Ee||(Ee={}));const Pe=[se.INTEGRATED_MESH,se.OPAQUE_TERRAIN,se.OPAQUE_MATERIAL,se.TRANSPARENT_MATERIAL],Re=[se.OPAQUE_MATERIAL_WITHOUT_NORMALS,se.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],Se=[se.INTEGRATED_MESH,se.OPAQUE_TERRAIN,se.OPAQUE_MATERIAL,se.OPAQUE_MATERIAL_WITHOUT_NORMALS],Ie=[se.TRANSPARENT_MATERIAL,se.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],we=[se.OPAQUE_MATERIAL,se.TRANSPARENT_MATERIAL,se.TRANSPARENT_MATERIAL_WITHOUT_DEPTH],Ce=[se.LINE_CALLOUTS_HUD_DEPTH,se.HUD_MATERIAL,se.LABEL_MATERIAL],De=[se.TRANSPARENT_MATERIAL,se.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,se.OPAQUE_MATERIAL,se.OPAQUE_MATERIAL_WITHOUT_NORMALS],Ne=[...De,se.TRANSPARENT_TERRAIN,se.INTEGRATED_MESH,se.OPAQUE_TERRAIN],Oe=T(),ye=T(),He=T();function xe(e){return t=>e.immediate.schedule(t)}export{Ae 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{removeMaybe as s,abortMaybe as a,destroyMaybe as n,releaseMaybe as h}from"../../../../core/maybe.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{watch as d,syncAndInitial as _,initial as l,sync as p}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as m}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 c,invert as g,multiply as f}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as T}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{fromValues as E,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as R}from"../../../../geometry/support/Indices.js";import{RenderCategory as S,InternalRenderCategory as w}from"../../webgl.js";import{debugFlags as I}from"../../support/debugFlags.js";import{DepthFormat as C,ColorFormat as D}from"../../webgl/formats.js";import{FBOCache as N,defaultWebGLFBO as O}from"../core/FBOCache.js";import{RenderPassManager as y}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as H,isColorOrColorEmission as x}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as L}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as M}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as v}from"../effects/RenderNodes.js";import{releaseTechniques as U}from"../effects/RenderPlugin.js";import{RenderPluginManager as F}from"../effects/RenderPluginManager.js";import{Blit as G}from"../effects/blit/Blit.js";import{renderHighlightBuffer as q}from"../effects/highlight/Highlight.js";import{OITBlend as V}from"../effects/transparency/OITBlend.js";import{AnimationTimer as j}from"./AnimationTimer.js";import{AnimationTimeStep as B}from"./AnimationTimeStep.js";import{RenderRequestType as Q}from"./basicInterfaces.js";import{BoundingInfo as W}from"./BoundingInfo.js";import{DepthRange as k}from"./DepthRange.js";import{depthRangeFromScene as z}from"./depthRangeUtils.js";import{MainFramebuffer as X}from"./MainFramebuffer.js";import{RenderOccludedFlag as Y}from"./Material.js";import{OITPass as K}from"./OITPass.js";import{RenderContext as J,defaultRenderOccludedMask as $}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as Z,RendererTarget as ee}from"./rendererUtils.js";import{setupFeatureDefaults as te,RenderFeature as re}from"./RenderFeature.js";import{RenderPluginInput as ie}from"./RenderPluginInput.js";import{RenderSlot as se}from"./RenderSlot.js";import{ShadowAccumulator as ae}from"./ShadowAccumulator.js";import{ShadowMap as ne,SnapshotSlot as he}from"./ShadowMap.js";import oe from"./SliceHelper.js";import{Transparency as de}from"./edgeRendering/interfaces.js";import{MergedRenderer as _e}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as le}from"../parts/renderUtils.js";import{RendererPerformanceInfo as pe,PerformanceCategory as ue}from"../statistics/RendererPerformanceInfo.js";import{RenderState as me}from"../../../support/RenderState.js";import{PixelFormat as ce,PixelType as ge,DepthStencilAttachment as fe,FramebufferBit as be,ColorAttachment as Te}from"../../../webgl/enums.js";class Ae{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 y,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=E(0,0,0,1),this._sliceHelper=new oe,this._blit=null,this._oitblend=null,this._state=u(me.IDLE),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new B,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new ie,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new N(s),this._renderStateFeatures=u(te(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new X(this.fboCache),this.performanceInfo=new pe(this._rctx),this._shadowMap=new ne(this.fboCache,e.viewingMode),this._shadowAccumulator=new ae(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(H.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new J(this._rctx,this._shadowMap,r),this._nodes=new v(this._renderContext),this._plugins=new F({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=[d((()=>this._stage.view.state.camera),(()=>n()),_),d((()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(de.TRANSPARENT):()=>{},n()}),l),d((()=>this._stage.view.environment.background?.color),(e=>{const t=e?i(e):P;A(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),_),d((()=>this._stage.view.state.camera.relativeElevation),(e=>this._inGlobeView=(e??1/0)>=M),_),d((()=>this._bindParameters.clouds.fadeFactor),(()=>this._bindParameters.fadeLighting()),p),d((()=>this._bindParameters.clouds.data?.state),(()=>n()),p),d((()=>this._stage.view.state.highlights),(e=>{this._bindParameters.highlights=e,this._updateHighlights(),n()}),l)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=s(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=a(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._renderers.clear(),this._blit=null,this._oitblend=null,W.prune(),_e.prune(),R()}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=te(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(re.HighQualityTransparency)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(re.WaterReflection))}get _hasHighlights(){return this._plugins.produces(H.Highlight,se.OPAQUE_MATERIAL,se.TRANSPARENT_MATERIAL,se.DRAPED_MATERIAL,se.HUD_MATERIAL,se.LABEL_MATERIAL)}get _hasHUDHighlights(){return this._plugins.produces(H.Highlight,se.HUD_MATERIAL,se.LABEL_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(re.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(re.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(re.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=h(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=h(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=h(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.hudVisibility=h(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");o(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:xe(this._stage.view.resourceController)});return this._handles.push(d((()=>r.updating),(()=>this._requestRender()),p)),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&&c(this._bindParameters.ssr.reprojectionMatrix,b)}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;Z(e).forEach(((r,i)=>{if(t.done)return;let s=this._renderers.get(i);null==s&&r.adds.length>0&&(s=new _e({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(H.Color,...Ce),has.water=this._plugins.produces(H.Normal,se.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new j(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation),null!=e.forcedAnimationTime&&this._animationTimer.forceTime(e.forcedAnimationTime);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations=this.overlay?.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?s(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=ee.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 le(this._pluginInput.get(S.FINAL),null)}_render(e,t,r=ee.Default,i){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===ee.Default,this._disposeBindBuffers();const s=this._framebuffer,{camera:a,contentCamera:n,mode:o,alignPixelEnabled:d}=e;this._state.value=o,this._bindParameters.overlay=this.overlay?.render(t),this._bindParameters.overlay&&this.performanceInfo.advance(ue.OVERLAY),this._renderContext.time=t,this._bindParameters.oitPass=K.NONE,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null,this._bindParameters.viewshedEnabled=this._nodes.produces(w.VIEWSHED);const _=this._nodes.produces("magnifier-color"),l=this._nodes.produces(S.FINAL);this._bindParameters.slicePlane=this._sliceHelper.plane,a.setGLViewport(this._rctx);const p=this._emissiveRequired,u=p?H.ColorEmission:H.Color,m=s.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,p);this.hasReflections?(m?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=m):m?.release(),this._ensureBindParametersCamera(a,n),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const c=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(H.Color,...we);this._precompilePrepasses(),this.performanceInfo.advance(ue.PREPARE);const f=this._computeDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,f),this._ensureBindParametersCamera(a,n),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,a,n),this._ensureBindParametersSSR(t),this._precompileShaders(c,g,u),this._renderContext.output=u,s.bind(),this._bindParameters.mainDepth=s.depth.attachment;const b=this.plugins.produces(H.Color,...Se);b&&this._renderOpaqueGeometry(),s.update((e=>this._renderNodes(S.OPAQUE,e,b))),this.fboCache.debugCallback?.("opaque-color",s.color.fbo),s.update((e=>this._renderNodes(w.OPAQUE_ENVIRONMENT,e))),this.fboCache.debugCallback?.(w.OPAQUE_ENVIRONMENT,s.color.fbo),this._renderTerrainDepth(c),this._renderEdges(de.OPAQUE),s.bind(),this._renderPlugins(se.VOXEL,ue.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOIT(Ee.Geometry,u):this._renderTransparentGeometry()),s.update((e=>this._renderNodes(S.TRANSPARENT,e,g))),this.fboCache.debugCallback?.("transparent-color",s.color.fbo),this._renderGeometryDepth(c),this._renderHUDVisibility(),c||this._plugins.render(this._pluginInput,se.LINE_CALLOUTS);const T=r===ee.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this._renderEdges(de.TRANSPARENT);const A=this._hasTransparentTerrain?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(ue.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(L.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,A.getTexture())),this._renderHUD(L.Occluded,s.color,u))),this._bindParameters.cullAboveTerrain=!1,A&&(s.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,A.getTexture()),A.release(),c&&(this._renderEdges(de.OPAQUE),g&&(this._oitEnabled?this._renderOIT(Ee.Geometry,u):this._renderTransparentGeometry(),this.performanceInfo.advance(ue.TRANSPARENT)),this._renderEdges(de.TRANSPARENT))),this._bindParameters.ssao=h(this._bindParameters.ssao),c&&this._renderLineCallouts(L.NotOccluded),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment(),this._pluginInput.set("focusArea",this._renderFocusAreaGeometry()),s.update((e=>this._renderNodes(w.TRANSPARENT_ENVIRONMENT,e))),s.update((e=>this._renderNodes(w.VIEWSHED,e))),s.update((e=>this._renderNodes(w.LASERLINES,e))),s.update((e=>this._renderNodes(w.OCCLUDED,e))),this._pluginInput.set("highlights",this._renderHighlightPrepass()),s.update((e=>this._renderNodes(S.COMPOSITE,e)));const E=!(r!==ee.Default||l||_&&!i&&r===ee.Default),P=this._pluginInput.get(S.COMPOSITE),R=E?O:this.fboCache.acquire(P.fbo.width,P.fbo.height,w.ANTIALIASING),I=this._nodes.produces(w.ANTIALIASING)?this._renderNodes(w.ANTIALIASING,R):this._blitFBO(P,R,!1);let C;this._pluginInput.set(w.ANTIALIASING,I),this._hasHUDHighlights?(this._renderHUD(L.NotOccluded,I,u),C=this._renderNodes(w.HIGHLIGHTS,I)):(C=this._renderNodes(w.HIGHLIGHTS,I),this._renderHUD(L.NotOccluded,C,u));const D=this._renderNodes(w.MAGNIFIER,C);return _&&!i&&r===ee.Default&&!l&&this._blitFBO(D),l?(D.attachDepth(s.depth),this._blitFBO(this._renderNodes(S.FINAL,D)),D.detachDepth()):this._pluginInput.set(S.FINAL,D),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),s.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ee.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),new le(this._pluginInput.get(S.FINAL),T)}_precompileShaders(e,t,r){if(++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=H.Depth,this._plugins.precompile(se.TRANSPARENT_TERRAIN),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(se.TRANSPARENT_TERRAIN),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._needsHUDVisibility&&this._plugins.precompile(se.OCCLUSION_PIXELS),this._plugins.precompile(se.LINE_CALLOUTS),this._precompileHUD(L.Occluded),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(w.VIEWSHED,w.LASERLINES,w.OCCLUDED),this._precompileHUD(L.NotOccluded),this._hasHighlights){const e=this._bindParameters;e.highlights.forEach(((t,r)=>{e.highlightLevel=r,this._precompileAllGeometry(H.Highlight)})),e.highlightLevel=null}this._nodes.precompile(S.COMPOSITE,w.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(se.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("focusArea")){const e=this._framebufferSize;let t=this.fboCache.acquire(e.width,e.height,"focusArea");return t=this._nodes.render(t,this._pluginInput),this.performanceInfo.advance(ue.FOCUS_AREA_MASK),t}return null}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;++this._techniques.precompiling;const e=this._framebufferSize;let t=this.fboCache.acquire(e.width,e.height,"olid");return t.acquireDepth(C.DEPTH_STENCIL_TEXTURE),t=this._nodes.render(t,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ue.OBJECT_AND_LAYER_ID_COLOR),t}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===Q.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(P),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],ce.RGBA,ge.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,ce.RGBA,ge.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,P),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(e===de.OPAQUE?ue.OPAQUE_EDGES:ue.TRANSPARENT_EDGES)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(re.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(H.ShadowHighlight,this._shadowMap),i.moveSnapshot(he.Highlight),this._renderShadowCascades(H.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(he.ExcludeHighlight),this._renderShadowCascades(H.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(H.Shadow),i.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(ue.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(H.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(fe):null;t?.retain(),this._pluginInput.set(w.SSAO,this._renderSSAO()),this._renderGeometryWithoutNormalsDepth(t)}else this._renderAllGeometryDepth()}_renderGeometryWithoutNormalsDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=h(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(be.STENCIL),this._renderGeometryWithoutNormals(H.Depth),h(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(ue.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=h(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"depth").acquireDepth(C.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(be.DEPTH|be.STENCIL),this.renderAllGeometry(H.Depth),h(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(ue.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=h(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=H.Depth;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth").acquireDepth(C.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(be.DEPTH|be.STENCIL),this._renderTransparentTerrain(),h(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=h(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth").acquireDepth(C.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(be.DEPTH|be.STENCIL),this._renderOpaqueAndTransparentGeometry(H.Depth),this._renderContext.output=t,h(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=z(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 _emissiveRequired(){return this._nodes.require("emissive",S.FINAL,S.COMPOSITE)>0&&this._plugins.hasEmissions}get _normalsRequired(){const e=this._nodes.require("normals",S.FINAL,S.COMPOSITE,"opaque-color","transparent-color","laserline-color");return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(H.Normal),this._needsDepth&&this._precompileAllGeometry(H.Depth),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(H.ShadowHighlight),this._precompileShadowCascades(H.ShadowExcludeHighlight),this._precompileShadowCascades(H.ShadowHighlight)):this._precompileShadowCascades(H.Shadow)),this._needsShadowAccumulation&&this._precompileAllGeometry(H.Shadow)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",D.RGBA);r.acquireDepth(C.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(P,!0,!0),this._renderGeometryWithNormals(H.Normal);const i=this._nodes.optional("normals",S.FINAL,S.COMPOSITE,"opaque-color","transparent-color","viewshed-color");return r.retain(e+i-1),this.performanceInfo.advance(ue.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();O.setName(w.SSAO);const t=this._nodes.render(O,this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(ue.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(se.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,...Ie);this._renderContext.renderOccludedMask=$}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),U(t))}))}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>Y.Occlude&&this._plugins.render(this._pluginInput,se.OCCLUDED_TERRAIN),this.renderSlots(e,...Ie),this._renderContext.renderOccludedMask=$}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,se.HUD_MATERIAL)}precompileViewshedShadowMap(){this._precompileAllGeometry(H.ViewshedShadow)}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(H.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,...Pe),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Re)}_precompileOpaqueGeometry(){this._plugins.precompile(...Se)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...Se)}_renderTransparentGeometry(){this._plugins.render(this._pluginInput,...we)}get _hasTransparentTerrain(){return this._plugins.produces(H.Color,se.TRANSPARENT_TERRAIN)}_renderTransparentTerrain(){const e=()=>this._plugins.render(this._pluginInput,se.TRANSPARENT_TERRAIN);if(!x(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,P),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,se.OCCLUSION_PIXELS)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=h(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",D.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,se.OCCLUSION_PIXELS),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(ue.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===L.Occluded){const e=()=>this._plugins.render(this._pluginInput,se.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(C.DEPTH16_BUFFER,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,se.LINE_CALLOUTS)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=H.Highlight,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&x(this._renderContext.output)?(this._bindParameters.oitPass=K.ColorAlpha,this._plugins.precompile(...Ce),this._bindParameters.oitPass=K.FrontFace,this._plugins.precompile(...Ce),this._bindParameters.oitPass=K.NONE):this._plugins.precompile(...Ce),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(Ee.HUD,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,e===L.Occluded){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(C.DEPTH16_BUFFER,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(C.DEPTH16_BUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===L.Occluded?ue.HUD_OCCLUDED:ue.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,...Ce)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(H.ShadowHighlight,se.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,s=e.acquire(i.width,i.height,"highlights",D.RG);return s.acquireDepth(C.DEPTH_STENCIL_TEXTURE),t.bindFramebuffer(s.fbo),t.clearFramebuffer(P,!0),this._renderContext.output=H.Highlight,t.bindFramebuffer(s.fbo),q(t,e,i,r,(()=>this._renderHighlightGeometries()),0),this.performanceInfo.advance(ue.HIGHLIGHTS),s}_renderHighlightGeometries(){const e=0===this._bindParameters.highlightLevel?Ne:De;this._plugins.render(this._pluginInput,...e),this._rctx.clear(be.DEPTH),this._renderHUDElements(L.Both)}get _needsShadowAccumulation(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,t,r){this._needsShadowAccumulation&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(ue.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&x(this._renderContext.output)?(this._bindParameters.oitPass=K.ColorAlpha,this._plugins.precompile(...we),this._bindParameters.oitPass=K.FrontFace,this._plugins.precompile(...we),this._bindParameters.oitPass=K.NONE):this._plugins.precompile(...we)}_renderOIT(e,t,r=L.Both){const i=e===Ee.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=K.ColorAlpha;const d=a?"oit hud color alpha":"oit color alpha",_=this.fboCache.acquire(s.width,s.height,d,D.RGBA16F),l=t===H.ColorEmission;_.acquireColor(Te.COLOR_ATTACHMENT1,D.R16F),a||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),n(),_.detachDepth(),h.oitPass=K.FrontFace;const p=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return a?p.acquireDepth(C.DEPTH16_BUFFER):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(P,!!a),n(),p.detachDepth(),h.oitPass=K.NONE,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(be.COLOR)):this._framebuffer.bind(),this._oitblend??=new V(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(ue.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(this._pluginInput,se.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),this.performanceInfo.advance(ue.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=O,r=!0){return this._blit??=new G(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=b:(g(ye,this._bindParameters.camera.viewMatrix),g(Oe,this._bindParameters.camera.projectionMatrix),f(He,ye,Oe),f(He,this._renderContext.lastFrameCamera.viewMatrix,He),f(He,this._renderContext.lastFrameCamera.projectionMatrix,He),this._reprojectionMatrix=He);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=b,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(Q.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 Ee;e([m({readOnly:!0})],Ae.prototype,"fullResolutionAtmosphere",null),e([m()],Ae.prototype,"_edgeView",void 0),e([m()],Ae.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(Ee||(Ee={}));const Pe=[se.INTEGRATED_MESH,se.OPAQUE_TERRAIN,se.OPAQUE_MATERIAL,se.TRANSPARENT_MATERIAL],Re=[se.OPAQUE_MATERIAL_WITHOUT_NORMALS,se.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],Se=[se.INTEGRATED_MESH,se.OPAQUE_TERRAIN,se.OPAQUE_MATERIAL,se.OPAQUE_MATERIAL_WITHOUT_NORMALS],we=[se.TRANSPARENT_MATERIAL,se.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],Ie=[se.OPAQUE_MATERIAL,se.TRANSPARENT_MATERIAL,se.TRANSPARENT_MATERIAL_WITHOUT_DEPTH],Ce=[se.LINE_CALLOUTS_HUD_DEPTH,se.HUD_MATERIAL,se.LABEL_MATERIAL],De=[se.TRANSPARENT_MATERIAL,se.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,se.OPAQUE_MATERIAL,se.OPAQUE_MATERIAL_WITHOUT_NORMALS],Ne=[...De,se.TRANSPARENT_TERRAIN,se.INTEGRATED_MESH,se.OPAQUE_TERRAIN],Oe=T(),ye=T(),He=T();function xe(e){return t=>e.immediate.schedule(t)}export{Ae as Renderer};