@arcgis/core 4.27.0-next.20230321 → 4.27.0-next.20230322

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 (136) hide show
  1. package/analysis/LineOfSightAnalysisObserver.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/02b6227c156ee0d8eb66.js +1 -0
  4. package/assets/esri/core/workers/chunks/{7e0c65aa61c2ff0c3504.js → 1c98b92933a48cf96c1e.js} +1 -1
  5. package/assets/esri/core/workers/chunks/321f272d4c7ed6b0cb46.js +1 -0
  6. package/assets/esri/core/workers/chunks/47bd558e2ce89f47f908.js +1 -0
  7. package/assets/esri/core/workers/chunks/76d6c1fc25f02bcf258e.js +1 -0
  8. package/assets/esri/core/workers/chunks/{c5d872adce711ec61ede.js → 8980c5dc389c27368b73.js} +1 -1
  9. package/assets/esri/core/workers/chunks/8d0143c0ff009b98a31f.js +1 -0
  10. package/assets/esri/core/workers/chunks/{6acaf28cba5d49a98fb6.js → 91b292f310f06a0cbf72.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{ff9efa829497557ec26a.js → aa4640a0207e0be224e2.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{92951b85676df776961f.js → ab8139e3a875a8b8dab9.js} +23 -25
  13. package/assets/esri/core/workers/chunks/{c8cd3fde6d8d43ddb954.js → b6cdf4daf07d9e55f61e.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{6b14673a4afd6ef81487.js → c76cabd2d2510a653dff.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{4be7647605300e07e843.js → c90fff7e28ba5b443b11.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{e637e47000f4dc48054d.js → cc7f4fd20443a2acf0f1.js} +1 -1
  17. package/assets/esri/core/workers/chunks/d19e9fab4f4fb765c6a3.js +1 -0
  18. package/assets/esri/core/workers/chunks/d9ef4891c8b0bdd90f5b.js +1 -0
  19. package/assets/esri/core/workers/chunks/{d92d6a43270fb0d366b4.js → de4f5c48efbcee82c3c1.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{32f9b488915a4a8864e5.js → f8b9e0c1671e55b61904.js} +1 -1
  21. package/assets/esri/views/3d/analysis/Slice/images/heading-rotate.ts.svg +7 -28
  22. package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.ts.svg +11 -0
  23. package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
  24. package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
  25. package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
  26. package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
  27. package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
  28. package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
  29. package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
  30. package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
  31. package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
  32. package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
  33. package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
  34. package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
  35. package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
  36. package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
  37. package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
  38. package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
  39. package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
  40. package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
  41. package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
  42. package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
  43. package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
  44. package/assets/esri/widgets/Editor/t9n/Editor_nb.json +1 -1
  45. package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
  46. package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
  47. package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
  48. package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
  49. package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
  50. package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
  51. package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
  52. package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
  53. package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
  54. package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
  55. package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
  56. package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
  57. package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
  58. package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
  59. package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
  60. package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
  61. package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
  62. package/chunks/ComponentShader.glsl.js +1 -1
  63. package/chunks/DefaultMaterial.glsl.js +4 -4
  64. package/chunks/vec42.js +1 -1
  65. package/core/Loadable.js +1 -1
  66. package/core/accessorSupport/Property.js +1 -1
  67. package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
  68. package/geometry/support/buffer/math/vec4.js +1 -1
  69. package/interfaces.d.ts +1 -1
  70. package/layers/LineOfSightLayer.js +1 -1
  71. package/layers/SceneLayer.js +1 -1
  72. package/layers/mixins/ImageryTileMixin.js +1 -1
  73. package/layers/mixins/RefreshableLayer.js +1 -1
  74. package/layers/support/rasterFunctions/clipUtils.js +1 -1
  75. package/layers/support/rasterFunctions/stretchUtils.js +1 -1
  76. package/package.json +1 -1
  77. package/support/revision.js +1 -1
  78. package/views/2d/engine/vectorTiles/TileHandler.js +1 -1
  79. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  80. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  81. package/views/3d/analysis/Slice/images/Factory.js +1 -1
  82. package/views/3d/analysis/Slice/images/generateTextures.js +1 -1
  83. package/views/3d/analysis/Slice/images/heading-rotate-svg.js +1 -1
  84. package/views/3d/analysis/Slice/images/tilt-rotate-svg.js +5 -0
  85. package/views/3d/analysis/Slice/settings.js +5 -0
  86. package/views/3d/environment/Stars.js +1 -1
  87. package/views/3d/interactive/Manipulator3D.js +1 -1
  88. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  89. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  90. package/views/3d/layers/PointCloudWorker.js +1 -1
  91. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  92. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  93. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  94. package/views/3d/layers/i3s/PointCloudRendererUtil.js +1 -1
  95. package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
  96. package/views/3d/layers/i3s/PointGraphic.js +1 -1
  97. package/views/3d/state/ViewState.js +1 -1
  98. package/views/3d/state/controllers/SurfaceCollisionCorrectionController.js +1 -1
  99. package/views/3d/terrain/GeometryState.js +1 -1
  100. package/views/3d/terrain/PatchGeometry.js +1 -1
  101. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  102. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  103. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  104. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  105. package/views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js +6 -5
  106. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +1 -1
  107. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +11 -11
  108. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeShadingNormal.glsl.js +1 -1
  109. package/views/3d/webgl-engine/lib/AnimationTimeStep.js +1 -1
  110. package/views/3d/webgl-engine/lib/AttributeArray.js +1 -1
  111. package/views/3d/webgl-engine/lib/DefaultVertexAttributeLocations.js +1 -1
  112. package/views/3d/webgl-engine/lib/Normals.js +5 -0
  113. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  114. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  115. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  116. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  117. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  118. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  119. package/views/3d/webgl-engine/shaders/RealisticTreeTechnique.js +1 -1
  120. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  121. package/views/LayerViewManager.js +1 -1
  122. package/views/SceneView.js +1 -1
  123. package/views/layers/SceneLayerView.js +1 -1
  124. package/views/webgl/ShaderTranspiler.js +1 -1
  125. package/widgets/Expand.js +1 -1
  126. package/assets/esri/core/workers/chunks/0487ab23a20ec356ab4c.js +0 -1
  127. package/assets/esri/core/workers/chunks/29ee4f14602caf6967e4.js +0 -1
  128. package/assets/esri/core/workers/chunks/2c0775541cfec9d43acb.js +0 -1
  129. package/assets/esri/core/workers/chunks/4879164b48da9ad4547a.js +0 -1
  130. package/assets/esri/core/workers/chunks/69060e5cffc19e76062a.js +0 -1
  131. package/assets/esri/core/workers/chunks/a71a5c8a9aa302bf6f01.js +0 -1
  132. package/assets/esri/core/workers/chunks/bc002e4dff8859571a7a.js +0 -1
  133. package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.svg +0 -80
  134. package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.ts.png +0 -0
  135. package/views/3d/analysis/Slice/images/tilt-rotate-png.js +0 -5
  136. package/views/3d/webgl-engine/core/shaderLibrary/util/DecodeNormal.glsl.js +0 -8
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{result as t,forEach as i}from"../../../core/asyncUtils.js";import r from"../../../core/Collection.js";import s from"../../../core/Logger.js";import{destroyMaybe as o,abortMaybe as n,isSome as a}from"../../../core/maybe.js";import{eachAlways as d,isAbortError as l,eachAlwaysValues as h,throwIfAborted as u}from"../../../core/promiseUtils.js";import{initial as p,watch as c,sync as _}from"../../../core/reactiveUtils.js";import{pt2px as m}from"../../../core/screenUtils.js";import{estimateSize as g,isArrayBuffer as f}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as y}from"../../../core/unitUtils.js";import{property as b}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as w}from"../../../core/accessorSupport/decorators/subclass.js";import{e as N,c as P}from"../../../chunks/vec3.js";import{b as x}from"../../../chunks/vec3f32.js";import{projectBoundingRect as v}from"../../../geometry/projection.js";import{create as C}from"../../../geometry/support/aaBoundingBox.js";import{containsPoint as S,create as A}from"../../../geometry/support/aaBoundingRect.js";import{create as I,fromNormalAndOffset as k}from"../../../geometry/support/plane.js";import{makeDehydratedPoint as V}from"../../../layers/graphics/dehydratedFeatures.js";import{CodedValue as R}from"../../../layers/support/CodedValue.js";import"../../../core/has.js";import L from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as j}from"../../../layers/support/fieldUtils.js";import{PromiseQueue as Q}from"../../../layers/support/PromiseQueue.js";import{getMetersPerUnit as U}from"../../../symbols/support/unitConversionUtils.js";import{LayerView3D as D}from"./LayerView3D.js";import{PointCloudWorkerHandle as F}from"./PointCloudWorkerHandle.js";import{checkPointCloudLayerValid as z,checkPointCloudLayerCompatibleWithView as M}from"./i3s/I3SUtil.js";import{nodeDiff as W,sortFrontToBack as E,splitWorkEntries as O}from"./i3s/LoDUtil.js";import B from"./i3s/PagedNodeIndex.js";import{getSplatSizeAlgorithm as G,getFixedSizeAlgorithm as H,getRendererInfo as q,getFilterInfo as T,rendererUsesFixedSizes as $,getAttributeInfo as J}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as K,readGeometry as X,elevationFromPositions as Y}from"./i3s/PointCloudWorkerUtil.js";import{PointGraphic as Z}from"./i3s/PointGraphic.js";import{PointRenderer as ee,isInstanceOfNode as te,PointRendererNode as ie}from"./i3s/PointRenderer.js";import{PopupSceneLayerView as re}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as se}from"../support/extentUtils.js";import{ClientType as oe}from"../support/index.js";import{minimumDistancePlane as ne}from"../support/orientedBoundingBox.js";import{updatingProgress as ae}from"../support/updatingProperties.js";import{RenderSlot as de}from"../webgl-engine/lib/RenderSlot.js";import le from"../../layers/LayerView.js";import{isScaleRangeActive as he,extractSafeScaleBounds as ue,scaleBoundsPredicate as pe}from"../../support/layerViewUtils.js";import{TaskPriority as ce}from"../../support/Scheduler.js";const _e=8,me=I();let ge=class extends(re(D(le))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._nodeScales=new Map,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new Q,this._indexPagesLoading=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl.path}get pointScale(){const e=G(this.layer&&this.layer.renderer),t=1;return e&&null!=e.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=H(this.layer&&this.layer.renderer),t=!1;return e&&null!=e.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=H(this.layer&&this.layer.renderer),t=0;return e&&null!=e.size?e.size:t}get inverseDensity(){const e=96;return this.layer&&this.layer.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=q(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=T(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of j(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=C(),t=this.view.renderSpatialReference;return se(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;if(e&&"absolute-height"===e.mode){const t=y(this.layer.spatialReference),i=U(e.unit);return(e.offset??0)*i/t}return 0}initialize(){const e=this.view.resourceController,t=Ne(e);this._worker=new F(t),this.addResolvingPromise(this._worker.promise),this._tmpPoint=V(0,0,0,this.layer.spatialReference),z(this.layer),M(this.layer,this.view),this._indexRequester=e.createStreamDataRequester(oe.I3S_INDEX),this._dataRequester=e.createStreamDataRequester(oe.I3S_DATA),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(this.layer.uid),this.updatingHandles.add((()=>this._clippingBox),(()=>this._setUpdateViewNeeded()),p),this.updatingHandles.add((()=>this._elevationOffset),(()=>this._elevationOffsetChanged()),p),this.updatingHandles.add((()=>this.layer.renderer),(()=>this._rendererChanged()),p),this.updatingHandles.add((()=>this.layer.filters),(()=>this._reload()),p),this.updatingHandles.add((()=>this.layer.outFields),(()=>this._reload()),p),this.updatingHandles.add((()=>this.layer.effectiveScaleRange),(()=>this._setUpdateViewNeeded())),this.updatingHandles.add((()=>this.view.state.contentCamera),(()=>this._setUpdateViewNeeded())),this.handles.add([this.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),c((()=>r.memoryFactor),(()=>this._setUpdateViewNeeded()),_)]),this.addResolvingPromise(i),this.when((()=>{this.handles.add([e.scheduler.registerTask(ce.POINT_CLOUD_LAYER,this),e.scheduler.registerIdleStateCallbacks((()=>this._idleBegin()),(()=>this._idleEnd())),this.updatingHandles.add((()=>this.suspended),(e=>{e?this._clearNodeState():this._setUpdateViewNeeded()}),p)])}),(()=>{this.updatingHandles.removeAll(),this.handles.removeAll()}))}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=o(this._worker),this._destroyRenderer(),this._memCache=o(this._memCache),this._codedDomainPopulationAbortController=n(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new ee({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerUid=this.layer.uid,this.updatingHandles.add((()=>this._clippingBox),(e=>this._renderer.clippingBox=e),p),this.updatingHandles.add((()=>this.suspended),(e=>this._setPointsVisible(!e)),p),this.updatingHandles.add((()=>this.pointScale),(e=>this._renderer.scaleFactor=e),p),this._renderer.minSizePx=Math.sqrt(2),this.updatingHandles.add((()=>this.useRealWorldSymbolSizes),(e=>this._renderer.useRealWorldSymbolSizes=e),p),this.updatingHandles.add((()=>this.pointSize),(e=>{const t=m(e);this._renderer.size=e,this._renderer.sizePx=t}),p),this.updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._renderer.slicePlaneEnabled=e),p),this.updatingHandles.add((()=>this.inverseDensity),(()=>this._setUpdateViewNeeded()),p),this.updatingHandles.add((()=>this.maximumPointCount),(()=>this._setUpdateViewNeeded()),p),this.updatingHandles.add((()=>this.view.qualitySettings.sceneService.pointCloud.lodFactor),(e=>{this._lodFactor=e,this._setUpdateViewNeeded()}),p)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i){const r=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,s=this.view.computeMapPointFromVec3d(i),o=this._createGraphicAttributes(e,r);return new Z({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:r,epoch:this._nodeLoadEpoch},geometry:s,attributes:o,layer:this.layer,sourceLayer:this.layer})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_encodeGraphicAttribute(e,t,i,r){const s=e.storageInfo?.attributeValues,o=s?.valuesPerElement??1;if(1===o)r[e.name]=t[i];else if("UInt8"===s?.valueType&&o<=4){let s=0;const n=i*o;for(let e=n;e<n+o;e++)s=(s<<8)+t[e];r[e.name]=s}else r[e.name]=void 0}_setPointsVisible(e){e&&!this._rendererAdded?(this.view._stage.addRenderPlugin([de.OPAQUE_MATERIAL],this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view._stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=$(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_scaleUpdateHandler(e){const t=this.layer.effectiveScaleRange;he(t.minScale,t.maxScale)?v(e.extent,e.spatialReference,be,this.layer.spatialReference)&&(this._nodeScales.forEach(((t,i)=>{if(!this._renderedNodes.has(i))return void this._nodeScales.delete(i);const r=this._index.getNode(i);S(be,r.obb.center)&&this._nodeScales.set(i,e.scale)})),this._setUpdateViewNeeded()):this._nodeScales.clear()}_displayNodes(e){this._workQueue=W([...this._renderedNodes],e,this._index),E(this._workQueue,this.view.state.contentCamera.viewForward,this._index),O(this._workQueue,_e,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){const e=new Array;this._loadingNodes.forEach((({abortController:t})=>e.push(t))),this._loadingNodes.clear();for(const t of e)t.abort();this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach((t=>t.load.forEach((t=>e.add(t)))));const t=new Array,i=new Map;this._loadingNodes.forEach(((r,s)=>{e.has(s)?i.set(s,r):t.push(r)})),this._loadingNodes=i;for(const{abortController:r}of t)r.abort();this._workQueue=this._workQueue.filter((e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0})),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._indexPagesLoading.forEach((({abortController:e})=>e.abort())),this._indexPagesLoading.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach((e=>this._removeFromRenderer(e))),this._cancelNodeLoading()}_idleBegin(){this._setUpdateViewNeeded()}_idleEnd(){this._setUpdateViewNeeded()}get running(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.running}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run((()=>this._updateWorkQueues()));this._indexQueue.length>0&&e.run((()=>this._processIndexQueue())););this._processWorkQueue(e),this._idleQueue.runTask(e)}}_processIndexQueue(){const e=this._indexQueue.shift(),t=this._loadNodePage(e);return this._indexPagesLoading.set(e,t),t.promise.then((t=>{this._index.addPage(e,t,this._elevationOffset),this._setUpdateViewNeeded()})).then((()=>{this._indexPagesLoading.delete(e)}),(()=>{this._indexPagesLoading.delete(e)})),!0}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return;this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find((e=>!this._renderedNodes.has(e))))return e;this._workQueue.push(e)}return null}_processWorkEntry(e){if(0!==e.load.length)Promise.all(e.load.map((e=>{const t=new AbortController,i=this._memCache.pop(e.toString());return null!=i?this._loadingNodes.set(e,{abortController:t,promise:Promise.resolve(i)}):this._loadingNodes.has(e)||this._loadingNodes.set(e,{abortController:t,promise:this._loadNode(e,t.signal)}),this._loadingNodes.get(e).promise}))).then((t=>{for(let i=0;i<e.load.length;i++)if(t[i]){const r=this._setupRendererData(e.load[i],t[i]);this._addToRenderer(r)}for(const i of e.remove)this._removeFromRenderer(i)})).catch((()=>{})).then((()=>{for(const t of e.load)this._loadingNodes.delete(t);this._updateLoading(),this._recalcWork&&!this._idleQueue.running&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())})),this._updateLoading();else for(const t of e.remove)this._removeFromRenderer(t)}async _populateClassCodeCodedDomain(e,i){const r="CLASS_CODE",s=this.layer.fieldsIndex.get(r);if(!s||s.domain)return;if(!e.includes(s.name))return;const o=await t(this.layer.queryCachedStatistics(r,{signal:i}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(s.domain=new L({name:"CLASS_CODE",codedValues:n.map((e=>new R({code:e.value,name:e.label})))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then((()=>{this._codedDomainPopulationAbortController=null}))),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const r=this._splitGraphicsPerNode(e),s=this.layer.attributeStorageInfo,o=t.map((e=>J(s,e))).filter(a),n=async(e,t)=>{const r=this._index.getNode(t);await i(o,(async t=>{const i=t.useElevation?await this._loadElevationAttributeFromGeometry(r.resourceId):await this._loadAndParseAttribute(r,t);if(i)for(const r of e)if(this._isValidPointGraphic(r)){const e=r.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,i,e,r.attributes)}}))},l=[];return r.forEach(((e,t)=>{l.push(n(e,t))})),await d(l),e}_isValidPointGraphic(e){return e instanceof Z&&e.pointCloudMetadata&&e.pointCloudMetadata.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return null!=i?K({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=X(t,await this._loadGeometry(e,null));return Y(i,i.length/3)}highlight(e){if(!e)return{remove(){}};const t=r.isCollection(e)?e.toArray():Array.isArray(e)?e:[e];return this._renderer.highlight(t.map((e=>this._graphicToPointDefinition(e))))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._indexPagesLoading.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}_initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;return this._index=new B(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock,this._loadNodePage(0).promise.then((e=>{this._index.addPage(0,e,this._elevationOffset),this._loadingInitNodePage=!1,this._setUpdateViewNeeded()}))}_loadNodePage(e){const t=new AbortController,i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return{promise:this._requestNodePage(i,t.signal).then((t=>t.nodes.map(((t,i)=>({resourceId:null!=t.resourceId?t.resourceId:e*this._index.pageSize+i,obb:t.obb,firstChild:t.firstChild,childCount:t.childCount,vertexCount:t.vertexCount??t.pointCount,lodThreshold:t.lodThreshold??t.effectiveArea}))))),abortController:t}}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;let e=this.inverseDensity/this._lodFactor*this._getLodMemoryFactor();const t=this.maximumPointCount*this._lodFactor*this._getLodMemoryFactor();let i=this._computeNodesForMinimumDensity(e),r=this._computePointCount(i),s=Math.sqrt(r/(.75*t));for(;r>t;)e*=s,i=this._computeNodesForMinimumDensity(e),r=this._computePointCount(i),s=Math.sqrt(2);return this._displayNodes(i),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_getLodMemoryFactor(){return this.view.resourceController.memoryController.memoryFactor}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=N(s,t.eye),n=k(s,-o,me),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const{minScale:h,maxScale:u}=ue(this.layer),p=0===h&&0===u?e=>l.push(e):e=>{const t=this._getScale(e);pe(t,h,u)&&l.push(e)};return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return p(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(p(e),!1)},pageMiss:(e,t)=>{p(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_getScale(e){let t=this._nodeScales.get(e);if(null==t){const i=this._index.getNode(e).obb.center;this._tmpPoint.x=i[0],this._tmpPoint.y=i[1],this._tmpPoint.z=i[2],t=this.view.basemapTerrain.getScale(this._tmpPoint),this._nodeScales.set(e,t)}return t}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,ne(e,r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw l(i)||s.getLogger(this.declaredClass).error(i),i}}async _loadAdditionalUserAttributes(e,t,i){const r=this.layer.outFields;if(!r)return[];const s=j(this.layer.fieldsIndex,r),o=new Set(e.map((e=>null!=e?e.name:null))),n=this.layer.attributeStorageInfo,d=[];for(const a of s){if(o.has(a))continue;const e=J(n,a);e&&d.push(t(e))}const l=await h(d);return u(i),l.filter(a)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=q(this.layer),s=T(this.layer),o=i.resourceId,n=async e=>{if(null==e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push((async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),h=n(d),p=s.map((e=>e.attributeInfo)),c=p.map((e=>n(e))),_=this._loadAdditionalUserAttributes([a,d,...p],n,t),[m,g,f,y,b]=await Promise.all([i,l,h,Promise.all(c),_]);u(t);const w={geometryBuffer:m,primaryAttributeData:g,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obb:this._index.getRenderObb(e),elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)}),t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(null==t||!t.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}_requestNodePage(e,t){const i={f:"json",token:this.layer.apiKey};return this._indexRequester.request(e,"json",{query:i,signal:t})}_requestData(e,t){return this._dataRequester.request(e,"binary",{query:{token:this.layer.apiKey},signal:t})}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._nodeScales.delete(e),this._memCache.put(t.id.toString(),t,ye(t))}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),o=this._index.getRenderObb(e);if(te(t))return t.splatSize=r,t.obb=o,P(t.origin,t.obb.center),t;const n=.01*Math.max(o.halfSize[0],o.halfSize[1],o.halfSize[2]);if(t.obb.halfSize[0]>o.halfSize[0]+n||t.obb.halfSize[1]>o.halfSize[1]+n||t.obb.halfSize[2]>o.halfSize[2]+n){if(this._maxLoggedBoxWarnings>0){const i=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;s.getLogger(this.declaredClass).warn(`Node ${e} reported bounding box too small. got ${i(o)} but points cover ${i(t.obb)}`),0==--this._maxLoggedBoxWarnings&&s.getLogger(this.declaredClass).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,t.obb)}return new ie(e,r,x(o.center),o,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode((t=>{e+=we,e+=g(t.coordinates);for(const i of t.attributes){const t=i.values;f(t.buffer)&&(e+=g(t))}})),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount));let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*we)/t)+i*we}get performanceInfo(){return{nodes:this._renderedNodes.size,displayedNumberOfFeatures:[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount),0),maximumNumberOfFeatures:this.maximumPointCount,totalNumberOfFeatures:-1,core:null,"Loading Nodes":this._loadingNodes.size,"Index Queue":this._indexQueue.length,"Work Queue":this._workQueue.length,"Idle Queue":this._idleQueue.length}}get test(){return{index:this._index,visibleNodes:this._renderedNodes}}};e([b()],ge.prototype,"layer",void 0),e([b()],ge.prototype,"baseUrl",null),e([b()],ge.prototype,"pointScale",null),e([b()],ge.prototype,"useRealWorldSymbolSizes",null),e([b()],ge.prototype,"pointSize",null),e([b()],ge.prototype,"inverseDensity",null),e([b()],ge.prototype,"maximumPointCount",void 0),e([b({readOnly:!0})],ge.prototype,"availableFields",null),e([b({readOnly:!0})],ge.prototype,"_clippingBox",null),e([b({readOnly:!0})],ge.prototype,"_elevationOffset",null),e([b({type:Boolean})],ge.prototype,"slicePlaneEnabled",void 0),e([b()],ge.prototype,"updating",void 0),e([b(ae)],ge.prototype,"updatingProgress",void 0),e([b({readOnly:!0})],ge.prototype,"updatingProgressValue",null),ge=e([w("esri.views.3d.layers.PointCloudLayerView3D")],ge);const fe=ge;function ye(e){return 5*e.coordinates.length+128}const be=A(),we=160;function Ne(e){return t=>e.immediate.schedule(t)}export{fe as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{result as t,forEach as i}from"../../../core/asyncUtils.js";import r from"../../../core/Collection.js";import s from"../../../core/Logger.js";import{destroyMaybe as o,abortMaybe as n,isSome as a}from"../../../core/maybe.js";import{eachAlways as d,isAbortError as l,eachAlwaysValues as h,throwIfAborted as u}from"../../../core/promiseUtils.js";import{initial as p,watch as c,sync as _}from"../../../core/reactiveUtils.js";import{pt2px as m}from"../../../core/screenUtils.js";import{estimateSize as g,isArrayBuffer as f}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as y}from"../../../core/unitUtils.js";import{property as b}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as w}from"../../../core/accessorSupport/decorators/subclass.js";import{e as N,c as P}from"../../../chunks/vec3.js";import{b as x}from"../../../chunks/vec3f32.js";import{projectBoundingRect as v}from"../../../geometry/projection.js";import{create as C}from"../../../geometry/support/aaBoundingBox.js";import{containsPoint as S,create as A}from"../../../geometry/support/aaBoundingRect.js";import{create as I,fromNormalAndOffset as k}from"../../../geometry/support/plane.js";import{makeDehydratedPoint as V}from"../../../layers/graphics/dehydratedFeatures.js";import{CodedValue as R}from"../../../layers/support/CodedValue.js";import"../../../core/has.js";import L from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as j}from"../../../layers/support/fieldUtils.js";import{PromiseQueue as Q}from"../../../layers/support/PromiseQueue.js";import{getMetersPerUnit as U}from"../../../symbols/support/unitConversionUtils.js";import{LayerView3D as D}from"./LayerView3D.js";import{PointCloudWorkerHandle as F}from"./PointCloudWorkerHandle.js";import{checkPointCloudLayerValid as z,checkPointCloudLayerCompatibleWithView as W}from"./i3s/I3SUtil.js";import{nodeDiff as M,sortFrontToBack as E,splitWorkEntries as O}from"./i3s/LoDUtil.js";import B from"./i3s/PagedNodeIndex.js";import{getSplatSizeAlgorithm as G,getFixedSizeAlgorithm as H,getRendererInfo as q,getFilterInfo as T,rendererUsesFixedSizes as $,getAttributeInfo as J}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as K,readGeometry as X,elevationFromPositions as Y}from"./i3s/PointCloudWorkerUtil.js";import{PointGraphic as Z}from"./i3s/PointGraphic.js";import{PointRenderer as ee,isInstanceOfNode as te,PointRendererNode as ie}from"./i3s/PointRenderer.js";import{PopupSceneLayerView as re}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as se}from"../support/extentUtils.js";import{ClientType as oe}from"../support/index.js";import{minimumDistancePlane as ne}from"../support/orientedBoundingBox.js";import{updatingProgress as ae}from"../support/updatingProperties.js";import{RenderSlot as de}from"../webgl-engine/lib/RenderSlot.js";import le from"../../layers/LayerView.js";import{isScaleRangeActive as he,extractSafeScaleBounds as ue,scaleBoundsPredicate as pe}from"../../support/layerViewUtils.js";import{TaskPriority as ce}from"../../support/Scheduler.js";const _e=8,me=I();let ge=class extends(re(D(le))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._nodeScales=new Map,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new Q,this._indexPagesLoading=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl.path}get pointScale(){const e=G(this.layer&&this.layer.renderer),t=1;return e&&null!=e.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=H(this.layer&&this.layer.renderer),t=!1;return e&&null!=e.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=H(this.layer&&this.layer.renderer),t=0;return e&&null!=e.size?e.size:t}get inverseDensity(){const e=96;return this.layer&&this.layer.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=q(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=T(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of j(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=C(),t=this.view.renderSpatialReference;return se(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;if(e&&"absolute-height"===e.mode){const t=y(this.layer.spatialReference),i=U(e.unit);return(e.offset??0)*i/t}return 0}initialize(){const e=this.view.resourceController,t=Ne(e);this._worker=new F(t),this.addResolvingPromise(this._worker.promise),this._tmpPoint=V(0,0,0,this.layer.spatialReference),z(this.layer),W(this.layer,this.view),this._indexRequester=e.createStreamDataRequester(oe.I3S_INDEX),this._dataRequester=e.createStreamDataRequester(oe.I3S_DATA),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(this.layer.uid),this.updatingHandles.add((()=>this._clippingBox),(()=>this._setUpdateViewNeeded()),p),this.updatingHandles.add((()=>this._elevationOffset),(()=>this._elevationOffsetChanged()),p),this.updatingHandles.add((()=>this.layer.renderer),(()=>this._rendererChanged()),p),this.updatingHandles.add((()=>this.layer.filters),(()=>this._reload()),p),this.updatingHandles.add((()=>this.layer.outFields),(()=>this._reload()),p),this.updatingHandles.add((()=>this.layer.effectiveScaleRange),(()=>this._setUpdateViewNeeded())),this.updatingHandles.add((()=>this.view.state.contentCamera),(()=>this._setUpdateViewNeeded())),this.handles.add([this.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),c((()=>r.memoryFactor),(()=>this._setUpdateViewNeeded()),_)]),this.addResolvingPromise(i),this.when((()=>{this.handles.add([e.scheduler.registerTask(ce.POINT_CLOUD_LAYER,this),e.scheduler.registerIdleStateCallbacks((()=>this._idleBegin()),(()=>this._idleEnd())),this.updatingHandles.add((()=>this.suspended),(e=>{e?this._clearNodeState():this._setUpdateViewNeeded()}),p)])}),(()=>{this.updatingHandles.removeAll(),this.handles.removeAll()}))}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=o(this._worker),this._destroyRenderer(),this._memCache=o(this._memCache),this._codedDomainPopulationAbortController=n(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new ee({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerUid=this.layer.uid,this.updatingHandles.add((()=>this._clippingBox),(e=>this._renderer.clippingBox=e),p),this.updatingHandles.add((()=>this.suspended),(e=>this._setPointsVisible(!e)),p),this.updatingHandles.add((()=>this.pointScale),(e=>this._renderer.scaleFactor=e),p),this._renderer.minSizePx=Math.sqrt(2),this.updatingHandles.add((()=>this.useRealWorldSymbolSizes),(e=>this._renderer.useRealWorldSymbolSizes=e),p),this.updatingHandles.add((()=>this.pointSize),(e=>{const t=m(e);this._renderer.size=e,this._renderer.sizePx=t}),p),this.updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._renderer.slicePlaneEnabled=e),p),this.updatingHandles.add((()=>this.inverseDensity),(()=>this._setUpdateViewNeeded()),p),this.updatingHandles.add((()=>this.maximumPointCount),(()=>this._setUpdateViewNeeded()),p),this.updatingHandles.add((()=>this.view.qualitySettings.sceneService.pointCloud.lodFactor),(e=>{this._lodFactor=e,this._setUpdateViewNeeded()}),p)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i){const r=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,s=this.view.computeMapPointFromVec3d(i),o=this._createGraphicAttributes(e,r);return new Z({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:r,epoch:this._nodeLoadEpoch},geometry:s,attributes:o,layer:this.layer,sourceLayer:this.layer})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_encodeGraphicAttribute(e,t,i,r){const s=e.storageInfo?.attributeValues,o=s?.valuesPerElement??1;if(1===o)r[e.name]=t[i];else if("UInt8"===s?.valueType&&o<=4){let s=0;const n=i*o;for(let e=n;e<n+o;e++)s=(s<<8)+t[e];r[e.name]=s}else r[e.name]=void 0}_setPointsVisible(e){e&&!this._rendererAdded?(this.view._stage.addRenderPlugin([de.OPAQUE_MATERIAL],this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view._stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=$(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_scaleUpdateHandler(e){const t=this.layer.effectiveScaleRange;he(t.minScale,t.maxScale)?v(e.extent,e.spatialReference,be,this.layer.spatialReference)&&(this._nodeScales.forEach(((t,i)=>{if(!this._renderedNodes.has(i))return void this._nodeScales.delete(i);const r=this._index.getNode(i);S(be,r.obb.center)&&this._nodeScales.set(i,e.scale)})),this._setUpdateViewNeeded()):this._nodeScales.clear()}_displayNodes(e){this._workQueue=M([...this._renderedNodes],e,this._index),E(this._workQueue,this.view.state.contentCamera.viewForward,this._index),O(this._workQueue,_e,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){const e=new Array;this._loadingNodes.forEach((({abortController:t})=>e.push(t))),this._loadingNodes.clear();for(const t of e)t.abort();this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach((t=>t.load.forEach((t=>e.add(t)))));const t=new Array,i=new Map;this._loadingNodes.forEach(((r,s)=>{e.has(s)?i.set(s,r):t.push(r)})),this._loadingNodes=i;for(const{abortController:r}of t)r.abort();this._workQueue=this._workQueue.filter((e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0})),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._indexPagesLoading.forEach((({abortController:e})=>e.abort())),this._indexPagesLoading.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach((e=>this._removeFromRenderer(e))),this._cancelNodeLoading()}_idleBegin(){this._setUpdateViewNeeded()}_idleEnd(){this._setUpdateViewNeeded()}get running(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.running}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run((()=>this._updateWorkQueues()));this._indexQueue.length>0&&e.run((()=>this._processIndexQueue())););this._processWorkQueue(e),this._idleQueue.runTask(e)}}_processIndexQueue(){const e=this._indexQueue.shift(),t=this._loadNodePage(e);return this._indexPagesLoading.set(e,t),t.promise.then((t=>{this._index.addPage(e,t,this._elevationOffset),this._setUpdateViewNeeded()})).then((()=>{this._indexPagesLoading.delete(e)}),(()=>{this._indexPagesLoading.delete(e)})),!0}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return;this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find((e=>!this._renderedNodes.has(e))))return e;this._workQueue.push(e)}return null}_processWorkEntry(e){if(0!==e.load.length)Promise.all(e.load.map((e=>{const t=new AbortController,i=this._memCache.pop(e.toString());return null!=i?this._loadingNodes.set(e,{abortController:t,promise:Promise.resolve(i)}):this._loadingNodes.has(e)||this._loadingNodes.set(e,{abortController:t,promise:this._loadNode(e,t.signal)}),this._loadingNodes.get(e).promise}))).then((t=>{for(let i=0;i<e.load.length;i++)if(t[i]){const r=this._setupRendererData(e.load[i],t[i]);this._addToRenderer(r)}for(const i of e.remove)this._removeFromRenderer(i)})).catch((()=>{})).then((()=>{for(const t of e.load)this._loadingNodes.delete(t);this._updateLoading(),this._recalcWork&&!this._idleQueue.running&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())})),this._updateLoading();else for(const t of e.remove)this._removeFromRenderer(t)}async _populateClassCodeCodedDomain(e,i){const r="CLASS_CODE",s=this.layer.fieldsIndex.get(r);if(!s||s.domain)return;if(!e.includes(s.name))return;const o=await t(this.layer.queryCachedStatistics(r,{signal:i}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(s.domain=new L({name:"CLASS_CODE",codedValues:n.map((e=>new R({code:e.value,name:e.label})))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then((()=>{this._codedDomainPopulationAbortController=null}))),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const r=this._splitGraphicsPerNode(e),s=this.layer.attributeStorageInfo,o=t.map((e=>J(s,e))).filter(a),n=async(e,t)=>{const r=this._index.getNode(t);await i(o,(async t=>{const i=t.useElevation?await this._loadElevationAttributeFromGeometry(r.resourceId):await this._loadAndParseAttribute(r,t);if(i)for(const r of e)if(this._isValidPointGraphic(r)){const e=r.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,i,e,r.attributes)}}))},l=[];return r.forEach(((e,t)=>{l.push(n(e,t))})),await d(l),e}_isValidPointGraphic(e){return e instanceof Z&&e.pointCloudMetadata?.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return null!=i?K({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=X(t,await this._loadGeometry(e,null));return Y(i,i.length/3)}highlight(e){if(!e)return{remove(){}};const t=r.isCollection(e)?e.toArray():Array.isArray(e)?e:[e];return this._renderer.highlight(t.map((e=>this._graphicToPointDefinition(e))))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._indexPagesLoading.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}_initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;return this._index=new B(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock,this._loadNodePage(0).promise.then((e=>{this._index.addPage(0,e,this._elevationOffset),this._loadingInitNodePage=!1,this._setUpdateViewNeeded()}))}_loadNodePage(e){const t=new AbortController,i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return{promise:this._requestNodePage(i,t.signal).then((t=>t.nodes.map(((t,i)=>({resourceId:null!=t.resourceId?t.resourceId:e*this._index.pageSize+i,obb:t.obb,firstChild:t.firstChild,childCount:t.childCount,vertexCount:t.vertexCount??t.pointCount,lodThreshold:t.lodThreshold??t.effectiveArea}))))),abortController:t}}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;let e=this.inverseDensity/this._lodFactor*this._getLodMemoryFactor();const t=this.maximumPointCount*this._lodFactor*this._getLodMemoryFactor();let i=this._computeNodesForMinimumDensity(e),r=this._computePointCount(i),s=Math.sqrt(r/(.75*t));for(;r>t;)e*=s,i=this._computeNodesForMinimumDensity(e),r=this._computePointCount(i),s=Math.sqrt(2);return this._displayNodes(i),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_getLodMemoryFactor(){return this.view.resourceController.memoryController.memoryFactor}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=N(s,t.eye),n=k(s,-o,me),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const{minScale:h,maxScale:u}=ue(this.layer),p=0===h&&0===u?e=>l.push(e):e=>{const t=this._getScale(e);pe(t,h,u)&&l.push(e)};return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return p(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(p(e),!1)},pageMiss:(e,t)=>{p(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_getScale(e){let t=this._nodeScales.get(e);if(null==t){const i=this._index.getNode(e).obb.center;this._tmpPoint.x=i[0],this._tmpPoint.y=i[1],this._tmpPoint.z=i[2],t=this.view.basemapTerrain.getScale(this._tmpPoint),this._nodeScales.set(e,t)}return t}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,ne(e,r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw l(i)||s.getLogger(this.declaredClass).error(i),i}}async _loadAdditionalUserAttributes(e,t,i){const r=this.layer.outFields;if(!r)return[];const s=j(this.layer.fieldsIndex,r),o=new Set(e.map((e=>null!=e?e.name:null))),n=this.layer.attributeStorageInfo,d=[];for(const a of s){if(o.has(a))continue;const e=J(n,a);e&&d.push(t(e))}const l=await h(d);return u(i),l.filter(a)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=q(this.layer),s=T(this.layer),o=i.resourceId,n=async e=>{if(!e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push((async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),h=n(d),p=s.map((e=>e.attributeInfo)),c=p.map((e=>n(e))),_=this._loadAdditionalUserAttributes([a,d,...p],n,t),[m,g,f,y,b]=await Promise.all([i,l,h,Promise.all(c),_]);u(t);const w={geometryBuffer:m,primaryAttributeData:g,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obb:this._index.getRenderObb(e),elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)}),t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(null==t||!t.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}_requestNodePage(e,t){const i={f:"json",token:this.layer.apiKey};return this._indexRequester.request(e,"json",{query:i,signal:t})}_requestData(e,t){return this._dataRequester.request(e,"binary",{query:{token:this.layer.apiKey},signal:t})}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._nodeScales.delete(e),this._memCache.put(t.id.toString(),t,ye(t))}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),o=this._index.getRenderObb(e);if(te(t))return t.splatSize=r,t.obb=o,P(t.origin,t.obb.center),t;const n=.01*Math.max(o.halfSize[0],o.halfSize[1],o.halfSize[2]);if(t.obb.halfSize[0]>o.halfSize[0]+n||t.obb.halfSize[1]>o.halfSize[1]+n||t.obb.halfSize[2]>o.halfSize[2]+n){if(this._maxLoggedBoxWarnings>0){const i=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;s.getLogger(this.declaredClass).warn(`Node ${e} reported bounding box too small. got ${i(o)} but points cover ${i(t.obb)}`),0==--this._maxLoggedBoxWarnings&&s.getLogger(this.declaredClass).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,t.obb)}return new ie(e,r,x(o.center),o,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode((t=>{e+=we,e+=g(t.coordinates);for(const i of t.attributes){const t=i.values;f(t.buffer)&&(e+=g(t))}})),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount));let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*we)/t)+i*we}get performanceInfo(){return{nodes:this._renderedNodes.size,displayedNumberOfFeatures:[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount),0),maximumNumberOfFeatures:this.maximumPointCount,totalNumberOfFeatures:-1,core:null,"Loading Nodes":this._loadingNodes.size,"Index Queue":this._indexQueue.length,"Work Queue":this._workQueue.length,"Idle Queue":this._idleQueue.length}}get test(){return{index:this._index,visibleNodes:this._renderedNodes}}};e([b()],ge.prototype,"layer",void 0),e([b()],ge.prototype,"baseUrl",null),e([b()],ge.prototype,"pointScale",null),e([b()],ge.prototype,"useRealWorldSymbolSizes",null),e([b()],ge.prototype,"pointSize",null),e([b()],ge.prototype,"inverseDensity",null),e([b()],ge.prototype,"maximumPointCount",void 0),e([b({readOnly:!0})],ge.prototype,"availableFields",null),e([b({readOnly:!0})],ge.prototype,"_clippingBox",null),e([b({readOnly:!0})],ge.prototype,"_elevationOffset",null),e([b({type:Boolean})],ge.prototype,"slicePlaneEnabled",void 0),e([b()],ge.prototype,"updating",void 0),e([b(ae)],ge.prototype,"updatingProgress",void 0),e([b({readOnly:!0})],ge.prototype,"updatingProgressValue",null),ge=e([w("esri.views.3d.layers.PointCloudLayerView3D")],ge);const fe=ge;function ye(e){return 5*e.coordinates.length+128}const be=A(),we=160;function Ne(e){return t=>e.immediate.schedule(t)}export{fe 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t}from"../../../core/maybe.js";import{isArrayBuffer as r}from"../../../core/typedArrayUtil.js";import{c as e}from"../../../chunks/quat.js";import{c as a}from"../../../chunks/quatf32.js";import{q as o}from"../../../chunks/vec3.js";import{f as n,c as f}from"../../../chunks/vec3f32.js";import{projectBuffer as i}from"../../../geometry/projection.js";import s from"../../../geometry/SpatialReference.js";import{readGeometry as u,getAttributeValues as l,evaluateRenderer as b,filterInPlace as m}from"./i3s/PointCloudWorkerUtil.js";class c{transform(t){const e=this._transform(t),a=[e.points.buffer,e.rgb.buffer];null!=e.pointIdFilterMap&&a.push(e.pointIdFilterMap.buffer);for(const o of e.attributes)"buffer"in o.values&&r(o.values.buffer)&&o.values.buffer!==e.rgb.buffer&&a.push(o.values.buffer);return Promise.resolve({result:e,transferList:a})}_transform(r){const e=u(r.schema,r.geometryBuffer);let a=e.length/3,o=null;const n=[],f=l(r.primaryAttributeData,e,a);null!=r.primaryAttributeData&&f&&n.push({attributeInfo:r.primaryAttributeData.attributeInfo,values:f});const i=l(r.modulationAttributeData,e,a);null!=r.modulationAttributeData&&i&&n.push({attributeInfo:r.modulationAttributeData.attributeInfo,values:i});let c=b(r.rendererInfo,f,i,a);if(r.filterInfo&&r.filterInfo.length>0&&null!=r.filterAttributesData){const f=r.filterAttributesData.filter(t).map((t=>{const r=l(t,e,a),o={attributeInfo:t.attributeInfo,values:r};return n.push(o),o}));o=new Uint32Array(a),a=m(e,c,o,r.filterInfo,f)}for(const t of r.userAttributesData){const r=l(t,e,a);n.push({attributeInfo:t.attributeInfo,values:r})}3*a<c.length&&(c=new Uint8Array(c.buffer.slice(0,3*a))),this._applyElevationOffsetInPlace(e,a,r.elevationOffset);const p=this._transformCoordinates(e,a,r.obb,s.fromJSON(r.inSR),s.fromJSON(r.outSR));return{obb:r.obb,points:p,rgb:c,attributes:n,pointIdFilterMap:o}}_transformCoordinates(t,r,a,s,u){if(!i(t,s,0,t,u,0,r))throw new Error("Can't reproject");const l=n(a.center[0],a.center[1],a.center[2]),b=f(),m=f();e(p,a.quaternion);const c=new Float32Array(3*r);for(let e=0;e<r;e++)b[0]=t[3*e]-l[0],b[1]=t[3*e+1]-l[1],b[2]=t[3*e+2]-l[2],o(m,b,p),a.halfSize[0]=Math.max(a.halfSize[0],Math.abs(m[0])),a.halfSize[1]=Math.max(a.halfSize[1],Math.abs(m[1])),a.halfSize[2]=Math.max(a.halfSize[2],Math.abs(m[2])),c[3*e]=b[0],c[3*e+1]=b[1],c[3*e+2]=b[2];return c}_applyElevationOffsetInPlace(t,r,e){if(0!==e)for(let a=0;a<r;a++)t[3*a+2]+=e}}const p=a();function h(){return new c}export{h as default};
5
+ import{isSome as t}from"../../../core/maybe.js";import{isArrayBuffer as r}from"../../../core/typedArrayUtil.js";import{c as e}from"../../../chunks/quat.js";import{c as a}from"../../../chunks/quatf32.js";import{q as o}from"../../../chunks/vec3.js";import{f as n,c as f}from"../../../chunks/vec3f32.js";import{projectBuffer as i}from"../../../geometry/projection.js";import s from"../../../geometry/SpatialReference.js";import{readGeometry as u,getAttributeValues as l,evaluateRenderer as b,filterInPlace as m}from"./i3s/PointCloudWorkerUtil.js";class c{transform(t){const e=this._transform(t),a=[e.points.buffer,e.rgb.buffer];null!=e.pointIdFilterMap&&a.push(e.pointIdFilterMap.buffer);for(const o of e.attributes)"buffer"in o.values&&r(o.values.buffer)&&o.values.buffer!==e.rgb.buffer&&a.push(o.values.buffer);return Promise.resolve({result:e,transferList:a})}_transform(r){const e=u(r.schema,r.geometryBuffer);let a=e.length/3,o=null;const n=new Array,f=l(r.primaryAttributeData,e,a);null!=r.primaryAttributeData&&f&&n.push({attributeInfo:r.primaryAttributeData.attributeInfo,values:f});const i=l(r.modulationAttributeData,e,a);null!=r.modulationAttributeData&&i&&n.push({attributeInfo:r.modulationAttributeData.attributeInfo,values:i});let c=b(r.rendererInfo,f,i,a);if(r.filterInfo&&r.filterInfo.length>0&&null!=r.filterAttributesData){const f=r.filterAttributesData.filter(t).map((t=>{const r=l(t,e,a),o={attributeInfo:t.attributeInfo,values:r};return n.push(o),o}));o=new Uint32Array(a),a=m(e,c,o,r.filterInfo,f)}for(const t of r.userAttributesData){const r=l(t,e,a);n.push({attributeInfo:t.attributeInfo,values:r})}3*a<c.length&&(c=new Uint8Array(c.buffer.slice(0,3*a))),this._applyElevationOffsetInPlace(e,a,r.elevationOffset);const p=this._transformCoordinates(e,a,r.obb,s.fromJSON(r.inSR),s.fromJSON(r.outSR));return{obb:r.obb,points:p,rgb:c,attributes:n,pointIdFilterMap:o}}_transformCoordinates(t,r,a,s,u){if(!i(t,s,0,t,u,0,r))throw new Error("Can't reproject");const l=n(a.center[0],a.center[1],a.center[2]),b=f(),m=f();e(p,a.quaternion);const c=new Float32Array(3*r);for(let e=0;e<r;e++)b[0]=t[3*e]-l[0],b[1]=t[3*e+1]-l[1],b[2]=t[3*e+2]-l[2],o(m,b,p),a.halfSize[0]=Math.max(a.halfSize[0],Math.abs(m[0])),a.halfSize[1]=Math.max(a.halfSize[1],Math.abs(m[1])),a.halfSize[2]=Math.max(a.halfSize[2],Math.abs(m[2])),c[3*e]=b[0],c[3*e+1]=b[1],c[3*e+2]=b[2];return c}_applyElevationOffsetInPlace(t,r,e){if(0!==e)for(let a=0;a<r;a++)t[3*a+2]+=e}}const p=a();function h(){return new c}export{h 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{disposeMaybe as i,abortMaybe as r,destroyMaybe as l}from"../../../core/maybe.js";import{isAborted as s}from"../../../core/promiseUtils.js";import{whenOnce as o}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{SchemaHelper as h}from"../../2d/engine/vectorTiles/SchemaHelper.js";import c from"../../2d/engine/vectorTiles/TileHandler3D.js";import p from"../../2d/engine/vectorTiles/VTLPainter3D.js";import m from"../../2d/engine/vectorTiles/style/StyleRepository.js";import{LayerView3D as d}from"./LayerView3D.js";import{TiledLayerView3D as f}from"./TiledLayerView3D.js";import{vtlAssumes256PixelSizeAsDefault as y,test as u}from"../terrain/terrainUtils.js";import g from"../../layers/LayerView.js";let _=class extends(f(d(g))){constructor(){super(...arguments),this._tileHandlerController=null,this.type="vector-tile-3d"}initialize(){if(null==this.layer.fullExtent)return void this.addResolvingPromise(Promise.reject(new t("vectortilelayerview:full-extent-undefined","This layer view's layer does not define a fullExtent.")));const{basemapTerrain:e,spatialReference:i,state:r,viewingMode:l}=this.view,n="local"===l&&!y(i)||u.force512VTL,a=this.layer.tileInfo.spatialReference.isGeographic,d=n?this.layer.tileInfo:this.layer.tileInfo.getOrCreateCompatible(256,a?1:2),f=this._getTileInfoSupportError(d,this.layer.fullExtent);if(null!=f)return this.addResolvingPromise(Promise.reject(f));const g=o((()=>this.view?.basemapTerrain?.tilingSchemeLocked)).then((()=>{const t=e.tilingScheme,i=t.pixelSize;let r;if(this.schemaHelper=new h(i,null!=e.spatialReference&&e.spatialReference.isGeographic),256===i){const e=this.layer.tileInfo.spatialReference.isGeographic;r=this.layer.tileInfo.getOrCreateCompatible(256,e?1:2)}else r=this.view.spatialReference?.isGeographic?this.layer.tileInfo.getOrCreateCompatible(512,.5):this.layer.tileInfo;const l=this._getTileInfoCompatibilityError(r,t);if(l)throw l;this.tileInfo=r}));this._tileHandlerController=new AbortController;const _=this.view.resourceController;this._memCache=_.memoryController.newCache(this.layer.uid,(e=>{e.release()}));const C=new m(this.layer.currentStyleInfo.style);this._tileHandler=new c(this.layer,C,r.contentPixelRatio,this._memCache);const H=this._tileHandlerController.signal,w=v(_),j=this._tileHandler.start({signal:H,schedule:w}),R=this._tileHandler.spriteMosaic;R.then((e=>{!s(H)&&this._tileHandler&&(this.painter=new p(e,this._tileHandler.glyphMosaic))})),j.then((()=>this._tileHandlerController=null)),this.updatingHandles.add((()=>({style:this.layer.currentStyleInfo.style,pixelRatio:this.view.state?.contentPixelRatio})),(({style:e,pixelRatio:t})=>{this._tileHandlerController&&this._tileHandlerController.abort(),this._tileHandlerController=new AbortController,this._memCache.clear();const i=new m(e),r=new c(this.layer,i,t,this._memCache),l=r.start({signal:this._tileHandlerController.signal,schedule:w}),s=r.spriteMosaic;l.then((()=>this._tileHandlerController=null)),this.updatingHandles.addPromise(Promise.all([l,s]).then((([,e])=>{const t=this._tileHandler,i=this.painter;this.painter=new p(e,r.glyphMosaic),this._tileHandler=r,this.emit("data-changed"),t.destroy(),i&&i.dispose()})))}));const T=Promise.all([g,j,R]);this.addResolvingPromise(T)}destroy(){this.painter=i(this.painter),this._tileHandlerController=r(this._tileHandlerController),l(this._tileHandler),this._memCache=l(this._memCache),this._tileHandler=null}get dataLevelRange(){const e=this.tileInfo.lods,t=e[0].scale,i=e[e.length-1].scale,r=this.levelRangeFromScaleRange(t,i);return 1===r.minLevel&&256===this.tileInfo.size[0]&&(r.minLevel=0),r}async fetchTile(e,t,i,r){return this._tileHandler.getVectorTile(e,t,i,r)}};e([n()],_.prototype,"layer",void 0),e([n()],_.prototype,"dataLevelRange",null),e([n()],_.prototype,"updatingProgressValue",void 0),_=e([a("esri.views.3d.layers.VectorTileLayerView3D")],_);const C=_;function v(e){return t=>e.immediate.schedule(t)}export{C as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{disposeMaybe as i,abortMaybe as r,destroyMaybe as l}from"../../../core/maybe.js";import{isAborted as s}from"../../../core/promiseUtils.js";import{whenOnce as o}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{SchemaHelper as h}from"../../2d/engine/vectorTiles/SchemaHelper.js";import c from"../../2d/engine/vectorTiles/TileHandler3D.js";import p from"../../2d/engine/vectorTiles/VTLPainter3D.js";import m from"../../2d/engine/vectorTiles/style/StyleRepository.js";import{LayerView3D as d}from"./LayerView3D.js";import{TiledLayerView3D as f}from"./TiledLayerView3D.js";import{vtlAssumes256PixelSizeAsDefault as y,test as u}from"../terrain/terrainUtils.js";import g from"../../layers/LayerView.js";let _=class extends(f(d(g))){constructor(){super(...arguments),this._tileHandlerController=null,this.type="vector-tile-3d"}initialize(){if(null==this.layer.fullExtent)return void this.addResolvingPromise(Promise.reject(new t("vectortilelayerview:full-extent-undefined","This layer view's layer does not define a fullExtent.")));const{basemapTerrain:e,spatialReference:i,state:r,viewingMode:l}=this.view,n="local"===l&&!y(i)||u.force512VTL,a=this.layer.tileInfo.spatialReference.isGeographic,d=n?this.layer.tileInfo:this.layer.tileInfo.getOrCreateCompatible(256,a?1:2),f=this._getTileInfoSupportError(d,this.layer.fullExtent);if(null!=f)return this.addResolvingPromise(Promise.reject(f));const g=o((()=>this.view?.basemapTerrain?.tilingSchemeLocked)).then((()=>{const t=e.tilingScheme,i=t.pixelSize;let r;if(this.schemaHelper=new h(i,null!=e.spatialReference&&e.spatialReference.isGeographic),256===i){const e=this.layer.tileInfo.spatialReference.isGeographic;r=this.layer.tileInfo.getOrCreateCompatible(256,e?1:2)}else r=this.view.spatialReference?.isGeographic?this.layer.tileInfo.getOrCreateCompatible(512,.5):this.layer.tileInfo;const l=this._getTileInfoCompatibilityError(r,t);if(l)throw l;this.tileInfo=r}));this._tileHandlerController=new AbortController;const _=this.view.resourceController;this._memCache=_.memoryController.newCache(this.layer.uid,(e=>{e.release()}));const C=new m(this.layer.currentStyleInfo.style);this._tileHandler=new c(this.layer,C,r.contentPixelRatio,this._memCache);const H=this._tileHandlerController.signal,w=v(_),j=this._tileHandler.start({signal:H,schedule:w}),R=this._tileHandler.spriteMosaic;R.then((e=>{!s(H)&&this._tileHandler&&(this.painter=new p(e,this._tileHandler.glyphMosaic))})),j.then((()=>this._tileHandlerController=null)),this.updatingHandles.add((()=>({style:this.layer.currentStyleInfo.style,pixelRatio:this.view.state?.contentPixelRatio})),(({style:e,pixelRatio:t})=>{this._tileHandlerController&&this._tileHandlerController.abort(),this._tileHandlerController=new AbortController,this._memCache.clear();const i=new m(e),r=new c(this.layer,i,t,this._memCache),l=r.start({signal:this._tileHandlerController.signal,schedule:w}),s=r.spriteMosaic;l.then((()=>this._tileHandlerController=null)),this.updatingHandles.addPromise(Promise.all([l,s]).then((([,e])=>{const t=this._tileHandler,i=this.painter;this.painter=new p(e,r.glyphMosaic),this._tileHandler=r,this.emit("data-changed"),t.destroy(),i&&i.dispose()})))}));const T=Promise.all([g,j,R]);this.addResolvingPromise(T)}destroy(){this.painter=i(this.painter),this._tileHandlerController=r(this._tileHandlerController),this._tileHandler=l(this._tileHandler),this._memCache=l(this._memCache)}get dataLevelRange(){const e=this.tileInfo.lods,t=e[0].scale,i=e[e.length-1].scale,r=this.levelRangeFromScaleRange(t,i);return 1===r.minLevel&&256===this.tileInfo.size[0]&&(r.minLevel=0),r}async fetchTile(e,t,i,r){return this._tileHandler.getVectorTile(e,t,i,r)}};e([n()],_.prototype,"layer",void 0),e([n()],_.prototype,"dataLevelRange",null),e([n()],_.prototype,"updatingProgressValue",void 0),_=e([a("esri.views.3d.layers.VectorTileLayerView3D")],_);const C=_;function v(e){return t=>e.immediate.schedule(t)}export{C 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.27/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import t from"../../../../core/Error.js";import{clone as e}from"../../../../core/lang.js";import{get as s}from"../../../../core/maybe.js";import{getMetersPerVerticalUnitForSR as r}from"../../../../core/unitUtils.js";import{e as n}from"../../../../chunks/earcut.js";import{b as o}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{a,u as l}from"../../../../chunks/mat4.js";import{c}from"../../../../chunks/mat4f64.js";import{c as h,n as m,s as p,b as d,f as g,m as u}from"../../../../chunks/vec3.js";import{d as f,c as y}from"../../../../chunks/vec3f64.js";import{computeTranslationToOriginAndRotation as b}from"../../../../geometry/projection.js";import{create as _,empty as x,expandWithBuffer as j,intersectsClippingArea as P}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as S}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as v,getZeroIndexArray as E}from"../../../../geometry/support/Indices.js";import{t as w,a as L}from"../../../../chunks/vec32.js";import{makeVertexCandidate as C,makeEdgeCandidate as I}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as O}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as M}from"../../../ViewingMode.js";import{needsElevationUpdates3D as A,SampleElevationInfo as z}from"./elevationAlignmentUtils.js";import{ElevationContext as D}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as R}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as G}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as B,computeCentroid as U}from"./graphicUtils.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{geometryAsPolygon as T}from"./polygonUtils.js";import{createMaterial as V}from"../support/edgeUtils.js";import N from"../../support/debugFlags.js";import{SamplePosition as H}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as F}from"../../support/renderInfoUtils/polygon.js";import{Attribute as W}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as q}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as Z}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as J}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as K}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{Object3D as Q}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as X}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Y}from"../../webgl-engine/materials/DefaultMaterial.js";const $=["polygon","extent"];class tt extends G{constructor(t,e,s,r){super(t,e,s,r),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const e=B(this._getSymbolSize());if(e)throw new t("graphics3dextrudesymbollayer:invalid-size",e)}const e=s(this.symbolLayer,"material","color"),r=this._getCombinedOpacityAndColor(e),n=f(r),o=r[3],i=o<1||this.needsDrivenTransparentPass,a={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:n,ambient:n,opacity:o,transparent:i,cullFace:i?q.None:q.Back,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0};this._material=new Y(a),this._bottomMaterial=new Y({...a,cullFace:q.Back}),this._context.stage.add(this._material),this._context.stage.add(this._bottomMaterial)}destroy(){super.destroy(),this._material&&(this._context.stage.remove(this._material),this._context.stage.remove(this._bottomMaterial))}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,$,this.symbolLayer.type))return null;const s=this._getVertexOpacityAndColor(t.renderingInfo,255),r=this.setGraphicElevationContext(e,new D);return this._createAs3DShape(e,t.renderingInfo,s,r,e.uid)}layerOpacityChanged(t,e){const r=s(this.symbolLayer,"material","color"),n=this._getCombinedOpacity(r),o=n<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:n,transparent:o}),this._bottomMaterial.setParameters({opacity:n,transparent:o});const i=this._getLayerOpacity();t.forEach((t=>{const s=e(t);null!=s&&s.layerOpacityChanged(i,this._context.isAsync)}))}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,A)}slicePlaneEnabledChanged(t,e){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._bottomMaterial.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t.forEach((t=>{const s=e(t);null!=s&&s.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._bottomMaterial.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?O(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?k.RecreateSymbol:k.RecreateGraphics}async queryForSnapping(t,s,n,o){const i=this._getExtrusionSize(n)*this._context.renderCoordsHelper.unitInMeters/r(s),{objectId:a,target:l}=t,c=e(l);switch(c.z=(c.z??0)+i,t.type){case"edge":{const{start:s,end:r}=t,n=e(s),o=e(r);return n.z=(n.z??0)+i,o.z=(o.z??0)+i,[I(a,c,1/0,n,o)]}case"vertex":return[C(a,c,1/0),I(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,s,r,l){const h=T(t.geometry);if(null==h)return null;if(0===h.rings.length||!h.rings.some((t=>t.length>0)))return this._logGeometryValidationWarnings(h.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=F(h,this._context.elevationProvider,this._context.renderCoordsHelper,r);this._logGeometryCreationWarnings(m,h.rings,"rings","ExtrudeSymbol3DLayer");const p=U(h);if(null==p)return null;const d=new Array,g=new Array,u=_(),f=c(),E=y(),C=this._context.renderCoordsHelper.viewingMode===M.Global;C||this._context.renderCoordsHelper.worldUpAtPosition(null,E),b(h.spatialReference,[p.x,p.y,0],f,this._context.renderCoordsHelper.spatialReference);const I=c();a(I,f);const O=i();o(O,I);const{polygons:z,mapPositions:D,position:G}=m;for(const o of z){const t=o.count;if(this._context.clippingExtent&&(x(u),j(u,o.mapPositions),!P(u,this._context.clippingExtent)))continue;const r=n(o.mapPositions,o.holeIndices,3);if(0===r.length)continue;const i=r.length,a=6*t,c=v(a+i),h=v(i),m=S(3*a),p=S(3*a),f=S(3*a),y=S(a);st(G,D,r,o,m,f,p,y,c,h,this._getExtrusionSize(e),E,C),w(m,m,I),L(p,p,O);const b=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:l,layerUid:this._context.layer.uid}),_=new jt(m,f,p,y);d.push(et(this._material,c,c.length-h.length,_,s,b),et(this._bottomMaterial,h,0,_,s,b)),g.push(_.heights)}if(0===d.length)return null;const B=new Q({geometries:d,layerUid:this._context.layer.uid,graphicUid:l,isElevationSource:!0});B.transformation=f;const k=V(this.symbolLayer,{opacity:this._getLayerOpacity()}),N=null!=k?{baseMaterial:this._material,edgeMaterials:[k],properties:{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}}:null,H=new R(this,B,d,null,null,((t,e,s,r,n)=>gt(t,e,s,r,n,g)),r,N);return H.alignedSampledElevation=m.sampledElevation,H.needsElevationUpdates=A(r.mode),H}}function et(t,e,s,r,n,o){const i=E(e.length),a=[[X.POSITION,new W(r.positions,3,!0)],[X.NORMAL,new W(r.normals,3,!0)],[X.COLOR,new W(n,4,!0)]],l=[[X.POSITION,e],[X.NORMAL,e],[X.COLOR,i]];return new J(t,a,l,r.elevation,Z.Mesh,o,s)}function st(t,e,s,r,n,o,i,a,l,c,h,m,p){const d=s.length/3;let g=0,u=2*r.count;rt(t,e,r.index,r.count,s,0,d,n,o,i,a,l,c,u,h,m,p);let f=2*r.count;u=0,it(n,o,a,i,g,r.pathLengths[0],r.count,f,l,u,h),f+=4*r.pathLengths[0],u+=2*r.pathLengths[0],g+=r.pathLengths[0];for(let y=1;y<r.pathLengths.length;++y)it(n,o,a,i,g,r.pathLengths[y],r.count,f,l,u,h),f+=4*r.pathLengths[y],u+=2*r.pathLengths[y],g+=r.pathLengths[y]}function rt(t,e,s,r,n,o,i,a,l,c,p,d,g,u,f,y,b){h(ft,y);const _=f>0?1:-1;let x=3*s,j=0,P=3*j,S=r,v=3*S;for(let h=0;h<r;++h)b&&(ft[0]=t[x],ft[1]=t[x+1],ft[2]=t[x+2],m(ft,ft)),a[P]=t[x],a[P+1]=t[x+1],a[P+2]=t[x+2],l[P]=e[x],l[P+1]=e[x+1],l[P+2]=e[x+2],c[P]=-_*ft[0],c[P+1]=-_*ft[1],c[P+2]=-_*ft[2],p[j]=0,a[v]=t[x]+f*ft[0],a[v+1]=t[x+1]+f*ft[1],a[v+2]=t[x+2]+f*ft[2],l[v]=e[x],l[v+1]=e[x+1],l[v+2]=e[x+2],c[v]=_*ft[0],c[v+1]=_*ft[1],c[v+2]=_*ft[2],p[S]=f,P+=3,v+=3,x+=3,j+=1,S+=1;x=3*o,P=0,v=3*u;const E=f<0?_t:bt,w=f<0?bt:_t;for(let h=0;h<i;++h)g[P]=n[x+E[0]],g[P+1]=n[x+E[1]],g[P+2]=n[x+E[2]],d[v]=n[x+w[0]]+r,d[v+1]=n[x+w[1]]+r,d[v+2]=n[x+w[2]]+r,P+=3,v+=3,x+=3}function nt(t,e,s,r,n,o,i){r[o]=r[i],i*=3,t[o*=3]=t[i],t[o+1]=t[i+1],t[o+2]=t[i+2],e[o]=e[i],e[o+1]=e[i+1],e[o+2]=e[i+2],s[o]=n[0],s[o+1]=n[1],s[o+2]=n[2]}const ot=y();function it(t,e,s,r,n,o,i,a,l,c,h){let m=n,p=n+1,d=n+i,g=n+i+1,u=a,f=a+1,y=a+2*o,b=a+2*o+1;h<0&&(m=n+i+1,g=n),c*=3;for(let _=0;_<o;++_)_===o-1&&(h>0?(p=n,g=n+i):(p=n,m=n+i)),pt(t,m,p,d,ot),nt(t,e,r,s,ot,u,m),nt(t,e,r,s,ot,f,p),nt(t,e,r,s,ot,y,d),nt(t,e,r,s,ot,b,g),l[c++]=u,l[c++]=y,l[c++]=b,l[c++]=u,l[c++]=b,l[c++]=f,m++,p++,d++,g++,u+=2,f+=2,y+=2,b+=2}const at=y(),lt=y(),ct=y(),ht=y(),mt=y();function pt(t,e,s,r,n){e*=3,s*=3,r*=3,p(at,t[e++],t[e++],t[e++]),p(lt,t[s++],t[s++],t[s++]),p(ct,t[r++],t[r++],t[r++]),d(ht,lt,at),d(mt,ct,at),g(n,mt,ht),m(n,n)}const dt=y();function gt(t,e,s,r,n,o){const i=t.stageObject,a=i.geometries,h=a.length,m="absolute-height"!==e.mode;let d=0;const g=i.transformation,f=l(c(),g);for(let l=0;l<h;l+=2){const t=a[l];if(!K(t))continue;const e=t.getMutableAttribute(X.POSITION).data,c=o[l/2],h=new H(t.mapPositions),y=e.length/3;let b=0,_=!1,x=0;for(let o=0;o<y;o++){dt[0]=e[b],dt[1]=e[b+1],dt[2]=e[b+2],r(h,yt),m&&(x+=yt.sampledElevation),N.TESTS_DISABLE_OPTIMIZATIONS?(p(ut,h.array[h.offset],h.array[h.offset+1],yt.z+c[b/3]),null!=s&&n.toRenderCoords(ut,s,ut),u(ut,ut,f)):(p(ut,e[b],e[b+1],e[b+2]),u(ut,ut,g),n.setAltitude(ut,yt.z+c[b/3]),u(ut,ut,f)),e[b]=ut[0],e[b+1]=ut[1],e[b+2]=ut[2];const t=xt/n.unitInMeters;(Math.abs(dt[0]-e[b])>=t||Math.abs(dt[1]-e[b+1])>=t||Math.abs(dt[2]-e[b+2])>=t)&&(_=!0),h.offset+=3,b+=3}_&&(t.invalidateBoundingInfo(),i.geometryVertexAttrsUpdated(a[l]),a[l+1].invalidateBoundingInfo(),i.geometryVertexAttrsUpdated(a[l+1])),d+=x/y}return d/h}const ut=y(),ft=y(),yt=new z,bt=[0,2,1],_t=[0,1,2],xt=.01;class jt{constructor(t,e,s,r){this.positions=t,this.elevation=e,this.normals=s,this.heights=r}}export{tt as Graphics3DExtrudeSymbolLayer};
5
+ import"../../../../core/has.js";import e from"../../../../core/Error.js";import{clone as t}from"../../../../core/lang.js";import{get as s}from"../../../../core/maybe.js";import{getMetersPerVerticalUnitForSR as r}from"../../../../core/unitUtils.js";import{e as n}from"../../../../chunks/earcut.js";import{b as o}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{a,u as l}from"../../../../chunks/mat4.js";import{c}from"../../../../chunks/mat4f64.js";import{c as h,n as m,s as p,b as g,f as d,m as u}from"../../../../chunks/vec3.js";import{d as f,c as y}from"../../../../chunks/vec3f64.js";import{computeTranslationToOriginAndRotation as b}from"../../../../geometry/projection.js";import{create as _,empty as j,expandWithBuffer as x,intersectsClippingArea as S}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as P}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as E,getZeroIndexArray as w}from"../../../../geometry/support/Indices.js";import{t as v}from"../../../../chunks/vec32.js";import{makeVertexCandidate as C,makeEdgeCandidate as L}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as O}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as I}from"../../../ViewingMode.js";import{needsElevationUpdates3D as M,SampleElevationInfo as A}from"./elevationAlignmentUtils.js";import{ElevationContext as z}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as R}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G,computeCentroid as B}from"./graphicUtils.js";import{ApplyRendererDiffResult as U}from"./interfaces.js";import{geometryAsPolygon as T}from"./polygonUtils.js";import{createMaterial as k}from"../support/edgeUtils.js";import N from"../../support/debugFlags.js";import{SamplePosition as V}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as H}from"../../support/renderInfoUtils/polygon.js";import{NormalType as F}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as W}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as q}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as Z}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as J}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as K}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as Q}from"../../webgl-engine/lib/Normals.js";import{Object3D as X}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as Y}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";const ee=["polygon","extent"];class te extends R{constructor(e,t,s,r){super(e,t,s,r),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=G(this._getSymbolSize());if(t)throw new e("graphics3dextrudesymbollayer:invalid-size",t)}const t=s(this.symbolLayer,"material","color"),r=this._getCombinedOpacityAndColor(t),n=f(r),o=r[3],i=o<1||this.needsDrivenTransparentPass,a={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:n,ambient:n,opacity:o,transparent:i,cullFace:i?q.None:q.Back,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0,normalType:F.CompressedAttribute};this._material=new $(a),this._bottomMaterial=new $({...a,cullFace:q.Back}),this._context.stage.add(this._material),this._context.stage.add(this._bottomMaterial)}destroy(){super.destroy(),this._material&&(this._context.stage.remove(this._material),this._context.stage.remove(this._bottomMaterial))}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,ee,this.symbolLayer.type))return null;const s=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t,new z);return this._createAs3DShape(t,e.renderingInfo,s,r,t.uid)}layerOpacityChanged(e,t){const r=s(this.symbolLayer,"material","color"),n=this._getCombinedOpacity(r),o=n<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:n,transparent:o}),this._bottomMaterial.setParameters({opacity:n,transparent:o});const i=this._getLayerOpacity();e.forEach((e=>{const s=t(e);null!=s&&s.layerOpacityChanged(i,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,M)}slicePlaneEnabledChanged(e,t){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._bottomMaterial.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),e.forEach((e=>{const s=t(e);null!=s&&s.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._bottomMaterial.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}_getExtrusionSize(e){let t;return t=e.size&&this._drivenProperties.size?O(e.size,2)??0:this._getSymbolSize(),t/=this._context.renderCoordsHelper.unitInMeters,t}applyRendererDiff(e,t){return this._drivenPropertiesChanged(t)?U.RecreateSymbol:U.RecreateGraphics}async queryForSnapping(e,s,n,o){const i=this._getExtrusionSize(n)*this._context.renderCoordsHelper.unitInMeters/r(s),{objectId:a,target:l}=e,c=t(l);switch(c.z=(c.z??0)+i,e.type){case"edge":{const{start:s,end:r}=e,n=t(s),o=t(r);return n.z=(n.z??0)+i,o.z=(o.z??0)+i,[L(a,c,1/0,n,o)]}case"vertex":return[C(a,c,1/0),L(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(e,t,s,r,l){const h=T(e.geometry);if(null==h)return null;if(0===h.rings.length||!h.rings.some((e=>e.length>0)))return this._logGeometryValidationWarnings(h.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=H(h,this._context.elevationProvider,this._context.renderCoordsHelper,r);this._logGeometryCreationWarnings(m,h.rings,"rings","ExtrudeSymbol3DLayer");const p=B(h);if(null==p)return null;const g=new Array,d=new Array,u=_(),f=c(),w=y(),C=this._context.renderCoordsHelper.viewingMode===I.Global;C||this._context.renderCoordsHelper.worldUpAtPosition(null,w),b(h.spatialReference,[p.x,p.y,0],f,this._context.renderCoordsHelper.spatialReference);const L=c();a(L,f);const O=i();o(O,L);const{polygons:A,mapPositions:z,position:R}=m;for(const o of A){const e=o.count;if(this._context.clippingExtent&&(j(u),x(u,o.mapPositions),!S(u,this._context.clippingExtent)))continue;const r=n(o.mapPositions,o.holeIndices,3);if(0===r.length)continue;const i=r.length,a=6*e,c=E(a+i),h=E(i),m=P(3*a),p=P(3*a),f=P(3*a),y=P(a);re(R,z,r,o,m,f,p,y,c,h,this._getExtrusionSize(t),w,C),v(m,m,L);const b=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:l,layerUid:this._context.layer.uid}),_=new Se(m,f,Q(p),y);g.push(se(this._material,c,c.length-h.length,_,s,b),se(this._bottomMaterial,h,0,_,s,b)),d.push(_.heights)}if(0===g.length)return null;const G=new X({geometries:g,layerUid:this._context.layer.uid,graphicUid:l,isElevationSource:!0});G.transformation=f;const U=k(this.symbolLayer,{opacity:this._getLayerOpacity()}),N=null!=U?{baseMaterial:this._material,edgeMaterials:[U],properties:{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}}:null,V=new D(this,G,g,null,null,((e,t,s,r,n)=>ue(e,t,s,r,n,d)),r,N);return V.alignedSampledElevation=m.sampledElevation,V.needsElevationUpdates=M(r.mode),V}}function se(e,t,s,r,n,o){const i=w(t.length),a=[[Y.POSITION,new W(r.positions,3,!0)],[Y.NORMALCOMPRESSED,new W(r.normals,2,!0)],[Y.COLOR,new W(n,4,!0)]],l=[[Y.POSITION,t],[Y.NORMALCOMPRESSED,t],[Y.COLOR,i]];return new J(e,a,l,r.elevation,Z.Mesh,o,s)}function re(e,t,s,r,n,o,i,a,l,c,h,m,p){const g=s.length/3;let d=0,u=2*r.count;ne(e,t,r.index,r.count,s,0,g,n,o,i,a,l,c,u,h,m,p);let f=2*r.count;u=0,ae(n,o,a,i,d,r.pathLengths[0],r.count,f,l,u,h),f+=4*r.pathLengths[0],u+=2*r.pathLengths[0],d+=r.pathLengths[0];for(let y=1;y<r.pathLengths.length;++y)ae(n,o,a,i,d,r.pathLengths[y],r.count,f,l,u,h),f+=4*r.pathLengths[y],u+=2*r.pathLengths[y],d+=r.pathLengths[y]}function ne(e,t,s,r,n,o,i,a,l,c,p,g,d,u,f,y,b){h(ye,y);const _=f>0?1:-1;let j=3*s,x=0,S=3*x,P=r,E=3*P;for(let h=0;h<r;++h)b&&(ye[0]=e[j],ye[1]=e[j+1],ye[2]=e[j+2],m(ye,ye)),a[S]=e[j],a[S+1]=e[j+1],a[S+2]=e[j+2],l[S]=t[j],l[S+1]=t[j+1],l[S+2]=t[j+2],c[S]=-_*ye[0],c[S+1]=-_*ye[1],c[S+2]=-_*ye[2],p[x]=0,a[E]=e[j]+f*ye[0],a[E+1]=e[j+1]+f*ye[1],a[E+2]=e[j+2]+f*ye[2],l[E]=t[j],l[E+1]=t[j+1],l[E+2]=t[j+2],c[E]=_*ye[0],c[E+1]=_*ye[1],c[E+2]=_*ye[2],p[P]=f,S+=3,E+=3,j+=3,x+=1,P+=1;j=3*o,S=0,E=3*u;const w=f<0?je:_e,v=f<0?_e:je;for(let h=0;h<i;++h)d[S]=n[j+w[0]],d[S+1]=n[j+w[1]],d[S+2]=n[j+w[2]],g[E]=n[j+v[0]]+r,g[E+1]=n[j+v[1]]+r,g[E+2]=n[j+v[2]]+r,S+=3,E+=3,j+=3}function oe(e,t,s,r,n,o,i){r[o]=r[i],i*=3,e[o*=3]=e[i],e[o+1]=e[i+1],e[o+2]=e[i+2],t[o]=t[i],t[o+1]=t[i+1],t[o+2]=t[i+2],s[o]=n[0],s[o+1]=n[1],s[o+2]=n[2]}const ie=y();function ae(e,t,s,r,n,o,i,a,l,c,h){let m=n,p=n+1,g=n+i,d=n+i+1,u=a,f=a+1,y=a+2*o,b=a+2*o+1;h<0&&(m=n+i+1,d=n),c*=3;for(let _=0;_<o;++_)_===o-1&&(h>0?(p=n,d=n+i):(p=n,m=n+i)),ge(e,m,p,g,ie),oe(e,t,r,s,ie,u,m),oe(e,t,r,s,ie,f,p),oe(e,t,r,s,ie,y,g),oe(e,t,r,s,ie,b,d),l[c++]=u,l[c++]=y,l[c++]=b,l[c++]=u,l[c++]=b,l[c++]=f,m++,p++,g++,d++,u+=2,f+=2,y+=2,b+=2}const le=y(),ce=y(),he=y(),me=y(),pe=y();function ge(e,t,s,r,n){t*=3,s*=3,r*=3,p(le,e[t++],e[t++],e[t++]),p(ce,e[s++],e[s++],e[s++]),p(he,e[r++],e[r++],e[r++]),g(me,ce,le),g(pe,he,le),d(n,pe,me),m(n,n)}const de=y();function ue(e,t,s,r,n,o){const i=e.stageObject,a=i.geometries,h=a.length,m="absolute-height"!==t.mode;let g=0;const d=i.transformation,f=l(c(),d);for(let l=0;l<h;l+=2){const e=a[l];if(!K(e))continue;const t=e.getMutableAttribute(Y.POSITION).data,c=o[l/2],h=new V(e.mapPositions),y=t.length/3;let b=0,_=!1,j=0;for(let o=0;o<y;o++){de[0]=t[b],de[1]=t[b+1],de[2]=t[b+2],r(h,be),m&&(j+=be.sampledElevation),N.TESTS_DISABLE_OPTIMIZATIONS?(p(fe,h.array[h.offset],h.array[h.offset+1],be.z+c[b/3]),null!=s&&n.toRenderCoords(fe,s,fe),u(fe,fe,f)):(p(fe,t[b],t[b+1],t[b+2]),u(fe,fe,d),n.setAltitude(fe,be.z+c[b/3]),u(fe,fe,f)),t[b]=fe[0],t[b+1]=fe[1],t[b+2]=fe[2];const e=xe/n.unitInMeters;(Math.abs(de[0]-t[b])>=e||Math.abs(de[1]-t[b+1])>=e||Math.abs(de[2]-t[b+2])>=e)&&(_=!0),h.offset+=3,b+=3}_&&(e.invalidateBoundingInfo(),i.geometryVertexAttrsUpdated(a[l]),a[l+1].invalidateBoundingInfo(),i.geometryVertexAttrsUpdated(a[l+1])),g+=j/y}return g/h}const fe=y(),ye=y(),be=new A,_e=[0,2,1],je=[0,1,2],xe=.01;class Se{constructor(e,t,s,r){this.positions=e,this.elevation=t,this.normals=s,this.heights=r}}export{te as Graphics3DExtrudeSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{get as t}from"../../../../core/maybe.js";import{b as r}from"../../../../chunks/mat3.js";import{c as o}from"../../../../chunks/mat3f64.js";import{a as s}from"../../../../chunks/mat4.js";import{c as n}from"../../../../chunks/mat4f64.js";import{m as i,b as l,D as a,l as u,n as c,h as m}from"../../../../chunks/vec3.js";import{c as f}from"../../../../chunks/vec3f64.js";import{empty as d,expandWithVec3 as p}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as g}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as x,BufferViewVec4u8 as b,BufferViewVec4u16 as h,BufferViewVec3f as T,BufferViewVec3u8 as y,BufferViewVec3u16 as w}from"../../../../geometry/support/buffer/BufferView.js";import{t as R,a as j,s as M}from"../../../../chunks/vec32.js";import{t as v,s as B}from"../../../../chunks/vec42.js";import{n as S}from"../../../../chunks/vec22.js";import{c as L}from"../../../../chunks/vec33.js";import{c as A}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as O}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as I}from"../../glTF/loader.js";import{convertPrimitiveToTriangles as k}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as C}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as F}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as E}from"./ProcessedObjectResource.js";import{load as N,processLoadResult as P}from"./wosrLoader.js";import{NormalAttributeType as U}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as V}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as D,DepthTestFunction as _,CullFaceOptions as G}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as H}from"../../webgl-engine/lib/Geometry.js";import{Texture as q}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as W}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";import{COLOR_GAMMA as z}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";async function K(r,o){const s=Q(e(r));if("wosr"===s.fileType){const e=await(o.cache?o.cache.loadWOSR(s.url,o):N(s.url,o)),{engineResources:t,referenceBoundingBox:r}=P(e,o);return{lods:t,referenceBoundingBox:r,isEsriSymbolResource:!1,isWosr:!0}}const n=await(o.cache?o.cache.loadGLTF(s.url,o,!!o.usePBR):I(new O(o.streamDataRequester),s.url,o,o.usePBR)),i=t(n.model.meta,"ESRI_proxyEllipsoid"),l=n.meta.isEsriSymbolResource&&null!=i&&n.meta.uri.includes("/RealisticTrees/");l&&!n.customMeta.esriTreeRendering&&(n.customMeta.esriTreeRendering=!0,te(n,i));const a=!!o.usePBR,u=n.meta.isEsriSymbolResource?{usePBR:a,isSchematic:!1,treeRendering:l,mrrFactors:[0,1,.2]}:{usePBR:a,isSchematic:!1,treeRendering:!1,mrrFactors:[0,1,.5]},c={...o.materialParamsMixin,treeRendering:l},{engineResources:m,referenceBoundingBox:f}=J(n,u,c,o.skipHighLods&&null==s.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:s.specifiedLodIndex});return{lods:m,referenceBoundingBox:f,isEsriSymbolResource:n.meta.isEsriSymbolResource,isWosr:!1}}function Q(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function J(e,t,r,o){const s=e.model,n=new Array,i=new Map,l=new Map,a=s.lods.length,u=d();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(a>1&&0===c||a>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new E(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new $({}):X(s,e,f,t,r,i,l),{geometry:n,vertexCount:a}=Y(e,null!=o?o:new $({})),d=n.boundingInfo;null!=d&&0===c&&(p(u,d.bbMin),p(u,d.bbMax)),null!=o&&(f.stageResources.geometries.push(n),f.numberOfVertices+=a)})),m||n.push(f)})),{engineResources:n,referenceBoundingBox:u}}function X(e,t,r,o,s,n,i){const l=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),a=e.materials.get(t.material),u=null!=t.attributes.texCoord0,c=null!=t.attributes.normal;if(null==a)return null;const m=ee(a.alphaMode);if(!n.has(l)){if(u){const t=(t,r=!1)=>{if(null!=t&&!i.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;i.set(t,new q(C(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!C(e)&&r,encoding:C(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(a.textureColor,m!==D.Opaque),t(a.textureNormal),t(a.textureOcclusion),t(a.textureEmissive),t(a.textureMetallicRoughness)}const r=a.color[0]**(1/z),f=a.color[1]**(1/z),d=a.color[2]**(1/z),p=a.emissiveFactor[0]**(1/z),g=a.emissiveFactor[1]**(1/z),x=a.emissiveFactor[2]**(1/z),b=null!=a.textureColor&&u?i.get(a.textureColor):null;n.set(l,new $({...o,transparent:m===D.Blend,customDepthTest:_.Lequal,textureAlphaMode:m,textureAlphaCutoff:a.alphaCutoff,diffuse:[r,f,d],ambient:[r,f,d],opacity:a.opacity,doubleSided:a.doubleSided,doubleSidedType:"winding-order",cullFace:a.doubleSided?G.None:G.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:c?U.Attribute:U.ScreenDerivative,castShadows:!0,receiveSSAO:!0,textureId:null!=b?b.id:void 0,colorMixMode:a.colorMixMode,normalTextureId:null!=a.textureNormal&&u?i.get(a.textureNormal).id:void 0,textureAlphaPremultiplied:null!=b&&!!b.params.preMultiplyAlpha,occlusionTextureId:null!=a.textureOcclusion&&u?i.get(a.textureOcclusion).id:void 0,emissiveTextureId:null!=a.textureEmissive&&u?i.get(a.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=a.textureMetallicRoughness&&u?i.get(a.textureMetallicRoughness).id:void 0,emissiveFactor:[p,g,x],mrrFactors:[a.metallicFactor,a.roughnessFactor,o.mrrFactors[2]],isSchematic:!1,colorTextureTransformMatrix:F(a.colorTextureTransform),normalTextureTransformMatrix:F(a.normalTextureTransform),occlusionTextureTransformMatrix:F(a.occlusionTextureTransform),emissiveTextureTransformMatrix:F(a.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:F(a.metallicRoughnessTextureTransform),...s}))}const f=n.get(l);if(r.stageResources.materials.push(f),u){const e=e=>{null!=e&&r.stageResources.textures.push(i.get(e))};e(a.textureColor),e(a.textureNormal),e(a.textureOcclusion),e(a.textureEmissive),e(a.textureMetallicRoughness)}return f}function Y(e,t){const o=e.attributes.position.count,s=k(e.indices||o,e.primitiveType),n=g(3*o),{typedBuffer:i,typedBufferStride:l}=e.attributes.position;R(n,i,e.transform,3,l);const a=[[W.POSITION,new V(n,3,!0)]],u=[[W.POSITION,s]];if(null!=e.attributes.normal){const t=g(3*o),{typedBuffer:n,typedBufferStride:i}=e.attributes.normal;r(Z,e.transform),j(t,n,Z,3,i),a.push([W.NORMAL,new V(t,3,!0)]),u.push([W.NORMAL,s])}if(null!=e.attributes.tangent){const t=g(4*o),{typedBuffer:n,typedBufferStride:i}=e.attributes.tangent;r(Z,e.transform),v(t,n,Z,4,i),a.push([W.TANGENT,new V(t,4,!0)]),u.push([W.TANGENT,s])}if(null!=e.attributes.texCoord0){const t=g(2*o),{typedBuffer:r,typedBufferStride:n}=e.attributes.texCoord0;S(t,r,2,n),a.push([W.UV0,new V(t,2,!0)]),u.push([W.UV0,s])}if(null!=e.attributes.color){const t=new Uint8Array(4*o);4===e.attributes.color.elementCount?e.attributes.color instanceof x?B(t,e.attributes.color,255):e.attributes.color instanceof b?A(t,e.attributes.color):e.attributes.color instanceof h&&B(t,e.attributes.color,1/256):(t.fill(255),e.attributes.color instanceof T?M(t,e.attributes.color,255,4):e.attributes.color instanceof y?L(t,e.attributes.color.typedBuffer,4,e.attributes.color.typedBufferStride):e.attributes.color instanceof w&&M(t,e.attributes.color,1/256,4)),a.push([W.COLOR,new V(t,4,!0)]),u.push([W.COLOR,s])}return{geometry:new H(t,a,u),vertexCount:o}}const Z=o();function ee(e){switch(e){case"BLEND":return D.Blend;case"MASK":return D.Mask;case"OPAQUE":case null:case void 0:return D.Opaque}}function te(e,t){for(let r=0;r<e.model.lods.length;++r){const o=e.model.lods[r];for(const d of o.parts){const o=d.attributes.normal;if(null==o)return;const p=d.attributes.position,g=p.count,x=f(),h=f(),y=f(),w=new Uint8Array(4*g),R=new Float64Array(3*g),j=s(n(),d.transform);let M=0,v=0;for(let s=0;s<g;s++){p.getVec(s,h),o.getVec(s,x),i(h,h,d.transform),l(y,h,t.center),a(y,y,t.radius);const n=y[2],f=u(y),g=Math.min(.45+.55*f*f,1);a(y,y,t.radius),null!==j&&i(y,y,j),c(y,y),r+1!==e.model.lods.length&&e.model.lods.length>1&&m(y,y,x,n>-1?.2:Math.min(-4*n-3.8,1)),R[M]=y[0],R[M+1]=y[1],R[M+2]=y[2],M+=3,w[v]=255*g,w[v+1]=255*g,w[v+2]=255*g,w[v+3]=255,v+=4}d.attributes.normal=new T(R),d.attributes.color=new b(w)}}}export{K as fetch,J as gltfToEngineResources,Q as parseUrl};
5
+ import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{get as t}from"../../../../core/maybe.js";import{b as r}from"../../../../chunks/mat3.js";import{c as o}from"../../../../chunks/mat3f64.js";import{a as s}from"../../../../chunks/mat4.js";import{c as n}from"../../../../chunks/mat4f64.js";import{m as i,b as l,D as a,l as u,n as c,h as m}from"../../../../chunks/vec3.js";import{c as f}from"../../../../chunks/vec3f64.js";import{empty as d,expandWithVec3 as p}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as g}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as x,BufferViewVec4u8 as b,BufferViewVec4u16 as h,BufferViewVec3f as T,BufferViewVec3u8 as y,BufferViewVec3u16 as w}from"../../../../geometry/support/buffer/BufferView.js";import{t as R,a as j,s as M}from"../../../../chunks/vec32.js";import{t as v,s as B}from"../../../../chunks/vec42.js";import{n as S}from"../../../../chunks/vec22.js";import{c as L}from"../../../../chunks/vec33.js";import{c as A}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as O}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as I}from"../../glTF/loader.js";import{convertPrimitiveToTriangles as k}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as C}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as F}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as E}from"./ProcessedObjectResource.js";import{load as N,processLoadResult as P}from"./wosrLoader.js";import{NormalType as U}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as V}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as D,DepthTestFunction as _,CullFaceOptions as G}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as H}from"../../webgl-engine/lib/Geometry.js";import{Texture as q}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as W}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";import{COLOR_GAMMA as z}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";async function K(r,o){const s=Q(e(r));if("wosr"===s.fileType){const e=await(o.cache?o.cache.loadWOSR(s.url,o):N(s.url,o)),{engineResources:t,referenceBoundingBox:r}=P(e,o);return{lods:t,referenceBoundingBox:r,isEsriSymbolResource:!1,isWosr:!0}}const n=await(o.cache?o.cache.loadGLTF(s.url,o,!!o.usePBR):I(new O(o.streamDataRequester),s.url,o,o.usePBR)),i=t(n.model.meta,"ESRI_proxyEllipsoid"),l=n.meta.isEsriSymbolResource&&null!=i&&n.meta.uri.includes("/RealisticTrees/");l&&!n.customMeta.esriTreeRendering&&(n.customMeta.esriTreeRendering=!0,te(n,i));const a=!!o.usePBR,u=n.meta.isEsriSymbolResource?{usePBR:a,isSchematic:!1,treeRendering:l,mrrFactors:[0,1,.2]}:{usePBR:a,isSchematic:!1,treeRendering:!1,mrrFactors:[0,1,.5]},c={...o.materialParamsMixin,treeRendering:l},{engineResources:m,referenceBoundingBox:f}=J(n,u,c,o.skipHighLods&&null==s.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:s.specifiedLodIndex});return{lods:m,referenceBoundingBox:f,isEsriSymbolResource:n.meta.isEsriSymbolResource,isWosr:!1}}function Q(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function J(e,t,r,o){const s=e.model,n=new Array,i=new Map,l=new Map,a=s.lods.length,u=d();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(a>1&&0===c||a>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new E(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new $({}):X(s,e,f,t,r,i,l),{geometry:n,vertexCount:a}=Y(e,null!=o?o:new $({})),d=n.boundingInfo;null!=d&&0===c&&(p(u,d.bbMin),p(u,d.bbMax)),null!=o&&(f.stageResources.geometries.push(n),f.numberOfVertices+=a)})),m||n.push(f)})),{engineResources:n,referenceBoundingBox:u}}function X(e,t,r,o,s,n,i){const l=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),a=e.materials.get(t.material),u=null!=t.attributes.texCoord0,c=null!=t.attributes.normal;if(null==a)return null;const m=ee(a.alphaMode);if(!n.has(l)){if(u){const t=(t,r=!1)=>{if(null!=t&&!i.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;i.set(t,new q(C(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!C(e)&&r,encoding:C(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(a.textureColor,m!==D.Opaque),t(a.textureNormal),t(a.textureOcclusion),t(a.textureEmissive),t(a.textureMetallicRoughness)}const r=a.color[0]**(1/z),f=a.color[1]**(1/z),d=a.color[2]**(1/z),p=a.emissiveFactor[0]**(1/z),g=a.emissiveFactor[1]**(1/z),x=a.emissiveFactor[2]**(1/z),b=null!=a.textureColor&&u?i.get(a.textureColor):null;n.set(l,new $({...o,transparent:m===D.Blend,customDepthTest:_.Lequal,textureAlphaMode:m,textureAlphaCutoff:a.alphaCutoff,diffuse:[r,f,d],ambient:[r,f,d],opacity:a.opacity,doubleSided:a.doubleSided,doubleSidedType:"winding-order",cullFace:a.doubleSided?G.None:G.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:c?U.Attribute:U.ScreenDerivative,castShadows:!0,receiveSSAO:!0,textureId:null!=b?b.id:void 0,colorMixMode:a.colorMixMode,normalTextureId:null!=a.textureNormal&&u?i.get(a.textureNormal).id:void 0,textureAlphaPremultiplied:null!=b&&!!b.params.preMultiplyAlpha,occlusionTextureId:null!=a.textureOcclusion&&u?i.get(a.textureOcclusion).id:void 0,emissiveTextureId:null!=a.textureEmissive&&u?i.get(a.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=a.textureMetallicRoughness&&u?i.get(a.textureMetallicRoughness).id:void 0,emissiveFactor:[p,g,x],mrrFactors:[a.metallicFactor,a.roughnessFactor,o.mrrFactors[2]],isSchematic:!1,colorTextureTransformMatrix:F(a.colorTextureTransform),normalTextureTransformMatrix:F(a.normalTextureTransform),occlusionTextureTransformMatrix:F(a.occlusionTextureTransform),emissiveTextureTransformMatrix:F(a.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:F(a.metallicRoughnessTextureTransform),...s}))}const f=n.get(l);if(r.stageResources.materials.push(f),u){const e=e=>{null!=e&&r.stageResources.textures.push(i.get(e))};e(a.textureColor),e(a.textureNormal),e(a.textureOcclusion),e(a.textureEmissive),e(a.textureMetallicRoughness)}return f}function Y(e,t){const o=e.attributes.position.count,s=k(e.indices||o,e.primitiveType),n=g(3*o),{typedBuffer:i,typedBufferStride:l}=e.attributes.position;R(n,i,e.transform,3,l);const a=[[W.POSITION,new V(n,3,!0)]],u=[[W.POSITION,s]];if(null!=e.attributes.normal){const t=g(3*o),{typedBuffer:n,typedBufferStride:i}=e.attributes.normal;r(Z,e.transform),j(t,n,Z,3,i),a.push([W.NORMAL,new V(t,3,!0)]),u.push([W.NORMAL,s])}if(null!=e.attributes.tangent){const t=g(4*o),{typedBuffer:n,typedBufferStride:i}=e.attributes.tangent;r(Z,e.transform),v(t,n,Z,4,i),a.push([W.TANGENT,new V(t,4,!0)]),u.push([W.TANGENT,s])}if(null!=e.attributes.texCoord0){const t=g(2*o),{typedBuffer:r,typedBufferStride:n}=e.attributes.texCoord0;S(t,r,2,n),a.push([W.UV0,new V(t,2,!0)]),u.push([W.UV0,s])}if(null!=e.attributes.color){const t=new Uint8Array(4*o);4===e.attributes.color.elementCount?e.attributes.color instanceof x?B(t,e.attributes.color,255):e.attributes.color instanceof b?A(t,e.attributes.color):e.attributes.color instanceof h&&B(t,e.attributes.color,1/256):(t.fill(255),e.attributes.color instanceof T?M(t,e.attributes.color,255,4):e.attributes.color instanceof y?L(t,e.attributes.color.typedBuffer,4,e.attributes.color.typedBufferStride):e.attributes.color instanceof w&&M(t,e.attributes.color,1/256,4)),a.push([W.COLOR,new V(t,4,!0)]),u.push([W.COLOR,s])}return{geometry:new H(t,a,u),vertexCount:o}}const Z=o();function ee(e){switch(e){case"BLEND":return D.Blend;case"MASK":return D.Mask;case"OPAQUE":case null:case void 0:return D.Opaque}}function te(e,t){for(let r=0;r<e.model.lods.length;++r){const o=e.model.lods[r];for(const d of o.parts){const o=d.attributes.normal;if(null==o)return;const p=d.attributes.position,g=p.count,x=f(),h=f(),y=f(),w=new Uint8Array(4*g),R=new Float64Array(3*g),j=s(n(),d.transform);let M=0,v=0;for(let s=0;s<g;s++){p.getVec(s,h),o.getVec(s,x),i(h,h,d.transform),l(y,h,t.center),a(y,y,t.radius);const n=y[2],f=u(y),g=Math.min(.45+.55*f*f,1);a(y,y,t.radius),null!==j&&i(y,y,j),c(y,y),r+1!==e.model.lods.length&&e.model.lods.length>1&&m(y,y,x,n>-1?.2:Math.min(-4*n-3.8,1)),R[M]=y[0],R[M+1]=y[1],R[M+2]=y[2],M+=3,w[v]=255*g,w[v+1]=255*g,w[v+2]=255*g,w[v+3]=255,v+=4}d.attributes.normal=new T(R),d.attributes.color=new b(w)}}}export{K as fetch,J as gltfToEngineResources,Q as parseUrl};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- function t(t){const e=t.renderer,n=e?.type,o=e?.toJSON()??null;let l=null,i=!1;const a=t.attributeStorageInfo;"point-cloud-unique-value"===n||"point-cloud-stretch"===n||"point-cloud-class-breaks"===n?l=u(a,e.field):"point-cloud-rgb"===n?(l=r(a,e.field),i=null!=l):(l=r(a,"RGB"),i=null!=l);let s=null;return e?.colorModulation&&(s=u(a,e.colorModulation.field)),{rendererJSON:o,isRGBRenderer:i,primaryAttribute:l,modulationAttribute:s}}function e(t){const e=t.filters;return e?e.map((e=>({filterJSON:e.toJSON(),attributeInfo:u(t.attributeStorageInfo,e.field)}))):[]}function n(t){const e=t?.pointSizeAlgorithm;return e&&"splat"===e.type?e:null}function o(t){const e=t?.pointSizeAlgorithm;return e&&"fixed-size"===e.type?e:null}function l(t){const e=t?.pointSizeAlgorithm;return!(!e||!e.type)&&"fixed-size"===e.type}function r(t,e){for(const n of t??[])if(n.name===e&&null!=n.attributeValues&&"UInt8"===n.attributeValues.valueType&&3===n.attributeValues.valuesPerElement)return{name:e,storageInfo:n,useElevation:!1};return null}function u(t,e){for(const n of t??[])if(n.name===e){const t="embedded-elevation"===n.encoding;return{name:e,storageInfo:t?null:n,useElevation:t}}return"elevation"===e?.toLowerCase()?{name:e,storageInfo:null,useElevation:!0}:null}export{u as getAttributeInfo,e as getFilterInfo,o as getFixedSizeAlgorithm,t as getRendererInfo,n as getSplatSizeAlgorithm,l as rendererUsesFixedSizes};
5
+ function t(t){const e=t.renderer,n=e?.type,o=e?.toJSON()??null;let l=null,i=!1;const a=t.attributeStorageInfo;"point-cloud-unique-value"===n||"point-cloud-stretch"===n||"point-cloud-class-breaks"===n?l=u(a,e.field):"point-cloud-rgb"===n?(l=r(a,e.field),i=null!=l):(l=r(a,"RGB"),i=null!=l);let s=null;return e?.colorModulation&&(s=u(a,e.colorModulation.field)),{rendererJSON:o,isRGBRenderer:i,primaryAttribute:l,modulationAttribute:s}}function e(t){const e=t.filters;return e?e.map((e=>({filterJSON:e.toJSON(),attributeInfo:u(t.attributeStorageInfo,e.field)}))):[]}function n(t){const e=t?.pointSizeAlgorithm;return e&&"splat"===e.type?e:null}function o(t){const e=t?.pointSizeAlgorithm;return e&&"fixed-size"===e.type?e:null}function l(t){const e=t?.pointSizeAlgorithm;return!(!e||!e.type)&&"fixed-size"===e.type}function r(t,e){for(const n of t??[])if(n.name===e&&null!=n.attributeValues&&"UInt8"===n.attributeValues.valueType&&3===n.attributeValues.valuesPerElement)return{name:e,storageInfo:n,useElevation:!1};return null}function u(t,e){for(const n of t??[])if(n.name===e){const t="embedded-elevation"===n.encoding;return t?{name:e,storageInfo:null,useElevation:t}:{name:e,storageInfo:n,useElevation:t}}return"elevation"===e?.toLowerCase()?{name:e,storageInfo:null,useElevation:!0}:null}export{u as getAttributeInfo,e as getFilterInfo,o as getFixedSizeAlgorithm,t as getRendererInfo,n as getSplatSizeAlgorithm,l as rendererUsesFixedSizes};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../renderers/PointCloudClassBreaksRenderer.js";import o from"../../../../renderers/PointCloudStretchRenderer.js";import r from"../../../../renderers/PointCloudUniqueValueRenderer.js";import{createGeometryIndexFromSchema as t,createTypedView as l,readBinaryAttribute as n}from"./I3SBinaryReader.js";import{decodeXYZ as s}from"./LEPCC.js";function i(t,l,n,s){const{rendererJSON:i,isRGBRenderer:u}=t;let f=null,c=null;if(l&&u)f=l;else if(l&&"pointCloudUniqueValueRenderer"===i?.type){c=r.fromJSON(i);const e=c.colorUniqueValueInfos;f=new Uint8Array(3*s);const o=d(c.fieldTransformType);for(let r=0;r<s;r++){const t=(o?o(l[r]):l[r])+"";for(let o=0;o<e.length;o++)if(e[o].values.includes(t)){f[3*r]=e[o].color.r,f[3*r+1]=e[o].color.g,f[3*r+2]=e[o].color.b;break}}}else if(l&&"pointCloudStretchRenderer"===i?.type){c=o.fromJSON(i);const e=c.stops;f=new Uint8Array(3*s);const r=d(c.fieldTransformType);for(let o=0;o<s;o++){const t=r?r(l[o]):l[o],n=e.length-1;if(t<e[0].value)f[3*o]=e[0].color.r,f[3*o+1]=e[0].color.g,f[3*o+2]=e[0].color.b;else if(t>=e[n].value)f[3*o]=e[n].color.r,f[3*o+1]=e[n].color.g,f[3*o+2]=e[n].color.b;else for(let r=1;r<e.length;r++)if(t<e[r].value){const l=(t-e[r-1].value)/(e[r].value-e[r-1].value);f[3*o]=e[r].color.r*l+e[r-1].color.r*(1-l),f[3*o+1]=e[r].color.g*l+e[r-1].color.g*(1-l),f[3*o+2]=e[r].color.b*l+e[r-1].color.b*(1-l);break}}}else if(l&&"pointCloudClassBreaksRenderer"===i?.type){c=e.fromJSON(i);const o=c.colorClassBreakInfos;f=new Uint8Array(3*s);const r=d(c.fieldTransformType);for(let e=0;e<s;e++){const t=r?r(l[e]):l[e];for(let r=0;r<o.length;r++)if(t>=o[r].minValue&&t<=o[r].maxValue){f[3*e]=o[r].color.r,f[3*e+1]=o[r].color.g,f[3*e+2]=o[r].color.b;break}}}else{f=new Uint8Array(3*s);for(let e=0;e<f.length;e++)f[e]=255}if(n&&c&&c.colorModulation){const e=c.colorModulation.minValue,o=c.colorModulation.maxValue,r=.3;for(let t=0;t<s;t++){const l=n[t],s=l>=o?1:l<=e?r:r+(1-r)*(l-e)/(o-e);f[3*t]=s*f[3*t],f[3*t+1]=s*f[3*t+1],f[3*t+2]=s*f[3*t+2]}}return f}function u(e,o){if(null==e.encoding||""===e.encoding){const r=t(o,e);if(null==r.vertexAttributes.position)return;const n=l(o,r.vertexAttributes.position),s=r.header.fields,i=[s.offsetX,s.offsetY,s.offsetZ],u=[s.scaleX,s.scaleY,s.scaleZ],f=n.length/3,c=new Float64Array(3*f);for(let e=0;e<f;e++)c[3*e]=n[3*e]*u[0]+i[0],c[3*e+1]=n[3*e+1]*u[1]+i[1],c[3*e+2]=n[3*e+2]*u[2]+i[2];return c}if("lepcc-xyz"===e.encoding)return s(o).result}function f(e,o,r){return null!=e&&e.attributeInfo.useElevation?o?c(o,r):null:null!=e&&e.attributeInfo.storageInfo?n(e.attributeInfo.storageInfo,e.buffer,r):null}function c(e,o){const r=new Float64Array(o);for(let t=0;t<o;t++)r[t]=e[3*t+2];return r}function a(e,o,r,t,l){const n=e.length/3;let s=0;for(let i=0;i<n;i++){let n=!0;for(let e=0;e<t.length&&n;e++){const{filterJSON:o}=t[e],r=l[e].values[i];switch(o.type){case"pointCloudValueFilter":{const e="exclude"===o.mode;o.values.includes(r)===e&&(n=!1);break}case"pointCloudBitfieldFilter":{const e=b(o.requiredSetBits),t=b(o.requiredClearBits);(r&e)===e&&0==(r&t)||(n=!1);break}case"pointCloudReturnFilter":{const e=15&r,t=r>>>4&15,l=t>1,s=1===e,i=e===t;let u=!1;for(const r of o.includedReturns)if("last"===r&&i||"firstOfMany"===r&&s&&l||"lastOfMany"===r&&i&&l||"single"===r&&!l){u=!0;break}u||(n=!1);break}}}n&&(r[s]=i,e[3*s]=e[3*i],e[3*s+1]=e[3*i+1],e[3*s+2]=e[3*i+2],o[3*s]=o[3*i],o[3*s+1]=o[3*i+1],o[3*s+2]=o[3*i+2],s++)}return s}function d(e){return null==e||"none"===e?null:"low-four-bit"===e?e=>15&e:"high-four-bit"===e?e=>(240&e)>>4:"absolute-value"===e?e=>Math.abs(e):"modulo-ten"===e?e=>e%10:null}function b(e){let o=0;for(const r of e||[])o|=1<<r;return o}export{c as elevationFromPositions,i as evaluateRenderer,a as filterInPlace,f as getAttributeValues,u as readGeometry};
5
+ import"../../../../core/has.js";import e from"../../../../renderers/PointCloudClassBreaksRenderer.js";import r from"../../../../renderers/PointCloudStretchRenderer.js";import o from"../../../../renderers/PointCloudUniqueValueRenderer.js";import{createGeometryIndexFromSchema as t,createTypedView as n,readBinaryAttribute as l}from"./I3SBinaryReader.js";import{decodeXYZ as s}from"./LEPCC.js";function i(t,n,l,s){const{rendererJSON:i,isRGBRenderer:u}=t;let c=null,a=null;if(n&&u)c=n;else if(n&&"pointCloudUniqueValueRenderer"===i?.type){a=o.fromJSON(i);const e=a.colorUniqueValueInfos;c=new Uint8Array(3*s);const r=d(a.fieldTransformType);for(let o=0;o<s;o++){const t=(r?r(n[o]):n[o])+"";for(let r=0;r<e.length;r++)if(e[r].values.includes(t)){c[3*o]=e[r].color.r,c[3*o+1]=e[r].color.g,c[3*o+2]=e[r].color.b;break}}}else if(n&&"pointCloudStretchRenderer"===i?.type){a=r.fromJSON(i);const e=a.stops;c=new Uint8Array(3*s);const o=d(a.fieldTransformType);for(let r=0;r<s;r++){const t=o?o(n[r]):n[r],l=e.length-1;if(t<e[0].value)c[3*r]=e[0].color.r,c[3*r+1]=e[0].color.g,c[3*r+2]=e[0].color.b;else if(t>=e[l].value)c[3*r]=e[l].color.r,c[3*r+1]=e[l].color.g,c[3*r+2]=e[l].color.b;else for(let o=1;o<e.length;o++)if(t<e[o].value){const n=(t-e[o-1].value)/(e[o].value-e[o-1].value);c[3*r]=e[o].color.r*n+e[o-1].color.r*(1-n),c[3*r+1]=e[o].color.g*n+e[o-1].color.g*(1-n),c[3*r+2]=e[o].color.b*n+e[o-1].color.b*(1-n);break}}}else if(n&&"pointCloudClassBreaksRenderer"===i?.type){a=e.fromJSON(i);const r=a.colorClassBreakInfos;c=new Uint8Array(3*s);const o=d(a.fieldTransformType);for(let e=0;e<s;e++){const t=o?o(n[e]):n[e];for(let o=0;o<r.length;o++)if(t>=r[o].minValue&&t<=r[o].maxValue){c[3*e]=r[o].color.r,c[3*e+1]=r[o].color.g,c[3*e+2]=r[o].color.b;break}}}else c=new Uint8Array(3*s).fill(255);if(l&&a&&a.colorModulation){const e=a.colorModulation.minValue,r=a.colorModulation.maxValue,o=.3;for(let t=0;t<s;t++){const n=l[t],s=n>=r?1:n<=e?o:o+(1-o)*(n-e)/(r-e);c[3*t]=s*c[3*t],c[3*t+1]=s*c[3*t+1],c[3*t+2]=s*c[3*t+2]}}return c}function u(e,r){if(null==e.encoding||""===e.encoding){const o=t(r,e);if(null==o.vertexAttributes.position)return;const l=n(r,o.vertexAttributes.position),s=o.header.fields,i=[s.offsetX,s.offsetY,s.offsetZ],u=[s.scaleX,s.scaleY,s.scaleZ],c=l.length/3,a=new Float64Array(3*c);for(let e=0;e<c;e++)a[3*e]=l[3*e]*u[0]+i[0],a[3*e+1]=l[3*e+1]*u[1]+i[1],a[3*e+2]=l[3*e+2]*u[2]+i[2];return a}if("lepcc-xyz"===e.encoding)return s(r).result}function c(e,r,o){return null!=e&&e.attributeInfo.useElevation?r?a(r,o):null:null!=e&&e.attributeInfo.storageInfo?l(e.attributeInfo.storageInfo,e.buffer,o):null}function a(e,r){const o=new Float64Array(r);for(let t=0;t<r;t++)o[t]=e[3*t+2];return o}function f(e,r,o,t,n){const l=e.length/3;let s=0;for(let i=0;i<l;i++){let l=!0;for(let e=0;e<t.length&&l;e++){const{filterJSON:r}=t[e],o=n[e].values[i];switch(r.type){case"pointCloudValueFilter":{const e="exclude"===r.mode;r.values.includes(o)===e&&(l=!1);break}case"pointCloudBitfieldFilter":{const e=p(r.requiredSetBits),t=p(r.requiredClearBits);(o&e)===e&&0==(o&t)||(l=!1);break}case"pointCloudReturnFilter":{const e=15&o,t=o>>>4&15,n=t>1,s=1===e,i=e===t;let u=!1;for(const o of r.includedReturns)if("last"===o&&i||"firstOfMany"===o&&s&&n||"lastOfMany"===o&&i&&n||"single"===o&&!n){u=!0;break}u||(l=!1);break}}}l&&(o[s]=i,e[3*s]=e[3*i],e[3*s+1]=e[3*i+1],e[3*s+2]=e[3*i+2],r[3*s]=r[3*i],r[3*s+1]=r[3*i+1],r[3*s+2]=r[3*i+2],s++)}return s}function d(e){switch(e){default:case null:case"none":return e=>e;case"low-four-bit":return e=>15&e;case"high-four-bit":return e=>(240&e)>>4;case"absolute-value":return e=>Math.abs(e);case"modulo-ten":return e=>e%10}}function p(e){let r=0;for(const o of e||[])r|=1<<o;return r}export{a as elevationFromPositions,i as evaluateRenderer,f as filterInPlace,c as getAttributeValues,u as readGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../../../chunks/tslib.es6.js";import o from"../../../../Graphic.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as e}from"../../../../core/accessorSupport/decorators/subclass.js";let t=class extends o{constructor(r){super(r)}};r([s({constructOnly:!0,clonable:"reference"})],t.prototype,"pointCloudMetadata",void 0),t=r([e("esri.views.3d.layers.i3s.PointGraphic")],t);export{t as PointGraphic};
5
+ import{_ as r}from"../../../../chunks/tslib.es6.js";import o from"../../../../Graphic.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";let e=class extends o{constructor(r){super(r),this.pointCloudMetadata=null}};r([s({constructOnly:!0,clonable:"reference"})],e.prototype,"pointCloudMetadata",void 0),e=r([t("esri.views.3d.layers.i3s.PointGraphic")],e);export{e as PointGraphic};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Evented.js";import{when as o}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{afterDispatch as s}from"../../../core/accessorSupport/watch.js";import{f as n}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as l}from"../../../geometry/ellipsoidUtils.js";import p from"../../ViewAnimation.js";import{ViewingMode as c}from"../../ViewingMode.js";import{Constraints as m}from"./Constraints.js";import{AnimationController as h}from"./controllers/AnimationController.js";import{State as d}from"./controllers/CameraController.js";import{PropertiesPool as u}from"../support/PropertiesPool.js";import{Camera as g,PaddingSide as C}from"../webgl-engine/lib/Camera.js";import{RenderState as y}from"../../support/RenderState.js";let _=class extends t{constructor(){super(...arguments),this._propertiesPool=new u({camera:g},this),this._lastSeenCameraProjectionValues=new g,this.mode=y.ANIMATING,this.rasterPixelRatio=1,this.contentPixelRatio=1,this.events=new r,this.viewingMode=c.Global,this._cameraChanged=!1,this._updateQueue=new Array,this._processingUpdates=!1}init(e,t){this._set("viewingMode",e),this._set("spatialReference",t),this._set("constraints",new m({mode:this.viewingMode}))}exit(){this.cameraController=null,this._propertiesPool.destroy(),this._propertiesPool=new u({camera:g},this)}createInitialCamera(){if(this.viewingMode===c.Global){const e=l(this.spatialReference).radius;this.camera=new g({eye:n(4*e,0,0),center:n(e,0,0),up:n(0,0,1)})}else this.camera=new g({eye:n(0,0,100),center:n(0,0,0),up:n(0,1,0)})}get animation(){return this.cameraController instanceof h&&null!=this.cameraController.viewAnimation?this.cameraController.viewAnimation:null}get camera(){return this._get("camera")}set camera(e){e!==v&&v.copyFrom(e),v.computeUp(this.viewingMode),this.events.emit("before-camera-change",v);const t=this._get("camera");if(this._cameraProjectionChanged(this._lastSeenCameraProjectionValues,v)&&(this._lastSeenCameraProjectionValues.copyFrom(v),this.events.emit("camera-projection-changed",this._lastSeenCameraProjectionValues)),(!t||!t.equals(v))&&(this._set("camera",this._propertiesPool.get("camera").copyFrom(v)),this._cameraChanged=!t||!t.almostEquals(v),this._cameraChanged)){const e=s((()=>{this._cameraChanged=!1,e.remove()}))}}get pixelRatio(){return this.camera.pixelRatio}get contentCamera(){return this._contentCamera??this.camera}set contentCamera(e){this._contentCamera=null!=e?e.clone():null}get fixedContentCamera(){return null!=this._contentCamera}get isGlobal(){return this.viewingMode===c.Global}get isLocal(){return this.viewingMode===c.Local}get navigating(){return!(!this.cameraController||!this.cameraController.isInteractive)}get stationary(){return!this._cameraChanged&&!this.navigating}get cameraController(){return this._get("cameraController")}set cameraController(e){this.stopActiveCameraController()?(e&&(this.removeHandles(w),this.addHandles(o((()=>e.state===d.Finished||e.state===d.Stopped),(()=>{this._set("cameraController",null),this.updateCamera((t=>e.onControllerEnd(t)))}),{sync:!0,once:!0}),w),e.onControllerStart(this.camera)),this._set("cameraController",e)):e&&(e.state=d.Rejected)}switchCameraController(e){return this.cameraController=e,e.state!==d.Rejected}stopActiveCameraController(){return!(this.cameraController&&!this.cameraController.stopController())}updateCamera(e){this._updateQueue.push(e),this._processUpdateQueue()}_processUpdateQueue(){if(0===this._updateQueue.length||this._processingUpdates)return;this._processingUpdates=!0;const e=this._updateQueue.shift();v.copyFrom(this._get("camera")),e(v),this.camera=v,this._processingUpdates=!1,this._processUpdateQueue()}_cameraProjectionChanged(e,t){return e.fov!==t.fov||(e.fullViewport[0]!==t.fullViewport[0]||e.fullViewport[1]!==t.fullViewport[1]||e.fullViewport[2]!==t.fullViewport[2]||e.fullViewport[3]!==t.fullViewport[3]||(e.padding[C.TOP]!==t.padding[C.TOP]||e.padding[C.RIGHT]!==t.padding[C.RIGHT]||e.padding[C.BOTTOM]!==t.padding[C.BOTTOM]||e.padding[C.LEFT]!==t.padding[C.LEFT]))}};e([a()],_.prototype,"mode",void 0),e([a({readOnly:!0,type:p})],_.prototype,"animation",null),e([a({type:g})],_.prototype,"camera",null),e([a({readOnly:!0})],_.prototype,"pixelRatio",null),e([a()],_.prototype,"rasterPixelRatio",void 0),e([a()],_.prototype,"contentPixelRatio",void 0),e([a({})],_.prototype,"_contentCamera",void 0),e([a({type:g})],_.prototype,"contentCamera",null),e([a({readOnly:!0})],_.prototype,"fixedContentCamera",null),e([a({readOnly:!0})],_.prototype,"constraints",void 0),e([a({readOnly:!0})],_.prototype,"events",void 0),e([a({readOnly:!0})],_.prototype,"isGlobal",null),e([a({readOnly:!0})],_.prototype,"isLocal",null),e([a({readOnly:!0})],_.prototype,"viewingMode",void 0),e([a({readOnly:!0})],_.prototype,"spatialReference",void 0),e([a()],_.prototype,"navigating",null),e([a()],_.prototype,"stationary",null),e([a()],_.prototype,"_cameraChanged",void 0),e([a()],_.prototype,"cameraController",null),_=e([i("esri.views.3d.state.ViewState")],_);const f=_,v=new g,w="ViewStateHandles";export{f as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Evented.js";import{when as o}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{afterDispatch as s}from"../../../core/accessorSupport/watch.js";import{f as n}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as l}from"../../../geometry/ellipsoidUtils.js";import p from"../../ViewAnimation.js";import{ViewingMode as c}from"../../ViewingMode.js";import{Constraints as m}from"./Constraints.js";import{AnimationController as h}from"./controllers/AnimationController.js";import{State as d}from"./controllers/CameraController.js";import{PropertiesPool as u}from"../support/PropertiesPool.js";import{Camera as C,PaddingSide as g}from"../webgl-engine/lib/Camera.js";import{RenderState as y}from"../../support/RenderState.js";let _=class extends t{constructor(){super(...arguments),this._propertiesPool=new u({camera:C},this),this._lastSeenCameraProjectionValues=new C,this.mode=y.ANIMATING,this.rasterPixelRatio=1,this.contentPixelRatio=1,this.events=new r,this.viewingMode=c.Global,this._cameraChanged=!1,this._updateQueue=new Array,this._processingUpdates=!1}init(e,t){this._set("viewingMode",e),this._set("spatialReference",t),this._set("constraints",new m({mode:this.viewingMode}))}exit(){this.cameraController?.destroy(),this.cameraController=null,this._propertiesPool.destroy(),this._propertiesPool=new u({camera:C},this)}destroy(){this.cameraController?.destroy(),this.cameraController=null,this._propertiesPool?.destroy(),this._propertiesPool=null}createInitialCamera(){if(this.viewingMode===c.Global){const e=l(this.spatialReference).radius;this.camera=new C({eye:n(4*e,0,0),center:n(e,0,0),up:n(0,0,1)})}else this.camera=new C({eye:n(0,0,100),center:n(0,0,0),up:n(0,1,0)})}get animation(){return this.cameraController instanceof h&&null!=this.cameraController.viewAnimation?this.cameraController.viewAnimation:null}get camera(){return this._get("camera")}set camera(e){e!==v&&v.copyFrom(e),v.computeUp(this.viewingMode),this.events.emit("before-camera-change",v);const t=this._get("camera");if(this._cameraProjectionChanged(this._lastSeenCameraProjectionValues,v)&&(this._lastSeenCameraProjectionValues.copyFrom(v),this.events.emit("camera-projection-changed",this._lastSeenCameraProjectionValues)),(!t||!t.equals(v))&&(this._set("camera",this._propertiesPool.get("camera").copyFrom(v)),this._cameraChanged=!t||!t.almostEquals(v),this._cameraChanged)){const e=s((()=>{this._cameraChanged=!1,e.remove()}))}}get pixelRatio(){return this.camera.pixelRatio}get contentCamera(){return this._contentCamera??this.camera}set contentCamera(e){this._contentCamera=null!=e?e.clone():null}get fixedContentCamera(){return null!=this._contentCamera}get isGlobal(){return this.viewingMode===c.Global}get isLocal(){return this.viewingMode===c.Local}get navigating(){return!(!this.cameraController||!this.cameraController.isInteractive)}get stationary(){return!this._cameraChanged&&!this.navigating}get cameraController(){return this._get("cameraController")}set cameraController(e){this.stopActiveCameraController()?(this.cameraController?.destroy(),e&&(this.removeHandles(w),this.addHandles(o((()=>e.state===d.Finished||e.state===d.Stopped),(()=>{this._set("cameraController",null),this.updateCamera((t=>e.onControllerEnd(t)))}),{sync:!0,once:!0}),w),e.onControllerStart(this.camera)),this._set("cameraController",e)):e&&(e.state=d.Rejected)}switchCameraController(e){return this.cameraController=e,e.state!==d.Rejected}stopActiveCameraController(){return!(this.cameraController&&!this.cameraController.stopController())}updateCamera(e){this._updateQueue.push(e),this._processUpdateQueue()}_processUpdateQueue(){if(0===this._updateQueue.length||this._processingUpdates)return;this._processingUpdates=!0;const e=this._updateQueue.shift();v.copyFrom(this._get("camera")),e(v),this.camera=v,this._processingUpdates=!1,this._processUpdateQueue()}_cameraProjectionChanged(e,t){return e.fov!==t.fov||(e.fullViewport[0]!==t.fullViewport[0]||e.fullViewport[1]!==t.fullViewport[1]||e.fullViewport[2]!==t.fullViewport[2]||e.fullViewport[3]!==t.fullViewport[3]||(e.padding[g.TOP]!==t.padding[g.TOP]||e.padding[g.RIGHT]!==t.padding[g.RIGHT]||e.padding[g.BOTTOM]!==t.padding[g.BOTTOM]||e.padding[g.LEFT]!==t.padding[g.LEFT]))}};e([a()],_.prototype,"mode",void 0),e([a({readOnly:!0,type:p})],_.prototype,"animation",null),e([a({type:C})],_.prototype,"camera",null),e([a({readOnly:!0})],_.prototype,"pixelRatio",null),e([a()],_.prototype,"rasterPixelRatio",void 0),e([a()],_.prototype,"contentPixelRatio",void 0),e([a({})],_.prototype,"_contentCamera",void 0),e([a({type:C})],_.prototype,"contentCamera",null),e([a({readOnly:!0})],_.prototype,"fixedContentCamera",null),e([a({readOnly:!0})],_.prototype,"constraints",void 0),e([a({readOnly:!0})],_.prototype,"events",void 0),e([a({readOnly:!0})],_.prototype,"isGlobal",null),e([a({readOnly:!0})],_.prototype,"isLocal",null),e([a({readOnly:!0})],_.prototype,"viewingMode",void 0),e([a({readOnly:!0})],_.prototype,"spatialReference",void 0),e([a()],_.prototype,"navigating",null),e([a()],_.prototype,"stationary",null),e([a()],_.prototype,"_cameraChanged",void 0),e([a()],_.prototype,"cameraController",null),_=e([i("esri.views.3d.state.ViewState")],_);const f=_,v=new C,w="ViewStateHandles";export{f 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Handles.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{eyeWithinExtent as o}from"../../camera/intersectionUtils.js";import{applySurfaceCollisionConstraint as a,Mode as i}from"../../camera/constraintUtils/surfaceCollision.js";import{CameraController as n,State as l}from"./CameraController.js";let c=class extends n{set desiredCamera(e){this._set("desiredCamera",e.clone())}constructor(e){super(e),this._handles=new r}get canStop(){return!0}get constraintEnabled(){return this.view.state.constraints.collision.enabled}onControllerStart(){this.state=l.Running,this._handles.add(this.view.basemapTerrain.on("elevation-change",(e=>this._handleElevationChangeEvent(e)))),this._applyCorrection()}onControllerEnd(){this._handles.removeAll()}stepController(){}_handleElevationChangeEvent(e){(null==e.spatialReference||o(this.view,this.desiredCamera,e.extent,e.spatialReference))&&this._applyCorrection()}_applyCorrection(){this.view.state.updateCamera((e=>{e.copyViewFrom(this.desiredCamera),a(this.view,e,i.EYE_AND_CENTER)||this.constraintEnabled||(this.state=l.Stopped)}))}};e([t({constructOnly:!0})],c.prototype,"desiredCamera",null),c=e([s("esri.views.3d.state.controllers.SurfaceCollisionCorrectionController")],c);export{c as SurfaceCollisionCorrectionController};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{eyeWithinExtent as s}from"../../camera/intersectionUtils.js";import{applySurfaceCollisionConstraint as o,Mode as a}from"../../camera/constraintUtils/surfaceCollision.js";import{CameraController as i,State as n}from"./CameraController.js";let l=class extends i{set desiredCamera(e){this._set("desiredCamera",e.clone())}constructor(e){super(e)}get canStop(){return!0}get constraintEnabled(){return this.view.state.constraints.collision.enabled}onControllerStart(){this.state=n.Running,this.addHandles(this.view.basemapTerrain.on("elevation-change",(e=>this._handleElevationChangeEvent(e)))),this._applyCorrection()}onControllerEnd(){this.removeAllHandles()}stepController(){}_handleElevationChangeEvent(e){(null==e.spatialReference||s(this.view,this.desiredCamera,e.extent,e.spatialReference))&&this._applyCorrection()}_applyCorrection(){this.view.state.updateCamera((e=>{e.copyViewFrom(this.desiredCamera),o(this.view,e,a.EYE_AND_CENTER)||this.constraintEnabled||(this.state=n.Stopped)}))}};e([t({constructOnly:!0})],l.prototype,"desiredCamera",null),l=e([r("esri.views.3d.state.controllers.SurfaceCollisionCorrectionController")],l);export{l as SurfaceCollisionCorrectionController};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- class e{constructor(){this.cornerTiles=[null,null,null,null],this.cornerTileSamplerVersions=[-1,-1,-1,-1]}}class l{constructor(){this.cornerNeighborData=[new e,new e,new e,new e],this.edgeResolutions=[-1,-1,-1,-1],this.edgePeerNeighbors=[null,null,null,null],this.edgePeerNeighborSamplerVersions=[-1,-1,-1,-1],this.cornerPeerNeighbors=[null,null,null,null]}}class s{constructor(){this.numVerticesPerSide=0,this.samplerData=null,this.clippingArea=null,this.wireframe=!1,this.shading=!1,this.samplerDataVersion=0,this.neighborData=new l}}export{e as CornerNeighborData,s as GeometryState,l as NeighborhoodData};
5
+ class e{constructor(){this.cornerTiles=[null,null,null,null],this.cornerTileSamplerVersions=[-1,-1,-1,-1]}}class l{constructor(){this.cornerNeighborData=[new e,new e,new e,new e],this.edgeResolutions=[-1,-1,-1,-1],this.edgePeerNeighbors=[null,null,null,null],this.edgePeerNeighborSamplerVersions=[-1,-1,-1,-1],this.cornerPeerNeighbors=[null,null,null,null]}}class r{constructor(){this.numVerticesPerSide=0,this.samplerData=null,this.clippingArea=null,this.wireframe=!1,this.samplerDataVersion=0,this.neighborData=new l}}export{e as CornerNeighborData,r as GeometryState,l as NeighborhoodData};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as t}from"../../../core/mathUtils.js";import{a as e}from"../../../chunks/vec2f64.js";import{a as s,n as i}from"../../../chunks/vec3.js";import{empty as r}from"../../../geometry/support/aaBoundingBox.js";import{BufferPool as n}from"../../../geometry/support/buffer/BufferPool.js";import{newLayout as o}from"../support/buffer/InterleavedLayout.js";import{internalAssert as u}from"./terrainUtils.js";import{VertexAttribute as a}from"../webgl-engine/lib/VertexAttribute.js";class l{constructor(){this.indices=null,this.vertexAttributes=null,this.boundingBox=r(),this.indexCount=0,this.numVerticesPerSide=0,this.uvRange=[0,0,1,1],this.outerEdges=[null,null,null,null],this.innerEdges=[null,null,null,null]}}class h{constructor(t,e,s,i,r){this.attributes=t,this.localOrigin=e,this.index0=s,this.stride=i,this.count=r}getVertexIndex(t){return this.getAttributeIndex(t)}getAttributeIndex(t){return u(0<=t&&t<this.count),this.index0+this.stride*t}_getVertexRaw(t,e){this.attributes.position.getVec(t,e)}_getNormalRaw(t,e){this.attributes.normalCompressed.getVec(t,e)}getVertexPos(t,e){this._getVertexRaw(this.getAttributeIndex(e),t),s(t,t,this.localOrigin)}getNormal(t,s){const i=e();this._getNormalRaw(this.getAttributeIndex(s),i),x(t,i)}_setNormal(t,e,s,i){d(this.attributes.normalCompressed,t,e,s,i)}_setUV(t,e,s){p(this.attributes.uv0,t,e,s)}setNormalFromValues(t,e,s,i){this._setNormal(this.getAttributeIndex(t),e,s,i)}setVertexFromValuesRawPositionUV(t,e,s,i,r,n){const o=this.getAttributeIndex(t);this.attributes.position.setValues(o,e,s,i),this._setUV(o,r,n)}setVertexFromValuesRawPositionUVNormal(t,e,s,i,r,n,o,u,a){const l=this.getAttributeIndex(t);this.attributes.position.setValues(l,e,s,i),this._setUV(l,r,n),this._setNormal(l,o,u,a)}}const c=o().vec3f(a.POSITION).vec2i16(a.UV0).vec2i16(a.NORMALCOMPRESSED,{glNormalized:!0}),m=new n((t=>c.createBuffer(t)),(t=>t.count));function b(){m.clear()}function g(t){return m.acquire(t)}function f(t){m.release(t.vertexAttributes),t.vertexAttributes=null,t.indices=null}function d(t,e,s,i,r){const n=1/(Math.abs(s)+Math.abs(i)+Math.abs(r)),o=s*n,u=i*n,a=r<=0?(o>=0?1:-1)*(1-Math.abs(u)):o,l=r<=0?(u>=0?1:-1)*(1-Math.abs(o)):u;t.setValues(e,A(a),A(l))}function x(t,e){const s=M(e[0]),r=M(e[1]),n=1-Math.abs(s)-Math.abs(r);t[2]=n,n<0?(t[0]=(s>=0?1:-1)*(1-Math.abs(r)),t[1]=(r>=0?1:-1)*(1-Math.abs(s))):(t[0]=s,t[1]=r),i(t,t)}const V=16384;function p(t,e,s,i){t.setValues(e,s*V,i*V)}function A(e){return t(Math.round(32767*e),-32767,32767)}function M(e){return t(e/32767,-1,1)}function v(t,e,s,i){t<i[0]?i[0]=t:t>i[3]&&(i[3]=t),e<i[1]?i[1]=e:e>i[4]&&(i[4]=e),s<i[2]?i[2]=s:s>i[5]&&(i[5]=s)}export{h as EdgeDescriptor,l as PatchGeometry,g as acquireTerrainAttributes,b as clearCaches,M as decodeInt16,x as decodeNormal,A as encodeInt16,d as encodeNormalInBuffer,p as encodeUVInBuffer,v as minMaxBoundingBox,f as releaseGeometry};
5
+ import{a as t}from"../../../chunks/vec3.js";import{empty as e}from"../../../geometry/support/aaBoundingBox.js";import{BufferPool as s}from"../../../geometry/support/buffer/BufferPool.js";import{newLayout as i}from"../support/buffer/InterleavedLayout.js";import{internalAssert as r}from"./terrainUtils.js";import{decompressNormal as n,compressNormal as o}from"../webgl-engine/lib/Normals.js";import{VertexAttribute as u}from"../webgl-engine/lib/VertexAttribute.js";class l{constructor(){this.indices=null,this.vertexAttributes=null,this.boundingBox=e(),this.indexCount=0,this.numVerticesPerSide=0,this.uvRange=[0,0,1,1],this.outerEdges=[null,null,null,null],this.innerEdges=[null,null,null,null]}}class a{constructor(t,e,s,i,r){this.attributes=t,this.localOrigin=e,this.index0=s,this.stride=i,this.count=r}getVertexIndex(t){return this.getAttributeIndex(t)}getAttributeIndex(t){return r(0<=t&&t<this.count),this.index0+this.stride*t}_getVertexRaw(t,e){this.attributes.position.getVec(t,e)}getVertexPos(e,s){this._getVertexRaw(this.getAttributeIndex(s),e),t(e,e,this.localOrigin)}getNormal(t,e){const{typedBuffer:s,typedBufferStride:i}=this.attributes.normalCompressed;n(t,s,this.getAttributeIndex(e),i)}_setNormal(t,e,s,i){const{typedBuffer:r,typedBufferStride:n}=this.attributes.normalCompressed;o(r,t,e,s,i,n)}_setUV(t,e,s){b(this.attributes.uv0,t,e,s)}setNormalFromValues(t,e,s,i){this._setNormal(this.getAttributeIndex(t),e,s,i)}setVertexFromValuesRawPositionUV(t,e,s,i,r,n){const o=this.getAttributeIndex(t);this.attributes.position.setValues(o,e,s,i),this._setUV(o,r,n)}setVertexFromValuesRawPositionUVNormal(t,e,s,i,r,n,o,u,l){const a=this.getAttributeIndex(t);this.attributes.position.setValues(a,e,s,i),this._setUV(a,r,n),this._setNormal(a,o,u,l)}}const h=i().vec3f(u.POSITION).vec2i16(u.UV0).vec2i16(u.NORMALCOMPRESSED,{glNormalized:!0}),c=new s((t=>h.createBuffer(t)),(t=>t.count));function m(){c.clear()}function d(t){return c.acquire(t)}function f(t){c.release(t.vertexAttributes),t.vertexAttributes=null,t.indices=null}const g=16384;function b(t,e,s,i){t.setValues(e,s*g,i*g)}function x(t,e,s,i){t<i[0]?i[0]=t:t>i[3]&&(i[3]=t),e<i[1]?i[1]=e:e>i[4]&&(i[4]=e),s<i[2]?i[2]=s:s>i[5]&&(i[5]=s)}export{a as EdgeDescriptor,l as PatchGeometry,d as acquireTerrainAttributes,m as clearCaches,b as encodeUVInBuffer,x as minMaxBoundingBox,f as releaseGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{isPowerOfTwo as t,clamp as e}from"../../../core/mathUtils.js";import{s as n}from"../../../chunks/vec4.js";import{empty as o}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as s}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as r}from"./ElevationData.js";import{PatchType as i,NeighborIndex as a}from"./interfaces.js";import{acquireTerrainAttributes as c,minMaxBoundingBox as l,encodeUVInBuffer as u,encodeNormalInBuffer as f,EdgeDescriptor as d}from"./PatchGeometry.js";import{PatchGeometryLUT as g}from"./PatchGeometryLUT.js";import{neighborTileIfLoadedOrSelf as m}from"./PatchRenderData.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as p,internalAssert as h,neighborEdgeIndices as M,almostEquals as x}from"./terrainUtils.js";import{isCornerNeighbor as y}from"./Tile.js";import{compareTilesByLij as S}from"./tileUtils.js";const v=65536;function b(t,e){const n=t.tile,{extent:s,extentInRadians:r,surface:a}=n,d=t.localOrigin,g=t.geometryState,m=a.isWebMercator,M=g.numVerticesPerSide,x=M-1,y=(M-2)**2,S=m&&(e===i.HAS_SOUTH_POLE||e===i.HAS_BOTH_POLES),v=m&&(e===i.HAS_NORTH_POLE||e===i.HAS_BOTH_POLES),b=6,R=((S?1:0)+(v?1:0))*b*(x+1),B=g.neighborData,T=B.edgeResolutions.reduce(((t,e)=>t+e+1),0),D=c(y+R+T),A=t.geometry;A.numVerticesPerSide=g.numVerticesPerSide,A.vertexAttributes=D;const V=A.boundingBox;o(V);const U=E(t);X.update(x,r,U),L(t),k(t,y),O(t);const C=[];if((()=>{let t=y+T;const e=d[0],o=d[1],r=d[2],i=n.ellipsoid.radius,a=s[1],c=s[3],g=(n,s)=>{const d=s*M;l(-e,-o,n*i-r,V),C.push({connectedRowOffset:d,connectedOuterEdgeOffset:1===n?0:2,rowOffset:t,latitudeResolution:b});const g=P(-1===n?a:c,i),m=n*Math.PI/2-g,p=.99*(1===n?1:-1),h=i+0,y=D.position,S=D.uv0,v=D.normalCompressed;for(let i=1;i<=b;++i){const n=g+m*(i/b),s=Math.cos(n),a=Math.sin(n);for(let i=0;i<=x;i++){const n=i/x,c=X.sinLonLUT[i],d=X.cosLonLUT[i]*s,g=c*s,m=a,M=d*h-e,b=g*h-o,L=m*h-r;l(M,b,L,V),y.setValues(t,M,b,L),u(S,t,n,p),f(v,t,d,g,m),++t}}};S&&g(-1,0),v&&g(1,x)})(),F(A,g.numVerticesPerSide,C,[0,M-1],[0,M-1],g.wireframe),t.intersectionData=null,p)for(let o=0;o<4;++o)h(A.outerEdges[o].count===B.edgeResolutions[o]+1)}function L(t){const e=t.tile;if(!e.intersectsClippingArea)return;const n=t.geometryState,o=n.numVerticesPerSide,s=o-2,i=o-1,a=t.geometry,c=a.vertexAttributes,d=c.position,g=c.uv0,m=c.normalCompressed,p=e.extent,h=p[0],M=p[2],x=p[1],y=p[3],S=e.ellipsoid.radius,v=n.samplerData,b=t.localOrigin,L=b[0],R=b[1],B=b[2],O=d.typedBuffer,T=d.typedBufferStride,D=1/i,P=a.boundingBox;let A=0;if(1<=s){const t=D,e=x*(1-t)+y*t,n=X.sinLatLUT[1],o=X.cosLatLUT[1];for(let i=1;i<=s;i++){const s=i*D,a=h*(1-s)+M*s,c=X.sinLonLUT[i],f=X.cosLonLUT[i],d=S+r(a,e,v),m=d*f*o-L,p=d*c*o-R,x=d*n-B;l(m,p,x,P);const y=(i-1)*T;O[y]=m,O[y+1]=p,O[y+2]=x,u(g,i-1,s,t)}}for(let V=1;V<=s;V++){const t=V*D,e=x*(1-t)+y*t,n=X.sinLatLUT[V],o=X.cosLatLUT[V],a=V+1,c=a*D,d=x*(1-c)+y*c,p=X.sinLatLUT[a],b=X.cosLatLUT[a],E=X.sinLonLUT[0],U=X.cosLonLUT[0],C=S+r(h,e,v);let I=U*o*C-L,j=E*o*C-R,w=n*C-B;const N=A*T;let H=O[N],_=O[N+1],q=O[N+2];for(let y=1;y<=s;y++){const t=y*D,a=h*(1-t)+M*t,E=X.sinLonLUT[y],U=X.cosLonLUT[y];let C=0,N=0,W=0;if(y<s){const t=(A+1)*T;C=O[t],N=O[t+1],W=O[t+2]}else{const t=X.sinLonLUT[i],s=X.cosLonLUT[i],a=S+r(M,e,v);C=s*o*a-L,N=t*o*a-R,W=n*a-B}const F=I,k=j,z=w;I=H,j=_,w=q,H=C,_=N,q=W;const G=C-F,J=N-k,K=W-z;let Q=0,Y=0,Z=0;if(V>1){const t=(A-s)*T;Q=O[t],Y=O[t+1],Z=O[t+2]}else{const t=X.sinLatLUT[0],e=X.cosLatLUT[0],n=S+r(a,x,v);Q=U*e*n-L,Y=E*e*n-R,Z=t*n-B}const $=S+r(a,d,v),tt=U*b*$-L,et=E*b*$-R,nt=p*$-B;if(V<s){const e=A+s,n=e*T;O[n]=tt,O[n+1]=et,O[n+2]=nt,l(tt,et,nt,P),u(g,e,t,c)}const ot=Q-tt,st=Y-et,rt=Z-nt;let it=U*o,at=E*o,ct=n;ct*ct<.999&&(it=K*st-J*rt,at=G*rt-K*ot,ct=J*ot-G*st);const lt=1/Math.sqrt(it*it+at*at+ct*ct);f(m,A,it*lt,at*lt,ct*lt),++A}}}function R(t){t.tile.intersectsClippingArea&&(O(t),K(t))}function B(t){t.tile.intersectsClippingArea&&(D(t),T(t,!0),K(t))}function O(t){t.tile.intersectsClippingArea&&(D(t),T(t))}function T(e,n=!1){const o=e.geometryState,s=e.geometry,i=o.neighborData,a=e.tile,c=a.level,f=a.extent,d=a.ellipsoid.radius,g=a.extentInRadians,y=g[0],v=g[2],b=g[1],L=g[3],R=o.samplerData,B=f[0],O=f[2],T=f[1],D=f[3],P=E(e),A=s.boundingBox,V=e.localOrigin,U=V[0],C=V[1],I=V[2],j=s.vertexAttributes,w=j.position,N=w.typedBuffer,H=w.typedBufferStride,_=j.uv0;for(let E=0;E<4;++E){const o=1===E||3===E,g=i.edgeResolutions[E];h(t(g));const V=g+1,j=m(a,i.edgePeerNeighbors[E]);if($(a,j,E)){z(e,E,j);continue}const w=null!=j;h(!w||j.level===a.level),h(!w||S(a,j)<=0);const q=j?.renderData,W=q?.geometryState;if(p){const t=a.surface;if(!j&&t&&!t.updatingRootTiles){const e=M[E],n=a.findNeighborTile(e,(t=>t.isLoaded||t.isLeaf||t.level===a.level));n?n.intersectsClippingArea&&(h(!n.isLoaded),h(!n.isLeaf),h(n.level===c)):h(null==t?.rootTiles||!a.shouldHaveNeighbor(e))}}const F=1===E?f[2]:f[0],k=j?.extent,G=k&&o?1===E?k[0]:k[2]:F,J=0===E?f[3]:f[1],K=1===E?1:0,Q=0===E?1:0,X=1===E?v:y,Y=0===E?L:b,Z=Math.sin(X),tt=Math.cos(X),et=Math.sin(Y),nt=Math.cos(Y),ot=W?.samplerData,st=w?(t,e,n)=>.5*(r(t,e,R)+r(n,e,ot)):(t,e,n)=>r(t,e,R),rt=s.outerEdges[E],it=n&&V>3?V-3:1,at=null!=R&&R.some((t=>null!=t)),ct=null!=ot&&ot.some((t=>null!=t)),lt=at||ct,ut=1/g,ft=rt.index0;h(!k||x(k[2]-k[0],f[2]-f[0]));(()=>{const t=1===E?-1:3===E?1:0,e=0===E?-1:2===E?1:0,n=(f[2]-f[0])*ut,s=t*n,i=e*n,a=o?t*((v-y)*ut):0,c=o?0:e*ut,g=Q,m=o?X+a:X,p=o?Math.sin(m):Z,h=o?Math.cos(m):tt,M=o?X-a:X,x=o?Math.sin(M):Z,S=o?Math.cos(M):tt,b=o?Y:P(g+c),L=o?et:Math.sin(b),j=o?nt:Math.cos(b),q=o?Y:P(g-c),W=o?et:Math.sin(q),k=o?nt:Math.cos(q);let z=0,$=0,at=0;{const t=0*ut,e=o?F:B*(1-t)+O*t,n=o?G:e,s=o?T*(1-t)+D*t:J,r=o?X:y*(1-t)+v*t,i=o?Z:Math.sin(r),a=o?tt:Math.cos(r),c=o?P(t):Y,l=o?Math.sin(c):et,u=o?Math.cos(c):nt,f=d+st(e,s,n);z=a*u*f,$=i*u*f,at=l*f}let ct=0,dt=0,gt=0;{const t=1*ut,e=o?F:B*(1-t)+O*t,n=o?G:e,s=o?T*(1-t)+D*t:J,r=o?X:y*(1-t)+v*t,i=o?Z:Math.sin(r),a=o?tt:Math.cos(r),c=o?P(t):Y,l=o?Math.sin(c):et,u=o?Math.cos(c):nt,f=d+st(e,s,n);ct=a*u*f,dt=i*u*f,gt=l*f}for(let f=1;f<V-1;f+=it){let t=0,e=0,n=0;{const s=(f+1)*ut,r=o?F:B*(1-s)+O*s,i=o?G:r,a=o?T*(1-s)+D*s:J,c=o?X:y*(1-s)+v*s,l=o?Z:Math.sin(c),u=o?tt:Math.cos(c),g=o?P(s):Y,m=o?Math.sin(g):et,p=o?Math.cos(g):nt,h=d+st(r,a,i);t=u*p*h,e=l*p*h,n=m*h}const a=t,c=e,g=n,m=ct,M=dt,b=gt;ct=a,dt=c,gt=g;{const t=ft+f,e=t*H,n=m-U,s=M-C,r=b-I;N[e]=n,N[e+1]=s,N[e+2]=r,l(n,s,r,A);const i=f*ut;u(_,t,o?K:i,o?i:Q)}const V=z,q=$,it=at;z=m,$=M,at=b;const mt=m,pt=M,ht=b,Mt=1/Math.sqrt(mt*mt+pt*pt+ht*ht),xt=ht*Mt;let yt=0,St=0,vt=0;if(lt&&xt*xt<.999){let t=0,e=0,n=0;{const o=0===E?-1:1;t=o*(a-V),e=o*(c-q),n=o*(g-it)}{const a=f*ut,c=o?F:B*(1-a)+O*a,l=o?G:c,u=o?T*(1-a)+D*a:J,g=o?X:y*(1-a)+v*a,m=o?Z:Math.sin(g),M=o?tt:Math.cos(g),b=o?P(a):Y,A=o?Math.sin(b):et,V=o?Math.cos(b):nt;let U=mt,C=pt,I=ht;if(w){const t=d+r(l-s,u-i,ot),e=o?V:k;U=(o?S:M)*e*t,C=(o?x:m)*e*t,I=(o?A:W)*t}{const a=d+r(c+s,u+i,R),l=o?V:j,f=(o?h:M)*l*a,g=(o?p:m)*l*a,x=(o?A:L)*a;w||(U=2*mt-f,C=2*pt-g,I=2*ht-x);const y=3===E?-1:1,S=y*(U-f),v=y*(C-g),b=y*(I-x);yt=n*v-e*b,St=t*b-n*S,vt=e*S-t*v;const B=1/Math.sqrt(yt*yt+St*St+vt*vt);yt*=B,St*=B,vt*=B}}}else yt=mt*Mt,St=pt*Mt,vt=ht*Mt;rt.setNormalFromValues(f,yt,St,vt)}})()}}function D(t){G(t)}function P(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function A(t,e,n,o){return P(t*(1-o)+e*o,n)}function V(t,e,n){return t*(1-n)+e*n}function E(t){const e=t.tile;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>A(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>V(n[1],n[3],t)}function U(t,e){const s=t.tile.extent,r=t.geometryState,i=s[0],a=s[1],l=s[2]-i,u=s[3]-a,f=r.clippingArea,d=null!=f?Math.max(0,(f[0]-i)/l):0,g=null!=f?Math.max(0,(f[1]-a)/u):0,m=null!=f?Math.min(1,(f[2]-i)/l):1,p=null!=f?Math.min(1,(f[3]-a)/u):1,h=r.numVerticesPerSide,M=(h-2)**2,x=r.neighborData.edgeResolutions.reduce(((t,e)=>t+e+1),0),y=c(M+x),S=t.geometry,v=S.boundingBox;o(v),S.numVerticesPerSide=r.numVerticesPerSide,S.vertexAttributes=y,n(S.uvRange,d,g,m,p),C(t),k(t,M),w(t),F(S,r.numVerticesPerSide,[],[0,h-1],[0,h-1],r.wireframe),t.intersectionData=null}function C(t){const n=t.tile;if(!n.intersectsClippingArea)return;const o=n.surface,s=t.geometryState,i=s.samplerData,a=t.localOrigin,c=o.isWebMercatorOnPlateeCarree,d=s.clippingArea,g=null!=d?d:Y,m=n.extent,p=m[0],h=m[1],M=m[2],x=m[3],y=Math.max(p,g[0]),S=Math.min(M,g[2]),v=Math.max(h,g[1]),b=Math.min(x,g[3]),L=n.ellipsoid.radius,R=n.horizontalScale,B=s.numVerticesPerSide,O=B-1,T=B-2,D=t.geometry,P=D.vertexAttributes,A=P.position,V=P.uv0,E=P.normalCompressed,U=D.uvRange,C=U[0],I=U[1],j=U[2],w=U[3],N=D.boundingBox,H=a[0],_=a[1],q=a[2],W=A.typedBuffer,F=A.typedBufferStride;let k=0;const z=e(h,v,b),G=c?(Math.PI/2-2*Math.atan(Math.exp(-z/L)))*L:z*R,J=1/O,K=e(h*(1-J)+x*J,v,b);let Q=G,X=c?(Math.PI/2-2*Math.atan(Math.exp(-K/L)))*L:K*R;for(let Y=1;Y<=T;Y++){const t=Y/O,n=e(h*(1-t)+x*t,v,b),o=e(t,I,w),s=X,a=(Y-1)/O,d=e(h*(1-a)+x*a,v,b),g=Q,m=(Y+1)/O,B=e(h*(1-m)+x*m,v,b),D=c?(Math.PI/2-2*Math.atan(Math.exp(-B/L)))*L:B*R,P=e(m,I,w);Q=X,X=D;const A=e(p,y,S);let U=A*R,z=r(A,n,i);const G=1/O,J=e(G,C,j),K=e(p*(1-J)+M*J,y,S);let Z=J,$=K,tt=K*R,et=r(K,n,i);if(1===Y){const t=tt-H,n=Q-_,s=et-q,r=0*F;W[r]=t,W[r+1]=n,W[r+2]=s,l(t,n,s,N);const i=e(G,C,j);u(V,k,i,o)}for(let c=1;c<=T;c++){const t=tt,a=et,m=(c+1)/O,h=e(m,C,j),x=e(p*(1-m)+M*m,y,S),v=$;$=x;{const t=k+1,e=t*F;if(1===Y||c===T){const a=x*R,f=r(x,n,i);if(1===Y&&c<T){const n=a-H,r=s-_,i=f-q;W[e]=n,W[e+1]=r,W[e+2]=i,l(n,r,i,N),u(V,t,h,o)}tt=a,et=f}else tt=W[e]+H,et=W[e+2]+q}const b=tt,L=et,A=U,I=z;U=t,z=a;const w=(k-T)*F,G=1===Y?r(v,d,i):W[w+2]+q,J=r(v,B,i);if(Y<T){const e=k+T,n=e*F,o=t-H,s=D-_,r=J-q;W[n]=o,W[n+1]=s,W[n+2]=r,l(o,s,r,N);const i=Z;Z=h,u(V,e,i,P)}{const t=b-A,e=g-D,n=e*(L-I),o=t*(G-J),s=-e*t,r=n*n+o*o+s*s;if(0===r)f(E,k,0,0,1);else{const t=1/Math.sqrt(r);f(E,k,n*t,o*t,s*t)}}++k}}}function I(t,e){t.tile.intersectsClippingArea&&(H(t),N(t,!0),K(t))}function j(t,e){t.tile.intersectsClippingArea&&(w(t),K(t))}function w(t,e){t.tile.intersectsClippingArea&&(H(t),N(t,!1))}function N(n,o){const s=n.geometryState,i=s.neighborData,a=n.tile,c=a.surface,u=a.extent,f=s.clippingArea,d=null!=f?f:Y,g=u[0],x=u[2],y=u[1],v=u[3],b=[v>d[3],x>d[2],y<d[1],g<d[0]],L=n.geometry,R=a.horizontalScale,B=W(c.isWebMercatorOnPlateeCarree,a.ellipsoid.radius,R),O=L.boundingBox,T=L.uvRange[0],D=L.uvRange[1],P=L.uvRange[2],A=L.uvRange[3],V=Math.max(g,d[0]),E=Math.min(x,d[2]),U=Math.max(y,d[1]),C=Math.min(v,d[3]),I=n.localOrigin,j=I[0],w=I[1],N=I[2],H=s.samplerData;for(let _=0;_<4;++_){const s=1===_||3===_,u=i.edgeResolutions[_];h(t(u));const f=u+1,d=b[_],I=m(a,i.edgePeerNeighbors[_]);if(!d&&$(a,I,_)){z(n,_,I);continue}const q=null!=I&&!d,W=I?.renderData,F=W?.geometryState;if(p&&(h(!q||I.level===a.level),h(!q||S(a,I)<=0),a&&!I&&!c.updatingRootTiles)){const t=M[_],e=a.findNeighborTile(t,(t=>t.isLoaded||t.isLeaf||t.level===a.level));c.updatingRootTiles||(e?e.intersectsClippingArea&&(h(!e.isLoaded),h(!e.isLeaf),h(e.level===a.level)):h(null==c?.rootTiles||!a.shouldHaveNeighbor(t)))}const k=e(1===_?x:g,V,E),G=e(0===_?v:y,U,C),J=F?.samplerData,K=L.outerEdges[_],Q=o&&f>3?f-3:1,X=e(1===_?1:0,T,P),Y=e(0===_?1:0,D,A),Z=q?(t,e)=>.5*(r(t,e,J)+r(t,e,H)):(t,e)=>r(t,e,H),tt=(x-g)/u,et=s?1===_?tt:-tt:0,nt=s?0:0===_?tt:-tt,ot=-et,st=-nt;let rt=0,it=0,at=0;{const t=0/u,n=s?k:e(g*(1-t)+x*t,V,E),o=s?e(y*(1-t)+v*t,U,C):G,r=Z(n,o);rt=n*R,it=B(o),at=r}let ct=0,lt=0,ut=0;{const t=1/u,n=s?k:e(g*(1-t)+x*t,V,E),o=s?e(y*(1-t)+v*t,U,C):G,r=Z(n,o);ct=n*R,lt=B(o),ut=r}for(let t=1;t<f-1;t+=Q){const n=t/u,o=ct,i=lt,a=ut;{const r=s?X:e(n,T,P),c=s?e(n,D,A):Y,u=o-j,f=i-w,d=a-N;l(o,f,d,O),K.setVertexFromValuesRawPositionUV(t,u,f,d,r,c)}{const n=(t+1)/u,o=s?k:e(g*(1-n)+x*n,V,E),r=s?e(y*(1-n)+v*n,U,C):G,i=Z(o,r);ct=o*R,lt=B(r),ut=i}const c=ct,f=ut,d=rt,m=it,p=at;rt=o,it=i,at=a;let h=0,M=0,S=0;if(s){const t=lt-i,s=f-a,c=m-i,l=p-a,u=e(y*(1-n)+v*n,U,C),d=k+ot,g=d*R-o,x=r(d,u,H)-a,b=3===_?-1:1;if(h=b*(-c+t)*x,M=b*g*(-l+s),S=-b*g*(-c+t),q){const e=k+et,n=e*R-o;h=(-c+t)*(x-(r(e,u,J)-a)),M=(g-n)*(-l+s),S=-(g-n)*(-c+t)}}else{const t=c-o,s=f-a,l=d-o,u=p-a,m=e(g*(1-n)+x*n,V,E),y=G+st,v=r(m,y,H)-a,b=B(y)-i,L=2===_?-1:1;if(h=L*b*(-u+s),M=L*(-l+t)*v,S=-L*b*(-l+t),q){const e=m,n=G+nt,o=B(n)-i;h=(-b+o)*(-u+s),M=(-l+t)*(-v+(r(e,n,J)-a)),S=-(-b+o)*(-l+t)}}const b=1/Math.sqrt(h*h+M*M+S*S);K.setNormalFromValues(t,h*b,M*b,S*b)}}}function H(t,e){G(t)}function _(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function q(t,e){return t*e}function W(t,e,n){return t?t=>_(t,e):t=>q(t,n)}function F(t,e,n,o,s,r){const i=e-1,a=t.vertexAttributes.count,c=2*(Math.min(e-2,o[1])-Math.max(1,o[0]))*(Math.min(e-2,s[1])-Math.max(1,s[0])),l=M.map(((t,n)=>0===n&&s[1]<e-2||1===n&&o[1]<e-2||2===n&&s[0]>1||3===n&&o[0]>1)),u=t.outerEdges.reduce(((t,e,n)=>t+(l[n]?0:i-2+e.count-1)),0),f=n.reduce(((t,e)=>t+i*(2*(e.latitudeResolution-1)+1)),0),d=r?2:1,g=3*(c+u+f)*d,m=a>=v?new Uint32Array(g):new Uint16Array(g);let x=0;const y=e-2,S=i-2;h(S>=0);const b=(t,e,n,o,s,r)=>{const i=t*s,a=r[i],c=r[i+1],l=r[i+2],u=e*s,f=r[u],d=r[u+1],g=r[u+2],m=n*s,p=r[m],h=r[m+1],M=r[m+2],x=o*s,y=r[x],S=r[x+1],v=r[x+2];return(f-y)*(f-y)+(d-S)*(d-S)+(g-v)*(g-v)>(a-p)*(a-p)+(c-h)*(c-h)+(l-M)*(l-M)};if(r){const r=(t,e,n)=>{m[x++]=t,m[x++]=e,m[x++]=e,m[x++]=n,m[x++]=n,m[x++]=t,p&&(h(t<a),h(e<a),h(n<a),h(x<=g))};(()=>{for(let n=Math.max(s[0],1)-1;n<Math.min(s[1],e-2)-1;++n){const s=n*y;for(let i=Math.max(o[0],1)-1;i<Math.min(o[1],e-2)-1;++i){const e=n*y+i,o=e+1,a=o+y,c=a-1,l=s+i,u=l+1,f=u+y,d=f-1,g=t.vertexAttributes.position.typedBuffer,m=t.vertexAttributes.position.typedBufferStride;b(l,u,f,d,m,g)?(r(e,o,a),r(a,c,e)):(r(e,o,c),r(c,a,o))}}})(),h(x===3*c*d);(()=>{for(let e=0;e<4;++e){const n=x;if(l[e])continue;const o=t.outerEdges[e],s=t.innerEdges[e];let a=0,c=0;const u=o.count,f=s.count;h(f===i-1);let g=0;const m=1===e||2===e?(t,e,n)=>r(t,e,n):(t,e,n)=>r(t,n,e);for(;a<u-1||c<f-1;){const t=s.getVertexIndex(c),e=o.getVertexIndex(a),n=a<u-1,r=c<f-1;if(n&&(!r||(n?0+i*(a+.5)/(u-1):0)<=(r?1+S*(c+.5)/(f-1):0))){++a,p&&h(a<u);m(t,e,o.getVertexIndex(a)),g++}else{++c,p&&h(c<f);m(t,e,s.getVertexIndex(c)),g++}}p&&(h(a===u-1),h(c===f-1),h(g===u+f-2),h(g===i-2+o.count-1),h(x===n+3*g*d))}})(),h(x===3*(c+u)*d);const f=n=>{const o=t.outerEdges[n.connectedOuterEdgeOffset];let s=o.getVertexIndex(0),a=o.stride;for(let t=0;t<n.latitudeResolution;++t){const o=0===t?n.rowOffset:s+e;for(let e=0;e<i;e++)r(s,s+1,o+e),t<n.latitudeResolution-1&&r(s+1,o+e+1,o+e),s+=a;s=o,a=1}};(()=>n.forEach(f))()}else{(()=>{const n=Math.max(s[0],1)-1,r=Math.min(s[1],e-2)-1,i=Math.max(o[0],1)-1,a=Math.min(o[1],e-2)-1;for(let e=n;e<r;++e){const n=e*y;for(let e=i;e<a;++e){const o=n+e,s=o+1,r=s+y,i=r-1,a=t.vertexAttributes.position.typedBuffer,c=t.vertexAttributes.position.typedBufferStride;b(o,s,r,i,c,a)?(m[x]=o,m[x+1]=s,m[x+2]=r,m[x+3]=r,m[x+4]=i,m[x+5]=o):(m[x]=o,m[x+1]=s,m[x+2]=i,m[x+3]=i,m[x+4]=s,m[x+5]=r),x+=6}}})(),h(x===3*c*d);(()=>{for(let e=0;e<4;++e){if(l[e])continue;const n=t.outerEdges[e],o=t.innerEdges[e];let s=0,r=0;const a=n.count,c=o.count;h(c===i-1);const u=1===e||2===e,f=u?1:2,d=u?2:1,g=n.index0,p=n.stride,M=o.index0,y=o.stride;for(;s<a-1||r<c-1;){const t=M+r*y,e=g+s*p,n=s<a-1,o=r<c-1,l=n&&(!o||(n?0+i*(s+.5)/(a-1):0)<=(o?1+S*(r+.5)/(c-1):0));l?++s:++r;const u=l?e+p:t+y;m[x]=t,m[x+f]=e,m[x+d]=u,x+=3}}})(),h(x===3*(c+u)*d);const r=n=>{const o=t.outerEdges[n.connectedOuterEdgeOffset];let s=o.getVertexIndex(0),r=o.stride;for(let t=0;t<n.latitudeResolution;++t){const o=0===t?n.rowOffset:s+e;for(let e=0;e<i;e++){const i=o+e;m[x]=s,m[x+1]=s+1,m[x+2]=i,t<n.latitudeResolution-1?(m[x+3]=s+1,m[x+4]=i+1,m[x+5]=i,x+=6):x+=3,s+=r}s=o,r=1}};(()=>n.forEach(r))()}h(x===g),t.indices=m,t.indexCount=g}function k(t,e){const n=t.localOrigin,o=t.geometry,s=t.geometryState.neighborData.edgeResolutions,r=o.numVerticesPerSide-2,i=o.vertexAttributes;let a=e;for(let c=0;c<4;++c){{const t=0===c||2===c,e=(0===c?r-1:0)*r+(1===c?r-1:0),s=(t?0:1)*r+(t?1:0);o.innerEdges[c]=new d(i,n,e,s,r)}{const t=a,e=s[c]+1;o.outerEdges[c]=new d(i,n,t,1,e),a+=e}}}function z(n,o,s){const r=(o+2)%4,i=n.geometryState,a=n.tile,c=i.neighborData,f=a.level-s.level,d=1===o||3===o,g=c.edgeResolutions[o];h(t(g));const m=g+1,p=n.geometry,M=p.boundingBox,x=p.outerEdges[o],y=p.uvRange[0],S=p.uvRange[1],v=p.uvRange[2],b=p.uvRange[3],L=e(1===o?1:0,y,v),R=e(0===o?1:0,S,b),B=s.renderData,O=B.geometryState,T=B.geometry.outerEdges[r],D=a.getNeighborEdgeStartVertexIndex(o,s)*g,P=g*2**f;h(O.neighborData.edgeResolutions[r]===P),h(T.count-1===P);const A=B.localOrigin[0]-n.localOrigin[0],V=B.localOrigin[1]-n.localOrigin[1],E=B.localOrigin[2]-n.localOrigin[2],U=x.attributes,C=x.index0,I=x.stride,j=U.position.typedBuffer,w=U.position.typedBufferStride,N=U.normalCompressed.typedBuffer,H=U.normalCompressed.typedBufferStride,_=U.uv0,q=T.attributes,W=T.index0,F=T.stride,k=q.position.typedBuffer,z=q.position.typedBufferStride,G=q.normalCompressed.typedBuffer,J=q.normalCompressed.typedBufferStride;for(let t=1;t<m-1;++t){const n=C+I*t,o=W+F*(D+t),s=n*w,r=o*z,i=k[r]+A,a=k[r+1]+V,c=k[r+2]+E;j[s]=i,j[s+1]=a,j[s+2]=c,l(i,a,c,M);const f=n*H,m=o*J;N[f]=G[m],N[f+1]=G[m+1];const p=t/g,h=d?L:e(p,y,v),x=d?e(p,S,b):R;u(_,n,h,x)}}function G(t){const n=t.geometryState,o=n.neighborData,s=t.localOrigin,i=o.cornerNeighborData,a=t.geometry,c=a.outerEdges,f=a.boundingBox,d=t.tile,g="local"===t.tile.surface.view?.viewingMode,m=d.ellipsoid.radius,p=d.extentInRadians,M=d.horizontalScale;let x=0,y=0,v=0;const b=(t,e,n)=>{const o=p[0===e?1:3],s=p[0===t?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=m+n;x=c*r*l,y=a*r*l,v=i*l},L=g?(()=>{const n=t.geometryState.clippingArea,o=d.extent,s=null!=n&&(o[3]>n[3]||o[2]>n[2]||o[1]<n[1]||o[0]<n[0]),r=W(d.surface.isWebMercatorOnPlateeCarree,d.ellipsoid.radius,M);return(t,o,i)=>{const a=0===t?j[0]:j[2],c=0===o?j[1]:j[3],l=s?e(a,n[0],n[2]):a,u=s?e(c,n[1],n[3]):c,f=i;x=l*M,y=r(u),v=f}})():b;let R=0,B=0,O=0,T=0,D=0,P=0,A=0,V=0,U=0;const C=g&&t.tile.surface.isWebMercatorOnPlateeCarree,I=(t,e,n,o,s)=>{let r=0,i=0,a=0;if(g){const t=e*M,s=C?(Math.PI/2-2*Math.atan(Math.exp(-n/m)))*m:n*M;r=t-x,i=s-y,a=o-v}else{const s=E(t),c=t.tile,l=c.extent,u=c.extentInRadians,f=(e-l[0])/(l[2]-l[0]),d=(n-l[1])/(l[3]-l[1]),g=u[0]*(1-f)+u[2]*f,p=s(d),h=Math.cos(p),M=Math.sin(p),S=Math.sin(g),b=Math.cos(g),L=m+o;r=b*h*L-x,i=S*h*L-y,a=M*L-v}switch(s){case 0:A+=r,V+=i,U+=a;break;case 1:T-=r,D-=i,P-=a;break;case 2:A-=r,V-=i,U-=a;break;case 3:T+=r,D+=i,P+=a}},j=d.extent,w=n.clippingArea,N=null!=w?w:Y,H=j[0],_=j[2],q=j[1],F=j[3],k=[F>N[3],_>N[2],q<N[1],H<N[0]],z=Math.max(H,N[0]),G=Math.min(_,N[2]),K=Math.max(q,N[1]),X=Math.min(F,N[3]),$=a.uvRange[0],tt=a.uvRange[1],et=a.uvRange[2],nt=a.uvRange[3],ot=t=>{const e=i[t].cornerTiles;R=0,B=0,O=1;let n=1/0;for(let r=0;r<4;++r)n=Math.min(n,e[r]?.level??1/0);for(let r=0;r<4;++r){const t=e[r];Z[r]=t?.level===n?t:null}let o=1,s=0;for(let r=0;r<4;++r){const t=Z[r];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),s=t.extent[2]-t.extent[0])}const a=s,c=o;h(c>1);const l=a/c;for(let i=0;i<4;++i){const t=Z[(i+3)%4],e=Z[i%4];if(!t&&!e)continue;const n=0===i?1:1===i?2:2===i?3:0,o=0===i?2:1===i?3:2===i?0:1;if(t&&e){const s=Q[i][0]*l,a=Q[i][1]*l,c=t.extent,u=c[0===n||1===n?2:0]+s,f=c[0===n||3===n?3:1]+a,d=e.extent,g=d[0===o||1===o?2:0]+s,m=d[0===o||3===o?3:1]+a,p=t.renderData,h=e.renderData,M=r(u,f,p.geometryState.samplerData),x=r(g,m,h.geometryState.samplerData);I(p,u,f,.5*(M+x),i)}else{const s=t??e,a=t?n:o,c=s.extent,u=Q[i],f=c[0===a||1===a?2:0]+u[0]*l,d=c[0===a||3===a?3:1]+u[1]*l,g=s.renderData,m=r(f,d,g.geometryState.samplerData);I(g,f,d,m,i)}}if(!g){const t=Math.sqrt(x*x+y*y+v*v);R=x/t,B=y/t,O=v/t}const u=Math.sqrt(T*T+D*D+P*P);T/=u,D/=u,P/=u;const f=Math.sqrt(A*A+V*V+U*U);if(A/=f,V/=f,U/=f,g||O*O<.999){R=P*V-D*U,B=T*U-P*A,O=D*A-T*V;const t=1/Math.sqrt(R*R+B*B+O*O);R*=t,B*=t,O*=t}};for(let E=0;E<4;++E){const o=E,a=(E+1)%4,g=0===E||1===E?1:0,m=0===E||3===E?1:0,p=e(g,$,et),M=e(m,tt,nt),b=c[o],T=0===E||3===E?b.count-1:0,D=c[a],P=0===E||1===E?D.count-1:0,A=i[E].cornerTiles;let V=-1;for(let t=0;t<4;++t){const e=A[t];e&&(-1===V||S(A[V],e)>0)&&(V=t)}const U=V,C=A[U];if(R=0,B=0,O=1,C!==d){const e=d.level-C.level,n=2**e,o=[C.lij[0]+e,C.lij[1]*n,C.lij[2]*n],s=[o[1]+n===d.lij[1],0===E&&(1===U||0===U&&C!==A[3])||1===E&&(0===U||1===U&&C!==A[2]),o[1]===d.lij[1]+1,2===E&&(3===U||2===U&&C!==A[1])||3===E&&(2===U||3===U&&C!==A[0])],r=s.reduce(((t,e)=>t+(e?1:0)),0);h(1===r||2===r);let i=-1,a=-1;const c=C.renderData;if(1===r){const e=s.findIndex((t=>t));h(0<=e&&e<=3),i=(e+2)%4;const n=t.geometryState.neighborData.edgeResolutions[e];a=d.getNeighborEdgeStartVertexIndex(e,C)*n+n*(0===e&&0===E||1===e&&0===E||2===e&&1===E||3===e&&3===E?1:0)}else{h(s[1]||s[3]),i=s[1]?3:1;const t=c.geometryState.neighborData.edgeResolutions[i];a=0===E||3===E?0:t}const g=c.geometry.outerEdges[i];{const e=b.index0+T*b.stride,n=D.index0+P*D.stride,o=g.index0+a*g.stride;{const s=g.attributes.position,r=s.typedBuffer,i=o*s.typedBufferStride,a=t.localOrigin,c=g.localOrigin,u=r[i]+c[0]-a[0],d=r[i+1]+c[1]-a[1],m=r[i+2]+c[2]-a[2];l(u,d,m,f);{const t=b.attributes.position,n=t.typedBuffer,o=e*t.typedBufferStride;n[o]=u,n[o+1]=d,n[o+2]=m}{const t=D.attributes.position,e=t.typedBuffer,o=n*t.typedBufferStride;e[o]=u,e[o+1]=d,e[o+2]=m}}u(b.attributes.uv0,e,p,M),u(D.attributes.uv0,n,p,M);{const t=g.attributes.normalCompressed.typedBuffer,s=o*g.attributes.normalCompressed.typedBufferStride;{const n=b.attributes.normalCompressed,o=n.typedBuffer,r=e*n.typedBufferStride;o[r]=t[s],o[r+1]=t[s+1]}{const e=D.attributes.normalCompressed,o=e.typedBuffer,r=n*e.typedBufferStride;o[r]=t[s],o[r+1]=t[s+1]}}}}else{const t=k[o],i=k[a];let c;if(t||i){const t=e(H*(1-g)+_*g,z,G),o=e(q*(1-m)+F*m,K,X),s=n.samplerData;c=r(t,o,s)}else c=J(A);L(g,m,c),ot(E);const u=x-s[0],d=y-s[1],h=v-s[2];l(u,d,h,f),b.setVertexFromValuesRawPositionUVNormal(T,u,d,h,p,M,R,B,O),D.setVertexFromValuesRawPositionUVNormal(P,u,d,h,p,M,R,B,O)}}for(let e=0;e<4;++e)Z[e]=null}function J(t){const e=t.reduce(((t,e)=>Math.min(t,e?.level??1/0)),1/0);p&&(h(!t[0]||!t[2]||y(t[0],t[2],a.SOUTH_WEST)),h(!t[1]||!t[3]||y(t[1],t[3],a.NORTH_WEST)));let n=0,o=0;for(let i=0;i<4;++i){const s=t[i];if(s&&s.level===e){const t=0===i||1===i,e=0===i||3===i,a=s.extent,c=a[t?0:2],l=a[e?1:3],u=s.renderData?.geometryState?.samplerData;o+=r(c,l,u),n++}}const s=n?o/n:0;return h(null!=s),s}function K(t){const e=t.vao,n=t.geometry.vertexAttributes.position.typedBuffer;e.vertexBuffers.geometry.setSubData(n,0,0,n.length)}const Q=[[0,1],[1,0],[0,-1],[-1,0]],X=new g,Y=s(-1/0,-1/0,1/0,1/0),Z=[null,null,null,null];function $(t,e,n){if(!e)return!1;const o=S(t,e);return o>0||0===o&&n>=2}export{U as createPlanarGlobePatch,b as createSphericalGlobePatch,B as updateCornerSpherical,I as updateCornersPlanar,j as updateEdgesAndCornersPlanar,R as updateEdgesAndCornersSpherical};
5
+ import{isPowerOfTwo as t,clamp as e}from"../../../core/mathUtils.js";import{s as n}from"../../../chunks/vec4.js";import{empty as o}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as s}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as r}from"./ElevationData.js";import{PatchType as i,NeighborIndex as a}from"./interfaces.js";import{acquireTerrainAttributes as l,minMaxBoundingBox as c,encodeUVInBuffer as u,EdgeDescriptor as f}from"./PatchGeometry.js";import{PatchGeometryLUT as d}from"./PatchGeometryLUT.js";import{neighborTileIfLoadedOrSelf as g}from"./PatchRenderData.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as m,internalAssert as p,neighborEdgeIndices as h,almostEquals as M}from"./terrainUtils.js";import{isCornerNeighbor as x}from"./Tile.js";import{compareTilesByLij as y}from"./tileUtils.js";import{compressNormal as S}from"../webgl-engine/lib/Normals.js";const b=65536;function v(t,e){const n=t.tile,{extent:s,extentInRadians:r,surface:a}=n,f=t.localOrigin,d=t.geometryState,g=a.isWebMercator,h=d.numVerticesPerSide,M=h-1,x=(h-2)**2,y=g&&(e===i.HAS_SOUTH_POLE||e===i.HAS_BOTH_POLES),b=g&&(e===i.HAS_NORTH_POLE||e===i.HAS_BOTH_POLES),v=6,L=((y?1:0)+(b?1:0))*v*(M+1),R=d.neighborData,T=R.edgeResolutions.reduce(((t,e)=>t+e+1),0),D=l(x+L+T),A=t.geometry;A.numVerticesPerSide=d.numVerticesPerSide,A.vertexAttributes=D;const V=A.boundingBox;o(V);const U=E(t);X.update(M,r,U),B(t),k(t,x),O(t);const C=[];if((()=>{let t=x+T;const e=f[0],o=f[1],r=f[2],i=n.ellipsoid.radius,a=s[1],l=s[3],d=(n,s)=>{const f=s*h;c(-e,-o,n*i-r,V),C.push({connectedRowOffset:f,connectedOuterEdgeOffset:1===n?0:2,rowOffset:t,latitudeResolution:v});const d=P(-1===n?a:l,i),g=n*Math.PI/2-d,m=.99*(1===n?1:-1),p=i+0,x=D.position,y=D.uv0,{typedBuffer:b,typedBufferStride:B}=D.normalCompressed;for(let i=1;i<=v;++i){const n=d+g*(i/v),s=Math.cos(n),a=Math.sin(n);for(let i=0;i<=M;i++){const n=i/M,l=X.sinLonLUT[i],f=X.cosLonLUT[i]*s,d=l*s,g=a,h=f*p-e,v=d*p-o,L=g*p-r;c(h,v,L,V),x.setValues(t,h,v,L),u(y,t,n,m),S(b,t,f,d,g,B),++t}}};y&&d(-1,0),b&&d(1,M)})(),F(A,d.numVerticesPerSide,C,[0,h-1],[0,h-1],d.wireframe),t.intersectionData=null,m)for(let o=0;o<4;++o)p(A.outerEdges[o].count===R.edgeResolutions[o]+1)}function B(t){const e=t.tile;if(!e.intersectsClippingArea)return;const n=t.geometryState,o=n.numVerticesPerSide,s=o-2,i=o-1,a=t.geometry,l=a.vertexAttributes,f=l.position,d=l.uv0,{typedBuffer:g,typedBufferStride:m}=l.normalCompressed,p=e.extent,h=p[0],M=p[2],x=p[1],y=p[3],b=e.ellipsoid.radius,v=n.samplerData,B=t.localOrigin,L=B[0],R=B[1],O=B[2],T=f.typedBuffer,D=f.typedBufferStride,P=1/i,A=a.boundingBox;let V=0;if(1<=s){const t=P,e=x*(1-t)+y*t,n=X.sinLatLUT[1],o=X.cosLatLUT[1];for(let i=1;i<=s;i++){const s=i*P,a=h*(1-s)+M*s,l=X.sinLonLUT[i],f=X.cosLonLUT[i],g=b+r(a,e,v),m=g*f*o-L,p=g*l*o-R,x=g*n-O;c(m,p,x,A);const y=(i-1)*D;T[y]=m,T[y+1]=p,T[y+2]=x,u(d,i-1,s,t)}}for(let E=1;E<=s;E++){const t=E*P,e=x*(1-t)+y*t,n=X.sinLatLUT[E],o=X.cosLatLUT[E],a=E+1,l=a*P,f=x*(1-l)+y*l,p=X.sinLatLUT[a],B=X.cosLatLUT[a],U=X.sinLonLUT[0],C=X.cosLonLUT[0],I=b+r(h,e,v);let j=C*o*I-L,w=U*o*I-R,N=n*I-O;const H=V*D;let _=T[H],q=T[H+1],W=T[H+2];for(let y=1;y<=s;y++){const t=y*P,a=h*(1-t)+M*t,U=X.sinLonLUT[y],C=X.cosLonLUT[y];let I=0,H=0,F=0;if(y<s){const t=(V+1)*D;I=T[t],H=T[t+1],F=T[t+2]}else{const t=X.sinLonLUT[i],s=X.cosLonLUT[i],a=b+r(M,e,v);I=s*o*a-L,H=t*o*a-R,F=n*a-O}const k=j,z=w,G=N;j=_,w=q,N=W,_=I,q=H,W=F;const J=I-k,K=H-z,Q=F-G;let Y=0,Z=0,$=0;if(E>1){const t=(V-s)*D;Y=T[t],Z=T[t+1],$=T[t+2]}else{const t=X.sinLatLUT[0],e=X.cosLatLUT[0],n=b+r(a,x,v);Y=C*e*n-L,Z=U*e*n-R,$=t*n-O}const tt=b+r(a,f,v),et=C*B*tt-L,nt=U*B*tt-R,ot=p*tt-O;if(E<s){const e=V+s,n=e*D;T[n]=et,T[n+1]=nt,T[n+2]=ot,c(et,nt,ot,A),u(d,e,t,l)}const st=Y-et,rt=Z-nt,it=$-ot;let at=C*o,lt=U*o,ct=n;ct*ct<.999&&(at=Q*rt-K*it,lt=J*it-Q*st,ct=K*st-J*rt);const ut=1/Math.sqrt(at*at+lt*lt+ct*ct);S(g,V,at*ut,lt*ut,ct*ut,m),++V}}}function L(t){t.tile.intersectsClippingArea&&(O(t),K(t))}function R(t){t.tile.intersectsClippingArea&&(D(t),T(t,!0),K(t))}function O(t){t.tile.intersectsClippingArea&&(D(t),T(t))}function T(e,n=!1){const o=e.geometryState,s=e.geometry,i=o.neighborData,a=e.tile,l=a.level,f=a.extent,d=a.ellipsoid.radius,x=a.extentInRadians,S=x[0],b=x[2],v=x[1],B=x[3],L=o.samplerData,R=f[0],O=f[2],T=f[1],D=f[3],P=E(e),A=s.boundingBox,V=e.localOrigin,U=V[0],C=V[1],I=V[2],j=s.vertexAttributes,w=j.position,N=w.typedBuffer,H=w.typedBufferStride,_=j.uv0;for(let E=0;E<4;++E){const o=1===E||3===E,x=i.edgeResolutions[E];p(t(x));const V=x+1,j=g(a,i.edgePeerNeighbors[E]);if($(a,j,E)){z(e,E,j);continue}const w=null!=j;p(!w||j.level===a.level),p(!w||y(a,j)<=0);const q=j?.renderData,W=q?.geometryState;if(m){const t=a.surface;if(!j&&t&&!t.updatingRootTiles){const e=h[E],n=a.findNeighborTile(e,(t=>t.isLoaded||t.isLeaf||t.level===a.level));n?n.intersectsClippingArea&&(p(!n.isLoaded),p(!n.isLeaf),p(n.level===l)):p(null==t?.rootTiles||!a.shouldHaveNeighbor(e))}}const F=1===E?f[2]:f[0],k=j?.extent,G=k&&o?1===E?k[0]:k[2]:F,J=0===E?f[3]:f[1],K=1===E?1:0,Q=0===E?1:0,X=1===E?b:S,Y=0===E?B:v,Z=Math.sin(X),tt=Math.cos(X),et=Math.sin(Y),nt=Math.cos(Y),ot=W?.samplerData,st=w?(t,e,n)=>.5*(r(t,e,L)+r(n,e,ot)):(t,e,n)=>r(t,e,L),rt=s.outerEdges[E],it=n&&V>3?V-3:1,at=null!=L&&L.some((t=>null!=t)),lt=null!=ot&&ot.some((t=>null!=t)),ct=at||lt,ut=1/x,ft=rt.index0;p(!k||M(k[2]-k[0],f[2]-f[0]));(()=>{const t=1===E?-1:3===E?1:0,e=0===E?-1:2===E?1:0,n=(f[2]-f[0])*ut,s=t*n,i=e*n,a=o?t*((b-S)*ut):0,l=o?0:e*ut,g=Q,m=o?X+a:X,p=o?Math.sin(m):Z,h=o?Math.cos(m):tt,M=o?X-a:X,x=o?Math.sin(M):Z,y=o?Math.cos(M):tt,v=o?Y:P(g+l),B=o?et:Math.sin(v),j=o?nt:Math.cos(v),q=o?Y:P(g-l),W=o?et:Math.sin(q),k=o?nt:Math.cos(q);let z=0,$=0,at=0;{const t=0*ut,e=o?F:R*(1-t)+O*t,n=o?G:e,s=o?T*(1-t)+D*t:J,r=o?X:S*(1-t)+b*t,i=o?Z:Math.sin(r),a=o?tt:Math.cos(r),l=o?P(t):Y,c=o?Math.sin(l):et,u=o?Math.cos(l):nt,f=d+st(e,s,n);z=a*u*f,$=i*u*f,at=c*f}let lt=0,dt=0,gt=0;{const t=1*ut,e=o?F:R*(1-t)+O*t,n=o?G:e,s=o?T*(1-t)+D*t:J,r=o?X:S*(1-t)+b*t,i=o?Z:Math.sin(r),a=o?tt:Math.cos(r),l=o?P(t):Y,c=o?Math.sin(l):et,u=o?Math.cos(l):nt,f=d+st(e,s,n);lt=a*u*f,dt=i*u*f,gt=c*f}for(let f=1;f<V-1;f+=it){let t=0,e=0,n=0;{const s=(f+1)*ut,r=o?F:R*(1-s)+O*s,i=o?G:r,a=o?T*(1-s)+D*s:J,l=o?X:S*(1-s)+b*s,c=o?Z:Math.sin(l),u=o?tt:Math.cos(l),g=o?P(s):Y,m=o?Math.sin(g):et,p=o?Math.cos(g):nt,h=d+st(r,a,i);t=u*p*h,e=c*p*h,n=m*h}const a=t,l=e,g=n,m=lt,M=dt,v=gt;lt=a,dt=l,gt=g;{const t=ft+f,e=t*H,n=m-U,s=M-C,r=v-I;N[e]=n,N[e+1]=s,N[e+2]=r,c(n,s,r,A);const i=f*ut;u(_,t,o?K:i,o?i:Q)}const V=z,q=$,it=at;z=m,$=M,at=v;const mt=m,pt=M,ht=v,Mt=1/Math.sqrt(mt*mt+pt*pt+ht*ht),xt=ht*Mt;let yt=0,St=0,bt=0;if(ct&&xt*xt<.999){let t=0,e=0,n=0;{const o=0===E?-1:1;t=o*(a-V),e=o*(l-q),n=o*(g-it)}{const a=f*ut,l=o?F:R*(1-a)+O*a,c=o?G:l,u=o?T*(1-a)+D*a:J,g=o?X:S*(1-a)+b*a,m=o?Z:Math.sin(g),M=o?tt:Math.cos(g),v=o?P(a):Y,A=o?Math.sin(v):et,V=o?Math.cos(v):nt;let U=mt,C=pt,I=ht;if(w){const t=d+r(c-s,u-i,ot),e=o?V:k;U=(o?y:M)*e*t,C=(o?x:m)*e*t,I=(o?A:W)*t}{const a=d+r(l+s,u+i,L),c=o?V:j,f=(o?h:M)*c*a,g=(o?p:m)*c*a,x=(o?A:B)*a;w||(U=2*mt-f,C=2*pt-g,I=2*ht-x);const y=3===E?-1:1,S=y*(U-f),b=y*(C-g),v=y*(I-x);yt=n*b-e*v,St=t*v-n*S,bt=e*S-t*b;const R=1/Math.sqrt(yt*yt+St*St+bt*bt);yt*=R,St*=R,bt*=R}}}else yt=mt*Mt,St=pt*Mt,bt=ht*Mt;rt.setNormalFromValues(f,yt,St,bt)}})()}}function D(t){G(t)}function P(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function A(t,e,n,o){return P(t*(1-o)+e*o,n)}function V(t,e,n){return t*(1-n)+e*n}function E(t){const e=t.tile;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>A(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>V(n[1],n[3],t)}function U(t,e){const s=t.tile.extent,r=t.geometryState,i=s[0],a=s[1],c=s[2]-i,u=s[3]-a,f=r.clippingArea,d=null!=f?Math.max(0,(f[0]-i)/c):0,g=null!=f?Math.max(0,(f[1]-a)/u):0,m=null!=f?Math.min(1,(f[2]-i)/c):1,p=null!=f?Math.min(1,(f[3]-a)/u):1,h=r.numVerticesPerSide,M=(h-2)**2,x=r.neighborData.edgeResolutions.reduce(((t,e)=>t+e+1),0),y=l(M+x),S=t.geometry,b=S.boundingBox;o(b),S.numVerticesPerSide=r.numVerticesPerSide,S.vertexAttributes=y,n(S.uvRange,d,g,m,p),C(t),k(t,M),w(t),F(S,r.numVerticesPerSide,[],[0,h-1],[0,h-1],r.wireframe),t.intersectionData=null}function C(t){const n=t.tile;if(!n.intersectsClippingArea)return;const o=n.surface,s=t.geometryState,i=s.samplerData,a=t.localOrigin,l=o.isWebMercatorOnPlateeCarree,f=s.clippingArea,d=null!=f?f:Y,g=n.extent,m=g[0],p=g[1],h=g[2],M=g[3],x=Math.max(m,d[0]),y=Math.min(h,d[2]),b=Math.max(p,d[1]),v=Math.min(M,d[3]),B=n.ellipsoid.radius,L=n.horizontalScale,R=s.numVerticesPerSide,O=R-1,T=R-2,D=t.geometry,P=D.vertexAttributes,A=P.position,V=P.uv0,{typedBuffer:E,typedBufferStride:U}=P.normalCompressed,C=D.uvRange,I=C[0],j=C[1],w=C[2],N=C[3],H=D.boundingBox,_=a[0],q=a[1],W=a[2],F=A.typedBuffer,k=A.typedBufferStride;let z=0;const G=e(p,b,v),J=l?(Math.PI/2-2*Math.atan(Math.exp(-G/B)))*B:G*L,K=1/O,Q=e(p*(1-K)+M*K,b,v);let X=J,Z=l?(Math.PI/2-2*Math.atan(Math.exp(-Q/B)))*B:Q*L;for(let Y=1;Y<=T;Y++){const t=Y/O,n=e(p*(1-t)+M*t,b,v),o=e(t,j,N),s=Z,a=(Y-1)/O,f=e(p*(1-a)+M*a,b,v),d=X,g=(Y+1)/O,R=e(p*(1-g)+M*g,b,v),D=l?(Math.PI/2-2*Math.atan(Math.exp(-R/B)))*B:R*L,P=e(g,j,N);X=Z,Z=D;const A=e(m,x,y);let C=A*L,G=r(A,n,i);const J=1/O,K=e(J,I,w),Q=e(m*(1-K)+h*K,x,y);let $=K,tt=Q,et=Q*L,nt=r(Q,n,i);if(1===Y){const t=et-_,n=X-q,s=nt-W,r=0*k;F[r]=t,F[r+1]=n,F[r+2]=s,c(t,n,s,H);const i=e(J,I,w);u(V,z,i,o)}for(let l=1;l<=T;l++){const t=et,a=nt,g=(l+1)/O,p=e(g,I,w),M=e(m*(1-g)+h*g,x,y),b=tt;tt=M;{const t=z+1,e=t*k;if(1===Y||l===T){const a=M*L,f=r(M,n,i);if(1===Y&&l<T){const n=a-_,r=s-q,i=f-W;F[e]=n,F[e+1]=r,F[e+2]=i,c(n,r,i,H),u(V,t,p,o)}et=a,nt=f}else et=F[e]+_,nt=F[e+2]+W}const v=et,B=nt,A=C,j=G;C=t,G=a;const N=(z-T)*k,J=1===Y?r(b,f,i):F[N+2]+W,K=r(b,R,i);if(Y<T){const e=z+T,n=e*k,o=t-_,s=D-q,r=K-W;F[n]=o,F[n+1]=s,F[n+2]=r,c(o,s,r,H);const i=$;$=p,u(V,e,i,P)}{const t=v-A,e=d-D,n=e*(B-j),o=t*(J-K),s=-e*t,r=n*n+o*o+s*s;if(0===r)S(E,z,0,0,1,U);else{const t=1/Math.sqrt(r);S(E,z,n*t,o*t,s*t,U)}}++z}}}function I(t,e){t.tile.intersectsClippingArea&&(H(t),N(t,!0),K(t))}function j(t,e){t.tile.intersectsClippingArea&&(w(t),K(t))}function w(t,e){t.tile.intersectsClippingArea&&(H(t),N(t,!1))}function N(n,o){const s=n.geometryState,i=s.neighborData,a=n.tile,l=a.surface,u=a.extent,f=s.clippingArea,d=null!=f?f:Y,M=u[0],x=u[2],S=u[1],b=u[3],v=[b>d[3],x>d[2],S<d[1],M<d[0]],B=n.geometry,L=a.horizontalScale,R=W(l.isWebMercatorOnPlateeCarree,a.ellipsoid.radius,L),O=B.boundingBox,T=B.uvRange[0],D=B.uvRange[1],P=B.uvRange[2],A=B.uvRange[3],V=Math.max(M,d[0]),E=Math.min(x,d[2]),U=Math.max(S,d[1]),C=Math.min(b,d[3]),I=n.localOrigin,j=I[0],w=I[1],N=I[2],H=s.samplerData;for(let _=0;_<4;++_){const s=1===_||3===_,u=i.edgeResolutions[_];p(t(u));const f=u+1,d=v[_],I=g(a,i.edgePeerNeighbors[_]);if(!d&&$(a,I,_)){z(n,_,I);continue}const q=null!=I&&!d,W=I?.renderData,F=W?.geometryState;if(m&&(p(!q||I.level===a.level),p(!q||y(a,I)<=0),a&&!I&&!l.updatingRootTiles)){const t=h[_],e=a.findNeighborTile(t,(t=>t.isLoaded||t.isLeaf||t.level===a.level));l.updatingRootTiles||(e?e.intersectsClippingArea&&(p(!e.isLoaded),p(!e.isLeaf),p(e.level===a.level)):p(null==l?.rootTiles||!a.shouldHaveNeighbor(t)))}const k=e(1===_?x:M,V,E),G=e(0===_?b:S,U,C),J=F?.samplerData,K=B.outerEdges[_],Q=o&&f>3?f-3:1,X=e(1===_?1:0,T,P),Y=e(0===_?1:0,D,A),Z=q?(t,e)=>.5*(r(t,e,J)+r(t,e,H)):(t,e)=>r(t,e,H),tt=(x-M)/u,et=s?1===_?tt:-tt:0,nt=s?0:0===_?tt:-tt,ot=-et,st=-nt;let rt=0,it=0,at=0;{const t=0/u,n=s?k:e(M*(1-t)+x*t,V,E),o=s?e(S*(1-t)+b*t,U,C):G,r=Z(n,o);rt=n*L,it=R(o),at=r}let lt=0,ct=0,ut=0;{const t=1/u,n=s?k:e(M*(1-t)+x*t,V,E),o=s?e(S*(1-t)+b*t,U,C):G,r=Z(n,o);lt=n*L,ct=R(o),ut=r}for(let t=1;t<f-1;t+=Q){const n=t/u,o=lt,i=ct,a=ut;{const r=s?X:e(n,T,P),l=s?e(n,D,A):Y,u=o-j,f=i-w,d=a-N;c(o,f,d,O),K.setVertexFromValuesRawPositionUV(t,u,f,d,r,l)}{const n=(t+1)/u,o=s?k:e(M*(1-n)+x*n,V,E),r=s?e(S*(1-n)+b*n,U,C):G,i=Z(o,r);lt=o*L,ct=R(r),ut=i}const l=lt,f=ut,d=rt,g=it,m=at;rt=o,it=i,at=a;let p=0,h=0,y=0;if(s){const t=ct-i,s=f-a,l=g-i,c=m-a,u=e(S*(1-n)+b*n,U,C),d=k+ot,M=d*L-o,x=r(d,u,H)-a,v=3===_?-1:1;if(p=v*(-l+t)*x,h=v*M*(-c+s),y=-v*M*(-l+t),q){const e=k+et,n=e*L-o;p=(-l+t)*(x-(r(e,u,J)-a)),h=(M-n)*(-c+s),y=-(M-n)*(-l+t)}}else{const t=l-o,s=f-a,c=d-o,u=m-a,g=e(M*(1-n)+x*n,V,E),S=G+st,b=r(g,S,H)-a,v=R(S)-i,B=2===_?-1:1;if(p=B*v*(-u+s),h=B*(-c+t)*b,y=-B*v*(-c+t),q){const e=g,n=G+nt,o=R(n)-i;p=(-v+o)*(-u+s),h=(-c+t)*(-b+(r(e,n,J)-a)),y=-(-v+o)*(-c+t)}}const v=1/Math.sqrt(p*p+h*h+y*y);K.setNormalFromValues(t,p*v,h*v,y*v)}}}function H(t,e){G(t)}function _(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function q(t,e){return t*e}function W(t,e,n){return t?t=>_(t,e):t=>q(t,n)}function F(t,e,n,o,s,r){const i=e-1,a=t.vertexAttributes.count,l=2*(Math.min(e-2,o[1])-Math.max(1,o[0]))*(Math.min(e-2,s[1])-Math.max(1,s[0])),c=h.map(((t,n)=>0===n&&s[1]<e-2||1===n&&o[1]<e-2||2===n&&s[0]>1||3===n&&o[0]>1)),u=t.outerEdges.reduce(((t,e,n)=>t+(c[n]?0:i-2+e.count-1)),0),f=n.reduce(((t,e)=>t+i*(2*(e.latitudeResolution-1)+1)),0),d=r?2:1,g=3*(l+u+f)*d,M=a>=b?new Uint32Array(g):new Uint16Array(g);let x=0;const y=e-2,S=i-2;p(S>=0);const v=(t,e,n,o,s,r)=>{const i=t*s,a=r[i],l=r[i+1],c=r[i+2],u=e*s,f=r[u],d=r[u+1],g=r[u+2],m=n*s,p=r[m],h=r[m+1],M=r[m+2],x=o*s,y=r[x],S=r[x+1],b=r[x+2];return(f-y)*(f-y)+(d-S)*(d-S)+(g-b)*(g-b)>(a-p)*(a-p)+(l-h)*(l-h)+(c-M)*(c-M)};if(r){const r=(t,e,n)=>{M[x++]=t,M[x++]=e,M[x++]=e,M[x++]=n,M[x++]=n,M[x++]=t,m&&(p(t<a),p(e<a),p(n<a),p(x<=g))};(()=>{for(let n=Math.max(s[0],1)-1;n<Math.min(s[1],e-2)-1;++n){const s=n*y;for(let i=Math.max(o[0],1)-1;i<Math.min(o[1],e-2)-1;++i){const e=n*y+i,o=e+1,a=o+y,l=a-1,c=s+i,u=c+1,f=u+y,d=f-1,g=t.vertexAttributes.position.typedBuffer,m=t.vertexAttributes.position.typedBufferStride;v(c,u,f,d,m,g)?(r(e,o,a),r(a,l,e)):(r(e,o,l),r(l,a,o))}}})(),p(x===3*l*d);(()=>{for(let e=0;e<4;++e){const n=x;if(c[e])continue;const o=t.outerEdges[e],s=t.innerEdges[e];let a=0,l=0;const u=o.count,f=s.count;p(f===i-1);let g=0;const h=1===e||2===e?(t,e,n)=>r(t,e,n):(t,e,n)=>r(t,n,e);for(;a<u-1||l<f-1;){const t=s.getVertexIndex(l),e=o.getVertexIndex(a),n=a<u-1,r=l<f-1;if(n&&(!r||(n?0+i*(a+.5)/(u-1):0)<=(r?1+S*(l+.5)/(f-1):0))){++a,m&&p(a<u);h(t,e,o.getVertexIndex(a)),g++}else{++l,m&&p(l<f);h(t,e,s.getVertexIndex(l)),g++}}m&&(p(a===u-1),p(l===f-1),p(g===u+f-2),p(g===i-2+o.count-1),p(x===n+3*g*d))}})(),p(x===3*(l+u)*d);const f=n=>{const o=t.outerEdges[n.connectedOuterEdgeOffset];let s=o.getVertexIndex(0),a=o.stride;for(let t=0;t<n.latitudeResolution;++t){const o=0===t?n.rowOffset:s+e;for(let e=0;e<i;e++)r(s,s+1,o+e),t<n.latitudeResolution-1&&r(s+1,o+e+1,o+e),s+=a;s=o,a=1}};(()=>n.forEach(f))()}else{(()=>{const n=Math.max(s[0],1)-1,r=Math.min(s[1],e-2)-1,i=Math.max(o[0],1)-1,a=Math.min(o[1],e-2)-1;for(let e=n;e<r;++e){const n=e*y;for(let e=i;e<a;++e){const o=n+e,s=o+1,r=s+y,i=r-1,a=t.vertexAttributes.position.typedBuffer,l=t.vertexAttributes.position.typedBufferStride;v(o,s,r,i,l,a)?(M[x]=o,M[x+1]=s,M[x+2]=r,M[x+3]=r,M[x+4]=i,M[x+5]=o):(M[x]=o,M[x+1]=s,M[x+2]=i,M[x+3]=i,M[x+4]=s,M[x+5]=r),x+=6}}})(),p(x===3*l*d);(()=>{for(let e=0;e<4;++e){if(c[e])continue;const n=t.outerEdges[e],o=t.innerEdges[e];let s=0,r=0;const a=n.count,l=o.count;p(l===i-1);const u=1===e||2===e,f=u?1:2,d=u?2:1,g=n.index0,m=n.stride,h=o.index0,y=o.stride;for(;s<a-1||r<l-1;){const t=h+r*y,e=g+s*m,n=s<a-1,o=r<l-1,c=n&&(!o||(n?0+i*(s+.5)/(a-1):0)<=(o?1+S*(r+.5)/(l-1):0));c?++s:++r;const u=c?e+m:t+y;M[x]=t,M[x+f]=e,M[x+d]=u,x+=3}}})(),p(x===3*(l+u)*d);const r=n=>{const o=t.outerEdges[n.connectedOuterEdgeOffset];let s=o.getVertexIndex(0),r=o.stride;for(let t=0;t<n.latitudeResolution;++t){const o=0===t?n.rowOffset:s+e;for(let e=0;e<i;e++){const i=o+e;M[x]=s,M[x+1]=s+1,M[x+2]=i,t<n.latitudeResolution-1?(M[x+3]=s+1,M[x+4]=i+1,M[x+5]=i,x+=6):x+=3,s+=r}s=o,r=1}};(()=>n.forEach(r))()}p(x===g),t.indices=M,t.indexCount=g}function k(t,e){const n=t.localOrigin,o=t.geometry,s=t.geometryState.neighborData.edgeResolutions,r=o.numVerticesPerSide-2,i=o.vertexAttributes;let a=e;for(let l=0;l<4;++l){{const t=0===l||2===l,e=(0===l?r-1:0)*r+(1===l?r-1:0),s=(t?0:1)*r+(t?1:0);o.innerEdges[l]=new f(i,n,e,s,r)}{const t=a,e=s[l]+1;o.outerEdges[l]=new f(i,n,t,1,e),a+=e}}}function z(n,o,s){const r=(o+2)%4,i=n.geometryState,a=n.tile,l=i.neighborData,f=a.level-s.level,d=1===o||3===o,g=l.edgeResolutions[o];p(t(g));const m=g+1,h=n.geometry,M=h.boundingBox,x=h.outerEdges[o],y=h.uvRange[0],S=h.uvRange[1],b=h.uvRange[2],v=h.uvRange[3],B=e(1===o?1:0,y,b),L=e(0===o?1:0,S,v),R=s.renderData,O=R.geometryState,T=R.geometry.outerEdges[r],D=a.getNeighborEdgeStartVertexIndex(o,s)*g,P=g*2**f;p(O.neighborData.edgeResolutions[r]===P),p(T.count-1===P);const A=R.localOrigin[0]-n.localOrigin[0],V=R.localOrigin[1]-n.localOrigin[1],E=R.localOrigin[2]-n.localOrigin[2],U=x.attributes,C=x.index0,I=x.stride,j=U.position.typedBuffer,w=U.position.typedBufferStride,N=U.normalCompressed.typedBuffer,H=U.normalCompressed.typedBufferStride,_=U.uv0,q=T.attributes,W=T.index0,F=T.stride,k=q.position.typedBuffer,z=q.position.typedBufferStride,G=q.normalCompressed.typedBuffer,J=q.normalCompressed.typedBufferStride;for(let t=1;t<m-1;++t){const n=C+I*t,o=W+F*(D+t),s=n*w,r=o*z,i=k[r]+A,a=k[r+1]+V,l=k[r+2]+E;j[s]=i,j[s+1]=a,j[s+2]=l,c(i,a,l,M);const f=n*H,m=o*J;N[f]=G[m],N[f+1]=G[m+1];const p=t/g,h=d?B:e(p,y,b),x=d?e(p,S,v):L;u(_,n,h,x)}}function G(t){const n=t.geometryState,o=n.neighborData,s=t.localOrigin,i=o.cornerNeighborData,a=t.geometry,l=a.outerEdges,f=a.boundingBox,d=t.tile,g="local"===t.tile.surface.view?.viewingMode,m=d.ellipsoid.radius,h=d.extentInRadians,M=d.horizontalScale;let x=0,S=0,b=0;const v=(t,e,n)=>{const o=h[0===e?1:3],s=h[0===t?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),l=Math.cos(s),c=m+n;x=l*r*c,S=a*r*c,b=i*c},B=g?(()=>{const n=t.geometryState.clippingArea,o=d.extent,s=null!=n&&(o[3]>n[3]||o[2]>n[2]||o[1]<n[1]||o[0]<n[0]),r=W(d.surface.isWebMercatorOnPlateeCarree,d.ellipsoid.radius,M);return(t,o,i)=>{const a=0===t?j[0]:j[2],l=0===o?j[1]:j[3],c=s?e(a,n[0],n[2]):a,u=s?e(l,n[1],n[3]):l,f=i;x=c*M,S=r(u),b=f}})():v;let L=0,R=0,O=0,T=0,D=0,P=0,A=0,V=0,U=0;const C=g&&t.tile.surface.isWebMercatorOnPlateeCarree,I=(t,e,n,o,s)=>{let r=0,i=0,a=0;if(g){const t=e*M,s=C?(Math.PI/2-2*Math.atan(Math.exp(-n/m)))*m:n*M;r=t-x,i=s-S,a=o-b}else{const s=E(t),l=t.tile,c=l.extent,u=l.extentInRadians,f=(e-c[0])/(c[2]-c[0]),d=(n-c[1])/(c[3]-c[1]),g=u[0]*(1-f)+u[2]*f,p=s(d),h=Math.cos(p),M=Math.sin(p),y=Math.sin(g),v=Math.cos(g),B=m+o;r=v*h*B-x,i=y*h*B-S,a=M*B-b}switch(s){case 0:A+=r,V+=i,U+=a;break;case 1:T-=r,D-=i,P-=a;break;case 2:A-=r,V-=i,U-=a;break;case 3:T+=r,D+=i,P+=a}},j=d.extent,w=n.clippingArea,N=null!=w?w:Y,H=j[0],_=j[2],q=j[1],F=j[3],k=[F>N[3],_>N[2],q<N[1],H<N[0]],z=Math.max(H,N[0]),G=Math.min(_,N[2]),K=Math.max(q,N[1]),X=Math.min(F,N[3]),$=a.uvRange[0],tt=a.uvRange[1],et=a.uvRange[2],nt=a.uvRange[3],ot=t=>{const e=i[t].cornerTiles;L=0,R=0,O=1;let n=1/0;for(let r=0;r<4;++r)n=Math.min(n,e[r]?.level??1/0);for(let r=0;r<4;++r){const t=e[r];Z[r]=t?.level===n?t:null}let o=1,s=0;for(let r=0;r<4;++r){const t=Z[r];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),s=t.extent[2]-t.extent[0])}const a=s,l=o;p(l>1);const c=a/l;for(let i=0;i<4;++i){const t=Z[(i+3)%4],e=Z[i%4];if(!t&&!e)continue;const n=0===i?1:1===i?2:2===i?3:0,o=0===i?2:1===i?3:2===i?0:1;if(t&&e){const s=Q[i][0]*c,a=Q[i][1]*c,l=t.extent,u=l[0===n||1===n?2:0]+s,f=l[0===n||3===n?3:1]+a,d=e.extent,g=d[0===o||1===o?2:0]+s,m=d[0===o||3===o?3:1]+a,p=t.renderData,h=e.renderData,M=r(u,f,p.geometryState.samplerData),x=r(g,m,h.geometryState.samplerData);I(p,u,f,.5*(M+x),i)}else{const s=t??e,a=t?n:o,l=s.extent,u=Q[i],f=l[0===a||1===a?2:0]+u[0]*c,d=l[0===a||3===a?3:1]+u[1]*c,g=s.renderData,m=r(f,d,g.geometryState.samplerData);I(g,f,d,m,i)}}if(!g){const t=Math.sqrt(x*x+S*S+b*b);L=x/t,R=S/t,O=b/t}const u=Math.sqrt(T*T+D*D+P*P);T/=u,D/=u,P/=u;const f=Math.sqrt(A*A+V*V+U*U);if(A/=f,V/=f,U/=f,g||O*O<.999){L=P*V-D*U,R=T*U-P*A,O=D*A-T*V;const t=1/Math.sqrt(L*L+R*R+O*O);L*=t,R*=t,O*=t}};for(let E=0;E<4;++E){const o=E,a=(E+1)%4,g=0===E||1===E?1:0,m=0===E||3===E?1:0,h=e(g,$,et),M=e(m,tt,nt),v=l[o],T=0===E||3===E?v.count-1:0,D=l[a],P=0===E||1===E?D.count-1:0,A=i[E].cornerTiles;let V=-1;for(let t=0;t<4;++t){const e=A[t];e&&(-1===V||y(A[V],e)>0)&&(V=t)}const U=V,C=A[U];if(L=0,R=0,O=1,C!==d){const e=d.level-C.level,n=2**e,o=[C.lij[0]+e,C.lij[1]*n,C.lij[2]*n],s=[o[1]+n===d.lij[1],0===E&&(1===U||0===U&&C!==A[3])||1===E&&(0===U||1===U&&C!==A[2]),o[1]===d.lij[1]+1,2===E&&(3===U||2===U&&C!==A[1])||3===E&&(2===U||3===U&&C!==A[0])],r=s.reduce(((t,e)=>t+(e?1:0)),0);p(1===r||2===r);let i=-1,a=-1;const l=C.renderData;if(1===r){const e=s.findIndex((t=>t));p(0<=e&&e<=3),i=(e+2)%4;const n=t.geometryState.neighborData.edgeResolutions[e];a=d.getNeighborEdgeStartVertexIndex(e,C)*n+n*(0===e&&0===E||1===e&&0===E||2===e&&1===E||3===e&&3===E?1:0)}else{p(s[1]||s[3]),i=s[1]?3:1;const t=l.geometryState.neighborData.edgeResolutions[i];a=0===E||3===E?0:t}const g=l.geometry.outerEdges[i];{const e=v.index0+T*v.stride,n=D.index0+P*D.stride,o=g.index0+a*g.stride;{const s=g.attributes.position,r=s.typedBuffer,i=o*s.typedBufferStride,a=t.localOrigin,l=g.localOrigin,u=r[i]+l[0]-a[0],d=r[i+1]+l[1]-a[1],m=r[i+2]+l[2]-a[2];c(u,d,m,f);{const t=v.attributes.position,n=t.typedBuffer,o=e*t.typedBufferStride;n[o]=u,n[o+1]=d,n[o+2]=m}{const t=D.attributes.position,e=t.typedBuffer,o=n*t.typedBufferStride;e[o]=u,e[o+1]=d,e[o+2]=m}}u(v.attributes.uv0,e,h,M),u(D.attributes.uv0,n,h,M);{const t=g.attributes.normalCompressed.typedBuffer,s=o*g.attributes.normalCompressed.typedBufferStride;{const n=v.attributes.normalCompressed,o=n.typedBuffer,r=e*n.typedBufferStride;o[r]=t[s],o[r+1]=t[s+1]}{const e=D.attributes.normalCompressed,o=e.typedBuffer,r=n*e.typedBufferStride;o[r]=t[s],o[r+1]=t[s+1]}}}}else{const t=k[o],i=k[a];let l;if(t||i){const t=e(H*(1-g)+_*g,z,G),o=e(q*(1-m)+F*m,K,X),s=n.samplerData;l=r(t,o,s)}else l=J(A);B(g,m,l),ot(E);const u=x-s[0],d=S-s[1],p=b-s[2];c(u,d,p,f),v.setVertexFromValuesRawPositionUVNormal(T,u,d,p,h,M,L,R,O),D.setVertexFromValuesRawPositionUVNormal(P,u,d,p,h,M,L,R,O)}}for(let e=0;e<4;++e)Z[e]=null}function J(t){const e=t.reduce(((t,e)=>Math.min(t,e?.level??1/0)),1/0);m&&(p(!t[0]||!t[2]||x(t[0],t[2],a.SOUTH_WEST)),p(!t[1]||!t[3]||x(t[1],t[3],a.NORTH_WEST)));let n=0,o=0;for(let i=0;i<4;++i){const s=t[i];if(s&&s.level===e){const t=0===i||1===i,e=0===i||3===i,a=s.extent,l=a[t?0:2],c=a[e?1:3],u=s.renderData?.geometryState?.samplerData;o+=r(l,c,u),n++}}const s=n?o/n:0;return p(null!=s),s}function K(t){const e=t.vao,n=t.geometry.vertexAttributes.position.typedBuffer;e.vertexBuffers.geometry.setSubData(n,0,0,n.length)}const Q=[[0,1],[1,0],[0,-1],[-1,0]],X=new d,Y=s(-1/0,-1/0,1/0,1/0),Z=[null,null,null,null];function $(t,e,n){if(!e)return!1;const o=y(t,e);return o>0||0===o&&n>=2}export{U as createPlanarGlobePatch,v as createSphericalGlobePatch,R as updateCornerSpherical,I as updateCornersPlanar,j as updateEdgesAndCornersPlanar,L as updateEdgesAndCornersSpherical};