@arcgis/core 4.32.0-next.20250119 → 4.32.0-next.20250121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/52b28aab40bb19e585bb.js +1 -0
  3. package/assets/esri/core/workers/chunks/{b372a0aab338a5ecad7c.js → 54f90273f0c8b74905dc.js} +1 -1
  4. package/assets/esri/core/workers/chunks/602c67fe1061ec5a3fa5.js +1 -0
  5. package/assets/esri/core/workers/chunks/{a40318ec20661bbe7a89.js → 74ba752dfab8ea5b6d2a.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{bdddf584ac34b6a88b2d.js → d5c93caa3a8bb06a0b3f.js} +1 -1
  7. package/assets/esri/core/workers/chunks/e4f4ad67d778dea5b956.js +1 -0
  8. package/assets/esri/core/workers/chunks/{ddada3c7f4bdf694e81a.js → fe441754962c8f8eebff.js} +25 -17
  9. package/assets/esri/libs/dxtEncoder/dxt_encoder.wasm +0 -0
  10. package/chunks/BloomComposition.glsl.js +6 -6
  11. package/chunks/ComponentShader.glsl.js +3 -3
  12. package/chunks/Fog.glsl.js +2 -2
  13. package/chunks/Terrain.glsl.js +6 -6
  14. package/chunks/dxt_encoder.js +5 -0
  15. package/interfaces.d.ts +423 -687
  16. package/layers/WMSLayer.js +1 -1
  17. package/libs/dxtEncoder/DXTEncoder.js +5 -0
  18. package/package.json +1 -1
  19. package/rest/support/ImageSampleParameters.js +1 -1
  20. package/support/revision.js +1 -1
  21. package/views/3d/terrain/TerrainRenderer.js +1 -1
  22. package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
  23. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +6 -8
  24. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  25. package/views/3d/webgl-engine/lib/TextureCompressionWorker.js +1 -1
  26. package/widgets/BuildingExplorer/BuildingLevel.js +1 -1
  27. package/widgets/BuildingExplorer/BuildingPhase.js +1 -1
  28. package/assets/esri/core/workers/chunks/8637dcdb58b0bc772c02.js +0 -1
  29. package/assets/esri/core/workers/chunks/bba3ff3d9941d5c6bd48.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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../config.js";import r from"../Graphic.js";import o from"../PopupTemplate.js";import s from"../request.js";import i from"../core/Collection.js";import a from"../core/CollectionFlattener.js";import n from"../core/Error.js";import{JSONMap as l}from"../core/jsonMap.js";import{clone as p}from"../core/lang.js";import{MultiOriginJSONMixin as m}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as u}from"../core/promiseUtils.js";import{on as c,watch as y,sync as f}from"../core/reactiveUtils.js";import{urlToObject as d,addQueryParameters as h,addProxy as g,Url as b}from"../core/urlUtils.js";import{property as w}from"../core/accessorSupport/decorators/property.js";import{Integer as v}from"../core/accessorSupport/ensureType.js";import{reader as x}from"../core/accessorSupport/decorators/reader.js";import{subclass as j}from"../core/accessorSupport/decorators/subclass.js";import{writer as I}from"../core/accessorSupport/decorators/writer.js";import{willPropertyWrite as S}from"../core/accessorSupport/write.js";import F from"../geometry/Extent.js";import P from"../geometry/SpatialReference.js";import{getScale as R}from"../geometry/support/scaleUtils.js";import{equals as E}from"../geometry/support/spatialReferenceUtils.js";import L from"./Layer.js";import{BlendLayer as O}from"./mixins/BlendLayer.js";import{OperationalLayer as U}from"./mixins/OperationalLayer.js";import{PortalLayer as M}from"./mixins/PortalLayer.js";import{RefreshableLayer as _}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as T}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as C}from"./mixins/TemporalLayer.js";import{isAxesOrderReversedForWkid as W}from"./ogc/crsUtils.js";import{isWmsServer as q}from"./support/arcgisLayerUrl.js";import{legendEnabled as N,url as $}from"./support/commonProperties.js";import{ExportWMSImageParameters as k}from"./support/ExportWMSImageParameters.js";import{createBitmap as B}from"./support/imageBitmapUtils.js";import H from"./support/WMSSublayer.js";import{normalizeWKID as G,toTimeQueryParameter as V,getPopupLayers as A,parseCapabilities as D}from"./support/wmsUtils.js";const J=new l({bmp:"image/bmp",gif:"image/gif",jpg:"image/jpeg",png:"image/png",svg:"image/svg+xml"},{ignoreUnknown:!1});function z(e){return"text/html"===e}function Q(e){return"text/plain"===e}let K=class extends(O(C(_(T(U(M(m(L)))))))){constructor(...e){super(...e),this.allSublayers=new a({getCollections:()=>[this.sublayers],getChildrenFunction:e=>e.sublayers}),this.customParameters=null,this.customLayerParameters=null,this.copyright=null,this.description=null,this.dimensions=null,this.fullExtent=null,this.fullExtents=null,this.featureInfoFormats=null,this.featureInfoUrl=null,this.fetchFeatureInfoFunction=null,this.imageFormat=null,this.imageMaxHeight=2048,this.imageMaxWidth=2048,this.imageTransparency=!0,this.legendEnabled=!0,this.mapUrl=null,this.isReference=null,this.operationalLayerType="WMS",this.spatialReference=null,this.spatialReferences=null,this.sublayers=null,this.type="wms",this.version=null,this.addHandles([c((()=>this.sublayers),"after-add",(({item:e})=>{e.parent=e.layer=this}),f),c((()=>this.sublayers),"after-remove",(({item:e})=>{e.layer=e.parent=null}),f),y((()=>this.sublayers),((e,t)=>{if(t)for(const r of t)r.layer=r.parent=null;if(e)for(const r of e)r.parent=r.layer=this}),f)])}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this.allSublayers.destroy()}load(e){const t=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["WMS"]},e).catch(u).then((()=>this._fetchService(t))).then((()=>this._checkLayerValidity()))),Promise.resolve(this)}readFullExtentFromItemOrMap(e,t){const r=t.extent;return r?new F({xmin:r[0][0],ymin:r[0][1],xmax:r[1][0],ymax:r[1][1]}):null}writeFullExtent(e,t){t.extent=[[e.xmin,e.ymin],[e.xmax,e.ymax]]}get featureInfoFormat(){return null==this.featureInfoFormats?null:this.featureInfoFormats.find(z)??this.featureInfoFormats.find(Q)??null}set featureInfoFormat(e){null==e?(this.revert("featureInfoFormat","service"),this._clearOverride("featureInfoFormat")):(z(e)||Q(e))&&this._override("featureInfoFormat",e)}readImageFormat(e,t){const r=t.supportedImageFormatTypes;return r&&r.includes("image/png")?"image/png":r&&r[0]}readSpatialReferenceFromItemOrDocument(e,t){return new P(t.spatialReferences[0])}writeSpatialReferences(e,t){const r=this.spatialReference?.wkid;e&&r?(t.spatialReferences=e.filter((e=>e!==r)),t.spatialReferences.unshift(r)):t.spatialReferences=e}readSublayersFromItemOrMap(e,t,r){return Y(t.layers,r,t.visibleLayers)}readSublayers(e,t,r){return Y(t.layers,r)}writeSublayers(e,t,r,o){t.layers=[];const s=new Map,i=e.flatten((({sublayers:e})=>e??[]));for(const a of i)if("number"==typeof a.parent?.id){const e=s.get(a.parent.id);null!=e?e.push(a.id):s.set(a.parent.id,[a.id])}for(const a of i){const e={sublayer:a,...o},r=a.write({parentLayerId:"number"==typeof a.parent?.id?a.parent.id:-1},e);if(s.has(a.id)&&(r.sublayerIds=s.get(a.id)),!a.sublayers&&a.name){const r=a.write({},e);delete r.id,t.layers.push(r)}}t.visibleLayers=i.filter((({visible:e,sublayers:t})=>e&&!t)).map((({name:e})=>e)).toArray()}set url(e){if(!e)return void this._set("url",e);const{path:t,query:r}=d(e);for(const s in r)/^(request|service)$/i.test(s)&&delete r[s];const o=h(t,r??{});this._set("url",o)}createExportImageParameters(e,t,r,o){const s=o?.pixelRatio??1,i=R({extent:e,width:t})*s,a=new k({layer:this,scale:i}),{xmin:n,ymin:l,xmax:p,ymax:m,spatialReference:u}=e,c=G(u,this.spatialReferences),y="1.3.0"===this.version&&W(c)?`${l},${n},${m},${p}`:`${n},${l},${p},${m}`,f=a.toJSON(),d="1.3.0"===this.version?"crs":"srs";return{bbox:y,[d]:null==c||isNaN(c)?void 0:"EPSG:"+c,...f}}async fetchImage(e,t,r,o){const i=this.mapUrl,a=this.createExportImageParameters(e,t,r,o);if(!a.layers){const e=document.createElement("canvas");return e.width=t,e.height=r,e}const n=V(o?.timeExtent),l={responseType:"image",query:this._mixCustomParameters({width:t,height:r,...a,time:n,...this.refreshParameters}),signal:o?.signal};return s(i??"",l).then((e=>e.data))}async fetchImageBitmap(e,t,r,o){const i=this.mapUrl??"",a=this.createExportImageParameters(e,t,r,o);if(!a.layers){const e=document.createElement("canvas");return e.width=t,e.height=r,e}const n=V(o?.timeExtent),l={responseType:"blob",query:this._mixCustomParameters({width:t,height:r,...a,time:n,...this.refreshParameters}),signal:o?.signal},{data:p}=await s(i,l);return B(p,i,o?.signal)}fetchFeatureInfo(e,t,r,o,s){const i=R({extent:e,width:t}),a=new k({layer:this,scale:i}),n=A(a.visibleSublayers);if(null==this.featureInfoUrl||null==n)return Promise.resolve([]);if(null==this.fetchFeatureInfoFunction&&null==this.featureInfoFormat)return Promise.resolve([]);const l="1.3.0"===this.version?{I:o,J:s}:{x:o,y:s},p={query_layers:n,request:"GetFeatureInfo",info_format:this.featureInfoFormat,feature_count:25,width:t,height:r,...l},m={...this.createExportImageParameters(e,t,r),...p},u=this._mixCustomParameters(m);return null!=this.fetchFeatureInfoFunction?this.fetchFeatureInfoFunction(u):this._defaultFetchFeatureInfoFunction(h(this.featureInfoUrl,u))}findSublayerById(e){return this.allSublayers.find((t=>t.id===e))}findSublayerByName(e){return this.allSublayers.find((t=>t.name===e))}serviceSupportsSpatialReference(e){return q(this.url)||null!=this.spatialReferences&&this.spatialReferences.some((t=>{const r=900913===t?P.WebMercator:new P({wkid:t});return E(r,e)}))}_defaultFetchFeatureInfoFunction(e){const t=document.createElement("iframe");t.src=g(e),t.style.border="none",t.style.margin="0",t.style.width="100%",t.setAttribute("sandbox","");const s=new o({title:this.title,content:t}),i=new r({sourceLayer:this,popupTemplate:s});return Promise.resolve([i])}async _fetchService(e){if(!this.resourceInfo&&this.parsedUrl?.path){const{path:t,query:r}=this.parsedUrl,{data:o}=await s(t,{query:{SERVICE:"WMS",REQUEST:"GetCapabilities",...r,...this.customParameters},responseType:"xml",signal:e});this.resourceInfo=D(o)}if(this.parsedUrl){const e=new b(this.parsedUrl.path),{httpsDomains:r}=t.request;"https"!==e.scheme||e.port&&"443"!==e.port||!e.host||r.includes(e.host)||r.push(e.host)}this.read(this.resourceInfo,{origin:"service"})}_checkLayerValidity(){if(!this.allSublayers.length)throw new n("wmslayer:empty-layer","The layer doesn't have any sublayer")}_mixCustomParameters(e){if(!this.customLayerParameters&&!this.customParameters)return e;const t={...this.customParameters,...this.customLayerParameters};for(const r in t)e[r.toLowerCase()]=t[r];return e}};function X(e,t){return e.some((e=>{for(const r in e)if(S(e,r,null,t))return!0;return!1}))}function Y(e,t,r){e=e??[];const o=new Map;e.every((e=>null==e.id))&&(e=p(e)).forEach(((e,t)=>e.id=t));for(const i of e){const e=new H;e.read(i,t),r&&!r.includes(e.name)&&(e.visible=!1),o.set(e.id,e)}const s=[];for(const a of e){const e=null!=a.id?o.get(a.id):null;if(e)if(null!=a.parentLayerId&&a.parentLayerId>=0){const t=o.get(a.parentLayerId);if(!t)continue;t.sublayers||(t.sublayers=new i),t.sublayers.push(e)}else s.push(e)}return s}e([w({readOnly:!0})],K.prototype,"allSublayers",void 0),e([w({json:{type:Object,write:!0}})],K.prototype,"customParameters",void 0),e([w({json:{type:Object,write:!0}})],K.prototype,"customLayerParameters",void 0),e([w({type:String,json:{write:!0}})],K.prototype,"copyright",void 0),e([w()],K.prototype,"description",void 0),e([w({readOnly:!0})],K.prototype,"dimensions",void 0),e([w({json:{type:[[Number]],read:{source:"extent"},write:{target:"extent"},origins:{"web-document":{write:{ignoreOrigin:!0}},"portal-item":{write:{ignoreOrigin:!0}}}}})],K.prototype,"fullExtent",void 0),e([x(["web-document","portal-item"],"fullExtent",["extent"])],K.prototype,"readFullExtentFromItemOrMap",null),e([I(["web-document","portal-item"],"fullExtent",{extent:{type:[[Number]]}})],K.prototype,"writeFullExtent",null),e([w()],K.prototype,"fullExtents",void 0),e([w({type:String,json:{write:{ignoreOrigin:!0}}})],K.prototype,"featureInfoFormat",null),e([w({type:[String],readOnly:!0})],K.prototype,"featureInfoFormats",void 0),e([w({type:String,json:{write:{ignoreOrigin:!0}}})],K.prototype,"featureInfoUrl",void 0),e([w()],K.prototype,"fetchFeatureInfoFunction",void 0),e([w({type:String,json:{origins:{"web-document":{default:"image/png",type:J.jsonValues,read:{reader:J.read,source:"format"},write:{writer:J.write,target:"format"}}}}})],K.prototype,"imageFormat",void 0),e([x("imageFormat",["supportedImageFormatTypes"])],K.prototype,"readImageFormat",null),e([w({type:Number,json:{read:{source:"maxHeight"},write:{target:"maxHeight"}}})],K.prototype,"imageMaxHeight",void 0),e([w({type:Number,json:{read:{source:"maxWidth"},write:{target:"maxWidth"}}})],K.prototype,"imageMaxWidth",void 0),e([w()],K.prototype,"imageTransparency",void 0),e([w(N)],K.prototype,"legendEnabled",void 0),e([w({type:["show","hide","hide-children"]})],K.prototype,"listMode",void 0),e([w({type:String,json:{write:{ignoreOrigin:!0}}})],K.prototype,"mapUrl",void 0),e([w({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],K.prototype,"isReference",void 0),e([w({type:["WMS"]})],K.prototype,"operationalLayerType",void 0),e([w()],K.prototype,"resourceInfo",void 0),e([w({type:P,json:{origins:{service:{read:{source:"extent.spatialReference"}}},write:!1}})],K.prototype,"spatialReference",void 0),e([x(["web-document","portal-item"],"spatialReference",["spatialReferences"])],K.prototype,"readSpatialReferenceFromItemOrDocument",null),e([w({type:[v],json:{read:!1,origins:{service:{read:!0},"web-document":{read:!1,write:{ignoreOrigin:!0}},"portal-item":{read:!1,write:{ignoreOrigin:!0}}}}})],K.prototype,"spatialReferences",void 0),e([I(["web-document","portal-item"],"spatialReferences")],K.prototype,"writeSpatialReferences",null),e([w({type:i.ofType(H),json:{write:{target:"layers",overridePolicy(e,t,r){if(X(this.allSublayers,r))return{ignoreOrigin:!0}}}}})],K.prototype,"sublayers",void 0),e([x(["web-document","portal-item"],"sublayers",["layers","visibleLayers"])],K.prototype,"readSublayersFromItemOrMap",null),e([x("service","sublayers",["layers"])],K.prototype,"readSublayers",null),e([I("sublayers",{layers:{type:[H]},visibleLayers:{type:[String]}})],K.prototype,"writeSublayers",null),e([w({json:{read:!1},readOnly:!0,value:"wms"})],K.prototype,"type",void 0),e([w($)],K.prototype,"url",null),e([w({type:String,json:{write:{ignoreOrigin:!0}}})],K.prototype,"version",void 0),K=e([j("esri.layers.WMSLayer")],K);const Z=K;export{Z as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../config.js";import r from"../Graphic.js";import o from"../PopupTemplate.js";import s from"../request.js";import i from"../core/Collection.js";import a from"../core/CollectionFlattener.js";import n from"../core/Error.js";import{JSONMap as l}from"../core/jsonMap.js";import{clone as p}from"../core/lang.js";import{MultiOriginJSONMixin as m}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as u}from"../core/promiseUtils.js";import{on as c,watch as y,sync as f}from"../core/reactiveUtils.js";import{urlToObject as d,addQueryParameters as h,addProxy as g,Url as b}from"../core/urlUtils.js";import{property as w}from"../core/accessorSupport/decorators/property.js";import{Integer as v}from"../core/accessorSupport/ensureType.js";import{reader as x}from"../core/accessorSupport/decorators/reader.js";import{subclass as j}from"../core/accessorSupport/decorators/subclass.js";import{writer as I}from"../core/accessorSupport/decorators/writer.js";import{willPropertyWrite as S}from"../core/accessorSupport/write.js";import F from"../geometry/Extent.js";import P from"../geometry/SpatialReference.js";import{getScale as R}from"../geometry/support/scaleUtils.js";import{equals as E}from"../geometry/support/spatialReferenceUtils.js";import L from"./Layer.js";import{BlendLayer as O}from"./mixins/BlendLayer.js";import{OperationalLayer as U}from"./mixins/OperationalLayer.js";import{PortalLayer as M}from"./mixins/PortalLayer.js";import{RefreshableLayer as _}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as T}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as C}from"./mixins/TemporalLayer.js";import{isAxesOrderReversedForWkid as W}from"./ogc/crsUtils.js";import{isWmsServer as q}from"./support/arcgisLayerUrl.js";import{legendEnabled as N,url as $}from"./support/commonProperties.js";import{ExportWMSImageParameters as k}from"./support/ExportWMSImageParameters.js";import{createBitmap as B}from"./support/imageBitmapUtils.js";import H from"./support/WMSSublayer.js";import{normalizeWKID as G,toTimeQueryParameter as V,getPopupLayers as A,parseCapabilities as D}from"./support/wmsUtils.js";const J=new l({bmp:"image/bmp",gif:"image/gif",jpg:"image/jpeg",png:"image/png",svg:"image/svg+xml"},{ignoreUnknown:!1});function z(e){return"text/html"===e}function Q(e){return"text/plain"===e}let K=class extends(O(C(_(T(U(M(m(L)))))))){constructor(...e){super(...e),this.allSublayers=new a({getCollections:()=>[this.sublayers],getChildrenFunction:e=>e.sublayers}),this.customParameters=null,this.customLayerParameters=null,this.copyright=null,this.description=null,this.dimensions=null,this.fullExtent=null,this.fullExtents=null,this.featureInfoFormats=null,this.featureInfoUrl=null,this.fetchFeatureInfoFunction=null,this.imageFormat=null,this.imageMaxHeight=2048,this.imageMaxWidth=2048,this.imageTransparency=!0,this.legendEnabled=!0,this.mapUrl=null,this.isReference=null,this.operationalLayerType="WMS",this.spatialReference=null,this.spatialReferences=null,this.sublayers=null,this.type="wms",this.version=null,this.addHandles([c((()=>this.sublayers),"after-add",(({item:e})=>{e.parent=e.layer=this}),f),c((()=>this.sublayers),"after-remove",(({item:e})=>{e.layer=e.parent=null}),f),y((()=>this.sublayers),((e,t)=>{if(t)for(const r of t)r.layer=r.parent=null;if(e)for(const r of e)r.parent=r.layer=this}),f)])}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this.allSublayers.destroy()}load(e){const t=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["WMS"]},e).catch(u).then((()=>this._fetchService(t))).then((()=>this._checkLayerValidity()))),Promise.resolve(this)}readFullExtentFromItemOrMap(e,t){const r=t.extent;return r?new F({xmin:r[0][0],ymin:r[0][1],xmax:r[1][0],ymax:r[1][1]}):null}writeFullExtent(e,t){t.extent=[[e.xmin,e.ymin],[e.xmax,e.ymax]]}get featureInfoFormat(){return null==this.featureInfoFormats?null:this.featureInfoFormats.find(z)??this.featureInfoFormats.find(Q)??null}set featureInfoFormat(e){null==e?(this.revert("featureInfoFormat","service"),this._clearOverride("featureInfoFormat")):(z(e)||Q(e))&&this._override("featureInfoFormat",e)}readImageFormat(e,t){const r=t.supportedImageFormatTypes;return r&&r.includes("image/png")?"image/png":r&&r[0]}readSpatialReferenceFromItemOrDocument(e,t){return new P(t.spatialReferences[0])}writeSpatialReferences(e,t){const r=this.spatialReference?.wkid;e&&r?(t.spatialReferences=e.filter((e=>e!==r)),t.spatialReferences.unshift(r)):t.spatialReferences=e}readSublayersFromItemOrMap(e,t,r){return Y(t.layers,r,t.visibleLayers)}readSublayers(e,t,r){return Y(t.layers,r)}writeSublayers(e,t,r,o){t.layers=[];const s=new Map,i=e.flatten((({sublayers:e})=>e??[]));for(const a of i)if("number"==typeof a.parent?.id){const e=s.get(a.parent.id);null!=e?e.push(a.id):s.set(a.parent.id,[a.id])}for(const a of i){const e={sublayer:a,...o},r=a.write({parentLayerId:"number"==typeof a.parent?.id?a.parent.id:-1},e);if(s.has(a.id)&&(r.sublayerIds=s.get(a.id)),!a.sublayers&&a.name){const r=a.write({},e);delete r.id,t.layers.push(r)}}t.visibleLayers=i.filter((({visible:e,sublayers:t})=>e&&!t)).map((({name:e})=>e)).toArray()}set url(e){if(!e)return void this._set("url",e);const{path:t,query:r}=d(e);for(const s in r)/^(request|service)$/i.test(s)&&delete r[s];const o=h(t,r??{});this._set("url",o)}createExportImageParameters(e,t,r,o){const s=o?.pixelRatio??1,i=R({extent:e,width:t})*s,a=new k({layer:this,scale:i}),{xmin:n,ymin:l,xmax:p,ymax:m,spatialReference:u}=e,c=G(u,this.spatialReferences),y="1.3.0"===this.version&&W(c)?`${l},${n},${m},${p}`:`${n},${l},${p},${m}`,f=a.toJSON(),d="1.3.0"===this.version?"crs":"srs";return{bbox:y,[d]:null==c||isNaN(c)?void 0:"EPSG:"+c,...f}}async fetchImage(e,t,r,o){const i=this.mapUrl,a=this.createExportImageParameters(e,t,r,o);if(!a.layers){const e=document.createElement("canvas");return e.width=t,e.height=r,e}const n=V(o?.timeExtent),l={responseType:"image",query:this._mixCustomParameters({width:t,height:r,...a,time:n,...this.refreshParameters}),signal:o?.signal};return s(i??"",l).then((e=>e.data))}async fetchImageBitmap(e,t,r,o){const i=this.mapUrl??"",a=this.createExportImageParameters(e,t,r,o);if(!a.layers){const e=document.createElement("canvas");return e.width=t,e.height=r,e}const n=V(o?.timeExtent),l={responseType:"blob",query:this._mixCustomParameters({width:t,height:r,...a,time:n,...this.refreshParameters}),signal:o?.signal},{data:p}=await s(i,l);return B(p,i,o?.signal)}fetchFeatureInfo(e,t,r,o,s){const i=R({extent:e,width:t}),a=new k({layer:this,scale:i}),n=A(a.visibleSublayers);if(null==this.featureInfoUrl||null==n)return Promise.resolve([]);if(null==this.fetchFeatureInfoFunction&&null==this.featureInfoFormat)return Promise.resolve([]);const l="1.3.0"===this.version?{I:o,J:s}:{x:o,y:s},p={query_layers:n,request:"GetFeatureInfo",info_format:this.featureInfoFormat,feature_count:25,width:t,height:r,...l},m={...this.createExportImageParameters(e,t,r),...p},u=this._mixCustomParameters(m);return null!=this.fetchFeatureInfoFunction?this.fetchFeatureInfoFunction(u):this._defaultFetchFeatureInfoFunction(h(this.featureInfoUrl,u))}findSublayerById(e){return this.allSublayers.find((t=>t.id===e))}findSublayerByName(e){return this.allSublayers.find((t=>t.name===e))}serviceSupportsSpatialReference(e){return q(this.url)||null!=this.spatialReferences&&this.spatialReferences.some((t=>{const r=900913===t?P.WebMercator:new P({wkid:t});return E(r,e)}))}_defaultFetchFeatureInfoFunction(e){const t=document.createElement("iframe");t.src=g(e),t.style.border="none",t.style.margin="0",t.style.width="100%",t.setAttribute("sandbox","");const s=new o({title:this.title,content:t}),i=new r({sourceLayer:this,popupTemplate:s});return Promise.resolve([i])}async _fetchService(e){if(!this.resourceInfo&&this.parsedUrl?.path){const{path:t,query:r}=this.parsedUrl,{data:o}=await s(t,{query:{SERVICE:"WMS",REQUEST:"GetCapabilities",...r,...this.customParameters},responseType:"xml",signal:e});this.resourceInfo=D(o)}if(this.parsedUrl){const e=new b(this.parsedUrl.path),{httpsDomains:r}=t.request;"https"!==e.scheme||e.port&&"443"!==e.port||!e.host||r.includes(e.host)||r.push(e.host)}this.read(this.resourceInfo,{origin:"service"})}_checkLayerValidity(){if(!this.allSublayers.length)throw new n("wmslayer:empty-layer","The layer doesn't have any sublayer")}_mixCustomParameters(e){if(!this.customLayerParameters&&!this.customParameters)return e;const t={...this.customParameters,...this.customLayerParameters};for(const r in t)e[r.toLowerCase()]=t[r];return e}};function X(e,t){return e.some((e=>{for(const r in e)if(S(e,r,null,t))return!0;return!1}))}function Y(e,t,r){e=e??[];const o=new Map;e.every((e=>null==e.id))&&(e=p(e)).forEach(((e,t)=>e.id=t));for(const i of e){const e=new H;e.read(i,t),r&&!r.includes(e.name)&&(e.visible=!1),o.set(e.id,e)}const s=[];for(const a of e){const e=null!=a.id?o.get(a.id):null;if(e)if(null!=a.parentLayerId&&a.parentLayerId>=0){const t=o.get(a.parentLayerId);if(!t)continue;t.sublayers||(t.sublayers=new i),t.sublayers.push(e)}else s.push(e)}return s}e([w({readOnly:!0})],K.prototype,"allSublayers",void 0),e([w({json:{type:Object,write:!0}})],K.prototype,"customParameters",void 0),e([w({json:{type:Object,write:!0}})],K.prototype,"customLayerParameters",void 0),e([w({type:String,json:{write:!0}})],K.prototype,"copyright",void 0),e([w()],K.prototype,"description",void 0),e([w({readOnly:!0})],K.prototype,"dimensions",void 0),e([w({json:{type:[[Number]],read:{source:"extent"},write:{target:"extent"},origins:{"web-document":{write:{ignoreOrigin:!0}},"portal-item":{write:{ignoreOrigin:!0}}}}})],K.prototype,"fullExtent",void 0),e([x(["web-document","portal-item"],"fullExtent",["extent"])],K.prototype,"readFullExtentFromItemOrMap",null),e([I(["web-document","portal-item"],"fullExtent",{extent:{type:[[Number]]}})],K.prototype,"writeFullExtent",null),e([w({type:[F]})],K.prototype,"fullExtents",void 0),e([w({type:String,json:{write:{ignoreOrigin:!0}}})],K.prototype,"featureInfoFormat",null),e([w({type:[String],readOnly:!0})],K.prototype,"featureInfoFormats",void 0),e([w({type:String,json:{write:{ignoreOrigin:!0}}})],K.prototype,"featureInfoUrl",void 0),e([w()],K.prototype,"fetchFeatureInfoFunction",void 0),e([w({type:String,json:{origins:{"web-document":{default:"image/png",type:J.jsonValues,read:{reader:J.read,source:"format"},write:{writer:J.write,target:"format"}}}}})],K.prototype,"imageFormat",void 0),e([x("imageFormat",["supportedImageFormatTypes"])],K.prototype,"readImageFormat",null),e([w({type:Number,json:{read:{source:"maxHeight"},write:{target:"maxHeight"}}})],K.prototype,"imageMaxHeight",void 0),e([w({type:Number,json:{read:{source:"maxWidth"},write:{target:"maxWidth"}}})],K.prototype,"imageMaxWidth",void 0),e([w()],K.prototype,"imageTransparency",void 0),e([w(N)],K.prototype,"legendEnabled",void 0),e([w({type:["show","hide","hide-children"]})],K.prototype,"listMode",void 0),e([w({type:String,json:{write:{ignoreOrigin:!0}}})],K.prototype,"mapUrl",void 0),e([w({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],K.prototype,"isReference",void 0),e([w({type:["WMS"]})],K.prototype,"operationalLayerType",void 0),e([w()],K.prototype,"resourceInfo",void 0),e([w({type:P,json:{origins:{service:{read:{source:"extent.spatialReference"}}},write:!1}})],K.prototype,"spatialReference",void 0),e([x(["web-document","portal-item"],"spatialReference",["spatialReferences"])],K.prototype,"readSpatialReferenceFromItemOrDocument",null),e([w({type:[v],json:{read:!1,origins:{service:{read:!0},"web-document":{read:!1,write:{ignoreOrigin:!0}},"portal-item":{read:!1,write:{ignoreOrigin:!0}}}}})],K.prototype,"spatialReferences",void 0),e([I(["web-document","portal-item"],"spatialReferences")],K.prototype,"writeSpatialReferences",null),e([w({type:i.ofType(H),json:{write:{target:"layers",overridePolicy(e,t,r){if(X(this.allSublayers,r))return{ignoreOrigin:!0}}}}})],K.prototype,"sublayers",void 0),e([x(["web-document","portal-item"],"sublayers",["layers","visibleLayers"])],K.prototype,"readSublayersFromItemOrMap",null),e([x("service","sublayers",["layers"])],K.prototype,"readSublayers",null),e([I("sublayers",{layers:{type:[H]},visibleLayers:{type:[String]}})],K.prototype,"writeSublayers",null),e([w({json:{read:!1},readOnly:!0,value:"wms"})],K.prototype,"type",void 0),e([w($)],K.prototype,"url",null),e([w({type:String,json:{write:{ignoreOrigin:!0}}})],K.prototype,"version",void 0),K=e([j("esri.layers.WMSLayer")],K);const Z=K;export{Z as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
+ */
5
+ import{getAssetUrl as t}from"../../assets.js";function e(){return r??=(async()=>{const e=await import("../../chunks/dxt_encoder.js");return await e.default({locateFile:e=>t(`esri/libs/dxtEncoder/${e}`)})})(),r}let r;export{e as getDXTEncoder};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.32.0-next.20250119",
3
+ "version": "4.32.0-next.20250121",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{geometryTypes as e}from"../../geometry.js";import o from"../../core/JSONSupport.js";import{clone as r}from"../../core/lang.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{writer as p}from"../../core/accessorSupport/decorators/writer.js";import{getJsonType as l,fromJSON as n}from"../../geometry/support/jsonUtils.js";import m from"../../layers/support/MosaicRule.js";import{interpolationKebab as a}from"../../layers/support/rasterEnums.js";import u from"../../time/TimeExtent.js";import y from"../../geometry/Multipoint.js";import c from"../../geometry/Point.js";var d;let j=d=class extends o{constructor(){super(...arguments),this.geometry=null,this.interpolation="nearest",this.mosaicRule=null,this.outFields=null,this.pixelSize=null,this.returnFirstValueOnly=!0,this.sampleDistance=null,this.sampleCount=null,this.sliceId=null,this.timeExtent=null}writeGeometry(t,e,o){null!=t&&(e.geometryType=l(t),e[o]=t.toJSON())}set locations(t){if(t?.length){const e=new y({spatialReference:t[0].spatialReference,points:t.map((({x:t,y:e})=>[t,e]))});this._set("locations",t),this.geometry=e}}clone(){return new d(r({geometry:this.geometry,locations:this.locations,interpolation:this.interpolation,mosaicRule:this.mosaicRule,outFields:this.outFields,raster:this.raster,returnFirstValueOnly:this.returnFirstValueOnly,sampleDistance:this.sampleDistance,sampleCount:this.sampleCount,sliceId:this.sliceId,pixelSize:this.pixelSize,timeExtent:this.timeExtent}))}};t([s({types:e,json:{read:n}})],j.prototype,"geometry",void 0),t([p("geometry")],j.prototype,"writeGeometry",null),t([s()],j.prototype,"locations",null),t([s({type:String,json:{type:a.jsonValues,read:a.read,write:a.write}})],j.prototype,"interpolation",void 0),t([s({type:m,json:{write:!0}})],j.prototype,"mosaicRule",void 0),t([s({type:[String],json:{write:!0}})],j.prototype,"outFields",void 0),t([s({type:c,json:{write:!0}})],j.prototype,"pixelSize",void 0),t([s({type:String,json:{write:!0}})],j.prototype,"raster",void 0),t([s({type:Boolean,json:{write:!0}})],j.prototype,"returnFirstValueOnly",void 0),t([s({type:Number,json:{write:!0}})],j.prototype,"sampleDistance",void 0),t([s({type:Number,json:{write:!0}})],j.prototype,"sampleCount",void 0),t([s({type:Number,json:{write:!0}})],j.prototype,"sliceId",void 0),t([s({type:u,json:{read:{source:"time"},write:{target:"time"}}})],j.prototype,"timeExtent",void 0),j=d=t([i("esri.rest.support.ImageSampleParameters")],j);const h=j;export{h as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{geometryTypes as e}from"../../geometry.js";import o from"../../core/JSONSupport.js";import{clone as r}from"../../core/lang.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{writer as p}from"../../core/accessorSupport/decorators/writer.js";import{getJsonType as l,fromJSON as n}from"../../geometry/support/jsonUtils.js";import m from"../../layers/support/MosaicRule.js";import{interpolationKebab as a}from"../../layers/support/rasterEnums.js";import u from"../../time/TimeExtent.js";import y from"../../geometry/Multipoint.js";import c from"../../geometry/Point.js";var d;let j=d=class extends o{constructor(){super(...arguments),this.geometry=null,this.interpolation="nearest",this.mosaicRule=null,this.outFields=null,this.pixelSize=null,this.returnFirstValueOnly=!0,this.sampleDistance=null,this.sampleCount=null,this.sliceId=null,this.timeExtent=null}writeGeometry(t,e,o){null!=t&&(e.geometryType=l(t),e[o]=t.toJSON())}set locations(t){if(t?.length){const e=new y({spatialReference:t[0].spatialReference,points:t.map((({x:t,y:e})=>[t,e]))});this._set("locations",t),this.geometry=e}}clone(){return new d(r({geometry:this.geometry,locations:this.locations,interpolation:this.interpolation,mosaicRule:this.mosaicRule,outFields:this.outFields,raster:this.raster,returnFirstValueOnly:this.returnFirstValueOnly,sampleDistance:this.sampleDistance,sampleCount:this.sampleCount,sliceId:this.sliceId,pixelSize:this.pixelSize,timeExtent:this.timeExtent}))}};t([s({types:e,json:{read:n}})],j.prototype,"geometry",void 0),t([p("geometry")],j.prototype,"writeGeometry",null),t([s({type:[c]})],j.prototype,"locations",null),t([s({type:String,json:{type:a.jsonValues,read:a.read,write:a.write}})],j.prototype,"interpolation",void 0),t([s({type:m,json:{write:!0}})],j.prototype,"mosaicRule",void 0),t([s({type:[String],json:{write:!0}})],j.prototype,"outFields",void 0),t([s({type:c,json:{write:!0}})],j.prototype,"pixelSize",void 0),t([s({type:String,json:{write:!0}})],j.prototype,"raster",void 0),t([s({type:Boolean,json:{write:!0}})],j.prototype,"returnFirstValueOnly",void 0),t([s({type:Number,json:{write:!0}})],j.prototype,"sampleDistance",void 0),t([s({type:Number,json:{write:!0}})],j.prototype,"sampleCount",void 0),t([s({type:Number,json:{write:!0}})],j.prototype,"sliceId",void 0),t([s({type:u,json:{read:{source:"time"},write:{target:"time"}}})],j.prototype,"timeExtent",void 0),j=d=t([i("esri.rest.support.ImageSampleParameters")],j);const h=j;export{h as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- const f="20250119",c="43f7bdcd5ea622f1880239fae071608d238075cf";export{f as buildDate,c as commitHash};
5
+ const b="20250121",c="cf54bebb42d97bf1f2c78274d21efb1ebcfc682b";export{b as buildDate,c as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as c}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,i as h,f as u}from"../../../chunks/vec32.js";import{ZEROS as g,fromValues as _,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as f,ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as b,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as T}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as R}from"../../ViewingMode.js";import{TextureUpdate as x}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlayContent as v}from"./OverlayContent.js";import{overlayRenderOccludedFlag as w}from"./OverlayRenderer.js";import{PatchRenderData as P}from"./PatchRenderData.js";import{RenderOrder as D}from"./RenderOrder.js";import{TerrainAttributesCache as S}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as E}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{TileUpdate as A}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as N,compareTiles as B}from"./tileUtils.js";import{TransparencyMode as I}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as q,ComponentIntersectionData as F}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as U}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncRenderPlugin as L,ConsumesDepth as M,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as z}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as V}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as Y}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as Q,StoreResults as W}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as X}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as K,intersectTriangles as Z,MeshIntersectionOptions as J}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as $}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as ee}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as te}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ie,getVerticalOffsetTerrain as re}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as se}from"../webgl-engine/materials/DrawParameters.js";import{T as ne}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as ae}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as oe}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as le}from"../../webgl/enums.js";const ce=7,de=10,he=b();let ue=class extends L{get _isGlobal(){return this._stage.viewingMode===R.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=Q.TERRAIN,this.isGround=!0,this._passParameters=new ne,this._drawParameters=new se,this._renderDataPool=new s(P),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new j,this._castShadows=!1,this._inViewshed=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=X.Occlude,this.produces=new Map([[$.OPAQUE_TERRAIN,()=>this._produces()&&this.transparency===I.Opaque],[$.TRANSPARENT_TERRAIN,()=>this._produces()&&(this.transparency===I.Transparent||this.transparency===I.InvisibleWithDraped)],[$.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileSize=256,this._configuration=new oe(t.viewingMode===R.Global),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new S(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?w:X.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?M:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get tileRenderer(){return this._tileRenderer}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return ie}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,A.TEXTURE_FADING)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=f(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===A.TEXTURE_FADING?x.FADING:x.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[O.ELEVATION])i.pendingUpdates&=~A.GEOMETRY;e.resetPendingUpdate(A.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=de-ce,i=Math.max(0,Math.floor((e.level-t)/ce)*ce);if(this._isGlobal&&0===i)return g;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=V.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=V.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=V.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C({rctx:this._rctx,tileSize:this._tileSize,techniques:this._techniques,cache:this._tileTextureCache}),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==I.Opaque)return;const s=ge,n=_e;d(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,g=e.options.store===W.MIN,_=!!e.results.ground.target,p=re(e.verticalOffset),f=e.tolerance;let m,b=g&&null!=a.dist?a.dist:1/0;const R=e.options,x=R.normalRequired||!R.backfacesTerrain,O=new J(!1,x),v=h=>{const _=h.renderData;if(!_?.vao)return;const v=_.geometry;y(he,v.boundingBox);const w=_.localOrigin;null!=p&&(p.localOrigin=w,p.applyToAabb(he));const P=he;if(pe[0]=i[0]-w[0],pe[1]=i[1]-w[1],pe[2]=i[2]-w[2],!K(P,pe,n,f,b))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),b=g&&null!=a.dist?a.dist:1/0},S=(n,c,d)=>{if((!x||null!=d)&&n>=0&&(R.backfacesTerrain||u(d,s)<0)&&(R.invisibleTerrain||!R.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),R.isFiltered)return;R.store===W.ALL&&(null==m?(m=Y(e.ray),D(m,n,d),e.results.all.push(m)):n<m.dist&&D(m,n,d)),(null==a.dist||n<a.dist)&&D(a,n,d),R.store!==W.MIN&&(null==o.dist||n>o.dist)&&D(o,n,d)}},E=fe;d(E,r,w);const{indices:C,indexCount:A}=v,j=v.vertexAttributes,N=j.getField(te.POSITION,T),B=new z(N.typedBuffer,3,j.stride/4),I=A/3;if(!p&&I>q){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new F(C,0,I,B)),e.intersectionData.intersectRay(pe,E,O,S)}else Z(pe,E,0,I,C,B,p,O,S)},w=this._rootTiles;if(null!=w){(()=>{const t=this._tileIterator;t.reset(w);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==p&&!e.intersectsRay(i,s,f,b)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}acquireTechniques(e){const t=!!has("enable-feature:terrain-shadows")&&e.bind.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bind.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bind.slot===$.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&w))return null}else{const t=this.transparency===I.Opaque?$.OPAQUE_TERRAIN:$.TRANSPARENT_TERRAIN;if(e.bind.slot!==t)return null}if(this.transparency===I.Invisible)return null;switch(this._configuration.screenSpaceReflections=this._configuration.cloudReflections=this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._configuration.overlayMode=this._overlayRenderer.mode,e.output){case U.Color:case U.ColorEmission:return this._configuration.screenSpaceReflections=null!=e.bind.ssr.lastFrameColor,this._configuration.cloudReflections=null!=e.bind.clouds.data,this._configuration.receiveShadows=e.bind.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bind.ssao,this._acquireTechnique(e.output,e.bind.slot===$.OCCLUDED_TERRAIN);case U.Shadow:case U.ShadowExcludeHighlight:return this._castShadows?this._acquireTechnique(U.Shadow,!1):null;case U.ViewshedShadow:return this._inViewshed?this._acquireTechnique(U.ViewshedShadow,!1):null;case U.Depth:case U.Normal:return this._acquireTechnique(e.output,!1);case U.ObjectAndLayerIdColor:return this._acquireTechnique(U.ObjectAndLayerIdColor,!1);case U.Highlight:return this._overlayRenderer.hasHighlights?this._acquireTechnique(U.Highlight,!1):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case U.Color:case U.ColorEmission:{const i=e.bind.slot===$.OCCLUDED_TERRAIN?v.Occluded:v.Color;this._renderMaterialPass(e,t,i);break}case U.Depth:case U.Normal:this._renderAuxiliaryPass(e,t,v.Color,this._visiblePatchesByOrigin);break;case U.Highlight:this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(v.Highlight)&&0===e.bind.highlightLevel&&this._renderAuxiliaryPass(e,t,v.Highlight,this._visiblePatchesByOrigin);break;case U.Shadow:case U.ShadowExcludeHighlight:case U.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case U.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,v.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=_(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,x.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?G.GridComposite:null!=i.backgroundColor?G.ColorComposite:G.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==D.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>B(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bind,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],le.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bind,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bind.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=ee(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===v.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",g),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:g;this._configuration.tileBlendInput===G.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?le.LINES:le.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;this._drawParameters.origin=r,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._configuration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,c,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(E&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.rctx.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._techniques.acquire(ae,this._configuration)}get test(){}hasHighlightOptions(e){return this._overlayRenderer.hasHighlightOptions(e)}};e([o({readOnly:!0})],ue.prototype,"_isGlobal",null),e([o()],ue.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],ue.prototype,"renderingDisabled",null),e([o({value:!0})],ue.prototype,"visible",null),e([o()],ue.prototype,"renderPatchBorders",null),e([o()],ue.prototype,"visualizeNormals",null),e([o()],ue.prototype,"cullBackFaces",null),e([o({value:D.FRONT_TO_BACK})],ue.prototype,"renderOrder",null),e([o()],ue.prototype,"wireframe",null),ue=e([l("esri.views.3d.terrain.TerrainRenderer")],ue);const ge=p(),_e=p(),pe=p(),fe=p();export{ue as TerrainRenderer};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as c}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,i as h,f as u}from"../../../chunks/vec32.js";import{ZEROS as g,fromValues as _,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as f,ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as b,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as T}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as R}from"../../ViewingMode.js";import{TextureUpdate as x}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlayContent as v}from"./OverlayContent.js";import{overlayRenderOccludedFlag as w}from"./OverlayRenderer.js";import{PatchRenderData as P}from"./PatchRenderData.js";import{RenderOrder as D}from"./RenderOrder.js";import{TerrainAttributesCache as S}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as E}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{TileUpdate as A}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as N,compareTiles as B}from"./tileUtils.js";import{TransparencyMode as I}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as q,ComponentIntersectionData as F}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as U}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncRenderPlugin as M,ConsumesDepth as L,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as z}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as V}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as Y}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as Q,StoreResults as W}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as X}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as K,intersectTriangles as Z,MeshIntersectionOptions as J}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as $}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as ee}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as te}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ie,getVerticalOffsetTerrain as re}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as se}from"../webgl-engine/materials/DrawParameters.js";import{T as ne}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as ae}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as oe}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as le}from"../../webgl/enums.js";const ce=7,de=10,he=b();let ue=class extends M{get _isGlobal(){return this._stage.viewingMode===R.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=Q.TERRAIN,this.isGround=!0,this._passParameters=new ne,this._drawParameters=new se,this._renderDataPool=new s(P),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new j,this._castShadows=!1,this._inViewshed=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=X.Occlude,this.produces=new Map([[$.OPAQUE_TERRAIN,()=>this._produces()&&this.transparency===I.Opaque],[$.TRANSPARENT_TERRAIN,()=>this._produces()&&(this.transparency===I.Transparent||this.transparency===I.InvisibleWithDraped)],[$.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileSize=256,this._configuration=new oe(t.viewingMode===R.Global),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new S(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?w:X.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?L:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get tileRenderer(){return this._tileRenderer}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return ie}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,A.TEXTURE_FADING)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=f(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===A.TEXTURE_FADING?x.FADING:x.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[O.ELEVATION])i.pendingUpdates&=~A.GEOMETRY;e.resetPendingUpdate(A.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=de-ce,i=Math.max(0,Math.floor((e.level-t)/ce)*ce);if(this._isGlobal&&0===i)return g;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=V.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=V.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=V.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C({rctx:this._rctx,tileSize:this._tileSize,techniques:this._techniques,cache:this._tileTextureCache}),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==I.Opaque)return;const s=ge,n=_e;d(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,g=e.options.store===W.MIN,_=!!e.results.ground.target,p=re(e.verticalOffset),f=e.tolerance;let m,b=g&&null!=a.dist?a.dist:1/0;const R=e.options,x=R.normalRequired||!R.backfacesTerrain,O=new J(!1,x),v=h=>{const _=h.renderData;if(!_?.vao)return;const v=_.geometry;y(he,v.boundingBox);const w=_.localOrigin;null!=p&&(p.localOrigin=w,p.applyToAabb(he));const P=he;if(pe[0]=i[0]-w[0],pe[1]=i[1]-w[1],pe[2]=i[2]-w[2],!K(P,pe,n,f,b))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),b=g&&null!=a.dist?a.dist:1/0},S=(n,c,d)=>{if((!x||null!=d)&&n>=0&&(R.backfacesTerrain||u(d,s)<0)&&(R.invisibleTerrain||!R.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),R.isFiltered)return;R.store===W.ALL&&(null==m?(m=Y(e.ray),D(m,n,d),e.results.all.push(m)):n<m.dist&&D(m,n,d)),(null==a.dist||n<a.dist)&&D(a,n,d),R.store!==W.MIN&&(null==o.dist||n>o.dist)&&D(o,n,d)}},E=fe;d(E,r,w);const{indices:C,indexCount:A}=v,j=v.vertexAttributes,N=j.getField(te.POSITION,T),B=new z(N.typedBuffer,3,j.stride/4),I=A/3;if(!p&&I>q){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new F(C,0,I,B)),e.intersectionData.intersectRay(pe,E,O,S)}else Z(pe,E,0,I,C,B,p,O,S)},w=this._rootTiles;if(null!=w){(()=>{const t=this._tileIterator;t.reset(w);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==p&&!e.intersectsRay(i,s,f,b)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}acquireTechniques(e){const t=!!has("enable-feature:terrain-shadows")&&e.bind.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bind.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bind.slot===$.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&w))return null}else{const t=this.transparency===I.Opaque?$.OPAQUE_TERRAIN:$.TRANSPARENT_TERRAIN;if(e.bind.slot!==t)return null}if(this.transparency===I.Invisible)return null;switch(this._configuration.screenSpaceReflections=this._configuration.cloudReflections=this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._configuration.overlayMode=this._overlayRenderer.mode,e.output){case U.Color:case U.ColorEmission:return this._configuration.screenSpaceReflections=null!=e.bind.ssr.lastFrameColor,this._configuration.cloudReflections=null!=e.bind.clouds.data,this._configuration.receiveShadows=e.bind.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bind.ssao,this._acquireTechnique(e.output,e.bind.slot===$.OCCLUDED_TERRAIN);case U.Shadow:case U.ShadowExcludeHighlight:return this._castShadows?this._acquireTechnique(U.Shadow,!1):null;case U.ViewshedShadow:return this._inViewshed?this._acquireTechnique(U.ViewshedShadow,!1):null;case U.Depth:case U.Normal:return this._acquireTechnique(e.output,!1);case U.ObjectAndLayerIdColor:return this._acquireTechnique(U.ObjectAndLayerIdColor,!1);case U.Highlight:return this._overlayRenderer.hasHighlights?this._acquireTechnique(U.Highlight,!1):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case U.Color:case U.ColorEmission:{const i=e.bind.slot===$.OCCLUDED_TERRAIN?v.Occluded:v.Color;this._renderMaterialPass(e,t,i);break}case U.Depth:case U.Normal:this._renderAuxiliaryPass(e,t,v.Color,this._visiblePatchesByOrigin);break;case U.Highlight:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(v.Highlight)&&this._overlayRenderer.hasHighlightOptions(i)&&this._renderAuxiliaryPass(e,t,v.Highlight,this._visiblePatchesByOrigin);break}case U.Shadow:case U.ShadowExcludeHighlight:case U.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case U.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,v.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=_(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,x.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?G.GridComposite:null!=i.backgroundColor?G.ColorComposite:G.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==D.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>B(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bind,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],le.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bind,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bind.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=ee(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===v.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",g),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:g;this._configuration.tileBlendInput===G.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?le.LINES:le.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;this._drawParameters.origin=r,t.program.bindDraw(e.bind,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._configuration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,c,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(E&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.rctx.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._techniques.acquire(ae,this._configuration)}get test(){}hasHighlightOptions(e){return this._overlayRenderer.hasHighlightOptions(e)}};e([o({readOnly:!0})],ue.prototype,"_isGlobal",null),e([o()],ue.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],ue.prototype,"renderingDisabled",null),e([o({value:!0})],ue.prototype,"visible",null),e([o()],ue.prototype,"renderPatchBorders",null),e([o()],ue.prototype,"visualizeNormals",null),e([o()],ue.prototype,"cullBackFaces",null),e([o({value:D.FRONT_TO_BACK})],ue.prototype,"renderOrder",null),e([o()],ue.prototype,"wireframe",null),ue=e([l("esri.views.3d.terrain.TerrainRenderer")],ue);const ge=p(),_e=p(),pe=p(),fe=p();export{ue as TerrainRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../core/PooledArray.js";import{RenderPassIdentifier as t}from"./AllRenderPasses.js";import{OITPass as r}from"../../lib/OITPass.js";import{DataType as i}from"../../../../webgl/enums.js";var s;!function(e){e[e.FrontToBack=0]="FrontToBack",e[e.BackToFront=1]="BackToFront"}(s||(s={}));class n{constructor(t,r,i=s.FrontToBack){this._rctx=t,this._techniques=r,this._sorting=i,this._draws=new e({initialSize:32,allocator:e=>e??{material:null,geometry:null,geometryRanges:null,bindDrawParams:null,depthSquaredHint:0,indexType:0}}),this._previouslyBoundDraw=new Map}submitDraw(e,t,r,i,s){const n=this._draws.pushNew();n.geometry=t,n.geometryRanges=r,n.material=e,n.depthSquaredHint=i,n.indexType=(t.indexed?t.vao.indexBuffer.indexType:null)??0,n.highlightName=s}acquire(e,t){return this._draws.map((r=>r.material.acquireTechnique(this._techniques,e,t,r.geometry.parameters)))}dispatch(e,i,s){const n=this._rctx;this._previouslyBoundDraw.clear();let a=null;const h=this._draws.length;for(let l=0;l<h;l++){const h=this._draws.data[l];if(e.identifier===t.Highlight){const e=h.highlightName;if(e&&e!==i.highlight?.name)continue}const c=s[l];c===a&&i.oitPass===r.NONE||(n.bindTechnique(c,i,e),a=c);const{geometryRanges:d,indexType:u,geometry:m,material:g}=h;n.bindVAO(m.vao),this._previouslyBoundDraw.get(c)!==g&&(c.program.bindDraw(i,e,g),this._previouslyBoundDraw.set(c,g));const p=d.length,{primitiveType:w}=m;for(let e=0;e<p;e+=2){const t=d[e],r=d[e+1];if(0!==u){const e=o.get(u);n.drawElements(w,r,u,t*e)}else n.drawArrays(w,t,r)}}}prepareSubmit(){this._draws.clear()}finishSubmit(){const e=this._sorting===s.FrontToBack?1:-1;this._draws.sort(((t,r)=>{const i=e*(t.depthSquaredHint-r.depthSquaredHint);return 0!==i?i:t.geometry.vao.byteSize-r.geometry.vao.byteSize}))}get count(){return this._draws.length}}const o=new Map;o.set(i.UNSIGNED_BYTE,1),o.set(i.UNSIGNED_SHORT,2),o.set(i.UNSIGNED_INT,4);export{n as RenderPass,s as RenderPassSorting};
5
+ import e from"../../../../../core/PooledArray.js";import{RenderPassIdentifier as t}from"./AllRenderPasses.js";import{OITPass as i}from"../../lib/OITPass.js";import{DataType as r}from"../../../../webgl/enums.js";var s;!function(e){e[e.FrontToBack=0]="FrontToBack",e[e.BackToFront=1]="BackToFront"}(s||(s={}));class n{constructor(t,i,r=s.FrontToBack){this._rctx=t,this._techniques=i,this._sorting=r,this._draws=new e({initialSize:32,allocator:e=>e??{material:null,geometry:null,geometryRanges:null,bindDrawParams:null,depthSquaredHint:0,indexType:0}}),this._previouslyBoundDraw=new Map}submitDraw(e,t,i,r,s){const n=this._draws.pushNew();n.geometry=t,n.geometryRanges=i,n.material=e,n.depthSquaredHint=r,n.indexType=(t.indexed?t.vao.indexBuffer.indexType:null)??0,n.highlightName=s}acquire(e,t){return this._draws.map((i=>i.material.acquireTechnique(this._techniques,e,t,i.geometry.parameters)))}dispatch(e,r,s){const n=this._rctx;this._previouslyBoundDraw.clear();let a=null;const h=this._draws.length,l=r.highlight?.name;for(let c=0;c<h;c++){const h=this._draws.data[c];if(e.identifier===t.Highlight){const e=h.highlightName;if(e){if(e!==l)continue}else if(!l||!r.overlay?.hasHighlightOptions(l))continue}const d=s[c];d===a&&r.oitPass===i.NONE||(n.bindTechnique(d,r,e),a=d);const{geometryRanges:u,indexType:m,geometry:g,material:p}=h;n.bindVAO(g.vao),this._previouslyBoundDraw.get(d)!==p&&(d.program.bindDraw(r,e,p),this._previouslyBoundDraw.set(d,p));const y=u.length,{primitiveType:w}=g;for(let e=0;e<y;e+=2){const t=u[e],i=u[e+1];if(0!==m){const e=o.get(m);n.drawElements(w,i,m,t*e)}else n.drawArrays(w,t,i)}}}prepareSubmit(){this._draws.clear()}finishSubmit(){const e=this._sorting===s.FrontToBack?1:-1;this._draws.sort(((t,i)=>{const r=e*(t.depthSquaredHint-i.depthSquaredHint);return 0!==r?r:t.geometry.vao.byteSize-i.geometry.vao.byteSize}))}get count(){return this._draws.length}}const o=new Map;o.set(r.UNSIGNED_BYTE,1),o.set(r.UNSIGNED_SHORT,2),o.set(r.UNSIGNED_INT,4);export{n as RenderPass,s as RenderPassSorting};
@@ -2,7 +2,7 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{ShaderOutput as i}from"../ShaderOutput.js";import{Integer2PassUniform as e}from"../../shaderModules/Integer2PassUniform.js";import{IntegerPassUniform as t}from"../../shaderModules/IntegerPassUniform.js";import{glsl as h}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as l}from"../../shaderModules/Texture2DPassUniform.js";function g(g,d){const{fragment:u}=g;d.output===i.Highlight?(u.uniforms.add(new l("depthTexture",((i,e)=>e.mainDepth)),new l("highlightTexture",((i,e)=>e.highlightMixTexture)),new t("highlightLevel",((i,e)=>e.highlightLevel??0)),new e("highlightMixOrigin",((i,e)=>e.highlightMixOrigin))),g.outputs.add("fragHighlight","vec2",0),u.code.add(h`vec2 getAccumulatedHighlight() {
5
+ import{HighlightReadBitmap as i}from"../HighlightReadBitmap.glsl.js";import{ShaderOutput as t}from"../ShaderOutput.js";import{Integer2PassUniform as e}from"../../shaderModules/Integer2PassUniform.js";import{IntegerPassUniform as h}from"../../shaderModules/IntegerPassUniform.js";import{glsl as l}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as g}from"../../shaderModules/Texture2DPassUniform.js";function u(u,d){const{fragment:o}=u;d.output===t.Highlight?(o.uniforms.add(new g("depthTexture",((i,t)=>t.mainDepth)),new g("highlightTexture",((i,t)=>t.highlightMixTexture)),new h("highlightLevel",((i,t)=>t.highlightLevel??0)),new e("highlightMixOrigin",((i,t)=>t.highlightMixOrigin))),u.outputs.add("fragHighlight","vec2",0),u.include(i),o.code.add(l`vec2 getAccumulatedHighlight() {
6
6
  return texelFetch(highlightTexture, ivec2(gl_FragCoord.xy) - highlightMixOrigin, 0).rg;
7
7
  }
8
8
  void outputHighlight(bool occluded) {
@@ -30,10 +30,8 @@ return gl_FragCoord.z > sceneDepth + 5e-7;
30
30
  }
31
31
  void calculateOcclusionAndOutputHighlight() {
32
32
  outputHighlight(isHighlightOccluded());
33
- }`),d.canHaveOverlay&&(u.constants.add("occlusionAndMask","int",85),u.code.add(h`void outputAllHighlights(vec2 highlightToAdd) {
34
- if (highlightToAdd == vec2(0.0)) { discard; }
35
- uint occludedOrMask = isHighlightOccluded() ? 0xaau : 0u;
36
- uvec2 added = uvec2(highlightToAdd * 255.0);
37
- uvec2 masked = (added & uvec2(occlusionAndMask)) | (uvec2(occludedOrMask) & (added<<1));
38
- fragHighlight = vec2(masked) / 255.0;
39
- }`))):u.code.add(h`void calculateOcclusionAndOutputHighlight() {}`)}export{g as OutputHighlight};
33
+ }`),d.canHaveOverlay&&o.code.add(l`void calculateOcclusionAndOutputHighlightOverlay(vec2 highlightToAdd) {
34
+ uint levelBits = readLevelBits(highlightToAdd, highlightLevel);
35
+ if ((levelBits & 1u) == 0u) { discard; }
36
+ outputHighlight(isHighlightOccluded());
37
+ }`)):o.code.add(l`void calculateOcclusionAndOutputHighlight() {}`)}export{u as OutputHighlight};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as s,abortMaybe as a,destroyMaybe as n,releaseMaybe as h}from"../../../../core/maybe.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{watch as d,syncAndInitial as _,initial as l,sync as p}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as c,invert as g,multiply as f}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as T}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{ZEROS as E}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as P,ZEROS as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as S}from"../../../../geometry/support/Indices.js";import{RenderCategory as C,InternalRenderCategory as w}from"../../webgl.js";import{debugFlags as I}from"../../support/debugFlags.js";import{DepthFormat as D,ColorFormat as N}from"../../webgl/formats.js";import{FBOCache as O,defaultWebGLFBO as H}from"../core/FBOCache.js";import{RenderPassManager as y}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as x,isColorOrColorEmission as L}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as M}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as v}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as U}from"../effects/RenderNodes.js";import{releaseTechniques as F}from"../effects/RenderPlugin.js";import{RenderPluginManager as G}from"../effects/RenderPluginManager.js";import{Blit as q}from"../effects/blit/Blit.js";import{renderHighlightBuffer as j}from"../effects/highlight/Highlight.js";import{OITBlend as V}from"../effects/transparency/OITBlend.js";import{AnimationTimer as B}from"./AnimationTimer.js";import{AnimationTimeStep as Q}from"./AnimationTimeStep.js";import{RenderRequestType as W}from"./basicInterfaces.js";import{BoundingInfo as k}from"./BoundingInfo.js";import{DepthRange as z}from"./DepthRange.js";import{depthRangeFromScene as X}from"./depthRangeUtils.js";import{MainFramebuffer as Y}from"./MainFramebuffer.js";import{RenderOccludedFlag as K}from"./Material.js";import{OITPass as J}from"./OITPass.js";import{RenderContext as Z,defaultRenderOccludedMask as $}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as ee,RendererTarget as te}from"./rendererUtils.js";import{setupFeatureDefaults as re,RenderFeature as ie}from"./RenderFeature.js";import{RenderPluginInput as se}from"./RenderPluginInput.js";import{RenderSlot as ae}from"./RenderSlot.js";import{ShadowAccumulator as ne}from"./ShadowAccumulator.js";import{ShadowMap as he,SnapshotSlot as oe}from"./ShadowMap.js";import de from"./SliceHelper.js";import{Transparency as _e}from"./edgeRendering/interfaces.js";import{MergedRenderer as le}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as pe}from"../parts/renderUtils.js";import{RendererPerformanceInfo as ue,PerformanceCategory as me}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ce}from"../../../support/RenderState.js";import{PixelFormat as ge,PixelType as fe,DepthStencilAttachment as be,FramebufferBit as Te,ColorAttachment as Ae}from"../../../webgl/enums.js";class Ee{constructor(e,t,r,s,a,n){this._stage=e,this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._renderers=new Map,this.renderPassManager=new y,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=P(0,0,0,1),this._sliceHelper=new de,this._blit=null,this._oitblend=null,this._state=u(ce.IDLE),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new Q,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(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 O(s),this._renderStateFeatures=u(re(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new Y(this.fboCache),this.performanceInfo=new ue(this._rctx),this._shadowMap=new he(this.fboCache,e.viewingMode),this._shadowAccumulator=new ne(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((e,t,r)=>{const i=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,i),this._renderShadowCascades(x.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new Z(this._rctx,this._shadowMap,r),this._nodes=new U(this._renderContext),this._plugins=new G({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this._handles=[d((()=>this._stage.view.state.camera),(()=>n()),_),d((()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(_e.TRANSPARENT):()=>{},n()}),l),d((()=>this._stage.view.environment.background?.color),(e=>{const t=e?i(e):R;A(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),_),d((()=>this._stage.view.state.camera.relativeElevation),(e=>this._inGlobeView=(e??1/0)>=v),_),d((()=>this._bindParameters.clouds.fadeFactor),(()=>this._bindParameters.fadeLighting()),p),d((()=>this._bindParameters.clouds.data?.state),(()=>n()),p),d((()=>this._stage.view.state.highlights),(e=>{this._bindParameters.highlights=e,this._updateHighlights(),n()}),l)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=s(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=a(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._renderers.clear(),this._blit=null,this._oitblend=null,k.prune(),le.prune(),S()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=re(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((i=>i.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(ie.HighQualityTransparency)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(ie.WaterReflection))}get _hasHighlights(){return this._plugins.produces(x.Highlight,ae.OPAQUE_MATERIAL,ae.TRANSPARENT_MATERIAL,ae.DRAPED_MATERIAL,ae.HUD_MATERIAL,ae.LABEL_MATERIAL)}hasHighlightOptions(e){return this._plugins.hasHighlightOptions(e)}get _hasHUDHighlights(){return this._plugins.produces(x.Highlight,ae.HUD_MATERIAL,ae.LABEL_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(ie.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(ie.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(ie.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=h(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=h(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=h(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");o(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Le(this._stage.view.resourceController)});return this._handles.push(d((()=>r.updating),(()=>this._requestRender()),p)),this._requestRender(),this._edgeViewCallbacks.forEach((e=>e(r))),this._edgeViewCallbacks.length=0,r}))),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&c(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slicePlane(e){this._sliceHelper.plane!==e&&(this._sliceHelper.plane=e,this._requestRender())}get plugins(){return this._plugins}getMaterialRenderer(e){return this._renderers.get(e)}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:i,updates:s}=e;if(0===r.length&&0===i.length&&0===s.length)return;ee(e).forEach(((r,i)=>{if(t.done)return;let s=this._renderers.get(i);null==s&&r.adds.length>0&&(s=new le({material:i,highlightOrderMap:this._stage.view.state.highlightOrderMap}),s.initializeRenderContext(this._plugins.context),this._plugins.add(s),this._renderers.set(i,s)),s&&(s.modify(r),s.updateHighlights(this._stage.view.state.highlightOrderMap),0===s.numGeometries&&(this._renderers.delete(s.material),this._plugins.remove(s),s.destroy())),r.removes.forEach((t=>e.removes.removeUnordered(t))),r.adds.forEach((t=>e.adds.removeUnordered(t))),r.updates.forEach((t=>e.updates.removeUnordered(t))),t.madeProgress()})),this.updateHasFlags()}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(x.Color,...De),has.water=this._plugins.produces(x.Normal,ae.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new B(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation),null!=e.forcedAnimationTime&&this._animationTimer.forceTime(e.forcedAnimationTime);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?s(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=te.Default,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new pe(this._pluginInput.get(C.FINAL),null)}_render(e,t,r=te.Default,i){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===te.Default,this._disposeBindBuffers();const{camera:s,contentCamera:a,mode:n,alignPixelEnabled:o}=e;this._state.value=n;const d=this._nodes.produces("magnifier-color"),_=this._nodes.produces("final-color"),l=this._nodes.require("emissive",C.FINAL,C.COMPOSITE)>0&&this._plugins.hasEmissions,p=l?x.ColorEmission:x.Color;this._renderContext.time=t,this._renderContext.output=p,this._bindParameters.oitPass=J.NONE,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null,this._bindParameters.slicePlane=this._sliceHelper.plane,this._bindParameters.viewshedEnabled=this._nodes.produces(w.VIEWSHED),this._renderOverlay(t),s.setGLViewport(this._rctx);const u=this._framebuffer,m=u.initialize(s.fullWidth,s.fullHeight,this._backgroundColor,l);this.hasReflections?(m?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=m):m?.release(),this._ensureBindParametersCamera(s,a),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const c=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(x.Color,...we);this._precompilePrepasses(),this.performanceInfo.advance(me.PREPARE);const f=this._computeDepthRange(s);this._renderShadowMap(s,this._bindParameters.lighting.mainLight.direction,f),this._ensureBindParametersCamera(s,a),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,s,a),this._ensureBindParametersSSR(t),this._precompileShaders(c,g,p),this._renderContext.output=p,u.bind(),this._bindParameters.mainDepth=u.depth.attachment;const b=this.plugins.produces(x.Color,...Ce);b&&this._renderOpaqueGeometry(),u.update((e=>this._renderNodes(C.OPAQUE,e,b))),this.fboCache.debugCallback?.("opaque-color",u.color.fbo),u.update((e=>this._renderNodes(w.OPAQUE_ENVIRONMENT,e))),this.fboCache.debugCallback?.(w.OPAQUE_ENVIRONMENT,u.color.fbo),this._renderTerrainDepth(c),this._renderEdges(_e.OPAQUE),u.bind(),this._renderPlugins(ae.VOXEL,me.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOIT(Pe.Geometry,p):this._renderTransparentGeometry()),u.update((e=>this._renderNodes(C.TRANSPARENT,e,g))),this.fboCache.debugCallback?.("transparent-color",u.color.fbo),this._renderGeometryDepth(c),this._renderHUDVisibility(),c||this._plugins.render(this._pluginInput,ae.LINE_CALLOUTS);const T=r===te.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this._renderEdges(_e.TRANSPARENT);const A=this._hasTransparentTerrain?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(me.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(M.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,A.getTexture())),this._renderHUD(M.Occluded,u.color,p))),this._bindParameters.cullAboveTerrain=!1,A&&(u.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,A.getTexture()),A.release(),c&&(this._renderEdges(_e.OPAQUE),g&&(this._oitEnabled?this._renderOIT(Pe.Geometry,p):this._renderTransparentGeometry(),this.performanceInfo.advance(me.TRANSPARENT)),this._renderEdges(_e.TRANSPARENT))),this._bindParameters.ssao=h(this._bindParameters.ssao),c&&this._renderLineCallouts(M.NotOccluded),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment(),this._pluginInput.set("focusArea",this._renderFocusAreaGeometry()),u.update((e=>this._renderNodes(w.TRANSPARENT_ENVIRONMENT,e))),u.update((e=>this._renderNodes(w.VIEWSHED,e))),u.update((e=>this._renderNodes(w.LASERLINES,e))),u.update((e=>this._renderNodes(w.OCCLUDED,e))),this._pluginInput.set("highlights",this._renderHighlightPrepass()),u.update((e=>this._renderNodes(C.COMPOSITE,e)));const E=!(r!==te.Default||_||d&&!i),P=this._pluginInput.get(C.COMPOSITE),R=E?H:this.fboCache.acquire(P.fbo.width,P.fbo.height,w.ANTIALIASING),S=this._nodes.produces(w.ANTIALIASING)?this._renderNodes(w.ANTIALIASING,R):this._blitFBO(P,R,!1);let I;this._pluginInput.set(w.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(M.NotOccluded,S,p),I=this._renderNodes(w.HIGHLIGHTS,S)):(I=this._renderNodes(w.HIGHLIGHTS,S),this._renderHUD(M.NotOccluded,I,p));const D=this._renderNodes(w.MAGNIFIER,I);return d&&!i&&r===te.Default&&!_&&this._blitFBO(D),_?(D.attachDepth(u.depth),this._blitFBO(this._renderNodes(C.FINAL,D)),D.detachDepth()):this._pluginInput.set(C.FINAL,D),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),u.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==te.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),new pe(this._pluginInput.get(C.FINAL),T)}_precompileShaders(e,t,r){if(++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=x.Depth,this._plugins.precompile(ae.TRANSPARENT_TERRAIN),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(ae.TRANSPARENT_TERRAIN),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._needsHUDVisibility&&this._plugins.precompile(ae.OCCLUSION_PIXELS),this._plugins.precompile(ae.LINE_CALLOUTS),this._precompileHUD(M.Occluded),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(w.VIEWSHED,w.LASERLINES,w.OCCLUDED),this._precompileHUD(M.NotOccluded),this._hasHighlights){const e=this._bindParameters;e.highlights.forEach(((t,r)=>{e.highlightLevel=r,this._precompileAllGeometry(x.Highlight)})),e.highlightLevel=null}this._nodes.precompile(C.COMPOSITE,w.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),--this._plugins.context.techniques.precompiling}_updateHighlights(){const e=this._stage.view.state;this._renderers.forEach((t=>t.updateHighlights(e.highlightOrderMap)))}_renderFocusAreaGeometry(){if(this._nodes.produces("focusArea")){const e=this._framebufferSize;let t=this.fboCache.acquire(e.width,e.height,"focusArea");return t=this._nodes.render(t,this._pluginInput),this.performanceInfo.advance(me.FOCUS_AREA_MASK),t}return null}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;++this._techniques.precompiling;const e=this._framebufferSize;let t=this.fboCache.acquire(e.width,e.height,"olid");return t.acquireDepth(D.DEPTH_STENCIL_TEXTURE),t=this._nodes.render(t,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(me.OBJECT_AND_LAYER_ID_COLOR),t}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===W.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear-depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(R),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],ge.RGBA,fe.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,ge.RGBA,fe.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=()=>t.render(this._bindParameters,e),a=this._bindParameters.geometryDepth;this.renderToTargets(s,i,a??this._framebuffer.depth,R),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(e===_e.OPAQUE?me.OPAQUE_EDGES:me.TRANSPARENT_EDGES)}_renderOverlay(e){this._bindParameters.overlay=this.overlay?.render(e),this._bindParameters.overlay&&this.performanceInfo.advance(me.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(ie.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(x.ShadowHighlight,this._shadowMap),i.moveSnapshot(oe.Highlight),this._renderShadowCascades(x.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(oe.ExcludeHighlight),this._renderShadowCascades(x.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(x.Shadow),i.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(me.SHADOW_MAP)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(x.Depth)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._needsShadowAccumulation||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");if(e){const t=this._needsDepth?e.getAttachment(be):null;t?.retain(),this._pluginInput.set(w.SSAO,this._renderSSAO()),this._renderGeometryWithoutNormalsDepth(t)}else this._renderAllGeometryDepth()}_renderGeometryWithoutNormalsDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=h(this._bindParameters.depth));const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"depth");r.attachDepth(e),e.release(),this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(Te.STENCIL),this._renderGeometryWithoutNormals(x.Depth),h(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(me.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=h(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"depth").acquireDepth(D.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(Te.DEPTH|Te.STENCIL),this.renderAllGeometry(x.Depth),h(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(me.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=h(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=x.Depth;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth").acquireDepth(D.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(Te.DEPTH|Te.STENCIL),this._renderTransparentTerrain(),h(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=h(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth").acquireDepth(D.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(Te.DEPTH|Te.STENCIL),this._renderOpaqueAndTransparentGeometry(x.Depth),this._renderContext.output=t,h(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowAccumulation}_computeDepthRange(e){if(!this._needsDepthRange)return z.zero;const t=X(e,this._plugins.plugins,this._stage.layers);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}get _normalsRequired(){const e=this._nodes.require("normals",C.FINAL,C.COMPOSITE,"opaque-color","transparent-color","laserline-color");return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(x.Normal),this._needsDepth&&this._precompileAllGeometry(x.Depth),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(x.ShadowHighlight),this._precompileShadowCascades(x.ShadowExcludeHighlight),this._precompileShadowCascades(x.ShadowHighlight)):this._precompileShadowCascades(x.Shadow)),this._needsShadowAccumulation&&this._precompileAllGeometry(x.Shadow)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",N.RGBA);r.acquireDepth(D.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(R,!0,!0),this._renderGeometryWithNormals(x.Normal);const i=this._nodes.optional("normals",C.FINAL,C.COMPOSITE,"opaque-color","transparent-color","viewshed-color");return r.retain(e+i-1),this.performanceInfo.advance(me.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();H.setName(w.SSAO);const t=this._nodes.render(H,this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(me.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(ae.TRANSPARENT_TERRAIN),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...Ie);this._renderContext.renderOccludedMask=$}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll((e=>{const t=e.acquireTechniques(this._renderContext);t&&(e.render(this._renderContext,t,this._pluginInput),F(t))}))}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>K.Occlude&&this._plugins.render(this._pluginInput,ae.OCCLUDED_TERRAIN),this.renderSlots(e,...Ie),this._renderContext.renderOccludedMask=$}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,ae.HUD_MATERIAL)}precompileViewshedShadowMap(){this._precompileAllGeometry(x.ViewshedShadow)}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(x.ViewshedShadow),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Re),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Se)}_precompileOpaqueGeometry(){this._plugins.precompile(...Ce)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...Ce)}_renderTransparentGeometry(){this._plugins.render(this._pluginInput,...we)}get _hasTransparentTerrain(){return this._plugins.produces(x.Color,ae.TRANSPARENT_TERRAIN)}_renderTransparentTerrain(){const e=()=>this._plugins.render(this._pluginInput,ae.TRANSPARENT_TERRAIN);if(!L(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,R),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,ae.OCCLUSION_PIXELS)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",N.RGBA4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(this._pluginInput,ae.OCCLUSION_PIXELS),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(me.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===M.Occluded){const e=()=>this._plugins.render(this._pluginInput,ae.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(D.DEPTH16_BUFFER,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(this._pluginInput,ae.LINE_CALLOUTS)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=x.Highlight,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&L(this._renderContext.output)?(this._bindParameters.oitPass=J.ColorAlpha,this._plugins.precompile(...De),this._bindParameters.oitPass=J.FrontFace,this._plugins.precompile(...De),this._bindParameters.oitPass=J.NONE):this._plugins.precompile(...De),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(Pe.HUD,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,e===M.Occluded){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(D.DEPTH16_BUFFER,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(D.DEPTH16_BUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===M.Occluded?me.HUD_OCCLUDED:me.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,...De)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(x.ShadowHighlight,ae.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,s=e.acquire(i.width,i.height,"highlights",N.RG);return s.acquireDepth(D.DEPTH_STENCIL_TEXTURE),t.bindFramebuffer(s.fbo),t.clearFramebuffer(R,!0),this._renderContext.output=x.Highlight,t.bindFramebuffer(s.fbo),j(t,e,i,r,(()=>this._renderHighlightGeometries())),this.performanceInfo.advance(me.HIGHLIGHTS),s}_renderHighlightGeometries(){const e=0===this._bindParameters.highlightLevel?Oe:Ne;this._plugins.render(this._pluginInput,...e),this._rctx.clear(Te.DEPTH),this._renderHUDElements(M.Both)}get _needsShadowAccumulation(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,t,r){this._needsShadowAccumulation&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(me.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&L(this._renderContext.output)?(this._bindParameters.oitPass=J.ColorAlpha,this._plugins.precompile(...we),this._bindParameters.oitPass=J.FrontFace,this._plugins.precompile(...we),this._bindParameters.oitPass=J.NONE):this._plugins.precompile(...we)}_renderOIT(e,t,r=M.Both){const i=e===Pe.HUD,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=J.ColorAlpha;const d=a?"oit hud color alpha":"oit color alpha",_=this.fboCache.acquire(s.width,s.height,d,N.RGBA16F),l=t===x.ColorEmission;l&&_.acquireColor(Ae.COLOR_ATTACHMENT1,N.RGBA16F,"emissive"),_.acquireColor(l?Ae.COLOR_ATTACHMENT2:Ae.COLOR_ATTACHMENT1,N.R16F),a||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.gl.clearBufferfv(this._rctx.gl.COLOR,1,E),n(),_.detachDepth(),h.oitPass=J.FrontFace;const p=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return l&&p.acquireColor(Ae.COLOR_ATTACHMENT1,N.RGBA,"emissive"),a?p.acquireDepth(D.DEPTH16_BUFFER):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(R,!!a),n(),p.detachDepth(),h.oitPass=J.NONE,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(Te.COLOR)):this._framebuffer.bind(),this._oitblend??=new V(this._techniques),this._oitblend.blend(this._rctx,_,p,h,l),a?.detachDepth(),p.release(),_.release(),this._renderContext.output=o,a}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(me.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(this._pluginInput,ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),this.performanceInfo.advance(me.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}_blitFBO(e,t=H,r=!0){return this._blit??=new q(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(g(ye,this._bindParameters.camera.viewMatrix),g(He,this._bindParameters.camera.projectionMatrix),f(xe,ye,He),f(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),f(xe,this._renderContext.lastFrameCamera.projectionMatrix,xe),this._reprojectionMatrix=xe);const t=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(W.UPDATE)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}}var Pe;e([m({readOnly:!0})],Ee.prototype,"fullResolutionAtmosphere",null),e([m()],Ee.prototype,"_edgeView",void 0),e([m()],Ee.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(Pe||(Pe={}));const Re=[ae.INTEGRATED_MESH,ae.OPAQUE_TERRAIN,ae.OPAQUE_MATERIAL,ae.TRANSPARENT_MATERIAL],Se=[ae.OPAQUE_MATERIAL_WITHOUT_NORMALS,ae.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],Ce=[ae.INTEGRATED_MESH,ae.OPAQUE_TERRAIN,ae.OPAQUE_MATERIAL,ae.OPAQUE_MATERIAL_WITHOUT_NORMALS],we=[ae.TRANSPARENT_MATERIAL,ae.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],Ie=[ae.OPAQUE_MATERIAL,ae.TRANSPARENT_MATERIAL,ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH],De=[ae.LINE_CALLOUTS_HUD_DEPTH,ae.HUD_MATERIAL,ae.LABEL_MATERIAL],Ne=[ae.TRANSPARENT_MATERIAL,ae.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,ae.OPAQUE_MATERIAL,ae.OPAQUE_MATERIAL_WITHOUT_NORMALS],Oe=[...Ne,ae.TRANSPARENT_TERRAIN,ae.INTEGRATED_MESH,ae.OPAQUE_TERRAIN],He=T(),ye=T(),xe=T();function Le(e){return t=>e.immediate.schedule(t)}export{Ee as Renderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as s,abortMaybe as a,destroyMaybe as n,releaseMaybe as h}from"../../../../core/maybe.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{watch as d,syncAndInitial as _,initial as l,sync as p}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/accessorSupport/interfaces.js";import"../../../../core/accessorSupport/tracking/Flags.js";import"../../../../core/Warning.js";import"../../../../core/Error.js";import{equals as c,invert as g,multiply as f}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as T}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as A}from"../../../../chunks/vec42.js";import{ZEROS as E}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as P,ZEROS as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as S}from"../../../../geometry/support/Indices.js";import{RenderCategory as C,InternalRenderCategory as w}from"../../webgl.js";import{debugFlags as I}from"../../support/debugFlags.js";import{DepthFormat as D,ColorFormat as N}from"../../webgl/formats.js";import{FBOCache as O,defaultWebGLFBO as H}from"../core/FBOCache.js";import{RenderPassManager as y}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as x,isColorOrColorEmission as L}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as M}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{distanceFadeEnd as v}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as U}from"../effects/RenderNodes.js";import{releaseTechniques as F}from"../effects/RenderPlugin.js";import{RenderPluginManager as G}from"../effects/RenderPluginManager.js";import{Blit as q}from"../effects/blit/Blit.js";import{renderHighlightBuffer as j}from"../effects/highlight/Highlight.js";import{OITBlend as V}from"../effects/transparency/OITBlend.js";import{AnimationTimer as B}from"./AnimationTimer.js";import{AnimationTimeStep as Q}from"./AnimationTimeStep.js";import{RenderRequestType as W}from"./basicInterfaces.js";import{BoundingInfo as k}from"./BoundingInfo.js";import{DepthRange as z}from"./DepthRange.js";import{depthRangeFromScene as X}from"./depthRangeUtils.js";import{MainFramebuffer as Y}from"./MainFramebuffer.js";import{RenderOccludedFlag as K}from"./Material.js";import{OITPass as J}from"./OITPass.js";import{RenderContext as Z,defaultRenderOccludedMask as $}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as ee,RendererTarget as te}from"./rendererUtils.js";import{setupFeatureDefaults as re,RenderFeature as ie}from"./RenderFeature.js";import{RenderPluginInput as se}from"./RenderPluginInput.js";import{RenderSlot as ae}from"./RenderSlot.js";import{ShadowAccumulator as ne}from"./ShadowAccumulator.js";import{ShadowMap as he,SnapshotSlot as oe}from"./ShadowMap.js";import de from"./SliceHelper.js";import{Transparency as _e}from"./edgeRendering/interfaces.js";import{MergedRenderer as le}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as pe}from"../parts/renderUtils.js";import{RendererPerformanceInfo as ue,PerformanceCategory as me}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ce}from"../../../support/RenderState.js";import{PixelFormat as ge,PixelType as fe,DepthStencilAttachment as be,FramebufferBit as Te,ColorAttachment as Ae}from"../../../webgl/enums.js";class Ee{constructor(e,t,r,s,a,n){this._stage=e,this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this._renderers=new Map,this.renderPassManager=new y,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=P(0,0,0,1),this._sliceHelper=new de,this._blit=null,this._oitblend=null,this._state=u(ce.IDLE),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new Q,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(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 O(s),this._renderStateFeatures=u(re(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new Y(this.fboCache),this.performanceInfo=new ue(this._rctx),this._shadowMap=new he(this.fboCache,e.viewingMode),this._shadowAccumulator=new ne(this.fboCache,r,e,(e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t}),((e,t,r)=>{const i=this._stage.view.qualitySettings.maximumPixelRatio;e.shadowMap.start(e.camera,t,r,!0,i),this._renderShadowCascades(x.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(e.camera,e.contentCamera)}),n),this._renderContext=new Z(this._rctx,this._shadowMap,r),this._nodes=new U(this._renderContext),this._plugins=new G({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this._handles=[d((()=>this._stage.view.state.camera),(()=>n()),_),d((()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(_e.TRANSPARENT):()=>{},n()}),l),d((()=>this._stage.view.environment.background?.color),(e=>{const t=e?i(e):R;A(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()}),_),d((()=>this._stage.view.state.camera.relativeElevation),(e=>this._inGlobeView=(e??1/0)>=v),_),d((()=>this._bindParameters.clouds.fadeFactor),(()=>this._bindParameters.fadeLighting()),p),d((()=>this._bindParameters.clouds.data?.state),(()=>n()),p),d((()=>this._stage.view.state.highlights),(e=>{this._bindParameters.highlights=e,this._updateHighlights(),n()}),l)]}destroy(){this._handles.forEach((e=>e.remove())),this._gpuTimerHandle=s(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.dispose(),this._loadEdgeViewTask=a(this._loadEdgeViewTask),this._edgeView=n(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),this._plugins.destroy(),this._renderers.clear(),this._blit=null,this._oitblend=null,k.prune(),le.prune(),S()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=re(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate((i=>i.set(t,e,r))),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(ie.HighQualityTransparency)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(ie.WaterReflection))}get _hasHighlights(){return this._plugins.produces(x.Highlight,ae.OPAQUE_MATERIAL,ae.TRANSPARENT_MATERIAL,ae.DRAPED_MATERIAL,ae.HUD_MATERIAL,ae.LABEL_MATERIAL)}hasHighlightOptions(e){return this._plugins.hasHighlightOptions(e)}get _hasHUDHighlights(){return this._plugins.produces(x.Highlight,ae.HUD_MATERIAL,ae.LABEL_MATERIAL)}get hasSSAO(){return(this._stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(ie.SSAO))&&!this._inGlobeView}get hasSMAA(){return this._stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(ie.Antialiasing)}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(ie.HighResolutionAtmosphere)}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=h(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=h(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=h(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility)}get updating(){return null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r((async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");o(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:xe(this._stage.view.resourceController)});return this._handles.push(d((()=>r.updating),(()=>this._requestRender()),p)),this._requestRender(),this._edgeViewCallbacks.forEach((e=>e(r))),this._edgeViewCallbacks.length=0,r}))),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&c(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slicePlane(e){this._sliceHelper.plane!==e&&(this._sliceHelper.plane=e,this._requestRender())}get plugins(){return this._plugins}getMaterialRenderer(e){return this._renderers.get(e)}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,t){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:i,updates:s}=e;if(0===r.length&&0===i.length&&0===s.length)return;ee(e).forEach(((r,i)=>{if(t.done)return;let s=this._renderers.get(i);null==s&&r.adds.length>0&&(s=new le({material:i,highlightOrderMap:this._stage.view.state.highlightOrderMap}),s.initializeRenderContext(this._plugins.context),this._plugins.add(s),this._renderers.set(i,s)),s&&(s.modify(r),s.updateHighlights(this._stage.view.state.highlightOrderMap),0===s.numGeometries&&(this._renderers.delete(s.material),this._plugins.remove(s),s.destroy())),r.removes.forEach((t=>e.removes.removeUnordered(t))),r.adds.forEach((t=>e.adds.removeUnordered(t))),r.updates.forEach((t=>e.updates.removeUnordered(t))),t.madeProgress()})),this.updateHasFlags()}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(x.Color,...De),has.water=this._plugins.produces(x.Normal,ae.DRAPED_WATER),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new B(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation),null!=e.forcedAnimationTime&&this._animationTimer.forceTime(e.forcedAnimationTime);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?s(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r=te.Default,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new pe(this._pluginInput.get(C.FINAL),null)}_render(e,t,r=te.Default,i){this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=r===te.Default,this._disposeBindBuffers();const{camera:s,contentCamera:a,mode:n,alignPixelEnabled:o}=e;this._state.value=n;const d=this._nodes.produces("magnifier-color"),_=this._nodes.produces("final-color"),l=this._nodes.require("emissive",C.FINAL,C.COMPOSITE)>0&&this._plugins.hasEmissions,p=l?x.ColorEmission:x.Color;this._renderContext.time=t,this._renderContext.output=p,this._bindParameters.oitPass=J.NONE,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null,this._bindParameters.slicePlane=this._sliceHelper.plane,this._bindParameters.viewshedEnabled=this._nodes.produces(w.VIEWSHED),this._renderOverlay(t),s.setGLViewport(this._rctx);const u=this._framebuffer,m=u.initialize(s.fullWidth,s.fullHeight,this._backgroundColor,l);this.hasReflections?(m?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=m):m?.release(),this._ensureBindParametersCamera(s,a),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const c=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(x.Color,...we);this._precompilePrepasses(),this.performanceInfo.advance(me.PREPARE);const f=this._computeDepthRange(s);this._renderShadowMap(s,this._bindParameters.lighting.mainLight.direction,f),this._ensureBindParametersCamera(s,a),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(f,s,a),this._ensureBindParametersSSR(t),this._precompileShaders(c,g,p),this._renderContext.output=p,u.bind(),this._bindParameters.mainDepth=u.depth.attachment;const b=this.plugins.produces(x.Color,...Ce);b&&this._renderOpaqueGeometry(),u.update((e=>this._renderNodes(C.OPAQUE,e,b))),this.fboCache.debugCallback?.("opaque-color",u.color.fbo),u.update((e=>this._renderNodes(w.OPAQUE_ENVIRONMENT,e))),this.fboCache.debugCallback?.(w.OPAQUE_ENVIRONMENT,u.color.fbo),this._renderTerrainDepth(c),this._renderEdges(_e.OPAQUE),u.bind(),this._renderPlugins(ae.VOXEL,me.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOIT(Pe.Geometry,p):this._renderTransparentGeometry()),u.update((e=>this._renderNodes(C.TRANSPARENT,e,g))),this.fboCache.debugCallback?.("transparent-color",u.color.fbo),this._renderGeometryDepth(c),this._renderHUDVisibility(),c||this._plugins.render(this._pluginInput,ae.LINE_CALLOUTS);const T=r===te.ObjectAndLayerID?this._renderObjectAndLayerIdColor():null;this._renderEdges(_e.TRANSPARENT);const A=this._hasTransparentTerrain?this._renderTransparentTerrain():null;A&&(this.performanceInfo.advance(me.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(M.Occluded):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,A.getTexture())),this._renderHUD(M.Occluded,u.color,p))),this._bindParameters.cullAboveTerrain=!1,A&&(u.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,A.getTexture()),A.release(),c&&(this._renderEdges(_e.OPAQUE),g&&(this._oitEnabled?this._renderOIT(Pe.Geometry,p):this._renderTransparentGeometry(),this.performanceInfo.advance(me.TRANSPARENT)),this._renderEdges(_e.TRANSPARENT))),this._bindParameters.ssao=h(this._bindParameters.ssao),c&&this._renderLineCallouts(M.NotOccluded),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment(),this._pluginInput.set("focusArea",this._renderFocusAreaGeometry()),u.update((e=>this._renderNodes(w.TRANSPARENT_ENVIRONMENT,e))),u.update((e=>this._renderNodes(w.VIEWSHED,e))),u.update((e=>this._renderNodes(w.LASERLINES,e))),u.update((e=>this._renderNodes(w.OCCLUDED,e))),this._pluginInput.set("highlights",this._renderHighlightPrepass()),u.update((e=>this._renderNodes(C.COMPOSITE,e)));const E=!(r!==te.Default||_||d&&!i),P=this._pluginInput.get(C.COMPOSITE),R=E?H:this.fboCache.acquire(P.fbo.width,P.fbo.height,w.ANTIALIASING),S=this._nodes.produces(w.ANTIALIASING)?this._renderNodes(w.ANTIALIASING,R):this._blitFBO(P,R,!1);let I;this._pluginInput.set(w.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(M.NotOccluded,S,p),I=this._renderNodes(w.HIGHLIGHTS,S)):(I=this._renderNodes(w.HIGHLIGHTS,S),this._renderHUD(M.NotOccluded,I,p));const D=this._renderNodes(w.MAGNIFIER,I);return d&&!i&&r===te.Default&&!_&&this._blitFBO(D),_?(D.attachDepth(u.depth),this._blitFBO(this._renderNodes(C.FINAL,D)),D.detachDepth()):this._pluginInput.set(C.FINAL,D),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),u.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),r!==te.Default&&(this._releaseFBOs(),this._disposeOffscreenBuffers()),new pe(this._pluginInput.get(C.FINAL),T)}_precompileShaders(e,t,r){if(++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=x.Depth,this._plugins.precompile(ae.TRANSPARENT_TERRAIN),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(ae.TRANSPARENT_TERRAIN),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._needsHUDVisibility&&this._plugins.precompile(ae.OCCLUSION_PIXELS),this._plugins.precompile(ae.LINE_CALLOUTS),this._precompileHUD(M.Occluded),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(w.VIEWSHED,w.LASERLINES,w.OCCLUDED),this._precompileHUD(M.NotOccluded),this._hasHighlights){const e=this._bindParameters;e.highlights.forEach(((t,r)=>{e.highlightLevel=r,this._precompileAllGeometry(x.Highlight)})),e.highlightLevel=null}this._nodes.precompile(C.COMPOSITE,w.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),--this._plugins.context.techniques.precompiling}_updateHighlights(){const e=this._stage.view.state;this._renderers.forEach((t=>t.updateHighlights(e.highlightOrderMap)))}_renderFocusAreaGeometry(){if(this._nodes.produces("focusArea")){const e=this._framebufferSize;let t=this.fboCache.acquire(e.width,e.height,"focusArea");return t=this._nodes.render(t,this._pluginInput),this.performanceInfo.advance(me.FOCUS_AREA_MASK),t}return null}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;++this._techniques.precompiling;const e=this._framebufferSize;let t=this.fboCache.acquire(e.width,e.height,"olid");return t.acquireDepth(D.DEPTH_STENCIL_TEXTURE),t=this._nodes.render(t,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(me.OBJECT_AND_LAYER_ID_COLOR),t}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=e===W.BACKGROUND;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear-depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(R),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],ge.RGBA,fe.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,ge.RGBA,fe.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=()=>t.render(this._bindParameters,e),a=this._bindParameters.geometryDepth;this.renderToTargets(s,i,a??this._framebuffer.depth,R),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(e===_e.OPAQUE?me.OPAQUE_EDGES:me.TRANSPARENT_EDGES)}_renderOverlay(e){this._bindParameters.overlay=this.overlay?.render(e),this._bindParameters.overlay&&this.performanceInfo.advance(me.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const i=this._shadowMap;i.start(e,t,r,this.isFeatureEnabled(ie.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(x.ShadowHighlight,this._shadowMap),i.moveSnapshot(oe.Highlight),this._renderShadowCascades(x.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(oe.ExcludeHighlight),this._renderShadowCascades(x.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(x.Shadow),i.finish(),e.setGLViewport(this._rctx),this.performanceInfo.advance(me.SHADOW_MAP)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(x.Depth)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._needsShadowAccumulation||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");if(e){const t=this._needsDepth?e.getAttachment(be):null;t?.retain(),this._pluginInput.set(w.SSAO,this._renderSSAO()),this._renderGeometryWithoutNormalsDepth(t)}else this._renderAllGeometryDepth()}_renderGeometryWithoutNormalsDepth(e){if(!this._needsDepth||!e)return void(this._bindParameters.depth=h(this._bindParameters.depth));const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"depth");r.attachDepth(e),e.release(),this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(Te.STENCIL),this._renderGeometryWithoutNormals(x.Depth),h(this._bindParameters.depth),this._bindParameters.depth=r.obtainDepthTexture(),r.release(),this.performanceInfo.advance(me.DEPTH)}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=h(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"depth").acquireDepth(D.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(Te.DEPTH|Te.STENCIL),this.renderAllGeometry(x.Depth),h(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(me.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=h(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=x.Depth;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth").acquireDepth(D.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(Te.DEPTH|Te.STENCIL),this._renderTransparentTerrain(),h(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=h(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth").acquireDepth(D.DEPTH_STENCIL_TEXTURE);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(Te.DEPTH|Te.STENCIL),this._renderOpaqueAndTransparentGeometry(x.Depth),this._renderContext.output=t,h(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowAccumulation}_computeDepthRange(e){if(!this._needsDepthRange)return z.zero;const t=X(e,this._plugins.plugins,this._stage.layers);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}get _normalsRequired(){const e=this._nodes.require("normals",C.FINAL,C.COMPOSITE,"opaque-color","transparent-color","laserline-color");return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(x.Normal),this._needsDepth&&this._precompileAllGeometry(x.Depth),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(x.ShadowHighlight),this._precompileShadowCascades(x.ShadowExcludeHighlight),this._precompileShadowCascades(x.ShadowHighlight)):this._precompileShadowCascades(x.Shadow)),this._needsShadowAccumulation&&this._precompileAllGeometry(x.Shadow)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",N.RGBA);r.acquireDepth(D.DEPTH_STENCIL_TEXTURE),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(R,!0,!0),this._renderGeometryWithNormals(x.Normal);const i=this._nodes.optional("normals",C.FINAL,C.COMPOSITE,"opaque-color","transparent-color","viewshed-color");return r.retain(e+i-1),this.performanceInfo.advance(me.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return void e?.detachDepth();H.setName(w.SSAO);const t=this._nodes.render(H,this._pluginInput);return this._bindParameters.ssao=t,e.detachDepth(),this._pluginInput.release("normals"),this.performanceInfo.advance(me.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(ae.TRANSPARENT_TERRAIN),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...Ie);this._renderContext.renderOccludedMask=$}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll((e=>{const t=e.acquireTechniques(this._renderContext);t&&(e.render(this._renderContext,t,this._pluginInput),F(t))}))}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>K.Occlude&&this._plugins.render(this._pluginInput,ae.OCCLUDED_TERRAIN),this.renderSlots(e,...Ie),this._renderContext.renderOccludedMask=$}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,ae.HUD_MATERIAL)}precompileViewshedShadowMap(){this._precompileAllGeometry(x.ViewshedShadow)}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(x.ViewshedShadow),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Re),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(this._pluginInput,...Se)}_precompileOpaqueGeometry(){this._plugins.precompile(...Ce)}_renderOpaqueGeometry(){this._plugins.render(this._pluginInput,...Ce)}_renderTransparentGeometry(){this._plugins.render(this._pluginInput,...we)}get _hasTransparentTerrain(){return this._plugins.produces(x.Color,ae.TRANSPARENT_TERRAIN)}_renderTransparentTerrain(){const e=()=>this._plugins.render(this._pluginInput,ae.TRANSPARENT_TERRAIN);if(!L(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,R),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,ae.OCCLUSION_PIXELS)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=h(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",N.RGBA4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(this._pluginInput,ae.OCCLUSION_PIXELS),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(me.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===M.Occluded){const e=()=>this._plugins.render(this._pluginInput,ae.LINE_CALLOUTS),t=this._framebufferSize,r=this.fboCache.acquireDepth(D.DEPTH16_BUFFER,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(this._pluginInput,ae.LINE_CALLOUTS)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=x.Highlight,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&L(this._renderContext.output)?(this._bindParameters.oitPass=J.ColorAlpha,this._plugins.precompile(...De),this._bindParameters.oitPass=J.FrontFace,this._plugins.precompile(...De),this._bindParameters.oitPass=J.NONE):this._plugins.precompile(...De),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(Pe.HUD,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,e===M.Occluded){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(D.DEPTH16_BUFFER,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(D.DEPTH16_BUFFER),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(e===M.Occluded?me.HUD_OCCLUDED:me.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(this._pluginInput,...De)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(x.ShadowHighlight,ae.OPAQUE_MATERIAL)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,s=e.acquire(i.width,i.height,"highlights",N.RG);return s.acquireDepth(D.DEPTH_STENCIL_TEXTURE),t.bindFramebuffer(s.fbo),t.clearFramebuffer(R,!0),this._renderContext.output=x.Highlight,t.bindFramebuffer(s.fbo),j(t,e,i,r,(()=>this._renderHighlightGeometries())),this.performanceInfo.advance(me.HIGHLIGHTS),s}_renderHighlightGeometries(){this._plugins.render(this._pluginInput,...Ne),this._rctx.clear(Te.DEPTH),this._renderHUDElements(M.Both)}get _needsShadowAccumulation(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,t,r){this._needsShadowAccumulation&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,e,t,r)&&this.performanceInfo.advance(me.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&L(this._renderContext.output)?(this._bindParameters.oitPass=J.ColorAlpha,this._plugins.precompile(...we),this._bindParameters.oitPass=J.FrontFace,this._plugins.precompile(...we),this._bindParameters.oitPass=J.NONE):this._plugins.precompile(...we)}_renderOIT(e,t,r=M.Both){const i=e===Pe.HUD,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=J.ColorAlpha;const d=a?"oit hud color alpha":"oit color alpha",_=this.fboCache.acquire(s.width,s.height,d,N.RGBA16F),l=t===x.ColorEmission;l&&_.acquireColor(Ae.COLOR_ATTACHMENT1,N.RGBA16F,"emissive"),_.acquireColor(l?Ae.COLOR_ATTACHMENT2:Ae.COLOR_ATTACHMENT1,N.R16F),a||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.gl.clearBufferfv(this._rctx.gl.COLOR,1,E),n(),_.detachDepth(),h.oitPass=J.FrontFace;const p=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return l&&p.acquireColor(Ae.COLOR_ATTACHMENT1,N.RGBA,"emissive"),a?p.acquireDepth(D.DEPTH16_BUFFER):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(R,!!a),n(),p.detachDepth(),h.oitPass=J.NONE,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(Te.COLOR)):this._framebuffer.bind(),this._oitblend??=new V(this._techniques),this._oitblend.blend(this._rctx,_,p,h,l),a?.detachDepth(),p.release(),_.release(),this._renderContext.output=o,a}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(me.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(this._pluginInput,ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH),this.performanceInfo.advance(me.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(this._pluginInput,e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}_blitFBO(e,t=H,r=!0){return this._blit??=new q(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(g(He,this._bindParameters.camera.viewMatrix),g(Oe,this._bindParameters.camera.projectionMatrix),f(ye,He,Oe),f(ye,this._renderContext.lastFrameCamera.viewMatrix,ye),f(ye,this._renderContext.lastFrameCamera.projectionMatrix,ye),this._reprojectionMatrix=ye);const t=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(W.UPDATE)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}}var Pe;e([m({readOnly:!0})],Ee.prototype,"fullResolutionAtmosphere",null),e([m()],Ee.prototype,"_edgeView",void 0),e([m()],Ee.prototype,"updating",null),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(Pe||(Pe={}));const Re=[ae.INTEGRATED_MESH,ae.OPAQUE_TERRAIN,ae.OPAQUE_MATERIAL,ae.TRANSPARENT_MATERIAL],Se=[ae.OPAQUE_MATERIAL_WITHOUT_NORMALS,ae.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],Ce=[ae.INTEGRATED_MESH,ae.OPAQUE_TERRAIN,ae.OPAQUE_MATERIAL,ae.OPAQUE_MATERIAL_WITHOUT_NORMALS],we=[ae.TRANSPARENT_MATERIAL,ae.TRANSPARENT_MATERIAL_WITHOUT_NORMALS],Ie=[ae.OPAQUE_MATERIAL,ae.TRANSPARENT_MATERIAL,ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH],De=[ae.LINE_CALLOUTS_HUD_DEPTH,ae.HUD_MATERIAL,ae.LABEL_MATERIAL],Ne=[ae.TRANSPARENT_MATERIAL,ae.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,ae.OPAQUE_MATERIAL,ae.OPAQUE_MATERIAL_WITHOUT_NORMALS,ae.TRANSPARENT_TERRAIN,ae.INTEGRATED_MESH,ae.OPAQUE_TERRAIN],Oe=T(),He=T(),ye=T();function xe(e){return t=>e.immediate.schedule(t)}export{Ee 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{getBasisEncoder as e}from"../../../../libs/basisu/BasisUEncoder.js";import{TextureFormat as t}from"../../../../libs/basisu/TextureFormat.js";import{CompressedTextureFormat as n,PixelFormat as s}from"../../../webgl/enums.js";let a=null,r=null;class l{constructor(e,t){this.internalFormat=e,this.compressedTexture=t}}async function i(e){await o();const t=d(e.data,e.flipped),n=await c(t,e.width,e.height,e.hasMipmap),s=n?await u(n,e.hasETC,e.hasS3TC):null;return{result:new l(s?.internalFormat??null,s?.compressedTexture??null)}}async function o(){return null==r&&(r=e(),a=await e()),r}async function c(e,t,n,s,r=255,l=0,i=!1,c=!1){null==a&&(a=await o());const u=new a.BasisEncoder;u.setPerceptual(!c),u.setCheckForAlpha(!0),u.setForceAlpha(!1),u.setRenormalize(c),u.setMipGen(s),u.setMipSRGB(!c),u.setCreateKTX2File(!0),u.setKTX2SRGBTransferFunc(!c),u.setQualityLevel(r),u.setCompressionLevel(l);const d=new Uint8Array(25165824);u.setSliceSourceImage(0,new Uint8Array(e),t,n,i);const m=u.encode(d),T=new Uint8Array(d.buffer,0,m),h=new a.KTX2File(new Uint8Array(T));return h.isValid()?(u.delete(),T):(h.close(),h.delete(),u.delete(),null)}async function u(e,r,l){null==a&&(a=await o());const i=new a.KTX2File(new Uint8Array(e));i.startTranscoding();const[c,u]=r?i.getHasAlpha()?[t.ETC2_RGBA,n.COMPRESSED_RGBA8_ETC2_EAC]:[t.ETC1_RGB,n.COMPRESSED_RGB8_ETC2]:l?i.getHasAlpha()?[t.BC3_RGBA,n.COMPRESSED_RGBA_S3TC_DXT5_EXT]:[t.BC1_RGB,n.COMPRESSED_RGB_S3TC_DXT1_EXT]:[t.RGBA32,s.RGBA],d=i.getLevels(),m=[];for(let t=0;t<d;t++)m.push(new Uint8Array(i.getImageTranscodedSizeInBytes(t,0,0,c))),i.transcodeImage(m[t],t,0,0,c,0,-1,-1);return i.close(),i.delete(),{internalFormat:u,compressedTexture:{type:"compressed",levels:m}}}function d(e,t=!1){const n=new OffscreenCanvas(e.width,e.height),s=n.getContext("2d");t&&(s.translate(0,n.height),s.scale(1,-1)),s.drawImage(e,0,0);return s.getImageData(0,0,n.width,n.height).data}export{l as TextureCompressionWorkerOutput,i as compress,c as compressRGBADataToKTX2,u as createTextureDataKTX2,o as loadBasisEncoder};
5
+ import{getBasisEncoder as e}from"../../../../libs/basisu/BasisUEncoder.js";import{TextureFormat as t}from"../../../../libs/basisu/TextureFormat.js";import{getDXTEncoder as n}from"../../../../libs/dxtEncoder/DXTEncoder.js";import{CompressedTextureFormat as r}from"../../../webgl/enums.js";let a=null,s=null;class l{constructor(e,t){this.internalFormat=e,this.compressedTexture=t}}async function i(e){const t=h(e.data,e.flipped);if(e.hasS3TC){await c();const n=new Uint8Array(25165824);s?.encode(new Uint8Array(t),e.width,e.height,n);const r=D(n,!0);return{result:new l(r?.internalFormat??null,r?.textureData??null)}}if(e.hasETC){await o();const n=await u(t,e.width,e.height,e.hasMipmap),r=n?await d(n):null;return{result:new l(r?.internalFormat??null,r?.compressedTexture??null)}}return{result:new l(null,null)}}async function o(){a||(a=await e())}async function c(){s||(s=await n())}async function u(e,t,n,r,s=255,l=0,i=!1,o=!1){if(!a)return null;const c=new a.BasisEncoder;c.setPerceptual(!o),c.setCheckForAlpha(!0),c.setForceAlpha(!1),c.setRenormalize(o),c.setMipGen(r),c.setMipSRGB(!o),c.setCreateKTX2File(!0),c.setKTX2SRGBTransferFunc(!o),c.setQualityLevel(s),c.setCompressionLevel(l);const u=new Uint8Array(25165824);c.setSliceSourceImage(0,new Uint8Array(e),t,n,i);const d=c.encode(u),h=new Uint8Array(u.buffer,0,d),f=new a.KTX2File(new Uint8Array(h));return f.isValid()?(c.delete(),h):(f.close(),f.delete(),c.delete(),null)}async function d(e){if(!a)return new l(null,null);const n=new a.KTX2File(new Uint8Array(e));n.startTranscoding();const[s,i]=n.getHasAlpha()?[t.ETC2_RGBA,r.COMPRESSED_RGBA8_ETC2_EAC]:[t.ETC1_RGB,r.COMPRESSED_RGB8_ETC2],o=n.getLevels(),c=[];for(let t=0;t<o;t++)c.push(new Uint8Array(n.getImageTranscodedSizeInBytes(t,0,0,s))),n.transcodeImage(c[t],t,0,0,s,0,-1,-1);return n.close(),n.delete(),{internalFormat:i,compressedTexture:{type:"compressed",levels:c}}}function h(e,t=!1){const n=new OffscreenCanvas(e.width,e.height),r=n.getContext("2d");t&&(r.translate(0,n.height),r.scale(1,-1)),r.drawImage(e,0,0);return r.getImageData(0,0,n.width,n.height).data}const f=31,w=1,m=2,T=3,p=4,C=7,E=21,A=131072;function y(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}const S=y("DXT1"),_=y("DXT3"),g=y("DXT5");function D(e,t){const n=new Int32Array(e.buffer,e.byteOffset,f);let a,s;switch(n[E]){case S:a=8,s=r.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case _:a=16,s=r.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case g:a=16,s=r.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}let l=1,i=n[p],o=n[T];(3&i||3&o)&&(i=i+3&-4,o=o+3&-4);const c=i,u=o;let d,h;n[m]&A&&!1!==t&&(l=Math.max(1,n[C]));let y=e.byteOffset+n[w]+4;const D=[];for(let r=0;r<l;++r)h=(i+3>>2)*(o+3>>2)*a,d=new Uint8Array(e.buffer,y,h),D.push(d),y+=h,i=Math.max(1,i>>1),o=Math.max(1,o>>1);return{textureData:{type:"compressed",levels:D},internalFormat:s,width:c,height:u}}export{l as TextureCompressionWorkerOutput,i as compress,u as compressRGBADataToKTX2,d as createTextureDataKTX2,o as loadBasisEncoder,c as loadDXTEncoder};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import t from"./BuildingNumericFilterViewModel.js";import{findFieldInfoByModelName as r}from"./support/buildingLayerUtils.js";import{getValueFromFilters as i}from"./support/filterUtils.js";import{getDomainInfo as o}from"./support/validation.js";const a="bldglevel";let n=class extends t{constructor(){super(...arguments),this._levelFieldName=null,this._parseValueFromFilter=e=>{const l=new RegExp(`${this._levelFieldName}\\s*=\\s*(\\d+)`,"gi"),s=new RegExp(`${this._levelFieldName}\\s*<\\s*(\\d+)`,"gi");for(const{filterMode:t,filterExpression:r}of e.filterBlocks?.items??[]){if(null==r)continue;let e=null;if("solid"===t.type?e=l.exec(r):"x-ray"===t.type&&(e=s.exec(r)),e)return parseInt(e[1],10)}return null}}get filterExpressions(){return this.enabled&&this._levelFieldName?{xRay:`${this._levelFieldName} < ${this.value}`,solid:`${this._levelFieldName} = ${this.value}`}:{solid:null,xRay:null}}get _firstValue(){const e=this.allowedValues;return e.length>0?e[0]:0}_setup(){const e=[];this.layers.forEach((l=>{const s=r(l,a);null!=s&&(this._levelFieldName=s.fieldName,e.push(s))})),this._domainInfo=o(e);const l=this._valueBeforeReady;this._set("state","ready"),this._valueBeforeReady=null;const s=l??i(this.layers,this._parseValueFromFilter);null!=s?this.select(s):(this.enabled=!1,this.value=this._firstValue)}};e([l({readOnly:!0})],n.prototype,"filterExpressions",null),e([l()],n.prototype,"_levelFieldName",void 0),e([l({readOnly:!0})],n.prototype,"_firstValue",null),n=e([s("esri.widgets.BuildingExplorer.BuildingLevel")],n);const u=n;export{u as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import t from"./BuildingNumericFilterViewModel.js";import{findFieldInfoByModelName as r}from"./support/buildingLayerUtils.js";import{getValueFromFilters as i}from"./support/filterUtils.js";import{getDomainInfo as o}from"./support/validation.js";const a="bldglevel";let n=class extends t{constructor(e){super(e),this._levelFieldName=null,this._parseValueFromFilter=e=>{const l=new RegExp(`${this._levelFieldName}\\s*=\\s*(\\d+)`,"gi"),s=new RegExp(`${this._levelFieldName}\\s*<\\s*(\\d+)`,"gi");for(const{filterMode:t,filterExpression:r}of e.filterBlocks?.items??[]){if(null==r)continue;let e=null;if("solid"===t.type?e=l.exec(r):"x-ray"===t.type&&(e=s.exec(r)),e)return parseInt(e[1],10)}return null}}get filterExpressions(){return this.enabled&&this._levelFieldName?{xRay:`${this._levelFieldName} < ${this.value}`,solid:`${this._levelFieldName} = ${this.value}`}:{solid:null,xRay:null}}get _firstValue(){const e=this.allowedValues;return e.length>0?e[0]:0}_setup(){const e=[];this.layers.forEach((l=>{const s=r(l,a);null!=s&&(this._levelFieldName=s.fieldName,e.push(s))})),this._domainInfo=o(e);const l=this._valueBeforeReady;this._set("state","ready"),this._valueBeforeReady=null;const s=l??i(this.layers,this._parseValueFromFilter);null!=s?this.select(s):(this.enabled=!1,this.value=this._firstValue)}};e([l({readOnly:!0})],n.prototype,"filterExpressions",null),e([l()],n.prototype,"_levelFieldName",void 0),e([l({readOnly:!0})],n.prototype,"_firstValue",null),n=e([s("esri.widgets.BuildingExplorer.BuildingLevel")],n);const u=n;export{u as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import l from"./BuildingNumericFilterViewModel.js";import{findFieldInfoByModelName as i}from"./support/buildingLayerUtils.js";import{getValueFromFilters as r}from"./support/filterUtils.js";import{getDomainInfo as o}from"./support/validation.js";const a="demolishedphase",d="createdphase";let n=class extends l{constructor(){super(...arguments),this._createdPhaseFieldName=null,this._demolishedPhaseFieldName=null,this._parseValueFromFilter=e=>{const s=this._createdPhaseFieldName,t=new RegExp(`${s}\\s*<=\\s*(\\d+)\\s*OR\\s*${s}\\s*IS\\s*NULL`,"gi"),l=this._demolishedPhaseFieldName,i=new RegExp(`${l}\\s*>\\s*(\\d+)\\s*OR\\s*${l}\\s*IS\\s*NULL`,"gi");for(const{filterExpression:r}of e.filterBlocks?.items??[]){const e=r?t.exec(r)??i.exec(r):null;if(e)return parseInt(e[1],10)}return null}}get filterExpressions(){if(!this.enabled)return{solid:null,xRay:null};const e=[],s=this._createdPhaseFieldName;s&&e.push(`(${s} <= ${this.value} OR ${s} IS NULL)`);const t=this._demolishedPhaseFieldName;t&&e.push(`(${t} > ${this.value} OR ${t} IS NULL)`);const l=e.join(" AND ");return{solid:l,xRay:l}}get _lastValue(){const e=this.allowedValues;return e.length>0?e[e.length-1]:0}_setup(){const e=[];this.layers.forEach((s=>{const t=i(s,d);null!=t&&(this._createdPhaseFieldName=t.fieldName,e.push(t));const l=i(s,a);null!=l&&(this._demolishedPhaseFieldName=l.fieldName,e.push(l))})),this._domainInfo=o(e);const s=this._valueBeforeReady;if(this._set("state","ready"),this._valueBeforeReady=null,this.allowedValues.length>0){const e=s??r(this.layers,this._parseValueFromFilter);this.select(e??this._lastValue)}else this.clear()}};e([s({readOnly:!0})],n.prototype,"filterExpressions",null),e([s()],n.prototype,"_createdPhaseFieldName",void 0),e([s()],n.prototype,"_demolishedPhaseFieldName",void 0),e([s({readOnly:!0})],n.prototype,"_lastValue",null),n=e([t("esri.widgets.BuildingExplorer.BuildingPhase")],n);const h=n;export{h as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import l from"./BuildingNumericFilterViewModel.js";import{findFieldInfoByModelName as i}from"./support/buildingLayerUtils.js";import{getValueFromFilters as r}from"./support/filterUtils.js";import{getDomainInfo as o}from"./support/validation.js";const a="demolishedphase",d="createdphase";let n=class extends l{constructor(e){super(e),this._createdPhaseFieldName=null,this._demolishedPhaseFieldName=null,this._parseValueFromFilter=e=>{const s=this._createdPhaseFieldName,t=new RegExp(`${s}\\s*<=\\s*(\\d+)\\s*OR\\s*${s}\\s*IS\\s*NULL`,"gi"),l=this._demolishedPhaseFieldName,i=new RegExp(`${l}\\s*>\\s*(\\d+)\\s*OR\\s*${l}\\s*IS\\s*NULL`,"gi");for(const{filterExpression:r}of e.filterBlocks?.items??[]){const e=r?t.exec(r)??i.exec(r):null;if(e)return parseInt(e[1],10)}return null}}get filterExpressions(){if(!this.enabled)return{solid:null,xRay:null};const e=[],s=this._createdPhaseFieldName;s&&e.push(`(${s} <= ${this.value} OR ${s} IS NULL)`);const t=this._demolishedPhaseFieldName;t&&e.push(`(${t} > ${this.value} OR ${t} IS NULL)`);const l=e.join(" AND ");return{solid:l,xRay:l}}get _lastValue(){const e=this.allowedValues;return e.length>0?e[e.length-1]:0}_setup(){const e=[];this.layers.forEach((s=>{const t=i(s,d);null!=t&&(this._createdPhaseFieldName=t.fieldName,e.push(t));const l=i(s,a);null!=l&&(this._demolishedPhaseFieldName=l.fieldName,e.push(l))})),this._domainInfo=o(e);const s=this._valueBeforeReady;if(this._set("state","ready"),this._valueBeforeReady=null,this.allowedValues.length>0){const e=s??r(this.layers,this._parseValueFromFilter);this.select(e??this._lastValue)}else this.clear()}};e([s({readOnly:!0})],n.prototype,"filterExpressions",null),e([s()],n.prototype,"_createdPhaseFieldName",void 0),e([s()],n.prototype,"_demolishedPhaseFieldName",void 0),e([s({readOnly:!0})],n.prototype,"_lastValue",null),n=e([t("esri.widgets.BuildingExplorer.BuildingPhase")],n);const h=n;export{h as default};