@arcgis/core 4.33.0-next.20250217 → 4.33.0-next.20250218
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/290f613ef70590de9f15.js +314 -0
- package/assets/esri/core/workers/chunks/3f077176c03a360e1edd.js +1 -0
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
- package/views/3d/layers/i3s/PointCloudHighlights.js +1 -1
- package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/RenderSubmitSystem.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/webgl/Program.js +1 -1
- package/assets/esri/core/workers/chunks/ace156db063b51797b1a.js +0 -1
- package/assets/esri/core/workers/chunks/aebbaa7ab7a6b3b1579c.js +0 -314
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import s from"../../../../core/PooledArray.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{d as n,l as o,h as a,v as l,f as h,k as c}from"../../../../chunks/vec32.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as u}from"../../../../chunks/vec42.js";import{create as m,offset as p,contains as g,containsPoint as _,set as f,positiveInfinity as P,equals as b}from"../../../../geometry/support/aaBoundingBox.js";import{create as x}from"../../../../geometry/support/plane.js";import{fromPoints as S}from"../../../../geometry/support/ray.js";import{PclTarget as R}from"./Intersector.js";import{PointCloudHighlights as w}from"./PointCloudHighlights.js";import{isDepth as z,ShaderOutput as A,isColorOrColorEmission as j}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as y}from"../../webgl-engine/effects/RenderPlugin.js";import{Default3D as I}from"../../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{newIntersectorResult as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import s from"../../../../core/PooledArray.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{d as n,l as o,h as a,v as l,f as h,k as c}from"../../../../chunks/vec32.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as u}from"../../../../chunks/vec42.js";import{create as m,offset as p,contains as g,containsPoint as _,set as f,positiveInfinity as P,equals as b}from"../../../../geometry/support/aaBoundingBox.js";import{create as x}from"../../../../geometry/support/plane.js";import{fromPoints as S}from"../../../../geometry/support/ray.js";import{PclTarget as R}from"./Intersector.js";import{PointCloudHighlights as w}from"./PointCloudHighlights.js";import{isDepth as z,ShaderOutput as A,isColorOrColorEmission as j}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as y}from"../../webgl-engine/effects/RenderPlugin.js";import{Default3D as I}from"../../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{newIntersectorResult as v}from"../../webgl-engine/lib/Intersector.js";import{IntersectorType as E,StoreResults as L}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{RenderSlot as O}from"../../webgl-engine/lib/RenderSlot.js";import{VertexArrayObject as q}from"../../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as T}from"../../webgl-engine/lib/VertexAttribute.js";import{P as M,g as N}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as F}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as H}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{BufferObject as U}from"../../../webgl/BufferObject.js";import{DataType as B,PrimitiveType as C,Usage as W}from"../../../webgl/enums.js";import{VertexElementDescriptor as D}from"../../../webgl/VertexElementDescriptor.js";const V=new Map([["positions",[new D(T.POSITION,3,B.FLOAT,0,12)]],["colors",[new D(T.COLOR,3,B.UNSIGNED_BYTE,0,3,!0)]]]);let k=class extends y{constructor(e){super(e),this.type=E.PCL,this.isGround=!1,this._passParameters=new M,this._highlights=new w({forEachNode:e=>this.forEachNode(e),addHighlight:(e,t,s)=>this._addHighlight(e,t,s),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.produces=new Map([[O.OPAQUE_MATERIAL,e=>!(z(e)||e===A.Highlight&&this._highlights.empty)],[O.OPAQUE_MATERIAL_WITHOUT_NORMALS,e=>z(e)]]),this.layerUid="",this._slicePlaneEnabled=!1,this._configuration=new H,this._nodes=new s}hasHighlight(e){return this._highlights.has(e)}initializeRenderContext(e){this._context=e,e.requestRender()}uninitializeRenderContext(){}intersect(e,t,s,i){const r=d(),f=d(),P=d(),b=d(),w=x(),z=e.camera.perScreenPixelRatio/2,A=e.camera.near;n(f,i,s);const j=1/o(f);a(f,f,j),l(P,f),u(w,f[0],f[1],f[2],-h(f,s));const y=new J,I=new J,E=new Array,O=m(),q=m(this._passParameters.clipBox);p(q,-s[0],-s[1],-s[2],q),this._nodes.forAll((o=>{const a=o.splatSize*this._passParameters.scaleFactor;let l=o.obb.minimumDistancePlane(w),d=o.obb.maximumDistancePlane(w);l-=Q(a,l+A,this._passParameters,z,o.isLeaf),d-=Q(a,d+A,this._passParameters,z,o.isLeaf);const u=d<0,m=null!=y.dist&&null!=I.dist&&y.dist<l*j&&I.dist>d*j;if(u||m)return;const x=G(a,d+A,this._passParameters,z,o.isLeaf);if(!o.obb.intersectRay(s,f,x))return;const S=x*x;o.obb.toAaBoundingBox(O),p(O,-s[0],-s[1],-s[2],O);const R=!g(q,O);n(b,o.origin,s);const v=o.coordinates.length/3;for(let n=0;n<v;n++){if(r[0]=b[0]+o.coordinates[3*n],r[1]=b[1]+o.coordinates[3*n+1],r[2]=b[2]+o.coordinates[3*n+2],R&&!_(q,r))continue;const l=h(r,f),d=c(r)-l*l;if(d>S)continue;let u=l+A;const m=Q(a,u,this._passParameters,z,o.isLeaf);if(l-m<0)continue;u-=m;const p=G(a,u,this._passParameters,z,o.isLeaf);if(d>p*p)continue;const g=(l-m)*j,x=e=>(e.point=Y(o,n,e.point),e.dist=g,e.normal=P,e.node=o,e.pointId=n,e.layerUid=this.layerUid,e);if((null==y.dist||g<y.dist)&&(null==t||t(s,i,g))&&x(y),e.options.store!==L.MIN&&(null==I.dist||g>I.dist)&&(null==t||t(s,i,g))&&x(I),e.options.store===L.ALL&&(null==t||t(s,i,g))){const e=new J;E.push(x(e))}}}));const T=e=>{const{layerUid:t,node:s,pointId:i}=e;return new R(e.point,t,i,(()=>this.createGraphic(s,i,e.point)))},M=(e,t)=>{const s=T(t);e.set(this.type,s,t.dist,t.normal)};if(K(y)){const t=e.results.min;(null==t.dist||y.dist<t.dist)&&M(t,y)}if(K(I)&&e.options.store!==L.MIN){const t=e.results.max;(null==t.dist||I.dist>t.dist)&&M(t,I)}if(e.options.store===L.ALL){const t=S(s,i);for(const s of E){const i=v(t);M(i,s),e.results.all.push(i)}}}acquireTechniques(e){return 0!==this._nodes.length&&(j(e.output)||z(e.output)&&e.bind.slot===O.OPAQUE_MATERIAL_WITHOUT_NORMALS||e.output===A.Highlight)?(this._nodes.forAll((t=>this._initNode(e,t))),this._configuration.drawScreenSize=this._passParameters.drawScreenSpace,this._configuration.useFixedSizes=this._passParameters.useFixedSizes,this._configuration.hasSlicePlane=this._slicePlaneEnabled,this._configuration.hasOccludees=e.bind.hasOccludees,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.output=e.output,this._context.techniques.get(F,this._configuration)):null}render(e,t){const{rctx:s,bind:i,output:r}=e,n=s.bindTechnique(t,i,this._passParameters),o=r===A.Highlight,a=i.highlight?.name??null;o&&!a||this._nodes.forAll((t=>{0===t.coordinates.length||o&&!t.highlightMap.has(a)||(n.bindDraw(i,this._passParameters,t),s.bindVAO(t.vao),o?this._renderHighlightFragments(e,t):s.drawArrays(C.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(e,t){const{highlightMap:s}=t,{rctx:i,bind:r}=e,{highlight:n}=r;if(!n)return;const o=n.name,a=s.get(o);if(!a||0===a.length)return;const{highlightOrderMap:l,highlightLevel:h}=r;if(null==h)return;for(const g of s.keys())if(g!==o){const e=l.get(g);if(void 0!==e&&e>h)return}let c=0,d=a[0].componentIndex,u=d+1;const m=()=>{for(;c<a.length&&a[c].id.highlightName!==o;)d=a[c].componentIndex,++c;u=d+1};m();const p=(e,t)=>{const s=t-e;s>0&&i.drawArrays(C.POINTS,e,s)};for(;c<a.length;){const e=a[c];if(e.id.highlightName!==o){p(d,u),++c,m();continue}const t=e.componentIndex;t!==u&&(p(d,u),d=t),u=t+1,++c}p(d,u)}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){f(this._passParameters.clipBox,e||P)}get _clippingEnabled(){return!b(this._passParameters.clipBox,P,((e,t)=>e===t))}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let s=null;return this._nodes.filterInPlace((i=>i.id!==e||(s=i,i.vao=t(i.vao),this._highlights.nodeRemoved(i),!1))),this._requestRender(),s}forEachNode(e){this._nodes.forAll(e)}removeAll(){this._nodes.forAll((e=>e.vao=t(e.vao))),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e,t){return this._highlights.add(e,t)}_addHighlight(e,t,s){e.addHighlight(t,s),this._requestRender()}_removeHighlight(e,t){e.removeHighlight(t),this._requestRender()}_initNode(e,t){t.vao??=new q(e.rctx,I,V,new Map([["positions",U.createVertex(e.rctx,W.STATIC_DRAW,t.coordinates)],["colors",U.createVertex(e.rctx,W.STATIC_DRAW,t.rgb)]]))}_requestRender(){this._context&&this._context.requestRender()}};function G(e,t,s,i,r){if(s.drawScreenSpace)return s.fixedSize*t*i;const n=N(r)*t*i;return s.useFixedSizes?Math.min(s.fixedSize/2,n):s.screenMinSize>0?Math.min(Math.max(s.screenMinSize*t*i,e/2),n):Math.min(e/2,n)}function Q(e,t,s,i,r){return s.drawScreenSpace?0:G(e,t,s,i,r)}function Y(e,t,s){return null==s&&(s=d()),s[0]=e.origin[0]+e.coordinates[3*t],s[1]=e.origin[1]+e.coordinates[3*t+1],s[2]=e.origin[2]+e.coordinates[3*t+2],s}e([i({constructOnly:!0})],k.prototype,"createGraphic",void 0),k=e([r("esri.views.3d.layers.i3s.PointCloudRenderer")],k);class J{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerUid=""}}function K(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}export{k as PointCloudRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import i from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as o,on as a,initial as h}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as u,fromTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{i as g}from"../../../chunks/vec32.js";import{ones as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{DrapeTargetType as m,DrapeSourceType as y,DrapedRenderGroup as f}from"../layers/interfaces.js";import{debugFlags as R}from"../support/debugFlags.js";import{OverlayIndex as b}from"./interfaces.js";import{Overlay as T}from"./Overlay.js";import{OverlayContent as w}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import v from"../webgl/RenderCamera.js";import{ShaderOutput as x}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as O}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as S}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as C}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as E,renderHighlightBuffer as P}from"../webgl-engine/effects/highlight/Highlight.js";import{RenderRequestType as j}from"../webgl-engine/lib/basicInterfaces.js";import{GLMaterialRepository as A}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as W}from"../webgl-engine/lib/Material.js";import{OITPass as I}from"../webgl-engine/lib/OITPass.js";import{OverlayRenderContext as q,defaultRenderOccludedMask as N}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as F}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as L}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as V}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as H}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{Update as G}from"../webgl-engine/lib/Update.js";import{UpdatePolicy as k}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as U}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as z}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as Y,noBudget as X}from"../../support/Scheduler.js";import{FramebufferBit as K,TextureSamplingMode as J}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends C{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new i,this._passParameters=new S,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new v,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[F.DRAPED_MATERIAL,e=>e!==x.Highlight||this.hasHighlights],[F.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this._view,r=e._stage,t=r.renderer.fboCache,{waterTextures:s,textures:i}=r.renderView;this._renderContext=new q(this._rctx,new L(t,e.state.viewingMode)),this.addHandles([n((()=>s.updating),(()=>this.events.emit("content-changed")),o),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),o),a((()=>e.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0)),n((()=>E(e.state.highlights)),(()=>this._sortedDrapeSourceRenderersDirty=!0),h),n((()=>e.state.highlights),(r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap,this._updateHighlights()}),h),e.resourceController.scheduler.registerTask(Y.STAGE,this)]),this._materials=new A(i,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed")));const{_bindParameters:l,_camera:d}=this;d.near=1,d.far=1e4,d.relativeElevation=null,l.slot=F.DRAPED_MATERIAL,l.mainDepth=null,l.camera=d,l.oitPass=I.NONE,l.updateLighting([new U(_())],0,0,G.Immediate)}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._passParameters.texture=s(this._passParameters.texture),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view._stage}get spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){this._pluginContext=e,this._techniques.precompile(z)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}_updateHighlights(){const e=this._view.state;this._renderers.forEach((r=>r.updateHighlights(e.highlightOrderMap)))}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===m.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===y.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===y.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new D(this._stage.renderer.fboCache),this._overlays=[new T,new T]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=s(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(w.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges(this._view.state.highlightOrderMap)&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"))}hasHighlightOptions(e){return t(this._renderers,(r=>r.hasHighlightOptions(e)))}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===k.SYNC))}get isEmpty(){return!R.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){const e=t(this._renderers,(e=>e.hasWater));return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se,++this._techniques.precompiling;const r=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,this._renderContext.renderOccludedMask=e,r}renders(e){if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==w.Occluded&&e!==w.Highlight)return!0;++this._techniques.precompiling;const r=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,r}get mode(){return this.isEmpty?O.Disabled:this.hasWater&&this.renders(w.WaterNormal)?O.EnabledWithWater:this._renderTargets?.getTexture(w.Color)?O.Enabled:O.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r&&this.parent.requestRender(j.BACKGROUND),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(this._renderTargets){this._bindParameters.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const e of this._renderTargets.targets){if(e.content===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const r=e.output;this._renderContext.output=r,this._bindParameters.slot=r===x.Normal?F.DRAPED_WATER:F.DRAPED_MATERIAL,e.content===w.Occluded&&(this._renderContext.renderOccludedMask=se),this._sortedRenderers.forAll((({drapeSource:r,renderer:t})=>{e.content===w.ColorNoRasterImage&&r.drapeSourceType===y.RasterImage||t.precompile(this._renderContext)})),this._renderContext.renderOccludedMask=N}--this._techniques.precompiling}}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryView();this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;for(const e of this._renderTargets.targets){if(e.content===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const r=this._drawTarget(b.INNER,e),t=this._drawTarget(b.OUTER,e);(r||t)&&e.fbo.generateMipMap()}}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===x.Normal&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:o,_camera:a,_renderContext:h,_bindParameters:l}=this;if(a.pixelRatio=t.pixelRatio*i,h.output=n,l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,l.slot=n===x.Normal?F.DRAPED_WATER:F.DRAPED_MATERIAL,r.content===w.Occluded&&(h.renderOccludedMask=se),!this.renders(r.content))return h.renderOccludedMask=N,!1;const{resolution:d}=t,c=e===b.INNER?0:d;o.setViewport(c,0,d,d),this._bindTargetFBO(r),e===b.INNER&&(o.setClearColor(0,0,0,0),o.clear(K.COLOR));if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==w.Occluded&&r.content!==w.Highlight){this._techniques.precompile(V,ie);const r=this._techniques.get(V,ie);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,re[e]),o.bindTechnique(r,l,this._passParameters),o.screen.draw()}if(r.output===x.Highlight){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),P(o,t,{width:s,height:s},l,(()=>this._renderAllGeometry(e,r)),c)}else this._renderAllGeometry(e,r);return o.bindFramebuffer(null),h.renderOccludedMask=N,!0}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll((({drapeSource:i,renderer:n})=>{if(r.content===w.ColorNoRasterImage&&i.drapeSourceType===y.RasterImage)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&r.output===x.Color&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(z);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}}))}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.bind(this._rctx,t,r)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(K.COLOR),s}get _resolution(){return this._overlays?.[b.INNER].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),n=i>=0,o=s.renderGroup??(n?f.MapLayer:f.ViewLayer),a=r*o+(n?i:0);this._sortedRenderers.push(new ee(s,t,a))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],u(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),p(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(g(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new Z(e);i.samplingMode=J.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t)}get test(){}};e([d()],$.prototype,"hasHighlights",void 0),e([d()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([d({constructOnly:!0})],$.prototype,"parent",void 0),e([d({readOnly:!0})],$.prototype,"_techniques",null),e([d({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([d()],$.prototype,"isEmpty",null),e([d({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([c("esri.views.3d.terrain.OverlayRenderer")],$);class ee{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const re=[[1,.5,.5],[.5,.5,1]],te=-2,se=W.OccludeAndTransparent,ie=new H;ie.hasAlpha=!0;export{$ as OverlayRenderer,te as drapedZ,se as overlayRenderOccludedFlag};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import i from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as o,on as a,initial as h}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as u,fromTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{i as g}from"../../../chunks/vec32.js";import{ones as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{DrapeTargetType as m,DrapeSourceType as y,DrapedRenderGroup as f}from"../layers/interfaces.js";import{debugFlags as R}from"../support/debugFlags.js";import{OverlayIndex as b}from"./interfaces.js";import{Overlay as T}from"./Overlay.js";import{OverlayContent as w}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import v from"../webgl/RenderCamera.js";import{ShaderOutput as x}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as O}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as S}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as C}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as E,renderHighlightBuffer as P}from"../webgl-engine/effects/highlight/Highlight.js";import{RenderRequestType as j}from"../webgl-engine/lib/basicInterfaces.js";import{GLMaterialRepository as A}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as W}from"../webgl-engine/lib/Material.js";import{OITPass as I}from"../webgl-engine/lib/OITPass.js";import{OverlayRenderContext as q,defaultRenderOccludedMask as N}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as F}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as L}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as V}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as H}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{Update as G}from"../webgl-engine/lib/Update.js";import{UpdatePolicy as k}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as U}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as z}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as Y,noBudget as X}from"../../support/Scheduler.js";import{FramebufferBit as K,TextureSamplingMode as J}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends C{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new i,this._passParameters=new S,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new v,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[F.DRAPED_MATERIAL,e=>e!==x.Highlight||this.hasHighlights],[F.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this._view,r=e._stage,t=r.renderer.fboCache,{waterTextures:s,textures:i}=r.renderView;this._renderContext=new q(this._rctx,new L(t,e.state.viewingMode)),this.addHandles([n((()=>s.updating),(()=>this.events.emit("content-changed")),o),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),o),a((()=>e.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0)),n((()=>E(e.state.highlights)),(()=>this._sortedDrapeSourceRenderersDirty=!0),h),n((()=>e.state.highlights),(r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap,this._updateHighlights()}),h),e.resourceController.scheduler.registerTask(Y.STAGE,this)]),this._materials=new A(i,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed")));const{_bindParameters:l,_camera:d}=this;d.near=1,d.far=1e4,d.relativeElevation=null,l.slot=F.DRAPED_MATERIAL,l.mainDepth=null,l.camera=d,l.oitPass=I.NONE,l.updateLighting([new U(_())],0,0,G.Immediate)}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._passParameters.texture=s(this._passParameters.texture),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view._stage}get spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){this._pluginContext=e,this._techniques.precompile(z)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}_updateHighlights(){const e=this._view.state;this._renderers.forEach((r=>r.updateHighlights(e.highlightOrderMap)))}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===m.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===y.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===y.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new D(this._stage.renderer.fboCache),this._overlays=[new T,new T]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=s(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(w.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges(this._view.state.highlightOrderMap)&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"))}hasHighlight(e){return t(this._renderers,(r=>r.hasHighlight(e)))}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===k.SYNC))}get isEmpty(){return!R.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){const e=t(this._renderers,(e=>e.hasWater));return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se,++this._techniques.precompiling;const r=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,this._renderContext.renderOccludedMask=e,r}renders(e){if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==w.Occluded&&e!==w.Highlight)return!0;++this._techniques.precompiling;const r=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,r}get mode(){return this.isEmpty?O.Disabled:this.hasWater&&this.renders(w.WaterNormal)?O.EnabledWithWater:this._renderTargets?.getTexture(w.Color)?O.Enabled:O.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r&&this.parent.requestRender(j.BACKGROUND),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(this._renderTargets){this._bindParameters.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const e of this._renderTargets.targets){if(e.content===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const r=e.output;this._renderContext.output=r,this._bindParameters.slot=r===x.Normal?F.DRAPED_WATER:F.DRAPED_MATERIAL,e.content===w.Occluded&&(this._renderContext.renderOccludedMask=se),this._sortedRenderers.forAll((({drapeSource:r,renderer:t})=>{e.content===w.ColorNoRasterImage&&r.drapeSourceType===y.RasterImage||t.precompile(this._renderContext)})),this._renderContext.renderOccludedMask=N}--this._techniques.precompiling}}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryView();this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;for(const e of this._renderTargets.targets){if(e.content===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const r=this._drawTarget(b.INNER,e),t=this._drawTarget(b.OUTER,e);(r||t)&&e.fbo.generateMipMap()}}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===x.Normal&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:o,_camera:a,_renderContext:h,_bindParameters:l}=this;if(a.pixelRatio=t.pixelRatio*i,h.output=n,l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,l.slot=n===x.Normal?F.DRAPED_WATER:F.DRAPED_MATERIAL,r.content===w.Occluded&&(h.renderOccludedMask=se),!this.renders(r.content))return h.renderOccludedMask=N,!1;const{resolution:d}=t,c=e===b.INNER?0:d;o.setViewport(c,0,d,d),this._bindTargetFBO(r),e===b.INNER&&(o.setClearColor(0,0,0,0),o.clear(K.COLOR));if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==w.Occluded&&r.content!==w.Highlight){this._techniques.precompile(V,ie);const r=this._techniques.get(V,ie);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,re[e]),o.bindTechnique(r,l,this._passParameters),o.screen.draw()}if(r.output===x.Highlight){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),P(o,t,{width:s,height:s},l,(()=>this._renderAllGeometry(e,r)),c)}else this._renderAllGeometry(e,r);return o.bindFramebuffer(null),h.renderOccludedMask=N,!0}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll((({drapeSource:i,renderer:n})=>{if(r.content===w.ColorNoRasterImage&&i.drapeSourceType===y.RasterImage)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&r.output===x.Color&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(z);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}}))}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.bind(this._rctx,t,r)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(K.COLOR),s}get _resolution(){return this._overlays?.[b.INNER].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),n=i>=0,o=s.renderGroup??(n?f.MapLayer:f.ViewLayer),a=r*o+(n?i:0);this._sortedRenderers.push(new ee(s,t,a))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],u(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),p(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(g(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new Z(e);i.samplingMode=J.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t)}get test(){}};e([d()],$.prototype,"hasHighlights",void 0),e([d()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([d({constructOnly:!0})],$.prototype,"parent",void 0),e([d({readOnly:!0})],$.prototype,"_techniques",null),e([d({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([d()],$.prototype,"isEmpty",null),e([d({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([c("esri.views.3d.terrain.OverlayRenderer")],$);class ee{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const re=[[1,.5,.5],[.5,.5,1]],te=-2,se=W.OccludeAndTransparent,ie=new H;ie.hasAlpha=!0;export{$ as OverlayRenderer,te as drapedZ,se as overlayRenderOccludedFlag};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../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 o}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as c}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,i as h,f as u}from"../../../chunks/vec32.js";import{ZEROS as g,fromValues as p,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as f,ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as b,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as T}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as R}from"../../ViewingMode.js";import{TextureUpdate as x}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlayContent as v}from"./OverlayContent.js";import{overlayRenderOccludedFlag as w}from"./OverlayRenderer.js";import{PatchRenderData as P}from"./PatchRenderData.js";import{RenderOrder as D}from"./RenderOrder.js";import{TerrainAttributesCache as S}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as C}from"./terrainUtils.js";import{TileRenderer as E}from"./TileRenderer.js";import{TileUpdate as A}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as N,compareTiles as B}from"./tileUtils.js";import{TransparencyMode as I}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as q,ComponentIntersectionData as F}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as U}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncRenderPlugin as M,ConsumesDepth as L,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as z}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as V}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as Y}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as Q,StoreResults as W}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as X}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as K,intersectTriangles as Z,MeshIntersectionOptions as J}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as $}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as ee}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as te}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ie,getVerticalOffsetTerrain as re}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as se}from"../webgl-engine/materials/DrawParameters.js";import{T as ne}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as oe}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ae}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as le}from"../../webgl/enums.js";const ce=7,de=10,he=b();let ue=class extends M{get _isGlobal(){return this._stage.viewingMode===R.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,o){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=Q.TERRAIN,this.isGround=!0,this._passParameters=new ne,this._drawParameters=new se,this._renderDataPool=new s(P),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new j,this._castShadows=!1,this._inViewshed=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=X.Occlude,this.produces=new Map([[$.OPAQUE_TERRAIN,()=>this._produces()&&this.transparency===I.Opaque],[$.TRANSPARENT_TERRAIN,()=>this._produces()&&(this.transparency===I.Transparent||this.transparency===I.InvisibleWithDraped)],[$.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileSize=256,this._configuration=new ae(t.viewingMode===R.Global),this._tileTextureCache=new r(((e,t)=>o.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new S(o)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?w:X.Occlude,this.setNeedsRender()}),o))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?L:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get tileRenderer(){return this._tileRenderer}get texturesBeingCompressed(){return this._tileRenderer?this._tileRenderer?.texturesBeingCompressed:null}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return ie}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,A.TEXTURE_FADING)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=f(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===A.TEXTURE_FADING?x.FADING:x.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[O.ELEVATION])i.pendingUpdates&=~A.GEOMETRY;e.resetPendingUpdate(A.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=de-ce,i=Math.max(0,Math.floor((e.level-t)/ce)*ce);if(this._isGlobal&&0===i)return g;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({rctx:this._rctx,tileSize:this._tileSize,techniques:this._techniques,cache:this._tileTextureCache}),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==I.Opaque)return;const s=ge,n=pe;d(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const o=e.results.min,a=e.results.max,l=e.results.ground,g=e.options.store===W.MIN,p=!!e.results.ground.target,_=re(e.verticalOffset),f=e.tolerance;let m,b=g&&null!=o.dist?o.dist:1/0;const R=e.options,x=R.normalRequired||!R.backfacesTerrain,O=new J(!1,x),v=h=>{const p=h.renderData;if(!p?.vao)return;const v=p.geometry;y(he,v.boundingBox);const w=p.localOrigin;null!=_&&(_.localOrigin=w,_.applyToAabb(he));const P=he;if(_e[0]=i[0]-w[0],_e[1]=i[1]-w[1],_e[2]=i[2]-w[2],!K(P,_e,n,f,b))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),b=g&&null!=o.dist?o.dist:1/0},S=(n,c,d)=>{if((!x||null!=d)&&n>=0&&(R.backfacesTerrain||u(d,s)<0)&&(R.invisibleTerrain||!R.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),R.isFiltered)return;R.store===W.ALL&&(null==m?(m=Y(e.ray),D(m,n,d),e.results.all.push(m)):n<m.dist&&D(m,n,d)),(null==o.dist||n<o.dist)&&D(o,n,d),R.store!==W.MIN&&(null==a.dist||n>a.dist)&&D(a,n,d)}},C=fe;d(C,r,w);const{indices:E,indexCount:A}=v,j=v.vertexAttributes,N=j.getField(te.POSITION,T),B=new z(N.typedBuffer,3,j.stride/4),I=A/3;if(!_&&I>q){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new F(E,0,I,B)),e.intersectionData.intersectRay(_e,C,O,S)}else Z(_e,C,0,I,E,B,_,O,S)},w=this._rootTiles;if(null!=w){(()=>{const t=this._tileIterator;t.reset(w);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==_&&!e.intersectsRay(i,s,f,b)||p&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}acquireTechniques(e){const t=!!has("enable-feature:terrain-shadows")&&e.bind.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bind.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bind.slot===$.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&w))return null}else{const t=this.transparency===I.Opaque?$.OPAQUE_TERRAIN:$.TRANSPARENT_TERRAIN;if(e.bind.slot!==t)return null}if(this.transparency===I.Invisible)return null;switch(this._configuration.screenSpaceReflections=this._configuration.cloudReflections=this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._configuration.overlayMode=this._overlayRenderer.mode,e.output){case U.Color:case U.ColorEmission:return this._configuration.screenSpaceReflections=null!=e.bind.ssr.lastFrameColor,this._configuration.cloudReflections=null!=e.bind.clouds.data,this._configuration.receiveShadows=e.bind.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bind.ssao,this._acquireTechnique(e.output,e.bind.slot===$.OCCLUDED_TERRAIN);case U.Shadow:case U.ShadowExcludeHighlight:return this._castShadows?this._acquireTechnique(U.Shadow,!1):null;case U.ViewshedShadow:return this._inViewshed?this._acquireTechnique(U.ViewshedShadow,!1):null;case U.Depth:case U.Normal:return this._acquireTechnique(e.output,!1);case U.ObjectAndLayerIdColor:return this._acquireTechnique(U.ObjectAndLayerIdColor,!1);case U.Highlight:return this._overlayRenderer.hasHighlights?this._acquireTechnique(U.Highlight,!1):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case U.Color:case U.ColorEmission:{const i=e.bind.slot===$.OCCLUDED_TERRAIN?v.Occluded:v.Color;this._renderMaterialPass(e,t,i);break}case U.Depth:case U.Normal:this._renderAuxiliaryPass(e,t,v.Color,this._visiblePatchesByOrigin);break;case U.Highlight:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(v.Highlight)&&this._overlayRenderer.hasHighlightOptions(i)&&this._renderAuxiliaryPass(e,t,v.Highlight,this._visiblePatchesByOrigin);break}case U.Shadow:case U.ShadowExcludeHighlight:case U.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case U.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,v.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=p(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,x.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?G.GridComposite:null!=i.backgroundColor?G.ColorComposite:G.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==D.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>B(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bind,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],le.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bind,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bind.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=ee(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const o=this._stencilEnabledLayerExtents.length>0,a=i===v.Occluded;a&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",g),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:g;this._configuration.tileBlendInput===G.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?le.LINES:le.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;this._drawParameters.origin=r,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!a){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,o,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const o=i.renderData,a=o.vao,l=a?.indexBuffer;if(!a||null==l)return void(C&&console.error("Rendered tile with no indices: ",i.lij," : ",o));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,o.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=o.geometry.indexCount;e.rctx.bindVAO(a),c.assertCompatibleVertexAttributeLocations(a),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._techniques.get(oe,this._configuration)}get test(){}hasHighlightOptions(e){return this._overlayRenderer.hasHighlightOptions(e)}};e([a({readOnly:!0})],ue.prototype,"_isGlobal",null),e([a()],ue.prototype,"renderOccludedFlags",void 0),e([a({value:!1})],ue.prototype,"renderingDisabled",null),e([a({value:!0})],ue.prototype,"visible",null),e([a()],ue.prototype,"texturesBeingCompressed",null),e([a()],ue.prototype,"renderPatchBorders",null),e([a()],ue.prototype,"visualizeNormals",null),e([a()],ue.prototype,"cullBackFaces",null),e([a({value:D.FRONT_TO_BACK})],ue.prototype,"renderOrder",null),e([a()],ue.prototype,"wireframe",null),ue=e([l("esri.views.3d.terrain.TerrainRenderer")],ue);const ge=_(),pe=_(),_e=_(),fe=_();export{ue as TerrainRenderer};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as o}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as c}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,i as h,f as u}from"../../../chunks/vec32.js";import{ZEROS as g,fromValues as _,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as f,ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as b,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as T}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as R}from"../../ViewingMode.js";import{TextureUpdate as x}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlayContent as v}from"./OverlayContent.js";import{overlayRenderOccludedFlag as w}from"./OverlayRenderer.js";import{PatchRenderData as P}from"./PatchRenderData.js";import{RenderOrder as D}from"./RenderOrder.js";import{TerrainAttributesCache as S}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as C}from"./terrainUtils.js";import{TileRenderer as E}from"./TileRenderer.js";import{TileUpdate as A}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as N,compareTiles as B}from"./tileUtils.js";import{TransparencyMode as I}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as q,ComponentIntersectionData as F}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as U}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncRenderPlugin as M,ConsumesDepth as L,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as z}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as V}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as Y}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as Q,StoreResults as W}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as X}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as K,intersectTriangles as Z,MeshIntersectionOptions as J}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as $}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as ee}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as te}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ie,getVerticalOffsetTerrain as re}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as se}from"../webgl-engine/materials/DrawParameters.js";import{T as ne}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as oe}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ae}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as le}from"../../webgl/enums.js";const ce=7,de=10,he=b();let ue=class extends M{get _isGlobal(){return this._stage.viewingMode===R.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,o){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=Q.TERRAIN,this.isGround=!0,this._passParameters=new ne,this._drawParameters=new se,this._renderDataPool=new s(P),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new j,this._castShadows=!1,this._inViewshed=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=X.Occlude,this.produces=new Map([[$.OPAQUE_TERRAIN,()=>this._produces()&&this.transparency===I.Opaque],[$.TRANSPARENT_TERRAIN,()=>this._produces()&&(this.transparency===I.Transparent||this.transparency===I.InvisibleWithDraped)],[$.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileSize=256,this._configuration=new ae(t.viewingMode===R.Global),this._tileTextureCache=new r(((e,t)=>o.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new S(o)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?w:X.Occlude,this.setNeedsRender()}),o))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?L:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get tileRenderer(){return this._tileRenderer}get texturesBeingCompressed(){return this._tileRenderer?this._tileRenderer?.texturesBeingCompressed:null}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return ie}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,A.TEXTURE_FADING)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=f(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===A.TEXTURE_FADING?x.FADING:x.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[O.ELEVATION])i.pendingUpdates&=~A.GEOMETRY;e.resetPendingUpdate(A.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=de-ce,i=Math.max(0,Math.floor((e.level-t)/ce)*ce);if(this._isGlobal&&0===i)return g;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({rctx:this._rctx,tileSize:this._tileSize,techniques:this._techniques,cache:this._tileTextureCache}),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==I.Opaque)return;const s=ge,n=_e;d(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const o=e.results.min,a=e.results.max,l=e.results.ground,g=e.options.store===W.MIN,_=!!e.results.ground.target,p=re(e.verticalOffset),f=e.tolerance;let m,b=g&&null!=o.dist?o.dist:1/0;const R=e.options,x=R.normalRequired||!R.backfacesTerrain,O=new J(!1,x),v=h=>{const _=h.renderData;if(!_?.vao)return;const v=_.geometry;y(he,v.boundingBox);const w=_.localOrigin;null!=p&&(p.localOrigin=w,p.applyToAabb(he));const P=he;if(pe[0]=i[0]-w[0],pe[1]=i[1]-w[1],pe[2]=i[2]-w[2],!K(P,pe,n,f,b))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),b=g&&null!=o.dist?o.dist:1/0},S=(n,c,d)=>{if((!x||null!=d)&&n>=0&&(R.backfacesTerrain||u(d,s)<0)&&(R.invisibleTerrain||!R.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),R.isFiltered)return;R.store===W.ALL&&(null==m?(m=Y(e.ray),D(m,n,d),e.results.all.push(m)):n<m.dist&&D(m,n,d)),(null==o.dist||n<o.dist)&&D(o,n,d),R.store!==W.MIN&&(null==a.dist||n>a.dist)&&D(a,n,d)}},C=fe;d(C,r,w);const{indices:E,indexCount:A}=v,j=v.vertexAttributes,N=j.getField(te.POSITION,T),B=new z(N.typedBuffer,3,j.stride/4),I=A/3;if(!p&&I>q){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new F(E,0,I,B)),e.intersectionData.intersectRay(pe,C,O,S)}else Z(pe,C,0,I,E,B,p,O,S)},w=this._rootTiles;if(null!=w){(()=>{const t=this._tileIterator;t.reset(w);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==p&&!e.intersectsRay(i,s,f,b)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}acquireTechniques(e){const t=!!has("enable-feature:terrain-shadows")&&e.bind.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bind.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bind.slot===$.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&w))return null}else{const t=this.transparency===I.Opaque?$.OPAQUE_TERRAIN:$.TRANSPARENT_TERRAIN;if(e.bind.slot!==t)return null}if(this.transparency===I.Invisible)return null;switch(this._configuration.screenSpaceReflections=this._configuration.cloudReflections=this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._configuration.overlayMode=this._overlayRenderer.mode,e.output){case U.Color:case U.ColorEmission:return this._configuration.screenSpaceReflections=null!=e.bind.ssr.lastFrameColor,this._configuration.cloudReflections=null!=e.bind.clouds.data,this._configuration.receiveShadows=e.bind.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bind.ssao,this._acquireTechnique(e.output,e.bind.slot===$.OCCLUDED_TERRAIN);case U.Shadow:case U.ShadowExcludeHighlight:return this._castShadows?this._acquireTechnique(U.Shadow,!1):null;case U.ViewshedShadow:return this._inViewshed?this._acquireTechnique(U.ViewshedShadow,!1):null;case U.Depth:case U.Normal:return this._acquireTechnique(e.output,!1);case U.ObjectAndLayerIdColor:return this._acquireTechnique(U.ObjectAndLayerIdColor,!1);case U.Highlight:return this._overlayRenderer.hasHighlights?this._acquireTechnique(U.Highlight,!1):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case U.Color:case U.ColorEmission:{const i=e.bind.slot===$.OCCLUDED_TERRAIN?v.Occluded:v.Color;this._renderMaterialPass(e,t,i);break}case U.Depth:case U.Normal:this._renderAuxiliaryPass(e,t,v.Color,this._visiblePatchesByOrigin);break;case U.Highlight:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(v.Highlight)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,v.Highlight,this._visiblePatchesByOrigin);break}case U.Shadow:case U.ShadowExcludeHighlight:case U.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case U.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,v.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=_(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,x.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?G.GridComposite:null!=i.backgroundColor?G.ColorComposite:G.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==D.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>B(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bind,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],le.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bind,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bind.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=ee(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const o=this._stencilEnabledLayerExtents.length>0,a=i===v.Occluded;a&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",g),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:g;this._configuration.tileBlendInput===G.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?le.LINES:le.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;this._drawParameters.origin=r,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!a){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,o,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const o=i.renderData,a=o.vao,l=a?.indexBuffer;if(!a||null==l)return void(C&&console.error("Rendered tile with no indices: ",i.lij," : ",o));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,o.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=o.geometry.indexCount;e.rctx.bindVAO(a),c.assertCompatibleVertexAttributeLocations(a),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._techniques.get(oe,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([a({readOnly:!0})],ue.prototype,"_isGlobal",null),e([a()],ue.prototype,"renderOccludedFlags",void 0),e([a({value:!1})],ue.prototype,"renderingDisabled",null),e([a({value:!0})],ue.prototype,"visible",null),e([a()],ue.prototype,"texturesBeingCompressed",null),e([a()],ue.prototype,"renderPatchBorders",null),e([a()],ue.prototype,"visualizeNormals",null),e([a()],ue.prototype,"cullBackFaces",null),e([a({value:D.FRONT_TO_BACK})],ue.prototype,"renderOrder",null),e([a()],ue.prototype,"wireframe",null),ue=e([l("esri.views.3d.terrain.TerrainRenderer")],ue);const ge=p(),_e=p(),pe=p(),fe=p();export{ue as TerrainRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import i from"../../../../../core/PooledArray.js";import{isTypedArray as o}from"../../../../../core/typedArrayUtil.js";import{s as n}from"../../../../../chunks/vec32.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as a}from"../../../../../geometry/support/Indices.js";import{c as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec33.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{ColorMixModeEnum as p,encodeSymbolColor as f}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as h}from"../../../support/orientedBoundingBox.js";import{glLayout as g}from"../../../support/buffer/glUtil.js";import{newLayout as d}from"../../../support/buffer/InterleavedLayout.js";import u from"./ComponentData.js";import{ComponentObject as b}from"./ComponentObject.js";import{IntersectionGeometry as y}from"./IntersectionGeometry.js";import{Renderable as v}from"./Renderable.js";import{RenderGeometry as _}from"./RenderGeometry.js";import{RenderSubmitSystem as C}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as M}from"./SourceGeometry.js";import{UniformComponentParameters as j}from"./UniformComponentParameters.js";import{ComponentParametersVarying as w,ComponentParametersUniform as O,ComponentParameterSummary as x,ComponentMaterial as D}from"./Material/ComponentMaterial.js";import{vertexAttributeLocations as A}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as R}from"./Material/shader/ComponentData.glsl.js";import{olidEnabled as S}from"../../effects/geometry/olidUtils.js";import{getVisibility as E,updateVisibilityWithCount as I}from"../../lib/ComponentUtils.js";import{assert as H}from"../../lib/Util.js";import{VertexAttribute as V}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as U}from"../../lib/verticalOffsetUtils.js";import{BufferManager as B}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as P}from"../../../../webgl/BufferObject.js";import{Usage as N,PrimitiveType as T}from"../../../../webgl/enums.js";import{VertexArrayObject as k}from"../../../../webgl/VertexArrayObject.js";const L=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class G{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new i,this._hidden=new i,this._renderSubmit=new C(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new B(e.rctx,2+(S()?1:0))}destroy(){H(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._hidden.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.clear()}createObject(e){const t=e.geometry,i=new u(this._componentBufferManager,a(t.componentOffsets)),o=this._createRenderable(e,i),n=new y(this._viewingMode,t.positionData,i),r=new b(e.transform,e.toMapSpace,e.obb.clone(),i,o,n);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const i=e.renderable.material;t(i),i.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,i=t.componentData.visibility.componentCount;return{visible:i,invisible:t.componentData.count-i}}setComponentData(e,t){const i=e,{renderable:o,componentData:n}=i,r=o.material,s=n.materialDataBuffer,a=n.materialDataIndices,l=new j,c=s.textureBuffer,m=new Uint8Array(4),g=new Uint32Array(m.buffer);let d=0,u=0,b=0,y=n.verticalOffsets,v=1/0,_=-1/0,C=!1,M=!1,D=0;for(let h=0;h<n.count;h++){t(h,l),d+=+(l.externalColor[3]<1),u+=+(l.externalColorMixMode===p.Replace&&1===l.externalColor[3]),b+=+l.castShadows,f(l.externalColor,l.externalColorMixMode,m),m[2]=254&m[2]|+l.castShadows,c.setData(a[h],0,m[0],m[1],m[2],m[3]),C||=h>0&&D!==g[0],D=g[0],M||=0!==l.elevationOffset,M&&null==y&&(y=new Array(h).fill(0)),null!=y&&(y[h]=l.elevationOffset),v=Math.min(v,l.elevationOffset),_=Math.max(_,l.elevationOffset),R(l.elevationOffset,m),c.setData(a[h],1,m[0],m[1],m[2],m[3]);const e=l.objectAndLayerIdColor;null!=e&&c.setData(a[h],2,e[0],e[1],e[2],e[3]),l.pickable!==E(n.pickability,h)&&(n.pickability=I(n.pickability,n.count,h,l.pickable))}n.verticalOffsets=M?y:null,i.offsetObb=M?h(i.obb,v,_,this._viewingMode,i.offsetObb??i.obb.clone()):null,C||M||S()?(r.componentParameters=new w,r.componentParameters.castShadows=W(b,n.count),r.componentParameters.transparent=W(d,n.count),r.componentParameters.opaqueOverride=W(u,n.count),r.componentParameters.texture=c,c.updateTexture()):(r.componentParameters=new O,r.componentParameters.castShadows=l.castShadows?x.All:x.None,r.componentParameters.externalColor=l.externalColor,r.componentParameters.externalColorMixMode=l.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,i,o=!1){e.intersectionGeometry.getComponentAabb(t,i);const n=e,r=n.componentData.verticalOffsets;if(o||null==r)return i;const s=r[t];if(this._viewingMode===m.Local||0===s)return i[2]+=s,i[5]+=s,i;const a=U(s);return a.localOrigin=n.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}expandRangeWithComponentObjectElevationRange(e,t,i,o){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||o.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const n=e,r=n.componentData,s=r.count,a=r.verticalOffsets,l=n.intersectionGeometry,c=this._viewingMode===m.Local,p=l.getComponentAabbs(),f=z;let h=1/0,g=-1/0;for(let m=0;m<s;m++){const e=6*m,r=a?.[m]??0;let s=1/0,l=-1/0;if(c)s=p[e+2]+r+t,l=p[e+5]+r+t;else{if(f[0]=p[e],f[1]=p[e+1],f[2]=p[e+2],f[3]=p[e+3],f[4]=p[e+4],f[5]=p[e+5],0!==r){const e=U(r);e.localOrigin=n.transform.position,e.applyToAabb(f)}const s=Math.max(Math.abs(f[3]),Math.abs(f[0])),a=Math.max(Math.abs(f[4]),Math.abs(f[1])),l=t+f[5]+i;o.expandElevationRangeValues(t+f[2],Math.sqrt(s*s+a*a+l*l)-i)}o.expandElevationRangeValues(s,l),h=Math.min(h,s),g=Math.max(g,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=h,this._elevationRangeCacheMax=g}intersect(e,t,i,o,n,r,s){const a=e,{transform:l}=a,{position:c}=l;return null!=n&&(n.localOrigin=c),a.intersectionGeometry.intersect(t,i,o,n,a.componentData.verticalOffsets,l,r,s)}addEdges(e,t,i,o,n){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.componentData.offsets;return t.addComponentObject(r,a,s,l,i,o,n)}async extractEdgeInformation(e,t,i){const o=e,n=o.componentData.visibility;if(n.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:a}=o.intersectionGeometry,m=o.componentData.offsets,{EdgeInputBufferLayout:p}=await import("../../lib/edgeRendering/bufferLayouts.js"),f=p.createBuffer(a.length/3);c(f.position.typedBuffer,a,f.position.typedBufferStride,3),l(f.position,f.position,o.transform.rotationScale),this._setComponentIndices(f.componentIndex,s,m);const h=f.count,g=this._computeVisibilityIndices(s,n,m,h);return{origin:r(o.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:g,indicesLength:g.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let o=0;for(let n=0;n<i.length-1;n++){const r=i[n],s=i[n+1];for(let i=r;i<s;i++){const n=t?t[i]:i;e.set(n,o)}o++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange(((e,t)=>(r+=i[t]-i[e],!0)));const s=o(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r):new Array(r);let a=0;return t.forEachComponentRange(((t,o)=>{const n=i[t],r=i[o];for(let i=n;i<r;i++)s[a++]=e?e[i]:i;return!0})),s}addComponentHighlight(e,i,o){const n=e.componentData,r=t(n.componentHighlights,o,(()=>new Uint32Array(n.count+1)));{const e=this._activeHighlightOptions.get(o)??0;this._activeHighlightOptions.set(o,e+1)}0===r[i]++&&(n.markHighlightsDirty(),this._notifyDirty()),r[n.count]++}removeComponentHighlight(e,t,i){const{componentData:o}=e,n=o.componentHighlights.get(i);if(void 0===n)return void L().warn("Removing non-existing highlight.");const r=n[t];if(0===r)return void L().warn("Removing non-existing highlight.");this._removeActiveHighlight(i);const s=n[o.count];if(r>1)return n[t]=r-1,void(n[o.count]=s-1);n[t]=0,1===s?o.componentHighlights.delete(i):n[o.count]=s-1,o.markHighlightsDirty(),this._notifyDirty()}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)L().warn("Removing non-existing highlight.");else{const o=i-t;o<0&&L().warn("Removing non-existing highlight."),o<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,o)}}clearHighlights(e){const{componentData:t}=e,{componentHighlights:i}=t;if(i.size>0){for(const e of i)this._removeActiveHighlight(e[0],e[1][t.count]);i.clear(),t.markHighlightsDirty(),this._notifyDirty()}}hasHighlightOptions(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const i=this._renderManager.rctx,o=e.geometry,n=o.vertices.layoutParameters,r=P.createVertex(i,N.STATIC_DRAW,o.vertices.data),s=o.indices?P.createIndex(i,N.STATIC_DRAW,o.indices):null,a=g(M(n)),l=new Uint16Array(o.vertices.count);for(let g=0;g<t.count;g++){const e=t.offsets[g],i=t.offsets[g+1],n=t.materialDataIndices[g];if(null!=o.indices)for(let t=e;t<i;t++){l[o.indices[t]]=n}else for(let t=e;t<i;t++)l[t]=n}const c=P.createVertex(i,N.STATIC_DRAW,l.buffer),m=new D(e.transform,e.toMapSpace),p=new k(i,A,new Map([["data",a],["componentIndices",q]]),new Map([["data",r],["componentIndices",c]]),s),f=new _(p,T.TRIANGLES,n,null!=s),h={cameraDepthSquared:.5,gpuMemoryEstimate:r.usedMemory+c.usedMemory+(null!=s?s.usedMemory:0)};return new v(m,f,h)}_notifyDirty(){this._renderManager.notifyDirty()}}const q=g(d().u16(V.COMPONENTINDEX));function W(e,t){return e===t?x.All:0===e?x.None:x.Some}const z=s();export{G as ComponentObjectCollection};
|
|
5
|
+
import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import i from"../../../../../core/PooledArray.js";import{isTypedArray as o}from"../../../../../core/typedArrayUtil.js";import{s as n}from"../../../../../chunks/vec32.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as a}from"../../../../../geometry/support/Indices.js";import{c as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec33.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{ColorMixModeEnum as p,encodeSymbolColor as f}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as h}from"../../../support/orientedBoundingBox.js";import{glLayout as g}from"../../../support/buffer/glUtil.js";import{newLayout as d}from"../../../support/buffer/InterleavedLayout.js";import u from"./ComponentData.js";import{ComponentObject as b}from"./ComponentObject.js";import{IntersectionGeometry as y}from"./IntersectionGeometry.js";import{Renderable as v}from"./Renderable.js";import{RenderGeometry as _}from"./RenderGeometry.js";import{RenderSubmitSystem as C}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as M}from"./SourceGeometry.js";import{UniformComponentParameters as j}from"./UniformComponentParameters.js";import{ComponentParametersVarying as w,ComponentParametersUniform as x,ComponentParameterSummary as O,ComponentMaterial as D}from"./Material/ComponentMaterial.js";import{vertexAttributeLocations as A}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as R}from"./Material/shader/ComponentData.glsl.js";import{olidEnabled as S}from"../../effects/geometry/olidUtils.js";import{getVisibility as E,updateVisibilityWithCount as I}from"../../lib/ComponentUtils.js";import{assert as H}from"../../lib/Util.js";import{VertexAttribute as V}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as U}from"../../lib/verticalOffsetUtils.js";import{BufferManager as B}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as P}from"../../../../webgl/BufferObject.js";import{Usage as N,PrimitiveType as T}from"../../../../webgl/enums.js";import{VertexArrayObject as k}from"../../../../webgl/VertexArrayObject.js";const L=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class G{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new i,this._hidden=new i,this._renderSubmit=new C(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new B(e.rctx,2+(S()?1:0))}destroy(){H(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.forAll((e=>e.destroy())),this._hidden.clear()}createObject(e){const t=e.geometry,i=new u(this._componentBufferManager,a(t.componentOffsets)),o=this._createRenderable(e,i),n=new y(this._viewingMode,t.positionData,i),r=new b(e.transform,e.toMapSpace,e.obb.clone(),i,o,n);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const i=e.renderable.material;t(i),i.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,i=t.componentData.visibility.componentCount;return{visible:i,invisible:t.componentData.count-i}}setComponentData(e,t){const i=e,{renderable:o,componentData:n}=i,r=o.material,s=n.materialDataBuffer,a=n.materialDataIndices,l=new j,c=s.textureBuffer,m=new Uint8Array(4),g=new Uint32Array(m.buffer);let d=0,u=0,b=0,y=n.verticalOffsets,v=1/0,_=-1/0,C=!1,M=!1,D=0;for(let h=0;h<n.count;h++){t(h,l),d+=+(l.externalColor[3]<1),u+=+(l.externalColorMixMode===p.Replace&&1===l.externalColor[3]),b+=+l.castShadows,f(l.externalColor,l.externalColorMixMode,m),m[2]=254&m[2]|+l.castShadows,c.setData(a[h],0,m[0],m[1],m[2],m[3]),C||=h>0&&D!==g[0],D=g[0],M||=0!==l.elevationOffset,M&&null==y&&(y=new Array(h).fill(0)),null!=y&&(y[h]=l.elevationOffset),v=Math.min(v,l.elevationOffset),_=Math.max(_,l.elevationOffset),R(l.elevationOffset,m),c.setData(a[h],1,m[0],m[1],m[2],m[3]);const e=l.objectAndLayerIdColor;null!=e&&c.setData(a[h],2,e[0],e[1],e[2],e[3]),l.pickable!==E(n.pickability,h)&&(n.pickability=I(n.pickability,n.count,h,l.pickable))}n.verticalOffsets=M?y:null,i.offsetObb=M?h(i.obb,v,_,this._viewingMode,i.offsetObb??i.obb.clone()):null,C||M||S()?(r.componentParameters=new w,r.componentParameters.castShadows=W(b,n.count),r.componentParameters.transparent=W(d,n.count),r.componentParameters.opaqueOverride=W(u,n.count),r.componentParameters.texture=c,c.updateTexture()):(r.componentParameters=new x,r.componentParameters.castShadows=l.castShadows?O.All:O.None,r.componentParameters.externalColor=l.externalColor,r.componentParameters.externalColorMixMode=l.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,i,o=!1){e.intersectionGeometry.getComponentAabb(t,i);const n=e,r=n.componentData.verticalOffsets;if(o||null==r)return i;const s=r[t];if(this._viewingMode===m.Local||0===s)return i[2]+=s,i[5]+=s,i;const a=U(s);return a.localOrigin=n.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}expandRangeWithComponentObjectElevationRange(e,t,i,o){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||o.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const n=e,r=n.componentData,s=r.count,a=r.verticalOffsets,l=n.intersectionGeometry,c=this._viewingMode===m.Local,p=l.getComponentAabbs(),f=z;let h=1/0,g=-1/0;for(let m=0;m<s;m++){const e=6*m,r=a?.[m]??0;let s=1/0,l=-1/0;if(c)s=p[e+2]+r+t,l=p[e+5]+r+t;else{if(f[0]=p[e],f[1]=p[e+1],f[2]=p[e+2],f[3]=p[e+3],f[4]=p[e+4],f[5]=p[e+5],0!==r){const e=U(r);e.localOrigin=n.transform.position,e.applyToAabb(f)}const s=Math.max(Math.abs(f[3]),Math.abs(f[0])),a=Math.max(Math.abs(f[4]),Math.abs(f[1])),l=t+f[5]+i;o.expandElevationRangeValues(t+f[2],Math.sqrt(s*s+a*a+l*l)-i)}o.expandElevationRangeValues(s,l),h=Math.min(h,s),g=Math.max(g,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=h,this._elevationRangeCacheMax=g}intersect(e,t,i,o,n,r,s){const a=e,{transform:l}=a,{position:c}=l;return null!=n&&(n.localOrigin=c),a.intersectionGeometry.intersect(t,i,o,n,a.componentData.verticalOffsets,l,r,s)}addEdges(e,t,i,o,n){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.componentData.offsets;return t.addComponentObject(r,a,s,l,i,o,n)}async extractEdgeInformation(e,t,i){const o=e,n=o.componentData.visibility;if(n.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:a}=o.intersectionGeometry,m=o.componentData.offsets,{EdgeInputBufferLayout:p}=await import("../../lib/edgeRendering/bufferLayouts.js"),f=p.createBuffer(a.length/3);c(f.position.typedBuffer,a,f.position.typedBufferStride,3),l(f.position,f.position,o.transform.rotationScale),this._setComponentIndices(f.componentIndex,s,m);const h=f.count,g=this._computeVisibilityIndices(s,n,m,h);return{origin:r(o.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:g,indicesLength:g.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let o=0;for(let n=0;n<i.length-1;n++){const r=i[n],s=i[n+1];for(let i=r;i<s;i++){const n=t?t[i]:i;e.set(n,o)}o++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange(((e,t)=>(r+=i[t]-i[e],!0)));const s=o(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r):new Array(r);let a=0;return t.forEachComponentRange(((t,o)=>{const n=i[t],r=i[o];for(let i=n;i<r;i++)s[a++]=e?e[i]:i;return!0})),s}addComponentHighlight(e,i,o){const n=e.componentData,r=t(n.componentHighlights,o,(()=>new Uint32Array(n.count+1)));{const e=this._activeHighlightOptions.get(o)??0;this._activeHighlightOptions.set(o,e+1)}0===r[i]++&&(n.markHighlightsDirty(),this._notifyDirty()),r[n.count]++}removeComponentHighlight(e,t,i){const{componentData:o}=e,n=o.componentHighlights.get(i);if(void 0===n)return void L().warn("Removing non-existing highlight.");const r=n[t];if(0===r)return void L().warn("Removing non-existing highlight.");this._removeActiveHighlight(i);const s=n[o.count];if(r>1)return n[t]=r-1,void(n[o.count]=s-1);n[t]=0,1===s?o.componentHighlights.delete(i):n[o.count]=s-1,o.markHighlightsDirty(),this._notifyDirty()}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)L().warn("Removing non-existing highlight.");else{const o=i-t;o<0&&L().warn("Removing non-existing highlight."),o<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,o)}}clearHighlights(e){const{componentData:t}=e,{componentHighlights:i}=t;if(i.size>0){for(const e of i)this._removeActiveHighlight(e[0],e[1][t.count]);i.clear(),t.markHighlightsDirty(),this._notifyDirty()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const i=this._renderManager.rctx,o=e.geometry,n=o.vertices.layoutParameters,r=P.createVertex(i,N.STATIC_DRAW,o.vertices.data),s=o.indices?P.createIndex(i,N.STATIC_DRAW,o.indices):null,a=g(M(n)),l=new Uint16Array(o.vertices.count);for(let g=0;g<t.count;g++){const e=t.offsets[g],i=t.offsets[g+1],n=t.materialDataIndices[g];if(null!=o.indices)for(let t=e;t<i;t++){l[o.indices[t]]=n}else for(let t=e;t<i;t++)l[t]=n}const c=P.createVertex(i,N.STATIC_DRAW,l.buffer),m=new D(e.transform,e.toMapSpace),p=new k(i,A,new Map([["data",a],["componentIndices",q]]),new Map([["data",r],["componentIndices",c]]),s),f=new _(p,T.TRIANGLES,n,null!=s),h={cameraDepthSquared:.5,gpuMemoryEstimate:r.usedMemory+c.usedMemory+(null!=s?s.usedMemory:0)};return new v(m,f,h)}_notifyDirty(){this._renderManager.notifyDirty()}}const q=g(d().u16(V.COMPONENTINDEX));function W(e,t){return e===t?O.All:0===e?O.None:O.Some}const z=s();export{G as ComponentObjectCollection};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{invert as t,transpose as r}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as o}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{p as s,J as a}from"../../../../../../chunks/vec32.js";import{freeze as i,ZEROS as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as n}from"../../../../../../chunks/vec42.js";import{freeze as h,fromValues as u}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as p}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as c}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as d}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as m,IntegratedMeshMode as g}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as f}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as x}from"./shader/VertexDiscardMode.js";import{MaterialBase as v,parameter as b,parameterBlock as M,MaterialParameterBlock as y}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as T}from"../../../core/renderPasses/RenderPassIdentifier.js";import{ShaderOutput as w}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as O}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{EmissionSource as C}from"../../../core/shaderLibrary/output/Emissions.glsl.js";import{NormalsDoubleSidedMode as S}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as P}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{EllipsoidMode as N}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as j}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as D,CullFaceOptions as q}from"../../../lib/basicInterfaces.js";import{OITPass as A}from"../../../lib/OITPass.js";import{advancedMRRFactors as R}from"../../../materials/pbrUtils.js";import{defaultHighlightName as F}from"../../../../../support/HighlightDefaults.js";import{alphaCutoff as I}from"../../../../../../webscene/support/AlphaCutoff.js";class E extends v{constructor(e,s){super(),this.toMapSpace=s,this.baseColor=h(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=R,this.emissiveFactor=i(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.commonMaterialParameters=new L,this.componentParameters=new V,this.objectOpacity=1,this.textureAlphaCutoff=I,this.alphaDiscardMode=D.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=N.Earth,this.hasOccludees=!1;const a=new j(e.position),l=o(e.rotationScale);t(l,l),r(l,l),this.transformNormalGlobalFromModel=l,this.transformWorldFromModelTL=a.low,this.transformWorldFromModelTH=a.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return this.baseColorTexture?.glTexture}get textureMetallicRoughness(){return this.metallicRoughnessTexture?.glTexture}get textureEmissive(){return this.emissionTexture?.glTexture}get hasEmissions(){return null!=this.emissionTexture||!s(this.emissiveFactor,l)}get textureOcclusion(){return this.occlusionTexture?.glTexture}get textureNormal(){return this.normalTexture?.glTexture}acquireTechnique(e,t,r,o){const s=new m(e.context.spherical,e.context.doublePrecisionRequiresObfuscation);s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.oitPass=t.identifier===T.Material&&null!=r.oitPass?r.oitPass:A.NONE,s.terrainDepthTest=t.identifier===T.Material&&r.terrainDepthTest,s.cullAboveTerrain=t.identifier===T.Material&&r.cullAboveTerrain,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?S.View:S.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===W.Transparent||a===W.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?U(r)?_(r)?g.ColorOverlayWithWater:g.ColorOverlay:g.NoOverlay:g.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===g.ColorOverlayWithWater?P.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?o.shadeNormals&&this.isIntegratedMesh?P.Disabled:P.Schematic:P.Normal:P.Disabled,s.emissionSource=null!=this.emissionTexture?C.Texture:s.pbrMode===P.Normal?C.Value:C.None,s.shadeNormals=o.shadeNormals,s.normalType=s.hasNormals?O.Compressed:O.ScreenDerivative,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===T.ShadowMap)s.output=w.Shadow,s.vertexDiscardMode=x.None;else if(t.identifier===T.ViewshedShadowMap)s.output=w.ViewshedShadow,s.vertexDiscardMode=x.None;else if(t.identifier===T.Highlight)s.output=w.Highlight,s.vertexDiscardMode=x.None;else{switch(a===W.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?x.Opaque:x.Transparent:s.vertexDiscardMode=x.None,s.output=t.output,s.receiveAmbientOcclusion=s.receiveShadows=!1,t.output){case w.Color:case w.ColorEmission:s.receiveAmbientOcclusion=o.applySSAO&&null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.screenSpaceReflections=null!=r.ssr.lastFrameColor,s.cloudReflections=null!=r.clouds.data;break;case w.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}const i=e.get(d,s);return this._setClean(),i}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(this.objectOpacity<=0)return;const{componentData:o,renderable:s}=r,{geometry:a}=s,i=s.meta.cameraDepthSquared;o.updateHighlights(t.highlights);const{geometryRanges:l,highlightRangesMap:n,shadowmapRanges:h}=o;switch(this._computeWhichMaterialPass()){case W.Opaque:e.opaque.submitDraw(this,a,l,i);break;case W.Transparent:e.transparent.submitDraw(this,a,l,i);break;case W.OpaqueAndTransparent:e.opaque.submitDraw(this,a,l,i),e.transparent.submitDraw(this,a,l,i);break;case W.IntegratedMesh:e.integratedMesh.submitDraw(this,a,l,i),H(t)&&e.highlightIntegratedMesh.submitDraw(this,a,l,i)}if(this.componentParameters.castShadows!==k.None){if(null!=n)for(const t of n)t[0]===F&&e.highlightShadowMap.submitDraw(this,a,t[1],i,t[0]);null!=h&&e.nonHighlightShadowMap.submitDraw(this,a,h,i),e.shadowMap.submitDraw(this,a,l,i)}if(null!=n)for(const u of n)e.highlight.submitDraw(this,a,u[1],i,u[0]);t.viewshedEnabled&&e.viewshedShadowMap.submitDraw(this,a,l,i)}_computeWhichMaterialPass(){if(this.isIntegratedMesh)return W.IntegratedMesh;if(this.objectOpacity<1)return W.Transparent;if(this.componentParameters.opaqueOverride===k.All)return W.Opaque;if(this.baseColor[3]<1||this.alphaDiscardMode===D.Blend||this.alphaDiscardMode===D.MaskBlend)return W.Transparent;switch(this.componentParameters.transparent){case k.None:return W.Opaque;case k.All:return W.Transparent;case k.Some:return W.OpaqueAndTransparent}}}var W,k;e([b({vectorOps:n})],E.prototype,"baseColor",void 0),e([b()],E.prototype,"usePBR",void 0),e([b()],E.prototype,"hasParametersFromSource",void 0),e([b({vectorOps:a})],E.prototype,"mrrFactors",void 0),e([b({vectorOps:a})],E.prototype,"emissiveFactor",void 0),e([b({dispose:!0})],E.prototype,"baseColorTexture",void 0),e([b({dispose:!0})],E.prototype,"metallicRoughnessTexture",void 0),e([b({dispose:!0})],E.prototype,"emissionTexture",void 0),e([b({dispose:!0})],E.prototype,"occlusionTexture",void 0),e([b({dispose:!0})],E.prototype,"normalTexture",void 0),e([M()],E.prototype,"commonMaterialParameters",void 0),e([M()],E.prototype,"componentParameters",void 0),e([b()],E.prototype,"objectOpacity",void 0),e([b()],E.prototype,"textureAlphaCutoff",void 0),e([b()],E.prototype,"alphaDiscardMode",void 0),e([b()],E.prototype,"isIntegratedMesh",void 0),e([b()],E.prototype,"polygonOffsetEnabled",void 0),e([b()],E.prototype,"ellipsoidMode",void 0),e([b()],E.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(W||(W={}));class L extends y{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=q.Back,this.hasSlicePlane=!0}}e([b()],L.prototype,"doubleSided",void 0),e([b()],L.prototype,"cullFace",void 0),e([b()],L.prototype,"hasSlicePlane",void 0);class V extends y{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=p.Multiply,this.castShadows=k.All}get transparent(){return this.externalColor[3]<1?k.All:k.None}get opaqueOverride(){return this.externalColorMixMode===p.Replace&&1===this.externalColor[3]?k.All:k.None}get visible(){return this.externalColor[3]>0?k.All:k.None}get type(){return f.Uniform}}e([b({vectorOps:n})],V.prototype,"externalColor",void 0),e([b()],V.prototype,"externalColorMixMode",void 0),e([b()],V.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(k||(k={}));class B extends y{constructor(){super(...arguments),this.texture=null,this.transparent=k.None,this.opaqueOverride=k.None,this.castShadows=k.None}get type(){return f.Varying}}function H(e){return null!=e.overlay?.getTexture(c.Highlight)}function _(e){return null!=e.overlay?.getTexture(c.WaterNormal)}function U(e){return null!=e.overlay?.getTexture(c.ColorNoRasterImage)}e([b()],B.prototype,"texture",void 0),e([b()],B.prototype,"transparent",void 0),e([b()],B.prototype,"opaqueOverride",void 0),e([b()],B.prototype,"castShadows",void 0);export{L as CommonMaterialParameters,E as ComponentMaterial,k as ComponentParameterSummary,V as ComponentParametersUniform,B as ComponentParametersVarying};
|
|
5
|
+
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{invert as t,transpose as r}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as o}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{p as s,J as a}from"../../../../../../chunks/vec32.js";import{freeze as i,ZEROS as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as n}from"../../../../../../chunks/vec42.js";import{freeze as h,fromValues as u}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as p}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as c}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as d}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as m,IntegratedMeshMode as f}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as g}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as x}from"./shader/VertexDiscardMode.js";import{MaterialBase as v,parameter as b,parameterBlock as M,MaterialParameterBlock as y}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as T}from"../../../core/renderPasses/RenderPassIdentifier.js";import{ShaderOutput as w}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as O}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{EmissionSource as C}from"../../../core/shaderLibrary/output/Emissions.glsl.js";import{NormalsDoubleSidedMode as S}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as P}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{EllipsoidMode as N}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as j}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as D,CullFaceOptions as q}from"../../../lib/basicInterfaces.js";import{OITPass as A}from"../../../lib/OITPass.js";import{advancedMRRFactors as R}from"../../../materials/pbrUtils.js";import{defaultHighlightName as F}from"../../../../../support/HighlightDefaults.js";import{alphaCutoff as I}from"../../../../../../webscene/support/AlphaCutoff.js";class E extends v{constructor(e,s){super(),this.toMapSpace=s,this.baseColor=h(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=R,this.emissiveFactor=i(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.commonMaterialParameters=new L,this.componentParameters=new V,this.objectOpacity=1,this.textureAlphaCutoff=I,this.alphaDiscardMode=D.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=N.Earth,this.hasOccludees=!1;const a=new j(e.position),l=o(e.rotationScale);t(l,l),r(l,l),this.transformNormalGlobalFromModel=l,this.transformWorldFromModelTL=a.low,this.transformWorldFromModelTH=a.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return this.baseColorTexture?.glTexture}get textureMetallicRoughness(){return this.metallicRoughnessTexture?.glTexture}get textureEmissive(){return this.emissionTexture?.glTexture}get hasEmissions(){return null!=this.emissionTexture||!s(this.emissiveFactor,l)}get textureOcclusion(){return this.occlusionTexture?.glTexture}get textureNormal(){return this.normalTexture?.glTexture}acquireTechnique(e,t,r,o){const s=new m(e.context.spherical,e.context.doublePrecisionRequiresObfuscation);s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.oitPass=t.identifier===T.Material&&null!=r.oitPass?r.oitPass:A.NONE,s.terrainDepthTest=t.identifier===T.Material&&r.terrainDepthTest,s.cullAboveTerrain=t.identifier===T.Material&&r.cullAboveTerrain,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?S.View:S.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===W.Transparent||a===W.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?U(r)?_(r)?f.ColorOverlayWithWater:f.ColorOverlay:f.NoOverlay:f.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===f.ColorOverlayWithWater?P.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?o.shadeNormals&&this.isIntegratedMesh?P.Disabled:P.Schematic:P.Normal:P.Disabled,s.emissionSource=null!=this.emissionTexture?C.Texture:s.pbrMode===P.Normal?C.Value:C.None,s.shadeNormals=o.shadeNormals,s.normalType=s.hasNormals?O.Compressed:O.ScreenDerivative,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===T.ShadowMap)s.output=w.Shadow,s.vertexDiscardMode=x.None;else if(t.identifier===T.ViewshedShadowMap)s.output=w.ViewshedShadow,s.vertexDiscardMode=x.None;else if(t.identifier===T.Highlight)s.output=w.Highlight,s.vertexDiscardMode=x.None;else{switch(a===W.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?x.Opaque:x.Transparent:s.vertexDiscardMode=x.None,s.output=t.output,s.receiveAmbientOcclusion=s.receiveShadows=!1,t.output){case w.Color:case w.ColorEmission:s.receiveAmbientOcclusion=o.applySSAO&&null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.screenSpaceReflections=null!=r.ssr.lastFrameColor,s.cloudReflections=null!=r.clouds.data;break;case w.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}const i=e.get(d,s);return this._setClean(),i}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(this.objectOpacity<=0)return;const{componentData:o,renderable:s}=r,{geometry:a}=s,i=s.meta.cameraDepthSquared;o.updateHighlights(t.highlights);const{geometryRanges:l,highlightRangesMap:n,shadowmapRanges:h}=o;switch(this._computeWhichMaterialPass()){case W.Opaque:e.opaque.submitDraw(this,a,l,i);break;case W.Transparent:e.transparent.submitDraw(this,a,l,i);break;case W.OpaqueAndTransparent:e.opaque.submitDraw(this,a,l,i),e.transparent.submitDraw(this,a,l,i);break;case W.IntegratedMesh:e.integratedMesh.submitDraw(this,a,l,i),H(t)&&e.highlightIntegratedMesh.submitDraw(this,a,l,i)}if(this.componentParameters.castShadows!==k.None){if(null!=n)for(const t of n)t[0]===F&&e.highlightShadowMap.submitDraw(this,a,t[1],i,t[0]);null!=h&&e.defaultShadowMap.submitDraw(this,a,h,i),e.shadowMap.submitDraw(this,a,l,i)}if(null!=n)for(const u of n)e.highlight.submitDraw(this,a,u[1],i,u[0]);t.viewshedEnabled&&e.viewshedShadowMap.submitDraw(this,a,l,i)}_computeWhichMaterialPass(){if(this.isIntegratedMesh)return W.IntegratedMesh;if(this.objectOpacity<1)return W.Transparent;if(this.componentParameters.opaqueOverride===k.All)return W.Opaque;if(this.baseColor[3]<1||this.alphaDiscardMode===D.Blend||this.alphaDiscardMode===D.MaskBlend)return W.Transparent;switch(this.componentParameters.transparent){case k.None:return W.Opaque;case k.All:return W.Transparent;case k.Some:return W.OpaqueAndTransparent}}}var W,k;e([b({vectorOps:n})],E.prototype,"baseColor",void 0),e([b()],E.prototype,"usePBR",void 0),e([b()],E.prototype,"hasParametersFromSource",void 0),e([b({vectorOps:a})],E.prototype,"mrrFactors",void 0),e([b({vectorOps:a})],E.prototype,"emissiveFactor",void 0),e([b({dispose:!0})],E.prototype,"baseColorTexture",void 0),e([b({dispose:!0})],E.prototype,"metallicRoughnessTexture",void 0),e([b({dispose:!0})],E.prototype,"emissionTexture",void 0),e([b({dispose:!0})],E.prototype,"occlusionTexture",void 0),e([b({dispose:!0})],E.prototype,"normalTexture",void 0),e([M()],E.prototype,"commonMaterialParameters",void 0),e([M()],E.prototype,"componentParameters",void 0),e([b()],E.prototype,"objectOpacity",void 0),e([b()],E.prototype,"textureAlphaCutoff",void 0),e([b()],E.prototype,"alphaDiscardMode",void 0),e([b()],E.prototype,"isIntegratedMesh",void 0),e([b()],E.prototype,"polygonOffsetEnabled",void 0),e([b()],E.prototype,"ellipsoidMode",void 0),e([b()],E.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(W||(W={}));class L extends y{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=q.Back,this.hasSlicePlane=!0}}e([b()],L.prototype,"doubleSided",void 0),e([b()],L.prototype,"cullFace",void 0),e([b()],L.prototype,"hasSlicePlane",void 0);class V extends y{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=p.Multiply,this.castShadows=k.All}get transparent(){return this.externalColor[3]<1?k.All:k.None}get opaqueOverride(){return this.externalColorMixMode===p.Replace&&1===this.externalColor[3]?k.All:k.None}get visible(){return this.externalColor[3]>0?k.All:k.None}get type(){return g.Uniform}}e([b({vectorOps:n})],V.prototype,"externalColor",void 0),e([b()],V.prototype,"externalColorMixMode",void 0),e([b()],V.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(k||(k={}));class B extends y{constructor(){super(...arguments),this.texture=null,this.transparent=k.None,this.opaqueOverride=k.None,this.castShadows=k.None}get type(){return g.Varying}}function H(e){return null!=e.overlay?.getTexture(c.Highlight)}function _(e){return null!=e.overlay?.getTexture(c.WaterNormal)}function U(e){return null!=e.overlay?.getTexture(c.ColorNoRasterImage)}e([b()],B.prototype,"texture",void 0),e([b()],B.prototype,"transparent",void 0),e([b()],B.prototype,"opaqueOverride",void 0),e([b()],B.prototype,"castShadows",void 0);export{L as CommonMaterialParameters,E as ComponentMaterial,k as ComponentParameterSummary,V as ComponentParametersUniform,B as ComponentParametersVarying};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{computeDepthRange as s}from"./DepthRange.js";class
|
|
5
|
+
import{computeDepthRange as s}from"./DepthRange.js";class e{constructor(s){this._objects=s}submit(s,e){this._objects.preSubmit(e),this._objects.visibleObjects.forAll((t=>t.renderable.material.submit(s,e,t)))}queryDepthRange(e){return this._objects.visibleObjects.length?s(e,this._objects.visibleObjects):null}get hasEmissions(){return this._objects.visibleObjects.some((s=>s.renderable.material.hasEmissions))}hasHighlight(s){return this._objects.hasHighlight(s)}}export{e as RenderSubmitSystem};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderPass as s,RenderPassSorting as e}from"./RenderPass.js";import{RenderPassIdentifier as i}from"./RenderPassIdentifier.js";import{ShaderOutput as r}from"../shaderLibrary/ShaderOutput.js";import{VertexNormalPassParameters as
|
|
5
|
+
import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderPass as s,RenderPassSorting as e}from"./RenderPass.js";import{RenderPassIdentifier as i}from"./RenderPassIdentifier.js";import{ShaderOutput as r}from"../shaderLibrary/ShaderOutput.js";import{VertexNormalPassParameters as a,VertexNormalDrawParameters as n}from"../shaderLibrary/attributes/VertexNormal.glsl.js";class o{constructor(t){const i=t.renderContext.rctx,r=t.techniques;this.opaque=new s(i,r),this.transparent=new s(i,r,e.BackToFront),this.integratedMesh=new s(i,r),this.shadowMap=new s(i,r),this.highlight=new s(i,r),this.highlightIntegratedMesh=new s(i,r),this.highlightShadowMap=new s(i,r),this.viewshedShadowMap=new s(i,r),this.defaultShadowMap=new s(i,r)}}class h extends a{constructor(){super(...arguments),this.slicePlaneLocalOrigin=t(),this.origin=this.slicePlaneLocalOrigin,this.modelTransformation=null}}class c extends n{}class d extends h{constructor(){super(...arguments),this.identifier=i.Material,this.output=r.Color,this.transparent=!1}}class l extends h{constructor(){super(...arguments),this.identifier=i.ShadowMap}}class p extends h{constructor(){super(...arguments),this.identifier=i.Highlight}}class u extends h{constructor(){super(...arguments),this.identifier=i.ViewshedShadowMap}}export{o as AllRenderPasses,c as DrawParameters,p as HighlightPassParameters,d as MaterialPassParameters,h as PassParameters,l as ShadowMapPassParameters,u as ViewshedShadowMapPassParameters};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../core/PooledArray.js";import{RenderPassIdentifier as t}from"./RenderPassIdentifier.js";import{OITPass as r}from"../../lib/OITPass.js";import{DataType as i}from"../../../../webgl/enums.js";var s;!function(e){e[e.FrontToBack=0]="FrontToBack",e[e.BackToFront=1]="BackToFront"}(s||(s={}));class n{constructor(t,r,i=s.FrontToBack){this._rctx=t,this._techniques=r,this._sorting=i,this._draws=new e({allocator:e=>e??{material:null,geometry:null,geometryRanges:null,bindDrawParams:null,depthSquaredHint:0,indexType:0}}),this._previouslyBoundDraw=new Map}submitDraw(e,t,r,i,s){const n=this._draws.pushNew();n.geometry=t,n.geometryRanges=r,n.material=e,n.depthSquaredHint=i,n.indexType=(t.indexed?t.vao.indexBuffer.indexType:null)??0,n.highlightName=s}acquire(e,t){return this._draws.map((r=>r.material.acquireTechnique(this._techniques,e,t,r.geometry.parameters)))}dispatch(e,i,s){const n=this._rctx;this._previouslyBoundDraw.clear();let a=null;const h=this._draws.length,l=i.highlight?.name;for(let c=0;c<h;c++){const h=this._draws.data[c];if(e.identifier===t.Highlight){const e=h.highlightName;if(e){if(e!==l)continue}else if(!l||!i.overlay?.
|
|
5
|
+
import e from"../../../../../core/PooledArray.js";import{RenderPassIdentifier as t}from"./RenderPassIdentifier.js";import{OITPass as r}from"../../lib/OITPass.js";import{DataType as i}from"../../../../webgl/enums.js";var s;!function(e){e[e.FrontToBack=0]="FrontToBack",e[e.BackToFront=1]="BackToFront"}(s||(s={}));class n{constructor(t,r,i=s.FrontToBack){this._rctx=t,this._techniques=r,this._sorting=i,this._draws=new e({allocator:e=>e??{material:null,geometry:null,geometryRanges:null,bindDrawParams:null,depthSquaredHint:0,indexType:0}}),this._previouslyBoundDraw=new Map}submitDraw(e,t,r,i,s){const n=this._draws.pushNew();n.geometry=t,n.geometryRanges=r,n.material=e,n.depthSquaredHint=i,n.indexType=(t.indexed?t.vao.indexBuffer.indexType:null)??0,n.highlightName=s}acquire(e,t){return this._draws.map((r=>r.material.acquireTechnique(this._techniques,e,t,r.geometry.parameters)))}dispatch(e,i,s){const n=this._rctx;this._previouslyBoundDraw.clear();let a=null;const h=this._draws.length,l=i.highlight?.name;for(let c=0;c<h;c++){const h=this._draws.data[c];if(e.identifier===t.Highlight){const e=h.highlightName;if(e){if(e!==l)continue}else if(!l||!i.overlay?.hasHighlight(l))continue}const d=s[c];d===a&&i.oitPass===r.NONE||(n.bindTechnique(d,i,e),a=d);const{geometryRanges:u,indexType:m,geometry:g,material:p}=h;n.bindVAO(g.vao),this._previouslyBoundDraw.get(d)!==p&&(d.program.bindDraw(i,e,p),this._previouslyBoundDraw.set(d,p));const y=u.length,{primitiveType:w}=g;for(let e=0;e<y;e+=2){const t=u[e],r=u[e+1];if(0!==m){const e=o.get(m);n.drawElements(w,r,m,t*e)}else n.drawArrays(w,t,r)}}}prepareSubmit(){this._draws.clear()}finishSubmit(){const e=this._sorting===s.FrontToBack?1:-1;this._draws.sort(((t,r)=>{const i=e*(t.depthSquaredHint-r.depthSquaredHint);return 0!==i?i:t.geometry.vao.byteSize-r.geometry.vao.byteSize}))}get count(){return this._draws.length}}const o=new Map;o.set(i.UNSIGNED_BYTE,1),o.set(i.UNSIGNED_SHORT,2),o.set(i.UNSIGNED_INT,4);export{n as RenderPass,s as RenderPassSorting};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as s}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as e}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as t,transpose as r,invert as a}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{copy as o}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{i as h,c as n}from"../../../../../chunks/vec32.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{MaterialPassParameters as c,ShadowMapPassParameters as l,HighlightPassParameters as
|
|
5
|
+
import{_ as s}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as e}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as t,transpose as r,invert as a}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{copy as o}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{i as h,c as n}from"../../../../../chunks/vec32.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{MaterialPassParameters as c,ShadowMapPassParameters as l,HighlightPassParameters as u,ViewshedShadowMapPassParameters as p,AllRenderPasses as d}from"./AllRenderPasses.js";import{RenderPassIdentifier as _}from"./RenderPassIdentifier.js";import{ShaderOutput as P}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as g}from"../util/TwoVectorPosition.js";import{SyncRenderPlugin as w}from"../../effects/RenderPlugin.js";import{DepthRange as f}from"../../lib/DepthRange.js";import{RenderSlot as R}from"../../lib/RenderSlot.js";let E=class extends w{constructor(){super({}),this.produces=new Map([[R.OPAQUE_MATERIAL,s=>this._produces(s,R.OPAQUE_MATERIAL)],[R.TRANSPARENT_MATERIAL,s=>this._produces(s,R.TRANSPARENT_MATERIAL)],[R.INTEGRATED_MESH,s=>this._produces(s,R.INTEGRATED_MESH)]]),this._materialPassParameters=new c,this._shadowPassParameters=new l,this._highlightPassParameters=new u,this._viewshedPassParameters=new p,this._systems=new Set}initializeRenderContext(s){this._context=s,this._passes=new d(s)}get rctx(){return this._context.renderContext.rctx}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.clear()}register(s){this._systems.add(s)}_produces(s,e){return!!this._invoke(s,e,(s=>s.count>0))}prepareRender(s){const{_systems:e,_passes:t}=this;if(0!==e.size&&null!=t){for(const s of Object.values(t))s.prepareSubmit();e.forEach((e=>e.submit(t,s.bind)));for(const s of Object.values(t))s.finishSubmit()}}acquireTechniques(s){if(0===this._systems.size)return null;const e=s.output===P.Shadow||s.output===P.ShadowHighlight||s.output===P.ShadowExcludeHighlight?this._shadowPassParameters:s.output===P.ViewshedShadow?this._viewshedPassParameters:s.output===P.Highlight?this._highlightPassParameters:this._materialPassParameters,t=s.bind;return this._updateParameters(t.camera,e,t.slot===R.TRANSPARENT_MATERIAL),this._materialPassParameters.output=s.output,this._invoke(s.output,s.bind.slot,((e,t)=>e.acquire(t,s.bind)))}render(s,e){this._invoke(s.output,s.bind.slot,((t,r)=>t.dispatch(r,s.bind,e)))}_invoke(s,e,t){if(null==this._passes)return null;switch(e){case R.OPAQUE_MATERIAL:switch(s){case P.Color:case P.ColorEmission:case P.Depth:case P.Normal:case P.ObjectAndLayerIdColor:return t(this._passes.opaque,this._materialPassParameters);case P.Highlight:return t(this._passes.highlight,this._highlightPassParameters);case P.Shadow:return t(this._passes.shadowMap,this._shadowPassParameters);case P.ShadowHighlight:return t(this._passes.highlightShadowMap,this._shadowPassParameters);case P.ShadowExcludeHighlight:return t(this._passes.defaultShadowMap,this._shadowPassParameters);case P.ViewshedShadow:return t(this._passes.viewshedShadowMap,this._viewshedPassParameters)}break;case R.TRANSPARENT_MATERIAL:switch(s){case P.Color:case P.ColorEmission:case P.Depth:case P.Normal:case P.ObjectAndLayerIdColor:return t(this._passes.transparent,this._materialPassParameters)}break;case R.INTEGRATED_MESH:switch(s){case P.Color:case P.ColorEmission:case P.Depth:case P.Normal:case P.ObjectAndLayerIdColor:return t(this._passes.integratedMesh,this._materialPassParameters);case P.Highlight:return t(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}}return null}notifyDirty(){this._context.requestRender()}queryDepthRange(s){const e=new f;return this._systems.forEach((t=>e.union(t.queryDepthRange(s)))),e}get hasEmissions(){let s=!1;return this._systems.forEach((e=>s=e.hasEmissions||s)),s}_updateParameters(s,e,i){const m=s.viewInverseTransposeMatrix;h(A,m[3],m[7],m[11]),S.set(A),n(e.transformWorldFromViewTH,S.high),n(e.transformWorldFromViewTL,S.low),n(e.slicePlaneLocalOrigin,A),t(e.transformViewFromCameraRelativeRS,s.viewMatrix),o(e.transformProjFromView,s.projectionMatrix),e.identifier===_.Material&&(this._materialPassParameters.transparent=i,r(b,e.transformViewFromCameraRelativeRS),a(e.transformNormalViewFromGlobal,b))}hasHighlight(s){for(const e of this._systems)if(e.hasHighlight(s))return!0;return!1}};E=s([e("esri.views.3d.webgl-engine.core.renderPasses.RenderPassManager")],E);const A=m(),b=i(),S=new g;export{E as RenderPassManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isPromiseLike as t,createAbortError as r}from"../../../../core/promiseUtils.js";import{signal as s}from"../../../../core/signal.js";import{DepthRange as n}from"../lib/DepthRange.js";import{RenderOccludedFlag as o}from"../lib/Material.js";import{RenderSlot as i}from"../lib/RenderSlot.js";class d{constructor(t){this.context=t,this._renderPlugins=new e,this._slots=new Array,this._version=s(0);for(let e=0;e<i.MAX_SLOTS;++e)this._slots[e]=[]}destroy(){this._renderPlugins.forEach((e=>e.destroy())),this._renderPlugins.clear()}get plugins(){return this._renderPlugins}add(e,s){const n=()=>{if(s?.aborted)throw e.uninitializeRenderContext(),r();this._renderPlugins.push(e),e.produces.forEach(((t,r)=>this._slots[r].push(e))),this.context.requestRender(),this._version.value++},o=e.initializeRenderContext(this.context,s);if(t(o))return o.then(n);n()}remove(e){this._renderPlugins.removeUnordered(e),e.uninitializeRenderContext();for(let t=0;t<this._slots.length;++t)this._slots[t]=this._slots[t].filter((t=>t!==e));this.context.requestRender(),this._version.value++}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this.context.renderContext)}))}updateAnimation(e){let t=!1;return this._renderPlugins.forAll((r=>t=r.updateAnimation?.(e)||t)),t}precompile(...e){++this.context.techniques.precompiling;const t=this.context.renderContext.bind.slot;for(const r of e)this.context.renderContext.bind.slot=r,this._forEachRender((()=>{}));this.context.renderContext.bind.slot=t,--this.context.techniques.precompiling}render(e,...t){for(const r of t)this.context.renderContext.bind.slot=r,this._forEachRender(((t,r)=>t.render(this.context.renderContext,r,e)))}_forEachRender(e){const t=this.context.renderContext.bind.slot,r=this.context.renderContext.output;this._slots[t].forEach((s=>{const n=s.produces.get(t);if(!n?.(r)||s.isDecoration&&!this.context.renderContext.bind.decorations)return;const o=s.acquireTechniques(this.context.renderContext);o&&e(s,o)}))}queryDepthRange(e){const t=new n;return this._renderPlugins.forAll((r=>{const s=r.queryDepthRange?.(e);t.union(s)})),t}get updating(){return this._version.value>=0&&this._renderPlugins.some((e=>e.running))}produces(e,...t){return t.some((t=>this._slots[t].some((r=>{const s=r.produces.get(t);return!!s&&s(e)}))))}consumes(e){return this._renderPlugins.some((t=>t.consumes().required.includes(e)))}
|
|
5
|
+
import"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isPromiseLike as t,createAbortError as r}from"../../../../core/promiseUtils.js";import{signal as s}from"../../../../core/signal.js";import{DepthRange as n}from"../lib/DepthRange.js";import{RenderOccludedFlag as o}from"../lib/Material.js";import{RenderSlot as i}from"../lib/RenderSlot.js";class d{constructor(t){this.context=t,this._renderPlugins=new e,this._slots=new Array,this._version=s(0);for(let e=0;e<i.MAX_SLOTS;++e)this._slots[e]=[]}destroy(){this._renderPlugins.forEach((e=>e.destroy())),this._renderPlugins.clear()}get plugins(){return this._renderPlugins}add(e,s){const n=()=>{if(s?.aborted)throw e.uninitializeRenderContext(),r();this._renderPlugins.push(e),e.produces.forEach(((t,r)=>this._slots[r].push(e))),this.context.requestRender(),this._version.value++},o=e.initializeRenderContext(this.context,s);if(t(o))return o.then(n);n()}remove(e){this._renderPlugins.removeUnordered(e),e.uninitializeRenderContext();for(let t=0;t<this._slots.length;++t)this._slots[t]=this._slots[t].filter((t=>t!==e));this.context.requestRender(),this._version.value++}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this.context.renderContext)}))}updateAnimation(e){let t=!1;return this._renderPlugins.forAll((r=>t=r.updateAnimation?.(e)||t)),t}precompile(...e){++this.context.techniques.precompiling;const t=this.context.renderContext.bind.slot;for(const r of e)this.context.renderContext.bind.slot=r,this._forEachRender((()=>{}));this.context.renderContext.bind.slot=t,--this.context.techniques.precompiling}render(e,...t){for(const r of t)this.context.renderContext.bind.slot=r,this._forEachRender(((t,r)=>t.render(this.context.renderContext,r,e)))}_forEachRender(e){const t=this.context.renderContext.bind.slot,r=this.context.renderContext.output;this._slots[t].forEach((s=>{const n=s.produces.get(t);if(!n?.(r)||s.isDecoration&&!this.context.renderContext.bind.decorations)return;const o=s.acquireTechniques(this.context.renderContext);o&&e(s,o)}))}queryDepthRange(e){const t=new n;return this._renderPlugins.forAll((r=>{const s=r.queryDepthRange?.(e);t.union(s)})),t}get updating(){return this._version.value>=0&&this._renderPlugins.some((e=>e.running))}produces(e,...t){return t.some((t=>this._slots[t].some((r=>{const s=r.produces.get(t);return!!s&&s(e)}))))}consumes(e){return this._renderPlugins.some((t=>t.consumes().required.includes(e)))}hasHighlight(e){return h.some((t=>this._slots[t].some((t=>t.hasHighlight(e)))))}get hasDecorations(){return this._renderPlugins.some((e=>e.isDecoration))}get hasOccludees(){return this._renderPlugins.some((e=>e.hasOccludees))}get hasEmissions(){return this._renderPlugins.some((e=>e.hasEmissions))}get renderOccludedFlags(){return this._renderPlugins.reduce(((e,t)=>e|t.renderOccludedFlags),o.None)}get usedMemory(){return this._renderPlugins.reduce(((e,t)=>t.material?e:e+(t.usedMemory??0)),0)}get test(){}}const h=[i.OPAQUE_MATERIAL,i.TRANSPARENT_MATERIAL,i.DRAPED_MATERIAL,i.HUD_MATERIAL,i.LABEL_MATERIAL];export{d as RenderPluginManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as r,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as l}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as a}from"../../../webgl.js";import{ColorFormat as g}from"../../../webgl/formats.js";import c from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as u}from"./HighlightApplyTechnique.js";import{HighlightDownsampleTechnique as m}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as p}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as d}from"./HighlightToSingleTechnique.js";import{SingleHighlightApplyTechnique as f}from"./SingleHighlightApplyTechnique.js";import{SingleHighlightBlurTechnique as b}from"./SingleHighlightBlurTechnique.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{Default3D as w}from"../../lib/DefaultVertexAttributeLocations.js";import{NoVertex as x}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as _}from"../../lib/VertexArrayObject.js";import{H as C,g as v}from"../../../../../chunks/HighlightDownsample.glsl.js";import{S as j}from"../../../../../chunks/SingleHighlightBlur.glsl.js";import{BufferObject as H}from"../../../../webgl/BufferObject.js";import{PixelFormat as q,TextureSamplingMode as P,FramebufferBit as R,Usage as D,TextureType as O,PrimitiveType as S,DataType as A}from"../../../../webgl/enums.js";import{Texture as E}from"../../../../webgl/Texture.js";import{TextureDescriptor as y}from"../../../../webgl/TextureDescriptor.js";let I=class extends c{constructor(){super(...arguments),this.produces=a.HIGHLIGHTS,this.consumes={required:[a.HIGHLIGHTS,"highlights"]},this._useMultipleHighlights=!1,this._downsampleDrawParameters=new C,this._passParameters=new p,this._singleHighlightBlurDrawParameters=new j,this._grid=new M}initialize(){this.addHandles([r((()=>this._updateOptionsTexture()),(()=>{}),s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=i(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new y(16,2);e.internalFormat=q.RGBA,e.samplingMode=P.NEAREST,this._passParameters.highlightOptionsTexture=new E(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(U(this.view.state.highlights)),this.requestRender(T.UPDATE)}precompile(){this.techniques.precompile(m),this._useMultipleHighlights?this.techniques.precompile(u):(this.techniques.precompile(d),this.techniques.precompile(b),this.techniques.precompile(f))}render(e){const t=e.find((({name:e})=>e===a.HIGHLIGHTS)),{techniques:i,bindParameters:r,_passParameters:s,renderingContext:o}=this;if(!r.decorations)return t;const h=i.get(m);if(!h.compiled)return this.requestRender(T.UPDATE),t;const l=e.find((({name:e})=>"highlights"===e)).getTexture(),n=()=>{this._gridUpdateResources(l);const e=this._gridComputeCoverage(h,l,r),{horizontalCellCount:t,verticalCellCount:i}=e;return s.horizontalCellCount=t,s.verticalCellCount=i,s.coverageTexture=e.coverage?.getTexture(),e},g=e=>{const t=e.verticalCellCount*e.horizontalCellCount;o.bindVAO(e.vao),o.drawElementsInstanced(S.TRIANGLES,6,A.UNSIGNED_BYTE,0,t)},{camera:c}=r,u=()=>{o.bindFramebuffer(t.fbo),o.setViewport4fv(c.fullViewport)};return this._useMultipleHighlights?this._renderMultiple(l,n,g,u):this._renderSingle(l,n,g,u),s.highlightTexture=null,s.coverageTexture=null,t}_renderMultiple(e,t,i,r){const{techniques:s,bindParameters:o,_passParameters:h,renderingContext:l}=this,n=s.get(u);if(!n.compiled)return void this.requestRender(T.UPDATE);const a=t();h.highlightTexture=e,h.pixelRatio=o.camera.pixelRatio,l.bindTechnique(n,o,h),r(),i(a)}_renderSingle(e,t,i,r){const{fboCache:s,techniques:o,bindParameters:h,_passParameters:n,renderingContext:a}=this,c=o.get(d),u=o.get(b),m=o.get(f);if(!m.compiled||!u.compiled||!c.compiled)return void this.requestRender(T.UPDATE);const p=t(),{width:w,height:x}=e.descriptor;n.highlightTexture=e;const{camera:_}=h,{fullWidth:C,fullHeight:v,pixelRatio:j}=_,H=Math.ceil(C/j),q=Math.ceil(v/j),{_singleHighlightBlurDrawParameters:P}=this,D=this.view._stage.renderView.renderer,{highlights:O}=h;for(let d=0;d<O.length;++d){const{name:e}=O[d];if(!D.
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as r,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as l}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as a}from"../../../webgl.js";import{ColorFormat as g}from"../../../webgl/formats.js";import c from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as u}from"./HighlightApplyTechnique.js";import{HighlightDownsampleTechnique as m}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as p}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as d}from"./HighlightToSingleTechnique.js";import{SingleHighlightApplyTechnique as f}from"./SingleHighlightApplyTechnique.js";import{SingleHighlightBlurTechnique as b}from"./SingleHighlightBlurTechnique.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{Default3D as w}from"../../lib/DefaultVertexAttributeLocations.js";import{NoVertex as x}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as _}from"../../lib/VertexArrayObject.js";import{H as C,g as v}from"../../../../../chunks/HighlightDownsample.glsl.js";import{S as j}from"../../../../../chunks/SingleHighlightBlur.glsl.js";import{BufferObject as H}from"../../../../webgl/BufferObject.js";import{PixelFormat as q,TextureSamplingMode as P,FramebufferBit as R,Usage as D,TextureType as O,PrimitiveType as S,DataType as A}from"../../../../webgl/enums.js";import{Texture as E}from"../../../../webgl/Texture.js";import{TextureDescriptor as y}from"../../../../webgl/TextureDescriptor.js";let I=class extends c{constructor(){super(...arguments),this.produces=a.HIGHLIGHTS,this.consumes={required:[a.HIGHLIGHTS,"highlights"]},this._useMultipleHighlights=!1,this._downsampleDrawParameters=new C,this._passParameters=new p,this._singleHighlightBlurDrawParameters=new j,this._grid=new M}initialize(){this.addHandles([r((()=>this._updateOptionsTexture()),(()=>{}),s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=i(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new y(16,2);e.internalFormat=q.RGBA,e.samplingMode=P.NEAREST,this._passParameters.highlightOptionsTexture=new E(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(U(this.view.state.highlights)),this.requestRender(T.UPDATE)}precompile(){this.techniques.precompile(m),this._useMultipleHighlights?this.techniques.precompile(u):(this.techniques.precompile(d),this.techniques.precompile(b),this.techniques.precompile(f))}render(e){const t=e.find((({name:e})=>e===a.HIGHLIGHTS)),{techniques:i,bindParameters:r,_passParameters:s,renderingContext:o}=this;if(!r.decorations)return t;const h=i.get(m);if(!h.compiled)return this.requestRender(T.UPDATE),t;const l=e.find((({name:e})=>"highlights"===e)).getTexture(),n=()=>{this._gridUpdateResources(l);const e=this._gridComputeCoverage(h,l,r),{horizontalCellCount:t,verticalCellCount:i}=e;return s.horizontalCellCount=t,s.verticalCellCount=i,s.coverageTexture=e.coverage?.getTexture(),e},g=e=>{const t=e.verticalCellCount*e.horizontalCellCount;o.bindVAO(e.vao),o.drawElementsInstanced(S.TRIANGLES,6,A.UNSIGNED_BYTE,0,t)},{camera:c}=r,u=()=>{o.bindFramebuffer(t.fbo),o.setViewport4fv(c.fullViewport)};return this._useMultipleHighlights?this._renderMultiple(l,n,g,u):this._renderSingle(l,n,g,u),s.highlightTexture=null,s.coverageTexture=null,t}_renderMultiple(e,t,i,r){const{techniques:s,bindParameters:o,_passParameters:h,renderingContext:l}=this,n=s.get(u);if(!n.compiled)return void this.requestRender(T.UPDATE);const a=t();h.highlightTexture=e,h.pixelRatio=o.camera.pixelRatio,l.bindTechnique(n,o,h),r(),i(a)}_renderSingle(e,t,i,r){const{fboCache:s,techniques:o,bindParameters:h,_passParameters:n,renderingContext:a}=this,c=o.get(d),u=o.get(b),m=o.get(f);if(!m.compiled||!u.compiled||!c.compiled)return void this.requestRender(T.UPDATE);const p=t(),{width:w,height:x}=e.descriptor;n.highlightTexture=e;const{camera:_}=h,{fullWidth:C,fullHeight:v,pixelRatio:j}=_,H=Math.ceil(C/j),q=Math.ceil(v/j),{_singleHighlightBlurDrawParameters:P}=this,D=this.view._stage.renderView.renderer,{highlights:O}=h;for(let d=0;d<O.length;++d){const{name:e}=O[d];if(!D.hasHighlight(e))continue;n.highlightLevel=d,a.setClearColor(0,0,0,0);const t=s.acquire(w,x,"single highlight",g.RG);a.bindFramebuffer(t.fbo),a.setViewport(0,0,w,x),a.clear(R.COLOR),a.bindTechnique(c,h,n),i(p),P.blurInput=t.getTexture(),l(P.blurSize,1/H,0);const o=s.acquire(H,q,"single highlight blur h",g.RG);a.unbindTexture(o.fbo?.colorTexture),a.bindFramebuffer(o.fbo),a.setViewport(0,0,H,q),a.clear(R.COLOR),a.bindTechnique(u,h,n,P),i(p),t.release(),l(P.blurSize,0,1/q),n.singleHighlightBlurTexture=o.getTexture(),r(),a.bindTechnique(m,h,n,P),i(p),o.release()}}_gridUpdateResources(e){const t=this._grid,{width:i,height:r}=e.descriptor;if(t.horizontalCellCount=Math.ceil(i/v),t.verticalCellCount=Math.ceil(r/v),t.vao)return;const s=this.renderingContext,o=H.createIndex(s,D.STATIC_DRAW,F);t.vao=new _(s,w,new Map([["geometry",x]]),new Map([["geometry",H.createVertex(s,D.STATIC_DRAW)]]),o)}_gridComputeCoverage(e,t,i){const r=this.renderingContext,s=this._grid,o=t.descriptor,h=Math.ceil(o.width/v),l=Math.ceil(o.height/v);this._downsampleDrawParameters.input=t,s.coverage?.release();const n=this.fboCache.acquire(h,l,"highlight coverage",g.RG);return s.coverage=n,r.bindFramebuffer(n.fbo),r.bindTechnique(e,i,this._passParameters,this._downsampleDrawParameters),r.setViewport(0,0,h,l),r.screen.draw(),s}get test(){}};e([o()],I.prototype,"produces",void 0),e([o()],I.prototype,"consumes",void 0),I=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],I);class M{constructor(){this.coverage=null,this.vao=null,this.verticalCellCount=0,this.horizontalCellCount=0,this.viewportWidth=0,this.viewportHeight=0}}function U(e){const t=new Uint8Array(128);let i=0;for(const r of e){const e=4*i,s=4*i+64;++i;const{color:o}=r,h=r.haloColor??o;t[e+0]=o.r,t[e+1]=o.g,t[e+2]=o.b,t[e+3]=r.fillOpacity*o.a*255,t[s+0]=h.r,t[s+1]=h.g,t[s+2]=h.b,t[s+3]=r.haloOpacity*h.a*255}return t}let G=0;function L(e){let t=0;for(const r of e){const{name:e}=r;t+=e.length;const{color:i,fillOpacity:s,haloColor:o,haloOpacity:h}=r;t+=i.r+i.g+i.b+i.a+s,t+=o?o.r+o.g+o.b+o.a+h:0}const i=e.at(0);if(i){const{shadowOpacity:e,shadowDifference:r,shadowColor:s}=i;t+=e+r+s.r+s.g+s.b+s.a}return G+++(t>=0?0:1)}const F=new Uint8Array([0,1,2,2,1,3]);function V(e,t,i,r,s,o=0){const h=r.highlights,a=h.length>1?t.acquire(i.width,i.height,"highlight mix",g.RG):null;if(a){const t=e.getBoundFramebufferObject();e.bindFramebuffer(a.fbo),e.clearFramebuffer(n),e.bindFramebuffer(t)}const c=a?.getTexture();r.highlightMixTexture=c,l(r.highlightMixOrigin,o,0),h.forEach(((t,h)=>{h>0&&(e.bindTexture(c,E.TEXTURE_UNIT_FOR_UPDATES),e.gl.copyTexSubImage2D(O.TEXTURE_2D,0,0,0,o,0,i.width,i.height),e.bindTexture(null,E.TEXTURE_UNIT_FOR_UPDATES)),e.clear(R.DEPTH),r.highlightLevel=h,s()})),r.highlightLevel=null,r.highlightMixTexture=null,a?.release()}export{I as Highlight,V as renderHighlightBuffer,L as trackHighlightOptions};
|