@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 2.78 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import e from"../../../../core/PooledArray.js";class i{constructor(e){this._layerView=e,this._lodGlobalDirty=!1}destroy(){this._index=null,this._lodGlobalHandling=null,this._removeNodes=null}startNodeLoading(e,i,s){this._maxLodLevel=s.maxLodLevel,this._index=i,this._removeNodes=e}shouldLoadNode(e){if(null==e)return!1;const i=this._index.nodeTraversalState(e);return!!this._isChosenMaxLOD(i)||!!i.isChosen&&this._childrenRequireLoading(e)}setLodGlobalDirty(){this._lodGlobalDirty=!0}get requiresLODGlobalHandling(){return null!=this._index&&!0===this._lodGlobalDirty}lodGlobalHandling(e){if(!this.requiresLODGlobalHandling)return!1;this._lodGlobalDirty=!1;const i=this._layerView.view.resourceController.memoryController.usedMemory,l=Math.max(0,Math.floor(10*(i-1)));s.clear(),this._lodGlobalHandling(this._index.rootNode,l,!1,!!this._layerView.nodeCrossfadingEnabled);const o=s.length;this._removeNodes(s,e);const d=s.length<o;return 0!==s.length&&(this._lodGlobalDirty=!0),s.clear(),d}_lodGlobalHandling(e,i,l,o){if(null==e)return!1;const d=e.index,t=this._index,n=this._layerView,r=t.nodeTraversalState(e),a=this._isChosenMaxLOD(r),h=e.resources.isEmpty;if(a&&h)return e.childrenLoaded>0&&this._removeChildrenRecursive(e),!0;const u=n.isNodeLoaded(d);if(o&&u&&a){const i=!l&&this.hasNoVisibleChildren(e);n.fadeNode(d,0,!i)}const _=u&&(!n.isNodeFullyFadedIn||n.isNodeFullyFadedIn(d));if(u&&(n.updateNodeState(d,a?1:0),a))return _&&this._removeChildrenRecursive(e),_;const c=e.childCount>0;let x=c;if(c)for(let s=0;s<e.childCount;s++){const e=t.getChildIndex(d,s),n=t.getNode(e);if(null!=n){!t.isGeometryVisible(e)||this._lodGlobalHandling(n,i,l||_,o)||(x=!1)}else t.isNodeVisible(e)&&(x=!1)}const L=u&&!a&&(x||s.length<i);L&&s.push(d),!o||L||!u||l||x||n.fadeNode(d,0,!1);const y=e.resources.isEmpty;return x||_&&!L||y}_removeChildrenRecursive(e){this._index.traverseDescendants(e,e=>((this._layerView.isNodeLoaded(e.index)||this._layerView.isNodeReloading(e.index))&&s.push(e.index),e.childrenLoaded>0))}hasNoVisibleChildren(e){let i=!0;return this._index.traverseDescendants(e,e=>!(!i||!this._index.isNodeVisible(e.index))&&(this._layerView.isNodeLoaded(e.index)?(i=!1,!1):e.childrenLoaded>0)),i}_childrenRequireLoading(e){let i=!1,s=!0;return this._index.traverseDescendants(e,e=>{if(!s||!this._index.isNodeVisible(e.index))return!1;const l=this._index.nodeTraversalState(e);return this._isChosenMaxLOD(l)&&this._index.isGeometryVisible(e.index)&&(i=!0),this._layerView.isNodeLoaded(e.index)?(s=!1,!1):e.childrenLoaded>0}),s&&i}_isChosenMaxLOD(e){return e.isChosen&&(!e.nodeHasLOD||e.lodLevel===this._maxLodLevel)}static cleanupI3SLodHandling(){s.prune()}}const s=new e({deallocator:null});export{i as default};