@arcgis/core 4.31.0-next.20240607 → 4.31.0-next.20240610
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/README.md +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/06ea3bb071a83a54f1b2.js +1 -0
- package/assets/esri/core/workers/chunks/{fa5e171c8ce844363b6c.js → 465c718f0b9f7ba0f1ea.js} +1 -1
- package/assets/esri/core/workers/chunks/{342426c8a8c9f5f84811.js → 491f402da260293592ff.js} +1 -1
- package/assets/esri/core/workers/chunks/4e2943968517e385bd12.js +1 -0
- package/assets/esri/core/workers/chunks/5f3600a6d7159228731d.js +1 -0
- package/assets/esri/core/workers/chunks/77a360d1c9ecce4d4bed.js +1 -0
- package/assets/esri/core/workers/chunks/ace3297f0f314c3724da.js +1 -0
- package/assets/esri/core/workers/chunks/c660649465058ef82045.js +1 -0
- package/assets/esri/core/workers/chunks/{6a943f384fcd0af5888b.js → e66ebcfffd081f847efe.js} +1 -1
- package/assets/esri/core/workers/chunks/ec06875eac992c640057.js +1 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
- package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +8 -0
- package/assets/esri/themes/base/widgets/_CatalogLayerList.scss +8 -0
- package/assets/esri/themes/base/widgets/_LayerList.scss +8 -0
- package/assets/esri/themes/base/widgets/_Print.scss +12 -0
- package/assets/esri/themes/base/widgets/_TableList.scss +8 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/Terrain.glsl.js +3 -1
- package/chunks/lyr3DWorker.js +1 -1
- package/interfaces.d.ts +152 -32
- package/layers/CatalogLayer.js +1 -1
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/MapImageLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/arcgisLayers.js +1 -1
- package/package.json +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/featureFlags.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/styleUtils.js +1 -1
- package/views/2d/engine/webgl/mesh/bufcut.js +1 -1
- package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
- package/views/3d/analysis/Viewshed/ScaleOrientManipulation.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/interactive/editingTools/manipulatorUtils.js +1 -1
- package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +1 -1
- package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerView3D.js +1 -1
- package/views/3d/layers/TiledLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/featureTileQuery3D.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/lib/PathGeometryData.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/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/webdoc/support/webdocSaveUtils.js +1 -1
- package/webscene/support/schemaValidator.js +1 -1
- package/widgets/BasemapLayerList/css.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/CatalogLayerList/css.js +1 -1
- package/widgets/CatalogLayerList.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
- package/widgets/FeatureTable/RelationshipColumn.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable/support/tableUtils.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/Fullscreen.js +1 -1
- package/widgets/LayerList/css.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Locate.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/TableList/css.js +1 -1
- package/widgets/TableList.js +1 -1
- package/widgets/Track.js +1 -1
- package/assets/esri/core/workers/chunks/230429bc1be19dd4944b.js +0 -1
- package/assets/esri/core/workers/chunks/441f3eaef3b703dd1026.js +0 -1
- package/assets/esri/core/workers/chunks/4d7578131569e65caedc.js +0 -1
- package/assets/esri/core/workers/chunks/4faf7055457c04dc9fc1.js +0 -1
- package/assets/esri/core/workers/chunks/ba988cd3a49987a0fb83.js +0 -1
- package/assets/esri/core/workers/chunks/c70683b7183458b338f8.js +0 -1
- package/assets/esri/core/workers/chunks/d03ada1212b13e76bff4.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{destroyMaybe as t}from"../../../../core/maybe.js";import{throwIfAborted as s,createAbortError as o}from"../../../../core/promiseUtils.js";import{difference as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{destroyMaybe as t}from"../../../../core/maybe.js";import{throwIfAborted as s,createAbortError as o}from"../../../../core/promiseUtils.js";import{difference as i}from"../../../../core/SetUtils.js";import{property as u}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromFeatureSetJSON as l}from"../../../../layers/graphics/dehydratedFeatures.js";import{runQuery as n,executeQuery as y}from"../../../../rest/query/operations/query.js";import{PBFDecoder as c}from"../../support/PBFDecoder.js";let p=class extends r{constructor(e){super(e)}get implicitFields(){const e=this.layer.outFields?.includes("*");if(!e)return new Set;const r=new Set(this.layerView.requiredFields),t=new Set(this.layerView.availableFields);return i(t,r)}get queryFeaturesDehydrated(){const{layer:e}=this,r=e.capabilities,t=r&&r.query,i=t&&t.supportsFormatPBF,u=e.parsedUrl;if(i){null==this._decoder&&(this._decoder=new c(this.controller));const r={sourceSpatialReference:e.spatialReference?.toJSON()??null,applyTransform:!0,maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:f};return(e,t)=>n(u,e,"pbf",this._createRequestOptions(t)).then((e=>(s(t),null!=this._decoder?this._decoder.invoke({buffer:e.data,options:r},t.signal):Promise.reject(o()))))}return(r,t)=>y(u,r,e.spatialReference,this._createRequestOptions(t)).then((e=>l(e.data,{maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:f})))}queryFeatureCount(e,r){return this.layer.queryFeatureCount(e,r)}destroy(){this._decoder=t(this._decoder)}_createRequestOptions(e){return{...e,query:{...this.layer.customParameters,token:this.layer.apiKey,...e?.query}}}};e([u({constructOnly:!0})],p.prototype,"layer",void 0),e([u({constructOnly:!0})],p.prototype,"layerView",void 0),e([u({constructOnly:!0})],p.prototype,"controller",void 0),e([u({readOnly:!0})],p.prototype,"implicitFields",null),e([u({readOnly:!0})],p.prototype,"queryFeaturesDehydrated",null),p=e([a("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileServiceQuery3D")],p);let d=class extends r{constructor(e){super(e)}queryFeaturesDehydrated(e,r){return this.layer.queryFeatures(e,r)}};e([u({constructOnly:!0})],d.prototype,"layer",void 0),d=e([a("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileOGCServiceQuery3D")],d);let m=class extends r{constructor(e){super(e)}queryFeaturesDehydrated(e,r){return this.source.queryFeaturesJSON(e,r).then(l,(t=>{if(t&&"query-features-json:unsupported"===t.name)return this.layer.queryFeatures(e,r);throw t}))}queryFeatureCount(e,r){return this.layer.queryFeatureCount(e,r)}};function h(e,r){const{layer:t}=e;return"feature"===t.type&&"feature-layer"===t.source.type||"catalog-footprint"===t.type?new p({layer:t,layerView:e,controller:r}):"feature"===t.type&&"memory"===t.source.type||"csv"===t.type||"geojson"===t.type||"oriented-imagery"===t.type||"wfs"===t.type?new m({layer:t,source:t.source}):"ogc-feature"===t.type?new d({layer:t}):null}e([u({constructOnly:!0})],m.prototype,"layer",void 0),e([u({constructOnly:!0})],m.prototype,"source",void 0),m=e([a("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileClientQuery3D")],m);const f=1024;export{h as createFeatureTileQuery3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{lerp as
|
|
5
|
+
import{lerp as t,clamp as e}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as i}from"../../../core/unitUtils.js";import{f as r,n as s,m as n,l as a}from"../../../chunks/vec32.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as o}from"../../../geometry/ellipsoidUtils.js";import h from"../../../geometry/Extent.js";import{ViewingMode as l}from"../../ViewingMode.js";import{computeInnerAltitudeFade as x}from"../environment/atmosphereUtils.js";function c(t,e,i){return t===l.Global?new M(i):new u(e,i)}class u{constructor(t,e){this._elevationProvider=t,this._referenceEllipsoid=o(e),this._unitInMeters=i(e,this._referenceEllipsoid.metersPerDegree)}compute(i,a,m,o,l){l||(l={near:0,far:0});let x=i[2]*this._unitInMeters;const c=x,u=x-o,M=this._elevationProvider?.visibleElevationBounds;M&&(x=u>=0?c-this._unitInMeters*M.min:this._unitInMeters*M.max-c);const _={x:(m=null!=m?m:new h({xmin:0,ymin:0,zmin:0,xmax:0,ymax:0,zmax:0})).xmax-m.xmin,y:m.ymax-m.ymin,z:4*Math.max(m.xmax-m.xmin,m.ymax-m.ymin)},I=Math.max(_.x,_.y,_.z);r(E,a,i),v[0]=E[0]>0?m.xmax:m.xmin,v[1]=E[1]>0?m.ymax:m.ymin,v[2]=E[2]>0?I/2:-I/2,r(v,v,i),s(E,E);const j=1.1*n(v,E)*this._unitInMeters,g=Math.sqrt(x*(x+2*this._referenceEllipsoid.radius)),b=Math.max(m.xmax-m.xmin,m.ymax-m.ymin),w=b*d*this._unitInMeters,z=b*y*this._unitInMeters,U=e((x-z)/(w-z),0,1)**3,P=Math.min(t(g,j,U),g)*Math.max(Math.log(Math.abs(u)),1);return f(Math.min(P,Math.max(34064e4,I))/this._unitInMeters,p,this._unitInMeters,l)}}class M{constructor(t){this._referenceEllipsoid=o(t)}compute(i,r,s,n,m){m||(m={near:0,far:0});const o=a(i),h=o-this._referenceEllipsoid.radius,l=this._referenceEllipsoid.radius+Math.min(0,n),c=Math.abs(h-n),u=Math.max(c,Math.abs(h)),M=Math.sqrt(u*(u+2*l)),p=o+this._referenceEllipsoid.radius;return f(1.2*t(M,p,x(u)),e(2e4-(Math.log(u)-7.983)/9.011*19900,100,2e4),1,m)}}function f(t,e,i,r){const s=_/i;return t/e>s?(r.far=t,r.near=r.far/e):(r.near=s,r.far=r.near*e),r}const p=2e4,_=2,d=.001,y=1e-4,v=m(),E=m();export{c as createNearFarHeuristic};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as a}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{s as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as f,DrapeSourceType as R,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as v}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import S from"../webgl/RenderCamera.js";import{ShaderOutput as C}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as P}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as E}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as j}from"../webgl-engine/effects/RenderPlugin.js";import{GLMaterialRepository as M}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as W}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as A}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as F,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as q}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as I}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as V}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as k}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as U}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as H}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as G}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{ClearBufferBit as J,TextureSamplingMode as K}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends j{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 o,this._passParameters=new O,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new S,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[q.DRAPED_MATERIAL,e=>e!==C.Highlight||this.hasHighlights],[q.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextures:t,stippleTextures:s,markerTextures:i}=r;this._techniques=new E({rctx:this._rctx,viewingMode:y.Local,stippleTextures:s,markerTextures:i,waterTextures:t}),this._renderContext=new F(this._rctx,new I(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),h),n((()=>this.spatialReference),(e=>this._localOriginFactory=new W(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materials=new M(r.textures,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=q.DRAPED_MATERIAL,this._bindParameters.mainDepth=null,this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=U.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new G(g(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(Y.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._techniques=a(this._techniques),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMemoryForMaterial(e){return Array.from(this._renderers.values()).reduce(((r,t)=>r+t.getMemoryForMaterial(e)),0)}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,V)}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===f.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===R.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===R.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.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(v.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()&&(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"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===H.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==v.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?P.Disabled:this._renderTargets?.getTexture(v.WaterNormal)?P.EnabledWithWater:this._renderTargets?.getTexture(v.Color)?P.Enabled:P.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets){if(r.content===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const t=this._drawTarget(w.INNER,r,e),s=this._drawTarget(w.OUTER,r,e);(t||s)&&r.fbo.generateMipMap()}}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return!1;const{alignPixelEnabled:a,contentPixelRatio:o}=t;this._screenToWorldRatio=o*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===C.Highlight&&!this.hasHighlights||n===C.Normal&&!this.hasWater||!s.hasSomeSizedView())return!1;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*o,this._renderContext.output=n,this._bindParameters.alignPixelEnabled=a,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=n===C.Normal?q.DRAPED_WATER:q.DRAPED_MATERIAL,r.content===v.Occluded&&(this._renderContext.renderOccludedMask=se),!this.renders(r.content))return this._renderContext.renderOccludedMask=L,!1;const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clear(J.COLOR_BUFFER_BIT));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==v.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,re[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();return this._sortedRenderers.forAll((({drapeSource:t,renderer:a})=>{if(r.content===v.ColorNoRasterImage&&t.drapeSourceType===R.RasterImage)return;const{fullOpacity:o}=t,d=null!=o&&o<1&&n===C.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),a.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniques.acquire(z);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),this._renderContext.renderOccludedMask=L,!0}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(e,r,"overlay tmp");return t.rctx.unbindTexture(s.fbo?.colorTexture),t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(J.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._techniques.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:a}of this._sortedRenderers)i=a.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),a=i>=0,o=s.renderGroup??(a?T.MapLayer:T.ViewLayer),n=r*o+(a?i:0);this._sortedRenderers.push(new ee(s,t,n))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(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 o=0;o<e;o++)for(let r=0;r<e;r++){const i=Math.floor(r/10),a=Math.floor(o/10);i<2||a<2||10*i>e-20||10*a>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&a?1&r^1&o?0:255:1&i^1&a?0:128)}const i=new Z(e);i.samplingMode=K.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t);const a=new k;a.hasAlpha=!0,this._debugTextureTechnique=this._techniques.acquire(N,a)}get test(){}};e([c()],$.prototype,"hasHighlights",void 0),e([c()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c()],$.prototype,"_techniques",void 0),e([c({constructOnly:!0})],$.prototype,"view",void 0),e([c()],$.prototype,"worldToPCSRatio",void 0),e([c()],$.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([c()],$.prototype,"isEmpty",null),e([c({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([u("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=A.OccludeAndTransparent;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{releaseMaybe as s,disposeMaybe as i,destroyMaybe as a}from"../../../core/maybe.js";import n from"../../../core/PooledArray.js";import{watch as o,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{s as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as f,DrapeSourceType as R,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as v}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import S from"../webgl/RenderCamera.js";import{ShaderOutput as C}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as P}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as E}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as j}from"../webgl-engine/effects/RenderPlugin.js";import{GLMaterialRepository as W}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as A}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as F,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as q}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as I}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as V}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as k}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as U}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as H}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as G}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{ClearBufferBit as J,TextureSamplingMode as K}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends j{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 n,this._passParameters=new O,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new S,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[q.DRAPED_MATERIAL,e=>e!==C.Highlight||this.hasHighlights],[q.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextures:t,stippleTextures:s,markerTextures:i}=r;this._techniques=new E({rctx:this._rctx,viewingMode:y.Local,stippleTextures:s,markerTextures:i,waterTextures:t}),this._renderContext=new F(this._rctx,new I(e,this.view.state.viewingMode),null),this.addHandles([o((()=>t.updating),(()=>this.events.emit("content-changed")),h),o((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materials=new W(r.textures,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=q.DRAPED_MATERIAL,this._bindParameters.mainDepth=null,this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=U.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new G(g(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(Y.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._techniques=a(this._techniques),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}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))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,V)}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(o((()=>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===f.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===R.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===R.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.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(v.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()&&(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"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===H.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==v.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?P.Disabled:this._renderTargets?.getTexture(v.WaterNormal)?P.EnabledWithWater:this._renderTargets?.getTexture(v.Color)?P.Enabled:P.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets){if(r.content===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const t=this._drawTarget(w.INNER,r,e),s=this._drawTarget(w.OUTER,r,e);(t||s)&&r.fbo.generateMipMap()}}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return!1;const{alignPixelEnabled:a,contentPixelRatio:n}=t;this._screenToWorldRatio=n*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const o=r.output;if(this.isEmpty||o===C.Highlight&&!this.hasHighlights||o===C.Normal&&!this.hasWater||!s.hasSomeSizedView())return!1;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*n,this._renderContext.output=o,this._bindParameters.alignPixelEnabled=a,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=o===C.Normal?q.DRAPED_WATER:q.DRAPED_MATERIAL,r.content===v.Occluded&&(this._renderContext.renderOccludedMask=se),!this.renders(r.content))return this._renderContext.renderOccludedMask=L,!1;const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clear(J.COLOR_BUFFER_BIT));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==v.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,re[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();return this._sortedRenderers.forAll((({drapeSource:t,renderer:a})=>{if(r.content===v.ColorNoRasterImage&&t.drapeSourceType===R.RasterImage)return;const{fullOpacity:n}=t,d=null!=n&&n<1&&o===C.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),a.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.getTexture(),this._overlayParameters.opacity=n,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniques.acquire(z);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),this._renderContext.renderOccludedMask=L,!0}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(e,r,"overlay tmp");return t.rctx.unbindTexture(s.fbo?.colorTexture),t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(J.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._techniques.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:a}of this._sortedRenderers)i=a.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),a=i>=0,n=s.renderGroup??(a?T.MapLayer:T.ViewLayer),o=r*n+(a?i:0);this._sortedRenderers.push(new ee(s,t,o))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(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),a=Math.floor(n/10);i<2||a<2||10*i>e-20||10*a>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&a?1&r^1&n?0:255:1&i^1&a?0:128)}const i=new Z(e);i.samplingMode=K.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t);const a=new k;a.hasAlpha=!0,this._debugTextureTechnique=this._techniques.acquire(N,a)}get test(){}};e([c()],$.prototype,"hasHighlights",void 0),e([c()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c()],$.prototype,"_techniques",void 0),e([c({constructOnly:!0})],$.prototype,"view",void 0),e([c()],$.prototype,"worldToPCSRatio",void 0),e([c()],$.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([c()],$.prototype,"isEmpty",null),e([c({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([u("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=A.OccludeAndTransparent;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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Accessor.js";import{ShaderOutput as r}from"../core/shaderLibrary/ShaderOutput.js";const t={required:[]},
|
|
5
|
+
import e from"../../../../core/Accessor.js";import{ShaderOutput as r}from"../core/shaderLibrary/ShaderOutput.js";const t={required:[]},s={required:[r.Depth]};class n extends e{consumes(){return t}get usedMemory(){return 0}get isDecoration(){return!1}get running(){return!1}modify(e){}get numGeometries(){return 0}get hasOccludees(){return!1}queryRenderOccludedState(e){return!1}}class u extends n{}class c extends n{constructor(){super(...arguments),this.drapedPriority=0}}class o extends n{}class i extends n{}class d extends n{}function a(e){return"prepareTechnique"in e}function p(e){return"prepareTechniques"in e}export{d as ASyncPreparesRenderPlugin,i as AsyncRenderPlugin,s as ConsumesDepth,t as ConsumesNone,c as SyncPrepareRenderPlugin,o as SyncPreparesRenderPlugin,u as SyncRenderPlugin,a as isPrepareRenderPlugin,p as isPreparesRenderPlugin};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isPromiseLike as r,createAbortError as t}from"../../../../core/promiseUtils.js";import{signal as n}from"../../../../core/signal.js";import{ShaderOutput as s}from"../core/shaderLibrary/ShaderOutput.js";import{isPrepareRenderPlugin as
|
|
5
|
+
import"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isPromiseLike as r,createAbortError as t}from"../../../../core/promiseUtils.js";import{signal as n}from"../../../../core/signal.js";import{ShaderOutput as s}from"../core/shaderLibrary/ShaderOutput.js";import{isPrepareRenderPlugin as i,isPreparesRenderPlugin as o}from"./RenderPlugin.js";import{Decorations as l}from"../lib/basicInterfaces.js";import{union as a,DepthRange as d}from"../lib/depthRange.js";import{RenderOccludedFlag as u}from"../lib/Material.js";import{RenderSlot as h}from"../lib/RenderSlot.js";class c{constructor(r){this._context=r,this._renderPlugins=new e,this._materialRenderers=new Map,this._slots=new Array,this._renderVersion=n(0);for(let e=0;e<h.MAX_SLOTS;++e)this._slots[e]=[]}destroy(){this._renderPlugins.forEach((e=>e.destroy())),this._renderPlugins.clear(),this._materialRenderers.clear()}get plugins(){return this._renderPlugins}add(e,n){const s=()=>{if(n?.aborted)throw e.uninitializeRenderContext(),t();this._renderPlugins.push(e),e.material&&this._materialRenderers.set(e.material,e),e.produces.forEach(((r,t)=>{this._slots[t].push(e)})),this._context.requestRender(),this._renderVersion.value++},i=e.initializeRenderContext(this._context,n);if(r(i))return i.then(s);s()}remove(e){if(null!=e.material&&this._materialRenderers.delete(e.material),null!=this._renderPlugins.removeUnordered(e)){for(let r=0;r<this._slots.length;++r)this._slots[r]=this._slots[r].filter((r=>r!==e));e.uninitializeRenderContext(),this._context.requestRender(),this._renderVersion.value++}}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this._context.renderContext)}))}updateAnimation(e){let r=!1;return this._renderPlugins.forAll((t=>{t.updateAnimation&&(r=t.updateAnimation(e)||r)})),r}renderFeatureChanged(){this._renderPlugins.forAll((e=>{e.renderFeatureChanged&&e.renderFeatureChanged()}))}prepare(...e){for(const r of e)this._context.renderContext.bindParameters.slot=r,this._slots[r].forEach((e=>{const t=e.produces.get(r);t?.(s.Color)&&(i(e)&&e.prepareTechnique(this._context.renderContext),o(e)&&e.prepareTechniques(this._context.renderContext))}))}_getRenderables(){const e=this._context.renderContext.bindParameters.slot,r=this._context.renderContext.output??s.Color,t=new Map;return this._slots[e].forEach((n=>{const s=n.produces.get(e);if(s?.(r)&&(!n.isDecoration||this._context.renderContext.bindParameters.decorations!==l.OFF))if(i(n)){const e=n.prepareTechnique(this._context.renderContext);null!=e&&t.set(n,e)}else if(o(n)){const e=n.prepareTechniques(this._context.renderContext);null!=e&&t.set(n,e)}else t.set(n,null)})),t}render(e,...r){for(const t of r)this._context.renderContext.bindParameters.slot=t,this._getRenderables().forEach(((r,t)=>t.renderNode(this._context.renderContext,r,e)))}queryDepthRange(e){const r=new d;return this._renderPlugins.forAll((t=>{const n=t.queryDepthRange?.(e);a(r,n)})),r}get updating(){return this._renderVersion.value>=0&&this._renderPlugins.some((e=>e.running))}produces(e,...r){for(const t of r)if(this._slots[t].some((r=>{const n=r.produces.get(t);return!!n&&n(e)})))return!0;return!1}consumes(e){return this._renderPlugins.some((r=>r.consumes().required.includes(e)))}getMaterialRenderer(e){return this._materialRenderers.get(e)}removeEmptyMaterialRenderers(){this._renderPlugins.filterInPlace((e=>!e.material||0!==e.numGeometries||(this._materialRenderers.delete(e.material),e.destroy(),!1)))}get hasDecorations(){return this._renderPlugins.some((e=>e.isDecoration))}get hasOccludees(){return this._renderPlugins.some((e=>e.hasOccludees))}get renderOccludedFlags(){return this._renderPlugins.reduce(((e,r)=>e|r.renderOccludedFlags),u.None)}get usedMemory(){return this._renderPlugins.reduce(((e,r)=>null!==r.material?e:e+(r.usedMemory??0)),0)}get test(){}}export{c 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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ZEROS as t}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorFormat as n}from"../../../webgl/formats.js";import i from"../../../webgl/RenderNode.js";import{alphaCutoff as s}from"../../core/shaderLibrary/util/AlphaCutoff.js";import{glsl as a}from"../../core/shaderModules/interfaces.js";import{Default3D as c}from"../../lib/DefaultVertexAttributeLocations.js";import{ClearBufferBit as l,ColorAttachment as u,BlendFactor as p,SizedPixelFormat as d,PixelFormat as f,DataType as h}from"../../../../webgl/enums.js";let m=class extends i{constructor(e){super(e),this.destroyedCB=null,this.produces="composite-color",this.consumes={required:["composite-color"]},this.clearColor=t,this._focusedFBOType=0,this._program=new Array}destroy(){this._program.forEach((e=>e.dispose())),this._program.length=0,this.destroyedCB()}render(e){const r=e.find((({name:e})=>"final-color"===e));if(!this._focusedFBO)return r;const o=this.renderingContext;o.bindFramebuffer(r.fbo),o.setClearColor(0,0,0,0),o.clear(l.COLOR_BUFFER_BIT);const t=this._ensureShader(o,!1);return o.useProgram(t),o.bindTexture(this._focusedFBO.getTexture(),0),t.setUniform1i("colorTex",0),t.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&t.setUniform2fv("nearFar",this.camera.nearFar),o.screen.draw(),r}getReplacingFBO(e,r,o,t,i){r===T.ON&&(t=e.width,i=e.height);const s=this.renderingContext,a=e.depthStencilTexture,c=this._ensureShader(s,null!=a),f=this.fboCache.acquire(t,i,"fbo visualizer"),h=!e.colorTexture?.descriptor.hasMipmap;h&&e.colorTexture?.generateMipmap(),s.useProgram(c),s.unbindTexture(f.fbo?.colorTexture),s.bindFramebuffer(f.fbo),a&&(s.bindTexture(a,1),c.setUniform1i("depthTex",1),f.acquireColor(u.COLOR_ATTACHMENT1,n.RGBA),s.gl.drawBuffers([u.COLOR_ATTACHMENT0,u.COLOR_ATTACHMENT1]));const m=s.getViewport();s.setViewport(0,0,t,i),s.setClearColor(0,0,0,0),s.clear(l.COLOR_BUFFER_BIT),s.setBlendingEnabled(!0),s.setBlendFunction(p.ONE,p.ONE_MINUS_SRC_ALPHA),s.bindTexture(e.colorTexture,0),c.setUniform1i("colorTex",0);const v="linear-depth"===o||o.includes("shadow"),F=e.colorTexture?.descriptor.internalFormat,g=v?3:F===d.R16F||F===d.R32F||F===d.R8?1:F===d.RG8?2:F===d.RGBA16F?4:0;return c.setUniform1i("inputType",g),v&&c.setUniform2fv("nearFar",this.camera.nearFar),s.screen.draw(),s.gl.drawBuffers([u.COLOR_ATTACHMENT0]),s.bindFramebuffer(null),s.setViewport(m.x,m.y,m.width,m.height),r===T.ON&&(this._focusedFBO=f,this._focusedFBOType=g),h&&e.colorTexture?.clearMipmap(),f}clearFocusedFBO(){this._focusedFBO=null}getPreviewContent(e,r,o,t){if(!o)return null;const n=this.renderingContext,i=this.fboCache.acquire(e,r,"fbo visualizer");n.bindFramebuffer(i?.fbo),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(l.COLOR_BUFFER_BIT),n.setBlendingEnabled(!0),n.setBlendFunction(p.ONE,p.ONE_MINUS_SRC_ALPHA),n.setViewport(0,0,e,r);const s=this._ensureShader(n,!1);n.useProgram(s),n.bindTexture(o.getColorTexture(t),0),s.setUniform1i("colorTex",0),s.setUniform1i("inputType",0),n.screen.draw();const a=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,f.RGBA,h.UNSIGNED_BYTE,new Uint8Array(a.data.buffer)),n.bindFramebuffer(null),i?.release(),a}_ensureShader(e,r){const o=r?1:0;if(this._program[o])return this._program[o];const t="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",n=`#version 300 es\n precision highp float;\n\n in vec2 uv;\n uniform sampler2D colorTex;\n layout(location = 0) out vec4 fragColor;\n ${r?"\n layout(location = 1) out vec4 fragDepth;\n uniform sampler2D depthTex;\n ":""}\n uniform int inputType;\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgba2float(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgba2float(depth));\n }\n\n float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }\n\n void main() {\n vec4 color;\n if(inputType == 1) {\n color = vec4(vec3(texture(colorTex, uv).r), 1.0);\n } else if(inputType == 2) {\n color = vec4(texture(colorTex, uv).rg, 0.0, 1.0);\n } else if(inputType == 3) {\n float depth = 1.0 - (-linearDepthFromTexture(colorTex, uv) / (nearFar[1] - nearFar[0]));\n color = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if(inputType == 4) {\n color = texture(colorTex, uv);\n color = vec4(color.rgb / color.a, color.a);\n } else {\n color = texture(colorTex, uv);\n }\n\n\n if(color.a < ${a.float(s)})\n discard;\n else {\n fragColor = color;\n ${r?"\n float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);\n ":""}\n }\n }`;return this._program[o]=e.programCache.acquire(t,n,c),this._program[o]}};var T;e([r()],m.prototype,"destroyedCB",void 0),e([r()],m.prototype,"produces",void 0),e([r()],m.prototype,"consumes",void 0),e([r()],m.prototype,"clearColor",void 0),m=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],m),function(e){e[e.ON=0]="ON",e[e.OFF=1]="OFF"}(T||(T={}));export{T as FocusState,m as RenderNodeVisualizerNode};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{set as t,length as e,normalize as r,dot as i,scale as s,add as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as n,b as h}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newFloatArray as u}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as b}from"../../../../geometry/support/Indices.js";import{Attribute as v,Vertices as m}from"./Attribute.js";import{compressNormal as p}from"./Normals.js";import{intersectTriangles as x}from"./RayIntersections.js";import{VertexAttribute as A}from"./VertexAttribute.js";class d{constructor(t){this.builder=t}onPathChanged(t){this.builder.onPathChanged()}}class f extends d{constructor(t){super(t),this.vertexAttributeColor=c(255,255,255,255),this.size=new Array,this.vertexAttributePosition=u(3*this.builder.numVerticesTotal),this.vertexAttributeNormal=new Int16Array(2*this.builder.numVerticesTotal)}bakeVertexColors(t){this.vertexAttributeColor[0]=255*t[0],this.vertexAttributeColor[1]=255*t[1],this.vertexAttributeColor[2]=255*t[2],this.vertexAttributeColor[3]=255*(t.length>3?t[3]:1)}bake(a){this.size=a;const{numVerticesTotal:l,pathVertexData:c,path:u,positions:b,profileRightAxes:v,profileUpAxes:m,profileVertexAndNormals:x}=this.builder;for(let A=0;A<l;++A){let l=c[A];const d=0===l||l===u.vertices.length-1;l*=3;const f=V;let g=0,D=0;const N=4*A,j=n(R,v[N],v[N+1],v[N+2]),E=n(w,m[N],m[N+1],m[N+2]),y=t(P,x[N]*a[0],x[N+1]*a[1]);if(d)h(f,E,j),g=v[N+3]*a[0],D=m[N+3];else{const a=I,h=C;t(a,v[N+3],m[N+3]);const l=e(a);r(a,a);const c=i(y,a);if(Math.abs(c)>l){t(h,-a[1],a[0]);const e=i(y,h);s(a,a,l*Math.sign(c)),s(h,h,e),o(y,a,h)}n(f,0,0,0)}const T=n(O,j[0]*y[0]+E[0]*y[1],j[1]*y[0]+E[1]*y[1],j[2]*y[0]+E[2]*y[1]),L=3*A;this.vertexAttributePosition[L]=b[l]+T[0]+f[0]*g,this.vertexAttributePosition[L+1]=b[l+1]+T[1]+f[1]*g,this.vertexAttributePosition[L+2]=b[l+2]+T[2]+f[2]*g;const M=t(P,x[N+2],x[N+3]);p(this.vertexAttributeNormal,A,j[0]*M[0]+E[0]*M[1]+f[0]*D,j[1]*M[0]+E[1]*M[1]+f[1]*D,j[2]*M[0]+E[2]*M[1]+f[2]*D)}}createGeometryData(){const t=this.builder.vertexIndices.length,{normalIndices:e,vertexIndices:r}=this.builder;return[[A.POSITION,new v(this.vertexAttributePosition,r,3,!0)],[A.NORMALCOMPRESSED,new v(this.vertexAttributeNormal,e,2,!0)],[A.COLOR,new v(this.vertexAttributeColor,b(t),4)]]}onPathChanged(t){super.onPathChanged(t),this.bake(this.size)}intersect(t,e,r,i){const s=this.builder.vertexIndices,o=new m(this.vertexAttributePosition,3),a=s.length/3;x(t,e,0,a,s,o,void 0,r,((t,e,r)=>
|
|
5
|
+
import{set as t,length as e,normalize as r,dot as i,scale as s,add as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as n,b as h}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newFloatArray as u}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as b}from"../../../../geometry/support/Indices.js";import{Attribute as v,Vertices as m}from"./Attribute.js";import{compressNormal as p}from"./Normals.js";import{intersectTriangles as x}from"./RayIntersections.js";import{VertexAttribute as A}from"./VertexAttribute.js";class d{constructor(t){this.builder=t}onPathChanged(t){this.builder.onPathChanged()}}class f extends d{constructor(t){super(t),this.vertexAttributeColor=c(255,255,255,255),this.size=new Array,this.vertexAttributePosition=u(3*this.builder.numVerticesTotal),this.vertexAttributeNormal=new Int16Array(2*this.builder.numVerticesTotal)}bakeVertexColors(t){this.vertexAttributeColor[0]=255*t[0],this.vertexAttributeColor[1]=255*t[1],this.vertexAttributeColor[2]=255*t[2],this.vertexAttributeColor[3]=255*(t.length>3?t[3]:1)}bake(a){this.size=a;const{numVerticesTotal:l,pathVertexData:c,path:u,positions:b,profileRightAxes:v,profileUpAxes:m,profileVertexAndNormals:x}=this.builder;for(let A=0;A<l;++A){let l=c[A];const d=0===l||l===u.vertices.length-1;l*=3;const f=V;let g=0,D=0;const N=4*A,j=n(R,v[N],v[N+1],v[N+2]),E=n(w,m[N],m[N+1],m[N+2]),y=t(P,x[N]*a[0],x[N+1]*a[1]);if(d)h(f,E,j),g=v[N+3]*a[0],D=m[N+3];else{const a=I,h=C;t(a,v[N+3],m[N+3]);const l=e(a);r(a,a);const c=i(y,a);if(Math.abs(c)>l){t(h,-a[1],a[0]);const e=i(y,h);s(a,a,l*Math.sign(c)),s(h,h,e),o(y,a,h)}n(f,0,0,0)}const T=n(O,j[0]*y[0]+E[0]*y[1],j[1]*y[0]+E[1]*y[1],j[2]*y[0]+E[2]*y[1]),L=3*A;this.vertexAttributePosition[L]=b[l]+T[0]+f[0]*g,this.vertexAttributePosition[L+1]=b[l+1]+T[1]+f[1]*g,this.vertexAttributePosition[L+2]=b[l+2]+T[2]+f[2]*g;const M=t(P,x[N+2],x[N+3]);p(this.vertexAttributeNormal,A,j[0]*M[0]+E[0]*M[1]+f[0]*D,j[1]*M[0]+E[1]*M[1]+f[1]*D,j[2]*M[0]+E[2]*M[1]+f[2]*D)}}createGeometryData(){const t=this.builder.vertexIndices.length,{normalIndices:e,vertexIndices:r}=this.builder;return[[A.POSITION,new v(this.vertexAttributePosition,r,3,!0)],[A.NORMALCOMPRESSED,new v(this.vertexAttributeNormal,e,2,!0)],[A.COLOR,new v(this.vertexAttributeColor,b(t),4)]]}onPathChanged(t){super.onPathChanged(t),this.bake(this.size)}intersect(t,e,r,i){const s=this.builder.vertexIndices,o=new m(this.vertexAttributePosition,3),a=s.length/3;x(t,e,0,a,s,o,void 0,r,((t,e,r)=>i(t,r,e,!1)))}}class g extends d{constructor(t,e,r,i){super(t),this.sizeAttributeValue=e,this.colorAttributeValue=r,this.opacityAttributeValue=i,this.vvData=null,this.baked=new f(t),this.vvData=u(4*this.builder.path.vertices.length);for(let s=0;s<this.builder.path.vertices.length;++s){this.vvData[4*s]=e,this.vvData[4*s+1]=r,this.vvData[4*s+2]=i;const t=0===s||s===this.builder.path.vertices.length-1;this.vvData[4*s+3]=t?1:0}}createGeometryData(){const{positions:t,profileRightAxes:e,profileUpAxes:r,profileVertexAndNormals:i,pathVertexIndices:s,vertexIndices:o}=this.builder;return[[A.POSITION,new v(t,s,3,!0)],[A.PROFILERIGHT,new v(e,o,4,!0)],[A.PROFILEUP,new v(r,o,4,!0)],[A.PROFILEVERTEXANDNORMAL,new v(i,o,4,!0)],[A.FEATUREVALUE,new v(this.vvData,s,4,!0)]]}onPathChanged(t){super.onPathChanged(t);const e=t.getMutableAttribute(A.POSITION);e&&(e.data=this.builder.positions)}}const P=a(),I=a(),C=a(),O=l(),V=l(),R=l(),w=l();export{g as FastUpdatePathGeometry,d as PathGeometryData,f as StaticPathGeometry};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,abortMaybe as a,destroyMaybe as n,releaseMaybe as h}from"../../../../core/maybe.js";import o from"../../../../core/PooledArray.js";import{throwIfAborted as d}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as _,initial as p,sync as u}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as f,invert as g,multiply as T}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as E}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{fromValues as R,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as S}from"../../../../chunks/boundedPlane.js";import{RenderCategory as C,InternalRenderCategory as w}from"../../webgl.js";import{debugFlags as I}from"../../support/debugFlags.js";import{TransparencyMode as O}from"../../terrain/TerrainRenderer.js";import{DepthFormat as N,ColorFormat as y}from"../../webgl/formats.js";import{FBOCache as D,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as x}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as L}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as v}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as H}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as F}from"../effects/RenderNodes.js";import{isPrepareRenderPlugin as U}from"../effects/RenderPlugin.js";import{RenderPluginManager as q}from"../effects/RenderPluginManager.js";import{Blit as V}from"../effects/blit/Blit.js";import{AnimationTimeStep as j}from"./AnimationTimeStep.js";import{Decorations as G,RenderRequestType as B,StencilBits as Q}from"./basicInterfaces.js";import{BoundingInfo as k}from"./BoundingInfo.js";import{zero as W,union as X}from"./depthRange.js";import{depthRangeFromScene as Y}from"./depthRangeUtils.js";import{RenderOccludedFlag as z}from"./Material.js";import{OffscreenRendering as J}from"./OffscreenRendering.js";import{RenderContext as K,defaultRenderOccludedMask as Z}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as $,RendererTarget as ee}from"./rendererUtils.js";import{setupFeatureDefaults as te,RenderFeature as re}from"./RenderFeature.js";import{RenderPluginInput as se}from"./RenderPluginInput.js";import{RenderSlot as ie}from"./RenderSlot.js";import{ShadowAccumulator as ae}from"./ShadowAccumulator.js";import{ShadowMap as ne,SnapshotSlot as he}from"./ShadowMap.js";import oe from"./SliceHelper.js";import{TransparencyPassType as de}from"./TransparencyPassType.js";import{Viewshed as le}from"./Viewshed.js";import{Transparency as _e}from"./edgeRendering/interfaces.js";import{MergedRenderer as pe}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as ue}from"../shaders/CompositingTechniqueConfiguration.js";import{OITCompositingTechnique as ce}from"../shaders/OITCompositingTechnique.js";import{RendererPerformanceInfo as me,PerformanceCategory as fe}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ge}from"../../../support/RenderState.js";import{DepthStencilAttachment as Te,PixelFormat as be,PixelType as Ee,ClearBufferBit as Ae}from"../../../webgl/enums.js";class Re{constructor(e,t,r,i,a,n){this._stage=e,this._techniques=r,this._rctx=i,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=R(0,0,0,1),this._sliceHelper=new oe,this._blit=null,this._state=c(ge.IDLE),this._highQualityTransparencyEnabled=!0,this._terrainTransparency=O.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new j,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new se,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new D(i),this._renderStateFeatures=c(te(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._offscreen=new J(this.fboCache,this._compositingHelper),this.performanceInfo=new me(this._rctx),this._shadowMap=new ne(this.fboCache,e.viewingMode),this._viewshed=new le({fboCache:this.fboCache,view:e.view},((e,t,r)=>{t.setGLViewport(this._rctx);const{camera:s,contentCamera:i}=e;this._ensureBindParametersCamera(t,t),this._renderAllGeometry(r),this._ensureBindParametersCamera(s,i),e.camera.setGLViewport(this._rctx)})),this._shadowAccumulator=new ae(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((e,t,r)=>{const s=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,s),this._renderShadowCascades(L.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new K(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._nodes=new F(this._renderContext),this._plugins=new q({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new x,this._plugins.add(this.renderPassManager),this._plugins.add(this._viewshed),this._handles=[l((()=>this._stage.view.state.camera),(()=>n()),_),l((()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(_e.TRANSPARENT):()=>{},n()}),p),l((()=>this._stage.view.environment.background?.color),(e=>{const t=e?s(e):P;A(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),_),l((()=>this._stage.view.state.camera.relativeElevation),(e=>{this._inGlobeView=(e??1/0)>=H}),_)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=i(this._gpuTimerHandle),this._nodes.destroy(),this._offscreen.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=a(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),k.prune()}get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=te(t,e),this._plugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((s=>s.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(re.HighQualityTransparency)}get hasReflections(){return(this._pluginsHas.water||this._hasOverlayWater)&&(this._ssrEnabled||this.isFeatureEnabled(re.WaterReflection))}get hasDecorations(){return this._plugins.hasDecorations||this._nodes.produces("magnifier-color")}get hasHighlights(){return this._plugins.produces(L.Highlight,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL,ie.DRAPED_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(re.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(re.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(re.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=h(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth)}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._viewshed.viewshedShadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");d(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Me(this._stage.view.resourceController)});return this._handles.push(l((()=>r.updating),(()=>this._requestRender()),u)),this._requestRender(),this._edgeViewCallbacks.forEach((e=>e(r))),this._edgeViewCallbacks.length=0,r}))),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&f(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}get hasSlicePlane(){return!!this._sliceHelper.plane}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:s,updates:i}=e;if(0===r.length&&0===s.length&&0===i.length)return;const a=$(e);let n=!1;a.forEach(((r,s)=>{if(t.done)return;let i=this._plugins.getMaterialRenderer(s);if(null==i&&r.adds.length>0){const e=new pe({material:s});e.initializeRenderContext(this._plugins._context),i=e,this._plugins.add(i)}i&&(i.modify(r),0===i.numGeometries&&(n=!0)),r.removes.forEach((t=>e.removes.removeUnordered(t))),r.adds.forEach((t=>e.adds.removeUnordered(t))),r.updates.forEach((t=>e.updates.removeUnordered(t))),t.madeProgress()})),n&&this._plugins.removeEmptyMaterialRenderers(),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(L.Color,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),has.water=this._plugins.produces(L.Normal,ie.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees}updateAnimation(e){const t=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(e),this._hasAnimations=this._nodes.updateAnimation()||this._hasAnimations,this._hasAnimations!==t&&(this._gpuTimerHandle=t?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=ee.Default,s=G.ON){this._isRendering=!0,this.performanceInfo.startFrame(),this.fboCache.frameStart(),this._disposeBindBuffers();const i=this._offscreen,{camera:a,contentCamera:n,mode:o,alignPixelEnabled:d}=e;this._state.value=o,this._bindParameters.overlay=this.renderOverlay(t),this._bindParameters.overlay&&this.performanceInfo.advance(fe.OVERLAY),this._renderContext.time=t,this._bindParameters.transparencyPassType=de.NONE,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=s,this._bindParameters.mainColor=this._bindParameters.mainDepth=null,this._bindParameters.viewshedEnabled=this._viewshed.enabled;const l=this._nodes.produces("magnifier-color"),_=this._nodes.produces("final-color"),p=S(this._sliceHelper.plane);s===G.OFF&&(this._sliceHelper.plane=null),a.setGLViewport(this._rctx);const u=i.initializeFrame(a,this._backgroundColor,r);this.hasReflections?this._bindParameters.ssr.lastFrameColor=u:u?.release(),this._ensureBindParametersCamera(a,n),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&s===G.ON;const c=this._plugins.produces(L.Color,ie.OPAQUE_TERRAIN)&&(this._terrainTransparency===O.Semitransparent||this._terrainTransparency===O.TransparentWithDraped),m=this._highQualityTransparency&&c,f=this._plugins.produces(L.Color,...Ie);this._prepareShaders(m,f),this.performanceInfo.advance(fe.PREPARE);const g=this._computeDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,g),this._ensureBindParametersCamera(a,n);let T=this._renderNormals();if(this._pluginInput.set("normals",T),T){let e=null;this._needsDepth&&(e=T.getAttachment(Te),e?.retain()),this._pluginInput.set("ssao",this._renderSSAO()),this._renderNoSSAOGeometryDepth(e),T=null}else this._renderAllGeometryDepth();this._renderShadowAccumulation(g,a,n),this._ensureBindParametersSSR(t),this._renderContext.output=L.Color,i.bindFbo(),this._bindParameters.mainColor=i.colorTexture,this._bindParameters.mainDepth=i.depthTexture;const b=this.plugins.produces(L.Color,...we);b&&this._renderOpaqueGeometry(),this._offscreen.updateColor((e=>this._renderNodes(C.OPAQUE,e,b))),this.fboCache.debugCallback?.("opaque-color",this._offscreen.color.fbo),this._renderPlugins(ie.OPAQUE_ENVIRONMENT,fe.OPAQUE_ENVIRONMENT),this._renderMultipassTerrainDepth(m),this._setMultipassTerrain(m),this._renderEdges(_e.OPAQUE),i.bindFbo(),this._renderPlugins(ie.VOXEL,fe.VOXEL),this._renderHiddenTransparentEdges(),f&&(this._oitEnabled?this._renderOITPass(Pe.Geometry):this._renderTransparentMaterial()),this._offscreen.updateColor((e=>this._renderNodes(C.TRANSPARENT,e,f))),this.fboCache.debugCallback?.("transparent-color",this._offscreen.color.fbo),this._renderMultipassGeometryDepth(m),this._renderHUDVisibility(),m||this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS);const E=r===ee.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this._renderEdges(_e.TRANSPARENT);const A=c?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(fe.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(m?this._renderLineCallouts(v.Occluded):i.compositeToHUDVisibility(this._bindParameters,A.getTexture()),this._renderHUD(v.Occluded,i.color))),this._setTerrainCulling(!1),A&&(i.compositeToFramebuffer(this._bindParameters,A.getTexture(),ue.PremultipliedAlpha,1),A.release(),m&&(this._renderEdges(_e.OPAQUE),f&&(this._oitEnabled?this._renderOITPass(Pe.Geometry):this._renderTransparentMaterial(),this.performanceInfo.advance(fe.TRANSPARENT)),this._renderEdges(_e.TRANSPARENT))),this._bindParameters.ssao=h(this._bindParameters.ssao),m&&this._renderLineCallouts(v.NotOccluded),this._setMultipassEnabled(!1),this._renderTransparentEnvironment(),this._renderViewshed(),this._renderLaserlines(),this._renderOccluded(),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._offscreen.updateColor((e=>this._renderNodes(C.COMPOSITE,e)));const R=this._nodes.produces("aa-color"),P=!(r!==ee.Default||_||l&&s===G.ON&&r===ee.Default),I=this._pluginInput.get("composite-color"),N=P?M:this.fboCache.acquire(I.fbo.width,I.fbo.height,"aa-color"),y=R?this._renderNodes(w.ANTIALIASING,N):this._blitToDefault(I,N,!1);this._pluginInput.set(w.ANTIALIASING,y),this._renderHUD(v.NotOccluded,y);const D=this._renderNodes(w.HIGHLIGHTS,y);let x=this._renderNodes(w.MAGNIFIER,D);return l&&s===G.ON&&r===ee.Default&&!_&&(x=this._blitToDefault(x)),_?(x.attachDepth(i.depth),this._blitToDefault(this._renderNodes(C.FINAL,x)),x.detachDepth()):this._pluginInput.set(C.FINAL,x),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=p,this._isRendering=!1,this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ee.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),{screen:this._pluginInput.get("final-color"),oid:E}}_prepareShaders(e,t){this._renderContext.output=L.Color,this._prepareOpaqueGeometry(),this._setMultipassTerrain(e),this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._plugins.prepare(ie.LINE_CALLOUTS),t&&this._prepareTransparencySlots(),this._plugins.prepare(ie.VIEWSHED,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT,ie.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(){if(!has("enable-feature:objectAndLayerId-rendering"))return;const e=this._renderContext.output,t=this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"oid");return t.acquireDepth(N.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(t.fbo),this.fboCache.rctx.clearFramebuffer([0,0,0,0],!0,!0),this._renderAllGeometry(L.ObjectAndLayerIdColor),this._rctx.bindFramebuffer(t.fbo),this.fboCache.rctx.clearFramebuffer(void 0,!0,!0),this._bindParameters.hudRenderStyle=v.NotOccluded,this._plugins.render(this._pluginInput,ie.HUD_MATERIAL),this._renderContext.output=e,this.performanceInfo.advance(fe.OBJECT_AND_LAYER_ID_COLOR),t}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===B.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0,s=t?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,r)}}readDepthPixels(e,t){if(!this._bindParameters.mainDepth)return;const{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"linear-depth");this._rctx.bindFramebuffer(i.fbo),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.clearFramebuffer([0,0,0,0],!0,!0),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,this._bindParameters.mainDepth),i.fbo?.readPixels(e[0],e[1],e[2],e[3],be.RGBA,Ee.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,t,r,s,i){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,s,be.RGBA,Ee.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const{width:r,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(r,s,"edges"),n=()=>t.render(this._bindParameters,e),h=this._bindParameters.multipassGeometry.depth;this._offscreen.renderToTargets(n,a,h??i,Ce),this._offscreen.compositeToFramebuffer(this._bindParameters,a.getTexture(),ue.Alpha,1),a.release(),this.performanceInfo.advance(e===_e.OPAQUE?fe.OPAQUE_EDGES:fe.TRANSPARENT_EDGES)}_renderShadowMap(e,t,r){const s=this._shadowMap;s.enabled&&(s.start(e,t,r,this.isFeatureEnabled(re.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(L.ShadowHighlight,this._shadowMap),s.moveSnapshot(he.Highlight),this._renderShadowCascades(L.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(he.ExcludeHighlight),this._renderShadowCascades(L.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(L.Shadow),s.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(fe.SHADOW_MAP))}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this._renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(L.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast||this._debugNeedsDepth}_renderNoSSAOGeometryDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=h(this._bindParameters.depth));const{width:t,height:r}=this._offscreen,s=this.fboCache.acquire(t,r,"depth");s.attachDepth(e),e.release(),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(void 0,!1,!0),this._renderGeometryExcludedFromSSAO(L.Depth),h(this._bindParameters.depth),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(fe.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=h(this._bindParameters.depth));const{width:e,height:t}=this._offscreen,r=this.fboCache.acquire(e,t,"depth").acquireDepth(N.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderAllGeometry(L.Depth),h(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(fe.DEPTH)}_renderMultipassTerrainDepth(e){if(!e)return void(this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth));const t=this._renderContext.output;this._renderContext.output=L.Depth;const{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"terrain depth").acquireDepth(N.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderTransparentTerrain(),h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassTerrain.depth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderMultipassGeometryDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth));const t=this._renderContext.output,{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"geometry depth").acquireDepth(N.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderOpaqueGeometryAndTransparentMaterial(L.Depth),this._renderContext.output=t,h(this._bindParameters.multipassGeometry.depth),this._bindParameters.multipassGeometry.depth=i.obtainDepthTexture(),i.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return W;const t=Y(e,this._plugins.plugins,this._stage.layers);return X(t,this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}_renderNormals(){const e=this._nodes.require("normals","final-color","composite-color","opaque-color","transparent-color"),t=(this.hasSSAO?1:0)+e;if(0===t)return;const r=this._offscreen.renderToCachedFBO(null,"normals",(()=>this._renderGeometryForSSAO(L.Normal)),[0,0,0,0],y.RGBA,N.DEPTH_STENCIL_TEXTURE),s=this._nodes.optional("normals","final-color","composite-color","opaque-color","transparent-color");return r.retain(t+s-1),this.performanceInfo.advance(fe.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();const t=this._nodes.render("ssao",this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(fe.SSAO),t}_renderAllGeometry(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderGeometryForSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL),this._renderTransparentTerrain()}_renderGeometryExcludedFromSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.OPAQUE_NO_SSAO_DEPTH,ie.TRANSPARENT_NO_SSAO_DEPTH)}_prepareOpaqueGeometry(){this._plugins.prepare(...we,ie.OPAQUE_ENVIRONMENT)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...we)}_renderTransparentMaterial(){this._plugins.render(this._pluginInput,...Ie)}_renderTransparentTerrain(){const e=this._renderContext.output;if(!this._plugins.produces(e,ie.TRANSPARENT_TERRAIN))return;const t=()=>this._plugins.render(this._pluginInput,ie.TRANSPARENT_TERRAIN);if(e!==L.Color)return void t();const{width:r,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(r,s,"transparent terrain");return this._offscreen.renderToTargets(t,a,i,[0,0,0,0]),a}_renderHUDVisibility(){this._plugins.produces(this._renderContext.output,ie.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._plugins.render(this._pluginInput,ie.OCCLUSION_PIXELS)),this._bindParameters.multipassGeometry.depth),this._offscreen.bindFbo(),this.performanceInfo.advance(fe.HUD_VISIBILITY)):this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===v.Occluded){const e=()=>this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS),{width:t,height:r,color:s}=this._offscreen,i=this.fboCache.acquireDepth(N.DEPTH16_BUFFER,t,r,"line callouts");this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS)}_renderLaserlines(){const e=this._plugins.produces(this._renderContext.output,ie.LASERLINES_CONTRAST_CONTROL);if(this._plugins.produces(this._renderContext.output,ie.LASERLINES)||e){if(this._plugins.render(this._pluginInput,ie.LASERLINES),e){const e=this._offscreen,{width:t,height:r,depth:s}=e,i=this.fboCache.acquire(t,r,"laser lines"),a=()=>this._plugins.render(this._pluginInput,ie.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,Ce),e.compositeToFramebuffer(this._bindParameters,i.getTexture(),ue.PremultipliedAlpha,1),i.release()}this.performanceInfo.advance(fe.LASER_LINES)}}_renderHUD(e,t){if(this._pluginsHas.hudElements){if(this._oitEnabled){const r=this._renderOITPass(Pe.HUD,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.composite(this._bindParameters,r.getTexture(),ue.PremultipliedAlpha),r.release()}else if(e===v.Occluded){this._renderContext.output=L.Color;const t=()=>this._renderHUDElements(e),{width:r,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(N.DEPTH16_BUFFER,r,s,"hud");this._offscreen.renderToTargets(t,i,a,void 0,!0,!0),a.release()}else this._renderContext.output=L.Color,t.acquireDepth(N.DEPTH16_BUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===v.Occluded?fe.HUD_OCCLUDED:fe.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.prepare(ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._plugins.produces(L.ShadowHighlight,ie.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this.hasHighlights)return;const e=()=>{this._renderAllGeometry(L.Highlight),this._rctx.clear(Ae.DEPTH_BUFFER_BIT),this._renderHUDElements(v.Both)},t=this._offscreen.renderToCachedFBO(null,"highlights",e,[0,0,0,0],y.RGBA4,N.DEPTH_STENCIL_TEXTURE);return t.detachDepth(),t}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,t,r){this._needsShadowCast&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(fe.ACCUMULATED_SHADOWS)}_prepareTransparencySlots(){this._renderContext.output=L.Color,this._bindParameters.transparencyPassType=de.ColorAlpha,this._plugins.prepare(...Ie),this._bindParameters.transparencyPassType=de.FrontFace,this._plugins.prepare(...Ie),this._bindParameters.transparencyPassType=de.NONE,this._techniques.acquire(ce).release()}_renderOITPass(e,t=v.Both){const r=e===Pe.HUD,s=r?this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"oit hud composite"):null,i=r?()=>this._renderHUDElements(t):()=>this._renderTransparentMaterial(),a=this._renderContext.output;return this._renderContext.output=L.Color,this._offscreen.renderOIT(this._bindParameters,i,s),this._renderContext.output=a,s}_renderOccluded(){let e=0;Oe.clear(),this._plugins.plugins.forAll((t=>{if(!t.materialReference)return;t.queryRenderOccludedState(z.OccludeAndTransparentStencil)&&(e|=z.OccludeAndTransparentStencil,Oe.push(t))}));const t=this._offscreen,r=(r,s,i,a,n)=>{if(!(e&s))return;const{width:h,height:o,depth:d}=t,l=this.fboCache.acquire(h,o,"tmp color");t.renderToTargets(i,l,d,[0,0,0,0],a,n),t.compositeToFramebuffer(this._bindParameters,l.getTexture(),ue.PremultipliedAlpha,r),l.release()},s=(e,t)=>{this._bindParameters.slot=e,t.forAll((e=>{if(U(e)){const t=e.prepareTechnique(this._renderContext);t&&e.renderNode(this._renderContext,t)}}))};0!==Oe.length&&(s(ie.OCCLUDER_MATERIAL,Oe),r(.5,z.OccludeAndTransparentStencil,(()=>s(ie.TRANSPARENT_OCCLUDER_MATERIAL,Oe)),!1,!1));const i=Oe.length>0;Oe.clear(),this._plugins.plugins.forAll((t=>{if(!t.materialReference)return;const r=t.queryRenderOccludedState(z.OccludeAndTransparent),s=t.queryRenderOccludedState(z.Transparent),i=t.queryRenderOccludedState(z.Opaque);(r||s||i)&&(e|=r?z.OccludeAndTransparent:s?z.Transparent:z.Opaque,Oe.push(t))}));const a=this._plugins.renderOccludedFlags;if(e|=a,!e)return;const n=e=>{this._renderContext.renderOccludedMask=e,a>z.Occlude&&this._plugins.render(this._pluginInput,ie.OCCLUDED_TERRAIN),s(ie.OPAQUE_MATERIAL,Oe),s(ie.TRANSPARENT_MATERIAL,Oe),s(ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Oe),this._renderContext.renderOccludedMask=Z};this._renderContext.output=L.Color,r(.5,z.OccludeAndTransparent,(()=>n(z.OccludeAndTransparent)),!0,Q.OutlineVisualElementMask),r(.5,z.Transparent,(()=>n(z.Transparent)),!0,Q.OutlineVisualElementMask),r(1,z.Opaque,(()=>n(z.Opaque)),!0,Q.OutlineVisualElementMask),(i||Oe.length>0)&&this.performanceInfo.advance(fe.OCCLUDED),Oe.clear()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this._offscreen.bindFbo(),this._plugins.render(this._pluginInput,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT),this.performanceInfo.advance(fe.TRANSPARENT_ENVIRONMENT)}_renderViewshed(){this._plugins.produces(this._renderContext.output,ie.VIEWSHED)&&(this._viewshed.renderHighQuality=this.isFeatureEnabled(re.HighResolutionViewshed),this._plugins.render(this._pluginInput,ie.VIEWSHED),this.performanceInfo.advance(fe.VIEWSHED))}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;t.setName(e),this._pluginInput.set(e,t);const s=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),s}_blitToDefault(e,t=M,r=!0){this._blit||(this._blit=new V(this._techniques));const s=this._blit.render(this._rctx,e,t,this._bindParameters,this._requestRender);return this._pluginInput.set(e.name,s),r&&e.release(),s}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(g(ye,this._bindParameters.camera.viewMatrix),g(Ne,this._bindParameters.camera.projectionMatrix),T(De,ye,Ne),T(De,this._renderContext.lastFrameCamera.viewMatrix,De),T(De,this._renderContext.lastFrameCamera.projectionMatrix,De),this._reprojectionMatrix=De);const t=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}get test(){}}var Pe,Se;e([m({readOnly:!0})],Re.prototype,"fullResolutionAtmosphere",null),e([m()],Re.prototype,"_edgeView",void 0),e([m()],Re.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(Pe||(Pe={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility",e[e.ViewshedShadowMap=4]="ViewshedShadowMap"}(Se||(Se={}));const Ce=[0,0,0,0],we=[ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.OPAQUE_NO_SSAO_DEPTH],Ie=[ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH],Oe=new o,Ne=E(),ye=E(),De=E();function Me(e){return t=>e.immediate.schedule(t)}export{Se as FramebufferId,Re as Renderer};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,abortMaybe as a,destroyMaybe as n,releaseMaybe as h}from"../../../../core/maybe.js";import o from"../../../../core/PooledArray.js";import{throwIfAborted as d}from"../../../../core/promiseUtils.js";import{watch as l,syncAndInitial as _,initial as p,sync as u}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as f,invert as g,multiply as T}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as E}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{fromValues as P,ZEROS as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as S}from"../../../../chunks/boundedPlane.js";import{RenderCategory as C,InternalRenderCategory as w}from"../../webgl.js";import{debugFlags as I}from"../../support/debugFlags.js";import{TransparencyMode as O}from"../../terrain/TerrainRenderer.js";import{DepthFormat as N,ColorFormat as y}from"../../webgl/formats.js";import{FBOCache as D,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as x}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as L}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as v}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as H}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as F}from"../effects/RenderNodes.js";import{isPrepareRenderPlugin as U}from"../effects/RenderPlugin.js";import{RenderPluginManager as q}from"../effects/RenderPluginManager.js";import{Blit as V}from"../effects/blit/Blit.js";import{AnimationTimeStep as j}from"./AnimationTimeStep.js";import{Decorations as G,RenderRequestType as B,StencilBits as Q}from"./basicInterfaces.js";import{BoundingInfo as k}from"./BoundingInfo.js";import{zero as W,union as X}from"./depthRange.js";import{depthRangeFromScene as Y}from"./depthRangeUtils.js";import{RenderOccludedFlag as z}from"./Material.js";import{OffscreenRendering as J}from"./OffscreenRendering.js";import{RenderContext as K,defaultRenderOccludedMask as Z}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as $,RendererTarget as ee}from"./rendererUtils.js";import{setupFeatureDefaults as te,RenderFeature as re}from"./RenderFeature.js";import{RenderPluginInput as se}from"./RenderPluginInput.js";import{RenderSlot as ie}from"./RenderSlot.js";import{ShadowAccumulator as ae}from"./ShadowAccumulator.js";import{ShadowMap as ne,SnapshotSlot as he}from"./ShadowMap.js";import oe from"./SliceHelper.js";import{TransparencyPassType as de}from"./TransparencyPassType.js";import{Viewshed as le}from"./Viewshed.js";import{Transparency as _e}from"./edgeRendering/interfaces.js";import{MergedRenderer as pe}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as ue}from"../shaders/CompositingTechniqueConfiguration.js";import{OITCompositingTechnique as ce}from"../shaders/OITCompositingTechnique.js";import{RendererPerformanceInfo as me,PerformanceCategory as fe}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ge}from"../../../support/RenderState.js";import{DepthStencilAttachment as Te,PixelFormat as be,PixelType as Ee,ClearBufferBit as Ae}from"../../../webgl/enums.js";class Pe{constructor(e,t,r,i,a,n){this._stage=e,this._techniques=r,this._rctx=i,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=P(0,0,0,1),this._sliceHelper=new oe,this._blit=null,this._state=c(ge.IDLE),this._highQualityTransparencyEnabled=!0,this._terrainTransparency=O.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new j,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new se,this._releaseNormals=e=>{e.some((({name:e})=>"normals"===e))&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this.fboCache=new D(i),this._renderStateFeatures=c(te(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._offscreen=new J(this.fboCache,this._compositingHelper),this.performanceInfo=new me(this._rctx),this._shadowMap=new ne(this.fboCache,e.viewingMode),this._viewshed=new le({fboCache:this.fboCache,view:e.view},((e,t,r)=>{t.setGLViewport(this._rctx);const{camera:s,contentCamera:i}=e;this._ensureBindParametersCamera(t,t),this._renderAllGeometry(r),this._ensureBindParametersCamera(s,i),e.camera.setGLViewport(this._rctx)})),this._shadowAccumulator=new ae(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((e,t,r)=>{const s=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,s),this._renderShadowCascades(L.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new K(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._nodes=new F(this._renderContext),this._plugins=new q({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new x,this._plugins.add(this.renderPassManager),this._plugins.add(this._viewshed),this._handles=[l((()=>this._stage.view.state.camera),(()=>n()),_),l((()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(_e.TRANSPARENT):()=>{},n()}),p),l((()=>this._stage.view.environment.background?.color),(e=>{const t=e?s(e):R;A(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),_),l((()=>this._stage.view.state.camera.relativeElevation),(e=>{this._inGlobeView=(e??1/0)>=H}),_)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=i(this._gpuTimerHandle),this._nodes.destroy(),this._offscreen.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=a(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),k.prune()}get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=te(t,e),this._plugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((s=>s.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(re.HighQualityTransparency)}get hasReflections(){return(this._pluginsHas.water||this._hasOverlayWater)&&(this._ssrEnabled||this.isFeatureEnabled(re.WaterReflection))}get hasDecorations(){return this._plugins.hasDecorations||this._nodes.produces("magnifier-color")}get hasHighlights(){return this._plugins.produces(L.Highlight,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL,ie.DRAPED_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(re.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(re.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(re.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=h(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth)}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._viewshed.viewshedShadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");d(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Me(this._stage.view.resourceController)});return this._handles.push(l((()=>r.updating),(()=>this._requestRender()),u)),this._requestRender(),this._edgeViewCallbacks.forEach((e=>e(r))),this._edgeViewCallbacks.length=0,r}))),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&f(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}get hasSlicePlane(){return!!this._sliceHelper.plane}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:s,updates:i}=e;if(0===r.length&&0===s.length&&0===i.length)return;const a=$(e);let n=!1;a.forEach(((r,s)=>{if(t.done)return;let i=this._plugins.getMaterialRenderer(s);if(null==i&&r.adds.length>0){const e=new pe({material:s});e.initializeRenderContext(this._plugins._context),i=e,this._plugins.add(i)}i&&(i.modify(r),0===i.numGeometries&&(n=!0)),r.removes.forEach((t=>e.removes.removeUnordered(t))),r.adds.forEach((t=>e.adds.removeUnordered(t))),r.updates.forEach((t=>e.updates.removeUnordered(t))),t.madeProgress()})),n&&this._plugins.removeEmptyMaterialRenderers(),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(L.Color,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),has.water=this._plugins.produces(L.Normal,ie.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees}updateAnimation(e){const t=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(e),this._hasAnimations=this._nodes.updateAnimation()||this._hasAnimations,this._hasAnimations!==t&&(this._gpuTimerHandle=t?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=ee.Default,s=G.ON){this._isRendering=!0,this.performanceInfo.startFrame(),this.fboCache.frameStart(),this._disposeBindBuffers();const i=this._offscreen,{camera:a,contentCamera:n,mode:o,alignPixelEnabled:d}=e;this._state.value=o,this._bindParameters.overlay=this.renderOverlay(t),this._bindParameters.overlay&&this.performanceInfo.advance(fe.OVERLAY),this._renderContext.time=t,this._bindParameters.transparencyPassType=de.NONE,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=s,this._bindParameters.mainColor=this._bindParameters.mainDepth=null,this._bindParameters.viewshedEnabled=this._viewshed.enabled;const l=this._nodes.produces("magnifier-color"),_=this._nodes.produces("final-color"),p=S(this._sliceHelper.plane);s===G.OFF&&(this._sliceHelper.plane=null),a.setGLViewport(this._rctx);const u=i.initializeFrame(a,this._backgroundColor,r);this.hasReflections?this._bindParameters.ssr.lastFrameColor=u:u?.release(),this._ensureBindParametersCamera(a,n),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&s===G.ON;const c=this._plugins.produces(L.Color,ie.OPAQUE_TERRAIN)&&(this._terrainTransparency===O.Semitransparent||this._terrainTransparency===O.TransparentWithDraped),m=this._highQualityTransparency&&c,f=this._plugins.produces(L.Color,...Ie);this._prepareShaders(m,f),this.performanceInfo.advance(fe.PREPARE);const g=this._computeDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,g),this._ensureBindParametersCamera(a,n);let T=this._renderNormals();if(this._pluginInput.set("normals",T),T){let e=null;this._needsDepth&&(e=T.getAttachment(Te),e?.retain()),this._pluginInput.set("ssao",this._renderSSAO()),this._renderNoSSAOGeometryDepth(e),T=null}else this._renderAllGeometryDepth();this._renderShadowAccumulation(g,a,n),this._ensureBindParametersSSR(t),this._renderContext.output=L.Color,i.bindFbo(),this._bindParameters.mainColor=i.colorTexture,this._bindParameters.mainDepth=i.depthTexture;const b=this.plugins.produces(L.Color,...we);b&&this._renderOpaqueGeometry(),this._offscreen.updateColor((e=>this._renderNodes(C.OPAQUE,e,b))),this.fboCache.debugCallback?.("opaque-color",this._offscreen.color.fbo),this._renderPlugins(ie.OPAQUE_ENVIRONMENT,fe.OPAQUE_ENVIRONMENT),this._renderMultipassTerrainDepth(m),this._setMultipassTerrain(m),this._renderEdges(_e.OPAQUE),i.bindFbo(),this._renderPlugins(ie.VOXEL,fe.VOXEL),this._renderHiddenTransparentEdges(),f&&(this._oitEnabled?this._renderOITPass(Re.Geometry):this._renderTransparentMaterial()),this._offscreen.updateColor((e=>this._renderNodes(C.TRANSPARENT,e,f))),this.fboCache.debugCallback?.("transparent-color",this._offscreen.color.fbo),this._renderMultipassGeometryDepth(m),this._renderHUDVisibility(),m||this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS);const E=r===ee.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this._renderEdges(_e.TRANSPARENT);const A=c?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(fe.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(m?this._renderLineCallouts(v.Occluded):i.compositeToHUDVisibility(this._bindParameters,A.getTexture()),this._renderHUD(v.Occluded,i.color))),this._setTerrainCulling(!1),A&&(i.compositeToFramebuffer(this._bindParameters,A.getTexture(),ue.PremultipliedAlpha,1),A.release(),m&&(this._renderEdges(_e.OPAQUE),f&&(this._oitEnabled?this._renderOITPass(Re.Geometry):this._renderTransparentMaterial(),this.performanceInfo.advance(fe.TRANSPARENT)),this._renderEdges(_e.TRANSPARENT))),this._bindParameters.ssao=h(this._bindParameters.ssao),m&&this._renderLineCallouts(v.NotOccluded),this._setMultipassEnabled(!1),this._renderTransparentEnvironment(),this._renderViewshed(),this._renderLaserlines(),this._renderOccluded(),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._offscreen.updateColor((e=>this._renderNodes(C.COMPOSITE,e)));const P=this._nodes.produces("aa-color"),R=!(r!==ee.Default||_||l&&s===G.ON&&r===ee.Default),I=this._pluginInput.get("composite-color"),N=R?M:this.fboCache.acquire(I.fbo.width,I.fbo.height,"aa-color"),y=P?this._renderNodes(w.ANTIALIASING,N):this._blitToDefault(I,N,!1);this._pluginInput.set(w.ANTIALIASING,y),this._renderHUD(v.NotOccluded,y);const D=this._renderNodes(w.HIGHLIGHTS,y);let x=this._renderNodes(w.MAGNIFIER,D);return l&&s===G.ON&&r===ee.Default&&!_&&(x=this._blitToDefault(x)),_?(x.attachDepth(i.depth),this._blitToDefault(this._renderNodes(C.FINAL,x)),x.detachDepth()):this._pluginInput.set(C.FINAL,x),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=p,this._isRendering=!1,this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==ee.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),{screen:this._pluginInput.get("final-color"),oid:E}}_prepareShaders(e,t){this._renderContext.output=L.Color,this._prepareOpaqueGeometry(),this._setMultipassTerrain(e),this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._plugins.prepare(ie.LINE_CALLOUTS),t&&this._prepareTransparencySlots(),this._plugins.prepare(ie.VIEWSHED,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT,ie.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(){if(!has("enable-feature:objectAndLayerId-rendering"))return;const e=this._renderContext.output,t=this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"oid");return t.acquireDepth(N.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(t.fbo),this.fboCache.rctx.clearFramebuffer([0,0,0,0],!0,!0),this._renderAllGeometry(L.ObjectAndLayerIdColor),this._rctx.bindFramebuffer(t.fbo),this.fboCache.rctx.clearFramebuffer(void 0,!0,!0),this._bindParameters.hudRenderStyle=v.NotOccluded,this._plugins.render(this._pluginInput,ie.HUD_MATERIAL),this._renderContext.output=e,this.performanceInfo.advance(fe.OBJECT_AND_LAYER_ID_COLOR),t}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===B.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0,s=t?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,r)}}readDepthPixels(e,t){if(!this._bindParameters.mainDepth)return;const{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"linear-depth");this._rctx.bindFramebuffer(i.fbo),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.clearFramebuffer([0,0,0,0],!0,!0),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,this._bindParameters.mainDepth),i.fbo?.readPixels(e[0],e[1],e[2],e[3],be.RGBA,Ee.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,t,r,s,i){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,s,be.RGBA,Ee.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const{width:r,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(r,s,"edges"),n=()=>t.render(this._bindParameters,e),h=this._bindParameters.multipassGeometry.depth;this._offscreen.renderToTargets(n,a,h??i,Ce),this._offscreen.compositeToFramebuffer(this._bindParameters,a.getTexture(),ue.Alpha,1),a.release(),this.performanceInfo.advance(e===_e.OPAQUE?fe.OPAQUE_EDGES:fe.TRANSPARENT_EDGES)}_renderShadowMap(e,t,r){const s=this._shadowMap;s.enabled&&(s.start(e,t,r,this.isFeatureEnabled(re.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(L.ShadowHighlight,this._shadowMap),s.moveSnapshot(he.Highlight),this._renderShadowCascades(L.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(he.ExcludeHighlight),this._renderShadowCascades(L.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(L.Shadow),s.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(fe.SHADOW_MAP))}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this._renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(L.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast||this._debugNeedsDepth}_renderNoSSAOGeometryDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=h(this._bindParameters.depth));const{width:t,height:r}=this._offscreen,s=this.fboCache.acquire(t,r,"depth");s.attachDepth(e),e.release(),this._rctx.bindFramebuffer(s.fbo),this._rctx.clearFramebuffer(void 0,!1,!0),this._renderGeometryExcludedFromSSAO(L.Depth),h(this._bindParameters.depth),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(fe.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=h(this._bindParameters.depth));const{width:e,height:t}=this._offscreen,r=this.fboCache.acquire(e,t,"depth").acquireDepth(N.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderAllGeometry(L.Depth),h(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(fe.DEPTH)}_renderMultipassTerrainDepth(e){if(!e)return void(this._bindParameters.multipassTerrain.depth=h(this._bindParameters.multipassTerrain.depth));const t=this._renderContext.output;this._renderContext.output=L.Depth;const{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"terrain depth").acquireDepth(N.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderTransparentTerrain(),h(this._bindParameters.multipassTerrain.depth),this._bindParameters.multipassTerrain.depth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderMultipassGeometryDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.depth=h(this._bindParameters.multipassGeometry.depth));const t=this._renderContext.output,{width:r,height:s}=this._offscreen,i=this.fboCache.acquire(r,s,"geometry depth").acquireDepth(N.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clearFramebuffer(void 0,!0,!0),this._renderOpaqueGeometryAndTransparentMaterial(L.Depth),this._renderContext.output=t,h(this._bindParameters.multipassGeometry.depth),this._bindParameters.multipassGeometry.depth=i.obtainDepthTexture(),i.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return W;const t=Y(e,this._plugins.plugins,this._stage.layers);return X(t,this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}_renderNormals(){const e=this._nodes.require("normals","final-color","composite-color","opaque-color","transparent-color"),t=(this.hasSSAO?1:0)+e;if(0===t)return;const r=this._offscreen.renderToCachedFBO(null,"normals",(()=>this._renderGeometryForSSAO(L.Normal)),[0,0,0,0],y.RGBA,N.DEPTH_STENCIL_TEXTURE),s=this._nodes.optional("normals","final-color","composite-color","opaque-color","transparent-color");return r.retain(t+s-1),this.performanceInfo.advance(fe.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();const t=this._nodes.render("ssao",this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(fe.SSAO),t}_renderAllGeometry(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._plugins.prepare(ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderGeometryForSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.TRANSPARENT_MATERIAL),this._renderTransparentTerrain()}_renderGeometryExcludedFromSSAO(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,ie.OPAQUE_NO_SSAO_DEPTH,ie.TRANSPARENT_NO_SSAO_DEPTH)}_prepareOpaqueGeometry(){this._plugins.prepare(...we,ie.OPAQUE_ENVIRONMENT)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...we)}_renderTransparentMaterial(){this._plugins.render(this._pluginInput,...Ie)}_renderTransparentTerrain(){const e=this._renderContext.output;if(!this._plugins.produces(e,ie.TRANSPARENT_TERRAIN))return;const t=()=>this._plugins.render(this._pluginInput,ie.TRANSPARENT_TERRAIN);if(e!==L.Color)return void t();const{width:r,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(r,s,"transparent terrain");return this._offscreen.renderToTargets(t,a,i,[0,0,0,0]),a}_renderHUDVisibility(){this._plugins.produces(this._renderContext.output,ie.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._plugins.render(this._pluginInput,ie.OCCLUSION_PIXELS)),this._bindParameters.multipassGeometry.depth),this._offscreen.bindFbo(),this.performanceInfo.advance(fe.HUD_VISIBILITY)):this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===v.Occluded){const e=()=>this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS),{width:t,height:r,color:s}=this._offscreen,i=this.fboCache.acquireDepth(N.DEPTH16_BUFFER,t,r,"line callouts");this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS)}_renderLaserlines(){const e=this._plugins.produces(this._renderContext.output,ie.LASERLINES_CONTRAST_CONTROL);if(this._plugins.produces(this._renderContext.output,ie.LASERLINES)||e){if(this._plugins.render(this._pluginInput,ie.LASERLINES),e){const e=this._offscreen,{width:t,height:r,depth:s}=e,i=this.fboCache.acquire(t,r,"laser lines"),a=()=>this._plugins.render(this._pluginInput,ie.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,Ce),e.compositeToFramebuffer(this._bindParameters,i.getTexture(),ue.PremultipliedAlpha,1),i.release()}this.performanceInfo.advance(fe.LASER_LINES)}}_renderHUD(e,t){if(this._pluginsHas.hudElements){if(this._oitEnabled){const r=this._renderOITPass(Re.HUD,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.composite(this._bindParameters,r.getTexture(),ue.PremultipliedAlpha),r.release()}else if(e===v.Occluded){this._renderContext.output=L.Color;const t=()=>this._renderHUDElements(e),{width:r,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(N.DEPTH16_BUFFER,r,s,"hud");this._offscreen.renderToTargets(t,i,a,void 0,!0,!0),a.release()}else this._renderContext.output=L.Color,t.acquireDepth(N.DEPTH16_BUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===v.Occluded?fe.HUD_OCCLUDED:fe.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.prepare(ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL),this._plugins.render(this._pluginInput,ie.LINE_CALLOUTS_HUD_DEPTH,ie.HUD_MATERIAL,ie.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._plugins.produces(L.ShadowHighlight,ie.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this.hasHighlights)return;const e=()=>{this._renderAllGeometry(L.Highlight),this._rctx.clear(Ae.DEPTH_BUFFER_BIT),this._renderHUDElements(v.Both)},t=this._offscreen.renderToCachedFBO(null,"highlights",e,[0,0,0,0],y.RGBA4,N.DEPTH_STENCIL_TEXTURE);return t.detachDepth(),t}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,t,r){this._needsShadowCast&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(fe.ACCUMULATED_SHADOWS)}_prepareTransparencySlots(){this._renderContext.output=L.Color,this._bindParameters.transparencyPassType=de.ColorAlpha,this._plugins.prepare(...Ie),this._bindParameters.transparencyPassType=de.FrontFace,this._plugins.prepare(...Ie),this._bindParameters.transparencyPassType=de.NONE,this._techniques.acquire(ce).release()}_renderOITPass(e,t=v.Both){const r=e===Re.HUD,s=r?this.fboCache.acquire(this._offscreen.width,this._offscreen.height,"oit hud composite"):null,i=r?()=>this._renderHUDElements(t):()=>this._renderTransparentMaterial(),a=this._renderContext.output;return this._renderContext.output=L.Color,this._offscreen.renderOIT(this._bindParameters,i,s),this._renderContext.output=a,s}_renderOccluded(){let e=0;Oe.clear(),this._plugins.plugins.forAll((t=>{if(!t.material)return;t.queryRenderOccludedState(z.OccludeAndTransparentStencil)&&(e|=z.OccludeAndTransparentStencil,Oe.push(t))}));const t=this._offscreen,r=(r,s,i,a,n)=>{if(!(e&s))return;const{width:h,height:o,depth:d}=t,l=this.fboCache.acquire(h,o,"tmp color");t.renderToTargets(i,l,d,[0,0,0,0],a,n),t.compositeToFramebuffer(this._bindParameters,l.getTexture(),ue.PremultipliedAlpha,r),l.release()},s=(e,t)=>{this._bindParameters.slot=e,t.forAll((e=>{if(U(e)){const t=e.prepareTechnique(this._renderContext);t&&e.renderNode(this._renderContext,t)}}))};0!==Oe.length&&(s(ie.OCCLUDER_MATERIAL,Oe),r(.5,z.OccludeAndTransparentStencil,(()=>s(ie.TRANSPARENT_OCCLUDER_MATERIAL,Oe)),!1,!1));const i=Oe.length>0;Oe.clear(),this._plugins.plugins.forAll((t=>{if(!t.material)return;const r=t.queryRenderOccludedState(z.OccludeAndTransparent),s=t.queryRenderOccludedState(z.Transparent),i=t.queryRenderOccludedState(z.Opaque);(r||s||i)&&(e|=r?z.OccludeAndTransparent:s?z.Transparent:z.Opaque,Oe.push(t))}));const a=this._plugins.renderOccludedFlags;if(e|=a,!e)return;const n=e=>{this._renderContext.renderOccludedMask=e,a>z.Occlude&&this._plugins.render(this._pluginInput,ie.OCCLUDED_TERRAIN),s(ie.OPAQUE_MATERIAL,Oe),s(ie.TRANSPARENT_MATERIAL,Oe),s(ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Oe),this._renderContext.renderOccludedMask=Z};this._renderContext.output=L.Color,r(.5,z.OccludeAndTransparent,(()=>n(z.OccludeAndTransparent)),!0,Q.OutlineVisualElementMask),r(.5,z.Transparent,(()=>n(z.Transparent)),!0,Q.OutlineVisualElementMask),r(1,z.Opaque,(()=>n(z.Opaque)),!0,Q.OutlineVisualElementMask),(i||Oe.length>0)&&this.performanceInfo.advance(fe.OCCLUDED),Oe.clear()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this._offscreen.bindFbo(),this._plugins.render(this._pluginInput,ie.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ie.TRANSPARENT_ENVIRONMENT),this.performanceInfo.advance(fe.TRANSPARENT_ENVIRONMENT)}_renderViewshed(){this._plugins.produces(this._renderContext.output,ie.VIEWSHED)&&(this._viewshed.renderHighQuality=this.isFeatureEnabled(re.HighResolutionViewshed),this._plugins.render(this._pluginInput,ie.VIEWSHED),this.performanceInfo.advance(fe.VIEWSHED))}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;t.setName(e),this._pluginInput.set(e,t);const s=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),s}_blitToDefault(e,t=M,r=!0){this._blit||(this._blit=new V(this._techniques));const s=this._blit.render(this._rctx,e,t,this._bindParameters,this._requestRender);return this._pluginInput.set(e.name,s),r&&e.release(),s}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(g(ye,this._bindParameters.camera.viewMatrix),g(Ne,this._bindParameters.camera.projectionMatrix),T(De,ye,Ne),T(De,this._renderContext.lastFrameCamera.viewMatrix,De),T(De,this._renderContext.lastFrameCamera.projectionMatrix,De),this._reprojectionMatrix=De);const t=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}get test(){}}var Re,Se;e([m({readOnly:!0})],Pe.prototype,"fullResolutionAtmosphere",null),e([m()],Pe.prototype,"_edgeView",void 0),e([m()],Pe.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(Re||(Re={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility",e[e.ViewshedShadowMap=4]="ViewshedShadowMap"}(Se||(Se={}));const Ce=[0,0,0,0],we=[ie.INTEGRATED_MESH,ie.OPAQUE_TERRAIN,ie.OPAQUE_MATERIAL,ie.OPAQUE_NO_SSAO_DEPTH],Ie=[ie.TRANSPARENT_MATERIAL,ie.TRANSPARENT_NO_SSAO_DEPTH],Oe=new o,Ne=E(),ye=E(),De=E();function Me(e){return t=>e.immediate.schedule(t)}export{Se as FramebufferId,Pe as Renderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import"../../../../core/has.js";import t from"../../../../core/PooledArray.js";import{property as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import"../../../../core/has.js";import{someMap as t}from"../../../../core/MapUtils.js";import s from"../../../../core/PooledArray.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{g as a}from"../../../../chunks/sphere.js";import{OverlayTarget as d}from"../../terrain/Intersector.js";import{ShaderOutput as h}from"../core/shaderLibrary/ShaderOutput.js";import{ChangeSet as l}from"./ChangeSet.js";import{newIntersectorResult as c}from"./Intersector.js";import{StoreResults as m,IntersectorType as p}from"./IntersectorInterfaces.js";import{RenderOccludedFlag as g}from"./Material.js";import{DirtyOperation as u,DirtyState as _}from"./ModelDirtyTypes.js";import{splitRenderGeometryChangeSetByMaterial as y}from"./rendererUtils.js";import{RenderSlot as f}from"./RenderSlot.js";import{MergedRenderer as R}from"../materials/renderers/MergedRenderer.js";let G=class extends r{constructor(e){super(e),this._pending=new v,this._changes=new l,this._materialRenderers=new Map,this._sortedMaterialRenderers=new s,this._geometries=new Map,this._hasHighlights=!1,this._hasWater=!1}destroy(){this._changes.prune(),this._materialRenderers.forEach((e=>e.destroy())),this._materialRenderers.clear(),this._sortedMaterialRenderers.clear(),this._geometries.clear(),this._pending.clear()}get updating(){return!this._pending.empty||this._changes.updates.length>0}get rctx(){return this.rendererContext.rctx}get _materials(){return this.rendererContext.materials}get _localOriginFactory(){return this.rendererContext.localOriginFactory}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccludedDraped(){return t(this._materialRenderers,(e=>0!==e.numGeometries&&!e.queryRenderOccludedState(g.Occlude)))}get isEmpty(){return!this.updating&&0===this._materialRenderers.size&&0===this._geometries.size}getMaterialRenderer(e){return this._materialRenderers.get(e)}commitChanges(){if(!this.updating)return!1;this._processAddsRemoves();const e=y(this._changes);let r=!1;return e.forEach(((e,t)=>{let s=this.getMaterialRenderer(t);if(!s&&e.adds.length>0){const e=new R({material:t});e.initializeRenderContext(this.rendererContext.pluginContext,this._materials),s=e,this._materialRenderers.set(t,s),r=!0}s&&(s.modify(e),0===s.numGeometries&&(this._materialRenderers.delete(t),s.destroy(),r=!0))})),this._changes.clear(),r&&this._updateSortedMaterialRenderers(),this._hasHighlights=t(this._materialRenderers,(e=>{const r=e.produces.get(f.DRAPED_MATERIAL);return!!r&&r(h.Highlight)})),this._hasWater=t(this._materialRenderers,(e=>{const r=e.produces.get(f.DRAPED_WATER);return!!r&&r(h.Normal)})),this.notifyChange("updating"),!0}addGeometries(e,r){if(0===e.length)return;const t=this._validateRenderGeometries(e);for(const i of t)this._geometries.set(i.id,i);const s=this._pending.empty;for(const i of t)this._pending.adds.add(i);s&&this.notifyChange("updating"),r===u.UPDATE&&this._notifyGraphicGeometryChanged(e)}removeGeometries(e,r){const t=this._pending.empty,s=this._pending.adds;for(const i of e)s.has(i)?(this._pending.removed.add(i),s.delete(i)):this._pending.removed.has(i)||this._pending.removes.add(i),this._geometries.delete(i.id);t&&!this._pending.empty&&this.notifyChange("updating"),r===u.UPDATE&&this._notifyGraphicGeometryChanged(e)}modifyGeometries(e,r){const t=0===this._changes.updates.length;for(const s of e){const e=this._changes.updates.pushNew();e.renderGeometry=this._validateRenderGeometry(s),e.updateType=r}switch(t&&this._changes.updates.length>0&&this.notifyChange("updating"),r){case _.TRANSFORMATION:case _.GEOMETRY:return this._notifyGraphicGeometryChanged(e);case _.VISIBILITY:return this._notifyGraphicVisibilityChanged(e)}}updateAnimation(e){let r=!1;return this._sortedMaterialRenderers.forAll((t=>r=!!t.updateAnimation&&t.updateAnimation(e)||r)),r}shouldRender(e){return this._sortedMaterialRenderers.some((r=>r.prepareTechnique(e)))}render(e){this._sortedMaterialRenderers.forAll((r=>{const t=r.prepareTechnique(e);null!=t&&r.renderNode(e,t)}))}intersect(e,r,t,s,i){return this._geometries.forEach((n=>{if(s&&!s(n))return;this._intersectRenderGeometry(n,t,r,0,e,i);const o=this.rendererContext.longitudeCyclical;o&&(n.boundingSphere[0]-n.boundingSphere[3]<o.min&&this._intersectRenderGeometry(n,t,r,o.range,e,i),n.boundingSphere[0]+n.boundingSphere[3]>o.max&&this._intersectRenderGeometry(n,t,r,-o.range,e,i)),i++})),i}_updateSortedMaterialRenderers(){this._sortedMaterialRenderers.clear();let e=0;for(const r of this._materialRenderers.values())r.drapedPriority=e++,this._sortedMaterialRenderers.push(r);this._sortedMaterialRenderers.sort(((e,r)=>r.material?.renderPriority===e.material?.renderPriority?e.drapedPriority-r.drapedPriority:(r.material?.renderPriority||0)-(e.material?.renderPriority||0)))}_processAddsRemoves(){this._changes.adds.clear(),this._changes.removes.clear(),this._changes.adds.pushArray(Array.from(this._pending.adds)),this._changes.removes.pushArray(Array.from(this._pending.removes));for(let e=0;e<this._changes.updates.length;){const r=this._changes.updates.data[e];this._pending.has(r.renderGeometry)?this._changes.updates.removeUnorderedIndex(e):e++}this._pending.clear()}_intersectRenderGeometry(e,r,t,s,i,n){if(!e.visible)return;let o=0;s+=e.transformation[12],o=e.transformation[13],A[0]=t[0]-s,A[1]=t[1]-o,e.screenToWorldRatio=this.rendererContext.screenToWorldRatio,e.material.intersectDraped(e,null,i,A,((t,s,o)=>{C(r,o,n,e.material.renderPriority,i,e.layerUid,e.graphicUid)}),r)}_notifyGraphicGeometryChanged(e){if(null==this.drapeSource.notifyGraphicGeometryChanged)return;let r;for(const t of e){const e=t.graphicUid;null!=e&&e!==r&&(this.drapeSource.notifyGraphicGeometryChanged(e),r=e)}}_notifyGraphicVisibilityChanged(e){if(null==this.drapeSource.notifyGraphicVisibilityChanged)return;let r;for(const t of e){const e=t.graphicUid;null!=e&&e!==r&&(this.drapeSource.notifyGraphicVisibilityChanged(e),r=e)}}_validateRenderGeometries(e){for(const r of e)this._validateRenderGeometry(r);return e}_validateRenderGeometry(e){return null==e.localOrigin&&(e.localOrigin=this._localOriginFactory.getOrigin(a(e.boundingSphere))),e}get test(){}};e([i()],G.prototype,"drapeSource",void 0),e([i()],G.prototype,"updating",null),e([i()],G.prototype,"rctx",null),e([i({constructOnly:!0})],G.prototype,"rendererContext",void 0),e([i()],G.prototype,"_materials",null),e([i()],G.prototype,"_localOriginFactory",null),e([i({readOnly:!0})],G.prototype,"isEmpty",null),e([i()],G.prototype,"_materialRenderers",void 0),e([i()],G.prototype,"_geometries",void 0),G=e([n("esri.views.3d.webgl-engine.lib.SortedRenderGeometryRenderer")],G);class v{constructor(){this.adds=new Set,this.removes=new Set,this.removed=new Set}get empty(){return 0===this.adds.size&&0===this.removes.size&&0===this.removed.size}has(e){return this.adds.has(e)||this.removes.has(e)||this.removed.has(e)}clear(){this.adds.clear(),this.removes.clear(),this.removed.clear()}}function C(e,r,t,s,i,n,o){const a=new d(n,o,r),h=r=>{r.set(p.OVERLAY,a,e.dist,e.normal,e.transformation,t,s)};if((null==i.results.min.drapedLayerOrder||t>=i.results.min.drapedLayerOrder)&&(null==i.results.min.dist||i.results.ground.dist<=i.results.min.dist)&&h(i.results.min),i.options.store!==m.MIN&&(null==i.results.max.drapedLayerOrder||t<i.results.max.drapedLayerOrder)&&(null==i.results.max.dist||i.results.ground.dist>i.results.max.dist)&&h(i.results.max),i.options.store===m.ALL){const e=c(i.ray);h(e),i.results.all.push(e)}}const A=o();export{G as SortedRenderGeometryRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{unpackFloatRGBA as
|
|
5
|
+
import{unpackFloatRGBA as t}from"../../../../core/floatRGBA.js";import e from"../../../../core/PooledArray.js";import{multiply as r,copy as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as s}from"../../../../chunks/vec32.js";import{l as a}from"../../../../chunks/vec42.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as h,create as f,copy as c}from"../../../../geometry/support/frustum.js";import{g as l,c as u}from"../../../../chunks/sphere.js";import{maxScale as _}from"../../support/mathUtils.js";import{empty as d,union as m,set as g,DepthRange as p}from"./depthRange.js";import b from"./Octree.js";import{assert as w}from"./Util.js";const v=1e4,R=100,j=500,C=500,A=.1;function B(e,r,i){return t(r,e)*(i[1]-i[0])+i[0]}function M(t,e,r){let i=0;if(!e.some((t=>!!t.material&&(i+=t.numGeometries,i>=v))))return Q.compute(t,e);const n=d();return r.forAll((e=>m(n,O(t,e)))),n}function O(t,e){if(!e.visible)return;const r=d(),i=e.getSpatialQueryAccelerator();return i?x(r,t,i):D(r,t,e.objects),r}function x(t,e,r){const i=e.eye,n=e.viewForward,s=e.frustum,a=t=>t.visible,o=r.objectCount;if(o<j)g(G,e.near,Math.min(t.near,e.far)),r.forEachInDepthRange(i,n,b.DepthOrder.FRONT_TO_BACK,G,((r,i)=>{T(t,e,r),G.far=t.near,i.setRange(G)}),s,a),g(G,Math.max(t.far,e.near),e.far),r.forEachInDepthRange(i,n,b.DepthOrder.BACK_TO_FRONT,G,((r,i)=>{T(t,e,r),G.near=t.far,i.setRange(G)}),s,a);else{const i=Math.max(Math.min(o,C),Math.ceil(o*A)),h=r.findClosest(n,b.DepthOrder.FRONT_TO_BACK,s,a,i),f=r.findClosest(n,b.DepthOrder.BACK_TO_FRONT,s,a,i);h&&f&&(I(t,e,h.boundingVolumeWorldSpace.bounds),I(t,e,f.boundingVolumeWorldSpace.bounds))}}function D(t,e,r){U.clear(),r.forAll((t=>{t.visible&&0!==t.geometries.length&&U.add(t)})),U.empty||(U.sort(e),g(G,e.near,Math.min(t.near,e.far)),U.forEachInDepthRange(G,b.DepthOrder.FRONT_TO_BACK,((r,i)=>{i<t.near&&T(t,e,r)})),g(G,Math.max(t.far,e.near),e.far),U.forEachInDepthRange(G,b.DepthOrder.BACK_TO_FRONT,((e,r,i)=>{t.far=Math.max(t.far,i)})))}function T(t,e,i){if(!i.visible)return;if(!h(e.frustum,i.boundingVolumeWorldSpace.bounds))return;const n=i.transformation,s=k;i.geometries.forEach((i=>{r(s,n,i.transformation);const a=_(s);F(t,e,i.boundingInfo,s,a)}))}function F(t,e,r,i,n){if(null==r)return;s(l(V),r.center,i);const{eye:a,viewForward:o}=e,f=o[0]*(V[0]-a[0])+o[1]*(V[1]-a[1])+o[2]*(V[2]-a[2]);if(V[3]=r.radius*n,!(f-V[3]>t.near&&f+V[3]<t.far)&&h(e.frustum,V))if(r.radius>R&&r.getChildren())for(const s of r.getChildren())F(t,e,s,i,n);else q.unionDepthRangeWithAABB(t,e.viewProjectionMatrix,i,r.bbMin,r.bbMax)}function I(t,e,r){const i=e.eye,n=e.viewForward,s=(r[0]-i[0])*n[0]+(r[1]-i[1])*n[1]+(r[2]-i[2])*n[2];t.near=Math.min(t.near,s-r[3]),t.far=Math.max(t.far,s+r[3])}class y{constructor(){this._items=new e({allocator:t=>t||{object:null,distance:0,near:0,far:0},deallocator:t=>(t.object=null,t.distance=0,t.near=0,t.far=0,t)})}get length(){return this._items.length}get empty(){return 0===this._items.length}clear(){this._items.clear()}add(t){this._items.pushNew().object=t}sort(t){const e=t.eye,r=t.viewForward;this._items.forAll((t=>{const i=t.object.boundingVolumeWorldSpace.bounds,n=(i[0]-e[0])*r[0]+(i[1]-e[1])*r[1]+(i[2]-e[2])*r[2];t.distance=n,t.near=n-i[3],t.far=n+i[3]})),this._items.sort(((t,e)=>t.distance-e.distance))}forEachInDepthRange(t,e,r){if(e===b.DepthOrder.FRONT_TO_BACK)for(let i=0;i<this._items.length;++i){const e=this._items.data[i];e.far<t.near||e.near>t.far||r(e.object,e.near,e.far)}else for(let i=this._items.length-1;i>=0;--i){const e=this._items.data[i];e.far<t.near||e.near>t.far||r(e.object,e.near,e.far)}}}class P{constructor(){this._view=n(),this._viewProj=n(),this._frustum=f(),this._geometries=new Array,this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange={near:0,far:0}}compute(t,e){this._reset(),i(this._view,t.viewMatrix),r(this._viewProj,t.projectionMatrix,this._view),c(this._frustum,t.frustum);const n=this._view,s=n[2],a=n[6],o=n[10],h=n[14];e.forAll((t=>{t.material&&t.forEachGeometry&&t.forEachGeometry((t=>{if(!t.visible||!t.castShadow)return;const e=t.boundingSphere,r=s*e[0]+a*e[1]+o*e[2]+h,i=r-e[3],n=r+e[3];this._geometries.push(t),this._near.push(-n),this._far.push(-i)}))}));const f=new p;if(0===this._geometries.length)return f;for(let r=0;r<this._geometries.length;++r)this._near[r]>f.far&&(f.far=this._near[r]),this._near[r]>2&&this._far[r]<f.near&&(f.near=this._far[r]);const l=this._looseRange;l.near=Math.max(.5*f.near,2),l.far=2*f.far;let u=0,_=0;for(let r=0;r<this._geometries.length;++r)this._near[r]<f.near&&(this._near[r]>=l.near?f.near=this._near[r]:this._nearCandidates[u++]=r),this._far[r]>f.far&&(this._far[r]<=l.far?f.far=this._far[r]:this._farCandidates[_++]=r);if(0===this._nearCandidates.length&&0===this._farCandidates.length)return f;this._nearCandidates.sort(((t,e)=>this._near[t]<this._near[e]?-1:this._near[t]>this._near[e]?1:0)),this._farCandidates.sort(((t,e)=>this._far[t]<this._far[e]?1:this._far[t]>this._far[e]?-1:0));for(let r=0;r<this._nearCandidates.length;++r){const t=this._nearCandidates[r];if(this._near[t]<f.near){const e=this._geometries[t],r=e.boundingInfo;this._includeNearBoundingInfoRec(r,e.shaderTransformation,f)}}for(let r=0;r<this._farCandidates.length;++r){const t=this._farCandidates[r];if(this._far[t]>f.far){const e=this._geometries[t],r=e.boundingInfo;this._includeFarBoundingInfoRec(r,e.shaderTransformation,f)}}return this._reset(),f}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_includeNearBoundingInfoRec(t,e,r){if(null==t)return;const i=t.center;s(l(V),i,e);const n=_(e),a=V[0],o=V[1],h=V[2],f=t.radius*n,c=this._frustum;if(c[0][0]*a+c[0][1]*o+c[0][2]*h+c[0][3]>f||c[1][0]*a+c[1][1]*o+c[1][2]*h+c[1][3]>f||c[2][0]*a+c[2][1]*o+c[2][2]*h+c[2][3]>f||c[3][0]*a+c[3][1]*o+c[3][2]*h+c[3][3]>f)return;const u=this._view[2]*a+this._view[6]*o+this._view[10]*h+this._view[14],d=u+f;if(!(-(u-f)<2||-d>=r.near))if(-d>this._looseRange.near)r.near=-d;else{if(f>R){const i=t.getChildren();if(void 0!==i){for(const t of i)this._includeNearBoundingInfoRec(t,e,r);return}}q.unionDepthRangeWithAABB(r,this._viewProj,e,t.bbMin,t.bbMax)}}_includeFarBoundingInfoRec(t,e,r){if(null==t)return;let i=t.radius;const n=t.center;s(l(V),n,e);const a=_(e),o=V[0],h=V[1],f=V[2];i*=a;const c=this._frustum;if(c[0][0]*o+c[0][1]*h+c[0][2]*f+c[0][3]>i||c[1][0]*o+c[1][1]*h+c[1][2]*f+c[1][3]>i||c[2][0]*o+c[2][1]*h+c[2][2]*f+c[2][3]>i||c[3][0]*o+c[3][1]*h+c[3][2]*f+c[3][3]>i)return;const u=this._view[2]*o+this._view[6]*h+this._view[10]*f+this._view[14]-i;if(!(-u<=r.far))if(-u<this._looseRange.far)r.far=-u;else{if(i>R){const i=t.getChildren();if(void 0!==i){for(const t of i)this._includeFarBoundingInfoRec(t,e,r);return}}q.unionDepthRangeWithAABB(r,this._viewProj,e,t.bbMin,t.bbMax)}}}class N{constructor(){this._modelViewProj=n(),this._clipPosition=[o(),o(),o(),o(),o(),o(),o(),o()]}unionDepthRangeWithAABB(t,e,i,n,s){const a=this._modelViewProj;r(a,e,i);let o=!1;for(let r=0;r<8;++r){const t=this._clipPosition[r],e=0===r||3===r||4===r||7===r?n[0]:s[0],i=0===r||1===r||4===r||5===r?n[1]:s[1],o=r<4?n[2]:s[2];t[0]=a[0]*e+a[4]*i+a[8]*o+a[12],t[1]=a[1]*e+a[5]*i+a[9]*o+a[13],t[2]=a[2]*e+a[6]*i+a[10]*o+a[14],t[3]=a[3]*e+a[7]*i+a[11]*o+a[15]}for(let r=0;r<12;++r){const e=E(this._clipPosition[S[r][0]],this._clipPosition[S[r][1]],this._clipPosition[S[r][2]]);let i=!0;for(let t=0;t<e.length;++t){if(e[t][3]>=2){i=!1;break}}if(!i){o=!0;for(let r=0;r<e.length;++r){const i=e[r][3];Number.isFinite(i)&&(t.near=Math.min(i,t.near),t.far=Math.max(i,t.far))}}}return o}}function E(t,e,r){let i=[t,e,r];for(let n=0;n<4;++n){const t=i;i=[];for(let e=0;e<t.length;++e){const r=t[e],s=t[(e+1)%t.length];W(s,n)?(W(r,n)||i.push(K(r,s,n)),i.push(s)):W(r,n)&&i.push(K(r,s,n))}}return i}function W(t,e){return 0===e?t[0]>=-t[3]:1===e?t[1]>=-t[3]:2===e?t[0]<=t[3]:3===e?t[1]<=t[3]:void w(!1)}function K(t,e,r){let i=0;return 0===r?i=(-t[3]-t[0])/(e[0]-t[0]+e[3]-t[3]):1===r?i=(-t[3]-t[1])/(e[1]-t[1]+e[3]-t[3]):2===r?i=(t[3]-t[0])/(e[0]-t[0]-e[3]+t[3]):3===r&&(i=(t[3]-t[1])/(e[1]-t[1]-e[3]+t[3])),a(o(),t,e,i)}const S=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],V=u(),k=n(),G=d(),U=new y,Q=new P,q=new N;export{P as DepthRangeFromRenderGeometries,O as depthRangeFromLayer,M as depthRangeFromScene,B as textureToDepth};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{removeUnordered as t,filterInPlace as r}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{nextHighestPowerOfTwo as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{NestedMap as o}from"../../../../../core/NestedMap.js";import a from"../../../../../core/PooledArray.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{multiply as u,invert as h,transpose as f}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as d}from"../../../support/buffer/glUtil.js";import{ShaderOutput as m}from"../../core/shaderLibrary/ShaderOutput.js";import{SyncPrepareRenderPlugin as g}from"../../effects/RenderPlugin.js";import{GLMaterials as p}from"../../lib/GLMaterials.js";import{DirtyState as y}from"../../lib/ModelDirtyTypes.js";import{RenderSlot as _}from"../../lib/RenderSlot.js";import{assert as b,setMatrixTranslation3 as v}from"../../lib/Util.js";import{DrawParameters as w}from"../DrawParameters.js";import{BufferRange as C,mergeAdjacentRanges as O}from"./BufferRange.js";import{Instance as A}from"./Instance.js";import{PerBufferData as E,hasVao as B}from"./PerBufferData.js";import{PerOriginData as H}from"./PerOriginData.js";import{VaoCache as D}from"./VaoCache.js";let R=class extends g{constructor(e){super(e),this._vaoCache=null,this._glMaterials=null,this._bufferWriter=null,this._dataByOrigin=new Map,this._hasHighlights=!1,this._hasOccludees=!1,this._produces=new Map,this.drapedPriority=0}destroy(){this._glMaterials=s(this._glMaterials),this._dataByOrigin.forEach((e=>e.dispose())),this._dataByOrigin.clear(),this._vaoCache=s(this._vaoCache)}initialize(){this.material.produces.forEach(((e,t)=>{this._produces.set(t,(t=>!(0===this._dataByOrigin.size||!(t!==m.Highlight&&t!==m.ShadowHighlight||this._hasHighlights))&&e(t)))}))}get produces(){return this._produces}initializeRenderContext(e,t){const{rctx:r}=e.renderContext;this._glMaterials=new p(this.material,t??e.materials),this._bufferWriter=this.material.createBufferWriter(),this._vaoCache=new D(r,this.material.vertexAttributeLocations,d(this._bufferWriter.vertexBufferLayout))}uninitializeRenderContext(){}get hasOccludees(){return this._hasOccludees}get isDecoration(){return this.material.parameters.isDecoration}queryRenderOccludedState(e){return this.material.queryRenderOccludedState(e)}get materialReference(){return this.material}get numGeometries(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.instances.size),0))),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.vao.usedMemory),0))),e}forEachGeometry(e){this._dataByOrigin.forEach((t=>t.buffers.forEach((t=>t.instances.forEach((t=>e(t.geometry)))))))}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateDrawCommands()}_updateGeometries(e){const t=this._bufferWriter;if(null===t)return;const r=t.vertexBufferLayout.stride/4;for(const i of e){const e=i.renderGeometry,s=this._dataByOrigin.get(e.localOrigin.id),o=s?.findBuffer(e.id);if(null==o)return;const a=o.instances.get(e.id);if(i.updateType&(y.GEOMETRY|y.TRANSFORMATION)){const i=N(t.elementCount(a.geometry.geometry)*r),s=t.vertexBufferLayout.createView(i.buffer);this._writeGeometry(e,s,0),o.vao.vertexBuffers.geometry.setSubData(i,a.from*r,0,a.numElements*r)}i.updateType&(y.HIGHLIGHT|y.OCCLUDEE|y.VISIBILITY)&&(o.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new o;for(const i of e){const e=i.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new S(e.vec3),r.set(e.id,null,t)),t.changes.push(i)}for(const i of t){const e=i.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),s=t?.findBuffer(i.id);if(null==s)continue;let o=r.get(e.id,s);null==o&&(o=new S(e.vec3),r.set(e.id,s,o)),o.changes.push(i)}return r}_addAndRemoveGeometries(e,r){if(null===this._bufferWriter||null===this._vaoCache)return;const{_bufferWriter:i,_dataByOrigin:s}=this,o=i.vertexBufferLayout.stride/4,a=this._computeDeltas(e,r);a.forEach(((e,r)=>{const n=e.get(null),l=null!=n?n.changes:[];a.delete(r,null);let u=s.get(r);if(e.forEach(((e,n)=>{if(a.delete(r,n),null==n)return void b(!1,"No VAO for removed geometries");if(n.instances.size===e.changes.length)return this._vaoCache.deleteVao(n.vao),t(u.buffers,n),void(0===u.buffers.length&&0===l.length&&s.delete(r));const h=n.numElements,f=n.vao.byteSize/4,c=l.reduce(((e,t)=>e+i.elementCount(t.geometry)),0),d=e.changes.reduce(((e,t)=>e+i.elementCount(t.geometry)),0),m=Math.min((h+c-d)*o,V),g=m>f;m>T&&m<f/2?(e.changes.forEach((({id:e})=>n.deleteInstance(e))),n.instances.forEach((({geometry:e})=>l.push(e))),this._vaoCache.deleteVao(n.vao),t(u.buffers,n)):g?this._applyAndRebuild(n,l,e):this._applyRemoves(n,e)})),l.length>0)for(null==u&&(u=new H(n.origin),s.set(r,u)),u.buffers.forEach((e=>this._applyAdds(e,l)));l.length>0;)u.buffers.push(this._applyAndRebuild(new E,l,null))}))}_updateDrawCommands(){this._hasHighlights=!1,this._hasOccludees=!1,this._dataByOrigin.forEach((e=>{e.buffers.forEach((e=>{if(e.drawCommandsDirty){e.hasHiddenInstances=e.hasHighlights=e.hasOccludees=!1;for(const t of e.instances.values())if(e.updateDrawState(t),e.hasHiddenInstances&&e.hasHighlights&&e.hasOccludees)break;e.updateDrawCommands(this._bufferWriter.vertexBufferLayout.stride)}this._hasHighlights=this._hasHighlights||e.hasHighlights,this._hasOccludees=this._hasOccludees||e.hasOccludees}))}))}_applyAndRebuild(e,t,r){if(null!=r)for(const d of r.changes)e.deleteInstance(d.id);const i=this._bufferWriter,s=i.vertexBufferLayout.stride,o=s/4,a=Math.floor(V/o);let n=e.numElements;for(;t.length>0;){const r=t.pop(),s=i.elementCount(r.geometry);if(n+s>a&&n>0){t.push(r);break}n+=s;const o=new A(r,0,0);b(null==e.instances.get(r.id)),e.addInstance(r.id,o)}const l=n*o,u=N(l),h=i.vertexBufferLayout.createView(u.buffer);let f=0;e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,e.instances.forEach(((t,r)=>{this._writeGeometry(t.geometry,h,f);const s=f;f+=i.elementCount(t.geometry.geometry),e.updateInstance(r,s,f),e.updateDrawState(t)})),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(U(l)),e.vao.vertexBuffers.geometry.setSubData(u,0,0,f*o),e.holes.clear();const c=e.holes.pushNew();return c.from=f,c.to=Math.floor(e.vao.byteSize/s),e.updateDrawCommands(s),e}_applyRemoves(e,t){if(0===t.changes.length||null===this._bufferWriter)return;for(const a of t.changes){const t=a.id,r=e.instances.get(t);if(!r)continue;e.deleteInstance(t);const i=I.back();if(i){if(i.to===r.from){i.to=r.to;continue}if(i.from===r.to){i.from=r.from;continue}}const s=I.pushNew();s.from=r.from,s.to=r.to}O(I);const r=this._bufferWriter.vertexBufferLayout.stride/4,i=I.reduce(((e,t)=>Math.max(e,t.numElements)),0)*r,s=N(i);s.fill(0,0,i);const o=e.vao.vertexBuffers.geometry;I.forAll((e=>o.setSubData(s,e.from*r,0,e.numElements*r))),e.holes.pushArray(I.data,I.length),I.forAll(((e,t)=>I.data[t]=null)),I.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t){if(0===t.length||null===this._bufferWriter)return;if(!B(e))return void this._applyAndRebuild(e,t,null);const i=this._bufferWriter,s=i.vertexBufferLayout.stride/4,o=e.numElements,a=t.reduce(((e,t)=>e+i.elementCount(t.geometry)),0),n=Math.min((o+a)*s,V),l=4*n;if(e.vao.byteSize<U(V-T)&&l>e.vao.byteSize)return void this._applyAndRebuild(e,t,null);O(e.holes);const u=new Array;for(const r of t){const t=i.elementCount(r.geometry),s=x(e.holes,t);u.push(s)}const h=e.vao.vertexBuffers.geometry;let f=0,c=0,d=0;const m=N(n),g=i.vertexBufferLayout.createView(m.buffer);t.forEach(((t,r)=>{const o=u[r];if(null==o)return;if(!(d===o)){const e=d-c;e>0&&h.setSubData(m,c*s,0,e*s),c=o,f=0}const a=i.elementCount(t.geometry);this._writeGeometry(t,g,f),f+=a,d=o+a;const n=new A(t,o,o+a);b(null==e.instances.get(t.id)),e.addInstance(t.id,n),e.drawCommandsDirty=!0}));const p=d-c;p>0&&h.setSubData(m,c*s,0,p*s),r(t,((e,t)=>null==u[t]))}_writeGeometry(e,t,r){if(null===this._bufferWriter)return;const i=e.localOrigin.vec3;v(M,-i[0],-i[1],-i[2]);const s=u(j,M,e.transformation);h(L,s),f(L,L),this._bufferWriter.write(s,L,e.geometry,t,r)}updateAnimation(e){return this.material.update(e)}prepareTechnique(e){if(!this.material.shouldRender(e))return null;const{output:t,bindParameters:r}=e,i=this.material.produces.get(r.slot);if(!i?.(t))return null;const s=t===m.Highlight||t===m.ShadowHighlight;if(s&&!this._hasHighlights)return null;const o=t===m.ShadowExcludeHighlight,a=!(s||o);for(const n of this._dataByOrigin.values())for(const i of n.buffers){if(s&&!i.hasHighlights)continue;const n=(s?i.drawCommandsHighlight:o&&i.needsMultipleCommands()?i.drawCommandsShadowHighlightRest:i.drawCommandsDefault)||null,l=a&&i.drawCommandsOccludees||null;if(n?.length||l?.length){const i=this._glMaterials.load(e.rctx,r.slot,t),s=null!=i?i.beginSlot(r):null;if(null!=s)return s}}return null}renderNode(e,t){const{output:r,bindParameters:i}=e,s=r===m.Highlight||r===m.ShadowHighlight,o=r===m.ShadowExcludeHighlight,a=!(s||o),n=i.slot===_.OCCLUDER_MATERIAL,l=i.slot===_.TRANSPARENT_OCCLUDER_MATERIAL,u=e.rctx;u.runAppleAmdDriverHelper(),u.bindTechnique(t,i,this.material.parameters);for(const h of this._dataByOrigin.values())for(const e of h.buffers){if(s&&!e.hasHighlights)continue;const r=(s?e.drawCommandsHighlight:o&&e.needsMultipleCommands()?e.drawCommandsShadowHighlightRest:e.drawCommandsDefault)||null,f=a&&e.drawCommandsOccludees||null;if(r?.length||f?.length){t.program.bindDraw(new w(h.origin),i,this.material.parameters),t.ensureAttributeLocations(e.vao),u.bindVAO(e.vao),r?.length&&(u.setPipelineState(t.getPipeline(!1,n,l)),r.forAll((e=>u.drawArrays(t.primitiveType,e.first,e.count)))),f?.length&&(u.setPipelineState(t.getPipeline(!0,n,l)),f.forAll((e=>u.drawArrays(t.primitiveType,e.first,e.count))))}}}get test(){}};e([n({constructOnly:!0})],R.prototype,"material",void 0),R=e([l("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],R);class S{constructor(e){this.origin=e,this.changes=new Array}}function x(e,t){let r;if(!e.some((e=>!(e.numElements<t)&&(r=e,!0))))return null;const i=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),i}const M=c(),j=c(),L=c(),I=new a({allocator:e=>e||new C,deallocator:null}),T=65536,G=4*T,W=1024,P=16777216,V=P/4;let z=new Float32Array(T);function N(e){return z.length<e&&(z=new Float32Array(e)),z}function U(e){const t=4*e;return t<=W?W:t<G?i(t):Math.max(Math.min(Math.ceil(1.5*t/G)*G,P),t)}export{R as MergedRenderer};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{removeUnordered as t,filterInPlace as r}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{nextHighestPowerOfTwo as s}from"../../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{NestedMap as o}from"../../../../../core/NestedMap.js";import a from"../../../../../core/PooledArray.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{multiply as u,invert as h,transpose as f}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as d}from"../../../support/buffer/glUtil.js";import{ShaderOutput as m}from"../../core/shaderLibrary/ShaderOutput.js";import{SyncPrepareRenderPlugin as g}from"../../effects/RenderPlugin.js";import{GLMaterials as p}from"../../lib/GLMaterials.js";import{DirtyState as y}from"../../lib/ModelDirtyTypes.js";import{RenderSlot as _}from"../../lib/RenderSlot.js";import{assert as b,setMatrixTranslation3 as v}from"../../lib/Util.js";import{DrawParameters as w}from"../DrawParameters.js";import{BufferRange as C,mergeAdjacentRanges as O}from"./BufferRange.js";import{Instance as A}from"./Instance.js";import{PerBufferData as E,hasVao as B}from"./PerBufferData.js";import{PerOriginData as H}from"./PerOriginData.js";import{VaoCache as D}from"./VaoCache.js";let S=class extends g{constructor(e){super(e),this._vaoCache=null,this._glMaterials=null,this._bufferWriter=null,this._dataByOrigin=new Map,this._hasHighlights=!1,this._hasOccludees=!1,this._produces=new Map,this.drapedPriority=0}destroy(){this._glMaterials=i(this._glMaterials),this._dataByOrigin.forEach((e=>e.dispose())),this._dataByOrigin.clear(),this._vaoCache=i(this._vaoCache)}initialize(){this.material.produces.forEach(((e,t)=>{this._produces.set(t,(t=>!(0===this._dataByOrigin.size||!(t!==m.Highlight&&t!==m.ShadowHighlight||this._hasHighlights))&&e(t)))}))}get produces(){return this._produces}initializeRenderContext(e,t){const{rctx:r}=e.renderContext;this._glMaterials=new p(this.material,t??e.materials),this._bufferWriter=this.material.createBufferWriter(),this._vaoCache=new D(r,this.material.vertexAttributeLocations,d(this._bufferWriter.vertexBufferLayout))}uninitializeRenderContext(){}get hasOccludees(){return this._hasOccludees}get isDecoration(){return this.material.parameters.isDecoration}queryRenderOccludedState(e){return this.material.queryRenderOccludedState(e)}get numGeometries(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.instances.size),0))),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.vao.usedMemory),0))),e}forEachGeometry(e){this._dataByOrigin.forEach((t=>t.buffers.forEach((t=>t.instances.forEach((t=>e(t.geometry)))))))}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateDrawCommands()}_updateGeometries(e){const t=this._bufferWriter;if(null===t)return;const r=t.vertexBufferLayout.stride/4;for(const s of e){const e=s.renderGeometry,i=this._dataByOrigin.get(e.localOrigin.id),o=i?.findBuffer(e.id);if(null==o)return;const a=o.instances.get(e.id);if(s.updateType&(y.GEOMETRY|y.TRANSFORMATION)){const s=N(t.elementCount(a.geometry.geometry)*r),i=t.vertexBufferLayout.createView(s.buffer);this._writeGeometry(e,i,0),o.vao.vertexBuffers.geometry.setSubData(s,a.from*r,0,a.numElements*r)}s.updateType&(y.HIGHLIGHT|y.OCCLUDEE|y.VISIBILITY)&&(o.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new o;for(const s of e){const e=s.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new x(e.vec3),r.set(e.id,null,t)),t.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),i=t?.findBuffer(s.id);if(null==i)continue;let o=r.get(e.id,i);null==o&&(o=new x(e.vec3),r.set(e.id,i,o)),o.changes.push(s)}return r}_addAndRemoveGeometries(e,r){if(null===this._bufferWriter||null===this._vaoCache)return;const{_bufferWriter:s,_dataByOrigin:i}=this,o=s.vertexBufferLayout.stride/4,a=this._computeDeltas(e,r);a.forEach(((e,r)=>{const n=e.get(null),l=null!=n?n.changes:[];a.delete(r,null);let u=i.get(r);if(e.forEach(((e,n)=>{if(a.delete(r,n),null==n)return void b(!1,"No VAO for removed geometries");if(n.instances.size===e.changes.length)return this._vaoCache.deleteVao(n.vao),t(u.buffers,n),void(0===u.buffers.length&&0===l.length&&i.delete(r));const h=n.numElements,f=n.vao.byteSize/4,c=l.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),d=e.changes.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),m=Math.min((h+c-d)*o,V),g=m>f;m>T&&m<f/2?(e.changes.forEach((({id:e})=>n.deleteInstance(e))),n.instances.forEach((({geometry:e})=>l.push(e))),this._vaoCache.deleteVao(n.vao),t(u.buffers,n)):g?this._applyAndRebuild(n,l,e):this._applyRemoves(n,e)})),l.length>0)for(null==u&&(u=new H(n.origin),i.set(r,u)),u.buffers.forEach((e=>this._applyAdds(e,l)));l.length>0;)u.buffers.push(this._applyAndRebuild(new E,l,null))}))}_updateDrawCommands(){this._hasHighlights=!1,this._hasOccludees=!1,this._dataByOrigin.forEach((e=>{e.buffers.forEach((e=>{if(e.drawCommandsDirty){e.hasHiddenInstances=e.hasHighlights=e.hasOccludees=!1;for(const t of e.instances.values())if(e.updateDrawState(t),e.hasHiddenInstances&&e.hasHighlights&&e.hasOccludees)break;e.updateDrawCommands(this._bufferWriter.vertexBufferLayout.stride)}this._hasHighlights=this._hasHighlights||e.hasHighlights,this._hasOccludees=this._hasOccludees||e.hasOccludees}))}))}_applyAndRebuild(e,t,r){if(null!=r)for(const d of r.changes)e.deleteInstance(d.id);const s=this._bufferWriter,i=s.vertexBufferLayout.stride,o=i/4,a=Math.floor(V/o);let n=e.numElements;for(;t.length>0;){const r=t.pop(),i=s.elementCount(r.geometry);if(n+i>a&&n>0){t.push(r);break}n+=i;const o=new A(r,0,0);b(null==e.instances.get(r.id)),e.addInstance(r.id,o)}const l=n*o,u=N(l),h=s.vertexBufferLayout.createView(u.buffer);let f=0;e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,e.instances.forEach(((t,r)=>{this._writeGeometry(t.geometry,h,f);const i=f;f+=s.elementCount(t.geometry.geometry),e.updateInstance(r,i,f),e.updateDrawState(t)})),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(U(l)),e.vao.vertexBuffers.geometry.setSubData(u,0,0,f*o),e.holes.clear();const c=e.holes.pushNew();return c.from=f,c.to=Math.floor(e.vao.byteSize/i),e.updateDrawCommands(i),e}_applyRemoves(e,t){if(0===t.changes.length||null===this._bufferWriter)return;for(const a of t.changes){const t=a.id,r=e.instances.get(t);if(!r)continue;e.deleteInstance(t);const s=I.back();if(s){if(s.to===r.from){s.to=r.to;continue}if(s.from===r.to){s.from=r.from;continue}}const i=I.pushNew();i.from=r.from,i.to=r.to}O(I);const r=this._bufferWriter.vertexBufferLayout.stride/4,s=I.reduce(((e,t)=>Math.max(e,t.numElements)),0)*r,i=N(s);i.fill(0,0,s);const o=e.vao.vertexBuffers.geometry;I.forAll((e=>o.setSubData(i,e.from*r,0,e.numElements*r))),e.holes.pushArray(I.data,I.length),I.forAll(((e,t)=>I.data[t]=null)),I.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t){if(0===t.length||null===this._bufferWriter)return;if(!B(e))return void this._applyAndRebuild(e,t,null);const s=this._bufferWriter,i=s.vertexBufferLayout.stride/4,o=e.numElements,a=t.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),n=Math.min((o+a)*i,V),l=4*n;if(e.vao.byteSize<U(V-T)&&l>e.vao.byteSize)return void this._applyAndRebuild(e,t,null);O(e.holes);const u=new Array;for(const r of t){const t=s.elementCount(r.geometry),i=R(e.holes,t);u.push(i)}const h=e.vao.vertexBuffers.geometry;let f=0,c=0,d=0;const m=N(n),g=s.vertexBufferLayout.createView(m.buffer);t.forEach(((t,r)=>{const o=u[r];if(null==o)return;if(!(d===o)){const e=d-c;e>0&&h.setSubData(m,c*i,0,e*i),c=o,f=0}const a=s.elementCount(t.geometry);this._writeGeometry(t,g,f),f+=a,d=o+a;const n=new A(t,o,o+a);b(null==e.instances.get(t.id)),e.addInstance(t.id,n),e.drawCommandsDirty=!0}));const p=d-c;p>0&&h.setSubData(m,c*i,0,p*i),r(t,((e,t)=>null==u[t]))}_writeGeometry(e,t,r){if(null===this._bufferWriter)return;const s=e.localOrigin.vec3;v(M,-s[0],-s[1],-s[2]);const i=u(j,M,e.transformation);h(L,i),f(L,L),this._bufferWriter.write(i,L,e.geometry,t,r)}updateAnimation(e){return this.material.update(e)}prepareTechnique(e){if(!this.material.shouldRender(e))return null;const{output:t,bindParameters:r}=e,s=this.material.produces.get(r.slot);if(!s?.(t))return null;const i=t===m.Highlight||t===m.ShadowHighlight;if(i&&!this._hasHighlights)return null;const o=t===m.ShadowExcludeHighlight,a=!(i||o);for(const n of this._dataByOrigin.values())for(const s of n.buffers){if(i&&!s.hasHighlights)continue;const n=(i?s.drawCommandsHighlight:o&&s.needsMultipleCommands()?s.drawCommandsShadowHighlightRest:s.drawCommandsDefault)||null,l=a&&s.drawCommandsOccludees||null;if(n?.length||l?.length){const s=this._glMaterials.load(e.rctx,r.slot,t),i=null!=s?s.beginSlot(r):null;if(null!=i)return i}}return null}renderNode(e,t){const{output:r,bindParameters:s}=e,i=r===m.Highlight||r===m.ShadowHighlight,o=r===m.ShadowExcludeHighlight,a=!(i||o),n=s.slot===_.OCCLUDER_MATERIAL,l=s.slot===_.TRANSPARENT_OCCLUDER_MATERIAL,u=e.rctx;u.runAppleAmdDriverHelper(),u.bindTechnique(t,s,this.material.parameters);for(const h of this._dataByOrigin.values())for(const e of h.buffers){if(i&&!e.hasHighlights)continue;const r=(i?e.drawCommandsHighlight:o&&e.needsMultipleCommands()?e.drawCommandsShadowHighlightRest:e.drawCommandsDefault)||null,f=a&&e.drawCommandsOccludees||null;if(r?.length||f?.length){t.program.bindDraw(new w(h.origin),s,this.material.parameters),t.ensureAttributeLocations(e.vao),u.bindVAO(e.vao),r?.length&&(u.setPipelineState(t.getPipeline(!1,n,l)),r.forAll((e=>u.drawArrays(t.primitiveType,e.first,e.count)))),f?.length&&(u.setPipelineState(t.getPipeline(!0,n,l)),f.forAll((e=>u.drawArrays(t.primitiveType,e.first,e.count))))}}}get test(){}};e([n({constructOnly:!0})],S.prototype,"material",void 0),S=e([l("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],S);class x{constructor(e){this.origin=e,this.changes=new Array}}function R(e,t){let r;if(!e.some((e=>!(e.numElements<t)&&(r=e,!0))))return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}const M=c(),j=c(),L=c(),I=new a({allocator:e=>e||new C,deallocator:null}),T=65536,G=4*T,W=1024,P=16777216,V=P/4;let z=new Float32Array(T);function N(e){return z.length<e&&(z=new Float32Array(e)),z}function U(e){const t=4*e;return t<=W?W:t<G?s(t):Math.max(Math.min(Math.ceil(1.5*t/G)*G,P),t)}export{S as MergedRenderer};
|