@arcgis/core 4.31.0-next.20240706 → 4.31.0-next.20240708
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.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{3edc527a24cb9a4868e5.js → 20d0390504e4cc9f93f4.js} +1 -1
- package/assets/esri/core/workers/chunks/{ef8ba10380053ea4c4dd.js → 34ea46659c8cebec3ffa.js} +1 -1
- package/assets/esri/core/workers/chunks/5089a12084a8a8fb93d8.js +1 -0
- package/assets/esri/core/workers/chunks/{5afc1562bb5c20127ef1.js → e840e54455eb500b501d.js} +18 -18
- package/chunks/ChapmanAtmosphere.glsl.js +1 -1
- package/chunks/ComponentShader.glsl.js +3 -3
- package/chunks/DefaultMaterial.glsl.js +1 -1
- package/chunks/EdgeShader.glsl.js +5 -6
- package/chunks/Heatmap.glsl.js +4 -4
- package/chunks/HighlightApply.glsl.js +172 -135
- package/chunks/LineCallout.glsl.js +4 -4
- package/chunks/MeasurementArrow.glsl.js +5 -5
- package/chunks/RealisticTree.glsl.js +2 -2
- package/chunks/Terrain.glsl.js +39 -39
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TransparencyMode.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/Laserline.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +11 -11
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Terrain.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js +9 -0
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +5 -0
- package/views/3d/webgl-engine/lib/RenderContext.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Heatmap.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/LineCallout.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/MeasurementArrow.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeShader.glsl.js +1 -1
- package/assets/esri/core/workers/chunks/9a9abefa8099aa1ebc3d.js +0 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/AlphaDiscard.glsl.js +0 -7
- package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlphaBlend.glsl.js +0 -7
- package/views/3d/webgl-engine/lib/MainColor.js +0 -5
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/DiscardByCoverage.glsl.js +0 -5
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ForwardLinearDepth as e}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{Offset as o}from"../views/3d/webgl-engine/core/shaderLibrary/Offset.glsl.js";import{ShaderOutput as r}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SliceDraw as i}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{Transform as a}from"../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js";import{InstancedDoublePrecision as l}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js";import{NormalAttribute as t}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{PositionAttribute as s}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/PositionAttribute.glsl.js";import{SymbolColor as n}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js";import{TextureCoordinateAttribute as d}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexColor as c}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js";import{VerticalOffset as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{DefaultMaterialAuxiliaryPasses as m}from"../views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js";import{EvaluateAmbientOcclusion as v}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import{EvaluateSceneLighting as b,addAmbientBoostFactor as w,addLightingGlobalFactor as p}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightDirection as u,addMainLightIntensity as h}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{multipassTerrainTest as f}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{PhysicallyBasedRendering as x}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js";import{PhysicallyBasedRenderingParameters as y,PBRMode as C}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReadShadowMapPass as L,ReadShadowMapDraw as j}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{VisualVariables as M}from"../views/3d/webgl-engine/core/shaderLibrary/shading/VisualVariables.glsl.js";import{alphaCutoff as O}from"../views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{DiscardOrAdjustAlphaPass as P}from"../views/3d/webgl-engine/core/shaderLibrary/util/
|
|
5
|
+
import{ForwardLinearDepth as e}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{Offset as o}from"../views/3d/webgl-engine/core/shaderLibrary/Offset.glsl.js";import{ShaderOutput as r}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SliceDraw as i}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{Transform as a}from"../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js";import{InstancedDoublePrecision as l}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js";import{NormalAttribute as t}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{PositionAttribute as s}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/PositionAttribute.glsl.js";import{SymbolColor as n}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js";import{TextureCoordinateAttribute as d}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexColor as c}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js";import{VerticalOffset as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{DefaultMaterialAuxiliaryPasses as m}from"../views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js";import{EvaluateAmbientOcclusion as v}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import{EvaluateSceneLighting as b,addAmbientBoostFactor as w,addLightingGlobalFactor as p}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightDirection as u,addMainLightIntensity as h}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{multipassTerrainTest as f}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{PhysicallyBasedRendering as x}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js";import{PhysicallyBasedRenderingParameters as y,PBRMode as C}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReadShadowMapPass as L,ReadShadowMapDraw as j}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{VisualVariables as M}from"../views/3d/webgl-engine/core/shaderLibrary/shading/VisualVariables.glsl.js";import{alphaCutoff as O}from"../views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{DiscardOrAdjustAlphaPass as P}from"../views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import{MixExternalColor as A}from"../views/3d/webgl-engine/core/shaderLibrary/util/MixExternalColor.glsl.js";import{addProjViewLocalOrigin as E,addCameraPosition as S}from"../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js";import{Float3PassUniform as N}from"../views/3d/webgl-engine/core/shaderModules/Float3PassUniform.js";import{Float4PassUniform as F}from"../views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js";import{FloatPassUniform as $}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as D}from"../views/3d/webgl-engine/core/shaderModules/interfaces.js";import{ShaderBuilder as T}from"../views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js";import{Texture2DPassUniform as V}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{VertexAttribute as I}from"../views/3d/webgl-engine/lib/VertexAttribute.js";import{outputColorHighlightOID as B}from"../views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js";function _(_){const R=new T,{vertex:z,fragment:k,varyings:G}=R;return E(z,_),R.include(s),G.add("vpos","vec3"),R.include(M,_),R.include(l,_),R.include(g,_),_.output===r.Color&&(S(R.vertex,_),R.include(t,_),R.include(a,_),_.offsetBackfaces&&R.include(o),_.instancedColor&&R.attributes.add(I.INSTANCECOLOR,"vec4"),G.add("vNormalWorld","vec3"),G.add("localvpos","vec3"),_.multipassEnabled&&G.add("depth","float"),R.include(d,_),R.include(e,_),R.include(n,_),R.include(c,_),z.uniforms.add(new F("externalColor",(e=>e.externalColor))),G.add("vcolorExt","vec4"),z.code.add(D`
|
|
6
6
|
void main(void) {
|
|
7
7
|
forwardNormalizedVertexColor();
|
|
8
8
|
vcolorExt = externalColor;
|
|
@@ -26,7 +26,7 @@ import{ForwardLinearDepth as e}from"../views/3d/webgl-engine/core/shaderLibrary/
|
|
|
26
26
|
forwardLinearDepth();
|
|
27
27
|
forwardTextureCoordinates();
|
|
28
28
|
}
|
|
29
|
-
`)),_.output===r.Color&&(R.include(b,_),R.include(v,_),R.include(P,_),R.include(_.instancedDoublePrecision?L:j,_),R.include(f,_),R.include(i,_),R.include(B,_),
|
|
29
|
+
`)),_.output===r.Color&&(R.include(b,_),R.include(v,_),R.include(P,_),R.include(_.instancedDoublePrecision?L:j,_),R.include(f,_),R.include(i,_),R.include(B,_),S(R.fragment,_),u(k),w(k),p(k),k.uniforms.add(z.uniforms.get("localOrigin"),z.uniforms.get("view"),new N("ambient",(e=>e.ambient)),new N("diffuse",(e=>e.diffuse)),new $("opacity",(e=>e.opacity)),new $("layerOpacity",(e=>e.layerOpacity))),_.hasColorTexture&&k.uniforms.add(new V("tex",(e=>e.texture))),R.include(y,_),R.include(x,_),k.include(A),h(k),k.code.add(D`
|
|
30
30
|
void main() {
|
|
31
31
|
discardBySlice(vpos);
|
|
32
32
|
${_.multipassEnabled?D`terrainDepthTest(depth);`:""}
|
package/chunks/Terrain.glsl.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{translate as e}from"../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../core/libs/gl-matrix-2/factories/mat4f64.js";import{n as o,s as i}from"./vec32.js";import{create as a}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{OverlayContent as l}from"../views/3d/terrain/OverlayContent.js";import{TransparencyMode as t}from"../views/3d/terrain/TransparencyMode.js";import{addLinearDepth as n,addNearFar as s,ForwardLinearDepth as d}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{ShaderOutput as c}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SliceDraw as v}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{Transform as m}from"../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js";import{NormalAttribute as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{PositionAttribute as p}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/PositionAttribute.glsl.js";import{TextureCoordinateAttribute as f}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexTangent as w}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexTangent.glsl.js";import{OutputDepth as h}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js";import{OutputHighlight as
|
|
5
|
+
import{translate as e}from"../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../core/libs/gl-matrix-2/factories/mat4f64.js";import{n as o,s as i}from"./vec32.js";import{create as a}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{OverlayContent as l}from"../views/3d/terrain/OverlayContent.js";import{TransparencyMode as t}from"../views/3d/terrain/TransparencyMode.js";import{addLinearDepth as n,addNearFar as s,ForwardLinearDepth as d}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{ShaderOutput as c}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SliceDraw as v}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{Transform as m}from"../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js";import{NormalAttribute as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{PositionAttribute as p}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/PositionAttribute.glsl.js";import{TextureCoordinateAttribute as f}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexTangent as w}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexTangent.glsl.js";import{OutputDepth as h}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js";import{OutputHighlight as b}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js";import{EvaluateAmbientOcclusion as u}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import{EvaluateSceneLighting as y,addAmbientBoostFactor as C,addLightingGlobalFactor as x}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightDirection as O,addMainLightIntensity as S}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{NormalUtils as j}from"../views/3d/webgl-engine/core/shaderLibrary/shading/NormalUtils.glsl.js";import{PBRMode as L}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReadShadowMapDraw as z}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{OverlayMode as P,OverlayTerrain as T}from"../views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{OverlayTerrainPassParameters as M,TerrainTexture as $}from"../views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js";import{alphaCutoff as N}from"../views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{addProjViewLocalOrigin as D,addViewNormal as W,addCameraPosition as V}from"../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js";import{Float3PassUniform as U}from"../views/3d/webgl-engine/core/shaderModules/Float3PassUniform.js";import{glsl as F}from"../views/3d/webgl-engine/core/shaderModules/interfaces.js";import{Matrix4DrawUniform as A}from"../views/3d/webgl-engine/core/shaderModules/Matrix4DrawUniform.js";import{ShaderBuilder as _}from"../views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js";import{Texture2DPassUniform as B}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";class k extends M{}function I(r){const a=new _,{vertex:M,fragment:k,varyings:I}=a;a.include(p),a.include(g,r),a.include(f,r);const E=()=>{a.include(j,r),M.code.add(F`vec3 getNormal() {
|
|
6
6
|
float z = 1.0 - abs(normalCompressed.x) - abs(normalCompressed.y);
|
|
7
7
|
vec3 n = vec3(normalCompressed + vec2(normalCompressed.x >= 0.0 ? 1.0 : -1.0,
|
|
8
8
|
normalCompressed.y >= 0.0 ? 1.0 : -1.0) * min(z, 0.0), z);
|
|
9
9
|
return normalize(n);
|
|
10
|
-
}`)}
|
|
10
|
+
}`)};D(M,r),a.include(m,r);const G=r.transparencyMode===t.InvisibleWithDraped||r.transparencyMode===t.Invisible,R=r.overlayMode!==P.Disabled,J=R&&G;switch(r.output){case c.Color:{a.include($,r),a.include(y,r),R&&a.include(T,{...r,pbrMode:r.pbrMode===L.Simplified?L.TerrainWithWater:L.Water});const t=r.overlayMode===P.EnabledWithWater;t&&a.include(w,r),I.add("vnormal","vec3"),I.add("vpos","vec3"),I.add("vup","vec3"),E(),r.screenSizePerspective&&W(M);const n=r.receiveShadows&&!r.renderOccluded;n&&a.include(d,r),r.screenSizePerspective&&(I.add("screenSizeDistanceToCamera","float"),I.add("screenSizeCosAngle","float")),M.code.add(F`
|
|
11
11
|
void main(void) {
|
|
12
12
|
//Position
|
|
13
13
|
vpos = position;
|
|
@@ -20,27 +20,27 @@ return normalize(n);
|
|
|
20
20
|
//Up
|
|
21
21
|
vup = getLocalUp(position, localOrigin);
|
|
22
22
|
|
|
23
|
-
${t?
|
|
23
|
+
${t?F`forwardVertexTangent(vnormal);`:F``}
|
|
24
24
|
|
|
25
25
|
//Texture UV
|
|
26
26
|
vec2 uv = getUV0();
|
|
27
27
|
forwardTextureCoordinatesWithTransform(uv);
|
|
28
|
-
${
|
|
29
|
-
${r.tileBorders?
|
|
28
|
+
${R?F`setOverlayVTC(uv);`:""}
|
|
29
|
+
${r.tileBorders?F`forwardTextureCoordinates();`:""}
|
|
30
30
|
|
|
31
|
-
${r.screenSizePerspective?
|
|
31
|
+
${r.screenSizePerspective?F`
|
|
32
32
|
vec3 viewPos = (view * vec4(vpos, 1.0)).xyz;
|
|
33
33
|
screenSizeDistanceToCamera = length(viewPos);
|
|
34
34
|
vec3 viewSpaceNormal = (viewNormal * vec4(normalize(positionWorld), 1.0)).xyz;
|
|
35
35
|
screenSizeCosAngle = abs(viewSpaceNormal.z);`:""}
|
|
36
36
|
|
|
37
|
-
${n?
|
|
37
|
+
${n?F`forwardLinearDepth();`:""}
|
|
38
38
|
|
|
39
39
|
}
|
|
40
|
-
`),a.include(v,r),a.include(y,r),a.include(
|
|
40
|
+
`),a.include(v,r),a.include(y,r),a.include(u,r),a.include(z,r),V(k,r),C(k),x(k),k.uniforms.add(M.uniforms.get("localOrigin"),new U("viewDirection",((e,r)=>o(q,i(q,r.camera.viewMatrix[12],r.camera.viewMatrix[13],r.camera.viewMatrix[14]))))),t&&k.uniforms.add(new B("ovWaterTex",((e,r)=>r.overlay?.getTexture(l.WaterNormal))),new A("view",((r,o)=>e(H,o.camera.viewMatrix,r.origin)))),k.code.add(F`const float sliceOpacity = 0.2;
|
|
41
41
|
float lum(vec3 c) {
|
|
42
42
|
return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
43
|
-
}`),O(
|
|
43
|
+
}`),O(k),S(k),k.code.add(F`
|
|
44
44
|
void main() {
|
|
45
45
|
vec3 normal = normalize(vnormal);
|
|
46
46
|
float vndl = dot(normal, mainLightDirection);
|
|
@@ -51,16 +51,16 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
51
51
|
float ssao = evaluateAmbientOcclusionInverse();
|
|
52
52
|
vec4 tileColor = getTileColor();
|
|
53
53
|
|
|
54
|
-
${
|
|
54
|
+
${R?F`
|
|
55
55
|
vec4 overlayColorOpaque = getOverlayColor(ovColorTex, vtcOverlay);
|
|
56
56
|
vec4 overlayColor = overlayOpacity * overlayColorOpaque;
|
|
57
|
-
${
|
|
57
|
+
${G?F`if (overlayColor.a < ${F.float(N)}) { discard; }`:""}
|
|
58
58
|
vec4 groundColor = tileColor;
|
|
59
59
|
tileColor = tileColor * (1.0 - overlayColor.a) + overlayColor;`:""}
|
|
60
60
|
|
|
61
61
|
// If combined alpha is 0 we can discard pixel. The performance impact by having a discard here
|
|
62
62
|
// is neglectable because terrain typically renders first into the framebuffer.
|
|
63
|
-
if(tileColor.a
|
|
63
|
+
if(tileColor.a < ${F.float(N)}) {
|
|
64
64
|
discard;
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -75,8 +75,8 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
75
75
|
|
|
76
76
|
vec3 additionalLight = ssao * mainLightIntensity * additionalAmbientScale * ambientBoostFactor * lightingGlobalFactor;
|
|
77
77
|
|
|
78
|
-
${r.pbrMode===L.Simplified||r.pbrMode===L.TerrainWithWater?
|
|
79
|
-
${t?
|
|
78
|
+
${r.pbrMode===L.Simplified||r.pbrMode===L.TerrainWithWater?F`fragColor = vec4(evaluatePBRSimplifiedLighting(normal, albedo, shadow, 1.0 - ssao, additionalLight, normalize(vpos - cameraPosition), vup), tileColor.a);`:F`fragColor = vec4(evaluateSceneLighting(normal, albedo, shadow, 1.0 - ssao, additionalLight), tileColor.a);`}
|
|
79
|
+
${t?F`
|
|
80
80
|
vec4 overlayWaterMask = getOverlayColor(ovWaterTex, vtcOverlay);
|
|
81
81
|
float waterNormalLength = length(overlayWaterMask);
|
|
82
82
|
if (waterNormalLength > 0.95) {
|
|
@@ -89,7 +89,7 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
89
89
|
// un-gamma the ground color to mix in linear space
|
|
90
90
|
fragColor = mix(groundColor, waterColorNonLinear, waterColorLinear.w) * opacity;
|
|
91
91
|
}`:""}
|
|
92
|
-
${r.screenSizePerspective?
|
|
92
|
+
${r.screenSizePerspective?F`
|
|
93
93
|
float perspectiveScale = screenSizePerspectiveScaleFloat(1.0, screenSizeCosAngle, screenSizeDistanceToCamera, vec4(0.0, 0.0, 0.0, 0.0));
|
|
94
94
|
if (perspectiveScale <= 0.25) {
|
|
95
95
|
fragColor = mix(fragColor, vec4(1.0, 0.0, 0.0, 1.0), perspectiveScale * 4.0);
|
|
@@ -103,72 +103,72 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
103
103
|
else {
|
|
104
104
|
fragColor = mix(fragColor, vec4(1.0, 0.0, 1.0, 1.0), (perspectiveScale - 0.5) * 2.0);
|
|
105
105
|
}`:""}
|
|
106
|
-
${r.visualizeNormals?r.spherical?
|
|
106
|
+
${r.visualizeNormals?r.spherical?F`
|
|
107
107
|
vec3 localUp = normalize(vpos + localOrigin);
|
|
108
108
|
vec3 right = normalize(cross(vec3(0.0, 0.0, 1.0), localUp));
|
|
109
109
|
vec3 forward = normalize(cross(localUp, right));
|
|
110
110
|
mat3 tbn = mat3(right, forward, localUp);
|
|
111
111
|
vec3 tNormal = normalize(normal * tbn);
|
|
112
112
|
fragColor = vec4(vec3(0.5) + 0.5 * tNormal, 0.0);
|
|
113
|
-
`:
|
|
113
|
+
`:F`
|
|
114
114
|
vec3 tNormal = normalize(normal);
|
|
115
115
|
fragColor = vec4(vec3(0.5) + 0.5 * tNormal, 0.0);
|
|
116
116
|
`:""}
|
|
117
|
-
${r.tileBorders?
|
|
117
|
+
${r.tileBorders?F`
|
|
118
118
|
vec2 dVuv = fwidth(vuv0);
|
|
119
119
|
vec2 edgeFactors = smoothstep(vec2(0.0), 1.5 * dVuv, min(vuv0, 1.0 - vuv0));
|
|
120
120
|
float edgeFactor = 1.0 - min(edgeFactors.x, edgeFactors.y);
|
|
121
121
|
fragColor = mix(fragColor, vec4(1.0, 0.0, 0.0, 1.0), edgeFactor);`:""}
|
|
122
122
|
fragColor = highlightSlice(fragColor, vpos);
|
|
123
123
|
}
|
|
124
|
-
`)}break;case c.Depth:
|
|
124
|
+
`)}break;case c.Depth:J&&a.include(T,r),M.code.add(F`
|
|
125
125
|
void main(void) {
|
|
126
|
-
${
|
|
126
|
+
${J?F`setOverlayVTC(getUV0());`:""}
|
|
127
127
|
gl_Position = transformPosition(proj, view, position);
|
|
128
128
|
}
|
|
129
|
-
`),
|
|
129
|
+
`),k.code.add(F`
|
|
130
130
|
void main() {
|
|
131
|
-
${
|
|
131
|
+
${J?F`if (getCombinedOverlayColor().a < ${F.float(N)}) discard;`:""}
|
|
132
132
|
}
|
|
133
|
-
`);break;case c.Shadow:case c.ShadowHighlight:case c.ShadowExcludeHighlight:case c.ViewshedShadow:a.include(h,r),n(a),s(a),M.code.add(
|
|
133
|
+
`);break;case c.Shadow:case c.ShadowHighlight:case c.ShadowExcludeHighlight:case c.ViewshedShadow:a.include(h,r),n(a),s(a),M.code.add(F`void main(void) {
|
|
134
134
|
gl_Position = transformPositionWithDepth(proj, view, position, nearFar, linearDepth);
|
|
135
|
-
}`),
|
|
135
|
+
}`),k.code.add(F`void main() {
|
|
136
136
|
outputDepth(linearDepth);
|
|
137
|
-
}`);break;case c.Normal:
|
|
137
|
+
}`);break;case c.Normal:J&&a.include(T,r),I.add("vnormal","vec3"),W(M),E(),M.code.add(F`
|
|
138
138
|
void main(void) {
|
|
139
|
-
${
|
|
139
|
+
${J?F`setOverlayVTC(getUV0());`:""}
|
|
140
140
|
gl_Position = transformPosition(proj, view, position);
|
|
141
141
|
vnormal = normalize((viewNormal * vec4(getNormal(), 1.0)).xyz);
|
|
142
142
|
}
|
|
143
|
-
`),
|
|
143
|
+
`),k.code.add(F`
|
|
144
144
|
void main() {
|
|
145
|
-
${
|
|
145
|
+
${J?F`if (getCombinedOverlayColor().a < ${F.float(N)}) discard;`:""}
|
|
146
146
|
vec3 normal = normalize(vnormal);
|
|
147
147
|
if (gl_FrontFacing == false) {
|
|
148
148
|
normal = -normal;
|
|
149
149
|
}
|
|
150
150
|
fragColor = vec4(vec3(0.5) + 0.5 * normal, 1.0);
|
|
151
151
|
}
|
|
152
|
-
`);break;case c.Highlight:
|
|
152
|
+
`);break;case c.Highlight:R&&a.include(T,r),M.code.add(F`
|
|
153
153
|
void main() {
|
|
154
|
-
${
|
|
154
|
+
${R?F`setOverlayVTC(getUV0());`:""}
|
|
155
155
|
gl_Position = transformPosition(proj, view, position);
|
|
156
156
|
}
|
|
157
|
-
`),a.include(
|
|
157
|
+
`),a.include(b,r),k.code.add(F`
|
|
158
158
|
void main() {
|
|
159
|
-
${
|
|
159
|
+
${R?F`
|
|
160
160
|
vec4 combinedOverlayColor = getCombinedOverlayColor();
|
|
161
161
|
if (combinedOverlayColor == vec4(0.0)) { discard; }
|
|
162
|
-
`:
|
|
162
|
+
`:F``}
|
|
163
163
|
outputHighlight();
|
|
164
164
|
}
|
|
165
|
-
`)}if(r.output===c.ObjectAndLayerIdColor)if(
|
|
165
|
+
`)}if(r.output===c.ObjectAndLayerIdColor)if(R)a.include(T,{...r,pbrMode:L.Disabled}),M.code.add(F`void main(void) {
|
|
166
166
|
gl_Position = transformPosition(proj, view, position);
|
|
167
167
|
setOverlayVTC(getUV0());
|
|
168
|
-
}`),
|
|
168
|
+
}`),k.code.add(F`void main() {
|
|
169
169
|
fragColor = getOverlayColorTexel(vtcOverlay);
|
|
170
|
-
}`);else{const e=r.transparencyMode===t.Opaque;M.code.add(
|
|
171
|
-
${e?
|
|
172
|
-
}`),
|
|
170
|
+
}`);else{const e=r.transparencyMode===t.Opaque;M.code.add(F`void main(void) {
|
|
171
|
+
${e?F` gl_Position = transformPosition(proj, view, position);`:""}
|
|
172
|
+
}`),k.code.add(F`void main() {
|
|
173
173
|
fragColor = vec4(0.0);
|
|
174
|
-
}`)}return a}const
|
|
174
|
+
}`)}return a}const H=r(),q=a(),E=Object.freeze(Object.defineProperty({__proto__:null,TerrainPassParameters:k,build:I},Symbol.toStringTag,{value:"Module"}));export{k as T,E as a,I as b};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import{deg2rad as s}from"../../../../../core/mathUtils.js";import{exactEquals as r}from"../../../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as i,clone as a}from"../../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{e as o}from"../../../../../chunks/vec32.js";import{ZEROS as n,clone as l,ONES as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import u from"../../../MeshMaterialMetallicRoughness.js";import{convertVertexSpace as h}from"../../vertexSpaceConversion.js";import{Buffer as f}from"./buffer.js";import{smoothNormals as m}from"./geometry.js";import{BufferOutputType as p,ImageOutputType as d,AttributeType as g,TargetBuffer as x,AlphaMode as _}from"./types.js";import{imageToArrayBuffer as T,imageToDataURI as R}from"./imageutils.js";import{isEncodedMeshTexture as A}from"../../../../../views/3d/glTF/internal/resourceUtils.js";import{DataType as b,TextureWrapMode as E}from"../../../../../views/webgl/enums.js";const M=()=>e.getLogger("esri.geometry.support.meshUtils.exporters.gltf.gltf");class O{constructor(e,t){this.options=t,this._materialMap=new Array,this._imageMap=new Map,this._textureMap=new Map,this.gltf={asset:{version:"2.0",copyright:e.copyright,generator:e.generator},extras:{output:t.output,binChunkBuffer:null,promises:[]}},this._addScenes(e)}_addScenes(e){this.gltf.scene=e.defaultScene;const t=this.gltf.extras,s=t.output.buffer===p.GLB||t.output.image===d.GLB;s&&(t.binChunkBuffer=new f(this.gltf)),e.forEachScene((e=>{this._addScene(e)})),s&&t.binChunkBuffer.finalize()}_addScene(e){this.gltf.scenes||(this.gltf.scenes=[]);const t={};e.name&&(t.name=e.name),e.forEachNode((e=>{t.nodes||(t.nodes=[]),t.nodes.push(...this._addNodes(e))})),this.gltf.scenes.push(t)}_addNodes(e){this.gltf.nodes||(this.gltf.nodes=[]);const t={};e.name&&(t.name=e.name);const s=e.translation;o(s,n)||(t.translation=l(s));const u=e.rotation;r(u,i)||(t.rotation=a(u));const h=e.scale;o(h,c)||(t.scale=l(h));const f=this.gltf.nodes.length;if(this.gltf.nodes.push(t),e.mesh&&e.mesh.vertexAttributes.position){const s=this._createMeshes(e.mesh),r=[f];if(1===s.length)this._addMesh(t,s[0]);else for(const e of s){const t={};this._addMesh(t,e),r.push(this.gltf.nodes.length),this.gltf.nodes.push(t)}return r}return e.forEachNode((e=>{t.children||(t.children=[]),t.children.push(...this._addNodes(e))})),[f]}_addMesh(e,t){this.gltf.meshes??=[];const s=this.gltf.meshes.length;this.gltf.meshes.push(t),e.mesh=s}_createMeshes(e){const t=this.gltf.extras,s=t.output.buffer===p.GLB;let r;r=s?t.binChunkBuffer:new f(this.gltf);const i=this.options.origin,a=e.vertexSpace.clone();a.origin=[i.x,i.y,i.z??0];const o=h({vertexAttributes:e.vertexAttributes,vertexSpace:e.vertexSpace,transform:this.options?.ignoreLocalTransform?null:e.transform,spatialReference:e.spatialReference},a,{targetUnit:"meters"});if(!o)return[];m(e,o),w(o);const{position:n,normal:l,tangent:c}=o,{uv:u,color:d}=e.vertexAttributes,_=r.addBufferView(b.FLOAT,g.VEC3,x.ARRAY_BUFFER);let T,R,A,E;l&&(T=r.addBufferView(b.FLOAT,g.VEC3,x.ARRAY_BUFFER)),u&&(R=r.addBufferView(b.FLOAT,g.VEC2,x.ARRAY_BUFFER)),c&&(A=r.addBufferView(b.FLOAT,g.VEC4,x.ARRAY_BUFFER)),d&&(E=r.addBufferView(b.UNSIGNED_BYTE,g.VEC4,x.ARRAY_BUFFER)),_.startAccessor("POSITION"),T&&T.startAccessor("NORMAL"),R&&R.startAccessor("TEXCOORD_0"),A&&A.startAccessor("TANGENT"),E&&E.startAccessor("COLOR_0");const M=o.position.length/3;for(let h=0;h<M;++h)_.push(n[3*h]),_.push(n[3*h+1]),_.push(n[3*h+2]),T&&null!=l&&(T.push(l[3*h]),T.push(l[3*h+1]),T.push(l[3*h+2])),R&&null!=u&&(R.push(u[2*h]),R.push(u[2*h+1])),A&&null!=c&&(A.push(c[4*h]),A.push(c[4*h+1]),A.push(c[4*h+2]),A.push(c[4*h+3])),E&&null!=d&&(E.push(d[4*h]),E.push(d[4*h+1]),E.push(d[4*h+2]),E.push(d[4*h+3]));const O=_.endAccessor(),
|
|
5
|
+
import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import{deg2rad as s}from"../../../../../core/mathUtils.js";import{exactEquals as r}from"../../../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as i,clone as a}from"../../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{e as o}from"../../../../../chunks/vec32.js";import{ZEROS as n,clone as l,ONES as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import u from"../../../MeshMaterialMetallicRoughness.js";import{convertVertexSpace as h}from"../../vertexSpaceConversion.js";import{Buffer as f}from"./buffer.js";import{smoothNormals as m}from"./geometry.js";import{BufferOutputType as p,ImageOutputType as d,AttributeType as g,TargetBuffer as x,AlphaMode as _}from"./types.js";import{imageToArrayBuffer as T,imageToDataURI as R}from"./imageutils.js";import{isEncodedMeshTexture as A}from"../../../../../views/3d/glTF/internal/resourceUtils.js";import{DataType as b,TextureWrapMode as E}from"../../../../../views/webgl/enums.js";const M=()=>e.getLogger("esri.geometry.support.meshUtils.exporters.gltf.gltf");class O{constructor(e,t){this.options=t,this._materialMap=new Array,this._imageMap=new Map,this._textureMap=new Map,this.gltf={asset:{version:"2.0",copyright:e.copyright,generator:e.generator},extras:{output:t.output,binChunkBuffer:null,promises:[]}},this._addScenes(e)}_addScenes(e){this.gltf.scene=e.defaultScene;const t=this.gltf.extras,s=t.output.buffer===p.GLB||t.output.image===d.GLB;s&&(t.binChunkBuffer=new f(this.gltf)),e.forEachScene((e=>{this._addScene(e)})),s&&t.binChunkBuffer.finalize()}_addScene(e){this.gltf.scenes||(this.gltf.scenes=[]);const t={};e.name&&(t.name=e.name),e.forEachNode((e=>{t.nodes||(t.nodes=[]),t.nodes.push(...this._addNodes(e))})),this.gltf.scenes.push(t)}_addNodes(e){this.gltf.nodes||(this.gltf.nodes=[]);const t={};e.name&&(t.name=e.name);const s=e.translation;o(s,n)||(t.translation=l(s));const u=e.rotation;r(u,i)||(t.rotation=a(u));const h=e.scale;o(h,c)||(t.scale=l(h));const f=this.gltf.nodes.length;if(this.gltf.nodes.push(t),e.mesh&&e.mesh.vertexAttributes.position){const s=this._createMeshes(e.mesh),r=[f];if(1===s.length)this._addMesh(t,s[0]);else for(const e of s){const t={};this._addMesh(t,e),r.push(this.gltf.nodes.length),this.gltf.nodes.push(t)}return r}return e.forEachNode((e=>{t.children||(t.children=[]),t.children.push(...this._addNodes(e))})),[f]}_addMesh(e,t){this.gltf.meshes??=[];const s=this.gltf.meshes.length;this.gltf.meshes.push(t),e.mesh=s}_createMeshes(e){const t=this.gltf.extras,s=t.output.buffer===p.GLB;let r;r=s?t.binChunkBuffer:new f(this.gltf);const i=this.options.origin,a=e.vertexSpace.clone();a.origin=[i.x,i.y,i.z??0];const o=h({vertexAttributes:e.vertexAttributes,vertexSpace:e.vertexSpace,transform:this.options?.ignoreLocalTransform?null:e.transform,spatialReference:e.spatialReference},a,{targetUnit:"meters"});if(!o)return[];m(e,o),w(o);const{position:n,normal:l,tangent:c}=o,{uv:u,color:d}=e.vertexAttributes,_=r.addBufferView(b.FLOAT,g.VEC3,x.ARRAY_BUFFER);let T,R,A,E;l&&(T=r.addBufferView(b.FLOAT,g.VEC3,x.ARRAY_BUFFER)),u&&(R=r.addBufferView(b.FLOAT,g.VEC2,x.ARRAY_BUFFER)),c&&(A=r.addBufferView(b.FLOAT,g.VEC4,x.ARRAY_BUFFER)),d&&(E=r.addBufferView(b.UNSIGNED_BYTE,g.VEC4,x.ARRAY_BUFFER)),_.startAccessor("POSITION"),T&&T.startAccessor("NORMAL"),R&&R.startAccessor("TEXCOORD_0"),A&&A.startAccessor("TANGENT"),E&&E.startAccessor("COLOR_0");const M=o.position.length/3;for(let h=0;h<M;++h)_.push(n[3*h]),_.push(n[3*h+1]),_.push(n[3*h+2]),T&&null!=l&&(T.push(l[3*h]),T.push(l[3*h+1]),T.push(l[3*h+2])),R&&null!=u&&(R.push(u[2*h]),R.push(u[2*h+1])),A&&null!=c&&(A.push(c[4*h]),A.push(c[4*h+1]),A.push(c[4*h+2]),A.push(c[4*h+3])),E&&null!=d&&(E.push(d[4*h]),E.push(d[4*h+1]),E.push(d[4*h+2]),E.push(d[4*h+3]));const O=_.endAccessor(),I=this._addAccessor(_.index,O);let N,C,v,S,B;if(T){const e=T.endAccessor();N=this._addAccessor(T.index,e)}if(R){const e=R.endAccessor();C=this._addAccessor(R.index,e)}if(A){const e=A.endAccessor();v=this._addAccessor(A.index,e)}if(E){const e=E.endAccessor();S=this._addAccessor(E.index,e)}const L=[];return e.components&&e.components.length>0&&e.components[0].faces?(B=r.addBufferView(b.UNSIGNED_INT,g.SCALAR,x.ELEMENT_ARRAY_BUFFER),this._addMeshVertexIndexed(B,e.components,L,I,N,C,v,S)):this._addMeshVertexNonIndexed(e.components,L,I,N,C,v,S),_.finalize(),T&&T.finalize(),R&&R.finalize(),A&&A.finalize(),B&&B.finalize(),E&&E.finalize(),s||r.finalize(),L}_addMaterial(e){if(null===e)return;const t=this._materialMap.indexOf(e);if(-1!==t)return t;this.gltf.materials||(this.gltf.materials=[]);const s={};switch(e.alphaMode){case"mask":s.alphaMode=_.MASK;break;case"auto":case"blend":s.alphaMode=_.BLEND}s.alphaCutoff=e.alphaCutoff,e.doubleSided&&(s.doubleSided=e.doubleSided),s.pbrMetallicRoughness={};const r=e=>e**2.1,i=e=>{const t=e.toRgba();return t[0]=r(t[0]/255),t[1]=r(t[1]/255),t[2]=r(t[2]/255),t};if(null!=e.color&&(s.pbrMetallicRoughness.baseColorFactor=i(e.color)),null!=e.colorTexture&&(s.pbrMetallicRoughness.baseColorTexture=this._createTextureInfo(e.colorTexture,e.colorTextureTransform)),null!=e.normalTexture&&(s.normalTexture=this._createTextureInfo(e.normalTexture,e.normalTextureTransform)),e instanceof u){if(null!=e.emissiveTexture&&(s.emissiveTexture=this._createTextureInfo(e.emissiveTexture,e.emissiveTextureTransform)),null!=e.emissiveColor){const t=i(e.emissiveColor);s.emissiveFactor=[t[0],t[1],t[2]]}null!=e.occlusionTexture&&(s.occlusionTexture=this._createTextureInfo(e.occlusionTexture,e.occlusionTextureTransform)),null!=e.metallicRoughnessTexture&&(s.pbrMetallicRoughness.metallicRoughnessTexture=this._createTextureInfo(e.metallicRoughnessTexture,e.metallicRoughnessTextureTransform)),s.pbrMetallicRoughness.metallicFactor=e.metallic,s.pbrMetallicRoughness.roughnessFactor=e.roughness}else s.pbrMetallicRoughness.metallicFactor=1,s.pbrMetallicRoughness.roughnessFactor=1,M().warnOnce("Meshes exported to GLTF without MeshMaterialMetallicRoughness material will appear different when imported back.");const a=this.gltf.materials.length;return this.gltf.materials.push(s),this._materialMap.push(e),a}_createTextureInfo(e,t){const r={index:this._addTexture(e)};return t?(r.extensions||(r.extensions={}),r.extensions.KHR_texture_transform={scale:t.scale,offset:t.offset,rotation:s(t.rotation)},r):r}_addTexture(e){const s=this.gltf.textures??[];return this.gltf.textures=s,t(this._textureMap,e,(()=>{const t={sampler:this._addSampler(e),source:this._addImage(e)},r=s.length;return s.push(t),r}))}_addImage(e){const t=this._imageMap.get(e);if(null!=t)return t;this.gltf.images||(this.gltf.images=[]);const s={};if(e.url)s.uri=e.url;else{const t=e.data;s.extras=t;for(let e=0;e<this.gltf.images.length;++e)if(t===this.gltf.images[e].extras)return e;const r=this.gltf.extras;switch(r.output.image){case d.GLB:{const e=r.binChunkBuffer.addBufferView(b.UNSIGNED_BYTE,g.SCALAR);if(A(t))null!=t.data&&e.writeOutToBuffer(t.data,0);else{const i=T(t,this.options.signal).then((({data:e,type:t})=>(s.mimeType=t,e)));r.promises.push(e.writeAsync(i).then((()=>{e.finalize()})))}s.bufferView=e.index;break}case d.DataURI:if(A(t)){M().warnOnce("Image export for basis compressed textures not available.");break}s.uri=R(t);break;default:if(A(t)){M().warnOnce("Image export for basis compressed textures not available.");break}r.promises.push(T(t,this.options.signal).then((({data:e,type:t})=>{s.uri=e,s.mimeType=t})))}}const r=this.gltf.images.length;return this.gltf.images.push(s),this._imageMap.set(e,r),r}_addSampler(e){this.gltf.samplers||(this.gltf.samplers=[]);let t=E.REPEAT,s=E.REPEAT;if("string"==typeof e.wrap)switch(e.wrap){case"clamp":t=E.CLAMP_TO_EDGE,s=E.CLAMP_TO_EDGE;break;case"mirror":t=E.MIRRORED_REPEAT,s=E.MIRRORED_REPEAT}else{switch(e.wrap.vertical){case"clamp":s=E.CLAMP_TO_EDGE;break;case"mirror":s=E.MIRRORED_REPEAT}switch(e.wrap.horizontal){case"clamp":t=E.CLAMP_TO_EDGE;break;case"mirror":t=E.MIRRORED_REPEAT}}const r={wrapS:t,wrapT:s};for(let a=0;a<this.gltf.samplers.length;++a)if(JSON.stringify(r)===JSON.stringify(this.gltf.samplers[a]))return a;const i=this.gltf.samplers.length;return this.gltf.samplers.push(r),i}_addAccessor(e,t){this.gltf.accessors||(this.gltf.accessors=[]);const s={bufferView:e,byteOffset:t.byteOffset,componentType:t.componentType,count:t.count,type:t.type,min:t.min,max:t.max,name:t.name};t.normalized&&(s.normalized=!0);const r=this.gltf.accessors.length;return this.gltf.accessors.push(s),r}_addMeshVertexIndexed(e,t,s,r,i,a,o,n){const l=new Map;for(const c of t){e.startAccessor("INDICES");for(let s=0;s<c.faces.length;++s)e.push(c.faces[s]);const t=e.endAccessor(),u={attributes:{POSITION:r},indices:this._addAccessor(e.index,t),material:this._addMaterial(c.material)};i&&"flat"!==c.shading&&(u.attributes.NORMAL=i),a&&(u.attributes.TEXCOORD_0=a),o&&"flat"!==c.shading&&(u.attributes.TANGENT=o),n&&(u.attributes.COLOR_0=n);const h=l.get(c.name);if(h)h.primitives.push(u);else{const e={name:c.name,primitives:[u]};l.set(c.name,e),s.push(e)}}}_addMeshVertexNonIndexed(e,t,s,r,i,a,o){const n={primitives:[]};t.push(n);const l={attributes:{POSITION:s}};r&&(l.attributes.NORMAL=r),i&&(l.attributes.TEXCOORD_0=i),a&&(l.attributes.TANGENT=a),o&&(l.attributes.COLOR_0=o),e&&(l.material=this._addMaterial(e[0].material)),n.primitives.push(l)}}function w({position:e,normal:t,tangent:s}){I(e,3),I(t,3),I(s,4)}function I(e,t){if(null!=e)for(let s=1,r=2;s<e.length;s+=t,r+=t){const t=e[s],i=e[r];e[s]=i,e[r]=-t}}export{O as GLTF};
|
package/package.json
CHANGED
package/support/revision.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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e="
|
|
5
|
+
const e="20240708",a="9ee0717e510087e1a276aef849bb9dd818674174";export{e as buildDate,a 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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{unitRGBAFromColor as e}from"../../../core/colorUtils.js";import t from"../../../core/Handles.js";import{clamp as s,lerp as i,smoothstep as
|
|
5
|
+
import{unitRGBAFromColor as e}from"../../../core/colorUtils.js";import t from"../../../core/Handles.js";import{clamp as s,lerp as i,smoothstep as r}from"../../../core/mathUtils.js";import{watch as a,syncAndInitial as o}from"../../../core/reactiveUtils.js";import{set as n}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{s as h,l as m,q as u}from"../../../chunks/vec32.js";import{s as c}from"../../../chunks/vec42.js";import{ZEROS as d}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{earth as p}from"../../../geometry/support/Ellipsoid.js";import{AtmosphereType as l}from"./AtmosphereType.js";import{atmosphereHeight as _,innerAtmosphereDepth as f,computeInnerAltitudeFade as b}from"./atmosphereUtils.js";import{ChapmanAtmospherePassParameters as T,ChapmanAtmosphereTechnique as q}from"./ChapmanAtmosphereTechnique.js";import{ChapmanAtmosphereTechniqueConfiguration as g}from"./ChapmanAtmosphereTechniqueConfiguration.js";import{ColorFormat as v}from"../webgl/formats.js";import{Pos2Tex as w}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{createQuadVAO as P}from"../webgl-engine/lib/glUtil3D.js";import{applyTextureResizeModulo as x}from"../webgl-engine/lib/textureUtils.js";import{A as j}from"../../../chunks/AtmosphereCompositing.glsl.js";import{AtmosphereCompositingTechnique as R}from"../webgl-engine/shaders/AtmosphereCompositingTechnique.js";import{PrimitiveType as E}from"../../webgl/enums.js";import z from"../../../webscene/background/ColorBackground.js";class B{constructor(s,i){this._view=s,this._context=i,this.type=l.Realistic,this._handles=new t,this._compositingPassParameters=new j,this._passParameters=new T,this._rootTileElevationMin=NaN,this._lowerBoundEarthRadius=p.radius,this._fadeHaze=0,this._updateRadius(p.radius);const r=this._context.renderContext.rctx;this._updateRootTileElevationBounds(),this._handles.add([a((()=>this._view?.basemapTerrain?.rootTileElevationBounds),(()=>this._view?.basemapTerrain?this._updateRootTileElevationBounds():null)),a((()=>this._view?.basemapTerrain?.visibleElevationBounds),(()=>this._view?.basemapTerrain?this._updateVisibleElevationBounds():null)),a((()=>this._view?.environment.background),(t=>{const s=t instanceof z?e(t.color):d;h(this._passParameters.backgroundColor,s[0]*s[3],s[1]*s[3],s[2]*s[3])}),o)]);const n=new g;n.haze=!1,this._atmosphereTechnique=this._context.techniques.acquire(q,n),this._compositingTechnique=this._context.techniques.acquire(R,n),n.haze=!0,this._atmosphereHazeTechnique=this._context.techniques.acquire(q,n),this._compositingHazeTechnique=this._context.techniques.acquire(R,n),n.reduced=!0,n.haze=!1,this._atmosphereReducedTechnique=this._context.techniques.acquire(q,n),n.haze=!0,this._atmosphereHazeReducedTechnique=this._context.techniques.acquire(q,n),this._vao=P(r,w)}destroy(){this._handles.destroy(),this._compositingTechnique.release(),this._compositingHazeTechnique.release(),this._atmosphereTechnique.release(),this._atmosphereHazeTechnique.release(),this._atmosphereReducedTechnique.release(),this._atmosphereHazeReducedTechnique.release(),this._vao.dispose()}render(e,t){this._render(e,t?this._atmosphereTechnique:this._atmosphereReducedTechnique,t,!1)}renderHaze(e,t,s){this._fadeHaze=t,this._render(e,s?this._atmosphereHazeTechnique:this._atmosphereHazeReducedTechnique,s,!0)}_render(e,t,s,r){if(!e.bindParameters.mainDepth)return;const a=e.bindParameters.camera;this._update(a);const o=e.rctx,n=o.bindTechnique(t,e.bindParameters,this._passParameters),h=e.framebuffer;if(s)h.renderWithoutDepth((()=>this._renderCommon(n,o)));else{const t=o.getViewport(),s=m(a.eye)-p.radius;let u;if(s<_){const e=Math.min(1,Math.max(0,s/_));u=r?i(.4,.5,e):i(.2,.3,e)}else{const e=Math.min(1,Math.max(0,(s-_)/(15*_)));u=r?i(.5,1,e):i(.3,.6,e)}const c=x(Math.round(u*a.fullViewport[2])),d=x(Math.round(u*a.fullViewport[3]));o.setViewport(0,0,c,d);const l=this._context.fbos.acquire(c,d,r?"chapman haze":"chapman",v.RGBA);o.bindFramebuffer(l.fbo),o.clearFramebuffer([0,0,0,1],!0,!0),this._renderCommon(n,o),o.setViewport(t.x,t.y,t.width,t.height),this._compositingPassParameters.color=l.getTexture();const f=r?this._compositingHazeTechnique:this._compositingTechnique;o.bindTechnique(f,e.bindParameters,this._compositingPassParameters),h.renderWithoutDepth((()=>o.screen.draw())),l.release()}}_renderCommon(e,t){null!=this._vao&&(t.bindVAO(this._vao),e.assertCompatibleVertexAttributeLocations(this._vao),t.drawArrays(E.TRIANGLE_STRIP,0,4))}_updateRootTileElevationBounds(){const e=this._view.basemapTerrain.rootTileElevationBounds.min;e!==this._rootTileElevationMin&&(this._rootTileElevationMin=e,this._lowerBoundEarthRadius=p.radius,this._updateVisibleElevationBounds())}_updateVisibleElevationBounds(){const e=H(p.radius+this._view.basemapTerrain.visibleElevationBounds.min);e<this._lowerBoundEarthRadius&&this._updateRadius(e)}_updateRadius(e){this._lowerBoundEarthRadius=e,n(this._passParameters.radii,e,e+_),this._passParameters.innerFadeDistance=2*Math.sqrt((2*e-f)*f)}_update(e){if(!e)return;const t=u(e.eye),a=Math.sqrt(t),o=t-this._passParameters.radii[1]*this._passParameters.radii[1],n=s((a-this._passParameters.radii[0])/_,0,1);c(this._passParameters.heightParameters,a,t,o,n),this._passParameters.altitudeFade=b(a-this._lowerBoundEarthRadius),this._passParameters.hazeStrength=i(i(.6,1,r(9500,10500,a-p.radius)),1,this._fadeHaze)}}function H(e){return e*Math.cos(Math.PI/16/16)}export{B as ChapmanAtmosphere};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import s from"../../../core/Accessor.js";import{smoothstep as e}from"../../../core/mathUtils.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{n as i,m as a,j as n,o as c,l as m}from"../../../chunks/vec32.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../geometry/ellipsoidUtils.js";import{atmosphereHeight as u}from"./atmosphereUtils.js";import{F as d}from"../../../chunks/Fog.glsl.js";import{FogTechnique as l}from"./FogTechnique.js";import{weatherHeightLimit as g}from"./weather.js";const f=.95,_=1;let j=class extends s{constructor(t){super(t),this._passParameters=new d,this._technique=new l(t);const s=h(t.view.spatialReference);this._planetRadius=s.radius,this._atmosphereRadius=s.radius+u}destroy(){this._technique.release()}set strength(t){this._passParameters.fogStrength=t}get strength(){return this._passParameters.fogStrength}render(t,s){
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import s from"../../../core/Accessor.js";import{smoothstep as e}from"../../../core/mathUtils.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{n as i,m as a,j as n,o as c,l as m}from"../../../chunks/vec32.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../geometry/ellipsoidUtils.js";import{atmosphereHeight as u}from"./atmosphereUtils.js";import{F as d}from"../../../chunks/Fog.glsl.js";import{FogTechnique as l}from"./FogTechnique.js";import{weatherHeightLimit as g}from"./weather.js";const f=.95,_=1;let j=class extends s{constructor(t){super(t),this._passParameters=new d,this._technique=new l(t);const s=h(t.view.spatialReference);this._planetRadius=s.radius,this._atmosphereRadius=s.radius+u}destroy(){this._technique.release()}set strength(t){this._passParameters.fogStrength=t}get strength(){return this._passParameters.fogStrength}render(t,s){this._update(t,s),this._passParameters.fogAmount<=0||(this._technique.compiled?t.framebuffer.renderWithoutDepth((()=>{t.rctx.bindTechnique(this._technique,t.bindParameters,this._passParameters),t.rctx.screen.draw()})):this.context.requestRender())}_update(t,s){const r=t.bindParameters.camera;i(P,r.eye);const o=Math.max(0,a(P,t.bindParameters.lighting.mainLight.direction)),p=s.color;n(v,p,.1),c(this._passParameters.fogColor,v,p,o);const h=m(r.eye),u=h*h;this._passParameters.atmosphereC=u-this._atmosphereRadius**2,this._passParameters.fogAmount=(1-e(f*g,_*g,Math.abs(h-this._planetRadius)))*s.amount,this._passParameters.fogStrength=s.strength}};t([r({constructOnly:!0})],j.prototype,"context",void 0),t([r({constructOnly:!0})],j.prototype,"view",void 0),t([r({constructOnly:!0})],j.prototype,"rctx",void 0),t([r({constructOnly:!0})],j.prototype,"viewingMode",void 0),j=t([o("esri.views.3d.environment.Fog")],j);class y{constructor(){this.color=p(),this.strength=0,this.amount=0}}const P=p(),v=p();export{j as Fog,y as FogParameters};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import has from"../../../core/has.js";import r from"../../../core/Logger.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{watch as s,initial as o}from"../../../core/reactiveUtils.js";import{schedule as n}from"../../../core/scheduling.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as c,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{IDENTITY as d,create as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as u,getTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{g as b,t as y}from"../../../chunks/vec32.js";import{fromArray as w,create as v}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as _}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as j}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{BufferViewVec4f as M,BufferViewVec4u8 as P,BufferViewVec4u16 as O,BufferViewVec3f as U,BufferViewVec3u8 as E,BufferViewVec3u16 as V,BufferViewVec2f as I,BufferViewInt16 as H,BufferViewUint32 as R,BufferViewUint16 as A}from"../../../geometry/support/buffer/BufferView.js";import{invalidLayerView as F,wasmFailedToInit as S,Lyr3DPrimitiveType as L,Lyr3DLightingModel as D,Lyr3DUvWrapMode as k,Lyr3DImageFormat as B,Lyr3DPixelFormat as G,Lyr3DVtxAtrbSemantic as N,Lyr3DType as z}from"../../../layers/ILyr3DWasmPerSceneView.js";import{getElevationOffsetInMeters as W}from"../../../support/elevationInfoUtils.js";import{ViewingMode as $}from"../../ViewingMode.js";import{IntegratedMesh3DTilesViewPerformanceInfo as J}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{DrapeTargetType as q}from"./interfaces.js";import{LayerView3D as K}from"./LayerView3D.js";import{addLayerViewToWasm as Q,removeLayerViewFromWasm as X,getLyr3DWasm as Y}from"./Lyr3DWasm.js";import{LayerElevationProvider as Z}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as ee,alphaModeConversion as te,faceCullingConversion as re,wrapModeConversion as ie,lyr3DTypeToByteSize as se}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as oe}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as ne}from"../support/ElevationRange.js";import{Obb as ae,compute as le}from"../support/orientedBoundingBox.js";import{ObjectParameters as ce}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as me}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as de}from"../webgl-engine/collections/Component/Transform.js";import{ComponentParameterSummary as he}from"../webgl-engine/collections/Component/Material/ComponentMaterial.js";import{RenderTexture as ue}from"../webgl-engine/core/material/RenderTexture.js";import{TextureCoordinateAttributeType as pe}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{getEllipsoidMode as fe}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as ge}from"../webgl-engine/lib/Attribute.js";import{CullFaceOptions as be,AlphaDiscardMode as ye,TextureEncodingMimeType as we}from"../webgl-engine/lib/basicInterfaces.js";import{compressAndTransformNormals as ve}from"../webgl-engine/lib/Normals.js";import{Texture as _e}from"../webgl-engine/lib/Texture.js";import{VertexAttribute as xe}from"../webgl-engine/lib/VertexAttribute.js";import{writeDefaultAttribute as je}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Ce from"../../layers/LayerView.js";import{isInEffectiveScaleRange as Te}from"../../support/layerViewUtils.js";var Me;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(Me||(Me={}));class Pe{constructor(){this.handle=0,this.isVisible=!1,this.components=[],this.texMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}totalMemory(){return this.texMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}}function Oe(e){return Math.round(e/1048.576)/1e3}let Ue=class extends(K(Ce)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this.drapeTargetType=q.WithoutRasterImage,this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}initialize(){if(this._dbgFlags.add(Me.Error),this._dbg(Me.VerboseAPI,"Tiles3DLayerView3D initialize() called"),!this._canProjectWithoutEngine())throw new t("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const e=Q(this).then((e=>{this._intersectionHandler=new oe(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._elevationProvider=new Z({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this),this._wasmLayerId=e;const t=this.view.resourceController.memoryController.newCache(`t3d-${this.uid}`,(e=>this._onRemoveFromCache(e)));this._memCache=t,this.addHandles([s((()=>this.layer.elevationInfo),(e=>this._elevationInfoChanged(e)))]),this._suspendedHandle=s((()=>this.suspended),(e=>{const t=Y(this.view);t&&t.setEnabled(this,!e)}),o)})).catch((e=>{if(X(this),this._wasmLayerId=-1,e===F)throw new t("tiles3d:addLayer-failure","The 3d tiles layer description was invalid.",{});if(e===S)throw new t("tiles3d:addLayer-failure","The 3d tiles layer web assembly module failed to download.",{})}));this.addResolvingPromise(e)}destroy(){this._dbg(Me.VerboseAPI,"Tiles3DLayerView3D destroy() called"),X(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach((e=>this.freeObject(e))),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._memCache=i(this._memCache),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_visibleGeometryChanged(){null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=n((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})))}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.objects.forEach((t=>{const r=this._collection.getMaterial(t);r.commonMaterialParameters.hasSlicePlane=e,r.commonMaterialParameters.cullFace=e?be.None:this._initialCullFace.get(t)}))}_elevationInfoChanged(e){const t=Y(this.view);t&&t.setLayerOffset(this,W(e))}get _obbs(){return this.objects.map((e=>this._collection.getComponentObb(e)))}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible&&(e+=t.totalMemory())})),e}get unloadedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible||(e+=t.totalMemory())})),e}get visibleAtCurrentScale(){return Te(this.layer.effectiveScaleRange,this.view.terrainScale)}get performanceInfo(){let e=0,t=0,r=0,i=0,s=0,o=0;return this._lyrHandleToObjects.forEach((n=>{n.isVisible?(e+=n.texMemoryUsage,t+=n.vboMemoryUsage,s++):(r+=n.texMemoryUsage,i+=n.vboMemoryUsage,o++)})),new J(this.usedMemory,s,o,Oe(t),Oe(e),Oe(i),Oe(r))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===$.Local){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view._stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return W(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ne(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce(((e,t)=>e.concat(t.components)),new Array)}isUpdating(){const e=Y(this.view);return!(this._wasmLayerId<0||null==e)&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const r=w(t.desc.origin),i=new Array,s=new Map,o=new Pe;o.handle=e.handle,this._lyrHandleToObjects.set(e.handle,o);const n=this.view.basemapTerrain.spatialReference;let a,l;if("global"===this.view.viewingMode){const e=f();j(x,r,e,n),a=c(h(),e),l=m(h(),a)}else a=d,l=d;const M=f();u(M,M,r);const P=p(v(),M);let O=null;const U=v();if(t.desc.obb){const e=t.desc.obb.quaternion;O=new ae(t.desc.obb.center,t.desc.obb.halfSize,g(e[0],e[1],e[2],e[3]))}for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];if(this._dbg(Me.VerboseAPI,JSON.stringify(e)),e.ptype===L.Lines)continue;if(null==ee[e.ptype]||null==t.data){this._dbg(Me.VerboseAPI,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const m=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,h=null!=m?m.lightingModel:D.Unlit,u=!has("disable-feature:im-shading"),{positionView:p,positionAttr:f,normalsView:g,normalsAttr:w,colorAttr:x,texCoord0Attr:j,indicesView:M}=this.getBufferViews(e,t.data.buffer,a,u);if(null==f||null==p||null==M)continue;const E={colors:null!=x,textureCoordinates:null!=j?pe.Default:pe.None,hasNormals:null!=g,needsNormals:u},V=f.data.length/f.size,I=(e,t)=>!e||e.data.length/e.size===V||(this._dbg(Me.Error,`${t} !== numPos. Skipping primitive.`),!1);if(!I(j,"numTexcoord")||!I(x,"numColors")||!I(w,"normals"))continue;const H=me(E);if(null!=O?O=O.clone():(O=le(f),b(U,O.center,r),O.center=U),a!==d)for(let t=0;t<p.count;t++)p.getVec(t,U),y(U,U,a),p.setVec(t,U);const R=H.createBuffer(f.data.length),A=new Map([[xe.POSITION,f]]);null!=j&&A.set(xe.UV0,j),null!=x&&A.set(xe.COLOR,x),null!=w&&A.set(xe.NORMALCOMPRESSED,w),A.forEach(((e,t)=>{null!=e&&je(t,e,null,null,R,0)}));const F=new Uint32Array([0,M.typedBuffer.length]),S={vertices:{data:R.buffer,count:R.byteLength/H.stride,layoutParameters:E},positionData:{positions:p.typedBuffer,indices:M.typedBuffer},indices:M.typedBuffer,componentOffsets:F};o.cpuMemoryUsage+=p.count,o.cpuMemoryUsage+=M.count;const k=this.view.renderSpatialReference,B=v(),G=[1,1,1];C(P,k,G,n)||this._dbg(Me.Error,"Unsupported coordinate system for IM overlay"),T(P,k,B,n);const N=this._collection.createObject(new ce(_(B[0],B[1],G[0],G[1]),new de(P,l),O,S));m&&this._collection.updateMaterial(N,(e=>{e.baseColor=m.baseColorFactor,e.usePBR=h===D.Pbr,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(m.baseColorTex,t,s),e.usePBR&&(e.mrrFactors=[m.metallicFactor,m.roughnessFactor,0],e.emissiveFactor=m.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(m.metalTex,t,s),e.emissionTexture=this._getTexture(m.emissiveTex,t,s),e.occlusionTexture=this._getTexture(m.occlusionTex,t,s),e.normalTexture=this._getTexture(m.normalTex,t,s)),e.objectOpacity=0,e.alphaDiscardMode=ye.Mask;const r=[];e.baseColorTexture&&r.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&r.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&r.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&r.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&r.push(e.normalTexture.loadPromise);const n=Promise.all(r);i.push(n),n.then((()=>{e.alphaDiscardMode=te[m.alphaMode],e.objectOpacity=1,o.texMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(o.texMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)})),e.commonMaterialParameters.doubleSided=m.isDoubleSided,e.commonMaterialParameters.cullFace=m.faceCulling?re[m.faceCulling]:be.Back,this._initialCullFace.set(N,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=he.All,e.textureAlphaCutoff=m.alphaCutoff??.1,e.alphaDiscardMode=te[m.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=fe(this.view.spatialReference)})),o.components.push(N),o.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage(N)}if(await Promise.all(i),s.forEach((e=>{o.textures.push(e)})),!this._memCache)throw new Error("no memCache");return this._memCache.put(`${o.handle}`,o,o.totalMemory()),{memUsageBytes:o.totalMemory()}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache&&this._memCache.pop(`${e.handle}`),e.components.forEach((t=>{e.textures.forEach((e=>{this._stage.remove(e)})),this._collection.destroyObject(t),this._initialCullFace.delete(t)}))}setRenderableVisibility(e,t,r){if(this._memCache){for(let i=0;i<r;++i){const r=e[i],s=t[i];if(!s)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=s,o.components.forEach((e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.pop(`${r}`))}for(let i=0;i<r;++i){const r=e[i],s=t[i];if(s)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=s,o.components.forEach((e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.put(`${r}`,o,o.totalMemory()))}}}_getTexture(e,t,r){let i=null;if(e&&t.desc?.images&&t.data?.buffer){const s=t.desc.images[e?.imageId];if(i=r.get(s),!i&&s){const o=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,n=o>1,a=ie[e.wrapMode??k.None];let l=s.alpha?4:3;const c=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,d=null,h=null;switch(s.format){case B.Raw:s.pixelFormat===G.R8?(m=c.buffer,l=1,d=""):s.pixelFormat===G.Rgb8?(m=c.buffer,l=3,d=""):s.pixelFormat===G.Rgba8&&(m=c.buffer,l=4,d="");break;case B.Dxt1:m=c.buffer,l=3,d=we.DDS_ENCODING;break;case B.Dxt5:m=c.buffer,l=4,d=we.DDS_ENCODING;break;case B.Png:d="image/png",h=document.createElement("img");break;case B.Jpeg:d="image/jpeg",h=document.createElement("img");break;case B.Etc2:d="image/ktx",h=document.createElement("img");break;case B.Astc:this._dbg(Me.Error,"Astc texture not supported");break;case B.Pvrtc:this._dbg(Me.Error,"Pvrtc texture not supported")}if(h&&d){const e=new Blob([c],{type:d});h.src=URL.createObjectURL(e),m=h}m&&null!=d&&(i=new _e(m,{mipmap:n,maxAnisotropy:o,encoding:d,wrap:a,components:l,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height}),this._stage.add(i),r.set(s,i))}}return i?new ue(this.view._stage.renderView.textures,i.id):null}getBufferViews(e,t,r,i){let s,o,n,a,l,c,m,d=null;for(let u=0;u<e.atrbs.length;u++){const m=e.atrbs[u],p=m.view,f=void 0,g=p.byteOffset+p.byteCount,b=p.byteCount/se[p.type],y=[...Array(b).keys()].map((e=>e));try{switch(m.sem){case N.Position:3!==p.ncomp||p.type!==z.F32?this._dbg(Me.Error,"[Unsupported Feature] Unsupported view for Position ("+p+")"):(s=new U(t,p.byteOffset,f,g),o=new ge(s.typedBuffer,y,3));break;case N.Normal:if(3!==p.ncomp||p.type!==z.F32)this._dbg(Me.Error,"[Unsupported Feature] Unsupported view for Normal ("+p+")");else if(i){const e=new U(t,p.byteOffset,f,g),i=ve(e.typedBuffer,r);l=new H(i),c=new ge(l.typedBuffer,y,2)}break;case N.TexCoord:2!==p.ncomp||p.type!==z.F32?this._dbg(Me.Error,"[Unsupported Feature] Unsupported view for Texcoord ("+p+")"):void 0===a&&(a=new ge(new I(t,p.byteOffset,f,g).typedBuffer,y,2));break;case N.Color:4===p.ncomp?(p.type===z.F32&&(d=new M(t,p.byteOffset,f,g)),p.type===z.U8&&(d=new P(t,p.byteOffset,f,g)),p.type===z.U16&&(d=new O(t,p.byteOffset,f,g))):3===p.ncomp&&(p.type===z.F32&&(d=new U(t,p.byteOffset,f,g)),p.type===z.U8&&(d=new E(t,p.byteOffset,f,g)),p.type===z.U16&&(d=new V(t,p.byteOffset,f,g))),null==d?this._dbg(Me.VerboseAPI,"[Unsupported Feature] Unsupported view for Color ("+p+")"):n=new ge(d.typedBuffer,y,p.ncomp);break;case N.FeatureIndex:break;default:this._dbg(Me.VerboseAPI,"[Unsupported Feature] Unsupported semantic ("+m.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(Me.VerboseAPI,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const r=e.index.view,i=void 0,s=r.byteOffset+r.byteCount;switch(e.index.view.type){case z.U16:m=new A(t,r.byteOffset,i,s);break;case z.U32:m=new R(t,r.byteOffset,i,s);break;case z.U8:default:this._dbg(Me.Error,"[Unsupported Feature] index type not supported ("+r.type+").")}}if(null==m&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);m=new A(t)}else{const t=new Uint32Array(e);m=new R(t)}for(let t=0;t<e;t++)m.set(t,t)}return{positionView:s,positionAttr:o,colorAttr:n,texCoord0Attr:a,indicesView:m,normalsView:l,normalsAttr:c}}_onRemoveFromCache(e){const t=Y(this.view);t&&t.onRenderableEvicted(this,e.handle,e.totalMemory()),this.freeRenderable(e.handle)}_dbg(e,t){this._dbgFlags.has(e)&&(e===Me.Error?r.getLogger(this).error(t):r.getLogger(this).warn(t))}};e([a()],Ue.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([a()],Ue.prototype,"layer",void 0),e([a({readOnly:!0})],Ue.prototype,"visibleAtCurrentScale",null),e([a()],Ue.prototype,"elevationOffset",null),Ue=e([l("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Ue);const Ee=Ue;export{Ee as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import has from"../../../core/has.js";import r from"../../../core/Logger.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{watch as s,initial as o}from"../../../core/reactiveUtils.js";import{schedule as n}from"../../../core/scheduling.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as c,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{IDENTITY as d,create as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as u,getTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{g as b,t as y}from"../../../chunks/vec32.js";import{fromArray as w,create as v}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as _}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as j}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{BufferViewVec4f as M,BufferViewVec4u8 as P,BufferViewVec4u16 as O,BufferViewVec3f as U,BufferViewVec3u8 as E,BufferViewVec3u16 as V,BufferViewVec2f as I,BufferViewInt16 as H,BufferViewUint32 as A,BufferViewUint16 as R}from"../../../geometry/support/buffer/BufferView.js";import{invalidLayerView as F,wasmFailedToInit as S,Lyr3DPrimitiveType as L,Lyr3DLightingModel as D,Lyr3DUvWrapMode as k,Lyr3DImageFormat as B,Lyr3DPixelFormat as G,Lyr3DVtxAtrbSemantic as N,Lyr3DType as z}from"../../../layers/ILyr3DWasmPerSceneView.js";import{getElevationOffsetInMeters as W}from"../../../support/elevationInfoUtils.js";import{ViewingMode as $}from"../../ViewingMode.js";import{IntegratedMesh3DTilesViewPerformanceInfo as J}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{DrapeTargetType as q}from"./interfaces.js";import{LayerView3D as K}from"./LayerView3D.js";import{addLayerViewToWasm as Q,removeLayerViewFromWasm as X,getLyr3DWasm as Y}from"./Lyr3DWasm.js";import{LayerElevationProvider as Z}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as ee,alphaModeConversion as te,faceCullingConversion as re,wrapModeConversion as ie,lyr3DTypeToByteSize as se}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as oe}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as ne}from"../support/ElevationRange.js";import{Obb as ae,compute as le}from"../support/orientedBoundingBox.js";import{ObjectParameters as ce}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as me}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as de}from"../webgl-engine/collections/Component/Transform.js";import{ComponentParameterSummary as he}from"../webgl-engine/collections/Component/Material/ComponentMaterial.js";import{RenderTexture as ue}from"../webgl-engine/core/material/RenderTexture.js";import{TextureCoordinateAttributeType as pe}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{alphaCutoff as fe}from"../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{getEllipsoidMode as ge}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as be}from"../webgl-engine/lib/Attribute.js";import{CullFaceOptions as ye,AlphaDiscardMode as we,TextureEncodingMimeType as ve}from"../webgl-engine/lib/basicInterfaces.js";import{compressAndTransformNormals as _e}from"../webgl-engine/lib/Normals.js";import{Texture as xe}from"../webgl-engine/lib/Texture.js";import{VertexAttribute as je}from"../webgl-engine/lib/VertexAttribute.js";import{writeDefaultAttribute as Ce}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Te from"../../layers/LayerView.js";import{isInEffectiveScaleRange as Me}from"../../support/layerViewUtils.js";var Pe;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(Pe||(Pe={}));class Oe{constructor(){this.handle=0,this.isVisible=!1,this.components=[],this.texMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}totalMemory(){return this.texMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}}function Ue(e){return Math.round(e/1048.576)/1e3}let Ee=class extends(K(Te)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this.drapeTargetType=q.WithoutRasterImage,this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}initialize(){if(this._dbgFlags.add(Pe.Error),this._dbg(Pe.VerboseAPI,"Tiles3DLayerView3D initialize() called"),!this._canProjectWithoutEngine())throw new t("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const e=Q(this).then((e=>{this._intersectionHandler=new oe(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._elevationProvider=new Z({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this),this._wasmLayerId=e;const t=this.view.resourceController.memoryController.newCache(`t3d-${this.uid}`,(e=>this._onRemoveFromCache(e)));this._memCache=t,this.addHandles([s((()=>this.layer.elevationInfo),(e=>this._elevationInfoChanged(e)))]),this._suspendedHandle=s((()=>this.suspended),(e=>{const t=Y(this.view);t&&t.setEnabled(this,!e)}),o)})).catch((e=>{if(X(this),this._wasmLayerId=-1,e===F)throw new t("tiles3d:addLayer-failure","The 3d tiles layer description was invalid.",{});if(e===S)throw new t("tiles3d:addLayer-failure","The 3d tiles layer web assembly module failed to download.",{})}));this.addResolvingPromise(e)}destroy(){this._dbg(Pe.VerboseAPI,"Tiles3DLayerView3D destroy() called"),X(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach((e=>this.freeObject(e))),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._memCache=i(this._memCache),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_visibleGeometryChanged(){null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=n((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})))}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.objects.forEach((t=>{const r=this._collection.getMaterial(t);r.commonMaterialParameters.hasSlicePlane=e,r.commonMaterialParameters.cullFace=e?ye.None:this._initialCullFace.get(t)}))}_elevationInfoChanged(e){const t=Y(this.view);t&&t.setLayerOffset(this,W(e))}get _obbs(){return this.objects.map((e=>this._collection.getComponentObb(e)))}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible&&(e+=t.totalMemory())})),e}get unloadedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible||(e+=t.totalMemory())})),e}get visibleAtCurrentScale(){return Me(this.layer.effectiveScaleRange,this.view.terrainScale)}get performanceInfo(){let e=0,t=0,r=0,i=0,s=0,o=0;return this._lyrHandleToObjects.forEach((n=>{n.isVisible?(e+=n.texMemoryUsage,t+=n.vboMemoryUsage,s++):(r+=n.texMemoryUsage,i+=n.vboMemoryUsage,o++)})),new J(this.usedMemory,s,o,Ue(t),Ue(e),Ue(i),Ue(r))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===$.Local){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view._stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return W(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ne(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce(((e,t)=>e.concat(t.components)),new Array)}isUpdating(){const e=Y(this.view);return!(this._wasmLayerId<0||null==e)&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const r=w(t.desc.origin),i=new Array,s=new Map,o=new Oe;o.handle=e.handle,this._lyrHandleToObjects.set(e.handle,o);const n=this.view.basemapTerrain.spatialReference;let a,l;if("global"===this.view.viewingMode){const e=f();j(x,r,e,n),a=c(h(),e),l=m(h(),a)}else a=d,l=d;const M=f();u(M,M,r);const P=p(v(),M);let O=null;const U=v();if(t.desc.obb){const e=t.desc.obb.quaternion;O=new ae(t.desc.obb.center,t.desc.obb.halfSize,g(e[0],e[1],e[2],e[3]))}for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];if(this._dbg(Pe.VerboseAPI,JSON.stringify(e)),e.ptype===L.Lines)continue;if(null==ee[e.ptype]||null==t.data){this._dbg(Pe.VerboseAPI,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const m=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,h=null!=m?m.lightingModel:D.Unlit,u=!has("disable-feature:im-shading"),{positionView:p,positionAttr:f,normalsView:g,normalsAttr:w,colorAttr:x,texCoord0Attr:j,indicesView:M}=this.getBufferViews(e,t.data.buffer,a,u);if(null==f||null==p||null==M)continue;const E={colors:null!=x,textureCoordinates:null!=j?pe.Default:pe.None,hasNormals:null!=g,needsNormals:u},V=f.data.length/f.size,I=(e,t)=>!e||e.data.length/e.size===V||(this._dbg(Pe.Error,`${t} !== numPos. Skipping primitive.`),!1);if(!I(j,"numTexcoord")||!I(x,"numColors")||!I(w,"normals"))continue;const H=me(E);if(null!=O?O=O.clone():(O=le(f),b(U,O.center,r),O.center=U),a!==d)for(let t=0;t<p.count;t++)p.getVec(t,U),y(U,U,a),p.setVec(t,U);const A=H.createBuffer(f.data.length),R=new Map([[je.POSITION,f]]);null!=j&&R.set(je.UV0,j),null!=x&&R.set(je.COLOR,x),null!=w&&R.set(je.NORMALCOMPRESSED,w),R.forEach(((e,t)=>{null!=e&&Ce(t,e,null,null,A,0)}));const F=new Uint32Array([0,M.typedBuffer.length]),S={vertices:{data:A.buffer,count:A.byteLength/H.stride,layoutParameters:E},positionData:{positions:p.typedBuffer,indices:M.typedBuffer},indices:M.typedBuffer,componentOffsets:F};o.cpuMemoryUsage+=p.count,o.cpuMemoryUsage+=M.count;const k=this.view.renderSpatialReference,B=v(),G=[1,1,1];C(P,k,G,n)||this._dbg(Pe.Error,"Unsupported coordinate system for IM overlay"),T(P,k,B,n);const N=this._collection.createObject(new ce(_(B[0],B[1],G[0],G[1]),new de(P,l),O,S));m&&this._collection.updateMaterial(N,(e=>{e.baseColor=m.baseColorFactor,e.usePBR=h===D.Pbr,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(m.baseColorTex,t,s),e.usePBR&&(e.mrrFactors=[m.metallicFactor,m.roughnessFactor,0],e.emissiveFactor=m.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(m.metalTex,t,s),e.emissionTexture=this._getTexture(m.emissiveTex,t,s),e.occlusionTexture=this._getTexture(m.occlusionTex,t,s),e.normalTexture=this._getTexture(m.normalTex,t,s)),e.objectOpacity=0,e.alphaDiscardMode=we.Mask;const r=[];e.baseColorTexture&&r.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&r.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&r.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&r.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&r.push(e.normalTexture.loadPromise);const n=Promise.all(r);i.push(n),n.then((()=>{e.alphaDiscardMode=te[m.alphaMode],e.objectOpacity=1,o.texMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(o.texMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)})),e.commonMaterialParameters.doubleSided=m.isDoubleSided,e.commonMaterialParameters.cullFace=m.faceCulling?re[m.faceCulling]:ye.Back,this._initialCullFace.set(N,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=he.All,e.textureAlphaCutoff=m.alphaCutoff??fe,e.alphaDiscardMode=te[m.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=ge(this.view.spatialReference)})),o.components.push(N),o.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage(N)}if(await Promise.all(i),s.forEach((e=>{o.textures.push(e)})),!this._memCache)throw new Error("no memCache");return this._memCache.put(`${o.handle}`,o,o.totalMemory()),{memUsageBytes:o.totalMemory()}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache&&this._memCache.pop(`${e.handle}`),e.components.forEach((t=>{e.textures.forEach((e=>{this._stage.remove(e)})),this._collection.destroyObject(t),this._initialCullFace.delete(t)}))}setRenderableVisibility(e,t,r){if(this._memCache){for(let i=0;i<r;++i){const r=e[i],s=t[i];if(!s)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=s,o.components.forEach((e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.pop(`${r}`))}for(let i=0;i<r;++i){const r=e[i],s=t[i];if(s)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=s,o.components.forEach((e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.put(`${r}`,o,o.totalMemory()))}}}_getTexture(e,t,r){let i=null;if(e&&t.desc?.images&&t.data?.buffer){const s=t.desc.images[e?.imageId];if(i=r.get(s),!i&&s){const o=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,n=o>1,a=ie[e.wrapMode??k.None];let l=s.alpha?4:3;const c=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,d=null,h=null;switch(s.format){case B.Raw:s.pixelFormat===G.R8?(m=c.buffer,l=1,d=""):s.pixelFormat===G.Rgb8?(m=c.buffer,l=3,d=""):s.pixelFormat===G.Rgba8&&(m=c.buffer,l=4,d="");break;case B.Dxt1:m=c.buffer,l=3,d=ve.DDS_ENCODING;break;case B.Dxt5:m=c.buffer,l=4,d=ve.DDS_ENCODING;break;case B.Png:d="image/png",h=document.createElement("img");break;case B.Jpeg:d="image/jpeg",h=document.createElement("img");break;case B.Etc2:d="image/ktx",h=document.createElement("img");break;case B.Astc:this._dbg(Pe.Error,"Astc texture not supported");break;case B.Pvrtc:this._dbg(Pe.Error,"Pvrtc texture not supported")}if(h&&d){const e=new Blob([c],{type:d});h.src=URL.createObjectURL(e),m=h}m&&null!=d&&(i=new xe(m,{mipmap:n,maxAnisotropy:o,encoding:d,wrap:a,components:l,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height}),this._stage.add(i),r.set(s,i))}}return i?new ue(this.view._stage.renderView.textures,i.id):null}getBufferViews(e,t,r,i){let s,o,n,a,l,c,m,d=null;for(let u=0;u<e.atrbs.length;u++){const m=e.atrbs[u],p=m.view,f=void 0,g=p.byteOffset+p.byteCount,b=p.byteCount/se[p.type],y=[...Array(b).keys()].map((e=>e));try{switch(m.sem){case N.Position:3!==p.ncomp||p.type!==z.F32?this._dbg(Pe.Error,"[Unsupported Feature] Unsupported view for Position ("+p+")"):(s=new U(t,p.byteOffset,f,g),o=new be(s.typedBuffer,y,3));break;case N.Normal:if(3!==p.ncomp||p.type!==z.F32)this._dbg(Pe.Error,"[Unsupported Feature] Unsupported view for Normal ("+p+")");else if(i){const e=new U(t,p.byteOffset,f,g),i=_e(e.typedBuffer,r);l=new H(i),c=new be(l.typedBuffer,y,2)}break;case N.TexCoord:2!==p.ncomp||p.type!==z.F32?this._dbg(Pe.Error,"[Unsupported Feature] Unsupported view for Texcoord ("+p+")"):void 0===a&&(a=new be(new I(t,p.byteOffset,f,g).typedBuffer,y,2));break;case N.Color:4===p.ncomp?(p.type===z.F32&&(d=new M(t,p.byteOffset,f,g)),p.type===z.U8&&(d=new P(t,p.byteOffset,f,g)),p.type===z.U16&&(d=new O(t,p.byteOffset,f,g))):3===p.ncomp&&(p.type===z.F32&&(d=new U(t,p.byteOffset,f,g)),p.type===z.U8&&(d=new E(t,p.byteOffset,f,g)),p.type===z.U16&&(d=new V(t,p.byteOffset,f,g))),null==d?this._dbg(Pe.VerboseAPI,"[Unsupported Feature] Unsupported view for Color ("+p+")"):n=new be(d.typedBuffer,y,p.ncomp);break;case N.FeatureIndex:break;default:this._dbg(Pe.VerboseAPI,"[Unsupported Feature] Unsupported semantic ("+m.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(Pe.VerboseAPI,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const r=e.index.view,i=void 0,s=r.byteOffset+r.byteCount;switch(e.index.view.type){case z.U16:m=new R(t,r.byteOffset,i,s);break;case z.U32:m=new A(t,r.byteOffset,i,s);break;case z.U8:default:this._dbg(Pe.Error,"[Unsupported Feature] index type not supported ("+r.type+").")}}if(null==m&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);m=new R(t)}else{const t=new Uint32Array(e);m=new A(t)}for(let t=0;t<e;t++)m.set(t,t)}return{positionView:s,positionAttr:o,colorAttr:n,texCoord0Attr:a,indicesView:m,normalsView:l,normalsAttr:c}}_onRemoveFromCache(e){const t=Y(this.view);t&&t.onRenderableEvicted(this,e.handle,e.totalMemory()),this.freeRenderable(e.handle)}_dbg(e,t){this._dbgFlags.has(e)&&(e===Pe.Error?r.getLogger(this).error(t):r.getLogger(this).warn(t))}};e([a()],Ee.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([a()],Ee.prototype,"layer",void 0),e([a({readOnly:!0})],Ee.prototype,"visibleAtCurrentScale",null),e([a()],Ee.prototype,"elevationOffset",null),Ee=e([l("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Ee);const Ve=Ee;export{Ve as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/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{f as d,s as h,m 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{ZEROS as g}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as m,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as O}from"./interfaces.js";import{LayerClass as R}from"./LayerClass.js";import{OverlayContent as x}from"./OverlayContent.js";import{overlayRenderOccludedFlag as P}from"./OverlayRenderer.js";import{PatchRenderData as v}from"./PatchRenderData.js";import{RenderOrder as w}from"./RenderOrder.js";import{TerrainAttributesCache as D}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as E}from"./TileRenderer.js";import{TileUpdate as A}from"./TileUpdate.js";import{IteratorPreorder as C,sortTiles as N,compareTiles as j}from"./tileUtils.js";import{TransparencyMode as B}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as I,ComponentIntersectionData as U}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as F}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as L}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as q,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{TerrainTechnique as ne}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ae}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as oe}from"../../webgl/enums.js";const le=7,ce=10,de=m();let he=class extends q{get _isGlobal(){return this._stage.viewingMode===T.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._tileSize=256,this._configuration=new ae,this._passParameters=new L,this._drawParameters=new se,this._renderDataPool=new s(v),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new C,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()],[$.TRANSPARENT_TERRAIN,()=>this._produces()],[$.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new D(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?P: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()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_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.updateTileTexture(e,A.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===A.TEXTURE_FADING?O.FADING:O.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[R.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=ce-le,i=Math.max(0,Math.floor((e.level-t)/le)*le);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 E(this._rctx,this._tileSize,this._techniques,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!==B.Opaque)return;const s=ue,n=_e;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,T=_&&null!=a.dist?a.dist:1/0;const O=e.options,R=O.normalRequired||!O.backfacesTerrain,x=new J(!1,R),P=h=>{const f=h.renderData;if(!f?.vao)return;const P=f.geometry;b(de,P.boundingBox);const v=f.localOrigin;null!=p&&(p.localOrigin=v,p.applyToAabb(de));const w=de;if(fe[0]=i[0]-v[0],fe[1]=i[1]-v[1],fe[2]=i[2]-v[2],!K(w,fe,n,g,T))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),T=_&&null!=a.dist?a.dist:1/0},S=(n,c,d)=>{if((!R||null!=d)&&n>=0&&(O.backfacesTerrain||u(d,s)<0)&&(O.invisibleTerrain||!O.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),O.isFiltered)return;O.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),O.store!==W.MIN&&(null==o.dist||n>o.dist)&&D(o,n,d)}},E=pe;d(E,r,v);const{indices:A,indexCount:C}=P,N=P.vertexAttributes,j=N.getField(te.POSITION,y),B=new z(j.typedBuffer,3,N.stride/4),F=C/3;if(!p&&F>I){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new U(A,0,F,B)),e.intersectionData.intersectRay(fe,E,x,S)}else Z(fe,E,0,F,A,B,p,x,S)},v=this._rootTiles;if(null!=v){(()=>{const t=this._tileIterator;t.reset(v);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,T)||f&&this._useStencilForTile(e)?t.skipSubtree():P(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()}}prepareTechnique(e){const t=has("enable-feature:terrain-shadows")&&e.bindParameters.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bindParameters.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bindParameters.slot===$.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&P))return null}else{const t=this.transparency===B.Opaque?$.OPAQUE_TERRAIN:$.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}if(this.transparency===B.Empty)return null;switch(e.output){case F.Color:return this._configuration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._configuration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._configuration.receiveShadows=e.bindParameters.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._configuration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(F.Color,e.bindParameters.slot===$.OCCLUDED_TERRAIN);case F.Shadow:case F.ShadowExcludeHighlight:return this._castShadows?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Shadow,!1)):null;case F.ViewshedShadow:return this._inViewshed?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.ViewshedShadow,!1)):null;case F.Depth:return this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Depth,!1);case F.Normal:return this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Normal,!1);case F.ObjectAndLayerIdColor:return this._updateTechnique(F.ObjectAndLayerIdColor,!1);case F.Highlight:return this._overlayRenderer.hasHighlights&&0===e.bindParameters.highlightLevel?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Highlight,!1)):null}return null}renderNode(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case F.Color:{const i=e.bindParameters.slot===$.OCCLUDED_TERRAIN?x.Occluded:x.Color;this._renderMaterialPass(e,t,i);break}case F.Depth:case F.Normal:this._renderAuxiliaryPass(e,t,x.Color,this._visiblePatchesByOrigin);break;case F.Highlight:0===e.bindParameters.highlightLevel&&this._renderAuxiliaryPass(e,t,x.Highlight,this._visiblePatchesByOrigin);break;case F.Shadow:case F.ShadowExcludeHighlight:case F.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case F.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,x.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,O.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!==w.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)=>j(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.bindParameters,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(this._drawParameters,e.bindParameters,this._passParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],oe.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bindParameters,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bindParameters.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===x.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",_),n.setUniform4fv("texOffsetAndScale",g));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:_;this._configuration.tileBlendInput===G.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?oe.LINES:oe.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;t.program.bindDraw(new se(r),e.bindParameters,this._passParameters),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(S&&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)}_updateTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(ne,this._configuration,this._shaderTechnique),this._shaderTechnique}get test(){}};e([o({readOnly:!0})],he.prototype,"_isGlobal",null),e([o()],he.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],he.prototype,"renderingDisabled",null),e([o({value:!0})],he.prototype,"visible",null),e([o()],he.prototype,"renderPatchBorders",null),e([o()],he.prototype,"visualizeNormals",null),e([o()],he.prototype,"cullBackFaces",null),e([o({value:w.FRONT_TO_BACK})],he.prototype,"renderOrder",null),e([o()],he.prototype,"wireframe",null),he=e([l("esri.views.3d.terrain.TerrainRenderer")],he);const ue=p(),_e=p(),fe=p(),pe=p();export{he 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{f as d,s as h,m 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{ZEROS as g}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as m,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as O}from"./interfaces.js";import{LayerClass as R}from"./LayerClass.js";import{OverlayContent as x}from"./OverlayContent.js";import{overlayRenderOccludedFlag as P}from"./OverlayRenderer.js";import{PatchRenderData as v}from"./PatchRenderData.js";import{RenderOrder as w}from"./RenderOrder.js";import{TerrainAttributesCache as D}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as A}from"./TileRenderer.js";import{TileUpdate as E}from"./TileUpdate.js";import{IteratorPreorder as C,sortTiles as N,compareTiles as j}from"./tileUtils.js";import{TransparencyMode as B}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as I,ComponentIntersectionData as U}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as F}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as L}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as q,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{TerrainTechnique as ne}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ae}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as oe}from"../../webgl/enums.js";const le=7,ce=10,de=m();let he=class extends q{get _isGlobal(){return this._stage.viewingMode===T.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._tileSize=256,this._configuration=new ae,this._passParameters=new L,this._drawParameters=new se,this._renderDataPool=new s(v),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new C,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()],[$.TRANSPARENT_TERRAIN,()=>this._produces()],[$.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new D(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?P: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()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_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.updateTileTexture(e,E.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===E.TEXTURE_FADING?O.FADING:O.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[R.ELEVATION])i.pendingUpdates&=~E.GEOMETRY;e.resetPendingUpdate(E.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=ce-le,i=Math.max(0,Math.floor((e.level-t)/le)*le);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 A(this._rctx,this._tileSize,this._techniques,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!==B.Opaque)return;const s=ue,n=_e;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,T=_&&null!=a.dist?a.dist:1/0;const O=e.options,R=O.normalRequired||!O.backfacesTerrain,x=new J(!1,R),P=h=>{const f=h.renderData;if(!f?.vao)return;const P=f.geometry;b(de,P.boundingBox);const v=f.localOrigin;null!=p&&(p.localOrigin=v,p.applyToAabb(de));const w=de;if(fe[0]=i[0]-v[0],fe[1]=i[1]-v[1],fe[2]=i[2]-v[2],!K(w,fe,n,g,T))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),T=_&&null!=a.dist?a.dist:1/0},S=(n,c,d)=>{if((!R||null!=d)&&n>=0&&(O.backfacesTerrain||u(d,s)<0)&&(O.invisibleTerrain||!O.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),O.isFiltered)return;O.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),O.store!==W.MIN&&(null==o.dist||n>o.dist)&&D(o,n,d)}},A=pe;d(A,r,v);const{indices:E,indexCount:C}=P,N=P.vertexAttributes,j=N.getField(te.POSITION,y),B=new z(j.typedBuffer,3,N.stride/4),F=C/3;if(!p&&F>I){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new U(E,0,F,B)),e.intersectionData.intersectRay(fe,A,x,S)}else Z(fe,A,0,F,E,B,p,x,S)},v=this._rootTiles;if(null!=v){(()=>{const t=this._tileIterator;t.reset(v);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,T)||f&&this._useStencilForTile(e)?t.skipSubtree():P(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()}}prepareTechnique(e){const t=has("enable-feature:terrain-shadows")&&e.bindParameters.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bindParameters.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bindParameters.slot===$.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&P))return null}else{const t=this.transparency===B.Opaque?$.OPAQUE_TERRAIN:$.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}if(this.transparency===B.Invisible)return null;switch(e.output){case F.Color:return this._configuration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._configuration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._configuration.receiveShadows=e.bindParameters.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._configuration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(F.Color,e.bindParameters.slot===$.OCCLUDED_TERRAIN);case F.Shadow:case F.ShadowExcludeHighlight:return this._castShadows?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Shadow,!1)):null;case F.ViewshedShadow:return this._inViewshed?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.ViewshedShadow,!1)):null;case F.Depth:return this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Depth,!1);case F.Normal:return this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Normal,!1);case F.ObjectAndLayerIdColor:return this._updateTechnique(F.ObjectAndLayerIdColor,!1);case F.Highlight:return this._overlayRenderer.hasHighlights&&0===e.bindParameters.highlightLevel?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Highlight,!1)):null}return null}renderNode(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case F.Color:{const i=e.bindParameters.slot===$.OCCLUDED_TERRAIN?x.Occluded:x.Color;this._renderMaterialPass(e,t,i);break}case F.Depth:case F.Normal:this._renderAuxiliaryPass(e,t,x.Color,this._visiblePatchesByOrigin);break;case F.Highlight:0===e.bindParameters.highlightLevel&&this._renderAuxiliaryPass(e,t,x.Highlight,this._visiblePatchesByOrigin);break;case F.Shadow:case F.ShadowExcludeHighlight:case F.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case F.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,x.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,O.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!==w.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)=>j(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.bindParameters,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(this._drawParameters,e.bindParameters,this._passParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],oe.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bindParameters,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bindParameters.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===x.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",_),n.setUniform4fv("texOffsetAndScale",g));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:_;this._configuration.tileBlendInput===G.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?oe.LINES:oe.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;t.program.bindDraw(new se(r),e.bindParameters,this._passParameters),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(S&&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)}_updateTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(ne,this._configuration,this._shaderTechnique),this._shaderTechnique}get test(){}};e([o({readOnly:!0})],he.prototype,"_isGlobal",null),e([o()],he.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],he.prototype,"renderingDisabled",null),e([o({value:!0})],he.prototype,"visible",null),e([o()],he.prototype,"renderPatchBorders",null),e([o()],he.prototype,"visualizeNormals",null),e([o()],he.prototype,"cullBackFaces",null),e([o({value:w.FRONT_TO_BACK})],he.prototype,"renderOrder",null),e([o()],he.prototype,"wireframe",null),he=e([l("esri.views.3d.terrain.TerrainRenderer")],he);const ue=p(),_e=p(),fe=p(),pe=p();export{he as TerrainRenderer};
|