@arcgis/core 5.2.0-next.132 → 5.2.0-next.134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/107f4bcf8e6c91a67010.js +1 -0
- package/assets/esri/core/workers/chunks/{081c9ccaa5884c730a91.js → 1688c4dcd36db992a9dc.js} +1 -1
- package/assets/esri/core/workers/chunks/3a6b8f9aabde7e138834.js +1 -0
- package/assets/esri/core/workers/chunks/{18d5bad86ea3ef3ec747.js → eba9e03c1c9aa55044a3.js} +120 -120
- package/assets/esri/core/workers/chunks/f6c8e5abe1d55ab5c7dd.js +1 -0
- package/assets/esri/themes/base/fonts/fonts/09ab0626-bb45-4650-acc8-0182d693df02-arabic.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/09ab0626-bb45-4650-acc8-0182d693df02-cyrillic.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/09ab0626-bb45-4650-acc8-0182d693df02-ext.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/09ab0626-bb45-4650-acc8-0182d693df02-georgian.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/09ab0626-bb45-4650-acc8-0182d693df02-greek.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/09ab0626-bb45-4650-acc8-0182d693df02-hebrew.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/09ab0626-bb45-4650-acc8-0182d693df02-math.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/09ab0626-bb45-4650-acc8-0182d693df02-thai.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/09ab0626-bb45-4650-acc8-0182d693df02-vietnamese.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/09ab0626-bb45-4650-acc8-0182d693df02.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/0c8a5d21-8a14-4451-8145-695071809cb7-arabic.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/0c8a5d21-8a14-4451-8145-695071809cb7-cyrillic.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/0c8a5d21-8a14-4451-8145-695071809cb7-ext.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/0c8a5d21-8a14-4451-8145-695071809cb7-georgian.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/0c8a5d21-8a14-4451-8145-695071809cb7-greek.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/0c8a5d21-8a14-4451-8145-695071809cb7-hebrew.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/0c8a5d21-8a14-4451-8145-695071809cb7-math.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/0c8a5d21-8a14-4451-8145-695071809cb7-thai.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/0c8a5d21-8a14-4451-8145-695071809cb7-vietnamese.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/0c8a5d21-8a14-4451-8145-695071809cb7.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/12f4c786-0bef-4a48-b7c0-eebaa7591688-arabic.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/12f4c786-0bef-4a48-b7c0-eebaa7591688-cyrillic.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/12f4c786-0bef-4a48-b7c0-eebaa7591688-ext.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/12f4c786-0bef-4a48-b7c0-eebaa7591688-georgian.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/12f4c786-0bef-4a48-b7c0-eebaa7591688-greek.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/12f4c786-0bef-4a48-b7c0-eebaa7591688-hebrew.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/12f4c786-0bef-4a48-b7c0-eebaa7591688-math.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/12f4c786-0bef-4a48-b7c0-eebaa7591688-thai.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/12f4c786-0bef-4a48-b7c0-eebaa7591688-vietnamese.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/12f4c786-0bef-4a48-b7c0-eebaa7591688.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/3ae1e25e-3aa6-4061-a016-a079159f9d65.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/41331c3c-3759-4462-8695-33c9a21b6a5b.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/94aa531e-7746-4df0-bb6e-349891f2eda5.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b8b15cdf-85d1-4120-8daa-48863d803939-arabic.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b8b15cdf-85d1-4120-8daa-48863d803939-cyrillic.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b8b15cdf-85d1-4120-8daa-48863d803939-ext.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b8b15cdf-85d1-4120-8daa-48863d803939-georgian.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b8b15cdf-85d1-4120-8daa-48863d803939-greek.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b8b15cdf-85d1-4120-8daa-48863d803939-hebrew.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b8b15cdf-85d1-4120-8daa-48863d803939-math.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b8b15cdf-85d1-4120-8daa-48863d803939-thai.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b8b15cdf-85d1-4120-8daa-48863d803939-vietnamese.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b8b15cdf-85d1-4120-8daa-48863d803939.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b9c5b839-db56-4419-8fcb-6ab661babb1d-cyrillic.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b9c5b839-db56-4419-8fcb-6ab661babb1d-ext.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b9c5b839-db56-4419-8fcb-6ab661babb1d-greek.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b9c5b839-db56-4419-8fcb-6ab661babb1d-hebrew.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b9c5b839-db56-4419-8fcb-6ab661babb1d-math.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b9c5b839-db56-4419-8fcb-6ab661babb1d-vietnamese.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts/b9c5b839-db56-4419-8fcb-6ab661babb1d.woff2 +0 -0
- package/assets/esri/themes/base/fonts/fonts.scss +0 -0
- package/chunks/GaussianSplat.glsl.js +24 -9
- package/chunks/LineMarker.glsl.js +23 -23
- package/chunks/RibbonLine.glsl.js +136 -99
- package/config.js +1 -1
- package/core/PooledArray.js +1 -1
- package/geometry/operators/affineTransformOperator.d.ts +4 -0
- package/geometry/operators/alphaShapeOperator.d.ts +10 -1
- package/geometry/operators/areaOperator.d.ts +3 -0
- package/geometry/operators/autoCompleteOperator.d.ts +3 -0
- package/geometry/operators/boundaryOperator.d.ts +4 -0
- package/geometry/operators/bufferOperator.d.ts +6 -0
- package/geometry/operators/centroidOperator.d.ts +3 -0
- package/geometry/operators/clipOperator.d.ts +4 -0
- package/geometry/operators/containsOperator.d.ts +4 -0
- package/geometry/operators/convexHullOperator.d.ts +6 -0
- package/geometry/operators/crossesOperator.d.ts +4 -0
- package/geometry/operators/cutOperator.d.ts +3 -0
- package/geometry/operators/densifyOperator.d.ts +5 -0
- package/geometry/operators/differenceOperator.d.ts +4 -0
- package/geometry/operators/disjointOperator.d.ts +4 -0
- package/geometry/operators/distanceOperator.d.ts +4 -0
- package/geometry/operators/equalsOperator.d.ts +4 -0
- package/geometry/operators/extendOperator.d.ts +4 -0
- package/geometry/operators/generalizeOperator.d.ts +5 -0
- package/geometry/operators/geodesicBufferOperator.d.ts +8 -0
- package/geometry/operators/geodesicProximityOperator.d.ts +9 -0
- package/geometry/operators/geodeticAreaOperator.d.ts +6 -0
- package/geometry/operators/geodeticDensifyOperator.d.ts +7 -0
- package/geometry/operators/geodeticDistanceOperator.d.ts +6 -0
- package/geometry/operators/geodeticLengthOperator.d.ts +6 -0
- package/geometry/operators/geodeticUtilsOperator.d.ts +7 -0
- package/geometry/operators/graphicBufferOperator.d.ts +4 -0
- package/geometry/operators/integrateOperator.d.ts +3 -0
- package/geometry/operators/intersectionOperator.d.ts +5 -0
- package/geometry/operators/intersectsOperator.d.ts +4 -0
- package/geometry/operators/isNearOperator.d.ts +4 -0
- package/geometry/operators/labelPointOperator.d.ts +4 -0
- package/geometry/operators/lengthOperator.d.ts +3 -0
- package/geometry/operators/linesToPolygonsOperator.d.ts +3 -0
- package/geometry/operators/locateBetweenOperator.d.ts +3 -0
- package/geometry/operators/minimumBoundingCircleOperator.d.ts +5 -0
- package/geometry/operators/multiPartToSinglePartOperator.d.ts +4 -0
- package/geometry/operators/offsetOperator.d.ts +5 -0
- package/geometry/operators/overlapsOperator.d.ts +4 -0
- package/geometry/operators/polygonOverlayOperator.d.ts +9 -1
- package/geometry/operators/polygonSlicerOperator.d.ts +7 -0
- package/geometry/operators/projectOperator.d.ts +6 -0
- package/geometry/operators/proximityOperator.d.ts +7 -0
- package/geometry/operators/relateOperator.d.ts +5 -0
- package/geometry/operators/reshapeOperator.d.ts +3 -0
- package/geometry/operators/shapePreservingProjectOperator.d.ts +7 -0
- package/geometry/operators/simplifyOGCOperator.d.ts +5 -0
- package/geometry/operators/simplifyOperator.d.ts +5 -0
- package/geometry/operators/support/GeographicTransformation.d.ts +2 -0
- package/geometry/operators/support/GeographicTransformationStep.d.ts +2 -0
- package/geometry/operators/support/Transformation.d.ts +6 -1
- package/geometry/operators/support/geographicTransformationUtils.d.ts +4 -0
- package/geometry/operators/symmetricDifferenceOperator.d.ts +4 -0
- package/geometry/operators/touchesOperator.d.ts +4 -0
- package/geometry/operators/types.d.ts +1 -0
- package/geometry/operators/unionOperator.d.ts +4 -0
- package/geometry/operators/withinOperator.d.ts +4 -0
- package/kernel.js +1 -1
- package/layers/GaussianSplatLayer.d.ts +0 -1
- package/layers/GeospatialPDFLayer.js +1 -1
- package/package.json +2 -2
- package/support/revision.js +1 -1
- package/symbols/LineSymbol3D.d.ts +0 -7
- package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
- package/views/2d/layers/GeospatialPDFLayerView2D.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/3d/interactive/placementTools/GroundNavigationPlacementTool3D.js +1 -1
- package/views/3d/layers/GeospatialPDFLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
- package/views/3d/navigation/modes/GroundNavigationMode3D.js +1 -1
- package/views/3d/state/Constraints.js +1 -1
- package/views/3d/state/utils/OffsetCorrectionController.js +1 -1
- package/views/3d/state/utils/groundNavigationUtils.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +23 -12
- package/views/3d/webgl-engine/core/shaderLibrary/shading/MarkerSizing.glsl.js +35 -25
- package/views/3d/webgl-engine/core/shaderLibrary/shading/readShadow.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/util/cameraUniforms.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/Intersector.js +1 -1
- package/views/3d/webgl-engine/lib/IntersectorResult.js +1 -1
- package/views/3d/webgl-engine/lib/LineMaterial.js +1 -1
- package/views/3d/webgl-engine/lib/PolygonIntersectionResults.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
- package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/intersectWithPolygonOffset.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplatPass.glsl.js +4 -4
- package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/LineTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
- package/views/support/PromiseQueue.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/widgets/BatchAttributeForm/ValueChangeTransaction.js +1 -1
- package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
- package/widgets/BatchAttributeForm/expressions/ExpressionsModel.js +1 -1
- package/widgets/BatchAttributeForm/inputs/InputBase.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.d.ts +148 -1
- package/assets/esri/core/workers/chunks/540f60e31b19d85e9371.js +0 -1
- package/assets/esri/core/workers/chunks/55a560fd872f7463b33d.js +0 -1
- package/assets/esri/core/workers/chunks/cf6f671823fa6c2a9a5e.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as s}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as n}from"../../../../geometry/support/sphere.js";import{NodeBoundingData as o,Node as r,NodeTraversalState as d}from"./I3SNode.js";import{addWraparound as a}from"./I3SUtil.js";import{ValidatedNode as l}from"./ValidatedNode.js";import{ElevationRange as h}from"../../support/ElevationRange.js";import{Obb as u}from"../../support/orientedBoundingBox.js";class c{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this._boundingData=s,this.node=n,this.parentIndex=-1,this.useAsHole=0,this.filterImpact=2,this.traversalState=null}get nodeBoundingData(){return this._boundingData}destroy(){this._boundingData=null,this.node=null,this.traversalState=null}invalidateBounds(){this.node?.invalidateServiceBVsInRenderSR(),this.nodeBoundingData?.invalidateServiceBVsInRenderSR()}}class g{constructor(e=new Array,t=new Array){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(const e of this._nodeDescriptors)e.destroy();this._nodeDescriptors.length=0,this._children.length=0}get nodes(){return this._nodeDescriptors}addNode(e){return this._nodeDescriptors.push(e),this._nodeDescriptors.length-1}setNodes(e,t){this._nodeDescriptors=e,this._children=t}get children(){return this._children}}class _{get _useNodePages(){return this._pageSize>0}constructor(t,i,s,n,r,d,a,l,h,u,c,_,f,v,N){if(this.viewingMode=t,this._layer=i,this._requester=n,this._clientNodeLoader=r,this._viewportQueries=d,this._logger=a,this.holeFilling=l,this._isLoaded=h,this._isReloading=u,this._shouldLoadNode=c,this._enable=_,this._needsUpdate=f,this._computeVisibilityObb=v,this._computeNodeFiltering=N,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=0,this._lodConversion=e=>e,this._isEditable=!1,this.urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=p(0),this._visibilityCacheVersion=p(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._progressiveLoadPenaltyWeight=10,this._missingPagesAndNodes=new Set,this._prioritizedMissingNodeAndPageIds=new Array,this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=new Array,this._updates=new m(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this._pageQueue=new Array,this._newPages=new Array,this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=null!=i.associatedLayer?.infoFor3D,i.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${i.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,"page"===s.type){const e=s.rootPage;switch(this.urlPrefix=s.urlPrefix,this._pageSize=s.pageSize,s.lodMetric){case"maxScreenThreshold":this._lodMetric=1;break;case"maxScreenThresholdSQ":this._lodMetric=1,this._lodConversion=E}if(this._isEditable){this._rootIndex=-1;const t=I(s.rootIndex,s.pageSize),i=e.nodes[t],n={nodes:[{index:this._rootIndex,children:[s.rootIndex],mesh:void 0,obb:i.obb,lodThreshold:i.lodThreshold}]};this._addPage(P(this._rootIndex,this._pageSize),n),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=s.rootIndex;this._addPage(P(s.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if("node"===s.type){this.urlPrefix=s.urlPrefix;const e=new g;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new g;const e={id:"-1",version:null,mbs:s.rootNode.mbs,obb:s.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:s.rootNode.mbs,obb:s.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new o(e.id),-1);const t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new o(s.rootNode.id),-1);const t=this._validateNode(s.rootNode.id,s.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){const i=-1,s=new o(e,t),n=this._makeClientRefNode(s,i);return this._linkChildToParentNode(i,n),this.requestUpdate(),n}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e))return void this._logger.error(`Requested load page [${e}] already loaded`);if(this._loadingPages.has(e))return void this._logger.error(`Requested load page [${e}] already loading`);this._loadingPages.add(e);const i=this.urlPrefix+e;this._requester.request(i,"json").then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(i=>{this._loadingPages.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._loadingPages.delete(t),e.madeProgress(),this._needsNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this._needsNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());e?.nodes.forEach(e=>{let t=e.parentIndex;for(;null!=t&&t!==this._rootIndex;){const e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}}_addPage(e,t){if(this._nodePages.has(e))return void this._logger.error(`Page[${e}] reloaded`);const i=[],s=[],o=t.nodes.map((t,o)=>{const d=i.length,a=t.children?t.children.length:0;s.push(this._rootIndex);for(let e=0;e<a;e++)i.push(t.children[e]);const l=`${t.index}`,h=u.fromJSON(t.obb),g=new n(h.getCenter(A),h.radius),_=t.mesh?.attribute,f=t.mesh?.geometry,m=t.mesh?.material,p={hasSharedResource:!1,isEmpty:null==f,attributes:null!=_?.resource?`${_.resource}`:void 0,geometry:null!=f?.resource?`${f.resource}`:void 0,texture:null!=m?.resource?`${m.resource}`:void 0,geometryDefinition:f?f.definition:-1,materialDefinition:m?m.definition:-1},N=new r(l,x(o,e,this._pageSize),g,a,0,p,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),f?.featureCount??null,h);return N.visibilityObbInRenderSR=this._computeVisibilityObb(N),N.vertexCount=f?f.vertexCount:0,new c(d,a,v(this._visibilityCacheVersion),null,N)}),d=new g(o,i);-1===e?this._clientNodePage=d:this._nodePages.set(e,d)}_updateParentsAndLevel(){const e=new Array,t=(t,i,s)=>{const n=this._getPage(t);if(null!=n){const o=I(t,this._pageSize),r=n.nodes[o];r.parentIndex=null!=i?i:-1;const d=r.node;null!=d&&(d.level=s,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),s=this.getNode(i);if(null!=s)for(let e=0;e<s.childCount;e++){t(this.getChildIndex(s.index,e),i,s.level+1),this._maxLevel=Math.max(this._maxLevel,s.level+1)}}}_getPage(e){const t=P(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[I(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),s=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?s+1:s);const{lodMetric:n,maxError:o}=R(e.lodSelection),d=this._getNodeDescriptor(t);if(null!=d.node)return this._logger.error(`Loaded node[${t}] already in descriptor`),d.node;const a=new r(e.id,t,e.mbs,d.childCount,s,e.resources,e.version,n,o,e.numFeatures,e.obb?u.fromJSON(e.obb):null);d.node=a,a.visibilityObbInRenderSR=this._computeVisibilityObb(a);const l=d.nodeBoundingData;return null!=l&&(null==l.serviceMbsInIndexSR&&(l.serviceMbsInIndexSR=e.mbs),a.shareServiceBVsInRenderSRWith(l),l.visibilityObbInRenderSR=a.visibilityObbInRenderSR),a}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const s=i.nodes.length,n=new c(0,0,v(this._visibilityCacheVersion),e,null);return i.addNode(n),n.parentIndex=t,e.invalidateServiceBVsInRenderSR(),s}_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 s=-(i.nodes.length+1),n=new c(0,0,v(this._visibilityCacheVersion),e,null);return i.addNode(n),n.parentIndex=t,e.invalidateServiceBVsInRenderSR(),s}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const s=I(e,this._pageSize),n=I(t,this._pageSize),o=i.nodes[s],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const d=1;o.childCount+=d,null!=o.node&&(o.node.childCount+=d);for(const a of i.nodes)a.childOffset>r&&(a.childOffset+=d);i.nodes[n].parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const s=this._clientNodePage;if(null==s)return;const n=this._getParentIndex(e);if(null==n)return;const o=new Set,r=new Map,d=e=>{const i=I(e,this._pageSize),n=s.nodes[i];if(n.childCount>0)for(let t=n.childOffset;t<n.childOffset+n.childCount;++t)d(s.children[t]);const r=n.node?.id??n.nodeBoundingData?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(n)};d(e);const a=s.nodes,l=s.children,h=s.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,s=x(g,-1,this._pageSize),n=x(t,-1,this._pageSize);if(e.node&&(e.node.index=n),h[g]=n,u.push(e),s!==n){const t=e.node?.id??e.nodeBoundingData?.id;if(null==t)throw new Error("Node has no id");i(t,s,n),r.set(s,n)}}for(let g=0;g<u.length;++g){const e=x(g,-1,this._pageSize),t=u[g],i=c.length;for(let s=t.childOffset;s<t.childOffset+t.childCount;++s){const t=l[s];if(t>=0)c.push(t);else{const i=I(t,this._pageSize),s=a[i];if(o.has(s))continue;const n=h[i];c.push(n),s.parentIndex=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}s.setNodes(u,c),this._updateParentBoundingInformation(h[I(n,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,o=this._clientNodeLoader.renderSR,r=this._getNodeDescriptor(t);if(null==r)return;for(let n=0;n<r.childCount;n++){const r=this.getChildIndex(t,n),d=this._getNodeDescriptor(r),a=null!=d?d.nodeBoundingData||d.node:null;if(null!=a?.serviceMbsInIndexSR&&a.serviceMbsInIndexSR.radius>0)if(null==e)e=M.copyFrom(a.serviceMbsInIndexSR);else{const t=D;s(a.serviceMbsInIndexSR,i,t,o);const n=V;s(e,i,n,o),s(t.union(n),o,e,i)}}const d=t=>{null!=t&&(t.serviceObbInIndexSR=null,null!=e?(t.serviceMbsInIndexSR??=new n,t.serviceMbsInIndexSR.copyFrom(e)):t.serviceMbsInIndexSR?.invalidate(),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};d(r.nodeBoundingData),d(r.node),this.invalidateNodeVisibilityCacheInternal(r),t=this._getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeDescriptor(e),s=this._getPage(e);i.childOffset=s.children.length,i.childCount=t.length;for(let n=0;n<t.length;n++){const i=this._makeRefNode(t[n],e);s.children.push(i)}}getNode(e){const t=this._getNodeDescriptor(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes((i,s)=>{(null!=i.node&&i.node.id===e||null!=i.nodeBoundingData&&i.nodeBoundingData.id===e)&&(t=s)}),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 s=i.nodes[I(e,this._pageSize)];return i.children[s.childOffset+t]}_getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[I(e,this._pageSize)]?.parentIndex:null}getParent(e){const t=this._getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeDescriptor(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{null!=e.node&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=p(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeDescriptor(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=v(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeDescriptor(e);null!=t&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeDescriptor(e);if(null==t)return;if(!this._needsNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.nodeBoundingData;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeDescriptor(e),i=t?.node;i&&(i.geometryObbInRenderSR=null,i.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeValid(e){if(!this._needsNodeElevationRange)return!0;const t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){const i=this._getNodeDescriptor(e);if(!i)return!1;const s=i?.node??i?.nodeBoundingData;if(!s)return!1;if(s.elevationRangeValid)return t?.expandElevationRange(s),!0;const n=new h;let o=!1;for(let a=0;a<i.childCount;a++){const t=this.getChildIndex(e,a),i=this._updateElevationRange(t,n);o=o||!i}if(0===i.childCount||o){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(s,e,n)}n.minElevation!==1/0&&n.maxElevation!==-1/0||n.expandElevationRangeValues(0,0);const{minElevation:r,maxElevation:d}=s;return r===n.minElevation&&d===n.maxElevation?(t?.expandElevationRange(s),!0):(i.node?.setElevationRange(n),i.nodeBoundingData?.setElevationRange(n),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(s),!0)}isNodeVisible(e){const t=this._getNodeDescriptor(e);if(null==t)return!0;const i=t.nodeBoundingData;if(null!=i&&!i.serviceMbsInIndexSR)return!0;if(this._isElevationRangeValid(t)&&b(t.visibilityCache,this._visibilityCacheVersion))return y(t.visibilityCache);const s=t.node,n=this._viewportQueries;if(s){const e=n.ensureElevationAgnosticBoundingVolume(s),i=n.isElevationAgnosticBoundingVolumeVisible(e);let o=i;if(this._needsNodeElevationRange&&i){const t=n.getNodeObbInRenderSRIndependentOfElevationOffset(s);null!=t&&(o=n.isObbVisibleIndependentOfElevation(e,t))}if(!o)return t.visibilityCache=N(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=s||null!=i)&&2===t.filterImpact){const e=null!=s?s.serviceMbsInIndexSR:null!=i?i.serviceMbsInIndexSR:null;t.filterImpact=null!=e?this._computeNodeFiltering(e):0}const o=null!=s&&1===t.filterImpact;let r=!(null!=s&&2===s.imModificationImpact)&&!o;if(r){const t=!s||i&&!s.visibilityObbInRenderSR?i??null:s;if(null!=t){this._needsNodeElevationRange&&this._updateElevationRange(e);r=n.isNodeVisible(t)}}return t.visibilityCache=N(r,this._visibilityCacheVersion),r}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeDescriptor(e);return!!(null==t?.node?.geometryObbInRenderSR||this.layerHasModifications&&4===t.node.imModificationImpact)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,s,n){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,d=new Array;for(let a=t.childOffset;a<r;++a){const e=o.children[a],t=this._getNodeDescriptor(e);null!=t?.node&&this.isGeometryVisible(e)&&d.push(t)}s/=d.length;for(const a of d){const e=a.node.index;this._isLoaded(e)||this._isReloading(e)?(n.delta=Math.max(n.delta,i),n.coverage+=s):this._traverseCoverage(e,a,i+1,s,n)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeDescriptor(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(b(t.useAsHole,this._version))return y(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const s=i.delta*i.coverage<=.5;return t.useAsHole=N(s,this._version),s}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.destroy(),this._nodePages.clear(),this._clientNodePage=null,this._layer=null,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._imModificationUncategorized.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=p(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{null!=e&&(e.imModificationImpact=4,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))}),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes(e=>{if(null!=e){e.filterImpact=2;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._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let s=!0;const n=new w,o=new C,r=this._imModificationUncategorized;r.clear();const d=new Set;let a=0;const l=(d,l,h)=>{const u=e=>{this._shouldLoadNode(e)&&e.childCount&&(s=!1)};if(!l){const e=P(d,this._pageSize);let t=this._getNodeLoadPriority(d);return t===1/0&&(t=this._getNodeLoadPriority(h)),f.set(e,Math.max(t,f.get(e)||0)),this._loadingPages.has(e)||this._failedPages.has(e)||(this._missingPagesAndNodes.add(e),++a),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t))}const{node:c,childCount:g}=l;if(this._updateNodeFeatureEstimate(c,o),!c){const e=this._getNodeLoadPriority(d);return this._loadingNodes.has(d)||this._failedNodes.has(d)||(this._missingPagesAndNodes.add(d),f.set(d,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const _=this._getPage(d);if(!this._useNodePages&&0===this._missingPagesAndNodes.size)for(let e=0;e<g;e++){const t=_.children[l.childOffset+e],i=this._getNodeDescriptor(t);null!=i&&!i.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(f.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(c.failed||c.resources.isEmpty)return void u(c);if(this._isLoaded(d)){if(n.known+=c.memory,++n.knownNodes,u(c),this._shouldLoadNode(c)||(n.unremoved+=c.memory),this._needsUpdate(c)){const e=this._getNodeLoadPriority(d);f.set(d,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(d)}return}if(c.memory&&(n.known+=c.memory,++n.knownNodes),!this._shouldLoadNode(c))return void(this._isReloading(d)&&this._updates.remove.push(d));if(u(c),c.memory?(n.missing+=c.memory,n.known+=c.memory,++n.knownNodes):++n.missingNodes,e.includes(c.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(d)),void(this._updates.cancel=this._updates.cancel.filter(e=>e!==c.index));if(!t.done&&this._enable(c))return void t.madeProgress();const m=this._getNodeLoadPriority(d);f.set(d,m),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,m),this._updates.add.push(d),this.layerHasModifications&&i&&null!=c&&4===c.imModificationImpact&&r.push(d)};this.traverseVisible(l,d),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(d,a),this._handleModifications(i,r),this._updateUnloadedMemoryEstimate(n),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=s,this._updates.add.filterInPlace(e=>f.get(e)>=this._maxUnloadedPrio).sort((e,t)=>f.get(e)-f.get(t)),this._updates.update.sort((e,t)=>f.get(e)-f.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,f.clear()}_updateUnloadedMemoryEstimate(e){this._unloadedMemoryEstimate=e.missing-e.unremoved,e.knownNodes>3&&e.missingNodes>0&&(this._unloadedMemoryEstimate+=e.known/e.knownNodes*e.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate)}resetUpdateState(e){this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),f.clear()}_prioritizeMissingNodesAndPages(){const e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>f.get(e)-f.get(t)),e.length>0&&(this._maxUnloadedPrio=f.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&0!==this._updates.add.length&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{const t=this._getNodeDescriptor(e),i=null==t?.node||2!==t.node.imModificationImpact;return i||this.invalidateNodeVisibilityCache(e),i}))}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,o=i,r=10;for(;r--;){const i=new C;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===r)break;o=s,s=.5*(s+n)}else n=s,s=.5*(s+o)}return this._version=p(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;const i=e.size,s=this._nodePages,n=s.size+this._loadingPages.size+t;if(n>O&&n>i){const t=new Array;for(const[i,n]of s)0!==n.numNodesWithLoadedChildren||e.has(i)||t.push([n.lastTraversed,i]);t.sort((e,t)=>e[0]-t[0]).some(e=>{const t=e[1];return this._deleteNodePage(t),s.size<=O})}}_updateFeatureEstimate(e,t){this._version=p(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,i)=>this._updateNodeFeatureEstimate(i?.node,t))}_updateNodeFeatureEstimate(e,t){null!=e&&!e.failed&&this._shouldLoadNode(e)&&(null!=e.numFeatures?(t.numFeatures+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.numFeatures;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.numFeatures/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._prioritizedMissingNodeAndPageIds,this._missingPagesAndNodes)}prefetch(){const e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>f.get(e)-f.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(0===e.length||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){const i=e[e.length-1];e.length--,t.delete(i),this._useNodePages&&i>=0?this._loadPage(i):this._loadNode(i)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.size>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.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;const t=e.index,i=this._getNodeDescriptor(t);if(!i)return null;let s=i?.traversalState;if(s&&b(s.version,this._version))return s;const n=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this._getParentIndex(t);if(null!=e){const t=this._getNodeDescriptor(e),i=t?.traversalState;r=!!i&&n>i.lodLevel}else r=n>0}else r=0===e.childCount;return s?(s.lodLevel=n,s.isChosen=r,s.version=N(!0,this._version),s):(s=new d(o,r,n,N(!0,this._version)),i.traversalState=s,s)}_loadNode(e){if(this._loadingNodes.has(e))return void this._logger.error(`Node[${e}] already loading`);this._loadingNodes.add(e);const i=this._getNodeDescriptor(e);if(i.node)return void this._logger.error(`Node[${e}] already in descriptor`);const s=i.nodeBoundingData;if(null==s)return void this._failedNodes.add(e);const n=s.id,o=this.urlPrefix+n,r=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.size&&0===this._loadingNodes.size&&this.requestUpdate()};(e>=0?this._requester.request(o,"json"):this._clientNodeLoader.loadNodeJSON(n)).then(t=>{r();const i=this._validateNode(n,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const s=this._addNode(i,e);this.nodeTraversalState(s)}).catch(i=>{r(),t(i)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+o),this._failedNodes.add(e))})}_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 s=t.attributeData,r=this._layer.attributeStorageInfo;null==s||Array.isArray(s)&&!s.some((e,t)=>e.href!==`./attributes/${r?.[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 d=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:void 0,a=1===t.featureData?.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,h=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;const s=new o(`${t.id}`,new n(t.mbs));return s.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty("obb")&&t.obb?u.fromJSON(t.obb):null,s.visibilityObbInRenderSR=this._computeVisibilityObb(s),s},c=Array.isArray(t.children)?t.children.map(h).filter(e=>null!=e):null,g=t.featureData?.length??!1,_=!0===t.isEmpty;return new l(e,new n(t.mbs),d,"string"==typeof t.version?t.version:null,{isEmpty:!g&&_,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},c,Array.isArray(t.lodSelection)?t.lodSelection:null,a)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{null!=e.node&&(e.node.failed=!1)})}_getNodeLoadPriority(e){const t=this._getNodeDescriptor(e),i=this._getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._getNodeLoadPriority(i);let s=0;if(t.node&&null!=i){const e=this._getNodeDescriptor(i);s=e.traversalState?.lodLevel??0}const n=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+s)+s*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+n}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;null!=t;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){const i=this._getNodeDescriptor(this._rootIndex);null!=i?this._traverseVisible(this._rootIndex,null,i,e,t):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,s,n){const o=P(e,this._pageSize);if(n&&n.add(o),i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&s(e,i,t));if(!this.isNodeVisible(e))return;if(s(e,i,t),null==i.node)return;const r=this.nodeTraversalState(i.node);if(r?.nodeHasLOD&&r.lodLevel===this._maxLodLevel)return;const d=this._getPageFromPageIndex(o);for(let a=0;a<i.childCount;a++){const t=d.children[i.childOffset+a],o=this._getNodeDescriptor(t);if(o)this._traverseVisible(t,e,o,s,n);else{if(n){const e=P(t,this._pageSize);n.add(e)}s(t,null,e)}}}traverse(e,t){for(const i of this.traverseValues(e,t));}*traverseValues(e,t){t(e)&&(yield e,yield*this._traverseDescendantValues(e,t))}*_traverseDescendantValues(e,t){const i=e.index,s=this._pageSize,n=P(i,s),o=this._getPageFromPageIndex(n);if(null==o)return;const r=this._frameNumber,d=this._nodePages,a=I(i,s),l=o.nodes[a],h=l.childCount;if(o.lastTraversed=r,0===h)return;const u=new Array,c=new Array;let g=0;{const{childOffset:e,childCount:t}=l,{children:i}=o;c.length=2**Math.ceil(Math.log2(g+t));for(let s=e;s<e+t;++s){const e=i[s];e>=0?(c[g]=e,++g):u.push(e)}}if(u.length>0){const e=this._clientNodePage;if(e){const i=e.children;let s=0;for(;s<u.length;){const n=u[s];++s;const o=-n-1,r=e.nodes[o],d=r.node;if(!d||!t(d))continue;yield d;const{childCount:a}=r;if(0===a)continue;const{childOffset:l}=r,h=l+a;for(let e=l;e<h;++e)u.push(i[e])}}}if(g>0){let e=0;if(s>0){let i=n*s,a=o,l=a.nodes;for(;e<g;){const n=c[e];let o;if(++e,i<=n&&n<i+s)o=a;else{const e=n/s|0,t=d.get(e);if(void 0===t)continue;o=t,o.lastTraversed=r,a=o,l=a.nodes,i=s*e}const h=l[n-i],u=h.node;if(null==u||!1===t(u))continue;yield u;const{childCount:_}=h;if(0===_)continue;const f=g+_;for(c.length<f&&(c.length=2**Math.ceil(Math.log2(g+_)));c.length<g+_;)c.length+=c.length;const m=o.children,{childOffset:v}=h,p=v+_;for(let e=v;e<p;++e)c[g]=m[e],++g}}else{const i=d.get(0);if(i)for(;e<g;){const s=c[e++],n=i.nodes[s],o=n.node;if(!o||!t(o))continue;yield o;const{childCount:r}=n;if(0===r)continue;c.length=Math.max(c.length,2**Math.ceil(Math.log2(g+r)));const d=i.children,{childOffset:a}=n,l=a+r;for(let e=a;e<l;++e)c[g]=d[e],++g}}}}traverseDescendants(e,t){for(const i of this._traverseDescendantValues(e,t));}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,s=e+t;i.childrenLoaded=s;const n=0===e?1:0===s?-1:0,o=i.index;if(0!==n){this._getPage(o).numNodesWithLoadedChildren+=n}i=this.getParent(o)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this._needsNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"relative-to-scene"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_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(const[t,i]of this._nodePages){const s=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(P(e,this._pageSize)));for(const[i,s]of e)if(0!==s.numNodesWithLoadedChildren||t.has(i))for(const e of s.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){if(!this._nodePages.has(e))return void this._logger.error(`Destroying non-existent page ${e}`);const t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const f=new Map;class m{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=[]}destroy(){this.update.prune(),this.add.prune(),this.remove.prune(),this.cancel.length=0}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function v(e){return a(e,-2)}function p(e){return a(e,2)}function N(e,t){return t+(e?1:0)}function b(e,t){return(-2&e)===t}function y(e){return!(1&~e)}function P(e,t){return e<0?-1:t>0?e/t|0:0}function I(e,t){return e<0?-e-1:0===t?e:e%t}function x(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const S=[["maxScreenThreshold",1],["screenSpaceRelative",2],["removedFeatureDiameter",3],["distanceRangeFromDefaultCamera",4]];function R(e){if(e)for(let t=0;t<e.length;t++)for(const i of S)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:0,maxError:0}}class w{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class C{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function E(e){return Math.sqrt(e*(4/Math.PI))}const M=new n,D=new n,V=new n,A=i(),O=has("esri-mobile")?100:300;export{_ as I3SIndex,R as selectErrorMetric};
|
|
2
|
+
import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as s}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as n}from"../../../../geometry/support/sphere.js";import{NodeBoundingData as o,Node as r,NodeTraversalState as d}from"./I3SNode.js";import{addWraparound as a}from"./I3SUtil.js";import{ValidatedNode as l}from"./ValidatedNode.js";import{ElevationRange as h}from"../../support/ElevationRange.js";import{Obb as u}from"../../support/orientedBoundingBox.js";class c{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this._boundingData=s,this.node=n,this.parentIndex=-1,this.useAsHole=0,this.filterImpact=2,this.traversalState=null}get nodeBoundingData(){return this._boundingData}destroy(){this._boundingData=null,this.node=null,this.traversalState=null}invalidateBounds(){this.node?.invalidateServiceBVsInRenderSR(),this.nodeBoundingData?.invalidateServiceBVsInRenderSR()}}class g{constructor(e=new Array,t=new Array){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(const e of this._nodeDescriptors)e.destroy();this._nodeDescriptors.length=0,this._children.length=0}get nodes(){return this._nodeDescriptors}addNode(e){return this._nodeDescriptors.push(e),this._nodeDescriptors.length-1}setNodes(e,t){this._nodeDescriptors=e,this._children=t}get children(){return this._children}}class _{get _useNodePages(){return this._pageSize>0}constructor(t,i,s,n,r,d,a,l,h,u,c,_,f,v,N){if(this.viewingMode=t,this._layer=i,this._requester=n,this._clientNodeLoader=r,this._viewportQueries=d,this._logger=a,this.holeFilling=l,this._isLoaded=h,this._isReloading=u,this._shouldLoadNode=c,this._enable=_,this._needsUpdate=f,this._computeVisibilityObb=v,this._computeNodeFiltering=N,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=0,this._lodConversion=e=>e,this._isEditable=!1,this.urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=p(0),this._visibilityCacheVersion=p(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._progressiveLoadPenaltyWeight=10,this._missingPagesAndNodes=new Set,this._prioritizedMissingNodeAndPageIds=new Array,this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=new Array,this._updates=new m(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this._pageQueue=new Array,this._newPages=new Array,this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=null!=i.associatedLayer?.infoFor3D,i.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${i.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,"page"===s.type){const e=s.rootPage;switch(this.urlPrefix=s.urlPrefix,this._pageSize=s.pageSize,s.lodMetric){case"maxScreenThreshold":this._lodMetric=1;break;case"maxScreenThresholdSQ":this._lodMetric=1,this._lodConversion=E}if(this._isEditable){this._rootIndex=-1;const t=I(s.rootIndex,s.pageSize),i=e.nodes[t],n={nodes:[{index:this._rootIndex,children:[s.rootIndex],mesh:void 0,obb:i.obb,lodThreshold:i.lodThreshold}]};this._addPage(P(this._rootIndex,this._pageSize),n),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=s.rootIndex;this._addPage(P(s.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if("node"===s.type){this.urlPrefix=s.urlPrefix;const e=new g;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new g;const e={id:"-1",version:null,mbs:s.rootNode.mbs,obb:s.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:s.rootNode.mbs,obb:s.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new o(e.id),-1);const t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new o(s.rootNode.id),-1);const t=this._validateNode(s.rootNode.id,s.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){const i=-1,s=new o(e,t),n=this._makeClientRefNode(s,i);return this._linkChildToParentNode(i,n),this.requestUpdate(),n}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e))return void this._logger.error(`Requested load page [${e}] already loaded`);if(this._loadingPages.has(e))return void this._logger.error(`Requested load page [${e}] already loading`);this._loadingPages.add(e);const i=this.urlPrefix+e;this._requester.request(i,"json").then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(i=>{this._loadingPages.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._loadingPages.delete(t),e.madeProgress(),this._needsNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this._needsNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());e?.nodes.forEach(e=>{let t=e.parentIndex;for(;null!=t&&t!==this._rootIndex;){const e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}}_addPage(e,t){if(this._nodePages.has(e))return void this._logger.error(`Page[${e}] reloaded`);const i=[],s=[],o=t.nodes.map((t,o)=>{const d=i.length,a=t.children?t.children.length:0;s.push(this._rootIndex);for(let e=0;e<a;e++)i.push(t.children[e]);const l=`${t.index}`,h=u.fromJSON(t.obb),g=new n(h.getCenter(A),h.radius),_=t.mesh?.attribute,f=t.mesh?.geometry,m=t.mesh?.material,p={hasSharedResource:!1,isEmpty:null==f,attributes:null!=_?.resource?`${_.resource}`:void 0,geometry:null!=f?.resource?`${f.resource}`:void 0,texture:null!=m?.resource?`${m.resource}`:void 0,geometryDefinition:f?f.definition:-1,materialDefinition:m?m.definition:-1},N=new r(l,x(o,e,this._pageSize),g,a,0,p,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),f?.featureCount??null,h);return N.visibilityObbInRenderSR=this._computeVisibilityObb(N),N.vertexCount=f?f.vertexCount:0,new c(d,a,v(this._visibilityCacheVersion),null,N)}),d=new g(o,i);-1===e?this._clientNodePage=d:this._nodePages.set(e,d)}_updateParentsAndLevel(){const e=new Array,t=(t,i,s)=>{const n=this._getPage(t);if(null!=n){const o=I(t,this._pageSize),r=n.nodes[o];r.parentIndex=null!=i?i:-1;const d=r.node;null!=d&&(d.level=s,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),s=this.getNode(i);if(null!=s)for(let e=0;e<s.childCount;e++){t(this.getChildIndex(s.index,e),i,s.level+1),this._maxLevel=Math.max(this._maxLevel,s.level+1)}}}_getPage(e){const t=P(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[I(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),s=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?s+1:s);const{lodMetric:n,maxError:o}=R(e.lodSelection),d=this._getNodeDescriptor(t);if(null!=d.node)return this._logger.error(`Loaded node[${t}] already in descriptor`),d.node;const a=new r(e.id,t,e.mbs,d.childCount,s,e.resources,e.version,n,o,e.numFeatures,e.obb?u.fromJSON(e.obb):null);d.node=a,a.visibilityObbInRenderSR=this._computeVisibilityObb(a);const l=d.nodeBoundingData;return null!=l&&(null==l.serviceMbsInIndexSR&&(l.serviceMbsInIndexSR=e.mbs),a.shareServiceBVsInRenderSRWith(l),l.visibilityObbInRenderSR=a.visibilityObbInRenderSR),a}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const s=i.nodes.length,n=new c(0,0,v(this._visibilityCacheVersion),e,null);return i.addNode(n),n.parentIndex=t,e.invalidateServiceBVsInRenderSR(),s}_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 s=-(i.nodes.length+1),n=new c(0,0,v(this._visibilityCacheVersion),e,null);return i.addNode(n),n.parentIndex=t,e.invalidateServiceBVsInRenderSR(),s}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const s=I(e,this._pageSize),n=I(t,this._pageSize),o=i.nodes[s],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const d=1;o.childCount+=d,null!=o.node&&(o.node.childCount+=d);for(const a of i.nodes)a.childOffset>r&&(a.childOffset+=d);i.nodes[n].parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const s=this._clientNodePage;if(null==s)return;const n=this._getParentIndex(e);if(null==n)return;const o=new Set,r=new Map,d=e=>{const i=I(e,this._pageSize),n=s.nodes[i];if(n.childCount>0)for(let t=n.childOffset;t<n.childOffset+n.childCount;++t)d(s.children[t]);const r=n.node?.id??n.nodeBoundingData?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(n)};d(e);const a=s.nodes,l=s.children,h=s.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,s=x(g,-1,this._pageSize),n=x(t,-1,this._pageSize);if(e.node&&(e.node.index=n),h[g]=n,u.push(e),s!==n){const t=e.node?.id??e.nodeBoundingData?.id;if(null==t)throw new Error("Node has no id");i(t,s,n),r.set(s,n)}}for(let g=0;g<u.length;++g){const e=x(g,-1,this._pageSize),t=u[g],i=c.length;for(let s=t.childOffset;s<t.childOffset+t.childCount;++s){const t=l[s];if(t>=0)c.push(t);else{const i=I(t,this._pageSize),s=a[i];if(o.has(s))continue;const n=h[i];c.push(n),s.parentIndex=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}s.setNodes(u,c),this._updateParentBoundingInformation(h[I(n,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,o=this._clientNodeLoader.renderSR,r=this._getNodeDescriptor(t);if(null==r)return;for(let n=0;n<r.childCount;n++){const r=this.getChildIndex(t,n),d=this._getNodeDescriptor(r),a=null!=d?d.nodeBoundingData||d.node:null;if(null!=a?.serviceMbsInIndexSR&&a.serviceMbsInIndexSR.radius>0)if(null==e)e=M.copyFrom(a.serviceMbsInIndexSR);else{const t=D;s(a.serviceMbsInIndexSR,i,t,o);const n=V;s(e,i,n,o),s(t.union(n),o,e,i)}}const d=t=>{null!=t&&(t.serviceObbInIndexSR=null,null!=e?(t.serviceMbsInIndexSR??=new n,t.serviceMbsInIndexSR.copyFrom(e)):t.serviceMbsInIndexSR?.invalidate(),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};d(r.nodeBoundingData),d(r.node),this.invalidateNodeVisibilityCacheInternal(r),t=this._getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeDescriptor(e),s=this._getPage(e);i.childOffset=s.children.length,i.childCount=t.length;for(let n=0;n<t.length;n++){const i=this._makeRefNode(t[n],e);s.children.push(i)}}getNode(e){const t=this._getNodeDescriptor(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes((i,s)=>{(null!=i.node&&i.node.id===e||null!=i.nodeBoundingData&&i.nodeBoundingData.id===e)&&(t=s)}),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 s=i.nodes[I(e,this._pageSize)];return i.children[s.childOffset+t]}_getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[I(e,this._pageSize)]?.parentIndex:null}getParent(e){const t=this._getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeDescriptor(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{null!=e.node&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=p(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeDescriptor(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=v(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeDescriptor(e);null!=t&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeDescriptor(e);if(null==t)return;if(!this._needsNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.nodeBoundingData;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeDescriptor(e),i=t?.node;i&&(i.geometryObbInRenderSR=null,i.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeValid(e){if(!this._needsNodeElevationRange)return!0;const t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){const i=this._getNodeDescriptor(e);if(!i)return!1;const s=i?.node??i?.nodeBoundingData;if(!s)return!1;if(s.elevationRangeValid)return t?.expandElevationRange(s),!0;const n=new h;let o=!1;for(let a=0;a<i.childCount;a++){const t=this.getChildIndex(e,a),i=this._updateElevationRange(t,n);o=o||!i}if(0===i.childCount||o){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(s,e,n)}n.minElevation!==1/0&&n.maxElevation!==-1/0||n.expandElevationRangeValues(0,0);const{minElevation:r,maxElevation:d}=s;return r===n.minElevation&&d===n.maxElevation?(t?.expandElevationRange(s),!0):(i.node?.setElevationRange(n),i.nodeBoundingData?.setElevationRange(n),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(s),!0)}isNodeVisible(e){const t=this._getNodeDescriptor(e);if(null==t)return!0;const i=t.nodeBoundingData;if(null!=i&&!i.serviceMbsInIndexSR)return!0;if(this._isElevationRangeValid(t)&&b(t.visibilityCache,this._visibilityCacheVersion))return y(t.visibilityCache);const s=t.node,n=this._viewportQueries;if(s){const e=n.ensureElevationAgnosticBoundingVolume(s),i=n.isElevationAgnosticBoundingVolumeVisible(e);let o=i;if(this._needsNodeElevationRange&&i){const t=n.getNodeObbInRenderSRIndependentOfElevationOffset(s);null!=t&&(o=n.isObbVisibleIndependentOfElevation(e,t))}if(!o)return t.visibilityCache=N(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=s||null!=i)&&2===t.filterImpact){const e=null!=s?s.serviceMbsInIndexSR:null!=i?i.serviceMbsInIndexSR:null;t.filterImpact=null!=e?this._computeNodeFiltering(e):0}const o=null!=s&&1===t.filterImpact;let r=!(null!=s&&2===s.imModificationImpact)&&!o;if(r){const t=!s||i&&!s.visibilityObbInRenderSR?i??null:s;if(null!=t){this._needsNodeElevationRange&&this._updateElevationRange(e);r=n.isNodeVisible(t)}}return t.visibilityCache=N(r,this._visibilityCacheVersion),r}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeDescriptor(e);return!!(null==t?.node?.geometryObbInRenderSR||this.layerHasModifications&&4===t.node.imModificationImpact)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,s,n){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,d=new Array;for(let a=t.childOffset;a<r;++a){const e=o.children[a],t=this._getNodeDescriptor(e);null!=t?.node&&this.isGeometryVisible(e)&&d.push(t)}s/=d.length;for(const a of d){const e=a.node.index;this._isLoaded(e)||this._isReloading(e)?(n.delta=Math.max(n.delta,i),n.coverage+=s):this._traverseCoverage(e,a,i+1,s,n)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeDescriptor(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(b(t.useAsHole,this._version))return y(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const s=i.delta*i.coverage<=.5;return t.useAsHole=N(s,this._version),s}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.destroy(),this._nodePages.clear(),this._clientNodePage=null,this._layer=null,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._imModificationUncategorized.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=p(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{null!=e&&(e.imModificationImpact=4,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))}),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes(e=>{if(null!=e){e.filterImpact=2;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._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let s=!0;const n=new w,o=new C,r=this._imModificationUncategorized;r.clear();const d=new Set;let a=0;const l=(d,l,h)=>{const u=e=>{this._shouldLoadNode(e)&&e.childCount&&(s=!1)};if(!l){const e=P(d,this._pageSize);let t=this._getNodeLoadPriority(d);return t===1/0&&(t=this._getNodeLoadPriority(h)),f.set(e,Math.max(t,f.get(e)||0)),this._loadingPages.has(e)||this._failedPages.has(e)||(this._missingPagesAndNodes.add(e),++a),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t))}const{node:c,childCount:g}=l;if(this._updateNodeFeatureEstimate(c,o),!c){const e=this._getNodeLoadPriority(d);return this._loadingNodes.has(d)||this._failedNodes.has(d)||(this._missingPagesAndNodes.add(d),f.set(d,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const _=this._getPage(d);if(!this._useNodePages&&0===this._missingPagesAndNodes.size)for(let e=0;e<g;e++){const t=_.children[l.childOffset+e],i=this._getNodeDescriptor(t);null!=i&&!i.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(f.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(c.failed||c.resources.isEmpty)return void u(c);if(this._isLoaded(d)){if(n.known+=c.memory,++n.knownNodes,u(c),this._shouldLoadNode(c)||(n.unremoved+=c.memory),this._needsUpdate(c)){const e=this._getNodeLoadPriority(d);f.set(d,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(d)}return}if(c.memory&&(n.known+=c.memory,++n.knownNodes),!this._shouldLoadNode(c))return void(this._isReloading(d)&&this._updates.remove.push(d));if(u(c),c.memory?(n.missing+=c.memory,n.known+=c.memory,++n.knownNodes):++n.missingNodes,e.includes(c.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(d)),void(this._updates.cancel=this._updates.cancel.filter(e=>e!==c.index));if(!t.done&&this._enable(c))return void t.madeProgress();const m=this._getNodeLoadPriority(d);f.set(d,m),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,m),this._updates.add.push(d),this.layerHasModifications&&i&&null!=c&&4===c.imModificationImpact&&r.push(d)};this.traverseVisible(l,d),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(d,a),this._handleModifications(i,r),this._updateUnloadedMemoryEstimate(n),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=s,this._updates.add.filterInPlace(e=>f.get(e)>=this._maxUnloadedPrio).sort((e,t)=>f.get(e)-f.get(t)),this._updates.update.sort((e,t)=>f.get(e)-f.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,f.clear()}_updateUnloadedMemoryEstimate(e){this._unloadedMemoryEstimate=e.missing-e.unremoved,e.knownNodes>3&&e.missingNodes>0&&(this._unloadedMemoryEstimate+=e.known/e.knownNodes*e.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate)}resetUpdateState(e){this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),f.clear()}_prioritizeMissingNodesAndPages(){const e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>f.get(e)-f.get(t)),e.length>0&&(this._maxUnloadedPrio=f.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&0!==this._updates.add.length&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{const t=this._getNodeDescriptor(e),i=null==t?.node||2!==t.node.imModificationImpact;return i||this.invalidateNodeVisibilityCache(e),i}))}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,o=i,r=10;for(;r--;){const i=new C;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===r)break;o=s,s=.5*(s+n)}else n=s,s=.5*(s+o)}return this._version=p(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;const i=e.size,s=this._nodePages,n=s.size+this._loadingPages.size+t;if(n>O&&n>i){const t=new Array;for(const[i,n]of s)0!==n.numNodesWithLoadedChildren||e.has(i)||t.push([n.lastTraversed,i]);t.sort((e,t)=>e[0]-t[0]).some(e=>{const t=e[1];return this._deleteNodePage(t),s.size<=O})}}_updateFeatureEstimate(e,t){this._version=p(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,i)=>this._updateNodeFeatureEstimate(i?.node,t))}_updateNodeFeatureEstimate(e,t){null!=e&&!e.failed&&this._shouldLoadNode(e)&&(null!=e.numFeatures?(t.numFeatures+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.numFeatures;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.numFeatures/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._prioritizedMissingNodeAndPageIds,this._missingPagesAndNodes)}prefetch(){const e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>f.get(e)-f.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(0===e.length||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){const i=e[e.length-1];e.length--,t.delete(i),this._useNodePages&&i>=0?this._loadPage(i):this._loadNode(i)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.size>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.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;const t=e.index,i=this._getNodeDescriptor(t);if(!i)return null;let s=i?.traversalState;if(s&&b(s.version,this._version))return s;const n=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this._getParentIndex(t);if(null!=e){const t=this._getNodeDescriptor(e),i=t?.traversalState;r=!!i&&n>i.lodLevel}else r=n>0}else r=0===e.childCount;return s?(s.lodLevel=n,s.isChosen=r,s.version=N(!0,this._version),s):(s=new d(o,r,n,N(!0,this._version)),i.traversalState=s,s)}_loadNode(e){if(this._loadingNodes.has(e))return void this._logger.error(`Node[${e}] already loading`);this._loadingNodes.add(e);const i=this._getNodeDescriptor(e);if(i.node)return void this._logger.error(`Node[${e}] already in descriptor`);const s=i.nodeBoundingData;if(null==s)return void this._failedNodes.add(e);const n=s.id,o=this.urlPrefix+n,r=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.size&&0===this._loadingNodes.size&&this.requestUpdate()};(e>=0?this._requester.request(o,"json"):this._clientNodeLoader.loadNodeJSON(n)).then(t=>{r();const i=this._validateNode(n,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const s=this._addNode(i,e);this.nodeTraversalState(s)}).catch(i=>{r(),t(i)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+o),this._failedNodes.add(e))})}_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 s=t.attributeData,r=this._layer.attributeStorageInfo;null==s||Array.isArray(s)&&!s.some((e,t)=>e.href!==`./attributes/${r?.[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 d=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:void 0,a=1===t.featureData?.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,h=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;const s=new o(`${t.id}`,new n(t.mbs));return s.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty("obb")&&t.obb?u.fromJSON(t.obb):null,s.visibilityObbInRenderSR=this._computeVisibilityObb(s),s},c=Array.isArray(t.children)?t.children.map(h).filter(e=>null!=e):null,g=t.featureData?.length??!1,_=!0===t.isEmpty;return new l(e,new n(t.mbs),d,"string"==typeof t.version?t.version:null,{isEmpty:!g&&_,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},c,Array.isArray(t.lodSelection)?t.lodSelection:null,a)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{null!=e.node&&(e.node.failed=!1)})}_getNodeLoadPriority(e){const t=this._getNodeDescriptor(e),i=this._getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._getNodeLoadPriority(i);let s=0;if(t.node&&null!=i){const e=this._getNodeDescriptor(i);s=e.traversalState?.lodLevel??0}const n=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+s)+s*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+n}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;null!=t;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){const i=this._getNodeDescriptor(this._rootIndex);null!=i?this._traverseVisible(this._rootIndex,null,i,e,t):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,s,n){const o=P(e,this._pageSize);if(n&&n.add(o),i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&s(e,i,t));if(!this.isNodeVisible(e))return;if(s(e,i,t),null==i.node)return;const r=this.nodeTraversalState(i.node);if(r?.nodeHasLOD&&r.lodLevel===this._maxLodLevel)return;const d=this._getPageFromPageIndex(o);for(let a=0;a<i.childCount;a++){const t=d.children[i.childOffset+a],o=this._getNodeDescriptor(t);if(o)this._traverseVisible(t,e,o,s,n);else{if(n){const e=P(t,this._pageSize);n.add(e)}s(t,null,e)}}}traverse(e,t){for(const i of this.traverseValues(e,t));}*traverseValues(e,t){t(e)&&(yield e,yield*this._traverseDescendantValues(e,t))}*_traverseDescendantValues(e,t){const i=e.index,s=this._pageSize,n=P(i,s),o=this._getPageFromPageIndex(n);if(null==o)return;const r=this._frameNumber,d=this._nodePages,a=I(i,s),l=o.nodes[a],h=l.childCount;if(o.lastTraversed=r,0===h)return;const u=new Array,c=new Array;let g=0;{const{childOffset:e,childCount:t}=l,{children:i}=o;c.length=2**Math.ceil(Math.log2(g+t));for(let s=e;s<e+t;++s){const e=i[s];e>=0?(c[g]=e,++g):u.push(e)}}if(u.length>0){const e=this._clientNodePage;if(e){const i=e.children;let s=0;for(;s<u.length;){const n=u[s];++s;const o=-n-1,r=e.nodes[o],d=r.node;if(!d||!t(d))continue;yield d;const{childCount:a}=r;if(0===a)continue;const{childOffset:l}=r,h=l+a;for(let e=l;e<h;++e)u.push(i[e])}}}if(g>0){let e=0;if(s>0){let i=n*s,a=o,l=a.nodes;for(;e<g;){const n=c[e];let o;if(++e,i<=n&&n<i+s)o=a;else{const e=n/s|0,t=d.get(e);if(void 0===t)continue;o=t,o.lastTraversed=r,a=o,l=a.nodes,i=s*e}const h=l[n-i],u=h?.node;if(null==u||!1===t(u))continue;if(yield u,null==h.node)continue;const{childCount:_}=h;if(0===_)continue;const f=g+_;for(c.length<f&&(c.length=2**Math.ceil(Math.log2(g+_)));c.length<g+_;)c.length+=c.length;const m=o.children,{childOffset:v}=h,p=v+_;for(let e=v;e<p;++e)c[g]=m[e],++g}}else{const i=d.get(0);if(i)for(;e<g;){const s=c[e++],n=i.nodes[s],o=n.node;if(!o||!t(o))continue;yield o;const{childCount:r}=n;if(0===r)continue;c.length=Math.max(c.length,2**Math.ceil(Math.log2(g+r)));const d=i.children,{childOffset:a}=n,l=a+r;for(let e=a;e<l;++e)c[g]=d[e],++g}}}}traverseDescendants(e,t){for(const i of this._traverseDescendantValues(e,t));}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,s=e+t;i.childrenLoaded=s;const n=0===e?1:0===s?-1:0,o=i.index;if(0!==n){this._getPage(o).numNodesWithLoadedChildren+=n}i=this.getParent(o)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this._needsNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"relative-to-scene"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_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(const[t,i]of this._nodePages){const s=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(P(e,this._pageSize)));for(const[i,s]of e)if(0!==s.numNodesWithLoadedChildren||t.has(i))for(const e of s.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){if(!this._nodePages.has(e))return void this._logger.error(`Destroying non-existent page ${e}`);const t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const f=new Map;class m{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=[]}destroy(){this.update.prune(),this.add.prune(),this.remove.prune(),this.cancel.length=0}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function v(e){return a(e,-2)}function p(e){return a(e,2)}function N(e,t){return t+(e?1:0)}function b(e,t){return(-2&e)===t}function y(e){return!(1&~e)}function P(e,t){return e<0?-1:t>0?e/t|0:0}function I(e,t){return e<0?-e-1:0===t?e:e%t}function x(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const S=[["maxScreenThreshold",1],["screenSpaceRelative",2],["removedFeatureDiameter",3],["distanceRangeFromDefaultCamera",4]];function R(e){if(e)for(let t=0;t<e.length;t++)for(const i of S)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:0,maxError:0}}class w{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class C{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function E(e){return Math.sqrt(e*(4/Math.PI))}const M=new n,D=new n,V=new n,A=i(),O=has("esri-mobile")?100:300;export{_ as I3SIndex,R as selectErrorMetric};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../../core/maybe.js";import i from"../../../../core/PooledArray.js";import{createScreenPointArray as s}from"../../../../core/screenUtils.js";import{property as r,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{subtract as o,length as a,scale as l,negate as h,dot as c,squaredLength as d,distance as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as m}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as _,offset as f,contains as P,containsPoint as x,set as b,positiveInfinity as S,equals as w}from"../../../../geometry/support/aaBoundingBox.js";import{create as R}from"../../../../geometry/support/plane.js";import{fromPoints as y}from"../../../../geometry/support/ray.js";import{Sphere as z}from"../../../../geometry/support/sphere.js";import{PclTarget as v}from"./Intersector.js";import{PointCloudHighlights as j}from"./PointCloudHighlights.js";import{isColor as q,isHighlight as F,isDepth as H}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as O}from"../../webgl-engine/effects/RenderPlugin.js";import{IntersectorResultRay as A}from"../../webgl-engine/lib/IntersectorResult.js";import{screenPolygonIntersectsCircle as E}from"../../webgl-engine/lib/screenPolygonOverlapUtils.js";import{VertexArrayObject as I}from"../../webgl-engine/lib/VertexArrayObject.js";import{P as B,g as M}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as D,positionsLayout as V,colorsLayout as N}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as T}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{PrimitiveType as C}from"../../../webgl/enums.js";import{VertexBuffer as U}from"../../../webgl/VertexBuffer.js";let W=class extends O{constructor(e){super(e),this.type=6,this.isGround=!1,this._passParameters=new B,this._highlights=new j({forEachNode:e=>this.forEachNode(e),addHighlights:(e,t,i)=>this._addHighlights(e,t,i),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.produces=new Map([[2,e=>q(e)||F(e)&&!this._highlights.empty],[3,e=>H(e)]]),this.point=g(),this.intersectionRayDir=g(),this.intersectionPlane=R(),this.nodeOriginOffset=g(),this.nodeBoundingBox=_(),this.layerViewUid="",this._slicePlaneEnabled=!1,this._configuration=new T,this._nodes=new i,this._highlightsInOrder=null}destroy(){this._nodes.prune()}hasHighlight(e){return this._highlights.has(e)}initializeRenderContext(e){this._context=e,e.requestRender()}uninitializeRenderContext(){}intersectRay(e,t,i,s){const{point:r,intersectionRayDir:n,nodeOriginOffset:u,intersectionPlane:p,layerViewUid:b,nodeBoundingBox:S}=this,w=y(i,s),R=this._passParameters,j=e.camera.perScreenPixelRatio/2,q=e.camera.near;o(n,s,i);const F=1/a(n);l(n,n,F);const H=g();h(H,n),m(p,n[0],n[1],n[2],-c(n,i));const O=new Y,E=new Y,I=new Array,B=_(R.clipBox);f(B,-i[0],-i[1],-i[2],B);const M=new J;this._nodes.forAll(a=>{const{isLeaf:l,coordinates:h}=a,g=a.splatSize*R.scaleFactor;let{min:m,max:_}=a.obb.signedDistanceRangePlane(p);m-=L(g,m+q,R,j,l),_-=L(g,_+q,R,j,l);const y=_<0,v=null!=O.dist&&null!=E.dist&&O.dist<m*F&&E.dist>_*F;if(y||v)return;const A=G(g,_+q,R,j,l);if(!new z(a.obb.getCenter($),a.obb.radius+A).intersectRay(w))return;if(!a.obb.intersectRay(i,n,A))return;const D=A*A;a.obb.toAaBoundingBox(S),f(S,-i[0],-i[1],-i[2],S);const V=!P(B,S);o(u,a.origin,i);const N=h.length/3;for(let o=0;o<N;o++){const p=3*o;if(r[0]=u[0]+h[p],r[1]=u[1]+h[p+1],r[2]=u[2]+h[p+2],V&&!x(B,r))continue;const m=c(r,n),_=m*m,f=d(r)-_;if(f>D)continue;const{distance:P,radius:S}=K(M,g,m+q,R,j,l),w=P-q;if(w<0)continue;if(f>S*S)continue;const y=w*F,z=e=>(e.point=e.point?Q(a,o,e.point):Q(a,o),e.dist=y,e.normal=H,e.node=a,e.pointId=o,e.layerViewUid=b,e);if((null==O.dist||y<O.dist)&&(null==t||t(i,s,y))&&z(O),0!==e.options.store&&(null==E.dist||y>E.dist)&&(null==t||t(i,s,y))&&z(E),2===e.options.store&&(null==t||t(i,s,y))){const e=new Y;I.push(z(e))}}});const D=e=>{const{layerViewUid:t,node:i,pointId:s}=e;return new v(e.point,t,s,()=>this.createGraphic(i,s,e.point))},V=(e,t)=>{const i=D(t);e.set(this.type,i,t.dist,t.dist,t.normal)};if(Z(O)){const t=e.results.min;(null==t.renderDistance||O.dist<t.renderDistance)&&V(t,O)}if(Z(E)&&0!==e.options.store){const t=e.results.max;(null==t.renderDistance||E.dist>t.renderDistance)&&V(t,E)}if(2===e.options.store)for(const o of I){const t=new A(w);V(t,o),e.results.all.push(t)}}*intersectScreenPolygon(e,t,i){const s=e.camera,{screenPolygonPrimitiveProcessor:r}=e,{point:n,layerViewUid:a,_nodes:l}=this,h=this._passParameters,d=s.perScreenPixelRatio/2,{eye:g,near:_,viewForward:f}=s,P=m(ie,f[0],f[1],f[2],-c(f,g)),x=new J,{bounds:b,broadPhaseFrustum:S}=t,{scaleFactor:w}=h;for(let m=0;m<l.length;++m){const R=l.data[m],{isLeaf:y,obb:z}=R,j=R.splatSize*w,q=k(h,y),F=G(j,Math.max(z.signedDistanceRangePlane(P).max,_),h,d,y);if(!z.intersectsFrustumConservativeApproximationWithMargin(S,F))continue;const{coordinates:H}=R,O=H.length/3;for(let l=0;l<O;l++){if(i.done&&(i=yield),!r.validatePoint(Q(R,l,n)))continue;if(!s.projectToScreen(n,ee))continue;if(!X(b,ee,q))continue;const m=c(o(te,n,g),f),{distance:P,radius:S}=K(x,j,m,h,d,y);if(P<_)continue;const w=S/s.computeScreenPixelSizeAtDist(P);E(t,ee,w)&&e.polygonResults.add(this.type,new v(p(n),a,null,()=>this.createGraphic(R,l,n)),u(g,n))}i=yield}}acquireTechniques(e){const t=10===e.output;return 0!==this._nodes.length&&(q(e.output)||H(e.output)&&3===e.bind.slot||t)?(this._nodes.forAll(t=>this._initNode(e,t)),this._configuration.drawScreenSize=this._passParameters.drawScreenSpace,this._configuration.useFixedSizes=this._passParameters.useFixedSizes,this._configuration.hasSlicePlane=this._slicePlaneEnabled,this._configuration.hasOccludees=e.bind.hasOccludees,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.hasHighlightMixTexture=t&&null!=e.bind.highlightMixTexture,this._configuration.output=e.output,this._configuration.hasEmission=e.bind.hasEmission,this._context.techniques.get(D,this._configuration)):null}render(e,t){const{rctx:i,bind:s,output:r}=e,n=i.bindTechnique(t,s,this._passParameters),o=10===r,a=s.highlight?.name??null;o&&!a||(o&&s.highlights!==this._highlightsInOrder&&this._updateResolvedHighlights(s.highlights),this._nodes.forAll(t=>{const r=o?t.resolvedHighlightRanges.get(a):null;0===t.coordinates.length||null==t.vao||o&&null==r||(n.assertCompatibleVertexAttributeLocations(t.vao),n.bindDraw(s,this._passParameters,t),i.bindVAO(t.vao),o?this._renderHighlightFragments(e,r):i.drawArrays(C.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(e,t){const{rctx:i}=e;for(let s=0;s<t.length;s+=2)i.drawArrays(C.POINTS,t[s],t[s+1])}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){b(this._passParameters.clipBox,e||S)}get _clippingEnabled(){return!w(this._passParameters.clipBox,S,(e,t)=>e===t)}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),e.clearHighlights(),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let i=null;return this._nodes.filterInPlace(s=>s.id!==e||(i=s,s.vao=t(s.vao),this._highlights.nodeRemoved(s),!1)),this._requestRender(),i}forEachNode(e){this._nodes.forEach(e)}removeAll(){this._nodes.forAll(e=>e.vao=t(e.vao)),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e,t){return this._highlights.add(e,t)}_addHighlights(e,t,i){for(const s of t)e.addHighlight(s,i);this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_removeHighlight(e,t){e.removeHighlight(t),this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_initNode(e,t){t.vao??=new I(e.rctx,new Map([["positions",new U(e.rctx,V,t.coordinates)],["colors",new U(e.rctx,N,t.rgb)]]))}_requestRender(){this._context&&this._context.requestRender()}_updateResolvedHighlights(e){this._highlightsInOrder=e,this._nodes.forAll(t=>t.updateResolvedHighlights(e))}};function G(e,t,i,s,r){if(i.drawScreenSpace)return i.fixedSize*t*s;const n=M(r)*t*s;return i.useFixedSizes?Math.min(i.fixedSize/2,n):i.screenMinSize>0?Math.min(Math.max(i.screenMinSize*t*s,e/2),n):Math.min(e/2,n)}function L(e,t,i,s,r){return i.drawScreenSpace?0:G(e,t,i,s,r)}function k(e,t){return e.drawScreenSpace?e.fixedSize/2:M(t)/2}e([r({constructOnly:!0})],W.prototype,"createGraphic",void 0),W=e([n("esri.views.3d.layers.i3s.PointCloudRenderer")],W);class J{constructor(){this.distance=0,this.radius=0}}function K(e,t,i,s,r,n){const o=i-L(t,i,s,r,n);return e.distance=o,e.radius=G(t,o,s,r,n),e}function Q(e,t,i=g()){return i[0]=e.origin[0]+e.coordinates[3*t],i[1]=e.origin[1]+e.coordinates[3*t+1],i[2]=e.origin[2]+e.coordinates[3*t+2],i}function X(e,t,i){return t[0]>=e[0]-i&&t[0]<=e[2]+i&&t[1]>=e[1]-i&&t[1]<=e[3]+i}class Y{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}function Z(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}const $=g(),ee=s(),te=g(),ie=R();export{W as PointCloudRenderer};
|
|
2
|
+
import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../../core/maybe.js";import i from"../../../../core/PooledArray.js";import{createScreenPointArray as s}from"../../../../core/screenUtils.js";import{property as r,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{subtract as o,length as a,scale as l,negate as h,dot as c,squaredLength as d,distance as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as m}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as _,offset as f,contains as P,containsPoint as x,set as b,positiveInfinity as S,equals as w}from"../../../../geometry/support/aaBoundingBox.js";import{create as R}from"../../../../geometry/support/plane.js";import{fromPoints as y}from"../../../../geometry/support/ray.js";import{Sphere as z}from"../../../../geometry/support/sphere.js";import{PclTarget as v}from"./Intersector.js";import{PointCloudHighlights as j}from"./PointCloudHighlights.js";import{isColor as q,isHighlight as F,isDepth as H}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as O}from"../../webgl-engine/effects/RenderPlugin.js";import{IntersectorResultRay as A}from"../../webgl-engine/lib/IntersectorResult.js";import{screenPolygonIntersectsCircle as E}from"../../webgl-engine/lib/screenPolygonOverlapUtils.js";import{VertexArrayObject as I}from"../../webgl-engine/lib/VertexArrayObject.js";import{P as B,g as M}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as D,positionsLayout as V,colorsLayout as N}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as T}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{PrimitiveType as C}from"../../../webgl/enums.js";import{VertexBuffer as U}from"../../../webgl/VertexBuffer.js";let W=class extends O{constructor(e){super(e),this.type=6,this.isGround=!1,this._passParameters=new B,this._highlights=new j({forEachNode:e=>this.forEachNode(e),addHighlights:(e,t,i)=>this._addHighlights(e,t,i),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.produces=new Map([[2,e=>q(e)||F(e)&&!this._highlights.empty],[3,e=>H(e)]]),this.point=g(),this.intersectionRayDir=g(),this.intersectionPlane=R(),this.nodeOriginOffset=g(),this.nodeBoundingBox=_(),this.layerViewUid="",this._slicePlaneEnabled=!1,this._configuration=new T,this._nodes=new i,this._highlightsInOrder=null}destroy(){this._nodes.prune()}hasHighlight(e){return this._highlights.has(e)}initializeRenderContext(e){this._context=e,e.requestRender()}uninitializeRenderContext(){}intersectRay(e,t,i,s){const{point:r,intersectionRayDir:n,nodeOriginOffset:u,intersectionPlane:p,layerViewUid:b,nodeBoundingBox:S}=this,w=y(i,s),R=this._passParameters,j=e.camera.perScreenPixelRatio/2,q=e.camera.near;o(n,s,i);const F=1/a(n);l(n,n,F);const H=g();h(H,n),m(p,n[0],n[1],n[2],-c(n,i));const O=new Y,E=new Y,I=new Array,B=_(R.clipBox);f(B,-i[0],-i[1],-i[2],B);const M=new J;this._nodes.forAll(a=>{const{isLeaf:l,coordinates:h}=a,g=a.splatSize*R.scaleFactor;let{min:m,max:_}=a.obb.signedDistanceRangePlane(p);m-=L(g,m+q,R,j,l),_-=L(g,_+q,R,j,l);const y=_<0,v=null!=O.dist&&null!=E.dist&&O.dist<m*F&&E.dist>_*F;if(y||v)return;const A=G(g,_+q,R,j,l);if(!new z(a.obb.getCenter($),a.obb.radius+A).intersectRay(w))return;if(!a.obb.intersectRay(i,n,A))return;const D=A*A;a.obb.toAaBoundingBox(S),f(S,-i[0],-i[1],-i[2],S);const V=!P(B,S);o(u,a.origin,i);const N=h.length/3;for(let o=0;o<N;o++){const p=3*o;if(r[0]=u[0]+h[p],r[1]=u[1]+h[p+1],r[2]=u[2]+h[p+2],V&&!x(B,r))continue;const m=c(r,n),_=m*m,f=d(r)-_;if(f>D)continue;const{distance:P,radius:S}=K(M,g,m+q,R,j,l),w=P-q;if(w<0)continue;if(f>S*S)continue;const y=w*F,z=e=>(e.point=e.point?Q(a,o,e.point):Q(a,o),e.dist=y,e.normal=H,e.node=a,e.pointId=o,e.layerViewUid=b,e);if((null==O.dist||y<O.dist)&&(null==t||t(i,s,y))&&z(O),0!==e.options.store&&(null==E.dist||y>E.dist)&&(null==t||t(i,s,y))&&z(E),2===e.options.store&&(null==t||t(i,s,y))){const e=new Y;I.push(z(e))}}});const D=e=>{const{layerViewUid:t,node:i,pointId:s}=e;return new v(e.point,t,s,()=>this.createGraphic(i,s,e.point))},V=(e,t)=>{const i=D(t);e.set(this.type,i,t.dist,t.dist,t.normal)};if(Z(O)){const t=e.results.min;(null==t.renderDistance||O.dist<t.renderDistance)&&V(t,O)}if(Z(E)&&0!==e.options.store){const t=e.results.max;(null==t.renderDistance||E.dist>t.renderDistance)&&V(t,E)}if(2===e.options.store)for(const o of I){const t=new A(w);V(t,o),e.results.all.push(t)}}*intersectScreenPolygon(e,t,i){const s=e.camera,{screenPolygonPrimitiveProcessor:r}=e,{point:n,layerViewUid:a,_nodes:l}=this,h=this._passParameters,d=s.perScreenPixelRatio/2,{eye:g,near:_,viewForward:f}=s,P=m(ie,f[0],f[1],f[2],-c(f,g)),x=new J,{bounds:b,broadPhaseFrustum:S}=t,{scaleFactor:w}=h;for(let m=0;m<l.length;++m){const R=l.data[m],{isLeaf:y,obb:z}=R,j=R.splatSize*w,q=k(h,y),F=G(j,Math.max(z.signedDistanceRangePlane(P).max,_),h,d,y);if(!z.intersectsFrustumConservativeApproximationWithMargin(S,F))continue;const{coordinates:H}=R,O=H.length/3;for(let l=0;l<O;l++){if(i.done&&(i=yield),!r.validatePoint(Q(R,l,n)))continue;if(!s.projectToScreen(n,ee))continue;if(!X(b,ee,q))continue;const m=c(o(te,n,g),f),{distance:P,radius:S}=K(x,j,m,h,d,y);if(P<_)continue;const w=S/s.computeScreenPixelSizeAtDist(P);if(!E(t,ee,w))continue;const z=p(n);e.polygonResults.add(this.type,new v(z,a,null,()=>this.createGraphic(R,l,z)),u(g,n))}i=yield}}acquireTechniques(e){const t=10===e.output;return 0!==this._nodes.length&&(q(e.output)||H(e.output)&&3===e.bind.slot||t)?(this._nodes.forAll(t=>this._initNode(e,t)),this._configuration.drawScreenSize=this._passParameters.drawScreenSpace,this._configuration.useFixedSizes=this._passParameters.useFixedSizes,this._configuration.hasSlicePlane=this._slicePlaneEnabled,this._configuration.hasOccludees=e.bind.hasOccludees,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.hasHighlightMixTexture=t&&null!=e.bind.highlightMixTexture,this._configuration.output=e.output,this._configuration.hasEmission=e.bind.hasEmission,this._context.techniques.get(D,this._configuration)):null}render(e,t){const{rctx:i,bind:s,output:r}=e,n=i.bindTechnique(t,s,this._passParameters),o=10===r,a=s.highlight?.name??null;o&&!a||(o&&s.highlights!==this._highlightsInOrder&&this._updateResolvedHighlights(s.highlights),this._nodes.forAll(t=>{const r=o?t.resolvedHighlightRanges.get(a):null;0===t.coordinates.length||null==t.vao||o&&null==r||(n.assertCompatibleVertexAttributeLocations(t.vao),n.bindDraw(s,this._passParameters,t),i.bindVAO(t.vao),o?this._renderHighlightFragments(e,r):i.drawArrays(C.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(e,t){const{rctx:i}=e;for(let s=0;s<t.length;s+=2)i.drawArrays(C.POINTS,t[s],t[s+1])}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){b(this._passParameters.clipBox,e||S)}get _clippingEnabled(){return!w(this._passParameters.clipBox,S,(e,t)=>e===t)}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),e.clearHighlights(),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let i=null;return this._nodes.filterInPlace(s=>s.id!==e||(i=s,s.vao=t(s.vao),this._highlights.nodeRemoved(s),!1)),this._requestRender(),i}forEachNode(e){this._nodes.forEach(e)}removeAll(){this._nodes.forAll(e=>e.vao=t(e.vao)),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e,t){return this._highlights.add(e,t)}_addHighlights(e,t,i){for(const s of t)e.addHighlight(s,i);this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_removeHighlight(e,t){e.removeHighlight(t),this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_initNode(e,t){t.vao??=new I(e.rctx,new Map([["positions",new U(e.rctx,V,t.coordinates)],["colors",new U(e.rctx,N,t.rgb)]]))}_requestRender(){this._context&&this._context.requestRender()}_updateResolvedHighlights(e){this._highlightsInOrder=e,this._nodes.forAll(t=>t.updateResolvedHighlights(e))}};function G(e,t,i,s,r){if(i.drawScreenSpace)return i.fixedSize*t*s;const n=M(r)*t*s;return i.useFixedSizes?Math.min(i.fixedSize/2,n):i.screenMinSize>0?Math.min(Math.max(i.screenMinSize*t*s,e/2),n):Math.min(e/2,n)}function L(e,t,i,s,r){return i.drawScreenSpace?0:G(e,t,i,s,r)}function k(e,t){return e.drawScreenSpace?e.fixedSize/2:M(t)/2}e([r({constructOnly:!0})],W.prototype,"createGraphic",void 0),W=e([n("esri.views.3d.layers.i3s.PointCloudRenderer")],W);class J{constructor(){this.distance=0,this.radius=0}}function K(e,t,i,s,r,n){const o=i-L(t,i,s,r,n);return e.distance=o,e.radius=G(t,o,s,r,n),e}function Q(e,t,i=g()){return i[0]=e.origin[0]+e.coordinates[3*t],i[1]=e.origin[1]+e.coordinates[3*t+1],i[2]=e.origin[2]+e.coordinates[3*t+2],i}function X(e,t,i){return t[0]>=e[0]-i&&t[0]<=e[2]+i&&t[1]>=e[1]-i&&t[1]<=e[3]+i}class Y{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}function Z(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}const $=g(),ee=s(),te=g(),ie=R();export{W as PointCloudRenderer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../../../core/Logger.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{NavigationMode3D as i}from"./NavigationMode3D.js";let r=class extends i{constructor(t){super(t),this.type="ground",this.nearOverride=.5,this.farOverride=1e4}attach(t){super.attach(t),this._warnIfOffsetIsBelowConstraints()}detach(){super.detach()}get offset(){const t=this._get("offset");return void 0!==t?t:1.
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../../core/Logger.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{NavigationMode3D as i}from"./NavigationMode3D.js";let r=class extends i{constructor(t){super(t),this.type="ground",this.nearOverride=.5,this.farOverride=1e4}attach(t){super.attach(t),this._warnIfOffsetIsBelowConstraints()}detach(){super.detach()}get offset(){const t=this._get("offset");return void 0!==t?t:1.5}set offset(t){this._set("offset",t),this._warnIfOffsetIsBelowConstraints()}_warnIfOffsetIsBelowConstraints(){if(null==this.view||null==this.offset)return;const t=this.view.state.constraints.altitude,s=this.view.state.constraints.collision;t&&this.offset<t.min&&e.getLogger(this).warn("offset-smaller-than-altitude-constraint",`The ground navigation offset of ${this.offset} is smaller than the view's min altitude constraint with a value of ${t.min}. Unexpected behaviour close to ground might occur. Adjust or remove constraints from view.constraints.altitude to address this.`);const o=this.view.state.constraints.elevationMargin;s?.enabled&&this.offset<o&&e.getLogger(this).warn("offset-smaller-than-navigation-constraint",`The ground navigation offset of ${this.offset} is smaller than the value of ${o} that is enforced by the view's navigation constraint. Unexpected behaviour close to ground might occur. Adjust or remove constraints from view.map.ground.navigationConstraint to address this.`)}};t([s()],r.prototype,"include",void 0),t([s()],r.prototype,"exclude",void 0),t([s()],r.prototype,"offset",null),r=t([o("esri.views.3d.navigation.modes.GroundNavigationMode3D")],r);export{r as GroundNavigationMode3D};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import i from"../../../core/Logger.js";import{clamp as o,deg2rad as
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import i from"../../../core/Logger.js";import{clamp as o,deg2rad as s}from"../../../core/mathUtils.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{earth as a}from"../../../geometry/support/Ellipsoid.js";import{makePiecewiseLinearFunction as l}from"../support/mathUtils.js";let m=class extends e{constructor(t){super(t),this.collision=new x,this.distance=1/0,this.minimumPoiDistance=4,this.tilt=null}get altitude(){return 2===this.mode?null:this._get("altitude")||null}set altitude(t){2!==this.mode?this._set("altitude",t):i.getLogger(this).warn("Altitude constraint is ignored in local scenes")}get elevationMargin(){return"ground"===this.state.view.navigation.mode.type||this.state.view.navigation.isInPlacementMode?g:h}get mode(){return this.state.viewingMode}clampAltitude(t){return this.altitude?o(t,this.altitude.min,this.altitude.max):t}clampTilt(t,e){if(!this.tilt)return e;const i=this.tilt(t);return o(e,i.min,i.max)}clampDistance(t){return Math.min(t,this.distance)}createDefaultTilt(){return 2===this.mode?this._createDefaultTiltLocal():this._createDefaultTiltGlobal()}createConstantMaxTilt(t){return(e,i=p)=>(i.min=d.min,i.max=t,i)}_createDefaultTiltLocal(){const t=this.collision.enabled?l([[4e3,d.max],[1e4,s(88)],[6e6,s(88)]]):()=>d.max;return(e,i=p)=>(i.min=d.min,i.max=t(e),i)}_createDefaultTiltGlobal(){const t=this.collision.enabled?l([[4e3,d.max],[5e4,s(88)],[6e6,s(88)],[2e7,d.min]]):l([[3e5,d.max],[3e6,s(88)],[6e6,s(88)],[2e7,d.min]]);return(e,i=p)=>(i.min=d.min,i.max=t(e),i)}};function c(t){return{min:-2e5,max:4*t.radius}}t([n()],m.prototype,"altitude",null),t([n({readOnly:!0})],m.prototype,"collision",void 0),t([n()],m.prototype,"elevationMargin",null),t([n()],m.prototype,"distance",void 0),t([n({readOnly:!0})],m.prototype,"minimumPoiDistance",void 0),t([n()],m.prototype,"tilt",void 0),t([n({constructOnly:!0})],m.prototype,"state",void 0),m=t([r("esri.views.3d.state.Constraints")],m);const u=c(a),d={min:s(.5),max:s(179.5)},p={min:0,max:0},h=5,g=1;let x=class extends e{constructor(){super(...arguments),this.enabled=!0}};t([n({type:Boolean})],x.prototype,"enabled",void 0),x=t([r("esri.views.3d.state.Constraints.CollisionConstraint")],x);export{m as Constraints,d as TiltRange,u as earthAltitudeConstraint};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{clamp as t}from"../../../../core/mathUtils.js";import{dot as e,distance as i,subtract as r,scale as s,add as n,copy as o,normalize as a,cross as c,scaleAndAdd as m}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as _}from"../../../../geometry/support/ray.js";import{applyConstraintsAndUpdateCenterRenderCamera as
|
|
2
|
+
import{clamp as t}from"../../../../core/mathUtils.js";import{dot as e,distance as i,subtract as r,scale as s,add as n,copy as o,normalize as a,cross as c,scaleAndAdd as m}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as _}from"../../../../geometry/support/ray.js";import{applyConstraintsAndUpdateCenterRenderCamera as d}from"../../camera/constraintUtils.js";import{Intersector as u}from"../../webgl-engine/lib/Intersector.js";const l=.5,y=1e-5,f=5,v=.03,g=1e5,C=new Set([0,2,8]),R=new Set(C).add(7);class I{constructor(t){this._view=t,this._tmpRay=_(),this._tmpWorldUp=p(),this._tmpScaledUp=p(),this._tmpCorrectionOffset=p(),this._tmpUpdatedCameraPos=p(),this._tmpCenterDiff=p(),this._tmpMovementDelta=p(),this._tmpPerpendicularMovementDelta=p(),this._tmpGroundIntersections=[p(),p(),p()],this._tmpGroundIntersectionHits=[!1,!1,!1],this._tmpRayOrigins=[p(),p(),p()],this._tmpRayDirection=p(),this._previousCameraPosition=null,this._intersector=new u(this._view.state.viewingMode),this._intersector.options.invisibleTerrain=!0}smoothlyCorrectGroundElevation(t,i,r,s){const n=this._prepareMode(s);if(!n)return 0;const o=this._view.renderCoordsHelper.worldUpAtPosition(t.eye,this._tmpWorldUp),a=this._prepareCameraAndPreviousIterationPosition(t,o,this._previousCameraPosition),c=this._prepareRays(t,o,a),m=this._intersectRays(n,o,c);if(!m.hasIntersection){const e=this._adjustCameraElevation(t,o,0,r);return this._previousCameraPosition=h(e),0}const p=this._filterRayResults(o,a,m),_=this._getSmoothedElevationCorrection(n,p,t,o,a,i),d=this._adjustCameraElevation(t,o,_,r);return this._previousCameraPosition=h(d),Math.abs(p-e(d,o))}immediatelyCorrectGroundElevation(t,s=Number.POSITIVE_INFINITY,n,o){const a=this._prepareMode(o);if(!a)return;const c=this._view.renderCoordsHelper.worldUpAtPosition(t.eye,this._tmpWorldUp),m=this._prepareRays(t,c),p=this._intersectRays(a,c,m),h=p.intersections[0];!p.hasIntersection||i(t.eye,h)>s?this._adjustCameraElevation(t,c,0,n):this._adjustCameraElevation(t,c,e(c,r(this._tmpCorrectionOffset,h,t.eye)),n)}_prepareMode(t){const e=t??this._view.navigation.mode;return"ground"===e.type&&e.offset?e:null}_prepareCameraAndPreviousIterationPosition(t,i,r){if(r){const o=e(i,t.eye),a=e(i,r);return s(this._tmpCorrectionOffset,i,a-o),t.eye=n(this._tmpUpdatedCameraPos,t.eye,this._tmpCorrectionOffset),t.center=n(this._tmpUpdatedCameraPos,t.center,this._tmpCorrectionOffset),r}return t.eye}_prepareRays(t,e,i){const r=s(this._tmpRayDirection,e,-g);if(o(this._tmpRayOrigins[0],t.eye),!i)return{origins:this._tmpRayOrigins,direction:r,count:1};const{forwardMovementDirection:n,rightMovementDirection:a}=this._getMovementDirections(t.eye,i,e);return this._getLeftRayOrigin(t.eye,n,a,this._tmpRayOrigins[1]),this._getRightRayOrigin(t.eye,n,a,this._tmpRayOrigins[2]),{origins:this._tmpRayOrigins,direction:r,count:this._tmpRayOrigins.length}}_getMovementDirections(t,i,n){const o=r(this._tmpMovementDelta,t,i);r(o,o,s(this._tmpScaledUp,n,e(n,o))),a(o,o);return{forwardMovementDirection:o,rightMovementDirection:c(this._tmpPerpendicularMovementDelta,o,n)}}_getLeftRayOrigin(t,e,i,r){return m(r,t,e,l),m(r,r,i,-l),r}_getRightRayOrigin(t,e,i,r){return m(r,t,e,l),m(r,r,i,l),r}_intersectRays(t,e,r){const s=t.offset,n=this._view.sceneIntersectionHelper,a=P(t,0===this._view.groundView.baseOpacity);o(this._tmpRay.direction,r.direction);for(let p=0;p<r.count;p++)o(this._tmpRay.origin,r.origins[p]),this._tmpGroundIntersectionHits[p]=n.intersectRay(this._tmpRay,this._intersector,this._tmpGroundIntersections[p],a),this._tmpGroundIntersectionHits[p]&&i(this._tmpGroundIntersections[p],this._tmpRay.origin)>g&&(this._tmpGroundIntersectionHits[p]=!1),this._tmpGroundIntersectionHits[p]&&m(this._tmpGroundIntersections[p],this._tmpGroundIntersections[p],e,s);const c=this._tmpGroundIntersectionHits.some((t,e)=>e<r.count&&t);return{intersections:this._tmpGroundIntersections,hits:this._tmpGroundIntersectionHits,count:r.count,hasIntersection:c}}_filterRayResults(t,i,r){const s=e(i,t);let n=null;for(let o=0;o<r.count;o++){if(!r.hits[o])continue;const i=r.intersections[o],a=e(i,t);(null==n||Math.abs(a-s)<Math.abs(n-s))&&(n=a)}return n}_getSmoothedElevationCorrection(r,s,n,o,a,c){const m=i(n.eye,a)/c,p=1+Math.max(0,(m-f)*v),h=(p*y)**c,_=e(a,o)*h+s*(1-h),d=e(n.eye,o),u=p*f*c*(r.offset??0);return t(_-d,-u,u)}_adjustCameraElevation(t,e,i,s){return 0!==i&&(m(this._tmpUpdatedCameraPos,t.eye,e,i),r(this._tmpCenterDiff,t.center,t.eye),t.eye=this._tmpUpdatedCameraPos,t.center=n(this._tmpUpdatedCameraPos,this._tmpUpdatedCameraPos,this._tmpCenterDiff)),d(this._view,t,s),t.eye}}function P(t,e){return w(t.include)?{include:t.include,exclude:t.exclude}:{exclude:t.exclude,objectFilter:t=>!!t.lastValidElevationBB,allowedIntersectorTypes:e?C:R}}function w(t){return null!=t&&t.size>0}export{I as OffsetCorrectionController};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../../../core/Logger.js";import{createScreenPointArray as t}from"../../../../core/screenUtils.js";import{distance as n,normalize as o,cross as r,add as i,crossAndNormalize as a,subtract as s,dot as c,scaleAndAdd as l,scale as u,copy as m,length as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as f}from"../../../../geometry/ellipsoidUtils.js";import{create as
|
|
2
|
+
import e from"../../../../core/Logger.js";import{createScreenPointArray as t}from"../../../../core/screenUtils.js";import{distance as n,normalize as o,cross as r,add as i,crossAndNormalize as a,subtract as s,dot as c,scaleAndAdd as l,scale as u,copy as m,length as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as f}from"../../../../geometry/ellipsoidUtils.js";import{fromValues as g}from"../../../../geometry/support/lineSegment.js";import{create as h,fromPositionAndNormal as y,distance as w,projectPoint as P,projectVector as j,intersectLineSegment as v}from"../../../../geometry/support/plane.js";import{create as S}from"../../../../geometry/support/ray.js";import{Sphere as I}from"../../../../geometry/support/sphere.js";import{fromRenderCamera as b}from"../../webgl.js";import{getVoxelWasm as M}from"../../layers/VoxelWasm.js";import{pickPointAndInitSphere as z,sphereOrPlanePointFromScreenPoint as x,intersectPlaneFromScreenPoint as H,searchAreaSize as C}from"./navigationUtils.js";import{OffsetCorrectionController as T}from"./OffsetCorrectionController.js";import{fromScreenAtEye as k}from"../../support/geometryUtils/ray.js";import A from"../../webgl/RenderCamera.js";import{Intersector as F}from"../../webgl-engine/lib/Intersector.js";const O=1.5,G={xSpeedMultiplier:O,ySpeedMultiplier:O,maxElevation:1e4,relativeHorizonPadding:.1,minimumHorizonPadding:12},N=2,R=.25,U=p(),q=p(),Y=t(),D=p(),E=h(),L=p(),V=p(),_=p(),W=p(),B=p(),J=p(),K=p(),Q=p(),X=p(),Z=p(),$=t(),ee=S(),te=new I,ne=p(),oe=h(),re=p(),ie=p();function ae(e,t){return j(t,e.viewForward,U),i(q,e.eye,U),e.projectToScreen(q,Y),Y[1]}function se(e,t,m){const d=e.eye;if(n(t.center,d)<t.radius)return o(B,d),r(J,B,e.viewRight),i(q,d,J),e.projectToScreen(q,$),$[1];const p=e.up;k(e,m,ee);const f=t.radius;if(a(D,p,ee.direction),y(d,D,E),w(E,t.center)>f)return null;P(E,t.center,L);const g=n(t.center,L),h=Math.sqrt(f**2-g**2);s(V,d,L),o(_,V),a(W,D,_);const j=c(V,_),v=c(V,W),S=Math.sqrt(j**2+v**2),I=h**2/S**2,b=h/S**2*Math.sqrt(S**2-h**2),M=I*j,z=b*-v,x=I*v,H=b*j,C=M-z,T=x+H,A=x-H;i(K,L,l(K,u(K,_,M+z),W,T)),i(Q,L,l(Q,u(Q,_,C),W,A)),s(X,K,d),o(X,X),s(Z,Q,d),o(Z,Z);return c(e.viewForward,X)>=c(e.viewForward,Z)?e.projectToScreen(K,$):e.projectToScreen(Q,$),$[1]}function ce(e,t,n=!0){return n?e<t:e<=t}function le(e,t,n=!0){return n?e>t:e>=t}function ue(e,t,n){return t?e>n:e<n}function me(e,t){const n=e.fullHeight/e.pixelRatio,o=Math.max(t,n-t);return Math.max(G.minimumHorizonPadding,G.relativeHorizonPadding*o)}function de(e,t){return[pe(e,t),fe(e,t)]}function pe(e,t){const n=e.fullHeight/e.pixelRatio;return Math.min(n,t+me(e,t))}function fe(e,t){return Math.max(0,t-me(e,t))}function ge(e,t,n){const o={translation:e,location:t};return n&&(o.normal=n),o}function he(e){const{view:t}=e;return"global"===t.viewingMode?ye(e):we(e)}function ye(e){const{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:s,outGrabLocation:c,outGrabNormal:l,intersectionOptions:u,depthSearchSize:d}=e,p=t.state.camera,g=ge(s,c,l);te.radius=f(t.spatialReference).radius;const h=z(t,p,r,te.radius,1,u);if(null==h.scenePickPoint)return!1;const y=h.hasGeometryIntersection;m(ne,h.scenePickPoint),m(g.location,ne);const w=h.sphere;g.normal&&h.normal&&m(g.normal,h.normal);const P=je(r,i,a,y),j=y?n(ne,p.eye):Number.POSITIVE_INFINITY;if(P.wasAdjusted){Se({view:t,screenAdjustment:P,intersector:ve(t),fallbackCheck:(e,t,n)=>{const r=x(w,p,e,t);return r&&n&&o(n,t),r},output:g,intersectionOptions:u})}return be({view:t,screenPoint:P.adjustedScreenPoint,camera:p,initialDistance:j,depthSearchSize:d??C,output:g}),!0}function we(e){const{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:s,outGrabLocation:c,outGrabNormal:u,intersectionOptions:d,depthSearchSize:p}=e,f=t.sceneIntersectionHelper,g=t.state.camera,h=ve(t),w=ge(s,c,u);f.intersectIntersectorScreen(r,h,d);const P=h.results.min.getIntersectionPoint(ne),j=P?n(ne,g.eye):Number.POSITIVE_INFINITY;P&&(m(w.location,ne),w.normal&&m(w.normal,h.results.min.normal)),t.renderCoordsHelper.worldUpAtPosition(g.eye,B),l(re,g.eye,B,-g.relativeElevation),y(re,B,oe);const v=je(r,i,a,P);if(v.wasAdjusted){Se({view:t,screenAdjustment:v,intersector:h,fallbackCheck:(e,t,n)=>{const r=H(oe,g,e,t);return r&&n&&o(n,B),r},output:w,intersectionOptions:d})}return be({view:t,screenPoint:v.adjustedScreenPoint,camera:g,initialDistance:j,depthSearchSize:p??C,output:w}),!0}function Pe(e,t,n,o){return!o&&ce(e,t)||o&&ue(e,!1,n[0])?n[0]:!o&&le(e,t,!1)?n[1]:null}function je(e,n,o,r){const i=Pe(e[1],n,o,r);return{originalScreenPoint:e,adjustedScreenPoint:t(e[0],i??e[1]),horizonY:n,horizonPadding:o,wasAdjusted:null!==i}}function ve(e){const t=new F(e.state.viewingMode);return t.options.selectionMode=!0,t.options.store=0,t.options.hud=!1,t.options.normalRequired=!0,t}function Se(e){const{view:t,screenAdjustment:n,fallbackCheck:o,intersector:r,output:i,intersectionOptions:a}=e,s=t.sceneIntersectionHelper;s.intersectIntersectorScreen(n.adjustedScreenPoint,r,{...a,requiresGroundFeedback:!0});let c=r.results.min.getIntersectionPoint(i.location);if(c)return void(i.normal&&m(i.normal,r.results.min.normal));const l=Ie(n);s.intersectIntersectorScreen(l,r,{...a,requiresGroundFeedback:!0}),c=r.results.min.getIntersectionPoint(i.location),c?i.normal&&m(i.normal,r.results.min.normal):(c=o(n.adjustedScreenPoint,i.location,i.normal),c||o(l,i.location,i.normal))}function Ie(e){const{originalScreenPoint:n,adjustedScreenPoint:o,horizonY:r,horizonPadding:i}=e,a=le(o[1],r)?Math.min(i[1],n[1]):Math.max(i[0],n[1]);return t(o[0],a)}function be(e){Me(e),ze(e)}function Me(e){const{view:t,camera:n,output:o}=e,{offset:r}=t.navigation.mode;if(!r)return;const{translation:i,location:a}=o;t.renderCoordsHelper.worldUpAtPosition(n.eye,B),l(re,n.eye,B,-r),y(re,B,E);v(E,g(n.eye,s(U,a,n.eye)),re)&&(m(a,re),s(i,a,n.eye))}function ze(e){const{view:t,screenPoint:n,camera:r,initialDistance:a,depthSearchSize:c,output:l}=e,m=c>0?t.stage.renderView.getMinimalDepthForArea(M(t),n[0],n[1],r,c):null;s(l.translation,l.location,r.eye);let p=Math.min(d(l.translation),a);m&&m<=p&&(p=m),o(l.translation,l.translation),u(l.translation,l.translation,p),i(l.location,l.translation,r.eye)}async function xe(t,o){if("ground"!==t.navigation.mode.type)return void e.getLogger("esri").warn("Can only advance while in ground navigation mode!");const{camera:r}=t.state;t.renderCoordsHelper.worldUpAtPosition(r.eye,B);const c=t.sceneIntersectionHelper,l=ve(t),p=a(U,B,r.viewRight);m(ee.origin,r.eye),u(ee.direction,p,o);const f=c.intersectRay(ee,l,ne),g=(new A).copyFrom(r),h=s(ie,r.center,r.eye);if(!f||n(ne,r.eye)>o)g.eye=i(U,ee.origin,ee.direction);else{s(U,ne,r.eye);d(U)>N&&(He(U,U,R,N),g.eye=i(U,r.eye,U))}g.center=i(U,g.eye,h);return new T(t).immediatelyCorrectGroundElevation(g,100),t.goTo(b(t,g),{duration:500,liftOffDisabled:!0})}function He(e,t,n,o){const r=d(e),i=Math.min(n,Math.max(r-o,0)/r);u(t,e,i)}export{me as computeHorizonPadding,de as computeHorizonPaddingLimits,he as findGroundNavigationGrabLocation,ae as findPlaneHorizonY,se as findSphereHorizonY,xe as groundNavigationAdvance,G as groundNavigationConstants,ce as isAboveHorizon,le as isBelowHorizon,He as shortenTranslation,ue as shouldClampScreenY};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{cyclicalPI as t}from"../../../../core/Cyclical.js";import{deg2rad as e,clamp as n,acosClamped as o,asinClamped as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as i}from"../../../../core/screenUtils.js";import{fromRotation as s,exactEquals as a,rotate as c,multiply as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as m,create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as p}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as h,length as M,dot as g,subtract as y,normalize as d,squaredDistance as b,copy as x,transformMat4 as j,add as v,distance as P,cross as w,scale as I,lerp as z,set as A}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as T,create as R}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as S,axis as U,fromPoints as q,wrapAxisAngle as E}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as G,vectorCoordinates as H}from"../../../../geometry/support/coordinateSystem.js";import{create as k,fromNormalAndOffset as C,intersectRay as F}from"../../../../geometry/support/plane.js";import{Sphere as O}from"../../../../geometry/support/sphere.js";import{sm4d as W,sv3d as B}from"../../../../geometry/support/vectorStacks.js";import{fromScreenAtEye as D,fromScreen as J}from"../../support/geometryUtils/ray.js";import{intersectScreen as K}from"../../support/geometryUtils/sphere.js";import L from"../../webgl/RenderCamera.js";import{Intersector as N}from"../../webgl-engine/lib/Intersector.js";import{terrainId as Q}from"../../webgl-engine/lib/verticalOffsetUtils.js";const V=30,X=[1,3e8],Y=8,Z=[200,1508e5],$=5,_=50,tt=5,et=10,nt=90,ot=1e-6,rt={exclude:new Set([Q])};function it(t,e,n){return n[0]=e[0]/(t.fullWidth/t.pixelRatio),n[1]=e[1]/(t.fullHeight/t.pixelRatio),n}function st(t){for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function at(t,e,n){const o=s(W.get(),n[3],U(n));null==o||a(o,m)||(y(re,t.eye,e),j(re,re,o),t.eye=v(re,re,e),y(re,t.center,e),j(re,re,o),t.center=v(re,re,e),t.up=j(re,t.up,o))}function ct(t,e,n,o){return F(t,J(e,n,me),o)}function lt(t,e,n,o){return F(t,D(e,n,me),o)}function mt(t,e,n,o){const r=B.get();let i=1-n;y(r,e,t.eye);const s=M(r);let a=s*(1-i);i>=0&&a<o&&(a=o,i=-(a-s)/s),Math.abs(s-a)<ot||(I(r,r,i),t.eye=v(re,t.eye,r),t.center=z(re,t.center,e,i))}function ut(t,e,n){e.getScreenCenter(pt),K(t,e,pt,re)&&(e.center=re);const o=e.distance,r=o*n;if(Math.abs(o-r)<ot)return;const i=I(B.get(),e.viewForward,r);e.eye=y(re,e.center,i)}const pt=i();function ft(t,e){A(e,0,0,0);for(const n of t)v(e,e,n);I(e,e,1/t.length)}function ht(t,e,n,o){return Math.sin(t/M(e))*(n+o.radius)}function Mt(t,e,n,o){return ht(Math.PI/2,e,n,o)+(t-Math.PI/2)}const gt={Elevation:3e4,Angle:e(16)},yt=e(80);function dt(t,e,n,o,r,i){const s=t.sceneIntersectionHelper,a=new N(t.state.viewingMode);a.options.selectionMode=!
|
|
2
|
+
import{cyclicalPI as t}from"../../../../core/Cyclical.js";import{deg2rad as e,clamp as n,acosClamped as o,asinClamped as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as i}from"../../../../core/screenUtils.js";import{fromRotation as s,exactEquals as a,rotate as c,multiply as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as m,create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as p}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as h,length as M,dot as g,subtract as y,normalize as d,squaredDistance as b,copy as x,transformMat4 as j,add as v,distance as P,cross as w,scale as I,lerp as z,set as A}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as T,create as R}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as S,axis as U,fromPoints as q,wrapAxisAngle as E}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as G,vectorCoordinates as H}from"../../../../geometry/support/coordinateSystem.js";import{create as k,fromNormalAndOffset as C,intersectRay as F}from"../../../../geometry/support/plane.js";import{Sphere as O}from"../../../../geometry/support/sphere.js";import{sm4d as W,sv3d as B}from"../../../../geometry/support/vectorStacks.js";import{fromScreenAtEye as D,fromScreen as J}from"../../support/geometryUtils/ray.js";import{intersectScreen as K}from"../../support/geometryUtils/sphere.js";import L from"../../webgl/RenderCamera.js";import{Intersector as N}from"../../webgl-engine/lib/Intersector.js";import{terrainId as Q}from"../../webgl-engine/lib/verticalOffsetUtils.js";const V=30,X=[1,3e8],Y=8,Z=[200,1508e5],$=5,_=50,tt=5,et=10,nt=90,ot=1e-6,rt={exclude:new Set([Q])};function it(t,e,n){return n[0]=e[0]/(t.fullWidth/t.pixelRatio),n[1]=e[1]/(t.fullHeight/t.pixelRatio),n}function st(t){for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function at(t,e,n){const o=s(W.get(),n[3],U(n));null==o||a(o,m)||(y(re,t.eye,e),j(re,re,o),t.eye=v(re,re,e),y(re,t.center,e),j(re,re,o),t.center=v(re,re,e),t.up=j(re,t.up,o))}function ct(t,e,n,o){return F(t,J(e,n,me),o)}function lt(t,e,n,o){return F(t,D(e,n,me),o)}function mt(t,e,n,o){const r=B.get();let i=1-n;y(r,e,t.eye);const s=M(r);let a=s*(1-i);i>=0&&a<o&&(a=o,i=-(a-s)/s),Math.abs(s-a)<ot||(I(r,r,i),t.eye=v(re,t.eye,r),t.center=z(re,t.center,e,i))}function ut(t,e,n){e.getScreenCenter(pt),K(t,e,pt,re)&&(e.center=re);const o=e.distance,r=o*n;if(Math.abs(o-r)<ot)return;const i=I(B.get(),e.viewForward,r);e.eye=y(re,e.center,i)}const pt=i();function ft(t,e){A(e,0,0,0);for(const n of t)v(e,e,n);I(e,e,1/t.length)}function ht(t,e,n,o){return Math.sin(t/M(e))*(n+o.radius)}function Mt(t,e,n,o){return ht(Math.PI/2,e,n,o)+(t-Math.PI/2)}const gt={Elevation:3e4,Angle:e(16)},yt=e(80);function dt(t,e,n,o,r,i){const s=t.sceneIntersectionHelper,a=new N(t.state.viewingMode);a.options.selectionMode=!1,a.options.store=0,a.options.hud=!1,a.options.normalRequired=!0;let c=null;const l=R(),m=new O;let u=!0,p=!0;const{eye:f}=e;s.intersectIntersectorScreen(n,a,i);const g=a.results.min;return g.getIntersectionPoint(l)&&!h(f,l)&&Jt(f,l,o)?(c=T(g.normal),m.radius=M(l)):(p=!1,e.aboveGround&&0!==r?m.radius=Math.max(M(e.center),.9*o):m.radius=M(e.eye)-e.relativeElevation,1===r?vt(m,e,n,l):u=K(m,e,n,l)),{sphere:m,scenePickPoint:u?l:null,hasGeometryIntersection:p,intersectorType:g.intersector,normal:c}}function bt(t,e,n,o){const r=t.relativeElevation;if(r>gt.Elevation&&"global"===o)return 1;D(t,e,ue);const i=Math.sign(r),s=n.worldUpAtPosition(t.eye,re);return-i*g(s,ue.direction)<Math.sin(gt.Angle)*M(ue.direction)?0:1}function xt(t,e,n){y(jt,n,e),t.eye=y(re,t.eye,jt),t.center=y(re,t.center,jt)}const jt=R();function vt(t,e,n,o){const r=D(e,n,me);return null!=r&&(t.closestPointOnSilhouette(r,Pt),t.intersectRay(r,o)?!(b(Pt,r.origin)<b(o,r.origin))||(x(o,Pt),!1):(y(wt,e.eye,e.center),d(wt,wt),C(wt,-g(d(wt,wt),Pt),It),F(It,r,o),!1))}const Pt=R(),wt=R(),It=k();function zt(i,s,a,c,l,m){let u=0;if(w(ae,i,s),y(ie,i,s),M(i)<=l||!c.aboveGround){w(a,ie,c.eye);const p=g(i,s)/(M(i)*M(s));if(p<.9999)u=o(p);else{const t=M(w(R(),i,s))/(M(i)*M(s));u=r(t)}const f=Math.cos(n(t.normalize(e(m)),0,yt));u=-u-Math.max(0,M(s)-l)/(f*l)}else y(At,c.eye,c.center),w(a,ie,At),u=-M(ie)/l;return d(a,a),I(a,a,M(ae)),u}const At=R();function Tt(r,i,s,a){let c,l;const m=Math.cos(n(t.normalize(e(a)),0,yt));return c=i>s?-(i-s)/(m*s):i<-s?Math.PI-(i+s)/(m*s):o(i/s),l=r>s?-(r-s)/(m*s):r<-s?Math.PI-(r+s)/(m*s):o(r/s),(l-c)*s}function Rt(t,e,n,o,r,i,s,a,c,l){const m=Tt(t[2],e[2],i.radius,a),u=c?Tt(t[0],e[0],i.radius,180):e[0]-t[0],f=Math.sin(s)*u-Math.cos(s)*m,h=Math.cos(s)*u+Math.sin(s)*m;d(re,r);const M=c?f/Math.sqrt(Math.abs(i.radius**2-g(n,re)**2)):f/i.radius,y=h/Math.sqrt(Math.abs(i.radius**2-g(n,o)**2));p(l,M,y)}function St(t,e,n,o,r,i,s,a,c,l){w(ae,t,e),G(i.up,i.eye,Qt,Vt,Xt),G([0,0,1],i.eye,Kt,Lt,Nt),x(n,Lt),x(o,Kt),d(n,n),I(n,n,M(ae)),H(t,d(Vt,Vt),d(Xt,Xt),d(Qt,Qt),Yt),H(e,Vt,Xt,Qt,Zt),Rt(Yt,Zt,t,Kt,Lt,s,a,c,l,r)}function Ut(t,e,n,o,r,i,a){s(te,r,o),s(ee,a,i),l(ne,te,ee),y(e,t,n),j(e,e,ne),v(e,e,n)}function qt(t,e,n,o,r,i){s(te,o,n),s(ee,i,r),l(ne,te,ee),y(re,t.eye,e),j(re,re,ne),t.eye=v(re,re,e),y(re,t.center,e),j(re,re,ne),t.center=v(re,re,e),y(re,t.up,e),j(re,re,ne),t.up=v(re,re,e)}const Et={Pole:.95,Angle:e(18),Tilt:45,TiltHysteresisMargin:1e-7};let Gt=!1;function Ht(t,e,n,o,r,i){const s=Math.abs(o)>Math.PI-Et.Angle||Math.abs(o)<Et.Angle,a=(Math.abs(t[2])<n*Et.Pole||Math.abs(e)>n)&&i;return s&&a?!Gt&&r<Et.Tilt-Et.TiltHysteresisMargin?Gt=!0:Gt&&r>Et.Tilt+Et.TiltHysteresisMargin&&(Gt=!1):Gt=!1,Gt}function kt(t,e,n,o,r,i){if(i)q(n,o,_t),at(e,t.center,_t);else{const i=zt(n,o,ce,e,t.radius,r);at(e,t.center,E(ce,i))}}function Ct(t,e,n,o,r,i,s){const a=s?20:1,c=1e-12;let l,m;x(oe,o),se.copyFrom(e);for(let u=0;u<a&&b(n,oe)>c&&(l=b(n,oe),St(n,oe,Lt,Kt,$t,se,t,r,i,s),qt(se,t.center,Kt,$t[1],Lt,$t[0]),Ut(oe,oe,t.center,Kt,$t[1],Lt,$t[0]),m=b(n,oe),m<l||0===u);u++)e.copyFrom(se)}function Ft(n,o,r,i,s,a,c){Ht(r,g(o.up,r),n.radius,-t.normalize(e(s)),a,o.aboveGround)?Ct(n,o,r,i,-t.normalize(e(s)),a,c):kt(n,o,r,i,a,c)}function Ot(t,e,n,o,r,i){const{eye:s}=t;G([0,0,1],s,Kt,Lt,Nt);const a=e.translation[0]*n.pan,l="zoom"===r.mode?0:e.translation[1]*n.pan,m=Math.max(Math.sqrt(Math.abs(1-g(t.center,Kt)**2/M(t.center)**2)),.5),u=(Math.sin(i)*l+Math.cos(i)*a)/m,p=-Math.cos(i)*l+Math.sin(i)*a;switch(c(o.pan.matrix,o.pan.matrix,u,Kt),o.pan.enabled=!0,r.mode){case"pan":c(o.pan.matrix,o.pan.matrix,p,Lt),o.pan.enabled=!0;break;case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Wt(t,e,n,o,r){const{eye:i,viewRight:s}=t,a=w(B.get(),s,i),l=e.translation[0]*n.pan;switch(0!==l&&(c(o.pan.matrix,o.pan.matrix,-l,a),o.pan.enabled=!0),r.mode){case"pan":{const t=e.translation[1]*n.pan;0!==t&&(c(o.pan.matrix,o.pan.matrix,t,s),o.pan.enabled=!0);break}case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Bt(n,o,r,i,s,a,c,l,m){Ht(n.center,g(n.up,n.center),M(n.center),-t.normalize(e(a)),c,o.aboveGround)?Ot(o,r,i,l,m,-t.normalize(e(s))):Wt(o,r,i,l,m)}function Dt(t,e,n=1/0){const o=Math.abs(g(t,e));return Math.min(n,1/o)}function Jt(t,e,n){const o=P(t,e),r=M(t);return o<Math.max(r,n)}const Kt=R(),Lt=R(),Nt=R(),Qt=R(),Vt=R(),Xt=R(),Yt=R(),Zt=R(),$t=f(),_t=S(),te=u(),ee=u(),ne=u(),oe=R(),re=R(),ie=R();let se=new L;const ae=R(),ce=R();function le(){se=new L}const me={origin:R(),direction:R()},ue={origin:R(),direction:R()};export{yt as TiltThresholdPanningSpeed,gt as VerticalPanTresholds,xt as applyPanPlanar,kt as applyPanSphericalDirectRotation,Ct as applyPanSphericalPreserveHeading,at as applyRotation,qt as applyRotationWithTwoAxes,ut as applyZoomOnSphere,mt as applyZoomToPoint,ft as centroid,le as cleanupNavigationUtils,ot as distanceComparisonTolerance,rt as excludeTerrain,Dt as getTiltScaleFactor,bt as inferNavigationMode,ct as intersectPlaneFromScreenPoint,lt as intersectPlaneFromScreenPointAtEye,Jt as isHitOnSamePlanetSide,Tt as lengthFromPoints,$ as maxPanDistanceModifier,tt as maxRotatePivotDistanceModifier,V as maxZoomPivotDistanceModifier,Y as maxZoomStepDistanceModifier,_ as minPinchAndPanCameraHeight,et as minRotatePivotDistance,it as normalizeCoordinate,st as normalizeRotationDelta,Mt as offSurfaceTiltToEyeTiltGlobal,ht as onSurfaceTiltToEyeTiltGlobal,Bt as panMotionToRotationMatrix,Ft as panToPosition,dt as pickPointAndInitSphere,Et as preservingHeadingThresholds,Ut as rotatePointAroundTwoAxes,zt as rotationAngleAndAxisDirectRotation,St as rotationAnglesAndAxesHeadingPreserving,Rt as rotationAnglesHeadingPreserving,nt as searchAreaSize,Ht as shouldPreserveHeading,vt as sphereOrPlanePointFromScreenPoint,X as zoomPivotDistanceClamp,Z as zoomStepDistanceClamp};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import"../../../core/has.js";import{lerp as t}from"../../../core/mathUtils.js";import{normalize as e,set as s,add as i,scale as n,len as o,dot as r}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a,ZEROS as l}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as u}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{intersectsSphere as h,numPlanes as c}from"../../../geometry/support/frustumPlanes.js";import{Sphere as p}from"../../../geometry/support/sphere.js";import{sphereIntersectsInfiniteRadialConeConservative as d}from"../support/ElevationAgnosticVisibility.js";import{correctSphericalTileCornersForLatitude as m,computeSmallestSphericalTileCone as g,getSphericalTilePole as _}from"../support/sphericalTileUtils.js";import{createSphericalGlobePatch as f,updateEdgesAndCornersSpherical as v,updateEdgeElevationsAndResolutionsSpherical as x}from"./PatchGeometryFactory.js";import"../../../core/Collection.js";import"../../../geometry/ellipsoidUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../kernel.js";import"../../../request.js";import"../../../core/urlUtils.js";import"../../../core/RandomLCG.js";import"../../../core/Logger.js";import"../../../core/accessorSupport/watch.js";import"../../../core/accessorSupport/tracking/SimpleTrackingTarget.js";import"../../../layers/Layer.js";import"../../../geometry/Extent.js";import"./TerrainConst.js";import"./TilingScheme.js";import{Tile as j}from"./Tile.js";class M extends j{constructor(t,e,s,i,n){super(),this._convexHull=new Array(24),this._boundingConeAxis=a(),this._boundingConeHalfAngleSin=1,this._boundingSphere=new p,this._baseUsedMemory=1816,this.init(t,e,s,i,n)}init(s,i,n,o,r){super.init(s,i,n,o,r);const a=this.ellipsoid.radius,l=this.extentInRadians[0],h=this.extentInRadians[1],c=this.extentInRadians[2],p=this.extentInRadians[3],d=t(h,p,.5),m=t(l,c,.5),g=0===s?0:Math.min(Math.abs(h),Math.abs(p));this._edgeLen=(c-l)*Math.cos(g)*a,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=a-Math.sqrt(a*a-this._edgeLen2/4),u(this.centerAtSeaLevel,m,d,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])t[1].center=l,s(t[0],0,0,0),s(t[2],0,0,0),t[1].radius=this.ellipsoid.radius+this.elevationBoundsMax;else{this._updateCenter();const e=t[1],s=this.convexHull;let i=0;const n=e.center;for(let t=0;t<8;++t)i=Math.max(i,b(n,s,3*t));t[1].radius=Math.sqrt(i)}}_calculateFrustumVisibility(t,e){if(!h(t,this._boundingSphere))return 2;
|
|
2
|
+
import"../../../core/has.js";import{lerp as t}from"../../../core/mathUtils.js";import{normalize as e,set as s,add as i,scale as n,len as o,dot as r}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a,ZEROS as l}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as u}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{intersectsSphere as h,numPlanes as c}from"../../../geometry/support/frustumPlanes.js";import{Sphere as p}from"../../../geometry/support/sphere.js";import{sphereIntersectsInfiniteRadialConeConservative as d}from"../support/ElevationAgnosticVisibility.js";import{correctSphericalTileCornersForLatitude as m,computeSmallestSphericalTileCone as g,getSphericalTilePole as _}from"../support/sphericalTileUtils.js";import{createSphericalGlobePatch as f,updateEdgesAndCornersSpherical as v,updateEdgeElevationsAndResolutionsSpherical as x}from"./PatchGeometryFactory.js";import"../../../core/Collection.js";import"../../../geometry/ellipsoidUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../kernel.js";import"../../../request.js";import"../../../core/urlUtils.js";import"../../../core/RandomLCG.js";import"../../../core/Logger.js";import"../../../core/accessorSupport/watch.js";import"../../../core/accessorSupport/tracking/SimpleTrackingTarget.js";import"../../../layers/Layer.js";import"../../../geometry/Extent.js";import"./TerrainConst.js";import"./TilingScheme.js";import{Tile as j}from"./Tile.js";class M extends j{constructor(t,e,s,i,n){super(),this._convexHull=new Array(24),this._boundingConeAxis=a(),this._boundingConeHalfAngleSin=1,this._boundingSphere=new p,this._baseUsedMemory=1816,this.init(t,e,s,i,n)}init(s,i,n,o,r){super.init(s,i,n,o,r);const a=this.ellipsoid.radius,l=this.extentInRadians[0],h=this.extentInRadians[1],c=this.extentInRadians[2],p=this.extentInRadians[3],d=t(h,p,.5),m=t(l,c,.5),g=0===s?0:Math.min(Math.abs(h),Math.abs(p));this._edgeLen=(c-l)*Math.cos(g)*a,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=a-Math.sqrt(a*a-this._edgeLen2/4),u(this.centerAtSeaLevel,m,d,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])t[1].center=l,s(t[0],0,0,0),s(t[2],0,0,0),t[1].radius=this.ellipsoid.radius+this.elevationBoundsMax;else{this._updateCenter();const e=t[1],s=this.convexHull;let i=0;const n=e.center;for(let t=0;t<8;++t)i=Math.max(i,b(n,s,3*t));t[1].radius=Math.sqrt(i)}}_calculateFrustumVisibility(t,e){if(!h(t,this._boundingSphere))return 2;const{level:s}=this;if(s>=2&&null!=e&&0===this._getPatchType()&&!d(this._boundingConeAxis,this._boundingConeHalfAngleSin,e.center,e.radius))return 2;if(s<10)return 1;const i=this.convexHull,n=this.surface.view.state.camera.near;let o=!0;for(let r=0;r<c;r++){const e=4===r,s=t[r],a=s[0],l=s[1],u=s[2],h=s[3]-(e?n:0);let c=!1;for(let t=0;t<8;++t){const e=3*t;if(a*i[e]+l*i[e+1]+u*i[e+2]+h<0){if(c=!0,!o)break}else o=!1}if(!c)return 2}return o?0:1}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){f(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere()}_updateBoundingSphere(){const t=this._boundingSphere,e=this.elevationBoundsMin,s=this.elevationBoundsMax,r=this.ellipsoid.radius,a=s;if(0===this.level)t.center=l,t.radius=r+a;else{const a=this.extentInRadians,l=.5*(a[0]+a[2]),u=a[1],h=a[3];B(H,l,u,r),B(A,l,h,r),i(t.center,H,A);const c=r+.5*(e+s);n(t.center,t.center,c/o(t.center));const p=this.convexHull;let d=0;const m=(t,e)=>{const s=t[0]-p[3*e],i=t[1]-p[3*e+1],n=t[2]-p[3*e+2];return Math.sqrt(s*s+i*i+n*n)};for(let e=0;e<8;++e){const s=m(t.center,e);d=Math.max(d,s)}const g=d;t.radius=g+2}}_updateConvexHull(){const t=this.extentInRadians,s=this.ellipsoid.radius;if(0===this.level)return;const n=this.elevationBoundsMin,o=this.elevationBoundsMax,l=this._getPatchType(),u=this.surface.isWebMercator,h=u&&1===l,c=u&&2===l,p=c||h,d=Math.PI/2,_=t[0],f=t[2],v=c?-d:t[1],x=h?d:t[3],j=.5*(_+f),M=n,y=s+(p?Math.min(0,M-1):M),b=(t,e,s)=>B(t,e,s,y),S=a(),H=a(),A=a(),R=a();b(S,_,v),b(H,_,x),b(A,f,x),b(R,f,v);const L=(t,e)=>{for(let s=0;s<3;++s)this._convexHull[3*e+s]=t[s]};L(S,0),L(H,1),L(A,2),L(R,3);const T=o,P=s+(p?Math.max(0,T+1):T),V=a(),E=a(),I=a();B(E,j,x,y),B(I,j,v,y),i(V,E,I),e(V,V);const U=C;U[0]=S,U[1]=R,U[2]=A,U[3]=H,U[4]=I,U[5]=E,m(U,y),this._boundingConeHalfAngleSin=g(S,R,A,H,this._boundingConeAxis),L(S,0),L(H,1),L(A,2),L(R,3);const k=(t,e)=>{const s=P/r(e,V);for(let i=0;i<3;++i)this._convexHull[3*t+i]=e[i]*s};k(4,S),k(5,H),k(6,A),k(7,R)}_getPatchType(){const t=_(this.lij,this.spatialReference),e=2===t||3===t;return 1===t||3===t?e?3:1:e?2:0}intersectsRay(t,e,s,i){const n=this._boundingSphere,o=n.radius+s,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],a=n.center[0]-t[0],l=n.center[1]-t[1],u=n.center[2]-t[2],h=(a*e[0]+l*e[1]+u*e[2])/r,c=e[0]*h-a,p=e[1]*h-l,d=e[2]*h-u;return c*c+p*p+d*d<o*o}get minimumVerticesPerSide(){return this.level<y.length?y[this.level]+1:2}updateEdgeElevations(){v(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){x(this.renderData),this._updateBoundingVolumes()}_checkBVs(){}get convexHull(){return this._convexHull}}const y=[128,64,64,32,16,8,8,4];function b(t,e,s){return S(t[0],t[1],t[2],e[s],e[s+1],e[s+2])}function S(t,e,s,i,n,o){const r=i-t,a=n-e,l=o-s;return r*r+a*a+l*l}const B=(t,e,s,i)=>{const n=Math.cos(e),o=Math.sin(e),r=Math.cos(s),a=Math.sin(s);t[0]=i*r*n,t[1]=i*r*o,t[2]=i*a},C=[null,null,null,null,null,null],H=a(),A=a();export{M as SphericalPatch};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{copy as t,sub as e}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as o,copy as s,expandWithAABB as i}from"../../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as r}from"../../../../../geometry/support/DoubleArray.js";import{intersectsTransformedAabb as a}from"../../../../../geometry/support/frustumPlanes.js";import{intersectTriangleRangeForComponent as l,intersectTriangleRangeScreenPolygonForComponent as c,ComponentObjectElevationAgnosticComponentGeometryBVH as h}from"./ComponentObjectElevationAgnosticComponentGeometryBVH.js";import{ElevationAgnosticBVH as m}from"./ElevationAgnosticBVH.js";import{MeshIntersectionOptions as p,computeInvDir as _,intersectAabbInvDir as f}from"../../lib/RayIntersections.js";import{elevationAlignVertexGlobal as b}from"../../lib/triangleIntersectionUtils.js";class u{constructor(t,e,o,s,i,r,a,l){this.vertexData=t,this.vertexStride=e,this.indexData=o,this._componentData=s,this._componentAabbs3D=i,this.geometryMinZ=r,this.planetCenterZ=a,this.localMode=l,this.maxBspNodeDepth=6,this.minElementCountForBVH=10,this.minBspNodeElementCount=3,this._ray0=P,this._ray1=v,this._invDir=n(),this._componentVerticalOffsets=null,this._verticalOffset=null,this._tolerance=0,this._intersectionOptions=I,this._callback=
|
|
2
|
+
import{copy as t,sub as e}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as o,copy as s,expandWithAABB as i}from"../../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as r}from"../../../../../geometry/support/DoubleArray.js";import{intersectsTransformedAabb as a}from"../../../../../geometry/support/frustumPlanes.js";import{intersectTriangleRangeForComponent as l,intersectTriangleRangeScreenPolygonForComponent as c,ComponentObjectElevationAgnosticComponentGeometryBVH as h}from"./ComponentObjectElevationAgnosticComponentGeometryBVH.js";import{ElevationAgnosticBVH as m}from"./ElevationAgnosticBVH.js";import{MeshIntersectionOptions as p,computeInvDir as _,intersectAabbInvDir as f}from"../../lib/RayIntersections.js";import{elevationAlignVertexGlobal as b}from"../../lib/triangleIntersectionUtils.js";class u{constructor(t,e,o,s,i,r,a,l){this.vertexData=t,this.vertexStride=e,this.indexData=o,this._componentData=s,this._componentAabbs3D=i,this.geometryMinZ=r,this.planetCenterZ=a,this.localMode=l,this.maxBspNodeDepth=6,this.minElementCountForBVH=10,this.minBspNodeElementCount=3,this._ray0=P,this._ray1=v,this._invDir=n(),this._componentVerticalOffsets=null,this._verticalOffset=null,this._tolerance=0,this._intersectionOptions=I,this._callback=O,this._screenPolygonCallback=A,this._screenPolygonIntersector=null,this._screenPolygonQuery=null,this._screenPolygonTransformation=null,this._localModeOffsetDisplacement=new S,this._nodeAabbs3D=null,this.rayDirectionC=n(),this._intersectComponent=O,this._componentIndexMap=null,this._bvh=new m(s.count,this),this.componentIntersectionData=new Array(s.count)}get numComponents(){return this._componentData.count}get minZGlobal(){return this.geometryMinZ-this.planetCenterZ}getAabbs2D(){return this.localMode?this.getAabbs2DLocal():this.getAabbs2DGlobal()}getAabbs2DGlobal(){const{numComponents:t,planetCenterZ:e,minZGlobal:n}=this,o=r(4*t),s=this._componentAabbs3D;for(let i=0;i<t;++i){const t=6*i,r=s[t+0],a=s[t+1],l=s[t+2],c=s[t+3],h=s[t+4],m=n/(l-e),p=n/(s[t+5]-e),_=Math.min(r*m,r*p),f=Math.min(a*m,a*p),b=Math.max(c*m,c*p),u=Math.max(h*m,h*p),y=4*i;o[y+0]=_,o[y+1]=f,o[y+2]=b,o[y+3]=u}return o}getAabbs2DLocal(){const{numComponents:t}=this,e=r(4*t),n=this._componentAabbs3D;for(let o=0;o<t;++o){const t=6*o,s=n[t+0],i=n[t+1],r=n[t+3],a=n[t+4],l=4*o;e[l+0]=s,e[l+1]=i,e[l+2]=r,e[l+3]=a}return e}intersectRay(t,e,n,o,s,i){const{isVerticalRay:r}=n,a=this._componentVerticalOffsets,l=this._verticalOffset,c=this._componentIndexMap,h=this._intersectComponent,m=this._callback;this._ray0=t,this._ray1=e,this._componentVerticalOffsets=s??null,this._verticalOffset=i??null,this._tolerance=n.tolerance,this._intersectionOptions=n,this._intersectComponent=this._intersectComponentRay,this._componentIndexMap=this._bvh.elementIndexMap,_(t,e,this._invDir),this._callback=o;try{this._bvh.intersectRay(t,e,r)}finally{this._callback=m,this._componentVerticalOffsets=a,this._verticalOffset=l,this._componentIndexMap=c,this._intersectComponent=h}}*intersectScreenPolygon(t,e,n,o,s,i){this._componentVerticalOffsets=s??null,this._verticalOffset=i??null,this._screenPolygonIntersector=t,this._screenPolygonQuery=e,this._screenPolygonTransformation=n,this._screenPolygonCallback=o,this._componentIndexMap=this._bvh.elementIndexMap,this._intersectComponent=this._intersectComponentScreenPolygon,yield*this._bvh.intersectNodesGenerator((t,e)=>this._intersectScreenPolygonNode(t,e)),this._componentIndexMap=null,this._componentVerticalOffsets=null,this._verticalOffset=null,this._screenPolygonCallback=A,this._screenPolygonTransformation=null,this._screenPolygonQuery=null,this._screenPolygonIntersector=null,this._intersectComponent=O}intersectRange(t,e){this._forEachIntersectableComponent(t,e,t=>{this._intersectComponent(t)})}*intersectRangeGenerator(t,e){const n=this._componentIndexMap,o=this._componentData;for(let s=t;s<e;++s){const t=n?n[s]:s;o.isPickable(t)&&o.isVisible(t)&&(this._intersectComponent(t),yield)}}getComponentTriangleCount(t){const e=this._componentData.offsets,n=e[t]/3;return e[t+1]/3-n}getComponentAabb3D(t,e){const n=this._componentAabbs3D,o=6*t;return e[0]=n[o],e[1]=n[o+1],e[2]=n[o+2],e[3]=n[o+3],e[4]=n[o+4],e[5]=n[o+5],e}_intersectComponentRay(n){const o=this.getComponentAabb3D(n,y);let s=!1;const{localMode:i,_componentVerticalOffsets:r,_verticalOffset:a,_ray0:c,_ray1:h,_invDir:m,planetCenterZ:p,_tolerance:_,rayDirectionC:u}=this,{isVerticalRay:g}=this._intersectionOptions,d=this._componentData.offsets,D=t(C,c),P=t(x,h),v=r?.[n]??0,O=v+(a?.offset??0);if(0!==O&&(i?(D[2]=c[2]-O,P[2]=h[2]-O,s=!0):(null!=a&&(a.componentOffset=v),g&&(b(D,-O,p,c),b(P,-O,p,h),s=!0))),null==a||s||0===O||a.applyToAabb(o),!f(o,D,m,_))return;e(u,P,D);const A=d[n]/3,I=d[n+1]/3,S=I-A,V=(t,e,o,s)=>this._callback(t,e,o,s,n),{vertexData:T,vertexStride:R,indexData:k,_intersectionOptions:N}=this,{normalRequired:j}=N;if(S>M){this._getOrCreateComponentGeometryBvh(n,A,I).intersectRay(D,P,g,s?0:O,V,j)}else{l(D,u,A,I,k,T,R,s?0:O,p,j,V)}}_intersectComponentScreenPolygon(t){const e=this._screenPolygonIntersector,n=this._screenPolygonQuery;if(null==e||null==n)return;const o=this.getComponentAabb3D(t,y),{_screenPolygonTransformation:i,_screenPolygonCallback:r,vertexData:l,vertexStride:h,indexData:m}=this,p=this._getScreenPolygonElevationDisplacement(t),_=null!=p?p.applyToAabb(s(g,o)):o;if(!a(n.broadPhaseFrustum,_,i))return;const f=this._componentData.offsets,b=f[t]/3,u=f[t+1]/3;if(u-b>M){return void this._getOrCreateComponentGeometryBvh(t,b,u).intersectScreenPolygon(e,i,n,p,(e,n,o)=>{r(e,n,t,o)})}const d=c(e,i,n,b,u,m,l,h,p);null!=d&&r(d.distance,d.primitiveIndex,t,d.point)}_intersectScreenPolygonNode(t,e){const n=this._screenPolygonQuery;if(null==n)return!1;const o=this._getScreenPolygonNodeAabb(t,e,g),{_screenPolygonTransformation:s}=this;return a(n.broadPhaseFrustum,o,s)}_forEachIntersectableComponent(t,e,n){const o=this._componentIndexMap,s=this._componentData;for(let i=t;i<e;++i){const t=o?o[i]:i;s.isPickable(t)&&s.isVisible(t)&&n(t)}}_getOrCreateComponentGeometryBvh(t,e,n){let o=this.componentIntersectionData[t];return null==o&&(o=new h(t,this.vertexData,this.vertexStride,this.indexData,e,n,this._componentAabbs3D[6*t+2],this._componentAabbs3D[6*t+5],this.geometryMinZ,this.planetCenterZ,this.localMode),this.componentIntersectionData[t]=o),o}_getScreenPolygonElevationDisplacement(t){const e=this._componentVerticalOffsets?.[t]??0;return this._getScreenPolygonDisplacementForOffset(e)}_getScreenPolygonDisplacementForOffset(t){const e=this._verticalOffset;return null!=e?0===t&&0===e.offset?null:(e.componentOffset=t,e):this.localMode&&0!==t?(this._localModeOffsetDisplacement.offset=t,this._localModeOffsetDisplacement):null}_getScreenPolygonNodeAabb(t,e,n){const o=this._getNodeAabb3D(t,e,n),[r,a]=this._getNodeComponentOffsetRange(t);if(r===a)return this._applyScreenPolygonDisplacementToAabb(o,r);const l=this._applyScreenPolygonDisplacementToAabb(s(d,o),r),c=this._applyScreenPolygonDisplacementToAabb(s(D,o),a);return i(l,c,n),n}_applyScreenPolygonDisplacementToAabb(t,e){const n=this._getScreenPolygonDisplacementForOffset(e);return null!=n?n.applyToAabb(t):t}_getNodeAabb3D(t,e,n){const r=this._nodeAabbs3D??=[],a=r[e];if(null!=a)return s(n,a);const l=this._componentIndexMap;let c=!1;for(let o=t.minIndexIndex;o<t.maxIndexIndex;++o){const t=l?l[o]:o,e=this.getComponentAabb3D(t,d);c?i(n,e):(s(n,e),c=!0)}const h=o();return s(h,n),r[e]=h,n}_getNodeComponentOffsetRange(t){const e=this._componentVerticalOffsets;if(null==e)return[0,0];const n=this._componentIndexMap;let o=0,s=0,i=!1;for(let r=t.minIndexIndex;r<t.maxIndexIndex;++r){const t=e[n?n[r]:r]??0;i?(o=Math.min(o,t),s=Math.max(s,t)):(o=t,s=t,i=!0)}return i?[o,s]:[0,0]}}const y=o(),g=o(),d=o(),D=o(),C=n(),x=n(),P=n(),v=n(),O=()=>{},A=()=>{},I=new p,M=40;class S{constructor(){this.offset=0}applyToVertex(t,e,n,o){return t[0]=e,t[1]=n,t[2]=o+this.offset,t}applyToAabb(t){return t[2]+=this.offset,t[5]+=this.offset,t}}export{u as ComponentObjectElevationAgnosticComponentBVH};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{MixExternalColor as e}from"../util/MixExternalColor.glsl.js";import{NoPerspectiveRead as t}from"../util/NoPerspective.glsl.js";import{addCameraPosition as i,addPixelRatio as o}from"../util/View.glsl.js";import{Float4PassUniform as
|
|
2
|
+
import{MixExternalColor as e}from"../util/MixExternalColor.glsl.js";import{NoPerspectiveRead as t}from"../util/NoPerspective.glsl.js";import{addCameraPosition as i,addPixelRatio as o}from"../util/View.glsl.js";import{Float4PassUniform as r}from"../../shaderModules/Float4PassUniform.js";import{FloatBindUniform as l}from"../../shaderModules/FloatBindUniform.js";import{FloatPassUniform as p}from"../../shaderModules/FloatPassUniform.js";import{glsl as s,If as a}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";import{isImagePattern as c}from"../../../materials/lineStippleUtils.js";import{computeTextureSize as d}from"../../../materials/stippleTextureRepository.js";import{ensureColor4 as f}from"../../../shaders/ensureColor4.js";function m(c,d){if(!d.stippleEnabled)return void c.fragment.code.add(s`float getStippleAlpha(float lineWidth) { return 1.0; }
|
|
3
3
|
void discardByStippleAlpha(float stippleAlpha, float threshold) {}
|
|
4
|
-
vec4 blendStipple(vec4 color, float stippleAlpha) { return color; }`);const m=!(d.draped&&d.stipplePreferContinuous),{vertex:
|
|
4
|
+
vec4 blendStipple(vec4 color, float stippleAlpha) { return color; }`);const m=!(d.draped&&d.stipplePreferContinuous),{vertex:S,fragment:u}=c;d.draped||(i(S,d),S.uniforms.add(new l("worldToScreenPerDistanceRatio",({camera:e})=>1/e.perScreenPixelRatio)).code.add(s`float computeWorldToScreenRatio(vec3 segmentCenter) {
|
|
5
5
|
float segmentDistanceToCamera = length(segmentCenter - cameraPosition);
|
|
6
6
|
return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
|
|
7
|
-
}`)),c.varyings.add("vStippleDistance","float"),c.varyings.add("vStippleDistanceLimits","vec2"),c.varyings.add("vStipplePatternStretch","float"),
|
|
7
|
+
}`)),c.varyings.add("vStippleDistance","float"),c.varyings.add("vStippleDistanceLimits","vec2"),c.varyings.add("vStipplePatternStretch","float"),S.code.add(s`
|
|
8
8
|
float discretizeStippleDistanceToScreenRatio(float stippleDistanceToScreenRatio) {
|
|
9
|
-
float step = ${
|
|
9
|
+
float step = ${s.float(g)};
|
|
10
10
|
|
|
11
11
|
float discreteStippleDistanceToScreenRatio = log(stippleDistanceToScreenRatio);
|
|
12
12
|
discreteStippleDistanceToScreenRatio = ceil(discreteStippleDistanceToScreenRatio / step) * step;
|
|
13
13
|
discreteStippleDistanceToScreenRatio = exp(discreteStippleDistanceToScreenRatio);
|
|
14
14
|
return discreteStippleDistanceToScreenRatio;
|
|
15
15
|
}
|
|
16
|
-
`),o(
|
|
16
|
+
`),o(S),S.code.add(s`
|
|
17
17
|
vec2 computeStippleDistanceLimits(float startPseudoScreen, float segmentLengthPseudoScreen, float segmentLengthScreen, float patternLength) {
|
|
18
18
|
|
|
19
19
|
// First check if the segment is long enough to support fully screen space patterns.
|
|
@@ -35,7 +35,7 @@ return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
|
|
|
35
35
|
}
|
|
36
36
|
return vec2(startPseudoScreen, startPseudoScreen + segmentLengthPseudoScreen);
|
|
37
37
|
}
|
|
38
|
-
`),
|
|
38
|
+
`),u.uniforms.add(new n("stipplePatternTexture",e=>e.stippleTexture),new p("stipplePatternPixelSizeInv",e=>1/v(e))),d.stippleOffColorEnabled&&u.uniforms.add(new r("stippleOffColor",e=>f(e.stippleOffColor))),c.include(t);const h=d.worldSized&&d.imagePattern,{usePerspectiveCorrectStipple:P}=d,C=!d.worldSized;P&&c.varyings.add("vStipplePerspective","vec4"),h?(c.varyings.add("vStippleV","float"),c.fragment.include(e),u.code.add(s`vec4 getStippleColor(out bool isClamped) {
|
|
39
39
|
vec2 aaCorrectedLimits = vStippleDistanceLimits + vec2(1.0, -1.0) / gl_FragCoord.w;
|
|
40
40
|
isClamped = vStippleDistance < aaCorrectedLimits.x || vStippleDistance > aaCorrectedLimits.y;
|
|
41
41
|
float u = vStippleDistance * stipplePatternPixelSizeInv;
|
|
@@ -59,15 +59,26 @@ int mixMode = 1;
|
|
|
59
59
|
vec3 col = mixExternalColor(color.rgb, vec3(1.0), stippleColor.rgb, mixMode);
|
|
60
60
|
float opacity = mixExternalOpacity(color.a, 1.0, stippleColor.a, mixMode);
|
|
61
61
|
return vec4(col, opacity);
|
|
62
|
-
}`)):
|
|
62
|
+
}`)):u.code.add(s`
|
|
63
63
|
float getStippleSDF(out bool isClamped) {
|
|
64
64
|
float stippleDistance = noPerspectiveRead(${C?"clamp(vStippleDistance, vStippleDistanceLimits.x, vStippleDistanceLimits.y)":"vStippleDistance"});
|
|
65
65
|
float lineSizeInv = noPerspectiveRead(vLineSizeInv);
|
|
66
66
|
|
|
67
|
-
${
|
|
67
|
+
${a(P,s`
|
|
68
|
+
// Convert screen-space progress to progress along the 3D segment using the endpoints' inverse clip-W values.
|
|
69
|
+
// This keeps dash lengths constant in world units, so farther dashes appear shorter on screen.
|
|
70
|
+
vec4 stipplePerspective = noPerspectiveRead(vStipplePerspective);
|
|
71
|
+
float segmentLength = stipplePerspective.y - stipplePerspective.x;
|
|
72
|
+
float segmentFactor = segmentLength > 0.0 ? (stippleDistance - stipplePerspective.x) / segmentLength : 0.0;
|
|
73
|
+
float interpolatedInverseW = mix(stipplePerspective.z, stipplePerspective.w, segmentFactor);
|
|
74
|
+
float perspectiveFactor = segmentFactor * stipplePerspective.w / interpolatedInverseW;
|
|
75
|
+
stippleDistance = mix(stipplePerspective.x, stipplePerspective.y, perspectiveFactor);
|
|
76
|
+
`)}
|
|
77
|
+
|
|
78
|
+
${C?s`
|
|
68
79
|
vec2 aaCorrectedLimits = vStippleDistanceLimits + vec2(1.0, -1.0) / gl_FragCoord.w;
|
|
69
80
|
isClamped = vStippleDistance < aaCorrectedLimits.x || vStippleDistance > aaCorrectedLimits.y;
|
|
70
|
-
`:
|
|
81
|
+
`:s`isClamped = false;`}
|
|
71
82
|
|
|
72
83
|
float u = stippleDistance * stipplePatternPixelSizeInv * lineSizeInv;
|
|
73
84
|
u = fract(u);
|
|
@@ -92,8 +103,8 @@ return vec4(col, opacity);
|
|
|
92
103
|
vec4 blendStipple(vec4 color, float stippleAlpha) {
|
|
93
104
|
return ${d.stippleOffColorEnabled?"mix(color, stippleOffColor, stippleAlpha)":"vec4(color.rgb, color.a * stippleAlpha)"};
|
|
94
105
|
}
|
|
95
|
-
`),
|
|
106
|
+
`),u.code.add(s`
|
|
96
107
|
void discardByStippleAlpha(float stippleAlpha, float threshold) {
|
|
97
|
-
${
|
|
108
|
+
${a(!d.stippleOffColorEnabled,"if (stippleAlpha < threshold) { discard; }")}
|
|
98
109
|
}
|
|
99
|
-
`)}function
|
|
110
|
+
`)}function v(e){const t=e.stipplePattern;return c(t)?t.length:t?d(t)/t.pixelRatio:1}const g=.4;export{m as LineStipple,v as computePixelSize};
|