@arcgis/core 4.27.0 → 4.27.2

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 (62) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/07f52b140db07fa962bb.js +1 -0
  3. package/assets/esri/core/workers/chunks/2d19500b2c042b6b79ac.js +1 -0
  4. package/assets/esri/core/workers/chunks/{979d9f37c555df0e8fa6.js → 7adbd577bb58c3bbaf28.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{588cd91d08cec5207be1.js → 873b608720cce890e572.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{9d4bd73dd50400e9d328.js → 9c8ab6bd8c170cbc5fa5.js} +1 -1
  7. package/assets/esri/core/workers/chunks/da2110b4caff9cc9b116.js +1 -0
  8. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +1 -1
  9. package/assets/esri/themes/base/widgets/_Feature.scss +1 -1
  10. package/assets/esri/themes/base/widgets/_ValuePicker.scss +5 -2
  11. package/assets/esri/themes/dark/main.css +1 -1
  12. package/assets/esri/themes/light/main.css +1 -1
  13. package/assets/esri/themes/light/view.css +1 -1
  14. package/chunks/Pattern.glsl.js +33 -32
  15. package/interfaces.d.ts +42 -12
  16. package/kernel.js +1 -1
  17. package/layers/SceneLayer.js +1 -1
  18. package/layers/VideoLayer.js +1 -1
  19. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  20. package/layers/support/ElevationQuery.js +1 -1
  21. package/layers/support/TelemetryData.js +1 -1
  22. package/layers/support/TelemetryDisplay.js +1 -1
  23. package/layers/support/imageryRendererUtils.js +1 -1
  24. package/layers/video/videoUtils.js +1 -1
  25. package/package.json +1 -1
  26. package/renderers/support/colorRampUtils.js +1 -1
  27. package/support/revision.js +1 -1
  28. package/views/2d/layers/MediaLayerView2D.js +1 -1
  29. package/views/2d/layers/TileLayerView2D.js +1 -1
  30. package/views/3d/layers/graphics/Labeler.js +1 -1
  31. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  32. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  33. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  34. package/views/3d/layers/i3s/featureEditing.js +1 -1
  35. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  36. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  37. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  38. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  39. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  40. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  41. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  42. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  43. package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
  44. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  45. package/views/webgl/AppleAmdDriverHelper.js +5 -0
  46. package/views/webgl/testAppleAmdDrawArrays.js +1 -1
  47. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  48. package/widgets/Attachments.js +1 -1
  49. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  50. package/widgets/Editor/UpdateWorkflow.js +1 -1
  51. package/widgets/Editor.js +1 -1
  52. package/widgets/Feature/FeatureAttachments.js +1 -1
  53. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  54. package/widgets/Feature/support/relatedFeatureUtils.js +1 -1
  55. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  56. package/widgets/FeatureForm/RelationshipInput.js +1 -1
  57. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  58. package/widgets/ValuePicker/ValuePickerSlider.js +1 -1
  59. package/assets/esri/core/workers/chunks/17ab08f60764244b2cf8.js +0 -1
  60. package/assets/esri/core/workers/chunks/38c6452dc9cf18e8bca8.js +0 -1
  61. package/assets/esri/core/workers/chunks/fbd3c78ee8e2219a6c7a.js +0 -1
  62. package/views/3d/webgl-engine/lib/AppleAmdDriverHelper.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{l as i}from"../../../../chunks/vec3.js";import{projectBoundingSphere as n}from"../../../../geometry/projection.js";import{f as s,h as o,u as r,c as l}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as a}from"../../../../support/featureFlags.js";import{LodMetric as d,NodeBase as h,Node as u,ElevationRange as c,NodeFilterImpact as _,NodeIMModificationImpact as g,NodeTraversalState as f}from"./I3SNode.js";import{invalidateMbs as m,invalidateObb as v,addWraparound as b}from"./I3SUtil.js";import{clone as p}from"../../support/orientedBoundingBox.js";class y{constructor(e,t,i,n,s){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=n,this.node=s,this.useAsHole=0,this.filterImpact=_.NotChecked}}class N{constructor(t,i,n,s,o,r,l,h,u,c,_,g,f,m,v){this._layer=t,this._streamDataController=n,this._clientNodeLoader=s,this._viewportQueries=o,this._logger=r,this.holeFilling=l,this._isLoaded=h,this._isReloading=u,this._isSelected=c,this._enable=_,this._needsUpdate=g,this._canRequest=f,this._computeVisibilityObb=m,this._computeNodeFiltering=v,this._dirty=!0,this._nodePages=new Array,this._clientNodePage=null,this._nodeCount=0,this._nodesPerPage=0,this._rootIndex=0,this._lodMetric=d.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loading=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._nodeTraversalState=new Map,this._version=w(0),this._visibilityCacheVersion=w(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missing=new e({deallocator:null}),this._prefetch=new e({deallocator:null}),this._updates=new x(this._missing),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=[],this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._isEditable=a()&&null!=t.associatedLayer&&null!=t.associatedLayer.infoFor3D,t.serviceUpdateTimeStamp&&t.serviceUpdateTimeStamp.lastUpdate&&(this._lastUpdate=`${t.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(i)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._nodesPerPage=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=d.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=d.MaxScreenThreshold,this._lodConversion=T}if(this._isEditable){this._rootIndex=-1;const i=V(e.rootIndex,e.pageSize),n=t.nodes[i],s={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(E(this._rootIndex,this._nodesPerPage),s),this.getNode(-1).serviceObb=void 0}else this._rootIndex=e.rootIndex;this._addPage(E(e.rootIndex,this._nodesPerPage),t),this._updateParentsAndLevel()}else if("node"===e.type){if(this._urlPrefix=e.urlPrefix,this._nodePages.push(O()),this._isEditable){this._clientNodePage=O();const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new h(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new h(e.rootNode.id,null),-1);const t=this._validateNode(e.rootNode.id,e.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){const i=-1,n=new h(e,t),s=this._makeClientRefNode(n,i);return this._linkChildToParentNode(i,s),this.requestUpdate(),s}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loading.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loading.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loading.delete(t),e.madeProgress()}this._updateParentsAndLevel()}_addPage(e,t){const n=[],o=[],r=t.nodes.map(((t,r)=>{const l=n.length,a=t.children?t.children.length:0;o.push(this._rootIndex);for(let e=0;e<a;e++)n.push(t.children[e]);const d=`${t.index}`,h=p(t.obb),c=s(h.center[0],h.center[1],h.center[2],i(h.halfSize)),_=t.mesh&&t.mesh.attribute,g=t.mesh&&t.mesh.geometry,f=t.mesh&&t.mesh.material,m={hasSharedResource:!1,isEmpty:null==g,attributes:_&&null!=_.resource?`${_.resource}`:void 0,geometry:g&&null!=g.resource?`${g.resource}`:void 0,texture:f&&null!=f.resource?`${f.resource}`:void 0,geometryDefinition:g?g.definition:-1,materialDefinition:f?f.definition:-1},v=new u(d,L(r,e,this._nodesPerPage),c,a,0,m,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?g.featureCount:null);return v.serviceObb=h,v.visibilityObb=this._computeVisibilityObb(v),v.vertexCount=g?g.vertexCount:0,new y(l,a,C(this._visibilityCacheVersion),null,v)}));if(-1===e)this._clientNodePage=O(r,n,o);else{for(let t=this._nodePages.length;t<e;t++)this._nodePages[t]=null;this._nodePages[e]=O(r,n,o)}this._nodeCount+=r.length}_updateParentsAndLevel(){const e=new Array,t=(t,i,n)=>{const s=this._getPage(t);if(null!=s){const o=V(t,this._nodesPerPage);s.parents[o]=null!=i?i:-1;const r=s.nodes[o].node;null!=r&&(r.level=n,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),n=this.getNode(i);if(null!=n)for(let e=0;e<n.childCount;e++){t(this.getChildIndex(n.index,e),i,n.level+1),this._maxLevel=Math.max(this._maxLevel,n.level+1)}}}_getPage(e){const t=E(e,this._nodesPerPage);return t<0?this._clientNodePage:this._nodePages[t]}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:t.nodes[V(e,this._nodesPerPage)]}_addNode(e,t){null!=e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),n=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?n+1:n);const{lodMetric:s,maxError:o}=A(e.lodSelection),r=this._getNodeInternal(t);return r.node=new u(e.id,t,e.mbs,r.childCount,n,e.resources,e.version,s,o,e.numFeatures),e.obb&&(r.node.serviceObb=p(e.obb)),r.node.visibilityObb=this._computeVisibilityObb(r.node),null!=r.ref&&(null==r.ref.mbs&&(r.ref.mbs=e.mbs),r.node.renderMbs=r.ref.renderMbs,r.node.serviceObbInRenderSR=r.ref.serviceObbInRenderSR,r.ref.visibilityObb=r.node.visibilityObb),r.node}_makeRefNode(e,t){const i=this._nodePages[0];if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const n=i.nodes.length;return i.nodes.push(new y(0,0,C(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),m(e.renderMbs),v(e.serviceObbInRenderSR),n}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const n=-(i.nodes.length+1);return i.nodes.push(new y(0,0,C(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),m(e.renderMbs),v(e.serviceObbInRenderSR),n}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const n=V(e,this._nodesPerPage),s=V(t,this._nodesPerPage),o=i.nodes[n],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const l=1;o.childCount+=l,null!=o.node&&(o.node.childCount+=l);for(const a of i.nodes)a.childOffset>r&&(a.childOffset+=l);i.parents[s]=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const n=this._clientNodePage;if(null==n)return;const s=this.getParentIndex(e);if(null==s)return;const o=new Set,r=new Map,l=e=>{const i=V(e,this._nodesPerPage),s=n.nodes[i];if(s.childCount>0)for(let t=s.childOffset;t<s.childOffset+s.childCount;++t)l(n.children[t]);t(s.node?.id,e),o.add(s),this._nodeTraversalState.delete(e)};l(e);const a=n.nodes,d=n.children,h=n.parents;n.nodes=[],n.children=[],n.parents=[];const u=n.nodes.map((()=>-1));for(let c=0;c<a.length;++c){const e=a[c];if(o.has(e))continue;const t=n.nodes.length,s=L(c,-1,this._nodesPerPage),l=L(t,-1,this._nodesPerPage);e.node&&(e.node.index=l),u[c]=l,n.nodes.push(e),s!==l&&(i(e.node?.id,s,l),r.set(s,l))}this._nodeCount-=a.length-n.nodes.length;for(let c=0;c<n.nodes.length;++c){const e=n.nodes[c],t=n.children.length;for(let s=e.childOffset;s<e.childOffset+e.childCount;++s){const e=d[s];if(e>=0)n.children.push(e);else{const t=V(e,this._nodesPerPage),i=a[t];if(o.has(i))continue;n.children.push(u[t])}}e.childOffset=t,e.childCount=n.children.length-t;const i=h[c];n.parents.push(u[V(i,this._nodesPerPage)]),e.node&&(e.node.childCount=e.childCount)}this._updateParentBoundingInformation(u[V(s,this._nodesPerPage)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,s=this._clientNodeLoader.renderSR,a=this._getNodeInternal(t);if(null==a)return;for(let l=0;l<a.childCount;l++){const a=this.getChildIndex(t,l),d=this._getNodeInternal(a),h=null!=d?d.ref||d.node:null;if(null!=h&&h.mbs[3]>0)if(null==e)e=o(h.mbs,D);else{const t=U,o=Q,l=$;n(h.mbs,i,t,s),n(e,i,o,s),r(t,o,l),n(l,s,e,i)}}const d=a.ref||a.node;null!=d&&(null!=e?d.mbs=o(e,null!=d.mbs?d.mbs:l()):m(d.mbs),m(d.renderMbs),v(d.serviceObbInRenderSR),d.geometryObb=null),this.invalidateNodeVisibilityCacheInternal(a),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),n=this._getPage(e);i.childOffset=n.children.length,i.childCount=t.length;for(let s=0;s<t.length;s++){const i=this._makeRefNode(t[s],e);n.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,n)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=n)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const n=i.nodes[V(e,this._nodesPerPage)];return i.children[n.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.parents[V(e,this._nodesPerPage)]:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get size(){return this._nodeCount}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=w(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=C(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(I(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;if(null==i)return;const n=i.elevationRange;null!=n&&(n.valid=!1)}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e);null!=t&&null!=t.node&&(t.node.geometryObb=null,m(t.node.renderMbs),v(t.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(e){const t=this._getNodeInternal(e);if(null==t)return null;const i=null!=t.node?t.node:t.ref;if(null==i)return null;const n=i.elevationRange;if(null!=n&&n.valid)return n;const s=new c;let o=!1;for(let r=0;r<t.childCount;r++){const t=this._updateElevationRange(this.getChildIndex(e,r));null!=t?(s.min=Math.min(s.min,t.min),s.max=Math.max(s.max,t.max)):o=!0}if(0===t.childCount||o&&null!=t.node&&t.node.resources.geometry){const e=this._viewportQueries.getElevationRange(i);null!=e&&(s.min=Math.min(s.min,e.min),s.max=Math.max(s.max,e.max))}return null!=n&&n.min===s.min&&n.max===s.max?(n.valid=!0,n):(s.valid=!0,null!=t.node&&(t.node.elevationRange=s),null!=t.ref&&(t.ref.elevationRange=s),this.invalidateBoundingVolumeCache(e),s)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t||null!=t.ref&&!t.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(e),!S(t.visibilityCache,this._visibilityCacheVersion)){const e=t.node,i=!e||t.ref&&!e.visibilityObb?t.ref??null:e;if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=e||null!=t.ref)&&t.filterImpact===_.NotChecked){const i=null!=e?e.mbs:null!=t.ref?t.ref.mbs:null;t.filterImpact=null!=i?this._computeNodeFiltering(i):_.Unmodified}const n=null!=e&&t.filterImpact===_.Culled,s=!(null!=e&&e.imModificationImpact===g.Culled)&&(!i||this._viewportQueries.isNodeVisible(i))&&!n;return t.visibilityCache=M(s,this._visibilityCacheVersion),s}return R(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t||null==t.node||null==t.node.geometryObb||this.layerHasModifications&&t.node.imModificationImpact===g.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,n,s){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,l=new Array;for(let a=t.childOffset;a<r;++a){const e=o.children[a],t=this._getNodeInternal(e);null!=t&&null!=t.node&&this.isGeometryVisible(e)&&l.push(t)}n/=l.length;for(const a of l){const e=a.node.index;this._isLoaded(e)||this._isReloading(e)?(s.delta=Math.max(s.delta,i),s.coverage+=n):this._traverseCoverage(e,a,i+1,n,s)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(S(t.useAsHole,this._version))return R(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const n=i.delta*i.coverage<=.5;return t.useAsHole=M(n,this._version),n}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=w(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=g.NotChecked,e.visibilityObb=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=_.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missing.clear(),this._prefetch.clear(),this._updates.reset(e),P.clear();let n=!0;const s=new F,o=new F,r=this._imModificationUncategorized;r.clear();const l=new Set,a=(a,d,h)=>{if(null==d){let e=this._entryPriority(a);e===1/0&&(e=this._entryPriority(h));const t=E(a,this._nodesPerPage);return P.set(t,Math.max(e,P.get(t)||0)),this._loading.has(t)||this._failedPages.has(t)||this._missing.push(t),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const u=d.node;if(this._updateNodeFeatureEstimate(u,o),null==u){const e=this._entryPriority(a);return this._loading.has(a)||this._failedNodes.has(a)||(this._missing.push(a),P.set(a,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const c=this._getPage(a);if(0===this._missing.length&&0===this._nodesPerPage)for(let e=0;e<d.childCount;e++){const t=c.children[d.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loading.has(t)||this._failedNodes.has(t)||(P.set(t,this._entryPriority(t)),this._prefetch.push(t))}if(u.failed||u.resources.isEmpty)return void(n&&d.childCount>0&&this._isSelected(u)&&(n=!1));if(l.add(u.id),this._isLoaded(a)){if(s.known+=u.memory,++s.knownNodes,this._isSelected(u)?d.childCount>0&&(n=!1):(s.unremoved+=u.memory,n=!1),this._needsUpdate(u)){const e=this._entryPriority(a);P.set(a,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(a)}return}if(u.memory&&(s.known+=u.memory,++s.knownNodes),!this._isSelected(u))return void(this._isReloading(a)&&this._updates.remove.push(a));if(d.childCount>0&&(n=!1),u.memory?(s.missing+=u.memory,s.known+=u.memory,++s.knownNodes):++s.missingNodes,e.includes(u.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(a)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==u.index)));if(!t.done&&this._enable(u))return void t.madeProgress();const _=this._entryPriority(a);P.set(a,_),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,_),this._updates.add.push(a),this.layerHasModifications&&i&&null!=u&&u.imModificationImpact===g.NotChecked&&r.push(a)};this.traverseVisible(a);const d=this._updates.add;d.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),d.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t||null==t.node||t.node.imModificationImpact!==g.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=s.missing-s.unremoved,s.knownNodes>3&&s.missingNodes>0&&(this._unloadedMemoryEstimate+=s.known/s.knownNodes*s.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=n,this._missing.sort(((e,t)=>e-t)),this._missing.filterInPlace(((e,t)=>t<1||this._missing.data[t-1]!==e)),this._missing.sort(((e,t)=>P.get(e)-P.get(t))),this._missing.length>0&&(this._maxUnloadedPrio=P.get(this._missing.back()),this._prefetch.clear()),this._updates.add.filterInPlace((e=>P.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>P.get(e)-P.get(t))),this._updates.update.sort(((e,t)=>P.get(e)-P.get(t))),this._indexMissing=this._loading.size+this._missing.length,this._dirty=this._indexMissing>0,P.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let n=t,s=t,o=i,r=10;for(;r--;){const i=new F;this._updateFeatureEstimate(n,i);if(this._computeFeatureEstimate(i)<=e){if(n>=t||i.missingNodes>0||0===r)break;o=n,n=.5*(n+s)}else s=n,n=.5*(n+o)}return this._version=w(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,n)}_updateFeatureEstimate(e,t){this._version=w(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){if(null!=e&&!e.failed&&null!=e.numFeatures)return this._isLoaded(e.index)?(t.known+=e.numFeatures,++t.knownNodes,void(this._isSelected(e)||(t.unremoved+=e.numFeatures))):void(this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes))}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missing)}prefetch(){return this._prefetch.sort(((e,t)=>P.get(e)-P.get(t))),this._load(this._prefetch)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();)if(0===this._nodesPerPage)this._loadNode(e.pop());else{const t=e.pop();t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetch.length>0}get indexLoading(){return this._loading.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;let t=this._nodeTraversalState.get(e.index);if(t&&S(t.version,this._version))return t;const i=this._viewportQueries.getLodLevel(e),n=this._viewportQueries.hasLOD(e);let s=!0;if(n){const t=this.getParentIndex(e.index);if(null!=t){const e=this._nodeTraversalState.get(t);s=!!e&&i>e.lodLevel}else s=i>0}else s=0===e.childCount;return t?(t.lodLevel=i,t.isChosen=s,t.version=M(!0,this._version),t):(t=new f(n,s,i,M(!0,this._version)),this._nodeTraversalState.set(e.index,t),t)}async _loadNode(e){this._loading.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const n=i.id,s=this._urlPrefix+n,o=()=>{this._loading.delete(e),0===this._missing.length&&0===this._loading.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(s,"json"):await this._clientNodeLoader.loadNodeJSON(n)}catch(d){return o(),void(t(d)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+s),this._failedNodes.add(e)))}o();const l=this._validateNode(n,r);if(null==l)return;l.obb&&this.invalidateNodeVisibilityCache(e);const a=this._addNode(l,e);this.nodeTraversalState(a)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const n=t.attributeData,s=this._layer.attributeStorageInfo;null==n||Array.isArray(n)&&!n.some(((e,t)=>e.href!==`./attributes/${s?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,l=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const n=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,s=new h(`${t.id}`,t.mbs);return s.serviceObb=n,s.visibilityObb=this._computeVisibilityObb(s),s},a=Array.isArray(t.children)?t.children.map(l).filter((e=>null!=e)):null,d=t.featureData&&t.featureData.length>1,u=t.isEmpty&&!0===t.isEmpty;return{id:e,mbs:t.mbs,obb:o,children:a,resources:{isEmpty:!d&&u,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:r}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let n=0;if(t.node&&null!=i){const e=this._nodeTraversalState.get(i);null!=e&&(n=e.lodLevel)}let s=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){s=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-n*(o+this.progressiveLoadPenalty)+s}traverseVisible(e){const t=this._getNodeInternal(this._rootIndex);null!=t?this._traverseVisible(this._rootIndex,null,t,e):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,n){if(i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&n(e,i,t));if(!this.isNodeVisible(e))return;if(n(e,i,t),null==i.node)return;const s=this.nodeTraversalState(i.node);if(s?.nodeHasLOD&&s.lodLevel===this._maxLodLevel)return;const o=this._getPage(e);for(let r=0;r<i.childCount;r++){const t=o.children[i.childOffset+r],s=this._getNodeInternal(t);null!=s?this._traverseVisible(t,e,s,n):n(t,null,e)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(e,t){const i=e.index,n=this._getNodeInternal(i);null!=n&&this._traverseChildren(i,n,t)}_traverseChildren(e,t,i){const n=this._getPage(e);if(null==n)return;const s=t.childOffset+t.childCount;for(let o=t.childOffset;o<s;++o){const e=n.children[o],t=this._getNodeInternal(e);null!=t&&null!=t.node&&i(t.node)&&this._traverseChildren(e,t,i)}}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;)i.childrenLoaded+=t,i=this.getParent(i.index)}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let n=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseChildren(i,(e=>(n+=t(e),!1))),i.childrenLoaded!==n&&e.push(i.index),n};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),(this._indexMissing||this._prefetch.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetch.length),e.prio=this._maxProcessingPrio,this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{I(e),null!=e.node&&(e.node.elevationRange=null),null!=e.ref&&(e.ref.elevationRange=null)}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(let t=0;t<this._nodePages.length;t++){const i=this._nodePages[t];if(i){const n=t*this._nodesPerPage;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],n+t)}}}get test(){return{addNode:(e,t)=>this._addNode(e,t)}}}const P=new Map;class x{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function I(e){null!=e.node&&(m(e.node.renderMbs),v(e.node.serviceObbInRenderSR)),null!=e.ref&&(m(e.ref.renderMbs),v(e.ref.serviceObbInRenderSR))}function C(e){return b(e,-2)}function w(e){return b(e,2)}function M(e,t){return t+(e?1:0)}function S(e,t){return(-2&e)===t}function R(e){return 1==(1&e)}function E(e,t){return e<0?-1:0===t?0:e/t|0}function O(e=[],t=[],i=[]){return{nodes:e,children:t,parents:i}}function V(e,t){return e<0?-e-1:0===t?e:e%t}function L(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const k=[["maxScreenThreshold",d.MaxScreenThreshold],["screenSpaceRelative",d.ScreenSpaceRelative],["removedFeatureDiameter",d.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",d.DistanceRangeFromDefaultCamera]];function A(e){if(e)for(let t=0;t<e.length;t++)for(const i of k)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:d.None,maxError:0}}class F{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function T(e){return Math.sqrt(e*(4/Math.PI))}const D=l(),U=l(),Q=l(),$=l();export{N as I3SIndex,A as selectErrorMetric};
5
+ import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{l as i}from"../../../../chunks/vec3.js";import{projectBoundingSphere as n}from"../../../../geometry/projection.js";import{f as s,h as o,u as r,c as l}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as a}from"../../../../support/featureFlags.js";import{LodMetric as d,NodeBase as h,Node as u,ElevationRange as c,NodeFilterImpact as _,NodeIMModificationImpact as g,NodeTraversalState as f}from"./I3SNode.js";import{invalidateMbs as m,invalidateObb as v,addWraparound as b}from"./I3SUtil.js";import{clone as p}from"../../support/orientedBoundingBox.js";class y{constructor(e,t,i,n,s){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=n,this.node=s,this.useAsHole=0,this.filterImpact=_.NotChecked}}class N{constructor(t,i,n,s,o,r,l,h,u,c,_,g,f,m,v){this._layer=t,this._streamDataController=n,this._clientNodeLoader=s,this._viewportQueries=o,this._logger=r,this.holeFilling=l,this._isLoaded=h,this._isReloading=u,this._isSelected=c,this._enable=_,this._needsUpdate=g,this._canRequest=f,this._computeVisibilityObb=m,this._computeNodeFiltering=v,this._dirty=!0,this._nodePages=new Array,this._clientNodePage=null,this._nodeCount=0,this._nodesPerPage=0,this._rootIndex=0,this._lodMetric=d.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loading=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._nodeTraversalState=new Map,this._version=w(0),this._visibilityCacheVersion=w(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missing=new e({deallocator:null}),this._prefetch=new e({deallocator:null}),this._updates=new x(this._missing),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=[],this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._isEditable=a()&&null!=t.associatedLayer&&null!=t.associatedLayer.infoFor3D,t.serviceUpdateTimeStamp&&t.serviceUpdateTimeStamp.lastUpdate&&(this._lastUpdate=`${t.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(i)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._nodesPerPage=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=d.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=d.MaxScreenThreshold,this._lodConversion=T}if(this._isEditable){this._rootIndex=-1;const i=V(e.rootIndex,e.pageSize),n=t.nodes[i],s={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(E(this._rootIndex,this._nodesPerPage),s),this.getNode(-1).serviceObb=void 0}else this._rootIndex=e.rootIndex;this._addPage(E(e.rootIndex,this._nodesPerPage),t),this._updateParentsAndLevel()}else if("node"===e.type){if(this._urlPrefix=e.urlPrefix,this._nodePages.push(O()),this._isEditable){this._clientNodePage=O();const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new h(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new h(e.rootNode.id,null),-1);const t=this._validateNode(e.rootNode.id,e.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){const i=-1,n=new h(e,t),s=this._makeClientRefNode(n,i);return this._linkChildToParentNode(i,s),this.requestUpdate(),s}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loading.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loading.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loading.delete(t),e.madeProgress()}this._updateParentsAndLevel()}_addPage(e,t){const n=[],o=[],r=t.nodes.map(((t,r)=>{const l=n.length,a=t.children?t.children.length:0;o.push(this._rootIndex);for(let e=0;e<a;e++)n.push(t.children[e]);const d=`${t.index}`,h=p(t.obb),c=s(h.center[0],h.center[1],h.center[2],i(h.halfSize)),_=t.mesh&&t.mesh.attribute,g=t.mesh&&t.mesh.geometry,f=t.mesh&&t.mesh.material,m={hasSharedResource:!1,isEmpty:null==g,attributes:_&&null!=_.resource?`${_.resource}`:void 0,geometry:g&&null!=g.resource?`${g.resource}`:void 0,texture:f&&null!=f.resource?`${f.resource}`:void 0,geometryDefinition:g?g.definition:-1,materialDefinition:f?f.definition:-1},v=new u(d,L(r,e,this._nodesPerPage),c,a,0,m,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?g.featureCount:null);return v.serviceObb=h,v.visibilityObb=this._computeVisibilityObb(v),v.vertexCount=g?g.vertexCount:0,new y(l,a,C(this._visibilityCacheVersion),null,v)}));if(-1===e)this._clientNodePage=O(r,n,o);else{for(let t=this._nodePages.length;t<e;t++)this._nodePages[t]=null;this._nodePages[e]=O(r,n,o)}this._nodeCount+=r.length}_updateParentsAndLevel(){const e=new Array,t=(t,i,n)=>{const s=this._getPage(t);if(null!=s){const o=V(t,this._nodesPerPage);s.parents[o]=null!=i?i:-1;const r=s.nodes[o].node;null!=r&&(r.level=n,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),n=this.getNode(i);if(null!=n)for(let e=0;e<n.childCount;e++){t(this.getChildIndex(n.index,e),i,n.level+1),this._maxLevel=Math.max(this._maxLevel,n.level+1)}}}_getPage(e){const t=E(e,this._nodesPerPage);return t<0?this._clientNodePage:this._nodePages[t]}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:t.nodes[V(e,this._nodesPerPage)]}_addNode(e,t){null!=e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),n=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?n+1:n);const{lodMetric:s,maxError:o}=A(e.lodSelection),r=this._getNodeInternal(t);return r.node=new u(e.id,t,e.mbs,r.childCount,n,e.resources,e.version,s,o,e.numFeatures),e.obb&&(r.node.serviceObb=p(e.obb)),r.node.visibilityObb=this._computeVisibilityObb(r.node),null!=r.ref&&(null==r.ref.mbs&&(r.ref.mbs=e.mbs),r.node.renderMbs=r.ref.renderMbs,r.node.serviceObbInRenderSR=r.ref.serviceObbInRenderSR,r.ref.visibilityObb=r.node.visibilityObb),r.node}_makeRefNode(e,t){const i=this._nodePages[0];if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const n=i.nodes.length;return i.nodes.push(new y(0,0,C(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),m(e.renderMbs),v(e.serviceObbInRenderSR),n}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const n=-(i.nodes.length+1);return i.nodes.push(new y(0,0,C(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),m(e.renderMbs),v(e.serviceObbInRenderSR),n}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const n=V(e,this._nodesPerPage),s=V(t,this._nodesPerPage),o=i.nodes[n],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const l=1;o.childCount+=l,null!=o.node&&(o.node.childCount+=l);for(const a of i.nodes)a.childOffset>r&&(a.childOffset+=l);i.parents[s]=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const n=this._clientNodePage;if(null==n)return;const s=this.getParentIndex(e);if(null==s)return;const o=new Set,r=new Map,l=e=>{const i=V(e,this._nodesPerPage),s=n.nodes[i];if(s.childCount>0)for(let t=s.childOffset;t<s.childOffset+s.childCount;++t)l(n.children[t]);t(s.node?.id,e),o.add(s),this._nodeTraversalState.delete(e)};l(e);const a=n.nodes,d=n.children,h=n.nodes.map((()=>-1)),u=[],c=[];for(let g=0;g<a.length;++g){const e=a[g];if(o.has(e))continue;const t=u.length,n=L(g,-1,this._nodesPerPage),s=L(t,-1,this._nodesPerPage);e.node&&(e.node.index=s),h[g]=s,u.push(e),n!==s&&(i(e.node?.id,n,s),r.set(n,s))}this._nodeCount-=a.length-u.length;const _=u.map((()=>-1));for(let g=0;g<u.length;++g){const e=L(g,-1,this._nodesPerPage),t=u[g],i=c.length;for(let n=t.childOffset;n<t.childOffset+t.childCount;++n){const t=d[n];if(t>=0)c.push(t);else{const i=V(t,this._nodesPerPage),n=a[i];if(o.has(n))continue;const s=h[i];c.push(s);_[V(s,this._nodesPerPage)]=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}n.nodes=u,n.children=c,n.parents=_,this._updateParentBoundingInformation(h[V(s,this._nodesPerPage)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,s=this._clientNodeLoader.renderSR,a=this._getNodeInternal(t);if(null==a)return;for(let l=0;l<a.childCount;l++){const a=this.getChildIndex(t,l),d=this._getNodeInternal(a),h=null!=d?d.ref||d.node:null;if(null!=h&&h.mbs[3]>0)if(null==e)e=o(h.mbs,D);else{const t=U,o=Q,l=$;n(h.mbs,i,t,s),n(e,i,o,s),r(t,o,l),n(l,s,e,i)}}const d=a.ref||a.node;null!=d&&(null!=e?d.mbs=o(e,null!=d.mbs?d.mbs:l()):m(d.mbs),m(d.renderMbs),v(d.serviceObbInRenderSR),d.geometryObb=null),this.invalidateNodeVisibilityCacheInternal(a),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),n=this._getPage(e);i.childOffset=n.children.length,i.childCount=t.length;for(let s=0;s<t.length;s++){const i=this._makeRefNode(t[s],e);n.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,n)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=n)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const n=i.nodes[V(e,this._nodesPerPage)];return i.children[n.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.parents[V(e,this._nodesPerPage)]:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get size(){return this._nodeCount}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=w(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=C(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(I(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;if(null==i)return;const n=i.elevationRange;null!=n&&(n.valid=!1)}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e);null!=t&&null!=t.node&&(t.node.geometryObb=null,m(t.node.renderMbs),v(t.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(e){const t=this._getNodeInternal(e);if(null==t)return null;const i=null!=t.node?t.node:t.ref;if(null==i)return null;const n=i.elevationRange;if(null!=n&&n.valid)return n;const s=new c;let o=!1;for(let r=0;r<t.childCount;r++){const t=this._updateElevationRange(this.getChildIndex(e,r));null!=t?(s.min=Math.min(s.min,t.min),s.max=Math.max(s.max,t.max)):o=!0}if(0===t.childCount||o&&null!=t.node&&t.node.resources.geometry){const e=this._viewportQueries.getElevationRange(i);null!=e&&(s.min=Math.min(s.min,e.min),s.max=Math.max(s.max,e.max))}return null!=n&&n.min===s.min&&n.max===s.max?(n.valid=!0,n):(s.valid=!0,null!=t.node&&(t.node.elevationRange=s),null!=t.ref&&(t.ref.elevationRange=s),this.invalidateBoundingVolumeCache(e),s)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t||null!=t.ref&&!t.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(e),!S(t.visibilityCache,this._visibilityCacheVersion)){const e=t.node,i=!e||t.ref&&!e.visibilityObb?t.ref??null:e;if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=e||null!=t.ref)&&t.filterImpact===_.NotChecked){const i=null!=e?e.mbs:null!=t.ref?t.ref.mbs:null;t.filterImpact=null!=i?this._computeNodeFiltering(i):_.Unmodified}const n=null!=e&&t.filterImpact===_.Culled,s=!(null!=e&&e.imModificationImpact===g.Culled)&&(!i||this._viewportQueries.isNodeVisible(i))&&!n;return t.visibilityCache=M(s,this._visibilityCacheVersion),s}return R(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t||null==t.node||null==t.node.geometryObb||this.layerHasModifications&&t.node.imModificationImpact===g.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,n,s){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,l=new Array;for(let a=t.childOffset;a<r;++a){const e=o.children[a],t=this._getNodeInternal(e);null!=t&&null!=t.node&&this.isGeometryVisible(e)&&l.push(t)}n/=l.length;for(const a of l){const e=a.node.index;this._isLoaded(e)||this._isReloading(e)?(s.delta=Math.max(s.delta,i),s.coverage+=n):this._traverseCoverage(e,a,i+1,n,s)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(S(t.useAsHole,this._version))return R(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const n=i.delta*i.coverage<=.5;return t.useAsHole=M(n,this._version),n}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=w(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=g.NotChecked,e.visibilityObb=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=_.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missing.clear(),this._prefetch.clear(),this._updates.reset(e),P.clear();let n=!0;const s=new F,o=new F,r=this._imModificationUncategorized;r.clear();const l=new Set,a=(a,d,h)=>{if(null==d){let e=this._entryPriority(a);e===1/0&&(e=this._entryPriority(h));const t=E(a,this._nodesPerPage);return P.set(t,Math.max(e,P.get(t)||0)),this._loading.has(t)||this._failedPages.has(t)||this._missing.push(t),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const u=d.node;if(this._updateNodeFeatureEstimate(u,o),null==u){const e=this._entryPriority(a);return this._loading.has(a)||this._failedNodes.has(a)||(this._missing.push(a),P.set(a,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const c=this._getPage(a);if(0===this._missing.length&&0===this._nodesPerPage)for(let e=0;e<d.childCount;e++){const t=c.children[d.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loading.has(t)||this._failedNodes.has(t)||(P.set(t,this._entryPriority(t)),this._prefetch.push(t))}if(u.failed||u.resources.isEmpty)return void(n&&d.childCount>0&&this._isSelected(u)&&(n=!1));if(l.add(u.id),this._isLoaded(a)){if(s.known+=u.memory,++s.knownNodes,this._isSelected(u)?d.childCount>0&&(n=!1):(s.unremoved+=u.memory,n=!1),this._needsUpdate(u)){const e=this._entryPriority(a);P.set(a,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(a)}return}if(u.memory&&(s.known+=u.memory,++s.knownNodes),!this._isSelected(u))return void(this._isReloading(a)&&this._updates.remove.push(a));if(d.childCount>0&&(n=!1),u.memory?(s.missing+=u.memory,s.known+=u.memory,++s.knownNodes):++s.missingNodes,e.includes(u.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(a)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==u.index)));if(!t.done&&this._enable(u))return void t.madeProgress();const _=this._entryPriority(a);P.set(a,_),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,_),this._updates.add.push(a),this.layerHasModifications&&i&&null!=u&&u.imModificationImpact===g.NotChecked&&r.push(a)};this.traverseVisible(a);const d=this._updates.add;d.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),d.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t||null==t.node||t.node.imModificationImpact!==g.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=s.missing-s.unremoved,s.knownNodes>3&&s.missingNodes>0&&(this._unloadedMemoryEstimate+=s.known/s.knownNodes*s.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=n,this._missing.sort(((e,t)=>e-t)),this._missing.filterInPlace(((e,t)=>t<1||this._missing.data[t-1]!==e)),this._missing.sort(((e,t)=>P.get(e)-P.get(t))),this._missing.length>0&&(this._maxUnloadedPrio=P.get(this._missing.back()),this._prefetch.clear()),this._updates.add.filterInPlace((e=>P.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>P.get(e)-P.get(t))),this._updates.update.sort(((e,t)=>P.get(e)-P.get(t))),this._indexMissing=this._loading.size+this._missing.length,this._dirty=this._indexMissing>0,P.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let n=t,s=t,o=i,r=10;for(;r--;){const i=new F;this._updateFeatureEstimate(n,i);if(this._computeFeatureEstimate(i)<=e){if(n>=t||i.missingNodes>0||0===r)break;o=n,n=.5*(n+s)}else s=n,n=.5*(n+o)}return this._version=w(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,n)}_updateFeatureEstimate(e,t){this._version=w(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){if(null!=e&&!e.failed&&null!=e.numFeatures)return this._isLoaded(e.index)?(t.known+=e.numFeatures,++t.knownNodes,void(this._isSelected(e)||(t.unremoved+=e.numFeatures))):void(this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes))}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missing)}prefetch(){return this._prefetch.sort(((e,t)=>P.get(e)-P.get(t))),this._load(this._prefetch)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();)if(0===this._nodesPerPage)this._loadNode(e.pop());else{const t=e.pop();t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetch.length>0}get indexLoading(){return this._loading.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;let t=this._nodeTraversalState.get(e.index);if(t&&S(t.version,this._version))return t;const i=this._viewportQueries.getLodLevel(e),n=this._viewportQueries.hasLOD(e);let s=!0;if(n){const t=this.getParentIndex(e.index);if(null!=t){const e=this._nodeTraversalState.get(t);s=!!e&&i>e.lodLevel}else s=i>0}else s=0===e.childCount;return t?(t.lodLevel=i,t.isChosen=s,t.version=M(!0,this._version),t):(t=new f(n,s,i,M(!0,this._version)),this._nodeTraversalState.set(e.index,t),t)}async _loadNode(e){this._loading.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const n=i.id,s=this._urlPrefix+n,o=()=>{this._loading.delete(e),0===this._missing.length&&0===this._loading.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(s,"json"):await this._clientNodeLoader.loadNodeJSON(n)}catch(d){return o(),void(t(d)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+s),this._failedNodes.add(e)))}o();const l=this._validateNode(n,r);if(null==l)return;l.obb&&this.invalidateNodeVisibilityCache(e);const a=this._addNode(l,e);this.nodeTraversalState(a)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const n=t.attributeData,s=this._layer.attributeStorageInfo;null==n||Array.isArray(n)&&!n.some(((e,t)=>e.href!==`./attributes/${s?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,l=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const n=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,s=new h(`${t.id}`,t.mbs);return s.serviceObb=n,s.visibilityObb=this._computeVisibilityObb(s),s},a=Array.isArray(t.children)?t.children.map(l).filter((e=>null!=e)):null,d=t.featureData&&t.featureData.length>1,u=t.isEmpty&&!0===t.isEmpty;return{id:e,mbs:t.mbs,obb:o,children:a,resources:{isEmpty:!d&&u,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:r}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let n=0;if(t.node&&null!=i){const e=this._nodeTraversalState.get(i);null!=e&&(n=e.lodLevel)}let s=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){s=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-n*(o+this.progressiveLoadPenalty)+s}traverseVisible(e){const t=this._getNodeInternal(this._rootIndex);null!=t?this._traverseVisible(this._rootIndex,null,t,e):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,n){if(i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&n(e,i,t));if(!this.isNodeVisible(e))return;if(n(e,i,t),null==i.node)return;const s=this.nodeTraversalState(i.node);if(s?.nodeHasLOD&&s.lodLevel===this._maxLodLevel)return;const o=this._getPage(e);for(let r=0;r<i.childCount;r++){const t=o.children[i.childOffset+r],s=this._getNodeInternal(t);null!=s?this._traverseVisible(t,e,s,n):n(t,null,e)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(e,t){const i=e.index,n=this._getNodeInternal(i);null!=n&&this._traverseChildren(i,n,t)}_traverseChildren(e,t,i){const n=this._getPage(e);if(null==n)return;const s=t.childOffset+t.childCount;for(let o=t.childOffset;o<s;++o){const e=n.children[o],t=this._getNodeInternal(e);null!=t&&null!=t.node&&i(t.node)&&this._traverseChildren(e,t,i)}}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;)i.childrenLoaded+=t,i=this.getParent(i.index)}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let n=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseChildren(i,(e=>(n+=t(e),!1))),i.childrenLoaded!==n&&e.push(i.index),n};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),(this._indexMissing||this._prefetch.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetch.length),e.prio=this._maxProcessingPrio,this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{I(e),null!=e.node&&(e.node.elevationRange=null),null!=e.ref&&(e.ref.elevationRange=null)}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(let t=0;t<this._nodePages.length;t++){const i=this._nodePages[t];if(i){const n=t*this._nodesPerPage;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],n+t)}}}get test(){return{addNode:(e,t)=>this._addNode(e,t)}}}const P=new Map;class x{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function I(e){null!=e.node&&(m(e.node.renderMbs),v(e.node.serviceObbInRenderSR)),null!=e.ref&&(m(e.ref.renderMbs),v(e.ref.serviceObbInRenderSR))}function C(e){return b(e,-2)}function w(e){return b(e,2)}function M(e,t){return t+(e?1:0)}function S(e,t){return(-2&e)===t}function R(e){return 1==(1&e)}function E(e,t){return e<0?-1:0===t?0:e/t|0}function O(e=[],t=[],i=[]){return{nodes:e,children:t,parents:i}}function V(e,t){return e<0?-e-1:0===t?e:e%t}function L(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const k=[["maxScreenThreshold",d.MaxScreenThreshold],["screenSpaceRelative",d.ScreenSpaceRelative],["removedFeatureDiameter",d.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",d.DistanceRangeFromDefaultCamera]];function A(e){if(e)for(let t=0;t<e.length;t++)for(const i of k)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:d.None,maxError:0}}class F{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function T(e){return Math.sqrt(e*(4/Math.PI))}const D=l(),U=l(),Q=l(),$=l();export{N as I3SIndex,A as selectErrorMetric};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as r}from"../../../../core/arrayUtils.js";import{resultOrAbort as i,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u,createResolver as m,ignoreAbortErrors as p,throwIfAborted as g}from"../../../../core/promiseUtils.js";import y from"../../../../core/ReactiveSet.js";import{watch as f,initial as _}from"../../../../core/reactiveUtils.js";import{property as b}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as O}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as C}from"../../../../intl/number.js";import{getMaximumQuerySize as j,queryAllJSON as v}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as I,extractMesh as A}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as F,i3sPatchingEnabled as L,sceneLayerEditingEnabled as w}from"../../../../support/featureFlags.js";import{isTimeoutError as E}from"../../../../support/requestUtils.js";import x from"../FeatureLayerView3D.js";const G="esri.views.3d.layers.i3s.I3SOverrides";let D=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=T,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new y,this._geometryChangedObjectIds=new y,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._pendingAttributeQueriesCache=new Map}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally((()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(F()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(f((()=>this._definitionExpression),(t=>e.definitionExpression=t),_)),this._associatedLayerView=new x({layer:this._associatedLayer,view:this.view}))})):L())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(F()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):L()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._pendingAttributeQueriesCache.clear()}get is3DOFL(){return w()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(F()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return L(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);const t=w()&&L()&&null!=this.is3DOFL,s=this._interactiveEditingSessions,r=new S(e,{rollback:()=>{s.remove(r)},commit:(s,r)=>{for(const[t,i]of s)this.updateAttributeValue(e,t,i);t&&null!=r&&this.updateGeometry(e,r)}});return s.unshift(r),r}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:r,attributeData:i}=t;if(null==r||0===r.length||null==i)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:r,attributeData:i},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryAttributeOverridesFromAssociatedLayer(a,d,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s)}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},r){const i=new Set,o=new Array;for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(r.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(i.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(i),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const r=this._getAttributeCacheKey(e,t);return this._memCache.get(r)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const r=s.getAttribute(t);if(void 0!==r)return r}}_getAttributeCacheKey(e,t){return`${e}-${t}`}async _queryAttributeOverridesFromAssociatedLayer(e,t,s){if(0===e.length)return null;this._logWarningIfMaximumObjectsExceeded();const{associatedLayer:r}=this.layer;if(null==r)return null;const i=this._pendingAttributeQueriesCache,o=new Array,n=new Map;for(const g of e){const e=i.get(g);if(e)o.push(e);else{const e=m();p(e.promise),n.set(g,e),i.set(g,e.promise)}}const a=Array.from(n.keys()),d=r.createQuery(),{objectIdField:c}=r,h=[c,...t];d.where="1=1",d.returnGeometry=!1,d.outFields=h,d.cacheHint=!0,d.objectIds=a;const[l,u]=await Promise.all([this._executeBatchQuery(r,a,d,s),Promise.all(o)]).then((e=>(g(s),e))).catch((e=>{for(const[t,s]of n)i.delete(t),s.reject(e);throw e})),y=[];for(const m of l)if(m.ok)for(const e of m.value.features){const t=e,s=t.attributes[c];n.get(s)?.resolve(t),i.delete(s),n.delete(s),y.push(t)}for(const m of u)m&&y.push(m);for(const[m,p]of n)i.delete(m),p.resolve(null);return y}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(0===e.length||!this.is3DOFL||!L())return null;this._logWarningIfMaximumObjectsExceeded();const s=this.layer.associatedLayer,{objectIdField:r,globalIdField:i}=s,o=[r,...null!=i?[i]:[]],n=s.createQuery();n.where="1=1",n.returnGeometry=!0,n.outFields=o,n.cacheHint=!0,n.objectIds=e,n.returnZ=s.hasZ,n.returnM=s.hasM;const a=await this._executeBatchQuery(s,e,n,t),d=s.infoFor3D,{spatialReference:c}=s,h=[];for(const l of a){if(!l.ok)continue;const e=l.value,{assetMaps:t,features:s,globalIdFieldName:r}=e;if(null==t)continue;const i=I(d,t);for(const o of s){const e=A(o,r,c,d,i),t=o;null!=e?(t.geometry=e,h.push(t)):t.geometry=null}}return h}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${C(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger(G).warn("#queryOverrides()",this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,s,o){if(0===t.length)return[];const n=j(e);t=[...t].sort(((e,t)=>e-t));const a=r(t,n).map((t=>{const r=s.clone();return r.objectIds=t,i(v(e,r,{signal:o}))}));return Promise.all(a)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:r,attributeData:i}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in i||(i[t]=new Array(e.length)),i[t]))),d=new Map(r.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const r=c[t],i=h.get(e),o=l.attributes[s[t]];a[t][i]=o,this._cacheAttributeValue(e,r,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:r}=s;if(null==r||!r.capabilities?.operations?.supportsChangeTracking)return;const i=this._getFetchChangedObjectIdsServerGen();if(null==i)return;const n=r.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:i}])};if(a){const e=r.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const h=await o(t(`${r.url}/extractChanges`,{method:"post",query:d,timeout:M,signal:e}));if(!h.ok&&E(h.error)){const e=this.layer.title;c.getLogger(G).warn("extractChanges:timeout",e,`${e} could not obtain edited features that are not cached in the scene service. Display of features may not be up to date with the latest edits. Consider re-caching the scene service.`)}if(h.ok&&1===h.value.data?.edits?.length){const t=h.value.data.edits[0],s=t?.objectIds,i=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],d=s?.deletes??[],c=[...o,...n,...d],l=a?[...o,...i??n,...d]:[],u=Math.min(this._maximumNumberOfEditOVerrides,c.length);u<c.length&&(this._warnMaximumChangedObjectsExceeded=!0);const m=c.sort(((e,t)=>e-t));for(let e=0;e<u;++e){const t=m[e];this._attributeChangedObjectIds.add(t)}for(const e of l)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&L()&&this._geometryChangedObjectIds.size>0){const t=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[r.objectIdField],e.geometry)}}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([b({constructOnly:!0})],D.prototype,"view",void 0),e([b({constructOnly:!0})],D.prototype,"layer",void 0),e([b({readOnly:!0})],D.prototype,"is3DOFL",null),e([b()],D.prototype,"_interactiveEditingSessions",void 0),e([b({readOnly:!0})],D.prototype,"sortedGeometryChangedObjectIds",null),e([b({readOnly:!0})],D.prototype,"geometryOverrides",void 0),e([b()],D.prototype,"_clientGeometryCache",void 0),e([b()],D.prototype,"_associatedLayer",null),e([b()],D.prototype,"_associatedLayerView",void 0),e([b({constructOnly:!0})],D.prototype,"memoryController",void 0),e([b()],D.prototype,"_attributeChangedObjectIds",void 0),e([b()],D.prototype,"_geometryChangedObjectIds",void 0),e([b()],D.prototype,"hasGeometryChanges",null),e([b()],D.prototype,"_pendingFetchChangedObjectIds",void 0),e([b()],D.prototype,"_pendingFetchAbortController",void 0),e([b()],D.prototype,"_definitionExpression",null),e([b()],D.prototype,"updating",null),e([b()],D.prototype,"isEmpty",null),D=e([O(G)],D);class S{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=V.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=V.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=V.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===V.ACTIVE}}var V;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(V||(V={}));const M=1e4,T=5e4;export{D as I3SOverrides};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as r}from"../../../../core/arrayUtils.js";import{resultOrAbort as i,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u,createResolver as m,ignoreAbortErrors as p,throwIfAborted as g}from"../../../../core/promiseUtils.js";import y from"../../../../core/ReactiveSet.js";import{watch as b,initial as _}from"../../../../core/reactiveUtils.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as O}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as C}from"../../../../intl/number.js";import{getMaximumQuerySize as j,queryAllJSON as v}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as I,extractMesh as A}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as F,i3sPatchingEnabled as L,sceneLayerEditingEnabled as w}from"../../../../support/featureFlags.js";import{isTimeoutError as E}from"../../../../support/requestUtils.js";import x from"../FeatureLayerView3D.js";const G="esri.views.3d.layers.i3s.I3SOverrides";let D=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=T,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new y,this._geometryChangedObjectIds=new y,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._pendingAttributeQueriesCache=new Map}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally((()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(F()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(b((()=>this._definitionExpression),(t=>e.definitionExpression=t),_)),this._associatedLayerView=new x({layer:this._associatedLayer,view:this.view}))})):L())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(F()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):L()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._pendingAttributeQueriesCache.clear()}get is3DOFL(){return w()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(F()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return L(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);const t=w()&&L()&&null!=this.is3DOFL,s=this._interactiveEditingSessions,r=new S(e,{rollback:()=>{s.remove(r)},commit:(s,r)=>{for(const[t,i]of s)this.updateAttributeValue(e,t,i);t&&null!=r&&this.updateGeometry(e,r)}});return s.unshift(r),r}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:r,attributeData:i}=t;if(null==r||0===r.length||null==i)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:r,attributeData:i},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryAttributeOverridesFromAssociatedLayer(a,d,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s)}featureAdded(e){this.is3DOFL&&L()&&this._geometryChangedObjectIds.add(e),this._attributeChangedObjectIds.add(e)}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},r){const i=new Set,o=new Array;for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(r.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(i.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(i),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const r=this._getAttributeCacheKey(e,t);return this._memCache.get(r)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const r=s.getAttribute(t);if(void 0!==r)return r}}_getAttributeCacheKey(e,t){return`${e}-${t}`}async _queryAttributeOverridesFromAssociatedLayer(e,t,s){if(0===e.length)return null;this._logWarningIfMaximumObjectsExceeded();const{associatedLayer:r}=this.layer;if(null==r)return null;const i=this._pendingAttributeQueriesCache,o=new Array,n=new Map;for(const g of e){const e=i.get(g);if(e)o.push(e);else{const e=m();p(e.promise),n.set(g,e),i.set(g,e.promise)}}const a=Array.from(n.keys()),d=r.createQuery(),{objectIdField:c}=r,h=[c,...t];d.where="1=1",d.returnGeometry=!1,d.outFields=h,d.cacheHint=!0,d.objectIds=a;const[l,u]=await Promise.all([this._executeBatchQuery(r,a,d,s),Promise.all(o)]).then((e=>(g(s),e))).catch((e=>{for(const[t,s]of n)i.delete(t),s.reject(e);throw e})),y=[];for(const m of l)if(m.ok)for(const e of m.value.features){const t=e,s=t.attributes[c];n.get(s)?.resolve(t),i.delete(s),n.delete(s),y.push(t)}for(const m of u)m&&y.push(m);for(const[m,p]of n)i.delete(m),p.resolve(null);return y}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(0===e.length||!this.is3DOFL||!L())return null;this._logWarningIfMaximumObjectsExceeded();const s=this.layer.associatedLayer,{objectIdField:r,globalIdField:i}=s,o=[r,...null!=i?[i]:[]],n=s.createQuery();n.where="1=1",n.returnGeometry=!0,n.outFields=o,n.cacheHint=!0,n.objectIds=e,n.returnZ=s.hasZ,n.returnM=s.hasM;const a=await this._executeBatchQuery(s,e,n,t),d=s.infoFor3D,{spatialReference:c}=s,h=[];for(const l of a){if(!l.ok)continue;const e=l.value,{assetMaps:t,features:s,globalIdFieldName:r}=e;if(null==t)continue;const i=I(d,t);for(const o of s){const e=A(o,r,c,d,i),t=o;null!=e?(t.geometry=e,h.push(t)):t.geometry=null}}return h}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${C(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger(G).warn("#queryOverrides()",this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,s,o){if(0===t.length)return[];const n=j(e);t=[...t].sort(((e,t)=>e-t));const a=r(t,n).map((t=>{const r=s.clone();return r.objectIds=t,i(v(e,r,{signal:o}))}));return Promise.all(a)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:r,attributeData:i}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in i||(i[t]=new Array(e.length)),i[t]))),d=new Map(r.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const r=c[t],i=h.get(e),o=l.attributes[s[t]];a[t][i]=o,this._cacheAttributeValue(e,r,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:r}=s;if(null==r||!r.capabilities?.operations?.supportsChangeTracking)return;const i=this._getFetchChangedObjectIdsServerGen();if(null==i)return;const n=r.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:i}])};if(a){const e=r.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const h=await o(t(`${r.url}/extractChanges`,{method:"post",query:d,timeout:M,signal:e}));if(!h.ok&&E(h.error)){const e=this.layer.title;c.getLogger(G).warn("extractChanges:timeout",e,`${e} could not obtain edited features that are not cached in the scene service. Display of features may not be up to date with the latest edits. Consider re-caching the scene service.`)}if(h.ok&&1===h.value.data?.edits?.length){const t=h.value.data.edits[0],s=t?.objectIds,i=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],d=s?.deletes??[],c=[...o,...n,...d],l=a?[...o,...i??n,...d]:[],u=Math.min(this._maximumNumberOfEditOVerrides,c.length);u<c.length&&(this._warnMaximumChangedObjectsExceeded=!0);const m=c.sort(((e,t)=>e-t));for(let e=0;e<u;++e){const t=m[e];this._attributeChangedObjectIds.add(t)}for(const e of l)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&L()&&this._geometryChangedObjectIds.size>0){const t=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[r.objectIdField],e.geometry)}}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([f({constructOnly:!0})],D.prototype,"view",void 0),e([f({constructOnly:!0})],D.prototype,"layer",void 0),e([f({readOnly:!0})],D.prototype,"is3DOFL",null),e([f()],D.prototype,"_interactiveEditingSessions",void 0),e([f({readOnly:!0})],D.prototype,"sortedGeometryChangedObjectIds",null),e([f({readOnly:!0})],D.prototype,"geometryOverrides",void 0),e([f()],D.prototype,"_clientGeometryCache",void 0),e([f()],D.prototype,"_associatedLayer",null),e([f()],D.prototype,"_associatedLayerView",void 0),e([f({constructOnly:!0})],D.prototype,"memoryController",void 0),e([f()],D.prototype,"_attributeChangedObjectIds",void 0),e([f()],D.prototype,"_geometryChangedObjectIds",void 0),e([f()],D.prototype,"hasGeometryChanges",null),e([f()],D.prototype,"_pendingFetchChangedObjectIds",void 0),e([f()],D.prototype,"_pendingFetchAbortController",void 0),e([f()],D.prototype,"_definitionExpression",null),e([f()],D.prototype,"updating",null),e([f()],D.prototype,"isEmpty",null),D=e([O(G)],D);class S{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=V.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=V.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=V.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===V.ACTIVE}}var V;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(V||(V={}));const M=1e4,T=5e4;export{D as I3SOverrides};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{clone as t}from"../../../../core/lang.js";import{attributeLookup as e}from"../support/attributeUtils.js";const n={setAttribute(){},setGeometry(t){},rollback(){},commit(){}};var r;function o(e,o){const s=o.attributes[e.objectIdField],l=e.sessions.get(s);if(l)return l;const u=t(o.attributes),i=new Set;if(null==s)return n;const a=e.i3sOverrides.createInteractiveEditSession(s),c=new Map,d=(t,e)=>{const n=c.get(t);if(null==n){const n=e.indexOf(s);return c.set(t,n),n}return n};let f=r.EDITING;const b={setAttribute(t,n){if(f!==r.EDITING)return;const s=e.fieldsIndex.get(t);if(!s)return;const l=e.attributeStorageInfo.findIndex((t=>t.name===s.name));if(l<0)return;a.setAttribute(l,n);const u=e.attributeStorageInfo[l];let c=!1;i.add(t),e.forEachNode(((t,r)=>{const s=d(t,r);if(-1===s)return;const l=e.getAttributeData(t.index);if(l){const r=l[u.name];r&&(r[s]=n,e.setAttributeData(t.index,l,o),c=!0)}})),c&&e.clearMemCache()},setGeometry(t){f===r.EDITING&&a.setGeometry(t)},rollback(){if(f===r.EDITING){for(const t of i)this.setAttribute(t,u[t]);a.rollback(),f=r.ROLLED_BACK,e.sessions.delete(s)}},commit(){f===r.EDITING&&(a.commit(),f=r.COMMITTED,e.sessions.delete(s))}};return e.sessions.set(s,b),b}function s(t,n){const r=t.fieldsIndex,o=t.objectIdField,s=t.globalIdField;if(null==s)return;const l=new Map,u=f(n.addedFeatures),i=n.edits.addFeatures,a=b(n.updatedFeatures),c=n.edits.updateFeatures,I=d(r,o,s,n.edits?.deleteFeatures),g=b(n.deletedFeatures,I),m=n.edits.deleteFeatures;if(null!=i&&i.length>0)for(const d of i){const t=e(r,d.attributes,s),n=u.get(t);null!=d.geometry&&"mesh"===d.geometry.type&&null!=n&&l.set(n,d.geometry)}if(null!=c&&c.length>0)for(const d of c){const t=e(r,d.attributes,o);null!=d.geometry&&"mesh"===d.geometry.type&&a.has(t)&&l.set(t,d.geometry)}if(null!=m&&m.length>0)for(const d of m){let t=null;t="attributes"in d?e(r,d.attributes,o):d.objectId,null!=t&&g.has(t)&&l.set(t,null)}for(const[e,d]of l)t.i3sOverrides.updateGeometry(e,d)}function l(t,e){const n=i(t,e),r=u(t,e);if(0===n.size&&0===r.size)return;const o=new Map;for(let u=0;u<t.attributeStorageInfo.length;u++)o.set(t.attributeStorageInfo[u].name,u);let s=!1;n.forEach(((e,n)=>{const r=t.getAttributeData(n);let l=!1;e.forEach(((e,n)=>{const u=null!=r?r[n]:null,i=o.get(n);for(const{featureIndex:r,value:o,featureId:a}of e)u&&(u[r]=o,l=!0,s=!0),t.i3sOverrides.updateAttributeValue(a,i,o)})),l&&t.setAttributeData(n,r,null)})),s&&t.clearMemCache();const{fieldsIndex:l}=t;for(const[u,i]of r){const{attributes:e}=i;for(const n in e){const r=l.normalizeFieldName(n),s=null!=r?o.get(r):null;if(null==s)continue;const i=e[n];t.i3sOverrides.updateAttributeValue(u,s,i)}}}function u(t,{edits:n,addedFeatures:r}){const o=new Map,s=n.addAssetFeatures,{fieldsIndex:l,globalIdField:u}=t;if(!s||0===s.length||null==u)return o;const i=f(r);for(const a of s){const t=e(l,a.attributes,u),n=i.get(t);null!=a.geometry&&"mesh"===a.geometry.type&&null!=n&&o.set(n,a)}return o}function i(t,n){const r=n.edits.updateFeatures;if(!r||0===r.length)return new g;const o=b(n.updatedFeatures),s=new g,l=new Map;for(let e=0;e<t.attributeStorageInfo.length;e++)l.set(t.attributeStorageInfo[e].name,e);const u=t.fieldsIndex,i=t.objectIdField,c=r.filter((t=>{const n=e(u,t.attributes,i);return o.has(n)}));return t.forEachNode(((n,r)=>{const o=new Set(r);for(const l of c){const c=e(u,l.attributes,i);if(!o.has(c))continue;const d=r.indexOf(c);for(const e in l.attributes){const r=t.fieldsIndex.normalizeFieldName(e),o=a(s,n.index,r),u=l.attributes[e];o.push({featureIndex:d,featureId:c,value:u})}}})),s}function a(t,e,n){const r=c(t,e),o=null!=n&&r.get(n);if(o)return o;const s=new Array;return r.set(n,s),s}function c(t,e){const n=t.get(e);if(n)return n;const r=new I;return t.set(e,r),r}function d(t,n,r,o){const s=new Map;if(!o)return s;for(const l of o){let o=null,u=null;"attributes"in l?(o=e(t,l.attributes,n),u=e(t,l.attributes,r)):(o=l.objectId,u=l.globalId),null!=u&&null!=o&&s.set(u,o)}return s}function f(t){const e=new Map;if(!t)return e;for(const n of t)null!=n.globalId&&null!=n.objectId&&null==n.error&&e.set(n.globalId,n.objectId);return e}function b(t,e=null){const n=new Set;if(!t)return n;for(const r of t)if(null==r.error)if(null!=r.objectId&&-1!==r.objectId)n.add(r.objectId);else if(null!=r.globalId&&null!=e){const t=e.get(r.globalId);null!=t&&n.add(t)}return n}!function(t){t[t.EDITING=0]="EDITING",t[t.ROLLED_BACK=1]="ROLLED_BACK",t[t.COMMITTED=2]="COMMITTED"}(r||(r={}));const I=Map,g=Map;export{o as createInteractiveEditSession,l as processAttributeEdits,s as processGeometryEdits};
5
+ import{clone as t}from"../../../../core/lang.js";import{attributeLookup as e}from"../support/attributeUtils.js";const n={setAttribute(){},setGeometry(t){},rollback(){},commit(){}};var o;function r(e,r){const s=r.attributes[e.objectIdField],l=e.sessions.get(s);if(l)return l;const u=t(r.attributes),i=new Set;if(null==s)return n;const a=e.i3sOverrides.createInteractiveEditSession(s),c=new Map,d=(t,e)=>{const n=c.get(t);if(null==n){const n=e.indexOf(s);return c.set(t,n),n}return n};let f=o.EDITING;const b={setAttribute(t,n){if(f!==o.EDITING)return;const s=e.fieldsIndex.get(t);if(!s)return;const l=e.attributeStorageInfo.findIndex((t=>t.name===s.name));if(l<0)return;a.setAttribute(l,n);const u=e.attributeStorageInfo[l];let c=!1;i.add(t),e.forEachNode(((t,o)=>{const s=d(t,o);if(-1===s)return;const l=e.getAttributeData(t.index);if(l){const o=l[u.name];o&&(o[s]=n,e.setAttributeData(t.index,l,r),c=!0)}})),c&&e.clearMemCache()},setGeometry(t){f===o.EDITING&&a.setGeometry(t)},rollback(){if(f===o.EDITING){for(const t of i)this.setAttribute(t,u[t]);a.rollback(),f=o.ROLLED_BACK,e.sessions.delete(s)}},commit(){f===o.EDITING&&(a.commit(),f=o.COMMITTED,e.sessions.delete(s))}};return e.sessions.set(s,b),b}function s(t,n){const o=t.fieldsIndex,r=t.objectIdField,s=t.globalIdField;if(null==s)return;const l=new Map,u=f(n.addedFeatures),i=n.edits.addFeatures,a=b(n.updatedFeatures),c=n.edits.updateFeatures,I=d(o,r,s,n.edits?.deleteFeatures),g=b(n.deletedFeatures,I),m=n.edits.deleteFeatures;if(null!=i&&i.length>0)for(const d of i){const t=e(o,d.attributes,s),n=u.get(t);null!=d.geometry&&"mesh"===d.geometry.type&&null!=n&&l.set(n,d.geometry)}if(null!=c&&c.length>0)for(const d of c){const t=e(o,d.attributes,r);null!=d.geometry&&"mesh"===d.geometry.type&&a.has(t)&&l.set(t,d.geometry)}if(null!=m&&m.length>0)for(const d of m){let t=null;t="attributes"in d?e(o,d.attributes,r):d.objectId,null!=t&&g.has(t)&&l.set(t,null)}for(const[e,d]of l)t.i3sOverrides.updateGeometry(e,d)}function l(t,e){const n=i(t,e),o=u(t,e);if(0===n.size&&0===o.size)return;const r=new Map;for(let u=0;u<t.attributeStorageInfo.length;u++)r.set(t.attributeStorageInfo[u].name,u);let s=!1;n.forEach(((e,n)=>{const o=t.getAttributeData(n);let l=!1;e.forEach(((e,n)=>{const u=null!=o?o[n]:null,i=r.get(n);for(const{featureIndex:o,value:r,featureId:a}of e)u&&(u[o]=r,l=!0,s=!0),t.i3sOverrides.updateAttributeValue(a,i,r)})),l&&t.setAttributeData(n,o,null)})),s&&t.clearMemCache();const{fieldsIndex:l,i3sOverrides:a,objectIdField:c,globalIdField:d}=t,f=a.layer.associatedLayer?.infoFor3D,b=new Set(f?[...Object.values(f.assetMapFieldRoles),...Object.values(f.transformFieldRoles)]:[]);for(const[u,i]of o){a.featureAdded(u);const{attributes:t}=i;for(const e in t){if(e!==c&&e!==d&&b.has(e))continue;const n=l.normalizeFieldName(e),o=null!=n?r.get(n):null;if(null==o)continue;const s=t[e];a.updateAttributeValue(u,o,s)}}}function u(t,{edits:n,addedFeatures:o}){const r=new Map,s=n.addAssetFeatures,{fieldsIndex:l,globalIdField:u}=t;if(!s||0===s.length||null==u)return r;const i=f(o);for(const a of s){const t=e(l,a.attributes,u),n=i.get(t);null!=a.geometry&&"mesh"===a.geometry.type&&null!=n&&r.set(n,a)}return r}function i(t,n){const o=n.edits.updateFeatures;if(!o||0===o.length)return new g;const r=b(n.updatedFeatures),s=new g,l=new Map;for(let e=0;e<t.attributeStorageInfo.length;e++)l.set(t.attributeStorageInfo[e].name,e);const u=t.fieldsIndex,i=t.objectIdField,c=o.filter((t=>{const n=e(u,t.attributes,i);return r.has(n)}));return t.forEachNode(((n,o)=>{const r=new Set(o);for(const l of c){const c=e(u,l.attributes,i);if(!r.has(c))continue;const d=o.indexOf(c);for(const e in l.attributes){const o=t.fieldsIndex.normalizeFieldName(e),r=a(s,n.index,o),u=l.attributes[e];r.push({featureIndex:d,featureId:c,value:u})}}})),s}function a(t,e,n){const o=c(t,e),r=null!=n&&o.get(n);if(r)return r;const s=new Array;return o.set(n,s),s}function c(t,e){const n=t.get(e);if(n)return n;const o=new I;return t.set(e,o),o}function d(t,n,o,r){const s=new Map;if(!r)return s;for(const l of r){let r=null,u=null;"attributes"in l?(r=e(t,l.attributes,n),u=e(t,l.attributes,o)):(r=l.objectId,u=l.globalId),null!=u&&null!=r&&s.set(u,r)}return s}function f(t){const e=new Map;if(!t)return e;for(const n of t)null!=n.globalId&&null!=n.objectId&&null==n.error&&e.set(n.globalId,n.objectId);return e}function b(t,e=null){const n=new Set;if(!t)return n;for(const o of t)if(null==o.error)if(null!=o.objectId&&-1!==o.objectId)n.add(o.objectId);else if(null!=o.globalId&&null!=e){const t=e.get(o.globalId);null!=t&&n.add(t)}return n}!function(t){t[t.EDITING=0]="EDITING",t[t.ROLLED_BACK=1]="ROLLED_BACK",t[t.COMMITTED=2]="COMMITTED"}(o||(o={}));const I=Map,g=Map;export{r as createInteractiveEditSession,l as processAttributeEdits,s as processGeometryEdits};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{NestedMap as e}from"../../../../core/NestedMap.js";import{RenderState as i}from"../../../support/RenderState.js";var o;function t(t=!has("disable-feature:high-quality-idle")){const s=new e;return t?(s.set(i.IDLE,o.Antialiasing,!0),s.set(i.IDLE,o.HighQualityTransparency,!0),s.set(i.IDLE,o.HighResolutionAtmosphere,!0),s.set(i.IDLE,o.SSAO,!0),s.set(i.IDLE,o.WaterReflection,!0),s.set(i.IDLE,o.PhysicalPixelRendering,!has("esri-mobile"))):(s.set(i.ANIMATING,o.HighResolutionShadows,!0),s.set(i.INTERACTING,o.HighResolutionShadows,!0)),s.set(i.IDLE,o.HighResolutionShadows,!0),s.set(i.IDLE,o.HighResolutionVoxel,!0),s}!function(e){e[e.Antialiasing=0]="Antialiasing",e[e.HighQualityTransparency=1]="HighQualityTransparency",e[e.HighResolutionVoxel=2]="HighResolutionVoxel",e[e.HighResolutionAtmosphere=3]="HighResolutionAtmosphere",e[e.SSAO=4]="SSAO",e[e.WaterReflection=5]="WaterReflection",e[e.HighResolutionShadows=6]="HighResolutionShadows",e[e.PhysicalPixelRendering=7]="PhysicalPixelRendering"}(o||(o={}));export{o as RenderFeature,t as setupFeatureDefaults};
5
+ import has from"../../../../core/has.js";import{NestedMap as e}from"../../../../core/NestedMap.js";import{RenderState as i}from"../../../support/RenderState.js";var o;function t(t=!has("disable-feature:high-quality-idle"),s=null){const n=new e;return t?(n.set(i.IDLE,o.Antialiasing,"low"!==s),n.set(i.IDLE,o.HighResolutionAtmosphere,"low"!==s),n.set(i.IDLE,o.HighQualityTransparency,!0),n.set(i.IDLE,o.SSAO,!0),n.set(i.IDLE,o.WaterReflection,!0),n.set(i.IDLE,o.PhysicalPixelRendering,!has("esri-mobile"))):(n.set(i.ANIMATING,o.HighResolutionShadows,!0),n.set(i.INTERACTING,o.HighResolutionShadows,!0)),n.set(i.IDLE,o.HighResolutionShadows,!0),n.set(i.IDLE,o.HighResolutionVoxel,!0),n}!function(e){e[e.Antialiasing=0]="Antialiasing",e[e.HighQualityTransparency=1]="HighQualityTransparency",e[e.HighResolutionVoxel=2]="HighResolutionVoxel",e[e.HighResolutionAtmosphere=3]="HighResolutionAtmosphere",e[e.SSAO=4]="SSAO",e[e.WaterReflection=5]="WaterReflection",e[e.HighResolutionShadows=6]="HighResolutionShadows",e[e.PhysicalPixelRendering=7]="PhysicalPixelRendering"}(o||(o={}));export{o as RenderFeature,t as setupFeatureDefaults};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import s from"../../../../core/Handles.js";import has from"../../../../core/has.js";import{removeMaybe as i,disposeMaybe as a,destroyMaybe as n,applySome as h}from"../../../../core/maybe.js";import o from"../../../../core/PooledArray.js";import{watch as d,syncAndInitial as l,initial as _,sync as p}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as u,a as f,m as T}from"../../../../chunks/mat4.js";import{I as g,c as R}from"../../../../chunks/mat4f64.js";import{a as A}from"../../../../chunks/boundedPlane.js";import E from"../../support/debugFlags.js";import{TransparencyMode as S}from"../../terrain/TerrainRenderer.js";import{RenderPassManager as P}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as b}from"../core/shaderLibrary/ShaderOutput.js";import{HUDTransparencyRenderStyle as y}from"../core/shaderLibrary/hud/HUDUniforms.js";import{AnimationTimeStep as I}from"./AnimationTimeStep.js";import{Decorations as O,RenderRequestType as C,StencilBits as D}from"./basicInterfaces.js";import{BoundingInfo as w}from"./BoundingInfo.js";import{ZERO as x,union as N}from"./depthRange.js";import{depthRangeFromScene as L}from"./depthRangeUtils.js";import{createEmptyDepthTexture as H}from"./glUtil3D.js";import{Highlight as M}from"./Highlight.js";import{RenderOccludedFlag as v}from"./Material.js";import{OffscreenRendering as U}from"./OffscreenRendering.js";import{RenderContext as F}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as j}from"./rendererUtils.js";import{RenderFeature as q,setupFeatureDefaults as G}from"./RenderFeature.js";import{RenderPluginManager as V}from"./RenderPluginManager.js";import{RenderSlot as B}from"./RenderSlot.js";import{ShadowAccumulator as Q}from"./ShadowAccumulator.js";import{ShadowHighlight as k}from"./ShadowHighlight.js";import{ShadowMap as W,SnapshotSlot as Y}from"./ShadowMap.js";import X from"./SliceHelper.js";import{SmaaRenderPass as z}from"./SmaaRenderPass.js";import{SSAOHelper as J}from"./SSAOHelper.js";import{TransparencyPassType as K}from"./TransparencyPassType.js";import{EdgeView as Z}from"./edgeRendering/EdgeView.js";import{Transparency as $}from"./edgeRendering/interfaces.js";import{MergedRenderer as ee}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as re}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as te,PerformanceCategory as se}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ie}from"../../../support/RenderState.js";import{ClearBufferBit as ae,PixelFormat as ne,PixelType as he}from"../../../webgl/enums.js";let oe=class extends r{get _bindParameters(){return this._renderContext.bindParameters}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _antialiasing(){return this._antialiasingEnabled||this.isFeatureEnabled(q.Antialiasing)}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(q.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(q.WaterReflection))}get hasWater(){return this._hasWater||this._hasOverlayWater}constructor(e,r,t,i,a,n,h,p){super({}),this._stage=e,this._materialRepository=r,this._techniqueRepository=i,this._rctx=a,this._compositingHelper=n,this._magnifierHelper=h,this._requestRender=p,this._materialRenderers=new o,this._needsTransparentPass=!1,this._hasHUDElements=!1,this._hasHighlights=!1,this._hasWater=!1,this._hasOverlayWater=!1,this._renderOverlay=e=>{},this._isRendering=!1,this._fallbackDepthStencilTexture=null,this._sliceHelper=new X,this._state=ie.IDLE,this._renderStateFeatures=G(),this._antialiasingEnabled=!0,this._highQualityTransparencyEnabled=!0,this._terrainRenderingEnabled=!0,this._terrainTransparency=S.Opaque,this._ssrEnabled=!1,this._ssaoEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new I,this._handles=new s,this._renderHiddenTransparentEdges=()=>{},this._oitUsed=!1,this._smaaPass=new z(this._rctx,i),p(),this._offscreen=new U(this._rctx,this._compositingHelper),this.performanceInfo=new te(this._rctx),this._shadowMap=new W(this._rctx,e.viewingMode),this._ssaoHelper=new J(e.view,i,this._rctx,p),this._highlight=new M(i,this._rctx),this._shadowHighlight=new k(this._rctx,e.viewingMode),this._shadowAccumulator=new Q(this._rctx,i,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t,!0,this._stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(b.Shadow,e.shadowMap),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),p),this._renderContext=new F(this._rctx,this._offscreen,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new V({renderContext:this._renderContext,techniqueRepository:i,textureRepository:t,materialRepository:this._materialRepository,requestRender:p,controller:e}),this.renderPassManager=new P(this._rctx,this._techniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this._handles.add([d((()=>this._stage.view.state.camera),(()=>p()),l),d((()=>E.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges($.TRANSPARENT):()=>{},p()}),_),d((()=>this._ssaoEnabled||this.isFeatureEnabled(q.SSAO)),(e=>this._ssaoHelper.enabled=e),l)])}normalizeCtorArgs(){return{}}destroy(){this._handles.destroy(),this._smaaPass.dispose(),this._gpuTimerHandle=i(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._fallbackDepthStencilTexture=a(this._fallbackDepthStencilTexture),this._shadowMap.dispose(),this._ssaoHelper.destroy(),this._highlight.dispose(),this._shadowHighlight.dispose(),this._shadowAccumulator.dispose(),this._edgeView=n(this._edgeView),this.renderPassManager.destroy(),w.prune()}disposeOffscreenBuffers(){this._offscreen.dispose(),this._shadowMap.disposeOffscreenBuffers(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing&&this._smaaPass.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._renderPlugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new Z({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:ue(e)}),this._handles.add(d((()=>h(this._edgeView,(e=>e.updating))),(()=>this._requestRender()),p)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return u(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.qualitySettings?.ambientOcclusion&&this._ssaoEnabled!==e.qualitySettings.ambientOcclusion&&(this._ssaoEnabled=e.qualitySettings.ambientOcclusion,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}e.background&&this._offscreen.background!==e.background&&(this._offscreen.background=e.background,this._requestRender()),void 0!==e.antialiasingEnabled&&this._antialiasingEnabled!==e.antialiasingEnabled&&(this._antialiasingEnabled=e.antialiasingEnabled,this._requestRender()),void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlight.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlight.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.overlays&&this._bindParameters.overlays!==e.overlays&&(this._bindParameters.overlays=e.overlays,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.renderOverlay&&this._renderOverlay!==e.renderOverlay&&(this._renderOverlay=e.renderOverlay,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainRenderingEnabled&&this._terrainRenderingEnabled!==e.terrainRenderingEnabled&&(this._terrainRenderingEnabled=e.terrainRenderingEnabled,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=j(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));null==i&&t.adds.length>0&&(i=new ee(this._rctx,this._materialRepository,s),this._materialRenderers.push(i)),i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._hasHighlights=this._materialRenderers.some((e=>e.hasHighlights)),this._bindParameters.hasOccludees=this._materialRenderers.some((e=>e.hasOccludees)),this._hasWater=this._materialRenderers.some((e=>e.hasWater)),this._hasHUDElements=this._materialRenderers.some((e=>e.requiresSlot(B.LINE_CALLOUTS_HUD_DEPTH,b.Color)||e.requiresSlot(B.HUD_MATERIAL,b.Color)||e.requiresSlot(B.LABEL_MATERIAL,b.Color))),this._requestRender()}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}render(e,r,t,s,i){this._isRendering=!0,this._oitUsed=!1,this.performanceInfo.startFrame();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=t;this._state=h,this._renderOverlay(i),this.performanceInfo.advance(se.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=K.NONE,this._bindParameters.alignPixelEnabled=o;const d=this._offscreen;d.setupRenderTarget(this.hasReflections);const l=A(this._sliceHelper.plane);s===O.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),a.setGLViewport(this._rctx),this._prepare(a,n),this._renderPlugins.prepareRender(),this.performanceInfo.advance(se.PREPARE);const _=this._computeDepthRange(a);this._renderShadowMap(e,a,this._bindParameters.lighting.mainLight.direction,_),this.performanceInfo.advance(se.SHADOW_MAP),d.initializeFrame(a),this._ensureBindParameters(a,n);const p=this._terrainRenderingEnabled&&(this._terrainTransparency===S.Semitransparent||this._terrainTransparency===S.TransparentWithDraped),c=this._highQualityTransparency&&p,m=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;this._prepareShaders(c,m),this._renderLinearDepth(),this.performanceInfo.advance(se.LINEAR_DEPTH),this._accumulateShadows(_,a,n),this.performanceInfo.advance(se.ACCUMULATED_SHADOWS),this._renderNormal(),this.performanceInfo.advance(se.NORMALS),this._ensureBindParametersSSR(i),this._renderSSAO(i),this.performanceInfo.advance(se.SSAO),this._renderContext.output=b.Color,d.bindFramebuffer(),this._renderOpaqueGeometry(),this.performanceInfo.advance(se.OPAQUE),this._renderTerrainLinearDepth(c),this._setMultipassTerrain(c),this._renderEdges($.OPAQUE),this.performanceInfo.advance(se.OPAQUE_EDGES),this._offscreen.bindTarget(this._offscreen.currentColorTarget,this._offscreen.mainDepth),this._renderSlot(B.VOXEL),this.performanceInfo.advance(se.VOXEL),this._renderHiddenTransparentEdges(),m&&(this._oitEnabled?this._renderOITPass(de.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(se.TRANSPARENT),this._renderGeometryLinearDepth(c);const u=this._renderHUDVisibility(c);c||this._renderInternalSlot(B.LINE_CALLOUTS),this.performanceInfo.advance(se.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(se.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges($.TRANSPARENT,c),this.performanceInfo.advance(se.TRANSPARENT_EDGES),this._renderTransparentTerrain(),p&&u&&(c?this._renderLineCallouts(y.Occluded):d.compositeTransparentTerrainOntoHUDVisibility(this._bindParameters),this._renderHUD(y.Occluded,d.framebuffer),this.performanceInfo.advance(se.HUD_OCCLUDED)),this.performanceInfo.advance(se.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),p&&(d.compositeTransparentTerrainOntoMain(this._bindParameters),c&&(this._renderEdges($.OPAQUE),this.performanceInfo.advance(se.OPAQUE_EDGES),m&&(this._oitEnabled?this._renderOITPass(de.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(se.TRANSPARENT),this._renderEdges($.TRANSPARENT),this.performanceInfo.advance(se.TRANSPARENT_EDGES))),c&&this._renderLineCallouts(y.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),d.renderToTargets((()=>{this._renderInternalSlot(B.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(B.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(B.LASERLINES)}),d.currentColorTarget,d.mainDepth),this.performanceInfo.advance(se.ENVIRONMENT),this._renderPlugins.needsLaserlineWithContrastControl&&d.renderTmpAndCompositeToMain((()=>this._renderSlot(B.LASERLINES_CONTRAST_CONTROL)),this._bindParameters,re.PremultipliedAlpha),this.performanceInfo.advance(se.LASER_LINE),this._renderOccluded(),this.performanceInfo.advance(se.OCCLUDED);const f=s===O.ON&&this._magnifierHelper.enabled,T=f&&null==e?this._offscreen.getFramebuffer(this._offscreen.tmpColor,this._offscreen.tmpDepth):e;this._rctx.bindFramebuffer(T);const g=this._offscreen.colorTexture;this._renderAntiAliasing(g)||null==g||this._compositingHelper.composite(this._bindParameters,g,re.None),this.performanceInfo.advance(se.ANTIALIASING),this._renderHUD(y.NotOccluded,T),this.performanceInfo.advance(se.HUD),this._renderHighlights(T,this._bindParameters),this.performanceInfo.advance(se.HIGHLIGHTS),f&&this._magnifierHelper.render(this._rctx,this._bindParameters),T!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._bindParameters,this._offscreen.tmpColorTexture,re.None)),this._disposeOITBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=l,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.finishFrame()}_prepareShaders(e,r){this._renderContext.output=b.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._prepareSlots(B.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,B.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,B.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._prepareSlots(B.POSTPROCESSING_ENVIRONMENT_TRANSPARENT,B.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(e){if(null!=e&&has("enable-feature:objectAndLayerId-rendering")){const r=this._renderContext.output;this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>this._renderGeometryAndTransparentTerrainPass(b.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>{this._bindParameters.renderTransparentlyOccludedHUD=y.NotOccluded,this._renderInternalSlot(B.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===C.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._offscreen.bindTarget(this._offscreen.linearDepth,this._offscreen.tmpDepth);if(!this._needsLinearDepth){this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const r=ae.COLOR_BUFFER_BIT|ae.DEPTH_BUFFER_BIT|ae.STENCIL_BUFFER_BIT;this._rctx.clearSafe(r),this._renderGeometryAndTransparentTerrainPass(b.Depth)}s.readPixels(r[0],r[1],r[2],r[3],ne.RGBA,he.UNSIGNED_BYTE,t)}readHUDVisibility(e,r,t,s,i){this._offscreen.bindTarget(this._offscreen.hudVisibility).readPixels(e,r,t,s,ne.RGBA,he.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassTerrain.enabled=this._bindParameters.multipassGeometry.enabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_prepareSlots(...e){this._renderPlugins.prepareSlots(e)}_renderSlot(e){this._bindParameters.slot=e,this._renderPlugins.render()}_renderEdges(e,r=!1){const t=this._edgeView;null!=t&&t.shouldRender()&&this._offscreen.renderTmpAndCompositeToMain((()=>t.render(this._bindParameters,e)),this._bindParameters,re.Alpha,r)}_renderShadowMap(e,r,t,s){const i=this._shadowMap;i.enabled&&(i.start(r,t,s,this.isFeatureEnabled(q.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(b.ShadowHighlight,this._shadowMap,(e=>i.takeCascadeSnapshotTo(e,Y.Highlight))),i.clear(),this._renderShadowCascades(b.ShadowExcludeHighlight,this._shadowMap,(e=>{i.takeCascadeSnapshotTo(e,Y.Default),this._renderGeometryAndTransparentTerrainPass(b.ShadowHighlight)}))):this._renderShadowCascades(b.Shadow),i.finish(e),r.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap,t=(e=>{})){for(const s of r.cascades)s.camera.setGLViewport(this._rctx),this._prepare(s.camera,s.camera),this._renderGeometryAndTransparentTerrainPass(e),t(s)}get _needsLinearDepth(){return this._ssaoHelper.active||this._renderPlugins.needsLinearDepth||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?this._offscreen.renderToTargets((()=>this._renderGeometryAndTransparentTerrainPass(b.Depth)),this._offscreen.linearDepth,this._offscreen.tmpDepth,[0,0,0,0],!0,!0):this._offscreen.disposeTarget(this._offscreen.linearDepth),this._bindParameters.linearDepthTexture=this._offscreen.linearDepthTexture}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=b.Depth,this._offscreen.renderToTargets((()=>this._renderTransparentTerrain()),this._offscreen.terrainLinearDepth,this._offscreen.tmpDepth,[-1e10,-1e10,-1e10,1],!0,!0),this._renderContext.output=e}else this._offscreen.disposeTarget(this._offscreen.terrainLinearDepth);this._bindParameters.multipassTerrain.linearDepthTexture=this._offscreen.terrainLinearDepthTexture}_renderGeometryLinearDepth(e){if(e){const e=this._renderContext.output;this._offscreen.renderToTargets((()=>this._renderGeometryPass(b.Depth)),this._offscreen.geometryLinearDepth,this._offscreen.tmpDepth,[1,1,1,1],!0,!0),this._renderContext.output=e}else this._offscreen.disposeTarget(this._offscreen.geometryLinearDepth);this._bindParameters.multipassGeometry.linearDepthTexture=this._offscreen.geometryLinearDepthTexture}get _needsNormal(){return this._ssaoHelper.active}_renderNormal(){this._needsNormal?this._offscreen.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(b.Normal)}),this._offscreen.normal,this._offscreen.tmpDepth,[0,0,0,0],!0,!0):this._offscreen.disposeTarget(this._offscreen.normal)}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return x;const r=L(e,this._materialRenderers,this._stage.layers);return N(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.output=e,this._prepareSlots(B.TRANSPARENT_TERRAIN),this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._prepareSlots(B.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderSSAO(e){this._ssaoHelper.render(this._bindParameters,e,this._offscreen.linearDepthTexture,this._offscreen.normalTexture)}_prepareOpaqueGeometrySlots(){this._prepareSlots(B.INTEGRATED_MESH,B.OPAQUE_TERRAIN,B.OPAQUE_MATERIAL,B.POSTPROCESSING_ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,B.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderSlot(B.INTEGRATED_MESH),this._renderSlot(B.OPAQUE_TERRAIN),this._renderInternalSlot(B.OPAQUE_MATERIAL),this._renderSlot(B.OPAQUE_MATERIAL),this._renderSlot(B.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(B.TRANSPARENT_MATERIAL),this._renderSlot(B.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){this._renderSlot(B.TRANSPARENT_TERRAIN)}_renderHUDVisibility(e){let r=!1;return this._renderContext.offscreenRenderingHelper&&this._renderContext.offscreenRenderingHelper.renderHUDVisibility((()=>{this._bindParameters.hudVisibilityTexture=this._renderContext.offscreenRenderingHelper.hudVisibilityTexture,r=this._renderInternalSlot(B.OCCLUSION_PIXELS)}),e),r}_renderLineCallouts(e){this._bindParameters.renderTransparentlyOccludedHUD=e,e===y.Occluded?this._offscreen.renderToTargets((()=>this._renderInternalSlot(B.LINE_CALLOUTS)),this._offscreen.currentColorTarget,this._offscreen.tmpDepth,void 0,!0,!0):this._renderInternalSlot(B.LINE_CALLOUTS)}_renderHUD(e,r){this._hasHUDElements&&(this._oitEnabled?(this._renderOITPass(de.HUD,e),this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._bindParameters,this._offscreen.hudColorTexture,re.PremultipliedAlpha)):e===y.Occluded?this._offscreen.renderToTargets((()=>this._renderHUDElements(y.Occluded)),this._offscreen.currentColorTarget,this._offscreen.tmpDepth,void 0,!0,!0):this._renderHUDElements(e))}_renderHUDElements(e){this._bindParameters.renderTransparentlyOccludedHUD=e,this._prepareInternalSlots(this._materialRenderers,B.LINE_CALLOUTS_HUD_DEPTH,B.HUD_MATERIAL,B.LABEL_MATERIAL),this._renderInternalSlot(B.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(B.HUD_MATERIAL),this._renderInternalSlot(B.LABEL_MATERIAL)}get _needsHighlight(){return this._hasHighlights||this._renderPlugins.needsHighlight}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this._needsHighlight}_renderHighlights(e,r){if(!this._needsHighlight)return void this._offscreen.disposeTarget(this._offscreen.highlight);const t=this._highlight,s=this._offscreen.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(b.Highlight),this._rctx.clearSafe(ae.DEPTH_BUFFER_BIT),this._renderHUDElements(y.Both)}),this._offscreen.highlight,this._offscreen.tmpDepth,[0,0,0,0],!0,!0);this._bindParameters.highlightColorTexture=s.colorTexture,this._needsShadowHighlight&&this._shadowHighlight.render(r,e),t.render(this._bindParameters,s,e)}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this._needsShadowCast&&null!=this._offscreen.linearDepthTexture&&this._shadowAccumulator.renderAccumulation(this._offscreen.linearDepthTexture,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=b.Alpha,this._bindParameters.transparencyPassType=K.Alpha,this._prepareInternalSlots(this._materialRenderers,B.TRANSPARENT_MATERIAL),this._prepareSlots(B.TRANSPARENT_MATERIAL),this._renderContext.output=b.Color,this._bindParameters.transparencyPassType=K.Color,this._prepareInternalSlots(this._materialRenderers,B.TRANSPARENT_MATERIAL),this._prepareSlots(B.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=K.FrontFace,this._prepareInternalSlots(this._materialRenderers,B.TRANSPARENT_MATERIAL),this._prepareSlots(B.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=K.NONE}_renderOITPass(e,r=y.Both){const t=e===de.HUD,s=t?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),i=e=>{this._bindParameters.transparencyPassType=e,this._offscreen.renderOITPass(s,e,t)},a=this._renderContext.output;this._renderContext.output=b.Alpha,i(K.Alpha),this._renderContext.output=b.Color,i(K.Color),i(K.FrontFace),this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,t),this._bindParameters.transparencyPassType=K.NONE,this._renderContext.output=a,this._oitUsed=!0}_disposeOITBuffers(){this._oitUsed||(this._offscreen.disposeTarget(this._offscreen.alphaFloatTarget),this._offscreen.disposeTarget(this._offscreen.colorFloatTarget),this._offscreen.disposeTarget(this._offscreen.frontFaceTarget))}_renderOccluded(){let e=0;_e.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.renderOccluded===v.OccludeAndTransparentStencil&&(e|=r.material.renderOccluded,_e.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{0!=(e&s)&&(r.renderToTargets(i,r.tmpColor,r.mainDepth,[0,0,0,0],a,n),r.compositeOccludedOntoMain(this._bindParameters,t))};0!==_e.length&&(this._prepareInternalSlots(_e,B.OCCLUDER_MATERIAL,B.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(B.OCCLUDER_MATERIAL,_e),t(.5,v.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(B.TRANSPARENT_OCCLUDER_MATERIAL,_e)),!1,!1)),_e.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.renderOccluded===v.OccludeAndTransparent||r.material.renderOccluded===v.Transparent||r.material.renderOccluded===v.Opaque)&&(e|=r.material.renderOccluded,_e.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(_e,B.OPAQUE_MATERIAL,B.TRANSPARENT_MATERIAL,B.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>v.Occlude&&this._renderSlot(B.OCCLUDED_TERRAIN),this._renderInternalSlot(B.OPAQUE_MATERIAL,_e),this._renderInternalSlot(B.TRANSPARENT_MATERIAL,_e),this._renderInternalSlot(B.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,_e),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=b.Color,t(.5,v.OccludeAndTransparent,(()=>i(v.OccludeAndTransparent)),!0,D.OutlineVisualElementMask),t(.5,v.Transparent,(()=>i(v.Transparent)),!0,D.OutlineVisualElementMask),t(1,v.Opaque,(()=>i(v.Opaque)),!0,D.OutlineVisualElementMask),_e.clear()}_renderAntiAliasing(e){if(this._antialiasing){if(this._smaaPass.enable((()=>this._requestRender()))&&null!=e)return this._smaaPass.render(e),!0}else this._smaaPass.disable();return!1}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.requiresSlot(B.TRANSPARENT_MATERIAL,b.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibilityTexture=t.hudVisibilityTexture,this._bindParameters.mainColorTexture=t.mainColorTexture,this._bindParameters.highlightDepthTexture=t.depthTexture??this._getFallbackDepthTexture()}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.enabled=this.hasReflections,this._bindParameters.ssr.enabled){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(f(ce,this._bindParameters.camera.viewMatrix),f(pe,this._bindParameters.camera.projectionMatrix),T(me,ce,pe),T(me,this._renderContext.lastFrameCamera.viewMatrix,me),T(me,this._renderContext.lastFrameCamera.projectionMatrix,me),this._reprojectionMatrix=me),this._bindParameters.ssr.lastFrameColorTexture=this._offscreen.lastFrameColorTexture;const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._bindParameters.ssr.lastFrameColorTexture=null,this._ssrEnableTime=null}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>{e.material.shouldRender(this._renderContext)&&e.prepareTechnique(this._renderContext)}))}_renderInternalSlot(e,r=this._materialRenderers){let t=!1;return this._bindParameters.slot=e,r.forAll((e=>{if(e.material.shouldRender(this._renderContext)){const r=e.prepareTechnique(this._renderContext);null!=r&&(e.render(this._renderContext,r),t=!0)}})),t}_getFallbackDepthTexture(){return this._fallbackDepthStencilTexture||(this._fallbackDepthStencilTexture=H(this._rctx)),this._fallbackDepthStencilTexture}get gpuMemoryUsage(){return{offscreen:this._offscreen?.gpuMemoryUsage??0,highlights:(this._highlight?.gpuMemoryUsage??0)+(this._shadowHighlight?.gpuMemoryUsage??0),shadows:this._shadowMap?.gpuMemoryUsage??0,ssao:this._ssaoHelper?.gpuMemoryUsage??0}}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=G()},getFramebufferTexture:r=>{switch(r){case le.Color:return e._offscreen.colorTexture;case le.LinearDepth:return e._offscreen.linearDepthTexture;case le.Normals:return e._offscreen.normalTexture;case le.ShadowMap:return e._shadowMap.depthTexture;case le.HudVisibility:return e._offscreen.hudVisibilityTexture;case le.Highlight:return e._offscreen.highlightTexture}}}}};var de,le;e([c()],oe.prototype,"_renderPlugins",void 0),e([c()],oe.prototype,"_shadowAccumulator",void 0),e([c()],oe.prototype,"_state",void 0),e([c()],oe.prototype,"_renderStateFeatures",void 0),e([c()],oe.prototype,"_antialiasingEnabled",void 0),e([c({readOnly:!0})],oe.prototype,"_antialiasing",null),e([c()],oe.prototype,"_ssaoEnabled",void 0),e([c()],oe.prototype,"_smaaPass",void 0),e([c({autoDestroy:!0})],oe.prototype,"_edgeView",void 0),e([c()],oe.prototype,"updating",null),e([c()],oe.prototype,"isCameraFinal",null),oe=e([m("esri.views.3d.webgl-engine.lib.Renderer")],oe),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(de||(de={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.Normals=2]="Normals",e[e.ShadowMap=3]="ShadowMap",e[e.HudVisibility=4]="HudVisibility",e[e.Highlight=5]="Highlight"}(le||(le={}));const _e=new o,pe=R(),ce=R(),me=R();function ue(e){return r=>e.immediate.schedule(r)}export{le as FramebufferId,oe as Renderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import s from"../../../../core/Handles.js";import has from"../../../../core/has.js";import{removeMaybe as i,disposeMaybe as a,destroyMaybe as n,applySome as h}from"../../../../core/maybe.js";import o from"../../../../core/PooledArray.js";import{watch as d,syncAndInitial as l,initial as _,sync as p}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as u,a as f,m as T}from"../../../../chunks/mat4.js";import{I as g,c as R}from"../../../../chunks/mat4f64.js";import{a as A}from"../../../../chunks/boundedPlane.js";import E from"../../support/debugFlags.js";import{TransparencyMode as S}from"../../terrain/TerrainRenderer.js";import{RenderPassManager as P}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as b}from"../core/shaderLibrary/ShaderOutput.js";import{HUDTransparencyRenderStyle as y}from"../core/shaderLibrary/hud/HUDUniforms.js";import{AnimationTimeStep as I}from"./AnimationTimeStep.js";import{Decorations as O,RenderRequestType as C,StencilBits as D}from"./basicInterfaces.js";import{BoundingInfo as w}from"./BoundingInfo.js";import{ZERO as x,union as N}from"./depthRange.js";import{depthRangeFromScene as L}from"./depthRangeUtils.js";import{createEmptyDepthTexture as H}from"./glUtil3D.js";import{Highlight as M}from"./Highlight.js";import{RenderOccludedFlag as v}from"./Material.js";import{OffscreenRendering as U}from"./OffscreenRendering.js";import{RenderContext as F}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as j}from"./rendererUtils.js";import{setupFeatureDefaults as q,RenderFeature as G}from"./RenderFeature.js";import{RenderPluginManager as V}from"./RenderPluginManager.js";import{RenderSlot as B}from"./RenderSlot.js";import{ShadowAccumulator as Q}from"./ShadowAccumulator.js";import{ShadowHighlight as k}from"./ShadowHighlight.js";import{ShadowMap as W,SnapshotSlot as Y}from"./ShadowMap.js";import X from"./SliceHelper.js";import{SmaaRenderPass as z}from"./SmaaRenderPass.js";import{SSAOHelper as J}from"./SSAOHelper.js";import{TransparencyPassType as K}from"./TransparencyPassType.js";import{EdgeView as Z}from"./edgeRendering/EdgeView.js";import{Transparency as $}from"./edgeRendering/interfaces.js";import{MergedRenderer as ee}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as re}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as te,PerformanceCategory as se}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ie}from"../../../support/RenderState.js";import{ClearBufferBit as ae,PixelFormat as ne,PixelType as he}from"../../../webgl/enums.js";let oe=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeature(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=q(r,e),this.notifyChange("_renderStateFeatures"),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures?.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures?.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _antialiasing(){return this._antialiasingEnabled||this.isFeatureEnabled(G.Antialiasing)}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(G.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(G.WaterReflection))}get hasWater(){return this._hasWater||this._hasOverlayWater}constructor(e,r,t,i,a,n,h,p){super({}),this._stage=e,this._materialRepository=r,this._techniqueRepository=i,this._rctx=a,this._compositingHelper=n,this._magnifierHelper=h,this._requestRender=p,this._materialRenderers=new o,this._needsTransparentPass=!1,this._hasHUDElements=!1,this._hasHighlights=!1,this._hasWater=!1,this._hasOverlayWater=!1,this._renderOverlay=e=>{},this._isRendering=!1,this._fallbackDepthStencilTexture=null,this._sliceHelper=new X,this._state=ie.IDLE,this._renderStateFeatures=null,this._antialiasingEnabled=!0,this._highQualityTransparencyEnabled=!0,this._terrainRenderingEnabled=!0,this._terrainTransparency=S.Opaque,this._ssrEnabled=!1,this._ssaoEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new I,this._handles=new s,this._renderHiddenTransparentEdges=()=>{},this._oitUsed=!1,this.updateRenderFeature(e.view.qualityProfile),this._smaaPass=new z(this._rctx,i),p(),this._offscreen=new U(this._rctx,this._compositingHelper),this.performanceInfo=new te(this._rctx),this._shadowMap=new W(this._rctx,e.viewingMode),this._ssaoHelper=new J(e.view,i,this._rctx,p),this._highlight=new M(i,this._rctx),this._shadowHighlight=new k(this._rctx,e.viewingMode),this._shadowAccumulator=new Q(this._rctx,i,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t,!0,this._stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(b.Shadow,e.shadowMap),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),p),this._renderContext=new F(this._rctx,this._offscreen,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new V({renderContext:this._renderContext,techniqueRepository:i,textureRepository:t,materialRepository:this._materialRepository,requestRender:p,controller:e}),this.renderPassManager=new P(this._rctx,this._techniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this._handles.add([d((()=>this._stage.view.state.camera),(()=>p()),l),d((()=>E.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges($.TRANSPARENT):()=>{},p()}),_),d((()=>this._ssaoEnabled||this.isFeatureEnabled(G.SSAO)),(e=>this._ssaoHelper.enabled=e),l)])}normalizeCtorArgs(){return{}}destroy(){this._handles.destroy(),this._smaaPass.dispose(),this._gpuTimerHandle=i(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._fallbackDepthStencilTexture=a(this._fallbackDepthStencilTexture),this._shadowMap.dispose(),this._ssaoHelper.destroy(),this._highlight.dispose(),this._shadowHighlight.dispose(),this._shadowAccumulator.dispose(),this._edgeView=n(this._edgeView),this.renderPassManager.destroy(),w.prune()}disposeOffscreenBuffers(){this._offscreen.dispose(),this._shadowMap.disposeOffscreenBuffers(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing&&this._smaaPass.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._renderPlugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new Z({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:ue(e)}),this._handles.add(d((()=>h(this._edgeView,(e=>e.updating))),(()=>this._requestRender()),p)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return u(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.qualitySettings?.ambientOcclusion&&this._ssaoEnabled!==e.qualitySettings.ambientOcclusion&&(this._ssaoEnabled=e.qualitySettings.ambientOcclusion,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}e.background&&this._offscreen.background!==e.background&&(this._offscreen.background=e.background,this._requestRender()),void 0!==e.antialiasingEnabled&&this._antialiasingEnabled!==e.antialiasingEnabled&&(this._antialiasingEnabled=e.antialiasingEnabled,this._requestRender()),void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlight.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlight.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.overlays&&this._bindParameters.overlays!==e.overlays&&(this._bindParameters.overlays=e.overlays,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.renderOverlay&&this._renderOverlay!==e.renderOverlay&&(this._renderOverlay=e.renderOverlay,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainRenderingEnabled&&this._terrainRenderingEnabled!==e.terrainRenderingEnabled&&(this._terrainRenderingEnabled=e.terrainRenderingEnabled,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=j(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));null==i&&t.adds.length>0&&(i=new ee(this._rctx,this._materialRepository,s),this._materialRenderers.push(i)),i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._hasHighlights=this._materialRenderers.some((e=>e.hasHighlights)),this._bindParameters.hasOccludees=this._materialRenderers.some((e=>e.hasOccludees)),this._hasWater=this._materialRenderers.some((e=>e.hasWater)),this._hasHUDElements=this._materialRenderers.some((e=>e.requiresSlot(B.LINE_CALLOUTS_HUD_DEPTH,b.Color)||e.requiresSlot(B.HUD_MATERIAL,b.Color)||e.requiresSlot(B.LABEL_MATERIAL,b.Color))),this._requestRender()}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}render(e,r,t,s,i){this._isRendering=!0,this._oitUsed=!1,this.performanceInfo.startFrame();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=t;this._state=h,this._renderOverlay(i),this.performanceInfo.advance(se.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=K.NONE,this._bindParameters.alignPixelEnabled=o;const d=this._offscreen;d.setupRenderTarget(this.hasReflections);const l=A(this._sliceHelper.plane);s===O.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),a.setGLViewport(this._rctx),this._prepare(a,n),this._renderPlugins.prepareRender(),this.performanceInfo.advance(se.PREPARE);const _=this._computeDepthRange(a);this._renderShadowMap(e,a,this._bindParameters.lighting.mainLight.direction,_),this.performanceInfo.advance(se.SHADOW_MAP),d.initializeFrame(a),this._ensureBindParameters(a,n);const p=this._terrainRenderingEnabled&&(this._terrainTransparency===S.Semitransparent||this._terrainTransparency===S.TransparentWithDraped),c=this._highQualityTransparency&&p,m=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;this._prepareShaders(c,m),this._renderLinearDepth(),this.performanceInfo.advance(se.LINEAR_DEPTH),this._accumulateShadows(_,a,n),this.performanceInfo.advance(se.ACCUMULATED_SHADOWS),this._renderNormal(),this.performanceInfo.advance(se.NORMALS),this._ensureBindParametersSSR(i),this._renderSSAO(i),this.performanceInfo.advance(se.SSAO),this._renderContext.output=b.Color,d.bindFramebuffer(),this._renderOpaqueGeometry(),this.performanceInfo.advance(se.OPAQUE),this._renderTerrainLinearDepth(c),this._setMultipassTerrain(c),this._renderEdges($.OPAQUE),this.performanceInfo.advance(se.OPAQUE_EDGES),this._offscreen.bindTarget(this._offscreen.currentColorTarget,this._offscreen.mainDepth),this._renderSlot(B.VOXEL),this.performanceInfo.advance(se.VOXEL),this._renderHiddenTransparentEdges(),m&&(this._oitEnabled?this._renderOITPass(de.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(se.TRANSPARENT),this._renderGeometryLinearDepth(c);const u=this._renderHUDVisibility(c);c||this._renderInternalSlot(B.LINE_CALLOUTS),this.performanceInfo.advance(se.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(se.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges($.TRANSPARENT,c),this.performanceInfo.advance(se.TRANSPARENT_EDGES),this._renderTransparentTerrain(),p&&u&&(c?this._renderLineCallouts(y.Occluded):d.compositeTransparentTerrainOntoHUDVisibility(this._bindParameters),this._renderHUD(y.Occluded,d.framebuffer),this.performanceInfo.advance(se.HUD_OCCLUDED)),this.performanceInfo.advance(se.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),p&&(d.compositeTransparentTerrainOntoMain(this._bindParameters),c&&(this._renderEdges($.OPAQUE),this.performanceInfo.advance(se.OPAQUE_EDGES),m&&(this._oitEnabled?this._renderOITPass(de.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(se.TRANSPARENT),this._renderEdges($.TRANSPARENT),this.performanceInfo.advance(se.TRANSPARENT_EDGES))),c&&this._renderLineCallouts(y.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),d.renderToTargets((()=>{this._renderInternalSlot(B.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(B.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(B.LASERLINES)}),d.currentColorTarget,d.mainDepth),this.performanceInfo.advance(se.ENVIRONMENT),this._renderPlugins.needsLaserlineWithContrastControl&&d.renderTmpAndCompositeToMain((()=>this._renderSlot(B.LASERLINES_CONTRAST_CONTROL)),this._bindParameters,re.PremultipliedAlpha),this.performanceInfo.advance(se.LASER_LINE),this._renderOccluded(),this.performanceInfo.advance(se.OCCLUDED);const f=s===O.ON&&this._magnifierHelper.enabled,T=f&&null==e?this._offscreen.getFramebuffer(this._offscreen.tmpColor,this._offscreen.tmpDepth):e;this._rctx.bindFramebuffer(T);const g=this._offscreen.colorTexture;this._renderAntiAliasing(g)||null==g||this._compositingHelper.composite(this._bindParameters,g,re.None),this.performanceInfo.advance(se.ANTIALIASING),this._renderHUD(y.NotOccluded,T),this.performanceInfo.advance(se.HUD),this._renderHighlights(T,this._bindParameters),this.performanceInfo.advance(se.HIGHLIGHTS),f&&this._magnifierHelper.render(this._rctx,this._bindParameters),T!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._bindParameters,this._offscreen.tmpColorTexture,re.None)),this._disposeOITBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=l,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.finishFrame()}_prepareShaders(e,r){this._renderContext.output=b.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._prepareSlots(B.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,B.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,B.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._prepareSlots(B.POSTPROCESSING_ENVIRONMENT_TRANSPARENT,B.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(e){if(null!=e&&has("enable-feature:objectAndLayerId-rendering")){const r=this._renderContext.output;this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>this._renderGeometryAndTransparentTerrainPass(b.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>{this._bindParameters.renderTransparentlyOccludedHUD=y.NotOccluded,this._renderInternalSlot(B.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===C.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._offscreen.bindTarget(this._offscreen.linearDepth,this._offscreen.tmpDepth);if(!this._needsLinearDepth){this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const r=ae.COLOR_BUFFER_BIT|ae.DEPTH_BUFFER_BIT|ae.STENCIL_BUFFER_BIT;this._rctx.clearSafe(r),this._renderGeometryAndTransparentTerrainPass(b.Depth)}s.readPixels(r[0],r[1],r[2],r[3],ne.RGBA,he.UNSIGNED_BYTE,t)}readHUDVisibility(e,r,t,s,i){this._offscreen.bindTarget(this._offscreen.hudVisibility).readPixels(e,r,t,s,ne.RGBA,he.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassTerrain.enabled=this._bindParameters.multipassGeometry.enabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_prepareSlots(...e){this._renderPlugins.prepareSlots(e)}_renderSlot(e){this._bindParameters.slot=e,this._renderPlugins.render()}_renderEdges(e,r=!1){const t=this._edgeView;null!=t&&t.shouldRender()&&this._offscreen.renderTmpAndCompositeToMain((()=>t.render(this._bindParameters,e)),this._bindParameters,re.Alpha,r)}_renderShadowMap(e,r,t,s){const i=this._shadowMap;i.enabled&&(i.start(r,t,s,this.isFeatureEnabled(G.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(b.ShadowHighlight,this._shadowMap,(e=>i.takeCascadeSnapshotTo(e,Y.Highlight))),i.clear(),this._renderShadowCascades(b.ShadowExcludeHighlight,this._shadowMap,(e=>{i.takeCascadeSnapshotTo(e,Y.Default),this._renderGeometryAndTransparentTerrainPass(b.ShadowHighlight)}))):this._renderShadowCascades(b.Shadow),i.finish(e),r.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap,t=(e=>{})){for(const s of r.cascades)s.camera.setGLViewport(this._rctx),this._prepare(s.camera,s.camera),this._renderGeometryAndTransparentTerrainPass(e),t(s)}get _needsLinearDepth(){return this._ssaoHelper.active||this._renderPlugins.needsLinearDepth||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?this._offscreen.renderToTargets((()=>this._renderGeometryAndTransparentTerrainPass(b.Depth)),this._offscreen.linearDepth,this._offscreen.tmpDepth,[0,0,0,0],!0,!0):this._offscreen.disposeTarget(this._offscreen.linearDepth),this._bindParameters.linearDepthTexture=this._offscreen.linearDepthTexture}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=b.Depth,this._offscreen.renderToTargets((()=>this._renderTransparentTerrain()),this._offscreen.terrainLinearDepth,this._offscreen.tmpDepth,[-1e10,-1e10,-1e10,1],!0,!0),this._renderContext.output=e}else this._offscreen.disposeTarget(this._offscreen.terrainLinearDepth);this._bindParameters.multipassTerrain.linearDepthTexture=this._offscreen.terrainLinearDepthTexture}_renderGeometryLinearDepth(e){if(e){const e=this._renderContext.output;this._offscreen.renderToTargets((()=>this._renderGeometryPass(b.Depth)),this._offscreen.geometryLinearDepth,this._offscreen.tmpDepth,[1,1,1,1],!0,!0),this._renderContext.output=e}else this._offscreen.disposeTarget(this._offscreen.geometryLinearDepth);this._bindParameters.multipassGeometry.linearDepthTexture=this._offscreen.geometryLinearDepthTexture}get _needsNormal(){return this._ssaoHelper.active}_renderNormal(){this._needsNormal?this._offscreen.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(b.Normal)}),this._offscreen.normal,this._offscreen.tmpDepth,[0,0,0,0],!0,!0):this._offscreen.disposeTarget(this._offscreen.normal)}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return x;const r=L(e,this._materialRenderers,this._stage.layers);return N(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.output=e,this._prepareSlots(B.TRANSPARENT_TERRAIN),this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._prepareSlots(B.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderSSAO(e){this._ssaoHelper.render(this._bindParameters,e,this._offscreen.linearDepthTexture,this._offscreen.normalTexture)}_prepareOpaqueGeometrySlots(){this._prepareSlots(B.INTEGRATED_MESH,B.OPAQUE_TERRAIN,B.OPAQUE_MATERIAL,B.POSTPROCESSING_ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,B.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderSlot(B.INTEGRATED_MESH),this._renderSlot(B.OPAQUE_TERRAIN),this._renderInternalSlot(B.OPAQUE_MATERIAL),this._renderSlot(B.OPAQUE_MATERIAL),this._renderSlot(B.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(B.TRANSPARENT_MATERIAL),this._renderSlot(B.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){this._renderSlot(B.TRANSPARENT_TERRAIN)}_renderHUDVisibility(e){let r=!1;return this._renderContext.offscreenRenderingHelper&&this._renderContext.offscreenRenderingHelper.renderHUDVisibility((()=>{this._bindParameters.hudVisibilityTexture=this._renderContext.offscreenRenderingHelper.hudVisibilityTexture,r=this._renderInternalSlot(B.OCCLUSION_PIXELS)}),e),r}_renderLineCallouts(e){this._bindParameters.renderTransparentlyOccludedHUD=e,e===y.Occluded?this._offscreen.renderToTargets((()=>this._renderInternalSlot(B.LINE_CALLOUTS)),this._offscreen.currentColorTarget,this._offscreen.tmpDepth,void 0,!0,!0):this._renderInternalSlot(B.LINE_CALLOUTS)}_renderHUD(e,r){this._hasHUDElements&&(this._oitEnabled?(this._renderOITPass(de.HUD,e),this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._bindParameters,this._offscreen.hudColorTexture,re.PremultipliedAlpha)):e===y.Occluded?this._offscreen.renderToTargets((()=>this._renderHUDElements(y.Occluded)),this._offscreen.currentColorTarget,this._offscreen.tmpDepth,void 0,!0,!0):this._renderHUDElements(e))}_renderHUDElements(e){this._bindParameters.renderTransparentlyOccludedHUD=e,this._prepareInternalSlots(this._materialRenderers,B.LINE_CALLOUTS_HUD_DEPTH,B.HUD_MATERIAL,B.LABEL_MATERIAL),this._renderInternalSlot(B.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(B.HUD_MATERIAL),this._renderInternalSlot(B.LABEL_MATERIAL)}get _needsHighlight(){return this._hasHighlights||this._renderPlugins.needsHighlight}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this._needsHighlight}_renderHighlights(e,r){if(!this._needsHighlight)return void this._offscreen.disposeTarget(this._offscreen.highlight);const t=this._highlight,s=this._offscreen.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(b.Highlight),this._rctx.clearSafe(ae.DEPTH_BUFFER_BIT),this._renderHUDElements(y.Both)}),this._offscreen.highlight,this._offscreen.tmpDepth,[0,0,0,0],!0,!0);this._bindParameters.highlightColorTexture=s.colorTexture,this._needsShadowHighlight&&this._shadowHighlight.render(r,e),t.render(this._bindParameters,s,e)}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this._needsShadowCast&&null!=this._offscreen.linearDepthTexture&&this._shadowAccumulator.renderAccumulation(this._offscreen.linearDepthTexture,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=b.Alpha,this._bindParameters.transparencyPassType=K.Alpha,this._prepareInternalSlots(this._materialRenderers,B.TRANSPARENT_MATERIAL),this._prepareSlots(B.TRANSPARENT_MATERIAL),this._renderContext.output=b.Color,this._bindParameters.transparencyPassType=K.Color,this._prepareInternalSlots(this._materialRenderers,B.TRANSPARENT_MATERIAL),this._prepareSlots(B.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=K.FrontFace,this._prepareInternalSlots(this._materialRenderers,B.TRANSPARENT_MATERIAL),this._prepareSlots(B.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=K.NONE}_renderOITPass(e,r=y.Both){const t=e===de.HUD,s=t?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),i=e=>{this._bindParameters.transparencyPassType=e,this._offscreen.renderOITPass(s,e,t)},a=this._renderContext.output;this._renderContext.output=b.Alpha,i(K.Alpha),this._renderContext.output=b.Color,i(K.Color),i(K.FrontFace),this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,t),this._bindParameters.transparencyPassType=K.NONE,this._renderContext.output=a,this._oitUsed=!0}_disposeOITBuffers(){this._oitUsed||(this._offscreen.disposeTarget(this._offscreen.alphaFloatTarget),this._offscreen.disposeTarget(this._offscreen.colorFloatTarget),this._offscreen.disposeTarget(this._offscreen.frontFaceTarget))}_renderOccluded(){let e=0;_e.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.renderOccluded===v.OccludeAndTransparentStencil&&(e|=r.material.renderOccluded,_e.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{0!=(e&s)&&(r.renderToTargets(i,r.tmpColor,r.mainDepth,[0,0,0,0],a,n),r.compositeOccludedOntoMain(this._bindParameters,t))};0!==_e.length&&(this._prepareInternalSlots(_e,B.OCCLUDER_MATERIAL,B.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(B.OCCLUDER_MATERIAL,_e),t(.5,v.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(B.TRANSPARENT_OCCLUDER_MATERIAL,_e)),!1,!1)),_e.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.renderOccluded===v.OccludeAndTransparent||r.material.renderOccluded===v.Transparent||r.material.renderOccluded===v.Opaque)&&(e|=r.material.renderOccluded,_e.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(_e,B.OPAQUE_MATERIAL,B.TRANSPARENT_MATERIAL,B.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>v.Occlude&&this._renderSlot(B.OCCLUDED_TERRAIN),this._renderInternalSlot(B.OPAQUE_MATERIAL,_e),this._renderInternalSlot(B.TRANSPARENT_MATERIAL,_e),this._renderInternalSlot(B.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,_e),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=b.Color,t(.5,v.OccludeAndTransparent,(()=>i(v.OccludeAndTransparent)),!0,D.OutlineVisualElementMask),t(.5,v.Transparent,(()=>i(v.Transparent)),!0,D.OutlineVisualElementMask),t(1,v.Opaque,(()=>i(v.Opaque)),!0,D.OutlineVisualElementMask),_e.clear()}_renderAntiAliasing(e){if(this._antialiasing){if(this._smaaPass.enable((()=>this._requestRender()))&&null!=e)return this._smaaPass.render(e),!0}else this._smaaPass.disable();return!1}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.requiresSlot(B.TRANSPARENT_MATERIAL,b.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibilityTexture=t.hudVisibilityTexture,this._bindParameters.mainColorTexture=t.mainColorTexture,this._bindParameters.highlightDepthTexture=t.depthTexture??this._getFallbackDepthTexture()}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.enabled=this.hasReflections,this._bindParameters.ssr.enabled){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(f(ce,this._bindParameters.camera.viewMatrix),f(pe,this._bindParameters.camera.projectionMatrix),T(me,ce,pe),T(me,this._renderContext.lastFrameCamera.viewMatrix,me),T(me,this._renderContext.lastFrameCamera.projectionMatrix,me),this._reprojectionMatrix=me),this._bindParameters.ssr.lastFrameColorTexture=this._offscreen.lastFrameColorTexture;const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._bindParameters.ssr.lastFrameColorTexture=null,this._ssrEnableTime=null}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>{e.material.shouldRender(this._renderContext)&&e.prepareTechnique(this._renderContext)}))}_renderInternalSlot(e,r=this._materialRenderers){let t=!1;return this._bindParameters.slot=e,r.forAll((e=>{if(e.material.shouldRender(this._renderContext)){const r=e.prepareTechnique(this._renderContext);null!=r&&(e.render(this._renderContext,r),t=!0)}})),t}_getFallbackDepthTexture(){return this._fallbackDepthStencilTexture||(this._fallbackDepthStencilTexture=H(this._rctx)),this._fallbackDepthStencilTexture}get gpuMemoryUsage(){return{offscreen:this._offscreen?.gpuMemoryUsage??0,highlights:(this._highlight?.gpuMemoryUsage??0)+(this._shadowHighlight?.gpuMemoryUsage??0),shadows:this._shadowMap?.gpuMemoryUsage??0,ssao:this._ssaoHelper?.gpuMemoryUsage??0}}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=q()},getFramebufferTexture:r=>{switch(r){case le.Color:return e._offscreen.colorTexture;case le.LinearDepth:return e._offscreen.linearDepthTexture;case le.Normals:return e._offscreen.normalTexture;case le.ShadowMap:return e._shadowMap.depthTexture;case le.HudVisibility:return e._offscreen.hudVisibilityTexture;case le.Highlight:return e._offscreen.highlightTexture}}}}};var de,le;e([c()],oe.prototype,"_renderPlugins",void 0),e([c()],oe.prototype,"_shadowAccumulator",void 0),e([c()],oe.prototype,"_state",void 0),e([c()],oe.prototype,"_renderStateFeatures",void 0),e([c()],oe.prototype,"_antialiasingEnabled",void 0),e([c({readOnly:!0})],oe.prototype,"_antialiasing",null),e([c()],oe.prototype,"_ssaoEnabled",void 0),e([c()],oe.prototype,"_smaaPass",void 0),e([c({autoDestroy:!0})],oe.prototype,"_edgeView",void 0),e([c()],oe.prototype,"updating",null),e([c()],oe.prototype,"isCameraFinal",null),oe=e([m("esri.views.3d.webgl-engine.lib.Renderer")],oe),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(de||(de={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.Normals=2]="Normals",e[e.ShadowMap=3]="ShadowMap",e[e.HudVisibility=4]="HudVisibility",e[e.Highlight=5]="Highlight"}(le||(le={}));const _e=new o,pe=R(),ce=R(),me=R();function ue(e){return r=>e.immediate.schedule(r)}export{le as FramebufferId,oe 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{RenderingContext as e}from"../../../webgl/RenderingContext.js";class t extends e{constructor(e,t,r){super(e,t),this.newCache=r,this._refCount=1}destroy(){--this._refCount>0||this.dispose()}ref(){++this._refCount}bindTechnique(e,t,r,s){return this.useProgram(e.program),e.bindPipelineState(this,r?.slot,!!s),e.program.bindPass(t,r),e.program}get test(){return this.programCache.test}}export{t as RenderingContext};
5
+ import{AppleAmdDriverHelper as e}from"../../../webgl/AppleAmdDriverHelper.js";import{RenderingContext as r}from"../../../webgl/RenderingContext.js";class s extends r{constructor(e,r,s){super(e,r),this.newCache=s,this._refCount=1,this._appleAmdDriverHelper=null}destroy(){--this._refCount>0||this.dispose()}ref(){++this._refCount}dispose(){super.dispose(),this._appleAmdDriverHelper?.dispose()}bindTechnique(e,r,s,t){return this.useProgram(e.program),e.bindPipelineState(this,s?.slot,!!t),e.program.bindPass(r,s),e.program}get appleAmdDriverHelper(){return this.driverTest.drawArraysRequiresIndicesTypeReset.result?(this._appleAmdDriverHelper=this._appleAmdDriverHelper??new e(this),this._appleAmdDriverHelper):null}get test(){return this.programCache.test}}export{s as RenderingContext};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{isSome as r}from"../../../../../core/arrayUtils.js";import a from"../../../../../core/Handles.js";import{destroyMaybe as s}from"../../../../../core/maybe.js";import{isAborted as n,throwIfAborted as i}from"../../../../../core/promiseUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../../chunks/mat4f64.js";import{b as h,e as d,m as u}from"../../../../../chunks/vec3.js";import{c as m}from"../../../../../chunks/vec3f64.js";import{c as p,f as _}from"../../../../../chunks/vec4f64.js";import f from"../../../support/debugFlags.js";import{glLayout as g}from"../../../support/buffer/glUtil.js";import{newLayout as I}from"../../../support/buffer/InterleavedLayout.js";import{ShaderOutput as y}from"../../core/shaderLibrary/ShaderOutput.js";import{Camera as C}from"../Camera.js";import{Default3D as v}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as E}from"../IntersectorInterfaces.js";import D from"../Octree.js";import{RenderSlot as R}from"../RenderSlot.js";import{assert as b}from"../Util.js";import{VertexAttribute as A}from"../VertexAttribute.js";import{InstanceData as T,StateFlags as L}from"./InstanceData.js";import{InstanceOctree as O}from"./InstanceOctree.js";import{LevelSelector as S}from"./LevelSelector.js";import{LodLevel as j}from"./LodLevel.js";import{RenderInstanceData as x}from"./RenderInstanceData.js";import{colorMixModes as N}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as U}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as M}from"../../shaders/DefaultMaterialTechnique.js";import{TaskPriority as w,noBudget as F}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as V,unbindVertexBufferLayout as H}from"../../../../webgl/Util.js";const B=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new S(t,r)};let q=class extends t{constructor(e,t){super(e),this.type=E.LOD,this.isGround=!1,this._handles=new a,this._levels=[],this._defaultRenderInstanceData=[new Array],this._highlightRenderInstanceData=[new Array],this._allRenderInstanceData=[this._defaultRenderInstanceData[0],this._highlightRenderInstanceData[0]],this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new C,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.slots=[R.OPAQUE_MATERIAL,R.TRANSPARENT_MATERIAL],this.canRender=!0,this._instanceData=new T({shaderTransformation:e.shaderTransformation},e.optionalFields),this._handles.add(t.registerTask(w.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=z(this.optionalFields),this._glInstanceBufferLayout=g(this._instanceBufferLayout,1),this._handles.add([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}destroy(){this._handles.destroy()}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get memoryUsage(){const e={cpu:0,gpu:0};return this._allRenderInstanceData.forEach((t=>t.forEach((t=>{e.cpu+=t.memoryUsage.cpu,e.gpu+=t.memoryUsage.gpu})))),e}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const a=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,s=e.triangleCount;t.push({renderedInstances:a,renderedTriangles:a*s,trianglesPerInstance:s})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,t){this._context=e;const a=e.renderContext.rctx,s=await Promise.allSettled(this.symbol.levels.map((r=>(this._defaultRenderInstanceData[0].push(new x(a,this._instanceBufferLayout)),this._highlightRenderInstanceData[0].push(new x(a,this._instanceBufferLayout)),j.create(e,r,t))))),o=s.map((e=>"fulfilled"===e.status?e.value:null)).filter(r);if(n(t)||o.length!==s.length){o.forEach((e=>e.destroy())),i(t);for(const e of s)if("rejected"===e.status)throw e.reason}this._levels=o,this._levelSelector=B(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData[0].forEach((e=>e.destroy())),this._highlightRenderInstanceData[0].forEach((e=>e.destroy()))}get needsTransparentPass(){return this._levels.some((e=>e.components.some((e=>e.material.requiresSlot(R.TRANSPARENT_MATERIAL,y.Color)))))}get needsHighlight(){return this._highlightRenderInstanceData[0].some((e=>e.size>0))}prepareRender(e){if(!f.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bindParameters.contentCamera.equals(this._camera);this._camera.copyFrom(e.bindParameters.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(F),this._needFullCycle=!1)}}prepareTechniques(e){if(!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e.output);if(!t)return null;const r=new Array;return t.forEach((t=>this.levels.forEach(((a,s)=>{a.components.forEach((a=>r.push(this._beginComponent(e,t[s],a))))})))),r}render(e,t){const r=this._getInstanceDatas(e.output);if(!r)return;let a=0;e.rctx.bindVAO(),r.forEach((r=>this.levels.forEach(((s,n)=>{s.components.forEach((s=>this._renderComponent(e,t[a++],r[n],s,n)))}))))}_getInstanceDatas(e){const t=e!==y.Highlight&&e!==y.ShadowHighlight,r=e!==y.ShadowExcludeHighlight;return t&&r?this._allRenderInstanceData:t?this._defaultRenderInstanceData:r?this._highlightRenderInstanceData:null}intersect(e,t,r,a){if(!this.baseMaterial.isVisible()||null==this._octree)return;const s=m();h(s,a,r);const n=s=>{this._instanceData.getCombinedModelTransform(s,K),e.transform.set(K),u(Y,r,e.transform.inverse),u(J,a,e.transform.inverse);const n=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;b(0!=(n&L.ACTIVE),"invalid instance state"),b(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,Y,J,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(n):this._octree.forEachAlongRay(r,s,n)}queryDepthRange(e){return this._queryDepthRangeOctree(e)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new O(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&L.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=s(this._octreeCached)}_queryDepthRangeOctree(e){if(null==this._octree)return{near:1/0,far:-1/0};const t=e.viewForward,r=this._octree.findClosest(t,D.DepthOrder.FRONT_TO_BACK,e.frustum),a=this._octree.findClosest(t,D.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==a)return{near:1/0,far:-1/0};const s=e.eye,n=this._instanceData.view;n.boundingSphere.getVec(r,W),h(W,W,s);const i=d(W,t)-W[3];n.boundingSphere.getVec(a,W),h(W,W,s);const o=d(W,t)+W[3];return{near:Math.max(e.near,i),far:Math.min(e.far,o)}}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const s=this._instanceData,n=s.view;let i=s.size;const o=s.capacity;let l=this._instanceIndex;for(let c=0;c<i&&!e.done;++c){l===this._cycleStartIndex&&this._startUpdateCycle();const c=n.state.get(l);let h=0;if(!(c&L.ALLOCATED)){l=l+1===o?0:l+1,i++;continue}const d=n.lodLevel.get(l);if(c&L.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[0][d].freeTail(),c&L.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[0][d].freeTail(),c&L.REMOVE)s.freeInstance(l);else if(c&L.VISIBLE){let e=0;t&&(n.modelOrigin.getVec(l,k),e=a.selectLevel(k,s.getCombinedMedianScaleFactor(l),r)),h=c&~(L.ACTIVE|L.TRANSFORM_CHANGED),e>=0&&(c&L.HIGHLIGHT?(P(this._highlightRenderInstanceData[0][e],n,l),h|=L.HIGHLIGHT_ACTIVE):(P(this._defaultRenderInstanceData[0][e],n,l),h|=L.DEFAULT_ACTIVE)),n.state.set(l,h),n.lodLevel.set(l,e)}else h=c&~(L.ACTIVE|L.TRANSFORM_CHANGED),n.state.set(l,h);if(null!=this._octreeCached){const e=!!(c&L.ACTIVE),t=!!(h&L.ACTIVE);!e&&t?this._octreeCached.addInstance(l):e&&!t?this._octreeCached.removeInstance(l):e&&t&&c&L.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(l),this._octreeCached.addInstance(l))}l=l+1===o?0:l+1,e.madeProgress()}this._instanceIndex=l,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){const{bindParameters:a,rctx:s,output:n}=e;if(0===t.size||!r.material.requiresSlot(a.slot,e.output))return null;const i=r.glMaterials.load(s,a.slot,n);return null!=i?i.beginSlot(a):null}_renderComponent(e,t,r,a,s){if(!t)return;const{bindParameters:n,rctx:i}=e,o=i.bindTechnique(t,a.material.parameters,n);i.bindVAO(a.vao),t.ensureAttributeLocations(a.vao),o.bindDraw(Z,n,a.material.parameters),f.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===y.Color&&(o.setUniform4fv("externalColor",Q[Math.min(s,Q.length-1)]),o.setUniform1i("colorMixMode",N.replace));const l=i.capabilities.instancing,c=r.capacity,h=r.headIndex,d=r.tailIndex,u=r.firstIndex,m=this._glInstanceBufferLayout,p=(e,s)=>{V(i,v,r.buffer,m,e),l.drawArraysInstanced(t.primitiveType,0,a.vertexCount,s-e),H(i,v,r.buffer,m)};a.material.parameters.transparent&&null!=u?h>d?(b(u>=d&&u<=h,"invalid firstIndex"),p(u,h),p(d,u)):h<d&&(u<=h?(b(u>=0&&u<=h,"invalid firstIndex"),p(u,h),p(d,c),p(0,u)):(b(u>=d&&u<=c,"invalid firstIndex"),p(u,c),p(0,h),p(d,u))):h>d?p(d,h):h<d&&(p(0,h),p(d,c)),i.bindVAO(null)}};function P(e,t,r){const a=e.allocateHead();G(t,r,e.view,a)}function G(e,t,r,a){U(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,a),r.model.copyFrom(a,e.model,t),r.modelNormal.copyFrom(a,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(a,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(a,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(a,e.featureAttribute,t)}function z(e){let t=I().vec3f(A.MODELORIGINHI).vec3f(A.MODELORIGINLO).mat3f(A.MODEL).mat3f(A.MODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(A.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(A.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(A.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([o({constructOnly:!0})],q.prototype,"symbol",void 0),e([o({constructOnly:!0})],q.prototype,"optionalFields",void 0),e([o({constructOnly:!0})],q.prototype,"metadata",void 0),e([o({constructOnly:!0})],q.prototype,"shaderTransformation",void 0),e([o()],q.prototype,"_instanceData",void 0),e([o()],q.prototype,"_cycleStartIndex",void 0),e([o({readOnly:!0})],q.prototype,"_enableLevelSelection",null),e([o()],q.prototype,"_updateCyclesWithStaticCamera",void 0),e([o({readOnly:!0})],q.prototype,"running",null),q=e([l("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],q);const k=m(),W=p(),K=c(),Y=m(),J=m(),Q=[_(1,0,1,1),_(0,0,1,1),_(0,1,0,1),_(1,1,0,1),_(1,0,0,1)],Z=new M;export{q as LodRenderer};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{isSome as r}from"../../../../../core/arrayUtils.js";import a from"../../../../../core/Handles.js";import{destroyMaybe as s}from"../../../../../core/maybe.js";import{isAborted as n,throwIfAborted as i}from"../../../../../core/promiseUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../../chunks/mat4f64.js";import{b as h,e as d,m as u}from"../../../../../chunks/vec3.js";import{c as m}from"../../../../../chunks/vec3f64.js";import{c as p,f as _}from"../../../../../chunks/vec4f64.js";import f from"../../../support/debugFlags.js";import{glLayout as g}from"../../../support/buffer/glUtil.js";import{newLayout as I}from"../../../support/buffer/InterleavedLayout.js";import{ShaderOutput as y}from"../../core/shaderLibrary/ShaderOutput.js";import{Camera as C}from"../Camera.js";import{Default3D as v}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as E}from"../IntersectorInterfaces.js";import D from"../Octree.js";import{RenderSlot as R}from"../RenderSlot.js";import{assert as b}from"../Util.js";import{VertexAttribute as A}from"../VertexAttribute.js";import{InstanceData as T,StateFlags as L}from"./InstanceData.js";import{InstanceOctree as O}from"./InstanceOctree.js";import{LevelSelector as S}from"./LevelSelector.js";import{LodLevel as j}from"./LodLevel.js";import{RenderInstanceData as x}from"./RenderInstanceData.js";import{colorMixModes as N}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as U}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as M}from"../../shaders/DefaultMaterialTechnique.js";import{TaskPriority as w,noBudget as F}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as V,unbindVertexBufferLayout as H}from"../../../../webgl/Util.js";const B=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new S(t,r)};let q=class extends t{constructor(e,t){super(e),this.type=E.LOD,this.isGround=!1,this._handles=new a,this._levels=[],this._defaultRenderInstanceData=[new Array],this._highlightRenderInstanceData=[new Array],this._allRenderInstanceData=[this._defaultRenderInstanceData[0],this._highlightRenderInstanceData[0]],this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new C,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.slots=[R.OPAQUE_MATERIAL,R.TRANSPARENT_MATERIAL],this.canRender=!0,this._instanceData=new T({shaderTransformation:e.shaderTransformation},e.optionalFields),this._handles.add(t.registerTask(w.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=z(this.optionalFields),this._glInstanceBufferLayout=g(this._instanceBufferLayout,1),this._handles.add([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}destroy(){this._handles.destroy()}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get memoryUsage(){const e={cpu:0,gpu:0};return this._allRenderInstanceData.forEach((t=>t.forEach((t=>{e.cpu+=t.memoryUsage.cpu,e.gpu+=t.memoryUsage.gpu})))),e}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const a=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,s=e.triangleCount;t.push({renderedInstances:a,renderedTriangles:a*s,trianglesPerInstance:s})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,t){this._context=e;const a=e.renderContext.rctx,s=await Promise.allSettled(this.symbol.levels.map((r=>(this._defaultRenderInstanceData[0].push(new x(a,this._instanceBufferLayout)),this._highlightRenderInstanceData[0].push(new x(a,this._instanceBufferLayout)),j.create(e,r,t))))),o=s.map((e=>"fulfilled"===e.status?e.value:null)).filter(r);if(n(t)||o.length!==s.length){o.forEach((e=>e.destroy())),i(t);for(const e of s)if("rejected"===e.status)throw e.reason}this._levels=o,this._levelSelector=B(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData[0].forEach((e=>e.destroy())),this._highlightRenderInstanceData[0].forEach((e=>e.destroy()))}get needsTransparentPass(){return this._levels.some((e=>e.components.some((e=>e.material.requiresSlot(R.TRANSPARENT_MATERIAL,y.Color)))))}get needsHighlight(){return this._highlightRenderInstanceData[0].some((e=>e.size>0))}prepareRender(e){if(!f.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bindParameters.contentCamera.equals(this._camera);this._camera.copyFrom(e.bindParameters.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(F),this._needFullCycle=!1)}}prepareTechniques(e){if(!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e.output);if(!t)return null;const r=new Array;return t.forEach((t=>this.levels.forEach(((a,s)=>{a.components.forEach((a=>r.push(this._beginComponent(e,t[s],a))))})))),r}render(e,t){const r=this._getInstanceDatas(e.output);if(!r)return;let a=0;e.rctx.bindVAO(),r.forEach((r=>this.levels.forEach(((s,n)=>{s.components.forEach((s=>this._renderComponent(e,t[a++],r[n],s,n)))}))))}_getInstanceDatas(e){const t=e!==y.Highlight&&e!==y.ShadowHighlight,r=e!==y.ShadowExcludeHighlight;return t&&r?this._allRenderInstanceData:t?this._defaultRenderInstanceData:r?this._highlightRenderInstanceData:null}intersect(e,t,r,a){if(!this.baseMaterial.isVisible()||null==this._octree)return;const s=m();h(s,a,r);const n=s=>{this._instanceData.getCombinedModelTransform(s,K),e.transform.set(K),u(Y,r,e.transform.inverse),u(J,a,e.transform.inverse);const n=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;b(0!=(n&L.ACTIVE),"invalid instance state"),b(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,Y,J,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(n):this._octree.forEachAlongRay(r,s,n)}queryDepthRange(e){return this._queryDepthRangeOctree(e)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new O(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&L.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=s(this._octreeCached)}_queryDepthRangeOctree(e){if(null==this._octree)return{near:1/0,far:-1/0};const t=e.viewForward,r=this._octree.findClosest(t,D.DepthOrder.FRONT_TO_BACK,e.frustum),a=this._octree.findClosest(t,D.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==a)return{near:1/0,far:-1/0};const s=e.eye,n=this._instanceData.view;n.boundingSphere.getVec(r,W),h(W,W,s);const i=d(W,t)-W[3];n.boundingSphere.getVec(a,W),h(W,W,s);const o=d(W,t)+W[3];return{near:Math.max(e.near,i),far:Math.min(e.far,o)}}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const s=this._instanceData,n=s.view;let i=s.size;const o=s.capacity;let l=this._instanceIndex;for(let c=0;c<i&&!e.done;++c){l===this._cycleStartIndex&&this._startUpdateCycle();const c=n.state.get(l);let h=0;if(!(c&L.ALLOCATED)){l=l+1===o?0:l+1,i++;continue}const d=n.lodLevel.get(l);if(c&L.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[0][d].freeTail(),c&L.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[0][d].freeTail(),c&L.REMOVE)s.freeInstance(l);else if(c&L.VISIBLE){let e=0;t&&(n.modelOrigin.getVec(l,k),e=a.selectLevel(k,s.getCombinedMedianScaleFactor(l),r)),h=c&~(L.ACTIVE|L.TRANSFORM_CHANGED),e>=0&&(c&L.HIGHLIGHT?(P(this._highlightRenderInstanceData[0][e],n,l),h|=L.HIGHLIGHT_ACTIVE):(P(this._defaultRenderInstanceData[0][e],n,l),h|=L.DEFAULT_ACTIVE)),n.state.set(l,h),n.lodLevel.set(l,e)}else h=c&~(L.ACTIVE|L.TRANSFORM_CHANGED),n.state.set(l,h);if(null!=this._octreeCached){const e=!!(c&L.ACTIVE),t=!!(h&L.ACTIVE);!e&&t?this._octreeCached.addInstance(l):e&&!t?this._octreeCached.removeInstance(l):e&&t&&c&L.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(l),this._octreeCached.addInstance(l))}l=l+1===o?0:l+1,e.madeProgress()}this._instanceIndex=l,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){const{bindParameters:a,rctx:s,output:n}=e;if(0===t.size||!r.material.requiresSlot(a.slot,e.output))return null;const i=r.glMaterials.load(s,a.slot,n);return null!=i?i.beginSlot(a):null}_renderComponent(e,t,r,a,s){if(!t)return;const{bindParameters:n,rctx:i}=e;i.appleAmdDriverHelper?.resetIndicesType();const o=i.bindTechnique(t,a.material.parameters,n);i.bindVAO(a.vao),t.ensureAttributeLocations(a.vao),o.bindDraw(Z,n,a.material.parameters),f.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===y.Color&&(o.setUniform4fv("externalColor",Q[Math.min(s,Q.length-1)]),o.setUniform1i("colorMixMode",N.replace));const l=i.capabilities.instancing,c=r.capacity,h=r.headIndex,d=r.tailIndex,u=r.firstIndex,m=this._glInstanceBufferLayout,p=(e,s)=>{V(i,v,r.buffer,m,e),l.drawArraysInstanced(t.primitiveType,0,a.vertexCount,s-e),H(i,v,r.buffer,m)};a.material.parameters.transparent&&null!=u?h>d?(b(u>=d&&u<=h,"invalid firstIndex"),p(u,h),p(d,u)):h<d&&(u<=h?(b(u>=0&&u<=h,"invalid firstIndex"),p(u,h),p(d,c),p(0,u)):(b(u>=d&&u<=c,"invalid firstIndex"),p(u,c),p(0,h),p(d,u))):h>d?p(d,h):h<d&&(p(0,h),p(d,c)),i.bindVAO(null)}};function P(e,t,r){const a=e.allocateHead();G(t,r,e.view,a)}function G(e,t,r,a){U(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,a),r.model.copyFrom(a,e.model,t),r.modelNormal.copyFrom(a,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(a,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(a,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(a,e.featureAttribute,t)}function z(e){let t=I().vec3f(A.MODELORIGINHI).vec3f(A.MODELORIGINLO).mat3f(A.MODEL).mat3f(A.MODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(A.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(A.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(A.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([o({constructOnly:!0})],q.prototype,"symbol",void 0),e([o({constructOnly:!0})],q.prototype,"optionalFields",void 0),e([o({constructOnly:!0})],q.prototype,"metadata",void 0),e([o({constructOnly:!0})],q.prototype,"shaderTransformation",void 0),e([o()],q.prototype,"_instanceData",void 0),e([o()],q.prototype,"_cycleStartIndex",void 0),e([o({readOnly:!0})],q.prototype,"_enableLevelSelection",null),e([o()],q.prototype,"_updateCyclesWithStaticCamera",void 0),e([o({readOnly:!0})],q.prototype,"running",null),q=e([l("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],q);const k=m(),W=p(),K=c(),Y=m(),J=m(),Q=[_(1,0,1,1),_(0,0,1,1),_(0,1,0,1),_(1,1,0,1),_(1,0,0,1)],Z=new M;export{q as LodRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{f as e}from"../../../../chunks/vec4f64.js";import{BufferViewMat3f as t,BufferViewVec4f as r,BufferViewVec4u8 as i,BufferViewVec3f as s}from"../../../../geometry/support/buffer/BufferView.js";import{newLayout as a}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{CullFaceOptions as n}from"../lib/basicInterfaces.js";import c from"../lib/GLMaterial.js";import{OITPolygonOffsetLimit as u}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as h}from"../lib/RenderSlot.js";import{assert as l}from"../lib/Util.js";import{VertexAttribute as p}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as f}from"./DefaultBufferWriter.js";import{Style as m}from"./PatternStyle.js";import{TriangleMaterial as d}from"./TriangleMaterial.js";import{VisualVariablePassParameters as g}from"./VisualVariablePassParameters.js";import{writeBufferVec4 as _,writeColor as A,writePosition as b}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocations as O,PatternTechniqueConfiguration as P,PatternTechnique as T}from"../shaders/PatternTechnique.js";class S extends d{constructor(e){super(e,new R),this.supportsEdges=!0,this._vertexAttributeLocations=O,this._configuration=new P}getConfiguration(e,t){return this._configuration.output=e,this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.style=this.parameters.style,this._configuration.patternSpacing=this.parameters.patternSpacing,this._configuration.lineWidth=this.parameters.lineWidth,this._configuration.draped=this.parameters.draped,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.enableOffset=t.camera.relativeElevation<u,this._configuration.hasMultipassTerrain=t.multipassTerrain.enabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}requiresSlot(e,t){if(t===o.Color||t===o.Alpha||t===o.Highlight||t===o.Depth&&this.parameters.writeLinearDepth){if(e===h.DRAPED_MATERIAL)return!0;if(t===o.Highlight)return e===h.OPAQUE_MATERIAL;return e===(this.parameters.writeDepth?h.TRANSPARENT_MATERIAL:h.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL)}return!1}createGLMaterial(e){return new y(e)}createBufferWriter(){const e=a().vec3f(p.POSITION).vec4u8(p.COLOR).vec4f(p.UVMAPSPACE);return this.parameters.draped||e.mat3f(p.BOUNDINGRECT),new E(e)}}class y extends c{_updateParameters(e){return this.ensureTechnique(T,e)}_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:e.hasOccludees})}beginSlot(e){return this._output!==o.Color&&this._output!==o.Alpha||this._updateOccludeeState(e),this._updateParameters(e)}}class E extends f{write(e,a,o,n,c){for(const u of this.vertexBufferLayout.fields.keys()){const a=o.vertexAttributes.get(u),h=o.indices.get(u);if(a&&h)switch(u){case p.POSITION:{l(3===a.size);const t=n.getField(u,s);t&&b(h,a.data,e,t,c);break}case p.COLOR:{l(3===a.size||4===a.size);const e=n.getField(u,i);e&&A(h,a.data,a.size,e,c);break}case p.UVMAPSPACE:{l(4===a.size);const e=n.getField(u,r);e&&_(h,a.data,e,c);break}case p.BOUNDINGRECT:{l(9===a.size);const r=n.getField(u,t);r&&this.writeBoundingRect(h,a.data,e,r,c);break}}}}writeBoundingRect(e,t,r,i,s){const a=r,o=i.typedBuffer,n=i.typedBufferStride,c=e.length;s*=n;for(let u=0;u<c;++u){const r=9*e[u],i=t[r],c=t[r+1],h=t[r+2];o[s]=a[0]*i+a[4]*c+a[8]*h+a[12],o[s+1]=a[1]*i+a[5]*c+a[9]*h+a[13],o[s+2]=a[2]*i+a[6]*c+a[10]*h+a[14];for(let e=3;e<9;++e)o[s+e]=t[r+e];s+=n}}}class R extends g{constructor(){super(...arguments),this.color=e(1,1,1,1),this.writeDepth=!0,this.writeLinearDepth=!1,this.polygonOffset=!1,this.hasSlicePlane=!1,this.cullFace=n.None,this.hasOccludees=!1,this.style=m.Cross,this.patternSpacing=10,this.lineWidth=1,this.draped=!0}}export{R as Parameters,S as PatternMaterial};
5
+ import{f as t}from"../../../../chunks/vec4f64.js";import{BufferViewMat3f as e,BufferViewVec4f as r}from"../../../../geometry/support/buffer/BufferView.js";import{newLayout as i}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as s}from"../core/shaderLibrary/ShaderOutput.js";import{CullFaceOptions as a}from"../lib/basicInterfaces.js";import o from"../lib/GLMaterial.js";import{OITPolygonOffsetLimit as n}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as h}from"../lib/RenderSlot.js";import{assert as u}from"../lib/Util.js";import{VertexAttribute as l}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as c}from"./DefaultBufferWriter.js";import{Style as p}from"./PatternStyle.js";import{TriangleMaterial as f}from"./TriangleMaterial.js";import{VisualVariablePassParameters as m}from"./VisualVariablePassParameters.js";import{writeDefaultAttribute as d,writeBufferVec4 as g}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocations as _,PatternTechniqueConfiguration as A,PatternTechnique as T}from"../shaders/PatternTechnique.js";class b extends f{constructor(t){super(t,new v),this.supportsEdges=!0,this._vertexAttributeLocations=_,this._configuration=new A}getConfiguration(t,e){return this._configuration.output=t,this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasVertexColors=this.parameters.hasVertexColors&&!this.parameters.vvColor,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.style=this.parameters.style,this._configuration.patternSpacing=this.parameters.patternSpacing,this._configuration.lineWidth=this.parameters.lineWidth,this._configuration.draped=this.parameters.draped,this._configuration.transparencyPassType=e.transparencyPassType,this._configuration.enableOffset=e.camera.relativeElevation<n,this._configuration.hasMultipassTerrain=e.multipassTerrain.enabled,this._configuration.cullAboveGround=e.multipassTerrain.cullAboveGround,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration}requiresSlot(t,e){if(e===s.Color||e===s.Alpha||e===s.Highlight||e===s.Depth&&this.parameters.writeLinearDepth){if(t===h.DRAPED_MATERIAL)return!0;if(e===s.Highlight)return t===h.OPAQUE_MATERIAL;return t===(this.parameters.writeDepth?h.TRANSPARENT_MATERIAL:h.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL)}return!1}createGLMaterial(t){return new O(t)}createBufferWriter(){const t=i().vec3f(l.POSITION).vec4f(l.UVMAPSPACE);return this.parameters.draped||t.mat3f(l.BOUNDINGRECT),this.parameters.vvColor?t.f32(l.COLORFEATUREATTRIBUTE):t.vec4u8(l.COLOR),new P(t)}}class O extends o{_updateParameters(t){return this.ensureTechnique(T,t)}_updateOccludeeState(t){t.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:t.hasOccludees})}beginSlot(t){return this._output!==s.Color&&this._output!==s.Alpha||this._updateOccludeeState(t),this._updateParameters(t)}}class P extends c{write(t,i,s,a,o){for(const n of this.vertexBufferLayout.fields.keys()){const h=s.vertexAttributes.get(n),c=s.indices.get(n);if(h&&c)switch(n){case l.UVMAPSPACE:{u(4===h.size);const t=a.getField(n,r);t&&g(c,h.data,t,o);break}case l.BOUNDINGRECT:{u(9===h.size);const r=a.getField(n,e);r&&this.writeBoundingRect(c,h.data,t,r,o);break}default:d(n,h,c,t,i,a,o)}}}writeBoundingRect(t,e,r,i,s){const a=r,o=i.typedBuffer,n=i.typedBufferStride,h=t.length;s*=n;for(let u=0;u<h;++u){const r=9*t[u],i=e[r],h=e[r+1],l=e[r+2];o[s]=a[0]*i+a[4]*h+a[8]*l+a[12],o[s+1]=a[1]*i+a[5]*h+a[9]*l+a[13],o[s+2]=a[2]*i+a[6]*h+a[10]*l+a[14];for(let t=3;t<9;++t)o[s+t]=e[r+t];s+=n}}}class v extends m{constructor(){super(...arguments),this.color=t(1,1,1,1),this.writeDepth=!0,this.writeLinearDepth=!1,this.hasVertexColors=!1,this.polygonOffset=!1,this.hasSlicePlane=!1,this.cullFace=a.None,this.hasOccludees=!1,this.style=p.Cross,this.patternSpacing=10,this.lineWidth=1,this.draped=!0}}export{v as Parameters,b as PatternMaterial};