@arcgis/core 6.0.0-next.34 → 6.0.0-next.35
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/Basemap.d.ts +2 -2
- package/analysis/ShadowCastAnalysis.d.ts +11 -5
- package/arcgisGlobal.d.ts +1 -0
- package/assets/esri/core/libs/libtess/libtess-f32.wasm +0 -0
- package/assets/esri/core/libs/libtess/libtess-f64.wasm +0 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/01f55004d64309f8538b.js +1 -0
- package/assets/esri/core/workers/chunks/0202eb8c2b2865f99981.js +1 -0
- package/assets/esri/core/workers/chunks/{67e533748435253aaba6.js → 0284f608d25c654fcc11.js} +1 -1
- package/assets/esri/core/workers/chunks/{7810586c35dfe1437516.js → 06102715e9a8f218e07c.js} +1 -1
- package/assets/esri/core/workers/chunks/{6029773458ab98600f67.js → 07e5482e1fc69be5de09.js} +1 -1
- package/assets/esri/core/workers/chunks/08140725277de5d2e41a.js +1 -0
- package/assets/esri/core/workers/chunks/{2d9a1f23ec6ce90723ac.js → 0d99bfb75dcb9fa29080.js} +1 -1
- package/assets/esri/core/workers/chunks/10ad7b35b6800d40444e.js +1 -0
- package/assets/esri/core/workers/chunks/1132e28aaa5825b10b6e.js +1 -0
- package/assets/esri/core/workers/chunks/{dd30b02c5978c1c5f511.js → 155861fbd0e5fc2db80c.js} +1 -1
- package/assets/esri/core/workers/chunks/165ca7a97b611c8f26c4.js +1 -0
- package/assets/esri/core/workers/chunks/1ae0c9345626e70affd3.js +2 -0
- package/assets/esri/core/workers/chunks/{cd355baab983033c3ef0.js → 1ec772eaa63eb6937231.js} +1 -1
- package/assets/esri/core/workers/chunks/{5c04835b0b52461183cd.js → 1fd82fcba2758741996a.js} +1 -1
- package/assets/esri/core/workers/chunks/21e1d423ee33f916547e.js +1 -0
- package/assets/esri/core/workers/chunks/{e8e54faf947a582b4cf7.js → 247617c0dbae2386ab3b.js} +1 -1
- package/assets/esri/core/workers/chunks/{97ec46605f16333144b7.js → 26ea39dfdf887f357fce.js} +1 -1
- package/assets/esri/core/workers/chunks/{85de980c5b296ec69323.js → 279089a6a3f08022c678.js} +1 -1
- package/assets/esri/core/workers/chunks/{b657363113f4a37e634b.js → 3223f9fbc76ba9ef8d13.js} +1 -1
- package/assets/esri/core/workers/chunks/322b22a5d54e404bebd5.js +1 -0
- package/assets/esri/core/workers/chunks/{122e75b21699a4e83b15.js → 338d800d4efcc91cead1.js} +1 -1
- package/assets/esri/core/workers/chunks/3537fe95b83a13b156cc.js +1 -0
- package/assets/esri/core/workers/chunks/{f09bc86cd52224febfcb.js → 3b380e64566a6cce59e2.js} +1 -1
- package/assets/esri/core/workers/chunks/{a1e8209d00809c9520a0.js → 3fe4c89acd325d36618d.js} +1 -1
- package/assets/esri/core/workers/chunks/449a2dee17b54946f245.js +1 -0
- package/assets/esri/core/workers/chunks/{311e4969f19df63451dd.js → 4e5405134d079bdf9b7a.js} +1 -1
- package/assets/esri/core/workers/chunks/{d070fcb73ce274ab80e4.js → 5504ec9bd9ee4d10af07.js} +1 -1
- package/assets/esri/core/workers/chunks/552c36b40e5a5ec117fb.js +1 -0
- package/assets/esri/core/workers/chunks/5622f3faa59434772857.js +1 -0
- package/assets/esri/core/workers/chunks/59a1b637d2c107504a04.js +1 -0
- package/assets/esri/core/workers/chunks/59a88dd53f8806bbec06.js +1 -0
- package/assets/esri/core/workers/chunks/5c2fe67527c9d7b4dba3.js +1 -0
- package/assets/esri/core/workers/chunks/5d781c2c6204cffffd0d.js +1 -0
- package/assets/esri/core/workers/chunks/61d36730564c5ac5edab.js +1 -0
- package/assets/esri/core/workers/chunks/6604272ef6fe85279032.js +1 -0
- package/assets/esri/core/workers/chunks/{90c1d10eae7ae71889b0.js → 7400b8c454b47ee4fb3c.js} +1 -1
- package/assets/esri/core/workers/chunks/796c6195b6bf59dcc9bd.js +1 -0
- package/assets/esri/core/workers/chunks/7b45ac83e279fe9516a5.js +1 -0
- package/assets/esri/core/workers/chunks/{2de077c7b971f2c215a6.js → 7ddbde8fdd1cf3c53f50.js} +1 -1
- package/assets/esri/core/workers/chunks/804606b194dc9e71d088.js +1 -0
- package/assets/esri/core/workers/chunks/8102f0bf5707c3be3310.js +1 -0
- package/assets/esri/core/workers/chunks/{676c8c0329d68f9f3ac4.js → 81bcc495e6eaf2cf7474.js} +1 -1
- package/assets/esri/core/workers/chunks/{d1d6154b4af1c9cc497b.js → 934e1f2153e6fad6ed23.js} +1 -1
- package/assets/esri/core/workers/chunks/{e096c1d9d53af74d3207.js → 990e96139b5a1dccb061.js} +1 -1
- package/assets/esri/core/workers/chunks/{f28b63c1179366dac8a2.js → 9e2c30b67bab5795306e.js} +1 -1
- package/assets/esri/core/workers/chunks/{9184c947cdefe06bf551.js → a18c3cbe505a19d29569.js} +1 -1
- package/assets/esri/core/workers/chunks/aa6ee2aa4ff6e6d41efb.js +1 -0
- package/assets/esri/core/workers/chunks/{3fd5c3cd8457ddc68798.js → aa779896fd9e5c341349.js} +1 -1
- package/assets/esri/core/workers/chunks/ac10c7d2c4829a150037.js +1 -0
- package/assets/esri/core/workers/chunks/{e0a7a75709121a26f255.js → afc8a9847f31bb66b13b.js} +1 -1
- package/assets/esri/core/workers/chunks/c7adb7b77721c75891f4.js +1 -0
- package/assets/esri/core/workers/chunks/{bead830a677690eeb6fb.js → ce8ef2eec290e1df6b2a.js} +1 -1
- package/assets/esri/core/workers/chunks/d3369ffed19f4c264dcd.js +1 -0
- package/assets/esri/core/workers/chunks/d3412518a7b518860fbb.js +1 -0
- package/assets/esri/core/workers/chunks/{3048e74e6246324ce6fc.js → d5916500514a41a4758f.js} +1 -1
- package/assets/esri/core/workers/chunks/{c034c30e577d620b8e28.js → dac69c0047488fdf986d.js} +1 -1
- package/assets/esri/core/workers/chunks/dcc782e4bf9e8a8202f9.js +1 -0
- package/assets/esri/core/workers/chunks/dcdf837a452dc0cac582.js +1 -0
- package/assets/esri/core/workers/chunks/{19a4fa965b70fc6f78f6.js → e209cb1f3f14bf576ebe.js} +1 -1
- package/assets/esri/core/workers/chunks/e67ea2f1714e5abeae44.js +1 -0
- package/assets/esri/core/workers/chunks/e8fb2ba7b7a4f0916325.js +1 -0
- package/assets/esri/core/workers/chunks/efcd38aad9aa667001b2.js +1 -0
- package/assets/esri/core/workers/chunks/{3aafdb905c697bc9b1ad.js → f372f4eb5527238c46f5.js} +1 -1
- package/assets/esri/core/workers/chunks/f497968055af459c5da4.js +1 -0
- package/assets/esri/core/workers/chunks/f7123ba1286f64e13e91.js +1 -0
- package/assets/esri/core/workers/chunks/fcb4707c2e95099b9f30.js +1 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/chunks/BlurEmission.glsl.js +9 -4
- package/chunks/Terrain.glsl.js +9 -9
- package/chunks/libtess-f32.js +1 -1
- package/chunks/libtess-f64.js +1 -1
- package/chunks/lyr3DMain.js +1 -1
- package/chunks/lyr3DWorker.js +2 -2
- package/config.d.ts +3 -3
- package/config.js +1 -1
- package/core/mathUtils.js +1 -1
- package/form/FormTemplate.d.ts +1 -1
- package/geometry/libtess.js +1 -1
- package/geometry/projection/projectors.js +1 -1
- package/identity/Credential.d.ts +1 -1
- package/identity/IdentityManager.d.ts +1 -1
- package/identity/OAuthInfo.d.ts +1 -1
- package/identity/ServerInfo.d.ts +1 -1
- package/kernel.js +1 -1
- package/layers/CSVLayer.js +1 -1
- package/layers/GaussianSplatLayer.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/VectorTileLayer.d.ts +2 -2
- package/layers/VideoLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/sources/CSVSource.js +1 -1
- package/layers/graphics/sources/GeoJSONSource.js +1 -1
- package/layers/graphics/sources/MemorySource.js +2 -2
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/graphics/sources/support/timeQueryUtils.js +2 -0
- package/layers/mixins/APIKeyMixin.d.ts +1 -1
- package/layers/ogc/types.d.ts +1 -1
- package/layers/support/TelemetryData.d.ts +28 -4
- package/layers/support/TimeInformation.js +1 -1
- package/layers/support/tiles3DUtils.js +1 -1
- package/layers/support/timeInfoUtils.js +2 -0
- package/layers/video/videoUtils.js +1 -1
- package/package.json +2 -2
- package/rest/query/executeAttributeBinsQuery.js +1 -1
- package/rest/query/executeForExtent.js +1 -1
- package/rest/query/executeForTopCount.js +1 -1
- package/rest/query/executeForTopExtents.js +1 -1
- package/rest/query/executeForTopIds.js +1 -1
- package/rest/query/executeTopFeaturesQuery.js +1 -1
- package/rest/query/operations/query.js +1 -1
- package/rest/query/operations/queryAttributeBins.js +1 -1
- package/rest/query/operations/queryTopFeatures.js +1 -1
- package/rest/support/timeUtils.js +1 -1
- package/views/2d/engine/webgl/FeatureDisplayList.js +1 -1
- package/views/2d/engine/webgl/GlyphMosaic.js +1 -1
- package/views/2d/engine/webgl/GlyphWorker.js +1 -1
- package/views/2d/engine/webgl/TextureManager.js +1 -1
- package/views/2d/engine/webgl/materialKeyUtils.js +2 -0
- package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedPolyMeshWriters.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
- package/views/2d/layers/VideoLayerView2D.js +1 -1
- package/views/3d/analysis/ShadowCast/ShadowCastError.d.ts +40 -0
- package/views/3d/analysis/ShadowCast/ShadowCastError.js +2 -0
- package/views/3d/analysis/ShadowCast/sunlightUtils.js +2 -0
- package/views/3d/analysis/ShadowCastAnalysisView3D.d.ts +16 -1
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/camera/constraintUtils/surfaceCollision.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/Lyr3DWorker.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/support/FeatureMemory.js +1 -1
- package/views/3d/layers/support/FeatureTile.js +1 -1
- package/views/3d/navigation/modes/GroundNavigationMode3D.js +1 -1
- package/views/3d/state/Constraints.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/state/utils/groundNavigationUtils.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/support/sphereExtentUtils.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/terrain/tileUtils.js +1 -1
- package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl.d.ts +1 -1
- package/views/support/Scheduler.js +1 -1
- package/widgets/Directions.d.ts +1 -1
- package/assets/esri/core/workers/chunks/0f6c0d42100c21367e5c.js +0 -1
- package/assets/esri/core/workers/chunks/176d0a06ebff5a29dedf.js +0 -1
- package/assets/esri/core/workers/chunks/18776a130d96879a68b1.js +0 -1
- package/assets/esri/core/workers/chunks/20a698709c3c11ff2c16.js +0 -1
- package/assets/esri/core/workers/chunks/24ada9511b074dc5ae27.js +0 -1
- package/assets/esri/core/workers/chunks/277263466837e1673f56.js +0 -1
- package/assets/esri/core/workers/chunks/2c8ca43563c4f3e94535.js +0 -1
- package/assets/esri/core/workers/chunks/379ef56f6b32494832a6.js +0 -1
- package/assets/esri/core/workers/chunks/38d852676677e5697864.js +0 -1
- package/assets/esri/core/workers/chunks/38df7b1d58c4bcf693d0.js +0 -1
- package/assets/esri/core/workers/chunks/507ecc3692e6d0700958.js +0 -1
- package/assets/esri/core/workers/chunks/5a9b7eb26f936f03d02e.js +0 -1
- package/assets/esri/core/workers/chunks/5f07f52bb8b7721f08d3.js +0 -1
- package/assets/esri/core/workers/chunks/661847f1b7044f21600f.js +0 -1
- package/assets/esri/core/workers/chunks/6b5c073dddd89d06ed80.js +0 -1
- package/assets/esri/core/workers/chunks/6ddc29a144640acb1192.js +0 -1
- package/assets/esri/core/workers/chunks/6ebe73f69ae822053b70.js +0 -1
- package/assets/esri/core/workers/chunks/6f6d1873753a9c6994aa.js +0 -1
- package/assets/esri/core/workers/chunks/7582654a0fc70910731c.js +0 -1
- package/assets/esri/core/workers/chunks/7e211d8a8ad6c6a7cf3e.js +0 -1
- package/assets/esri/core/workers/chunks/849f446c718e892f39ce.js +0 -1
- package/assets/esri/core/workers/chunks/8517d96fc8ba7b21d845.js +0 -2
- package/assets/esri/core/workers/chunks/a107f16cd004626b5018.js +0 -1
- package/assets/esri/core/workers/chunks/a65951f1d5702cfd996e.js +0 -1
- package/assets/esri/core/workers/chunks/bf62be00f3040f91aaee.js +0 -1
- package/assets/esri/core/workers/chunks/c570b90995c65bbb2e14.js +0 -1
- package/assets/esri/core/workers/chunks/c576bef77e34920af188.js +0 -1
- package/assets/esri/core/workers/chunks/caad4f475d6eb01c2850.js +0 -1
- package/assets/esri/core/workers/chunks/cf1ec61eb2ad147bb931.js +0 -1
- package/assets/esri/core/workers/chunks/daae21cf77864f3293ef.js +0 -1
- package/assets/esri/core/workers/chunks/dc2f93453dfa40f623ab.js +0 -1
- package/assets/esri/core/workers/chunks/e81173724e8de8c1e65b.js +0 -1
- package/assets/esri/core/workers/chunks/e83f9abee611c5b80009.js +0 -1
- package/assets/esri/core/workers/chunks/ec8b7476eac4718eb0ac.js +0 -1
- package/assets/esri/core/workers/chunks/f45064066e1ab041a0b2.js +0 -1
- package/assets/esri/core/workers/chunks/ffe49d9e7df081bef4a5.js +0 -1
- package/views/2d/engine/webgl/hashMosaic.js +0 -2
- /package/assets/esri/core/workers/chunks/{8517d96fc8ba7b21d845.js.LICENSE.txt → 1ae0c9345626e70affd3.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/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 n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as r}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as i}from"../../../../geometry/support/sphere.js";import{NodeBoundingData as a,Node as o,NodeTraversalState as s}from"./I3SNode.js";import{addWraparound as c}from"./I3SUtil.js";import{ValidatedNode as l}from"./ValidatedNode.js";import{ElevationRange as u}from"../../support/ElevationRange.js";import{Obb as d}from"../../support/orientedBoundingBox.js";class f{constructor(e,t,n,r,i){this.childOffset=e,this.childCount=t,this.visibilityCache=n,this._boundingData=r,this.node=i,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 p{constructor(e=[],t=[]){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(let 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 m{get _useNodePages(){return this._pageSize>0}constructor(t,n,r,i,o,s,c,l,u,d,f,m,h,_,y){if(this.viewingMode=t,this._layer=n,this._requester=i,this._clientNodeLoader=o,this._viewportQueries=s,this._logger=c,this.holeFilling=l,this._isLoaded=u,this._isReloading=d,this._shouldLoadNode=f,this._enable=m,this._needsUpdate=h,this._computeVisibilityObb=_,this._computeNodeFiltering=y,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=-1/0,this._maxProcessingPrio=1/0,this._version=v(0),this._visibilityCacheVersion=v(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._progressiveLoadPenaltyWeight=10,this._missingPagesAndNodes=new Set,this._prioritizedMissingNodeAndPageIds=[],this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=[],this._updates=new g(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this._pageQueue=[],this._newPages=[],this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=n.associatedLayer?.infoFor3D!=null,n.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${n.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,r.type===`page`){let e=r.rootPage;switch(this.urlPrefix=r.urlPrefix,this._pageSize=r.pageSize,r.lodMetric){case`maxScreenThreshold`:this._lodMetric=1;break;case`maxScreenThresholdSQ`:this._lodMetric=1,this._lodConversion=k}if(this._isEditable){this._rootIndex=-1;let t=C(r.rootIndex,r.pageSize),n=e.nodes[t],i={nodes:[{index:this._rootIndex,children:[r.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(S(this._rootIndex,this._pageSize),i),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=r.rootIndex;this._addPage(S(r.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if(r.type===`node`){this.urlPrefix=r.urlPrefix;let e=new p;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new p;let e={id:`-1`,version:null,mbs:r.rootNode.mbs,obb:r.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:`root`,href:`../root`,mbs:r.rootNode.mbs,obb:r.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new a(e.id),-1);let t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new a(r.rootNode.id),-1);let t=this._validateNode(r.rootNode.id,r.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){let n=new a(e,t),r=this._makeClientRefNode(n,-1);return this._linkChildToParentNode(-1,r),this.requestUpdate(),r}removeClientNodeFromIndex(e,t,n){this._destroyClientRefNode(e,t,n),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e)){this._logger.error(`Requested load page [${e}] already loaded`);return}if(this._loadingPages.has(e)){this._logger.error(`Requested load page [${e}] already loading`);return}this._loadingPages.add(e);let n=this.urlPrefix+e;this._requester.request(n,`json`).then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(n=>{this._loadingPages.delete(e),t(n)||(this._failedPages.add(e),this._logger.error(`#loadPage()`,this._layer,`Error when loading page ${e}`,n))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){let{pageIndex:t,page:n}=this._pageQueue.shift();this._addPage(t,n),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;)this._nodePages.get(this._newPages.shift())?.nodes.forEach(e=>{let t=e.parentIndex;for(;t!=null&&t!==this._rootIndex;){let e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}_addPage(e,t){if(this._nodePages.has(e)){this._logger.error(`Page[${e}] reloaded`);return}let n=[],r=[],a=t.nodes.map((t,a)=>{let s=n.length,c=t.children?t.children.length:0;r.push(this._rootIndex);for(let e=0;e<c;e++)n.push(t.children[e]);let l=`${t.index}`,u=d.fromJSON(t.obb),p=new i(u.getCenter(N),u.radius),m=t.mesh?.attribute,h=t.mesh?.geometry,g=t.mesh?.material,v={hasSharedResource:!1,isEmpty:h==null,attributes:m?.resource==null?void 0:`${m.resource}`,geometry:h?.resource==null?void 0:`${h.resource}`,texture:g?.resource==null?void 0:`${g.resource}`,geometryDefinition:h?h.definition:-1,materialDefinition:g?g.definition:-1},y=new o(l,w(a,e,this._pageSize),p,c,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),h?.featureCount??null,u);return y.visibilityObbInRenderSR=this._computeVisibilityObb(y),y.vertexCount=h?h.vertexCount:0,new f(s,c,_(this._visibilityCacheVersion),null,y)}),s=new p(a,n);e===-1?this._clientNodePage=s:this._nodePages.set(e,s)}_updateParentsAndLevel(){let e=[],t=(t,n,r)=>{let i=this._getPage(t);if(i!=null){let a=C(t,this._pageSize),o=i.nodes[a];o.parentIndex=n??-1;let s=o.node;s!=null&&(s.level=r,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){let n=e.pop(),r=this.getNode(n);if(r!=null)for(let e=0;e<r.childCount;e++)t(this.getChildIndex(r.index,e),n,r.level+1),this._maxLevel=Math.max(this._maxLevel,r.level+1)}}_getPage(e){let t=S(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){let t=this._getPage(e);return t==null?null:(t.lastTraversed=this._frameNumber,t.nodes[C(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);let n=this.getParent(t),r=n==null?0:n.level+1;this._maxLevel=Math.max(this._maxLevel,e.children?r+1:r);let{lodMetric:i,maxError:a}=E(e.lodSelection),s=this._getNodeDescriptor(t);if(s.node!=null)return this._logger.error(`Loaded node[${t}] already in descriptor`),s.node;let c=new o(e.id,t,e.mbs,s.childCount,r,e.resources,e.version,i,a,e.numFeatures,e.obb?d.fromJSON(e.obb):null);s.node=c,c.visibilityObbInRenderSR=this._computeVisibilityObb(c);let l=s.nodeBoundingData;return l!=null&&(l.serviceMbsInIndexSR??=e.mbs,c.shareServiceBVsInRenderSRWith(l),l.visibilityObbInRenderSR=c.visibilityObbInRenderSR),c}_makeRefNode(e,t){let n=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(n==null)return-1;let r=n.nodes.length,i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_makeClientRefNode(e,t){let n=this._clientNodePage;if(n==null)return-1;if(t>=0)throw Error(`I3SIndex::client side nodes can not be made children of service side nodes.`);let r=-(n.nodes.length+1),i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_linkChildToParentNode(e,t){let n=this._clientNodePage;if(n==null||e>=0)return;let r=C(e,this._pageSize),i=C(t,this._pageSize),a=n.nodes[r],o=a.childOffset;n.children.splice(a.childOffset+a.childCount,0,t),a.childCount+=1,a.node!=null&&(a.node.childCount+=1);for(let e of n.nodes)e.childOffset>o&&(e.childOffset+=1);let s=n.nodes[i];s.parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,n){let r=this._clientNodePage;if(r==null)return;let i=this._getParentIndex(e);if(i==null)return;let a=new Set,o=new Map,s=e=>{let n=C(e,this._pageSize),i=r.nodes[n];if(i.childCount>0)for(let e=i.childOffset;e<i.childOffset+i.childCount;++e)s(r.children[e]);let o=i.node?.id??i.nodeBoundingData?.id;if(o==null)throw Error(`Node has no id`);t(o,e),a.add(i)};s(e);let c=r.nodes,l=r.children,u=r.nodes.map(()=>-1),d=[],f=[];for(let e=0;e<c.length;++e){let t=c[e];if(a.has(t))continue;let r=d.length,i=w(e,-1,this._pageSize),s=w(r,-1,this._pageSize);if(t.node&&(t.node.index=s),u[e]=s,d.push(t),i!==s){let e=t.node?.id??t.nodeBoundingData?.id;if(e==null)throw Error(`Node has no id`);n(e,i,s),o.set(i,s)}}for(let e=0;e<d.length;++e){let t=w(e,-1,this._pageSize),n=d[e],r=f.length;for(let e=n.childOffset;e<n.childOffset+n.childCount;++e){let n=l[e];if(n>=0)f.push(n);else{let e=C(n,this._pageSize),r=c[e];if(a.has(r))continue;let i=u[e];f.push(i),r.parentIndex=t}}n.childOffset=r,n.childCount=f.length-r,n.node&&(n.node.childCount=n.childCount)}r.setNodes(d,f),this._updateParentBoundingInformation(u[C(i,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null,n=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,o=this._getNodeDescriptor(t);if(o==null)return;for(let i=0;i<o.childCount;i++){let o=this.getChildIndex(t,i),s=this._getNodeDescriptor(o),c=s==null?null:s.nodeBoundingData||s.node;if(c?.serviceMbsInIndexSR!=null&&c.serviceMbsInIndexSR.radius>0){if(e==null)e=A.copyFrom(c.serviceMbsInIndexSR);else{let t=j;r(c.serviceMbsInIndexSR,n,t,a);let i=M;r(e,n,i,a),r(t.union(i),a,e,n)}}}let s=t=>{t!=null&&(t.serviceObbInIndexSR=null,e==null?t.serviceMbsInIndexSR?.invalidate():(t.serviceMbsInIndexSR??=new i,t.serviceMbsInIndexSR.copyFrom(e)),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};s(o.nodeBoundingData),s(o.node),this.invalidateNodeVisibilityCacheInternal(o),t=this._getParentIndex(t)}while(t!=null)}populateChildren(e,t){let n=this._getNodeDescriptor(e),r=this._getPage(e);n.childOffset=r.children.length,n.childCount=t.length;for(let n=0;n<t.length;n++){let i=this._makeRefNode(t[n],e);r.children.push(i)}}getNode(e){let t=this._getNodeDescriptor(e);return t==null?null:t.node}getIndexById(e){let t;return this._forAllNodes((n,r)=>{(n.node!=null&&n.node.id===e||n.nodeBoundingData!=null&&n.nodeBoundingData.id===e)&&(t=r)}),t}getNodeById(e){let t=this.getIndexById(e);return t!=null&&t>=0?this.getNode(t):null}getChildIndex(e,t){let n=this._getPage(e);if(n==null)return-1;let r=n.nodes[C(e,this._pageSize)];return n.children[r.childOffset+t]}_getParentIndex(e){let t=this._getPage(e);return t!=null&&e!==this._rootIndex?t.nodes[C(e,this._pageSize)]?.parentIndex:null}getParent(e){let t=this._getParentIndex(e);return t==null?null:this.getNode(t)}isLeaf(e){let t=this._getNodeDescriptor(e);return t!=null&&t.childCount===0}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{e.node!=null&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=v(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){let t=this._getNodeDescriptor(e);t!=null&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=_(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){let t=this._getNodeDescriptor(e);t!=null&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){let t=this._getNodeDescriptor(e);t!=null&&(this._needsNodeElevationRange?(t.node==null?t.nodeBoundingData:t.node)?.invalidateElevationRange():this.invalidateBoundingVolumeCache(e))}invalidateGeometryVisibility(e){let t=this._getNodeDescriptor(e)?.node;t&&(t.geometryObbInRenderSR=null,t.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){this.rootNode!=null&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeValid(e){if(!this._needsNodeElevationRange)return!0;let t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){let n=this._getNodeDescriptor(e);if(!n)return!1;let r=n?.node??n?.nodeBoundingData;if(!r)return!1;if(r.elevationRangeValid)return t?.expandElevationRange(r),!0;let i=new u,a=!1;for(let t=0;t<n.childCount;t++){let n=this.getChildIndex(e,t),r=this._updateElevationRange(n,i);a||=!r}if(n.childCount===0||a){let e=!n.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(r,e,i)}(i.minElevation===1/0||i.maxElevation===-1/0)&&i.expandElevationRangeValues(0,0);let{minElevation:o,maxElevation:s}=r;return o===i.minElevation&&s===i.maxElevation?(t?.expandElevationRange(r),!0):(n.node?.setElevationRange(i),n.nodeBoundingData?.setElevationRange(i),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(r),!0)}isNodeVisible(e){let t=this._getNodeDescriptor(e);if(t==null)return!0;let n=t.nodeBoundingData;if(n!=null&&!n.serviceMbsInIndexSR)return!0;if(this._isElevationRangeValid(t)&&b(t.visibilityCache,this._visibilityCacheVersion))return x(t.visibilityCache);let r=t.node,i=this._viewportQueries;if(r){let e=i.ensureElevationAgnosticBoundingVolume(r),n=i.isElevationAgnosticBoundingVolumeVisible(e),a=n;if(this._needsNodeElevationRange&&n){let t=i.getNodeObbInRenderSRIndependentOfElevationOffset(r);t!=null&&(a=i.isObbVisibleIndependentOfElevation(e,t))}if(!a)return t.visibilityCache=y(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(r!=null||n!=null)&&t.filterImpact===2){let e=r==null?n==null?null:n.serviceMbsInIndexSR:r.serviceMbsInIndexSR;t.filterImpact=e==null?0:this._computeNodeFiltering(e)}let a=r!=null&&t.filterImpact===1,o=(r==null||r.imModificationImpact!==2)&&!a;if(o){let t=r&&(!n||r.visibilityObbInRenderSR)?r:n??null;t!=null&&(this._needsNodeElevationRange&&this._updateElevationRange(e),o=i.isNodeVisible(t))}return t.visibilityCache=y(o,this._visibilityCacheVersion),o}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;let t=this._getNodeDescriptor(e);return t?.node?.geometryObbInRenderSR!=null&&(!this.layerHasModifications||t.node.imModificationImpact!==4)?this._viewportQueries.isGeometryVisible(t.node):!0}_traverseCoverage(e,t,n,r,i){let a=this._getPage(e);if(a==null||t.childCount===0)return;let o=t.childOffset+t.childCount,s=[];for(let e=t.childOffset;e<o;++e){let t=a.children[e],n=this._getNodeDescriptor(t);n?.node!=null&&this.isGeometryVisible(t)&&s.push(n)}r/=s.length;for(let e of s){let t=e.node.index;this._isLoaded(t)||this._isReloading(t)?(i.delta=Math.max(i.delta,n),i.coverage+=r):this._traverseCoverage(t,e,n+1,r,i)}}useNodeAsHole(e){if(this.holeFilling===`off`)return!1;let t=this._getNodeDescriptor(e);if(t==null)return!1;if(this.holeFilling===`always`)return!0;if(b(t.useAsHole,this._version))return x(t.useAsHole);let n={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,n);let r=n.delta*n.coverage<=.5;return t.useAsHole=y(r,this._version),r}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=v(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{e!=null&&(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(e!=null){e.filterImpact=2;let t=e.node;t!=null&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,n){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let r=!0,i=new D,a=new O,o=this._imModificationUncategorized;o.clear();let s=new Set,c=0;this.traverseVisible((s,l,u)=>{let d=e=>{this._shouldLoadNode(e)&&e.childCount&&(r=!1)};if(!l){let e=S(s,this._pageSize),t=this._getNodeLoadPriority(s);t===1/0&&(t=this._getNodeLoadPriority(u)),h.set(e,Math.max(t,h.get(e)||0)),!this._loadingPages.has(e)&&!this._failedPages.has(e)&&(this._missingPagesAndNodes.add(e),++c),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t);return}let{node:f,childCount:p}=l;if(this._updateNodeFeatureEstimate(f,a),!f){let e=this._getNodeLoadPriority(s);!this._loadingNodes.has(s)&&!this._failedNodes.has(s)&&(this._missingPagesAndNodes.add(s),h.set(s,e)),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e);return}let m=this._getPage(s);if(!this._useNodePages&&this._missingPagesAndNodes.size===0)for(let e=0;e<p;e++){let t=m.children[l.childOffset+e],n=this._getNodeDescriptor(t);n!=null&&!n.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(h.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(f.failed||f.resources.isEmpty){d(f);return}if(this._isLoaded(s)){if(i.known+=f.memory,++i.knownNodes,d(f),this._shouldLoadNode(f)||(i.unremoved+=f.memory),this._needsUpdate(f)){let e=this._getNodeLoadPriority(s);h.set(s,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(s)}return}if(f.memory&&(i.known+=f.memory,++i.knownNodes),!this._shouldLoadNode(f)){this._isReloading(s)&&this._updates.remove.push(s);return}if(d(f),f.memory?(i.missing+=f.memory,i.known+=f.memory,++i.knownNodes):++i.missingNodes,e.includes(f.index)){this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(s)),this._updates.cancel=this._updates.cancel.filter(e=>e!==f.index);return}if(!t.done&&this._enable(f)){t.madeProgress();return}let g=this._getNodeLoadPriority(s);h.set(s,g),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,g),this._updates.add.push(s),this.layerHasModifications&&n&&f!=null&&f.imModificationImpact===4&&o.push(s)},s),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(s,c),this._handleModifications(n,o),this._updateUnloadedMemoryEstimate(i),this._featureEstimate.estimate=this._computeFeatureEstimate(a),this._featureEstimate.leavesReached=r,this._updates.add.filterInPlace(e=>h.get(e)>=this._maxUnloadedPrio).sort((e,t)=>h.get(e)-h.get(t)),this._updates.update.sort((e,t)=>h.get(e)-h.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,h.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=Math.max(0,this._unloadedMemoryEstimate)*.8}resetUpdateState(e){this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=-1/0,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),h.clear()}_prioritizeMissingNodesAndPages(){let e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),e.length>0&&(this._maxUnloadedPrio=h.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&this._updates.add.length!==0&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{let t=this._getNodeDescriptor(e),n=t?.node==null||t.node.imModificationImpact!==2;return n||this.invalidateNodeVisibilityCache(e),n}))}checkFeatureTarget(e,t){let n=this._viewportQueries.updateScreenSpaceErrorBias(t),r=t,i=t,a=n,o=10;for(;o--;){let n=new O;if(this._updateFeatureEstimate(r,n),this._computeFeatureEstimate(n)<=e){if(r>=t||n.missingNodes>0||o===0)break;a=r,r=(r+i)*.5}else i=r,r=(r+a)*.5}return this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(n),Math.min(t,r)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;let n=e.size,r=this._nodePages,i=r.size+this._loadingPages.size+t;if(i>P&&i>n){let t=[];for(let[n,i]of r)i.numNodesWithLoadedChildren===0&&!e.has(n)&&t.push([i.lastTraversed,n]);t.sort((e,t)=>e[0]-t[0]).some(e=>{let t=e[1];return this._deleteNodePage(t),r.size<=P})}}_updateFeatureEstimate(e,t){this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,n)=>this._updateNodeFeatureEstimate(n?.node,t))}_updateNodeFeatureEstimate(e,t){e!=null&&!e.failed&&this._shouldLoadNode(e)&&(e.numFeatures==null?++t.missingNodes:(t.numFeatures+=e.numFeatures,++t.knownNodes))}_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(){let e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(e.length===0||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){let n=e[e.length-1];e.length--,t.delete(n),this._useNodePages&&n>=0?this._loadPage(n):this._loadNode(n)}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(e==null)return null;let t=e.index,n=this._getNodeDescriptor(t);if(!n)return null;let r=n?.traversalState;if(r&&b(r.version,this._version))return r;let i=this._viewportQueries.getLodLevel(e),a=this._viewportQueries.hasLOD(e),o=!0;if(a){let e=this._getParentIndex(t);if(e!=null){let t=this._getNodeDescriptor(e)?.traversalState;o=!!t&&i>t.lodLevel}else o=i>0}else o=e.childCount===0;return r?(r.lodLevel=i,r.isChosen=o,r.version=y(!0,this._version),r):(r=new s(a,o,i,y(!0,this._version)),n.traversalState=r,r)}_loadNode(e){if(this._loadingNodes.has(e)){this._logger.error(`Node[${e}] already loading`);return}this._loadingNodes.add(e);let n=this._getNodeDescriptor(e);if(n.node){this._logger.error(`Node[${e}] already in descriptor`);return}let r=n.nodeBoundingData;if(r==null){this._failedNodes.add(e);return}let i=r.id,a=this.urlPrefix+i,o=()=>{this._loadingNodes.delete(e),this._missingPagesAndNodes.size===0&&this._loadingNodes.size===0&&this.requestUpdate()};(e>=0?this._requester.request(a,`json`):this._clientNodeLoader.loadNodeJSON(i)).then(t=>{o();let n=this._validateNode(i,t);if(n==null)return;n.obb&&this.invalidateNodeVisibilityCache(e);let r=this._addNode(n,e);this.nodeTraversalState(r)}).catch(n=>{o(),t(n)||(this._logger.error(`#loadNode()`,this._layer,`Error loading node: `+a),this._failedNodes.add(e))})}_validateNode(e,t){if(typeof t!=`object`||!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&&t.sharedResource.href!==`./shared`&&t.sharedResource.href!==`./shared/`&&this._logger.warn(`#validateNode()`,this._layer,`Invalid shared resource href on node "${e}"`);let n=t.geometryData;n!=null&&!(Array.isArray(n)&&n.length===0)&&!(Array.isArray(n)&&n.length===1&&n[0].href===`./geometries/0`)&&this._logger.warn(`#validateNode()`,this._layer,`Invalid geometry data on node "${e}"`);let r=t.attributeData,o=this._layer.attributeStorageInfo;r!=null&&(!Array.isArray(r)||r.some((e,t)=>e.href!==`./attributes/${o?.[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.`);let s=t.hasOwnProperty(`obb`)&&!this.ignoreServiceObb?t.obb:void 0,c=t.featureData?.length===1&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,u=Array.isArray(t.children)?t.children.map(t=>{if(t==null)return null;let n=t=>this._logger.error(`#validateNode()`,this._layer,`Invalid node reference on node ${e}: ${t}`);if(typeof t.id==`number`)n(`id ${t.id} is a number instead of a string.`);else if(typeof t.id!=`string`||!Array.isArray(t.mbs))return n(`Missing or invalid id.`),null;if(!Array.isArray(t.mbs))return n(`Invalid bounding volume on reference ${t.id}.`),null;let r=new a(`${t.id}`,new i(t.mbs));return r.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty(`obb`)&&t.obb?d.fromJSON(t.obb):null,r.visibilityObbInRenderSR=this._computeVisibilityObb(r),r}).filter(e=>e!=null):null,f=t.featureData?.length??!1,p=t.isEmpty===!0;return new l(e,new i(t.mbs),s,typeof t.version==`string`?t.version:null,{isEmpty:!f&&p,hasSharedResource:t.sharedResource!=null,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:t.geometryData==null?void 0:e},u,Array.isArray(t.lodSelection)?t.lodSelection:null,c)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{e.node!=null&&(e.node.failed=!1)})}_getNodeLoadPriority(e){let t=this._getNodeDescriptor(e),n=this._getParentIndex(e);if(t==null||n==null&&t.node==null)return n==null?1/0:this._getNodeLoadPriority(n);let r=0;t.node&&n!=null&&(r=this._getNodeDescriptor(n).traversalState?.lodLevel??0);let i=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+r)+r*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+i}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;t!=null;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){let n=this._getNodeDescriptor(this._rootIndex);n==null?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,null,n,e,t)}_traverseVisible(e,t,n,r,i){let a=S(e,this._pageSize);if(i&&i.add(a),n.node&&n.childCount===0){this.isGeometryVisible(e)&&r(e,n,t);return}if(!this.isNodeVisible(e)||(r(e,n,t),n.node==null))return;let o=this.nodeTraversalState(n.node);if(o?.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;let s=this._getPageFromPageIndex(a);for(let t=0;t<n.childCount;t++){let a=s.children[n.childOffset+t],o=this._getNodeDescriptor(a);if(o)this._traverseVisible(a,e,o,r,i);else{if(i){let e=S(a,this._pageSize);i.add(e)}r(a,null,e)}}}traverse(e,t){for(let n of this.traverseValues(e,t));}*traverseValues(e,t){t(e)&&(yield e,yield*this._traverseDescendantValues(e,t))}*_traverseDescendantValues(e,t){let n=e.index,r=this._pageSize,i=S(n,r),a=this._getPageFromPageIndex(i);if(a==null)return;let o=this._frameNumber,s=this._nodePages,c=C(n,r),l=a.nodes[c],u=l.childCount;if(a.lastTraversed=o,u===0)return;let d=[],f=[],p=0;{let{childOffset:e,childCount:t}=l,{children:n}=a;f.length=2**Math.ceil(Math.log2(p+t));for(let r=e;r<e+t;++r){let e=n[r];e>=0?(f[p]=e,++p):d.push(e)}}if(d.length>0){let e=this._clientNodePage;if(e){let n=e.children,r=0;for(;r<d.length;){let i=d[r];++r;let a=-i-1,o=e.nodes[a],s=o.node;if(!s||!t(s))continue;yield s;let{childCount:c}=o;if(c===0)continue;let{childOffset:l}=o,u=l+c;for(let e=l;e<u;++e)d.push(n[e])}}}if(p>0){let e=0;if(r>0){let n=i*r,c=a,l=c.nodes;for(;e<p;){let i=f[e];++e;let a;if(n<=i&&i<n+r)a=c;else{let e=i/r|0,t=s.get(e);if(t===void 0)continue;a=t,a.lastTraversed=o,c=a,l=c.nodes,n=r*e}let u=i-n,d=l[u],m=d?.node;if(m==null||t(m)===!1||(yield m,d.node==null))continue;let{childCount:h}=d;if(h===0)continue;let g=p+h;for(f.length<g&&(f.length=2**Math.ceil(Math.log2(p+h)));f.length<p+h;)f.length+=f.length;let _=a.children,{childOffset:v}=d,y=v+h;for(let e=v;e<y;++e)f[p]=_[e],++p}}else{let n=s.get(0);if(n)for(;e<p;){let r=f[e++],i=n.nodes[r],a=i.node;if(!a||!t(a))continue;yield a;let{childCount:o}=i;if(o===0)continue;f.length=Math.max(f.length,2**Math.ceil(Math.log2(p+o)));let s=n.children,{childOffset:c}=i,l=c+o;for(let e=c;e<l;++e)f[p]=s[e],++p}}}}traverseDescendants(e,t){for(let n of this._traverseDescendantValues(e,t));}updateChildrenLoaded(e,t){let n=this.getNode(e);for(;n!=null;){let e=n.childrenLoaded,r=e+t;n.childrenLoaded=r;let i=e===0?1:r===0?-1:0,a=n.index;if(i!==0){let e=this._getPage(a);e.numNodesWithLoadedChildren+=i}n=this.getParent(a)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this._needsNodeElevationRange=t&&!!e&&(e.mode===`relative-to-ground`||e.mode===`relative-to-scene`||e.mode===`on-the-ground`),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_forAllNodes(e){if(this._clientNodePage!=null){let t=this._clientNodePage;for(let n=0;n<t.nodes.length;n++)e(t.nodes[n],-(n+1))}for(let[t,n]of this._nodePages){let r=t*this._pageSize;for(let t=0;t<n.nodes.length;t++)e(n.nodes[t],r+t)}}clearCaches(){if(this._useNodePages){let e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(S(e,this._pageSize)));for(let[n,r]of e)if(r.numNodesWithLoadedChildren===0&&!t.has(n))this._deleteNodePage(n);else for(let e of r.nodes)e.traversalState=null}}_deleteNodePage(e){if(!this._nodePages.has(e)){this._logger.error(`Destroying non-existent page ${e}`);return}let t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const h=new Map;class g{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 _(e){return c(e,-2)}function v(e){return c(e,2)}function y(e,t){return t+ +!!e}function b(e,t){return(e&-2)===t}function x(e){return(e&1)==1}function S(e,t){return e<0?-1:t>0?e/t|0:0}function C(e,t){return e<0?-e-1:t===0?e:e%t}function w(e,t,n){return t===-1?-(e+1):n===0?e:t*n+e}const T=[[`maxScreenThreshold`,1],[`screenSpaceRelative`,2],[`removedFeatureDiameter`,3],[`distanceRangeFromDefaultCamera`,4]];function E(e){if(e){for(let t=0;t<e.length;t++)for(let n of T)if(n[0]===e[t].metricType)return{lodMetric:n[1],maxError:e[t].maxError}}return{lodMetric:0,maxError:0}}class D{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class O{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function k(e){return Math.sqrt(4/Math.PI*e)}const A=new i,j=new i,M=new i,N=n(),P=has(`esri-mobile`)?100:300;export{m as I3SIndex,E 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 n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as r}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as i}from"../../../../geometry/support/sphere.js";import{NodeBoundingData as a,Node as o,NodeTraversalState as s}from"./I3SNode.js";import{addWraparound as c}from"./I3SUtil.js";import{ValidatedNode as l}from"./ValidatedNode.js";import{ElevationRange as u}from"../../support/ElevationRange.js";import{Obb as d}from"../../support/orientedBoundingBox.js";class f{constructor(e,t,n,r,i){this.childOffset=e,this.childCount=t,this.visibilityCache=n,this._boundingData=r,this.node=i,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 p{constructor(e=[],t=[]){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(let 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 m{get _useNodePages(){return this._pageSize>0}constructor(t,n,r,i,o,s,c,l,u,d,f,m,h,_,y,b,x){if(this.viewingMode=t,this._layer=n,this._groundNavigationCheckDistance=i,this._requester=s,this._clientNodeLoader=c,this._viewportQueries=l,this._logger=u,this.holeFilling=d,this._isLoaded=f,this._isReloading=m,this._shouldLoadNode=h,this._enable=_,this._needsUpdate=y,this._computeVisibilityObb=b,this._computeNodeFiltering=x,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=-1/0,this._maxProcessingPrio=1/0,this._version=v(0),this._visibilityCacheVersion=v(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._progressiveLoadPenaltyWeight=10,this._missingPagesAndNodes=new Set,this._prioritizedMissingNodeAndPageIds=[],this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=[],this._updates=new g(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.isGroundNavigationMode=!1,this._pageQueue=[],this._newPages=[],this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=n.associatedLayer?.infoFor3D!=null,this.isGroundNavigationMode=r,n.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${n.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,o.type===`page`){let e=o.rootPage;switch(this.urlPrefix=o.urlPrefix,this._pageSize=o.pageSize,o.lodMetric){case`maxScreenThreshold`:this._lodMetric=1;break;case`maxScreenThresholdSQ`:this._lodMetric=1,this._lodConversion=k}if(this._isEditable){this._rootIndex=-1;let t=C(o.rootIndex,o.pageSize),n=e.nodes[t],r={nodes:[{index:this._rootIndex,children:[o.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(S(this._rootIndex,this._pageSize),r),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=o.rootIndex;this._addPage(S(o.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if(o.type===`node`){this.urlPrefix=o.urlPrefix;let e=new p;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new p;let e={id:`-1`,version:null,mbs:o.rootNode.mbs,obb:o.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:`root`,href:`../root`,mbs:o.rootNode.mbs,obb:o.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new a(e.id),-1);let t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new a(o.rootNode.id),-1);let t=this._validateNode(o.rootNode.id,o.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){let n=new a(e,t),r=this._makeClientRefNode(n,-1);return this._linkChildToParentNode(-1,r),this.requestUpdate(),r}removeClientNodeFromIndex(e,t,n){this._destroyClientRefNode(e,t,n),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e)){this._logger.error(`Requested load page [${e}] already loaded`);return}if(this._loadingPages.has(e)){this._logger.error(`Requested load page [${e}] already loading`);return}this._loadingPages.add(e);let n=this.urlPrefix+e;this._requester.request(n,`json`).then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(n=>{this._loadingPages.delete(e),t(n)||(this._failedPages.add(e),this._logger.error(`#loadPage()`,this._layer,`Error when loading page ${e}`,n))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){let{pageIndex:t,page:n}=this._pageQueue.shift();this._addPage(t,n),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;)this._nodePages.get(this._newPages.shift())?.nodes.forEach(e=>{let t=e.parentIndex;for(;t!=null&&t!==this._rootIndex;){let e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}_addPage(e,t){if(this._nodePages.has(e)){this._logger.error(`Page[${e}] reloaded`);return}let n=[],r=[],a=t.nodes.map((t,a)=>{let s=n.length,c=t.children?t.children.length:0;r.push(this._rootIndex);for(let e=0;e<c;e++)n.push(t.children[e]);let l=`${t.index}`,u=d.fromJSON(t.obb),p=new i(u.getCenter(N),u.radius),m=t.mesh?.attribute,h=t.mesh?.geometry,g=t.mesh?.material,v={hasSharedResource:!1,isEmpty:h==null,attributes:m?.resource==null?void 0:`${m.resource}`,geometry:h?.resource==null?void 0:`${h.resource}`,texture:g?.resource==null?void 0:`${g.resource}`,geometryDefinition:h?h.definition:-1,materialDefinition:g?g.definition:-1},y=new o(l,w(a,e,this._pageSize),p,c,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),h?.featureCount??null,u);return y.visibilityObbInRenderSR=this._computeVisibilityObb(y),y.vertexCount=h?h.vertexCount:0,new f(s,c,_(this._visibilityCacheVersion),null,y)}),s=new p(a,n);e===-1?this._clientNodePage=s:this._nodePages.set(e,s)}_updateParentsAndLevel(){let e=[],t=(t,n,r)=>{let i=this._getPage(t);if(i!=null){let a=C(t,this._pageSize),o=i.nodes[a];o.parentIndex=n??-1;let s=o.node;s!=null&&(s.level=r,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){let n=e.pop(),r=this.getNode(n);if(r!=null)for(let e=0;e<r.childCount;e++)t(this.getChildIndex(r.index,e),n,r.level+1),this._maxLevel=Math.max(this._maxLevel,r.level+1)}}_getPage(e){let t=S(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){let t=this._getPage(e);return t==null?null:(t.lastTraversed=this._frameNumber,t.nodes[C(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);let n=this.getParent(t),r=n==null?0:n.level+1;this._maxLevel=Math.max(this._maxLevel,e.children?r+1:r);let{lodMetric:i,maxError:a}=E(e.lodSelection),s=this._getNodeDescriptor(t);if(s.node!=null)return this._logger.error(`Loaded node[${t}] already in descriptor`),s.node;let c=new o(e.id,t,e.mbs,s.childCount,r,e.resources,e.version,i,a,e.numFeatures,e.obb?d.fromJSON(e.obb):null);s.node=c,c.visibilityObbInRenderSR=this._computeVisibilityObb(c);let l=s.nodeBoundingData;return l!=null&&(l.serviceMbsInIndexSR??=e.mbs,c.shareServiceBVsInRenderSRWith(l),l.visibilityObbInRenderSR=c.visibilityObbInRenderSR),c}_makeRefNode(e,t){let n=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(n==null)return-1;let r=n.nodes.length,i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_makeClientRefNode(e,t){let n=this._clientNodePage;if(n==null)return-1;if(t>=0)throw Error(`I3SIndex::client side nodes can not be made children of service side nodes.`);let r=-(n.nodes.length+1),i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_linkChildToParentNode(e,t){let n=this._clientNodePage;if(n==null||e>=0)return;let r=C(e,this._pageSize),i=C(t,this._pageSize),a=n.nodes[r],o=a.childOffset;n.children.splice(a.childOffset+a.childCount,0,t),a.childCount+=1,a.node!=null&&(a.node.childCount+=1);for(let e of n.nodes)e.childOffset>o&&(e.childOffset+=1);let s=n.nodes[i];s.parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,n){let r=this._clientNodePage;if(r==null)return;let i=this._getParentIndex(e);if(i==null)return;let a=new Set,o=new Map,s=e=>{let n=C(e,this._pageSize),i=r.nodes[n];if(i.childCount>0)for(let e=i.childOffset;e<i.childOffset+i.childCount;++e)s(r.children[e]);let o=i.node?.id??i.nodeBoundingData?.id;if(o==null)throw Error(`Node has no id`);t(o,e),a.add(i)};s(e);let c=r.nodes,l=r.children,u=r.nodes.map(()=>-1),d=[],f=[];for(let e=0;e<c.length;++e){let t=c[e];if(a.has(t))continue;let r=d.length,i=w(e,-1,this._pageSize),s=w(r,-1,this._pageSize);if(t.node&&(t.node.index=s),u[e]=s,d.push(t),i!==s){let e=t.node?.id??t.nodeBoundingData?.id;if(e==null)throw Error(`Node has no id`);n(e,i,s),o.set(i,s)}}for(let e=0;e<d.length;++e){let t=w(e,-1,this._pageSize),n=d[e],r=f.length;for(let e=n.childOffset;e<n.childOffset+n.childCount;++e){let n=l[e];if(n>=0)f.push(n);else{let e=C(n,this._pageSize),r=c[e];if(a.has(r))continue;let i=u[e];f.push(i),r.parentIndex=t}}n.childOffset=r,n.childCount=f.length-r,n.node&&(n.node.childCount=n.childCount)}r.setNodes(d,f),this._updateParentBoundingInformation(u[C(i,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null,n=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,o=this._getNodeDescriptor(t);if(o==null)return;for(let i=0;i<o.childCount;i++){let o=this.getChildIndex(t,i),s=this._getNodeDescriptor(o),c=s==null?null:s.nodeBoundingData||s.node;if(c?.serviceMbsInIndexSR!=null&&c.serviceMbsInIndexSR.radius>0){if(e==null)e=A.copyFrom(c.serviceMbsInIndexSR);else{let t=j;r(c.serviceMbsInIndexSR,n,t,a);let i=M;r(e,n,i,a),r(t.union(i),a,e,n)}}}let s=t=>{t!=null&&(t.serviceObbInIndexSR=null,e==null?t.serviceMbsInIndexSR?.invalidate():(t.serviceMbsInIndexSR??=new i,t.serviceMbsInIndexSR.copyFrom(e)),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};s(o.nodeBoundingData),s(o.node),this.invalidateNodeVisibilityCacheInternal(o),t=this._getParentIndex(t)}while(t!=null)}populateChildren(e,t){let n=this._getNodeDescriptor(e),r=this._getPage(e);n.childOffset=r.children.length,n.childCount=t.length;for(let n=0;n<t.length;n++){let i=this._makeRefNode(t[n],e);r.children.push(i)}}getNode(e){let t=this._getNodeDescriptor(e);return t==null?null:t.node}getIndexById(e){let t;return this._forAllNodes((n,r)=>{(n.node!=null&&n.node.id===e||n.nodeBoundingData!=null&&n.nodeBoundingData.id===e)&&(t=r)}),t}getNodeById(e){let t=this.getIndexById(e);return t!=null&&t>=0?this.getNode(t):null}getChildIndex(e,t){let n=this._getPage(e);if(n==null)return-1;let r=n.nodes[C(e,this._pageSize)];return n.children[r.childOffset+t]}_getParentIndex(e){let t=this._getPage(e);return t!=null&&e!==this._rootIndex?t.nodes[C(e,this._pageSize)]?.parentIndex:null}getParent(e){let t=this._getParentIndex(e);return t==null?null:this.getNode(t)}isLeaf(e){let t=this._getNodeDescriptor(e);return t!=null&&t.childCount===0}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{e.node!=null&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=v(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){let t=this._getNodeDescriptor(e);t!=null&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=_(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){let t=this._getNodeDescriptor(e);t!=null&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){let t=this._getNodeDescriptor(e);t!=null&&(this._needsNodeElevationRange?(t.node==null?t.nodeBoundingData:t.node)?.invalidateElevationRange():this.invalidateBoundingVolumeCache(e))}invalidateGeometryVisibility(e){let t=this._getNodeDescriptor(e)?.node;t&&(t.geometryObbInRenderSR=null,t.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){this.rootNode!=null&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeValid(e){if(!this._needsNodeElevationRange)return!0;let t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){let n=this._getNodeDescriptor(e);if(!n)return!1;let r=n?.node??n?.nodeBoundingData;if(!r)return!1;if(r.elevationRangeValid)return t?.expandElevationRange(r),!0;let i=new u,a=!1;for(let t=0;t<n.childCount;t++){let n=this.getChildIndex(e,t),r=this._updateElevationRange(n,i);a||=!r}if(n.childCount===0||a){let e=!n.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(r,e,i)}(i.minElevation===1/0||i.maxElevation===-1/0)&&i.expandElevationRangeValues(0,0);let{minElevation:o,maxElevation:s}=r;return o===i.minElevation&&s===i.maxElevation?(t?.expandElevationRange(r),!0):(n.node?.setElevationRange(i),n.nodeBoundingData?.setElevationRange(i),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(r),!0)}isNodeVisible(e){let t=this._getNodeDescriptor(e);if(t==null)return!0;let n=t.nodeBoundingData;if(n!=null&&!n.serviceMbsInIndexSR)return!0;if(this._isElevationRangeValid(t)&&b(t.visibilityCache,this._visibilityCacheVersion))return x(t.visibilityCache);let r=t.node,i=this._viewportQueries;if(r){let e=i.ensureElevationAgnosticBoundingVolume(r),n=i.isElevationAgnosticBoundingVolumeVisible(e,this.isGroundNavigationMode?this._groundNavigationCheckDistance:0),a=n;if(this._needsNodeElevationRange&&n){let t=i.getNodeObbInRenderSRIndependentOfElevationOffset(r);t!=null&&(a=i.isObbVisibleIndependentOfElevation(e,t))}if(!a)return t.visibilityCache=y(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(r!=null||n!=null)&&t.filterImpact===2){let e=r==null?n==null?null:n.serviceMbsInIndexSR:r.serviceMbsInIndexSR;t.filterImpact=e==null?0:this._computeNodeFiltering(e)}let a=r!=null&&t.filterImpact===1,o=(r==null||r.imModificationImpact!==2)&&!a;if(o){let t=r&&(!n||r.visibilityObbInRenderSR)?r:n??null;t!=null&&(this._needsNodeElevationRange&&this._updateElevationRange(e),o=i.isNodeVisible(t,this.isGroundNavigationMode))}return t.visibilityCache=y(o,this._visibilityCacheVersion),o}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;let t=this._getNodeDescriptor(e);return t?.node?.geometryObbInRenderSR!=null&&(!this.layerHasModifications||t.node.imModificationImpact!==4)?this._viewportQueries.isGeometryVisible(t.node,this.isGroundNavigationMode):!0}_traverseCoverage(e,t,n,r,i){let a=this._getPage(e);if(a==null||t.childCount===0)return;let o=t.childOffset+t.childCount,s=[];for(let e=t.childOffset;e<o;++e){let t=a.children[e],n=this._getNodeDescriptor(t);n?.node!=null&&this.isGeometryVisible(t)&&s.push(n)}r/=s.length;for(let e of s){let t=e.node.index;this._isLoaded(t)||this._isReloading(t)?(i.delta=Math.max(i.delta,n),i.coverage+=r):this._traverseCoverage(t,e,n+1,r,i)}}useNodeAsHole(e){if(this.holeFilling===`off`)return!1;let t=this._getNodeDescriptor(e);if(t==null)return!1;if(this.holeFilling===`always`)return!0;if(b(t.useAsHole,this._version))return x(t.useAsHole);let n={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,n);let r=n.delta*n.coverage<=.5;return t.useAsHole=y(r,this._version),r}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=v(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{e!=null&&(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(e!=null){e.filterImpact=2;let t=e.node;t!=null&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,n){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let r=!0,i=new D,a=new O,o=this._imModificationUncategorized;o.clear();let s=new Set,c=0;this.traverseVisible((s,l,u)=>{let d=e=>{this._shouldLoadNode(e)&&e.childCount&&(r=!1)};if(!l){let e=S(s,this._pageSize),t=this._getNodeLoadPriority(s);t===1/0&&(t=this._getNodeLoadPriority(u)),h.set(e,Math.max(t,h.get(e)||0)),!this._loadingPages.has(e)&&!this._failedPages.has(e)&&(this._missingPagesAndNodes.add(e),++c),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t);return}let{node:f,childCount:p}=l;if(this._updateNodeFeatureEstimate(f,a),!f){let e=this._getNodeLoadPriority(s);!this._loadingNodes.has(s)&&!this._failedNodes.has(s)&&(this._missingPagesAndNodes.add(s),h.set(s,e)),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e);return}let m=this._getPage(s);if(!this._useNodePages&&this._missingPagesAndNodes.size===0)for(let e=0;e<p;e++){let t=m.children[l.childOffset+e],n=this._getNodeDescriptor(t);n!=null&&!n.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(h.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(f.failed||f.resources.isEmpty){d(f);return}if(this._isLoaded(s)){if(i.known+=f.memory,++i.knownNodes,d(f),this._shouldLoadNode(f)||(i.unremoved+=f.memory),this._needsUpdate(f)){let e=this._getNodeLoadPriority(s);h.set(s,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(s)}return}if(f.memory&&(i.known+=f.memory,++i.knownNodes),!this._shouldLoadNode(f)){this._isReloading(s)&&this._updates.remove.push(s);return}if(d(f),f.memory?(i.missing+=f.memory,i.known+=f.memory,++i.knownNodes):++i.missingNodes,e.includes(f.index)){this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(s)),this._updates.cancel=this._updates.cancel.filter(e=>e!==f.index);return}if(!t.done&&this._enable(f)){t.madeProgress();return}let g=this._getNodeLoadPriority(s);h.set(s,g),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,g),this._updates.add.push(s),this.layerHasModifications&&n&&f!=null&&f.imModificationImpact===4&&o.push(s)},s),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(s,c),this._handleModifications(n,o),this._updateUnloadedMemoryEstimate(i),this._featureEstimate.estimate=this._computeFeatureEstimate(a),this._featureEstimate.leavesReached=r,this._updates.add.filterInPlace(e=>h.get(e)>=this._maxUnloadedPrio).sort((e,t)=>h.get(e)-h.get(t)),this._updates.update.sort((e,t)=>h.get(e)-h.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,h.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=Math.max(0,this._unloadedMemoryEstimate)*.8}resetUpdateState(e){this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=-1/0,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),h.clear()}_prioritizeMissingNodesAndPages(){let e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),e.length>0&&(this._maxUnloadedPrio=h.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&this._updates.add.length!==0&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{let t=this._getNodeDescriptor(e),n=t?.node==null||t.node.imModificationImpact!==2;return n||this.invalidateNodeVisibilityCache(e),n}))}checkFeatureTarget(e,t){let n=this._viewportQueries.updateScreenSpaceErrorBias(t),r=t,i=t,a=n,o=10;for(;o--;){let n=new O;if(this._updateFeatureEstimate(r,n),this._computeFeatureEstimate(n)<=e){if(r>=t||n.missingNodes>0||o===0)break;a=r,r=(r+i)*.5}else i=r,r=(r+a)*.5}return this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(n),Math.min(t,r)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;let n=e.size,r=this._nodePages,i=r.size+this._loadingPages.size+t;if(i>P&&i>n){let t=[];for(let[n,i]of r)i.numNodesWithLoadedChildren===0&&!e.has(n)&&t.push([i.lastTraversed,n]);t.sort((e,t)=>e[0]-t[0]).some(e=>{let t=e[1];return this._deleteNodePage(t),r.size<=P})}}_updateFeatureEstimate(e,t){this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,n)=>this._updateNodeFeatureEstimate(n?.node,t))}_updateNodeFeatureEstimate(e,t){e!=null&&!e.failed&&this._shouldLoadNode(e)&&(e.numFeatures==null?++t.missingNodes:(t.numFeatures+=e.numFeatures,++t.knownNodes))}_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(){let e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(e.length===0||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){let n=e[e.length-1];e.length--,t.delete(n),this._useNodePages&&n>=0?this._loadPage(n):this._loadNode(n)}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(e==null)return null;let t=e.index,n=this._getNodeDescriptor(t);if(!n)return null;let r=n?.traversalState;if(r&&b(r.version,this._version))return r;let i=this._viewportQueries.getLodLevel(e),a=this._viewportQueries.hasLOD(e),o=!0;if(a){let e=this._getParentIndex(t);if(e!=null){let t=this._getNodeDescriptor(e)?.traversalState;o=!!t&&i>t.lodLevel}else o=i>0}else o=e.childCount===0;return r?(r.lodLevel=i,r.isChosen=o,r.version=y(!0,this._version),r):(r=new s(a,o,i,y(!0,this._version)),n.traversalState=r,r)}_loadNode(e){if(this._loadingNodes.has(e)){this._logger.error(`Node[${e}] already loading`);return}this._loadingNodes.add(e);let n=this._getNodeDescriptor(e);if(n.node){this._logger.error(`Node[${e}] already in descriptor`);return}let r=n.nodeBoundingData;if(r==null){this._failedNodes.add(e);return}let i=r.id,a=this.urlPrefix+i,o=()=>{this._loadingNodes.delete(e),this._missingPagesAndNodes.size===0&&this._loadingNodes.size===0&&this.requestUpdate()};(e>=0?this._requester.request(a,`json`):this._clientNodeLoader.loadNodeJSON(i)).then(t=>{o();let n=this._validateNode(i,t);if(n==null)return;n.obb&&this.invalidateNodeVisibilityCache(e);let r=this._addNode(n,e);this.nodeTraversalState(r)}).catch(n=>{o(),t(n)||(this._logger.error(`#loadNode()`,this._layer,`Error loading node: `+a),this._failedNodes.add(e))})}_validateNode(e,t){if(typeof t!=`object`||!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&&t.sharedResource.href!==`./shared`&&t.sharedResource.href!==`./shared/`&&this._logger.warn(`#validateNode()`,this._layer,`Invalid shared resource href on node "${e}"`);let n=t.geometryData;n!=null&&!(Array.isArray(n)&&n.length===0)&&!(Array.isArray(n)&&n.length===1&&n[0].href===`./geometries/0`)&&this._logger.warn(`#validateNode()`,this._layer,`Invalid geometry data on node "${e}"`);let r=t.attributeData,o=this._layer.attributeStorageInfo;r!=null&&(!Array.isArray(r)||r.some((e,t)=>e.href!==`./attributes/${o?.[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.`);let s=t.hasOwnProperty(`obb`)&&!this.ignoreServiceObb?t.obb:void 0,c=t.featureData?.length===1&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,u=Array.isArray(t.children)?t.children.map(t=>{if(t==null)return null;let n=t=>this._logger.error(`#validateNode()`,this._layer,`Invalid node reference on node ${e}: ${t}`);if(typeof t.id==`number`)n(`id ${t.id} is a number instead of a string.`);else if(typeof t.id!=`string`||!Array.isArray(t.mbs))return n(`Missing or invalid id.`),null;if(!Array.isArray(t.mbs))return n(`Invalid bounding volume on reference ${t.id}.`),null;let r=new a(`${t.id}`,new i(t.mbs));return r.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty(`obb`)&&t.obb?d.fromJSON(t.obb):null,r.visibilityObbInRenderSR=this._computeVisibilityObb(r),r}).filter(e=>e!=null):null,f=t.featureData?.length??!1,p=t.isEmpty===!0;return new l(e,new i(t.mbs),s,typeof t.version==`string`?t.version:null,{isEmpty:!f&&p,hasSharedResource:t.sharedResource!=null,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:t.geometryData==null?void 0:e},u,Array.isArray(t.lodSelection)?t.lodSelection:null,c)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{e.node!=null&&(e.node.failed=!1)})}_getNodeLoadPriority(e){let t=this._getNodeDescriptor(e),n=this._getParentIndex(e);if(t==null||n==null&&t.node==null)return n==null?1/0:this._getNodeLoadPriority(n);let r=0;t.node&&n!=null&&(r=this._getNodeDescriptor(n).traversalState?.lodLevel??0);let i=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+r)+r*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+i}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;t!=null;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){let n=this._getNodeDescriptor(this._rootIndex);n==null?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,null,n,e,t)}_traverseVisible(e,t,n,r,i){let a=S(e,this._pageSize);if(i&&i.add(a),n.node&&n.childCount===0){this.isGeometryVisible(e)&&r(e,n,t);return}if(!this.isNodeVisible(e)||(r(e,n,t),n.node==null))return;let o=this.nodeTraversalState(n.node);if(o?.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;let s=this._getPageFromPageIndex(a);for(let t=0;t<n.childCount;t++){let a=s.children[n.childOffset+t],o=this._getNodeDescriptor(a);if(o)this._traverseVisible(a,e,o,r,i);else{if(i){let e=S(a,this._pageSize);i.add(e)}r(a,null,e)}}}traverse(e,t){for(let n of this.traverseValues(e,t));}*traverseValues(e,t){t(e)&&(yield e,yield*this._traverseDescendantValues(e,t))}*_traverseDescendantValues(e,t){let n=e.index,r=this._pageSize,i=S(n,r),a=this._getPageFromPageIndex(i);if(a==null)return;let o=this._frameNumber,s=this._nodePages,c=C(n,r),l=a.nodes[c],u=l.childCount;if(a.lastTraversed=o,u===0)return;let d=[],f=[],p=0;{let{childOffset:e,childCount:t}=l,{children:n}=a;f.length=2**Math.ceil(Math.log2(p+t));for(let r=e;r<e+t;++r){let e=n[r];e>=0?(f[p]=e,++p):d.push(e)}}if(d.length>0){let e=this._clientNodePage;if(e){let n=e.children,r=0;for(;r<d.length;){let i=d[r];++r;let a=-i-1,o=e.nodes[a],s=o.node;if(!s||!t(s))continue;yield s;let{childCount:c}=o;if(c===0)continue;let{childOffset:l}=o,u=l+c;for(let e=l;e<u;++e)d.push(n[e])}}}if(p>0){let e=0;if(r>0){let n=i*r,c=a,l=c.nodes;for(;e<p;){let i=f[e];++e;let a;if(n<=i&&i<n+r)a=c;else{let e=i/r|0,t=s.get(e);if(t===void 0)continue;a=t,a.lastTraversed=o,c=a,l=c.nodes,n=r*e}let u=i-n,d=l[u],m=d?.node;if(m==null||t(m)===!1||(yield m,d.node==null))continue;let{childCount:h}=d;if(h===0)continue;let g=p+h;for(f.length<g&&(f.length=2**Math.ceil(Math.log2(p+h)));f.length<p+h;)f.length+=f.length;let _=a.children,{childOffset:v}=d,y=v+h;for(let e=v;e<y;++e)f[p]=_[e],++p}}else{let n=s.get(0);if(n)for(;e<p;){let r=f[e++],i=n.nodes[r],a=i.node;if(!a||!t(a))continue;yield a;let{childCount:o}=i;if(o===0)continue;f.length=Math.max(f.length,2**Math.ceil(Math.log2(p+o)));let s=n.children,{childOffset:c}=i,l=c+o;for(let e=c;e<l;++e)f[p]=s[e],++p}}}}traverseDescendants(e,t){for(let n of this._traverseDescendantValues(e,t));}updateChildrenLoaded(e,t){let n=this.getNode(e);for(;n!=null;){let e=n.childrenLoaded,r=e+t;n.childrenLoaded=r;let i=e===0?1:r===0?-1:0,a=n.index;if(i!==0){let e=this._getPage(a);e.numNodesWithLoadedChildren+=i}n=this.getParent(a)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this._needsNodeElevationRange=t&&!!e&&(e.mode===`relative-to-ground`||e.mode===`relative-to-scene`||e.mode===`on-the-ground`),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_forAllNodes(e){if(this._clientNodePage!=null){let t=this._clientNodePage;for(let n=0;n<t.nodes.length;n++)e(t.nodes[n],-(n+1))}for(let[t,n]of this._nodePages){let r=t*this._pageSize;for(let t=0;t<n.nodes.length;t++)e(n.nodes[t],r+t)}}clearCaches(){if(this._useNodePages){let e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(S(e,this._pageSize)));for(let[n,r]of e)if(r.numNodesWithLoadedChildren===0&&!t.has(n))this._deleteNodePage(n);else for(let e of r.nodes)e.traversalState=null}}_deleteNodePage(e){if(!this._nodePages.has(e)){this._logger.error(`Destroying non-existent page ${e}`);return}let t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const h=new Map;class g{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 _(e){return c(e,-2)}function v(e){return c(e,2)}function y(e,t){return t+ +!!e}function b(e,t){return(e&-2)===t}function x(e){return(e&1)==1}function S(e,t){return e<0?-1:t>0?e/t|0:0}function C(e,t){return e<0?-e-1:t===0?e:e%t}function w(e,t,n){return t===-1?-(e+1):n===0?e:t*n+e}const T=[[`maxScreenThreshold`,1],[`screenSpaceRelative`,2],[`removedFeatureDiameter`,3],[`distanceRangeFromDefaultCamera`,4]];function E(e){if(e){for(let t=0;t<e.length;t++)for(let n of T)if(n[0]===e[t].metricType)return{lodMetric:n[1],maxError:e[t].maxError}}return{lodMetric:0,maxError:0}}class D{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class O{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function k(e){return Math.sqrt(4/Math.PI*e)}const A=new i,j=new i,M=new i,N=n(),P=has(`esri-mobile`)?100:300;export{m as I3SIndex,E as selectErrorMetric};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import"../../../../core/has.js";import{normalize as e,length as t,set as n,equals as r,subtract as i,dot as a,len as o,sqrDist as s,copy as c,scale as l,sub as u,scaleAndAdd as d,distance as f,squaredLength as p,squaredDistance as m,add as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import v from"../../../../geometry/SpatialReference.js";import{getSphericalPCPF as y}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingRect as b}from"../../../../geometry/projection/projectBoundingRect.js";import{projectBoundingSphere as x}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as ee}from"../../../../geometry/projection/projectors.js";import{create as S,fromValues as C}from"../../../../geometry/support/aaBoundingRect.js";import{signedDistance as w,getNormal as T}from"../../../../geometry/support/plane.js";import{isPlateCarree as te,webMercatorValid as ne}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as re}from"../../../../geometry/support/sphere.js";import{evaluateElevationAlignmentAtPoint as E}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as D}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as O,extractExpressionInfo as ie}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as k}from"./I3SUtil.js";import{Frustum as A}from"../../state/Frustum.js";import"../../support/elevationUpdateExtentUtils.js";import{Obb as j,computeOffsetObb as ae}from"../../support/orientedBoundingBox.js";import{SweptSphereCylindricalVolume as oe,SphereGlobal as se,SweptSphereConicalVolume as ce}from"../../support/SweptSphereVolume.js";import{sphereToGeographicExtent as le,intersectsGeographicExtent as ue}from"../../support/sphereExtentUtils.js";const M=1e5;class N{get _frustumPlanes(){return this._frustum.planes}constructor(e,t,n,r,i,a,o,s,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=i,this._elevationProvider=a,this._viewingMode=o,this._options=c,this._viewDirection=g(),this._useFrustumCulling=!1,this._poi=g(),this._cameraPOIDirection=g(),this._elevationContext=null,this.minCenterDistance=1/0,this.maxCenterDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this._frustum=new A(t),this.updateCamera(n,r);let l=this._renderCoordsHelper.spatialReference;this._renderSR=l,this._renderSRSphericalPCPF=y(l),this._isGlobalMode=this._viewingMode===1,this.elevationIntersectionSpatialReference=this._isGlobalMode?this._indexSR.isWebMercator?this._indexSR:this._elevationProvider.spatialReference:l,this.updateElevationInfo(s),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(l.isWebMercator||te(l)),this._indexSREllipsoidRadius=_(this._indexSR).radius,this._indexSRSphericalPCPF=y(e),this._projectorIndexSRToIndexSRSphericalPCPF=ee(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){e==null?this._elevationContext=null:(this._elevationContext=D.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(O(ie(e,!1))))}updateCamera(t,n){this._useFrustumCulling=n,e(this._viewDirection,t.viewForward),n&&this._frustum.update(t),this._halfScreenPixelSizePerDistance=t.screenPixelSizePerDistance/2,this._camPos=t.eye,this._updateCameraPOIDirection(),this.minCenterDistance=1/0,this.maxCenterDistance=0}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){let t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,n){if(this._elevationContext==null)return;let r=e.serviceMbsInIndexSR;if(!r)return;let i=this._elevationContext.mode===`relative-to-scene`?`scene`:`ground`,a=this._elevationProvider;if(a.getSphereElevationRange){let e=a.getSphereElevationRange(r,this._indexSR,i);if(e){n.expandElevationRange(e);return}}let[o,s,c]=r.center,l=a.getElevation(o,s,c,this._indexSR,i);l&&n.expandElevationRangeValues(l,l);let u=t?null:a.getRootElevationRange?.();u&&n.expandElevationRange(u)}calculateServiceMbsInRenderSR(e){let{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e;if(!n?.isValid)return t;let r=G;return x(n,this._indexSR,r,this._renderSR),e.updateServiceMbsInRenderSR(r)}intersectsElevationUpdate(e,t){if(this._isGlobalMode&&this._indexSR.isWebMercator){let n=t.serviceMbsInIndexSR;if(!n?.isValid)return!0;let[r,i]=ne,a=i-r,o=e[2]-e[0]>=a,s=o?0:Math.round((n.center[0]-(e[0]+e[2])/2)/a)*a;return C(o?-1/0:e[0]+s,e[1],o?1/0:e[2]+s,e[3],K),k(K,n)!==0}let n=this.calculateServiceMbsInRenderSR(t);if(!n.isValid)return!0;if(!this._isGlobalMode)return k(e,n)!==0;let r=t.serviceMbsElevationUpdateExtent;return r[0]>r[2]&&(le(n,r),this.elevationIntersectionSpatialReference.isWebMercator&&Number.isFinite(r[0])&&(r[1]=Math.max(-90,r[1]),r[3]=Math.min(90,r[3]),b(r,v.WGS84,r,this.elevationIntersectionSpatialReference)||C(-1/0,-1/0,1/0,1/0,r))),ue(e,r,this.elevationIntersectionSpatialReference)}calculateServiceMbsInRenderSRElevationAdjusted(e){let{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e,r=this.calculateServiceMbsInRenderSR(e);if(!r.isValid||!n?.isValid)return t;let i=G;i.copyFrom(r);let{_elevationContext:a}=this;if(a){let{minElevation:t}=e,{_renderCoordsHelper:r}=this,o=n.center,s=0;if(Number.isFinite(t)){let n=0,c=0,{maxElevation:l}=e,u=o[2];switch(a.mode){case`relative-to-ground`:case`relative-to-scene`:n=a.geometryZWithOffset(u,r)+t-u,c=l-t;break;case`on-the-ground`:n=t-u,c=l-t}s=n+.5*c,i.radius+=.5*c}else i.radius<M&&(s=E(o,this._elevationProvider,a,r)-o[2]);s&&fe(i,s,this._viewingMode)}return e.updateServiceMbsInRenderSRElevationAdjusted(i)}_isGlobalMbsContainingPlanetCenter(e){return this._viewingMode===1&&t(e.center)<=e.radius}calculateMbsConeInRenderSR(e){let{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;let{minElevation:n,maxElevation:r}=e;if(!Number.isFinite(n)||!(n<r))return null;let i=this.calculateServiceMbsInRenderSR(e);if(!i.isValid)return null;let a=this._elevationContext;if(a?.mode===`relative-to-ground`||a?.mode===`relative-to-scene`){let t=e.serviceMbsInIndexSR;if(!t?.isValid)return null;let i=t.center[2],o=a.geometryZWithOffset(i,this._renderCoordsHelper);if(this._viewingMode===2)n+=o,r+=o;else{let e=o-i;n+=e,r+=e}}let o=this._renderCoordsHelper.referenceEllipsoid.radius,s=this._viewingMode===2?new oe(i,n,r):this._isGlobalMbsContainingPlanetCenter(i)?new se(i,o+n,o+r):new ce(i,o+n,o+r);return e.updateMbsConeInRenderSR(s)}getAndUpdateVisibilityObbInRenderSR(e){{let t=e.visibilityObbInRenderSR;if(t)return t}let t=this._indexSREllipsoidRadius*.01,{serviceMbsInIndexSR:r,serviceObbInIndexSR:i}=e;if(i==null||!r||!i.isValid||this._isECEFOBBInLocalMode&&(i.halfSizeX>t||i.halfSizeY>t||i.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(t==null)t=new j,e.serviceObbInRenderSR=t;else if(t.isValid)return t;let a=r.radius,o=0,s=0,c=i.centerZ,l=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){let{minElevation:t,maxElevation:n}=e;switch(u.mode){case`relative-to-ground`:case`relative-to-scene`:o=u.geometryZWithOffset(c,l)+t-c,s=n-t;break;case`on-the-ground`:o=t-c,s=n-t}}else if(u&&a<M){let e=n(z,i.centerX,i.centerY,c);o=E(e,this._elevationProvider,u,l)-c}let d=s>0,f=d?R:t;return i.transform(f,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&ae(f,0,s,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{let t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}let t=e.serviceObbInIndexSR;return t?this._viewingMode===2&&Math.max(t.halfSizeX,t.halfSizeY,t.halfSizeZ)>.2*this._indexSREllipsoidRadius?null:(t.transform(R,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),R):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(this._viewingMode===1?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){r(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(i(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){let n=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),r=t.elevationAgnosticBoundingVolume,i=-1,s;if(n){let t=z;n.getCenter(t),e(t,t),s=t,n.getCorners(B);for(let n of B){e(n,n);let o=a(n,t);if(o<=0){r.invalidate();return}let s=Math.sqrt(Math.max(0,1-o*o));i=Math.max(i,s)}}else{let n=t.serviceMbsInRenderSR;if(!n.isValid){r.invalidate();return}let{center:a,radius:c}=n,l=o(a);if(l<c){r.invalidate();return}i=c/l,s=e(W,a)}r.set(s,i+_e)}_updateElevationAgnosticBoundingVolumeLocal(e){let t=e.elevationAgnosticBoundingVolume,n=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(n){let e=n.getCenter(z);e[2]=0;let r=0,i=V;n.getCorners(B);for(let e of B){e[2]=0;let t=s(i,e);r=Math.max(r,t)}t.set(e,Math.sqrt(r))}else{let n=e.serviceMbsInRenderSR;if(n.isValid){let e=c(z,n.center);e[2]=0,t.set(e,n.radius)}}}isNodeVisible(e){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling)return!0;let t=this.getAndUpdateVisibilityObbInRenderSR(e);return t?t.intersectsFrustumConservativeApproximation(this._frustumPlanes):this._frustum.intersectsSphere(this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||!e.valid?!0:e.intersectsFrustumConservative(this._frustum,this._viewingMode,1)?this._viewingMode!==1||this._isConeVisibleInFrustum(e):!1}_isConeVisibleInFrustum(t){let n=t.radius;if(n>he)return!0;let r=this._frustumPlanes,{center:i,radius:o}=this._frustum.boundingSphere,s=t.getAxis(W),c=a(s,i),f=o+1,p=c-f,m=c+f;if(p<=0)return!0;let h=l(F,s,p),g=l(I,s,m),_=n/Math.sqrt(1-n*n);for(let t of r){let n=T(t),r=e(L,n),i=a(r,s);if(Math.abs(1-i)<ge)continue;let o=H;l(o,s,i),u(o,o,r),e(o,o);let c=de;if(d(c,h,o,p*_),!(w(t,c)<=0)&&(d(c,g,o,m*_),!(w(t,c)<=0)))return!1}return!0}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling||!e.valid)return!0;let{center:n,radius:r}=this._frustum.boundingSphere,i=r+1,o=this._frustumPlanes,s=B;if(t.getCorners(s),this._viewingMode===1){let t=e.getAxis(W),r=a(t,n),c=r-i,u=r+i;if(c<=0)return!0;for(let e of o){let n=!0;for(let r of s){let i=a(r,t),o=U;if(l(o,r,c/i),w(e,o)<=0){n=!1;break}let s=U;if(l(s,r,u/i),w(e,s)<=0){n=!1;break}}if(n)return!1}}else{let e=n[2]-i,t=n[2]+i;for(let n of o){let r=!0,i=T(n),a=i[0],o=i[1],c=i[2],l=n[3];for(let n of s){let i=a*n[0]+o*n[1]+l;if(i+c*e<=0||i+c*t<=0){r=!1;break}}if(r)return!1}}return!0}isGeometryVisible(e){return this._useFrustumCulling?e.geometryObbInRenderSR?.intersectsFrustumConservativeApproximation(this._frustumPlanes)??this.isNodeVisible(e):!0}_isMBSinClippingArea(e){return this._clippingArea==null||k(this._clippingArea,e)!==0}_screenSpaceDiameterMbs(e,t){let n=this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e);return n<0?pe:t/n/this._halfScreenPixelSizePerDistance}calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e){let t=this.calculateMbsConeInRenderSR(e);if(t==null)return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e);let n=t.calculateSurfaceDistanceFromPoint(this._camPos),r=t.calculateCenterDistanceFromPoint(this._camPos);return this._updateMinMaxDistanceToCenter(r),n}calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=f(t.center,this._camPos);return this._updateMinMaxDistanceToCenter(n),n}_calculateAngleDependentLoDForSphere(e,n){let r=u(V,e,this._camPos),i=t(e),o=t(r);if(i===0||o===0)return 1;let s=(Math.abs(a(e,r))/i+n)/o;return Math.min(1,s)}calcAngleDependentLoD(e){let n=this.calculateMbsConeInRenderSR(e);if(n==null){let{center:t,radius:n}=this.calculateServiceMbsInRenderSRElevationAdjusted(e);return this._calculateAngleDependentLoDForSphere(t,n)}let{center:r,radius:i}=this.calculateServiceMbsInRenderSR(e);if(this._viewingMode===2)c(q,r),q[2]=n.lowerCenterHeight,c(J,r),J[2]=n.upperCenterHeight;else{let e=t(r);if(e===0)return 1;l(q,r,n.lowerCenterHeight/e),l(J,r,n.upperCenterHeight/e)}let o=this._calculateAngleDependentLoDForSphere(q,i),s=this._calculateAngleDependentLoDForSphere(J,i);if(this._viewingMode===2)c(Y,r),Y[2]=Math.max(n.lowerCenterHeight,Math.min(n.upperCenterHeight,this._camPos[2]));else{let e=t(r);if(e===0)return Math.max(o,s);let i=Math.max(n.lowerCenterHeight,Math.min(n.upperCenterHeight,a(this._camPos,r)/e));l(Y,r,i/e)}return Math.max(o,s,this._calculateAngleDependentLoDForSphere(Y,i))}hasLOD(e){return e.lodMetric!==0}_getDistanceToSurfaceGlobeMode(e,n){let r=t(n.center),o=t(e)-r;l(q,e,a(e,n.center)/p(e));let s=m(n.center,q),c=n.radius;if(s<=c*c)return Math.abs(o);let u=l(q,n.center,1/r),d=c*c/(2*r),g=l(J,u,r-d),_=i(Y,e,g),v=i(Y,_,l(X,u,a(u,_))),y=h(Y,g,l(Y,v,c/t(v))),b=f(e,y);if(o>=Z){let n=i(J,e,y),r=a(n,u)/t(n);r<Q&&(r=$),b/=r}return b}_getDistanceToSurface(e,t){return this._isGlobalMode?this._getDistanceToSurfaceGlobeMode(e,t):P(e,t)}_applyGlobalFlatAngleCorrectionToConeDistance(e,n){n.calculateClosestCenterToPoint(this._camPos,X);let r=t(X);if(r===0||t(this._camPos)-r<Z)return e;let o=i(Y,this._camPos,X),s=t(o);if(s===0)return e;let c=a(o,X)/(s*r);return e/(c<Q?$:c)}calculateScreenSpaceRelativeSphere(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=this._getDistanceToSurface(this._camPos,t),r=n+t.radius;return this._updateMinMaxDistanceToCenter(r),2*n*this._halfScreenPixelSizePerDistance}calculateScreenSpaceRelativeCone(e){let t=e.calculateCenterDistanceFromPoint(this._camPos);this._updateMinMaxDistanceToCenter(t);let n=e.calculateSurfaceDistanceFromPoint(this._camPos);return 2*(this._isGlobalMode?this._applyGlobalFlatAngleCorrectionToConeDistance(n,e):n)*this._halfScreenPixelSizePerDistance}_updateMinMaxDistanceToCenter(e){e>0?(this.minCenterDistance=Math.min(this.minCenterDistance,e),this.maxCenterDistance=Math.max(this.maxCenterDistance,e)):(this.minCenterDistance=0,this.maxCenterDistance=Math.max(this.maxCenterDistance,-e))}getLodLevel(e){if(e.lodMetric===0)return 0;if(e.childCount===0)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){let t=this._progressiveLoadFactor*this._screenspaceErrorBias,n=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,n)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let n=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(n*=this.calcAngleDependentLoD(e)),n<e.maxError}case 2:{let n=this.calculateMbsConeInRenderSR(e),r=n?this.calculateScreenSpaceRelativeCone(n):this.calculateScreenSpaceRelativeSphere(e);return e.maxError*t<=r}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<me;case 4:return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(e==null)return 0;let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=t.center,r=a(n,this._cameraPOIDirection),i=r*r,o=p(n)-i;return Math.sqrt(o)-t.radius}distCameraToPOI(){return f(this._camPos,this._poi)}}function P(e,t){let n=e[0]-t.center[0],r=e[1]-t.center[1],i=e[2]-t.center[2],a=n*n+r*r,o=t.radius;if(a<=o*o)return Math.abs(i);let s=Math.sqrt(a)-o;return Math.sqrt(i*i+s*s)}const F=g(),I=g(),L=g(),R=new j,z=g(),B=[g(),g(),g(),g(),g(),g(),g(),g()],V=g(),H=g(),de=g(),U=g(),W=g(),G=new re,K=S(),q=g(),J=g(),Y=g(),X=g();function fe(e,n,r){if(r===2)e.center[2]+=n;else{let r=t(e.center);if(r===0){e.radius+=Math.abs(n);return}l(e.center,e.center,1+n/r)}}const pe=.5*Number.MAX_VALUE,me=10,Z=2e5,Q=.08,$=1e-4,he=.9,ge=.01,_e=.001;export{N as default};
|
|
2
|
+
import"../../../../core/has.js";import{normalize as e,add as t,scale as n,length as r,set as i,equals as a,subtract as o,dot as s,len as c,sqrDist as l,copy as u,sub as d,scaleAndAdd as f,distance as p,squaredLength as m,squaredDistance as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import v from"../../../../geometry/SpatialReference.js";import{getSphericalPCPF as y}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingRect as b}from"../../../../geometry/projection/projectBoundingRect.js";import{projectBoundingSphere as ee}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as x}from"../../../../geometry/projection/projectors.js";import{create as S,fromValues as C}from"../../../../geometry/support/aaBoundingRect.js";import{create as te,fromPoints as ne,distance2 as re}from"../../../../geometry/support/lineSegment.js";import{signedDistance as w,getNormal as T}from"../../../../geometry/support/plane.js";import{isPlateCarree as ie,webMercatorValid as E}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as ae}from"../../../../geometry/support/sphere.js";import{evaluateElevationAlignmentAtPoint as D}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as oe}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as O,extractExpressionInfo as se}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as k}from"./I3SUtil.js";import{Frustum as ce}from"../../state/Frustum.js";import{groundNavigationConstants as le}from"../../state/utils/groundNavigationUtils.js";import"../../support/elevationUpdateExtentUtils.js";import{Obb as A,computeOffsetObb as ue}from"../../support/orientedBoundingBox.js";import{SweptSphereCylindricalVolume as de,SphereGlobal as fe,SweptSphereConicalVolume as pe}from"../../support/SweptSphereVolume.js";import{sphereToGeographicExtent as j,intersectsGeographicExtent as M}from"../../support/sphereExtentUtils.js";const N=1e5;class P{get _frustumPlanes(){return this._frustum.planes}constructor(e,t,n,r,i,a,o,s,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=i,this._elevationProvider=a,this._viewingMode=o,this._options=c,this._viewDirection=g(),this._useFrustumCulling=!1,this._poi=g(),this._cameraPOIDirection=g(),this._elevationContext=null,this._checkBelowSegmentEnd=g(),this.minCenterDistance=1/0,this.maxCenterDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this._frustum=new ce(t),this.updateCamera(n,r);let l=this._renderCoordsHelper.spatialReference;this._renderSR=l,this._renderSRSphericalPCPF=y(l),this._isGlobalMode=this._viewingMode===1,this.elevationIntersectionSpatialReference=this._isGlobalMode?this._indexSR.isWebMercator?this._indexSR:this._elevationProvider.spatialReference:l,this.updateElevationInfo(s),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(l.isWebMercator||ie(l)),this._indexSREllipsoidRadius=_(this._indexSR).radius,this._indexSRSphericalPCPF=y(e),this._projectorIndexSRToIndexSRSphericalPCPF=x(this._indexSR,this._indexSRSphericalPCPF),this._groundNavigationCheckDistance=le.i3sNodeDownwardCheckDistanceInMeters/this._renderCoordsHelper.unitInMeters}updateElevationInfo(e){e==null?this._elevationContext=null:(this._elevationContext=oe.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(O(se(e,!1))))}updateCamera(r,i){this._useFrustumCulling=i,e(this._viewDirection,r.viewForward),i&&this._frustum.update(r),this._halfScreenPixelSizePerDistance=r.screenPixelSizePerDistance/2,this._camPos=r.eye,this._updateCameraPOIDirection(),this.minCenterDistance=1/0,this.maxCenterDistance=0,t(this._checkBelowSegmentEnd,this._camPos,n(this._checkBelowSegmentEnd,this._renderCoordsHelper.worldUpAtPosition(this._camPos,this._checkBelowSegmentEnd),-this._groundNavigationCheckDistance))}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){let t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,n){if(this._elevationContext==null)return;let r=e.serviceMbsInIndexSR;if(!r)return;let i=this._elevationContext.mode===`relative-to-scene`?`scene`:`ground`,a=this._elevationProvider;if(a.getSphereElevationRange){let e=a.getSphereElevationRange(r,this._indexSR,i);if(e){n.expandElevationRange(e);return}}let[o,s,c]=r.center,l=a.getElevation(o,s,c,this._indexSR,i);l&&n.expandElevationRangeValues(l,l);let u=t?null:a.getRootElevationRange?.();u&&n.expandElevationRange(u)}calculateServiceMbsInRenderSR(e){let{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e;if(!n?.isValid)return t;let r=G;return ee(n,this._indexSR,r,this._renderSR),e.updateServiceMbsInRenderSR(r)}intersectsElevationUpdate(e,t){if(this._isGlobalMode&&this._indexSR.isWebMercator){let n=t.serviceMbsInIndexSR;if(!n?.isValid)return!0;let[r,i]=E,a=i-r,o=e[2]-e[0]>=a,s=o?0:Math.round((n.center[0]-(e[0]+e[2])/2)/a)*a;return C(o?-1/0:e[0]+s,e[1],o?1/0:e[2]+s,e[3],K),k(K,n)!==0}let n=this.calculateServiceMbsInRenderSR(t);if(!n.isValid)return!0;if(!this._isGlobalMode)return k(e,n)!==0;let r=t.serviceMbsElevationUpdateExtent;return r[0]>r[2]&&(j(n,r),this.elevationIntersectionSpatialReference.isWebMercator&&Number.isFinite(r[0])&&(r[1]=Math.max(-90,r[1]),r[3]=Math.min(90,r[3]),b(r,v.WGS84,r,this.elevationIntersectionSpatialReference)||C(-1/0,-1/0,1/0,1/0,r))),M(e,r,this.elevationIntersectionSpatialReference)}calculateServiceMbsInRenderSRElevationAdjusted(e){let{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e,r=this.calculateServiceMbsInRenderSR(e);if(!r.isValid||!n?.isValid)return t;let i=G;i.copyFrom(r);let{_elevationContext:a}=this;if(a){let{minElevation:t}=e,{_renderCoordsHelper:r}=this,o=n.center,s=0;if(Number.isFinite(t)){let n=0,c=0,{maxElevation:l}=e,u=o[2];switch(a.mode){case`relative-to-ground`:case`relative-to-scene`:n=a.geometryZWithOffset(u,r)+t-u,c=l-t;break;case`on-the-ground`:n=t-u,c=l-t}s=n+.5*c,i.radius+=.5*c}else i.radius<N&&(s=D(o,this._elevationProvider,a,r)-o[2]);s&&_e(i,s,this._viewingMode)}return e.updateServiceMbsInRenderSRElevationAdjusted(i)}_isGlobalMbsContainingPlanetCenter(e){return this._viewingMode===1&&r(e.center)<=e.radius}calculateMbsConeInRenderSR(e){let{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;let{minElevation:n,maxElevation:r}=e;if(!Number.isFinite(n)||!(n<r))return null;let i=this.calculateServiceMbsInRenderSR(e);if(!i.isValid)return null;let a=this._elevationContext;if(a?.mode===`relative-to-ground`||a?.mode===`relative-to-scene`){let t=e.serviceMbsInIndexSR;if(!t?.isValid)return null;let i=t.center[2],o=a.geometryZWithOffset(i,this._renderCoordsHelper);if(this._viewingMode===2)n+=o,r+=o;else{let e=o-i;n+=e,r+=e}}let o=this._renderCoordsHelper.referenceEllipsoid.radius,s=this._viewingMode===2?new de(i,n,r):this._isGlobalMbsContainingPlanetCenter(i)?new fe(i,o+n,o+r):new pe(i,o+n,o+r);return e.updateMbsConeInRenderSR(s)}getAndUpdateVisibilityObbInRenderSR(e){{let t=e.visibilityObbInRenderSR;if(t)return t}let t=this._indexSREllipsoidRadius*.01,{serviceMbsInIndexSR:n,serviceObbInIndexSR:r}=e;if(r==null||!n||!r.isValid||this._isECEFOBBInLocalMode&&(r.halfSizeX>t||r.halfSizeY>t||r.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(t==null)t=new A,e.serviceObbInRenderSR=t;else if(t.isValid)return t;let a=n.radius,o=0,s=0,c=r.centerZ,l=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){let{minElevation:t,maxElevation:n}=e;switch(u.mode){case`relative-to-ground`:case`relative-to-scene`:o=u.geometryZWithOffset(c,l)+t-c,s=n-t;break;case`on-the-ground`:o=t-c,s=n-t}}else if(u&&a<N){let e=i(B,r.centerX,r.centerY,c);o=D(e,this._elevationProvider,u,l)-c}let d=s>0,f=d?z:t;return r.transform(f,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&ue(f,0,s,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{let t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}let t=e.serviceObbInIndexSR;return t?this._viewingMode===2&&Math.max(t.halfSizeX,t.halfSizeY,t.halfSizeZ)>.2*this._indexSREllipsoidRadius?null:(t.transform(z,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),z):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(this._viewingMode===1?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){a(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(o(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){let n=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),r=t.elevationAgnosticBoundingVolume,i=-1,a;if(n){let t=B;n.getCenter(t),e(t,t),a=t,n.getCorners(V);for(let n of V){e(n,n);let a=s(n,t);if(a<=0){r.invalidate();return}let o=Math.sqrt(Math.max(0,1-a*a));i=Math.max(i,o)}}else{let n=t.serviceMbsInRenderSR;if(!n.isValid){r.invalidate();return}let{center:o,radius:s}=n,l=c(o);if(l<s){r.invalidate();return}i=s/l,a=e(W,o)}r.set(a,i+Se)}_updateElevationAgnosticBoundingVolumeLocal(e){let t=e.elevationAgnosticBoundingVolume,n=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(n){let e=n.getCenter(B);e[2]=0;let r=0,i=H;n.getCorners(V);for(let e of V){e[2]=0;let t=l(i,e);r=Math.max(r,t)}t.set(e,Math.sqrt(r))}else{let n=e.serviceMbsInRenderSR;if(n.isValid){let e=u(B,n.center);e[2]=0,t.set(e,n.radius)}}}isNodeVisible(e,t=!1){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling||t&&this.isNodeCloseBelowCamera(e))return!0;let n=this.getAndUpdateVisibilityObbInRenderSR(e);return n?n.intersectsFrustumConservativeApproximation(this._frustumPlanes):this._frustum.intersectsSphere(this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isNodeCloseBelowCamera(e){let t=this.getAndUpdateVisibilityObbInRenderSR(e);if(t?.isValid)return t.intersectSegment(this._camPos,this._checkBelowSegmentEnd);let n=this.calculateServiceMbsInRenderSRElevationAdjusted(e);if(!n.isValid)return!0;let r=ne(this._camPos,this._checkBelowSegmentEnd,me);return re(r,n.center)<=n.radius**2}isElevationAgnosticBoundingVolumeVisible(e,t){return!this._useFrustumCulling||!e.valid?!0:e.intersectsFrustumConservative(this._frustum,this._viewingMode,1+t)?this._viewingMode!==1||this._isConeVisibleInFrustum(e):!1}_isConeVisibleInFrustum(t){let r=t.radius;if(r>be)return!0;let i=this._frustumPlanes,{center:a,radius:o}=this._frustum.boundingSphere,c=t.getAxis(W),l=s(c,a),u=o+1,p=l-u,m=l+u;if(p<=0)return!0;let h=n(I,c,p),g=n(L,c,m),_=r/Math.sqrt(1-r*r);for(let t of i){let r=T(t),i=e(R,r),a=s(i,c);if(Math.abs(1-a)<xe)continue;let o=he;n(o,c,a),d(o,o,i),e(o,o);let l=ge;if(f(l,h,o,p*_),!(w(t,l)<=0)&&(f(l,g,o,m*_),!(w(t,l)<=0)))return!1}return!0}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling||!e.valid)return!0;let{center:r,radius:i}=this._frustum.boundingSphere,a=i+1,o=this._frustumPlanes,c=V;if(t.getCorners(c),this._viewingMode===1){let t=e.getAxis(W),i=s(t,r),l=i-a,u=i+a;if(l<=0)return!0;for(let e of o){let r=!0;for(let i of c){let a=s(i,t),o=U;if(n(o,i,l/a),w(e,o)<=0){r=!1;break}let c=U;if(n(c,i,u/a),w(e,c)<=0){r=!1;break}}if(r)return!1}}else{let e=r[2]-a,t=r[2]+a;for(let n of o){let r=!0,i=T(n),a=i[0],o=i[1],s=i[2],l=n[3];for(let n of c){let i=a*n[0]+o*n[1]+l;if(i+s*e<=0||i+s*t<=0){r=!1;break}}if(r)return!1}}return!0}isGeometryVisible(e,t){if(!this._useFrustumCulling)return!0;let n=e.geometryObbInRenderSR;return!n?.isValid||n.intersectsFrustumConservativeApproximation(this._frustumPlanes)||t&&n.intersectSegment(this._camPos,this._checkBelowSegmentEnd)}_isMBSinClippingArea(e){return this._clippingArea==null||k(this._clippingArea,e)!==0}_screenSpaceDiameterMbs(e,t){let n=this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e);return n<0?ve:t/n/this._halfScreenPixelSizePerDistance}calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e){let t=this.calculateMbsConeInRenderSR(e);if(t==null)return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e);let n=t.calculateSurfaceDistanceFromPoint(this._camPos),r=t.calculateCenterDistanceFromPoint(this._camPos);return this._updateMinMaxDistanceToCenter(r),n}calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=p(t.center,this._camPos);return this._updateMinMaxDistanceToCenter(n),n}_calculateAngleDependentLoDForSphere(e,t){let n=d(H,e,this._camPos),i=r(e),a=r(n);if(i===0||a===0)return 1;let o=(Math.abs(s(e,n))/i+t)/a;return Math.min(1,o)}calcAngleDependentLoD(e){let t=this.calculateMbsConeInRenderSR(e);if(t==null){let{center:t,radius:n}=this.calculateServiceMbsInRenderSRElevationAdjusted(e);return this._calculateAngleDependentLoDForSphere(t,n)}let{center:i,radius:a}=this.calculateServiceMbsInRenderSR(e);if(this._viewingMode===2)u(q,i),q[2]=t.lowerCenterHeight,u(J,i),J[2]=t.upperCenterHeight;else{let e=r(i);if(e===0)return 1;n(q,i,t.lowerCenterHeight/e),n(J,i,t.upperCenterHeight/e)}let o=this._calculateAngleDependentLoDForSphere(q,a),c=this._calculateAngleDependentLoDForSphere(J,a);if(this._viewingMode===2)u(Y,i),Y[2]=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,this._camPos[2]));else{let e=r(i);if(e===0)return Math.max(o,c);let a=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,s(this._camPos,i)/e));n(Y,i,a/e)}return Math.max(o,c,this._calculateAngleDependentLoDForSphere(Y,a))}hasLOD(e){return e.lodMetric!==0}_getDistanceToSurfaceGlobeMode(e,i){let a=r(i.center),c=r(e)-a;n(q,e,s(e,i.center)/m(e));let l=h(i.center,q),u=i.radius;if(l<=u*u)return Math.abs(c);let d=n(q,i.center,1/a),f=u*u/(2*a),g=n(J,d,a-f),_=o(Y,e,g),v=o(Y,_,n(X,d,s(d,_))),y=t(Y,g,n(Y,v,u/r(v))),b=p(e,y);if(c>=Z){let t=o(J,e,y),n=s(t,d)/r(t);n<Q&&(n=$),b/=n}return b}_getDistanceToSurface(e,t){return this._isGlobalMode?this._getDistanceToSurfaceGlobeMode(e,t):F(e,t)}_applyGlobalFlatAngleCorrectionToConeDistance(e,t){t.calculateClosestCenterToPoint(this._camPos,X);let n=r(X);if(n===0||r(this._camPos)-n<Z)return e;let i=o(Y,this._camPos,X),a=r(i);if(a===0)return e;let c=s(i,X)/(a*n);return e/(c<Q?$:c)}calculateScreenSpaceRelativeSphere(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=this._getDistanceToSurface(this._camPos,t),r=n+t.radius;return this._updateMinMaxDistanceToCenter(r),2*n*this._halfScreenPixelSizePerDistance}calculateScreenSpaceRelativeCone(e){let t=e.calculateCenterDistanceFromPoint(this._camPos);this._updateMinMaxDistanceToCenter(t);let n=e.calculateSurfaceDistanceFromPoint(this._camPos);return 2*(this._isGlobalMode?this._applyGlobalFlatAngleCorrectionToConeDistance(n,e):n)*this._halfScreenPixelSizePerDistance}_updateMinMaxDistanceToCenter(e){e>0?(this.minCenterDistance=Math.min(this.minCenterDistance,e),this.maxCenterDistance=Math.max(this.maxCenterDistance,e)):(this.minCenterDistance=0,this.maxCenterDistance=Math.max(this.maxCenterDistance,-e))}getLodLevel(e){if(e.lodMetric===0)return 0;if(e.childCount===0)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){let t=this._progressiveLoadFactor*this._screenspaceErrorBias,n=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,n)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let n=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(n*=this.calcAngleDependentLoD(e)),n<e.maxError}case 2:{let n=this.calculateMbsConeInRenderSR(e),r=n?this.calculateScreenSpaceRelativeCone(n):this.calculateScreenSpaceRelativeSphere(e);return e.maxError*t<=r}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<ye;case 4:return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(e==null)return 0;let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=t.center,r=s(n,this._cameraPOIDirection),i=r*r,a=m(n)-i;return Math.sqrt(a)-t.radius}distCameraToPOI(){return p(this._camPos,this._poi)}}function F(e,t){let n=e[0]-t.center[0],r=e[1]-t.center[1],i=e[2]-t.center[2],a=n*n+r*r,o=t.radius;if(a<=o*o)return Math.abs(i);let s=Math.sqrt(a)-o;return Math.sqrt(i*i+s*s)}const I=g(),L=g(),R=g(),z=new A,B=g(),V=[g(),g(),g(),g(),g(),g(),g(),g()],H=g(),me=te(),he=g(),ge=g(),U=g(),W=g(),G=new ae,K=S(),q=g(),J=g(),Y=g(),X=g();function _e(e,t,i){if(i===2)e.center[2]+=t;else{let i=r(e.center);if(i===0){e.radius+=Math.abs(t);return}n(e.center,e.center,1+t/i)}}const ve=.5*Number.MAX_VALUE,ye=10,Z=2e5,Q=.08,$=1e-4,be=.9,xe=.01,Se=.001;export{P as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import"../../../../core/has.js";import{getOrCreateMapValue as e}from"../../../../core/MapUtils.js";import{estimateAttributesMemory as t}from"../../../../core/memoryEstimations.js";import{signal as n}from"../../../../core/signal.js";import{estimateGeometryMemory as
|
|
2
|
+
import"../../../../core/has.js";import{getOrCreateMapValue as e}from"../../../../core/MapUtils.js";import{estimateAttributesMemory as t}from"../../../../core/memoryEstimations.js";import{signal as n}from"../../../../core/signal.js";import{baseDehydratedGraphicMemory as r,estimateGeometryMemory as i}from"../../../../layers/graphics/dehydratedFeatures.js";class a{constructor(e=()=>void 0){this._getGeometryKey=e,this._payloads=new Map,this._geometries=new Map,this._usedMemory=n(0),this._duplicatedMemory=n(0),this._referenceCount=n(0)}findGeometry(e,t){if(e===void 0)return;let n=this._geometries.get(e);if(n){for(let e of n)if(t(e))return e}}get usedMemory(){return this._usedMemory.value}get usedMemoryPerFeature(){return this._referenceCount.value>0?this._duplicatedMemory.value/this._referenceCount.value:0}getFeatureSize(e){return r+(e.geometry==null?0:this._payloads.get(e.geometry)?.size??0)+(e.attributes==null?0:this._payloads.get(e.attributes)?.size??0)}ref(n,r,a=!0){let o;a&&n.geometry&&!this._payloads.has(n.geometry)&&(o=this._getGeometryKey(n.geometry,r),o!==void 0&&e(this._geometries,o,()=>new Set).add(n.geometry)),this._duplicatedMemory.value+=this._refPayload(n.geometry,i,o)+this._refPayload(n.attributes,t),this._referenceCount.value++}unref(e){let t=e.geometry,n=t&&this._payloads.get(t);if(t&&n?.count===1&&n.geometryKey!==void 0){let e=this._geometries.get(n.geometryKey);e.delete(t),e.size===0&&this._geometries.delete(n.geometryKey)}this._duplicatedMemory.value-=this._unrefPayload(e.geometry)+this._unrefPayload(e.attributes),this._referenceCount.value--}_refPayload(e,t,n){if(e==null)return 0;let r=this._payloads.get(e);if(r)return r.count++,r.size;let i=t(e);return this._payloads.set(e,new o(i,n)),this._usedMemory.value+=i,i}_unrefPayload(e){if(e==null)return 0;let t=this._payloads.get(e);return--t.count===0&&(this._payloads.delete(e),this._usedMemory.value-=t.size),t.size}get test(){}}class o{constructor(e,t){this.size=e,this.geometryKey=t,this.count=1}}export{a as FeatureMemory};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{shuffle as e}from"../../../../core/arrayUtils.js";import has from"../../../../core/has.js";import{baseObjectMemory as t}from"../../../../core/memoryEstimations.js";import{signal as n}from"../../../../core/signal.js";import{create as r,diameter as i}from"../../../../geometry/support/aaBoundingBox.js";import{create as a,fromExtent as o,intersects as s,copy as c,positiveInfinity as l,intersection as u}from"../../../../geometry/support/aaBoundingRect.js";import{numVertices as d,
|
|
2
|
+
import{shuffle as e}from"../../../../core/arrayUtils.js";import has from"../../../../core/has.js";import{baseObjectMemory as t}from"../../../../core/memoryEstimations.js";import{signal as n}from"../../../../core/signal.js";import{create as r,diameter as i}from"../../../../geometry/support/aaBoundingBox.js";import{create as a,fromExtent as o,intersects as s,copy as c,positiveInfinity as l,intersection as u}from"../../../../geometry/support/aaBoundingRect.js";import{numVertices as d,getObjectId as f,computeAABB as p}from"../../../../layers/graphics/dehydratedFeatures.js";import{computeMaxZ as m}from"../graphics/graphicUtils.js";import{SampledGeometryMaxDistanceRatio as h}from"./SampledGeometryMaxDistanceRatio.js";class g{constructor(e,t){this.descriptor=e,this._memory=t,this._numVertices=0,this.exceededTransferLimit=n(!1),this._fetchFailed=n(!1),this._sorted=!1,this._numFeatures=n(_),this._emptyFeatureRatio=n(0),this._estimatedSize=-1,this._sampledDensityEstimate=-1,this._displayingFeatures=null,this.alive=!0,this.filtered=!1,this._features=null,this._featuresLength=n(0),this._featureLimit=n(0),this._fetchStatus=0,this.fetchInformation=n(``),this.fetchingResolution=this.displayingResolution=e.resolution}get featuresMissing(){return this.fetchFailed||(this.hasPreciseFeatureCount?this._featuresLength.value<this.numFeatures:this.exceededTransferLimit.value)}get showsAllFeatures(){return!this.fetchFailed&&this.displayingFeatures!=null&&(this.hasPreciseFeatureCount?this.displayingFeatures.length===this.numFeatures:!this.exceededTransferLimit.value)}get missingAttributes(){return this._missingAttributes}get fetchFailed(){return this._fetchFailed.value}set fetchFailed(e){this._fetchFailed.value=e}get displayingFeatures(){return this._displayingFeatures}set displayingFeatures(e){this._displayingFeatures=e,this.extentIncludingBorrowedFeatures=null}get perTileMaximumNumberOfFeaturesExceeded(){let e=this.isFetched&&this.featuresMissing;return!this.filtered&&(e||this.hasFeatureLimit)}get features(){return this._features}get featureLimit(){return this._featureLimit.value}set featureLimit(e){this._featureLimit.value=e}get hasFeatureLimit(){return this.featureLimit!==this._featuresLength.value}get availableFields(){return this._availableFields}setFeatures(e,t,n,r,i=this.fetchingResolution,a=!0){this._replaceFeatures(e,i,a),this._availableFields=n,this._featuresLength.value=e?.length??0,this._sorted=!1,this._estimatedSize=-1,this._sampledDensityEstimate=-1,this._missingAttributes=r,e&&e.length>0?(this._emptyFeatureRatio.value=t/(e.length+t),this._numVertices=e.reduce((e,t)=>e+d(t.geometry),0)):(this._emptyFeatureRatio.value=0,this._numVertices=0)}computeZQuantizationFactor(){if(this._features&&this._features.length>0){let e=this._features.reduce((e,{geometry:t})=>Math.max(e,m(t)??0),0);return Math.floor(e/this.descriptor.planetRadius)+1}return 1}get emptyFeatureRatio(){return this._emptyFeatureRatio.value}get numFeatures(){return this.hasPreciseFeatureCount?this._numFeatures.value:this._features?this._featuresLength.value:0}set numFeatures(e){this._numFeatures.value=e}get hasPreciseFeatureCount(){return this._numFeatures.value>_}get needsFeatureCount(){return this._numFeatures.value===_}get numVertices(){return this._numVertices}get id(){return this.descriptor.id}get estimatedSize(){return this.updateEstimates(),this._estimatedSize}get sampledDensityEstimate(){return this._sampledDensityEstimate}updateEstimates(){if(this._estimatedSize<0||this._sampledDensityEstimate<0){this._estimatedSize=0,this._sampledDensityEstimate=0;let e=Math.floor(Math.sqrt(x));if(this._features){let t=null,n=new h(x,has(`featurelayer-snapping-density-max-distance`)*this.fetchingResolution),r=this._features.length;for(let i=0;i<r;++i){let a=this._features[i],o=this._memory.getFeatureSize(a);if(this._estimatedSize+=o,!n.done){let o=r-i,s=Math.ceil(o/Math.max(1,Math.floor(Math.sqrt(n.numRemainingSamples))));if(i%s===0){let r=Math.max(Math.floor(n.numRemainingSamples/o),e);n.sampleGeometry(a.geometry,t,r)}}t=a.geometry}this._sampledDensityEstimate=n.numSamples>=S?n.ratio:0}return!0}return!1}get fetchStatus(){return this._fetchStatus}requestFetch(){this._fetchStatus=0}requestRefetch(){this._fetchStatus=1}requestAttributes(){this._fetchStatus=this._fetchStatus===9||this.attributeRefetchCompletionStatus===9?6:4}get needsAttributesFetching(){return this._fetchStatus===4||this._fetchStatus===5||this._fetchStatus===6||this._fetchStatus===7}get attributeRefetchCompletionStatus(){return this._fetchStatus===6||this._fetchStatus===7?9:8}startFetch(){this._fetchStatus=this.needsAttributesFetching?this.attributeRefetchCompletionStatus===9?7:5:this.needsRefetch?3:2}fetchDone(e){this._fetchStatus=e}get isFetching(){return this._fetchStatus===2||this.isRefetching}get isRefetching(){return this._fetchStatus===3||this._fetchStatus===5||this._fetchStatus===7}get needsFetch(){return this._fetchStatus===0||this.needsRefetch}get needsRefetch(){return this._fetchStatus===1||this._fetchStatus===4||this._fetchStatus===6}get isFetched(){return this._fetchStatus===8||this._fetchStatus===9}isFullyFetched(e){return!!this.features&&(this.features.length>=e||this.fetchStatus===9)}resetFetching(){this.needsAttributesFetching?this.requestAttributes():this._fetchStatus=+!!this.isRefetching}get needsDisplayUpdate(){return!!this._features&&!b(this._features,this.displayingFeatures,this.featureLimit)}intersects(e){return e==null||!this.descriptor.extent||(o(e,C),s(this.descriptor.extent,C))}intersectionIncludingBorrowed(e,t){let n=this.extentIncludingBorrowedFeatures==null?this.descriptor.extent:this.extentIncludingBorrowedFeatures;return!e&&!n?(c(t,l),t):(e==null?c(t,n):(o(e,t),u(t,n,t)),t)}_shuffle(t){this._features?.sort((e,n)=>f(e,t)-f(n,t)),e(this._features,16438)}_sortBySize(e){this._features?.sort((t,n)=>i(p(n.geometry,w))-i(p(t.geometry,w))||f(t,e)-f(n,e))}reduceFeatures(e,t,n,r){if(e<=0)return!1;if(!this._features)return this.featureLimit=0,!1;let i=!1;this.featureLimit=Math.ceil(this.numFeatures*e),this.featureLimit>this._features.length&&this._fetchStatus===8&&this._features.length>0&&(this._fetchStatus=1,i=!0),!this._sorted&&e<1&&(r===1?this._shuffle(n):this._sortBySize(n),this._sorted=!0);let a=Math.max(this.featureLimit,Math.ceil(t*this.numFeatures));if(this._features.length>a){for(let e=a;e<this._features.length;e++)this._memory.unref(this._features[e]);switch(this._features.length=this._featuresLength.value=a,this._estimatedSize=-1,this.exceededTransferLimit.value=!1,this._fetchStatus){case 9:this._fetchStatus=8;break;case 6:this._fetchStatus=4;break;case 7:this._fetchStatus=5}}return i}get cache(){return new y(this,this._features,this._numFeatures.value,this._emptyFeatureRatio.value)}set cache(e){this._replaceFeatures(e.features,e.resolution),this.requestController=null,this._availableFields=e.availableFields,this._featuresLength.value=e.features?.length??0,this._numFeatures.value=e.numFeatures,this._emptyFeatureRatio.value=e.emptyFeatureRatio,this._fetchStatus=e.fetchStatus,this.exceededTransferLimit.value=e.exceededTransferLimit,this._estimatedSize=-1,this._sampledDensityEstimate=-1,this.fetchInformation.value=e.fetchInformation}_replaceFeatures(e,t,n=!0){for(let r of e??[])this._memory.ref(r,t,n);for(let e of this._features??[])this._memory.unref(e);this._features=e}}const _=-1,v=-2;class y{constructor(e,n,r,i){this.features=n,this.numFeatures=r,this.emptyFeatureRatio=i,this.usedMemory=t+e.estimatedSize,this.resolution=e.displayingResolution,this.availableFields=e.availableFields,this.fetchStatus=e.fetchStatus,this.exceededTransferLimit=e.exceededTransferLimit.value,this.fetchInformation=e.fetchInformation.value}}function b(e,t,n){if(t==null||e==null||n!==t.length||n>e.length)return!1;for(let r=0;r<n;++r)if(e[r]!==t[r])return!1;return!0}const x=150,S=100,C=a(),w=r();export{g as FeatureTile,y as FeatureTileCacheItem,v as failedFeatureCount};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Logger.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{NavigationMode3D as i}from"./NavigationMode3D.js";let a=class extends i{constructor(e){super(e),this.type=`ground`,this.nearOverride=.5,this.farOverride=1e4}attach(e){super.attach(e),this._warnIfOffsetIsBelowConstraints()}detach(){super.detach()}get offset(){let e=this._get(`offset`);return e===void 0?1.5:e}set offset(e){this._set(`offset`,e),this._warnIfOffsetIsBelowConstraints()}_warnIfOffsetIsBelowConstraints(){if(this.view==null||this.offset==null)return;let e=this.view.state.constraints.altitude,n=this.view.state.constraints.collision;e&&this.offset<e.min&&t.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 ${e.min}. Unexpected behaviour close to ground might occur. Adjust or remove constraints from view.constraints.altitude to address this.`);let r=
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Logger.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{NavigationMode3D as i}from"./NavigationMode3D.js";let a=class extends i{constructor(e){super(e),this.type=`ground`,this.nearOverride=.5,this.farOverride=1e4}attach(e){super.attach(e),this._warnIfOffsetIsBelowConstraints()}detach(){super.detach()}get offset(){let e=this._get(`offset`);return e===void 0?1.5:e}set offset(e){this._set(`offset`,e),this._warnIfOffsetIsBelowConstraints()}_warnIfOffsetIsBelowConstraints(){if(this.view==null||this.offset==null)return;let e=this.view.state.constraints.altitude,n=this.view.state.constraints.collision;e&&this.offset<e.min&&t.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 ${e.min}. Unexpected behaviour close to ground might occur. Adjust or remove constraints from view.constraints.altitude to address this.`);let r=n.elevationMargin;n?.enabled&&this.offset<r&&t.getLogger(this).warn(`offset-smaller-than-navigation-constraint`,`The ground navigation offset of ${this.offset} is smaller than the value of ${r} 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.`)}};e([n()],a.prototype,`include`,void 0),e([n()],a.prototype,`exclude`,void 0),e([n()],a.prototype,`offset`,null),a=e([r(`esri.views.3d.navigation.modes.GroundNavigationMode3D`)],a);export{a as GroundNavigationMode3D};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import n from"../../../core/Logger.js";import{clamp as r,deg2rad as i}from"../../../core/mathUtils.js";import{property as a,subclass as o}from"../../../core/accessorSupport/decorators.js";import{earth as s}from"../../../geometry/support/Ellipsoid.js";import{makePiecewiseLinearFunction as c}from"../support/mathUtils.js";let l=class extends t{constructor(e){super(e),this.collision=new
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import n from"../../../core/Logger.js";import{clamp as r,deg2rad as i}from"../../../core/mathUtils.js";import{property as a,subclass as o}from"../../../core/accessorSupport/decorators.js";import{earth as s}from"../../../geometry/support/Ellipsoid.js";import{makePiecewiseLinearFunction as c}from"../support/mathUtils.js";let l=class extends t{constructor(e){super(e),this.collision=new m,this.distance=1/0,this.minimumPoiDistance=4,this.tilt=null}get altitude(){return this.mode===2?null:this._get(`altitude`)||null}set altitude(e){this.mode===2?n.getLogger(this).warn(`Altitude constraint is ignored in local scenes`):this._set(`altitude`,e)}get mode(){return this.state.viewingMode}clampAltitude(e){return this.altitude?r(e,this.altitude.min,this.altitude.max):e}clampTilt(e,t){if(!this.tilt)return t;let n=this.tilt(e);return r(t,n.min,n.max)}clampDistance(e){return Math.min(e,this.distance)}createDefaultTilt(){return this.mode===2?this._createDefaultTiltLocal():this._createDefaultTiltGlobal()}createConstantMaxTilt(e){return(t,n=p)=>(n.min=f.min,n.max=e,n)}_createDefaultTiltLocal(){let e=this.collision.enabled?c([[4e3,f.max],[1e4,i(88)],[6e6,i(88)]]):()=>f.max;return(t,n=p)=>(n.min=f.min,n.max=e(t),n)}_createDefaultTiltGlobal(){let e=this.collision.enabled?c([[4e3,f.max],[5e4,i(88)],[6e6,i(88)],[2e7,f.min]]):c([[3e5,f.max],[3e6,i(88)],[6e6,i(88)],[2e7,f.min]]);return(t,n=p)=>(n.min=f.min,n.max=e(t),n)}};e([a()],l.prototype,`altitude`,null),e([a({readOnly:!0})],l.prototype,`collision`,void 0),e([a()],l.prototype,`distance`,void 0),e([a({readOnly:!0})],l.prototype,`minimumPoiDistance`,void 0),e([a()],l.prototype,`tilt`,void 0),e([a({constructOnly:!0})],l.prototype,`state`,void 0),l=e([o(`esri.views.3d.state.Constraints`)],l);function u(e){return{min:-2e5,max:4*e.radius}}const d=u(s),f={min:i(.5),max:i(179.5)},p={min:0,max:0};let m=class extends t{constructor(){super(...arguments),this.enabled=!0,this.elevationMargin=1}};e([a({type:Boolean})],m.prototype,`enabled`,void 0),e([a({type:Number})],m.prototype,`elevationMargin`,void 0),m=e([o(`esri.views.3d.state.Constraints.CollisionConstraint`)],m);export{l as Constraints,f as TiltRange,d as earthAltitudeConstraint};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{acosClamped as e,lerp as t,clamp as
|
|
2
|
+
import{acosClamped as e,lerp as t,smoothstep as n,clamp as r}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as i}from"../../../core/units.js";import{length as a,normalize as o,scale as s,dot as c,subtract as l,set as u}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as f}from"../../../geometry/ellipsoidUtils.js";import p from"../../../geometry/Extent.js";import{create as m,fromValues as h}from"../../../geometry/support/ray.js";import{Sphere as g}from"../../../geometry/support/sphere.js";import{computeInnerAltitudeFade as _}from"../webgl-engine/effects/atmosphere/atmosphereUtils.js";import{DepthRange as v}from"../webgl-engine/lib/DepthRange.js";function y(e,t,n){return e===1?new x(t,n):new b(t,n)}class b{constructor(e,t){this._elevationProvider=e,this._referenceEllipsoid=f(t),this._unitInMeters=i(t,this._referenceEllipsoid.metersPerDegree)}compute(e,n,i,a){let{eye:s,center:d}=e,f=this._unitInMeters,p=s[2]*f,m=p-a,h=this._elevationProvider?.visibleElevationRange,g=h?m>=0?p-f*h.minElevation:f*h.maxElevation-p:p,_=n??B,v={x:_.xmax-_.xmin,y:_.ymax-_.ymin,z:4*Math.max(_.xmax-_.xmin,_.ymax-_.ymin)},y=Math.max(v.x,v.y,v.z),b=l(I,d,s),x=u(F,b[0]>0?_.xmax:_.xmin,b[1]>0?_.ymax:_.ymin,b[2]>0?y/2:-y/2);l(x,x,s),o(b,b);let w=c(x,b)*1.1*f,T=Math.abs(m),D=Math.sqrt(T*(T+2*this._referenceEllipsoid.radius)),O=Math.max(_.xmax-_.xmin,_.ymax-_.ymin),k=O*N*f,A=O*P*f,j=r((g-A)/(k-A),0,1)**3,M=Math.min(t(D,w,j),D)*Math.max(Math.log(Math.abs(m)),1);return S(Math.min(M,Math.max(34064e4,y))/f,E,f,L),C(p,a,L)}computeFarDistance(e,t,n){return n}}class x{constructor(e,t){this._elevationProvider=e,this._referenceEllipsoid=f(t)}compute(n,i,u,d){let{eye:f}=n,p=a(f),m=this._referenceEllipsoid.radius,g=p-m,y=this._computeVirtualAltitude(g,d),b=this._elevationProvider?.visibleElevationRange.maxElevation??0,x=_(y),O=this._computeFarDistance(p,y,d),k=(Math.log(y)-w)/(T-w);S(O,r(E-k*(E-D),D,E),1,L);let A=m+b,j=m+this._referenceEllipsoid.atmosphereHeight,N=Math.max(A,j),P=p-N;if(x>0&&P>M){let r=o(F,s(F,n.eye,-1)),i=o(I,n.viewForward),d=e(c(r,i)),f=n.fovY*.5,p=Math.cos(f),m=v.Infinite.near;if(d<=f)m=P*p;else{let e=o(F,n.viewUp),t=s(F,e,Math.tan(f)),r=o(F,l(F,i,t)),c=h(n.eye,r,z);if(R.radius=N,R.intersectRay(c,F)){let e=l(F,F,n.eye);m=a(e)*p}}let g=Math.min(u.near,m)*.99;g<v.Infinite.near&&g>L.near&&(L.near=t(L.near,g,x))}return C(g,d,L)}computeFarDistance(e,t){let n=a(e),r=n-this._referenceEllipsoid.radius,i=this._computeVirtualAltitude(r,t);return this._computeFarDistance(n,i,t)}_computeFarDistance(e,t,n){let r=this._referenceEllipsoid.radius,i=r+Math.min(0,n),a=_(t),o=Math.sqrt(t*(t+2*i)),s=o+Math.min(o*.2,r*.01),c=(e+r)*1.2;return a<.5?s:c}_computeVirtualAltitude(e,t){let n=Math.abs(e-t);return Math.max(n,Math.abs(e))}}function S(e,t,n,r){let i=M/n,a=e/t;return a>i?(r.far=e,r.near=a):(r.near=i,r.far=r.near*t),r}function C(e,r,i){let a=Math.abs(e-r),o=n(A,j,a);return i.near=t(O,L.near,o),i.far=t(k,L.far,o),i}const w=7.983,T=16.994,E=2e4,D=100,O=1,k=4e4,A=1,j=5,M=2,N=.001,P=1e-4,F=d(),I=d(),L={near:0,far:0},R=new g,z=m(),B=new p({xmin:0,ymin:0,zmin:0,xmax:0,ymax:0,zmax:0});export{x as NearFarHeuristicGlobal,b as NearFarHeuristicLocal,y as createNearFarHeuristic,M as minNearDistanceInMeters};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{createScreenPointArray as e}from"../../../../core/screenUtils.js";import{crossAndNormalize as t,copy as n,scale as r,subtract as i,add as a,distance as o,normalize as s,cross as c,dot as l,scaleAndAdd as u,length as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{fromValues as m}from"../../../../geometry/support/lineSegment.js";import{create as h,fromPositionAndNormal as g,distance as _,projectPoint as v,projectVector as y,intersectLineSegment as b}from"../../../../geometry/support/plane.js";import{create as x}from"../../../../geometry/support/ray.js";import{Sphere as S}from"../../../../geometry/support/sphere.js";import{fromRenderCamera as ee}from"../../webgl.js";import{getVoxelWasm as C}from"../../layers/VoxelWasm.js";import{pickPointAndInitSphere as w,sphereOrPlanePointFromScreenPoint as T,intersectPlaneFromScreenPoint as E,searchAreaSize as D}from"./navigationUtils.js";import{OffsetCorrectionController as O}from"./OffsetCorrectionController.js";import{fromScreenAtEye as te}from"../../support/geometryUtils/ray.js";import ne from"../../webgl/RenderCamera.js";import{Intersector as re}from"../../webgl-engine/lib/Intersector.js";const k=1.5,A={xSpeedMultiplier:k,ySpeedMultiplier:k,maxElevation:1e4,relativeHorizonPadding:.1,minimumHorizonPadding:12},j=f(),M=f(),N=e(),P=f(),F=h(),I=f(),L=f(),R=f(),z=f(),B=f(),ie=f(),V=f(),H=f(),U=f(),W=f(),G=e(),K=x(),q=new S,J=f(),Y=h(),X=f(),ae=f();function oe(e,t){return y(t,e.viewForward,j),a(M,e.eye,j),e.projectToScreen(M,N),N[1]}function se(e,n,d){let f=e.eye;if(o(n.center,f)<n.radius)return s(B,f),c(ie,B,e.viewRight),a(M,f,ie),e.projectToScreen(M,G),G[1];let p=e.up;te(e,d,K);let m=n.radius;if(t(P,p,K.direction),g(f,P,F),_(F,n.center)>m)return null;v(F,n.center,I);let h=o(n.center,I),y=Math.sqrt(m**2-h**2);i(L,f,I),s(R,L),t(z,P,R);let b=l(L,R),x=l(L,z),S=Math.sqrt(b**2+x**2),ee=Math.sqrt(S**2-y**2),C=y**2/S**2,w=y/S**2*ee,T=C*b,E=w*-x,D=C*x,O=w*b,ne=T+E,re=T-E,k=D+O,A=D-O;return a(V,I,u(V,r(V,R,ne),z,k)),a(H,I,u(H,r(H,R,re),z,A)),i(U,V,f),s(U,U),i(W,H,f),s(W,W),l(e.viewForward,U)>=l(e.viewForward,W)?e.projectToScreen(V,G):e.projectToScreen(H,G),G[1]}function ce(e,t,n=!0){return n?e<t:e<=t}function Z(e,t,n=!0){return n?e>t:e>=t}function le(e,t,n){return t?e>n:e<n}function Q(e,t){let n=e.fullHeight/e.pixelRatio,r=Math.max(t,n-t);return Math.max(A.minimumHorizonPadding,A.relativeHorizonPadding*r)}function ue(e,t){return[de(e,t),fe(e,t)]}function de(e,t){let n=e.fullHeight/e.pixelRatio;return Math.min(n,t+Q(e,t))}function fe(e,t){return Math.max(0,t-Q(e,t))}function pe(e,t,n){let r={translation:e,location:t};return n&&(r.normal=n),r}function me(e){let{view:t}=e;return t.viewingMode===`global`?he(e):ge(e)}function he(e){let{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:c,outGrabLocation:l,outGrabNormal:u,intersectionOptions:d,depthSearchSize:f}=e,m=t.state.camera,h=pe(c,l,u);q.radius=p(t.spatialReference).radius;let g=w(t,m,r,q.radius,1,d);if(g.scenePickPoint==null)return!1;let _=g.hasGeometryIntersection;n(J,g.scenePickPoint),n(h.location,J);let v=g.sphere;h.normal&&g.normal&&n(h.normal,g.normal);let y=ve(r,i,a,_),b=_?o(J,m.eye):1/0;return y.wasAdjusted&&ye({view:t,screenAdjustment:y,intersector:$(t),fallbackCheck:(e,t,n)=>{let r=T(v,m,e,t);return r&&n&&s(n,t),r},output:h,intersectionOptions:d}),xe({view:t,screenPoint:y.adjustedScreenPoint,camera:m,initialDistance:b,depthSearchSize:f??D,output:h}),!0}function ge(e){let{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:c,outGrabLocation:l,outGrabNormal:d,intersectionOptions:f,depthSearchSize:p}=e,m=t.sceneIntersectionHelper,h=t.state.camera,_=$(t),v=pe(c,l,d);m.intersectIntersectorScreen(r,_,f);let y=_.results.min.getIntersectionPoint(J),b=y?o(J,h.eye):1/0;y&&(n(v.location,J),v.normal&&n(v.normal,_.results.min.normal)),t.renderCoordsHelper.worldUpAtPosition(h.eye,B),u(X,h.eye,B,-h.relativeElevation),g(X,B,Y);let x=ve(r,i,a,y);return x.wasAdjusted&&ye({view:t,screenAdjustment:x,intersector:_,fallbackCheck:(e,t,n)=>{let r=E(Y,h,e,t);return r&&n&&s(n,B),r},output:v,intersectionOptions:f}),xe({view:t,screenPoint:x.adjustedScreenPoint,camera:h,initialDistance:b,depthSearchSize:p??D,output:v}),!0}function _e(e,t,n,r){return!r&&ce(e,t)||r&&le(e,!1,n[0])?n[0]:!r&&Z(e,t,!1)?n[1]:null}function ve(t,n,r,i){let a=_e(t[1],n,r,i);return{originalScreenPoint:t,adjustedScreenPoint:e(t[0],a??t[1]),horizonY:n,horizonPadding:r,wasAdjusted:a!==null}}function $(e){let t=new re(e.state.viewingMode);return t.options.selectionMode=!0,t.options.store=0,t.options.hud=!1,t.options.normalRequired=!0,t}function ye(e){let{view:t,screenAdjustment:r,fallbackCheck:i,intersector:a,output:o,intersectionOptions:s}=e,c=t.sceneIntersectionHelper;c.intersectIntersectorScreen(r.adjustedScreenPoint,a,{...s,requiresGroundFeedback:!0});let l=a.results.min.getIntersectionPoint(o.location);if(l){o.normal&&n(o.normal,a.results.min.normal);return}let u=be(r);c.intersectIntersectorScreen(u,a,{...s,requiresGroundFeedback:!0}),l=a.results.min.getIntersectionPoint(o.location),l?o.normal&&n(o.normal,a.results.min.normal):(l=i(r.adjustedScreenPoint,o.location,o.normal),l||i(u,o.location,o.normal))}function be(t){let{originalScreenPoint:n,adjustedScreenPoint:r,horizonY:i,horizonPadding:a}=t,o=Z(r[1],i)?Math.min(a[1],n[1]):Math.max(a[0],n[1]);return e(r[0],o)}function xe(e){Se(e),Ce(e)}function Se(e){let{view:t,camera:r,output:a}=e,{offset:o}=t.navigation.mode;if(!o)return;let{translation:s,location:c}=a;t.renderCoordsHelper.worldUpAtPosition(r.eye,B),u(X,r.eye,B,-o),g(X,B,F),b(F,m(r.eye,i(j,c,r.eye)),X)&&(n(c,X),i(s,c,r.eye))}function Ce(e){let{view:t,screenPoint:n,camera:o,initialDistance:c,depthSearchSize:l,output:u}=e,f=l>0?t.stage.renderView.getMinimalDepthForArea(C(t),n[0],n[1],o,l):null;i(u.translation,u.location,o.eye);let p=Math.min(d(u.translation),c);f&&f<=p&&(p=f),s(u.translation,u.translation),r(u.translation,u.translation,p),a(u.location,u.translation,o.eye)}async function we(e,t,n,r,i){let a=new ne().copyFrom(e.state.camera);if(Te({view:e,camera:a,forwardDirection:t,forwardDistance:n,detectCollisions:!0}))return r?r.smoothlyCorrectGroundElevation({camera:a,deltaTime:i}):new O(e).immediatelyCorrectGroundElevation({camera:a,correctionLimit:100}),e.goTo(ee(e,a),{duration:500,liftOffDisabled:!0})}function Te(e){let{view:s,camera:c,forwardDirection:l,forwardDistance:u,detectCollisions:f}=e,p=s.navigation.mode;if(p.type!==`ground`)return!1;s.renderCoordsHelper.worldUpAtPosition(c.eye,B);let m=s.sceneIntersectionHelper,h=$(s),g=t(j,B,t(j,l,B));n(K.origin,c.eye),r(K.direction,g,u);let _=m.intersectRay(K,h,J,{include:p.include,exclude:p.exclude}),v=i(ae,c.center,c.eye);return!f||!_||o(J,c.eye)>Math.abs(u)?c.eye=a(j,K.origin,K.direction):(i(j,J,c.eye),d(j)>2&&(Ee(j,j,.25,2),c.eye=a(j,c.eye,j))),c.center=a(j,c.eye,v),!0}function Ee(e,t,n,i){let a=d(e),o=Math.min(n,Math.max(a-i,0)/a);r(t,e,o)}export{Te as advanceGroundNavigationCamera,Q as computeHorizonPadding,ue as computeHorizonPaddingLimits,me as findGroundNavigationGrabLocation,oe as findPlaneHorizonY,se as findSphereHorizonY,we as groundNavigationAdvance,A as groundNavigationConstants,ce as isAboveHorizon,Z as isBelowHorizon,Ee as shortenTranslation,le as shouldClampScreenY};
|
|
2
|
+
import{createScreenPointArray as e}from"../../../../core/screenUtils.js";import{crossAndNormalize as t,copy as n,scale as r,subtract as i,add as a,distance as o,normalize as s,cross as c,dot as l,scaleAndAdd as u,length as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{fromValues as m}from"../../../../geometry/support/lineSegment.js";import{create as h,fromPositionAndNormal as g,distance as _,projectPoint as v,projectVector as y,intersectLineSegment as b}from"../../../../geometry/support/plane.js";import{create as x}from"../../../../geometry/support/ray.js";import{Sphere as S}from"../../../../geometry/support/sphere.js";import{fromRenderCamera as ee}from"../../webgl.js";import{getVoxelWasm as C}from"../../layers/VoxelWasm.js";import{pickPointAndInitSphere as w,sphereOrPlanePointFromScreenPoint as T,intersectPlaneFromScreenPoint as E,searchAreaSize as D}from"./navigationUtils.js";import{OffsetCorrectionController as O}from"./OffsetCorrectionController.js";import{fromScreenAtEye as te}from"../../support/geometryUtils/ray.js";import ne from"../../webgl/RenderCamera.js";import{Intersector as re}from"../../webgl-engine/lib/Intersector.js";const k=1.5,A={xSpeedMultiplier:k,ySpeedMultiplier:k,maxElevation:1e4,relativeHorizonPadding:.1,minimumHorizonPadding:12,i3sNodeDownwardCheckDistanceInMeters:5},j=f(),M=f(),N=e(),P=f(),F=h(),I=f(),L=f(),R=f(),z=f(),B=f(),ie=f(),V=f(),H=f(),U=f(),W=f(),G=e(),K=x(),q=new S,J=f(),Y=h(),X=f(),ae=f();function oe(e,t){return y(t,e.viewForward,j),a(M,e.eye,j),e.projectToScreen(M,N),N[1]}function se(e,n,d){let f=e.eye;if(o(n.center,f)<n.radius)return s(B,f),c(ie,B,e.viewRight),a(M,f,ie),e.projectToScreen(M,G),G[1];let p=e.up;te(e,d,K);let m=n.radius;if(t(P,p,K.direction),g(f,P,F),_(F,n.center)>m)return null;v(F,n.center,I);let h=o(n.center,I),y=Math.sqrt(m**2-h**2);i(L,f,I),s(R,L),t(z,P,R);let b=l(L,R),x=l(L,z),S=Math.sqrt(b**2+x**2),ee=Math.sqrt(S**2-y**2),C=y**2/S**2,w=y/S**2*ee,T=C*b,E=w*-x,D=C*x,O=w*b,ne=T+E,re=T-E,k=D+O,A=D-O;return a(V,I,u(V,r(V,R,ne),z,k)),a(H,I,u(H,r(H,R,re),z,A)),i(U,V,f),s(U,U),i(W,H,f),s(W,W),l(e.viewForward,U)>=l(e.viewForward,W)?e.projectToScreen(V,G):e.projectToScreen(H,G),G[1]}function ce(e,t,n=!0){return n?e<t:e<=t}function Z(e,t,n=!0){return n?e>t:e>=t}function le(e,t,n){return t?e>n:e<n}function Q(e,t){let n=e.fullHeight/e.pixelRatio,r=Math.max(t,n-t);return Math.max(A.minimumHorizonPadding,A.relativeHorizonPadding*r)}function ue(e,t){return[de(e,t),fe(e,t)]}function de(e,t){let n=e.fullHeight/e.pixelRatio;return Math.min(n,t+Q(e,t))}function fe(e,t){return Math.max(0,t-Q(e,t))}function pe(e,t,n){let r={translation:e,location:t};return n&&(r.normal=n),r}function me(e){let{view:t}=e;return t.viewingMode===`global`?he(e):ge(e)}function he(e){let{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:c,outGrabLocation:l,outGrabNormal:u,intersectionOptions:d,depthSearchSize:f}=e,m=t.state.camera,h=pe(c,l,u);q.radius=p(t.spatialReference).radius;let g=w(t,m,r,q.radius,1,d);if(g.scenePickPoint==null)return!1;let _=g.hasGeometryIntersection;n(J,g.scenePickPoint),n(h.location,J);let v=g.sphere;h.normal&&g.normal&&n(h.normal,g.normal);let y=ve(r,i,a,_),b=_?o(J,m.eye):1/0;return y.wasAdjusted&&ye({view:t,screenAdjustment:y,intersector:$(t),fallbackCheck:(e,t,n)=>{let r=T(v,m,e,t);return r&&n&&s(n,t),r},output:h,intersectionOptions:d}),xe({view:t,screenPoint:y.adjustedScreenPoint,camera:m,initialDistance:b,depthSearchSize:f??D,output:h}),!0}function ge(e){let{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:c,outGrabLocation:l,outGrabNormal:d,intersectionOptions:f,depthSearchSize:p}=e,m=t.sceneIntersectionHelper,h=t.state.camera,_=$(t),v=pe(c,l,d);m.intersectIntersectorScreen(r,_,f);let y=_.results.min.getIntersectionPoint(J),b=y?o(J,h.eye):1/0;y&&(n(v.location,J),v.normal&&n(v.normal,_.results.min.normal)),t.renderCoordsHelper.worldUpAtPosition(h.eye,B),u(X,h.eye,B,-h.relativeElevation),g(X,B,Y);let x=ve(r,i,a,y);return x.wasAdjusted&&ye({view:t,screenAdjustment:x,intersector:_,fallbackCheck:(e,t,n)=>{let r=E(Y,h,e,t);return r&&n&&s(n,B),r},output:v,intersectionOptions:f}),xe({view:t,screenPoint:x.adjustedScreenPoint,camera:h,initialDistance:b,depthSearchSize:p??D,output:v}),!0}function _e(e,t,n,r){return!r&&ce(e,t)||r&&le(e,!1,n[0])?n[0]:!r&&Z(e,t,!1)?n[1]:null}function ve(t,n,r,i){let a=_e(t[1],n,r,i);return{originalScreenPoint:t,adjustedScreenPoint:e(t[0],a??t[1]),horizonY:n,horizonPadding:r,wasAdjusted:a!==null}}function $(e){let t=new re(e.state.viewingMode);return t.options.selectionMode=!0,t.options.store=0,t.options.hud=!1,t.options.normalRequired=!0,t}function ye(e){let{view:t,screenAdjustment:r,fallbackCheck:i,intersector:a,output:o,intersectionOptions:s}=e,c=t.sceneIntersectionHelper;c.intersectIntersectorScreen(r.adjustedScreenPoint,a,{...s,requiresGroundFeedback:!0});let l=a.results.min.getIntersectionPoint(o.location);if(l){o.normal&&n(o.normal,a.results.min.normal);return}let u=be(r);c.intersectIntersectorScreen(u,a,{...s,requiresGroundFeedback:!0}),l=a.results.min.getIntersectionPoint(o.location),l?o.normal&&n(o.normal,a.results.min.normal):(l=i(r.adjustedScreenPoint,o.location,o.normal),l||i(u,o.location,o.normal))}function be(t){let{originalScreenPoint:n,adjustedScreenPoint:r,horizonY:i,horizonPadding:a}=t,o=Z(r[1],i)?Math.min(a[1],n[1]):Math.max(a[0],n[1]);return e(r[0],o)}function xe(e){Se(e),Ce(e)}function Se(e){let{view:t,camera:r,output:a}=e,{offset:o}=t.navigation.mode;if(!o)return;let{translation:s,location:c}=a;t.renderCoordsHelper.worldUpAtPosition(r.eye,B),u(X,r.eye,B,-o),g(X,B,F),b(F,m(r.eye,i(j,c,r.eye)),X)&&(n(c,X),i(s,c,r.eye))}function Ce(e){let{view:t,screenPoint:n,camera:o,initialDistance:c,depthSearchSize:l,output:u}=e,f=l>0?t.stage.renderView.getMinimalDepthForArea(C(t),n[0],n[1],o,l):null;i(u.translation,u.location,o.eye);let p=Math.min(d(u.translation),c);f&&f<=p&&(p=f),s(u.translation,u.translation),r(u.translation,u.translation,p),a(u.location,u.translation,o.eye)}async function we(e,t,n,r,i){let a=new ne().copyFrom(e.state.camera);if(Te({view:e,camera:a,forwardDirection:t,forwardDistance:n,detectCollisions:!0}))return r?r.smoothlyCorrectGroundElevation({camera:a,deltaTime:i}):new O(e).immediatelyCorrectGroundElevation({camera:a,correctionLimit:100}),e.goTo(ee(e,a),{duration:500,liftOffDisabled:!0})}function Te(e){let{view:s,camera:c,forwardDirection:l,forwardDistance:u,detectCollisions:f}=e,p=s.navigation.mode;if(p.type!==`ground`)return!1;s.renderCoordsHelper.worldUpAtPosition(c.eye,B);let m=s.sceneIntersectionHelper,h=$(s),g=t(j,B,t(j,l,B));n(K.origin,c.eye),r(K.direction,g,u);let _=m.intersectRay(K,h,J,{include:p.include,exclude:p.exclude}),v=i(ae,c.center,c.eye);return!f||!_||o(J,c.eye)>Math.abs(u)?c.eye=a(j,K.origin,K.direction):(i(j,J,c.eye),d(j)>2&&(Ee(j,j,.25,2),c.eye=a(j,c.eye,j))),c.center=a(j,c.eye,v),!0}function Ee(e,t,n,i){let a=d(e),o=Math.min(n,Math.max(a-i,0)/a);r(t,e,o)}export{Te as advanceGroundNavigationCamera,Q as computeHorizonPadding,ue as computeHorizonPaddingLimits,me as findGroundNavigationGrabLocation,oe as findPlaneHorizonY,se as findSphereHorizonY,we as groundNavigationAdvance,A as groundNavigationConstants,ce as isAboveHorizon,Z as isBelowHorizon,Ee as shortenTranslation,le as shouldClampScreenY};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{fromQuat as e,scale as t}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as i,conjugate as a,multiply as o}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as s,create as c}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{transformQuat as l,dot as u,cross as d,len as f,scale as p,set as m,transformMat3 as h,add as g,transformQuatValues as _,sub as v,abs as y,max as b,min as x,length as S,scaleAndAdd as C,sign as w,multiply as T}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as E,freeze as D,create as O,UNIT_Z as k}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transformMat4 as A}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{create as ee}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as te}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as j}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as ne}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as M}from"../../../geometry/projection/projectBuffer.js";import{getProjector as N}from"../../../geometry/projection/projectors.js";import{getNormal as P}from"../../../geometry/support/plane.js";import{isPlateCarree as re}from"../../../geometry/support/spatialReferenceUtils.js";import{computeOBB as ie}from"./dito.js";import{Vertices as ae}from"../webgl-engine/lib/Attribute.js";class F{constructor(e=E,t=me,n=s){this._data=[e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3]]}clone(){return F.fromData(this._data)}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(e){let t=new F;return t._copyFromData(e),t}static fromJSON(e){return new F(e.center,e.halfSize,e.quaternion)}copy(e){this._copyFromData(e.data)}_copyFromData(e){for(let t=0;t<10;++t)this._data[t]=e[t]}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(e){return e[0]=this._data[0],e[1]=this._data[1],e[2]=this._data[2],e}setCenter(e){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2]}setCenterFromValues(e,t,n){this._data[0]=e,this._data[1]=t,this._data[2]=n}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(e){return e[0]=this._data[3],e[1]=this._data[4],e[2]=this._data[5],e}setHalfSize(e){this._data[3]=e[0],this._data[4]=e[1],this._data[5]=e[2]}setHalfSizeFromValues(e,t,n){this._data[3]=e,this._data[4]=t,this._data[5]=n}getQuaternion(e){return e[0]=this._data[6],e[1]=this._data[7],e[2]=this._data[8],e[3]=this._data[9],e}getQuaternionConjugate(e){return e[0]=-this._data[6],e[1]=-this._data[7],e[2]=-this._data[8],e[3]=this._data[9],e}setQuaternion(e){this._data[6]=e[0],this._data[7]=e[1],this._data[8]=e[2],this._data[9]=e[3]}get data(){return this._data}getCorners(e){let t=this._data,n=i(I,t[6],t[7],t[8],t[9]);for(let r=0;r<8;++r){let i=e[r];i[0]=(r&1?-1:1)*t[3],i[1]=(r&2?-1:1)*t[4],i[2]=(r&4?-1:1)*t[5],l(i,i,n),i[0]+=t[0],i[1]+=t[1],i[2]+=t[2]}return e}getAxes(e){let t=this._data,n=i(I,t[6],t[7],t[8],t[9]);return l(e[0],[1,0,0],n),l(e[1],[0,1,0],n),l(e[2],[0,0,1],n),e}intersectsFrustum(e){let{centerX:t,centerY:n,centerZ:r}=this,i=e.planes;for(let e of i){let i=P(e),a=this.projectedRadius(i);if(t*i[0]+n*i[1]+r*i[2]+e[3]-a>0)return!1}let a=this.getAxes(X),o=e.points,s=this.getHalfSize(K);for(let e=0;e<3;++e){let i=a[e],c=-i[0]*t-i[1]*n-i[2]*r,l=s[e],d=!0,f=!0;for(let e of o){let t=u(e,i)+c;d&&=t>l,f&&=t<-l}if(d||f)return!1}if(this.getCorners(Y).some(t=>e.intersectsPoint(t)))return!0;let c=ve;for(let e=0;e<3;++e){let i=a[e];c[e]=i[0]*t+i[1]*n+i[2]*r}let l=e=>{for(let t=0;t<3;++t){let n=a[t],r=s[t],i=n[0]*e[0]+n[1]*e[1]+n[2]*e[2]-c[t];if(i>r||i<-r)return!1}return!0};if(e.points.some(e=>l(e)))return!0;let m=e.lines,h=_e;for(let e=0;e<8;++e){let i=m[e].direction;for(let e of a){d(h,i,e);let a=f(h);if(a>0)p(h,h,1/a);else continue;let s=this.projectedRadius(h),c=h[0]*t+h[1]*n+h[2]*r,l=c-s,m=c+s,g=!1,_=!1,v=!0;for(let e of o){let t=u(h,e);if(t>m){if(_){v=!1;break}g=!0}else if(t<l){if(g){v=!1;break}_=!0}else{v=!1;break}}if(v)return!1}}return!0}intersectsFrustumConservativeApproximation(e){return this.intersectPlane(e[0])<=0&&this.intersectPlane(e[1])<=0&&this.intersectPlane(e[2])<=0&&this.intersectPlane(e[3])<=0&&this.intersectPlane(e[4])<=0&&this.intersectPlane(e[5])<=0}intersectsFrustumConservativeApproximationWithMargin(e,t){return this.signedDistanceRangePlane(e[0]).min<=t&&this.signedDistanceRangePlane(e[1]).min<=t&&this.signedDistanceRangePlane(e[2]).min<=t&&this.signedDistanceRangePlane(e[3]).min<=t&&this.signedDistanceRangePlane(e[4]).min<=t&&this.signedDistanceRangePlane(e[5]).min<=t}get radius(){let e=this._data[3],t=this._data[4],n=this._data[5];return Math.sqrt(e*e+t*t+n*n)}intersectsPoint(e){let t=this.getAxes(X),n=this.getHalfSize(K),r=this.getCenter(G);for(let i=0;i<3;++i){let a=t[i],o=n[i],s=u(a,e)-u(a,r);if(s>o||s<-o)return!1}return!0}intersectSphere(e){let{center:t,radius:n}=e,r=this._data,i=r[3],a=r[4],o=r[5],s=i+a+o+n,c=r[0]-t[0];if(Math.abs(c)>s)return!1;let l=r[1]-t[1];if(Math.abs(l)>s)return!1;let u=r[2]-t[2];if(Math.abs(u)>s)return!1;let d=-r[6],f=-r[7],p=-r[8],m=r[9],h=f*u-p*l,g=p*c-d*u,_=d*l-f*c,v=f*_-p*g,y=p*h-d*_,b=d*g-f*h,x=m*2,S=Math.abs(c+h*x+v*2),C=Math.abs(l+g*x+y*2),w=Math.abs(u+_*x+b*2),T=Math.min(S,i),E=Math.min(C,a),D=Math.min(w,o),O=S-T,k=C-E,A=w-D;return O*O+k*k+A*A<=n*n}intersectSphereWithMBS(e,t=this.radius){let n=this._data,{center:r,radius:i}=e,a=t+i,o=n[0]-r[0];if(o>a)return!1;let s=n[1]-r[1];if(s>a)return!1;let c=n[2]-r[2];if(c>a||o*o+s*s+c*c>a*a)return!1;let l=-n[6],u=-n[7],d=-n[8],f=n[9],p=u*c-d*s,m=d*o-l*c,h=l*s-u*o,g=u*h-d*m,_=d*p-l*h,v=l*m-u*p,y=f*2,b=Math.abs(o+p*y+g*2),x=Math.abs(s+m*y+_*2),S=Math.abs(c+h*y+v*2),C=Math.min(b,n[3]),w=Math.min(x,n[4]),T=Math.min(S,n[5]),E=b-C,D=x-w,O=S-T;return E*E+D*D+O*O<i*i}intersectPlane(e){let t=e[0]*this._data[0]+e[1]*this._data[1]+e[2]*this._data[2]+e[3],n=this.projectedRadius(P(e));return t>n?1:t<-n?-1:0}intersectRay(e,t,n=0){let r=this._data,i=I;i[0]=-r[6],i[1]=-r[7],i[2]=-r[8],i[3]=r[9],R[0]=e[0]-r[0],R[1]=e[1]-r[1],R[2]=e[2]-r[2];let a=l(R,R,I),o=l(se,t,I),s=-1/0,c=1/0,u=this.getHalfSize(K);for(let e=0;e<3;e++){let t=a[e],r=o[e],i=u[e]+n;if(Math.abs(r)>1e-6){let e=(i-t)/r,n=(-i-t)/r;s=Math.max(s,Math.min(e,n)),c=Math.min(c,Math.max(e,n))}else if(t>i||t<-i)return!1}return s<=c}projectedArea(n,r,i,o){let s=this.getQuaternion(L);a(I,s),R[0]=n[0]-this._data[0],R[1]=n[1]-this._data[1],R[2]=n[2]-this._data[2],l(R,R,I);let c=this.getHalfSize(K),u=R[0]<-c[0]?-1:+(R[0]>c[0]),d=R[1]<-c[1]?-1:+(R[1]>c[1]),f=R[2]<-c[2]?-1:+(R[2]>c[2]),p=Math.abs(u)+Math.abs(d)+Math.abs(f);if(p===0)return 1/0;let _=p===1?4:6,v=(u+d*3+f*9+13)*6;e(q,s),t(q,q,c);let y=this.getCenter(G);for(let e=0;e<_;e++){let t=ce[v+e];m(R,((t&1)<<1)-1,(t&2)-1,((t&4)>>1)-1),h(R,R,q),g(z,y,R),z[3]=1,A(z,z,r);let n=1/Math.max(1e-6,z[3]);V[e*2]=z[0]*n,V[e*2+1]=z[1]*n}let b=_*2-2,x=V[0]*(V[3]-V[b+1])+V[b]*(V[1]-V[b-1]);for(let e=2;e<b;e+=2)x+=V[e]*(V[e+3]-V[e-1]);return Math.abs(x)*i*o*.125}projectedRadius(e){let t=this._data;return _(R,e,-t[6],-t[7],-t[8],t[9]),Math.abs(R[0]*t[3])+Math.abs(R[1]*t[4])+Math.abs(R[2]*t[5])}signedDistancePlane(e,t){let n=this._data,r=e[0]*n[0]+e[1]*n[1]+e[2]*n[2]+t,i=this.projectedRadius(e);return r>i?r-i:r<-i?r+i:0}signedDistanceRangePlane(e){let t=e[0]*this._data[0]+e[1]*this._data[1]+e[2]*this._data[2]+e[3],n=this.projectedRadius(P(e));return{min:t-n,max:t+n}}toAaBoundingBox(t){let n=this.getQuaternion(L),r=e(q,n),i=this._data[3]*Math.abs(r[0])+this._data[4]*Math.abs(r[3])+this._data[5]*Math.abs(r[6]),a=this._data[3]*Math.abs(r[1])+this._data[4]*Math.abs(r[4])+this._data[5]*Math.abs(r[7]),o=this._data[3]*Math.abs(r[2])+this._data[4]*Math.abs(r[5])+this._data[5]*Math.abs(r[8]);t[0]=this._data[0]-i,t[1]=this._data[1]-a,t[2]=this._data[2]-o,t[3]=this._data[0]+i,t[4]=this._data[1]+a,t[5]=this._data[2]+o}transform(e,t,n,r=0,i=j(n),a=j(t),o=N(t,a)){if(n===i)t.isGeographic?pe(this,e,t,r,a):fe(this,e,t,r,a,o);else if(t.isGeographic&&(n.isWebMercator||re(n)))ue(t,this,n,e,r);else if(t.isWebMercator&&re(n))de(t,this,n,e,r);else{let i=this.getCenter(G);i[2]+=r,M(i,t,0,i,n,0),e.setCenter(i),this!==e&&(e.setQuaternion(this.getQuaternion(L)),e.setHalfSize(this.getHalfSize(K)))}}}const I=c(),L=c(),oe=c(),R=O(),se=O(),z=ee();function B(e,t=new F){return ie(e,t),t}const V=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],ce=(()=>{let e=new Int8Array(162),t=0,n=n=>{for(let r=0;r<n.length;r++)e[t+r]=n[r];t+=6};return n([6,2,3,1,5,4]),n([0,2,3,1,5,4]),n([0,2,3,7,5,4]),n([0,1,3,2,6,4]),n([0,1,3,2,0,0]),n([0,1,5,7,3,2]),n([0,1,3,7,6,4]),n([0,1,3,7,6,2]),n([0,1,5,7,6,2]),n([0,1,5,4,6,2]),n([0,1,5,4,0,0]),n([0,1,3,7,5,4]),n([0,2,6,4,0,0]),n([0,0,0,0,0,0]),n([1,3,7,5,0,0]),n([2,3,7,6,4,0]),n([2,3,7,6,0,0]),n([2,3,1,5,7,6]),n([0,1,5,7,6,2]),n([0,1,5,7,6,4]),n([0,1,3,7,6,4]),n([4,5,7,6,2,0]),n([4,5,7,6,0,0]),n([4,5,1,3,7,6]),n([0,2,3,7,5,4]),n([6,2,3,7,5,4]),n([6,2,3,1,5,4]),e})();function le(e,t,n,r,i){let o=e.getQuaternion(L);i.setQuaternion(o),a(I,o);let s=e.getCenter(G),c=e.getHalfSize(K);if(r===1){l(Z,s,I),y(Q,Z),x($,Q,c),v($,Q,$);let r=S($);g($,Q,c);let a=S($);if(r<n)i.setCenter(s),m(Z,n,n,n),i.setHalfSize(g(Z,c,Z));else{let o=a>0?1+t/a:1,s=r>0?1+n/r:1,u=(s+o)/2,d=(s-o)/2;p($,Q,d),i.setHalfSize(C($,$,c,u)),p($,Q,u),C($,$,c,d),w(Z,Z),T(Z,$,Z);let f=e.getQuaternion(oe);i.setCenter(l(Z,Z,f))}}else{i.setCenter(C(Z,s,k,(n+t)/2));let e=l(Z,k,I);y(e,e),i.setHalfSize(C(Q,c,e,(n-t)/2))}return i}function ue(e,t,n,r,i){let a=t.getCenter(G);a[2]+=i;let o=j(n);M(a,e,0,a,o,0),H(o,t,a,n,r)}function de(e,t,n,r,i){let a=t.getCenter(G);a[2]+=i,H(e,t,a,n,r)}function H(t,n,r,i,a){let o=n.getQuaternion(L),s=e(q,o),c=n.getHalfSize(K);for(let e=0;e<8;++e){for(let t=0;t<3;++t)W[t]=c[t]*(e&1<<t?-1:1);for(let t=0;t<3;++t){let n=r[t];for(let e=0;e<3;++e)n+=W[e]*s[3*e+t];U[e*3+t]=n}}M(U,t,0,U,i,0,8),B(ge,a)}function fe(e,t,n,r,i=j(n),s=N(n,i)){e.getCorners(Y);let c=e.getCenter(G);c[2]+=r,ne(n,c,J,i),t.setCenterFromValues(J[12],J[13],J[14]);let u=Math.sqrt(1+J[0]+J[5]+J[10])*2;I[0]=(J[6]-J[9])/u,I[1]=(J[8]-J[2])/u,I[2]=(J[1]-J[4])/u,I[3]=u*.25;let d=e.getQuaternion(L);t.setQuaternion(o(I,I,d)),a(I,I),m(Q,0,0,0);let f=t.getCenter(G);for(let e of Y)e[2]+=r,s(e,0,e,0),v(Z,e,f),l(Z,Z,I),y(Z,Z),b(Q,Q,Z);t.setHalfSize(Q)}function pe(e,t,n,r,i=j(n)){let o=te(n),s=1+Math.max(0,r)/(o.radius+e.centerZ);e.getCenter(W),W[2]+=r,M(W,n,0,W,i,0),t.setCenter(W);let c=e.getQuaternion(L);t.setQuaternion(c),a(I,c),m(Z,0,0,1),l(Z,Z,I);let u=e.getHalfSize(K);m(Z,u[0]*Math.abs(Z[0]),u[1]*Math.abs(Z[1]),u[2]*Math.abs(Z[2])),p(Z,Z,o.inverseFlattening),g(Z,u,Z),t.setHalfSize(p(Z,Z,s))}const me=D(-1,-1,-1);function he(e){return Array.from(e)}const U=Array(24),ge=new ae(U,3),W=O(),G=O(),K=O(),q=n(),J=r(),Y=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],X=[O(),O(),O()],Z=O(),Q=O(),$=O(),_e=O(),ve=[0,0,0];export{F as Obb,B as compute,le as computeOffsetObb,he as ensurePackedObbData};
|
|
2
|
+
import{fromQuat as e,scale as t}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as i,conjugate as a,multiply as o}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as s,create as c}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{transformQuat as l,dot as u,cross as d,len as f,scale as p,distance as m,direction as h,set as g,transformMat3 as _,add as v,transformQuatValues as y,sub as b,abs as x,max as S,min as C,length as w,scaleAndAdd as T,sign as E,multiply as D}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as O,freeze as k,create as A,UNIT_Z as ee}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transformMat4 as te}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{create as ne}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as re}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as j}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as ie}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as M}from"../../../geometry/projection/projectBuffer.js";import{getProjector as ae}from"../../../geometry/projection/projectors.js";import{getNormal as N}from"../../../geometry/support/plane.js";import{isPlateCarree as P}from"../../../geometry/support/spatialReferenceUtils.js";import{computeOBB as oe}from"./dito.js";import{Vertices as se}from"../webgl-engine/lib/Attribute.js";class F{constructor(e=O,t=_e,n=s){this._data=[e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3]]}clone(){return F.fromData(this._data)}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(e){let t=new F;return t._copyFromData(e),t}static fromJSON(e){return new F(e.center,e.halfSize,e.quaternion)}copy(e){this._copyFromData(e.data)}_copyFromData(e){for(let t=0;t<10;++t)this._data[t]=e[t]}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(e){return e[0]=this._data[0],e[1]=this._data[1],e[2]=this._data[2],e}setCenter(e){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2]}setCenterFromValues(e,t,n){this._data[0]=e,this._data[1]=t,this._data[2]=n}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(e){return e[0]=this._data[3],e[1]=this._data[4],e[2]=this._data[5],e}setHalfSize(e){this._data[3]=e[0],this._data[4]=e[1],this._data[5]=e[2]}setHalfSizeFromValues(e,t,n){this._data[3]=e,this._data[4]=t,this._data[5]=n}getQuaternion(e){return e[0]=this._data[6],e[1]=this._data[7],e[2]=this._data[8],e[3]=this._data[9],e}getQuaternionConjugate(e){return e[0]=-this._data[6],e[1]=-this._data[7],e[2]=-this._data[8],e[3]=this._data[9],e}setQuaternion(e){this._data[6]=e[0],this._data[7]=e[1],this._data[8]=e[2],this._data[9]=e[3]}get data(){return this._data}getCorners(e){let t=this._data,n=i(I,t[6],t[7],t[8],t[9]);for(let r=0;r<8;++r){let i=e[r];i[0]=(r&1?-1:1)*t[3],i[1]=(r&2?-1:1)*t[4],i[2]=(r&4?-1:1)*t[5],l(i,i,n),i[0]+=t[0],i[1]+=t[1],i[2]+=t[2]}return e}getAxes(e){let t=this._data,n=i(I,t[6],t[7],t[8],t[9]);return l(e[0],[1,0,0],n),l(e[1],[0,1,0],n),l(e[2],[0,0,1],n),e}intersectsFrustum(e){let{centerX:t,centerY:n,centerZ:r}=this,i=e.planes;for(let e of i){let i=N(e),a=this.projectedRadius(i);if(t*i[0]+n*i[1]+r*i[2]+e[3]-a>0)return!1}let a=this.getAxes(X),o=e.points,s=this.getHalfSize(K);for(let e=0;e<3;++e){let i=a[e],c=-i[0]*t-i[1]*n-i[2]*r,l=s[e],d=!0,f=!0;for(let e of o){let t=u(e,i)+c;d&&=t>l,f&&=t<-l}if(d||f)return!1}if(this.getCorners(Y).some(t=>e.intersectsPoint(t)))return!0;let c=xe;for(let e=0;e<3;++e){let i=a[e];c[e]=i[0]*t+i[1]*n+i[2]*r}let l=e=>{for(let t=0;t<3;++t){let n=a[t],r=s[t],i=n[0]*e[0]+n[1]*e[1]+n[2]*e[2]-c[t];if(i>r||i<-r)return!1}return!0};if(e.points.some(e=>l(e)))return!0;let m=e.lines,h=be;for(let e=0;e<8;++e){let i=m[e].direction;for(let e of a){d(h,i,e);let a=f(h);if(a>0)p(h,h,1/a);else continue;let s=this.projectedRadius(h),c=h[0]*t+h[1]*n+h[2]*r,l=c-s,m=c+s,g=!1,_=!1,v=!0;for(let e of o){let t=u(h,e);if(t>m){if(_){v=!1;break}g=!0}else if(t<l){if(g){v=!1;break}_=!0}else{v=!1;break}}if(v)return!1}}return!0}intersectsFrustumConservativeApproximation(e){return this.intersectPlane(e[0])<=0&&this.intersectPlane(e[1])<=0&&this.intersectPlane(e[2])<=0&&this.intersectPlane(e[3])<=0&&this.intersectPlane(e[4])<=0&&this.intersectPlane(e[5])<=0}intersectsFrustumConservativeApproximationWithMargin(e,t){return this.signedDistanceRangePlane(e[0]).min<=t&&this.signedDistanceRangePlane(e[1]).min<=t&&this.signedDistanceRangePlane(e[2]).min<=t&&this.signedDistanceRangePlane(e[3]).min<=t&&this.signedDistanceRangePlane(e[4]).min<=t&&this.signedDistanceRangePlane(e[5]).min<=t}get radius(){let e=this._data[3],t=this._data[4],n=this._data[5];return Math.sqrt(e*e+t*t+n*n)}intersectsPoint(e){let t=this.getAxes(X),n=this.getHalfSize(K),r=this.getCenter(G);for(let i=0;i<3;++i){let a=t[i],o=n[i],s=u(a,e)-u(a,r);if(s>o||s<-o)return!1}return!0}intersectSphere(e){let{center:t,radius:n}=e,r=this._data,i=r[3],a=r[4],o=r[5],s=i+a+o+n,c=r[0]-t[0];if(Math.abs(c)>s)return!1;let l=r[1]-t[1];if(Math.abs(l)>s)return!1;let u=r[2]-t[2];if(Math.abs(u)>s)return!1;let d=-r[6],f=-r[7],p=-r[8],m=r[9],h=f*u-p*l,g=p*c-d*u,_=d*l-f*c,v=f*_-p*g,y=p*h-d*_,b=d*g-f*h,x=m*2,S=Math.abs(c+h*x+v*2),C=Math.abs(l+g*x+y*2),w=Math.abs(u+_*x+b*2),T=Math.min(S,i),E=Math.min(C,a),D=Math.min(w,o),O=S-T,k=C-E,A=w-D;return O*O+k*k+A*A<=n*n}intersectSphereWithMBS(e,t=this.radius){let n=this._data,{center:r,radius:i}=e,a=t+i,o=n[0]-r[0];if(o>a)return!1;let s=n[1]-r[1];if(s>a)return!1;let c=n[2]-r[2];if(c>a||o*o+s*s+c*c>a*a)return!1;let l=-n[6],u=-n[7],d=-n[8],f=n[9],p=u*c-d*s,m=d*o-l*c,h=l*s-u*o,g=u*h-d*m,_=d*p-l*h,v=l*m-u*p,y=f*2,b=Math.abs(o+p*y+g*2),x=Math.abs(s+m*y+_*2),S=Math.abs(c+h*y+v*2),C=Math.min(b,n[3]),w=Math.min(x,n[4]),T=Math.min(S,n[5]),E=b-C,D=x-w,O=S-T;return E*E+D*D+O*O<i*i}intersectPlane(e){let t=e[0]*this._data[0]+e[1]*this._data[1]+e[2]*this._data[2]+e[3],n=this.projectedRadius(N(e));return t>n?1:t<-n?-1:0}intersectRay(e,t,n=0,r=-1/0,i=1/0){let a=this._data,o=I;o[0]=-a[6],o[1]=-a[7],o[2]=-a[8],o[3]=a[9],R[0]=e[0]-a[0],R[1]=e[1]-a[1],R[2]=e[2]-a[2];let s=l(R,R,I),c=l(le,t,I),u=r,d=i,f=this.getHalfSize(K);for(let e=0;e<3;e++){let t=s[e],r=c[e],i=f[e]+n;if(Math.abs(r)>1e-6){let e=(i-t)/r,n=(-i-t)/r;u=Math.max(u,Math.min(e,n)),d=Math.min(d,Math.max(e,n))}else if(t>i||t<-i)return!1}return u<=d}intersectSegment(e,t,n=0){let r=m(e,t);return h(H,e,t),this.intersectRay(e,H,n,0,r)}projectedArea(n,r,i,o){let s=this.getQuaternion(L);a(I,s),R[0]=n[0]-this._data[0],R[1]=n[1]-this._data[1],R[2]=n[2]-this._data[2],l(R,R,I);let c=this.getHalfSize(K),u=R[0]<-c[0]?-1:+(R[0]>c[0]),d=R[1]<-c[1]?-1:+(R[1]>c[1]),f=R[2]<-c[2]?-1:+(R[2]>c[2]),p=Math.abs(u)+Math.abs(d)+Math.abs(f);if(p===0)return 1/0;let m=p===1?4:6,h=(u+d*3+f*9+13)*6;e(q,s),t(q,q,c);let y=this.getCenter(G);for(let e=0;e<m;e++){let t=de[h+e];g(R,((t&1)<<1)-1,(t&2)-1,((t&4)>>1)-1),_(R,R,q),v(z,y,R),z[3]=1,te(z,z,r);let n=1/Math.max(1e-6,z[3]);B[e*2]=z[0]*n,B[e*2+1]=z[1]*n}let b=m*2-2,x=B[0]*(B[3]-B[b+1])+B[b]*(B[1]-B[b-1]);for(let e=2;e<b;e+=2)x+=B[e]*(B[e+3]-B[e-1]);return Math.abs(x)*i*o*.125}projectedRadius(e){let t=this._data;return y(R,e,-t[6],-t[7],-t[8],t[9]),Math.abs(R[0]*t[3])+Math.abs(R[1]*t[4])+Math.abs(R[2]*t[5])}signedDistancePlane(e,t){let n=this._data,r=e[0]*n[0]+e[1]*n[1]+e[2]*n[2]+t,i=this.projectedRadius(e);return r>i?r-i:r<-i?r+i:0}signedDistanceRangePlane(e){let t=e[0]*this._data[0]+e[1]*this._data[1]+e[2]*this._data[2]+e[3],n=this.projectedRadius(N(e));return{min:t-n,max:t+n}}toAaBoundingBox(t){let n=this.getQuaternion(L),r=e(q,n),i=this._data[3]*Math.abs(r[0])+this._data[4]*Math.abs(r[3])+this._data[5]*Math.abs(r[6]),a=this._data[3]*Math.abs(r[1])+this._data[4]*Math.abs(r[4])+this._data[5]*Math.abs(r[7]),o=this._data[3]*Math.abs(r[2])+this._data[4]*Math.abs(r[5])+this._data[5]*Math.abs(r[8]);t[0]=this._data[0]-i,t[1]=this._data[1]-a,t[2]=this._data[2]-o,t[3]=this._data[0]+i,t[4]=this._data[1]+a,t[5]=this._data[2]+o}transform(e,t,n,r=0,i=j(n),a=j(t),o=ae(t,a)){if(n===i)t.isGeographic?ge(this,e,t,r,a):he(this,e,t,r,a,o);else if(t.isGeographic&&(n.isWebMercator||P(n)))pe(t,this,n,e,r);else if(t.isWebMercator&&P(n))me(t,this,n,e,r);else{let i=this.getCenter(G);i[2]+=r,M(i,t,0,i,n,0),e.setCenter(i),this!==e&&(e.setQuaternion(this.getQuaternion(L)),e.setHalfSize(this.getHalfSize(K)))}}}const I=c(),L=c(),ce=c(),R=A(),le=A(),z=ne();function ue(e,t=new F){return oe(e,t),t}const B=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],de=(()=>{let e=new Int8Array(162),t=0,n=n=>{for(let r=0;r<n.length;r++)e[t+r]=n[r];t+=6};return n([6,2,3,1,5,4]),n([0,2,3,1,5,4]),n([0,2,3,7,5,4]),n([0,1,3,2,6,4]),n([0,1,3,2,0,0]),n([0,1,5,7,3,2]),n([0,1,3,7,6,4]),n([0,1,3,7,6,2]),n([0,1,5,7,6,2]),n([0,1,5,4,6,2]),n([0,1,5,4,0,0]),n([0,1,3,7,5,4]),n([0,2,6,4,0,0]),n([0,0,0,0,0,0]),n([1,3,7,5,0,0]),n([2,3,7,6,4,0]),n([2,3,7,6,0,0]),n([2,3,1,5,7,6]),n([0,1,5,7,6,2]),n([0,1,5,7,6,4]),n([0,1,3,7,6,4]),n([4,5,7,6,2,0]),n([4,5,7,6,0,0]),n([4,5,1,3,7,6]),n([0,2,3,7,5,4]),n([6,2,3,7,5,4]),n([6,2,3,1,5,4]),e})();function fe(e,t,n,r,i){let o=e.getQuaternion(L);i.setQuaternion(o),a(I,o);let s=e.getCenter(G),c=e.getHalfSize(K);if(r===1){l(Z,s,I),x(Q,Z),C($,Q,c),b($,Q,$);let r=w($);v($,Q,c);let a=w($);if(r<n)i.setCenter(s),g(Z,n,n,n),i.setHalfSize(v(Z,c,Z));else{let o=a>0?1+t/a:1,s=r>0?1+n/r:1,u=(s+o)/2,d=(s-o)/2;p($,Q,d),i.setHalfSize(T($,$,c,u)),p($,Q,u),T($,$,c,d),E(Z,Z),D(Z,$,Z);let f=e.getQuaternion(ce);i.setCenter(l(Z,Z,f))}}else{i.setCenter(T(Z,s,ee,(n+t)/2));let e=l(Z,ee,I);x(e,e),i.setHalfSize(T(Q,c,e,(n-t)/2))}return i}function pe(e,t,n,r,i){let a=t.getCenter(G);a[2]+=i;let o=j(n);M(a,e,0,a,o,0),V(o,t,a,n,r)}function me(e,t,n,r,i){let a=t.getCenter(G);a[2]+=i,V(e,t,a,n,r)}function V(t,n,r,i,a){let o=n.getQuaternion(L),s=e(q,o),c=n.getHalfSize(K);for(let e=0;e<8;++e){for(let t=0;t<3;++t)W[t]=c[t]*(e&1<<t?-1:1);for(let t=0;t<3;++t){let n=r[t];for(let e=0;e<3;++e)n+=W[e]*s[3*e+t];U[e*3+t]=n}}M(U,t,0,U,i,0,8),ue(ye,a)}function he(e,t,n,r,i=j(n),s=ae(n,i)){e.getCorners(Y);let c=e.getCenter(G);c[2]+=r,ie(n,c,J,i),t.setCenterFromValues(J[12],J[13],J[14]);let u=Math.sqrt(1+J[0]+J[5]+J[10])*2;I[0]=(J[6]-J[9])/u,I[1]=(J[8]-J[2])/u,I[2]=(J[1]-J[4])/u,I[3]=u*.25;let d=e.getQuaternion(L);t.setQuaternion(o(I,I,d)),a(I,I),g(Q,0,0,0);let f=t.getCenter(G);for(let e of Y)e[2]+=r,s(e,0,e,0),b(Z,e,f),l(Z,Z,I),x(Z,Z),S(Q,Q,Z);t.setHalfSize(Q)}function ge(e,t,n,r,i=j(n)){let o=re(n),s=1+Math.max(0,r)/(o.radius+e.centerZ);e.getCenter(W),W[2]+=r,M(W,n,0,W,i,0),t.setCenter(W);let c=e.getQuaternion(L);t.setQuaternion(c),a(I,c),g(Z,0,0,1),l(Z,Z,I);let u=e.getHalfSize(K);g(Z,u[0]*Math.abs(Z[0]),u[1]*Math.abs(Z[1]),u[2]*Math.abs(Z[2])),p(Z,Z,o.inverseFlattening),v(Z,u,Z),t.setHalfSize(p(Z,Z,s))}const _e=k(-1,-1,-1);function ve(e){return Array.from(e)}const H=A(),U=Array(24),ye=new se(U,3),W=A(),G=A(),K=A(),q=n(),J=r(),Y=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],X=[A(),A(),A()],Z=A(),Q=A(),$=A(),be=A(),xe=[0,0,0];export{F as Obb,ue as compute,fe as computeOffsetObb,ve as ensurePackedObbData};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{length as e}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{intersects as
|
|
2
|
+
import{length as e}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{getSphericalPCPF as t}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as n}from"../../../geometry/projection/projectBoundingSphere.js";import{intersects as r,fromValues as i}from"../../../geometry/support/aaBoundingRect.js";import{earth as a}from"../../../geometry/support/Ellipsoid.js";import{getInfo as o}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as s}from"../../../geometry/support/sphere.js";function c(e,t,n){if(r(e,t))return!0;let i=o(n);if(i==null||e[1]>t[3]||e[3]<t[1])return!1;let a=i.valid[1]-i.valid[0];return Math.ceil((e[0]-t[2])/a)<=Math.floor((e[2]-t[0])/a)}function l(t,n){let r=e(t.center);if(!t.isValid||r<=t.radius)return i(-1/0,-1/0,1/0,1/0,n);let a=Math.asin(t.radius/r),o=Math.atan2(t.center[2],Math.hypot(t.center[0],t.center[1])),s=o*180/Math.PI;return f(Math.atan2(t.center[1],t.center[0])*180/Math.PI,s,o,a,n)}function u(e,t,n=a.radius){let r=n+e.center[2],o=e.radius;if(!e.isValid||r<=o||Math.abs(e.center[1])>90)return i(-1/0,-1/0,1/0,1/0,t);let s=e.center[0]-360*Math.floor((e.center[0]+180)/360),c=e.center[1];return f(s,c,c*Math.PI/180,Math.asin(o/r),t)}function d(e,r,i,a){return n(e,r,p,t(a))?(l(p,i),!0):!1}function f(e,t,n,r,a){let o=r*180/Math.PI;if(Math.abs(n)+r>=Math.PI/2)return i(-180,Math.max(-90,t-o),180,Math.min(90,t+o),a);let s=Math.asin(Math.min(1,Math.sin(r)/Math.cos(n)))*180/Math.PI;return i(e-s,t-o,e+s,t+o,a)}const p=new s;export{u as geographicMbsToGeographicExtent,c as intersectsGeographicExtent,d as mbsToGeographicExtent,l as sphereToGeographicExtent};
|