@arcgis/core 4.29.6 → 4.29.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{4984e2b79d862114d6a6.js → 1a8d56e01ddfec2257c3.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{3afb525a131b6841276b.js → 1e4d779a884f13762601.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{2447a4d5886aeb0ff72a.js → 205597cd91cb7ff3d2b4.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{6c50daccd84ba5545bfe.js → 22ebdec0867e44d8d58c.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{da4616b02dd0c3dd3d5d.js → 321547d796a2ecd72ab4.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{6c3ae96ec90e9ed7dd50.js → 32be478638e9e643ea32.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{a61f337802ae963d7f65.js → 59f03847a9eb96e5f65c.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{7a98d2e026f63a581b1e.js → 5b08309b184f5d8345a0.js} +1 -1
  10. package/assets/esri/core/workers/chunks/631bda7b99a27f4453c1.js +1 -0
  11. package/assets/esri/core/workers/chunks/{c527692694688a5b3b07.js → 658a8ee9a4f24bc03f7f.js} +1 -1
  12. package/assets/esri/core/workers/chunks/99ac2a6a5be0604ee4c2.js +1 -0
  13. package/assets/esri/core/workers/chunks/{48db6e0bbb1a9c043193.js → b7a78246d25dc07f173d.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{60ab18c6a04d4b2f1d4c.js → bb05528d2ca12c57a031.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{5227f9eea6988aadad7f.js → cf0dc0ccbeaf9458de6e.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{f59b5ea05caca8a1a398.js → d40408be9bbcb0021d18.js} +1 -1
  17. package/assets/esri/core/workers/chunks/df6fbabbc74a408575fc.js +1 -0
  18. package/chunks/Laserlines.glsl.js +1 -1
  19. package/chunks/sphere.js +1 -1
  20. package/chunks/vec32.js +1 -1
  21. package/chunks/vec42.js +1 -1
  22. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  23. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  24. package/core/libs/gl-matrix-2/math/vec4.js +1 -1
  25. package/geometry/support/sphere.js +1 -1
  26. package/interfaces.d.ts +8 -2
  27. package/kernel.js +1 -1
  28. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  29. package/layers/mixins/FeatureLayerBase.js +1 -1
  30. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  31. package/layers/support/SubtypeSublayer.js +1 -1
  32. package/layers/voxel/VoxelVolume.js +1 -1
  33. package/networks/UtilityNetwork.js +1 -1
  34. package/package.json +1 -1
  35. package/support/revision.js +1 -1
  36. package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
  37. package/views/2d/engine/webgl/mesh/MultiTileMeshData.js +1 -1
  38. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  39. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  40. package/views/2d/layers/features/FeatureContainer.js +1 -1
  41. package/views/2d/layers/features/Processor.js +1 -1
  42. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  43. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  44. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  45. package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
  46. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  47. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  48. package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
  49. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  50. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  51. package/views/3d/camera/constraintUtils/distance.js +1 -1
  52. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  53. package/views/3d/layers/I3SMeshView3D.js +1 -1
  54. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  55. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  56. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  57. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  58. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  59. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  60. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  61. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  62. package/views/3d/layers/support/makeScheduleFunction.js +5 -0
  63. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  64. package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
  65. package/views/3d/state/controllers/global/ZoomController.js +1 -1
  66. package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
  67. package/views/3d/state/controllers/momentum/ZoomSphericalMomentumController.js +1 -1
  68. package/views/3d/state/utils/navigationUtils.js +1 -1
  69. package/views/3d/support/geometryUtils/sphere.js +1 -1
  70. package/views/3d/terrain/OverlayManager.js +1 -1
  71. package/views/3d/terrain/PatchRenderData.js +1 -1
  72. package/views/3d/terrain/SphericalPatch.js +1 -1
  73. package/views/3d/terrain/TerrainSurface.js +1 -1
  74. package/views/3d/terrain/Tile.js +1 -1
  75. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  76. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  77. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  78. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  79. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  80. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  81. package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
  82. package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
  83. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  84. package/views/interactive/sketch/constraints.js +1 -1
  85. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  86. package/views/support/geometry3dUtils.js +1 -1
  87. package/assets/esri/core/workers/chunks/a068f0c8c1c632e8b2cb.js +0 -1
  88. package/assets/esri/core/workers/chunks/a28b7d868346e13468bb.js +0 -1
  89. package/assets/esri/core/workers/chunks/ccd53b81c2688dd11584.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{assertIsSome as t}from"../../../../core/maybe.js";import{MinPriority as o}from"../../../../core/MemCache.js";import{throwIfAborted as r}from"../../../../core/promiseUtils.js";import{generateUUID as n}from"../../../../core/uuid.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{j as i}from"../../../../chunks/vec32.js";import{ONES as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as d}from"../../../../geometry/projection/projectBoundingSphere.js";import{isRelativeVertexSpace as u}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{b as m}from"../../../../chunks/sphere.js";import{convertMeshMaterialToPBRMaterial as c}from"./I3SClientMaterialUtil.js";class h{constructor(e,t,o,r){this._uid=e,this._worker=r,this._id2Meta=new Map,this._oid2Meta=new Map,this._indexSR=t.indexSR,this._vertexSR=t.vertexSR,this._renderSR=t.renderSR,this._localMode=t.localMode,this._memCache=o.newCache(`sl-client-mesh-data-${this._uid}`)}get uid(){return this._uid}get worker(){return this._worker}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o=`mesh${t}`,r=e.extent,n=r.spatialReference,s=this._indexSR,a=f(r,e.origin);d(a,n,a,s);return{type:"mesh",id:o,version:g(e),oid:t,mbs:a,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(t,o){if(null!=this.getMeshNodeIndex(o.oid))throw new e(`I3SClientNodeLoader: client side mesh for feature oid=${o.oid} already exists`);o.nodeIndex=t,this._id2Meta.set(o.id,o),this._oid2Meta.set(o.oid,o)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(t){const o=this._id2Meta.get(t);if(null==o)throw new e(`I3SClientNodeLoader::loadNodeJSON unable to find node ${t}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new e(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${t}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const r=[],n=o.components;for(let s=0;s<n.length;++s){const o=`${t}-component${s}`,n={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(n.id,n),e.componentNodeIds.push(o),r.push({id:n.id,href:null,mbs:n.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:r}}updateNodeIndex(e,t,o){const r=this._id2Meta.get(e);r&&"mesh"===r.type&&(r.nodeIndex=o)}async _loadMeshComponentNodeJSON(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}async loadNodeData(o,n){const s=this._id2Meta.get(o);if(null==s||"mesh-component"!==s.type)throw new e(`Failed to load client node data for node ${o} (unexpected node info)`);const a=s.meshNodeInfo,i=await this._getMeshData(a),l=i.loadedMesh,d=a.oid;if(null==l.components)throw new e(`Failed to load client node data for node ${o} (unexpected null reference)`);const u=l.components[s.componentIndex],{material:m,requiredTextures:h,textureData:f}=await c(u.material);if(null!=f)for(const e of f)null!=e&&s.textureData.set(e.id,e);const y={params:{material:m},type:"ArrayBufferView"},{vertexSpace:g,origin:M,transform:S}=l,_=[M.x,M.y,M.z??0],b={featureDataPosition:_,featureIds:[],geometries:[y]},w={attributeData:{},loadedAttributes:[]};i.projectionPromise||(t(this._worker,"SceneLayerWorker is needed to project mesh"),i.projectionPromise=this._worker.project({positions:l.vertexAttributes.position,localMatrix:S?.localMatrix,vertexSpace:g.toJSON(),origin:_,inSpatialReference:l.spatialReference.toJSON(),outSpatialReference:this._vertexSR.toJSON(),localMode:this._localMode},n));const{projected:N,original:v}=await i.projectionPromise;l.vertexAttributes.position=v;const{transformed:D,original:j}=await p(u,i,this._worker,n);l.vertexAttributes.normal=j,r(n);const{geometryBuffer:I,geometryDescriptor:R}=x(N,u.faces,D,l.vertexAttributes.uv,l.vertexAttributes.color,d);return{geometryData:b,attributeDataInfo:w,geometryBuffer:I,geometryDescriptor:R,requiredTextures:h,textureData:f,normalReferenceFrame:this._vertexSR.isGeographic?"east-north-up":"vertex-reference-frame"}}async loadAttributes(e,t,o){const r=e.numFeatures,n={};for(const{field:{name:s}}of t)n[s]=new Array(r);return n}async loadTextures(e,t,o){const r=e.id,n=this._id2Meta.get(r);if(null==n||"mesh-component"!==n.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(n.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,r=this._memCache.get(t);if(null==r){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const r=async(r,n)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(l){n(l)}const a=s.memoryUsage,i={loadedMesh:s,projectionPromise:null,normalsTransformPromise:null,usedMemoryInBytes:a};this._memCache.put(t,i,a,o),e.loadMeshPromise=null,r(i)};return e.loadMeshPromise=new Promise(((e,t)=>r(e,t))),e.loadMeshPromise}return r}}function f(e,t){const{spatialReference:o}=e,r=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],s=o.isGeographic?o.metersPerUnit:1,a=e.center;let i=0;if(e.hasZ)for(let l=0;l<2;++l)for(let e=0;e<2;++e)for(let o=0;o<2;++o){const d=(a.x+r[l]*n[0]-t.x)*s,u=(a.y+r[e]*n[1]-t.y)*s,m=a.z+r[o]*n[2]-t.z;i=Math.max(d*d+u*u+m*m,i)}else for(let l=0;l<2;++l)for(let e=0;e<2;++e){const o=(a.x+r[l]*n[0]-t.x)*s,d=(a.y+r[e]*n[1]-t.y)*s;i=Math.max(o*o+d*d,i)}return m([t.x,t.y,t.z],Math.sqrt(i))}async function p(e,o,r,n){const{transform:d,vertexAttributes:u}=o.loadedMesh,m="source"===e.shading?u.normal:null;if(!(null!=m&&null!=d&&(0!==d.rotationAngle||!i(d.scale,l))))return{transformed:m,original:u.normal};if(!o.normalsTransformPromise){t(r,"SceneLayerWorker is needed to transform mesh normals");const e=a();s(e,d.localMatrix),o.normalsTransformPromise=r.transformNormals({normalMatrix:e,normals:m},n)}return o.normalsTransformPromise}function x(e,t,o,r,n,s){const a=1,i=t.length/3,l=3*i;let d=0,u=0,m=!1,c=0,h=!1,f=0,p=!1,x=0,g=0,w=0;d+=M,d+=M,u=d,d+=3*l*S,null!=o&&(m=!0,c=d,d+=3*l*S),null!=r&&(h=!0,f=d,d+=2*l*S),null!=n&&(p=!0,x=d,d+=4*l*_),g=d,d+=a*b,w=d,d+=2*a*M;const N=new ArrayBuffer(d),v=new Uint8Array(N);y(v,0,l),y(v,M,a);const D=new Float32Array(N,u),j=null!=o?new Float32Array(N,c):null,I=null!=r?new Float32Array(N,f):null,R=null!=n?new Uint8Array(N,x):null;for(let y=0;y<i;++y){const s=3*y;for(let a=0;a<3;++a){const i=t[s+a],l=3*i,d=9*y+3*a;if(D[d]=e[l],D[d+1]=e[l+1],D[d+2]=e[l+2],null!=j&&(j[d]=o[l],j[d+1]=o[l+1],j[d+2]=o[l+2]),null!=I){const e=2*i,t=6*y+2*a;I[t]=r[e],I[t+1]=r[e+1]}if(null!=R){const e=4*i,t=12*y+4*a;R[t]=n[e],R[t+1]=n[e+1],R[t+2]=n[e+2],R[t+3]=n[e+3]}}}y(v,g,s),y(v,g+M,s/2**32),y(v,w,0),y(v,w+M,i-1);return{geometryBuffer:N,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:m,uv0:h,uvRegion:!1,featureIndex:!0}}}function y(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function g(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const o=t;let r="";for(const n of o)r+=n.makeHash();return r+JSON.stringify(null!=e.transform?e.transform.toJSON():"")+(u(e.vertexSpace)?JSON.stringify(e.vertexSpace.origin):"")}const M=4,S=4,_=1,b=8;export{h as I3SClientNodeLoader,f as createSphereFromExtent,S as sizeOfFloat32,M as sizeOfInt32,b as sizeOfUInt64,_ as sizeOfUInt8,p as transformNormals};
5
+ import e from"../../../../core/Error.js";import{assertIsSome as t}from"../../../../core/maybe.js";import{MinPriority as o}from"../../../../core/MemCache.js";import{throwIfAborted as r}from"../../../../core/promiseUtils.js";import{generateUUID as n}from"../../../../core/uuid.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{j as i}from"../../../../chunks/vec32.js";import{ONES as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as d}from"../../../../geometry/projection/projectBoundingSphere.js";import{isRelativeVertexSpace as u}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{k as m}from"../../../../chunks/sphere.js";import{convertMeshMaterialToPBRMaterial as c}from"./I3SClientMaterialUtil.js";class h{constructor(e,t,o,r){this._uid=e,this._worker=r,this._id2Meta=new Map,this._oid2Meta=new Map,this._indexSR=t.indexSR,this._vertexSR=t.vertexSR,this._renderSR=t.renderSR,this._localMode=t.localMode,this._memCache=o.newCache(`sl-client-mesh-data-${this._uid}`)}get uid(){return this._uid}get worker(){return this._worker}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o=`mesh${t}`,r=e.extent,n=r.spatialReference,s=this._indexSR,a=f(r,e.origin);d(a,n,a,s);return{type:"mesh",id:o,version:g(e),oid:t,mbs:a,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(t,o){if(null!=this.getMeshNodeIndex(o.oid))throw new e(`I3SClientNodeLoader: client side mesh for feature oid=${o.oid} already exists`);o.nodeIndex=t,this._id2Meta.set(o.id,o),this._oid2Meta.set(o.oid,o)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(t){const o=this._id2Meta.get(t);if(null==o)throw new e(`I3SClientNodeLoader::loadNodeJSON unable to find node ${t}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new e(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${t}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const r=[],n=o.components;for(let s=0;s<n.length;++s){const o=`${t}-component${s}`,n={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(n.id,n),e.componentNodeIds.push(o),r.push({id:n.id,href:null,mbs:n.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:r}}updateNodeIndex(e,t,o){const r=this._id2Meta.get(e);r&&"mesh"===r.type&&(r.nodeIndex=o)}async _loadMeshComponentNodeJSON(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}async loadNodeData(o,n){const s=this._id2Meta.get(o);if(null==s||"mesh-component"!==s.type)throw new e(`Failed to load client node data for node ${o} (unexpected node info)`);const a=s.meshNodeInfo,i=await this._getMeshData(a),l=i.loadedMesh,d=a.oid;if(null==l.components)throw new e(`Failed to load client node data for node ${o} (unexpected null reference)`);const u=l.components[s.componentIndex],{material:m,requiredTextures:h,textureData:f}=await c(u.material);if(null!=f)for(const e of f)null!=e&&s.textureData.set(e.id,e);const y={params:{material:m},type:"ArrayBufferView"},{vertexSpace:g,origin:M,transform:S}=l,_=[M.x,M.y,M.z??0],w={featureDataPosition:_,featureIds:[],geometries:[y]},b={attributeData:{},loadedAttributes:[]};i.projectionPromise||(t(this._worker,"SceneLayerWorker is needed to project mesh"),i.projectionPromise=this._worker.project({positions:l.vertexAttributes.position,localMatrix:S?.localMatrix,vertexSpace:g.toJSON(),origin:_,inSpatialReference:l.spatialReference.toJSON(),outSpatialReference:this._vertexSR.toJSON(),localMode:this._localMode},n));const{projected:N,original:v}=await i.projectionPromise;l.vertexAttributes.position=v;const{transformed:D,original:j}=await p(u,i,this._worker,n);l.vertexAttributes.normal=j,r(n);const{geometryBuffer:I,geometryDescriptor:R}=x(N,u.faces,D,l.vertexAttributes.uv,l.vertexAttributes.color,d);return{geometryData:w,attributeDataInfo:b,geometryBuffer:I,geometryDescriptor:R,requiredTextures:h,textureData:f,normalReferenceFrame:this._vertexSR.isGeographic?"east-north-up":"vertex-reference-frame"}}async loadAttributes(e,t,o){const r=e.numFeatures,n={};for(const{field:{name:s}}of t)n[s]=new Array(r);return n}async loadTextures(e,t,o){const r=e.id,n=this._id2Meta.get(r);if(null==n||"mesh-component"!==n.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(n.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,r=this._memCache.get(t);if(null==r){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const r=async(r,n)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(l){n(l)}const a=s.memoryUsage,i={loadedMesh:s,projectionPromise:null,normalsTransformPromise:null,usedMemoryInBytes:a};this._memCache.put(t,i,a,o),e.loadMeshPromise=null,r(i)};return e.loadMeshPromise=new Promise(((e,t)=>r(e,t))),e.loadMeshPromise}return r}}function f(e,t){const{spatialReference:o}=e,r=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],s=o.isGeographic?o.metersPerUnit:1,a=e.center;let i=0;if(e.hasZ)for(let l=0;l<2;++l)for(let e=0;e<2;++e)for(let o=0;o<2;++o){const d=(a.x+r[l]*n[0]-t.x)*s,u=(a.y+r[e]*n[1]-t.y)*s,m=a.z+r[o]*n[2]-t.z;i=Math.max(d*d+u*u+m*m,i)}else for(let l=0;l<2;++l)for(let e=0;e<2;++e){const o=(a.x+r[l]*n[0]-t.x)*s,d=(a.y+r[e]*n[1]-t.y)*s;i=Math.max(o*o+d*d,i)}return m([t.x,t.y,t.z],Math.sqrt(i))}async function p(e,o,r,n){const{transform:d,vertexAttributes:u}=o.loadedMesh,m="source"===e.shading?u.normal:null;if(!(null!=m&&null!=d&&(0!==d.rotationAngle||!i(d.scale,l))))return{transformed:m,original:u.normal};if(!o.normalsTransformPromise){t(r,"SceneLayerWorker is needed to transform mesh normals");const e=a();s(e,d.localMatrix),o.normalsTransformPromise=r.transformNormals({normalMatrix:e,normals:m},n)}return o.normalsTransformPromise}function x(e,t,o,r,n,s){const a=1,i=t.length/3,l=3*i;let d=0,u=0,m=!1,c=0,h=!1,f=0,p=!1,x=0,g=0,b=0;d+=M,d+=M,u=d,d+=3*l*S,null!=o&&(m=!0,c=d,d+=3*l*S),null!=r&&(h=!0,f=d,d+=2*l*S),null!=n&&(p=!0,x=d,d+=4*l*_),g=d,d+=a*w,b=d,d+=2*a*M;const N=new ArrayBuffer(d),v=new Uint8Array(N);y(v,0,l),y(v,M,a);const D=new Float32Array(N,u),j=null!=o?new Float32Array(N,c):null,I=null!=r?new Float32Array(N,f):null,R=null!=n?new Uint8Array(N,x):null;for(let y=0;y<i;++y){const s=3*y;for(let a=0;a<3;++a){const i=t[s+a],l=3*i,d=9*y+3*a;if(D[d]=e[l],D[d+1]=e[l+1],D[d+2]=e[l+2],null!=j&&(j[d]=o[l],j[d+1]=o[l+1],j[d+2]=o[l+2]),null!=I){const e=2*i,t=6*y+2*a;I[t]=r[e],I[t+1]=r[e+1]}if(null!=R){const e=4*i,t=12*y+4*a;R[t]=n[e],R[t+1]=n[e+1],R[t+2]=n[e+2],R[t+3]=n[e+3]}}}y(v,g,s),y(v,g+M,s/2**32),y(v,b,0),y(v,b+M,i-1);return{geometryBuffer:N,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:m,uv0:h,uvRegion:!1,featureIndex:!0}}}function y(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function g(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const o=t;let r="";for(const n of o)r+=n.makeHash();return r+JSON.stringify(null!=e.transform?e.transform.toJSON():"")+(u(e.vertexSpace)?JSON.stringify(e.vertexSpace.origin):"")}const M=4,S=4,_=1,w=8;export{h as I3SClientNodeLoader,f as createSphereFromExtent,S as sizeOfFloat32,M as sizeOfInt32,w as sizeOfUInt64,_ as sizeOfUInt8,p as transformNormals};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as i}from"../../../../geometry/projection/projectBoundingSphere.js";import{b as n,c as s,u as o,d as r}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as a}from"../../../../support/featureFlags.js";import{LodMetric as l,NodeBase as d,Node as h,NodeFilterImpact as u,NodeIMModificationImpact as c,NodeTraversalState as g}from"./I3SNode.js";import{invalidateMbs as _,addWraparound as f}from"./I3SUtil.js";import{ValidatedNode as m}from"./ValidatedNode.js";import{ElevationRange as v}from"../../support/ElevationRange.js";import{Obb as N}from"../../support/orientedBoundingBox.js";class p{constructor(e,t,i,n,s){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=n,this.node=s,this.useAsHole=0,this.filterImpact=u.NotChecked,this.traversalState=null,this.parent=-1}}class b{constructor(e=new Array,t=new Array){this.nodes=e,this.children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}}class I{get _useNodePages(){return this._pageSize>0}constructor(t,i,n,s,o,r,d,h,u,c,g,_,f,m,v,N){this.viewingMode=t,this._layer=i,this._streamDataController=s,this._clientNodeLoader=o,this._viewportQueries=r,this._logger=d,this.holeFilling=h,this._isLoaded=u,this._isReloading=c,this._isSelected=g,this._enable=_,this._needsUpdate=f,this._canRequest=m,this._computeVisibilityObb=v,this._computeNodeFiltering=N,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=l.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=R(0),this._visibilityCacheVersion=R(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missingPagesAndNodes=new e({deallocator:null}),this._prefetchNodes=new e({deallocator:null}),this._updates=new y(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._traverseDescendantsQueue=[0],this._traverseDescendantsNestingLevel=0,this._isEditable=a()&&null!=i.associatedLayer?.infoFor3D,i.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${i.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(n)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._pageSize=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=l.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=l.MaxScreenThreshold,this._lodConversion=k}if(this._isEditable){this._rootIndex=-1;const i=V(e.rootIndex,e.pageSize),n=t.nodes[i],s={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(E(this._rootIndex,this._pageSize),s),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=e.rootIndex;this._addPage(E(e.rootIndex,this._pageSize),t),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix;const t=new b;if(this._nodePages.set(0,t),this._isEditable){this._clientNodePage=new b;const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new d(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new d(e.rootNode.id,null),-1);const i=this._validateNode(e.rootNode.id,e.rootNode);i&&this._addNode(i,0)}}addClientNodeToIndex(e,t){const i=-1,n=new d(e,t),s=this._makeClientRefNode(n,i);return this._linkChildToParentNode(i,s),this.requestUpdate(),s}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loadingPages.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());e?.nodes.forEach((e=>{let t=e.parent;for(;null!=t&&t!==this._rootIndex;){const e=this.getNode(t);e&&!Number.isNaN(e?.elevationRangeMin)&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this.getParentIndex(t)}}))}}_addPage(e,t){const i=[],s=[],o=t.nodes.map(((t,o)=>{const r=i.length,a=t.children?t.children.length:0;s.push(this._rootIndex);for(let e=0;e<a;e++)i.push(t.children[e]);const l=`${t.index}`,d=N.fromJSON(t.obb),u=n(d.center,d.radius),c=t.mesh?.attribute,g=t.mesh?.geometry,_=t.mesh?.material,f={hasSharedResource:!1,isEmpty:null==g,attributes:null!=c?.resource?`${c.resource}`:void 0,geometry:null!=g?.resource?`${g.resource}`:void 0,texture:null!=_?.resource?`${_.resource}`:void 0,geometryDefinition:g?g.definition:-1,materialDefinition:_?_.definition:-1},m=new h(l,A(o,e,this._pageSize),u,a,0,f,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?g.featureCount:null);return m.serviceObbInIndexSR=d,m.visibilityObbInRenderSR=this._computeVisibilityObb(m),m.vertexCount=g?g.vertexCount:0,new p(r,a,S(this._visibilityCacheVersion),null,m)})),r=new b(o,i);-1===e?this._clientNodePage=r:this._nodePages.set(e,r)}_updateParentsAndLevel(){const e=new Array,t=(t,i,n)=>{const s=this._getPage(t);if(null!=s){const o=V(t,this._pageSize),r=s.nodes[o];r.parent=null!=i?i:-1;const a=r.node;null!=a&&(a.level=n,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),n=this.getNode(i);if(null!=n)for(let e=0;e<n.childCount;e++){t(this.getChildIndex(n.index,e),i,n.level+1),this._maxLevel=Math.max(this._maxLevel,n.level+1)}}}_getPage(e){const t=E(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[V(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),n=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?n+1:n);const{lodMetric:s,maxError:o}=L(e.lodSelection),r=this._getNodeInternal(t),a=new h(e.id,t,e.mbs,r.childCount,n,e.resources,e.version,s,o,e.numFeatures);r.node=a,e.obb&&(a.serviceObbInIndexSR=N.fromJSON(e.obb)),a.visibilityObbInRenderSR=this._computeVisibilityObb(a);const l=r.ref;return null!=l&&(null==l.serviceMbsInIndexSR&&(l.serviceMbsInIndexSR=e.mbs),a.shareServiceBVsInRenderSRWith(l),l.visibilityObbInRenderSR=a.visibilityObbInRenderSR),a}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const n=i.nodes.length,s=new p(0,0,S(this._visibilityCacheVersion),e,null);return i.nodes.push(s),s.parent=t,e.invalidateServiceBVsInRenderSR(),n}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const n=-(i.nodes.length+1),s=new p(0,0,S(this._visibilityCacheVersion),e,null);return i.nodes.push(s),s.parent=t,e.invalidateServiceBVsInRenderSR(),n}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const n=V(e,this._pageSize),s=V(t,this._pageSize),o=i.nodes[n],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const a=1;o.childCount+=a,null!=o.node&&(o.node.childCount+=a);for(const l of i.nodes)l.childOffset>r&&(l.childOffset+=a);i.nodes[s].parent=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const n=this._clientNodePage;if(null==n)return;const s=this.getParentIndex(e);if(null==s)return;const o=new Set,r=new Map,a=e=>{const i=V(e,this._pageSize),s=n.nodes[i];if(s.childCount>0)for(let t=s.childOffset;t<s.childOffset+s.childCount;++t)a(n.children[t]);const r=s.node?.id??s.ref?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(s)};a(e);const l=n.nodes,d=n.children,h=n.nodes.map((()=>-1)),u=[],c=[];for(let g=0;g<l.length;++g){const e=l[g];if(o.has(e))continue;const t=u.length,n=A(g,-1,this._pageSize),s=A(t,-1,this._pageSize);if(e.node&&(e.node.index=s),h[g]=s,u.push(e),n!==s){const t=e.node?.id??e.ref?.id;if(null==t)throw new Error("Node has no id");i(t,n,s),r.set(n,s)}}for(let g=0;g<u.length;++g){const e=A(g,-1,this._pageSize),t=u[g],i=c.length;for(let n=t.childOffset;n<t.childOffset+t.childCount;++n){const t=d[n];if(t>=0)c.push(t);else{const i=V(t,this._pageSize),n=l[i];if(o.has(n))continue;const s=h[i];c.push(s),n.parent=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}n.nodes=u,n.children=c,this._updateParentBoundingInformation(h[V(s,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const n=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,l=this._getNodeInternal(t);if(null==l)return;for(let r=0;r<l.childCount;r++){const l=this.getChildIndex(t,r),d=this._getNodeInternal(l),h=null!=d?d.ref||d.node:null;if(null!=h&&h.serviceMbsInIndexSR[3]>0)if(null==e)e=s(h.serviceMbsInIndexSR,z);else{const t=D,s=T,r=B;i(h.serviceMbsInIndexSR,n,t,a),i(e,n,s,a),o(t,s,r),i(r,a,e,n)}}const d=l.ref||l.node;null!=d&&(null!=e?(d.serviceMbsInIndexSR??=r(),s(e,d.serviceMbsInIndexSR)):_(d.serviceMbsInIndexSR),d.invalidateServiceBVsInRenderSR(),d.geometryObbInRenderSR=null),this.invalidateNodeVisibilityCacheInternal(l),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),n=this._getPage(e);i.childOffset=n.children.length,i.childCount=t.length;for(let s=0;s<t.length;s++){const i=this._makeRefNode(t[s],e);n.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,n)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=n)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const n=i.nodes[V(e,this._pageSize)];return i.children[n.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[V(e,this._pageSize)].parent:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObbInRenderSR=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=R(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=S(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(x(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e),i=t?.node;i&&(i.geometryObbInRenderSR=null,i.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0)))}_updateElevationRange(e){this._updateElevationRangeInternal(e,null)}_updateElevationRangeInternal(e,t){const i=this._getNodeInternal(e);if(!i)return!1;const n=i?.node??i?.ref;if(!n)return!1;if(n.elevationRangeValid)return t?.expandElevationRange(n),!0;const s=new v;let o=!1;for(let l=0;l<i.childCount;l++){const t=this.getChildIndex(e,l),i=this._updateElevationRangeInternal(t,s);o=o||!i}if(0===i.childCount||o){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(n,e,s)}const r=n.elevationRangeMin,a=n.elevationRangeMax;return r===s.elevationRangeMin&&a===s.elevationRangeMax?(t?.expandElevationRange(n),!0):(i.node?.setElevationRange(s),i.ref?.setElevationRange(s),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(n),!0)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t)return!0;const i=t.ref;if(null!=i&&!i.serviceMbsInIndexSR)return!0;if(!this.needNodeElevationRange&&w(t.visibilityCache,this._visibilityCacheVersion))return M(t.visibilityCache);const n=t.node,s=this._viewportQueries;if(n&&n.level>0){s.ensureElevationAgnosticBoundingVolume(n,this.viewingMode);const e=n.elevationAgnosticBoundingVolume;if(!s.isElevationAgnosticBoundingVolumeVisible(this.viewingMode,e))return t.visibilityCache=C(!1,this._visibilityCacheVersion),!1}if(this.needNodeElevationRange&&this._updateElevationRange(e),!w(t.visibilityCache,this._visibilityCacheVersion)){if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=n||null!=i)&&t.filterImpact===u.NotChecked){const e=null!=n?n.serviceMbsInIndexSR:null!=i?i.serviceMbsInIndexSR:null;t.filterImpact=null!=e?this._computeNodeFiltering(e):u.Unmodified}const e=null!=n&&t.filterImpact===u.Culled,o=null!=n&&n.imModificationImpact===c.Culled,r=!n||i&&!n.visibilityObbInRenderSR?i??null:n,a=!o&&(!r||s.isNodeVisible(r))&&!e;return t.visibilityCache=C(a,this._visibilityCacheVersion),a}return M(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t?.node?.geometryObbInRenderSR||this.layerHasModifications&&t.node.imModificationImpact===c.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,n,s){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,a=new Array;for(let l=t.childOffset;l<r;++l){const e=o.children[l],t=this._getNodeInternal(e);null!=t?.node&&this.isGeometryVisible(e)&&a.push(t)}n/=a.length;for(const l of a){const e=l.node.index;this._isLoaded(e)||this._isReloading(e)?(s.delta=Math.max(s.delta,i),s.coverage+=n):this._traverseCoverage(e,l,i+1,n,s)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(w(t.useAsHole,this._version))return M(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const n=i.delta*i.coverage<=.5;return t.useAsHole=C(n,this._version),n}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=R(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=c.NotChecked,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=u.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),P.clear();let n=!0;const s=new F,o=new F,r=this._imModificationUncategorized;r.clear();const a=new Set;let l=0;const d=(a,d,h)=>{const u=E(a,this._pageSize);if(null==d){let e=this._entryPriority(a);return e===1/0&&(e=this._entryPriority(h)),P.set(u,Math.max(e,P.get(u)||0)),this._loadingPages.has(u)||this._failedPages.has(u)||(this._missingPagesAndNodes.push(u),++l),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const g=d.node;if(this._updateNodeFeatureEstimate(g,o),null==g){const e=this._entryPriority(a);return this._loadingNodes.has(a)||this._failedNodes.has(a)||(this._missingPagesAndNodes.push(a),P.set(a,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const _=this._getPage(a);if(0===this._missingPagesAndNodes.length&&!this._useNodePages)for(let e=0;e<d.childCount;e++){const t=_.children[d.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loadingNodes.has(t)||this._failedNodes.has(t)||(P.set(t,this._entryPriority(t)),this._prefetchNodes.push(t))}if(g.failed||g.resources.isEmpty)return void(n&&d.childCount>0&&this._isSelected(g)&&(n=!1));if(this._isLoaded(a)){if(s.known+=g.memory,++s.knownNodes,this._isSelected(g)?d.childCount>0&&(n=!1):(s.unremoved+=g.memory,n=!1),this._needsUpdate(g)){const e=this._entryPriority(a);P.set(a,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(a)}return}if(g.memory&&(s.known+=g.memory,++s.knownNodes),!this._isSelected(g))return void(this._isReloading(a)&&this._updates.remove.push(a));if(d.childCount>0&&(n=!1),g.memory?(s.missing+=g.memory,s.known+=g.memory,++s.knownNodes):++s.missingNodes,e.includes(g.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(a)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==g.index)));if(!t.done&&this._enable(g))return void t.madeProgress();const f=this._entryPriority(a);P.set(a,f),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,f),this._updates.add.push(a),this.layerHasModifications&&i&&null!=g&&g.imModificationImpact===c.NotChecked&&r.push(a)};this.traverseVisible(d,a),this._frameNumber++,this._missingPagesAndNodes.sort(((e,t)=>e-t)),this._missingPagesAndNodes.filterInPlace(((e,t)=>t<1||this._missingPagesAndNodes.data[t-1]!==e)),this._missingPagesAndNodes.sort(((e,t)=>P.get(e)-P.get(t))),this._missingPagesAndNodes.length>0&&(this._maxUnloadedPrio=P.get(this._missingPagesAndNodes.back()),this._prefetchNodes.clear()),this._removeUnusedNodePages(a,l);const h=this._updates.add;h.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),h.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t?.node||t.node.imModificationImpact!==c.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=s.missing-s.unremoved,s.knownNodes>3&&s.missingNodes>0&&(this._unloadedMemoryEstimate+=s.known/s.knownNodes*s.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=n,this._updates.add.filterInPlace((e=>P.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>P.get(e)-P.get(t))),this._updates.update.sort(((e,t)=>P.get(e)-P.get(t))),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.length,this._dirty=this._indexMissing>0,P.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let n=t,s=t,o=i,r=10;for(;r--;){const i=new F;this._updateFeatureEstimate(n,i);if(this._computeFeatureEstimate(i)<=e){if(n>=t||i.missingNodes>0||0===r)break;o=n,n=.5*(n+s)}else s=n,n=.5*(n+o)}return this._version=R(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,n)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;const i=e.size,n=this._nodePages,s=n.size+this._loadingPages.size+t;if(s>Q&&s>i){const t=new Array;for(const[i,s]of n)0!==s.numNodesWithLoadedChildren||e.has(i)||t.push([s.lastTraversed,i]);t.sort(((e,t)=>e[0]-t[0])).some((e=>{const t=e[1];return this._deleteNodePage(t),n.size<=Q}))}}_updateFeatureEstimate(e,t){this._version=R(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){null==e||e.failed||null==e.numFeatures||this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missingPagesAndNodes)}prefetch(){return this._prefetchNodes.sort(((e,t)=>P.get(e)-P.get(t))),this._load(this._prefetchNodes)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();){const t=e.pop();this._useNodePages&&t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.length>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;const t=e.index,i=this._getNodeInternal(t);if(!i)return null;let n=i?.traversalState;if(n&&w(n.version,this._version))return n;const s=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this.getParentIndex(t);if(null!=e){const t=this._getNodeInternal(e),i=t?.traversalState;r=!!i&&s>i.lodLevel}else r=s>0}else r=0===e.childCount;return n?(n.lodLevel=s,n.isChosen=r,n.version=C(!0,this._version),n):(n=new g(o,r,s,C(!0,this._version)),i.traversalState=n,n)}async _loadNode(e){this._loadingNodes.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const n=i.id,s=this._urlPrefix+n,o=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.length&&0===this._loadingNodes.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(s,"json"):await this._clientNodeLoader.loadNodeJSON(n)}catch(d){return o(),void(t(d)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+s),this._failedNodes.add(e)))}o();const a=this._validateNode(n,r);if(null==a)return;a.obb&&this.invalidateNodeVisibilityCache(e);const l=this._addNode(a,e);this.nodeTraversalState(l)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const n=t.attributeData,s=this._layer.attributeStorageInfo;null==n||Array.isArray(n)&&!n.some(((e,t)=>e.href!==`./attributes/${s?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:void 0,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,a=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const n=new d(`${t.id}`,t.mbs);return n.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty("obb")&&t.obb?N.fromJSON(t.obb):null,n.visibilityObbInRenderSR=this._computeVisibilityObb(n),n},l=Array.isArray(t.children)?t.children.map(a).filter((e=>null!=e)):null,h=t.featureData?.length??!1,u=!0===t.isEmpty;return new m(e,t.mbs,o,"string"==typeof t.version?t.version:null,{isEmpty:!h&&u,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},l,Array.isArray(t.lodSelection)?t.lodSelection:null,r)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let n=0;if(t.node&&null!=i){const e=this._getNodeInternal(i).traversalState;null!=e&&(n=e.lodLevel)}let s=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){s=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-n*(o+this.progressiveLoadPenalty)+s}traverseVisible(e,t){const i=this._getNodeInternal(this._rootIndex);null!=i?this._traverseVisible(this._rootIndex,null,i,e,t):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,n,s){const o=E(e,this._pageSize);if(s&&s.add(o),i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&n(e,i,t));if(!this.isNodeVisible(e))return;if(n(e,i,t),null==i.node)return;const r=this.nodeTraversalState(i.node);if(r?.nodeHasLOD&&r.lodLevel===this._maxLodLevel)return;const a=this._getPageFromPageIndex(o);for(let l=0;l<i.childCount;l++){const t=a.children[i.childOffset+l],o=this._getNodeInternal(t);if(o)this._traverseVisible(t,e,o,n,s);else{if(s){const e=E(t,this._pageSize);s.add(e)}n(t,null,e)}}}traverse(e,t){t(e)&&this.traverseDescendants(e,t)}traverseDescendants(e,t){++this._traverseDescendantsNestingLevel;const i=e.index,n=this._pageSize,s=E(i,n),o=this._getPageFromPageIndex(s);if(null==o)return;const r=this._frameNumber,a=this._nodePages;o.lastTraversed=r;const l=V(i,n),d=o.nodes[l],{childCount:h}=d;if(0===h)return;const u=1===this._traverseDescendantsNestingLevel?this._traverseDescendantsQueue:[0];let c=0;const g=[];{const{childOffset:e,childCount:t}=d,{children:i}=o;u.length=2**Math.ceil(Math.log2(c+t));for(let n=e;n<e+t;++n){const e=i[n];e>=0?(u[c]=e,++c):g.push(e)}}if(g.length>0){const e=this._clientNodePage;if(e){const i=e.children;let n=0;for(;n<g.length;){const s=g[n];++n;const o=-s-1,r=e.nodes[o],a=r.node;if(!a)continue;if(!t(a))continue;const{childCount:l}=r;if(0===l)continue;const{childOffset:d}=r,h=d+l;for(let e=d;e<h;++e)g.push(i[e])}}}if(c>0){let e=0;if(n>0){let i=s*n,l=o,d=l.nodes;for(;e<c;){const s=u[e];let o;if(++e,i<=s&&s<i+n)o=l;else{const e=s/n|0,t=a.get(e);if(void 0===t)continue;o=t,o.lastTraversed=r,l=o,d=l.nodes,i=n*e}const h=d[s-i],g=h.node;if(null==g)continue;if(!1===t(g))continue;const{childCount:_}=h;if(0===_)continue;const f=c+_;for(u.length<f&&(u.length=2**Math.ceil(Math.log2(c+_)));u.length<c+_;)u.length+=u.length;const m=o.children,{childOffset:v}=h,N=v+_;for(let e=v;e<N;++e)u[c]=m[e],++c}}else{const i=a.get(0);if(i)for(;e<c;){const n=u[e];++e;const s=i.nodes[n],o=s.node;if(!o)continue;if(!t(o))continue;const{childCount:r}=s;if(0===r)continue;u.length=Math.max(u.length,2**Math.ceil(Math.log2(c+r)));const a=i.children,{childOffset:l}=s,d=l+r;for(let e=l;e<d;++e)u[c]=a[e],++c}}}--this._traverseDescendantsNestingLevel}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,n=e+t;i.childrenLoaded=n;const s=0===e?1:0===n?-1:0,o=i.index;if(0!==s){this._getPage(o).numNodesWithLoadedChildren+=s}i=this.getParent(o)}}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let n=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseDescendants(i,(e=>(n+=t(e),!1))),i.childrenLoaded!==n&&e.push(i.index),n};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{x(e),null!=e.node&&e.node.invalidateElevationRange(),null!=e.ref&&e.ref.invalidateElevationRange()}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const n=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],n+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible((e=>t.add(E(e,this._pageSize))));for(const[i,n]of e)if(0!==n.numNodesWithLoadedChildren||t.has(i))for(const e of n.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){this._nodePages.delete(e)}get test(){return{addNode:(e,t)=>this._addNode(this._validateNode(e.id,e),t),getNodeInternal:e=>this._getNodeInternal(e),getPageIndex:e=>E(e,this._pageSize),getIndexWithinPage:e=>V(e,this._pageSize),getNodePage:e=>e<0?this._clientNodePage:this._nodePages.get(e),getChildIndices:e=>{const t=this._getNodeInternal(e),i=this._getPage(e);if(null==t||null==i)return[];const n=[];for(let s=t.childOffset;s<t.childOffset+t.childCount;++s)n.push(i.children[s]);return n},rootIndex:this._rootIndex,clientNodePage:this._clientNodePage,nodePages:this._nodePages}}}const P=new Map;class y{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function x(e){e.node?.invalidateServiceBVsInRenderSR(),e.ref?.invalidateServiceBVsInRenderSR()}function S(e){return f(e,-2)}function R(e){return f(e,2)}function C(e,t){return t+(e?1:0)}function w(e,t){return(-2&e)===t}function M(e){return 1==(1&e)}function E(e,t){return e<0?-1:t>0?e/t|0:0}function V(e,t){return e<0?-e-1:0===t?e:e%t}function A(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const O=[["maxScreenThreshold",l.MaxScreenThreshold],["screenSpaceRelative",l.ScreenSpaceRelative],["removedFeatureDiameter",l.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",l.DistanceRangeFromDefaultCamera]];function L(e){if(e)for(let t=0;t<e.length;t++)for(const i of O)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:l.None,maxError:0}}class F{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function k(e){return Math.sqrt(e*(4/Math.PI))}const z=r(),D=r(),T=r(),B=r(),Q=has("esri-mobile")?100:300;export{I as I3SIndex,L as selectErrorMetric};
5
+ import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as i}from"../../../../geometry/projection/projectBoundingSphere.js";import{k as n,a as s,u as o,c as r}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as a}from"../../../../support/featureFlags.js";import{LodMetric as l,NodeBase as d,Node as h,NodeFilterImpact as u,NodeIMModificationImpact as c,NodeTraversalState as g}from"./I3SNode.js";import{invalidateMbs as _,addWraparound as f}from"./I3SUtil.js";import{ValidatedNode as m}from"./ValidatedNode.js";import{ElevationRange as v}from"../../support/ElevationRange.js";import{Obb as N}from"../../support/orientedBoundingBox.js";class p{constructor(e,t,i,n,s){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=n,this.node=s,this.useAsHole=0,this.filterImpact=u.NotChecked,this.traversalState=null,this.parent=-1}}class b{constructor(e=new Array,t=new Array){this.nodes=e,this.children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}}class I{get _useNodePages(){return this._pageSize>0}constructor(t,i,n,s,o,r,d,h,u,c,g,_,f,m,v,N){this.viewingMode=t,this._layer=i,this._streamDataController=s,this._clientNodeLoader=o,this._viewportQueries=r,this._logger=d,this.holeFilling=h,this._isLoaded=u,this._isReloading=c,this._isSelected=g,this._enable=_,this._needsUpdate=f,this._canRequest=m,this._computeVisibilityObb=v,this._computeNodeFiltering=N,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=l.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=R(0),this._visibilityCacheVersion=R(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missingPagesAndNodes=new e({deallocator:null}),this._prefetchNodes=new e({deallocator:null}),this._updates=new y(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._traverseDescendantsQueue=[0],this._traverseDescendantsNestingLevel=0,this._isEditable=a()&&null!=i.associatedLayer?.infoFor3D,i.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${i.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(n)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._pageSize=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=l.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=l.MaxScreenThreshold,this._lodConversion=F}if(this._isEditable){this._rootIndex=-1;const i=V(e.rootIndex,e.pageSize),n=t.nodes[i],s={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(E(this._rootIndex,this._pageSize),s),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=e.rootIndex;this._addPage(E(e.rootIndex,this._pageSize),t),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix;const t=new b;if(this._nodePages.set(0,t),this._isEditable){this._clientNodePage=new b;const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new d(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new d(e.rootNode.id,null),-1);const i=this._validateNode(e.rootNode.id,e.rootNode);i&&this._addNode(i,0)}}addClientNodeToIndex(e,t){const i=-1,n=new d(e,t),s=this._makeClientRefNode(n,i);return this._linkChildToParentNode(i,s),this.requestUpdate(),s}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loadingPages.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());e?.nodes.forEach((e=>{let t=e.parent;for(;null!=t&&t!==this._rootIndex;){const e=this.getNode(t);e&&!Number.isNaN(e?.elevationRangeMin)&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this.getParentIndex(t)}}))}}_addPage(e,t){const i=[],s=[],o=t.nodes.map(((t,o)=>{const r=i.length,a=t.children?t.children.length:0;s.push(this._rootIndex);for(let e=0;e<a;e++)i.push(t.children[e]);const l=`${t.index}`,d=N.fromJSON(t.obb),u=n(d.center,d.radius),c=t.mesh?.attribute,g=t.mesh?.geometry,_=t.mesh?.material,f={hasSharedResource:!1,isEmpty:null==g,attributes:null!=c?.resource?`${c.resource}`:void 0,geometry:null!=g?.resource?`${g.resource}`:void 0,texture:null!=_?.resource?`${_.resource}`:void 0,geometryDefinition:g?g.definition:-1,materialDefinition:_?_.definition:-1},m=new h(l,A(o,e,this._pageSize),u,a,0,f,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?g.featureCount:null);return m.serviceObbInIndexSR=d,m.visibilityObbInRenderSR=this._computeVisibilityObb(m),m.vertexCount=g?g.vertexCount:0,new p(r,a,S(this._visibilityCacheVersion),null,m)})),r=new b(o,i);-1===e?this._clientNodePage=r:this._nodePages.set(e,r)}_updateParentsAndLevel(){const e=new Array,t=(t,i,n)=>{const s=this._getPage(t);if(null!=s){const o=V(t,this._pageSize),r=s.nodes[o];r.parent=null!=i?i:-1;const a=r.node;null!=a&&(a.level=n,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),n=this.getNode(i);if(null!=n)for(let e=0;e<n.childCount;e++){t(this.getChildIndex(n.index,e),i,n.level+1),this._maxLevel=Math.max(this._maxLevel,n.level+1)}}}_getPage(e){const t=E(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[V(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),n=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?n+1:n);const{lodMetric:s,maxError:o}=L(e.lodSelection),r=this._getNodeInternal(t),a=new h(e.id,t,e.mbs,r.childCount,n,e.resources,e.version,s,o,e.numFeatures);r.node=a,e.obb&&(a.serviceObbInIndexSR=N.fromJSON(e.obb)),a.visibilityObbInRenderSR=this._computeVisibilityObb(a);const l=r.ref;return null!=l&&(null==l.serviceMbsInIndexSR&&(l.serviceMbsInIndexSR=e.mbs),a.shareServiceBVsInRenderSRWith(l),l.visibilityObbInRenderSR=a.visibilityObbInRenderSR),a}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const n=i.nodes.length,s=new p(0,0,S(this._visibilityCacheVersion),e,null);return i.nodes.push(s),s.parent=t,e.invalidateServiceBVsInRenderSR(),n}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const n=-(i.nodes.length+1),s=new p(0,0,S(this._visibilityCacheVersion),e,null);return i.nodes.push(s),s.parent=t,e.invalidateServiceBVsInRenderSR(),n}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const n=V(e,this._pageSize),s=V(t,this._pageSize),o=i.nodes[n],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const a=1;o.childCount+=a,null!=o.node&&(o.node.childCount+=a);for(const l of i.nodes)l.childOffset>r&&(l.childOffset+=a);i.nodes[s].parent=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const n=this._clientNodePage;if(null==n)return;const s=this.getParentIndex(e);if(null==s)return;const o=new Set,r=new Map,a=e=>{const i=V(e,this._pageSize),s=n.nodes[i];if(s.childCount>0)for(let t=s.childOffset;t<s.childOffset+s.childCount;++t)a(n.children[t]);const r=s.node?.id??s.ref?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(s)};a(e);const l=n.nodes,d=n.children,h=n.nodes.map((()=>-1)),u=[],c=[];for(let g=0;g<l.length;++g){const e=l[g];if(o.has(e))continue;const t=u.length,n=A(g,-1,this._pageSize),s=A(t,-1,this._pageSize);if(e.node&&(e.node.index=s),h[g]=s,u.push(e),n!==s){const t=e.node?.id??e.ref?.id;if(null==t)throw new Error("Node has no id");i(t,n,s),r.set(n,s)}}for(let g=0;g<u.length;++g){const e=A(g,-1,this._pageSize),t=u[g],i=c.length;for(let n=t.childOffset;n<t.childOffset+t.childCount;++n){const t=d[n];if(t>=0)c.push(t);else{const i=V(t,this._pageSize),n=l[i];if(o.has(n))continue;const s=h[i];c.push(s),n.parent=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}n.nodes=u,n.children=c,this._updateParentBoundingInformation(h[V(s,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const n=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,l=this._getNodeInternal(t);if(null==l)return;for(let r=0;r<l.childCount;r++){const l=this.getChildIndex(t,r),d=this._getNodeInternal(l),h=null!=d?d.ref||d.node:null;if(null!=h&&h.serviceMbsInIndexSR[3]>0)if(null==e)e=s(h.serviceMbsInIndexSR,z);else{const t=D,s=T,r=B;i(h.serviceMbsInIndexSR,n,t,a),i(e,n,s,a),o(t,s,r),i(r,a,e,n)}}const d=l.ref||l.node;null!=d&&(null!=e?(d.serviceMbsInIndexSR??=r(),s(e,d.serviceMbsInIndexSR)):_(d.serviceMbsInIndexSR),d.invalidateServiceBVsInRenderSR(),d.geometryObbInRenderSR=null),this.invalidateNodeVisibilityCacheInternal(l),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),n=this._getPage(e);i.childOffset=n.children.length,i.childCount=t.length;for(let s=0;s<t.length;s++){const i=this._makeRefNode(t[s],e);n.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,n)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=n)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const n=i.nodes[V(e,this._pageSize)];return i.children[n.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[V(e,this._pageSize)].parent:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObbInRenderSR=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=R(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=S(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(x(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e),i=t?.node;i&&(i.geometryObbInRenderSR=null,i.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0)))}_updateElevationRange(e){this._updateElevationRangeInternal(e,null)}_updateElevationRangeInternal(e,t){const i=this._getNodeInternal(e);if(!i)return!1;const n=i?.node??i?.ref;if(!n)return!1;if(n.elevationRangeValid)return t?.expandElevationRange(n),!0;const s=new v;let o=!1;for(let l=0;l<i.childCount;l++){const t=this.getChildIndex(e,l),i=this._updateElevationRangeInternal(t,s);o=o||!i}if(0===i.childCount||o){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(n,e,s)}const r=n.elevationRangeMin,a=n.elevationRangeMax;return r===s.elevationRangeMin&&a===s.elevationRangeMax?(t?.expandElevationRange(n),!0):(i.node?.setElevationRange(s),i.ref?.setElevationRange(s),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(n),!0)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t)return!0;const i=t.ref;if(null!=i&&!i.serviceMbsInIndexSR)return!0;if(!this.needNodeElevationRange&&w(t.visibilityCache,this._visibilityCacheVersion))return M(t.visibilityCache);const n=t.node,s=this._viewportQueries;if(n&&n.level>0){s.ensureElevationAgnosticBoundingVolume(n,this.viewingMode);const e=n.elevationAgnosticBoundingVolume;if(!s.isElevationAgnosticBoundingVolumeVisible(this.viewingMode,e))return t.visibilityCache=C(!1,this._visibilityCacheVersion),!1}if(this.needNodeElevationRange&&this._updateElevationRange(e),!w(t.visibilityCache,this._visibilityCacheVersion)){if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=n||null!=i)&&t.filterImpact===u.NotChecked){const e=null!=n?n.serviceMbsInIndexSR:null!=i?i.serviceMbsInIndexSR:null;t.filterImpact=null!=e?this._computeNodeFiltering(e):u.Unmodified}const e=null!=n&&t.filterImpact===u.Culled,o=null!=n&&n.imModificationImpact===c.Culled,r=!n||i&&!n.visibilityObbInRenderSR?i??null:n,a=!o&&(!r||s.isNodeVisible(r))&&!e;return t.visibilityCache=C(a,this._visibilityCacheVersion),a}return M(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t?.node?.geometryObbInRenderSR||this.layerHasModifications&&t.node.imModificationImpact===c.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,n,s){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,a=new Array;for(let l=t.childOffset;l<r;++l){const e=o.children[l],t=this._getNodeInternal(e);null!=t?.node&&this.isGeometryVisible(e)&&a.push(t)}n/=a.length;for(const l of a){const e=l.node.index;this._isLoaded(e)||this._isReloading(e)?(s.delta=Math.max(s.delta,i),s.coverage+=n):this._traverseCoverage(e,l,i+1,n,s)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(w(t.useAsHole,this._version))return M(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const n=i.delta*i.coverage<=.5;return t.useAsHole=C(n,this._version),n}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=R(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=c.NotChecked,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=u.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),P.clear();let n=!0;const s=new k,o=new k,r=this._imModificationUncategorized;r.clear();const a=new Set;let l=0;const d=(a,d,h)=>{const u=E(a,this._pageSize);if(null==d){let e=this._entryPriority(a);return e===1/0&&(e=this._entryPriority(h)),P.set(u,Math.max(e,P.get(u)||0)),this._loadingPages.has(u)||this._failedPages.has(u)||(this._missingPagesAndNodes.push(u),++l),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const g=d.node;if(this._updateNodeFeatureEstimate(g,o),null==g){const e=this._entryPriority(a);return this._loadingNodes.has(a)||this._failedNodes.has(a)||(this._missingPagesAndNodes.push(a),P.set(a,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const _=this._getPage(a);if(0===this._missingPagesAndNodes.length&&!this._useNodePages)for(let e=0;e<d.childCount;e++){const t=_.children[d.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loadingNodes.has(t)||this._failedNodes.has(t)||(P.set(t,this._entryPriority(t)),this._prefetchNodes.push(t))}if(g.failed||g.resources.isEmpty)return void(n&&d.childCount>0&&this._isSelected(g)&&(n=!1));if(this._isLoaded(a)){if(s.known+=g.memory,++s.knownNodes,this._isSelected(g)?d.childCount>0&&(n=!1):(s.unremoved+=g.memory,n=!1),this._needsUpdate(g)){const e=this._entryPriority(a);P.set(a,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(a)}return}if(g.memory&&(s.known+=g.memory,++s.knownNodes),!this._isSelected(g))return void(this._isReloading(a)&&this._updates.remove.push(a));if(d.childCount>0&&(n=!1),g.memory?(s.missing+=g.memory,s.known+=g.memory,++s.knownNodes):++s.missingNodes,e.includes(g.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(a)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==g.index)));if(!t.done&&this._enable(g))return void t.madeProgress();const f=this._entryPriority(a);P.set(a,f),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,f),this._updates.add.push(a),this.layerHasModifications&&i&&null!=g&&g.imModificationImpact===c.NotChecked&&r.push(a)};this.traverseVisible(d,a),this._frameNumber++,this._missingPagesAndNodes.sort(((e,t)=>e-t)),this._missingPagesAndNodes.filterInPlace(((e,t)=>t<1||this._missingPagesAndNodes.data[t-1]!==e)),this._missingPagesAndNodes.sort(((e,t)=>P.get(e)-P.get(t))),this._missingPagesAndNodes.length>0&&(this._maxUnloadedPrio=P.get(this._missingPagesAndNodes.back()),this._prefetchNodes.clear()),this._removeUnusedNodePages(a,l);const h=this._updates.add;h.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),h.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t?.node||t.node.imModificationImpact!==c.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=s.missing-s.unremoved,s.knownNodes>3&&s.missingNodes>0&&(this._unloadedMemoryEstimate+=s.known/s.knownNodes*s.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=n,this._updates.add.filterInPlace((e=>P.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>P.get(e)-P.get(t))),this._updates.update.sort(((e,t)=>P.get(e)-P.get(t))),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.length,this._dirty=this._indexMissing>0,P.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let n=t,s=t,o=i,r=10;for(;r--;){const i=new k;this._updateFeatureEstimate(n,i);if(this._computeFeatureEstimate(i)<=e){if(n>=t||i.missingNodes>0||0===r)break;o=n,n=.5*(n+s)}else s=n,n=.5*(n+o)}return this._version=R(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,n)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;const i=e.size,n=this._nodePages,s=n.size+this._loadingPages.size+t;if(s>Q&&s>i){const t=new Array;for(const[i,s]of n)0!==s.numNodesWithLoadedChildren||e.has(i)||t.push([s.lastTraversed,i]);t.sort(((e,t)=>e[0]-t[0])).some((e=>{const t=e[1];return this._deleteNodePage(t),n.size<=Q}))}}_updateFeatureEstimate(e,t){this._version=R(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){null==e||e.failed||null==e.numFeatures||this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missingPagesAndNodes)}prefetch(){return this._prefetchNodes.sort(((e,t)=>P.get(e)-P.get(t))),this._load(this._prefetchNodes)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();){const t=e.pop();this._useNodePages&&t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.length>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;const t=e.index,i=this._getNodeInternal(t);if(!i)return null;let n=i?.traversalState;if(n&&w(n.version,this._version))return n;const s=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this.getParentIndex(t);if(null!=e){const t=this._getNodeInternal(e),i=t?.traversalState;r=!!i&&s>i.lodLevel}else r=s>0}else r=0===e.childCount;return n?(n.lodLevel=s,n.isChosen=r,n.version=C(!0,this._version),n):(n=new g(o,r,s,C(!0,this._version)),i.traversalState=n,n)}async _loadNode(e){this._loadingNodes.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const n=i.id,s=this._urlPrefix+n,o=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.length&&0===this._loadingNodes.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(s,"json"):await this._clientNodeLoader.loadNodeJSON(n)}catch(d){return o(),void(t(d)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+s),this._failedNodes.add(e)))}o();const a=this._validateNode(n,r);if(null==a)return;a.obb&&this.invalidateNodeVisibilityCache(e);const l=this._addNode(a,e);this.nodeTraversalState(l)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const n=t.attributeData,s=this._layer.attributeStorageInfo;null==n||Array.isArray(n)&&!n.some(((e,t)=>e.href!==`./attributes/${s?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:void 0,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,a=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const n=new d(`${t.id}`,t.mbs);return n.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty("obb")&&t.obb?N.fromJSON(t.obb):null,n.visibilityObbInRenderSR=this._computeVisibilityObb(n),n},l=Array.isArray(t.children)?t.children.map(a).filter((e=>null!=e)):null,h=t.featureData?.length??!1,u=!0===t.isEmpty;return new m(e,t.mbs,o,"string"==typeof t.version?t.version:null,{isEmpty:!h&&u,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},l,Array.isArray(t.lodSelection)?t.lodSelection:null,r)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let n=0;if(t.node&&null!=i){const e=this._getNodeInternal(i).traversalState;null!=e&&(n=e.lodLevel)}let s=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){s=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-n*(o+this.progressiveLoadPenalty)+s}traverseVisible(e,t){const i=this._getNodeInternal(this._rootIndex);null!=i?this._traverseVisible(this._rootIndex,null,i,e,t):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,n,s){const o=E(e,this._pageSize);if(s&&s.add(o),i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&n(e,i,t));if(!this.isNodeVisible(e))return;if(n(e,i,t),null==i.node)return;const r=this.nodeTraversalState(i.node);if(r?.nodeHasLOD&&r.lodLevel===this._maxLodLevel)return;const a=this._getPageFromPageIndex(o);for(let l=0;l<i.childCount;l++){const t=a.children[i.childOffset+l],o=this._getNodeInternal(t);if(o)this._traverseVisible(t,e,o,n,s);else{if(s){const e=E(t,this._pageSize);s.add(e)}n(t,null,e)}}}traverse(e,t){t(e)&&this.traverseDescendants(e,t)}traverseDescendants(e,t){++this._traverseDescendantsNestingLevel;const i=e.index,n=this._pageSize,s=E(i,n),o=this._getPageFromPageIndex(s);if(null==o)return;const r=this._frameNumber,a=this._nodePages;o.lastTraversed=r;const l=V(i,n),d=o.nodes[l],{childCount:h}=d;if(0===h)return;const u=1===this._traverseDescendantsNestingLevel?this._traverseDescendantsQueue:[0];let c=0;const g=[];{const{childOffset:e,childCount:t}=d,{children:i}=o;u.length=2**Math.ceil(Math.log2(c+t));for(let n=e;n<e+t;++n){const e=i[n];e>=0?(u[c]=e,++c):g.push(e)}}if(g.length>0){const e=this._clientNodePage;if(e){const i=e.children;let n=0;for(;n<g.length;){const s=g[n];++n;const o=-s-1,r=e.nodes[o],a=r.node;if(!a)continue;if(!t(a))continue;const{childCount:l}=r;if(0===l)continue;const{childOffset:d}=r,h=d+l;for(let e=d;e<h;++e)g.push(i[e])}}}if(c>0){let e=0;if(n>0){let i=s*n,l=o,d=l.nodes;for(;e<c;){const s=u[e];let o;if(++e,i<=s&&s<i+n)o=l;else{const e=s/n|0,t=a.get(e);if(void 0===t)continue;o=t,o.lastTraversed=r,l=o,d=l.nodes,i=n*e}const h=d[s-i],g=h.node;if(null==g)continue;if(!1===t(g))continue;const{childCount:_}=h;if(0===_)continue;const f=c+_;for(u.length<f&&(u.length=2**Math.ceil(Math.log2(c+_)));u.length<c+_;)u.length+=u.length;const m=o.children,{childOffset:v}=h,N=v+_;for(let e=v;e<N;++e)u[c]=m[e],++c}}else{const i=a.get(0);if(i)for(;e<c;){const n=u[e];++e;const s=i.nodes[n],o=s.node;if(!o)continue;if(!t(o))continue;const{childCount:r}=s;if(0===r)continue;u.length=Math.max(u.length,2**Math.ceil(Math.log2(c+r)));const a=i.children,{childOffset:l}=s,d=l+r;for(let e=l;e<d;++e)u[c]=a[e],++c}}}--this._traverseDescendantsNestingLevel}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,n=e+t;i.childrenLoaded=n;const s=0===e?1:0===n?-1:0,o=i.index;if(0!==s){this._getPage(o).numNodesWithLoadedChildren+=s}i=this.getParent(o)}}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let n=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseDescendants(i,(e=>(n+=t(e),!1))),i.childrenLoaded!==n&&e.push(i.index),n};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{x(e),null!=e.node&&e.node.invalidateElevationRange(),null!=e.ref&&e.ref.invalidateElevationRange()}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const n=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],n+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible((e=>t.add(E(e,this._pageSize))));for(const[i,n]of e)if(0!==n.numNodesWithLoadedChildren||t.has(i))for(const e of n.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){this._nodePages.delete(e)}get test(){return{addNode:(e,t)=>this._addNode(this._validateNode(e.id,e),t),getNodeInternal:e=>this._getNodeInternal(e),getPageIndex:e=>E(e,this._pageSize),getIndexWithinPage:e=>V(e,this._pageSize),getNodePage:e=>e<0?this._clientNodePage:this._nodePages.get(e),getChildIndices:e=>{const t=this._getNodeInternal(e),i=this._getPage(e);if(null==t||null==i)return[];const n=[];for(let s=t.childOffset;s<t.childOffset+t.childCount;++s)n.push(i.children[s]);return n},rootIndex:this._rootIndex,clientNodePage:this._clientNodePage,nodePages:this._nodePages}}}const P=new Map;class y{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function x(e){e.node?.invalidateServiceBVsInRenderSR(),e.ref?.invalidateServiceBVsInRenderSR()}function S(e){return f(e,-2)}function R(e){return f(e,2)}function C(e,t){return t+(e?1:0)}function w(e,t){return(-2&e)===t}function M(e){return 1==(1&e)}function E(e,t){return e<0?-1:t>0?e/t|0:0}function V(e,t){return e<0?-e-1:0===t?e:e%t}function A(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const O=[["maxScreenThreshold",l.MaxScreenThreshold],["screenSpaceRelative",l.ScreenSpaceRelative],["removedFeatureDiameter",l.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",l.DistanceRangeFromDefaultCamera]];function L(e){if(e)for(let t=0;t<e.length;t++)for(const i of O)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:l.None,maxError:0}}class k{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function F(e){return Math.sqrt(e*(4/Math.PI))}const z=r(),D=r(),T=r(),B=r(),Q=has("esri-mobile")?100:300;export{I as I3SIndex,L as selectErrorMetric};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{n as e,z as t,k as i,r as s,c as n,D as r,w as o,h as a,o as c,a as l,q as h,l as d,p as u,f as m,g as p}from"../../../../chunks/vec32.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as v,b as g}from"../../../../chunks/vec42.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as S}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as R}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as x}from"../../../../geometry/projection/projectors.js";import{create as M,fromMatrix as I,intersectsSphere as C,createPoints as P}from"../../../../geometry/support/frustum.js";import{isPlateCarree as D}from"../../../../geometry/support/spatialReferenceUtils.js";import{g as E,w as F}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as O}from"../../../../layers/graphics/dehydratedPoint.js";import{ViewingMode as B}from"../../../ViewingMode.js";import{evaluateElevationAlignmentAtPoint as V}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as j}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as L,extractExpressionInfo as A}from"../graphics/featureExpressionInfoUtils.js";import{LodMetric as y}from"./I3SNode.js";import{isValidMbs as w,intersectBoundingRectWithMbs as G,MbsIntersectResult as N}from"./I3SUtil.js";import{Obb as U,computeOffsetObb as z}from"../../support/orientedBoundingBox.js";const T=1e5;class q{constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=M(),this._frustumMbs=f(),this._useFrustumCulling=!1,this._poi=_(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmpObb=new U,this._tmp1=_(),this._tmp2=_(),this._tmp3=_(),this._tmp0=_(),this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const l=this._renderCoordsHelper.spatialReference;this._renderSR=l,this._renderSRSphericalPCPF=R(l),this._isGlobalMode=l===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._tmpPoint=O(0,0,0,e),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(l.isWebMercator||D(l)),this._indexSREllipsoidRadius=S(this._indexSR).radius,this._indexSRSphericalPCPF=R(e),this._projectorIndexSRToIndexSRSphericalPCPF=x(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=j.fromElevationInfo(e),this._elevationContext.updateFeatureExpressionInfoContext(L(A(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,r){I(n.viewMatrix,n.projectionMatrix,this._frustum,H);{const r=n.eye,o=k;e(o,n.viewForward);const a=W;t(a,H[4],r);const c=.5*i(a,a)/i(o,a),l=this._frustumMbs;s(l,r,o,c);const h=1+c;l[3]=h}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground";if(this._elevationProvider.getSphereElevationBounds){const e=this._elevationProvider.getSphereElevationBounds(s,this._indexSR,n);return void(e&&i.expandElevationRange(e))}const r=s[0],o=s[1],a=s[2],c=this._elevationProvider.getElevation(r,o,a,this._indexSR,n);c&&i.expandElevationRangeValues(c,c);const l=t?null:this._elevationProvider.getRootElevationBounds?.();l&&i.expandElevationRange(l)}getServiceMbsInRenderSR(e){const t=e.serviceMbsInRenderSR;if(w(t))return t;e.serviceMbsInIndexSR&&v(t,e.serviceMbsInIndexSR);const i=e.elevationRangeMin;if(this._elevationContext&&Number.isFinite(i)){let s=0,n=0;const r=e.elevationRangeMax;switch(this._elevationContext.mode){case"relative-to-ground":s=this._elevationContext.geometryZWithOffset(t[2],this._renderCoordsHelper)+i-t[2],n=r-i;break;case"on-the-ground":s=i-t[2],n=r-i}t[2]+=s+.5*n,t[3]+=.5*n}else this._elevationContext&&t[3]<T&&(this._tmpPoint.x=t[0],this._tmpPoint.y=t[1],this._tmpPoint.z=t[2],t[2]=V(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper));return b(t,this._indexSR,t,this._renderSR),t}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new U,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i[3];let r=0,o=0;const a=s.centerZ,c=this._renderCoordsHelper,l=this._elevationContext;if(l&&e.elevationRangeValid){const t=e.elevationRangeMin,i=e.elevationRangeMax;switch(l.mode){case"relative-to-ground":r=l.geometryZWithOffset(a,c)+t-a,o=i-t;break;case"on-the-ground":r=t-a,o=i-t}}else if(l&&n<T){const e=this._tmpPoint;e.x=s.centerX,e.y=s.centerY,e.z=a,r=V(e,this._elevationProvider,l,c)-a}const h=o>0,d=h?this._tmpObb:t;return s.transform(d,this._indexSR,this._renderSR,r,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),h&&z(d,0,o,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(X,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),X):null}ensureElevationAgnosticBoundingVolume(e,t){-1===e.elevationAgnosticBoundingVolume[3]&&(t===B.Global?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e))}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),o=t.elevationAgnosticBoundingVolume,a=Y;let c=-1;if(s){s.getCenter(a),e(a,a),s.getCorners(J);for(const t of J){e(t,t);const s=i(t,a);if(s<=0)return void(o[3]=-1);const n=Math.sqrt(1-s*s);c=Math.max(c,n)}}else{const i=t.serviceMbsInRenderSR;if(!w(i))return void(o[3]=-1);{const t=n(Y,E(i)),s=i[3],o=r(t);c=0===s?0:o<s?-1:s/o,e(t,t)}}g(o,a);const l=.001;o[3]=c+l}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(Y);e[2]=0,g(t,e);let s=0;const n=K;i.getCorners(J);for(const t of J){t[2]=0;const e=o(n,t);s=Math.max(s,e)}t[3]=Math.sqrt(s)}else{const i=e.serviceMbsInRenderSR;if(w(i)){const e=n(Y,E(i));e[2]=0,g(t,e),t[3]=i[3]}}}isNodeVisible(e){const t=this.getServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.isVisible(this._frustum):C(this._frustum,F(t))}isElevationAgnosticBoundingVolumeVisible(e,t){return!this._useFrustumCulling||(-1===t[3]||(e===B.Global?this._isConeVisibleInFrustum(t):this._isCylinderVisibleInFrustum(t)))}_isConeVisibleInFrustum(e){const t=this._frustumMbs,s=t,n=r(s),o=t[3],l=e,h=i(l,s),d=e[3];if(d>.9)return!0;if(n<=o)return!0;{const e=a(Z,l,h);if(c(e,s)<o)return!0}const u=h/n;if(h<=0){return-u<o}const m=Math.sqrt(1-u*u);if(m<d)return!0;const p=o/n;return m*Math.sqrt(1-p*p)-p*u<d}_isCylinderVisibleInFrustum(e){const t=this._frustumMbs,i=t,s=t[3],r=n(Z,i);r[2]=0;const o=e[3];return c(r,e)<=o+s}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.isVisible(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||G(this._clippingArea,e)!==N.OUTSIDE}_screenSpaceDiameterMbs(e,t){const i=this.getServiceMbsInRenderSR(e),s=Math.sqrt(l(E(i),this._camPos)),n=s-i[3];return this._updateMinMaxDistance(s),n<0?.5*Number.MAX_VALUE:t/n*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.getServiceMbsInRenderSR(e)[3]}calcCameraDistanceToCenter(e){const t=this.getServiceMbsInRenderSR(e),i=h(E(t),this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const t=this.getServiceMbsInRenderSR(e),i=t[3],s=(Math.abs(t[0]*(t[0]-this._camPos[0])+t[1]*(t[1]-this._camPos[1])+t[2]*(t[2]-this._camPos[2]))/d(E(t))+i)/h(E(t),this._camPos);return Math.min(1,s)}hasLOD(e){return e.lodMetric!==y.None}_getDistancePlanarMode(e,t){const i=e[0]-t[0],s=e[1]-t[1],n=e[2]-t[2],r=i*i+s*s,o=t[3];if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}_getDistanceGlobeMode(e,t){const s=d(E(t)),n=d(e)-s;a(this._tmp0,e,i(e,E(t))/u(e));const r=l(E(t),this._tmp0),o=t[3];if(r<=o*o)return Math.abs(n);{const r=a(this._tmp0,E(t),1/s),c=s,l=o*o/2/c,u=a(this._tmp1,r,c-l),_=e,v=m(this._tmp2,_,u),g=m(this._tmp2,v,a(this._tmp3,r,i(r,v))),f=p(this._tmp2,u,a(this._tmp2,g,o/d(g)));let S=h(_,f);if(n>=2e5){const e=m(this._tmp1,_,f);let t=i(e,r)/d(e);t<.08&&(t=1e-4),S/=t}return S}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):this._getDistancePlanarMode(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(e.lodMetric===y.None)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case y.ScreenSpaceRelative:{const i=this.getServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i[3];return this._updateMinMaxDistance(r),e.maxError*t<=n}case y.MaxScreenThreshold:{let i=this._screenSpaceDiameterMbs(e,e.serviceMbsInIndexSR[3]*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case y.RemovedFeatureDiameter:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case y.DistanceRangeFromDefaultCamera:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToPOI(e){const t=this.getServiceMbsInRenderSR(e);return h(E(t),this._poi)-t[3]}distCameraToPOI(){return h(this._camPos,this._poi)}}const k=_(),H=P(),W=_(),Z=_(),X=new U,Y=_(),J=[_(),_(),_(),_(),_(),_(),_(),_()],K=_();export{q as default};
5
+ import{n as e,z as t,k as i,r as s,c as n,H as r,w as o,h as a,o as c,a as l,q as h,l as d,p as u,f as m,g as p}from"../../../../chunks/vec32.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as v,h as g}from"../../../../chunks/vec42.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as S}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as R}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as x}from"../../../../geometry/projection/projectors.js";import{create as M,fromMatrix as I,intersectsSphere as C,createPoints as P}from"../../../../geometry/support/frustum.js";import{isPlateCarree as E}from"../../../../geometry/support/spatialReferenceUtils.js";import{g as D,w as F}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as O}from"../../../../layers/graphics/dehydratedPoint.js";import{ViewingMode as B}from"../../../ViewingMode.js";import{evaluateElevationAlignmentAtPoint as V}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as j}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as L,extractExpressionInfo as A}from"../graphics/featureExpressionInfoUtils.js";import{LodMetric as y}from"./I3SNode.js";import{isValidMbs as w,intersectBoundingRectWithMbs as G,MbsIntersectResult as N}from"./I3SUtil.js";import{Obb as U,computeOffsetObb as z}from"../../support/orientedBoundingBox.js";const T=1e5;class q{constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=M(),this._frustumMbs=f(),this._useFrustumCulling=!1,this._poi=_(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmpObb=new U,this._tmp1=_(),this._tmp2=_(),this._tmp3=_(),this._tmp0=_(),this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const l=this._renderCoordsHelper.spatialReference;this._renderSR=l,this._renderSRSphericalPCPF=R(l),this._isGlobalMode=l===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._tmpPoint=O(0,0,0,e),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(l.isWebMercator||E(l)),this._indexSREllipsoidRadius=S(this._indexSR).radius,this._indexSRSphericalPCPF=R(e),this._projectorIndexSRToIndexSRSphericalPCPF=x(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=j.fromElevationInfo(e),this._elevationContext.updateFeatureExpressionInfoContext(L(A(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,r){I(n.viewMatrix,n.projectionMatrix,this._frustum,H);{const r=n.eye,o=k;e(o,n.viewForward);const a=W;t(a,H[4],r);const c=.5*i(a,a)/i(o,a),l=this._frustumMbs;s(l,r,o,c);const h=1+c;l[3]=h}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground";if(this._elevationProvider.getSphereElevationBounds){const e=this._elevationProvider.getSphereElevationBounds(s,this._indexSR,n);return void(e&&i.expandElevationRange(e))}const r=s[0],o=s[1],a=s[2],c=this._elevationProvider.getElevation(r,o,a,this._indexSR,n);c&&i.expandElevationRangeValues(c,c);const l=t?null:this._elevationProvider.getRootElevationBounds?.();l&&i.expandElevationRange(l)}getServiceMbsInRenderSR(e){const t=e.serviceMbsInRenderSR;if(w(t))return t;e.serviceMbsInIndexSR&&v(t,e.serviceMbsInIndexSR);const i=e.elevationRangeMin;if(this._elevationContext&&Number.isFinite(i)){let s=0,n=0;const r=e.elevationRangeMax;switch(this._elevationContext.mode){case"relative-to-ground":s=this._elevationContext.geometryZWithOffset(t[2],this._renderCoordsHelper)+i-t[2],n=r-i;break;case"on-the-ground":s=i-t[2],n=r-i}t[2]+=s+.5*n,t[3]+=.5*n}else this._elevationContext&&t[3]<T&&(this._tmpPoint.x=t[0],this._tmpPoint.y=t[1],this._tmpPoint.z=t[2],t[2]=V(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper));return b(t,this._indexSR,t,this._renderSR),t}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new U,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i[3];let r=0,o=0;const a=s.centerZ,c=this._renderCoordsHelper,l=this._elevationContext;if(l&&e.elevationRangeValid){const t=e.elevationRangeMin,i=e.elevationRangeMax;switch(l.mode){case"relative-to-ground":r=l.geometryZWithOffset(a,c)+t-a,o=i-t;break;case"on-the-ground":r=t-a,o=i-t}}else if(l&&n<T){const e=this._tmpPoint;e.x=s.centerX,e.y=s.centerY,e.z=a,r=V(e,this._elevationProvider,l,c)-a}const h=o>0,d=h?this._tmpObb:t;return s.transform(d,this._indexSR,this._renderSR,r,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),h&&z(d,0,o,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(X,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),X):null}ensureElevationAgnosticBoundingVolume(e,t){-1===e.elevationAgnosticBoundingVolume[3]&&(t===B.Global?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e))}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),o=t.elevationAgnosticBoundingVolume,a=Y;let c=-1;if(s){s.getCenter(a),e(a,a),s.getCorners(J);for(const t of J){e(t,t);const s=i(t,a);if(s<=0)return void(o[3]=-1);const n=Math.sqrt(1-s*s);c=Math.max(c,n)}}else{const i=t.serviceMbsInRenderSR;if(!w(i))return void(o[3]=-1);{const t=n(Y,D(i)),s=i[3],o=r(t);c=0===s?0:o<s?-1:s/o,e(t,t)}}g(o,a);const l=.001;o[3]=c+l}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(Y);e[2]=0,g(t,e);let s=0;const n=K;i.getCorners(J);for(const t of J){t[2]=0;const e=o(n,t);s=Math.max(s,e)}t[3]=Math.sqrt(s)}else{const i=e.serviceMbsInRenderSR;if(w(i)){const e=n(Y,D(i));e[2]=0,g(t,e),t[3]=i[3]}}}isNodeVisible(e){const t=this.getServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.isVisible(this._frustum):C(this._frustum,F(t))}isElevationAgnosticBoundingVolumeVisible(e,t){return!this._useFrustumCulling||(-1===t[3]||(e===B.Global?this._isConeVisibleInFrustum(t):this._isCylinderVisibleInFrustum(t)))}_isConeVisibleInFrustum(e){const t=this._frustumMbs,s=t,n=r(s),o=t[3],l=e,h=i(l,s),d=e[3];if(d>.9)return!0;if(n<=o)return!0;{const e=a(Z,l,h);if(c(e,s)<o)return!0}const u=h/n;if(h<=0){return-u<o}const m=Math.sqrt(1-u*u);if(m<d)return!0;const p=o/n;return m*Math.sqrt(1-p*p)-p*u<d}_isCylinderVisibleInFrustum(e){const t=this._frustumMbs,i=t,s=t[3],r=n(Z,i);r[2]=0;const o=e[3];return c(r,e)<=o+s}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.isVisible(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||G(this._clippingArea,e)!==N.OUTSIDE}_screenSpaceDiameterMbs(e,t){const i=this.getServiceMbsInRenderSR(e),s=Math.sqrt(l(D(i),this._camPos)),n=s-i[3];return this._updateMinMaxDistance(s),n<0?.5*Number.MAX_VALUE:t/n*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.getServiceMbsInRenderSR(e)[3]}calcCameraDistanceToCenter(e){const t=this.getServiceMbsInRenderSR(e),i=h(D(t),this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const t=this.getServiceMbsInRenderSR(e),i=t[3],s=(Math.abs(t[0]*(t[0]-this._camPos[0])+t[1]*(t[1]-this._camPos[1])+t[2]*(t[2]-this._camPos[2]))/d(D(t))+i)/h(D(t),this._camPos);return Math.min(1,s)}hasLOD(e){return e.lodMetric!==y.None}_getDistancePlanarMode(e,t){const i=e[0]-t[0],s=e[1]-t[1],n=e[2]-t[2],r=i*i+s*s,o=t[3];if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}_getDistanceGlobeMode(e,t){const s=d(D(t)),n=d(e)-s;a(this._tmp0,e,i(e,D(t))/u(e));const r=l(D(t),this._tmp0),o=t[3];if(r<=o*o)return Math.abs(n);{const r=a(this._tmp0,D(t),1/s),c=s,l=o*o/2/c,u=a(this._tmp1,r,c-l),_=e,v=m(this._tmp2,_,u),g=m(this._tmp2,v,a(this._tmp3,r,i(r,v))),f=p(this._tmp2,u,a(this._tmp2,g,o/d(g)));let S=h(_,f);if(n>=2e5){const e=m(this._tmp1,_,f);let t=i(e,r)/d(e);t<.08&&(t=1e-4),S/=t}return S}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):this._getDistancePlanarMode(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(e.lodMetric===y.None)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case y.ScreenSpaceRelative:{const i=this.getServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i[3];return this._updateMinMaxDistance(r),e.maxError*t<=n}case y.MaxScreenThreshold:{let i=this._screenSpaceDiameterMbs(e,e.serviceMbsInIndexSR[3]*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case y.RemovedFeatureDiameter:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case y.DistanceRangeFromDefaultCamera:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToPOI(e){const t=this.getServiceMbsInRenderSR(e);return h(D(t),this._poi)-t[3]}distCameraToPOI(){return h(this._camPos,this._poi)}}const k=_(),H=P(),W=_(),Z=_(),X=new U,Y=_(),J=[_(),_(),_(),_(),_(),_(),_(),_()],K=_();export{q as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{acosClamped as e}from"../../../../core/mathUtils.js";import t from"../../../../core/ObjectPool.js";import{f as s,h as r,g as i,n,z as o,k as u,r as c,s as a,o as l,b as d,F as _,D as h}from"../../../../chunks/vec32.js";import{create as f,fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{projectBuffer as T}from"../../../../geometry/projection/projectBuffer.js";import{projectVec3Array as F}from"../../../../geometry/projection/projectVec3Array.js";import{PlaneIndex as g,PointIndex as E}from"../../../../geometry/support/frustum.js";import{create as I,projectVector as R,fromPoints as A,getNormal as O,signedDistance as S}from"../../../../geometry/support/plane.js";import{wrap as b}from"../../../../geometry/support/ray.js";import{ViewingMode as P}from"../../../ViewingMode.js";import{FeatureTileDescriptor3D as B,Visibility as H}from"./FeatureTileDescriptor3D.js";import{Frustum as j}from"../../state/Frustum.js";import{FrustumExtentIntersection as x}from"../../support/FrustumExtentIntersection.js";class N{constructor(e){this._renderCoordsHelper=e,this._surfaceElevation=0,this._cache=new Map,this._frustumBoundingSphereCenter=f(),this._frustumBoundingSphereRadius=0,this._frustum=new j(e),this._extendedFrustum=new j(e),this._intersector=new x({renderCoordsHelper:e}),this._renderCoordsHelper=e}begin(e,t){this._surfaceElevation=t,this._aboveGround=this._renderCoordsHelper.getAltitude(e.eye)>t,this._frustum.update(e),this._shortenFrustumFarPlane(this._frustum),this._updateExtendedFrustum(e),this._updateFrustumBoundingSphere()}end(){this._cache.clear()}calculate(e){const t=this._renderCoordsHelper.viewingMode===P.Global&&e.lij[0]>=V&&e.lij[0]<G,s=this._getOrCalculateSingleTileVisibility(e,!t);return s!==H.INVISIBLE&&t?this._calculateAggregatedChildrenVisibility(e):s}_shortenFrustumFarPlane(e){const t=j.nearFarLineIndices,n=e.mutablePoints;for(const o of t){const[e,t]=o,u=n[e],c=n[t];s(v,c,u),r(v,v,C),i(n[t],u,v)}e.updatePoints(n)}_calculateAggregatedChildrenVisibility(e){let t=H.INVISIBLE;const s=this._cache.get(e.id);if(null!=s)return s;const r=U.acquire();e.getChildren(r);for(const i of r){const e=this.calculate(i);if(e!==H.INVISIBLE&&(t=e,e===H.VISIBLE_ON_SURFACE))break}return U.release(r),this._cache.set(e.id,t),t}_getOrCalculateSingleTileVisibility(e,t){const s=this._cache.get(e.id);if(null!=s)return s;const r=this._calculateSingleTileVisibility(e);return t&&this._cache.set(e.id,r),r}_calculateSingleTileVisibility(e){if(!this._aboveGround&&this._renderCoordsHelper.viewingMode===P.Global&&e.lij[0]<M){return this._calculateSingleTileVisibilitySided(e,!1)===H.INVISIBLE?this._calculateSingleTileVisibilitySided(e,!0):void 0}return this._calculateSingleTileVisibilitySided(e,this._aboveGround)}_isTileVisibleInFrustum(e){return this._renderCoordsHelper.viewingMode===P.Local?this._isTileVisibleInFrustumLocal(e):this._isTileVisibleInFrustumGlobal(e)}_updateFrustumBoundingSphere(){const e=this._frustum,t=e.origin,s=ce;n(s,e.direction);const r=e.points,i=ae;o(i,r[4],t);const a=.5*u(i,i)/u(s,i),l=this._frustumBoundingSphereCenter;c(l,t,s,a);const d=1+a;this._frustumBoundingSphereRadius=d}_isTileVisibleInFrustumLocal(e){const t=e.tilingScheme.spatialReference,s=e.extent,r=this._renderCoordsHelper.spatialReference,i=Q;if(i[0]=s[0],i[1]=s[1],i[2]=0,i[3]=s[2],i[4]=s[3],i[5]=0,!T(i,t,0,i,r,0,2))return!1;const n=Z;a(n[0],i[0],i[1],0),a(n[1],i[3],i[1],0),a(n[2],i[3],i[4],0),a(n[3],i[0],i[4],0);const d=$;a(d,.5*(i[0]+i[3]),.5*(i[1]+i[4]),.5*(i[2]+i[5]));const _=ee;a(_,0,0,1);const h=.5*l(n[0],n[2]),f=this._frustum,m=this._frustumBoundingSphereRadius,p=this._frustumBoundingSphereCenter,F=de;o(F,p,d);const g=u(_,F),E=le;c(E,d,_,g);if(l(E,p)>h+m)return!1;const I=K,R=g+m,A=g-m;for(let o=0;o<4;++o)c(I[o],n[o],_,R),c(I[o+4],n[o],_,A);return!X(f.planes,I,8)}_isTileVisibleInFrustumGlobal(e){const t=e.tilingScheme.spatialReference,s=e.extent,_=this._renderCoordsHelper.spatialReference;if(e.lij[0]<Y)return!0;const h=Z,f=.5*(s[0]+s[2]);if(a(h[0],s[0],s[1],0),a(h[1],s[2],s[1],0),a(h[2],s[2],s[3],0),a(h[3],s[0],s[3],0),a(h[4],f,s[1],0),a(h[5],f,s[3],0),!F(h,t,0,h,_,0,6))return!1;const T=h[0][2]>0,g=h[3][2]<0,E=T||g,I=p(_).radius;if(E){const e=m(0,0,1),t=se;D(t,e,h[0]);const s=re;if(D(s,e,h[1]),T){const r=te,i=h[4],n=ie;D(n,i,e),D(r,n,i);const o=h[0];d(o,t,r),k(o,I);const u=h[1];d(u,s,r),k(u,I)}else if(g){const r=te,i=h[5],n=ie;D(n,i,e),D(r,i,n);const o=h[3];d(o,r,t),k(o,I);const u=h[2];d(u,r,s),k(u,I)}}const R=$;{const e=pe;o(e,h[3],h[0]),n(e,e);const t=Te;i(t,h[0],h[3]),r(t,t,.5);const s=-u(t,e),a=Fe,l=ge;i(a,h[0],h[1]),r(a,a,.5),i(l,h[2],h[3]),r(l,l,.5);const d=Ee;o(d,l,a),n(d,d);const _=-(s+u(e,a))/u(e,d);c(R,a,d,_),k(R,I)}const A=this._frustumBoundingSphereRadius,O=this._frustumBoundingSphereCenter,S=this._frustum,b=S.planes;if(h.some((e=>S.intersectsPoint(e))))return!0;if(S.intersectsPoint(R))return!0;const P=ne;n(P,R);const B=he;o(B,O,_e);const H=u(B,P);if(H<-A)return!1;const j=ue;n(j,h[0]);const x=u(j,P);if(x<=0)return!0;const N=oe;r(N,P,H);const V=l(N,O),G=t.isWGS84,M=e.lij,C=G&&M[2]===2**M[0]-1,L=G&&0===M[2],v=L?je:C?Be:be,y=L?xe:C?He:Pe,w=S.points;{const e=h,t=Ne,s=Ie,r=Re,i=_e;for(const n of v){const o=e[n];if(W(s,e[(n+1)%4],o),W(r,i,o),D(t,r,s),J(t,w,1))return!1}}let U=null;if(H<2*A){const e=2.5*A;if(V>x*e+A)return!1;const t=me,s=e/x;for(let i=0;i<4;++i)r(t[i],h[i],s/I);a(t[4],0,0,0),U=t}else{const e=(H+A)/x,t=(H-A)/x,s=fe;for(let i=0;i<4;++i){const n=h[i];r(s[i+4],n,t/I),r(s[i],n,e/I)}U=s}if(X(b,U,U.length))return!1;const z=S.lines,q=Ae,K=Oe;for(const r of y){n(q,h[r]);for(const e of z)if(n(K,e.direction),Ce(K,q,U,w))return!1}return!0}_calculateSingleTileVisibilitySided(e,t){if(this._isTileVisibleInFrustum(e)){this._intersector.update(e.extent,e.tilingScheme.spatialReference,this._surfaceElevation,t);const s=p(e.tilingScheme.spatialReference).radius;return this._intersector.isVisibleInFrustum(this._frustum,s,!0)?H.VISIBLE_ON_SURFACE:H.VISIBLE_WHEN_EXTENDED}return H.INVISIBLE}_updateExtendedFrustum(t){this._extendedFrustum.update(t),this._shortenFrustumFarPlane(this._extendedFrustum);const s=this._renderCoordsHelper.worldUpAtPosition(t.eye,v);this._aboveGround||_(s,s);const i=e(-u(s,t.viewForward));if(this._hasExtendedFrustum=i>t.fovY/2,!this._hasExtendedFrustum)return;const n=this._extendedFrustumParameters(),o=this._extendedFrustum.mutablePoints;for(let e=0;e<4;e++){const t=n.pointIndices[e],s=o[t],i=this._renderCoordsHelper.getAltitude(s);if(n.needsAltitudeAdjustment(i)){switch(this._renderCoordsHelper.worldUpAtPosition(s,v),t){case E.FAR_BOTTOM_LEFT:case E.FAR_TOP_LEFT:case E.NEAR_BOTTOM_LEFT:case E.NEAR_TOP_LEFT:R(this._extendedFrustum.planes[g.LEFT],v,v);break;case E.FAR_BOTTOM_RIGHT:case E.FAR_TOP_RIGHT:case E.NEAR_BOTTOM_RIGHT:case E.NEAR_TOP_RIGHT:R(this._extendedFrustum.planes[g.RIGHT],v,v)}r(v,v,n.direction),this._renderCoordsHelper.intersectInfiniteManifold(b(s,v),n.zWithMargin,s)}}if(this._extendedFrustum.updatePoints(o),A(o[E.NEAR_BOTTOM_LEFT],o[E.NEAR_BOTTOM_RIGHT],o[E.NEAR_TOP_RIGHT],y),A(o[E.NEAR_BOTTOM_RIGHT],o[E.NEAR_TOP_RIGHT],o[E.NEAR_TOP_LEFT],w),u(O(y),O(w))<0){const e=this._extendedFrustum.mutablePoints;this._aboveGround?[e[E.NEAR_BOTTOM_LEFT],e[E.NEAR_BOTTOM_RIGHT]]=[e[E.NEAR_BOTTOM_RIGHT],e[E.NEAR_BOTTOM_LEFT]]:[e[E.NEAR_TOP_LEFT],e[E.NEAR_TOP_RIGHT]]=[e[E.NEAR_TOP_RIGHT],e[E.NEAR_TOP_LEFT]],this._extendedFrustum.updatePoints(e)}}_extendedFrustumParameters(){return this._aboveGround?this._extendedFrustumParametersAboveSurface():this._extendedFrustumParametersBelowSurface()}_extendedFrustumParametersAboveSurface(){const e=this._surfaceElevation-L;return{zWithMargin:e,pointIndices:j.planePointIndices.bottom,direction:-1,needsAltitudeAdjustment:t=>t>e}}_extendedFrustumParametersBelowSurface(){const e=this._surfaceElevation+L;return{zWithMargin:e,pointIndices:j.planePointIndices.top,direction:1,needsAltitudeAdjustment:t=>t<e}}}const V=2,G=6,M=12,C=.95,L=1,v=f(),y=I(),w=I(),U=new t(Array,(e=>{4!==e.length&&(e[0]=new B,e[1]=new B,e[2]=new B,e[3]=new B)}),(e=>{e[0].release(),e[1].release(),e[2].release(),e[3].release()}));function D(e,t,s){return d(e,t,s),n(e,e),e}function W(e,t,s){return o(e,t,s),n(e,e),e}function k(e,t){return r(e,e,t/h(e)),e}const z=[g.LEFT,g.RIGHT,g.BOTTOM,g.TOP,g.FAR];function q(e,t,s){for(let r=0;r<s;++r)if(S(e,t[r])<0)return!1;return!0}function X(e,t,s){for(const r of z)if(q(e[r],t,s))return!0;return!1}const Y=3;function J(e,t,s){for(const r of t)if(u(r,e)<s)return!1;return!0}const K=[f(),f(),f(),f(),f(),f(),f(),f()],Q=[0,0,0,0,0,0],Z=[f(),f(),f(),f(),f(),f()],$=f(),ee=f(),te=f(),se=f(),re=f(),ie=f(),ne=f(),oe=f(),ue=f(),ce=f(),ae=f(),le=f(),de=f(),_e=m(0,0,0),he=f(),fe=[f(),f(),f(),f(),f(),f(),f(),f()],me=[f(),f(),f(),f(),f()],pe=f(),Te=f(),Fe=f(),ge=f(),Ee=f(),Ie=f(),Re=f(),Ae=f(),Oe=f(),Se=f(),be=[0,1,2,3],Pe=[0,1,2,3],Be=[0,1,3],He=[0,1,3],je=[1,2,3],xe=[1,2,3],Ne=f();function Ve(e,t,s){let r=1/0,i=-1/0;for(const n of s){const e=u(t,n);r=Math.min(r,e),i=Math.max(i,e)}e[0]=r,e[1]=i}function Ge(e,t,s,r){let i=1/0,n=-1/0;for(const o of r){const r=u(s,o);if(i=Math.min(i,r),n=Math.max(n,r),i<=t&&n>=e)return!1}return!0}const Me=[0,0];function Ce(e,t,s,r){const i=Se;D(i,e,t);const n=Me;return Ve(n,i,s),Ge(n[0],n[1],i,r)}export{N as FeatureTileVisibility3D,Y as globalTileLevelThreshold,X as isConvexHullOutsideOfFrustum};
5
+ import{acosClamped as e}from"../../../../core/mathUtils.js";import t from"../../../../core/ObjectPool.js";import{f as s,h as r,g as i,n,z as o,k as u,r as c,s as a,o as l,b as d,F as _,H as h}from"../../../../chunks/vec32.js";import{create as f,fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{projectBuffer as T}from"../../../../geometry/projection/projectBuffer.js";import{projectVec3Array as F}from"../../../../geometry/projection/projectVec3Array.js";import{PlaneIndex as g,PointIndex as E}from"../../../../geometry/support/frustum.js";import{create as I,projectVector as R,fromPoints as A,getNormal as O,signedDistance as S}from"../../../../geometry/support/plane.js";import{wrap as b}from"../../../../geometry/support/ray.js";import{ViewingMode as P}from"../../../ViewingMode.js";import{FeatureTileDescriptor3D as B,Visibility as H}from"./FeatureTileDescriptor3D.js";import{Frustum as j}from"../../state/Frustum.js";import{FrustumExtentIntersection as x}from"../../support/FrustumExtentIntersection.js";class N{constructor(e){this._renderCoordsHelper=e,this._surfaceElevation=0,this._cache=new Map,this._frustumBoundingSphereCenter=f(),this._frustumBoundingSphereRadius=0,this._frustum=new j(e),this._extendedFrustum=new j(e),this._intersector=new x({renderCoordsHelper:e}),this._renderCoordsHelper=e}begin(e,t){this._surfaceElevation=t,this._aboveGround=this._renderCoordsHelper.getAltitude(e.eye)>t,this._frustum.update(e),this._shortenFrustumFarPlane(this._frustum),this._updateExtendedFrustum(e),this._updateFrustumBoundingSphere()}end(){this._cache.clear()}calculate(e){const t=this._renderCoordsHelper.viewingMode===P.Global&&e.lij[0]>=V&&e.lij[0]<G,s=this._getOrCalculateSingleTileVisibility(e,!t);return s!==H.INVISIBLE&&t?this._calculateAggregatedChildrenVisibility(e):s}_shortenFrustumFarPlane(e){const t=j.nearFarLineIndices,n=e.mutablePoints;for(const o of t){const[e,t]=o,u=n[e],c=n[t];s(v,c,u),r(v,v,C),i(n[t],u,v)}e.updatePoints(n)}_calculateAggregatedChildrenVisibility(e){let t=H.INVISIBLE;const s=this._cache.get(e.id);if(null!=s)return s;const r=U.acquire();e.getChildren(r);for(const i of r){const e=this.calculate(i);if(e!==H.INVISIBLE&&(t=e,e===H.VISIBLE_ON_SURFACE))break}return U.release(r),this._cache.set(e.id,t),t}_getOrCalculateSingleTileVisibility(e,t){const s=this._cache.get(e.id);if(null!=s)return s;const r=this._calculateSingleTileVisibility(e);return t&&this._cache.set(e.id,r),r}_calculateSingleTileVisibility(e){if(!this._aboveGround&&this._renderCoordsHelper.viewingMode===P.Global&&e.lij[0]<M){return this._calculateSingleTileVisibilitySided(e,!1)===H.INVISIBLE?this._calculateSingleTileVisibilitySided(e,!0):void 0}return this._calculateSingleTileVisibilitySided(e,this._aboveGround)}_isTileVisibleInFrustum(e){return this._renderCoordsHelper.viewingMode===P.Local?this._isTileVisibleInFrustumLocal(e):this._isTileVisibleInFrustumGlobal(e)}_updateFrustumBoundingSphere(){const e=this._frustum,t=e.origin,s=ce;n(s,e.direction);const r=e.points,i=ae;o(i,r[4],t);const a=.5*u(i,i)/u(s,i),l=this._frustumBoundingSphereCenter;c(l,t,s,a);const d=1+a;this._frustumBoundingSphereRadius=d}_isTileVisibleInFrustumLocal(e){const t=e.tilingScheme.spatialReference,s=e.extent,r=this._renderCoordsHelper.spatialReference,i=Q;if(i[0]=s[0],i[1]=s[1],i[2]=0,i[3]=s[2],i[4]=s[3],i[5]=0,!T(i,t,0,i,r,0,2))return!1;const n=Z;a(n[0],i[0],i[1],0),a(n[1],i[3],i[1],0),a(n[2],i[3],i[4],0),a(n[3],i[0],i[4],0);const d=$;a(d,.5*(i[0]+i[3]),.5*(i[1]+i[4]),.5*(i[2]+i[5]));const _=ee;a(_,0,0,1);const h=.5*l(n[0],n[2]),f=this._frustum,m=this._frustumBoundingSphereRadius,p=this._frustumBoundingSphereCenter,F=de;o(F,p,d);const g=u(_,F),E=le;c(E,d,_,g);if(l(E,p)>h+m)return!1;const I=K,R=g+m,A=g-m;for(let o=0;o<4;++o)c(I[o],n[o],_,R),c(I[o+4],n[o],_,A);return!X(f.planes,I,8)}_isTileVisibleInFrustumGlobal(e){const t=e.tilingScheme.spatialReference,s=e.extent,_=this._renderCoordsHelper.spatialReference;if(e.lij[0]<Y)return!0;const h=Z,f=.5*(s[0]+s[2]);if(a(h[0],s[0],s[1],0),a(h[1],s[2],s[1],0),a(h[2],s[2],s[3],0),a(h[3],s[0],s[3],0),a(h[4],f,s[1],0),a(h[5],f,s[3],0),!F(h,t,0,h,_,0,6))return!1;const T=h[0][2]>0,g=h[3][2]<0,E=T||g,I=p(_).radius;if(E){const e=m(0,0,1),t=se;W(t,e,h[0]);const s=re;if(W(s,e,h[1]),T){const r=te,i=h[4],n=ie;W(n,i,e),W(r,n,i);const o=h[0];d(o,t,r),z(o,I);const u=h[1];d(u,s,r),z(u,I)}else if(g){const r=te,i=h[5],n=ie;W(n,i,e),W(r,i,n);const o=h[3];d(o,r,t),z(o,I);const u=h[2];d(u,r,s),z(u,I)}}const R=$;{const e=pe;o(e,h[3],h[0]),n(e,e);const t=Te;i(t,h[0],h[3]),r(t,t,.5);const s=-u(t,e),a=Fe,l=ge;i(a,h[0],h[1]),r(a,a,.5),i(l,h[2],h[3]),r(l,l,.5);const d=Ee;o(d,l,a),n(d,d);const _=-(s+u(e,a))/u(e,d);c(R,a,d,_),z(R,I)}const A=this._frustumBoundingSphereRadius,O=this._frustumBoundingSphereCenter,S=this._frustum,b=S.planes;if(h.some((e=>S.intersectsPoint(e))))return!0;if(S.intersectsPoint(R))return!0;const P=ne;n(P,R);const B=he;o(B,O,_e);const H=u(B,P);if(H<-A)return!1;const j=ue;n(j,h[0]);const x=u(j,P);if(x<=0)return!0;const N=oe;r(N,P,H);const V=l(N,O),G=t.isWGS84,M=e.lij,C=G&&M[2]===2**M[0]-1,L=G&&0===M[2],v=L?je:C?Be:be,y=L?xe:C?He:Pe,w=S.points;{const e=h,t=Ne,s=Ie,r=Re,i=_e;for(const n of v){const o=e[n];if(k(s,e[(n+1)%4],o),k(r,i,o),W(t,r,s),J(t,w,1))return!1}}let U=null;if(H<2*A){const e=2.5*A;if(V>x*e+A)return!1;const t=me,s=e/x;for(let i=0;i<4;++i)r(t[i],h[i],s/I);a(t[4],0,0,0),U=t}else{const e=(H+A)/x,t=(H-A)/x,s=fe;for(let i=0;i<4;++i){const n=h[i];r(s[i+4],n,t/I),r(s[i],n,e/I)}U=s}if(X(b,U,U.length))return!1;const D=S.lines,q=Ae,K=Oe;for(const r of y){n(q,h[r]);for(const e of D)if(n(K,e.direction),Ce(K,q,U,w))return!1}return!0}_calculateSingleTileVisibilitySided(e,t){if(this._isTileVisibleInFrustum(e)){this._intersector.update(e.extent,e.tilingScheme.spatialReference,this._surfaceElevation,t);const s=p(e.tilingScheme.spatialReference).radius;return this._intersector.isVisibleInFrustum(this._frustum,s,!0)?H.VISIBLE_ON_SURFACE:H.VISIBLE_WHEN_EXTENDED}return H.INVISIBLE}_updateExtendedFrustum(t){this._extendedFrustum.update(t),this._shortenFrustumFarPlane(this._extendedFrustum);const s=this._renderCoordsHelper.worldUpAtPosition(t.eye,v);this._aboveGround||_(s,s);const i=e(-u(s,t.viewForward));if(this._hasExtendedFrustum=i>t.fovY/2,!this._hasExtendedFrustum)return;const n=this._extendedFrustumParameters(),o=this._extendedFrustum.mutablePoints;for(let e=0;e<4;e++){const t=n.pointIndices[e],s=o[t],i=this._renderCoordsHelper.getAltitude(s);if(n.needsAltitudeAdjustment(i)){switch(this._renderCoordsHelper.worldUpAtPosition(s,v),t){case E.FAR_BOTTOM_LEFT:case E.FAR_TOP_LEFT:case E.NEAR_BOTTOM_LEFT:case E.NEAR_TOP_LEFT:R(this._extendedFrustum.planes[g.LEFT],v,v);break;case E.FAR_BOTTOM_RIGHT:case E.FAR_TOP_RIGHT:case E.NEAR_BOTTOM_RIGHT:case E.NEAR_TOP_RIGHT:R(this._extendedFrustum.planes[g.RIGHT],v,v)}r(v,v,n.direction),this._renderCoordsHelper.intersectInfiniteManifold(b(s,v),n.zWithMargin,s)}}if(this._extendedFrustum.updatePoints(o),A(o[E.NEAR_BOTTOM_LEFT],o[E.NEAR_BOTTOM_RIGHT],o[E.NEAR_TOP_RIGHT],y),A(o[E.NEAR_BOTTOM_RIGHT],o[E.NEAR_TOP_RIGHT],o[E.NEAR_TOP_LEFT],w),u(O(y),O(w))<0){const e=this._extendedFrustum.mutablePoints;this._aboveGround?[e[E.NEAR_BOTTOM_LEFT],e[E.NEAR_BOTTOM_RIGHT]]=[e[E.NEAR_BOTTOM_RIGHT],e[E.NEAR_BOTTOM_LEFT]]:[e[E.NEAR_TOP_LEFT],e[E.NEAR_TOP_RIGHT]]=[e[E.NEAR_TOP_RIGHT],e[E.NEAR_TOP_LEFT]],this._extendedFrustum.updatePoints(e)}}_extendedFrustumParameters(){return this._aboveGround?this._extendedFrustumParametersAboveSurface():this._extendedFrustumParametersBelowSurface()}_extendedFrustumParametersAboveSurface(){const e=this._surfaceElevation-L;return{zWithMargin:e,pointIndices:j.planePointIndices.bottom,direction:-1,needsAltitudeAdjustment:t=>t>e}}_extendedFrustumParametersBelowSurface(){const e=this._surfaceElevation+L;return{zWithMargin:e,pointIndices:j.planePointIndices.top,direction:1,needsAltitudeAdjustment:t=>t<e}}}const V=2,G=6,M=12,C=.95,L=1,v=f(),y=I(),w=I(),U=new t(Array,(e=>{4!==e.length&&(e[0]=new B,e[1]=new B,e[2]=new B,e[3]=new B)}),(e=>{e[0].release(),e[1].release(),e[2].release(),e[3].release()}));function W(e,t,s){return d(e,t,s),n(e,e),e}function k(e,t,s){return o(e,t,s),n(e,e),e}function z(e,t){return r(e,e,t/h(e)),e}const D=[g.LEFT,g.RIGHT,g.BOTTOM,g.TOP,g.FAR];function q(e,t,s){for(let r=0;r<s;++r)if(S(e,t[r])<0)return!1;return!0}function X(e,t,s){for(const r of D)if(q(e[r],t,s))return!0;return!1}const Y=3;function J(e,t,s){for(const r of t)if(u(r,e)<s)return!1;return!0}const K=[f(),f(),f(),f(),f(),f(),f(),f()],Q=[0,0,0,0,0,0],Z=[f(),f(),f(),f(),f(),f()],$=f(),ee=f(),te=f(),se=f(),re=f(),ie=f(),ne=f(),oe=f(),ue=f(),ce=f(),ae=f(),le=f(),de=f(),_e=m(0,0,0),he=f(),fe=[f(),f(),f(),f(),f(),f(),f(),f()],me=[f(),f(),f(),f(),f()],pe=f(),Te=f(),Fe=f(),ge=f(),Ee=f(),Ie=f(),Re=f(),Ae=f(),Oe=f(),Se=f(),be=[0,1,2,3],Pe=[0,1,2,3],Be=[0,1,3],He=[0,1,3],je=[1,2,3],xe=[1,2,3],Ne=f();function Ve(e,t,s){let r=1/0,i=-1/0;for(const n of s){const e=u(t,n);r=Math.min(r,e),i=Math.max(i,e)}e[0]=r,e[1]=i}function Ge(e,t,s,r){let i=1/0,n=-1/0;for(const o of r){const r=u(s,o);if(i=Math.min(i,r),n=Math.max(n,r),i<=t&&n>=e)return!1}return!0}const Me=[0,0];function Ce(e,t,s,r){const i=Se;W(i,e,t);const n=Me;return Ve(n,i,s),Ge(n[0],n[1],i,r)}export{N as FeatureTileVisibility3D,Y as globalTileLevelThreshold,X as isConvexHullOutsideOfFrustum};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
+ */
5
+ function e(e){return r=>{if(e.immediate)return e.immediate.schedule(r);const o="No immediate scheduler";throw console.error(o),new Error(o)}}export{e as makeScheduleFunction};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import{neverReached as e}from"../../../../core/compilerUtils.js";import{clamp as i,acosClamped as a,deg2rad as r}from"../../../../core/mathUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{translate as n,rotate as c,identity as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as p,e as h,g as d,h as u,c as _,F as f,l as v,s as C,n as g,b as y,q as w,E as O,k as b}from"../../../../chunks/vec32.js";import{create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as x}from"../../../../geometry/ellipsoidUtils.js";import{wrap as j}from"../../../../geometry/support/ray.js";import{j as L,k as M,t as T}from"../../../../chunks/sphere.js";import{angle as A}from"../../../../geometry/support/vector.js";import{sv3d as E}from"../../../../geometry/support/vectorStacks.js";import{applyAll as z}from"../../camera/constraintUtils.js";import{ConstraintOptions as I}from"../../camera/constraintUtils/ConstraintOptions.js";import{ConstraintTypes as U}from"../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as D}from"../../camera/constraintUtils/InteractionType.js";import{TiltMode as R}from"../../camera/constraintUtils/TiltMode.js";import{TiltRange as k}from"../Constraints.js";import{InteractiveController as H}from"./InteractiveController.js";import{panMotionToRotationMatrix as N,onSurfaceTiltToEyeTiltGlobal as P,offSurfaceTiltToEyeTiltGlobal as F}from"../utils/navigationUtils.js";import{viewAngle as G}from"../utils/viewUtils.js";import{headingTiltToDirectionUp as V}from"../../support/cameraUtils.js";import{createDirectionUp as B}from"../../support/cameraUtilsInternal.js";import{Camera as K}from"../../webgl-engine/lib/Camera.js";import{extractTransformation as X,isZeroTransformation as q,extractTransformationKeyboard as Z}from"../../../navigation/gamepadAndKeyboardUtils.js";let J=class extends H{constructor(t){super(t),this._filteredSurfaceElevation=0,this._transformation={translation:[0,0,0],heading:0,tilt:0,zoom:0},this._keysButtonState=[0,0,0,0,0,0,0,0,0,0,0,0],this._tmpCamera=new K,this._headingStart=0,this._constraintOptions=new I(U.ALL,D.NONE,0,new K,null,R.LOOK_AROUND)}handleEventGamepad(t){const e=X(t,this.view.navigation.gamepad,this._transformation);("end"===t.action||q(e))&&this.finishController()}activateDirection(t){this._keysButtonState[t]=1,Z(this._keysButtonState,this._transformation)}deactivateDirection(t){this._keysButtonState[t]=0;const e=Z(this._keysButtonState,this._transformation);q(e)&&this.finishController()}onControllerStart(t){this._filteredSurfaceElevation=this.view.pointsOfInterest.cameraOnSurface.location.z,this._headingStart=this.view.camera.heading,super.onControllerStart(t)}_updateFilteredSurfaceElevation(t){const e=this.view.pointsOfInterest.cameraOnSurface.location.z,i=1;this._filteredSurfaceElevation+=i*(e-this._filteredSurfaceElevation)*t}stepController(t,e){this._updateStartHeading(),this._updateFilteredSurfaceElevation(t),this.currentCamera.copyViewFrom(e),this._updateCameraCenter(),this._constraintOptions.interactionStartCamera?.copyFrom(this.currentCamera),this._calculateControlTransformation(t,this.currentCamera,at),this._applyDisabledMovementTypes(at),this._applyPan(at.pan),this._applyRotate(at.rotate),this._applyZoom(at.zoom),this._applyAscend(at.ascend),this._constraintOptions.interactionType=D.NONE,this._constraintOptions.selection=U.COLLISION,z(this.view,this.currentCamera,this._constraintOptions),super.stepController(t,e)}_updateStartHeading(){0!==this._transformation.heading&&(this._headingStart=this.view.camera.heading)}_applyRotate(t){if(!t.enabled)return;const e=this.currentCamera;p(rt,e.center,e.eye),h(rt,rt,t.matrix),e.center=d(rt,rt,e.eye),e.up=h(rt,e.up,t.matrix),this._constraintOptions.interactionType=D.LOOK_AROUND,this._constraintOptions.selection=U.ALL_EXCEPT_COLLISION,z(this.view,e,this._constraintOptions)}_applyPan(t,e=this.currentCamera){if(!t.enabled)return;e.eye=h(rt,e.eye,t.matrix),e.center=h(rt,e.center,t.matrix);this.view.state.isGlobal&&(e.up=h(rt,e.up,t.matrix)),this._constraintOptions.interactionType=D.PAN,this._constraintOptions.selection=U.ALL,z(this.view,e,this._constraintOptions)}_applyZoom(t){if(!t)return;const e=this.currentCamera.viewForward;this.currentCamera.eye=d(rt,this.currentCamera.eye,u(E.get(),e,t)),_(ot,e),f(ot,ot),this._constraintOptions.interactionDirection=ot,this._constraintOptions.interactionType=D.ZOOM,this._constraintOptions.selection=U.ALL_EXCEPT_COLLISION,z(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null}_applyAscend(t){if(!t)return;const e=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,E.get());this._constraintOptions.interactionDirection=_(ot,e);if(this.view.state.isGlobal){const e=v(this.currentCamera.eye),i=(e+t)/e;this.currentCamera.eye=u(rt,this.currentCamera.eye,i),this.currentCamera.center=u(rt,this.currentCamera.center,i)}else{const i=u(E.get(),e,t);this.currentCamera.eye=d(rt,this.currentCamera.eye,i),this.currentCamera.center=d(rt,this.currentCamera.center,i)}this._updateCameraCenter(),this._constraintOptions.interactionType=D.ASCEND,this._constraintOptions.selection=U.COLLISION,z(this.view,this.currentCamera,this._constraintOptions)&&this._updateCameraCenter(),this._constraintOptions.selection=U.ALL_EXCEPT_COLLISION,z(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null}_calculateControlTransformation(t,e,i){nt(i);const a=this._computeVelocities(t);this.view.state.isLocal?this._calculateControlTransformationLocal(a,e,i):this._calculateControlTransformationGlobal(a,e,i)}_updateCameraCenter(){const t=this.view.pointsOfInterest.centerOnSurfaceFrequent.estimatedSurfaceAltitude,e=this.view.renderCoordsHelper,i=this.currentCamera.ray;this.currentCamera.center=e.intersectManifoldClosestSilhouette(i,t,rt)}_calculateControlTransformationLocal(t,a,r){const{viewRight:o,viewForward:s}=a,m=this._transformation,l=this.view.navigation.gamepad,p=C(E.get(),s[0],s[1],0);g(p,p);const h=m.translation[0]*t.pan;if(0!==h){const t=u(E.get(),o,h);n(r.pan.matrix,r.pan.matrix,t),r.pan.enabled=!0}switch(l.mode){case"pan":{const e=-m.translation[1]*t.pan;if(0!==e){const t=u(E.get(),p,e);n(r.pan.matrix,r.pan.matrix,t),r.pan.enabled=!0}r.zoom=m.zoom*t.zoom;break}case"zoom":r.zoom=(-m.translation[1]+m.zoom)*t.zoom;break;default:e(l.mode)}const d=m.translation[2]*t.ascend;r.ascend=d;const _=-m.heading*t.rotate;0!==_&&(c(r.rotate.matrix,r.rotate.matrix,_,this.view.renderCoordsHelper.worldUpAtPosition(a.eye,E.get())),r.rotate.enabled=!0);const f=m.tilt*t.rotate,v=G(this.view.renderCoordsHelper,a.center,a.eye),y=i(v+f,k.min,k.max)-v;y&&(c(r.rotate.matrix,r.rotate.matrix,y,o),r.rotate.enabled=!0)}_calculateControlTransformationGlobal(t,e,i){const{eye:a,viewRight:r}=e,o=this._transformation,s=this.view.navigation.gamepad,n=y(E.get(),r,a);g(n,n),f(n,n),N(this.startCamera,e,o,t,this.view.camera.heading,this._headingStart,this.view.camera.tilt,i,s),this._tmpCamera.copyFrom(this.currentCamera),this._applyPan(at.pan,this._tmpCamera);const m=this.view.pointsOfInterest.centerOnSurfaceFrequent.estimatedSurfaceAltitude,l=o.translation[2]*t.ascend;i.ascend=l;const p=-o.heading*t.rotate;0!==p&&(c(i.rotate.matrix,i.rotate.matrix,p,this._tmpCamera.eye),i.rotate.enabled=!0);const h=o.tilt*t.rotate,d=this._clampTiltDeltaGlobalToValidRange(h,e.ray,m);0!==d&&(c(i.rotate.matrix,i.rotate.matrix,d,this._tmpCamera.viewRight),i.rotate.enabled=!0),i.zoom+=o.zoom*t.zoom}_clampTiltDeltaGlobalToValidRange(t,e,a){const r=x(this.view.spatialReference),o=P(k.min,e.origin,a,r);let s=0,n=0;const c=E.get();if(this.view.renderCoordsHelper.intersectManifold(e,a,c)){const t=G(this.view.renderCoordsHelper,c,e.origin);s=P(t,e.origin,a,r),n=P(k.max,e.origin,a,r)}else{L(M(T,a+r.radius),e,c);const t=Math.PI+A(e.direction,c);s=F(t,e.origin,a,r),n=F(k.max,e.origin,a,r)}return i(s+t,o,n)-s}_getPointAbsoluteSurfaceElevation(t,e,i){const{renderCoordsHelper:a}=this.view,r=a.getAltitude(t),o=e+Math.abs(r-e);return a.setAltitude(i,o,t),o}_clampedDistanceToSurface(t,e){const{renderCoordsHelper:i}=this.view,{camera:a}=this.view.state,{direction:r}=V(this.view,e,0,W,st),o=i.intersectManifoldClosestSilhouette(j(e,r),t,E.get()),s=w(e,o),n=i.intersectManifoldClosestSilhouette(j(e,O(E.get(),e,a.center)),t,E.get()),c=w(e,n);return Math.min(s,c)}_computeHeadingRotateRadius(t){const{renderCoordsHelper:e,state:i}=this.view,{camera:r,isGlobal:o}=i,s=e.intersectManifoldClosestSilhouette(r.ray,this._filteredSurfaceElevation,E.get());if(o){const e=p(E.get(),t,s),i=v(e);u(e,e,1/i);const r=g(E.get(),t),o=a(b(r,e));return i*Math.sin(Math.min(Y,o))}{const i=_(E.get(),t);return e.setAltitude(i,this._filteredSurfaceElevation),w(s,i)}}_minimumAscendVelocity(){return this.view.state.constraints.collision.enabled?0:tt}_computeVelocities(t){const e=this._filteredSurfaceElevation,a=e+x(this.view.spatialReference).radius,{camera:r,isGlobal:o}=this.view.state,s=E.get(),n=this._getPointAbsoluteSurfaceElevation(r.eye,e,s),c=this._clampedDistanceToSurface(e,s),m=r.width/2,l=$*r.width,p=$*r.width,h=c*Math.tan(.5*r.fovX)/m,d=h/a,u=h/this._computeHeadingRotateRadius(s),_=n-e;return{pan:(o?d:h)*l*t,ascend:Math.max(this._minimumAscendVelocity()*t,2**(l*t/m)*_-_),zoom:2**(l*t/m)*c-c,rotate:i(u*p,et,it)*t}}_applyDisabledMovementTypes(t){null==this.disableMovements||void 0!==this.disableMovements.mode&&this.view.state.viewingMode!==this.disableMovements.mode||(t.zoom=this.disableMovements.zoom?0:t.zoom,t.ascend=this.disableMovements.ascend?0:t.ascend,t.pan.enabled=!this.disableMovements.pan,this.disableMovements.pan&&m(t.pan.matrix),t.rotate.enabled=!this.disableMovements.rotate,this.disableMovements.rotate&&m(t.rotate.matrix))}static activatesFor(t,e){const i=X(e,t.navigation.gamepad,Q);return!("end"===e.action||q(i))}};t([o({constructOnly:!0})],J.prototype,"gamepadDevice",void 0),t([o({constructOnly:!0})],J.prototype,"disableMovements",void 0),J=t([s("esri.views.3d.state.controllers.GamepadKeyboardController")],J);const Q={translation:[0,0,0],heading:0,tilt:0,zoom:0},W=80,Y=r(W),$=.75,tt=5,et=r(30),it=r(80),at={zoom:0,ascend:0,pan:{enabled:!1,matrix:l()},rotate:{enabled:!1,matrix:l()}},rt=S(),ot=S(),st=B();function nt(t){t.zoom=0,t.ascend=0,t.pan.enabled=!1,m(t.pan.matrix),t.rotate.enabled=!1,m(t.rotate.matrix)}export{J as GamepadKeyboardController};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import{neverReached as e}from"../../../../core/compilerUtils.js";import{clamp as i,acosClamped as a,deg2rad as r}from"../../../../core/mathUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{translate as n,rotate as c,identity as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as h,e as p,g as d,h as u,c as _,F as f,l as v,s as C,n as g,b as y,q as w,E as O,k as b}from"../../../../chunks/vec32.js";import{create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as x}from"../../../../geometry/ellipsoidUtils.js";import{wrap as j}from"../../../../geometry/support/ray.js";import{e as L,h as M,t as T}from"../../../../chunks/sphere.js";import{angle as A}from"../../../../geometry/support/vector.js";import{sv3d as E}from"../../../../geometry/support/vectorStacks.js";import{applyAll as z}from"../../camera/constraintUtils.js";import{ConstraintOptions as I}from"../../camera/constraintUtils/ConstraintOptions.js";import{ConstraintTypes as U}from"../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as D}from"../../camera/constraintUtils/InteractionType.js";import{TiltMode as R}from"../../camera/constraintUtils/TiltMode.js";import{TiltRange as H}from"../Constraints.js";import{InteractiveController as N}from"./InteractiveController.js";import{panMotionToRotationMatrix as k,onSurfaceTiltToEyeTiltGlobal as P,offSurfaceTiltToEyeTiltGlobal as F}from"../utils/navigationUtils.js";import{viewAngle as G}from"../utils/viewUtils.js";import{headingTiltToDirectionUp as V}from"../../support/cameraUtils.js";import{createDirectionUp as B}from"../../support/cameraUtilsInternal.js";import{Camera as K}from"../../webgl-engine/lib/Camera.js";import{extractTransformation as X,isZeroTransformation as q,extractTransformationKeyboard as Z}from"../../../navigation/gamepadAndKeyboardUtils.js";let J=class extends N{constructor(t){super(t),this._filteredSurfaceElevation=0,this._transformation={translation:[0,0,0],heading:0,tilt:0,zoom:0},this._keysButtonState=[0,0,0,0,0,0,0,0,0,0,0,0],this._tmpCamera=new K,this._headingStart=0,this._constraintOptions=new I(U.ALL,D.NONE,0,new K,null,R.LOOK_AROUND)}handleEventGamepad(t){const e=X(t,this.view.navigation.gamepad,this._transformation);("end"===t.action||q(e))&&this.finishController()}activateDirection(t){this._keysButtonState[t]=1,Z(this._keysButtonState,this._transformation)}deactivateDirection(t){this._keysButtonState[t]=0;const e=Z(this._keysButtonState,this._transformation);q(e)&&this.finishController()}onControllerStart(t){this._filteredSurfaceElevation=this.view.pointsOfInterest.cameraOnSurface.location.z,this._headingStart=this.view.camera.heading,super.onControllerStart(t)}_updateFilteredSurfaceElevation(t){const e=this.view.pointsOfInterest.cameraOnSurface.location.z,i=1;this._filteredSurfaceElevation+=i*(e-this._filteredSurfaceElevation)*t}stepController(t,e){this._updateStartHeading(),this._updateFilteredSurfaceElevation(t),this.currentCamera.copyViewFrom(e),this._updateCameraCenter(),this._constraintOptions.interactionStartCamera?.copyFrom(this.currentCamera),this._calculateControlTransformation(t,this.currentCamera,at),this._applyDisabledMovementTypes(at),this._applyPan(at.pan),this._applyRotate(at.rotate),this._applyZoom(at.zoom),this._applyAscend(at.ascend),this._constraintOptions.interactionType=D.NONE,this._constraintOptions.selection=U.COLLISION,z(this.view,this.currentCamera,this._constraintOptions),super.stepController(t,e)}_updateStartHeading(){0!==this._transformation.heading&&(this._headingStart=this.view.camera.heading)}_applyRotate(t){if(!t.enabled)return;const e=this.currentCamera;h(rt,e.center,e.eye),p(rt,rt,t.matrix),e.center=d(rt,rt,e.eye),e.up=p(rt,e.up,t.matrix),this._constraintOptions.interactionType=D.LOOK_AROUND,this._constraintOptions.selection=U.ALL_EXCEPT_COLLISION,z(this.view,e,this._constraintOptions)}_applyPan(t,e=this.currentCamera){if(!t.enabled)return;e.eye=p(rt,e.eye,t.matrix),e.center=p(rt,e.center,t.matrix);this.view.state.isGlobal&&(e.up=p(rt,e.up,t.matrix)),this._constraintOptions.interactionType=D.PAN,this._constraintOptions.selection=U.ALL,z(this.view,e,this._constraintOptions)}_applyZoom(t){if(!t)return;const e=this.currentCamera.viewForward;this.currentCamera.eye=d(rt,this.currentCamera.eye,u(E.get(),e,t)),_(ot,e),f(ot,ot),this._constraintOptions.interactionDirection=ot,this._constraintOptions.interactionType=D.ZOOM,this._constraintOptions.selection=U.ALL_EXCEPT_COLLISION,z(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null}_applyAscend(t){if(!t)return;const e=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,E.get());this._constraintOptions.interactionDirection=_(ot,e);if(this.view.state.isGlobal){const e=v(this.currentCamera.eye),i=(e+t)/e;this.currentCamera.eye=u(rt,this.currentCamera.eye,i),this.currentCamera.center=u(rt,this.currentCamera.center,i)}else{const i=u(E.get(),e,t);this.currentCamera.eye=d(rt,this.currentCamera.eye,i),this.currentCamera.center=d(rt,this.currentCamera.center,i)}this._updateCameraCenter(),this._constraintOptions.interactionType=D.ASCEND,this._constraintOptions.selection=U.COLLISION,z(this.view,this.currentCamera,this._constraintOptions)&&this._updateCameraCenter(),this._constraintOptions.selection=U.ALL_EXCEPT_COLLISION,z(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null}_calculateControlTransformation(t,e,i){nt(i);const a=this._computeVelocities(t);this.view.state.isLocal?this._calculateControlTransformationLocal(a,e,i):this._calculateControlTransformationGlobal(a,e,i)}_updateCameraCenter(){const t=this.view.pointsOfInterest.centerOnSurfaceFrequent.estimatedSurfaceAltitude,e=this.view.renderCoordsHelper,i=this.currentCamera.ray;this.currentCamera.center=e.intersectManifoldClosestSilhouette(i,t,rt)}_calculateControlTransformationLocal(t,a,r){const{viewRight:o,viewForward:s}=a,m=this._transformation,l=this.view.navigation.gamepad,h=C(E.get(),s[0],s[1],0);g(h,h);const p=m.translation[0]*t.pan;if(0!==p){const t=u(E.get(),o,p);n(r.pan.matrix,r.pan.matrix,t),r.pan.enabled=!0}switch(l.mode){case"pan":{const e=-m.translation[1]*t.pan;if(0!==e){const t=u(E.get(),h,e);n(r.pan.matrix,r.pan.matrix,t),r.pan.enabled=!0}r.zoom=m.zoom*t.zoom;break}case"zoom":r.zoom=(-m.translation[1]+m.zoom)*t.zoom;break;default:e(l.mode)}const d=m.translation[2]*t.ascend;r.ascend=d;const _=-m.heading*t.rotate;0!==_&&(c(r.rotate.matrix,r.rotate.matrix,_,this.view.renderCoordsHelper.worldUpAtPosition(a.eye,E.get())),r.rotate.enabled=!0);const f=m.tilt*t.rotate,v=G(this.view.renderCoordsHelper,a.center,a.eye),y=i(v+f,H.min,H.max)-v;y&&(c(r.rotate.matrix,r.rotate.matrix,y,o),r.rotate.enabled=!0)}_calculateControlTransformationGlobal(t,e,i){const{eye:a,viewRight:r}=e,o=this._transformation,s=this.view.navigation.gamepad,n=y(E.get(),r,a);g(n,n),f(n,n),k(this.startCamera,e,o,t,this.view.camera.heading,this._headingStart,this.view.camera.tilt,i,s),this._tmpCamera.copyFrom(this.currentCamera),this._applyPan(at.pan,this._tmpCamera);const m=this.view.pointsOfInterest.centerOnSurfaceFrequent.estimatedSurfaceAltitude,l=o.translation[2]*t.ascend;i.ascend=l;const h=-o.heading*t.rotate;0!==h&&(c(i.rotate.matrix,i.rotate.matrix,h,this._tmpCamera.eye),i.rotate.enabled=!0);const p=o.tilt*t.rotate,d=this._clampTiltDeltaGlobalToValidRange(p,e.ray,m);0!==d&&(c(i.rotate.matrix,i.rotate.matrix,d,this._tmpCamera.viewRight),i.rotate.enabled=!0),i.zoom+=o.zoom*t.zoom}_clampTiltDeltaGlobalToValidRange(t,e,a){const r=x(this.view.spatialReference),o=P(H.min,e.origin,a,r);let s=0,n=0;const c=E.get();if(this.view.renderCoordsHelper.intersectManifold(e,a,c)){const t=G(this.view.renderCoordsHelper,c,e.origin);s=P(t,e.origin,a,r),n=P(H.max,e.origin,a,r)}else{L(M(T,a+r.radius),e,c);const t=Math.PI+A(e.direction,c);s=F(t,e.origin,a,r),n=F(H.max,e.origin,a,r)}return i(s+t,o,n)-s}_getPointAbsoluteSurfaceElevation(t,e,i){const{renderCoordsHelper:a}=this.view,r=a.getAltitude(t),o=e+Math.abs(r-e);return a.setAltitude(i,o,t),o}_clampedDistanceToSurface(t,e){const{renderCoordsHelper:i}=this.view,{camera:a}=this.view.state,{direction:r}=V(this.view,e,0,W,st),o=i.intersectManifoldClosestSilhouette(j(e,r),t,E.get()),s=w(e,o),n=i.intersectManifoldClosestSilhouette(j(e,O(E.get(),e,a.center)),t,E.get()),c=w(e,n);return Math.min(s,c)}_computeHeadingRotateRadius(t){const{renderCoordsHelper:e,state:i}=this.view,{camera:r,isGlobal:o}=i,s=e.intersectManifoldClosestSilhouette(r.ray,this._filteredSurfaceElevation,E.get());if(o){const e=h(E.get(),t,s),i=v(e);u(e,e,1/i);const r=g(E.get(),t),o=a(b(r,e));return i*Math.sin(Math.min(Y,o))}{const i=_(E.get(),t);return e.setAltitude(i,this._filteredSurfaceElevation),w(s,i)}}_minimumAscendVelocity(){return this.view.state.constraints.collision.enabled?0:tt}_computeVelocities(t){const e=this._filteredSurfaceElevation,a=e+x(this.view.spatialReference).radius,{camera:r,isGlobal:o}=this.view.state,s=E.get(),n=this._getPointAbsoluteSurfaceElevation(r.eye,e,s),c=this._clampedDistanceToSurface(e,s),m=r.width/2,l=$*r.width,h=$*r.width,p=c*Math.tan(.5*r.fovX)/m,d=p/a,u=p/this._computeHeadingRotateRadius(s),_=n-e;return{pan:(o?d:p)*l*t,ascend:Math.max(this._minimumAscendVelocity()*t,2**(l*t/m)*_-_),zoom:2**(l*t/m)*c-c,rotate:i(u*h,et,it)*t}}_applyDisabledMovementTypes(t){null==this.disableMovements||void 0!==this.disableMovements.mode&&this.view.state.viewingMode!==this.disableMovements.mode||(t.zoom=this.disableMovements.zoom?0:t.zoom,t.ascend=this.disableMovements.ascend?0:t.ascend,t.pan.enabled=!this.disableMovements.pan,this.disableMovements.pan&&m(t.pan.matrix),t.rotate.enabled=!this.disableMovements.rotate,this.disableMovements.rotate&&m(t.rotate.matrix))}static activatesFor(t,e){const i=X(e,t.navigation.gamepad,Q);return!("end"===e.action||q(i))}};t([o({constructOnly:!0})],J.prototype,"gamepadDevice",void 0),t([o({constructOnly:!0})],J.prototype,"disableMovements",void 0),J=t([s("esri.views.3d.state.controllers.GamepadKeyboardController")],J);const Q={translation:[0,0,0],heading:0,tilt:0,zoom:0},W=80,Y=r(W),$=.75,tt=5,et=r(30),it=r(80),at={zoom:0,ascend:0,pan:{enabled:!1,matrix:l()},rotate:{enabled:!1,matrix:l()}},rt=S(),ot=S(),st=B();function nt(t){t.zoom=0,t.ascend=0,t.pan.enabled=!1,m(t.pan.matrix),t.rotate.enabled=!1,m(t.rotate.matrix)}export{J as GamepadKeyboardController};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import{cyclicalPI as i}from"../../../../../core/Cyclical.js";import{deg2rad as e}from"../../../../../core/mathUtils.js";import{createScreenPointArray as n,screenPointObjectToArray as s,createRenderScreenPointArray3 as o}from"../../../../../core/screenUtils.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as a,distance as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{c as h,F as c,l as _,f as p,n as l,g as u,h as g,k as d}from"../../../../../chunks/vec32.js";import{create as P}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as C}from"../../../../../geometry/ellipsoidUtils.js";import{wrapAxisAngle as v}from"../../../../../geometry/support/axisAngle.js";import{create as w,fromPositionAndNormal as M,getNormal as S}from"../../../../../geometry/support/plane.js";import{d as b,g as f}from"../../../../../chunks/sphere.js";import{pixelDistanceToInteractionFactor as j,applyAll as E}from"../../../camera/constraintUtils.js";import{ConstraintOptions as O}from"../../../camera/constraintUtils/ConstraintOptions.js";import{ConstraintTypes as y}from"../../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as A}from"../../../camera/constraintUtils/InteractionType.js";import{ExponentialFalloff as z}from"../../../input/util.js";import{InteractiveController as R}from"../InteractiveController.js";import{PanPlanarMomentumController as k}from"../momentum/PanPlanarMomentumController.js";import{PanSphericalMomentumController as x}from"../momentum/PanSphericalMomentumController.js";import{RotationMomentumController as H}from"../momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as F}from"../momentum/ZoomPlanarMomentumController.js";import{ZoomSphericalMomentumController as T}from"../momentum/ZoomSphericalMomentumController.js";import{NavigationMode as U,pickPointAndInitSphere as D,contentIntersectorOptions as I,SpherePickPointFallback as L,decideNavigationMode as Z,sphereOrPlanePointFromScreenPoint as G,panDistanceModifier as N,minHeightLimit as B,screenPixelArea as V,intersectPlaneFromScreenPointAtEye as q,applyZoomOnSphere as J,preserveHeadingThreshold as K,applyPanSphericalPreserveHeading as Q,applyPanSphericalDirectRotation as W,normalizeRotationDelta as X,applyRotation as Y,applyPanPlanar as $,applyZoomToPoint as tt}from"../../utils/navigationUtils.js";import{Camera as it}from"../../../webgl-engine/lib/Camera.js";import{PanPlanarMomentumEstimator as et}from"../../../../navigation/PanPlanarMomentumEstimator.js";import{PanSphericalMomentumEstimator as nt}from"../../../../navigation/PanSphericalMomentumEstimator.js";import{RotationMomentumEstimator as st}from"../../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as ot}from"../../../../navigation/ZoomMomentumEstimator.js";let rt=class extends R{constructor(){super(...arguments),this._smoothRotation=new z(.05),this._rotationAxis=P(),this._beginAngle=0,this._beginHeading=0,this._panningPlane=w(),this._beginRadius=0,this._smoothScaling=new z(.05),this._zoomCenterScreen=n(),this._zoomMomentumEstimator=new ot,this._rotationMomentumEstimator=new st,this._panSphericalMomentumEstimator=new nt,this._panPlanarMomentumEstimator=new et,this._adjustedSphere=b(),this._tmp3d=P(),this._tmpScreenPointArray=n(),this._beginScreenPoint=n(),this._beginScenePoint=P(),this._screenPickPoint=n(),this._scenePickPoint=P(),this._mode=U.Horizontal,this._sphere=b(),this._pointerCount=0,this._tmpInteractionDirection=P(),this._beginCamera=new it,this._constraintOptions=new O(y.ALL,A.NONE,0,this._beginCamera)}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.active)return;this._zoomMomentumEstimator.enabled=this._rotationMomentumEstimator.enabled=this._panPlanarMomentumEstimator.enabled=this._panSphericalMomentumEstimator.enabled=this.view.navigation.momentumEnabled,this._beginHeading=-i.normalize(e(this.view.camera.heading)),this._beginRadius=t.radius,this._pointerCount=t.pointers.size,this._beginAngle=t.angle,this._smoothRotation.reset(),s(t.center,this._screenPickPoint),a(this._beginScreenPoint,this._screenPickPoint);const n=C(this.view.spatialReference),o=D(this._intersectionHelper,this.startCamera,this._screenPickPoint,n,L.Silhouette,0===this.view.map.ground.opacity?I:{});null!=o.scenePickPoint&&(this._scenePickPoint=o.scenePickPoint,this._sphere=o.sphere,h(this._beginScenePoint,this._scenePickPoint),this._mode=Z(this.startCamera,this._screenPickPoint,n),this._mode===U.Vertical&&this._preparePlanarPanMode(t,o.hasGeometryIntersection),this._beginCamera.copyFrom(this.startCamera))}update(t){if(!this.active)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1;this._mode===U.Horizontal?(i&&this._zoomSpherical(t),this._panningSpherical(t),i&&this._rotateSpherical(t)):(i&&this._zoomPlanar(t),this._panningPlanar(t),i&&this._rotatePlanar(t)),this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this._zoomMomentumEstimator.evaluateMomentum();if(i)return this._mode===U.Horizontal?new T({view:this.view,momentum:i,screenCenter:this._zoomCenterScreen,sceneCenter:this._beginScenePoint,radius:this._sphere[3]}):new F({view:this.view,momentum:i,zoomCenter:this._beginScenePoint});const e=this._rotationMomentumEstimator.evaluateMomentum();if(e)return new H({view:this.view,momentum:e,center:f(this._sphere),axis:this._rotationAxis});if(this._mode===U.Horizontal){const t=this._panSphericalMomentumEstimator.evaluateMomentum();if(t)return new x({view:this.view,momentum:t})}else{const t=this._panPlanarMomentumEstimator.evaluateMomentum();if(t)return new k({view:this.view,momentum:t})}return null}_preparePlanarPanMode(t,i){const e=c(this._tmp3d,this.startCamera.viewForward);M(this._scenePickPoint,e,this._panningPlane);const r=n(this._screenPickPoint[0],0),a=P(),m=_(this.startCamera.eye);this._adjustedSphere[3]=m<this._sphere[3]?m-100:this._sphere[3],G(this._adjustedSphere,this.startCamera,r,a);const C=o();this.startCamera.projectToRenderScreen(a,C);const v=P(),w=P(),b=P();p(v,this._scenePickPoint,this.currentCamera.eye);const f=_(v);l(v,v);const j=N*Math.max(Math.abs(this.view.camera.position.z),B),E=this.view._stage.renderView.getMinimalDepthForArea(null,this._screenPickPoint[0],this._screenPickPoint[1],this.view.state.camera,V);let O=null!=E?E:j;O=i?Math.min(O,f):O,h(b,u(w,this.currentCamera.eye,g(w,v,O))),this._panningPlane[3]=-d(S(this._panningPlane),b),this.startCamera.center=u(w,this.startCamera.eye,g(w,this.startCamera.viewForward,O));const y=s(t.center,this._tmpScreenPointArray);q(this._panningPlane,this.startCamera,y,this._beginScenePoint)}_zoomSpherical(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),J(this._sphere,this.currentCamera,this._smoothScaling.value),s(t.center,this._zoomCenterScreen),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),this._constraintOptions.interactionType=A.ZOOM,this._constraintOptions.interactionFactor=j(t.radius-this._beginRadius),E(this.view,this.currentCamera,this._constraintOptions)}_panningSpherical(t){const i=s(t.center,this._tmpScreenPointArray);G(this._sphere,this.currentCamera,i,this._tmp3d),K(this._beginScenePoint,d(this.currentCamera.up,this._beginScenePoint),this._sphere[3],this._beginHeading,this.view.camera.tilt,this.startCamera)?(Q(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this._beginHeading,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumPreserveHeading(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere,this._beginHeading,this.view.camera.tilt)):(W(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumDirectRotation(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere[3],this.view.camera.tilt)),this._constraintOptions.interactionType=A.PAN,this._constraintOptions.interactionFactor=j(m(this._screenPickPoint,i)),E(this.view,this.currentCamera,this._constraintOptions)}_rotateSpherical(t){l(this._rotationAxis,this._scenePickPoint),this.currentCamera.aboveGround||c(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value,e=i+X(t.angle-i),n=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=n,this._smoothRotation.update(e);const s=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(s,.001*t.timestamp),Y(this.currentCamera,f(this._sphere),v(this._rotationAxis,s)),this._constraintOptions.interactionType=A.TUMBLE,this._constraintOptions.interactionFactor=j(t.radius*e),E(this.view,this.currentCamera,this._constraintOptions)}_panningPlanar(t){const i=s(t.center,this._tmpScreenPointArray);q(this._panningPlane,this.currentCamera,i,this._tmp3d)&&($(this.currentCamera,this._beginScenePoint,this._tmp3d),this._panPlanarMomentumEstimator.add(i,this._tmp3d,.001*t.timestamp),this._constraintOptions.interactionType=A.PAN,this._constraintOptions.interactionFactor=j(m(this._beginScreenPoint,i)),this._constraintOptions.interactionDirection=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,this._tmpInteractionDirection),E(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null)}_zoomPlanar(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),tt(this.currentCamera,this._beginScenePoint,this._smoothScaling.value,this.view.state.constraints.minimumPoiDistance),this._constraintOptions.interactionType=A.ZOOM,this._constraintOptions.interactionFactor=j(t.radius-this._beginRadius),E(this.view,this.currentCamera,this._constraintOptions)}_rotatePlanar(t){h(this._rotationAxis,this._beginScenePoint),this.currentCamera.aboveGround||c(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value;let e=t.angle-i;e=X(e);const n=i+e,s=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=s,this._smoothRotation.update(n);const o=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(o,.001*t.timestamp),Y(this.currentCamera,f(this._sphere),v(this._rotationAxis,o)),this._constraintOptions.interactionType=A.TUMBLE,this._constraintOptions.interactionFactor=j(t.radius*o),E(this.view,this.currentCamera,this._constraintOptions)}};rt=t([r("esri.views.3d.state.controllers.global.PinchAndPanController")],rt);export{rt as PinchAndPanController};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import{cyclicalPI as i}from"../../../../../core/Cyclical.js";import{deg2rad as e}from"../../../../../core/mathUtils.js";import{createScreenPointArray as n,screenPointObjectToArray as s,createRenderScreenPointArray3 as o}from"../../../../../core/screenUtils.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as a,distance as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{c as h,F as c,l as _,f as p,n as l,g as u,h as g,k as d}from"../../../../../chunks/vec32.js";import{create as P}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as C}from"../../../../../geometry/ellipsoidUtils.js";import{wrapAxisAngle as v}from"../../../../../geometry/support/axisAngle.js";import{create as w,fromPositionAndNormal as M,getNormal as S}from"../../../../../geometry/support/plane.js";import{c as b,g as f}from"../../../../../chunks/sphere.js";import{pixelDistanceToInteractionFactor as j,applyAll as E}from"../../../camera/constraintUtils.js";import{ConstraintOptions as O}from"../../../camera/constraintUtils/ConstraintOptions.js";import{ConstraintTypes as y}from"../../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as A}from"../../../camera/constraintUtils/InteractionType.js";import{ExponentialFalloff as z}from"../../../input/util.js";import{InteractiveController as R}from"../InteractiveController.js";import{PanPlanarMomentumController as k}from"../momentum/PanPlanarMomentumController.js";import{PanSphericalMomentumController as x}from"../momentum/PanSphericalMomentumController.js";import{RotationMomentumController as H}from"../momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as F}from"../momentum/ZoomPlanarMomentumController.js";import{ZoomSphericalMomentumController as T}from"../momentum/ZoomSphericalMomentumController.js";import{NavigationMode as U,pickPointAndInitSphere as D,contentIntersectorOptions as I,SpherePickPointFallback as L,decideNavigationMode as Z,sphereOrPlanePointFromScreenPoint as G,panDistanceModifier as N,minHeightLimit as B,screenPixelArea as V,intersectPlaneFromScreenPointAtEye as q,applyZoomOnSphere as J,preserveHeadingThreshold as K,applyPanSphericalPreserveHeading as Q,applyPanSphericalDirectRotation as W,normalizeRotationDelta as X,applyRotation as Y,applyPanPlanar as $,applyZoomToPoint as tt}from"../../utils/navigationUtils.js";import{Camera as it}from"../../../webgl-engine/lib/Camera.js";import{PanPlanarMomentumEstimator as et}from"../../../../navigation/PanPlanarMomentumEstimator.js";import{PanSphericalMomentumEstimator as nt}from"../../../../navigation/PanSphericalMomentumEstimator.js";import{RotationMomentumEstimator as st}from"../../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as ot}from"../../../../navigation/ZoomMomentumEstimator.js";let rt=class extends R{constructor(){super(...arguments),this._smoothRotation=new z(.05),this._rotationAxis=P(),this._beginAngle=0,this._beginHeading=0,this._panningPlane=w(),this._beginRadius=0,this._smoothScaling=new z(.05),this._zoomCenterScreen=n(),this._zoomMomentumEstimator=new ot,this._rotationMomentumEstimator=new st,this._panSphericalMomentumEstimator=new nt,this._panPlanarMomentumEstimator=new et,this._adjustedSphere=b(),this._tmp3d=P(),this._tmpScreenPointArray=n(),this._beginScreenPoint=n(),this._beginScenePoint=P(),this._screenPickPoint=n(),this._scenePickPoint=P(),this._mode=U.Horizontal,this._sphere=b(),this._pointerCount=0,this._tmpInteractionDirection=P(),this._beginCamera=new it,this._constraintOptions=new O(y.ALL,A.NONE,0,this._beginCamera)}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.active)return;this._zoomMomentumEstimator.enabled=this._rotationMomentumEstimator.enabled=this._panPlanarMomentumEstimator.enabled=this._panSphericalMomentumEstimator.enabled=this.view.navigation.momentumEnabled,this._beginHeading=-i.normalize(e(this.view.camera.heading)),this._beginRadius=t.radius,this._pointerCount=t.pointers.size,this._beginAngle=t.angle,this._smoothRotation.reset(),s(t.center,this._screenPickPoint),a(this._beginScreenPoint,this._screenPickPoint);const n=C(this.view.spatialReference),o=D(this._intersectionHelper,this.startCamera,this._screenPickPoint,n,L.Silhouette,0===this.view.map.ground.opacity?I:{});null!=o.scenePickPoint&&(this._scenePickPoint=o.scenePickPoint,this._sphere=o.sphere,h(this._beginScenePoint,this._scenePickPoint),this._mode=Z(this.startCamera,this._screenPickPoint,n),this._mode===U.Vertical&&this._preparePlanarPanMode(t,o.hasGeometryIntersection),this._beginCamera.copyFrom(this.startCamera))}update(t){if(!this.active)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1;this._mode===U.Horizontal?(i&&this._zoomSpherical(t),this._panningSpherical(t),i&&this._rotateSpherical(t)):(i&&this._zoomPlanar(t),this._panningPlanar(t),i&&this._rotatePlanar(t)),this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this._zoomMomentumEstimator.evaluateMomentum();if(i)return this._mode===U.Horizontal?new T({view:this.view,momentum:i,screenCenter:this._zoomCenterScreen,sceneCenter:this._beginScenePoint,radius:this._sphere[3]}):new F({view:this.view,momentum:i,zoomCenter:this._beginScenePoint});const e=this._rotationMomentumEstimator.evaluateMomentum();if(e)return new H({view:this.view,momentum:e,center:f(this._sphere),axis:this._rotationAxis});if(this._mode===U.Horizontal){const t=this._panSphericalMomentumEstimator.evaluateMomentum();if(t)return new x({view:this.view,momentum:t})}else{const t=this._panPlanarMomentumEstimator.evaluateMomentum();if(t)return new k({view:this.view,momentum:t})}return null}_preparePlanarPanMode(t,i){const e=c(this._tmp3d,this.startCamera.viewForward);M(this._scenePickPoint,e,this._panningPlane);const r=n(this._screenPickPoint[0],0),a=P(),m=_(this.startCamera.eye);this._adjustedSphere[3]=m<this._sphere[3]?m-100:this._sphere[3],G(this._adjustedSphere,this.startCamera,r,a);const C=o();this.startCamera.projectToRenderScreen(a,C);const v=P(),w=P(),b=P();p(v,this._scenePickPoint,this.currentCamera.eye);const f=_(v);l(v,v);const j=N*Math.max(Math.abs(this.view.camera.position.z),B),E=this.view._stage.renderView.getMinimalDepthForArea(null,this._screenPickPoint[0],this._screenPickPoint[1],this.view.state.camera,V);let O=null!=E?E:j;O=i?Math.min(O,f):O,h(b,u(w,this.currentCamera.eye,g(w,v,O))),this._panningPlane[3]=-d(S(this._panningPlane),b),this.startCamera.center=u(w,this.startCamera.eye,g(w,this.startCamera.viewForward,O));const y=s(t.center,this._tmpScreenPointArray);q(this._panningPlane,this.startCamera,y,this._beginScenePoint)}_zoomSpherical(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),J(this._sphere,this.currentCamera,this._smoothScaling.value),s(t.center,this._zoomCenterScreen),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),this._constraintOptions.interactionType=A.ZOOM,this._constraintOptions.interactionFactor=j(t.radius-this._beginRadius),E(this.view,this.currentCamera,this._constraintOptions)}_panningSpherical(t){const i=s(t.center,this._tmpScreenPointArray);G(this._sphere,this.currentCamera,i,this._tmp3d),K(this._beginScenePoint,d(this.currentCamera.up,this._beginScenePoint),this._sphere[3],this._beginHeading,this.view.camera.tilt,this.startCamera)?(Q(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this._beginHeading,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumPreserveHeading(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere,this._beginHeading,this.view.camera.tilt)):(W(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumDirectRotation(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere[3],this.view.camera.tilt)),this._constraintOptions.interactionType=A.PAN,this._constraintOptions.interactionFactor=j(m(this._screenPickPoint,i)),E(this.view,this.currentCamera,this._constraintOptions)}_rotateSpherical(t){l(this._rotationAxis,this._scenePickPoint),this.currentCamera.aboveGround||c(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value,e=i+X(t.angle-i),n=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=n,this._smoothRotation.update(e);const s=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(s,.001*t.timestamp),Y(this.currentCamera,f(this._sphere),v(this._rotationAxis,s)),this._constraintOptions.interactionType=A.TUMBLE,this._constraintOptions.interactionFactor=j(t.radius*e),E(this.view,this.currentCamera,this._constraintOptions)}_panningPlanar(t){const i=s(t.center,this._tmpScreenPointArray);q(this._panningPlane,this.currentCamera,i,this._tmp3d)&&($(this.currentCamera,this._beginScenePoint,this._tmp3d),this._panPlanarMomentumEstimator.add(i,this._tmp3d,.001*t.timestamp),this._constraintOptions.interactionType=A.PAN,this._constraintOptions.interactionFactor=j(m(this._beginScreenPoint,i)),this._constraintOptions.interactionDirection=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,this._tmpInteractionDirection),E(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null)}_zoomPlanar(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),tt(this.currentCamera,this._beginScenePoint,this._smoothScaling.value,this.view.state.constraints.minimumPoiDistance),this._constraintOptions.interactionType=A.ZOOM,this._constraintOptions.interactionFactor=j(t.radius-this._beginRadius),E(this.view,this.currentCamera,this._constraintOptions)}_rotatePlanar(t){h(this._rotationAxis,this._beginScenePoint),this.currentCamera.aboveGround||c(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value;let e=t.angle-i;e=X(e);const n=i+e,s=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=s,this._smoothRotation.update(n);const o=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(o,.001*t.timestamp),Y(this.currentCamera,f(this._sphere),v(this._rotationAxis,o)),this._constraintOptions.interactionType=A.TUMBLE,this._constraintOptions.interactionFactor=j(t.radius*o),E(this.view,this.currentCamera,this._constraintOptions)}};rt=t([r("esri.views.3d.state.controllers.global.PinchAndPanController")],rt);export{rt as PinchAndPanController};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{createScreenPointArray as r}from"../../../../../core/screenUtils.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as e,distance as a}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{n as o,f as h,l as c,k as m,h as p,g as l}from"../../../../../chunks/vec32.js";import{create as _}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as u}from"../../../../../geometry/ellipsoidUtils.js";import{create as P,fromPoints as C}from"../../../../../geometry/support/axisAngle.js";import{d as y,g as d}from"../../../../../chunks/sphere.js";import{pixelDistanceToInteractionFactor as f,applyAll as g}from"../../../camera/constraintUtils.js";import{ConstraintOptions as v}from"../../../camera/constraintUtils/ConstraintOptions.js";import{ConstraintTypes as R}from"../../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as j}from"../../../camera/constraintUtils/InteractionType.js";import{applySurfaceCollisionConstraint as k}from"../../../camera/constraintUtils/surfaceCollision.js";import{InteractiveController as w}from"../InteractiveController.js";import{NavigationMode as D,normalizeCoordinate as A,pickPointAndInitSphere as M,contentIntersectorOptions as b,SpherePickPointFallback as O,decideNavigationMode as U,distanceClampValues as x,pivotDistanceModifier as z,screenPixelArea as H,sphereOrPlanePointFromScreenPoint as L,applyRotation as I}from"../../utils/navigationUtils.js";import{fromScreenAtEye as S}from"../../../support/geometryUtils/ray.js";let B=class extends w{constructor(){super(...arguments),this._pickPoint=_(),this._tmpP0=n(),this._panAxisAngle=P(),this._tmpRayDir=_(),this._tmpRayDirPick=_(),this._targetOnSphere=_(),this._navMode=D.Horizontal,this._tmpRay={origin:_(),direction:_()},this.dragBeginPoint=r(),this._normalizedAnchorPoint=n(),this._constraintOptions=new v(R.ALL_EXCEPT_COLLISION,j.ZOOM,0,this.startCamera),this._sphere=y(),this._hasPickPoint=!1}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.active)return;e(this.dragBeginPoint,t),A(this.startCamera,t,this._normalizedAnchorPoint);const r=u(this.view.spatialReference),s=M(this._intersectionHelper,this.startCamera,t,r,O.Ellipsoid,0===this.view.map.ground.opacity?b:{});if(this._navMode=U(this.startCamera,t,r),this._navMode===D.Horizontal)this._hasPickPoint=!!s.scenePickPoint,this._pickPoint=s.scenePickPoint??this._pickPoint,this._sphere=s.sphere;else{let r;S(this.startCamera,t,this._tmpRay),o(this._tmpRay.direction,this._tmpRay.direction),null!=s.scenePickPoint&&(h(this._tmpRayDirPick,this.startCamera.eye,s.scenePickPoint),r=c(this._tmpRayDirPick));const e=Math.abs(this.view.camera.position.z);this.view.renderCoordsHelper.worldUpAtPosition(this.startCamera.eye,T);let a=i(Math.min(z,1/Math.abs(m(T,this._tmpRay.direction)))*e,x[0],x[1]);const n=this.view._stage.renderView.getMinimalDepthForArea(null,t[0],t[1],this.view.state.camera,H);a=null!=n?n:a,a=null!=r?Math.min(a,r):a,this._hasPickPoint=!0,p(this._tmpRay.direction,this._tmpRay.direction,a),l(this._pickPoint,this._tmpRay.origin,this._tmpRay.direction)}}update(t){if(this.active){if(this.currentCamera.eye=this.startCamera.eye,this.currentCamera.center=this.startCamera.center,this.currentCamera.up=this.startCamera.up,this._navMode===D.Horizontal){h(this._tmpRayDir,this.currentCamera.center,this.currentCamera.eye);const i=c(this._tmpRayDir);A(this.currentCamera,t,this._tmpP0);const r=12*(this._normalizedAnchorPoint[1]-this._tmpP0[1]);let s=i*2**r;const e=this.view.state.constraints.minimumPoiDistance;if(r<0&&s<e&&(s=e),Math.abs(i-s)<1e-6)return;if(this._hasPickPoint&&s<i){const t=1-(1-s/i)*(1-this._sphere[3]/c(this.currentCamera.center));this.currentCamera.center=p(E,this.currentCamera.center,t)}p(this._tmpRayDir,this._tmpRayDir,-s/i),this.currentCamera.eye=l(E,this.currentCamera.center,this._tmpRayDir),this._constraintOptions.interactionFactor=f(a(this.dragBeginPoint,t)),g(this.view,this.currentCamera,this._constraintOptions),this._hasPickPoint&&(L(this._sphere,this.currentCamera,this.dragBeginPoint,this._targetOnSphere),C(this._pickPoint,this._targetOnSphere,this._panAxisAngle),I(this.currentCamera,d(this._sphere),this._panAxisAngle))}else{const i=c(this._tmpRay.direction);A(this.currentCamera,t,this._tmpP0);const r=12*(this._normalizedAnchorPoint[1]-this._tmpP0[1]);let s=i*2**r;const e=this.view.state.constraints.minimumPoiDistance;if(r<0&&s<e&&(s=e),Math.abs(i-s)<1e-6)return;p(this._tmpRayDir,this._tmpRay.direction,1-s/i),this.currentCamera.eye=l(E,this.currentCamera.eye,this._tmpRayDir),this.currentCamera.center=l(E,this.currentCamera.center,this._tmpRayDir)}k(this.view,this.currentCamera),this.commitCamera()}}end(){this.active&&this.finishController()}};B=t([s("esri.views.3d.state.controllers.global.ZoomController")],B);const E=_(),T=_();export{B as ZoomController};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{createScreenPointArray as r}from"../../../../../core/screenUtils.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as e,distance as a}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{n as o,f as h,l as c,k as m,h as p,g as l}from"../../../../../chunks/vec32.js";import{create as _}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as u}from"../../../../../geometry/ellipsoidUtils.js";import{create as P,fromPoints as C}from"../../../../../geometry/support/axisAngle.js";import{c as y,g as d}from"../../../../../chunks/sphere.js";import{pixelDistanceToInteractionFactor as f,applyAll as g}from"../../../camera/constraintUtils.js";import{ConstraintOptions as v}from"../../../camera/constraintUtils/ConstraintOptions.js";import{ConstraintTypes as R}from"../../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as j}from"../../../camera/constraintUtils/InteractionType.js";import{applySurfaceCollisionConstraint as k}from"../../../camera/constraintUtils/surfaceCollision.js";import{InteractiveController as w}from"../InteractiveController.js";import{NavigationMode as D,normalizeCoordinate as A,pickPointAndInitSphere as M,contentIntersectorOptions as b,SpherePickPointFallback as O,decideNavigationMode as U,distanceClampValues as x,pivotDistanceModifier as z,screenPixelArea as H,sphereOrPlanePointFromScreenPoint as L,applyRotation as I}from"../../utils/navigationUtils.js";import{fromScreenAtEye as S}from"../../../support/geometryUtils/ray.js";let B=class extends w{constructor(){super(...arguments),this._pickPoint=_(),this._tmpP0=n(),this._panAxisAngle=P(),this._tmpRayDir=_(),this._tmpRayDirPick=_(),this._targetOnSphere=_(),this._navMode=D.Horizontal,this._tmpRay={origin:_(),direction:_()},this.dragBeginPoint=r(),this._normalizedAnchorPoint=n(),this._constraintOptions=new v(R.ALL_EXCEPT_COLLISION,j.ZOOM,0,this.startCamera),this._sphere=y(),this._hasPickPoint=!1}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.active)return;e(this.dragBeginPoint,t),A(this.startCamera,t,this._normalizedAnchorPoint);const r=u(this.view.spatialReference),s=M(this._intersectionHelper,this.startCamera,t,r,O.Ellipsoid,0===this.view.map.ground.opacity?b:{});if(this._navMode=U(this.startCamera,t,r),this._navMode===D.Horizontal)this._hasPickPoint=!!s.scenePickPoint,this._pickPoint=s.scenePickPoint??this._pickPoint,this._sphere=s.sphere;else{let r;S(this.startCamera,t,this._tmpRay),o(this._tmpRay.direction,this._tmpRay.direction),null!=s.scenePickPoint&&(h(this._tmpRayDirPick,this.startCamera.eye,s.scenePickPoint),r=c(this._tmpRayDirPick));const e=Math.abs(this.view.camera.position.z);this.view.renderCoordsHelper.worldUpAtPosition(this.startCamera.eye,T);let a=i(Math.min(z,1/Math.abs(m(T,this._tmpRay.direction)))*e,x[0],x[1]);const n=this.view._stage.renderView.getMinimalDepthForArea(null,t[0],t[1],this.view.state.camera,H);a=null!=n?n:a,a=null!=r?Math.min(a,r):a,this._hasPickPoint=!0,p(this._tmpRay.direction,this._tmpRay.direction,a),l(this._pickPoint,this._tmpRay.origin,this._tmpRay.direction)}}update(t){if(this.active){if(this.currentCamera.eye=this.startCamera.eye,this.currentCamera.center=this.startCamera.center,this.currentCamera.up=this.startCamera.up,this._navMode===D.Horizontal){h(this._tmpRayDir,this.currentCamera.center,this.currentCamera.eye);const i=c(this._tmpRayDir);A(this.currentCamera,t,this._tmpP0);const r=12*(this._normalizedAnchorPoint[1]-this._tmpP0[1]);let s=i*2**r;const e=this.view.state.constraints.minimumPoiDistance;if(r<0&&s<e&&(s=e),Math.abs(i-s)<1e-6)return;if(this._hasPickPoint&&s<i){const t=1-(1-s/i)*(1-this._sphere[3]/c(this.currentCamera.center));this.currentCamera.center=p(E,this.currentCamera.center,t)}p(this._tmpRayDir,this._tmpRayDir,-s/i),this.currentCamera.eye=l(E,this.currentCamera.center,this._tmpRayDir),this._constraintOptions.interactionFactor=f(a(this.dragBeginPoint,t)),g(this.view,this.currentCamera,this._constraintOptions),this._hasPickPoint&&(L(this._sphere,this.currentCamera,this.dragBeginPoint,this._targetOnSphere),C(this._pickPoint,this._targetOnSphere,this._panAxisAngle),I(this.currentCamera,d(this._sphere),this._panAxisAngle))}else{const i=c(this._tmpRay.direction);A(this.currentCamera,t,this._tmpP0);const r=12*(this._normalizedAnchorPoint[1]-this._tmpP0[1]);let s=i*2**r;const e=this.view.state.constraints.minimumPoiDistance;if(r<0&&s<e&&(s=e),Math.abs(i-s)<1e-6)return;p(this._tmpRayDir,this._tmpRay.direction,1-s/i),this.currentCamera.eye=l(E,this.currentCamera.eye,this._tmpRayDir),this.currentCamera.center=l(E,this.currentCamera.center,this._tmpRayDir)}k(this.view,this.currentCamera),this.commitCamera()}}end(){this.active&&this.finishController()}};B=t([s("esri.views.3d.state.controllers.global.ZoomController")],B);const E=_(),T=_();export{B as ZoomController};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{Milliseconds as e}from"../../../../../core/time.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c as s,n as o,h as a,k as n,l as m,f as h,g as c,a as p}from"../../../../../chunks/vec32.js";import{create as _}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as l}from"../../../../../geometry/ellipsoidUtils.js";import{d as y}from"../../../../../chunks/sphere.js";import{applyAll as f}from"../../../camera/constraintUtils.js";import{ConstraintOptions as g}from"../../../camera/constraintUtils/ConstraintOptions.js";import{ConstraintTypes as w}from"../../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as C}from"../../../camera/constraintUtils/InteractionType.js";import{applySurfaceCollisionConstraint as d}from"../../../camera/constraintUtils/surfaceCollision.js";import{PointToPointAnimationController as j}from"../PointToPointAnimationController.js";import{contentIntersectorOptions as u,decideNavigationMode as D,zoomMaxDistanceModifier as b,zoomMinDistanceModifier as v,zoomDistanceModifier as R,NavigationMode as L,panToPosition as M}from"../../utils/navigationUtils.js";import{fromScreenAtEye as z}from"../../../support/geometryUtils/ray.js";import{intersectScreen as O}from"../../../support/geometryUtils/sphere.js";import{Camera as U}from"../../../webgl-engine/lib/Camera.js";import{newIntersector as S}from"../../../webgl-engine/lib/Intersector.js";import{outExpo as V}from"../../../../animation/easing.js";const k=.6,x=4,A=60;let F=class extends j{constructor(){super(...arguments),this._zoomLocation=_(),this._tmpCamera=new U,this._tmpViewDir=_(),this._tmpRayDir={origin:_(),direction:_()},this._targetOnSphere=_(),this._tmpCenter=_(),this._beginCamera=new U,this._constraintOptions=new g(w.ALL_EXCEPT_COLLISION,C.ZOOM,null,this._beginCamera),this._sphere=y()}initialize(){this._intersector=S(this.view.state.viewingMode)}zoomStep(t,i){if(!this.active)return;const e=this.view.state;this.animation.finished?this._beginCamera.copyFrom(e.camera):this.animation.cameraAt(1,this._beginCamera);let r=!1,o=!1;this.intersectionHelper.intersectScreen(i,this._zoomLocation,0===this.view.map.ground.opacity?u:{})&&(r=t>0,o=!0),this._tmpCamera.copyFrom(e.camera),r?this.intersectionHelper.intersectRay(this._tmpCamera.ray,this._intersector,this._tmpCenter)&&(this._tmpCamera.center=this._tmpCenter):this.intersectionHelper.intersectRay(this._tmpCamera.ray,this._intersector,this._zoomLocation)?this._tmpCamera.center=this._zoomLocation:s(this._zoomLocation,this._tmpCamera.center),this._updateCamera(this._tmpCamera,t,this._zoomLocation,i,o),this.begin(this._tmpCamera)}animationSettings(){return{duration:e(600),easing:V}}_updateCamera(t,e,r,s,_){const y=l(this.view.spatialReference),g=D(t,s,y),w=Math.abs(this.view.camera.position.z);o(I,t.eye),a(I,I,-1),z(t,s,this._tmpRayDir),o(this._tmpRayDir.direction,this._tmpRayDir.direction);const C=i(Math.min(R,1/Math.abs(n(I,this._tmpRayDir.direction)))*w,v,b);if(g===L.Horizontal){let i=k**e;this._sphere[3]=m(r),h(this._tmpViewDir,t.center,t.eye);const o=Math.min(m(this._tmpViewDir),C);let n=o*i;if(i<=1&&n<x&&(n=x,i=n/o),Math.abs(o-n)<1e-6)return;const _=m(t.center);if(this._sphere[3]!==_){const e=this._sphere[3]+i*(_-this._sphere[3]);t.center=a(H,t.center,e/_)}a(this._tmpViewDir,this._tmpViewDir,-i),t.eye=c(H,t.center,this._tmpViewDir),f(this.view,t,this._constraintOptions),p(r,t.center)>1e-12&&O(this._sphere,t,s,this._targetOnSphere)&&M(this._sphere,t,r,this._targetOnSphere,this.view.camera.heading,this.view.camera.tilt,!0)}else{let i=k**Math.abs(e);const o=e>0?1:-1;h(this._tmpViewDir,r,t.eye);const n=m(this._tmpViewDir),p=this.view._stage.renderView.getMinimalDepthForArea(null,s[0],s[1],this.view.state.camera,A);let l=null!=p?p:C;l=_&&e>0?Math.min(l,n):l,a(this._tmpRayDir.direction,this._tmpRayDir.direction,l),c(r,this._tmpRayDir.origin,this._tmpRayDir.direction);let y=l*i;const f=Math.max(x,1.01*t.nearFar[0]);if(e>0&&y<f&&(y=f,i=y/l),Math.abs(l-y)<1e-6)return;a(this._tmpRayDir.direction,this._tmpRayDir.direction,o*(1-i)),t.eye=c(H,t.eye,this._tmpRayDir.direction),t.center=c(H,t.center,this._tmpRayDir.direction)}d(this.view,t)}};F=t([r("esri.views.3d.state.controllers.global.ZoomStepController")],F);const H=_(),I=_();export{F as ZoomStepController};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{Milliseconds as e}from"../../../../../core/time.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c as s,n as o,h as a,k as n,l as m,f as h,g as c,a as p}from"../../../../../chunks/vec32.js";import{create as _}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as l}from"../../../../../geometry/ellipsoidUtils.js";import{c as y}from"../../../../../chunks/sphere.js";import{applyAll as f}from"../../../camera/constraintUtils.js";import{ConstraintOptions as g}from"../../../camera/constraintUtils/ConstraintOptions.js";import{ConstraintTypes as w}from"../../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as C}from"../../../camera/constraintUtils/InteractionType.js";import{applySurfaceCollisionConstraint as d}from"../../../camera/constraintUtils/surfaceCollision.js";import{PointToPointAnimationController as j}from"../PointToPointAnimationController.js";import{contentIntersectorOptions as u,decideNavigationMode as D,zoomMaxDistanceModifier as b,zoomMinDistanceModifier as v,zoomDistanceModifier as R,NavigationMode as L,panToPosition as M}from"../../utils/navigationUtils.js";import{fromScreenAtEye as z}from"../../../support/geometryUtils/ray.js";import{intersectScreen as O}from"../../../support/geometryUtils/sphere.js";import{Camera as U}from"../../../webgl-engine/lib/Camera.js";import{newIntersector as S}from"../../../webgl-engine/lib/Intersector.js";import{outExpo as V}from"../../../../animation/easing.js";const k=.6,x=4,A=60;let F=class extends j{constructor(){super(...arguments),this._zoomLocation=_(),this._tmpCamera=new U,this._tmpViewDir=_(),this._tmpRayDir={origin:_(),direction:_()},this._targetOnSphere=_(),this._tmpCenter=_(),this._beginCamera=new U,this._constraintOptions=new g(w.ALL_EXCEPT_COLLISION,C.ZOOM,null,this._beginCamera),this._sphere=y()}initialize(){this._intersector=S(this.view.state.viewingMode)}zoomStep(t,i){if(!this.active)return;const e=this.view.state;this.animation.finished?this._beginCamera.copyFrom(e.camera):this.animation.cameraAt(1,this._beginCamera);let r=!1,o=!1;this.intersectionHelper.intersectScreen(i,this._zoomLocation,0===this.view.map.ground.opacity?u:{})&&(r=t>0,o=!0),this._tmpCamera.copyFrom(e.camera),r?this.intersectionHelper.intersectRay(this._tmpCamera.ray,this._intersector,this._tmpCenter)&&(this._tmpCamera.center=this._tmpCenter):this.intersectionHelper.intersectRay(this._tmpCamera.ray,this._intersector,this._zoomLocation)?this._tmpCamera.center=this._zoomLocation:s(this._zoomLocation,this._tmpCamera.center),this._updateCamera(this._tmpCamera,t,this._zoomLocation,i,o),this.begin(this._tmpCamera)}animationSettings(){return{duration:e(600),easing:V}}_updateCamera(t,e,r,s,_){const y=l(this.view.spatialReference),g=D(t,s,y),w=Math.abs(this.view.camera.position.z);o(I,t.eye),a(I,I,-1),z(t,s,this._tmpRayDir),o(this._tmpRayDir.direction,this._tmpRayDir.direction);const C=i(Math.min(R,1/Math.abs(n(I,this._tmpRayDir.direction)))*w,v,b);if(g===L.Horizontal){let i=k**e;this._sphere[3]=m(r),h(this._tmpViewDir,t.center,t.eye);const o=Math.min(m(this._tmpViewDir),C);let n=o*i;if(i<=1&&n<x&&(n=x,i=n/o),Math.abs(o-n)<1e-6)return;const _=m(t.center);if(this._sphere[3]!==_){const e=this._sphere[3]+i*(_-this._sphere[3]);t.center=a(H,t.center,e/_)}a(this._tmpViewDir,this._tmpViewDir,-i),t.eye=c(H,t.center,this._tmpViewDir),f(this.view,t,this._constraintOptions),p(r,t.center)>1e-12&&O(this._sphere,t,s,this._targetOnSphere)&&M(this._sphere,t,r,this._targetOnSphere,this.view.camera.heading,this.view.camera.tilt,!0)}else{let i=k**Math.abs(e);const o=e>0?1:-1;h(this._tmpViewDir,r,t.eye);const n=m(this._tmpViewDir),p=this.view._stage.renderView.getMinimalDepthForArea(null,s[0],s[1],this.view.state.camera,A);let l=null!=p?p:C;l=_&&e>0?Math.min(l,n):l,a(this._tmpRayDir.direction,this._tmpRayDir.direction,l),c(r,this._tmpRayDir.origin,this._tmpRayDir.direction);let y=l*i;const f=Math.max(x,1.01*t.nearFar[0]);if(e>0&&y<f&&(y=f,i=y/l),Math.abs(l-y)<1e-6)return;a(this._tmpRayDir.direction,this._tmpRayDir.direction,o*(1-i)),t.eye=c(H,t.eye,this._tmpRayDir.direction),t.center=c(H,t.center,this._tmpRayDir.direction)}d(this.view,t)}};F=t([r("esri.views.3d.state.controllers.global.ZoomStepController")],F);const H=_(),I=_();export{F as ZoomStepController};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import{createScreenPointArray as e}from"../../../../../core/screenUtils.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{clone as o,create as i}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n,fromPoints as c}from"../../../../../geometry/support/axisAngle.js";import{d as m,g as p}from"../../../../../chunks/sphere.js";import{applyAll as a}from"../../../camera/constraintUtils.js";import{InteractionType as h}from"../../../camera/constraintUtils/InteractionType.js";import{MomentumController as l}from"./MomentumController.js";import{applyZoomOnSphere as u,sphereOrPlanePointFromScreenPoint as j,applyRotation as y}from"../../utils/navigationUtils.js";let C=class extends l{set screenCenter(t){this._set("screenCenter",e(t[0],t[1]))}set sceneCenter(t){this._set("sceneCenter",o(t))}constructor(t){super(t),this.interactionType=h.ZOOM,this.radius=0,this._tmpSceneCenter=i(),this._tmpZoomAxisAngle=n(),this._sphere=m()}initialize(){this._sphere[3]=this.radius}momentumStep(t,e){const s=this.momentum.valueDelta(0,t);u(this._sphere,e,s),this.constraintOptions.interactionType=h.ZOOM,a(this.view,e,this.constraintOptions),j(this._sphere,e,this.screenCenter,this._tmpSceneCenter),c(this.sceneCenter,this._tmpSceneCenter,this._tmpZoomAxisAngle),y(e,p(this._sphere),this._tmpZoomAxisAngle),this.constraintOptions.interactionType=h.PAN}};t([s({constructOnly:!0})],C.prototype,"momentum",void 0),t([s({constructOnly:!0})],C.prototype,"screenCenter",null),t([s({constructOnly:!0})],C.prototype,"sceneCenter",null),t([s({constructOnly:!0})],C.prototype,"radius",void 0),C=t([r("esri.views.3d.state.controllers.momentum.ZoomSphericalMomentumController")],C);export{C as ZoomSphericalMomentumController};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import{createScreenPointArray as e}from"../../../../../core/screenUtils.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{clone as o,create as i}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n,fromPoints as c}from"../../../../../geometry/support/axisAngle.js";import{c as m,g as p}from"../../../../../chunks/sphere.js";import{applyAll as a}from"../../../camera/constraintUtils.js";import{InteractionType as h}from"../../../camera/constraintUtils/InteractionType.js";import{MomentumController as l}from"./MomentumController.js";import{applyZoomOnSphere as u,sphereOrPlanePointFromScreenPoint as j,applyRotation as y}from"../../utils/navigationUtils.js";let C=class extends l{set screenCenter(t){this._set("screenCenter",e(t[0],t[1]))}set sceneCenter(t){this._set("sceneCenter",o(t))}constructor(t){super(t),this.interactionType=h.ZOOM,this.radius=0,this._tmpSceneCenter=i(),this._tmpZoomAxisAngle=n(),this._sphere=m()}initialize(){this._sphere[3]=this.radius}momentumStep(t,e){const s=this.momentum.valueDelta(0,t);u(this._sphere,e,s),this.constraintOptions.interactionType=h.ZOOM,a(this.view,e,this.constraintOptions),j(this._sphere,e,this.screenCenter,this._tmpSceneCenter),c(this.sceneCenter,this._tmpSceneCenter,this._tmpZoomAxisAngle),y(e,p(this._sphere),this._tmpZoomAxisAngle),this.constraintOptions.interactionType=h.PAN}};t([s({constructOnly:!0})],C.prototype,"momentum",void 0),t([s({constructOnly:!0})],C.prototype,"screenCenter",null),t([s({constructOnly:!0})],C.prototype,"sceneCenter",null),t([s({constructOnly:!0})],C.prototype,"radius",void 0),C=t([r("esri.views.3d.state.controllers.momentum.ZoomSphericalMomentumController")],C);export{C as ZoomSphericalMomentumController};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{cyclicalPI as t}from"../../../../core/Cyclical.js";import{deg2rad as e,clamp as n,acosClamped as o,asinClamped as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as a}from"../../../../core/screenUtils.js";import{fromRotation as i,exactEquals as s,multiply as c,rotate as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as m,create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as p}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{f as h,e as g,g as M,l as y,h as b,m as d,s as x,n as j,k as v,a as z,c as P,b as I}from"../../../../chunks/vec32.js";import{create as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as S,axis as k,fromPoints as E,wrapAxisAngle as A}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as H,vectorCoordinates as U}from"../../../../geometry/support/coordinateSystem.js";import{create as G,intersectRay as q,fromNormalAndOffset as C}from"../../../../geometry/support/plane.js";import{j as F,h as R,g as V,d as T}from"../../../../chunks/sphere.js";import{angle as O}from"../../../../geometry/support/vector.js";import{sm4d as W,sv3d as B}from"../../../../geometry/support/vectorStacks.js";import{fromScreen as D,fromScreenAtEye as J}from"../../support/geometryUtils/ray.js";import{intersectScreen as K}from"../../support/geometryUtils/sphere.js";import{Camera as L}from"../../webgl-engine/lib/Camera.js";import{terrainId as N}from"../../webgl-engine/lib/verticalOffsetUtils.js";var Q;!function(t){t[t.Ellipsoid=0]="Ellipsoid",t[t.Silhouette=1]="Silhouette"}(Q||(Q={}));const X=30,Y=[1,3e8],Z=80,$=8,_=200,tt=1508e5,et=5,nt=50,ot=5,rt=10,at=90,it={exclude:new Set([N])};function st(t,e,n){return n[0]=e[0]/(t.fullWidth/t.pixelRatio),n[1]=e[1]/(t.fullHeight/t.pixelRatio),n}function ct(t){for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function lt(t,e,n){const o=i(W.get(),n[3],k(n));null==o||s(o,m)||(h(re,t.eye,e),g(re,re,o),t.eye=M(re,re,e),h(re,t.center,e),g(re,re,o),t.center=M(re,re,e),t.up=g(re,t.up,o))}function mt(t,e,n,o){return q(t,D(e,n,le),o)}function ut(t,e,n,o){return q(t,J(e,n,le),o)}function pt(t,e,n,o){const r=B.get();let a=1-n;h(r,e,t.eye);const i=y(r);let s=i*(1-a);a>=0&&s<o&&(s=o,a=-(s-i)/i),Math.abs(i-s)<1e-6||(b(r,r,a),t.eye=M(re,t.eye,r),t.center=d(re,t.center,e,a))}function ft(t,e,n){e.getScreenCenter(ht),K(t,e,ht,re)&&(e.center=re);const o=e.distance,r=o*n;if(Math.abs(o-r)<1e-6)return;const a=b(B.get(),e.viewForward,r);e.eye=h(re,e.center,a)}const ht=a();function gt(t,e){x(e,0,0,0);for(const n of t)M(e,e,n);b(e,e,1/t.length)}function Mt(t,e,n,o){return Math.sin(t/y(e))*(n+o.radius)}function yt(t,e,n,o){return Mt(Math.PI/2,e,n,o)+(t-Math.PI/2)}var bt;!function(t){t[t.Vertical=0]="Vertical",t[t.Horizontal=1]="Horizontal"}(bt||(bt={}));const dt={Elevation:3e4,Angle:e(16)},xt={Pole:.95,Angle:e(18),Tilt:45},jt=e(80);function vt(t,e,n,o,r,a){const i=w(),s=T();let c=!0,l=!0;return t.intersectScreen(n,i,a)?s[3]=y(i):(l=!1,e.aboveGround&&r!==Q.Ellipsoid?s[3]=Math.max(y(e.center),.9*o.radius):s[3]=y(e.eye)-e.relativeElevation,r===Q.Silhouette?wt(s,e,n,i):c=K(s,e,n,i)),{sphere:s,scenePickPoint:c?i:null,hasGeometryIntersection:l}}function zt(t,e,n){if(y(t.eye)-n.radius>dt.Elevation)return bt.Horizontal;J(t,e,me);return-Math.sign(t.relativeElevation)*(.5*Math.PI+O(t.eye,me.direction))<dt.Angle?bt.Vertical:bt.Horizontal}function Pt(t,e,n){h(It,n,e),t.eye=h(re,t.eye,It),t.center=h(re,t.center,It)}const It=w();function wt(t,e,n,o){const r=J(e,n,le);return null!=r&&(F(t,r,St),R(t,r,o)?!(z(St,r.origin)<z(o,r.origin))||(P(o,St),!1):(h(kt,e.eye,e.center),j(kt,kt),C(kt,-v(j(kt,kt),St),Et),q(Et,r,o),!1))}const St=w(),kt=w(),Et=G();function At(a,i,s,c,l,m){let u=0;if(I(se,a,i),h(ae,a,i),y(a)<=l||!c.aboveGround){I(s,ae,c.eye);const p=v(a,i)/(y(a)*y(i));if(p<.9999)u=o(p);else{const t=y(I(w(),a,i))/(y(a)*y(i));u=r(t)}const f=Math.cos(n(t.normalize(e(m)),0,jt));u=-u-Math.max(0,y(i)-l)/(f*l)}else h(Ht,c.eye,c.center),I(s,ae,Ht),u=-y(ae)/l;return j(s,s),b(s,s,y(se)),u}const Ht=w();function Ut(r,a,i,s){let c,l;const m=Math.cos(n(t.normalize(e(s)),0,jt));return c=a>i?-(a-i)/(m*i):a<-i?Math.PI-(a+i)/(m*i):o(a/i),l=r>i?-(r-i)/(m*i):r<-i?Math.PI-(r+i)/(m*i):o(r/i),(l-c)*i}function Gt(t,e,n,o,r,a,i,s,c,l){const m=Ut(t[2],e[2],a[3],s),u=c?Ut(t[0],e[0],a[3],180):e[0]-t[0],f=Math.sin(i)*u-Math.cos(i)*m,h=Math.cos(i)*u+Math.sin(i)*m;j(re,r);const g=c?f/Math.sqrt(Math.abs(a[3]**2-v(n,re)**2)):f/a[3],M=h/Math.sqrt(Math.abs(a[3]**2-v(n,o)**2));p(l,g,M)}function qt(t,e,n,o,r,a,i,s,c,l){I(se,t,e),H(a.up,a.eye,Nt,Qt,Xt),H([0,0,1],a.eye,Jt,Kt,Lt),P(n,Kt),P(o,Jt),j(n,n),b(n,n,y(se)),U(t,j(Qt,Qt),j(Xt,Xt),j(Nt,Nt),Yt),U(e,Qt,Xt,Nt,Zt),Gt(Yt,Zt,t,Jt,Kt,i,s,c,l,r)}function Ct(t,e,n,o,r,a,s){i(te,r,o),i(ee,s,a),c(ne,te,ee),h(e,t,n),g(e,e,ne),M(e,e,n)}function Ft(t,e,n,o,r,a){i(te,o,n),i(ee,a,r),c(ne,te,ee),h(re,t.eye,e),g(re,re,ne),t.eye=M(re,re,e),h(re,t.center,e),g(re,re,ne),t.center=M(re,re,e),h(re,t.up,e),g(re,re,ne),t.up=M(re,re,e)}function Rt(t,e,n,o,r,a){return(Math.abs(o)>Math.PI-xt.Angle||Math.abs(o)<xt.Angle)&&(Math.abs(t[2])<n*xt.Pole||Math.abs(e)>n)&&a.aboveGround&&r<xt.Tilt}function Vt(t,e,n,o,r,a){if(a)E(n,o,_t),lt(e,V(t),_t);else{const a=At(n,o,ce,e,t[3],r);lt(e,V(t),A(ce,a))}}function Tt(t,e,n,o,r,a,i){const s=i?20:1,c=1e-12;let l,m;P(oe,o),ie.copyFrom(e);for(let u=0;u<s&&z(n,oe)>c&&(l=z(n,oe),qt(n,oe,Kt,Jt,$t,ie,t,r,a,i),Ft(ie,V(t),Jt,$t[1],Kt,$t[0]),Ct(oe,oe,V(t),Jt,$t[1],Kt,$t[0]),m=z(n,oe),m<l||0===u);u++)e.copyFrom(ie)}function Ot(n,o,r,a,i,s,c){Rt(r,v(o.up,r),n[3],-t.normalize(e(i)),s,o)?Tt(n,o,r,a,-t.normalize(e(i)),s,c):Vt(n,o,r,a,s,c)}function Wt(t,e,n,o,r,a){const{eye:i}=t;H([0,0,1],i,Jt,Kt,Lt);const s=e.translation[0]*n.pan,c="zoom"===r.mode?0:e.translation[1]*n.pan,m=Math.max(Math.sqrt(Math.abs(1-v(t.center,Jt)**2/y(t.center)**2)),.5),u=(Math.sin(a)*c+Math.cos(a)*s)/m,p=-Math.cos(a)*c+Math.sin(a)*s;switch(l(o.pan.matrix,o.pan.matrix,u,Jt),o.pan.enabled=!0,r.mode){case"pan":l(o.pan.matrix,o.pan.matrix,p,Kt),o.pan.enabled=!0;break;case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Bt(t,e,n,o,r){const{eye:a,viewRight:i}=t,s=I(B.get(),i,a),c=e.translation[0]*n.pan;switch(0!==c&&(l(o.pan.matrix,o.pan.matrix,-c,s),o.pan.enabled=!0),r.mode){case"pan":{const t=e.translation[1]*n.pan;0!==t&&(l(o.pan.matrix,o.pan.matrix,t,i),o.pan.enabled=!0);break}case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Dt(n,o,r,a,i,s,c,l,m){Rt(n.center,v(n.up,n.center),y(n.center),-t.normalize(e(s)),c,o)?Wt(o,r,a,l,m,-t.normalize(e(i))):Bt(o,r,a,l,m)}const Jt=w(),Kt=w(),Lt=w(),Nt=w(),Qt=w(),Xt=w(),Yt=w(),Zt=w(),$t=f(),_t=S(),te=u(),ee=u(),ne=u(),oe=w(),re=w(),ae=w(),ie=new L,se=w(),ce=w(),le={origin:w(),direction:w()},me={origin:w(),direction:w()};export{bt as NavigationMode,xt as PreservingHeadingThreshold,Q as SpherePickPointFallback,jt as TiltThresholdPanningSpeed,dt as VerticalPanTresholds,Pt as applyPanPlanar,Vt as applyPanSphericalDirectRotation,Tt as applyPanSphericalPreserveHeading,lt as applyRotation,Ft as applyRotationWithTwoAxes,ft as applyZoomOnSphere,pt as applyZoomToPoint,gt as centroid,it as contentIntersectorOptions,zt as decideNavigationMode,Y as distanceClampValues,mt as intersectPlaneFromScreenPoint,ut as intersectPlaneFromScreenPointAtEye,Ut as lengthFromPoints,nt as minHeightLimit,st as normalizeCoordinate,ct as normalizeRotationDelta,yt as offSurfaceTiltToEyeTiltGlobal,Mt as onSurfaceTiltToEyeTiltGlobal,et as panDistanceModifier,Dt as panMotionToRotationMatrix,Ot as panToPosition,vt as pickPointAndInitSphere,X as pivotDistanceModifier,Rt as preserveHeadingThreshold,ot as rotatePivotDistanceModifier,rt as rotatePivotMinDistanceModifier,Ct as rotatePointAroundTwoAxes,at as rotateScreenPixelArea,At as rotationAngleAndAxisDirectRotation,qt as rotationAnglesAndAxesHeadingPreserving,Gt as rotationAnglesHeadingPreserving,Z as screenPixelArea,wt as sphereOrPlanePointFromScreenPoint,$ as zoomDistanceModifier,tt as zoomMaxDistanceModifier,_ as zoomMinDistanceModifier};
5
+ import{cyclicalPI as t}from"../../../../core/Cyclical.js";import{deg2rad as e,clamp as n,acosClamped as o,asinClamped as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as a}from"../../../../core/screenUtils.js";import{fromRotation as i,exactEquals as s,multiply as c,rotate as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as m,create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as p}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{f as h,e as g,g as M,l as y,h as b,m as d,s as x,n as v,k as j,a as z,c as P,b as I}from"../../../../chunks/vec32.js";import{create as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as S,axis as k,fromPoints as E,wrapAxisAngle as A}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as H,vectorCoordinates as U}from"../../../../geometry/support/coordinateSystem.js";import{create as G,intersectRay as q,fromNormalAndOffset as C}from"../../../../geometry/support/plane.js";import{e as F,i as R,g as V,c as T}from"../../../../chunks/sphere.js";import{angle as O}from"../../../../geometry/support/vector.js";import{sm4d as W,sv3d as B}from"../../../../geometry/support/vectorStacks.js";import{fromScreen as D,fromScreenAtEye as J}from"../../support/geometryUtils/ray.js";import{intersectScreen as K}from"../../support/geometryUtils/sphere.js";import{Camera as L}from"../../webgl-engine/lib/Camera.js";import{terrainId as N}from"../../webgl-engine/lib/verticalOffsetUtils.js";var Q;!function(t){t[t.Ellipsoid=0]="Ellipsoid",t[t.Silhouette=1]="Silhouette"}(Q||(Q={}));const X=30,Y=[1,3e8],Z=80,$=8,_=200,tt=1508e5,et=5,nt=50,ot=5,rt=10,at=90,it={exclude:new Set([N])};function st(t,e,n){return n[0]=e[0]/(t.fullWidth/t.pixelRatio),n[1]=e[1]/(t.fullHeight/t.pixelRatio),n}function ct(t){for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function lt(t,e,n){const o=i(W.get(),n[3],k(n));null==o||s(o,m)||(h(re,t.eye,e),g(re,re,o),t.eye=M(re,re,e),h(re,t.center,e),g(re,re,o),t.center=M(re,re,e),t.up=g(re,t.up,o))}function mt(t,e,n,o){return q(t,D(e,n,le),o)}function ut(t,e,n,o){return q(t,J(e,n,le),o)}function pt(t,e,n,o){const r=B.get();let a=1-n;h(r,e,t.eye);const i=y(r);let s=i*(1-a);a>=0&&s<o&&(s=o,a=-(s-i)/i),Math.abs(i-s)<1e-6||(b(r,r,a),t.eye=M(re,t.eye,r),t.center=d(re,t.center,e,a))}function ft(t,e,n){e.getScreenCenter(ht),K(t,e,ht,re)&&(e.center=re);const o=e.distance,r=o*n;if(Math.abs(o-r)<1e-6)return;const a=b(B.get(),e.viewForward,r);e.eye=h(re,e.center,a)}const ht=a();function gt(t,e){x(e,0,0,0);for(const n of t)M(e,e,n);b(e,e,1/t.length)}function Mt(t,e,n,o){return Math.sin(t/y(e))*(n+o.radius)}function yt(t,e,n,o){return Mt(Math.PI/2,e,n,o)+(t-Math.PI/2)}var bt;!function(t){t[t.Vertical=0]="Vertical",t[t.Horizontal=1]="Horizontal"}(bt||(bt={}));const dt={Elevation:3e4,Angle:e(16)},xt={Pole:.95,Angle:e(18),Tilt:45},vt=e(80);function jt(t,e,n,o,r,a){const i=w(),s=T();let c=!0,l=!0;return t.intersectScreen(n,i,a)?s[3]=y(i):(l=!1,e.aboveGround&&r!==Q.Ellipsoid?s[3]=Math.max(y(e.center),.9*o.radius):s[3]=y(e.eye)-e.relativeElevation,r===Q.Silhouette?wt(s,e,n,i):c=K(s,e,n,i)),{sphere:s,scenePickPoint:c?i:null,hasGeometryIntersection:l}}function zt(t,e,n){if(y(t.eye)-n.radius>dt.Elevation)return bt.Horizontal;J(t,e,me);return-Math.sign(t.relativeElevation)*(.5*Math.PI+O(t.eye,me.direction))<dt.Angle?bt.Vertical:bt.Horizontal}function Pt(t,e,n){h(It,n,e),t.eye=h(re,t.eye,It),t.center=h(re,t.center,It)}const It=w();function wt(t,e,n,o){const r=J(e,n,le);return null!=r&&(F(t,r,St),R(t,r,o)?!(z(St,r.origin)<z(o,r.origin))||(P(o,St),!1):(h(kt,e.eye,e.center),v(kt,kt),C(kt,-j(v(kt,kt),St),Et),q(Et,r,o),!1))}const St=w(),kt=w(),Et=G();function At(a,i,s,c,l,m){let u=0;if(I(se,a,i),h(ae,a,i),y(a)<=l||!c.aboveGround){I(s,ae,c.eye);const p=j(a,i)/(y(a)*y(i));if(p<.9999)u=o(p);else{const t=y(I(w(),a,i))/(y(a)*y(i));u=r(t)}const f=Math.cos(n(t.normalize(e(m)),0,vt));u=-u-Math.max(0,y(i)-l)/(f*l)}else h(Ht,c.eye,c.center),I(s,ae,Ht),u=-y(ae)/l;return v(s,s),b(s,s,y(se)),u}const Ht=w();function Ut(r,a,i,s){let c,l;const m=Math.cos(n(t.normalize(e(s)),0,vt));return c=a>i?-(a-i)/(m*i):a<-i?Math.PI-(a+i)/(m*i):o(a/i),l=r>i?-(r-i)/(m*i):r<-i?Math.PI-(r+i)/(m*i):o(r/i),(l-c)*i}function Gt(t,e,n,o,r,a,i,s,c,l){const m=Ut(t[2],e[2],a[3],s),u=c?Ut(t[0],e[0],a[3],180):e[0]-t[0],f=Math.sin(i)*u-Math.cos(i)*m,h=Math.cos(i)*u+Math.sin(i)*m;v(re,r);const g=c?f/Math.sqrt(Math.abs(a[3]**2-j(n,re)**2)):f/a[3],M=h/Math.sqrt(Math.abs(a[3]**2-j(n,o)**2));p(l,g,M)}function qt(t,e,n,o,r,a,i,s,c,l){I(se,t,e),H(a.up,a.eye,Nt,Qt,Xt),H([0,0,1],a.eye,Jt,Kt,Lt),P(n,Kt),P(o,Jt),v(n,n),b(n,n,y(se)),U(t,v(Qt,Qt),v(Xt,Xt),v(Nt,Nt),Yt),U(e,Qt,Xt,Nt,Zt),Gt(Yt,Zt,t,Jt,Kt,i,s,c,l,r)}function Ct(t,e,n,o,r,a,s){i(te,r,o),i(ee,s,a),c(ne,te,ee),h(e,t,n),g(e,e,ne),M(e,e,n)}function Ft(t,e,n,o,r,a){i(te,o,n),i(ee,a,r),c(ne,te,ee),h(re,t.eye,e),g(re,re,ne),t.eye=M(re,re,e),h(re,t.center,e),g(re,re,ne),t.center=M(re,re,e),h(re,t.up,e),g(re,re,ne),t.up=M(re,re,e)}function Rt(t,e,n,o,r,a){return(Math.abs(o)>Math.PI-xt.Angle||Math.abs(o)<xt.Angle)&&(Math.abs(t[2])<n*xt.Pole||Math.abs(e)>n)&&a.aboveGround&&r<xt.Tilt}function Vt(t,e,n,o,r,a){if(a)E(n,o,_t),lt(e,V(t),_t);else{const a=At(n,o,ce,e,t[3],r);lt(e,V(t),A(ce,a))}}function Tt(t,e,n,o,r,a,i){const s=i?20:1,c=1e-12;let l,m;P(oe,o),ie.copyFrom(e);for(let u=0;u<s&&z(n,oe)>c&&(l=z(n,oe),qt(n,oe,Kt,Jt,$t,ie,t,r,a,i),Ft(ie,V(t),Jt,$t[1],Kt,$t[0]),Ct(oe,oe,V(t),Jt,$t[1],Kt,$t[0]),m=z(n,oe),m<l||0===u);u++)e.copyFrom(ie)}function Ot(n,o,r,a,i,s,c){Rt(r,j(o.up,r),n[3],-t.normalize(e(i)),s,o)?Tt(n,o,r,a,-t.normalize(e(i)),s,c):Vt(n,o,r,a,s,c)}function Wt(t,e,n,o,r,a){const{eye:i}=t;H([0,0,1],i,Jt,Kt,Lt);const s=e.translation[0]*n.pan,c="zoom"===r.mode?0:e.translation[1]*n.pan,m=Math.max(Math.sqrt(Math.abs(1-j(t.center,Jt)**2/y(t.center)**2)),.5),u=(Math.sin(a)*c+Math.cos(a)*s)/m,p=-Math.cos(a)*c+Math.sin(a)*s;switch(l(o.pan.matrix,o.pan.matrix,u,Jt),o.pan.enabled=!0,r.mode){case"pan":l(o.pan.matrix,o.pan.matrix,p,Kt),o.pan.enabled=!0;break;case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Bt(t,e,n,o,r){const{eye:a,viewRight:i}=t,s=I(B.get(),i,a),c=e.translation[0]*n.pan;switch(0!==c&&(l(o.pan.matrix,o.pan.matrix,-c,s),o.pan.enabled=!0),r.mode){case"pan":{const t=e.translation[1]*n.pan;0!==t&&(l(o.pan.matrix,o.pan.matrix,t,i),o.pan.enabled=!0);break}case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Dt(n,o,r,a,i,s,c,l,m){Rt(n.center,j(n.up,n.center),y(n.center),-t.normalize(e(s)),c,o)?Wt(o,r,a,l,m,-t.normalize(e(i))):Bt(o,r,a,l,m)}const Jt=w(),Kt=w(),Lt=w(),Nt=w(),Qt=w(),Xt=w(),Yt=w(),Zt=w(),$t=f(),_t=S(),te=u(),ee=u(),ne=u(),oe=w(),re=w(),ae=w(),ie=new L,se=w(),ce=w(),le={origin:w(),direction:w()},me={origin:w(),direction:w()};export{bt as NavigationMode,xt as PreservingHeadingThreshold,Q as SpherePickPointFallback,vt as TiltThresholdPanningSpeed,dt as VerticalPanTresholds,Pt as applyPanPlanar,Vt as applyPanSphericalDirectRotation,Tt as applyPanSphericalPreserveHeading,lt as applyRotation,Ft as applyRotationWithTwoAxes,ft as applyZoomOnSphere,pt as applyZoomToPoint,gt as centroid,it as contentIntersectorOptions,zt as decideNavigationMode,Y as distanceClampValues,mt as intersectPlaneFromScreenPoint,ut as intersectPlaneFromScreenPointAtEye,Ut as lengthFromPoints,nt as minHeightLimit,st as normalizeCoordinate,ct as normalizeRotationDelta,yt as offSurfaceTiltToEyeTiltGlobal,Mt as onSurfaceTiltToEyeTiltGlobal,et as panDistanceModifier,Dt as panMotionToRotationMatrix,Ot as panToPosition,jt as pickPointAndInitSphere,X as pivotDistanceModifier,Rt as preserveHeadingThreshold,ot as rotatePivotDistanceModifier,rt as rotatePivotMinDistanceModifier,Ct as rotatePointAroundTwoAxes,at as rotateScreenPixelArea,At as rotationAngleAndAxisDirectRotation,qt as rotationAnglesAndAxesHeadingPreserving,Gt as rotationAnglesHeadingPreserving,Z as screenPixelArea,wt as sphereOrPlanePointFromScreenPoint,$ as zoomDistanceModifier,tt as zoomMaxDistanceModifier,_ as zoomMinDistanceModifier};